From 1c034c1150339c9451142286283f25b03a97fe65 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 13 Aug 2008 22:54:24 +0000 Subject: [PATCH] - 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) --- docs/rh-log.txt | 6 +- src/d_dehacked.cpp | 2 +- src/g_doom/a_bossbrain.cpp | 16 +- src/g_doom/a_doomweaps.cpp | 39 +- src/g_doom/a_fatso.cpp | 34 +- src/g_doom/a_lostsoul.cpp | 11 +- src/g_doom/a_painelemental.cpp | 9 +- src/g_doom/a_scriptedmarine.cpp | 16 +- src/g_heretic/a_hereticweaps.cpp | 17 +- src/g_hexen/a_fighterquietus.cpp | 8 +- src/g_shared/a_action.cpp | 2 +- src/g_shared/a_bridge.cpp | 21 +- src/g_shared/a_specialspot.cpp | 14 +- src/g_strife/a_strifeweapons.cpp | 23 +- src/g_strife/a_thingstoblowup.cpp | 6 +- src/info.h | 2 +- src/p_enemy.cpp | 44 +- src/p_enemy_a_lookex.cpp | 19 +- src/p_pspr.cpp | 7 +- src/p_user.cpp | 7 +- src/thingdef/thingdef.h | 49 ++- src/thingdef/thingdef_codeptr.cpp | 612 ++++++++++++--------------- src/thingdef/thingdef_exp.cpp | 21 + src/thingdef/thingdef_properties.cpp | 9 +- src/thingdef/thingdef_states.cpp | 2 - 25 files changed, 439 insertions(+), 557 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 868da57e7..853926bc7 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -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. diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 67f5cce54..e4a4c3d8c 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -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. diff --git a/src/g_doom/a_bossbrain.cpp b/src/g_doom/a_bossbrain.cpp index c2dda3ae2..4840c8907 100644 --- a/src/g_doom/a_bossbrain.cpp +++ b/src/g_doom/a_bossbrain.cpp @@ -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; diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index 159e2c33e..5b168ecfb 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -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) diff --git a/src/g_doom/a_fatso.cpp b/src/g_doom/a_fatso.cpp index 044f2de71..809eccd0c 100644 --- a/src/g_doom/a_fatso.cpp +++ b/src/g_doom/a_fatso.cpp @@ -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); diff --git a/src/g_doom/a_lostsoul.cpp b/src/g_doom/a_lostsoul.cpp index 2d2c2ca6f..1005494b5 100644 --- a/src/g_doom/a_lostsoul.cpp +++ b/src/g_doom/a_lostsoul.cpp @@ -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); } diff --git a/src/g_doom/a_painelemental.cpp b/src/g_doom/a_painelemental.cpp index 8da1ce048..fb8147d49 100644 --- a/src/g_doom/a_painelemental.cpp +++ b/src/g_doom/a_painelemental.cpp @@ -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; } diff --git a/src/g_doom/a_scriptedmarine.cpp b/src/g_doom/a_scriptedmarine.cpp index 6ed27685f..e7fd0dc68 100644 --- a/src/g_doom/a_scriptedmarine.cpp +++ b/src/g_doom/a_scriptedmarine.cpp @@ -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); diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index 8edb30bbc..889059a23 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -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) diff --git a/src/g_hexen/a_fighterquietus.cpp b/src/g_hexen/a_fighterquietus.cpp index 82cc66aef..7067d1c24 100644 --- a/src/g_hexen/a_fighterquietus.cpp +++ b/src/g_hexen/a_fighterquietus.cpp @@ -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); diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp index 245548771..d38a1b063 100644 --- a/src/g_shared/a_action.cpp +++ b/src/g_shared/a_action.cpp @@ -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(head); head->player = self->player; + head->player->mo = static_cast(head); self->player = NULL; head->ObtainInventory (self); } diff --git a/src/g_shared/a_bridge.cpp b/src/g_shared/a_bridge.cpp index d33d3b7bf..7e743a0af 100644 --- a/src/g_shared/a_bridge.cpp +++ b/src/g_shared/a_bridge.cpp @@ -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); diff --git a/src/g_shared/a_specialspot.cpp b/src/g_shared/a_specialspot.cpp index ab2a5ce1c..08b6678c3 100644 --- a/src/g_shared/a_specialspot.cpp +++ b/src/g_shared/a_specialspot.cpp @@ -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; diff --git a/src/g_strife/a_strifeweapons.cpp b/src/g_strife/a_strifeweapons.cpp index ab98a5b34..137487b57 100644 --- a/src/g_strife/a_strifeweapons.cpp +++ b/src/g_strife/a_strifeweapons.cpp @@ -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); diff --git a/src/g_strife/a_thingstoblowup.cpp b/src/g_strife/a_thingstoblowup.cpp index dbedab347..0d26edfb7 100644 --- a/src/g_strife/a_thingstoblowup.cpp +++ b/src/g_strife/a_thingstoblowup.cpp @@ -27,11 +27,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_Bang4Cloud) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveQuestItem) { - int index=CheckIndex(1); - if (index<0) return; + ACTION_PARAM_START(1); + ACTION_PARAM_INT(questitem, 0); - int questitem = EvalExpressionI (StateParameters[index], self); - // Give one of these quest items to every player in the game for (int i = 0; i < MAXPLAYERS; ++i) { diff --git a/src/info.h b/src/info.h index 5bd30ca33..8bbd27959 100644 --- a/src/info.h +++ b/src/info.h @@ -141,7 +141,7 @@ struct FState { if (ActionFunc != NULL) { - ActionFunc(self, this, ParameterIndex); + ActionFunc(self, this, ParameterIndex-1); return true; } else diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 1efc14665..a269cfeb0 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2233,17 +2233,17 @@ 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; - - int index=CheckIndex(1); - if (index<0) - { - name = NAME_None; - } - else - { - name = ENamedName(StateParameters[index]); - } + ACTION_PARAM_START(1); + ACTION_PARAM_NAME(damagetype, 0); - P_DamageMobj (self, NULL, NULL, self->health, name); + P_DamageMobj (self, NULL, NULL, self->health, damagetype); } // diff --git a/src/p_enemy_a_lookex.cpp b/src/p_enemy_a_lookex.cpp index 1b29289e1..5d45490cd 100644 --- a/src/p_enemy_a_lookex.cpp +++ b/src/p_enemy_a_lookex.cpp @@ -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; diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index ea744a8eb..49c3c0ff4 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -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(EvalExpressionI (StateParameters[index], self), 0, 20); + self->player->extralight = clamp(light, 0, 20); } } diff --git a/src/p_user.cpp b/src/p_user.cpp index 8947880c6..2c1650c13 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -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"); diff --git a/src/thingdef/thingdef.h b/src/thingdef/thingdef.h index 75151067c..5244f3619 100644 --- a/src/thingdef/thingdef.h +++ b/src/thingdef/thingdef.h @@ -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 diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 304753ddf..123c64386 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -240,16 +240,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_ComboAttack) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BasicAttack) { - int index=CheckIndex(4); - if (index > 0) - { - int MeleeDamage=EvalExpressionI(StateParameters[index], self); - FSoundID MeleeSound=StateParameters[index+1]; - const PClass *MissileType=PClass::FindClass((ENamedName)StateParameters[index+2]); - fixed_t MissileHeight=fixed_t(EvalExpressionF(StateParameters[index+3], self)/65536.f); + ACTION_PARAM_START(4); + ACTION_PARAM_INT(MeleeDamage, 0); + ACTION_PARAM_SOUND(MeleeSound, 1); + ACTION_PARAM_CLASS(MissileType, 2); + ACTION_PARAM_FIXED(MissileHeight, 3); - DoAttack(self, true, true, MeleeDamage, MeleeSound, MissileType, MissileHeight); - } + DoAttack(self, true, true, MeleeDamage, MeleeSound, MissileType, MissileHeight); } //========================================================================== @@ -262,19 +259,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BasicAttack) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlaySound) { - int index=CheckIndex(1); - if (index<0) return; + ACTION_PARAM_START(1); + ACTION_PARAM_SOUND(soundid, 0); - int soundid = StateParameters[index]; S_Sound (self, CHAN_BODY, soundid, 1, ATTN_NORM); } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlayWeaponSound) { - int index=CheckIndex(1); - if (index<0) return; + ACTION_PARAM_START(1); + ACTION_PARAM_SOUND(soundid, 0); - int soundid = StateParameters[index]; S_Sound (self, CHAN_WEAPON, soundid, 1, ATTN_NORM); } @@ -285,13 +280,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_StopSound) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlaySoundEx) { - int index = CheckIndex(4); - if (index < 0) return; - - int soundid = StateParameters[index]; - ENamedName channel = ENamedName(StateParameters[index + 1]); - INTBOOL looping = EvalExpressionI(StateParameters[index + 2], self); - int attenuation_raw = EvalExpressionI(StateParameters[index + 3], self); + ACTION_PARAM_START(4); + ACTION_PARAM_SOUND(soundid, 0); + ACTION_PARAM_NAME(channel, 1); + ACTION_PARAM_BOOL(looping, 2); + ACTION_PARAM_INT(attenuation_raw, 3); int attenuation; switch (attenuation_raw) @@ -310,27 +303,25 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlaySoundEx) if (!looping) { - S_Sound (self, channel - NAME_Auto, soundid, 1, attenuation); + S_Sound (self, int(channel) - NAME_Auto, soundid, 1, attenuation); } else { - if (!S_IsActorPlayingSomething (self, channel - NAME_Auto, soundid)) + if (!S_IsActorPlayingSomething (self, int(channel) - NAME_Auto, soundid)) { - S_Sound (self, (channel - NAME_Auto) | CHAN_LOOP, soundid, 1, attenuation); + S_Sound (self, (int(channel) - NAME_Auto) | CHAN_LOOP, soundid, 1, attenuation); } } } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StopSoundEx) { - int index = CheckIndex (1); - if (index < 0) return; - - ENamedName channel = ENamedName(StateParameters[index]); + ACTION_PARAM_START(1); + ACTION_PARAM_NAME(channel, 0); if (channel > NAME_Auto && channel <= NAME_SoundSlot7) { - S_StopSound (self, channel - NAME_Auto); + S_StopSound (self, int(channel) - NAME_Auto); } } @@ -341,12 +332,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StopSoundEx) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SeekerMissile) { - int index=CheckIndex(2); - if (index<0) return; + ACTION_PARAM_START(2); + ACTION_PARAM_INT(ang1, 0); + ACTION_PARAM_INT(ang2, 1); - P_SeekerMissile(self, - clamp(EvalExpressionI (StateParameters[index], self), 0, 90) * ANGLE_1, - clamp(EvalExpressionI (StateParameters[index+1], self), 0, 90) * ANGLE_1); + P_SeekerMissile(self, clamp(ang1, 0, 90) * ANGLE_1, clamp(ang2, 0, 90) * ANGLE_1); } //========================================================================== @@ -354,7 +344,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SeekerMissile) // Hitscan attack with a customizable amount of bullets (specified in damage) // //========================================================================== -DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BulletAttack) +DEFINE_ACTION_FUNCTION(AActor, A_BulletAttack) { int i; int bangle; @@ -463,21 +453,20 @@ static void DoJump(AActor * self, FState * CallingState, int offset) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Jump) { - int index = CheckIndex(3); - int maxchance; + ACTION_PARAM_START(3); + ACTION_PARAM_INT(count, 0); + ACTION_PARAM_INT(maxchance, 1); + ACTION_PARAM_VARARG(jumps, 2); - if (index >= 0 && - StateParameters[index] >= 2 && - (maxchance = clamp(EvalExpressionI (StateParameters[index + 1], self), 0, 256), - maxchance == 256 || pr_cajump() < maxchance)) + if (count >= 2 && (maxchance >= 256 || pr_cajump() < maxchance)) { - if (StateParameters[index] == 2) + if (count == 2) { - DoJump(self, CallingState, StateParameters[index + 2]); + DoJump(self, CallingState, *jumps); } else { - DoJump(self, CallingState, StateParameters[index + (pr_cajump() % (StateParameters[index] - 1)) + 2]); + DoJump(self, CallingState, jumps[(pr_cajump() % (count - 1)) + 2]); } } if (pStateCall != NULL) pStateCall->Result=false; // Jumps should never set the result for inventory state chains! @@ -490,10 +479,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Jump) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHealthLower) { - int index=CheckIndex(2); + ACTION_PARAM_START(2); + ACTION_PARAM_INT(health, 0); + ACTION_PARAM_STATE(jump, 1); - if (index>=0 && self->health < EvalExpressionI (StateParameters[index], self)) - DoJump(self, CallingState, StateParameters[index+1]); + if (self->health < health) DoJump(self, CallingState, jump); if (pStateCall != NULL) pStateCall->Result=false; // Jumps should never set the result for inventory state chains! } @@ -505,8 +495,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHealthLower) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfCloser) { - int index = CheckIndex(2); - AActor * target; + ACTION_PARAM_START(2); + ACTION_PARAM_FIXED(dist, 0); + ACTION_PARAM_STATE(jump, 1); + + AActor *target; if (!self->player) { @@ -523,13 +516,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfCloser) // No target - no jump if (target==NULL) return; - fixed_t dist = fixed_t(EvalExpressionF (StateParameters[index], self) * FRACUNIT); - if (index > 0 && P_AproxDistance(self->x-target->x, self->y-target->y) < dist && + if (P_AproxDistance(self->x-target->x, self->y-target->y) < dist && ( (self->z > target->z && self->z - (target->z + target->height) < dist) || (self->z <=target->z && target->z - (self->z + self->height) < dist) ) ) - DoJump(self, CallingState, StateParameters[index+1]); + DoJump(self, CallingState, jump); } //========================================================================== @@ -539,13 +531,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfCloser) //========================================================================== void DoJumpIfInventory(AActor * self, AActor * owner, DECLARE_PARAMINFO) { - int index=CheckIndex(3); - if (index<0) return; - - ENamedName ItemType=(ENamedName)StateParameters[index]; - int ItemAmount = EvalExpressionI (StateParameters[index+1], self); - int JumpOffset = StateParameters[index+2]; - const PClass * Type=PClass::FindClass(ItemType); + ACTION_PARAM_START(3); + ACTION_PARAM_CLASS(Type, 0); + ACTION_PARAM_INT(ItemAmount, 1); + ACTION_PARAM_STATE(JumpOffset, 2); if (pStateCall != NULL) pStateCall->Result=false; // Jumps should never set the result for inventory state chains! @@ -578,18 +567,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetInventory) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Explode) { - int damage; - int distance; - bool hurtSource; - bool alert; - - int index=CheckIndex(4); - if (index < 0) return; - - damage = EvalExpressionI (StateParameters[index], self); - distance = EvalExpressionI (StateParameters[index+1], self); - hurtSource = !!EvalExpressionI (StateParameters[index+2], self); - alert = !!EvalExpressionI (StateParameters[index+3], self); + ACTION_PARAM_START(4); + ACTION_PARAM_INT(damage, 0); + ACTION_PARAM_FIXED(distance, 1); + ACTION_PARAM_BOOL(hurtSource, 2); + ACTION_PARAM_BOOL(alert, 3); if (damage < 0) // get parameters from metadata { @@ -623,16 +605,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Explode) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusThrust) { - int force = 0; - int distance = 0; - bool affectSource = true; - - int index=CheckIndex(3); - if (index < 0) return; - - force = EvalExpressionI (StateParameters[index], self); - distance = EvalExpressionI (StateParameters[index+1], self); - affectSource = !!EvalExpressionI (StateParameters[index+2], self); + ACTION_PARAM_START(3); + ACTION_PARAM_INT(force, 0); + ACTION_PARAM_FIXED(distance, 1); + ACTION_PARAM_BOOL(affectSource, 2); if (force <= 0) force = 128; if (distance <= 0) distance = force; @@ -651,15 +627,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusThrust) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CallSpecial) { - int index=CheckIndex(6); - if (index<0) return; + ACTION_PARAM_START(6); + ACTION_PARAM_INT(special, 0); + ACTION_PARAM_INT(arg1, 1); + ACTION_PARAM_INT(arg2, 2); + ACTION_PARAM_INT(arg3, 3); + ACTION_PARAM_INT(arg4, 4); + ACTION_PARAM_INT(arg5, 5); - bool res = !!LineSpecials[StateParameters[index]](NULL, self, false, - EvalExpressionI (StateParameters[index+1], self), - EvalExpressionI (StateParameters[index+2], self), - EvalExpressionI (StateParameters[index+3], self), - EvalExpressionI (StateParameters[index+4], self), - EvalExpressionI (StateParameters[index+5], self)); + bool res = !!LineSpecials[special](NULL, self, false, arg1, arg2, arg3, arg4, arg5); if (pStateCall != NULL) pStateCall->Result = res; } @@ -691,15 +667,14 @@ enum CM_Flags DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) { - int index=CheckIndex(6); - if (index<0) return; + ACTION_PARAM_START(6); + ACTION_PARAM_CLASS(ti, 0); + ACTION_PARAM_FIXED(SpawnHeight, 1); + ACTION_PARAM_INT(Spawnofs_XY, 2); + ACTION_PARAM_ANGLE(Angle, 3); + ACTION_PARAM_INT(flags, 4); + ACTION_PARAM_ANGLE(pitch, 5); - ENamedName MissileName=(ENamedName)StateParameters[index]; - fixed_t SpawnHeight=fixed_t(EvalExpressionF (StateParameters[index+1], self) * FRACUNIT); - int Spawnofs_XY=EvalExpressionI (StateParameters[index+2], self); - angle_t Angle=angle_t(EvalExpressionF (StateParameters[index+3], self) * ANGLE_1); - int flags=EvalExpressionI (StateParameters[index+4], self); - angle_t pitch=angle_t(EvalExpressionF (StateParameters[index+5], self) * ANGLE_1); int aimmode = flags & CMF_AIMMODE; AActor * targ; @@ -707,7 +682,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) if (self->target != NULL || aimmode==2) { - const PClass * ti=PClass::FindClass(MissileName); if (ti) { angle_t ang = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT; @@ -813,31 +787,26 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack) { - int index=CheckIndex(7); - if (index<0) return; - - angle_t Spread_XY=angle_t(EvalExpressionF (StateParameters[index], self) * ANGLE_1); - angle_t Spread_Z=angle_t(EvalExpressionF (StateParameters[index+1], self) * ANGLE_1); - int NumBullets=EvalExpressionI (StateParameters[index+2], self); - int DamagePerBullet=EvalExpressionI (StateParameters[index+3], self); - ENamedName PuffType=(ENamedName)StateParameters[index+4]; - fixed_t Range = fixed_t(EvalExpressionF (StateParameters[index+5], self) * FRACUNIT); - bool AimFacing = !!EvalExpressionI (StateParameters[index+6], self); + ACTION_PARAM_START(7); + ACTION_PARAM_ANGLE(Spread_XY, 0); + ACTION_PARAM_ANGLE(Spread_Z, 1); + ACTION_PARAM_INT(NumBullets, 2); + ACTION_PARAM_INT(DamagePerBullet, 3); + ACTION_PARAM_CLASS(pufftype, 4); + ACTION_PARAM_FIXED(Range, 5); + ACTION_PARAM_BOOL(AimFacing, 6); if(Range==0) Range=MISSILERANGE; - int i; int bangle; int bslope; - const PClass *pufftype; if (self->target || AimFacing) { if (!AimFacing) A_FaceTarget (self); bangle = self->angle; - pufftype = PClass::FindClass(PuffType); if (!pufftype) pufftype = PClass::FindClass(NAME_BulletPuff); bslope = P_AimLineAttack (self, bangle, MISSILERANGE); @@ -860,14 +829,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMeleeAttack) { - int index=CheckIndex(5); - if (index<0) return; - - int damage = EvalExpressionI (StateParameters[index], self); - int MeleeSound = StateParameters[index+1]; - int MissSound = StateParameters[index+2]; - ENamedName DamageType = (ENamedName)StateParameters[index+3]; - bool bleed = !!EvalExpressionI (StateParameters[index+4], self); + ACTION_PARAM_START(5); + ACTION_PARAM_INT(damage, 0); + ACTION_PARAM_SOUND(MeleeSound, 1); + ACTION_PARAM_SOUND(MissSound, 2); + ACTION_PARAM_NAME(DamageType, 3); + ACTION_PARAM_BOOL(bleed, 4); if (DamageType==NAME_None) DamageType = NAME_Melee; // Melee is the default type @@ -894,16 +861,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMeleeAttack) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomComboAttack) { - int index=CheckIndex(6); - if (index<0) return; - - ENamedName MissileName=(ENamedName)StateParameters[index]; - fixed_t SpawnHeight=fixed_t(EvalExpressionF (StateParameters[index+1], self) * FRACUNIT); - int damage = EvalExpressionI (StateParameters[index+2], self); - int MeleeSound = StateParameters[index+3]; - ENamedName DamageType = (ENamedName)StateParameters[index+4]; - bool bleed = !!EvalExpressionI (StateParameters[index+5], self); - + ACTION_PARAM_START(6); + ACTION_PARAM_CLASS(ti, 0); + ACTION_PARAM_FIXED(SpawnHeight, 1); + ACTION_PARAM_INT(damage, 2); + ACTION_PARAM_SOUND(MeleeSound, 3); + ACTION_PARAM_NAME(DamageType, 4); + ACTION_PARAM_BOOL(bleed, 5); if (!self->target) return; @@ -916,30 +880,26 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomComboAttack) P_DamageMobj (self->target, self, self, damage, DamageType); if (bleed) P_TraceBleed (damage, self->target, self); } - else + else if (ti) { - const PClass * ti=PClass::FindClass(MissileName); - if (ti) - { - // This seemingly senseless code is needed for proper aiming. - self->z+=SpawnHeight-32*FRACUNIT; - AActor * missile = P_SpawnMissileXYZ (self->x, self->y, self->z + 32*FRACUNIT, self, self->target, ti, false); - self->z-=SpawnHeight-32*FRACUNIT; + // This seemingly senseless code is needed for proper aiming. + self->z+=SpawnHeight-32*FRACUNIT; + AActor * missile = P_SpawnMissileXYZ (self->x, self->y, self->z + 32*FRACUNIT, self, self->target, ti, false); + self->z-=SpawnHeight-32*FRACUNIT; - if (missile) + if (missile) + { + // automatic handling of seeker missiles + if (missile->flags2&MF2_SEEKERMISSILE) { - // automatic handling of seeker missiles - if (missile->flags2&MF2_SEEKERMISSILE) - { - missile->tracer=self->target; - } - // set the health value so that the missile works properly - if (missile->flags4&MF4_SPECTRAL) - { - missile->health=-2; - } - P_CheckMissileSpawn(missile); + missile->tracer=self->target; } + // set the health value so that the missile works properly + if (missile->flags4&MF4_SPECTRAL) + { + missile->health=-2; + } + P_CheckMissileSpawn(missile); } } } @@ -951,13 +911,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomComboAttack) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfNoAmmo) { - int index=CheckIndex(1); + ACTION_PARAM_START(1); + ACTION_PARAM_STATE(jump, 0); if (pStateCall != NULL) pStateCall->Result=false; // Jumps should never set the result for inventory state chains! - if (index<0 || !self->player || !self->player->ReadyWeapon || pStateCall != NULL) return; // only for weapons! + if (!self->player || !self->player->ReadyWeapon || pStateCall != NULL) return; // only for weapons! if (!self->player->ReadyWeapon->CheckAmmo(self->player->ReadyWeapon->bAltFire, false, true)) - DoJump(self, CallingState, StateParameters[index]); + DoJump(self, CallingState, jump); } @@ -969,18 +930,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfNoAmmo) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) { - int index=CheckIndex(7); - if (index<0 || !self->player) return; + ACTION_PARAM_START(7); + ACTION_PARAM_ANGLE(Spread_XY, 0); + ACTION_PARAM_ANGLE(Spread_Z, 1); + ACTION_PARAM_INT(NumberOfBullets, 2); + ACTION_PARAM_INT(DamagePerBullet, 3); + ACTION_PARAM_CLASS(PuffType, 4); + ACTION_PARAM_BOOL(UseAmmo, 5); + ACTION_PARAM_FIXED(Range, 6); - angle_t Spread_XY=angle_t(EvalExpressionF (StateParameters[index], self) * ANGLE_1); - angle_t Spread_Z=angle_t(EvalExpressionF (StateParameters[index+1], self) * ANGLE_1); - int NumberOfBullets=EvalExpressionI (StateParameters[index+2], self); - int DamagePerBullet=EvalExpressionI (StateParameters[index+3], self); - ENamedName PuffTypeName=(ENamedName)StateParameters[index+4]; - bool UseAmmo=!!EvalExpressionI (StateParameters[index+5], self); - fixed_t Range=fixed_t(EvalExpressionF (StateParameters[index+6], self) * FRACUNIT); - - const PClass * PuffType; + if (!self->player) return; player_t * player=self->player; AWeapon * weapon=player->ReadyWeapon; @@ -1001,7 +960,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) bslope = P_BulletSlope(self); bangle = self->angle; - PuffType = PClass::FindClass(PuffTypeName); if (!PuffType) PuffType = PClass::FindClass(NAME_BulletPuff); S_Sound (self, CHAN_WEAPON, weapon->AttackSound, 1, ATTN_NORM); @@ -1032,15 +990,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile) { - int index=CheckIndex(6); - if (index<0 || !self->player) return; + ACTION_PARAM_START(6); + ACTION_PARAM_CLASS(ti, 0); + ACTION_PARAM_ANGLE(Angle, 1); + ACTION_PARAM_BOOL(UseAmmo, 2); + ACTION_PARAM_INT(SpawnOfs_XY, 3); + ACTION_PARAM_FIXED(SpawnHeight, 4); + ACTION_PARAM_BOOL(AimAtAngle, 5); - ENamedName MissileName=(ENamedName)StateParameters[index]; - angle_t Angle=angle_t(EvalExpressionF (StateParameters[index+1], self) * ANGLE_1); - bool UseAmmo=!!EvalExpressionI (StateParameters[index+2], self); - int SpawnOfs_XY=EvalExpressionI (StateParameters[index+3], self); - fixed_t SpawnHeight=fixed_t(EvalExpressionF (StateParameters[index+4], self) * FRACUNIT); - INTBOOL AimAtAngle=EvalExpressionI (StateParameters[index+5], self); + if (!self->player) return; player_t *player=self->player; AWeapon * weapon=player->ReadyWeapon; @@ -1051,7 +1009,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile) if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return; // out of ammo } - const PClass * ti=PClass::FindClass(MissileName); if (ti) { angle_t ang = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT; @@ -1092,17 +1049,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch) { - int index=CheckIndex(5); - if (index<0 || !self->player) return; - - int Damage=EvalExpressionI (StateParameters[index], self); - bool norandom=!!EvalExpressionI (StateParameters[index+1], self); - bool UseAmmo=!!EvalExpressionI (StateParameters[index+2], self); - ENamedName PuffTypeName=(ENamedName)StateParameters[index+3]; - fixed_t Range=fixed_t(EvalExpressionF (StateParameters[index+4], self) * FRACUNIT); - - const PClass * PuffType; + ACTION_PARAM_START(5); + ACTION_PARAM_INT(Damage, 0); + ACTION_PARAM_BOOL(norandom, 1); + ACTION_PARAM_BOOL(UseAmmo, 2); + ACTION_PARAM_CLASS(PuffType, 3); + ACTION_PARAM_FIXED(Range, 4); + if (!self->player) return; player_t *player=self->player; AWeapon * weapon=player->ReadyWeapon; @@ -1124,7 +1078,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch) if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return; // out of ammo } - PuffType = PClass::FindClass(PuffTypeName); if (!PuffType) PuffType = PClass::FindClass(NAME_BulletPuff); P_LineAttack (self, angle, Range, pitch, Damage, GetDefaultByType(PuffType)->DamageType, PuffType, true); @@ -1149,17 +1102,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack) { - int index=CheckIndex(7); - if (index<0 || !self->player) return; + ACTION_PARAM_START(8); + ACTION_PARAM_INT(Damage, 0); + ACTION_PARAM_INT(Spawnofs_XY, 1); + ACTION_PARAM_BOOL(UseAmmo, 2); + ACTION_PARAM_COLOR(Color1, 3); + ACTION_PARAM_COLOR(Color2, 4); + ACTION_PARAM_BOOL(Silent, 5); + ACTION_PARAM_FLOAT(MaxDiff, 6); + ACTION_PARAM_NAME(PuffTypeName, 7); - int Damage=EvalExpressionI (StateParameters[index], self); - int Spawnofs_XY=EvalExpressionI (StateParameters[index+1], self); - bool UseAmmo=!!EvalExpressionI (StateParameters[index+2], self); - int Color1=StateParameters[index+3]; - int Color2=StateParameters[index+4]; - bool Silent=!!EvalExpressionI (StateParameters[index+5], self); - float MaxDiff=EvalExpressionF (StateParameters[index+6], self); - ENamedName PuffTypeName=(ENamedName)StateParameters[index+7]; + if (!self->player) return; AWeapon * weapon=self->player->ReadyWeapon; @@ -1180,17 +1133,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) { - int index = CheckIndex(7); - if (index < 0) return; - - int Damage = EvalExpressionI (StateParameters[index], self); - int Spawnofs_XY = EvalExpressionI (StateParameters[index+1], self); - int Color1 = StateParameters[index+2]; - int Color2 = StateParameters[index+3]; - bool Silent = !!EvalExpressionI (StateParameters[index+4], self); - bool aim = !!EvalExpressionI (StateParameters[index+5], self); - float MaxDiff = EvalExpressionF (StateParameters[index+6], self); - ENamedName PuffTypeName = (ENamedName)StateParameters[index+7]; + ACTION_PARAM_START(8); + ACTION_PARAM_INT(Damage, 0); + ACTION_PARAM_INT(Spawnofs_XY, 1); + ACTION_PARAM_COLOR(Color1, 2); + ACTION_PARAM_COLOR(Color2, 3); + ACTION_PARAM_BOOL(Silent, 4); + ACTION_PARAM_BOOL(aim, 5); + ACTION_PARAM_FLOAT(MaxDiff, 6); + ACTION_PARAM_NAME(PuffTypeName, 7); if (aim && self->target == NULL) { @@ -1239,15 +1190,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) static void DoGiveInventory(AActor * self, AActor * receiver, DECLARE_PARAMINFO) { - int index=CheckIndex(2); - bool res=true; - if (index<0 || receiver == NULL) return; + ACTION_PARAM_START(2); + ACTION_PARAM_CLASS(mi, 0); + ACTION_PARAM_INT(amount, 1); - ENamedName item =(ENamedName)StateParameters[index]; - int amount=EvalExpressionI (StateParameters[index+1], self); + bool res=true; + if (receiver == NULL) return; if (amount==0) amount=1; - const PClass * mi=PClass::FindClass(item); if (mi) { AInventory *item = static_cast(Spawn (mi, 0, 0, 0, NO_REPLACE)); @@ -1295,11 +1245,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveToTarget) void DoTakeInventory(AActor * self, AActor * receiver, DECLARE_PARAMINFO) { - int index=CheckIndex(2); - if (index<0 || receiver == NULL) return; - - ENamedName item =(ENamedName)StateParameters[index]; - int amount=EvalExpressionI (StateParameters[index+1], self); + ACTION_PARAM_START(2); + ACTION_PARAM_CLASS(item, 0); + ACTION_PARAM_INT(amount, 1); + + if (receiver == NULL) return; if (pStateCall != NULL) pStateCall->Result=false; @@ -1422,14 +1372,12 @@ static void InitSpawnedItem(AActor *self, AActor *mo, int flags) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem) { - int index=CheckIndex(5); - if (index<0) return; - - const PClass * missile= PClass::FindClass((ENamedName)StateParameters[index]); - fixed_t distance = fixed_t(EvalExpressionF (StateParameters[index+1], self) * FRACUNIT); - fixed_t zheight = fixed_t(EvalExpressionF (StateParameters[index+2], self) * FRACUNIT); - bool useammo = !!EvalExpressionI (StateParameters[index+3], self); - INTBOOL transfer_translation = EvalExpressionI (StateParameters[index+4], self); + ACTION_PARAM_START(5); + ACTION_PARAM_CLASS(missile, 0); + ACTION_PARAM_FIXED(distance, 1); + ACTION_PARAM_FIXED(zheight, 2); + ACTION_PARAM_BOOL(useammo, 3); + ACTION_PARAM_BOOL(transfer_translation, 4); if (!missile) { @@ -1473,19 +1421,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) { - int index=CheckIndex(9); - if (index<0) return; - - const PClass * missile= PClass::FindClass((ENamedName)StateParameters[index]); - fixed_t xofs = fixed_t(EvalExpressionF (StateParameters[index+1], self) * FRACUNIT); - fixed_t yofs = fixed_t(EvalExpressionF (StateParameters[index+2], self) * FRACUNIT); - fixed_t zofs = fixed_t(EvalExpressionF (StateParameters[index+3], self) * FRACUNIT); - fixed_t xmom = fixed_t(EvalExpressionF (StateParameters[index+4], self) * FRACUNIT); - fixed_t ymom = fixed_t(EvalExpressionF (StateParameters[index+5], self) * FRACUNIT); - fixed_t zmom = fixed_t(EvalExpressionF (StateParameters[index+6], self) * FRACUNIT); - angle_t Angle= angle_t(EvalExpressionF (StateParameters[index+7], self) * ANGLE_1); - int flags = EvalExpressionI (StateParameters[index+8], self); - int chance = EvalExpressionI (StateParameters[index+9], self); + ACTION_PARAM_START(10); + ACTION_PARAM_CLASS(missile, 0); + ACTION_PARAM_FIXED(xofs, 1); + ACTION_PARAM_FIXED(yofs, 2); + ACTION_PARAM_FIXED(zofs, 3); + ACTION_PARAM_FIXED(xmom, 4); + ACTION_PARAM_FIXED(ymom, 5); + ACTION_PARAM_FIXED(zmom, 6); + ACTION_PARAM_ANGLE(Angle, 7); + ACTION_PARAM_INT(flags, 8); + ACTION_PARAM_INT(chance, 9); if (!missile) { @@ -1549,14 +1495,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade) { - int index=CheckIndex(5); - if (index<0) return; - - const PClass * missile= PClass::FindClass((ENamedName)StateParameters[index]); - fixed_t zheight = fixed_t(EvalExpressionF (StateParameters[index+1], self) * FRACUNIT); - fixed_t xymom = fixed_t(EvalExpressionF (StateParameters[index+2], self) * FRACUNIT); - fixed_t zmom = fixed_t(EvalExpressionF (StateParameters[index+3], self) * FRACUNIT); - bool useammo = !!EvalExpressionI (StateParameters[index+4], self); + ACTION_PARAM_START(5); + ACTION_PARAM_CLASS(missile, 0); + ACTION_PARAM_FIXED(zheight, 1); + ACTION_PARAM_FIXED(xymom, 2); + ACTION_PARAM_FIXED(zmom, 3); + ACTION_PARAM_BOOL(useammo, 4); if (self->player && CallingState != self->state && (pStateCall==NULL || CallingState != pStateCall->State)) { @@ -1604,9 +1548,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Recoil) { - int index=CheckIndex(1); - if (index<0) return; - fixed_t xymom = fixed_t(EvalExpressionF (StateParameters[index], self) * FRACUNIT); + ACTION_PARAM_START(1); + ACTION_PARAM_FIXED(xymom, 0); angle_t angle = self->angle + ANG180; angle >>= ANGLETOFINESHIFT; @@ -1622,10 +1565,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Recoil) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SelectWeapon) { - int index=CheckIndex(1); - if (index<0 || self->player == NULL) return; + ACTION_PARAM_START(1); + ACTION_PARAM_CLASS(cls, 0); - AWeapon * weaponitem = static_cast(self->FindInventory((ENamedName)StateParameters[index])); + if (self->player == NULL) return; + + AWeapon * weaponitem = static_cast(self->FindInventory(cls)); if (weaponitem != NULL && weaponitem->IsKindOf(RUNTIME_CLASS(AWeapon))) { @@ -1647,14 +1592,14 @@ EXTERN_CVAR(Float, con_midtime) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Print) { - int index=CheckIndex(3); - if (index<0) return; + ACTION_PARAM_START(3); + ACTION_PARAM_STRING(text, 0); + ACTION_PARAM_FLOAT(time, 1); + ACTION_PARAM_NAME(fontname, 2); if (self->CheckLocalView (consoleplayer) || (self->target!=NULL && self->target->CheckLocalView (consoleplayer))) { - float time = EvalExpressionF (StateParameters[index+1], self); - FName fontname = (ENamedName)StateParameters[index+2]; FFont * oldfont = screen->Font; float saved = con_midtime; @@ -1669,7 +1614,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Print) con_midtime = time; } - C_MidPrint(FName((ENamedName)StateParameters[index]).GetChars()); + C_MidPrint(text); screen->SetFont(oldfont); con_midtime = saved; } @@ -1683,11 +1628,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Print) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTranslucent) { - int index=CheckIndex(2); - if (index<0) return; + ACTION_PARAM_START(2); + ACTION_PARAM_FIXED(alpha, 0); + ACTION_PARAM_INT(mode, 1); - fixed_t alpha = fixed_t(EvalExpressionF (StateParameters[index], self) * FRACUNIT); - int mode = EvalExpressionI (StateParameters[index+1], self); mode = mode == 0 ? STYLE_Translucent : mode == 2 ? STYLE_Fuzzy : STYLE_Add; self->RenderStyle.Flags &= ~STYLEF_Alpha1; @@ -1704,14 +1648,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTranslucent) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FadeIn) { - fixed_t reduce = 0; - - int index=CheckIndex(1); - if (index>=0) - { - reduce = fixed_t(EvalExpressionF (StateParameters[index], self) * FRACUNIT); - } - + ACTION_PARAM_START(1); + ACTION_PARAM_FIXED(reduce, 0); + if (reduce == 0) reduce = FRACUNIT/10; self->RenderStyle.Flags &= ~STYLEF_Alpha1; @@ -1728,13 +1667,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FadeIn) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FadeOut) { - fixed_t reduce = 0; - - int index=CheckIndex(1); - if (index>=0) - { - reduce = fixed_t(EvalExpressionF (StateParameters[index], self) * FRACUNIT); - } + ACTION_PARAM_START(1); + ACTION_PARAM_FIXED(reduce, 0); if (reduce == 0) reduce = FRACUNIT/10; @@ -1752,18 +1686,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris) { int i; AActor * mo; - const PClass * debris; - int index=CheckIndex(4); - if (index<0) return; + ACTION_PARAM_START(4); + ACTION_PARAM_CLASS(debris, 0); + ACTION_PARAM_BOOL(transfer_translation, 1); + ACTION_PARAM_FIXED(mult_h, 2); + ACTION_PARAM_FIXED(mult_v, 3); - debris = PClass::FindClass((ENamedName)StateParameters[index]); if (debris == NULL) return; - INTBOOL transfer_translation = EvalExpressionI (StateParameters[index+1], self); - fixed_t mult_h = fixed_t(EvalExpressionF (StateParameters[index+2], self) * FRACUNIT); - fixed_t mult_v = fixed_t(EvalExpressionF (StateParameters[index+3], self) * FRACUNIT); - // only positive values make sense here if (mult_v<=0) mult_v=FRACUNIT; if (mult_h<=0) mult_h=FRACUNIT; @@ -1796,6 +1727,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSight) { + ACTION_PARAM_START(1); + ACTION_PARAM_STATE(jump, 0); + if (pStateCall != NULL) pStateCall->Result=false; // Jumps should never set the result for inventory state chains! for (int i=0;i=0) DoJump(self, CallingState, StateParameters[index]); + DoJump(self, CallingState, jump); } @@ -1817,10 +1749,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSight) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropInventory) { - int index=CheckIndex(1); - if (index<0) return; + ACTION_PARAM_START(1); + ACTION_PARAM_CLASS(drop, 0); - AInventory * inv = self->FindInventory((ENamedName)StateParameters[index]); + AInventory * inv = self->FindInventory(drop); if (inv) { self->DropInventory(inv); @@ -1835,12 +1767,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropInventory) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetBlend) { - int index=CheckIndex(3); - if (index<0) return; - PalEntry color = StateParameters[index]; - float alpha = clamp (EvalExpressionF (StateParameters[index+1], self), 0, 1); - int tics = EvalExpressionI (StateParameters[index+2], self); - PalEntry color2 = StateParameters[index+3]; + ACTION_PARAM_START(4); + ACTION_PARAM_COLOR(color, 0); + ACTION_PARAM_FLOAT(alpha, 1); + ACTION_PARAM_INT(tics, 2); + ACTION_PARAM_COLOR(color2, 3); if (color == MAKEARGB(255,255,255,255)) color=0; if (color2 == MAKEARGB(255,255,255,255)) color2=0; @@ -1860,12 +1791,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetBlend) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIf) { - int index=CheckIndex(2); - if (index<0) return; - INTBOOL expression = EvalExpressionI (StateParameters[index], self); + ACTION_PARAM_START(2); + ACTION_PARAM_BOOL(expression, 0); + ACTION_PARAM_STATE(jump, 1); if (pStateCall != NULL) pStateCall->Result=false; // Jumps should never set the result for inventory state chains! - if (expression) DoJump(self, CallingState, StateParameters[index+1]); + if (expression) DoJump(self, CallingState, jump); } @@ -1908,12 +1839,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_KillChildren) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CountdownArg) { - int index=CheckIndex(1); - if (index<0) return; - index = EvalExpressionI (StateParameters[index], self) - 1; + ACTION_PARAM_START(1); + ACTION_PARAM_INT(cnt, 0); - if (index<0 || index>=5) return; - if (!self->args[index]--) + if (cnt<0 || cnt>=5) return; + if (!self->args[cnt]--) { if (self->flags&MF_MISSILE) { @@ -1939,11 +1869,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CountdownArg) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Burst) { + ACTION_PARAM_START(1); + ACTION_PARAM_CLASS(chunk, 0); + int i, numChunks; AActor * mo; - int index=CheckIndex(1); - if (index<0) return; - const PClass * chunk = PClass::FindClass((ENamedName)StateParameters[index]); + if (chunk == NULL) return; self->momx = self->momy = self->momz = 0; @@ -1992,12 +1923,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Burst) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFloor) { - int index = CheckIndex (1); + ACTION_PARAM_START(1); + ACTION_PARAM_STATE(jump, 0); if (pStateCall != NULL) pStateCall->Result=false; // Jumps should never set the result for inventory state chains! - if (self->z <= self->floorz && index >= 0) + if (self->z <= self->floorz) { - DoJump (self, CallingState, StateParameters[index]); + DoJump (self, CallingState, jump); } } @@ -2026,6 +1958,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_Stop) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) { + ACTION_PARAM_START(1); + ACTION_PARAM_BOOL(fog, 0); + fixed_t x = self->SpawnPoint[0]; fixed_t y = self->SpawnPoint[1]; sector_t *sec; @@ -2047,8 +1982,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) self->SetState (self->SpawnState); self->renderflags &= ~RF_INVISIBLE; - int index=CheckIndex(1); - if (index<0 || EvalExpressionI (StateParameters[index], self)) + if (fog) { Spawn (x, y, self->z + TELEFOGHEIGHT, ALLOW_REPLACE); } @@ -2069,16 +2003,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlayerSkinCheck) { + ACTION_PARAM_START(1); + ACTION_PARAM_STATE(jump, 0); + if (pStateCall != NULL) pStateCall->Result=false; // Jumps should never set the result for inventory state chains! if (self->player != NULL && skins[self->player->userinfo.skin].othergame) { - int index = CheckIndex(1); - - if (index >= 0) - { - DoJump(self, CallingState, StateParameters[index]); - } + DoJump(self, CallingState, jump); } } @@ -2089,10 +2021,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlayerSkinCheck) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetGravity) { - int index=CheckIndex(1); - if (index<0) return; + ACTION_PARAM_START(1); + ACTION_PARAM_FIXED(val, 0); - self->gravity = clamp (fixed_t(EvalExpressionF (StateParameters[index], self)*FRACUNIT), 0, FRACUNIT); + self->gravity = clamp (val, 0, FRACUNIT*10); } @@ -2126,12 +2058,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_ClearTarget) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) { - int index = CheckIndex(3); - if (index < 0) return; + ACTION_PARAM_START(3); + ACTION_PARAM_STATE(jump, 0); + ACTION_PARAM_ANGLE(fov, 1); + ACTION_PARAM_BOOL(projtarg, 2); angle_t an; - angle_t fov = angle_t(EvalExpressionF (StateParameters[index+1], self) * ANGLE_1); - INTBOOL projtarg = EvalExpressionI (StateParameters[index+2], self); AActor *target; if (pStateCall != NULL) pStateCall->Result=false; // Jumps should never set the result for inventory state chains! @@ -2178,7 +2110,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) if (!target) return; - DoJump(self, CallingState, StateParameters[index]); + DoJump(self, CallingState, jump); } //=========================================================================== @@ -2189,11 +2121,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageMaster) { - int index = CheckIndex(2); - if (index<0) return; - - int amount = EvalExpressionI (StateParameters[index], self); - ENamedName DamageType = (ENamedName)StateParameters[index+1]; + ACTION_PARAM_START(2); + ACTION_PARAM_INT(amount, 0); + ACTION_PARAM_NAME(DamageType, 1); if (self->master != NULL) { @@ -2220,11 +2150,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageChildren) TThinkerIterator it; AActor * mo; - int index = CheckIndex(2); - if (index<0) return; - - int amount = EvalExpressionI (StateParameters[index], self); - ENamedName DamageType = (ENamedName)StateParameters[index+3]; + ACTION_PARAM_START(2); + ACTION_PARAM_INT(amount, 0); + ACTION_PARAM_NAME(DamageType, 1); while ( (mo = it.Next()) ) { @@ -2256,11 +2184,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckForReload) if ( self->player == NULL || self->player->ReadyWeapon == NULL ) return; - int index = CheckIndex(2); - if (index<0) return; - + ACTION_PARAM_START(2); + ACTION_PARAM_INT(count, 0); + ACTION_PARAM_STATE(jump, 1); + AWeapon *weapon = self->player->ReadyWeapon; - int count = EvalExpressionI (StateParameters[index], self); weapon->ReloadCounter = (weapon->ReloadCounter+1) % count; @@ -2268,7 +2196,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckForReload) if (weapon->ReloadCounter != 0) { // Go back to the refire frames, instead of continuing on to the reload frames. - DoJump(self, CallingState, StateParameters[index + 1]); + DoJump(self, CallingState, jump); } else { diff --git a/src/thingdef/thingdef_exp.cpp b/src/thingdef/thingdef_exp.cpp index 73a9666f5..296dc93ba 100644 --- a/src/thingdef/thingdef_exp.cpp +++ b/src/thingdef/thingdef_exp.cpp @@ -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; diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index b438a2fdd..de2d358f5 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -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 { diff --git a/src/thingdef/thingdef_states.cpp b/src/thingdef/thingdef_states.cpp index bb78791b7..9831a07f3 100644 --- a/src/thingdef/thingdef_states.cpp +++ b/src/thingdef/thingdef_states.cpp @@ -67,8 +67,6 @@ static TArray StateArray; // //========================================================================== -DECLARE_ACTION(A_CallSpecial) - //========================================================================== // // Find a function by name using a binary search