- 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 - fixed: A_CallSpecial must be declared in DECORATE so that a symbol table
entry can be generated for it. 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 replaced pickups multiple times for changing its states.
- fixed: Dehacked must copy AInventory's state to any item it hacks to be a - fixed: Dehacked must copy AInventory's state to any item it hacks to be a
pickup. pickup.
- fixed a few more DECORATE bugs. - fixed a few more DECORATE bugs.

View file

@ -2599,7 +2599,7 @@ void FinishDehPatch ()
type->ActorInfo->Replacement = subclass->ActorInfo; type->ActorInfo->Replacement = subclass->ActorInfo;
subclass->ActorInfo->Replacee = type->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. // 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; AActor *spit;
bool isdefault = false; bool isdefault = false;
ACTION_PARAM_START(1);
ACTION_PARAM_CLASS(spawntype, 0);
// shoot a cube at current target // shoot a cube at current target
targ = state->GetNextInList(PClass::FindClass("BossTarget"), G_SkillProperty(SKILLP_EasyBossBrain)); targ = state->GetNextInList(PClass::FindClass("BossTarget"), G_SkillProperty(SKILLP_EasyBossBrain));
if (targ != NULL) if (targ != NULL)
{ {
const PClass *spawntype = NULL;
int index = CheckIndex (1);
if (index < 0) return;
spawntype = PClass::FindClass ((ENamedName)StateParameters[index]);
if (spawntype == NULL) if (spawntype == NULL)
{ {
spawntype = PClass::FindClass("SpawnShot"); spawntype = PClass::FindClass("SpawnShot");
isdefault = true; isdefault = true;
} }
// spawn brain missile // spawn brain missile
spit = P_SpawnMissile (self, targ, spawntype); 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) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnFly)
{ {
const PClass *spawntype = NULL;
FSoundID sound; FSoundID sound;
int index = CheckIndex (1); ACTION_PARAM_START(1);
// First spawn teleport fire. ACTION_PARAM_CLASS(spawntype, 0);
if (index < 0) return;
spawntype = PClass::FindClass ((ENamedName)StateParameters[index]);
if (spawntype != NULL) if (spawntype != NULL)
{ {
sound = GetDefaultByType(spawntype)->SeeSound; sound = GetDefaultByType(spawntype)->SeeSound;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -62,12 +62,14 @@ bool AFighterWeaponPiece::TryPickup (AActor *toucher)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropWeaponPieces) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropWeaponPieces)
{ {
int index=CheckIndex(3); ACTION_PARAM_START(3);
if (index<0) return; 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) 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) if (cls)
{ {
AActor *piece = Spawn (cls, self->x, self->y, self->z, ALLOW_REPLACE); 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; head->angle = self->angle;
if (head->IsKindOf(RUNTIME_CLASS(APlayerPawn))) if (head->IsKindOf(RUNTIME_CLASS(APlayerPawn)))
{ {
head->player->mo = static_cast<APlayerPawn*>(head);
head->player = self->player; head->player = self->player;
head->player->mo = static_cast<APlayerPawn*>(head);
self->player = NULL; self->player = NULL;
head->ObtainInventory (self); 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) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit)
{ {
angle_t startangle; angle_t startangle;
AActor *ball; AActor *ball;
fixed_t cx, cy, cz; fixed_t cx, cy, cz;
ACTION_PARAM_START(1);
ACTION_PARAM_CLASS(balltype, 0);
if (balltype == NULL) balltype = PClass::FindClass("BridgeBall");
cx = self->x; cx = self->x;
cy = self->y; cy = self->y;
cz = self->z; 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. // Spawn triad into world -- may be more than a triad now.
int ballcount = self->args[2]==0 ? 3 : self->args[2]; int ballcount = self->args[2]==0 ? 3 : self->args[2];
const PClass *balltype = GetBallType(PUSH_PARAMINFO);
for (int i = 0; i < ballcount; i++) for (int i = 0; i < ballcount; i++)
{ {
ball = Spawn(balltype, cx, cy, cz, ALLOW_REPLACE); 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 (state != NULL) spot = state->GetRandomSpot(RUNTIME_TYPE(self), true);
if (spot == NULL) return; if (spot == NULL) return;
int index=CheckIndex(4); ACTION_PARAM_START(4);
if (index<0) return; ACTION_PARAM_CLASS(cls, 0);
ACTION_PARAM_INT(fail_sp, 1);
ENamedName SpawnType = (ENamedName)StateParameters[index]; ACTION_PARAM_INT(fail_co, 2);
int fail_sp = EvalExpressionI (StateParameters[index+1], self); ACTION_PARAM_INT(fail_dm, 3);
int fail_co = EvalExpressionI (StateParameters[index+2], self);
int fail_dm = EvalExpressionI (StateParameters[index+3], self);
if (!multiplayer && pr_spawnmace() < fail_sp) if (!multiplayer && pr_spawnmace() < fail_sp)
{ // Sometimes doesn't show up if not in deathmatch { // Sometimes doesn't show up if not in deathmatch
@ -411,7 +409,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnSingleItem)
{ {
return; return;
} }
const PClass *cls = PClass::FindClass(SpawnType);
if (cls == NULL) if (cls == NULL)
{ {
return; return;

View file

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

View file

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

View file

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

View file

@ -2233,17 +2233,17 @@ enum ChaseFlags
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Chase) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Chase)
{ {
int index=CheckIndex(3); ACTION_PARAM_START(3);
if (index < 0) return; 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 *melee = P_GetState(self, CallingState, i_melee);
FState *missile = P_GetState(self, CallingState, StateParameters[index+1]); FState *missile = P_GetState(self, CallingState, i_missile);
int flags = EvalExpressionI (StateParameters[index+2], self);
if (flags & CHF_RESURRECT && P_CheckForResurrection(self, false)) return; if (flags & CHF_RESURRECT && P_CheckForResurrection(self, false)) return;
A_DoChase(self, !!(flags&CHF_FASTCHASE), melee, missile, !(flags&CHF_NOPLAYACTIVE), A_DoChase(self, !!(flags&CHF_FASTCHASE), melee, missile, !(flags&CHF_NOPLAYACTIVE),
!!(flags&CHF_NIGHTMAREFAST), !!(flags&CHF_DONTMOVE)); !!(flags&CHF_NIGHTMAREFAST), !!(flags&CHF_DONTMOVE));
@ -2267,15 +2267,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_VileChase)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ExtChase) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ExtChase)
{ {
// Now that A_Chase can handle state label parameters, this function has become rather useless... ACTION_PARAM_START(4);
int index=CheckIndex(4); ACTION_PARAM_BOOL(domelee, 0);
if (index<0) return; 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, A_DoChase(self, false,
EvalExpressionI (StateParameters[index], self) ? self->MeleeState:NULL, domelee ? self->MeleeState:NULL, domissile ? self->MissileState:NULL,
EvalExpressionI (StateParameters[index+1], self) ? self->MissileState:NULL, playactive, nightmarefast, false);
!!EvalExpressionI (StateParameters[index+2], self),
!!EvalExpressionI (StateParameters[index+3], self), false);
} }
// for internal use // for internal use
@ -2592,19 +2593,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_Pain)
// killough 11/98: kill an object // killough 11/98: kill an object
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Die) 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) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
{ {
int index=CheckIndex(6); ACTION_PARAM_START(6);
if (index<0) return; 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); FState *seestate = P_GetState(self, CallingState, i_state);
//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]);
AActor *targ = NULL; // Shuts up gcc AActor *targ = NULL; // Shuts up gcc
fixed_t dist; fixed_t dist;

View file

@ -707,11 +707,12 @@ DEFINE_ACTION_FUNCTION(AInventory, A_Light2)
DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_Light) 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) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullPop)
{ {
ACTION_PARAM_START(1);
ACTION_PARAM_CLASS(spawntype, 0);
APlayerPawn *mo; APlayerPawn *mo;
player_t *player; player_t *player;
// [GRB] Parameterized version // [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))) if (!spawntype || !spawntype->IsDescendantOf (RUNTIME_CLASS (APlayerChunk)))
{ {
spawntype = PClass::FindClass("BloodySkull"); spawntype = PClass::FindClass("BloodySkull");

View file

@ -126,6 +126,7 @@ int ParseExpression (FScanner &sc, bool _not, PClass *cls);
bool IsExpressionConst(int id); bool IsExpressionConst(int id);
int EvalExpressionI (int id, AActor *self, const PClass *cls=NULL); int EvalExpressionI (int id, AActor *self, const PClass *cls=NULL);
float EvalExpressionF (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 enum
@ -186,30 +187,32 @@ enum EDefinitionType
#define CALL_ACTION(name,self) AF_##name(self, NULL, 0) #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) \ #define ACTION_PARAM_INT(var, i) \
int ap_index_ = CheckIndex(count); \ int var = EvalExpressionI(StateParameters[ParameterIndex+i], self);
if (ap_index_ <= 0) return; #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) \ #define ACTION_PARAM_ANGLE(var,i) \
int ap_index_ = CheckIndex(count); angle_t var = angle_t(EvalExpressionF(StateParameters[ParameterIndex+i], self)*ANGLE_90/90.f);
#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_++]));
#endif #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) static ExpVal EvalExpression (ExpData *data, AActor *self, const PClass *cls)
{ {
ExpVal val; ExpVal val;

View file

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

View file

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