I have a STAT_INFO thinker made using new(). When I call Destroy() on it, it appears to be destroyed (the OnDestroy() method does happen, as far as I can tell), but upon inspecting the saved game, the object reference stays inside the map's saved game. They will pile up as they keep being new()'d and Destroy()'d.
EDIT: Changing it to STAT_STATIC will correctly delete the object from the saved game after a Destroy()... so I'm not sure if this is a bug or if that's how the engine works?
[?] new()'d STAT_INFO Thinkers persist after Destroy()
Moderator: GZDoom Developers
Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [?] new()'d STAT_INFO Thinkers persist after Destroy()
Make a test mod to demonstrate it.
Re: [?] new()'d STAT_INFO Thinkers persist after Destroy()
Follow these exact steps to reproduce:
1) Start new game. In MAP01, press Fire once. A new thinker is created.
2) Step into the teleporter to go to MAP02. In MAP02, press AltFire once.
3) Travel back to MAP01. Press AltFire once more.
Open the MAP01 JSON save file. You will see that the TestThinker is permanently baked into the saved game, despite being destroyed and unused in-game.
1) Start new game. In MAP01, press Fire once. A new thinker is created.
2) Step into the teleporter to go to MAP02. In MAP02, press AltFire once.
3) Travel back to MAP01. Press AltFire once more.
Open the MAP01 JSON save file. You will see that the TestThinker is permanently baked into the saved game, despite being destroyed and unused in-game.
- Attachments
-
- thinkertest.pk3
- (4.02 KiB) Downloaded 21 times
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [?] new()'d STAT_INFO Thinkers persist after Destroy()
Do not use thinkers like that. I remember saying some time ago that thinkers are owned by the map. So when you transition from MAP01 to MAP02 the thinkers are written out to the savegame and removed from the list. So your neat little 'DestroyThinkers' function on MAP02 will not find any valid thinker and do nothing, and once you return to MAP01 the player will have lost the connection to its thinkers so they persist until all eternity.
If you want persistent thinkers across maps you HAVE to use STAT_STATIC. It cannot and will never work without it.
If you want persistent thinkers across maps you HAVE to use STAT_STATIC. It cannot and will never work without it.
Re: [?] new()'d STAT_INFO Thinkers persist after Destroy()
Ok understood, yeah I'm getting a much clearer picture now of how these things work. Thanks.