diff --git a/src/dsectoreffect.cpp b/src/dsectoreffect.cpp index 78e00e6b0..815b49dc4 100644 --- a/src/dsectoreffect.cpp +++ b/src/dsectoreffect.cpp @@ -60,6 +60,7 @@ void DSectorEffect::Destroy() } DSectorEffect::DSectorEffect (sector_t *sector) + : DThinker(STAT_SECTOREFFECT) { m_Sector = sector; } diff --git a/src/g_level.cpp b/src/g_level.cpp index dcf97ba4f..90b31138d 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1207,29 +1207,23 @@ void G_FinishTravel () pnum = int(pawn->player - players); pawn->ChangeStatNum (STAT_PLAYER); pawndup = pawn->player->mo; - start = NULL; assert (pawn != pawndup); - if (pawndup == NULL) - { // Oh no! there was no start for this player! - start = G_PickPlayerStart(pnum, PPS_FORCERANDOM); - if (start != NULL) pawndup = P_SpawnPlayer(start, pnum, (level.flags2 & LEVEL2_PRERAISEWEAPON) ? SPF_WEAPONFULLYUP : 0); - if (pawndup == NULL) - { - pawn->flags |= MF_NOSECTOR | MF_NOBLOCKMAP; - pawn->Destroy(); - continue; - } - } + start = G_PickPlayerStart(pnum, 0); if (start == NULL) { - start = G_PickPlayerStart(pnum, 0); - if (start == NULL) + if (pawndup != nullptr) { Printf(TEXTCOLOR_RED "No player %d start to travel to!\n", pnum + 1); // Move to the coordinates this player had when they left the level. pawn->SetXYZ(pawndup->Pos()); } + else + { + // Could not find a start for this player at all. This really should never happen but if it does, let's better abort. + DThinker::DestroyThinkersInList(STAT_TRAVELLING); + I_Error ("No player %d start to travel to!\n", pnum + 1); + } } oldpawn = pawndup; @@ -1266,8 +1260,11 @@ void G_FinishTravel () pawn->player->camera = pawn; pawn->player->viewheight = pawn->ViewHeight; pawn->flags2 &= ~MF2_BLASTED; - DObject::StaticPointerSubstitution (oldpawn, pawn); - oldpawn->Destroy(); + if (oldpawn != nullptr) + { + DObject::StaticPointerSubstitution (oldpawn, pawn); + oldpawn->Destroy(); + } if (pawndup != NULL) { pawndup->Destroy(); diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 170273b43..24e5ff9ee 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -642,6 +642,11 @@ static void ReadOnePlayer(FSerializer &arc, bool skipload) { CopyPlayer(&players[i], &playerTemp, name); } + else + { + // we need the player actor, so that G_FinishTravel can destroy it later. + players[i].mo = playerTemp.mo; + } } else { @@ -755,6 +760,13 @@ static void ReadMultiplePlayers(FSerializer &arc, int numPlayers, int numPlayers } } } + else + { + for (i = 0; i < MAXPLAYERS; ++i) + { + players[i].mo = playertemp[i].mo; + } + } delete[] tempPlayerUsed; delete[] playertemp;