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

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 a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [?] new()'d STAT_INFO Thinkers persist after Destroy()

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

by Nash » Sat Sep 02, 2017 1:41 am

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

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

by Graf Zahl » Sat Sep 02, 2017 12:22 am

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.

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

by Nash » Sun Aug 27, 2017 11:05 am

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

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

by Graf Zahl » Sun Aug 27, 2017 1:24 am

Make a test mod to demonstrate it.

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

by Nash » Fri Aug 18, 2017 5:06 am

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?

Top