This could be a bug but I wasn't sure what the intended usage/behavior is, or if I'm doing something in a really unwise way.
Spoiler:
Moderator: GZDoom Developers
Spoiler:
I wasn't aware it created a copy of the player, is the level load process described anywhere?_mental_ wrote:Before destruction of old player's actor its clone is created in the current level.
This happens after destruction of thinkers and before destruction of old player pawn.
For this reason stack array from TestPlayer objects survives map change.
Although it contains nulls because objects were already destroyed and garbage collected.
Both OnDestroy() overrides are rather pointless, everything will work in the same way without them.
In other words, this is not a problem of dynamic arrays, Clear() or any other method.
Okay, I've edited the OP with better language and will use this in the future._mental_ wrote:And the last but not least. Could you please stop calling VM abort a crash? This is very misleading but continue to happen regularly.
Crash is unhandled exception after which OS has nothing else to do except to terminate guilty process.
When script is trying to access null object, GZDoom handles this gracefully and displays corresponding error(s) in console.
No, I doubt so. The code responsible for whole process is in G_FinishTravel() function.JPL wrote:I wasn't aware it created a copy of the player, is this process described anywhere?
The same function, these lines to be precise.JPL wrote:I can see that a new player is getting created before the old one is destroyed, but why do those two functions run twice?
JPL wrote:I tried replacing the OnDestroy calls with a TestPlayer.BeginPlay override that clears the stacks list, but this didn't seem to change anything.
In both invocations of TestPlayer.BeginPlay() stack is still empty. Its content (bunch of nulls in our case) is copied after exiting from overridden BeginPlay() method.JPL wrote:Regardless, I can't figure out why the stacks.Clear() in TestPlayer.BeginPlay doesn't remove the old actor references and prevent the VM abort.