Skip to content

Commit

Permalink
Fixes for spawn farthest DM option
Browse files Browse the repository at this point in the history
No longer picks a random spot on the first spawn but will account for players spawning in sequentially. No longer fails to return a spawn spot if every player is dead while respawning (instead it picks a random one).
  • Loading branch information
Boondorl authored and coelckers committed Apr 16, 2024
1 parent 70a165b commit f2072ce
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/g_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1606,10 +1606,20 @@ void FLevelLocals::DeathMatchSpawnPlayer (int playernum)
if (selections < 1)
I_Error ("No deathmatch starts");

bool hasSpawned = false;
for (int i = 0; i < MAXPLAYERS; ++i)
{
if (PlayerInGame(i) && Players[i]->mo != nullptr && Players[i]->health > 0)
{
hasSpawned = true;
break;
}
}

// At level start, none of the players have mobjs attached to them,
// so we always use the random deathmatch spawn. During the game,
// though, we use whatever dmflags specifies.
if ((dmflags & DF_SPAWN_FARTHEST) && players[playernum].mo)
if ((dmflags & DF_SPAWN_FARTHEST) && hasSpawned)
spot = SelectFarthestDeathmatchSpot (selections);
else
spot = SelectRandomDeathmatchSpot (playernum, selections);
Expand Down

0 comments on commit f2072ce

Please sign in to comment.