Page 1 of 1

IsSaveGame works with EventHandler.

Posted: Thu Dec 30, 2021 6:07 am
by Accensus
...but only sometimes.

Test: https://drive.google.com/file/d/1T72EnO ... sp=sharing

1. Load Hideous Destructor. I know, I know, you don't have to actually play with it even for 2 seconds, it's just that this bug can't be reproduced without it being loaded for some reason.
2. Load AUGER;ZENITH.
3. use "map map16" (changemap also works; doesn't matter)
4. Save the game.
5. Load the save.
6. Console should print "lawl". It'll keep printing it each time you load the save.

Do the same but with map12 for example. No lawl is printed.

Re: IsSaveGame works with EventHandler.

Posted: Thu Dec 30, 2021 8:02 am
by Marisa the Magician
IsSaveGame is only guaranteed to work in static handlers. I'm pretty sure this is by design, considering normal handlers are part of the map itself and get serialized/deserialized like any other map object.

Re: IsSaveGame works with EventHandler.

Posted: Thu Dec 30, 2021 8:07 am
by Accensus
Yeah. Except it still does, even with EventHandler, hence the report in the first place. And it only works on this particular map with this particular mod for ???? reason. I discovered this chasing a VM abort where a reference was nulled as part of a DestroyAllThinkers routine during save game loading. That issue also happened only on that specific map and only once per engine load, afterwards loading the save resulted in "Unloading scripts cannot exit the level again."

Unless I'm misunderstanding your post and IsSaveGame working with EventHandler is not a bug, just not something you can rely on.

Re: IsSaveGame works with EventHandler.

Posted: Thu Dec 30, 2021 11:05 am
by Graf Zahl
Your event handler is not static. What you run into here is plain and simply undefined behavior.
The WorldUnloaded event is called from different places for static and non-static event handlers so whatever you get is not guaranteed.