- Macro-fied access to action function parameters.

- Deactivated debug output code in d_Dehacked.cpp.
- fixed: A_FreezeDeathChunks crashed when a player's head got spawned.


SVN r1168 (trunk)
This commit is contained in:
Christoph Oelckers 2008-08-13 22:54:24 +00:00
parent db5a6e3d24
commit 1c034c1150
25 changed files with 439 additions and 557 deletions

View file

@ -1,8 +1,10 @@
August 12, 2008 (Changes by Graf Zahl)
August 13, 2008 (Changes by Graf Zahl)
- Macro-fied access to action function parameters.
- Deactivated debug output code in d_Dehacked.cpp.
- fixed: A_FreezeDeathChunks crashed when a player's head got spawned.
- fixed: A_CallSpecial must be declared in DECORATE so that a symbol table
entry can be generated for it.
- fixed: Dehacked replaced pickups multiple times for changing its states.
- fixed: Dehacked replaced pickups multiple times for changing its states.
- fixed: Dehacked must copy AInventory's state to any item it hacks to be a
pickup.
- fixed a few more DECORATE bugs.

View file

@ -2599,7 +2599,7 @@ void FinishDehPatch ()
type->ActorInfo->Replacement = subclass->ActorInfo;
subclass->ActorInfo->Replacee = type->ActorInfo;
Printf ("%s replaces %s\n", subclass->TypeName.GetChars(), type->TypeName.GetChars());
DPrintf ("%s replaces %s\n", subclass->TypeName.GetChars(), type->TypeName.GetChars());
}
// Now that all Dehacked patches have been processed, it's okay to free StateMap.

View file

@ -83,23 +83,20 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BrainSpit)
AActor *spit;
bool isdefault = false;
ACTION_PARAM_START(1);
ACTION_PARAM_CLASS(spawntype, 0);
// shoot a cube at current target
targ = state->GetNextInList(PClass::FindClass("BossTarget"), G_SkillProperty(SKILLP_EasyBossBrain));
if (targ != NULL)
{
const PClass *spawntype = NULL;
int index = CheckIndex (1);
if (index < 0) return;
spawntype = PClass::FindClass ((ENamedName)StateParameters[index]);
if (spawntype == NULL)
{
spawntype = PClass::FindClass("SpawnShot");
isdefault = true;
}
// spawn brain missile
spit = P_SpawnMissile (self, targ, spawntype);
@ -243,14 +240,11 @@ static void SpawnFly(AActor *self, const PClass *spawntype, FSoundID sound)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnFly)
{
const PClass *spawntype = NULL;
FSoundID sound;
int index = CheckIndex (1);
// First spawn teleport fire.
if (index < 0) return;
ACTION_PARAM_START(1);
ACTION_PARAM_CLASS(spawntype, 0);
spawntype = PClass::FindClass ((ENamedName)StateParameters[index]);
if (spawntype != NULL)
{
sound = GetDefaultByType(spawntype)->SeeSound;

View file

@ -99,13 +99,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePistol)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw)
{
angle_t angle;
int damage=0;
player_t *player;
AActor *linetarget;
FSoundID fullsound;
FSoundID hitsound;
const PClass * pufftype = NULL;
ACTION_PARAM_START(4);
ACTION_PARAM_SOUND(fullsound, 0);
ACTION_PARAM_SOUND(hitsound, 1);
ACTION_PARAM_INT(damage, 2);
ACTION_PARAM_CLASS(pufftype, 3);
if (NULL == (player = self->player))
{
@ -119,13 +120,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw)
return;
}
int index = CheckIndex (4);
if (index < 0) return;
fullsound = FSoundID(StateParameters[index]);
hitsound = FSoundID(StateParameters[index+1]);
damage = EvalExpressionI (StateParameters[index+2], self);
pufftype = PClass::FindClass ((ENamedName)StateParameters[index+3]);
if (pufftype == NULL) pufftype = PClass::FindClass(NAME_BulletPuff);
if (damage == 0) damage = 2;
@ -488,23 +482,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
int damage;
angle_t an;
AActor *thingToHit;
const PClass *spraytype = NULL;
int numrays = 40;
int damagecnt = 15;
AActor *linetarget;
int index = CheckIndex (3);
if (index < 0) return;
ACTION_PARAM_START(3);
ACTION_PARAM_CLASS(spraytype, 0);
ACTION_PARAM_INT(numrays, 1);
ACTION_PARAM_INT(damagecnt, 2);
spraytype = PClass::FindClass ((ENamedName)StateParameters[index]);
if (spraytype == NULL)
spraytype = PClass::FindClass("BFGExtra");
numrays = EvalExpressionI (StateParameters[index+1], self);
if (numrays <= 0)
numrays = 40;
damagecnt = EvalExpressionI (StateParameters[index+2], self);
if (damagecnt <= 0)
damagecnt = 15;
if (spraytype == NULL) spraytype = PClass::FindClass("BFGExtra");
if (numrays <= 0) numrays = 40;
if (damagecnt <= 0) damagecnt = 15;
// [RH] Don't crash if no target
if (!self->target)

View file

@ -29,9 +29,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack1)
if (!self->target)
return;
const PClass *spawntype = NULL;
int index = CheckIndex (1);
if (index >= 0) spawntype = PClass::FindClass ((ENamedName)StateParameters[index]);
ACTION_PARAM_START(1);
ACTION_PARAM_CLASS(spawntype, 0);
if (spawntype == NULL) spawntype = PClass::FindClass("FatShot");
A_FaceTarget (self);
@ -57,9 +57,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack2)
if (!self->target)
return;
const PClass *spawntype = NULL;
int index = CheckIndex (1);
if (index >= 0) spawntype = PClass::FindClass ((ENamedName)StateParameters[index]);
ACTION_PARAM_START(1);
ACTION_PARAM_CLASS(spawntype, 0);
if (spawntype == NULL) spawntype = PClass::FindClass("FatShot");
A_FaceTarget (self);
@ -85,9 +85,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack3)
if (!self->target)
return;
const PClass *spawntype = NULL;
int index = CheckIndex (1);
if (index >= 0) spawntype = PClass::FindClass ((ENamedName)StateParameters[index]);
ACTION_PARAM_START(1);
ACTION_PARAM_CLASS(spawntype, 0);
if (spawntype == NULL) spawntype = PClass::FindClass("FatShot");
A_FaceTarget (self);
@ -118,17 +118,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack3)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Mushroom)
{
int i, j, n = self->GetMissileDamage (0, 1);
int i, j;
const PClass *spawntype = NULL;
int index = CheckIndex (2);
if (index >= 0)
{
spawntype = PClass::FindClass((ENamedName)StateParameters[index]);
n = EvalExpressionI (StateParameters[index+1], self);
if (n == 0)
n = self->GetMissileDamage (0, 1);
}
ACTION_PARAM_START(2);
ACTION_PARAM_CLASS(spawntype, 0);
ACTION_PARAM_INT(n, 1);
if (n == 0) n = self->GetMissileDamage (0, 1);
if (spawntype == NULL) spawntype = PClass::FindClass("FatShot");
P_RadiusAttack (self, self->target, 128, 128, self->DamageType, true);

View file

@ -46,15 +46,10 @@ void A_SkullAttack(AActor *self, fixed_t speed)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullAttack)
{
int n = 0;
int index = CheckIndex (1);
if (index >= 0)
{
n = FLOAT2FIXED(EvalExpressionF (StateParameters[index], self));
}
if (n == 0) n = SKULLSPEED;
ACTION_PARAM_START(1);
ACTION_PARAM_FIXED(n, 0);
if (n <= 0) n = SKULLSPEED;
A_SkullAttack(self, n);
}

View file

@ -12,12 +12,9 @@ DECLARE_ACTION(A_SkullAttack)
static const PClass *GetSpawnType(DECLARE_PARAMINFO)
{
const PClass *spawntype = NULL;
int index=CheckIndex(1);
if (index>=0)
{
spawntype = PClass::FindClass((ENamedName)StateParameters[index]);
}
ACTION_PARAM_START(1);
ACTION_PARAM_CLASS(spawntype, 0);
if (spawntype == NULL) spawntype = PClass::FindClass("LostSoul");
return spawntype;
}

View file

@ -327,10 +327,10 @@ static void MarinePunch(AActor *self, int damagemul)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Punch)
{
int index=CheckIndex(1);
if (index<0) return;
ACTION_PARAM_START(1);
ACTION_PARAM_INT(mult, 0);
MarinePunch(self, EvalExpressionI (StateParameters[index], self));
MarinePunch(self, mult);
}
//============================================================================
@ -366,9 +366,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_FirePistol)
if (self->target == NULL)
return;
int index=CheckIndex(1);
if (index<0) return;
bool accurate = !!EvalExpressionI (StateParameters[index], self);
ACTION_PARAM_START(1);
ACTION_PARAM_BOOL(accurate, 0);
S_Sound (self, CHAN_WEAPON, "weapons/pistol", 1, ATTN_NORM);
A_FaceTarget (self);
@ -456,9 +455,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_FireCGun)
if (self->target == NULL)
return;
int index=CheckIndex(1);
if (index<0) return;
bool accurate = !!EvalExpressionI (StateParameters[index], self);
ACTION_PARAM_START(1);
ACTION_PARAM_BOOL(accurate, 0);
S_Sound (self, CHAN_WEAPON, "weapons/chngun", 1, ATTN_NORM);
A_FaceTarget (self);

View file

@ -62,7 +62,6 @@ extern bool P_AutoUseChaosDevice (player_t *player);
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack)
{
angle_t angle;
int damage;
int slope;
player_t *player;
AActor *linetarget;
@ -72,12 +71,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack)
return;
}
int index = CheckIndex (2);
if (index < 0) return;
damage = EvalExpressionI (StateParameters[index], self);
const PClass *puff = PClass::FindClass ((ENamedName)StateParameters[index+1]);
ACTION_PARAM_START(2);
ACTION_PARAM_INT(damage, 0);
ACTION_PARAM_CLASS(puff, 1);
AWeapon *weapon = player->ReadyWeapon;
if (weapon != NULL)
@ -242,7 +238,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack)
fixed_t dist;
player_t *player;
const PClass *pufftype;
int power;
AActor *linetarget;
if (NULL == (player = self->player))
@ -250,10 +245,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack)
return;
}
int index = CheckIndex (1);
if (index < 0) return;
power = EvalExpressionI (StateParameters[index], self);
ACTION_PARAM_START(1);
ACTION_PARAM_INT(power, 0);
AWeapon *weapon = player->ReadyWeapon;
if (weapon != NULL)

View file

@ -62,12 +62,14 @@ bool AFighterWeaponPiece::TryPickup (AActor *toucher)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropWeaponPieces)
{
int index=CheckIndex(3);
if (index<0) return;
ACTION_PARAM_START(3);
ACTION_PARAM_CLASS(p1, 0);
ACTION_PARAM_CLASS(p2, 1);
ACTION_PARAM_CLASS(p3, 2);
for (int i = 0, j = 0, fineang = 0; i < 3; ++i)
{
const PClass *cls = PClass::FindClass((ENamedName)StateParameters[index+j]);
const PClass *cls = j==0? p1 : j==1? p2 : p3;
if (cls)
{
AActor *piece = Spawn (cls, self->x, self->y, self->z, ALLOW_REPLACE);

View file

@ -275,8 +275,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks)
head->angle = self->angle;
if (head->IsKindOf(RUNTIME_CLASS(APlayerPawn)))
{
head->player->mo = static_cast<APlayerPawn*>(head);
head->player = self->player;
head->player->mo = static_cast<APlayerPawn*>(head);
self->player = NULL;
head->ObtainInventory (self);
}

View file

@ -100,26 +100,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit)
}
static const PClass *GetBallType(DECLARE_PARAMINFO)
{
const PClass *balltype = NULL;
int index=CheckIndex(1);
if (index>=0)
{
balltype = PClass::FindClass((ENamedName)StateParameters[index]);
}
if (balltype == NULL) balltype = PClass::FindClass("BridgeBall");
return balltype;
}
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit)
{
angle_t startangle;
AActor *ball;
fixed_t cx, cy, cz;
ACTION_PARAM_START(1);
ACTION_PARAM_CLASS(balltype, 0);
if (balltype == NULL) balltype = PClass::FindClass("BridgeBall");
cx = self->x;
cy = self->y;
cz = self->z;
@ -128,7 +119,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit)
// Spawn triad into world -- may be more than a triad now.
int ballcount = self->args[2]==0 ? 3 : self->args[2];
const PClass *balltype = GetBallType(PUSH_PARAMINFO);
for (int i = 0; i < ballcount; i++)
{
ball = Spawn(balltype, cx, cy, cz, ALLOW_REPLACE);

View file

@ -389,13 +389,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnSingleItem)
if (state != NULL) spot = state->GetRandomSpot(RUNTIME_TYPE(self), true);
if (spot == NULL) return;
int index=CheckIndex(4);
if (index<0) return;
ENamedName SpawnType = (ENamedName)StateParameters[index];
int fail_sp = EvalExpressionI (StateParameters[index+1], self);
int fail_co = EvalExpressionI (StateParameters[index+2], self);
int fail_dm = EvalExpressionI (StateParameters[index+3], self);
ACTION_PARAM_START(4);
ACTION_PARAM_CLASS(cls, 0);
ACTION_PARAM_INT(fail_sp, 1);
ACTION_PARAM_INT(fail_co, 2);
ACTION_PARAM_INT(fail_dm, 3);
if (!multiplayer && pr_spawnmace() < fail_sp)
{ // Sometimes doesn't show up if not in deathmatch
@ -411,7 +409,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnSingleItem)
{
return;
}
const PClass *cls = PClass::FindClass(SpawnType);
if (cls == NULL)
{
return;

View file

@ -215,10 +215,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireArrow)
{
angle_t savedangle;
int index=CheckIndex(1);
if (index<0) return;
ENamedName MissileName=(ENamedName)StateParameters[index];
ACTION_PARAM_START(1);
ACTION_PARAM_CLASS(ti, 0);
if (self->player == NULL)
return;
@ -230,7 +228,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireArrow)
return;
}
const PClass * ti=PClass::FindClass(MissileName);
if (ti)
{
savedangle = self->angle;
@ -634,32 +631,28 @@ DEFINE_ACTION_FUNCTION(AActor, A_Burnination)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade)
{
const PClass *grenadetype;
player_t *player = self->player;
AActor *grenade;
angle_t an;
fixed_t tworadii;
AWeapon *weapon;
int index=CheckIndex(3);
if (index<0) return;
ACTION_PARAM_START(3);
ACTION_PARAM_CLASS(grenadetype, 0);
ACTION_PARAM_ANGLE(Angle, 1);
ACTION_PARAM_STATE(flash, 2);
ENamedName MissileName=(ENamedName)StateParameters[index];
angle_t Angle=angle_t(EvalExpressionF (StateParameters[index+1], self) * ANGLE_1);
if (player == NULL)
if (player == NULL || grenadetype == NULL)
return;
if ((weapon = player->ReadyWeapon) == NULL)
return;
grenadetype = PClass::FindClass(MissileName);
if (!weapon->DepleteAmmo (weapon->bAltFire))
return;
// Make it flash
FState *jumpto = P_GetState(weapon, NULL, StateParameters[index + 2]);
FState *jumpto = P_GetState(weapon, NULL, flash);
P_SetPsprite (player, ps_flash, jumpto);

View file

@ -27,10 +27,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Bang4Cloud)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveQuestItem)
{
int index=CheckIndex(1);
if (index<0) return;
int questitem = EvalExpressionI (StateParameters[index], self);
ACTION_PARAM_START(1);
ACTION_PARAM_INT(questitem, 0);
// Give one of these quest items to every player in the game
for (int i = 0; i < MAXPLAYERS; ++i)

View file

@ -141,7 +141,7 @@ struct FState
{
if (ActionFunc != NULL)
{
ActionFunc(self, this, ParameterIndex);
ActionFunc(self, this, ParameterIndex-1);
return true;
}
else

View file

@ -2233,18 +2233,18 @@ enum ChaseFlags
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Chase)
{
int index=CheckIndex(3);
if (index < 0) return;
ACTION_PARAM_START(3);
ACTION_PARAM_STATE(i_melee, 0);
ACTION_PARAM_STATE(i_missile, 1);
ACTION_PARAM_INT(flags, 2);
if (StateParameters[index] != INT_MIN)
if (i_melee != INT_MIN)
{
FState *melee = P_GetState(self, CallingState, StateParameters[index]);
FState *missile = P_GetState(self, CallingState, StateParameters[index+1]);
FState *melee = P_GetState(self, CallingState, i_melee);
FState *missile = P_GetState(self, CallingState, i_missile);
int flags = EvalExpressionI (StateParameters[index+2], self);
if (flags & CHF_RESURRECT && P_CheckForResurrection(self, false)) return;
A_DoChase(self, !!(flags&CHF_FASTCHASE), melee, missile, !(flags&CHF_NOPLAYACTIVE),
!!(flags&CHF_NIGHTMAREFAST), !!(flags&CHF_DONTMOVE));
}
@ -2267,15 +2267,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_VileChase)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ExtChase)
{
// Now that A_Chase can handle state label parameters, this function has become rather useless...
int index=CheckIndex(4);
if (index<0) return;
ACTION_PARAM_START(4);
ACTION_PARAM_BOOL(domelee, 0);
ACTION_PARAM_BOOL(domissile, 1);
ACTION_PARAM_BOOL(playactive, 2);
ACTION_PARAM_BOOL(nightmarefast, 3);
// Now that A_Chase can handle state label parameters, this function has become rather useless...
A_DoChase(self, false,
EvalExpressionI (StateParameters[index], self) ? self->MeleeState:NULL,
EvalExpressionI (StateParameters[index+1], self) ? self->MissileState:NULL,
!!EvalExpressionI (StateParameters[index+2], self),
!!EvalExpressionI (StateParameters[index+3], self), false);
domelee ? self->MeleeState:NULL, domissile ? self->MissileState:NULL,
playactive, nightmarefast, false);
}
// for internal use
@ -2592,19 +2593,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_Pain)
// killough 11/98: kill an object
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Die)
{
ENamedName name;
ACTION_PARAM_START(1);
ACTION_PARAM_NAME(damagetype, 0);
int index=CheckIndex(1);
if (index<0)
{
name = NAME_None;
}
else
{
name = ENamedName(StateParameters[index]);
}
P_DamageMobj (self, NULL, NULL, self->health, name);
P_DamageMobj (self, NULL, NULL, self->health, damagetype);
}
//

View file

@ -715,18 +715,15 @@ enum LO_Flags
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
{
int index=CheckIndex(6);
if (index<0) return;
ACTION_PARAM_START(6);
ACTION_PARAM_INT(flags, 0);
ACTION_PARAM_FIXED(minseedist, 1);
ACTION_PARAM_FIXED(maxseedist, 2);
ACTION_PARAM_FIXED(maxheardist, 3);
ACTION_PARAM_ANGLE(fov, 4);
ACTION_PARAM_STATE(i_state, 5);
int flags = EvalExpressionI (StateParameters[index], self);
//if ((flags & LOF_NOSIGHTCHECK) && (flags & LOF_NOSOUNDCHECK)) return; // [KS] Can't see and can't hear so it'd be redundant to continue with a check we know would be false.
//But it can still be used to make an self leave to a goal without waking up immediately under certain conditions.
fixed_t minseedist = fixed_t(EvalExpressionF (StateParameters[index+1], self) * FRACUNIT);
fixed_t maxseedist = fixed_t(EvalExpressionF (StateParameters[index+2], self) * FRACUNIT);
fixed_t maxheardist = fixed_t(EvalExpressionF (StateParameters[index+3], self) * FRACUNIT);
angle_t fov = angle_t(EvalExpressionF (StateParameters[index+4], self) * ANGLE_1);
FState *seestate = P_GetState(self, CallingState, StateParameters[index+5]);
FState *seestate = P_GetState(self, CallingState, i_state);
AActor *targ = NULL; // Shuts up gcc
fixed_t dist;

View file

@ -707,11 +707,12 @@ DEFINE_ACTION_FUNCTION(AInventory, A_Light2)
DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_Light)
{
int index=CheckIndex(1);
ACTION_PARAM_START(1);
ACTION_PARAM_INT(light, 0);
if (self->player != NULL && index > 0)
if (self->player != NULL)
{
self->player->extralight = clamp<int>(EvalExpressionI (StateParameters[index], self), 0, 20);
self->player->extralight = clamp<int>(light, 0, 20);
}
}

View file

@ -1239,14 +1239,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullPop)
{
ACTION_PARAM_START(1);
ACTION_PARAM_CLASS(spawntype, 0);
APlayerPawn *mo;
player_t *player;
// [GRB] Parameterized version
const PClass *spawntype = NULL;
int index = CheckIndex (1);
if (index >= 0)
spawntype = PClass::FindClass((ENamedName)StateParameters[index]);
if (!spawntype || !spawntype->IsDescendantOf (RUNTIME_CLASS (APlayerChunk)))
{
spawntype = PClass::FindClass("BloodySkull");

View file

@ -126,6 +126,7 @@ int ParseExpression (FScanner &sc, bool _not, PClass *cls);
bool IsExpressionConst(int id);
int EvalExpressionI (int id, AActor *self, const PClass *cls=NULL);
float EvalExpressionF (int id, AActor *self, const PClass *cls=NULL);
fixed_t EvalExpressionFix (int id, AActor *self, const PClass *cls=NULL);
enum
@ -186,30 +187,32 @@ enum EDefinitionType
#define CALL_ACTION(name,self) AF_##name(self, NULL, 0)
#define CheckIndex(count) (ParameterIndex-1)
#define ACTION_PARAM_START(count)
#define ACTION_PARAM_START(count) \
int ap_index_ = CheckIndex(count); \
if (ap_index_ <= 0) return;
#define ACTION_PARAM_INT(var, i) \
int var = EvalExpressionI(StateParameters[ParameterIndex+i], self);
#define ACTION_PARAM_BOOL(var,i) \
bool var = !!EvalExpressionI(StateParameters[ParameterIndex+i], self);
#define ACTION_PARAM_FIXED(var,i) \
fixed_t var = EvalExpressionFix(StateParameters[ParameterIndex+i], self);
#define ACTION_PARAM_FLOAT(var,i) \
float var = EvalExpressionF(StateParameters[ParameterIndex+i], self);
#define ACTION_PARAM_CLASS(var,i) \
const PClass *var = PClass::FindClass(ENamedName(StateParameters[ParameterIndex+i]));
#define ACTION_PARAM_STATE(var,i) \
int var = StateParameters[ParameterIndex+i];
#define ACTION_PARAM_COLOR(var,i) \
PalEntry var = StateParameters[ParameterIndex+i];
#define ACTION_PARAM_SOUND(var,i) \
FSoundID var = StateParameters[ParameterIndex+i];
#define ACTION_PARAM_STRING(var,i) \
const char *var = FName(ENamedName(StateParameters[ParameterIndex+i]));
#define ACTION_PARAM_NAME(var,i) \
FName var = ENamedName(StateParameters[ParameterIndex+i]);
#define ACTION_PARAM_VARARG(var, i) \
int *var = &StateParameters[ParameterIndex+i];
#define ACTION_PARAM_START_OPTIONAL(count) \
int ap_index_ = CheckIndex(count);
#define ACTION_PARAM_INT(var) \
int var = EvalExpressionI(StateParameters[ap_index_++], self);
#define ACTION_PARAM_BOOL(var) \
bool var = !!EvalExpressionI(StateParameters[ap_index_++], self);
#define ACTION_PARAM_FIXED(var) \
fixed_t var = fixed_t(EvalExpressionF(StateParameters[ap_index_++], self)*65536.f);
#define ACTION_PARAM_FLOAT(var) \
float var = EvalExpressionF(StateParameters[ap_index_++], self);
#define ACTION_PARAM_CLASS(var) \
const PClass *var = PClass::FindClass(ENamedName(StateParameters[ap_index_++]));
#define ACTION_PARAM_STATE(var) \
int var = StateParameters[ap_index_++];
#define ACTION_PARAM_SOUND(var) \
FSoundID var = StateParameters[ap_index_++];
#define ACTION_PARAM_STRING(var) \
const char *var = FName(ENamedName(StateParameters[ap_index_++]));
#define ACTION_PARAM_ANGLE(var,i) \
angle_t var = angle_t(EvalExpressionF(StateParameters[ParameterIndex+i], self)*ANGLE_90/90.f);
#endif

File diff suppressed because it is too large Load diff

View file

@ -953,6 +953,27 @@ float EvalExpressionF (int id, AActor *self, const PClass *cls)
}
}
fixed_t EvalExpressionFix (int id, AActor *self, const PClass *cls)
{
if (StateExpressions.Size() <= (unsigned int)id) return 0;
if (cls == NULL && self != NULL)
{
cls = self->GetClass();
}
ExpVal val = EvalExpression (StateExpressions[id], self, cls);
switch (val.Type)
{
default:
case VAL_Int:
return val.Int << FRACBITS;
case VAL_Float:
return fixed_t(val.Float*FRACUNIT);
}
}
static ExpVal EvalExpression (ExpData *data, AActor *self, const PClass *cls)
{
ExpVal val;

View file

@ -458,10 +458,9 @@ static void HandleDeprecatedFlags(AActor *defaults, bool set, int index)
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeFlag)
{
int index=CheckIndex(2);
if (index < 0) return;
const char * flagname = FName((ENamedName)StateParameters[index]).GetChars();
int expression = EvalExpressionI (StateParameters[index+1], self);
ACTION_PARAM_START(2);
ACTION_PARAM_STRING(flagname, 0);
ACTION_PARAM_BOOL(expression, 1);
const char *dot = strchr (flagname, '.');
flagdef *fd;
@ -480,7 +479,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeFlag)
{
if (fd->structoffset == -1)
{
HandleDeprecatedFlags(self, !!expression, fd->flagbit);
HandleDeprecatedFlags(self, expression, fd->flagbit);
}
else
{

View file

@ -67,8 +67,6 @@ static TArray<FState> StateArray;
//
//==========================================================================
DECLARE_ACTION(A_CallSpecial)
//==========================================================================
//
// Find a function by name using a binary search