diff --git a/src/g_game.cpp b/src/g_game.cpp index e271c8a51..934e36d5e 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1521,12 +1521,7 @@ void G_DeathMatchSpawnPlayer (int playernum) } } - if (playernum < 4) - spot->type = playernum+1; - else - spot->type = playernum + gameinfo.player5start - 4; - - AActor *mo = P_SpawnPlayer (spot); + AActor *mo = P_SpawnPlayer(spot, playernum); if (mo != NULL) P_PlayerStartStomp(mo); } @@ -1599,7 +1594,7 @@ void G_DoReborn (int playernum, bool freshbot) if (G_CheckSpot (playernum, &playerstarts[playernum]) ) { - AActor *mo = P_SpawnPlayer (&playerstarts[playernum]); + AActor *mo = P_SpawnPlayer(&playerstarts[playernum], playernum); if (mo != NULL) P_PlayerStartStomp(mo); } else @@ -1609,27 +1604,13 @@ void G_DoReborn (int playernum, bool freshbot) { if (G_CheckSpot (playernum, &playerstarts[i]) ) { - int oldtype = playerstarts[i].type; - - // fake as other player - // [RH] These numbers should be common across all games. Or better yet, not - // used at all outside P_SpawnMapThing(). - if (playernum < 4) - { - playerstarts[i].type = playernum + 1; - } - else - { - playerstarts[i].type = playernum + gameinfo.player5start - 4; - } - AActor *mo = P_SpawnPlayer (&playerstarts[i]); + AActor *mo = P_SpawnPlayer(&playerstarts[i], playernum); if (mo != NULL) P_PlayerStartStomp(mo); - playerstarts[i].type = oldtype; // restore return; } // he's going to be inside something. Too bad. } - AActor *mo = P_SpawnPlayer (&playerstarts[playernum]); + AActor *mo = P_SpawnPlayer(&playerstarts[playernum], playernum); if (mo != NULL) P_PlayerStartStomp(mo); } } diff --git a/src/g_level.cpp b/src/g_level.cpp index c51b58a66..6f2c5e164 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1121,7 +1121,7 @@ void G_FinishTravel () // The player being spawned here is a short lived dummy and // must not start any ENTER script or big problems will happen. - pawndup = P_SpawnPlayer (&playerstarts[pawn->player - players], true); + pawndup = P_SpawnPlayer (&playerstarts[pawn->player - players], pawn->player - players, true); if (!(changeflags & CHANGELEVEL_KEEPFACING)) { pawn->angle = pawndup->angle; diff --git a/src/p_local.h b/src/p_local.h index 9f805f90d..fe47f5999 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -118,7 +118,7 @@ extern fixed_t FloatBobOffsets[64]; struct FMapThing; -APlayerPawn *P_SpawnPlayer (FMapThing *mthing, bool tempplayer=false); +APlayerPawn *P_SpawnPlayer (FMapThing *mthing, int playernum, bool tempplayer=false); void P_ThrustMobj (AActor *mo, angle_t angle, fixed_t move); int P_FaceMobj (AActor *source, AActor *target, angle_t *delta); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 10f5de9d9..4da09b01b 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4074,29 +4074,16 @@ EXTERN_CVAR (Bool, chasedemo) extern bool demonew; -APlayerPawn *P_SpawnPlayer (FMapThing *mthing, bool tempplayer) +APlayerPawn *P_SpawnPlayer (FMapThing *mthing, int playernum, bool tempplayer) { - int playernum; player_t *p; APlayerPawn *mobj, *oldactor; BYTE state; fixed_t spawn_x, spawn_y, spawn_z; angle_t spawn_angle; - // [RH] Things 4001-? are also multiplayer starts. Just like 1-4. - // To make things simpler, figure out which player is being - // spawned here. - if (mthing->type <= 4) - { - playernum = mthing->type - 1; - } - else - { - playernum = mthing->type - gameinfo.player5start + 4; - } - // not playing? - if (playernum >= MAXPLAYERS || !playeringame[playernum]) + if ((unsigned)playernum >= (unsigned)MAXPLAYERS || !playeringame[playernum]) return NULL; p = &players[playernum]; @@ -4495,7 +4482,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) // save spots for respawning in network games playerstarts[pnum] = *mthing; if (!deathmatch) - return P_SpawnPlayer (mthing); + return P_SpawnPlayer(&playerstarts[pnum], pnum); return NULL; } diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 27c42b7ef..205e91443 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -310,7 +310,7 @@ static void SpawnExtraPlayers () if (playeringame[i] && players[i].mo == NULL) { players[i].playerstate = PST_ENTER; - P_SpawnPlayer (&playerstarts[i]); + P_SpawnPlayer(&playerstarts[i], i); } } }