mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 20:21:26 +00:00
- removed some more hubtravel related player start fudging.
* do not skip the player_t init when travelling in a hub. The old player may still be needed in some edge cases. This applies only to singleplayer for now. The multiplayer version still needs reviewing. I left it alone because it may shuffle players around which is not wanted when doing hub travelling. * do not spawn two temp players in G_FinishTravel. Instead handle the case where no player_t::mo can be found gracefully by adding a few nullptr checks. This temp player served no real purpose except for having a valid pointer. The actual start position was retrieved from somewhere else.
This commit is contained in:
parent
74b8e9f286
commit
6a6a0e8017
2 changed files with 17 additions and 23 deletions
|
@ -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();
|
||||
|
|
|
@ -537,7 +537,7 @@ void P_SerializeSounds(FSerializer &arc)
|
|||
//==========================================================================
|
||||
|
||||
void CopyPlayer(player_t *dst, player_t *src, const char *name);
|
||||
static void ReadOnePlayer(FSerializer &arc, bool skipload);
|
||||
static void ReadOnePlayer(FSerializer &arc);
|
||||
static void ReadMultiplePlayers(FSerializer &arc, int numPlayers, int numPlayersNow, bool skipload);
|
||||
static void SpawnExtraPlayers();
|
||||
|
||||
|
@ -594,7 +594,7 @@ void P_SerializePlayers(FSerializer &arc, bool skipload)
|
|||
// first player present, no matter what their name.
|
||||
if (numPlayers == 1)
|
||||
{
|
||||
ReadOnePlayer(arc, skipload);
|
||||
ReadOnePlayer(arc);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -617,7 +617,7 @@ void P_SerializePlayers(FSerializer &arc, bool skipload)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void ReadOnePlayer(FSerializer &arc, bool skipload)
|
||||
static void ReadOnePlayer(FSerializer &arc)
|
||||
{
|
||||
int i;
|
||||
const char *name = NULL;
|
||||
|
@ -636,10 +636,7 @@ static void ReadOnePlayer(FSerializer &arc, bool skipload)
|
|||
didIt = true;
|
||||
player_t playerTemp;
|
||||
playerTemp.Serialize(arc);
|
||||
if (!skipload)
|
||||
{
|
||||
CopyPlayer(&players[i], &playerTemp, name);
|
||||
}
|
||||
CopyPlayer(&players[i], &playerTemp, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue