diff --git a/src/p_spec.c b/src/p_spec.c index b0586f2da..c321c80b8 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2054,9 +2054,6 @@ static void K_HandleLapIncrement(player_t *player) } P_DoPlayerExit(player); - - if (!(player->pflags & PF_NOCONTEST)) - P_SetupSignExit(player); } else { @@ -4617,13 +4614,15 @@ static void P_SetupSignObject(mobj_t *sign, mobj_t *pmo, boolean error) // Finds the exit sign in the current sector and // sets its target to the player who passed the map. // -void P_SetupSignExit(player_t *player) +void P_SetupSignExit(player_t *player, boolean tie) { mobj_t *thing; msecnode_t *node = player->mo->subsector->sector->touching_thinglist; // things touching this sector thinker_t *think; INT32 numfound = 0; + angle_t bestAngle = K_MomentumAngle(player->mo) + ANGLE_180; + if (player->position != 1) return; @@ -4633,6 +4632,13 @@ void P_SetupSignExit(player_t *player) if (thing->type != MT_SIGN) continue; + bestAngle = thing->angle; + + if (tie) + { + break; + } + if (thing->state != &states[thing->info->spawnstate]) continue; @@ -4654,6 +4660,13 @@ void P_SetupSignExit(player_t *player) if (thing->type != MT_SIGN) continue; + bestAngle = thing->angle; + + if (tie) + { + break; + } + if (thing->state != &states[thing->info->spawnstate]) continue; @@ -4668,8 +4681,8 @@ void P_SetupSignExit(player_t *player) if (player->mo && !P_MobjWasRemoved(player->mo)) { thing = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->floorz, MT_SIGN); - thing->angle = player->mo->angle; - P_SetupSignObject(thing, player->mo, true); // Use :youfuckedup: sign face + thing->angle = bestAngle; + P_SetupSignObject(thing, player->mo, (tie == false)); // Use :youfuckedup: sign face, except during ties } } @@ -5166,7 +5179,7 @@ static void P_ProcessExitSector(player_t *player, mtag_t sectag) // Exit (for FOF exits; others are handled in P_PlayerThink in p_user.c) P_DoPlayerExit(player); - P_SetupSignExit(player); + P_SetupSignExit(player, false); #if 0 if (!G_CoopGametype()) diff --git a/src/p_spec.h b/src/p_spec.h index d33cdeb3f..1ec766f09 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -600,7 +600,7 @@ struct activator_t boolean P_CanActivateSpecial(INT16 special); boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, char **stringargs); -void P_SetupSignExit(player_t *player); +void P_SetupSignExit(player_t *player, boolean tie); boolean P_IsMobjTouchingSectorPlane(mobj_t *mo, sector_t *sec); boolean P_IsMobjTouching3DFloor(mobj_t *mo, ffloor_t *ffloor, sector_t *sec); diff --git a/src/p_tick.c b/src/p_tick.c index 4ed8fd83a..b7911571c 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -629,9 +629,37 @@ void P_Ticker(boolean run) ps_thinkertime = I_GetPreciseTime() - ps_thinkertime; // Run any "after all the other thinkers" stuff - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) - P_PlayerAfterThink(&players[i]); + { + player_t *finishingPlayers[MAXPLAYERS]; + UINT8 numFinishingPlayers = 0; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) + { + P_PlayerAfterThink(&players[i]); + + // Check for the number of ties for first place after every player has thunk run for this tic + if (players[i].exiting == 1 && players[i].position == 1 && + (players[i].pflags & (PF_HITFINISHLINE|PF_NOCONTEST)) == PF_HITFINISHLINE) + { + finishingPlayers[numFinishingPlayers++] = &players[i]; + } + } + } + + if (numFinishingPlayers > 1) + { + for (i = 0; i < numFinishingPlayers; i++) + { + P_SetupSignExit(finishingPlayers[i], true); + } + } + else if (numFinishingPlayers == 1) + { + P_SetupSignExit(finishingPlayers[0], false); + } + } if (K_CheckBossIntro() == true) {