Make trigger conditions for "all players" triggers consistent

This commit is contained in:
MascaraSnake 2021-12-09 21:36:46 +01:00
parent a35a3b3edc
commit 21f8baea4a
3 changed files with 28 additions and 29 deletions

View file

@ -1043,23 +1043,6 @@ void T_MarioBlockChecker(mariocheck_t *block)
}
}
static boolean P_IsPlayerValid(size_t playernum)
{
if (!playeringame[playernum])
return false;
if (!players[playernum].mo)
return false;
if (players[playernum].mo->health <= 0)
return false;
if (players[playernum].spectator)
return false;
return true;
}
// This is the Thwomp's 'brain'. It looks around for players nearby, and if
// it finds any, **SMASH**!!! Muahahhaa....
void T_ThwompSector(thwomp_t *thwomp)
@ -1278,7 +1261,7 @@ static boolean P_CheckAllTrigger(eachtime_t *eachtime)
for (i = 0; i < MAXPLAYERS; i++)
{
if (P_IsPlayerValid(i) && !eachtime->playersInArea[i])
if (P_CanPlayerTrigger(i) && !eachtime->playersInArea[i])
return false;
}
@ -1297,7 +1280,7 @@ void T_EachTimeThinker(eachtime_t *eachtime)
for (i = 0; i < MAXPLAYERS; i++)
{
oldPlayersInArea[i] = eachtime->playersInArea[i];
caller[i] = P_IsPlayerValid(i) ? P_FindPlayerTrigger(&players[i], eachtime->sourceline) : NULL;
caller[i] = P_CanPlayerTrigger(i) ? P_FindPlayerTrigger(&players[i], eachtime->sourceline) : NULL;
eachtime->playersInArea[i] = caller[i] != NULL;
}
@ -1312,7 +1295,7 @@ void T_EachTimeThinker(eachtime_t *eachtime)
continue;
// If player has just left, check if still valid
if (!eachtime->playersInArea[i] && (!eachtime->triggerOnExit || !P_IsPlayerValid(i)))
if (!eachtime->playersInArea[i] && (!eachtime->triggerOnExit || !P_CanPlayerTrigger(i)))
continue;
// If sector has an "all players" trigger type, all players need to be in area

View file

@ -4205,6 +4205,28 @@ sector_t *P_FindPlayerTrigger(player_t *player, line_t *sourceline)
return false;
}
boolean P_IsPlayerValid(size_t playernum)
{
if (!playeringame[playernum])
return false;
if (!players[playernum].mo)
return false;
if (players[playernum].mo->health <= 0)
return false;
if (players[playernum].spectator)
return false;
return true;
}
boolean P_CanPlayerTrigger(size_t playernum)
{
return P_IsPlayerValid(playernum) && !players[playernum].bot;
}
/// \todo check continues for proper splitscreen support?
static boolean P_DoAllPlayersTrigger(mtag_t sectag)
{
@ -4215,15 +4237,7 @@ static boolean P_DoAllPlayersTrigger(mtag_t sectag)
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i])
continue;
if (!players[i].mo)
continue;
if (players[i].spectator)
continue;
if (players[i].bot)
continue;
if (G_CoopGametype() && players[i].lives <= 0)
if (!P_CanPlayerTrigger(i))
continue;
if (!P_FindPlayerTrigger(&players[i], &dummyline))
return false;

View file

@ -358,6 +358,8 @@ void P_PlayerInSpecialSector(player_t *player);
void P_CheckPushableTrigger(mobj_t *mobj, sector_t *sec);
void P_CheckMobjTrigger(mobj_t *mobj);
sector_t *P_FindPlayerTrigger(player_t *player, line_t *sourceline);
boolean P_IsPlayerValid(size_t playernum);
boolean P_CanPlayerTrigger(size_t playernum);
void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *roversector);
fixed_t P_FindLowestFloorSurrounding(sector_t *sec);