- added a function to execute action specials and changed all calls to use this function. This was done to make it easier to check such calls.

SVN r3152 (trunk)
This commit is contained in:
Christoph Oelckers 2011-02-13 10:18:28 +00:00
parent 99df7354b1
commit 1ea5cc8bd8
19 changed files with 77 additions and 38 deletions

View file

@ -2344,7 +2344,7 @@ void Net_DoCommand (int type, BYTE **stream, int player)
} }
if (!CheckCheatmode(player == consoleplayer)) if (!CheckCheatmode(player == consoleplayer))
{ {
LineSpecials[snum](NULL, players[player].mo, false, arg[0], arg[1], arg[2], arg[3], arg[4]); P_ExecuteSpecial(snum, NULL, players[player].mo, false, arg[0], arg[1], arg[2], arg[3], arg[4]);
} }
} }
break; break;

View file

@ -2221,7 +2221,7 @@ void FParser::SF_LineTrigger()
mld.special=intvalue(t_argv[0]); mld.special=intvalue(t_argv[0]);
mld.tag=t_argc > 1 ? intvalue(t_argv[1]) : 0; mld.tag=t_argc > 1 ? intvalue(t_argv[1]) : 0;
P_TranslateLineDef(&line, &mld); P_TranslateLineDef(&line, &mld);
LineSpecials[line.special](NULL, Script->trigger, false, P_ExecuteSpecial(line.special, NULL, Script->trigger, false,
line.args[0],line.args[1],line.args[2],line.args[3],line.args[4]); line.args[0],line.args[1],line.args[2],line.args[3],line.args[4]);
} }
} }
@ -4042,7 +4042,7 @@ void FParser::SF_Ls()
if (t_argc>=i+2) args[i]=intvalue(t_argv[i+1]); if (t_argc>=i+2) args[i]=intvalue(t_argv[i+1]);
} }
if (spc>=0 && spc<256) if (spc>=0 && spc<256)
LineSpecials[spc](NULL,Script->trigger,false, args[0],args[1],args[2],args[3],args[4]); P_ExecuteSpecial(spc, NULL,Script->trigger,false, args[0],args[1],args[2],args[3],args[4]);
} }
} }
@ -4421,7 +4421,7 @@ void FParser::RunLineSpecial(const FLineSpecial *spec)
if (t_argc>i) args[i]=intvalue(t_argv[i]); if (t_argc>i) args[i]=intvalue(t_argv[i]);
else args[i] = 0; else args[i] = 0;
} }
t_return.value.i = LineSpecials[spec->number](NULL,Script->trigger,false, args[0],args[1],args[2],args[3],args[4]); t_return.value.i = P_ExecuteSpecial(spec->number, NULL,Script->trigger,false, args[0],args[1],args[2],args[3],args[4]);
} }
} }

View file

@ -332,7 +332,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BellReset1)
self->height <<= 2; self->height <<= 2;
if (self->special) if (self->special)
{ // Initiate death action { // Initiate death action
LineSpecials[self->special] (NULL, NULL, false, self->args[0], P_ExecuteSpecial(self->special, NULL, NULL, false, self->args[0],
self->args[1], self->args[2], self->args[3], self->args[4]); self->args[1], self->args[2], self->args[3], self->args[4]);
self->special = 0; self->special = 0;
} }

View file

@ -134,7 +134,7 @@ int ATelOtherFX1::DoSpecialDamage (AActor *target, int damage)
if (target->flags3 & MF3_ISMONSTER && target->special) if (target->flags3 & MF3_ISMONSTER && target->special)
{ {
target->RemoveFromHash (); target->RemoveFromHash ();
LineSpecials[target->special] (NULL, level.flags & LEVEL_ACTOWNSPECIAL P_ExecuteSpecial(target->special, NULL, level.flags & LEVEL_ACTOWNSPECIAL
? target : (AActor *)(this->target), false, target->args[0], target->args[1], ? target : (AActor *)(this->target), false, target->args[0], target->args[1],
target->args[2], target->args[3], target->args[4]); target->args[2], target->args[3], target->args[4]);
target->special = 0; target->special = 0;

View file

@ -191,7 +191,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeath)
} }
else if (self->flags3 & MF3_ISMONSTER && self->special) else if (self->flags3 & MF3_ISMONSTER && self->special)
{ // Initiate monster death actions { // Initiate monster death actions
LineSpecials [self->special] (NULL, self, false, self->args[0], P_ExecuteSpecial(self->special, NULL, self, false, self->args[0],
self->args[1], self->args[2], self->args[3], self->args[4]); self->args[1], self->args[2], self->args[3], self->args[4]);
self->special = 0; self->special = 0;
} }

View file

@ -350,7 +350,7 @@ void APathFollower::NewNode ()
while ( (spec = iterator.Next ()) ) while ( (spec = iterator.Next ()) )
{ {
LineSpecials[spec->special] (NULL, NULL, false, spec->args[0], P_ExecuteSpecial(spec->special, NULL, NULL, false, spec->args[0],
spec->args[1], spec->args[2], spec->args[3], spec->args[4]); spec->args[1], spec->args[2], spec->args[3], spec->args[4]);
} }
} }

View file

@ -951,7 +951,7 @@ void AInventory::DoPickupSpecial (AActor *toucher)
{ {
if (special) if (special)
{ {
LineSpecials[special] (NULL, toucher, false, P_ExecuteSpecial(special, NULL, toucher, false,
args[0], args[1], args[2], args[3], args[4]); args[0], args[1], args[2], args[3], args[4]);
special = 0; special = 0;
} }

View file

@ -97,7 +97,7 @@ bool ASectorAction::CheckTrigger (AActor *triggerer) const
((flags & MF_AMBUSH) && (triggerer->flags2 & MF2_MCROSS)) || ((flags & MF_AMBUSH) && (triggerer->flags2 & MF2_MCROSS)) ||
((flags2 & MF2_DORMANT) && (triggerer->flags2 & MF2_PCROSS)))) ((flags2 & MF2_DORMANT) && (triggerer->flags2 & MF2_PCROSS))))
{ {
bool res = !!LineSpecials[special] (NULL, triggerer, false, args[0], args[1], bool res = !!P_ExecuteSpecial(special, NULL, triggerer, false, args[0], args[1],
args[2], args[3], args[4]); args[2], args[3], args[4]);
return res; return res;
} }

View file

@ -474,7 +474,13 @@ void P_Recalculate3DFloors(sector_t * sector)
oldlist.Delete(pickindex); oldlist.Delete(pickindex);
if (pick->flags&(FF_SWIMMABLE|FF_TRANSLUCENT) && pick->flags&FF_EXISTS) if (pick->flags & FF_THISINSIDE)
{
// These have the floor higher than the ceiling and cannot be processed
// by the clipping code below.
ffloors.Push(pick);
}
else if (pick->flags&(FF_SWIMMABLE|FF_TRANSLUCENT) && pick->flags&FF_EXISTS)
{ {
clipped=pick; clipped=pick;
clipped_top=height; clipped_top=height;

View file

@ -761,7 +761,7 @@ void DPlaneWatcher::Tick ()
if ((LastD < WatchD && newd >= WatchD) || if ((LastD < WatchD && newd >= WatchD) ||
(LastD > WatchD && newd <= WatchD)) (LastD > WatchD && newd <= WatchD))
{ {
LineSpecials[Special] (Line, Activator, LineSide, Arg0, Arg1, Arg2, Arg3, Arg4); P_ExecuteSpecial(Special, Line, Activator, LineSide, Arg0, Arg1, Arg2, Arg3, Arg4);
Destroy (); Destroy ();
} }
@ -3760,39 +3760,39 @@ int DLevelScript::RunScript ()
break; break;
case PCD_LSPEC1: case PCD_LSPEC1:
LineSpecials[NEXTBYTE] (activationline, activator, backSide, P_ExecuteSpecial(NEXTBYTE, activationline, activator, backSide,
STACK(1), 0, 0, 0, 0); STACK(1), 0, 0, 0, 0);
sp -= 1; sp -= 1;
break; break;
case PCD_LSPEC2: case PCD_LSPEC2:
LineSpecials[NEXTBYTE] (activationline, activator, backSide, P_ExecuteSpecial(NEXTBYTE, activationline, activator, backSide,
STACK(2), STACK(1), 0, 0, 0); STACK(2), STACK(1), 0, 0, 0);
sp -= 2; sp -= 2;
break; break;
case PCD_LSPEC3: case PCD_LSPEC3:
LineSpecials[NEXTBYTE] (activationline, activator, backSide, P_ExecuteSpecial(NEXTBYTE, activationline, activator, backSide,
STACK(3), STACK(2), STACK(1), 0, 0); STACK(3), STACK(2), STACK(1), 0, 0);
sp -= 3; sp -= 3;
break; break;
case PCD_LSPEC4: case PCD_LSPEC4:
LineSpecials[NEXTBYTE] (activationline, activator, backSide, P_ExecuteSpecial(NEXTBYTE, activationline, activator, backSide,
STACK(4), STACK(3), STACK(2), STACK(4), STACK(3), STACK(2),
STACK(1), 0); STACK(1), 0);
sp -= 4; sp -= 4;
break; break;
case PCD_LSPEC5: case PCD_LSPEC5:
LineSpecials[NEXTBYTE] (activationline, activator, backSide, P_ExecuteSpecial(NEXTBYTE, activationline, activator, backSide,
STACK(5), STACK(4), STACK(3), STACK(5), STACK(4), STACK(3),
STACK(2), STACK(1)); STACK(2), STACK(1));
sp -= 5; sp -= 5;
break; break;
case PCD_LSPEC5RESULT: case PCD_LSPEC5RESULT:
STACK(5) = LineSpecials[NEXTBYTE] (activationline, activator, backSide, STACK(5) = P_ExecuteSpecial(NEXTBYTE, activationline, activator, backSide,
STACK(5), STACK(4), STACK(3), STACK(5), STACK(4), STACK(3),
STACK(2), STACK(1)); STACK(2), STACK(1));
sp -= 4; sp -= 4;
@ -3800,66 +3800,66 @@ int DLevelScript::RunScript ()
case PCD_LSPEC1DIRECT: case PCD_LSPEC1DIRECT:
temp = NEXTBYTE; temp = NEXTBYTE;
LineSpecials[temp] (activationline, activator, backSide, P_ExecuteSpecial(temp, activationline, activator, backSide,
uallong(pc[0]), 0, 0, 0, 0); uallong(pc[0]), 0, 0, 0, 0);
pc += 1; pc += 1;
break; break;
case PCD_LSPEC2DIRECT: case PCD_LSPEC2DIRECT:
temp = NEXTBYTE; temp = NEXTBYTE;
LineSpecials[temp] (activationline, activator, backSide, P_ExecuteSpecial(temp, activationline, activator, backSide,
uallong(pc[0]), uallong(pc[1]), 0, 0, 0); uallong(pc[0]), uallong(pc[1]), 0, 0, 0);
pc += 2; pc += 2;
break; break;
case PCD_LSPEC3DIRECT: case PCD_LSPEC3DIRECT:
temp = NEXTBYTE; temp = NEXTBYTE;
LineSpecials[temp] (activationline, activator, backSide, P_ExecuteSpecial(temp, activationline, activator, backSide,
uallong(pc[0]), uallong(pc[1]), uallong(pc[2]), 0, 0); uallong(pc[0]), uallong(pc[1]), uallong(pc[2]), 0, 0);
pc += 3; pc += 3;
break; break;
case PCD_LSPEC4DIRECT: case PCD_LSPEC4DIRECT:
temp = NEXTBYTE; temp = NEXTBYTE;
LineSpecials[temp] (activationline, activator, backSide, P_ExecuteSpecial(temp, activationline, activator, backSide,
uallong(pc[0]), uallong(pc[1]), uallong(pc[2]), uallong(pc[3]), 0); uallong(pc[0]), uallong(pc[1]), uallong(pc[2]), uallong(pc[3]), 0);
pc += 4; pc += 4;
break; break;
case PCD_LSPEC5DIRECT: case PCD_LSPEC5DIRECT:
temp = NEXTBYTE; temp = NEXTBYTE;
LineSpecials[temp] (activationline, activator, backSide, P_ExecuteSpecial(temp, activationline, activator, backSide,
uallong(pc[0]), uallong(pc[1]), uallong(pc[2]), uallong(pc[3]), uallong(pc[4])); uallong(pc[0]), uallong(pc[1]), uallong(pc[2]), uallong(pc[3]), uallong(pc[4]));
pc += 5; pc += 5;
break; break;
case PCD_LSPEC1DIRECTB: case PCD_LSPEC1DIRECTB:
LineSpecials[((BYTE *)pc)[0]] (activationline, activator, backSide, P_ExecuteSpecial(((BYTE *)pc)[0], activationline, activator, backSide,
((BYTE *)pc)[1], 0, 0, 0, 0); ((BYTE *)pc)[1], 0, 0, 0, 0);
pc = (int *)((BYTE *)pc + 2); pc = (int *)((BYTE *)pc + 2);
break; break;
case PCD_LSPEC2DIRECTB: case PCD_LSPEC2DIRECTB:
LineSpecials[((BYTE *)pc)[0]] (activationline, activator, backSide, P_ExecuteSpecial(((BYTE *)pc)[0], activationline, activator, backSide,
((BYTE *)pc)[1], ((BYTE *)pc)[2], 0, 0, 0); ((BYTE *)pc)[1], ((BYTE *)pc)[2], 0, 0, 0);
pc = (int *)((BYTE *)pc + 3); pc = (int *)((BYTE *)pc + 3);
break; break;
case PCD_LSPEC3DIRECTB: case PCD_LSPEC3DIRECTB:
LineSpecials[((BYTE *)pc)[0]] (activationline, activator, backSide, P_ExecuteSpecial(((BYTE *)pc)[0], activationline, activator, backSide,
((BYTE *)pc)[1], ((BYTE *)pc)[2], ((BYTE *)pc)[3], 0, 0); ((BYTE *)pc)[1], ((BYTE *)pc)[2], ((BYTE *)pc)[3], 0, 0);
pc = (int *)((BYTE *)pc + 4); pc = (int *)((BYTE *)pc + 4);
break; break;
case PCD_LSPEC4DIRECTB: case PCD_LSPEC4DIRECTB:
LineSpecials[((BYTE *)pc)[0]] (activationline, activator, backSide, P_ExecuteSpecial(((BYTE *)pc)[0], activationline, activator, backSide,
((BYTE *)pc)[1], ((BYTE *)pc)[2], ((BYTE *)pc)[3], ((BYTE *)pc)[1], ((BYTE *)pc)[2], ((BYTE *)pc)[3],
((BYTE *)pc)[4], 0); ((BYTE *)pc)[4], 0);
pc = (int *)((BYTE *)pc + 5); pc = (int *)((BYTE *)pc + 5);
break; break;
case PCD_LSPEC5DIRECTB: case PCD_LSPEC5DIRECTB:
LineSpecials[((BYTE *)pc)[0]] (activationline, activator, backSide, P_ExecuteSpecial(((BYTE *)pc)[0], activationline, activator, backSide,
((BYTE *)pc)[1], ((BYTE *)pc)[2], ((BYTE *)pc)[3], ((BYTE *)pc)[1], ((BYTE *)pc)[2], ((BYTE *)pc)[3],
((BYTE *)pc)[4], ((BYTE *)pc)[5]); ((BYTE *)pc)[4], ((BYTE *)pc)[5]);
pc = (int *)((BYTE *)pc + 6); pc = (int *)((BYTE *)pc + 6);

View file

@ -1302,7 +1302,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply
if (reply->ActionSpecial != 0) if (reply->ActionSpecial != 0)
{ {
takestuff |= !!LineSpecials[reply->ActionSpecial](NULL, player->mo, false, takestuff |= !!P_ExecuteSpecial(reply->ActionSpecial, NULL, player->mo, false,
reply->Args[0], reply->Args[1], reply->Args[2], reply->Args[3], reply->Args[4]); reply->Args[0], reply->Args[1], reply->Args[2], reply->Args[3], reply->Args[4]);
} }

View file

@ -2295,7 +2295,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
// as the goal. // as the goal.
while ( (spec = specit.Next()) ) while ( (spec = specit.Next()) )
{ {
LineSpecials[spec->special] (NULL, actor, false, spec->args[0], P_ExecuteSpecial(spec->special, NULL, actor, false, spec->args[0],
spec->args[1], spec->args[2], spec->args[3], spec->args[4]); spec->args[1], spec->args[2], spec->args[3], spec->args[4]);
} }
@ -3134,7 +3134,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BossDeath)
} }
checked = true; checked = true;
LineSpecials[sa->Action](NULL, self, false, P_ExecuteSpecial(sa->Action, NULL, self, false,
sa->Args[0], sa->Args[1], sa->Args[2], sa->Args[3], sa->Args[4]); sa->Args[0], sa->Args[1], sa->Args[2], sa->Args[3], sa->Args[4]);
} }
} }

View file

@ -3400,3 +3400,27 @@ int P_FindLineSpecial (const char *string, int *min_args, int *max_args)
} }
return 0; return 0;
} }
//==========================================================================
//
// P_ExecuteSpecial
//
//==========================================================================
int P_ExecuteSpecial(int num,
struct line_t *line,
class AActor *activator,
bool backSide,
int arg1,
int arg2,
int arg3,
int arg4,
int arg5)
{
if (num >= 0 && num <= 255)
{
return LineSpecials[num](line, activator, backSide, arg1, arg2, arg3, arg4, arg5);
}
return 0;
}

View file

@ -199,5 +199,14 @@ extern lnSpecFunc LineSpecials[256];
int P_FindLineSpecial (const char *string, int *min_args=NULL, int *max_args=NULL); int P_FindLineSpecial (const char *string, int *min_args=NULL, int *max_args=NULL);
bool P_ActivateThingSpecial(AActor * thing, AActor * trigger, bool death=false); bool P_ActivateThingSpecial(AActor * thing, AActor * trigger, bool death=false);
int P_ExecuteSpecial(int num,
struct line_t *line,
class AActor *activator,
bool backSide,
int arg1,
int arg2,
int arg3,
int arg4,
int arg5);
#endif //__P_LNSPEC_H__ #endif //__P_LNSPEC_H__

View file

@ -5532,7 +5532,7 @@ bool P_ActivateThingSpecial(AActor * thing, AActor * trigger, bool death)
// Run the special, if any // Run the special, if any
if (thing->special) if (thing->special)
{ {
res = !! LineSpecials[thing->special] (NULL, res = !! P_ExecuteSpecial(thing->special, NULL,
// TriggerActs overrides the level flag, which only concerns thing activated by death // TriggerActs overrides the level flag, which only concerns thing activated by death
(((death && level.flags & LEVEL_ACTOWNSPECIAL && !(thing->activationtype & THINGSPEC_TriggerActs)) (((death && level.flags & LEVEL_ACTOWNSPECIAL && !(thing->activationtype & THINGSPEC_TriggerActs))
|| (thing->activationtype & THINGSPEC_ThingActs)) // Who triggers? || (thing->activationtype & THINGSPEC_ThingActs)) // Who triggers?

View file

@ -222,8 +222,8 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType)
lineActivation = line->activation; lineActivation = line->activation;
repeat = line->flags & ML_REPEAT_SPECIAL; repeat = line->flags & ML_REPEAT_SPECIAL;
buttonSuccess = false; buttonSuccess = false;
buttonSuccess = LineSpecials[line->special] buttonSuccess = P_ExecuteSpecial(line->special,
(line, mo, side == 1, line->args[0], line, mo, side == 1, line->args[0],
line->args[1], line->args[2], line->args[1], line->args[2],
line->args[3], line->args[4]); line->args[3], line->args[4]);

View file

@ -79,7 +79,7 @@ public:
bool TryPickup (AActor *&toucher) bool TryPickup (AActor *&toucher)
{ {
INTBOOL success = LineSpecials[special] (NULL, toucher, false, INTBOOL success = P_ExecuteSpecial(special, NULL, toucher, false,
args[0], args[1], args[2], args[3], args[4]); args[0], args[1], args[2], args[3], args[4]);
if (success) if (success)

View file

@ -671,7 +671,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CallSpecial)
ACTION_PARAM_INT(arg4, 4); ACTION_PARAM_INT(arg4, 4);
ACTION_PARAM_INT(arg5, 5); ACTION_PARAM_INT(arg5, 5);
bool res = !!LineSpecials[special](NULL, self, false, arg1, arg2, arg3, arg4, arg5); bool res = !!P_ExecuteSpecial(special, NULL, self, false, arg1, arg2, arg3, arg4, arg5);
ACTION_SET_RESULT(res); ACTION_SET_RESULT(res);
} }
@ -3555,7 +3555,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LineEffect)
{ {
oldjunk.tag = tag; // Sector tag for linedef oldjunk.tag = tag; // Sector tag for linedef
P_TranslateLineDef(&junk, &oldjunk); // Turn into native type P_TranslateLineDef(&junk, &oldjunk); // Turn into native type
res = !!LineSpecials[junk.special](NULL, self, false, junk.args[0], res = !!P_ExecuteSpecial(junk.special, NULL, self, false, junk.args[0],
junk.args[1], junk.args[2], junk.args[3], junk.args[4]); junk.args[1], junk.args[2], junk.args[3], junk.args[4]);
if (res && !(junk.flags & ML_REPEAT_SPECIAL)) // If only once, if (res && !(junk.flags & ML_REPEAT_SPECIAL)) // If only once,
self->flags6 |= MF6_LINEDONE; // no more for this thing self->flags6 |= MF6_LINEDONE; // no more for this thing

View file

@ -2415,7 +2415,7 @@ ExpVal FxActionSpecialCall::EvalExpression (AActor *self)
} }
ExpVal ret; ExpVal ret;
ret.Type = VAL_Int; ret.Type = VAL_Int;
ret.Int = LineSpecials[Special](NULL, self, false, v[0], v[1], v[2], v[3], v[4]); ret.Int = P_ExecuteSpecial(Special, NULL, self, false, v[0], v[1], v[2], v[3], v[4]);
return ret; return ret;
} }