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 (Ayumi), 662 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
DoSomething before Engine shut down #408488
10/02/12 11:06
10/02/12 11:06
Joined: Dec 2003
Posts: 1,225
germany
gri Offline OP
Serious User
gri  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,225
germany


hey,

with many structs and malloc'ated memory I need a possibility to free and clean up the memory before the engine closes.

Yes I know about sys_exit but what if the user shut down the engine via ESC key?
What is the best practice in that case?


"Make a great game or kill it early" (Bruce Shelley, Ensemble Studios)
Re: DoSomething before Engine shut down [Re: gri] #408489
10/02/12 11:17
10/02/12 11:17
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
on_esc, on_close
or just let the engine do the stuff (if you use sys_malloc)


Visit my site: www.masterq32.de
Re: DoSomething before Engine shut down [Re: MasterQ32] #408491
10/02/12 11:38
10/02/12 11:38
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
I use a function attached to on_exit, which has only one frame to be executed. sys_exit runs the on_exit event just before really shutting down. it is called also when you get an error message and press cancel. in this case I found it useful to free dynamically allocated stuff. (normally engine really does the job)

as I know on_close is for handling application window X icon.


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: DoSomething before Engine shut down [Re: sivan] #408493
10/02/12 11:59
10/02/12 11:59
Joined: Dec 2003
Posts: 1,225
germany
gri Offline OP
Serious User
gri  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,225
germany


thank you both.

great! I thought on_exit is only called on sys_exit. Sorry Sivan I could not belive that on_exit got called even on engine crash.

So I gave on_exit the functionality to create a single file in the folder.....and yes a forced crash let the file occuring before the engine dies.

Works with ESC key too. Now I have the event for cleaning work laugh
Thank you again.


"Make a great game or kill it early" (Bruce Shelley, Ensemble Studios)
Re: DoSomething before Engine shut down [Re: gri] #408496
10/02/12 12:21
10/02/12 12:21
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
I said error message, not a total crash to desktop!
"The on_exit function is executed just before the engine exits due to a sys_exit call, or A7.76 when the Cancel button was hit on an engine error message. It can be used to free DLLs or release user-allocated memory. "


Free world editor for 3D Gamestudio: MapBuilder Editor

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