Don't cancel P_LinedefExecute early

This commit is contained in:
spherallic 2023-03-16 11:47:21 +01:00
parent f1106236ad
commit d8dd988451
2 changed files with 25 additions and 29 deletions

View file

@ -1741,14 +1741,13 @@ static boolean P_ActivateLinedefExecutorsInSector(line_t *triggerline, mobj_t *a
/** Used by P_LinedefExecute to check a trigger linedef's conditions
* The linedef executor specials in the trigger linedef's sector are run if all conditions are met.
* Return false cancels P_LinedefExecute, this happens if a condition is not met.
*
* \param triggerline Trigger linedef to check conditions for; should NEVER be NULL.
* \param actor Object initiating the action; should not be NULL.
* \param caller Sector in which the action was started. May be NULL.
* \sa P_ProcessLineSpecial, P_LinedefExecute
*/
boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller)
void P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller)
{
INT16 specialtype = triggerline->special;
@ -1761,12 +1760,12 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
if (caller->triggerer == TO_PLAYEREMERALDS)
{
if (!(ALL7EMERALDS(emeralds)))
return false;
return;
}
else if (caller->triggerer == TO_PLAYERNIGHTS)
{
if (!P_CheckPlayerMareOld(triggerline))
return false;
return;
}
}
@ -1774,22 +1773,22 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
{
case 303:
if (!P_CheckPlayerRings(triggerline, actor))
return false;
return;
break;
case 305:
if (!(actor && actor->player && actor->player->charability == triggerline->args[1]))
return false;
return;
break;
case 309:
// Only red/blue team members can activate this.
if (!(actor && actor->player))
return false;
return;
if (actor->player->ctfteam != ((triggerline->args[1] == TMT_RED) ? 1 : 2))
return false;
return;
break;
case 314:
if (!P_CheckPushables(triggerline, caller))
return false;
return;
break;
case 317:
{ // Unlockable triggers required
@ -1798,10 +1797,10 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
if (trigid < 0 || trigid > 31) // limited by 32 bit variable
{
CONS_Debug(DBG_GAMELOGIC, "Unlockable trigger (sidedef %hu): bad trigger ID %d\n", triggerline->sidenum[0], trigid);
return false;
return;
}
else if (!(unlocktriggers & (1 << trigid)))
return false;
return;
}
break;
case 319:
@ -1811,10 +1810,10 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
if (unlockid < 0 || unlockid >= MAXUNLOCKABLES) // limited by unlockable count
{
CONS_Debug(DBG_GAMELOGIC, "Unlockable check (sidedef %hu): bad unlockable ID %d\n", triggerline->sidenum[0], unlockid);
return false;
return;
}
else if (!(serverGamedata->unlocked[unlockid-1]))
return false;
return;
}
break;
case 321:
@ -1822,7 +1821,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
if (triggerline->callcount > 0)
{
if (--triggerline->callcount > 0)
return false;
return;
}
break;
case 323: // nightserize
@ -1830,15 +1829,15 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
case 327: // nights lap
case 329: // nights egg capsule touch
if (!P_CheckNightsTriggerLine(triggerline, actor))
return false;
return;
break;
case 331:
if (!(actor && actor->player))
return false;
return;
if (!triggerline->stringargs[0])
return false;
return;
if (!(stricmp(triggerline->stringargs[0], skins[actor->player->skin].name) == 0) ^ !!(triggerline->args[1]))
return false;
return;
break;
case 334: // object dye
{
@ -1846,22 +1845,22 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
UINT16 color = (actor->player ? actor->player->powers[pw_dye] : actor->color);
if (!!(triggerline->args[1]) ^ (triggercolor != color))
return false;
return;
}
break;
case 337: // emerald check
if (!P_CheckEmeralds(triggerline->args[2], (UINT16)triggerline->args[1]))
return false;
return;
break;
case 340: // NiGHTS mare
if (!P_CheckPlayerMare(triggerline))
return false;
return;
break;
case 343: // gravity check
if (triggerline->args[1] == TMG_TEMPREVERSE && (!(actor->flags2 & MF2_OBJECTFLIP) != !(actor->player->powers[pw_gravityboots])))
return false;
return;
if ((triggerline->args[1] == TMG_NORMAL) != !(actor->eflags & MFE_VERTICALFLIP))
return false;
return;
break;
default:
break;
@ -1872,7 +1871,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
/////////////////////////////////
if (!P_ActivateLinedefExecutorsInSector(triggerline, actor, caller))
return false;
return;
// "Trigger on X calls" linedefs reset if args[2] is set
if (specialtype == 321 && triggerline->args[2])
@ -1905,8 +1904,6 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
&& triggerline->args[0] == TMT_ONCE)
triggerline->special = 0;
}
return true;
}
/** Runs a linedef executor.
@ -1959,8 +1956,7 @@ void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller)
if (lines[masterline].special == 321 && lines[masterline].args[0] > TMXT_EACHTIMEMASK) // Trigger after X calls
continue;
if (!P_RunTriggerLinedef(&lines[masterline], actor, caller))
return; // cancel P_LinedefExecute if function returns false
P_RunTriggerLinedef(&lines[masterline], actor, caller); // Even if it fails, there might be more linedefs to trigger
}
}

View file

@ -527,7 +527,7 @@ boolean P_IsMobjTouchingPolyobj(mobj_t *mo, polyobj_t *po, sector_t *polysec);
void P_SwitchWeather(INT32 weathernum);
boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller);
void P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller);
void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller);
void P_RunNightserizeExecutors(mobj_t *actor);
void P_RunDeNightserizeExecutors(mobj_t *actor);