Skip to content

Commit

Permalink
Fixed: Behavior when there are no free DM startspots
Browse files Browse the repository at this point in the history
Instead of Con_Error() it just selects one of them.
  • Loading branch information
skyjake committed Aug 4, 2011
1 parent a073ff3 commit 3634ba7
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions doomsday/plugins/common/src/p_start.c
Expand Up @@ -1047,22 +1047,21 @@ void G_DeathMatchSpawnPlayer(int playerNum)
Con_Error("G_DeathMatchSpawnPlayer: Error, minimum of two "
"(deathmatch) mapspots required for deathmatch.");

for(i = 0; i < 20; ++i)
#define NUM_TRIES 20
for(i = 0; i < NUM_TRIES; ++i)
{
const playerstart_t* start =
&deathmatchStarts[P_Random() % numPlayerDMStarts];

if(P_CheckSpot(start->pos[VX], start->pos[VY]))
// Last attempt will succeed even though blocked.
if(P_CheckSpot(start->pos[VX], start->pos[VY]) || i == NUM_TRIES-1)
{
spawnPlayer(playerNum, pClass, start->pos[VX], start->pos[VY],
start->pos[VZ], start->angle, start->spawnFlags, false,
true, true);
return;
}
}

Con_Error("G_DeathMatchSpawnPlayer: Failed to spawn player %i.",
playerNum);
}

typedef struct {
Expand Down

0 comments on commit 3634ba7

Please sign in to comment.