From 25071e26e58fe3eab24cc12b655a47ed5ac008d8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Feb 2019 09:11:33 +0100 Subject: [PATCH] - fixed: The CheckEnvironmant call in PlayerThink can already invalidate the PlayerPawn so even the calls to CheckUndoMorph and CheckUse need to get the pawn through the PlayerInfo. --- wadsrc/static/zscript/shared/player.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wadsrc/static/zscript/shared/player.txt b/wadsrc/static/zscript/shared/player.txt index 3e3bd2e56..5bc9d3818 100644 --- a/wadsrc/static/zscript/shared/player.txt +++ b/wadsrc/static/zscript/shared/player.txt @@ -1635,10 +1635,11 @@ class PlayerPawn : Actor if (!(player.cheats & CF_PREDICTING)) { CheckEnvironment(); - CheckUse(); - CheckUndoMorph(); + // Note that after this point the PlayerPawn may have changed due to getting unmorphed or getting its skull popped so 'self' is no longer safe to use. + // This also must not read mo into a local variable because several functions in this block can change the attached PlayerPawn. + player.mo.CheckUse(); + player.mo.CheckUndoMorph(); // Cycle psprites. - // Note that after this point the PlayerPawn may have changed due to getting unmorphed so 'self' is no longer safe to use. player.mo.TickPSprites(); // Other Counters if (player.damagecount) player.damagecount--;