Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,306 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Push stuff on to garbage collection stack? #178834
01/19/08 22:37
01/19/08 22:37
Joined: Mar 2002
Posts: 580
San Francisco
clone45 Offline OP
User
clone45  Offline OP
User

Joined: Mar 2002
Posts: 580
San Francisco
Hello!

I'm creating a lot of structures in a lite-c script that I eventually want to release as an ultra-cool inventory system. To clean up the structures, I currently have a function called inv_cleanup() which must be called before the engine is closed. That seems to work, but maybe there's a better way. If 3d GameStudio allowed me to push pointers to my structures on some garbage collection stack so it would automatically free the structures on shut-down, that would be even better. That way, programmers would not have to remember to call inv_cleanup(). Does GameStudio have such a stack that I can access?

Also, does hitting escape trigger an on_exit event?

Thanks,
- Bret

Re: Push stuff on to garbage collection stack? [Re: clone45] #178835
01/20/08 00:22
01/20/08 00:22
Joined: Dec 2006
Posts: 78
Nevada, USA
Futurulus Offline
Junior Member
Futurulus  Offline
Junior Member

Joined: Dec 2006
Posts: 78
Nevada, USA
You might not have to go that low-level. If you set on_exit to your cleanup function, it would automatically run before GS closes. (Be sure to check if on_exit is already defined so you don't mess up the other programmers' exit routine.)

Re: Push stuff on to garbage collection stack? [Re: Futurulus] #178836
01/20/08 02:20
01/20/08 02:20
Joined: Mar 2002
Posts: 580
San Francisco
clone45 Offline OP
User
clone45  Offline OP
User

Joined: Mar 2002
Posts: 580
San Francisco
Quote:

Be sure to check if on_exit is already defined so you don't mess up the other programmers' exit routine.




Hi Futurulus,

I thought about that, but as you pointed out I didn't want to set on_exit in my library for fear that I would interfere with the other programmer's code. If there's no way to push trash on to the "garbage stack", then I'll do what you suggest that optionally use the on_exit event to help make sure that the structures are cleaned up.

Thanks!
- Bret

Re: Push stuff on to garbage collection stack? [Re: clone45] #178837
01/20/08 09:37
01/20/08 09:37
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
To prevent messing with the programmers code, you could see if on_exit != null. If it is, store its content and call that at the end of your cleanup code.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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