Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, alibaba), 1,426 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: more skills [Re: gri] #387171
11/15/11 11:36
11/15/11 11:36
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
gri, you should never care about freeing the memory if it lives throughout the applications lifecycle! The OS has a much better way to get rid of the memory at once, once your application exits! However, if you have memory that doesn't live with your application, you really should free it!


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: more skills [Re: WretchedSid] #387183
11/15/11 13:57
11/15/11 13:57
Joined: Nov 2011
Posts: 21
MO:US and sometimes Ambato Ecu...
L
LewyT Offline OP
Newbie
LewyT  Offline OP
Newbie
L

Joined: Nov 2011
Posts: 21
MO:US and sometimes Ambato Ecu...
I agree with JustSid,
If you use the same object(s) throughout the game you won't need to free them.
If you are creating a lot of pointers that need to be allocated and then all or many of those objects are discarded during the game then you probably should make a habit of freeing them when they are no longer used.
Obviously larger objects such as entities take more memory and thus more important to free when disposed of.
In my example the object is a struct attached to my character. Even when the character dies and has to restart, I will still be using the same "info" pointer so I won't free it during the game. Even if I were "switching" characters, I could probably still use the same struct and just load in the new character's data from a file.
However, if I make this a multiplayer game and then if players join and leave the game before it is over, their info should probably be freed when they exit.
In the help file, it says about level_load:
Quote:
All current entities in the old level are removed, thus all entity pointers referring to them can't be used anymore.
so I'm not sure how that will effect my situation.

Re: more skills [Re: LewyT] #387186
11/15/11 14:28
11/15/11 14:28
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
I think the on_ent_remove event is a pretty convenient way to free allocated memory that is saved in entity skills:

#define path skill90

ent.path = sys_malloc...

void on_ent_remove_event(ENTITY* ent)
{
if(ent.path) sys_free...
}

On the downside, you should not use the specific skill for anything else.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: more skills [Re: Superku] #387207
11/15/11 19:00
11/15/11 19:00
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Originally Posted By: SuperKu
On the downside, you should not use the specific skill for anything else.

Or at least not for real numbers, only unique sys_malloc'ed structures...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 2 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1