Fix rare crash in K_SetRespawnAtNextWaypoint
This commit is contained in:
parent
39302801ad
commit
e10af1eb70
1 changed files with 9 additions and 4 deletions
13
src/k_kart.c
13
src/k_kart.c
|
|
@ -8661,17 +8661,22 @@ static void K_FudgeRespawn(player_t *player, const waypoint_t *const waypoint)
|
|||
|
||||
void K_SetRespawnAtNextWaypoint(player_t * player)
|
||||
{
|
||||
mobj_t *currentwaypoint = player->currentwaypoint->mobj;
|
||||
mobj_t *safewaypoint = player->nextwaypoint->mobj;
|
||||
angle_t respawnangle = R_PointToAngle2(currentwaypoint->x, currentwaypoint->y, safewaypoint->x, safewaypoint->y);
|
||||
mobj_t *currentwaypoint;
|
||||
mobj_t *safewaypoint;
|
||||
angle_t respawnangle;
|
||||
|
||||
// Safety :P
|
||||
if (!safewaypoint || !currentwaypoint)
|
||||
if (!player->currentwaypoint || !player->nextwaypoint)
|
||||
{
|
||||
// Better safe then sorry.
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Tried to respawn at invalid waypoint!\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
currentwaypoint = player->currentwaypoint->mobj;
|
||||
safewaypoint = player->nextwaypoint->mobj;
|
||||
respawnangle = R_PointToAngle2(currentwaypoint->x, currentwaypoint->y, safewaypoint->x, safewaypoint->y);
|
||||
|
||||
player->pflags |= PF_TRUSTWAYPOINTS;
|
||||
player->starposttime = player->realtime;
|
||||
player->starpostz = (safewaypoint->spawnpoint->z + 15) >> FRACBITS;
|
||||
|
|
|
|||
Loading…
Reference in a new issue