From 0f0768652ae7f209c805048e2627c00df53b80c7 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 2 May 2020 09:20:37 -0400 Subject: [PATCH] - force player respawn to call up the player's default class settings before determining where to respawn the player --- src/g_game.cpp | 19 ++++++++++++++- src/g_levellocals.h | 1 + src/playsim/p_mobj.cpp | 53 +++++++++++++++++++++++------------------- 3 files changed, 48 insertions(+), 25 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 09445e3136..d5662767c5 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1709,7 +1709,24 @@ void FLevelLocals::DoReborn (int playernum, bool freshbot) } else { - bool isUnfriendly = players[playernum].mo && !(players[playernum].mo->flags & MF_FRIENDLY); + bool isUnfriendly; + + PlayerSpawnPickClass(playernum); + + // this condition should never be false + assert(players[playernum].cls != NULL); + + if (players[playernum].cls != NULL) + { + isUnfriendly = !(GetDefaultByType(players[playernum].cls)->flags & MF_FRIENDLY); + DPrintf(DMSG_NOTIFY, "Player class IS defined: unfriendly is %i\n", isUnfriendly); + } + else + { + // we shouldn't be here, but if we are, get the player's current status + isUnfriendly = players[playernum].mo && !(players[playernum].mo->flags & MF_FRIENDLY); + DPrintf(DMSG_NOTIFY, "Player class NOT defined: unfriendly is %i\n", isUnfriendly); + } // respawn at the start // first disassociate the corpse diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 40dc85c203..cfde061189 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -165,6 +165,7 @@ private: void ReadOnePlayer(FSerializer &arc, bool skipload); void ReadMultiplePlayers(FSerializer &arc, int numPlayers, int numPlayersNow, bool skipload); void SerializeSounds(FSerializer &arc); + void PlayerSpawnPickClass (int playernum); public: void SnapshotLevel(); diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index c98bc9c7b1..74d311551b 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -4996,31 +4996,9 @@ void StaticPointerSubstitution(AActor* old, AActor* notOld) } } - - -AActor *FLevelLocals::SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) +void FLevelLocals::PlayerSpawnPickClass (int playernum) { - player_t *p; - AActor *mobj, *oldactor; - uint8_t state; - DVector3 spawn; - DAngle SpawnAngle; - - if (mthing == NULL) - { - return NULL; - } - // not playing? - if ((unsigned)playernum >= (unsigned)MAXPLAYERS || !PlayerInGame(playernum) ) - return NULL; - - // Old lerp data needs to go - if (playernum == consoleplayer) - { - P_PredictionLerpReset(); - } - - p = Players[playernum]; + auto p = Players[playernum]; if (p->cls == NULL) { @@ -5049,6 +5027,33 @@ AActor *FLevelLocals::SpawnPlayer (FPlayerStart *mthing, int playernum, int flag } p->cls = PlayerClasses[p->CurrentPlayerClass].Type; } +} + +AActor *FLevelLocals::SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) +{ + player_t *p; + AActor *mobj, *oldactor; + uint8_t state; + DVector3 spawn; + DAngle SpawnAngle; + + if (mthing == NULL) + { + return NULL; + } + // not playing? + if ((unsigned)playernum >= (unsigned)MAXPLAYERS || !PlayerInGame(playernum) ) + return NULL; + + // Old lerp data needs to go + if (playernum == consoleplayer) + { + P_PredictionLerpReset(); + } + + p = Players[playernum]; + + PlayerSpawnPickClass(playernum); if (( dmflags2 & DF2_SAME_SPAWN_SPOT ) && ( p->playerstate == PST_REBORN ) &&