[Won't change] Actors instantly NULL'd on death if they lack a Death state

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Actors instantly NULL'd on death if they lack a Death state

Postby Marisa Kirisame » Fri Aug 13, 2021 10:19 am

This is something that has caused me endless grief for years on end during my modding career, and I don't understand why do I have to be the one who has to constantly add null checks after every single call to DamageMobj in any piece of code.

The fact here is that the default actor class lacks a Death state, and thus any other actor that doesn't define one is erased instantly inside DamageMobj and all pointers to it are immediately invalid afterwards. THIS is a problem, especially if we're dealing with code that, for example, spawns blood effects or whatever after the damage has been dealt and needs to check certain flags on the actor such as NOBLOOD and whatnot. It's a serious problem, and if this is intentional, I cannot understand why.
User avatar
Marisa Kirisame
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: MarisaDOOM
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Actors instantly NULL'd on death if they lack a Death st

Postby Graf Zahl » Fri Aug 13, 2021 10:35 am

You can still access the actor, but you have to keep its address in a local non-gc'd variable before calling anything that may destroy it.
Despite being nulled, you have a guarantee that nothing will ever get collected unlike control returns to the thinker ticking loop.

Even ensuring that the actor still runs one more state won't give you any guarantee whatsoever that calling DamageMobj won't result in its destruction due to the multitude of code that can be run recursively from there.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 0 guests