[?] new()'d STAT_INFO Thinkers persist after Destroy()

Bugs that have been investigated and resolved somehow.

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.
Post Reply
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

[?] new()'d STAT_INFO Thinkers persist after Destroy()

Post by Nash »

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?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
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()

Post by Graf Zahl »

Make a test mod to demonstrate it.
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: [?] new()'d STAT_INFO Thinkers persist after Destroy()

Post by Nash »

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.
Attachments
thinkertest.pk3
(4.02 KiB) Downloaded 21 times
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
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()

Post by Graf Zahl »

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.
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: [?] new()'d STAT_INFO Thinkers persist after Destroy()

Post by Nash »

Ok understood, yeah I'm getting a much clearer picture now of how these things work. Thanks.
Post Reply

Return to “Closed Bugs [GZDoom]”