Restore game sequence with plugins?

Started by Kweepa, Sat 04/06/2005 19:49:18

Previous topic - Next topic

Kweepa

Hi,
I'm updating the fire plugin to fix some reported and unreported problems.

The plugin creates dynamic sprites when an object is set on fire, and deletes them when the player leaves the room.
It keeps a list of burning objects which is also cleared at that point.

When the game is restored though, I don't see any way to clear the dynamic sprites before the restore, without forcing the game author to call a dll function directly.

[EDIT] There's not even a guaranteed way to call a dll function - on_event eEventRestoreGame is presumably called after the restore, and RestoreGameDialog doesn't necessarily restore a game. (Oh, and Restarting the game should also clear the fire list.)

Does anyone have any advice?

Cheers!
Still waiting for Purity of the Surf II

Scorpiorus

What about the RequestEventHook's AGSE_RESTOREGAME event? Is it what you're after?

Kweepa

No, that's called after the rest of the restore has happened - the room has already changed, etc.
I want to clean up the old room before I leave it.

I guess what I really want to know is what happens to dynamically created sprites when the game is saved and restored.

Option one is that the save game includes those, and that on restore all dynamic sprites are first destroyed.
Option two is that dynamic sprites are global across the game and across saves and restores.
Or there's some third option that I don't understand yet.

My limited testing indicates option one. I'd like to be sure I'm doing the right thing before I release my plugin.

At the very least I want to be able to reset the object graphic to a non-dynamic sprite whilst the room is not around so that next time it's loaded the object isn't referencing a dynamic sprite that doesn't exist.
Still waiting for Purity of the Surf II

Pumaman

As of 2.7, dynamic sprites are persisted in the save game file.

If you restore a game, all existing dynamic sprites are freed, and any dynamic sprites that were present at the time that the game was saved are recreated.

Therefore, you should be perfectly safe storing your list of dynamic sprites as part of the save game, because it will still be correct when the game is restored.

However, in 2.62 and previous versions, the behaviour is as your "option two" states -- the dynamic sprites are global across saves and restores. In order to get around this, I would make your plugin require 2.7 as a minimum AGS version.

Kweepa

#4
Thanks CJ.
That explains my confusion.
I guess that means upgrading my own game to 2.7!

[EDIT] What about engine shutdown? Do I need to free the sprites? Do they get freed before or after the AGS_EngineShutdown call to the plugin?
Still waiting for Purity of the Surf II

Pumaman

Yes, you should free the sprites. If you don't do so in AGS_EngineShutdown, warnings are generated.

Kweepa

Cheers.
The fire plugin has been updated to v2.7 only.
Still waiting for Purity of the Surf II

Rui 'Trovatore' Pires

#7
Linky link, so I can up it to my site. :)
EDIT - Whoops sorry, hadn't checked the Tech Archive...
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

SMF spam blocked by CleanTalk