Fixed: Co-op players could spawn at (0,0) if no start spots for them

- Check if a co-op start exists. If not, pick one at random.
- Don't telefrag other players when spawning in co-op games, since
  you're allowed to move out of other players now.
This commit is contained in:
Randy Heit 2016-01-28 20:08:09 -06:00
parent 058bfdea26
commit 87dee5c611
3 changed files with 12 additions and 7 deletions

View file

@ -1557,7 +1557,7 @@ void G_DeathMatchSpawnPlayer (int playernum)
if (spot == NULL)
{ // We have a player 1 start, right?
spot = &playerstarts[0];
if (spot == NULL)
if (spot->type == 0)
{ // Fine, whatever.
spot = &deathmatchstarts[0];
}
@ -1573,7 +1573,8 @@ void G_DeathMatchSpawnPlayer (int playernum)
//
FPlayerStart *G_PickPlayerStart(int playernum, int flags)
{
if ((level.flags2 & LEVEL2_RANDOMPLAYERSTARTS) || (flags & PPS_FORCERANDOM))
if ((level.flags2 & LEVEL2_RANDOMPLAYERSTARTS) || (flags & PPS_FORCERANDOM) ||
playerstarts[playernum].type == 0)
{
if (!(flags & PPS_NOBLOCKINGCHECK))
{
@ -1592,7 +1593,7 @@ FPlayerStart *G_PickPlayerStart(int playernum, int flags)
{ // Pick an open spot at random.
return good_starts[pr_pspawn(good_starts.Size())];
}
}
}
// Pick a spot at random, whether it's open or not.
return &AllPlayerStarts[pr_pspawn(AllPlayerStarts.Size())];
}
@ -1665,16 +1666,17 @@ void G_DoReborn (int playernum, bool freshbot)
}
if (!(level.flags2 & LEVEL2_RANDOMPLAYERSTARTS) &&
playerstarts[playernum].type != 0 &&
G_CheckSpot (playernum, &playerstarts[playernum]))
{
AActor *mo = P_SpawnPlayer(&playerstarts[playernum], playernum);
if (mo != NULL) P_PlayerStartStomp(mo);
if (mo != NULL) P_PlayerStartStomp(mo, true);
}
else
{ // try to spawn at any random player's spot
FPlayerStart *start = G_PickPlayerStart(playernum, PPS_FORCERANDOM);
AActor *mo = P_SpawnPlayer(start, playernum);
if (mo != NULL) P_PlayerStartStomp(mo);
if (mo != NULL) P_PlayerStartStomp(mo, true);
}
}
}

View file

@ -485,7 +485,7 @@ inline bool P_TeleportMove(AActor* thing, const fixedvec3 &pos, bool telefrag, b
{
return P_TeleportMove(thing, pos.x, pos.y, pos.z, telefrag, modifyactor);
}
void P_PlayerStartStomp (AActor *actor); // [RH] Stomp on things for a newly spawned player
void P_PlayerStartStomp (AActor *actor, bool mononly=false); // [RH] Stomp on things for a newly spawned player
void P_SlideMove (AActor* mo, fixed_t tryx, fixed_t tryy, int numsteps);
bool P_BounceWall (AActor *mo);
bool P_BounceActor (AActor *mo, AActor *BlockingMobj, bool ontop);

View file

@ -504,7 +504,7 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra
//
//==========================================================================
void P_PlayerStartStomp(AActor *actor)
void P_PlayerStartStomp(AActor *actor, bool mononly)
{
AActor *th;
FBlockThingsIterator it(FBoundingBox(actor->X(), actor->Y(), actor->radius));
@ -525,6 +525,9 @@ void P_PlayerStartStomp(AActor *actor)
if (th->player == NULL && !(th->flags3 & MF3_ISMONSTER))
continue;
if (th->player != NULL && mononly)
continue;
if (actor->Z() > th->Top())
continue; // overhead
if (actor->Top() < th->Z())