diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index c2859ef78..4889b2f75 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -1603,7 +1603,7 @@ static void SetPointer(FState *state, PSymbol *sym, int frame = 0) else { FString symname = sym->SymbolName.GetChars(); - state->SetAction(static_cast(sym)); + state->SetAction(static_cast(sym)->Function); // Note: CompareNoCase() calls stricmp() and therefore returns 0 when they're the same. for (unsigned int i = 0; i < MBFCodePointers.Size(); i++) diff --git a/src/dobjgc.cpp b/src/dobjgc.cpp index 101729037..3bdca01bd 100644 --- a/src/dobjgc.cpp +++ b/src/dobjgc.cpp @@ -71,6 +71,7 @@ #include "r_interpolate.h" #include "doomstat.h" #include "m_argv.h" +#include "autosegs.h" // MACROS ------------------------------------------------------------------ @@ -328,6 +329,17 @@ static void MarkRoot() SectorMarker->SecNum = 0; } Mark(SectorMarker); + // Mark action functions + if (!FinalGC) + { + FAutoSegIterator probe(ARegHead, ARegTail); + + while (*++probe != NULL) + { + AFuncDesc *afunc = (AFuncDesc *)*probe; + Mark(*(afunc->VMPointer)); + } + } // Mark classes for (unsigned j = 0; j < PClass::m_Types.Size(); ++j) { @@ -362,7 +374,7 @@ static void MarkRoot() // // Atomic // -// If their were any propagations that needed to be done atomicly, they +// If there were any propagations that needed to be done atomicly, they // would go here. It also sets things up for the sweep state. // //========================================================================== diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 236646820..33faac64d 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -224,7 +224,7 @@ void PClass::InsertIntoHash () } // Find a type, passed the name as a name -const PClass *PClass::FindClass (FName zaname) +PClass *PClass::FindClass (FName zaname) { if (zaname == NAME_None) { @@ -518,7 +518,9 @@ size_t PClass::PropagateMark() IMPLEMENT_ABSTRACT_CLASS(PSymbol); IMPLEMENT_CLASS(PSymbolConst); IMPLEMENT_CLASS(PSymbolVariable); -IMPLEMENT_CLASS(PSymbolActionFunction); +IMPLEMENT_POINTY_CLASS(PSymbolActionFunction) + DECLARE_POINTER(Function) +END_POINTERS IMPLEMENT_POINTY_CLASS(PSymbolVMFunction) DECLARE_POINTER(Function) END_POINTERS diff --git a/src/dobjtype.h b/src/dobjtype.h index 5ad13eaf6..b6ff7bc43 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -6,6 +6,7 @@ #endif #include "thingdef/thingdef_type.h" +#include "vm.h" // Symbol information ------------------------------------------------------- @@ -81,23 +82,27 @@ public: // parameters passed. struct FState; struct StateCallData; -typedef void (*actionf_p)(AActor *self, AActor *stateowner, FState *state, int parameters, StateCallData *statecall); +class VMFrameStack; +struct VMValue; +struct VMReturn; +typedef int (*actionf_p)(VMFrameStack *stack, VMValue *param, int numparam, VMReturn *ret, int numret);/*(VM_ARGS)*/ +class VMFunction; class PSymbolActionFunction : public PSymbol { DECLARE_CLASS(PSymbolActionFunction, PSymbol); + HAS_OBJECT_POINTERS; public: FString Arguments; - actionf_p Function; + VMFunction *Function; int defaultparameterindex; PSymbolActionFunction(FName name) : PSymbol(name, SYM_ActionFunction) {} PSymbolActionFunction() : PSymbol(NAME_None, SYM_ActionFunction) {} }; -// A symbol table ----------------------------------------------------------- +// A VM function ------------------------------------------------------------ -class VMFunction; class PSymbolVMFunction : public PSymbol { DECLARE_CLASS(PSymbolVMFunction, PSymbol); @@ -195,10 +200,10 @@ public: } // Find a type, given its name. - static const PClass *FindClass (const char *name) { return FindClass (FName (name, true)); } - static const PClass *FindClass (const FString &name) { return FindClass (FName (name, true)); } - static const PClass *FindClass (ENamedName name) { return FindClass (FName (name)); } - static const PClass *FindClass (FName name); + static PClass *FindClass (const char *name) { return FindClass (FName (name, true)); } + static PClass *FindClass (const FString &name) { return FindClass (FName (name, true)); } + static PClass *FindClass (ENamedName name) { return FindClass (FName (name)); } + static PClass *FindClass (FName name); const PClass *FindClassTentative (FName name); // not static! static TArray m_Types; diff --git a/src/g_doom/a_arachnotron.cpp b/src/g_doom/a_arachnotron.cpp index 19c3bb63a..65e258720 100644 --- a/src/g_doom/a_arachnotron.cpp +++ b/src/g_doom/a_arachnotron.cpp @@ -8,18 +8,23 @@ */ DEFINE_ACTION_FUNCTION(AActor, A_BspiAttack) -{ +{ + PARAM_ACTION_PROLOGUE; + if (!self->target) - return; + return 0; A_FaceTarget (self); // launch a missile P_SpawnMissile (self, self->target, PClass::FindClass("ArachnotronPlasma")); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_BabyMetal) { + PARAM_ACTION_PROLOGUE; S_Sound (self, CHAN_BODY, "baby/walk", 1, ATTN_IDLE); - A_Chase (self); + A_Chase (stack, self); + return 0; } diff --git a/src/g_doom/a_archvile.cpp b/src/g_doom/a_archvile.cpp index 53e0ea202..88fd5f565 100644 --- a/src/g_doom/a_archvile.cpp +++ b/src/g_doom/a_archvile.cpp @@ -21,7 +21,9 @@ void A_Fire(AActor *self, int height); // DEFINE_ACTION_FUNCTION(AActor, A_VileStart) { + PARAM_ACTION_PROLOGUE; S_Sound (self, CHAN_VOICE, "vile/start", 1, ATTN_NORM); + return 0; } @@ -31,22 +33,27 @@ DEFINE_ACTION_FUNCTION(AActor, A_VileStart) // DEFINE_ACTION_FUNCTION(AActor, A_StartFire) { + PARAM_ACTION_PROLOGUE; S_Sound (self, CHAN_BODY, "vile/firestrt", 1, ATTN_NORM); A_Fire (self, 0); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_FireCrackle) { + PARAM_ACTION_PROLOGUE; S_Sound (self, CHAN_BODY, "vile/firecrkl", 1, ATTN_NORM); A_Fire (self, 0); + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Fire) { - ACTION_PARAM_START(1); - ACTION_PARAM_FIXED(height,0); + PARAM_ACTION_PROLOGUE; + PARAM_FIXED_OPT(height) { height = 0; } A_Fire(self, height); + return 0; } void A_Fire(AActor *self, int height) @@ -77,12 +84,13 @@ void A_Fire(AActor *self, int height) // DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileTarget) { - ACTION_PARAM_START(1); - ACTION_PARAM_CLASS(fire,0); + PARAM_ACTION_PROLOGUE; + PARAM_CLASS_OPT(fire, AActor) { fire = PClass::FindClass("ArchvileFire"); } + AActor *fog; if (!self->target) - return; + return 0; A_FaceTarget (self); @@ -93,6 +101,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileTarget) fog->target = self; fog->tracer = self->target; A_Fire(fog, 0); + return 0; } @@ -102,25 +111,25 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileTarget) // A_VileAttack // DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileAttack) -{ - ACTION_PARAM_START(6); - ACTION_PARAM_SOUND(snd,0); - ACTION_PARAM_INT(dmg,1); - ACTION_PARAM_INT(blastdmg,2); - ACTION_PARAM_INT(blastrad,3); - ACTION_PARAM_FIXED(thrust,4); - ACTION_PARAM_NAME(dmgtype,5); +{ + PARAM_ACTION_PROLOGUE; + PARAM_SOUND_OPT (snd) { snd = "vile/stop"; } + PARAM_INT_OPT (dmg) { dmg = 20; } + PARAM_INT_OPT (blastdmg) { blastdmg = 70; } + PARAM_INT_OPT (blastrad) { blastrad = 70; } + PARAM_FIXED_OPT (thrust) { thrust = FRACUNIT; } + PARAM_NAME_OPT (dmgtype) { dmgtype = NAME_Fire; } AActor *fire, *target; angle_t an; if (NULL == (target = self->target)) - return; + return 0; A_FaceTarget (self); if (!P_CheckSight (self, target, 0) ) - return; + return 0; S_Sound (self, CHAN_WEAPON, snd, 1, ATTN_NORM); P_TraceBleed (dmg, target); @@ -139,4 +148,5 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileAttack) P_RadiusAttack (fire, self, blastdmg, blastrad, dmgtype, false); } target->velz = Scale(thrust, 1000, target->Mass); + return 0; } diff --git a/src/g_doom/a_bossbrain.cpp b/src/g_doom/a_bossbrain.cpp index 7764f2ecd..49517bb8e 100644 --- a/src/g_doom/a_bossbrain.cpp +++ b/src/g_doom/a_bossbrain.cpp @@ -18,13 +18,17 @@ static FRandom pr_spawnfly ("SpawnFly"); DEFINE_ACTION_FUNCTION(AActor, A_BrainAwake) { + PARAM_ACTION_PROLOGUE; // killough 3/26/98: only generates sound now S_Sound (self, CHAN_VOICE, "brain/sight", 1, ATTN_NONE); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_BrainPain) { + PARAM_ACTION_PROLOGUE; S_Sound (self, CHAN_VOICE, "brain/pain", 1, ATTN_NONE); + return 0; } static void BrainishExplosion (fixed_t x, fixed_t y, fixed_t z) @@ -53,6 +57,7 @@ static void BrainishExplosion (fixed_t x, fixed_t y, fixed_t z) DEFINE_ACTION_FUNCTION(AActor, A_BrainScream) { + PARAM_ACTION_PROLOGUE; fixed_t x; for (x = self->x - 196*FRACUNIT; x < self->x + 320*FRACUNIT; x += 8*FRACUNIT) @@ -61,34 +66,40 @@ DEFINE_ACTION_FUNCTION(AActor, A_BrainScream) 128 + (pr_brainscream() << (FRACBITS + 1))); } S_Sound (self, CHAN_VOICE, "brain/death", 1, ATTN_NONE); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_BrainExplode) { + PARAM_ACTION_PROLOGUE; fixed_t x = self->x + pr_brainexplode.Random2()*2048; fixed_t z = 128 + pr_brainexplode()*2*FRACUNIT; BrainishExplosion (x, self->y, z); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_BrainDie) { + PARAM_ACTION_PROLOGUE; + // [RH] If noexit, then don't end the level. if ((deathmatch || alwaysapplydmflags) && (dmflags & DF_NO_EXIT)) - return; + return 0; G_ExitLevel (0, false); + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BrainSpit) { + PARAM_ACTION_PROLOGUE; + PARAM_CLASS(spawntype, AActor); + DSpotState *state = DSpotState::GetSpotState(); AActor *targ; 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)); @@ -135,6 +146,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BrainSpit) S_Sound (self, CHAN_WEAPON, "brain/spit", 1, ATTN_NONE); } } + return 0; } static void SpawnFly(AActor *self, const PClass *spawntype, FSoundID sound) @@ -255,10 +267,10 @@ static void SpawnFly(AActor *self, const PClass *spawntype, FSoundID sound) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnFly) { - FSoundID sound; + PARAM_ACTION_PROLOGUE; + PARAM_CLASS_OPT (spawntype, AActor) { spawntype = NULL; } - ACTION_PARAM_START(1); - ACTION_PARAM_CLASS(spawntype, 0); + FSoundID sound; if (spawntype != NULL) { @@ -266,15 +278,18 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnFly) } else { - spawntype = PClass::FindClass ("SpawnFire"); + spawntype = PClass::FindClass("SpawnFire"); sound = "brain/spawn"; } SpawnFly(self, spawntype, sound); + return 0; } // travelling cube sound DEFINE_ACTION_FUNCTION(AActor, A_SpawnSound) { + PARAM_ACTION_PROLOGUE; S_Sound (self, CHAN_BODY, "brain/cube", 1, ATTN_IDLE); SpawnFly(self, PClass::FindClass("SpawnFire"), "brain/spawn"); + return 0; } diff --git a/src/g_doom/a_bruiser.cpp b/src/g_doom/a_bruiser.cpp index 24c6c48eb..c4adec04f 100644 --- a/src/g_doom/a_bruiser.cpp +++ b/src/g_doom/a_bruiser.cpp @@ -3,8 +3,10 @@ static FRandom pr_bruisattack ("BruisAttack"); DEFINE_ACTION_FUNCTION(AActor, A_BruisAttack) { + PARAM_ACTION_PROLOGUE; + if (!self->target) - return; + return 0; if (self->CheckMeleeRange ()) { @@ -12,9 +14,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_BruisAttack) S_Sound (self, CHAN_WEAPON, "baron/melee", 1, ATTN_NORM); P_DamageMobj (self->target, self, self, damage, NAME_Melee); P_TraceBleed (damage, self->target, self); - return; + return 0; } // launch a missile P_SpawnMissile (self, self->target, PClass::FindClass("BaronBall")); + return 0; } diff --git a/src/g_doom/a_cacodemon.cpp b/src/g_doom/a_cacodemon.cpp index 0eb923890..1fd9b3ce4 100644 --- a/src/g_doom/a_cacodemon.cpp +++ b/src/g_doom/a_cacodemon.cpp @@ -14,8 +14,10 @@ static FRandom pr_headattack ("HeadAttack"); DEFINE_ACTION_FUNCTION(AActor, A_HeadAttack) { + PARAM_ACTION_PROLOGUE; + if (!self->target) - return; + return 0; A_FaceTarget (self); if (self->CheckMeleeRange ()) @@ -24,9 +26,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_HeadAttack) S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); P_DamageMobj (self->target, self, self, damage, NAME_Melee); P_TraceBleed (damage, self->target, self); - return; + return 0; } // launch a missile P_SpawnMissile (self, self->target, PClass::FindClass("CacodemonBall")); + return 0; } diff --git a/src/g_doom/a_cyberdemon.cpp b/src/g_doom/a_cyberdemon.cpp index f13728e48..a7d7409ea 100644 --- a/src/g_doom/a_cyberdemon.cpp +++ b/src/g_doom/a_cyberdemon.cpp @@ -9,15 +9,21 @@ DEFINE_ACTION_FUNCTION(AActor, A_CyberAttack) { + PARAM_ACTION_PROLOGUE; + if (!self->target) - return; + return 0; A_FaceTarget (self); P_SpawnMissile (self, self->target, PClass::FindClass("Rocket")); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_Hoof) { + PARAM_ACTION_PROLOGUE; + S_Sound (self, CHAN_BODY, "cyber/hoof", 1, ATTN_IDLE); - A_Chase (self); + A_Chase (stack, self); + return 0; } diff --git a/src/g_doom/a_demon.cpp b/src/g_doom/a_demon.cpp index c890c32b0..c8df07cca 100644 --- a/src/g_doom/a_demon.cpp +++ b/src/g_doom/a_demon.cpp @@ -13,8 +13,10 @@ static FRandom pr_sargattack ("SargAttack"); DEFINE_ACTION_FUNCTION(AActor, A_SargAttack) { + PARAM_ACTION_PROLOGUE; + if (!self->target) - return; + return 0; A_FaceTarget (self); if (self->CheckMeleeRange ()) @@ -23,4 +25,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_SargAttack) P_DamageMobj (self->target, self, self, damage, NAME_Melee); P_TraceBleed (damage, self->target, self); } + return 0; } diff --git a/src/g_doom/a_doomimp.cpp b/src/g_doom/a_doomimp.cpp index 401fa4577..025fb7d27 100644 --- a/src/g_doom/a_doomimp.cpp +++ b/src/g_doom/a_doomimp.cpp @@ -17,8 +17,10 @@ static FRandom pr_troopattack ("TroopAttack"); // DEFINE_ACTION_FUNCTION(AActor, A_TroopAttack) { + PARAM_ACTION_PROLOGUE; + if (!self->target) - return; + return 0; A_FaceTarget (self); if (self->CheckMeleeRange ()) @@ -27,9 +29,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_TroopAttack) S_Sound (self, CHAN_WEAPON, "imp/melee", 1, ATTN_NORM); P_DamageMobj (self->target, self, self, damage, NAME_Melee); P_TraceBleed (damage, self->target, self); - return; + return 0; } // launch a missile P_SpawnMissile (self, self->target, PClass::FindClass("DoomImpBall")); + return 0; } diff --git a/src/g_doom/a_doommisc.cpp b/src/g_doom/a_doommisc.cpp index 898068d66..883cd3a5c 100644 --- a/src/g_doom/a_doommisc.cpp +++ b/src/g_doom/a_doommisc.cpp @@ -37,6 +37,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_BarrelDestroy) { + PARAM_ACTION_PROLOGUE; + if ((dmflags2 & DF2_BARRELS_RESPAWN) && (deathmatch || alwaysapplydmflags)) { @@ -48,5 +50,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_BarrelDestroy) { self->Destroy (); } + return 0; } diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index fcd6ea3a0..024495ce6 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -28,6 +28,8 @@ static FRandom pr_oldbfg ("OldBFG"); // DEFINE_ACTION_FUNCTION(AActor, A_Punch) { + PARAM_ACTION_PROLOGUE; + angle_t angle; int damage; int pitch; @@ -39,7 +41,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch) if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } } @@ -63,6 +65,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch) linetarget->x, linetarget->y); } + return 0; } // @@ -70,6 +73,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch) // DEFINE_ACTION_FUNCTION(AActor, A_FirePistol) { + PARAM_ACTION_PROLOGUE; + bool accurate; if (self->player != NULL) @@ -78,7 +83,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePistol) if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; P_SetPsprite (self->player, ps_flash, weapon->FindState(NAME_Flash)); } @@ -94,6 +99,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePistol) S_Sound (self, CHAN_WEAPON, "weapons/pistol", 1, ATTN_NORM); P_GunShot (self, accurate, PClass::FindClass(NAME_BulletPuff), P_BulletSlope (self)); + return 0; } // @@ -101,32 +107,34 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePistol) // DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw) { + PARAM_ACTION_PROLOGUE; + PARAM_SOUND_OPT (fullsound) { fullsound = "weapons/sawfull"; } + PARAM_SOUND_OPT (hitsound) { hitsound = "weapons/sawhit"; } + PARAM_INT_OPT (damage) { damage = 2; } + PARAM_CLASS_OPT (pufftype, AActor) { pufftype = NULL; } + angle_t angle; player_t *player; AActor *linetarget; - 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)) { - return; + return 0; } AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } - if (pufftype == NULL) pufftype = PClass::FindClass(NAME_BulletPuff); - if (damage == 0) damage = 2; + if (pufftype == NULL) + pufftype = PClass::FindClass(NAME_BulletPuff); + if (damage == 0) + damage = 2; - damage *= (pr_saw()%10+1); + damage *= (pr_saw()%10 + 1); angle = self->angle; angle += pr_saw.Random2() << 18; @@ -138,7 +146,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw) if (!linetarget) { S_Sound (self, CHAN_WEAPON, fullsound, 1, ATTN_NORM); - return; + return 0; } S_Sound (self, CHAN_WEAPON, hitsound, 1, ATTN_NORM); @@ -160,6 +168,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw) self->angle += ANG90/20; } self->flags |= MF_JUSTATTACKED; + return 0; } // @@ -167,12 +176,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw) // DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun) { + PARAM_ACTION_PROLOGUE; + int i; player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } S_Sound (self, CHAN_WEAPON, "weapons/shotgf", 1, ATTN_NORM); @@ -180,7 +191,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun) if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; P_SetPsprite (player, ps_flash, weapon->FindState(NAME_Flash)); } player->mo->PlayAttacking2 (); @@ -189,6 +200,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun) for (i=0 ; i<7 ; i++) P_GunShot (self, false, PClass::FindClass(NAME_BulletPuff), pitch); + return 0; } // @@ -196,6 +208,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun) // DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2) { + PARAM_ACTION_PROLOGUE; + int i; angle_t angle; int damage; @@ -203,7 +217,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2) if (NULL == (player = self->player)) { - return; + return 0; } S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM); @@ -211,7 +225,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2) if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; P_SetPsprite (player, ps_flash, weapon->FindState(NAME_Flash)); } player->mo->PlayAttacking2 (); @@ -237,22 +251,29 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2) pitch + (pr_fireshotgun2.Random2() * 332063), damage, NAME_None, NAME_BulletPuff); } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_OpenShotgun2) { + PARAM_ACTION_PROLOGUE; S_Sound (self, CHAN_WEAPON, "weapons/sshoto", 1, ATTN_NORM); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_LoadShotgun2) { + PARAM_ACTION_PROLOGUE; S_Sound (self, CHAN_WEAPON, "weapons/sshotl", 1, ATTN_NORM); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_CloseShotgun2) { + PARAM_ACTION_PROLOGUE; S_Sound (self, CHAN_WEAPON, "weapons/sshotc", 1, ATTN_NORM); CALL_ACTION(A_ReFire, self); + return 0; } @@ -305,18 +326,20 @@ void P_SetSafeFlash(AWeapon * weapon, player_t * player, FState * flashstate, in // DEFINE_ACTION_FUNCTION(AActor, A_FireCGun) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (self == NULL || NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; S_Sound (self, CHAN_WEAPON, "weapons/chngun", 1, ATTN_NORM); @@ -340,6 +363,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCGun) player->mo->PlayAttacking2 (); P_GunShot (self, !player->refire, PClass::FindClass(NAME_BulletPuff), P_BulletSlope (self)); + return 0; } // @@ -347,19 +371,22 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCGun) // DEFINE_ACTION_FUNCTION(AActor, A_FireMissile) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } P_SpawnPlayerMissile (self, PClass::FindClass("Rocket")); + return 0; } // @@ -367,20 +394,23 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMissile) // DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireSTGrenade) { + PARAM_ACTION_PROLOGUE; + PARAM_CLASS_OPT(grenade, AActor) { grenade = PClass::FindClass("Grenade"); } + player_t *player; - ACTION_PARAM_START(1); - ACTION_PARAM_CLASS(grenade, 0); - if (grenade == NULL) return; + + if (grenade == NULL) + return 0; if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } // Temporarily raise the pitch to send the grenade slightly upwards @@ -388,6 +418,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireSTGrenade) self->pitch -= (1152 << FRACBITS); P_SpawnPlayerMissile(self, grenade); self->pitch = SavedPlayerPitch; + return 0; } // @@ -395,17 +426,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireSTGrenade) // DEFINE_ACTION_FUNCTION(AActor, A_FirePlasma) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; FState *flash = weapon->FindState(NAME_Flash); if (flash != NULL) @@ -415,6 +448,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePlasma) } P_SpawnPlayerMissile (self, PClass::FindClass("PlasmaBall")); + return 0; } // @@ -451,22 +485,29 @@ static void FireRailgun(AActor *self, int RailOffset) DEFINE_ACTION_FUNCTION(AActor, A_FireRailgun) { + PARAM_ACTION_PROLOGUE; FireRailgun(self, 0); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunRight) { + PARAM_ACTION_PROLOGUE; FireRailgun(self, 10); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunLeft) { + PARAM_ACTION_PROLOGUE; FireRailgun(self, -10); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_RailWait) { // Okay, this was stupid. Just use a NULL function instead of this. + return 0; } // @@ -475,21 +516,24 @@ DEFINE_ACTION_FUNCTION(AActor, A_RailWait) DEFINE_ACTION_FUNCTION(AActor, A_FireBFG) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } P_SpawnPlayerMissile (self, 0, 0, 0, PClass::FindClass("BFGBall"), self->angle, NULL, NULL, !!(dmflags2 & DF2_NO_FREEAIMBFG)); + return 0; } // @@ -498,6 +542,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireBFG) // DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) { + PARAM_ACTION_PROLOGUE; + PARAM_CLASS_OPT (spraytype, AActor) { spraytype = NULL; } + PARAM_INT_OPT (numrays) { numrays = 40; } + PARAM_INT_OPT (damagecnt) { damagecnt = 15; } + int i; int j; int damage; @@ -505,10 +554,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) AActor *thingToHit; AActor *linetarget; - ACTION_PARAM_START(3); - ACTION_PARAM_CLASS(spraytype, 0); - ACTION_PARAM_INT(numrays, 1); - ACTION_PARAM_INT(damagecnt, 2); if (spraytype == NULL) spraytype = PClass::FindClass("BFGExtra"); if (numrays <= 0) numrays = 40; @@ -516,7 +561,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) // [RH] Don't crash if no target if (!self->target) - return; + return 0; // offset angles from its attack angle for (i = 0; i < numrays; i++) @@ -544,6 +589,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) P_DamageMobj (thingToHit, self->target, self->target, damage, NAME_BFGSplash); P_TraceBleed (damage, thingToHit, self->target); } + return 0; } // @@ -551,7 +597,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) // DEFINE_ACTION_FUNCTION(AActor, A_BFGsound) { + PARAM_ACTION_PROLOGUE; S_Sound (self, CHAN_WEAPON, "weapons/bfgf", 1, ATTN_NORM); + return 0; } // @@ -565,6 +613,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BFGsound) DEFINE_ACTION_FUNCTION(AActor, A_FireOldBFG) { + PARAM_ACTION_PROLOGUE; const PClass * plasma[] = {PClass::FindClass("PlasmaBall1"), PClass::FindClass("PlasmaBall2")}; AActor * mo = NULL; @@ -572,14 +621,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireOldBFG) if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } self->player->extralight = 2; @@ -597,5 +646,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireOldBFG) self->angle = SavedPlayerAngle; self->pitch = SavedPlayerPitch; } - if (doesautoaim) self->player->ReadyWeapon->WeaponFlags &= ~WIF_NOAUTOAIM; // Restore autoaim setting + if (doesautoaim) + { // Restore autoaim setting + self->player->ReadyWeapon->WeaponFlags &= ~WIF_NOAUTOAIM; + } + return 0; } diff --git a/src/g_doom/a_fatso.cpp b/src/g_doom/a_fatso.cpp index e9dfa98e3..741622b9a 100644 --- a/src/g_doom/a_fatso.cpp +++ b/src/g_doom/a_fatso.cpp @@ -19,20 +19,23 @@ DEFINE_ACTION_FUNCTION(AActor, A_FatRaise) { + PARAM_ACTION_PROLOGUE; + A_FaceTarget (self); S_Sound (self, CHAN_WEAPON, "fatso/raiseguns", 1, ATTN_NORM); + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack1) { + PARAM_ACTION_PROLOGUE; + PARAM_CLASS_OPT(spawntype, AActor) { spawntype = NULL; } + AActor *missile; angle_t an; if (!self->target) - return; - - ACTION_PARAM_START(1); - ACTION_PARAM_CLASS(spawntype, 0); + return 0; if (spawntype == NULL) spawntype = PClass::FindClass("FatShot"); @@ -49,18 +52,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack1) missile->velx = FixedMul (missile->Speed, finecosine[an]); missile->vely = FixedMul (missile->Speed, finesine[an]); } + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack2) { + PARAM_ACTION_PROLOGUE; + PARAM_CLASS_OPT(spawntype, AActor) { spawntype = NULL; } + AActor *missile; angle_t an; if (!self->target) - return; - - ACTION_PARAM_START(1); - ACTION_PARAM_CLASS(spawntype, 0); + return 0; if (spawntype == NULL) spawntype = PClass::FindClass("FatShot"); @@ -77,18 +81,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack2) missile->velx = FixedMul (missile->Speed, finecosine[an]); missile->vely = FixedMul (missile->Speed, finesine[an]); } + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack3) { + PARAM_ACTION_PROLOGUE; + PARAM_CLASS_OPT(spawntype, AActor) { spawntype = NULL; } + AActor *missile; angle_t an; if (!self->target) - return; - - ACTION_PARAM_START(1); - ACTION_PARAM_CLASS(spawntype, 0); + return 0; if (spawntype == NULL) spawntype = PClass::FindClass("FatShot"); @@ -111,6 +116,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack3) missile->velx = FixedMul (missile->Speed, finecosine[an]); missile->vely = FixedMul (missile->Speed, finesine[an]); } + return 0; } // @@ -122,14 +128,14 @@ AActor * P_OldSpawnMissile(AActor * source, AActor * dest, const PClass *type); DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Mushroom) { - int i, j; + PARAM_ACTION_PROLOGUE; + PARAM_CLASS_OPT (spawntype, AActor) { spawntype = NULL; } + PARAM_INT_OPT (n) { n = 0; } + PARAM_INT_OPT (flags) { flags = 0; } + PARAM_FIXED_OPT (vrange) { vrange = 4*FRACUNIT; } + PARAM_FIXED_OPT (hrange) { hrange = FRACUNIT/2; } - ACTION_PARAM_START(5); - ACTION_PARAM_CLASS(spawntype, 0); - ACTION_PARAM_INT(n, 1); - ACTION_PARAM_INT(flags, 2); - ACTION_PARAM_FIXED(vrange, 3); - ACTION_PARAM_FIXED(hrange, 4); + int i, j; if (n == 0) n = self->Damage; // GetMissileDamage (0, 1); if (spawntype == NULL) spawntype = PClass::FindClass("FatShot"); @@ -169,4 +175,5 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Mushroom) } } target->Destroy(); + return 0; } diff --git a/src/g_doom/a_keen.cpp b/src/g_doom/a_keen.cpp index 42231a915..2cb7196d1 100644 --- a/src/g_doom/a_keen.cpp +++ b/src/g_doom/a_keen.cpp @@ -13,8 +13,12 @@ // DOOM II special, map 32. // Uses special tag 666 by default. // + DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_KeenDie) { + PARAM_ACTION_PROLOGUE; + PARAM_INT(doortag); + CALL_ACTION(A_NoBlocking, self); // scan the remaining thinkers to see if all Keens are dead @@ -27,14 +31,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_KeenDie) if (other != self && other->health > 0 && other->IsA (matchClass)) { // other Keen not dead - return; + return 0; } } - ACTION_PARAM_START(1); - ACTION_PARAM_INT(doortag, 0); - EV_DoDoor (DDoor::doorOpen, NULL, NULL, doortag, 2*FRACUNIT, 0, 0, 0); + return 0; } diff --git a/src/g_doom/a_lostsoul.cpp b/src/g_doom/a_lostsoul.cpp index c648afaba..5851b158b 100644 --- a/src/g_doom/a_lostsoul.cpp +++ b/src/g_doom/a_lostsoul.cpp @@ -48,24 +48,29 @@ void A_SkullAttack(AActor *self, fixed_t speed) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullAttack) { - ACTION_PARAM_START(1); - ACTION_PARAM_FIXED(n, 0); + PARAM_ACTION_PROLOGUE; + PARAM_FIXED_OPT(speed) { speed = SKULLSPEED; } - if (n <= 0) n = SKULLSPEED; - A_SkullAttack(self, n); + if (speed <= 0) + speed = SKULLSPEED; + A_SkullAttack(self, speed); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_BetaSkullAttack) { + PARAM_ACTION_PROLOGUE; + int damage; if (!self || !self->target || self->target->GetSpecies() == self->GetSpecies()) - return; + return 0; S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); A_FaceTarget(self); damage = (pr_oldsoul()%8+1)*self->Damage; P_DamageMobj(self->target, self, self, damage, NAME_None); + return 0; } diff --git a/src/g_doom/a_painelemental.cpp b/src/g_doom/a_painelemental.cpp index bf0d0501b..f0c77eaef 100644 --- a/src/g_doom/a_painelemental.cpp +++ b/src/g_doom/a_painelemental.cpp @@ -12,13 +12,22 @@ DECLARE_ACTION(A_SkullAttack) -static const PClass *GetSpawnType(DECLARE_PARAMINFO) +static const PClass *GetSpawnType(VMValue *param) { - ACTION_PARAM_START(1); - ACTION_PARAM_CLASS(spawntype, 0); + const PClass *spawntype; - if (spawntype == NULL) spawntype = PClass::FindClass("LostSoul"); - return spawntype; + if (param == NULL || param->Type == REGT_NIL) + { + spawntype = NULL; + } + else + { + assert(param->Type == REGT_POINTER); + assert(param->atag == ATAG_OBJECT || param->a == NULL); + spawntype = (const PClass *)param->a; + } + + return (spawntype != NULL) ? spawntype : PClass::FindClass("LostSoul"); } @@ -38,7 +47,7 @@ void A_PainShootSkull (AActor *self, angle_t angle, const PClass *spawntype) int prestep; if (spawntype == NULL) return; - if (self->DamageType==NAME_Massacre) return; + if (self->DamageType == NAME_Massacre) return; // [RH] check to make sure it's not too close to the ceiling if (self->z + self->height + 8*FRACUNIT > self->ceilingz) @@ -139,34 +148,43 @@ void A_PainShootSkull (AActor *self, angle_t angle, const PClass *spawntype) // DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PainAttack) { - if (!self->target) - return; + PARAM_ACTION_PROLOGUE; - const PClass *spawntype = GetSpawnType(PUSH_PARAMINFO); + if (!self->target) + return 0; + + const PClass *spawntype = GetSpawnType(numparam > NAP ? ¶m[NAP] : NULL); A_FaceTarget (self); A_PainShootSkull (self, self->angle, spawntype); + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DualPainAttack) { - if (!self->target) - return; + PARAM_ACTION_PROLOGUE; - const PClass *spawntype = GetSpawnType(PUSH_PARAMINFO); + if (!self->target) + return 0; + + const PClass *spawntype = GetSpawnType(numparam > NAP ? ¶m[NAP] : NULL); A_FaceTarget (self); A_PainShootSkull (self, self->angle + ANG45, spawntype); A_PainShootSkull (self, self->angle - ANG45, spawntype); + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PainDie) { - if (self->target != NULL && self->IsFriend (self->target)) + PARAM_ACTION_PROLOGUE; + + if (self->target != NULL && self->IsFriend(self->target)) { // And I thought you were my friend! self->flags &= ~MF_FRIENDLY; } - const PClass *spawntype = GetSpawnType(PUSH_PARAMINFO); + const PClass *spawntype = GetSpawnType(numparam > NAP ? ¶m[NAP] : NULL); CALL_ACTION(A_NoBlocking, self); A_PainShootSkull (self, self->angle + ANG90, spawntype); A_PainShootSkull (self, self->angle + ANG180, spawntype); A_PainShootSkull (self, self->angle + ANG270, spawntype); + return 0; } diff --git a/src/g_doom/a_possessed.cpp b/src/g_doom/a_possessed.cpp index e435bff14..af34dfe5f 100644 --- a/src/g_doom/a_possessed.cpp +++ b/src/g_doom/a_possessed.cpp @@ -20,12 +20,14 @@ static FRandom pr_cposrefire ("CPosRefire"); // DEFINE_ACTION_FUNCTION(AActor, A_PosAttack) { + PARAM_ACTION_PROLOGUE; + int angle; int damage; int slope; if (!self->target) - return; + return 0; A_FaceTarget (self); angle = self->angle; @@ -35,6 +37,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PosAttack) angle += pr_posattack.Random2() << 20; damage = ((pr_posattack()%5)+1)*3; P_LineAttack (self, angle, MISSILERANGE, slope, damage, NAME_None, NAME_BulletPuff); + return 0; } static void A_SPosAttack2 (AActor *self) @@ -57,33 +60,41 @@ static void A_SPosAttack2 (AActor *self) DEFINE_ACTION_FUNCTION(AActor, A_SPosAttackUseAtkSound) { + PARAM_ACTION_PROLOGUE; + if (!self->target) - return; + return 0; S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); A_SPosAttack2 (self); + return 0; } // This version of the function, which uses a hard-coded sound, is // meant for Dehacked only. DEFINE_ACTION_FUNCTION(AActor, A_SPosAttack) { + PARAM_ACTION_PROLOGUE; + if (!self->target) - return; + return 0; S_Sound (self, CHAN_WEAPON, "shotguy/attack", 1, ATTN_NORM); A_SPosAttack2 (self); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_CPosAttack) { + PARAM_ACTION_PROLOGUE; + int angle; int bangle; int damage; int slope; if (!self->target) - return; + return 0; // [RH] Andy Baker's stealth monsters if (self->flags & MF_STEALTH) @@ -99,15 +110,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_CPosAttack) angle = bangle + (pr_cposattack.Random2() << 20); damage = ((pr_cposattack()%5)+1)*3; P_LineAttack (self, angle, MISSILERANGE, slope, damage, NAME_None, NAME_BulletPuff); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_CPosRefire) { + PARAM_ACTION_PROLOGUE; + // keep firing unless target got out of sight A_FaceTarget (self); if (pr_cposrefire() < 40) - return; + return 0; if (!self->target || P_HitFriend (self) @@ -116,4 +130,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_CPosRefire) { self->SetState (self->SeeState); } + return 0; } diff --git a/src/g_doom/a_revenant.cpp b/src/g_doom/a_revenant.cpp index 92a3dc13f..b03106892 100644 --- a/src/g_doom/a_revenant.cpp +++ b/src/g_doom/a_revenant.cpp @@ -19,11 +19,13 @@ static FRandom pr_skelfist ("SkelFist"); // A_SkelMissile // DEFINE_ACTION_FUNCTION(AActor, A_SkelMissile) -{ +{ + PARAM_ACTION_PROLOGUE; + AActor *missile; if (!self->target) - return; + return 0; A_FaceTarget (self); missile = P_SpawnMissileZ (self, self->z + 48*FRACUNIT, @@ -35,12 +37,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkelMissile) missile->y += missile->vely; missile->tracer = self->target; } + return 0; } #define TRACEANGLE (0xc000000) DEFINE_ACTION_FUNCTION(AActor, A_Tracer) { + PARAM_ACTION_PROLOGUE; + angle_t exact; fixed_t dist; fixed_t slope; @@ -57,7 +62,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer) // [RH] level.time is always 0-based, so nothing special to do here. if (level.time & 3) - return; + return 0; // spawn a puff of smoke behind the rocket P_SpawnPuff (self, PClass::FindClass(NAME_BulletPuff), self->x, self->y, self->z, 0, 3); @@ -74,7 +79,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer) dest = self->tracer; if (!dest || dest->health <= 0 || self->Speed == 0 || !self->CanSeek(dest)) - return; + return 0; // change angle exact = R_PointToAngle2 (self->x, self->y, dest->x, dest->y); @@ -124,21 +129,27 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer) else self->velz += FRACUNIT/8; } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_SkelWhoosh) { + PARAM_ACTION_PROLOGUE; + if (!self->target) - return; + return 0; A_FaceTarget (self); S_Sound (self, CHAN_WEAPON, "skeleton/swing", 1, ATTN_NORM); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_SkelFist) { + PARAM_ACTION_PROLOGUE; + if (!self->target) - return; + return 0; A_FaceTarget (self); @@ -149,4 +160,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkelFist) P_DamageMobj (self->target, self, self, damage, NAME_Melee); P_TraceBleed (damage, self->target, self); } + return 0; } diff --git a/src/g_doom/a_scriptedmarine.cpp b/src/g_doom/a_scriptedmarine.cpp index 9f6f54051..6ca1c1995 100644 --- a/src/g_doom/a_scriptedmarine.cpp +++ b/src/g_doom/a_scriptedmarine.cpp @@ -164,17 +164,19 @@ void AScriptedMarine::Tick () DEFINE_ACTION_FUNCTION(AActor, A_M_Refire) { + PARAM_ACTION_PROLOGUE; + if (self->target == NULL || self->target->health <= 0) { if (self->MissileState && pr_m_refire() < 160) { // Look for a new target most of the time if (P_LookForPlayers (self, true, NULL) && P_CheckMissileRange (self)) { // Found somebody new and in range, so don't stop shooting - return; + return 0; } } self->SetState (self->state + 1); - return; + return 0; } if ((self->MissileState == NULL && !self->CheckMeleeRange ()) || !P_CheckSight (self, self->target) || @@ -182,6 +184,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_Refire) { self->SetState (self->state + 1); } + return 0; } //============================================================================ @@ -192,15 +195,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_Refire) DEFINE_ACTION_FUNCTION(AActor, A_M_SawRefire) { + PARAM_ACTION_PROLOGUE; + if (self->target == NULL || self->target->health <= 0) { self->SetState (self->state + 1); - return; + return 0; } if (!self->CheckMeleeRange ()) { self->SetState (self->state + 1); } + return 0; } //============================================================================ @@ -211,10 +217,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_SawRefire) DEFINE_ACTION_FUNCTION(AActor, A_MarineNoise) { + PARAM_ACTION_PROLOGUE; + if (static_cast(self)->CurrentWeapon == AScriptedMarine::WEAPON_Chainsaw) { S_Sound (self, CHAN_WEAPON, "weapons/sawidle", 1, ATTN_NORM); } + return 0; } //============================================================================ @@ -225,8 +234,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_MarineNoise) DEFINE_ACTION_FUNCTION(AActor, A_MarineChase) { + PARAM_ACTION_PROLOGUE; CALL_ACTION(A_MarineNoise, self); - A_Chase (self); + A_Chase (stack, self); + return 0; } //============================================================================ @@ -237,8 +248,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_MarineChase) DEFINE_ACTION_FUNCTION(AActor, A_MarineLook) { + PARAM_ACTION_PROLOGUE; CALL_ACTION(A_MarineNoise, self); CALL_ACTION(A_Look, self); + return 0; } //============================================================================ @@ -249,14 +262,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_MarineLook) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Saw) { - ACTION_PARAM_START(4); - ACTION_PARAM_SOUND(fullsound, 0); - ACTION_PARAM_SOUND(hitsound, 1); - ACTION_PARAM_INT(damage, 2); - ACTION_PARAM_CLASS(pufftype, 3); + PARAM_ACTION_PROLOGUE; + PARAM_SOUND_OPT (fullsound) { fullsound = "weapons/sawfull"; } + PARAM_SOUND_OPT (hitsound) { hitsound = "weapons/sawhit"; } + PARAM_INT_OPT (damage) { damage = 2; } + PARAM_CLASS_OPT (pufftype, AActor) { pufftype = NULL; } if (self->target == NULL) - return; + return 0; if (pufftype == NULL) pufftype = PClass::FindClass(NAME_BulletPuff); if (damage == 0) damage = 2; @@ -277,7 +290,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Saw) if (!linetarget) { S_Sound (self, CHAN_WEAPON, fullsound, 1, ATTN_NORM); - return; + return 0; } S_Sound (self, CHAN_WEAPON, hitsound, 1, ATTN_NORM); @@ -303,6 +316,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Saw) S_Sound (self, CHAN_WEAPON, fullsound, 1, ATTN_NORM); } //A_Chase (self); + return 0; } //============================================================================ @@ -338,10 +352,11 @@ static void MarinePunch(AActor *self, int damagemul) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Punch) { - ACTION_PARAM_START(1); - ACTION_PARAM_INT(mult, 0); + PARAM_ACTION_PROLOGUE; + PARAM_INT(mult); MarinePunch(self, mult); + return 0; } //============================================================================ @@ -374,16 +389,17 @@ void P_GunShot2 (AActor *mo, bool accurate, int pitch, const PClass *pufftype) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_FirePistol) { - if (self->target == NULL) - return; + PARAM_ACTION_PROLOGUE; + PARAM_BOOL(accurate); - ACTION_PARAM_START(1); - ACTION_PARAM_BOOL(accurate, 0); + if (self->target == NULL) + return 0; S_Sound (self, CHAN_WEAPON, "weapons/pistol", 1, ATTN_NORM); A_FaceTarget (self); P_GunShot2 (self, accurate, P_AimLineAttack (self, self->angle, MISSILERANGE), PClass::FindClass(NAME_BulletPuff)); + return 0; } //============================================================================ @@ -394,10 +410,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_FirePistol) DEFINE_ACTION_FUNCTION(AActor, A_M_FireShotgun) { + PARAM_ACTION_PROLOGUE; + int pitch; if (self->target == NULL) - return; + return 0; S_Sound (self, CHAN_WEAPON, "weapons/shotgf", 1, ATTN_NORM); A_FaceTarget (self); @@ -407,6 +425,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_FireShotgun) P_GunShot2 (self, false, pitch, PClass::FindClass(NAME_BulletPuff)); } self->special1 = level.maptime + 27; + return 0; } //============================================================================ @@ -417,6 +436,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_FireShotgun) DEFINE_ACTION_FUNCTION(AActor, A_M_CheckAttack) { + PARAM_ACTION_PROLOGUE; + if (self->special1 != 0 || self->target == NULL) { self->SetState (self->FindState("SkipAttack")); @@ -425,6 +446,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_CheckAttack) { A_FaceTarget (self); } + return 0; } //============================================================================ @@ -435,10 +457,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_CheckAttack) DEFINE_ACTION_FUNCTION(AActor, A_M_FireShotgun2) { + PARAM_ACTION_PROLOGUE; + int pitch; if (self->target == NULL) - return; + return 0; S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM); A_FaceTarget (self); @@ -453,6 +477,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_FireShotgun2) NAME_None, PClass::FindClass(NAME_BulletPuff)); } self->special1 = level.maptime; + return 0; } //============================================================================ @@ -463,16 +488,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_FireShotgun2) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_FireCGun) { - if (self->target == NULL) - return; + PARAM_ACTION_PROLOGUE; + PARAM_BOOL(accurate); - ACTION_PARAM_START(1); - ACTION_PARAM_BOOL(accurate, 0); + if (self->target == NULL) + return 0; S_Sound (self, CHAN_WEAPON, "weapons/chngun", 1, ATTN_NORM); A_FaceTarget (self); P_GunShot2 (self, accurate, P_AimLineAttack (self, self->angle, MISSILERANGE), PClass::FindClass(NAME_BulletPuff)); + return 0; } //============================================================================ @@ -487,8 +513,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_FireCGun) DEFINE_ACTION_FUNCTION(AActor, A_M_FireMissile) { + PARAM_ACTION_PROLOGUE; + if (self->target == NULL) - return; + return 0; if (self->CheckMeleeRange ()) { // If too close, punch it @@ -499,6 +527,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_FireMissile) A_FaceTarget (self); P_SpawnMissile (self, self->target, PClass::FindClass("Rocket")); } + return 0; } //============================================================================ @@ -509,11 +538,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_FireMissile) DEFINE_ACTION_FUNCTION(AActor, A_M_FireRailgun) { + PARAM_ACTION_PROLOGUE; + if (self->target == NULL) - return; + return 0; CALL_ACTION(A_MonsterRail, self); self->special1 = level.maptime + 50; + return 0; } //============================================================================ @@ -524,12 +556,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_FireRailgun) DEFINE_ACTION_FUNCTION(AActor, A_M_FirePlasma) { + PARAM_ACTION_PROLOGUE; + if (self->target == NULL) - return; + return 0; A_FaceTarget (self); P_SpawnMissile (self, self->target, PClass::FindClass("PlasmaBall")); self->special1 = level.maptime + 20; + return 0; } //============================================================================ @@ -540,8 +575,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_FirePlasma) DEFINE_ACTION_FUNCTION(AActor, A_M_BFGsound) { + PARAM_ACTION_PROLOGUE; + if (self->target == NULL) - return; + return 0; if (self->special1 != 0) { @@ -554,6 +591,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_BFGsound) // Don't interrupt the firing sequence self->PainChance = 0; } + return 0; } //============================================================================ @@ -564,13 +602,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_BFGsound) DEFINE_ACTION_FUNCTION(AActor, A_M_FireBFG) { + PARAM_ACTION_PROLOGUE; + if (self->target == NULL) - return; + return 0; A_FaceTarget (self); P_SpawnMissile (self, self->target, PClass::FindClass("BFGBall")); self->special1 = level.maptime + 30; self->PainChance = MARINE_PAIN_CHANCE; + return 0; } //--------------------------------------------------------------------------- diff --git a/src/g_doom/a_spidermaster.cpp b/src/g_doom/a_spidermaster.cpp index a29561b56..f8d89ce5f 100644 --- a/src/g_doom/a_spidermaster.cpp +++ b/src/g_doom/a_spidermaster.cpp @@ -13,11 +13,13 @@ static FRandom pr_spidrefire ("SpidRefire"); DEFINE_ACTION_FUNCTION(AActor, A_SpidRefire) { + PARAM_ACTION_PROLOGUE; + // keep firing unless target got out of sight A_FaceTarget (self); if (pr_spidrefire() < 10) - return; + return 0; if (!self->target || P_HitFriend (self) @@ -26,10 +28,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpidRefire) { self->SetState (self->SeeState); } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_Metal) { + PARAM_ACTION_PROLOGUE; + S_Sound (self, CHAN_BODY, "spider/walk", 1, ATTN_IDLE); - A_Chase (self); + A_Chase (stack, self); + return 0; } diff --git a/src/g_heretic/a_chicken.cpp b/src/g_heretic/a_chicken.cpp index 86e71774f..86c4243cb 100644 --- a/src/g_heretic/a_chicken.cpp +++ b/src/g_heretic/a_chicken.cpp @@ -66,9 +66,11 @@ void AChickenPlayer::MorphPlayerThink () DEFINE_ACTION_FUNCTION(AActor, A_ChicAttack) { + PARAM_ACTION_PROLOGUE; + if (!self->target) { - return; + return 0; } if (self->CheckMeleeRange()) { @@ -76,6 +78,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ChicAttack) P_DamageMobj (self->target, self, self, damage, NAME_Melee); P_TraceBleed (damage, self->target, self); } + return 0; } //---------------------------------------------------------------------------- @@ -86,6 +89,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_ChicAttack) DEFINE_ACTION_FUNCTION(AActor, A_Feathers) { + PARAM_ACTION_PROLOGUE; + int i; int count; AActor *mo; @@ -107,6 +112,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Feathers) mo->velz = FRACUNIT + (pr_feathers() << 9); mo->SetState (mo->SpawnState + (pr_feathers()&7)); } + return 0; } //--------------------------------------------------------------------------- @@ -132,14 +138,17 @@ void P_UpdateBeak (AActor *self) DEFINE_ACTION_FUNCTION(AActor, A_BeakRaise) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } player->psprites[ps_weapon].sy = WEAPONTOP; P_SetPsprite (player, ps_weapon, player->ReadyWeapon->GetReadyState()); + return 0; } //---------------------------------------------------------------------------- @@ -161,6 +170,8 @@ void P_PlayPeck (AActor *chicken) DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL1) { + PARAM_ACTION_PROLOGUE; + angle_t angle; int damage; int slope; @@ -169,7 +180,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL1) if (NULL == (player = self->player)) { - return; + return 0; } damage = 1 + (pr_beakatkpl1()&3); @@ -184,6 +195,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL1) P_PlayPeck (player->mo); player->chickenPeck = 12; player->psprites[ps_weapon].tics -= pr_beakatkpl1() & 7; + return 0; } //---------------------------------------------------------------------------- @@ -194,6 +206,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL1) DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL2) { + PARAM_ACTION_PROLOGUE; + angle_t angle; int damage; int slope; @@ -202,7 +216,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL2) if (NULL == (player = self->player)) { - return; + return 0; } damage = pr_beakatkpl2.HitDice (4); @@ -217,4 +231,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL2) P_PlayPeck (player->mo); player->chickenPeck = 12; player->psprites[ps_weapon].tics -= pr_beakatkpl2()&3; + return 0; } diff --git a/src/g_heretic/a_dsparil.cpp b/src/g_heretic/a_dsparil.cpp index b6a8c6a1e..8ec664d84 100644 --- a/src/g_heretic/a_dsparil.cpp +++ b/src/g_heretic/a_dsparil.cpp @@ -28,8 +28,11 @@ static FRandom pr_bluespark ("BlueSpark"); DEFINE_ACTION_FUNCTION(AActor, A_Sor1Pain) { + PARAM_ACTION_PROLOGUE; + self->special1 = 20; // Number of steps to walk fast CALL_ACTION(A_Pain, self); + return 0; } //---------------------------------------------------------------------------- @@ -40,12 +43,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_Sor1Pain) DEFINE_ACTION_FUNCTION(AActor, A_Sor1Chase) { + PARAM_ACTION_PROLOGUE; + if (self->special1) { self->special1--; self->tics -= 3; } - A_Chase(self); + A_Chase(stack, self); + return 0; } //---------------------------------------------------------------------------- @@ -58,13 +64,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_Sor1Chase) DEFINE_ACTION_FUNCTION(AActor, A_Srcr1Attack) { + PARAM_ACTION_PROLOGUE; + AActor *mo; fixed_t velz; angle_t angle; if (!self->target) { - return; + return 0; } S_Sound (self, CHAN_BODY, self->AttackSound, 1, ATTN_NORM); if (self->CheckMeleeRange ()) @@ -72,7 +80,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Srcr1Attack) int damage = pr_scrc1atk.HitDice (8); P_DamageMobj (self->target, self, self, damage, NAME_Melee); P_TraceBleed (damage, self->target, self); - return; + return 0; } const PClass *fx = PClass::FindClass("SorcererFX1"); @@ -103,6 +111,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Srcr1Attack) } } } + return 0; } //---------------------------------------------------------------------------- @@ -113,6 +122,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Srcr1Attack) DEFINE_ACTION_FUNCTION(AActor, A_SorcererRise) { + PARAM_ACTION_PROLOGUE; + AActor *mo; self->flags &= ~MF_SOLID; @@ -120,6 +131,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcererRise) mo->SetState (mo->FindState("Rise")); mo->angle = self->angle; mo->CopyFriendliness (self, true); + return 0; } //---------------------------------------------------------------------------- @@ -165,6 +177,7 @@ void P_DSparilTeleport (AActor *actor) DEFINE_ACTION_FUNCTION(AActor, A_Srcr2Decide) { + PARAM_ACTION_PROLOGUE; static const int chance[] = { @@ -181,6 +194,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Srcr2Decide) { P_DSparilTeleport (self); } + return 0; } //---------------------------------------------------------------------------- @@ -191,11 +205,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_Srcr2Decide) DEFINE_ACTION_FUNCTION(AActor, A_Srcr2Attack) { + PARAM_ACTION_PROLOGUE; + int chance; if (!self->target) { - return; + return 0; } S_Sound (self, CHAN_BODY, self->AttackSound, 1, ATTN_NONE); if (self->CheckMeleeRange()) @@ -203,7 +219,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Srcr2Attack) int damage = pr_s2a.HitDice (20); P_DamageMobj (self->target, self, self, damage, NAME_Melee); P_TraceBleed (damage, self->target, self); - return; + return 0; } chance = self->health < self->SpawnHealth()/2 ? 96 : 48; if (pr_s2a() < chance) @@ -220,6 +236,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Srcr2Attack) { // Blue bolt P_SpawnMissile (self, self->target, PClass::FindClass("Sorcerer2FX1")); } + return 0; } //---------------------------------------------------------------------------- @@ -230,6 +247,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Srcr2Attack) DEFINE_ACTION_FUNCTION(AActor, A_BlueSpark) { + PARAM_ACTION_PROLOGUE; + int i; AActor *mo; @@ -240,6 +259,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BlueSpark) mo->vely = pr_bluespark.Random2() << 9; mo->velz = FRACUNIT + (pr_bluespark()<<8); } + return 0; } //---------------------------------------------------------------------------- @@ -250,6 +270,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_BlueSpark) DEFINE_ACTION_FUNCTION(AActor, A_GenWizard) { + PARAM_ACTION_PROLOGUE; + AActor *mo; mo = Spawn("Wizard", self->x, self->y, self->z, ALLOW_REPLACE); @@ -273,6 +295,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_GenWizard) Spawn (self->x, self->y, self->z, ALLOW_REPLACE); } } + return 0; } //---------------------------------------------------------------------------- @@ -283,8 +306,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_GenWizard) DEFINE_ACTION_FUNCTION(AActor, A_Sor2DthInit) { + PARAM_ACTION_PROLOGUE; + self->special1 = 7; // Animation loop counter P_Massacre (); // Kill monsters early + return 0; } //---------------------------------------------------------------------------- @@ -295,9 +321,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_Sor2DthInit) DEFINE_ACTION_FUNCTION(AActor, A_Sor2DthLoop) { + PARAM_ACTION_PROLOGUE; + if (--self->special1) { // Need to loop self->SetState (self->FindState("DeathLoop")); } + return 0; } diff --git a/src/g_heretic/a_hereticartifacts.cpp b/src/g_heretic/a_hereticartifacts.cpp index 1b7a79966..accb8afa9 100644 --- a/src/g_heretic/a_hereticartifacts.cpp +++ b/src/g_heretic/a_hereticartifacts.cpp @@ -47,6 +47,8 @@ bool AArtiTomeOfPower::Use (bool pickup) DEFINE_ACTION_FUNCTION(AActor, A_TimeBomb) { + PARAM_ACTION_PROLOGUE; + self->z += 32*FRACUNIT; self->RenderStyle = STYLE_Add; self->alpha = FRACUNIT; @@ -55,6 +57,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_TimeBomb) { P_HitFloor (self); } + return 0; } class AArtiTimeBomb : public AInventory diff --git a/src/g_heretic/a_hereticimp.cpp b/src/g_heretic/a_hereticimp.cpp index b2c92426e..6d25905a9 100644 --- a/src/g_heretic/a_hereticimp.cpp +++ b/src/g_heretic/a_hereticimp.cpp @@ -19,6 +19,8 @@ static FRandom pr_imp ("ImpExplode"); DEFINE_ACTION_FUNCTION(AActor, A_ImpExplode) { + PARAM_ACTION_PROLOGUE; + AActor *chunk; self->flags &= ~MF_NOGRAVITY; @@ -36,6 +38,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ImpExplode) { // Extreme death crash self->SetState (self->FindState("XCrash")); } + return 0; } //---------------------------------------------------------------------------- @@ -46,8 +49,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_ImpExplode) DEFINE_ACTION_FUNCTION(AActor, A_ImpDeath) { + PARAM_ACTION_PROLOGUE; + self->flags &= ~MF_SOLID; self->flags2 |= MF2_FLOORCLIP; + return 0; } //---------------------------------------------------------------------------- @@ -58,9 +64,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_ImpDeath) DEFINE_ACTION_FUNCTION(AActor, A_ImpXDeath1) { + PARAM_ACTION_PROLOGUE; + self->flags &= ~MF_SOLID; self->flags |= MF_NOGRAVITY; self->flags2 |= MF2_FLOORCLIP; self->special1 = 666; // Flag the crash routine + return 0; } diff --git a/src/g_heretic/a_hereticmisc.cpp b/src/g_heretic/a_hereticmisc.cpp index 7fc249378..141dff651 100644 --- a/src/g_heretic/a_hereticmisc.cpp +++ b/src/g_heretic/a_hereticmisc.cpp @@ -42,8 +42,8 @@ static FRandom pr_volcimpact ("VolcBallImpact"); DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PodPain) { - ACTION_PARAM_START(1); - ACTION_PARAM_CLASS(gootype, 0); + PARAM_ACTION_PROLOGUE; + PARAM_CLASS_OPT (gootype, AActor) { gootype = PClass::FindClass("PodGoo"); } int count; int chance; @@ -52,7 +52,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PodPain) chance = pr_podpain (); if (chance < 128) { - return; + return 0; } for (count = chance > 240 ? 2 : 1; count; count--) { @@ -62,6 +62,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PodPain) goo->vely = pr_podpain.Random2() << 9; goo->velz = FRACUNIT/2 + (pr_podpain() << 9); } + return 0; } //---------------------------------------------------------------------------- @@ -72,15 +73,18 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PodPain) DEFINE_ACTION_FUNCTION(AActor, A_RemovePod) { + PARAM_ACTION_PROLOGUE; + AActor *mo; - if ( (mo = self->master)) + if ( (mo = self->master) ) { if (mo->special1 > 0) { mo->special1--; } } + return 0; } //---------------------------------------------------------------------------- @@ -93,8 +97,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_RemovePod) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MakePod) { - ACTION_PARAM_START(1); - ACTION_PARAM_CLASS(podtype, 0); + PARAM_ACTION_PROLOGUE; + PARAM_CLASS_OPT(podtype, AActor) { podtype = PClass::FindClass("Pod"); } AActor *mo; fixed_t x; @@ -103,7 +107,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MakePod) if (self->special1 == MAX_GEN_PODS) { // Too many generated pods - return; + return 0; } x = self->x; y = self->y; @@ -112,14 +116,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MakePod) if (!P_CheckPosition (mo, x, y)) { // Didn't fit mo->Destroy (); - return; + return 0; } mo->SetState (mo->FindState("Grow")); P_ThrustMobj (mo, pr_makepod()<<24, (fixed_t)(4.5*FRACUNIT)); S_Sound (mo, CHAN_BODY, self->AttackSound, 1, ATTN_IDLE); self->special1++; // Increment generated pod count mo->master = self; // Link the generator to the pod - return; + return 0; } //---------------------------------------------------------------------------- @@ -130,10 +134,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MakePod) DEFINE_ACTION_FUNCTION(AActor, A_AccTeleGlitter) { + PARAM_ACTION_PROLOGUE; + if (++self->health > 35) { self->velz += self->velz/2; } + return 0; } @@ -145,7 +152,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_AccTeleGlitter) DEFINE_ACTION_FUNCTION(AActor, A_VolcanoSet) { + PARAM_ACTION_PROLOGUE; + self->tics = 105 + (pr_volcano() & 127); + return 0; } //---------------------------------------------------------------------------- @@ -156,6 +166,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcanoSet) DEFINE_ACTION_FUNCTION(AActor, A_VolcanoBlast) { + PARAM_ACTION_PROLOGUE; + int i; int count; AActor *blast; @@ -176,6 +188,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcanoBlast) S_Sound (blast, CHAN_BODY, "world/volcano/shoot", 1, ATTN_NORM); P_CheckMissileSpawn (blast); } + return 0; } //---------------------------------------------------------------------------- @@ -186,6 +199,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcanoBlast) DEFINE_ACTION_FUNCTION(AActor, A_VolcBallImpact) { + PARAM_ACTION_PROLOGUE; + int i; AActor *tiny; angle_t angle; @@ -210,5 +225,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcBallImpact) tiny->velz = FRACUNIT + (pr_volcimpact() << 9); P_CheckMissileSpawn (tiny); } + return 0; } diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index f17e72545..c6c22154d 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -61,6 +61,8 @@ extern bool P_AutoUseChaosDevice (player_t *player); DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack) { + PARAM_ACTION_PROLOGUE; + angle_t angle; int slope; player_t *player; @@ -68,18 +70,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack) if (NULL == (player = self->player)) { - return; + return 0; } - ACTION_PARAM_START(2); - ACTION_PARAM_INT(damage, 0); - ACTION_PARAM_CLASS(puff, 1); + PARAM_INT (damage); + PARAM_CLASS (puff, AActor); AWeapon *weapon = player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } if (puff == NULL) puff = PClass::FindClass(NAME_BulletPuff); // just to be sure angle = self->angle; @@ -93,6 +94,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack) self->angle = R_PointToAngle2 (self->x, self->y, linetarget->x, linetarget->y); } + return 0; } @@ -104,20 +106,22 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack) DEFINE_ACTION_FUNCTION(AActor, A_FireGoldWandPL1) { + PARAM_ACTION_PROLOGUE; + angle_t angle; int damage; player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } angle_t pitch = P_BulletSlope(self); damage = 7+(pr_fgw()&7); @@ -128,6 +132,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireGoldWandPL1) } P_LineAttack (self, angle, PLAYERMISSILERANGE, pitch, damage, NAME_None, "GoldWandPuff1"); S_Sound (self, CHAN_WEAPON, "weapons/wandhit", 1, ATTN_NORM); + return 0; } //---------------------------------------------------------------------------- @@ -138,6 +143,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireGoldWandPL1) DEFINE_ACTION_FUNCTION(AActor, A_FireGoldWandPL2) { + PARAM_ACTION_PROLOGUE; + int i; angle_t angle; int damage; @@ -146,14 +153,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireGoldWandPL2) if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } angle_t pitch = P_BulletSlope(self); velz = FixedMul (GetDefaultByName("GoldWandFX2")->Speed, @@ -168,6 +175,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireGoldWandPL2) angle += ((ANG45/8)*2)/4; } S_Sound (self, CHAN_WEAPON, "weapons/wandhit", 1, ATTN_NORM); + return 0; } //---------------------------------------------------------------------------- @@ -178,22 +186,25 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireGoldWandPL2) DEFINE_ACTION_FUNCTION(AActor, A_FireCrossbowPL1) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } P_SpawnPlayerMissile (self, PClass::FindClass("CrossbowFX1")); P_SpawnPlayerMissile (self, PClass::FindClass("CrossbowFX3"), self->angle-(ANG45/10)); P_SpawnPlayerMissile (self, PClass::FindClass("CrossbowFX3"), self->angle+(ANG45/10)); + return 0; } //---------------------------------------------------------------------------- @@ -204,24 +215,27 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCrossbowPL1) DEFINE_ACTION_FUNCTION(AActor, A_FireCrossbowPL2) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } P_SpawnPlayerMissile (self, PClass::FindClass("CrossbowFX2")); P_SpawnPlayerMissile (self, PClass::FindClass("CrossbowFX2"), self->angle-(ANG45/10)); P_SpawnPlayerMissile (self, PClass::FindClass("CrossbowFX2"), self->angle+(ANG45/10)); P_SpawnPlayerMissile (self, PClass::FindClass("CrossbowFX3"), self->angle-(ANG45/5)); P_SpawnPlayerMissile (self, PClass::FindClass("CrossbowFX3"), self->angle+(ANG45/5)); + return 0; } //--------------------------------------------------------------------------- @@ -232,6 +246,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCrossbowPL2) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack) { + PARAM_ACTION_PROLOGUE; + angle_t angle; int damage; int slope; @@ -243,17 +259,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack) if (NULL == (player = self->player)) { - return; + return 0; } - ACTION_PARAM_START(1); - ACTION_PARAM_INT(power, 0); + PARAM_INT(power); AWeapon *weapon = player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } player->psprites[ps_weapon].sx = ((pr_gatk()&3)-2) * FRACUNIT; player->psprites[ps_weapon].sy = WEAPONTOP + (pr_gatk()&3) * FRACUNIT; @@ -281,7 +296,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack) player->extralight = !player->extralight; } S_Sound (self, CHAN_AUTO, "weapons/gauntletson", 1, ATTN_NORM); - return; + return 0; } randVal = pr_gatk(); if (randVal < 64) @@ -323,6 +338,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack) self->angle += ANG90/20; } self->flags |= MF_JUSTATTACKED; + return 0; } // --- Mace ----------------------------------------------------------------- @@ -406,24 +422,26 @@ void FireMacePL1B (AActor *actor) DEFINE_ACTION_FUNCTION(AActor, A_FireMacePL1) { + PARAM_ACTION_PROLOGUE; + AActor *ball; player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } if (pr_maceatk() < 28) { FireMacePL1B (self); - return; + return 0; } AWeapon *weapon = player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } player->psprites[ps_weapon].sx = ((pr_maceatk()&3)-2)*FRACUNIT; player->psprites[ps_weapon].sy = WEAPONTOP+(pr_maceatk()&3)*FRACUNIT; @@ -433,6 +451,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMacePL1) { ball->special1 = 16; // tics till dropoff } + return 0; } //---------------------------------------------------------------------------- @@ -443,14 +462,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMacePL1) DEFINE_ACTION_FUNCTION(AActor, A_MacePL1Check) { + PARAM_ACTION_PROLOGUE; + if (self->special1 == 0) { - return; + return 0; } self->special1 -= 4; if (self->special1 > 0) { - return; + return 0; } self->special1 = 0; self->flags &= ~MF_NOGRAVITY; @@ -469,6 +490,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MacePL1Check) self->vely = (int)(self->vely * velscale); #endif self->velz -= self->velz >> 1; + return 0; } //---------------------------------------------------------------------------- @@ -479,6 +501,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_MacePL1Check) DEFINE_ACTION_FUNCTION(AActor, A_MaceBallImpact) { + PARAM_ACTION_PROLOGUE; + if ((self->health != MAGIC_JUNK) && (self->flags & MF_INBOUNCE)) { // Bounce self->health = MAGIC_JUNK; @@ -494,6 +518,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaceBallImpact) self->gravity = FRACUNIT; S_Sound (self, CHAN_BODY, "weapons/macehit", 1, ATTN_NORM); } + return 0; } //---------------------------------------------------------------------------- @@ -504,6 +529,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaceBallImpact) DEFINE_ACTION_FUNCTION(AActor, A_MaceBallImpact2) { + PARAM_ACTION_PROLOGUE; + AActor *tiny; angle_t angle; @@ -558,6 +585,7 @@ boom: self->BounceFlags = BOUNCE_None; self->gravity = FRACUNIT; } + return 0; } //---------------------------------------------------------------------------- @@ -568,20 +596,22 @@ boom: DEFINE_ACTION_FUNCTION(AActor, A_FireMacePL2) { + PARAM_ACTION_PROLOGUE; + AActor *mo; player_t *player; AActor *linetarget; if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } mo = P_SpawnPlayerMissile (self, 0,0,0, RUNTIME_CLASS(AMaceFX4), self->angle, &linetarget); if (mo) @@ -596,6 +626,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMacePL2) } } S_Sound (self, CHAN_WEAPON, "weapons/maceshoot", 1, ATTN_NORM); + return 0; } //---------------------------------------------------------------------------- @@ -606,6 +637,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMacePL2) DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact) { + PARAM_ACTION_PROLOGUE; + int i; AActor *target; angle_t angle = 0; @@ -615,7 +648,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact) if ((self->z <= self->floorz) && P_HitFloor (self)) { // Landed in some sort of liquid self->Destroy (); - return; + return 0; } if (self->flags & MF_INBOUNCE) { @@ -687,6 +720,7 @@ boom: self->gravity = FRACUNIT; S_Sound (self, CHAN_BODY, "weapons/maceexplode", 1, ATTN_NORM); } + return 0; } @@ -762,20 +796,22 @@ int ARipper::DoSpecialDamage (AActor *target, int damage) DEFINE_ACTION_FUNCTION(AActor, A_FireBlasterPL1) { + PARAM_ACTION_PROLOGUE; + angle_t angle; int damage; player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } angle_t pitch = P_BulletSlope(self); damage = pr_fb1.HitDice (4); @@ -786,6 +822,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireBlasterPL1) } P_LineAttack (self, angle, PLAYERMISSILERANGE, pitch, damage, NAME_None, "BlasterPuff"); S_Sound (self, CHAN_WEAPON, "weapons/blastershoot", 1, ATTN_NORM); + return 0; } //---------------------------------------------------------------------------- @@ -796,6 +833,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireBlasterPL1) DEFINE_ACTION_FUNCTION(AActor, A_SpawnRippers) { + PARAM_ACTION_PROLOGUE; + int i; angle_t angle; AActor *ripper; @@ -811,6 +850,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnRippers) ripper->vely = FixedMul (ripper->Speed, finesine[angle]); P_CheckMissileSpawn (ripper); } + return 0; } // --- Skull rod ------------------------------------------------------------ @@ -883,19 +923,21 @@ void ARainTracker::Serialize (FArchive &arc) DEFINE_ACTION_FUNCTION(AActor, A_FireSkullRodPL1) { + PARAM_ACTION_PROLOGUE; + AActor *mo; player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } mo = P_SpawnPlayerMissile (self, PClass::FindClass("HornRodFX1")); // Randomize the first frame @@ -903,6 +945,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSkullRodPL1) { mo->SetState (mo->state->GetNextState()); } + return 0; } //---------------------------------------------------------------------------- @@ -916,19 +959,21 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSkullRodPL1) DEFINE_ACTION_FUNCTION(AActor, A_FireSkullRodPL2) { + PARAM_ACTION_PROLOGUE; + player_t *player; AActor *MissileActor; AActor *linetarget; if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } P_SpawnPlayerMissile (self, 0,0,0, RUNTIME_CLASS(AHornRodFX2), self->angle, &linetarget, &MissileActor); // Use MissileActor instead of the return value from @@ -943,6 +988,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSkullRodPL2) } S_Sound (MissileActor, CHAN_WEAPON, "weapons/hornrodpowshoot", 1, ATTN_NORM); } + return 0; } //---------------------------------------------------------------------------- @@ -953,11 +999,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSkullRodPL2) DEFINE_ACTION_FUNCTION(AActor, A_AddPlayerRain) { + PARAM_ACTION_PROLOGUE; + ARainTracker *tracker; if (self->target == NULL || self->target->health <= 0) { // Shooter is dead or nonexistant - return; + return 0; } tracker = self->target->FindInventory (); @@ -1000,6 +1048,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_AddPlayerRain) tracker->Rain1 = self; } self->special1 = S_FindSound ("misc/rain"); + return 0; } //---------------------------------------------------------------------------- @@ -1010,6 +1059,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_AddPlayerRain) DEFINE_ACTION_FUNCTION(AActor, A_SkullRodStorm) { + PARAM_ACTION_PROLOGUE; + fixed_t x; fixed_t y; AActor *mo; @@ -1021,7 +1072,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkullRodStorm) if (self->target == NULL) { // Player left the game self->Destroy (); - return; + return 0; } tracker = self->target->FindInventory (); if (tracker != NULL) @@ -1036,11 +1087,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkullRodStorm) } } self->Destroy (); - return; + return 0; } if (pr_storm() < 25) { // Fudge rain frequency - return; + return 0; } x = self->x + ((pr_storm()&127) - 64) * FRACUNIT; y = self->y + ((pr_storm()&127) - 64) * FRACUNIT; @@ -1056,6 +1107,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkullRodStorm) { S_Sound (self, CHAN_BODY|CHAN_LOOP, self->special1, 1, ATTN_NORM); } + return 0; } //---------------------------------------------------------------------------- @@ -1066,6 +1118,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkullRodStorm) DEFINE_ACTION_FUNCTION(AActor, A_RainImpact) { + PARAM_ACTION_PROLOGUE; + if (self->z > self->floorz) { self->SetState (self->FindState("NotFloor")); @@ -1074,6 +1128,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RainImpact) { P_HitFloor (self); } + return 0; } //---------------------------------------------------------------------------- @@ -1084,7 +1139,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_RainImpact) DEFINE_ACTION_FUNCTION(AActor, A_HideInCeiling) { + PARAM_ACTION_PROLOGUE; + self->z = self->ceilingz + 4*FRACUNIT; + return 0; } // --- Phoenix Rod ---------------------------------------------------------- @@ -1168,25 +1226,28 @@ int APhoenixFX2::DoSpecialDamage (AActor *target, int damage) DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL1) { + PARAM_ACTION_PROLOGUE; + angle_t angle; player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } P_SpawnPlayerMissile (self, RUNTIME_CLASS(APhoenixFX1)); angle = self->angle + ANG180; angle >>= ANGLETOFINESHIFT; self->velx += FixedMul (4*FRACUNIT, finecosine[angle]); self->vely += FixedMul (4*FRACUNIT, finesine[angle]); + return 0; } //---------------------------------------------------------------------------- @@ -1197,6 +1258,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL1) DEFINE_ACTION_FUNCTION(AActor, A_PhoenixPuff) { + PARAM_ACTION_PROLOGUE; + AActor *puff; angle_t angle; @@ -1214,6 +1277,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PhoenixPuff) puff->velx = FixedMul (FRACUNIT*13/10, finecosine[angle]); puff->vely = FixedMul (FRACUNIT*13/10, finesine[angle]); puff->velz = 0; + return 0; } //---------------------------------------------------------------------------- @@ -1224,6 +1288,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_PhoenixPuff) DEFINE_ACTION_FUNCTION(AActor, A_InitPhoenixPL2) { + PARAM_ACTION_PROLOGUE; + if (self->player != NULL) { APhoenixRod *flamethrower = static_cast (self->player->ReadyWeapon); @@ -1232,6 +1298,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_InitPhoenixPL2) flamethrower->FlameCount = FLAME_THROWER_TICS; } } + return 0; } //---------------------------------------------------------------------------- @@ -1244,6 +1311,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_InitPhoenixPL2) DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2) { + PARAM_ACTION_PROLOGUE; + AActor *mo; angle_t angle; fixed_t x, y, z; @@ -1254,7 +1323,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2) if (NULL == (player = self->player)) { - return; + return 0; } soundid = "weapons/phoenixpowshoot"; @@ -1265,7 +1334,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2) P_SetPsprite (player, ps_weapon, flamethrower->FindState("Powerdown")); player->refire = 0; S_StopSound (self, CHAN_WEAPON); - return; + return 0; } angle = self->angle; x = self->x + (pr_fp2.Random2() << 9); @@ -1284,6 +1353,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2) S_Sound (self, CHAN_WEAPON|CHAN_LOOP, soundid, 1, ATTN_NORM); } P_CheckMissileSpawn (mo); + return 0; } //---------------------------------------------------------------------------- @@ -1294,19 +1364,22 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2) DEFINE_ACTION_FUNCTION(AActor, A_ShutdownPhoenixPL2) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } S_StopSound (self, CHAN_WEAPON); AWeapon *weapon = player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } + return 0; } //---------------------------------------------------------------------------- @@ -1317,7 +1390,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShutdownPhoenixPL2) DEFINE_ACTION_FUNCTION(AActor, A_FlameEnd) { + PARAM_ACTION_PROLOGUE; + self->velz += FRACUNIT*3/2; + return 0; } //---------------------------------------------------------------------------- @@ -1328,6 +1404,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_FlameEnd) DEFINE_ACTION_FUNCTION(AActor, A_FloatPuff) { + PARAM_ACTION_PROLOGUE; + self->velz += FRACUNIT*18/10; + return 0; } diff --git a/src/g_heretic/a_ironlich.cpp b/src/g_heretic/a_ironlich.cpp index 61220f419..f21dc5208 100644 --- a/src/g_heretic/a_ironlich.cpp +++ b/src/g_heretic/a_ironlich.cpp @@ -59,6 +59,8 @@ int AWhirlwind::DoSpecialDamage (AActor *target, int damage) DEFINE_ACTION_FUNCTION(AActor, A_LichAttack) { + PARAM_ACTION_PROLOGUE; + int i; AActor *fire; AActor *baseFire; @@ -77,7 +79,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichAttack) target = self->target; if (target == NULL) { - return; + return 0; } A_FaceTarget (self); if (self->CheckMeleeRange ()) @@ -85,7 +87,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichAttack) int damage = pr_atk.HitDice (6); P_DamageMobj (target, self, self, damage, NAME_Melee); P_TraceBleed (damage, target, self); - return; + return 0; } dist = P_AproxDistance (self->x-target->x, self->y-target->y) > 8*64*FRACUNIT; @@ -133,6 +135,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichAttack) S_Sound (self, CHAN_BODY, "ironlich/attack3", 1, ATTN_NORM); } } + return 0; } //---------------------------------------------------------------------------- @@ -143,13 +146,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichAttack) DEFINE_ACTION_FUNCTION(AActor, A_WhirlwindSeek) { + PARAM_ACTION_PROLOGUE; + self->health -= 3; if (self->health < 0) { self->velx = self->vely = self->velz = 0; self->SetState (self->FindState(NAME_Death)); self->flags &= ~MF_MISSILE; - return; + return 0; } if ((self->special2 -= 3) < 0) { @@ -158,9 +163,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_WhirlwindSeek) } if (self->tracer && self->tracer->flags&MF_SHADOW) { - return; + return 0; } P_SeekerMissile (self, ANGLE_1*10, ANGLE_1*30); + return 0; } //---------------------------------------------------------------------------- @@ -171,6 +177,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_WhirlwindSeek) DEFINE_ACTION_FUNCTION(AActor, A_LichIceImpact) { + PARAM_ACTION_PROLOGUE; + int i; angle_t angle; AActor *shard; @@ -187,6 +195,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichIceImpact) shard->velz = -FRACUNIT*6/10; P_CheckMissileSpawn (shard); } + return 0; } //---------------------------------------------------------------------------- @@ -197,6 +206,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichIceImpact) DEFINE_ACTION_FUNCTION(AActor, A_LichFireGrow) { + PARAM_ACTION_PROLOGUE; + self->health--; self->z += 9*FRACUNIT; if (self->health == 0) @@ -204,5 +215,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichFireGrow) self->Damage = self->GetDefault()->Damage; self->SetState (self->FindState("NoGrow")); } + return 0; } diff --git a/src/g_heretic/a_knight.cpp b/src/g_heretic/a_knight.cpp index 2fb8a0ef4..d6a3d2760 100644 --- a/src/g_heretic/a_knight.cpp +++ b/src/g_heretic/a_knight.cpp @@ -21,6 +21,8 @@ static FRandom pr_knightatk ("KnightAttack"); DEFINE_ACTION_FUNCTION(AActor, A_DripBlood) { + PARAM_ACTION_PROLOGUE; + AActor *mo; fixed_t x, y; @@ -30,6 +32,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DripBlood) mo->velx = pr_dripblood.Random2 () << 10; mo->vely = pr_dripblood.Random2 () << 10; mo->gravity = FRACUNIT/8; + return 0; } //---------------------------------------------------------------------------- @@ -40,9 +43,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_DripBlood) DEFINE_ACTION_FUNCTION(AActor, A_KnightAttack) { + PARAM_ACTION_PROLOGUE; + if (!self->target) { - return; + return 0; } if (self->CheckMeleeRange ()) { @@ -50,16 +55,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_KnightAttack) P_DamageMobj (self->target, self, self, damage, NAME_Melee); P_TraceBleed (damage, self->target, self); S_Sound (self, CHAN_BODY, "hknight/melee", 1, ATTN_NORM); - return; + return 0; } // Throw axe S_Sound (self, CHAN_BODY, self->AttackSound, 1, ATTN_NORM); if (self->flags & MF_SHADOW || pr_knightatk () < 40) { // Red axe P_SpawnMissileZ (self, self->z + 36*FRACUNIT, self->target, PClass::FindClass("RedAxe")); - return; + return 0; } // Green axe P_SpawnMissileZ (self, self->z + 36*FRACUNIT, self->target, PClass::FindClass("KnightAxe")); + return 0; } diff --git a/src/g_heretic/a_wizard.cpp b/src/g_heretic/a_wizard.cpp index 119a1b1ef..69611546d 100644 --- a/src/g_heretic/a_wizard.cpp +++ b/src/g_heretic/a_wizard.cpp @@ -20,8 +20,11 @@ static FRandom pr_wizatk3 ("WizAtk3"); DEFINE_ACTION_FUNCTION(AActor, A_GhostOff) { + PARAM_ACTION_PROLOGUE; + self->RenderStyle = STYLE_Normal; self->flags3 &= ~MF3_GHOST; + return 0; } //---------------------------------------------------------------------------- @@ -32,8 +35,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_GhostOff) DEFINE_ACTION_FUNCTION(AActor, A_WizAtk1) { + PARAM_ACTION_PROLOGUE; + A_FaceTarget (self); CALL_ACTION(A_GhostOff, self); + return 0; } //---------------------------------------------------------------------------- @@ -44,10 +50,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_WizAtk1) DEFINE_ACTION_FUNCTION(AActor, A_WizAtk2) { + PARAM_ACTION_PROLOGUE; + A_FaceTarget (self); self->alpha = HR_SHADOW; self->RenderStyle = STYLE_Translucent; self->flags3 |= MF3_GHOST; + return 0; } //---------------------------------------------------------------------------- @@ -58,12 +67,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_WizAtk2) DEFINE_ACTION_FUNCTION(AActor, A_WizAtk3) { + PARAM_ACTION_PROLOGUE; + AActor *mo; CALL_ACTION(A_GhostOff, self); if (!self->target) { - return; + return 0; } S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); if (self->CheckMeleeRange()) @@ -71,7 +82,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_WizAtk3) int damage = pr_wizatk3.HitDice (4); P_DamageMobj (self->target, self, self, damage, NAME_Melee); P_TraceBleed (damage, self->target, self); - return; + return 0; } const PClass *fx = PClass::FindClass("WizardFX1"); mo = P_SpawnMissile (self, self->target, fx); @@ -80,4 +91,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_WizAtk3) P_SpawnMissileAngle(self, fx, mo->angle-(ANG45/8), mo->velz); P_SpawnMissileAngle(self, fx, mo->angle+(ANG45/8), mo->velz); } + return 0; } diff --git a/src/g_hexen/a_bats.cpp b/src/g_hexen/a_bats.cpp index c1674d218..c6d0389d9 100644 --- a/src/g_hexen/a_bats.cpp +++ b/src/g_hexen/a_bats.cpp @@ -27,17 +27,22 @@ static FRandom pr_batmove ("BatMove"); DEFINE_ACTION_FUNCTION(AActor, A_BatSpawnInit) { + PARAM_ACTION_PROLOGUE; + self->special1 = 0; // Frequency count + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_BatSpawn) { + PARAM_ACTION_PROLOGUE; + AActor *mo; int delta; angle_t angle; // Countdown until next spawn - if (self->special1-- > 0) return; + if (self->special1-- > 0) return 0; self->special1 = self->args[0]; // Reset frequency count delta = self->args[1]; @@ -51,11 +56,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_BatSpawn) mo->special2 = self->args[3]<<3; // Set lifetime mo->target = self; } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_BatMove) { + PARAM_ACTION_PROLOGUE; + angle_t newangle; if (self->special2 < 0) @@ -86,4 +94,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_BatMove) // Handle Z movement self->z = self->target->z + 2*FloatBobOffsets[self->args[0]]; self->args[0] = (self->args[0]+3)&63; + return 0; } diff --git a/src/g_hexen/a_bishop.cpp b/src/g_hexen/a_bishop.cpp index 1e4109748..22541a57a 100644 --- a/src/g_hexen/a_bishop.cpp +++ b/src/g_hexen/a_bishop.cpp @@ -24,9 +24,11 @@ static FRandom pr_pain ("BishopPainBlur"); DEFINE_ACTION_FUNCTION(AActor, A_BishopAttack) { + PARAM_ACTION_PROLOGUE; + if (!self->target) { - return; + return 0; } S_Sound (self, CHAN_BODY, self->AttackSound, 1, ATTN_NORM); if (self->CheckMeleeRange()) @@ -34,9 +36,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopAttack) int damage = pr_atk.HitDice (4); P_DamageMobj (self->target, self, self, damage, NAME_Melee); P_TraceBleed (damage, self->target, self); - return; + return 0; } self->special1 = (pr_atk() & 3) + 5; + return 0; } //============================================================================ @@ -48,13 +51,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopAttack) DEFINE_ACTION_FUNCTION(AActor, A_BishopAttack2) { + PARAM_ACTION_PROLOGUE; + AActor *mo; if (!self->target || !self->special1) { self->special1 = 0; self->SetState (self->SeeState); - return; + return 0; } mo = P_SpawnMissile (self, self->target, PClass::FindClass("BishopFX")); if (mo != NULL) @@ -63,6 +68,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopAttack2) mo->special2 = 16; // High word == x/y, Low word == z } self->special1--; + return 0; } //============================================================================ @@ -73,6 +79,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopAttack2) DEFINE_ACTION_FUNCTION(AActor, A_BishopMissileWeave) { + PARAM_ACTION_PROLOGUE; + fixed_t newX, newY; int weaveXY, weaveZ; int angle; @@ -92,6 +100,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopMissileWeave) weaveZ = (weaveZ + 2) & 63; self->z += FloatBobOffsets[weaveZ]; self->special2 = weaveZ + (weaveXY<<16); + return 0; } //============================================================================ @@ -102,14 +111,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopMissileWeave) DEFINE_ACTION_FUNCTION(AActor, A_BishopDecide) { + PARAM_ACTION_PROLOGUE; + if (pr_decide() < 220) { - return; + return 0; } else { self->SetState (self->FindState ("Blur")); - } + } + return 0; } //============================================================================ @@ -120,6 +132,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopDecide) DEFINE_ACTION_FUNCTION(AActor, A_BishopDoBlur) { + PARAM_ACTION_PROLOGUE; + self->special1 = (pr_doblur() & 3) + 3; // Random number of blurs if (pr_doblur() < 120) { @@ -134,6 +148,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopDoBlur) P_ThrustMobj (self, self->angle, 11*FRACUNIT); } S_Sound (self, CHAN_BODY, "BishopBlur", 1, ATTN_NORM); + return 0; } //============================================================================ @@ -144,6 +159,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopDoBlur) DEFINE_ACTION_FUNCTION(AActor, A_BishopSpawnBlur) { + PARAM_ACTION_PROLOGUE; + AActor *mo; if (!--self->special1) @@ -164,6 +181,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopSpawnBlur) { mo->angle = self->angle; } + return 0; } //============================================================================ @@ -174,9 +192,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopSpawnBlur) DEFINE_ACTION_FUNCTION(AActor, A_BishopChase) { + PARAM_ACTION_PROLOGUE; + self->z -= FloatBobOffsets[self->special2] >> 1; self->special2 = (self->special2 + 4) & 63; self->z += FloatBobOffsets[self->special2] >> 1; + return 0; } //============================================================================ @@ -187,6 +208,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopChase) DEFINE_ACTION_FUNCTION(AActor, A_BishopPuff) { + PARAM_ACTION_PROLOGUE; + AActor *mo; mo = Spawn ("BishopPuff", self->x, self->y, self->z + 40*FRACUNIT, ALLOW_REPLACE); @@ -194,6 +217,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopPuff) { mo->velz = FRACUNIT/2; } + return 0; } //============================================================================ @@ -204,12 +228,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopPuff) DEFINE_ACTION_FUNCTION(AActor, A_BishopPainBlur) { + PARAM_ACTION_PROLOGUE; + AActor *mo; if (pr_pain() < 64) { self->SetState (self->FindState ("Blur")); - return; + return 0; } fixed_t x = self->x + (pr_pain.Random2()<<12); fixed_t y = self->y + (pr_pain.Random2()<<12); @@ -219,4 +245,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopPainBlur) { mo->angle = self->angle; } + return 0; } diff --git a/src/g_hexen/a_centaur.cpp b/src/g_hexen/a_centaur.cpp index f7ba3b99f..ff79ae9fd 100644 --- a/src/g_hexen/a_centaur.cpp +++ b/src/g_hexen/a_centaur.cpp @@ -16,6 +16,8 @@ static FRandom pr_centaurdefend ("CentaurDefend"); DEFINE_ACTION_FUNCTION(AActor, A_CentaurDefend) { + PARAM_ACTION_PROLOGUE; + A_FaceTarget (self); if (self->CheckMeleeRange() && pr_centaurdefend() < 32) { @@ -24,4 +26,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_CentaurDefend) self->flags2&=~(MF2_REFLECTIVE|MF2_INVULNERABLE); self->SetState (self->MeleeState); } + return 0; } diff --git a/src/g_hexen/a_clericflame.cpp b/src/g_hexen/a_clericflame.cpp index 0fe482ede..2b62c8f90 100644 --- a/src/g_hexen/a_clericflame.cpp +++ b/src/g_hexen/a_clericflame.cpp @@ -69,20 +69,23 @@ void ACFlameMissile::Effect () DEFINE_ACTION_FUNCTION(AActor, A_CFlameAttack) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } P_SpawnPlayerMissile (self, RUNTIME_CLASS(ACFlameMissile)); S_Sound (self, CHAN_WEAPON, "ClericFlameFire", 1, ATTN_NORM); + return 0; } //============================================================================ @@ -93,11 +96,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_CFlameAttack) DEFINE_ACTION_FUNCTION(AActor, A_CFlamePuff) { + PARAM_ACTION_PROLOGUE; + self->renderflags &= ~RF_INVISIBLE; self->velx = 0; self->vely = 0; self->velz = 0; S_Sound (self, CHAN_BODY, "ClericFlameExplode", 1, ATTN_NORM); + return 0; } //============================================================================ @@ -108,6 +114,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CFlamePuff) DEFINE_ACTION_FUNCTION(AActor, A_CFlameMissile) { + PARAM_ACTION_PROLOGUE; + int i; int an, an90; fixed_t dist; @@ -148,6 +156,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CFlameMissile) } self->SetState (self->SpawnState); } + return 0; } //============================================================================ @@ -158,10 +167,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_CFlameMissile) DEFINE_ACTION_FUNCTION(AActor, A_CFlameRotate) { + PARAM_ACTION_PROLOGUE; + int an; an = (self->angle+ANG90)>>ANGLETOFINESHIFT; self->velx = self->special1+FixedMul(FLAMEROTSPEED, finecosine[an]); self->vely = self->special2+FixedMul(FLAMEROTSPEED, finesine[an]); self->angle += ANG90/15; + return 0; } diff --git a/src/g_hexen/a_clericholy.cpp b/src/g_hexen/a_clericholy.cpp index 6ad6522c3..e45ed07b2 100644 --- a/src/g_hexen/a_clericholy.cpp +++ b/src/g_hexen/a_clericholy.cpp @@ -184,6 +184,8 @@ bool AHolySpirit::IsOkayToAttack (AActor *link) DEFINE_ACTION_FUNCTION(AActor, A_CHolyAttack2) { + PARAM_ACTION_PROLOGUE; + int j; int i; AActor *mo; @@ -229,6 +231,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyAttack2) } SpawnSpiritTail (mo); } + return 0; } //============================================================================ @@ -261,24 +264,27 @@ void SpawnSpiritTail (AActor *spirit) DEFINE_ACTION_FUNCTION(AActor, A_CHolyAttack) { + PARAM_ACTION_PROLOGUE; + player_t *player; AActor *linetarget; if (NULL == (player = self->player)) { - return; + return 0; } ACWeapWraithverge *weapon = static_cast (self->player->ReadyWeapon); if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } AActor * missile = P_SpawnPlayerMissile (self, 0,0,0, PClass::FindClass ("HolyMissile"), self->angle, &linetarget); if (missile != NULL) missile->tracer = linetarget; weapon->CHolyCount = 3; S_Sound (self, CHAN_WEAPON, "HolySymbolFire", 1, ATTN_NORM); + return 0; } //============================================================================ @@ -289,6 +295,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyAttack) DEFINE_ACTION_FUNCTION(AActor, A_CHolyPalette) { + PARAM_ACTION_PROLOGUE; + if (self->player != NULL) { ACWeapWraithverge *weapon = static_cast (self->player->ReadyWeapon); @@ -297,6 +305,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyPalette) weapon->CHolyCount--; } } + return 0; } //============================================================================ @@ -372,6 +381,8 @@ static void CHolyTailRemove (AActor *actor) DEFINE_ACTION_FUNCTION(AActor, A_CHolyTail) { + PARAM_ACTION_PROLOGUE; + AActor *parent; parent = self->target; @@ -379,7 +390,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyTail) if (parent == NULL || parent->health <= 0) // better check for health than current state - it's safer! { // Ghost removed, so remove all tail parts CHolyTailRemove (self); - return; + return 0; } else { @@ -391,6 +402,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyTail) } CHolyTailFollow (self, 10*FRACUNIT); } + return 0; } //============================================================================ @@ -529,6 +541,8 @@ static void CHolyWeave (AActor *actor) DEFINE_ACTION_FUNCTION(AActor, A_CHolySeek) { + PARAM_ACTION_PROLOGUE; + self->health--; if (self->health <= 0) { @@ -537,7 +551,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolySeek) self->velz = 0; self->SetState (self->FindState(NAME_Death)); self->tics -= pr_holyseek()&3; - return; + return 0; } if (self->tracer) { @@ -549,6 +563,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolySeek) } } CHolyWeave (self); + return 0; } //============================================================================ @@ -559,6 +574,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolySeek) DEFINE_ACTION_FUNCTION(AActor, A_CHolyCheckScream) { + PARAM_ACTION_PROLOGUE; + CALL_ACTION(A_CHolySeek, self); if (pr_checkscream() < 20) { @@ -568,6 +585,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyCheckScream) { CHolyFindTarget(self); } + return 0; } //============================================================================ @@ -579,10 +597,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyCheckScream) DEFINE_ACTION_FUNCTION(AActor, A_ClericAttack) { - if (!self->target) return; + PARAM_ACTION_PROLOGUE; + + if (!self->target) return 0; AActor * missile = P_SpawnMissileZ (self, self->z + 40*FRACUNIT, self->target, PClass::FindClass ("HolyMissile")); if (missile != NULL) missile->tracer = NULL; // No initial target S_Sound (self, CHAN_WEAPON, "HolySymbolFire", 1, ATTN_NORM); + return 0; } diff --git a/src/g_hexen/a_clericmace.cpp b/src/g_hexen/a_clericmace.cpp index d834dcd1b..cb9cc1b7b 100644 --- a/src/g_hexen/a_clericmace.cpp +++ b/src/g_hexen/a_clericmace.cpp @@ -17,6 +17,8 @@ static FRandom pr_maceatk ("CMaceAttack"); DEFINE_ACTION_FUNCTION(AActor, A_CMaceAttack) { + PARAM_ACTION_PROLOGUE; + angle_t angle; int damage; int slope; @@ -26,7 +28,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CMaceAttack) if (NULL == (player = self->player)) { - return; + return 0; } damage = 25+(pr_maceatk()&15); @@ -60,5 +62,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_CMaceAttack) slope = P_AimLineAttack (player->mo, angle, MELEERANGE, &linetarget); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff")); macedone: - return; + return 0; } diff --git a/src/g_hexen/a_clericstaff.cpp b/src/g_hexen/a_clericstaff.cpp index 220dc55e7..476560e8f 100644 --- a/src/g_hexen/a_clericstaff.cpp +++ b/src/g_hexen/a_clericstaff.cpp @@ -46,6 +46,8 @@ int ACStaffMissile::DoSpecialDamage (AActor *target, int damage) DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck) { + PARAM_ACTION_PROLOGUE; + AActor *pmo; int damage; int newLife; @@ -57,7 +59,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck) if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = self->player->ReadyWeapon; @@ -107,6 +109,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck) break; } } + return 0; } //============================================================================ @@ -117,19 +120,21 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck) DEFINE_ACTION_FUNCTION(AActor, A_CStaffAttack) { + PARAM_ACTION_PROLOGUE; + AActor *mo; player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } mo = P_SpawnPlayerMissile (self, RUNTIME_CLASS(ACStaffMissile), self->angle-(ANG45/15)); if (mo) @@ -142,6 +147,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffAttack) mo->special2 = 0; } S_Sound (self, CHAN_WEAPON, "ClericCStaffFire", 1, ATTN_NORM); + return 0; } //============================================================================ @@ -152,6 +158,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffAttack) DEFINE_ACTION_FUNCTION(AActor, A_CStaffMissileSlither) { + PARAM_ACTION_PROLOGUE; + fixed_t newX, newY; int weaveXY; int angle; @@ -165,6 +173,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffMissileSlither) newY += FixedMul(finesine[angle], FloatBobOffsets[weaveXY]); P_TryMove (self, newX, newY, true); self->special2 = weaveXY; + return 0; } //============================================================================ @@ -175,7 +184,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffMissileSlither) DEFINE_ACTION_FUNCTION(AActor, A_CStaffInitBlink) { + PARAM_ACTION_PROLOGUE; + self->special1 = (pr_blink()>>1)+20; + return 0; } //============================================================================ @@ -186,6 +198,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffInitBlink) DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheckBlink) { + PARAM_ACTION_PROLOGUE; + if (self->player && self->player->ReadyWeapon) { if (!--self->special1) @@ -198,4 +212,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheckBlink) DoReadyWeapon(self); } } + return 0; } diff --git a/src/g_hexen/a_dragon.cpp b/src/g_hexen/a_dragon.cpp index 0c5ea81b5..87f58f196 100644 --- a/src/g_hexen/a_dragon.cpp +++ b/src/g_hexen/a_dragon.cpp @@ -164,6 +164,8 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax) DEFINE_ACTION_FUNCTION(AActor, A_DragonInitFlight) { + PARAM_ACTION_PROLOGUE; + FActorIterator iterator (self->tid); do @@ -172,10 +174,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonInitFlight) if (self->tracer == NULL) { self->SetState (self->SpawnState); - return; + return 0; } } while (self->tracer == self); self->RemoveFromHash (); + return 0; } //============================================================================ @@ -186,6 +189,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonInitFlight) DEFINE_ACTION_FUNCTION(AActor, A_DragonFlight) { + PARAM_ACTION_PROLOGUE; + angle_t angle; DragonSeek (self, 4*ANGLE_1, 8*ANGLE_1); @@ -194,7 +199,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFlight) if(!(self->target->flags&MF_SHOOTABLE)) { // target died self->target = NULL; - return; + return 0; } angle = R_PointToAngle2(self->x, self->y, self->target->x, self->target->y); @@ -215,6 +220,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFlight) { P_LookForPlayers (self, true, NULL); } + return 0; } //============================================================================ @@ -225,6 +231,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFlight) DEFINE_ACTION_FUNCTION(AActor, A_DragonFlap) { + PARAM_ACTION_PROLOGUE; + CALL_ACTION(A_DragonFlight, self); if (pr_dragonflap() < 240) { @@ -234,6 +242,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFlap) { self->PlayActiveSound (); } + return 0; } //============================================================================ @@ -244,7 +253,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFlap) DEFINE_ACTION_FUNCTION(AActor, A_DragonAttack) { - P_SpawnMissile (self, self->target, PClass::FindClass ("DragonFireball")); + PARAM_ACTION_PROLOGUE; + + P_SpawnMissile (self, self->target, PClass::FindClass ("DragonFireball")); + return 0; } //============================================================================ @@ -255,6 +267,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonAttack) DEFINE_ACTION_FUNCTION(AActor, A_DragonFX2) { + PARAM_ACTION_PROLOGUE; + AActor *mo; int i; int delay; @@ -272,7 +286,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFX2) mo->tics = delay+(pr_dragonfx2()&3)*i*2; mo->target = self->target; } - } + } + return 0; } //============================================================================ @@ -283,11 +298,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFX2) DEFINE_ACTION_FUNCTION(AActor, A_DragonPain) { + PARAM_ACTION_PROLOGUE; + CALL_ACTION(A_Pain, self); if (!self->tracer) { // no destination spot yet self->SetState (self->SeeState); } + return 0; } //============================================================================ @@ -298,8 +316,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonPain) DEFINE_ACTION_FUNCTION(AActor, A_DragonCheckCrash) { + PARAM_ACTION_PROLOGUE; + if (self->z <= self->floorz) { self->SetState (self->FindState ("Crash")); } + return 0; } diff --git a/src/g_hexen/a_fighteraxe.cpp b/src/g_hexen/a_fighteraxe.cpp index 281d20c2c..8c5e8c540 100644 --- a/src/g_hexen/a_fighteraxe.cpp +++ b/src/g_hexen/a_fighteraxe.cpp @@ -70,11 +70,13 @@ FState *AFWeapAxe::GetAtkState (bool hold) DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReady) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } if (player->ReadyWeapon->Ammo1->Amount) { @@ -84,6 +86,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReady) { DoReadyWeapon(self); } + return 0; } //============================================================================ @@ -94,11 +97,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReady) DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReadyG) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } if (player->ReadyWeapon->Ammo1->Amount <= 0) { @@ -108,6 +113,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReadyG) { DoReadyWeapon(self); } + return 0; } //============================================================================ @@ -118,11 +124,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReadyG) DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUp) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } if (player->ReadyWeapon->Ammo1->Amount) { @@ -132,6 +140,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUp) { CALL_ACTION(A_Raise, self); } + return 0; } //============================================================================ @@ -142,11 +151,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUp) DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUpG) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } if (player->ReadyWeapon->Ammo1->Amount <= 0) { @@ -156,6 +167,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUpG) { CALL_ACTION(A_Raise, self); } + return 0; } //============================================================================ @@ -166,16 +178,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUpG) DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckAtk) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } if (player->ReadyWeapon->Ammo1->Amount) { P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("FireGlow")); } + return 0; } //============================================================================ @@ -186,6 +201,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckAtk) DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack) { + PARAM_ACTION_PROLOGUE; + angle_t angle; fixed_t power; int damage; @@ -199,7 +216,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack) if (NULL == (player = self->player)) { - return; + return 0; } AActor *pmo=player->mo; @@ -271,6 +288,6 @@ axedone: } } } - return; + return 0; } diff --git a/src/g_hexen/a_fighterhammer.cpp b/src/g_hexen/a_fighterhammer.cpp index edb618bea..2116ec665 100644 --- a/src/g_hexen/a_fighterhammer.cpp +++ b/src/g_hexen/a_fighterhammer.cpp @@ -27,6 +27,8 @@ extern void AdjustPlayerAngle (AActor *pmo, AActor *linetarget); DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack) { + PARAM_ACTION_PROLOGUE; + angle_t angle; int damage; fixed_t power; @@ -37,7 +39,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack) if (NULL == (player = self->player)) { - return; + return 0; } AActor *pmo=player->mo; @@ -91,7 +93,7 @@ hammerdone: { pmo->special1 = false; } - return; + return 0; } //============================================================================ @@ -102,27 +104,30 @@ hammerdone: DEFINE_ACTION_FUNCTION(AActor, A_FHammerThrow) { + PARAM_ACTION_PROLOGUE; + AActor *mo; player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } if (!player->mo->special1) { - return; + return 0; } AWeapon *weapon = player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire, false)) - return; + return 0; } mo = P_SpawnPlayerMissile (player->mo, PClass::FindClass ("HammerMissile")); if (mo) { mo->special1 = 0; - } + } + return 0; } diff --git a/src/g_hexen/a_fighterplayer.cpp b/src/g_hexen/a_fighterplayer.cpp index ba1bc9e82..afa15d702 100644 --- a/src/g_hexen/a_fighterplayer.cpp +++ b/src/g_hexen/a_fighterplayer.cpp @@ -134,6 +134,8 @@ void AdjustPlayerAngle (AActor *pmo, AActor *linetarget) DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack) { + PARAM_ACTION_PROLOGUE; + angle_t angle; int damage; int slope; @@ -145,7 +147,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack) if (NULL == (player = self->player)) { - return; + return 0; } APlayerPawn *pmo = player->mo; @@ -207,6 +209,6 @@ punchdone: P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("Fire2")); S_Sound (pmo, CHAN_VOICE, "*fistgrunt", 1, ATTN_NORM); } - return; + return 0; } diff --git a/src/g_hexen/a_fighterquietus.cpp b/src/g_hexen/a_fighterquietus.cpp index dc930a34f..6a73b7eca 100644 --- a/src/g_hexen/a_fighterquietus.cpp +++ b/src/g_hexen/a_fighterquietus.cpp @@ -63,10 +63,10 @@ bool AFighterWeaponPiece::TryPickup (AActor *&toucher) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropWeaponPieces) { - ACTION_PARAM_START(3); - ACTION_PARAM_CLASS(p1, 0); - ACTION_PARAM_CLASS(p2, 1); - ACTION_PARAM_CLASS(p3, 2); + PARAM_ACTION_PROLOGUE; + PARAM_CLASS(p1, AActor); + PARAM_CLASS(p2, AActor); + PARAM_CLASS(p3, AActor); for (int i = 0, j = 0, fineang = 0; i < 3; ++i) { @@ -85,6 +85,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropWeaponPieces) } } } + return 0; } @@ -117,17 +118,19 @@ int AFSwordMissile::DoSpecialDamage(AActor *victim, AActor *source, int damage) DEFINE_ACTION_FUNCTION(AActor, A_FSwordAttack) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } P_SpawnPlayerMissile (self, 0, 0, -10*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->angle+ANGLE_45/4); P_SpawnPlayerMissile (self, 0, 0, -5*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->angle+ANGLE_45/8); @@ -135,6 +138,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FSwordAttack) P_SpawnPlayerMissile (self, 0, 0, 5*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->angle-ANGLE_45/8); P_SpawnPlayerMissile (self, 0, 0, 10*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->angle-ANGLE_45/4); S_Sound (self, CHAN_WEAPON, "FighterSwordFire", 1, ATTN_NORM); + return 0; } //============================================================================ @@ -145,6 +149,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FSwordAttack) DEFINE_ACTION_FUNCTION(AActor, A_FSwordFlames) { + PARAM_ACTION_PROLOGUE; + int i; for (i = 1+(pr_fswordflame()&3); i; i--) @@ -154,6 +160,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FSwordFlames) fixed_t z = self->z+((pr_fswordflame()-128)<<11); Spawn ("FSwordFlame", x, y, z, ALLOW_REPLACE); } + return 0; } //============================================================================ @@ -164,7 +171,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_FSwordFlames) DEFINE_ACTION_FUNCTION(AActor, A_FighterAttack) { - if (!self->target) return; + PARAM_ACTION_PROLOGUE; + + if (!self->target) return 0; angle_t angle = self->angle; @@ -174,5 +183,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_FighterAttack) P_SpawnMissileAngle (self, RUNTIME_CLASS(AFSwordMissile), angle-ANG45/8, 0); P_SpawnMissileAngle (self, RUNTIME_CLASS(AFSwordMissile), angle-ANG45/4, 0); S_Sound (self, CHAN_WEAPON, "FighterSwordFire", 1, ATTN_NORM); + return 0; } diff --git a/src/g_hexen/a_firedemon.cpp b/src/g_hexen/a_firedemon.cpp index d0366fdf0..d13b6600e 100644 --- a/src/g_hexen/a_firedemon.cpp +++ b/src/g_hexen/a_firedemon.cpp @@ -81,11 +81,14 @@ void A_FiredSpawnRock (AActor *actor) DEFINE_ACTION_FUNCTION(AActor, A_FiredRocks) { + PARAM_ACTION_PROLOGUE; + A_FiredSpawnRock (self); A_FiredSpawnRock (self); A_FiredSpawnRock (self); A_FiredSpawnRock (self); A_FiredSpawnRock (self); + return 0; } //============================================================================ @@ -96,11 +99,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredRocks) DEFINE_ACTION_FUNCTION(AActor, A_SmBounce) { + PARAM_ACTION_PROLOGUE; + // give some more velocity (x,y,&z) self->z = self->floorz + FRACUNIT; self->velz = (2*FRACUNIT) + (pr_smbounce() << 10); self->velx = pr_smbounce()%3<vely = pr_smbounce()%3<target == NULL) - return; + return 0; AActor *mo = P_SpawnMissile (self, self->target, PClass::FindClass ("FireDemonMissile")); if (mo) S_Sound (self, CHAN_BODY, "FireDemonAttack", 1, ATTN_NORM); + return 0; } //============================================================================ @@ -125,6 +134,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredAttack) DEFINE_ACTION_FUNCTION(AActor, A_FiredChase) { + PARAM_ACTION_PROLOGUE; + int weaveindex = self->special1; AActor *target = self->target; angle_t ang; @@ -146,7 +157,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredChase) if(!self->target || !(self->target->flags&MF_SHOOTABLE)) { // Invalid target P_LookForPlayers (self,true, NULL); - return; + return 0; } // Strafe @@ -194,7 +205,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredChase) { self->SetState (self->MissileState); self->flags |= MF_JUSTATTACKED; - return; + return 0; } } else @@ -207,6 +218,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredChase) { self->PlayActiveSound (); } + return 0; } //============================================================================ @@ -217,6 +229,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredChase) DEFINE_ACTION_FUNCTION(AActor, A_FiredSplotch) { + PARAM_ACTION_PROLOGUE; + AActor *mo; mo = Spawn ("FireDemonSplotch1", self->x, self->y, self->z, ALLOW_REPLACE); @@ -233,4 +247,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredSplotch) mo->vely = (pr_firedemonsplotch() - 128) << 11; mo->velz = (pr_firedemonsplotch() << 10) + FRACUNIT*3; } + return 0; } diff --git a/src/g_hexen/a_flechette.cpp b/src/g_hexen/a_flechette.cpp index 884e356fd..4049c2ee6 100644 --- a/src/g_hexen/a_flechette.cpp +++ b/src/g_hexen/a_flechette.cpp @@ -297,6 +297,8 @@ int APoisonCloud::DoSpecialDamage (AActor *victim, int damage) DEFINE_ACTION_FUNCTION(AActor, A_PoisonBagInit) { + PARAM_ACTION_PROLOGUE; + AActor *mo; mo = Spawn (self->x, self->y, self->z+28*FRACUNIT, ALLOW_REPLACE); @@ -304,6 +306,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PoisonBagInit) { mo->target = self->target; } + return 0; } //=========================================================================== @@ -314,14 +317,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_PoisonBagInit) DEFINE_ACTION_FUNCTION(AActor, A_PoisonBagCheck) { + PARAM_ACTION_PROLOGUE; + if (--self->special1 <= 0) { self->SetState (self->FindState ("Death")); } else { - return; + return 0; } + return 0; } //=========================================================================== @@ -332,12 +338,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_PoisonBagCheck) DEFINE_ACTION_FUNCTION(AActor, A_PoisonBagDamage) { + PARAM_ACTION_PROLOGUE; + int bobIndex; P_RadiusAttack (self, self->target, 4, 40, self->DamageType, true); bobIndex = self->special2; self->z += FloatBobOffsets[bobIndex]>>4; self->special2 = (bobIndex+1)&63; + return 0; } //=========================================================================== @@ -348,10 +357,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_PoisonBagDamage) DEFINE_ACTION_FUNCTION(AActor, A_CheckThrowBomb) { + PARAM_ACTION_PROLOGUE; + if (--self->health <= 0) { self->SetState (self->FindState(NAME_Death)); } + return 0; } //=========================================================================== @@ -362,6 +374,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckThrowBomb) DEFINE_ACTION_FUNCTION(AActor, A_CheckThrowBomb2) { + PARAM_ACTION_PROLOGUE; + // [RH] Check using actual velocity, although the velz < 2 check still stands //if (abs(self->velx) < FRACUNIT*3/2 && abs(self->vely) < FRACUNIT*3/2 // && self->velz < 2*FRACUNIT) @@ -376,4 +390,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckThrowBomb2) self->flags &= ~MF_MISSILE; } CALL_ACTION(A_CheckThrowBomb, self); + return 0; } diff --git a/src/g_hexen/a_fog.cpp b/src/g_hexen/a_fog.cpp index 34b1537ea..e755c6f10 100644 --- a/src/g_hexen/a_fog.cpp +++ b/src/g_hexen/a_fog.cpp @@ -27,6 +27,8 @@ static FRandom pr_fogspawn ("FogSpawn"); DEFINE_ACTION_FUNCTION(AActor, A_FogSpawn) { + PARAM_ACTION_PROLOGUE; + static const char *fogs[3] = { "FogPatchSmall", @@ -34,11 +36,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_FogSpawn) "FogPatchLarge" }; - AActor *mo=NULL; + AActor *mo = NULL; angle_t delta; - if (self->special1-- > 0) return; - + if (self->special1-- > 0) + { + return 0; + } self->special1 = self->args[2]; // Reset frequency count mo = Spawn (fogs[pr_fogspawn()%3], self->x, self->y, self->z, ALLOW_REPLACE); @@ -55,6 +59,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FogSpawn) mo->args[4] = 1; // Set to moving mo->special2 = pr_fogspawn()&63; } + return 0; } //========================================================================== @@ -65,16 +70,21 @@ DEFINE_ACTION_FUNCTION(AActor, A_FogSpawn) DEFINE_ACTION_FUNCTION(AActor, A_FogMove) { + PARAM_ACTION_PROLOGUE; + int speed = self->args[0]<args[4])) return; + if (!self->args[4]) + { + return 0; + } if (self->args[3]-- <= 0) { self->SetStateNF (self->FindState(NAME_Death)); - return; + return 0; } if ((self->args[3] % 4) == 0) @@ -87,5 +97,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_FogMove) angle = self->angle>>ANGLETOFINESHIFT; self->velx = FixedMul(speed, finecosine[angle]); self->vely = FixedMul(speed, finesine[angle]); + return 0; } diff --git a/src/g_hexen/a_heresiarch.cpp b/src/g_hexen/a_heresiarch.cpp index 2107f2722..ecb27b5ed 100644 --- a/src/g_hexen/a_heresiarch.cpp +++ b/src/g_hexen/a_heresiarch.cpp @@ -231,6 +231,8 @@ void ASorcBall1::DoFireSpell () DEFINE_ACTION_FUNCTION(AActor, A_SorcSpinBalls) { + PARAM_ACTION_PROLOGUE; + AActor *mo; fixed_t z; @@ -252,6 +254,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcSpinBalls) if (mo) mo->target = self; mo = Spawn("SorcBall3", self->x, self->y, z, NO_REPLACE); if (mo) mo->target = self; + return 0; } @@ -263,11 +266,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcSpinBalls) DEFINE_ACTION_FUNCTION(AActor, A_SorcBallOrbit) { + PARAM_ACTION_PROLOGUE; + // [RH] If no parent, then die instead of crashing if (self->target == NULL) { self->SetState (self->FindState(NAME_Pain)); - return; + return 0; } ASorcBall *actor; @@ -287,7 +292,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBallOrbit) if (actor->target->health <= 0) { actor->SetState (actor->FindState(NAME_Pain)); - return; + return 0; } baseangle = (angle_t)parent->special1; @@ -375,6 +380,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBallOrbit) actor->SetOrigin (x, y, parent->z - parent->floorclip + parent->height); actor->floorz = parent->floorz; actor->ceilingz = parent->ceilingz; + return 0; } //============================================================================ @@ -387,8 +393,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBallOrbit) DEFINE_ACTION_FUNCTION(AActor, A_SpeedBalls) { + PARAM_ACTION_PROLOGUE; + self->args[3] = SORC_ACCELERATE; // speed mode self->args[2] = SORCBALL_TERMINAL_SPEED; // target speed + return 0; } @@ -682,8 +691,11 @@ void A_SorcOffense2(AActor *actor) DEFINE_ACTION_FUNCTION(AActor, A_SorcBossAttack) { + PARAM_ACTION_PROLOGUE; + self->args[3] = SORC_ACCELERATE; self->args[2] = SORCBALL_INITIAL_SPEED; + return 0; } //============================================================================ @@ -696,6 +708,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBossAttack) DEFINE_ACTION_FUNCTION(AActor, A_SpawnFizzle) { + PARAM_ACTION_PROLOGUE; + fixed_t x,y,z; fixed_t dist = 5*FRACUNIT; angle_t angle = self->angle >> ANGLETOFINESHIFT; @@ -718,6 +732,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnFizzle) mo->velz = FRACUNIT*2; } } + return 0; } @@ -731,8 +746,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnFizzle) DEFINE_ACTION_FUNCTION(AActor, A_SorcFX1Seek) { + PARAM_ACTION_PROLOGUE; + A_DoBounceCheck (self, "SorcererHeadScream"); P_SeekerMissile (self,ANGLE_1*2,ANGLE_1*6); + return 0; } @@ -754,6 +772,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX1Seek) // Split ball in two DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Split) { + PARAM_ACTION_PROLOGUE; + AActor *mo; mo = Spawn(self->GetClass(), self->x, self->y, self->z, NO_REPLACE); @@ -773,6 +793,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Split) mo->SetState (mo->FindState("Orbit")); } self->Destroy (); + return 0; } //============================================================================ @@ -785,6 +806,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Split) DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Orbit) { + PARAM_ACTION_PROLOGUE; + angle_t angle; fixed_t x,y,z; AActor *parent = self->target; @@ -793,7 +816,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Orbit) if (parent == NULL) { self->Destroy(); - return; + return 0; } fixed_t dist = parent->radius; @@ -841,6 +864,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Orbit) self->SetOrigin (x, y, z); self->floorz = parent->floorz; self->ceilingz = parent->ceilingz; + return 0; } //============================================================================ @@ -853,6 +877,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Orbit) DEFINE_ACTION_FUNCTION(AActor, A_SpawnBishop) { + PARAM_ACTION_PROLOGUE; + AActor *mo; mo = Spawn("Bishop", self->x, self->y, self->z, ALLOW_REPLACE); if (mo) @@ -869,6 +895,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnBishop) } } self->Destroy (); + return 0; } //============================================================================ @@ -879,8 +906,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnBishop) DEFINE_ACTION_FUNCTION(AActor, A_SorcererBishopEntry) { + PARAM_ACTION_PROLOGUE; + Spawn("SorcFX3Explosion", self->x, self->y, self->z, ALLOW_REPLACE); S_Sound (self, CHAN_VOICE, self->SeeSound, 1, ATTN_NORM); + return 0; } //============================================================================ @@ -893,10 +923,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcererBishopEntry) DEFINE_ACTION_FUNCTION(AActor, A_SorcFX4Check) { + PARAM_ACTION_PROLOGUE; + if (self->special2-- <= 0) { self->SetState (self->FindState(NAME_Death)); } + return 0; } //============================================================================ @@ -909,6 +942,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX4Check) DEFINE_ACTION_FUNCTION(AActor, A_SorcBallPop) { + PARAM_ACTION_PROLOGUE; + S_Sound (self, CHAN_BODY, "SorcererBallPop", 1, ATTN_NONE); self->flags &= ~MF_NOGRAVITY; self->gravity = FRACUNIT/8; @@ -918,6 +953,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBallPop) self->special2 = 4*FRACUNIT; // Initial bounce factor self->args[4] = BOUNCE_TIME_UNIT; // Bounce time unit self->args[3] = 5; // Bounce time in seconds + return 0; } //============================================================================ @@ -950,5 +986,8 @@ void A_DoBounceCheck (AActor *self, const char *sound) DEFINE_ACTION_FUNCTION(AActor, A_BounceCheck) { + PARAM_ACTION_PROLOGUE; + A_DoBounceCheck (self, "SorcererBigBallExplode"); + return 0; } diff --git a/src/g_hexen/a_hexenspecialdecs.cpp b/src/g_hexen/a_hexenspecialdecs.cpp index a3fee8557..0edb27e25 100644 --- a/src/g_hexen/a_hexenspecialdecs.cpp +++ b/src/g_hexen/a_hexenspecialdecs.cpp @@ -55,6 +55,8 @@ void APottery1::HitFloor () DEFINE_ACTION_FUNCTION(AActor, A_PotteryExplode) { + PARAM_ACTION_PROLOGUE; + AActor *mo = NULL; int i; @@ -79,6 +81,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PotteryExplode) self->x, self->y, self->z, ALLOW_REPLACE); } } + return 0; } //============================================================================ @@ -89,8 +92,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_PotteryExplode) DEFINE_ACTION_FUNCTION(AActor, A_PotteryChooseBit) { + PARAM_ACTION_PROLOGUE; + self->SetState (self->FindState(NAME_Death) + 1 + 2*(pr_bit()%5)); self->tics = 256+(pr_bit()<<1); + return 0; } //============================================================================ @@ -101,6 +107,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_PotteryChooseBit) DEFINE_ACTION_FUNCTION(AActor, A_PotteryCheck) { + PARAM_ACTION_PROLOGUE; + int i; for(i = 0; i < MAXPLAYERS; i++) @@ -112,10 +120,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_PotteryCheck) pmo->y, self->x, self->y) - pmo->angle) <= ANGLE_45)) { // Previous state (pottery bit waiting state) self->SetState (self->state - 1); - return; + return 0; } } - } + } + return 0; } // Lynched corpse (no heart) ------------------------------------------------ @@ -143,10 +152,13 @@ void AZCorpseLynchedNoHeart::PostBeginPlay () DEFINE_ACTION_FUNCTION(AActor, A_CorpseBloodDrip) { + PARAM_ACTION_PROLOGUE; + if (pr_drip() <= 128) { Spawn ("CorpseBloodDrip", self->x, self->y, self->z + self->height/2, ALLOW_REPLACE); } + return 0; } //============================================================================ @@ -157,6 +169,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CorpseBloodDrip) DEFINE_ACTION_FUNCTION(AActor, A_CorpseExplode) { + PARAM_ACTION_PROLOGUE; + AActor *mo; int i; @@ -182,6 +196,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CorpseExplode) } S_Sound (self, CHAN_BODY, self->DeathSound, 1, ATTN_IDLE); self->Destroy (); + return 0; } //============================================================================ @@ -192,6 +207,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CorpseExplode) DEFINE_ACTION_FUNCTION(AActor, A_LeafSpawn) { + PARAM_ACTION_PROLOGUE; + AActor *mo; int i; @@ -208,6 +225,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LeafSpawn) mo->special1 = 0; } } + return 0; } //============================================================================ @@ -218,10 +236,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_LeafSpawn) DEFINE_ACTION_FUNCTION(AActor, A_LeafThrust) { + PARAM_ACTION_PROLOGUE; + if (pr_leafthrust() <= 96) { self->velz += (pr_leafthrust()<<9)+FRACUNIT; } + return 0; } //============================================================================ @@ -232,11 +253,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_LeafThrust) DEFINE_ACTION_FUNCTION(AActor, A_LeafCheck) { + PARAM_ACTION_PROLOGUE; + self->special1++; if (self->special1 >= 20) { self->SetState (NULL); - return; + return 0; } angle_t ang = self->target ? self->target->angle : self->angle; if (pr_leafcheck() > 64) @@ -245,12 +268,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_LeafCheck) { P_ThrustMobj (self, ang, (pr_leafcheck()<<9)+FRACUNIT); } - return; + return 0; } self->SetState (self->SpawnState + 7); self->velz = (pr_leafcheck()<<9)+FRACUNIT; P_ThrustMobj (self, ang, (pr_leafcheck()<<9)+2*FRACUNIT); self->flags |= MF_MISSILE; + return 0; } //=========================================================================== @@ -261,7 +285,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_LeafCheck) DEFINE_ACTION_FUNCTION(AActor, A_PoisonShroom) { + PARAM_ACTION_PROLOGUE; + self->tics = 128+(pr_shroom()<<1); + return 0; } //=========================================================================== @@ -272,6 +299,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_PoisonShroom) DEFINE_ACTION_FUNCTION(AActor, A_SoAExplode) { + PARAM_ACTION_PROLOGUE; + AActor *mo; int i; @@ -299,6 +328,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SoAExplode) } S_Sound (self, CHAN_BODY, self->DeathSound, 1, ATTN_NORM); self->Destroy (); + return 0; } // Bell --------------------------------------------------------------------- @@ -328,6 +358,8 @@ void AZBell::Activate (AActor *activator) DEFINE_ACTION_FUNCTION(AActor, A_BellReset1) { + PARAM_ACTION_PROLOGUE; + self->flags |= MF_NOGRAVITY; self->height <<= 2; if (self->special) @@ -336,6 +368,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BellReset1) self->args[1], self->args[2], self->args[3], self->args[4]); self->special = 0; } + return 0; } //=========================================================================== @@ -346,8 +379,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_BellReset1) DEFINE_ACTION_FUNCTION(AActor, A_BellReset2) { + PARAM_ACTION_PROLOGUE; + self->flags |= MF_SHOOTABLE; self->flags &= ~MF_CORPSE; self->health = 5; + return 0; } diff --git a/src/g_hexen/a_iceguy.cpp b/src/g_hexen/a_iceguy.cpp index 2d908f974..f43a76122 100644 --- a/src/g_hexen/a_iceguy.cpp +++ b/src/g_hexen/a_iceguy.cpp @@ -26,6 +26,8 @@ static const char *WispTypes[2] = DEFINE_ACTION_FUNCTION(AActor, A_IceGuyLook) { + PARAM_ACTION_PROLOGUE; + fixed_t dist; fixed_t an; @@ -40,6 +42,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyLook) self->y+FixedMul(dist, finesine[an]), self->z+60*FRACUNIT, ALLOW_REPLACE); } + return 0; } //============================================================================ @@ -50,11 +53,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyLook) DEFINE_ACTION_FUNCTION(AActor, A_IceGuyChase) { + PARAM_ACTION_PROLOGUE; + fixed_t dist; fixed_t an; AActor *mo; - A_Chase (self); + A_Chase (stack, self); if (pr_iceguychase() < 128) { dist = ((pr_iceguychase()-128)*self->radius)>>7; @@ -72,6 +77,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyChase) mo->target = self; } } + return 0; } //============================================================================ @@ -82,11 +88,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyChase) DEFINE_ACTION_FUNCTION(AActor, A_IceGuyAttack) { + PARAM_ACTION_PROLOGUE; + fixed_t an; if(!self->target) { - return; + return 0; } an = (self->angle+ANG90)>>ANGLETOFINESHIFT; P_SpawnMissileXYZ(self->x+FixedMul(self->radius>>1, @@ -99,6 +107,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyAttack) finesine[an]), self->z+40*FRACUNIT, self, self->target, PClass::FindClass ("IceGuyFX")); S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); + return 0; } //============================================================================ @@ -109,11 +118,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyAttack) DEFINE_ACTION_FUNCTION(AActor, A_IceGuyDie) { + PARAM_ACTION_PROLOGUE; + self->velx = 0; self->vely = 0; self->velz = 0; self->height = self->GetDefault()->height; CALL_ACTION(A_FreezeDeathChunks, self); + return 0; } //============================================================================ @@ -124,6 +136,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyDie) DEFINE_ACTION_FUNCTION(AActor, A_IceGuyMissileExplode) { + PARAM_ACTION_PROLOGUE; + AActor *mo; int i; @@ -136,5 +150,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyMissileExplode) mo->target = self->target; } } + return 0; } diff --git a/src/g_hexen/a_korax.cpp b/src/g_hexen/a_korax.cpp index 6f67cd6bd..a1f729865 100644 --- a/src/g_hexen/a_korax.cpp +++ b/src/g_hexen/a_korax.cpp @@ -89,6 +89,8 @@ extern void SpawnSpiritTail (AActor *spirit); DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase) { + PARAM_ACTION_PROLOGUE; + AActor *spot; if ((!self->special2) && (self->health <= (self->SpawnHealth()/2))) @@ -103,10 +105,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase) P_StartScript (self, NULL, 249, NULL, 0, 0, 0, 0, 0, false); self->special2 = 1; // Don't run again - return; + return 0; } - if (!self->target) return; + if (self->target == NULL) + { + return 0; + } if (pr_koraxchase()<30) { self->SetState (self->MissileState); @@ -140,6 +145,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase) } } } + return 0; } //============================================================================ @@ -150,6 +156,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase) DEFINE_ACTION_FUNCTION(AActor, A_KoraxBonePop) { + PARAM_ACTION_PROLOGUE; + AActor *mo; int i; @@ -161,6 +169,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxBonePop) } P_StartScript (self, NULL, 255, NULL, 0, 0, 0, 0, false, false); // Death script + return 0; } //============================================================================ @@ -190,6 +199,8 @@ void KSpiritInit (AActor *spirit, AActor *korax) DEFINE_ACTION_FUNCTION(AActor, A_KoraxDecide) { + PARAM_ACTION_PROLOGUE; + if (pr_koraxdecide()<220) { self->SetState (self->FindState("Attack")); @@ -198,6 +209,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxDecide) { self->SetState (self->FindState("Command")); } + return 0; } //============================================================================ @@ -208,6 +220,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxDecide) DEFINE_ACTION_FUNCTION(AActor, A_KoraxMissile) { + PARAM_ACTION_PROLOGUE; + static const struct { const char *type, *sound; } choices[6] = { { "WraithFX1", "WraithMissileFire" }, @@ -236,6 +250,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxMissile) { KoraxFire (self, info, i); } + return 0; } //============================================================================ @@ -248,6 +263,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxMissile) DEFINE_ACTION_FUNCTION(AActor, A_KoraxCommand) { + PARAM_ACTION_PROLOGUE; + fixed_t x,y,z; angle_t ang; int numcommands; @@ -272,6 +289,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxCommand) P_StartScript (self, NULL, 250+(pr_koraxcommand()%numcommands), NULL, 0, 0, 0, 0, false, false); + return 0; } //============================================================================ @@ -329,6 +347,8 @@ void KoraxFire (AActor *actor, const PClass *type, int arm) DEFINE_ACTION_FUNCTION(AActor, A_KSpiritWeave) { + PARAM_ACTION_PROLOGUE; + fixed_t newX, newY; int weaveXY, weaveZ; int angle; @@ -350,6 +370,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KSpiritWeave) weaveZ = (weaveZ+(pr_kspiritweave()%5))&63; self->z += FloatBobOffsets[weaveZ]<<1; self->special2 = weaveZ+(weaveXY<<16); + return 0; } //============================================================================ @@ -430,6 +451,8 @@ void A_KSpiritSeeker (AActor *actor, angle_t thresh, angle_t turnMax) DEFINE_ACTION_FUNCTION(AActor, A_KSpiritRoam) { + PARAM_ACTION_PROLOGUE; + if (self->health-- <= 0) { S_Sound (self, CHAN_VOICE, "SpiritDie", 1, ATTN_NORM); @@ -448,6 +471,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KSpiritRoam) S_Sound (self, CHAN_VOICE, "SpiritActive", 1, ATTN_NONE); } } + return 0; } //============================================================================ @@ -458,11 +482,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_KSpiritRoam) DEFINE_ACTION_FUNCTION(AActor, A_KBolt) { + PARAM_ACTION_PROLOGUE; + // Countdown lifetime if (self->special1-- <= 0) { self->Destroy (); } + return 0; } //============================================================================ @@ -473,6 +500,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_KBolt) DEFINE_ACTION_FUNCTION(AActor, A_KBoltRaise) { + PARAM_ACTION_PROLOGUE; + AActor *mo; fixed_t z; @@ -491,6 +520,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KBoltRaise) { // Maybe cap it off here } + return 0; } //============================================================================ diff --git a/src/g_hexen/a_magecone.cpp b/src/g_hexen/a_magecone.cpp index a80eae659..4e1ff7739 100644 --- a/src/g_hexen/a_magecone.cpp +++ b/src/g_hexen/a_magecone.cpp @@ -51,6 +51,8 @@ int AFrostMissile::DoSpecialDamage (AActor *victim, int damage) DEFINE_ACTION_FUNCTION(AActor, A_FireConePL1) { + PARAM_ACTION_PROLOGUE; + angle_t angle; int damage; int slope; @@ -62,14 +64,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireConePL1) if (NULL == (player = self->player)) { - return; + return 0; } AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } S_Sound (self, CHAN_WEAPON, "MageShardsFire", 1, ATTN_NORM); @@ -99,6 +101,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireConePL1) mo->args[0] = 3; // Mark Initial shard as super damage } } + return 0; } //============================================================================ @@ -109,11 +112,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireConePL1) DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) { + PARAM_ACTION_PROLOGUE; + AActor *mo; int spawndir = self->special1; int spermcount = self->special2; - if (spermcount <= 0) return; // No sperm left + if (spermcount <= 0) + { + return 0; // No sperm left + } self->special2 = 0; spermcount--; @@ -173,4 +181,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) mo->args[0] = (spermcount==3)?2:0; } } + return 0; } diff --git a/src/g_hexen/a_magelightning.cpp b/src/g_hexen/a_magelightning.cpp index 7231514b9..10c555e4c 100644 --- a/src/g_hexen/a_magelightning.cpp +++ b/src/g_hexen/a_magelightning.cpp @@ -126,11 +126,14 @@ int ALightningZap::SpecialMissileHit (AActor *thing) DEFINE_ACTION_FUNCTION(AActor, A_LightningReady) { + PARAM_ACTION_PROLOGUE; + DoReadyWeapon(self); if (pr_lightningready() < 160) { S_Sound (self, CHAN_WEAPON, "MageLightningReady", 1, ATTN_NORM); } + return 0; } //============================================================================ @@ -141,6 +144,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningReady) DEFINE_ACTION_FUNCTION(AActor, A_LightningClip) { + PARAM_ACTION_PROLOGUE; + AActor *cMo; AActor *target = NULL; int zigZag; @@ -149,7 +154,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningClip) { if (self->lastenemy == NULL) { - return; + return 0; } self->z = self->floorz; target = self->lastenemy->tracer; @@ -196,6 +201,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningClip) P_ThrustMobj (self, self->angle, self->Speed>>1); } } + return 0; } @@ -207,6 +213,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningClip) DEFINE_ACTION_FUNCTION(AActor, A_LightningZap) { + PARAM_ACTION_PROLOGUE; const PClass *lightning=PClass::FindClass((ENamedName) self->GetClass()->Meta.GetMetaInt (ACMETA_MissileName, NAME_None)); if (lightning == NULL) lightning = PClass::FindClass("LightningZap"); @@ -219,7 +226,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningZap) if (self->health <= 0) { self->SetState (self->FindState(NAME_Death)); - return; + return 0; } if (self->flags3 & MF3_FLOORHUGGER) { @@ -251,6 +258,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningZap) { S_Sound (self, CHAN_BODY, self->ActiveSound, 1, ATTN_NORM); } + return 0; } //============================================================================ @@ -261,9 +269,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningZap) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MLightningAttack) { - ACTION_PARAM_START(2); - ACTION_PARAM_CLASS(floor, 0); - ACTION_PARAM_CLASS(ceiling, 1); + PARAM_ACTION_PROLOGUE; + PARAM_CLASS_OPT(floor, AActor) { floor = PClass::FindClass("LightningFloor"); } + PARAM_CLASS_OPT(ceiling, AActor) { ceiling = PClass::FindClass("LightningCeiling"); } AActor *fmo, *cmo; @@ -291,6 +299,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MLightningAttack) weapon->DepleteAmmo (weapon->bAltFire); } } + return 0; } //============================================================================ @@ -301,6 +310,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MLightningAttack) DEFINE_ACTION_FUNCTION(AActor, A_ZapMimic) { + PARAM_ACTION_PROLOGUE; + AActor *mo; mo = self->lastenemy; @@ -316,6 +327,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ZapMimic) self->vely = mo->vely; } } + return 0; } //============================================================================ @@ -326,7 +338,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_ZapMimic) DEFINE_ACTION_FUNCTION(AActor, A_LastZap) { - const PClass *lightning=PClass::FindClass((ENamedName) self->GetClass()->Meta.GetMetaInt (ACMETA_MissileName, NAME_None)); + PARAM_ACTION_PROLOGUE; + + const PClass *lightning = PClass::FindClass(ENamedName(self->GetClass()->Meta.GetMetaInt(ACMETA_MissileName, NAME_None))); if (lightning == NULL) lightning = PClass::FindClass("LightningZap"); AActor *mo; @@ -338,6 +352,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LastZap) mo->velz = 40*FRACUNIT; mo->Damage = 0; } + return 0; } //============================================================================ @@ -348,6 +363,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_LastZap) DEFINE_ACTION_FUNCTION(AActor, A_LightningRemove) { + PARAM_ACTION_PROLOGUE; + AActor *mo; mo = self->lastenemy; @@ -356,4 +373,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningRemove) mo->lastenemy = NULL; P_ExplodeMissile (mo, NULL, NULL); } + return 0; } diff --git a/src/g_hexen/a_magestaff.cpp b/src/g_hexen/a_magestaff.cpp index 76610f693..503d81a17 100644 --- a/src/g_hexen/a_magestaff.cpp +++ b/src/g_hexen/a_magestaff.cpp @@ -179,20 +179,22 @@ void MStaffSpawn (AActor *pmo, angle_t angle) DEFINE_ACTION_FUNCTION(AActor, A_MStaffAttack) { + PARAM_ACTION_PROLOGUE; + angle_t angle; player_t *player; AActor *linetarget; if (NULL == (player = self->player)) { - return; + return 0; } AMWeapBloodscourge *weapon = static_cast (self->player->ReadyWeapon); if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } angle = self->angle; @@ -211,6 +213,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MStaffAttack) MStaffSpawn (self, angle+ANGLE_1*5); S_Sound (self, CHAN_WEAPON, "MageStaffFire", 1, ATTN_NORM); weapon->MStaffCount = 3; + return 0; } //============================================================================ @@ -221,6 +224,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_MStaffAttack) DEFINE_ACTION_FUNCTION(AActor, A_MStaffPalette) { + PARAM_ACTION_PROLOGUE; + if (self->player != NULL) { AMWeapBloodscourge *weapon = static_cast (self->player->ReadyWeapon); @@ -229,6 +234,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MStaffPalette) weapon->MStaffCount--; } } + return 0; } //============================================================================ @@ -239,11 +245,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_MStaffPalette) DEFINE_ACTION_FUNCTION(AActor, A_MStaffTrack) { + PARAM_ACTION_PROLOGUE; + if ((self->tracer == 0) && (pr_mstafftrack()<50)) { self->tracer = P_RoughMonsterSearch (self, 10); } P_SeekerMissile (self, ANGLE_1*2, ANGLE_1*10); + return 0; } //============================================================================ @@ -299,13 +308,17 @@ void MStaffSpawn2 (AActor *actor, angle_t angle) DEFINE_ACTION_FUNCTION(AActor, A_MageAttack) { - if (!self->target) return; + PARAM_ACTION_PROLOGUE; + if (self->target == NULL) + { + return 0; + } angle_t angle; angle = self->angle; MStaffSpawn2 (self, angle); MStaffSpawn2 (self, angle-ANGLE_1*5); MStaffSpawn2 (self, angle+ANGLE_1*5); S_Sound (self, CHAN_WEAPON, "MageStaffFire", 1, ATTN_NORM); + return 0; } - diff --git a/src/g_hexen/a_magewand.cpp b/src/g_hexen/a_magewand.cpp index b5d2aaa0f..de29bf7d8 100644 --- a/src/g_hexen/a_magewand.cpp +++ b/src/g_hexen/a_magewand.cpp @@ -51,8 +51,11 @@ void AMageWandMissile::Effect () DEFINE_ACTION_FUNCTION(AActor, A_MWandAttack) { + PARAM_ACTION_PROLOGUE; + AActor *mo; mo = P_SpawnPlayerMissile (self, RUNTIME_CLASS(AMageWandMissile)); S_Sound (self, CHAN_WEAPON, "MageWandFire", 1, ATTN_NORM); + return 0; } diff --git a/src/g_hexen/a_pig.cpp b/src/g_hexen/a_pig.cpp index 21d2ab936..e75ef9921 100644 --- a/src/g_hexen/a_pig.cpp +++ b/src/g_hexen/a_pig.cpp @@ -60,6 +60,8 @@ void APigPlayer::MorphPlayerThink () DEFINE_ACTION_FUNCTION(AActor, A_SnoutAttack) { + PARAM_ACTION_PROLOGUE; + angle_t angle; int damage; int slope; @@ -69,7 +71,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SnoutAttack) if (NULL == (player = self->player)) { - return; + return 0; } damage = 3+(pr_snoutattack()&3); @@ -85,6 +87,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SnoutAttack) S_Sound(player->mo, CHAN_VOICE, "PigAttack", 1, ATTN_NORM); } } + return 0; } //============================================================================ @@ -95,9 +98,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_SnoutAttack) DEFINE_ACTION_FUNCTION(AActor, A_PigPain) { + PARAM_ACTION_PROLOGUE; + CALL_ACTION(A_Pain, self); if (self->z <= self->floorz) { self->velz = FRACUNIT*7/2; } + return 0; } diff --git a/src/g_hexen/a_serpent.cpp b/src/g_hexen/a_serpent.cpp index b44a6175d..8cbf0e163 100644 --- a/src/g_hexen/a_serpent.cpp +++ b/src/g_hexen/a_serpent.cpp @@ -25,8 +25,11 @@ static FRandom pr_delaygib ("DelayGib"); DEFINE_ACTION_FUNCTION(AActor, A_SerpentUnHide) { + PARAM_ACTION_PROLOGUE; + self->renderflags &= ~RF_INVISIBLE; self->floorclip = 24*FRACUNIT; + return 0; } //============================================================================ @@ -37,8 +40,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentUnHide) DEFINE_ACTION_FUNCTION(AActor, A_SerpentHide) { + PARAM_ACTION_PROLOGUE; + self->renderflags |= RF_INVISIBLE; self->floorclip = 0; + return 0; } //============================================================================ @@ -50,7 +56,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentHide) DEFINE_ACTION_FUNCTION(AActor, A_SerpentRaiseHump) { + PARAM_ACTION_PROLOGUE; + self->floorclip -= 4*FRACUNIT; + return 0; } //============================================================================ @@ -61,7 +70,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentRaiseHump) DEFINE_ACTION_FUNCTION(AActor, A_SerpentLowerHump) { + PARAM_ACTION_PROLOGUE; + self->floorclip += 4*FRACUNIT; + return 0; } //============================================================================ @@ -74,21 +86,23 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentLowerHump) DEFINE_ACTION_FUNCTION(AActor, A_SerpentHumpDecide) { + PARAM_ACTION_PROLOGUE; + if (self->MissileState != NULL) { if (pr_serpenthump() > 30) { - return; + return 0; } else if (pr_serpenthump() < 40) { // Missile attack self->SetState (self->MeleeState); - return; + return 0; } } else if (pr_serpenthump() > 3) { - return; + return 0; } if (!self->CheckMeleeRange ()) { // The hump shouldn't occur when within melee range @@ -102,6 +116,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentHumpDecide) S_Sound (self, CHAN_BODY, "SerpentActive", 1, ATTN_NORM); } } + return 0; } //============================================================================ @@ -112,16 +127,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentHumpDecide) DEFINE_ACTION_FUNCTION(AActor, A_SerpentCheckForAttack) { + PARAM_ACTION_PROLOGUE; + if (!self->target) { - return; + return 0; } if (self->MissileState != NULL) { if (!self->CheckMeleeRange ()) { self->SetState (self->FindState ("Attack")); - return; + return 0; } } if (P_CheckMeleeRange2 (self)) @@ -139,6 +156,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentCheckForAttack) self->SetState (self->FindState ("Attack")); } } + return 0; } //============================================================================ @@ -149,14 +167,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentCheckForAttack) DEFINE_ACTION_FUNCTION(AActor, A_SerpentChooseAttack) { + PARAM_ACTION_PROLOGUE; + if (!self->target || self->CheckMeleeRange()) { - return; + return 0; } if (self->MissileState != NULL) { self->SetState (self->MissileState); } + return 0; } //============================================================================ @@ -167,9 +188,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentChooseAttack) DEFINE_ACTION_FUNCTION(AActor, A_SerpentMeleeAttack) { + PARAM_ACTION_PROLOGUE; + if (!self->target) { - return; + return 0; } if (self->CheckMeleeRange ()) { @@ -182,6 +205,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentMeleeAttack) { CALL_ACTION(A_SerpentCheckForAttack, self); } + return 0; } //============================================================================ @@ -192,6 +216,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentMeleeAttack) DEFINE_ACTION_FUNCTION(AActor, A_SerpentSpawnGibs) { + PARAM_ACTION_PROLOGUE; + AActor *mo; static const char *GibTypes[] = { @@ -213,6 +239,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentSpawnGibs) mo->floorclip = 6*FRACUNIT; } } + return 0; } //============================================================================ @@ -223,7 +250,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentSpawnGibs) DEFINE_ACTION_FUNCTION(AActor, A_FloatGib) { + PARAM_ACTION_PROLOGUE; + self->floorclip -= FRACUNIT; + return 0; } //============================================================================ @@ -234,7 +264,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FloatGib) DEFINE_ACTION_FUNCTION(AActor, A_SinkGib) { + PARAM_ACTION_PROLOGUE; + self->floorclip += FRACUNIT; + return 0; } //============================================================================ @@ -245,7 +278,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SinkGib) DEFINE_ACTION_FUNCTION(AActor, A_DelayGib) { + PARAM_ACTION_PROLOGUE; + self->tics -= pr_delaygib()>>2; + return 0; } //============================================================================ @@ -256,6 +292,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_DelayGib) DEFINE_ACTION_FUNCTION(AActor, A_SerpentHeadCheck) { + PARAM_ACTION_PROLOGUE; + if (self->z <= self->floorz) { if (Terrains[P_GetThingFloorType(self)].IsLiquid) @@ -268,5 +306,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentHeadCheck) self->SetState (self->FindState(NAME_Death)); } } + return 0; } diff --git a/src/g_hexen/a_spike.cpp b/src/g_hexen/a_spike.cpp index ea9d7c3d2..741781280 100644 --- a/src/g_hexen/a_spike.cpp +++ b/src/g_hexen/a_spike.cpp @@ -78,16 +78,21 @@ void AThrustFloor::Deactivate (AActor *activator) DEFINE_ACTION_FUNCTION(AActor, A_ThrustInitUp) { + PARAM_ACTION_PROLOGUE; + self->special2 = 5; // Raise speed self->args[0] = 1; // Mark as up self->floorclip = 0; self->flags = MF_SOLID; self->flags2 = MF2_NOTELEPORT|MF2_FLOORCLIP; self->special1 = 0L; + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_ThrustInitDn) { + PARAM_ACTION_PROLOGUE; + self->special2 = 5; // Raise speed self->args[0] = 0; // Mark as down self->floorclip = self->GetDefault()->height; @@ -96,11 +101,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_ThrustInitDn) self->renderflags = RF_INVISIBLE; static_cast(self)->DirtClump = Spawn("DirtClump", self->x, self->y, self->z, ALLOW_REPLACE); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_ThrustRaise) { + PARAM_ACTION_PROLOGUE; + AThrustFloor *actor = static_cast(self); if (A_RaiseMobj (actor, self->special2*FRACUNIT)) @@ -123,10 +131,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_ThrustRaise) if (pr_thrustraise()<40) P_SpawnDirt (actor, actor->radius); actor->special2++; // Increase raise speed + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_ThrustLower) { + PARAM_ACTION_PROLOGUE; + if (A_SinkMobj (self, 6*FRACUNIT)) { self->args[0] = 0; @@ -135,10 +146,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_ThrustLower) else self->SetStateNF (self->FindState ("ThrustInit1")); } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_ThrustImpale) { + PARAM_ACTION_PROLOGUE; + AActor *thing; FBlockThingsIterator it(FBoundingBox(self->x, self->y, self->radius)); while ((thing = it.Next())) @@ -158,5 +172,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_ThrustImpale) P_TraceBleed (10001, thing); self->args[1] = 1; // Mark thrust thing as bloody } + return 0; } diff --git a/src/g_hexen/a_summon.cpp b/src/g_hexen/a_summon.cpp index 69c0238ba..6f698cbc2 100644 --- a/src/g_hexen/a_summon.cpp +++ b/src/g_hexen/a_summon.cpp @@ -49,6 +49,8 @@ bool AArtiDarkServant::Use (bool pickup) DEFINE_ACTION_FUNCTION(AActor, A_Summon) { + PARAM_ACTION_PROLOGUE; + AMinotaurFriend *mo; mo = Spawn (self->x, self->y, self->z, ALLOW_REPLACE); @@ -59,7 +61,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Summon) mo->Destroy (); AActor *arti = Spawn (self->x, self->y, self->z, ALLOW_REPLACE); if (arti) arti->flags |= MF_DROPPED; - return; + return 0; } mo->StartTime = level.maptime; @@ -82,4 +84,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_Summon) Spawn ("MinotaurSmoke", self->x, self->y, self->z, ALLOW_REPLACE); S_Sound (self, CHAN_VOICE, mo->ActiveSound, 1, ATTN_NORM); } + return 0; } diff --git a/src/g_hexen/a_teleportother.cpp b/src/g_hexen/a_teleportother.cpp index 22f0673f5..fd8fa9a48 100644 --- a/src/g_hexen/a_teleportother.cpp +++ b/src/g_hexen/a_teleportother.cpp @@ -65,30 +65,41 @@ static void TeloSpawn (AActor *source, const char *type) DEFINE_ACTION_FUNCTION(AActor, A_TeloSpawnA) { + PARAM_ACTION_PROLOGUE; TeloSpawn (self, "TelOtherFX2"); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_TeloSpawnB) { + PARAM_ACTION_PROLOGUE; TeloSpawn (self, "TelOtherFX3"); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_TeloSpawnC) { + PARAM_ACTION_PROLOGUE; TeloSpawn (self, "TelOtherFX4"); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_TeloSpawnD) { + PARAM_ACTION_PROLOGUE; TeloSpawn (self, "TelOtherFX5"); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_CheckTeleRing) { + PARAM_ACTION_PROLOGUE; + if (self->special1-- <= 0) { self->SetState (self->FindState(NAME_Death)); } + return 0; } //=========================================================================== diff --git a/src/g_hexen/a_wraith.cpp b/src/g_hexen/a_wraith.cpp index 219c3a6bb..9ed3fd3df 100644 --- a/src/g_hexen/a_wraith.cpp +++ b/src/g_hexen/a_wraith.cpp @@ -29,6 +29,8 @@ static FRandom pr_wraithfx4 ("WraithFX4"); DEFINE_ACTION_FUNCTION(AActor, A_WraithInit) { + PARAM_ACTION_PROLOGUE; + self->z += 48<special1 = 0; // index into floatbob + return 0; } //============================================================================ @@ -48,11 +51,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithInit) DEFINE_ACTION_FUNCTION(AActor, A_WraithRaiseInit) { + PARAM_ACTION_PROLOGUE; + self->renderflags &= ~RF_INVISIBLE; self->flags2 &= ~MF2_NONSHOOTABLE; self->flags3 &= ~MF3_DONTBLAST; self->flags |= MF_SHOOTABLE|MF_SOLID; self->floorclip = self->height; + return 0; } //============================================================================ @@ -63,6 +69,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithRaiseInit) DEFINE_ACTION_FUNCTION(AActor, A_WraithRaise) { + PARAM_ACTION_PROLOGUE; + if (A_RaiseMobj (self, 2*FRACUNIT)) { // Reached it's target height @@ -75,6 +83,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithRaise) } P_SpawnDirt (self, self->radius); + return 0; } //============================================================================ @@ -85,6 +94,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithRaise) DEFINE_ACTION_FUNCTION(AActor, A_WraithMelee) { + PARAM_ACTION_PROLOGUE; + int amount; // Steal health from target and give to self @@ -94,6 +105,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithMelee) P_DamageMobj (self->target, self, self, amount, NAME_Melee); self->health += amount; } + return 0; } //============================================================================ @@ -104,6 +116,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithMelee) DEFINE_ACTION_FUNCTION(AActor, A_WraithFX2) { + PARAM_ACTION_PROLOGUE; + AActor *mo; angle_t angle; int i; @@ -130,6 +144,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithFX2) mo->floorclip = 10*FRACUNIT; } } + return 0; } //============================================================================ @@ -142,6 +157,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithFX2) DEFINE_ACTION_FUNCTION(AActor, A_WraithFX3) { + PARAM_ACTION_PROLOGUE; + AActor *mo; int numdropped = pr_wraithfx3()%15; @@ -156,6 +173,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithFX3) mo->target = self; } } + return 0; } //============================================================================ @@ -225,6 +243,8 @@ void A_WraithFX4 (AActor *self) DEFINE_ACTION_FUNCTION(AActor, A_WraithChase) { + PARAM_ACTION_PROLOGUE; + int weaveindex = self->special1; self->z += FloatBobOffsets[weaveindex]; self->special1 = (weaveindex+2)&63; @@ -233,6 +253,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithChase) // P_SetMobjState(self, S_WRAITH_RAISE2); // return; // } - A_Chase (self); + A_Chase (stack, self); A_WraithFX4 (self); + return 0; } diff --git a/src/g_raven/a_minotaur.cpp b/src/g_raven/a_minotaur.cpp index 3dc9e141a..1057a7c9b 100644 --- a/src/g_raven/a_minotaur.cpp +++ b/src/g_raven/a_minotaur.cpp @@ -174,18 +174,23 @@ bool AMinotaurFriend::OkayToSwitchTarget (AActor *other) DEFINE_ACTION_FUNCTION(AActor, A_MinotaurDeath) { + PARAM_ACTION_PROLOGUE; + if (Wads.CheckNumForName ("MNTRF1", ns_sprites) < 0 && Wads.CheckNumForName ("MNTRF0", ns_sprites) < 0) self->SetState(self->FindState ("FadeOut")); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk1) { + PARAM_ACTION_PROLOGUE; + player_t *player; if (!self->target) { - return; + return 0; } S_Sound (self, CHAN_WEAPON, "minotaur/melee", 1, ATTN_NORM); if (self->CheckMeleeRange()) @@ -199,6 +204,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk1) player->deltaviewheight = -16*FRACUNIT; } } + return 0; } //---------------------------------------------------------------------------- @@ -213,6 +219,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk1) DEFINE_ACTION_FUNCTION(AActor, A_MinotaurDecide) { + PARAM_ACTION_PROLOGUE; + bool friendly = !!(self->flags5 & MF5_SUMMONEDMONSTER); angle_t angle; AActor *target; @@ -221,7 +229,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurDecide) target = self->target; if (!target) { - return; + return 0; } if (!friendly) { @@ -260,6 +268,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurDecide) // Don't need to call P_SetMobjState because the current state // falls through to the swing attack } + return 0; } //---------------------------------------------------------------------------- @@ -270,10 +279,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurDecide) DEFINE_ACTION_FUNCTION(AActor, A_MinotaurCharge) { + PARAM_ACTION_PROLOGUE; + AActor *puff; - if (!self->target) return; - + if (self->target == NULL) + { + return 0; + } if (self->special1 > 0) { const PClass *type; @@ -296,6 +309,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurCharge) self->flags2 &= ~MF2_INVULNERABLE; self->SetState (self->SeeState); } + return 0; } //---------------------------------------------------------------------------- @@ -308,15 +322,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurCharge) DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk2) { + PARAM_ACTION_PROLOGUE; + AActor *mo; angle_t angle; fixed_t velz; fixed_t z; bool friendly = !!(self->flags5 & MF5_SUMMONEDMONSTER); - if (!self->target) + if (self->target == NULL) { - return; + return 0; } S_Sound (self, CHAN_WEAPON, "minotaur/attack2", 1, ATTN_NORM); if (self->CheckMeleeRange()) @@ -325,7 +341,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk2) damage = pr_atk.HitDice (friendly ? 3 : 5); P_DamageMobj (self->target, self, self, damage, NAME_Melee); P_TraceBleed (damage, self->target, self); - return; + return 0; } z = self->z + 40*FRACUNIT; const PClass *fx = PClass::FindClass("MinotaurFX1"); @@ -343,6 +359,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk2) P_SpawnMissileAngleZ (self, z, fx, angle+(ANG45/16), velz); } } + return 0; } //---------------------------------------------------------------------------- @@ -355,13 +372,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk2) DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk3) { + PARAM_ACTION_PROLOGUE; + AActor *mo; player_t *player; bool friendly = !!(self->flags5 & MF5_SUMMONEDMONSTER); if (!self->target) { - return; + return 0; } S_Sound (self, CHAN_VOICE, "minotaur/attack3", 1, ATTN_NORM); if (self->CheckMeleeRange()) @@ -398,6 +417,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk3) self->SetState (self->FindState ("HammerLoop")); self->special2 = 1; } + return 0; } //---------------------------------------------------------------------------- @@ -408,6 +428,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk3) DEFINE_ACTION_FUNCTION(AActor, A_MntrFloorFire) { + PARAM_ACTION_PROLOGUE; + AActor *mo; fixed_t x, y; @@ -418,6 +440,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MntrFloorFire) mo->target = self->target; mo->velx = 1; // Force block checking P_CheckMissileSpawn (mo); + return 0; } //--------------------------------------------------------------------------- @@ -464,6 +487,8 @@ void P_MinotaurSlam (AActor *source, AActor *target) DEFINE_ACTION_FUNCTION(AActor, A_MinotaurRoam) { + PARAM_ACTION_PROLOGUE; + // In case pain caused him to skip his fade in. self->RenderStyle = STYLE_Normal; @@ -474,7 +499,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurRoam) if (self1->StartTime >= 0 && (level.maptime - self1->StartTime) >= MAULATORTICS) { P_DamageMobj (self1, NULL, NULL, TELEFRAG_DAMAGE, NAME_None); - return; + return 0; } } @@ -496,6 +521,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurRoam) self->movedir = (self->movedir+7)%8; FaceMovementDirection (self); } + return 0; } @@ -509,10 +535,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurRoam) DEFINE_ACTION_FUNCTION(AActor, A_MinotaurLook) { + PARAM_ACTION_PROLOGUE; + if (!self->IsKindOf(RUNTIME_CLASS(AMinotaurFriend))) { CALL_ACTION(A_Look, self); - return; + return 0; } AActor *mo = NULL; @@ -573,14 +601,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurLook) { self->SetStateNF (self->FindState ("Roam")); } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_MinotaurChase) { + PARAM_ACTION_PROLOGUE; + if (!self->IsKindOf(RUNTIME_CLASS(AMinotaurFriend))) { - A_Chase (self); - return; + A_Chase (stack, self); + return 0; } AMinotaurFriend *self1 = static_cast (self); @@ -591,7 +622,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurChase) if (self1->StartTime >= 0 && (level.maptime - self1->StartTime) >= MAULATORTICS) { P_DamageMobj (self1, NULL, NULL, TELEFRAG_DAMAGE, NAME_None); - return; + return 0; } if (pr_minotaurchase() < 30) @@ -601,7 +632,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurChase) !(self1->target->flags&MF_SHOOTABLE)) { // look for a new target self1->SetState (self1->FindState ("Spawn")); - return; + return 0; } FaceMovementDirection (self1); @@ -615,14 +646,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurChase) S_Sound (self1, CHAN_WEAPON, self1->AttackSound, 1, ATTN_NORM); } self1->SetState (self1->MeleeState); - return; + return 0; } // Missile attack if (self1->MissileState && P_CheckMissileRange(self1)) { self1->SetState (self1->MissileState); - return; + return 0; } // chase towards target @@ -637,5 +668,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurChase) { self1->PlayActiveSound (); } + return 0; } diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp index 767d282b8..494ea11f0 100644 --- a/src/g_shared/a_action.cpp +++ b/src/g_shared/a_action.cpp @@ -59,6 +59,8 @@ IMPLEMENT_CLASS (ASwitchingDecoration) DEFINE_ACTION_FUNCTION(AActor, A_NoBlocking) { + PARAM_ACTION_PROLOGUE; + // [RH] Andy Baker's stealth monsters if (self->flags & MF_STEALTH) { @@ -73,7 +75,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_NoBlocking) { P_DropItem (self, self->Conversation->DropType, -1, 256); self->Conversation = NULL; - return; + return 0; } self->Conversation = NULL; @@ -96,11 +98,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_NoBlocking) } } } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_Fall) { + PARAM_ACTION_PROLOGUE; + CALL_ACTION(A_NoBlocking, self); + return 0; } //========================================================================== @@ -111,8 +117,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_Fall) DEFINE_ACTION_FUNCTION(AActor, A_SetFloorClip) { + PARAM_ACTION_PROLOGUE; + self->flags2 |= MF2_FLOORCLIP; self->AdjustFloorClip (); + return 0; } //========================================================================== @@ -123,8 +132,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetFloorClip) DEFINE_ACTION_FUNCTION(AActor, A_UnSetFloorClip) { + PARAM_ACTION_PROLOGUE; + self->flags2 &= ~MF2_FLOORCLIP; self->floorclip = 0; + return 0; } //========================================================================== @@ -135,7 +147,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_UnSetFloorClip) DEFINE_ACTION_FUNCTION(AActor, A_HideThing) { + PARAM_ACTION_PROLOGUE; + self->renderflags |= RF_INVISIBLE; + return 0; } //========================================================================== @@ -146,7 +161,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_HideThing) DEFINE_ACTION_FUNCTION(AActor, A_UnHideThing) { + PARAM_ACTION_PROLOGUE; + self->renderflags &= ~RF_INVISIBLE; + return 0; } //============================================================================ @@ -157,6 +175,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_UnHideThing) DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeath) { + PARAM_ACTION_PROLOGUE; + int t = pr_freezedeath(); self->tics = 75+t+pr_freezedeath(); self->flags |= MF_SOLID|MF_SHOOTABLE|MF_NOBLOOD|MF_ICECORPSE; @@ -184,6 +204,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeath) self->args[1], self->args[2], self->args[3], self->args[4]); self->special = 0; } + return 0; } //========================================================================== @@ -194,8 +215,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeath) DEFINE_ACTION_FUNCTION(AActor, A_GenericFreezeDeath) { + PARAM_ACTION_PROLOGUE; + self->Translation = TRANSLATION(TRANSLATION_Standard, 7); CALL_ACTION(A_FreezeDeath, self); + return 0; } //============================================================================ @@ -206,6 +230,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_GenericFreezeDeath) DEFINE_ACTION_FUNCTION(AActor, A_IceSetTics) { + PARAM_ACTION_PROLOGUE; + int floor; self->tics = 70+(pr_icesettics()&63); @@ -218,6 +244,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceSetTics) { self->tics <<= 1; } + return 0; } //============================================================================ @@ -228,6 +255,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceSetTics) DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks) { + PARAM_ACTION_PROLOGUE; int i; int numChunks; @@ -236,7 +264,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks) if (self->velx || self->vely || self->velz) { self->tics = 3*TICRATE; - return; + return 0; } S_Sound (self, CHAN_BODY, "misc/icebreak", 1, ATTN_NORM); @@ -297,6 +325,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks) CALL_ACTION(A_NoBlocking, self); self->SetState(self->FindState(NAME_Null)); + return 0; } //---------------------------------------------------------------------------- @@ -400,13 +429,20 @@ void DCorpsePointer::Serialize (FArchive &arc) // throw another corpse on the queue DEFINE_ACTION_FUNCTION(AActor, A_QueueCorpse) { + PARAM_ACTION_PROLOGUE; + if (sv_corpsequeuesize > 0) + { new DCorpsePointer (self); + } + return 0; } // Remove an self from the queue (for resurrection) DEFINE_ACTION_FUNCTION(AActor, A_DeQueueCorpse) { + PARAM_ACTION_PROLOGUE; + TThinkerIterator iterator (STAT_CORPSEPOINTER); DCorpsePointer *corpsePtr; @@ -416,9 +452,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeQueueCorpse) { corpsePtr->Corpse = NULL; corpsePtr->Destroy (); - return; + return 0; } } + return 0; } //============================================================================ @@ -429,7 +466,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeQueueCorpse) DEFINE_ACTION_FUNCTION(AActor, A_SetInvulnerable) { + PARAM_ACTION_PROLOGUE; + self->flags2 |= MF2_INVULNERABLE; + return 0; } //============================================================================ @@ -440,7 +480,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetInvulnerable) DEFINE_ACTION_FUNCTION(AActor, A_UnSetInvulnerable) { + PARAM_ACTION_PROLOGUE; + self->flags2 &= ~MF2_INVULNERABLE; + return 0; } //============================================================================ @@ -451,7 +494,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_UnSetInvulnerable) DEFINE_ACTION_FUNCTION(AActor, A_SetReflective) { + PARAM_ACTION_PROLOGUE; + self->flags2 |= MF2_REFLECTIVE; + return 0; } //============================================================================ @@ -462,7 +508,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetReflective) DEFINE_ACTION_FUNCTION(AActor, A_UnSetReflective) { + PARAM_ACTION_PROLOGUE; + self->flags2 &= ~MF2_REFLECTIVE; + return 0; } //============================================================================ @@ -473,7 +522,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_UnSetReflective) DEFINE_ACTION_FUNCTION(AActor, A_SetReflectiveInvulnerable) { + PARAM_ACTION_PROLOGUE; + self->flags2 |= MF2_REFLECTIVE|MF2_INVULNERABLE; + return 0; } //============================================================================ @@ -484,7 +536,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetReflectiveInvulnerable) DEFINE_ACTION_FUNCTION(AActor, A_UnSetReflectiveInvulnerable) { + PARAM_ACTION_PROLOGUE; + self->flags2 &= ~(MF2_REFLECTIVE|MF2_INVULNERABLE); + return 0; } //========================================================================== @@ -495,8 +550,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_UnSetReflectiveInvulnerable) DEFINE_ACTION_FUNCTION(AActor, A_SetShootable) { + PARAM_ACTION_PROLOGUE; + self->flags2 &= ~MF2_NONSHOOTABLE; self->flags |= MF_SHOOTABLE; + return 0; } //========================================================================== @@ -507,8 +565,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetShootable) DEFINE_ACTION_FUNCTION(AActor, A_UnSetShootable) { + PARAM_ACTION_PROLOGUE; + self->flags2 |= MF2_NONSHOOTABLE; self->flags &= ~MF_SHOOTABLE; + return 0; } //=========================================================================== @@ -519,7 +580,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_UnSetShootable) DEFINE_ACTION_FUNCTION(AActor, A_NoGravity) { + PARAM_ACTION_PROLOGUE; + self->flags |= MF_NOGRAVITY; + return 0; } //=========================================================================== @@ -530,8 +594,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_NoGravity) DEFINE_ACTION_FUNCTION(AActor, A_Gravity) { + PARAM_ACTION_PROLOGUE; + self->flags &= ~MF_NOGRAVITY; self->gravity = FRACUNIT; + return 0; } //=========================================================================== @@ -542,8 +609,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_Gravity) DEFINE_ACTION_FUNCTION(AActor, A_LowGravity) { + PARAM_ACTION_PROLOGUE; + self->flags &= ~MF_NOGRAVITY; self->gravity = FRACUNIT/8; + return 0; } //=========================================================================== diff --git a/src/g_shared/a_bridge.cpp b/src/g_shared/a_bridge.cpp index 7e743a0af..99a7c1a70 100644 --- a/src/g_shared/a_bridge.cpp +++ b/src/g_shared/a_bridge.cpp @@ -72,10 +72,12 @@ void ACustomBridge::BeginPlay () DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit) { + PARAM_ACTION_PROLOGUE; + if (self->target == NULL) { // Don't crash if somebody spawned this into the world // independantly of a Bridge actor. - return; + return 0; } // Set default values // Every five tics, Hexen moved the ball 3/256th of a revolution. @@ -97,18 +99,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit) self->x = self->target->x + rotationradius * finecosine[self->angle >> ANGLETOFINESHIFT]; self->y = self->target->y + rotationradius * finesine[self->angle >> ANGLETOFINESHIFT]; self->z = self->target->z; + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit) { + PARAM_ACTION_PROLOGUE; + PARAM_CLASS_OPT(balltype, AActor) { balltype = NULL; } + 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; @@ -127,6 +130,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit) ball->target = self; CALL_ACTION(A_BridgeOrbit, ball); } + return 0; } /* never used diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index e9d9e2003..ad5505be2 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -266,11 +266,14 @@ bool P_GiveBody (AActor *actor, int num) DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialThing1) { + PARAM_ACTION_PROLOGUE; + self->renderflags &= ~RF_INVISIBLE; if (static_cast(self)->DoRespawn ()) { S_Sound (self, CHAN_VOICE, "misc/spawn", 1, ATTN_IDLE); } + return 0; } //--------------------------------------------------------------------------- @@ -281,12 +284,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialThing1) DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialThing2) { + PARAM_ACTION_PROLOGUE; + self->flags |= MF_SPECIAL; if (!(self->GetDefault()->flags & MF_NOGRAVITY)) { self->flags &= ~MF_NOGRAVITY; } self->SetState (self->SpawnState); + return 0; } @@ -298,6 +304,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialThing2) DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialDoomThing) { + PARAM_ACTION_PROLOGUE; + self->renderflags &= ~RF_INVISIBLE; self->flags |= MF_SPECIAL; if (!(self->GetDefault()->flags & MF_NOGRAVITY)) @@ -310,6 +318,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialDoomThing) S_Sound (self, CHAN_VOICE, "misc/spawn", 1, ATTN_IDLE); Spawn ("ItemFog", self->x, self->y, self->z, ALLOW_REPLACE); } + return 0; } //--------------------------------------------------------------------------- @@ -320,6 +329,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialDoomThing) DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) { + PARAM_ACTION_PROLOGUE; + // Move item back to its original location fixed_t _x, _y; sector_t *sec; @@ -356,6 +367,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) self->z += FloatBobOffsets[(self->FloatBobPhase + level.maptime) & 63]; } } + return 0; } int AInventory::StaticLastMessageTic; diff --git a/src/g_shared/a_randomspawner.cpp b/src/g_shared/a_randomspawner.cpp index a5ffa9251..1d8ceaa54 100644 --- a/src/g_shared/a_randomspawner.cpp +++ b/src/g_shared/a_randomspawner.cpp @@ -164,7 +164,7 @@ class ARandomSpawner : public AActor Super::Tick(); if (tracer == NULL || tracer->health <= 0) { - CALL_ACTION(A_BossDeath, this); + A_BossDeath(this); Destroy(); } } @@ -172,4 +172,3 @@ class ARandomSpawner : public AActor }; IMPLEMENT_CLASS (ARandomSpawner) - diff --git a/src/g_shared/a_specialspot.cpp b/src/g_shared/a_specialspot.cpp index dbf2cffca..8bf280e78 100644 --- a/src/g_shared/a_specialspot.cpp +++ b/src/g_shared/a_specialspot.cpp @@ -384,36 +384,36 @@ void ASpecialSpot::Destroy() DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnSingleItem) { + PARAM_ACTION_PROLOGUE; + PARAM_CLASS (cls, AActor); + PARAM_INT_OPT (fail_sp) { fail_sp = 0; } + PARAM_INT_OPT (fail_co) { fail_co = 0; } + PARAM_INT_OPT (fail_dm) { fail_dm = 0; } + AActor *spot = NULL; DSpotState *state = DSpotState::GetSpotState(); if (state != NULL) spot = state->GetRandomSpot(RUNTIME_TYPE(self), true); - if (spot == NULL) return; - - 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 (spot == NULL) return 0; if (!multiplayer && pr_spawnmace() < fail_sp) { // Sometimes doesn't show up if not in deathmatch - return; + return 0; } if (multiplayer && !deathmatch && pr_spawnmace() < fail_co) { - return; + return 0; } if (deathmatch && pr_spawnmace() < fail_dm) { - return; + return 0; } if (cls == NULL) { - return; + return 0; } AActor *spawned = Spawn(cls, self->x, self->y, self->z, ALLOW_REPLACE); @@ -432,5 +432,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnSingleItem) static_cast(spawned)->SpawnPointClass = RUNTIME_TYPE(self); } } + return 0; } diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index e02391640..d2387fba0 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -1702,23 +1702,24 @@ const PClass *Net_ReadWeapon(BYTE **stream) DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_ZoomFactor) { - ACTION_PARAM_START(2); - ACTION_PARAM_FLOAT(zoom, 0); - ACTION_PARAM_INT(flags, 1); + PARAM_ACTION_PROLOGUE; + PARAM_FLOAT_OPT (zoom) { zoom = 1; } + PARAM_INT_OPT (flags) { flags = 0; } if (self->player != NULL && self->player->ReadyWeapon != NULL) { - zoom = 1 / clamp(zoom, 0.1f, 50.f); + zoom = 1 / clamp(zoom, 0.1, 50.0); if (flags & 1) { // Make the zoom instant. - self->player->FOV = self->player->DesiredFOV * zoom; + self->player->FOV = float(self->player->DesiredFOV * zoom); } if (flags & 2) { // Disable pitch/yaw scaling. zoom = -zoom; } - self->player->ReadyWeapon->FOVScale = zoom; + self->player->ReadyWeapon->FOVScale = float(zoom); } + return 0; } //=========================================================================== @@ -1729,11 +1730,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_ZoomFactor) DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_SetCrosshair) { - ACTION_PARAM_START(1); - ACTION_PARAM_INT(xhair, 0); + PARAM_ACTION_PROLOGUE; + PARAM_INT(xhair); if (self->player != NULL && self->player->ReadyWeapon != NULL) { self->player->ReadyWeapon->Crosshair = xhair; } + return 0; } diff --git a/src/g_strife/a_acolyte.cpp b/src/g_strife/a_acolyte.cpp index 6785de1ac..9b84b92bb 100644 --- a/src/g_strife/a_acolyte.cpp +++ b/src/g_strife/a_acolyte.cpp @@ -27,11 +27,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_HideDecepticon) { + PARAM_ACTION_PROLOGUE; + EV_DoDoor (DDoor::doorClose, NULL, self, 999, 8*FRACUNIT, 0, 0, 0); if (self->target != NULL && self->target->player != NULL) { P_NoiseAlert (self->target, self); } + return 0; } //============================================================================ @@ -42,6 +45,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_HideDecepticon) DEFINE_ACTION_FUNCTION(AActor, A_AcolyteDie) { + PARAM_ACTION_PROLOGUE; + int i; // [RH] Disable translucency here. @@ -49,7 +54,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_AcolyteDie) // Only the Blue Acolyte does extra stuff on death. if (self->GetClass()->TypeName != NAME_AcolyteBlue) - return; + return 0; // Make sure somebody is still alive for (i = 0; i < MAXPLAYERS; ++i) @@ -58,7 +63,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_AcolyteDie) break; } if (i == MAXPLAYERS) - return; + return 0; // Make sure all the other blue acolytes are dead. TThinkerIterator iterator(NAME_AcolyteBlue); @@ -68,7 +73,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_AcolyteDie) { if (other != self && other->health > 0) { // Found a living one - return; + return 0; } } @@ -76,6 +81,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_AcolyteDie) players[i].SetLogNumber (14); S_StopSound (CHAN_VOICE); S_Sound (CHAN_VOICE, "svox/voc14", 1, ATTN_NORM); + return 0; } //============================================================================ @@ -86,9 +92,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_AcolyteDie) DEFINE_ACTION_FUNCTION(AActor, A_BeShadowyFoe) { + PARAM_ACTION_PROLOGUE; + self->RenderStyle = STYLE_Translucent; self->alpha = HR_SHADOW; self->flags &= ~MF_FRIENDLY; + return 0; } //============================================================================ @@ -99,6 +108,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeShadowyFoe) DEFINE_ACTION_FUNCTION(AActor, A_AcolyteBits) { + PARAM_ACTION_PROLOGUE; + if (self->SpawnFlags & MTF_SHADOW) { CALL_ACTION(A_BeShadowyFoe, self); @@ -115,4 +126,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_AcolyteBits) self->RenderStyle.BlendOp = STYLEOP_None; } } + return 0; } diff --git a/src/g_strife/a_alienspectres.cpp b/src/g_strife/a_alienspectres.cpp index 6506cdb1c..1c58805b9 100644 --- a/src/g_strife/a_alienspectres.cpp +++ b/src/g_strife/a_alienspectres.cpp @@ -22,6 +22,8 @@ AActor *P_SpawnSubMissile (AActor *source, const PClass *type, AActor *target); DEFINE_ACTION_FUNCTION(AActor, A_SpectreChunkSmall) { + PARAM_ACTION_PROLOGUE; + AActor *foo = Spawn("AlienChunkSmall", self->x, self->y, self->z + 10*FRACUNIT, ALLOW_REPLACE); if (foo != NULL) @@ -36,10 +38,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectreChunkSmall) foo->velz = (pr_spectrechunk() & 15) << FRACBITS; } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_SpectreChunkLarge) { + PARAM_ACTION_PROLOGUE; + AActor *foo = Spawn("AlienChunkLarge", self->x, self->y, self->z + 10*FRACUNIT, ALLOW_REPLACE); if (foo != NULL) @@ -54,13 +59,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectreChunkLarge) foo->velz = (pr_spectrechunk() & 7) << FRACBITS; } - + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_Spectre3Attack) { + PARAM_ACTION_PROLOGUE; + if (self->target == NULL) - return; + return 0; AActor *foo = Spawn("SpectralLightningV2", self->x, self->y, self->z + 32*FRACUNIT, ALLOW_REPLACE); @@ -76,10 +83,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_Spectre3Attack) P_SpawnSubMissile (self, PClass::FindClass("SpectralLightningBall2"), self); } self->angle -= ANGLE_180 / 20 * 10; + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_AlienSpectreDeath) { + PARAM_ACTION_PROLOGUE; + AActor *player; char voc[32]; int log; @@ -88,7 +98,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_AlienSpectreDeath) CALL_ACTION(A_NoBlocking, self); // [RH] Need this for Sigil rewarding if (!CheckBossDeath (self)) { - return; + return 0; } for (i = 0, player = NULL; i < MAXPLAYERS; ++i) { @@ -100,7 +110,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_AlienSpectreDeath) } if (player == NULL) { - return; + return 0; } switch (self->GetClass()->TypeName) @@ -184,9 +194,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_AlienSpectreDeath) break; default: - return; + return 0; } mysnprintf (voc, countof(voc), "svox/voc%d", log); S_Sound (CHAN_VOICE, voc, 1, ATTN_NORM); player->player->SetLogNumber (log); + return 0; } diff --git a/src/g_strife/a_crusader.cpp b/src/g_strife/a_crusader.cpp index f4f0024fd..1b32c8051 100644 --- a/src/g_strife/a_crusader.cpp +++ b/src/g_strife/a_crusader.cpp @@ -20,8 +20,10 @@ bool Sys_1ed64 (AActor *self) DEFINE_ACTION_FUNCTION(AActor, A_CrusaderChoose) { + PARAM_ACTION_PROLOGUE; + if (self->target == NULL) - return; + return 0; if (Sys_1ed64 (self)) { @@ -44,42 +46,55 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrusaderChoose) } self->SetState (self->SeeState); } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_CrusaderSweepLeft) { + PARAM_ACTION_PROLOGUE; + self->angle += ANGLE_90/16; AActor *misl = P_SpawnMissileZAimed (self, self->z + 48*FRACUNIT, self->target, PClass::FindClass("FastFlameMissile")); if (misl != NULL) { misl->velz += FRACUNIT; } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_CrusaderSweepRight) { + PARAM_ACTION_PROLOGUE; + self->angle -= ANGLE_90/16; AActor *misl = P_SpawnMissileZAimed (self, self->z + 48*FRACUNIT, self->target, PClass::FindClass("FastFlameMissile")); if (misl != NULL) { misl->velz += FRACUNIT; } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_CrusaderRefire) { + PARAM_ACTION_PROLOGUE; + if (self->target == NULL || self->target->health <= 0 || !P_CheckSight (self, self->target)) { self->SetState (self->SeeState); } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_CrusaderDeath) { + PARAM_ACTION_PROLOGUE; + if (CheckBossDeath (self)) { EV_DoFloor (DFloor::floorLowerToLowest, NULL, 667, FRACUNIT, 0, 0, 0, false); } + return 0; } diff --git a/src/g_strife/a_entityboss.cpp b/src/g_strife/a_entityboss.cpp index f69d43fc6..3df9a786a 100644 --- a/src/g_strife/a_entityboss.cpp +++ b/src/g_strife/a_entityboss.cpp @@ -14,10 +14,13 @@ static FRandom pr_entity ("Entity"); DEFINE_ACTION_FUNCTION(AActor, A_SubEntityDeath) { + PARAM_ACTION_PROLOGUE; + if (CheckBossDeath (self)) { G_ExitLevel (0, false); } + return 0; } void A_SpectralMissile (AActor *self, const char *missilename) @@ -41,6 +44,8 @@ DECLARE_ACTION(A_Spectre3Attack) DEFINE_ACTION_FUNCTION(AActor, A_EntityAttack) { + PARAM_ACTION_PROLOGUE; + // Apparent Strife bug: Case 5 was unreachable because they used % 5 instead of % 6. // I've fixed that by making case 1 duplicate it, since case 1 did nothing. switch (pr_entity() % 5) @@ -66,11 +71,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_EntityAttack) A_SpectralMissile (self, "SpectralLightningBigBall2"); break; } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_SpawnEntity) { + PARAM_ACTION_PROLOGUE; + AActor *entity = Spawn("EntityBoss", self->x, self->y, self->z + 70*FRACUNIT, ALLOW_REPLACE); if (entity != NULL) { @@ -79,10 +87,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnEntity) entity->velz = 5*FRACUNIT; entity->tracer = self; } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_EntityDeath) { + PARAM_ACTION_PROLOGUE; + AActor *second; fixed_t secondRadius = GetDefaultByName("EntitySecond")->radius * 2; angle_t an; @@ -121,4 +132,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_EntityDeath) second->velx = FixedMul (secondRadius, finecosine[an]) << 2; second->vely = FixedMul (secondRadius, finesine[an]) << 2; A_FaceTarget (second); + return 0; } diff --git a/src/g_strife/a_inquisitor.cpp b/src/g_strife/a_inquisitor.cpp index 14bfdf57f..3835a314f 100644 --- a/src/g_strife/a_inquisitor.cpp +++ b/src/g_strife/a_inquisitor.cpp @@ -12,8 +12,11 @@ static FRandom pr_inq ("Inquisitor"); DEFINE_ACTION_FUNCTION(AActor, A_InquisitorWalk) { + PARAM_ACTION_PROLOGUE; + S_Sound (self, CHAN_BODY, "inquisitor/walk", 1, ATTN_NORM); - A_Chase (self); + A_Chase (stack, self); + return 0; } bool InquisitorCheckDistance (AActor *self) @@ -27,8 +30,10 @@ bool InquisitorCheckDistance (AActor *self) DEFINE_ACTION_FUNCTION(AActor, A_InquisitorDecide) { + PARAM_ACTION_PROLOGUE; + if (self->target == NULL) - return; + return 0; A_FaceTarget (self); if (!InquisitorCheckDistance (self)) @@ -42,14 +47,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorDecide) self->SetState (self->FindState("Jump")); } } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_InquisitorAttack) { + PARAM_ACTION_PROLOGUE; + AActor *proj; if (self->target == NULL) - return; + return 0; A_FaceTarget (self); @@ -67,16 +75,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorAttack) proj->velz += 16*FRACUNIT; } self->z -= 32*FRACBITS; + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump) { + PARAM_ACTION_PROLOGUE; + fixed_t dist; fixed_t speed; angle_t an; if (self->target == NULL) - return; + return 0; S_Sound (self, CHAN_ITEM|CHAN_LOOP, "inquisitor/jump", 1, ATTN_NORM); self->z += 64*FRACUNIT; @@ -94,10 +105,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump) self->velz = (self->target->z - self->z) / dist; self->reactiontime = 60; self->flags |= MF_NOGRAVITY; + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_InquisitorCheckLand) { + PARAM_ACTION_PROLOGUE; + self->reactiontime--; if (self->reactiontime < 0 || self->velx == 0 || @@ -108,21 +122,24 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorCheckLand) self->reactiontime = 0; self->flags &= ~MF_NOGRAVITY; S_StopSound (self, CHAN_ITEM); - return; + return 0; } if (!S_IsActorPlayingSomething (self, CHAN_ITEM, -1)) { S_Sound (self, CHAN_ITEM|CHAN_LOOP, "inquisitor/jump", 1, ATTN_NORM); } - + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_TossArm) { + PARAM_ACTION_PROLOGUE; + AActor *foo = Spawn("InquisitorArm", self->x, self->y, self->z + 24*FRACUNIT, ALLOW_REPLACE); foo->angle = self->angle - ANGLE_90 + (pr_inq.Random2() << 22); foo->velx = FixedMul (foo->Speed, finecosine[foo->angle >> ANGLETOFINESHIFT]) >> 3; foo->vely = FixedMul (foo->Speed, finesine[foo->angle >> ANGLETOFINESHIFT]) >> 3; foo->velz = pr_inq() << 10; + return 0; } diff --git a/src/g_strife/a_loremaster.cpp b/src/g_strife/a_loremaster.cpp index 8613aacee..b22a935ab 100644 --- a/src/g_strife/a_loremaster.cpp +++ b/src/g_strife/a_loremaster.cpp @@ -41,8 +41,11 @@ int ALoreShot::DoSpecialDamage (AActor *target, int damage) DEFINE_ACTION_FUNCTION(AActor, A_LoremasterChain) { + PARAM_ACTION_PROLOGUE; + S_Sound (self, CHAN_BODY, "loremaster/active", 1, ATTN_NORM); Spawn("LoreShot2", self->x, self->y, self->z, ALLOW_REPLACE); Spawn("LoreShot2", self->x - (self->velx >> 1), self->y - (self->vely >> 1), self->z - (self->velz >> 1), ALLOW_REPLACE); Spawn("LoreShot2", self->x - self->velx, self->y - self->vely, self->z - self->velz, ALLOW_REPLACE); + return 0; } diff --git a/src/g_strife/a_oracle.cpp b/src/g_strife/a_oracle.cpp index 11a9a52e4..519b68c10 100644 --- a/src/g_strife/a_oracle.cpp +++ b/src/g_strife/a_oracle.cpp @@ -20,6 +20,8 @@ IMPLEMENT_CLASS (AOracle) DEFINE_ACTION_FUNCTION(AActor, A_WakeOracleSpectre) { + PARAM_ACTION_PROLOGUE; + TThinkerIterator it(NAME_AlienSpectre3); AActor *spectre = it.Next(); @@ -29,6 +31,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_WakeOracleSpectre) spectre->target = self->target; spectre->SetState (spectre->SeeState); } + return 0; } diff --git a/src/g_strife/a_programmer.cpp b/src/g_strife/a_programmer.cpp index 196fae584..7458476d4 100644 --- a/src/g_strife/a_programmer.cpp +++ b/src/g_strife/a_programmer.cpp @@ -75,21 +75,24 @@ PalEntry AProgLevelEnder::GetBlend () DEFINE_ACTION_FUNCTION(AActor, A_ProgrammerMelee) { + PARAM_ACTION_PROLOGUE; + int damage; if (self->target == NULL) - return; + return 0; A_FaceTarget (self); if (!self->CheckMeleeRange ()) - return; + return 0; S_Sound (self, CHAN_WEAPON, "programmer/clank", 1, ATTN_NORM); damage = ((pr_prog() % 10) + 1) * 6; P_DamageMobj (self->target, self, self, damage, NAME_Melee); P_TraceBleed (damage, self->target, self); + return 0; } //============================================================================ @@ -100,10 +103,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_ProgrammerMelee) DEFINE_ACTION_FUNCTION(AActor, A_SpotLightning) { + PARAM_ACTION_PROLOGUE; + AActor *spot; if (self->target == NULL) - return; + return 0; spot = Spawn("SpectralLightningSpot", self->target->x, self->target->y, self->target->floorz, ALLOW_REPLACE); if (spot != NULL) @@ -113,6 +118,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpotLightning) spot->health = -2; spot->tracer = self->target; } + return 0; } //============================================================================ @@ -123,6 +129,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpotLightning) DEFINE_ACTION_FUNCTION(AActor, A_SpawnProgrammerBase) { + PARAM_ACTION_PROLOGUE; + AActor *foo = Spawn("ProgrammerBase", self->x, self->y, self->z + 24*FRACUNIT, ALLOW_REPLACE); if (foo != NULL) { @@ -131,6 +139,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnProgrammerBase) foo->vely = FixedMul (foo->Speed, finesine[foo->angle >> ANGLETOFINESHIFT]); foo->velz = pr_prog() << 9; } + return 0; } //============================================================================ @@ -141,8 +150,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnProgrammerBase) DEFINE_ACTION_FUNCTION(AActor, A_ProgrammerDeath) { + PARAM_ACTION_PROLOGUE; + if (!CheckBossDeath (self)) - return; + return 0; for (int i = 0; i < MAXPLAYERS; ++i) { @@ -154,4 +165,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_ProgrammerDeath) } // the sky change scripts are now done as special actions in MAPINFO CALL_ACTION(A_BossDeath, self); + return 0; } diff --git a/src/g_strife/a_reaver.cpp b/src/g_strife/a_reaver.cpp index 893386534..33e933e23 100644 --- a/src/g_strife/a_reaver.cpp +++ b/src/g_strife/a_reaver.cpp @@ -13,6 +13,8 @@ static FRandom pr_reaverattack ("ReaverAttack"); DEFINE_ACTION_FUNCTION(AActor, A_ReaverRanged) { + PARAM_ACTION_PROLOGUE; + if (self->target != NULL) { angle_t bangle; @@ -30,4 +32,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_ReaverRanged) P_LineAttack (self, angle, MISSILERANGE, pitch, damage, NAME_None, NAME_StrifePuff); } } + return 0; } diff --git a/src/g_strife/a_rebels.cpp b/src/g_strife/a_rebels.cpp index 855da34fb..3944dd960 100644 --- a/src/g_strife/a_rebels.cpp +++ b/src/g_strife/a_rebels.cpp @@ -22,10 +22,12 @@ static FRandom pr_shootgun ("ShootGun"); DEFINE_ACTION_FUNCTION(AActor, A_ShootGun) { + PARAM_ACTION_PROLOGUE; + int pitch; if (self->target == NULL) - return; + return 0; S_Sound (self, CHAN_WEAPON, "monsters/rifle", 1, ATTN_NORM); A_FaceTarget (self); @@ -33,6 +35,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShootGun) P_LineAttack (self, self->angle + (pr_shootgun.Random2() << 19), MISSILERANGE, pitch, 3*(pr_shootgun() % 5 + 1), NAME_None, NAME_StrifePuff); + return 0; } // Teleporter Beacon -------------------------------------------------------- @@ -71,6 +74,8 @@ bool ATeleporterBeacon::Use (bool pickup) DEFINE_ACTION_FUNCTION(AActor, A_Beacon) { + PARAM_ACTION_PROLOGUE; + AActor *owner = self->target; AActor *rebel; angle_t an; @@ -79,7 +84,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Beacon) if (!P_TryMove (rebel, rebel->x, rebel->y, true)) { rebel->Destroy (); - return; + return 0; } // Once the rebels start teleporting in, you can't pick up the beacon anymore. self->flags &= ~MF_SPECIAL; @@ -114,4 +119,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_Beacon) { self->SetState(self->FindState(NAME_Death)); } + return 0; } diff --git a/src/g_strife/a_sentinel.cpp b/src/g_strife/a_sentinel.cpp index 5f012cfb1..993cd1283 100644 --- a/src/g_strife/a_sentinel.cpp +++ b/src/g_strife/a_sentinel.cpp @@ -11,15 +11,17 @@ static FRandom pr_sentinelrefire ("SentinelRefire"); DEFINE_ACTION_FUNCTION(AActor, A_SentinelBob) { + PARAM_ACTION_PROLOGUE; + fixed_t minz, maxz; if (self->flags & MF_INFLOAT) { self->velz = 0; - return; + return 0; } if (self->threshold != 0) - return; + return 0; maxz = self->ceilingz - self->height - 16*FRACUNIT; minz = self->floorz + 96*FRACUNIT; @@ -36,16 +38,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelBob) self->velz += FRACUNIT; } self->reactiontime = (minz >= self->z) ? 4 : 0; + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_SentinelAttack) { + PARAM_ACTION_PROLOGUE; + AActor *missile, *trail; // [BB] Without a target the P_SpawnMissileZAimed call will crash. if (!self->target) { - return; + return 0; } missile = P_SpawnMissileZAimed (self, self->z + 32*FRACUNIT, self->target, PClass::FindClass("SentinelFX2")); @@ -69,10 +74,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelAttack) } missile->z += missile->velz >> 2; } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_SentinelRefire) { + PARAM_ACTION_PROLOGUE; + A_FaceTarget (self); if (pr_sentinelrefire() >= 30) @@ -86,4 +94,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelRefire) self->SetState (self->SeeState); } } + return 0; } diff --git a/src/g_strife/a_spectral.cpp b/src/g_strife/a_spectral.cpp index 9506b3412..4ab555660 100644 --- a/src/g_strife/a_spectral.cpp +++ b/src/g_strife/a_spectral.cpp @@ -28,14 +28,19 @@ void ASpectralMonster::Touch (AActor *toucher) DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightningTail) { + PARAM_ACTION_PROLOGUE; + AActor *foo = Spawn("SpectralLightningHTail", self->x - self->velx, self->y - self->vely, self->z, ALLOW_REPLACE); foo->angle = self->angle; foo->health = self->health; + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_SpectralBigBallLightning) { + PARAM_ACTION_PROLOGUE; + const PClass *cls = PClass::FindClass("SpectralLightningH3"); if (cls) { @@ -46,12 +51,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectralBigBallLightning) self->angle += ANGLE_90; P_SpawnSubMissile (self, cls, self->target); } + return 0; } static FRandom pr_zap5 ("Zap5"); DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightning) { + PARAM_ACTION_PROLOGUE; + AActor *flash; fixed_t x, y; @@ -76,6 +84,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightning) flash->target = self->target; flash->velz = -18*FRACUNIT; flash->health = self->health; + return 0; } // In Strife, this number is stored in the data segment, but it doesn't seem to be @@ -84,6 +93,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightning) DEFINE_ACTION_FUNCTION(AActor, A_Tracer2) { + PARAM_ACTION_PROLOGUE; + AActor *dest; angle_t exact; fixed_t dist; @@ -92,7 +103,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer2) dest = self->tracer; if (!dest || dest->health <= 0 || self->Speed == 0 || !self->CanSeek(dest)) - return; + return 0; // change angle exact = R_PointToAngle2 (self->x, self->y, dest->x, dest->y); @@ -144,4 +155,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer2) self->velz += FRACUNIT/8; } } + return 0; } diff --git a/src/g_strife/a_stalker.cpp b/src/g_strife/a_stalker.cpp index 67cbd3282..2f0d5c4d3 100644 --- a/src/g_strife/a_stalker.cpp +++ b/src/g_strife/a_stalker.cpp @@ -13,6 +13,8 @@ static FRandom pr_stalker ("Stalker"); DEFINE_ACTION_FUNCTION(AActor, A_StalkerChaseDecide) { + PARAM_ACTION_PROLOGUE; + if (!(self->flags & MF_NOGRAVITY)) { self->SetState (self->FindState("SeeFloor")); @@ -21,10 +23,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_StalkerChaseDecide) { self->SetState (self->FindState("Drop")); } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_StalkerLookInit) { + PARAM_ACTION_PROLOGUE; + FState *state; if (self->flags & MF_NOGRAVITY) { @@ -38,16 +43,22 @@ DEFINE_ACTION_FUNCTION(AActor, A_StalkerLookInit) { self->SetState (state); } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_StalkerDrop) { + PARAM_ACTION_PROLOGUE; + self->flags5 &= ~MF5_NOVERTICALMELEERANGE; self->flags &= ~MF_NOGRAVITY; + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_StalkerAttack) { + PARAM_ACTION_PROLOGUE; + if (self->flags & MF_NOGRAVITY) { self->SetState (self->FindState("Drop")); @@ -63,11 +74,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_StalkerAttack) P_TraceBleed (damage, self->target, self); } } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_StalkerWalk) { + PARAM_ACTION_PROLOGUE; + S_Sound (self, CHAN_BODY, "stalker/walk", 1, ATTN_NORM); - A_Chase (self); + A_Chase (stack, self); + return 0; } diff --git a/src/g_strife/a_strifeitems.cpp b/src/g_strife/a_strifeitems.cpp index 06674a1ae..cd65b59ee 100644 --- a/src/g_strife/a_strifeitems.cpp +++ b/src/g_strife/a_strifeitems.cpp @@ -23,6 +23,8 @@ IMPLEMENT_CLASS(ADegninOre) DEFINE_ACTION_FUNCTION(AActor, A_RemoveForceField) { + PARAM_ACTION_PROLOGUE; + self->flags &= ~MF_SPECIAL; for (int i = 0; i < self->Sector->linecount; ++i) @@ -36,6 +38,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RemoveForceField) line->sidedef[1]->SetTexture(side_t::mid, FNullTextureID()); } } + return 0; } bool ADegninOre::Use (bool pickup) diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index 2764a2c0b..2865725ce 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -431,22 +431,30 @@ int AForceFieldGuard::TakeSpecialDamage (AActor *inflictor, AActor *source, int DEFINE_ACTION_FUNCTION(AActor, A_SetShadow) { + PARAM_ACTION_PROLOGUE; + self->flags |= MF_STRIFEx8000000|MF_SHADOW; self->RenderStyle = STYLE_Translucent; self->alpha = HR_SHADOW; + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_ClearShadow) { + PARAM_ACTION_PROLOGUE; + self->flags &= ~(MF_STRIFEx8000000|MF_SHADOW); self->RenderStyle = STYLE_Normal; self->alpha = OPAQUE; + return 0; } static FRandom pr_gethurt ("HurtMe!"); DEFINE_ACTION_FUNCTION(AActor, A_GetHurt) { + PARAM_ACTION_PROLOGUE; + self->flags4 |= MF4_INCOMBAT; if ((pr_gethurt() % 5) == 0) { @@ -457,16 +465,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_GetHurt) { self->Die (self->target, self->target); } + return 0; } // Klaxon Warning Light ----------------------------------------------------- DEFINE_ACTION_FUNCTION(AActor, A_TurretLook) { + PARAM_ACTION_PROLOGUE; + AActor *target; if (self->flags5 & MF5_INCONVERSATION) - return; + return 0; self->threshold = 0; target = self->LastHeard; @@ -478,7 +489,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_TurretLook) self->target = target; if ((self->flags & MF_AMBUSH) && !P_CheckSight (self, target)) { - return; + return 0; } if (self->SeeSound != 0) { @@ -488,10 +499,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_TurretLook) self->threshold = 10; self->SetState (self->SeeState); } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_KlaxonBlare) { + PARAM_ACTION_PROLOGUE; + if (--self->reactiontime < 0) { self->target = NULL; @@ -515,6 +529,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KlaxonBlare) { S_Sound (self, CHAN_VOICE, "misc/alarm", 1, ATTN_NORM); } + return 0; } // Power Coupling ----------------------------------------------------------- @@ -578,6 +593,8 @@ IMPLEMENT_CLASS (AMeat) DEFINE_ACTION_FUNCTION(AActor, A_TossGib) { + PARAM_ACTION_PROLOGUE; + const char *gibtype = (self->flags & MF_NOBLOOD) ? "Junk" : "Meat"; AActor *gib = Spawn (gibtype, self->x, self->y, self->z + 24*FRACUNIT, ALLOW_REPLACE); angle_t an; @@ -585,7 +602,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_TossGib) if (gib == NULL) { - return; + return 0; } an = pr_gibtosser() << 24; @@ -594,37 +611,49 @@ DEFINE_ACTION_FUNCTION(AActor, A_TossGib) gib->velx = speed * finecosine[an >> ANGLETOFINESHIFT]; gib->vely = speed * finesine[an >> ANGLETOFINESHIFT]; gib->velz = (pr_gibtosser() & 15) << FRACBITS; + return 0; } //============================================================================ DEFINE_ACTION_FUNCTION(AActor, A_FLoopActiveSound) { + PARAM_ACTION_PROLOGUE; + if (self->ActiveSound != 0 && !(level.time & 7)) { S_Sound (self, CHAN_VOICE, self->ActiveSound, 1, ATTN_NORM); } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_Countdown) { + PARAM_ACTION_PROLOGUE; + if (--self->reactiontime <= 0) { P_ExplodeMissile (self, NULL, NULL); self->flags &= ~MF_SKULLFLY; } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_LoopActiveSound) { + PARAM_ACTION_PROLOGUE; + if (self->ActiveSound != 0 && !S_IsActorPlayingSomething (self, CHAN_VOICE, -1)) { S_Sound (self, CHAN_VOICE|CHAN_LOOP, self->ActiveSound, 1, ATTN_NORM); } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain) { + PARAM_ACTION_PROLOGUE; + sector_t *sec = self->Sector; if (self->z == sec->floorplane.ZatPoint (self->x, self->y)) @@ -643,6 +672,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain) self->vely += FixedMul (speed, finesine[finean]); } } + return 0; } //============================================================================ @@ -653,6 +683,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain) DEFINE_ACTION_FUNCTION(AActor, A_ClearSoundTarget) { + PARAM_ACTION_PROLOGUE; + AActor *actor; self->Sector->SoundTarget = NULL; @@ -660,11 +692,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_ClearSoundTarget) { actor->LastHeard = NULL; } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_ItBurnsItBurns) { + PARAM_ACTION_PROLOGUE; + S_Sound (self, CHAN_VOICE, "human/imonfire", 1, ATTN_NORM); if (self->player != NULL && self->player->mo == self) @@ -676,17 +711,23 @@ DEFINE_ACTION_FUNCTION(AActor, A_ItBurnsItBurns) self->player->playerstate = PST_LIVE; self->player->extralight = 3; } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_DropFire) { + PARAM_ACTION_PROLOGUE; + AActor *drop = Spawn("FireDroplet", self->x, self->y, self->z + 24*FRACUNIT, ALLOW_REPLACE); drop->velz = -FRACUNIT; P_RadiusAttack (self, self, 64, 64, NAME_Fire, false); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_CrispyPlayer) { + PARAM_ACTION_PROLOGUE; + if (self->player != NULL && self->player->mo == self) { self->player->playerstate = PST_DEAD; @@ -694,10 +735,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrispyPlayer) self->player->psprites[ps_weapon].state + (self->FindState("FireHandsLower") - self->FindState("FireHands"))); } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_HandLower) { + PARAM_ACTION_PROLOGUE; + if (self->player != NULL) { pspdef_t *psp = &self->player->psprites[ps_weapon]; @@ -708,5 +752,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_HandLower) } if (self->player->extralight > 0) self->player->extralight--; } + return 0; } diff --git a/src/g_strife/a_strifeweapons.cpp b/src/g_strife/a_strifeweapons.cpp index 6c53fa247..b4d35c94c 100644 --- a/src/g_strife/a_strifeweapons.cpp +++ b/src/g_strife/a_strifeweapons.cpp @@ -94,6 +94,8 @@ void P_DaggerAlert (AActor *target, AActor *emitter) DEFINE_ACTION_FUNCTION(AActor, A_JabDagger) { + PARAM_ACTION_PROLOGUE; + angle_t angle; int damage; int pitch; @@ -129,6 +131,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_JabDagger) { S_Sound (self, CHAN_WEAPON, "misc/swish", 1, ATTN_NORM); } + return 0; } //============================================================================ @@ -139,6 +142,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_JabDagger) DEFINE_ACTION_FUNCTION(AActor, A_AlertMonsters) { + PARAM_ACTION_PROLOGUE; + if (self->player != NULL) { P_NoiseAlert(self, self); @@ -147,6 +152,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_AlertMonsters) { P_NoiseAlert (self->target, self); } + return 0; } // Poison Bolt -------------------------------------------------------------- @@ -186,12 +192,15 @@ int APoisonBolt::DoSpecialDamage (AActor *target, int damage) DEFINE_ACTION_FUNCTION(AActor, A_ClearFlash) { + PARAM_ACTION_PROLOGUE; + player_t *player = self->player; if (player == NULL) - return; + return 0; P_SetPsprite (player, ps_flash, NULL); + return 0; } //============================================================================ @@ -202,10 +211,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_ClearFlash) DEFINE_ACTION_FUNCTION(AActor, A_ShowElectricFlash) { + PARAM_ACTION_PROLOGUE; + if (self->player != NULL) { P_SetPsprite (self->player, ps_flash, self->player->ReadyWeapon->FindState(NAME_Flash)); } + return 0; } //============================================================================ @@ -216,19 +228,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShowElectricFlash) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireArrow) { + PARAM_ACTION_PROLOGUE; + PARAM_CLASS(ti, AActor); + angle_t savedangle; - ACTION_PARAM_START(1); - ACTION_PARAM_CLASS(ti, 0); - if (self->player == NULL) - return; + return 0; AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } if (ti) @@ -240,6 +252,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireArrow) self->angle = savedangle; S_Sound (self, CHAN_WEAPON, "weapons/xbowshoot", 1, ATTN_NORM); } + return 0; } // Assault Gun -------------------------------------------------------------- @@ -274,6 +287,8 @@ void P_StrifeGunShot (AActor *mo, bool accurate, angle_t pitch) DEFINE_ACTION_FUNCTION(AActor, A_FireAssaultGun) { + PARAM_ACTION_PROLOGUE; + bool accurate; S_Sound (self, CHAN_WEAPON, "weapons/assaultgun", 1, ATTN_NORM); @@ -284,7 +299,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireAssaultGun) if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } self->player->mo->PlayAttacking2 (); accurate = !self->player->refire; @@ -295,6 +310,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireAssaultGun) } P_StrifeGunShot (self, accurate, P_BulletSlope (self)); + return 0; } // Mini-Missile Launcher ---------------------------------------------------- @@ -307,17 +323,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireAssaultGun) DEFINE_ACTION_FUNCTION(AActor, A_FireMiniMissile) { + PARAM_ACTION_PROLOGUE; + player_t *player = self->player; angle_t savedangle; if (self->player == NULL) - return; + return 0; AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } savedangle = self->angle; @@ -325,6 +343,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMiniMissile) player->mo->PlayAttacking2 (); P_SpawnPlayerMissile (self, PClass::FindClass("MiniMissile")); self->angle = savedangle; + return 0; } //============================================================================ @@ -335,6 +354,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMiniMissile) DEFINE_ACTION_FUNCTION(AActor, A_RocketInFlight) { + PARAM_ACTION_PROLOGUE; + AActor *trail; S_Sound (self, CHAN_VOICE, "misc/missileinflight", 1, ATTN_NORM); @@ -344,6 +365,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RocketInFlight) { trail->velz = FRACUNIT; } + return 0; } // Flame Thrower ------------------------------------------------------------ @@ -356,8 +378,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_RocketInFlight) DEFINE_ACTION_FUNCTION(AActor, A_FlameDie) { + PARAM_ACTION_PROLOGUE; + self->flags |= MF_NOGRAVITY; self->velz = (pr_flamedie() & 3) << FRACBITS; + return 0; } //============================================================================ @@ -368,6 +393,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FlameDie) DEFINE_ACTION_FUNCTION(AActor, A_FireFlamer) { + PARAM_ACTION_PROLOGUE; + player_t *player = self->player; if (player != NULL) @@ -376,7 +403,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireFlamer) if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } player->mo->PlayAttacking2 (); } @@ -387,6 +414,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireFlamer) { self->velz += 5*FRACUNIT; } + return 0; } // Mauler ------------------------------------------------------------------- @@ -402,13 +430,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireFlamer) DEFINE_ACTION_FUNCTION(AActor, A_FireMauler1) { + PARAM_ACTION_PROLOGUE; + if (self->player != NULL) { AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } // Strife apparently didn't show the player shooting. Let's fix that. self->player->mo->PlayAttacking2 (); @@ -431,6 +461,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMauler1) // original. P_LineAttack (self, angle, PLAYERMISSILERANGE, pitch, damage, NAME_Disintegrate, NAME_MaulerPuff); } + return 0; } //============================================================================ @@ -443,6 +474,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMauler1) DEFINE_ACTION_FUNCTION(AActor, A_FireMauler2Pre) { + PARAM_ACTION_PROLOGUE; + S_Sound (self, CHAN_WEAPON, "weapons/mauler2charge", 1, ATTN_NORM); if (self->player != NULL) @@ -450,6 +483,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMauler2Pre) self->player->psprites[ps_weapon].sx += pr_mauler2.Random2() << 10; self->player->psprites[ps_weapon].sy += pr_mauler2.Random2() << 10; } + return 0; } //============================================================================ @@ -462,19 +496,22 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMauler2Pre) DEFINE_ACTION_FUNCTION(AActor, A_FireMauler2) { + PARAM_ACTION_PROLOGUE; + if (self->player != NULL) { AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; } self->player->mo->PlayAttacking2 (); } P_SpawnPlayerMissile (self, PClass::FindClass("MaulerTorpedo")); P_DamageMobj (self, self, NULL, 20, self->DamageType); P_ThrustMobj (self, self->angle + ANGLE_180, 0x7D000); + return 0; } //============================================================================ @@ -489,6 +526,8 @@ AActor *P_SpawnSubMissile (AActor *source, const PClass *type, AActor *target); DEFINE_ACTION_FUNCTION(AActor, A_MaulerTorpedoWave) { + PARAM_ACTION_PROLOGUE; + AActor *wavedef = GetDefaultByName("MaulerTorpedoWave"); fixed_t savedz; self->angle += ANGLE_180; @@ -506,6 +545,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaulerTorpedoWave) P_SpawnSubMissile (self, PClass::FindClass("MaulerTorpedoWave"), self->target); } self->z = savedz; + return 0; } AActor *P_SpawnSubMissile (AActor *source, const PClass *type, AActor *target) @@ -568,11 +608,16 @@ int APhosphorousFire::DoSpecialDamage (AActor *target, int damage) DEFINE_ACTION_FUNCTION(AActor, A_BurnArea) { + PARAM_ACTION_PROLOGUE; + P_RadiusAttack (self, self->target, 128, 128, self->DamageType, true); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_Burnination) { + PARAM_ACTION_PROLOGUE; + self->velz -= 8*FRACUNIT; self->velx += (pr_phburn.Random2 (3)) << FRACBITS; self->vely += (pr_phburn.Random2 (3)) << FRACBITS; @@ -624,6 +669,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Burnination) drop->flags |= MF_DROPPED; } } + return 0; } //============================================================================ @@ -634,25 +680,25 @@ DEFINE_ACTION_FUNCTION(AActor, A_Burnination) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade) { + PARAM_ACTION_PROLOGUE; + PARAM_CLASS(grenadetype, AActor); + PARAM_ANGLE(angleofs); + PARAM_STATE(flash) + player_t *player = self->player; AActor *grenade; angle_t an; fixed_t tworadii; AWeapon *weapon; - ACTION_PARAM_START(3); - ACTION_PARAM_CLASS(grenadetype, 0); - ACTION_PARAM_ANGLE(Angle, 1); - ACTION_PARAM_STATE(flash, 2); - if (player == NULL || grenadetype == NULL) - return; + return 0; if ((weapon = player->ReadyWeapon) == NULL) - return; + return 0; if (!weapon->DepleteAmmo (weapon->bAltFire)) - return; + return 0; P_SetPsprite (player, ps_flash, flash); @@ -662,7 +708,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade) grenade = P_SpawnSubMissile (self, grenadetype, self); self->z -= 32*FRACUNIT; if (grenade == NULL) - return; + return 0; if (grenade->SeeSound != 0) { @@ -676,11 +722,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade) grenade->x += FixedMul (finecosine[an], tworadii); grenade->y += FixedMul (finesine[an], tworadii); - an = self->angle + Angle; + an = self->angle + angleofs; an >>= ANGLETOFINESHIFT; grenade->x += FixedMul (finecosine[an], 15*FRACUNIT); grenade->y += FixedMul (finesine[an], 15*FRACUNIT); } + return 0; } // The Almighty Sigil! ------------------------------------------------------ @@ -771,12 +818,15 @@ AInventory *ASigil::CreateCopy (AActor *other) DEFINE_ACTION_FUNCTION(AActor, A_SelectPiece) { + PARAM_ACTION_PROLOGUE; + int pieces = MIN (static_cast(self)->NumPieces, 5); if (pieces > 1) { self->SetState (self->FindState("Spawn")+pieces); } + return 0; } //============================================================================ @@ -794,15 +844,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_SelectPiece) DEFINE_ACTION_FUNCTION(AActor, A_SelectSigilView) { + PARAM_ACTION_PROLOGUE; + int pieces; if (self->player == NULL) { - return; + return 0; } pieces = static_cast(self->player->ReadyWeapon)->NumPieces; P_SetPsprite (self->player, ps_weapon, self->player->psprites[ps_weapon].state + pieces); + return 0; } //============================================================================ @@ -817,11 +870,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_SelectSigilView) DEFINE_ACTION_FUNCTION(AActor, A_SelectSigilDown) { + PARAM_ACTION_PROLOGUE; + int pieces; if (self->player == NULL) { - return; + return 0; } pieces = static_cast(self->player->ReadyWeapon)->DownPieces; static_cast(self->player->ReadyWeapon)->DownPieces = 0; @@ -831,6 +886,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SelectSigilDown) } P_SetPsprite (self->player, ps_weapon, self->player->psprites[ps_weapon].state + pieces); + return 0; } //============================================================================ @@ -843,15 +899,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_SelectSigilDown) DEFINE_ACTION_FUNCTION(AActor, A_SelectSigilAttack) { + PARAM_ACTION_PROLOGUE; + int pieces; if (self->player == NULL) { - return; + return 0; } pieces = static_cast(self->player->ReadyWeapon)->NumPieces; P_SetPsprite (self->player, ps_weapon, self->player->psprites[ps_weapon].state + 4*pieces - 3); + return 0; } //============================================================================ @@ -862,11 +921,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_SelectSigilAttack) DEFINE_ACTION_FUNCTION(AActor, A_SigilCharge) { + PARAM_ACTION_PROLOGUE; + S_Sound (self, CHAN_WEAPON, "weapons/sigilcharge", 1, ATTN_NORM); if (self->player != NULL) { self->player->extralight = 2; } + return 0; } //============================================================================ @@ -877,10 +939,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_SigilCharge) DEFINE_ACTION_FUNCTION(AActor, A_LightInverse) { + PARAM_ACTION_PROLOGUE; + if (self->player != NULL) { self->player->extralight = INT_MIN; } + return 0; } //============================================================================ @@ -891,12 +956,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightInverse) DEFINE_ACTION_FUNCTION(AActor, A_FireSigil1) { + PARAM_ACTION_PROLOGUE; + AActor *spot; player_t *player = self->player; AActor *linetarget; if (player == NULL || player->ReadyWeapon == NULL) - return; + return 0; P_DamageMobj (self, self, NULL, 1*4, 0, DMG_NO_ARMOR); S_Sound (self, CHAN_WEAPON, "weapons/sigilcharge", 1, ATTN_NORM); @@ -924,6 +991,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil1) spot->health = -1; spot->target = self; } + return 0; } //============================================================================ @@ -934,15 +1002,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil1) DEFINE_ACTION_FUNCTION(AActor, A_FireSigil2) { + PARAM_ACTION_PROLOGUE; + player_t *player = self->player; if (player == NULL || player->ReadyWeapon == NULL) - return; + return 0; P_DamageMobj (self, self, NULL, 2*4, 0, DMG_NO_ARMOR); S_Sound (self, CHAN_WEAPON, "weapons/sigilcharge", 1, ATTN_NORM); P_SpawnPlayerMissile (self, PClass::FindClass("SpectralLightningH1")); + return 0; } //============================================================================ @@ -953,12 +1024,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil2) DEFINE_ACTION_FUNCTION(AActor, A_FireSigil3) { + PARAM_ACTION_PROLOGUE; + AActor *spot; player_t *player = self->player; int i; if (player == NULL || player->ReadyWeapon == NULL) - return; + return 0; P_DamageMobj (self, self, NULL, 3*4, 0, DMG_NO_ARMOR); S_Sound (self, CHAN_WEAPON, "weapons/sigilcharge", 1, ATTN_NORM); @@ -974,6 +1047,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil3) } } self->angle -= (ANGLE_180/20)*10; + return 0; } //============================================================================ @@ -984,12 +1058,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil3) DEFINE_ACTION_FUNCTION(AActor, A_FireSigil4) { + PARAM_ACTION_PROLOGUE; + AActor *spot; player_t *player = self->player; AActor *linetarget; if (player == NULL || player->ReadyWeapon == NULL) - return; + return 0; P_DamageMobj (self, self, NULL, 4*4, 0, DMG_NO_ARMOR); S_Sound (self, CHAN_WEAPON, "weapons/sigilcharge", 1, ATTN_NORM); @@ -1012,6 +1088,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil4) spot->vely += FixedMul (spot->Speed, finesine[self->angle >> ANGLETOFINESHIFT]); } } + return 0; } //============================================================================ @@ -1022,15 +1099,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil4) DEFINE_ACTION_FUNCTION(AActor, A_FireSigil5) { + PARAM_ACTION_PROLOGUE; + player_t *player = self->player; if (player == NULL || player->ReadyWeapon == NULL) - return; + return 0; P_DamageMobj (self, self, NULL, 5*4, 0, DMG_NO_ARMOR); S_Sound (self, CHAN_WEAPON, "weapons/sigilcharge", 1, ATTN_NORM); P_SpawnPlayerMissile (self, PClass::FindClass("SpectralLightningBigBall1")); + return 0; } //============================================================================ diff --git a/src/g_strife/a_templar.cpp b/src/g_strife/a_templar.cpp index afdac2e15..0dd95090b 100644 --- a/src/g_strife/a_templar.cpp +++ b/src/g_strife/a_templar.cpp @@ -13,13 +13,15 @@ static FRandom pr_templar ("Templar"); DEFINE_ACTION_FUNCTION(AActor, A_TemplarAttack) { + PARAM_ACTION_PROLOGUE; + int damage; angle_t angle; int pitch; int pitchdiff; if (self->target == NULL) - return; + return 0; S_Sound (self, CHAN_WEAPON, "templar/shoot", 1, ATTN_NORM); A_FaceTarget (self); @@ -32,4 +34,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_TemplarAttack) pitchdiff = pr_templar.Random2() * 332063; P_LineAttack (self, angle, MISSILERANGE+64*FRACUNIT, pitch+pitchdiff, damage, NAME_Disintegrate, NAME_MaulerPuff); } + return 0; } diff --git a/src/g_strife/a_thingstoblowup.cpp b/src/g_strife/a_thingstoblowup.cpp index 52cb1d3e5..7350ab1f5 100644 --- a/src/g_strife/a_thingstoblowup.cpp +++ b/src/g_strife/a_thingstoblowup.cpp @@ -18,30 +18,36 @@ extern const PClass *QuestItemClasses[31]; DEFINE_ACTION_FUNCTION(AActor, A_Bang4Cloud) { + PARAM_ACTION_PROLOGUE; + fixed_t spawnx, spawny; spawnx = self->x + (pr_bang4cloud.Random2() & 3) * 10240; spawny = self->y + (pr_bang4cloud.Random2() & 3) * 10240; Spawn("Bang4Cloud", spawnx, spawny, self->z, ALLOW_REPLACE); + return 0; } // ------------------------------------------------------------------- DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveQuestItem) { - ACTION_PARAM_START(1); - ACTION_PARAM_INT(questitem, 0); + PARAM_ACTION_PROLOGUE; + PARAM_INT(questitem); // Give one of these quest items to every player in the game - for (int i = 0; i < MAXPLAYERS; ++i) + if (questitem >= 0 && questitem < countof(QuestItemClasses)) { - if (playeringame[i]) + for (int i = 0; i < MAXPLAYERS; ++i) { - AInventory *item = static_cast(Spawn (QuestItemClasses[questitem-1], 0,0,0, NO_REPLACE)); - if (!item->CallTryPickup (players[i].mo)) + if (playeringame[i]) { - item->Destroy (); + AInventory *item = static_cast(Spawn (QuestItemClasses[questitem - 1], 0,0,0, NO_REPLACE)); + if (!item->CallTryPickup (players[i].mo)) + { + item->Destroy (); + } } } } @@ -55,20 +61,26 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveQuestItem) { C_MidPrint (SmallFont, name); } + return 0; } // PowerCrystal ------------------------------------------------------------------- DEFINE_ACTION_FUNCTION(AActor, A_ExtraLightOff) { + PARAM_ACTION_PROLOGUE; + if (self->target != NULL && self->target->player != NULL) { self->target->player->extralight = 0; } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_Explode512) { + PARAM_ACTION_PROLOGUE; + P_RadiusAttack (self, self->target, 512, 512, NAME_None, true); if (self->target != NULL && self->target->player != NULL) { @@ -81,10 +93,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_Explode512) // Strife didn't do this next part, but it looks good self->RenderStyle = STYLE_Add; + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_LightGoesOut) { + PARAM_ACTION_PROLOGUE; + AActor *foo; sector_t *sec = self->Sector; vertex_t *spot; @@ -106,4 +121,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightGoesOut) foo->velz = (7 + (pr_lightout() & 3)) << FRACBITS; } } + return 0; } diff --git a/src/info.cpp b/src/info.cpp index 0edcfea5e..3bb0ab482 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -51,79 +51,13 @@ extern void LoadActors (); -int CallDecorateAction(VMFrameStack *stack, VMValue *param, int numparam, VMReturn *ret, int numret) -{ - assert(numparam == 6); - actionf_p action = (actionf_p)param[5].a; - action((AActor *)param[0].a, (AActor *)param[1].a, (FState *)param[2].a, param[3].i, (StateCallData *)param[4].a); - return 0; -} - -void FState::SetAction(PSymbolActionFunction *func, bool setdefaultparams) -{ - if (func != NULL) - { - // All generated functions use this code. - static const VM_UBYTE codetemplate[] = - { - OP_PARAM, 0, REGT_POINTER, 0, - OP_PARAM, 0, REGT_POINTER, 1, - OP_PARAM, 0, REGT_POINTER, 2, - OP_PARAM, 0, REGT_INT, 0, - OP_PARAM, 0, REGT_POINTER, 3, - OP_PARAM, 0, REGT_POINTER|REGT_KONST, 0, - OP_CALL_K, 1, 6, 0, - OP_RET, 0, REGT_NIL, 0 - }; - - // Find the CallDecorateAction function. If not found, create it and install it - // in Actor. - VMFunction *callfunc; - PSymbol *sym = RUNTIME_CLASS(AActor)->Symbols.FindSymbol("CallDecorateAction", false); - if (sym == NULL) - { - PSymbolVMFunction *symfunc = new PSymbolVMFunction("CallDecorateAction"); - VMNativeFunction *calldec = new VMNativeFunction(CallDecorateAction); - symfunc->Function = calldec; - sym = symfunc; - RUNTIME_CLASS(AActor)->Symbols.AddSymbol(sym); - } - assert(sym->SymbolType == SYM_VMFunction); - assert(((PSymbolVMFunction *)sym)->Function != NULL); - callfunc = ((PSymbolVMFunction *)sym)->Function; - - // Create a function for this state. - VMScriptFunction *vmfunc = new VMScriptFunction; - vmfunc->Alloc(sizeof(codetemplate)/sizeof(VMOP), 0, 0, 0, 2); - memcpy(vmfunc->Code, codetemplate, sizeof(codetemplate)); - FVoidObj *konsta = vmfunc->KonstA; - VM_ATAG *atag = vmfunc->KonstATags(); - konsta[0].v = (void *)func->Function; - konsta[1].o = callfunc; - atag[0] = ATAG_GENERIC; - atag[1] = ATAG_OBJECT; - vmfunc->NumRegA = 4; - vmfunc->NumRegD = 1; - vmfunc->MaxParam = 6; - vmfunc->NumArgs = 5; - ActionFunc = vmfunc; - - if (setdefaultparams) ParameterIndex = func->defaultparameterindex+1; - } - else - { - ActionFunc = NULL; - if (setdefaultparams) ParameterIndex = 0; - } -} - bool FState::CallAction(AActor *self, AActor *stateowner, StateCallData *statecall) { if (ActionFunc != NULL) { //ActionFunc(self, stateowner, this, ParameterIndex-1, statecall); VMFrameStack stack; - VMValue params[5] = { self, stateowner, this, ParameterIndex - 1, VMValue(statecall, ATAG_STATE) }; + VMValue params[4] = { self, stateowner, VMValue(this, ATAG_STATE), statecall }; stack.Call(ActionFunc, params, countof(params), NULL, 0, NULL); return true; } diff --git a/src/info.h b/src/info.h index 9ce3e662e..66e00b7af 100644 --- a/src/info.h +++ b/src/info.h @@ -62,7 +62,6 @@ struct FState BYTE DefineFlags; // Unused byte so let's use it during state creation. FState *NextState; VMFunction *ActionFunc; - int ParameterIndex; inline int GetFrame() const { @@ -92,7 +91,7 @@ struct FState { Frame = (Frame & SF_FULLBRIGHT) | (frame-'A'); } - void SetAction(PSymbolActionFunction *func, bool setdefaultparams = true); + void SetAction(VMFunction *func) { ActionFunc = func; } bool CallAction(AActor *self, AActor *stateowner, StateCallData *statecall = NULL); static const PClass *StaticFindStateOwner (const FState *state); static const PClass *StaticFindStateOwner (const FState *state, const FActorInfo *info); @@ -190,4 +189,21 @@ extern FDoomEdMap DoomEdMap; int GetSpriteIndex(const char * spritename); TArray &MakeStateNameList(const char * fname); +// Standard parameters for all action functons +// self - Actor this action is to operate on (player if a weapon) +// stateowner - Actor this action really belongs to (may be a weapon) +// callingstate - State this action was called from +// statecall - CustomInventory stuff +#define PARAM_ACTION_PROLOGUE_TYPE(type) \ + PARAM_PROLOGUE; \ + PARAM_OBJECT (self, type); \ + PARAM_OBJECT_OPT (stateowner, AActor) { stateowner = self; } \ + PARAM_STATE_OPT (callingstate) { callingstate = NULL; } \ + PARAM_POINTER_OPT(statecall, StateCallData) { statecall = NULL; } + +#define PARAM_ACTION_PROLOGUE PARAM_ACTION_PROLOGUE_TYPE(AActor) + +// Number of action paramaters +#define NAP 4 + #endif // __INFO_H__ diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 7e3bb0b26..5e24f1fbc 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -1688,10 +1688,12 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params) // DEFINE_ACTION_FUNCTION(AActor, A_Look) { + PARAM_ACTION_PROLOGUE; + AActor *targ; if (self->flags5 & MF5_INCONVERSATION) - return; + return 0; // [RH] Set goal now if appropriate if (self->special == Thing_SetGoal && self->args[0] == 0) @@ -1723,7 +1725,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look) if (targ && targ->player && (targ->player->cheats & CF_NOTARGET)) { - return; + return 0; } } @@ -1767,7 +1769,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look) } if (!P_LookForPlayers (self, self->flags4 & MF4_LOOKALLAROUND, NULL)) - return; + return 0; // go into chase state seeyou: @@ -1793,6 +1795,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look) { self->SetState (self->SeeState); } + return 0; } @@ -1805,30 +1808,32 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) { - 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(seestate, 5); + PARAM_ACTION_PROLOGUE; + PARAM_INT_OPT (flags) { flags = 0; } + PARAM_FIXED_OPT (minseedist) { minseedist = 0; } + PARAM_FIXED_OPT (maxseedist) { maxseedist = 0; } + PARAM_FIXED_OPT (maxheardist) { maxheardist = 0; } + PARAM_ANGLE_OPT (fov) { fov = 0; } + PARAM_STATE_OPT (seestate) { seestate = NULL; } AActor *targ = NULL; // Shuts up gcc fixed_t dist; - FLookExParams params = {fov, minseedist, maxseedist, maxheardist, flags, seestate }; + FLookExParams params = { fov, minseedist, maxseedist, maxheardist, flags, seestate }; if (self->flags5 & MF5_INCONVERSATION) - return; + return 0; // [RH] Set goal now if appropriate if (self->special == Thing_SetGoal && self->args[0] == 0) { - NActorIterator iterator (NAME_PatrolPoint, self->args[1]); + NActorIterator iterator(NAME_PatrolPoint, self->args[1]); self->special = 0; self->goal = iterator.Next (); self->reactiontime = self->args[2] * TICRATE + level.maptime; - if (self->args[3] == 0) self->flags5 &=~ MF5_CHASEGOAL; - else self->flags5 |= MF5_CHASEGOAL; + if (self->args[3] == 0) + self->flags5 &= ~MF5_CHASEGOAL; + else + self->flags5 |= MF5_CHASEGOAL; } self->threshold = 0; // any shot will wake up @@ -1851,8 +1856,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) } else { - dist = P_AproxDistance (targ->x - self->x, - targ->y - self->y); + dist = P_AproxDistance (targ->x - self->x, targ->y - self->y); // [KS] If the target is too far away, don't respond to the sound. if (maxheardist && dist > maxheardist) @@ -1866,7 +1870,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) if (targ && targ->player && (targ->player->cheats & CF_NOTARGET)) { - return; + return 0; } } @@ -1923,8 +1927,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) { if (self->flags & MF_AMBUSH) { - dist = P_AproxDistance (self->target->x - self->x, - self->target->y - self->y); + dist = P_AproxDistance (self->target->x - self->x, self->target->y - self->y); if (P_CheckSight (self, self->target, 2) && (!minseedist || dist > minseedist) && (!maxseedist || dist < maxseedist)) @@ -1941,11 +1944,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) if (!(flags & LOF_NOSIGHTCHECK)) { if (!P_LookForPlayers(self, true, ¶ms)) - return; + return 0; } else { - return; + return 0; } // go into chase state @@ -1979,6 +1982,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) self->SetState (self->SeeState); } } + return 0; } // [KS] *** End additions by me *** @@ -1990,20 +1994,22 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) //========================================================================== DEFINE_ACTION_FUNCTION(AActor, A_Wander) { + PARAM_ACTION_PROLOGUE; + // [RH] Strife probably clears this flag somewhere, but I couldn't find where. // This seems as good a place as any. self->flags4 &= ~MF4_INCOMBAT; if (self->flags5 & MF5_INCONVERSATION) - return; + return 0; if (self->flags4 & MF4_STANDSTILL) - return; + return 0; if (self->reactiontime != 0) { self->reactiontime--; - return; + return 0; } // turn towards movement direction if not there yet @@ -2026,6 +2032,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Wander) P_RandomChaseDir (self); self->movecount += 5; } + return 0; } @@ -2036,10 +2043,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_Wander) //========================================================================== DEFINE_ACTION_FUNCTION(AActor, A_Look2) { + PARAM_ACTION_PROLOGUE; + AActor *targ; if (self->flags5 & MF5_INCONVERSATION) - return; + return 0; self->threshold = 0; targ = self->LastHeard; @@ -2062,7 +2071,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look2) self->target = targ; self->threshold = 10; self->SetState (self->SeeState); - return; + return 0; } else { @@ -2070,7 +2079,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look2) goto nosee; self->SetState (self->SeeState); self->flags4 |= MF4_INCOMBAT; - return; + return 0; } } nosee: @@ -2082,6 +2091,7 @@ nosee: { self->SetState (self->SpawnState + 3); } + return 0; } //============================================================================= @@ -2097,7 +2107,7 @@ nosee: //============================================================================= #define CLASS_BOSS_STRAFE_RANGE 64*10*FRACUNIT -void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove) +void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove) { int delta; @@ -2607,53 +2617,60 @@ enum ChaseFlags DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Chase) { - ACTION_PARAM_START(3); - ACTION_PARAM_STATE(melee, 0); - ACTION_PARAM_STATE(missile, 1); - ACTION_PARAM_INT(flags, 2); + PARAM_ACTION_PROLOGUE; + PARAM_STATE_OPT (melee) { melee = NULL; } + PARAM_STATE_OPT (missile) { missile = NULL; } + PARAM_INT_OPT (flags) { flags = 0; } - if (melee != (FState*)-1) + if (numparam >= NAP + 1) { - if (flags & CHF_RESURRECT && P_CheckForResurrection(self, false)) return; + if ((flags & CHF_RESURRECT) && P_CheckForResurrection(self, false)) + return 0; - A_DoChase(self, !!(flags&CHF_FASTCHASE), melee, missile, !(flags&CHF_NOPLAYACTIVE), + A_DoChase(stack, self, !!(flags&CHF_FASTCHASE), melee, missile, !(flags&CHF_NOPLAYACTIVE), !!(flags&CHF_NIGHTMAREFAST), !!(flags&CHF_DONTMOVE)); } else // this is the old default A_Chase { - A_DoChase (self, false, self->MeleeState, self->MissileState, true, !!(gameinfo.gametype & GAME_Raven), false); + A_DoChase(stack, self, false, self->MeleeState, self->MissileState, true, !!(gameinfo.gametype & GAME_Raven), false); } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_FastChase) { - A_DoChase (self, true, self->MeleeState, self->MissileState, true, true, false); + PARAM_ACTION_PROLOGUE; + A_DoChase(stack, self, true, self->MeleeState, self->MissileState, true, true, false); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_VileChase) { + PARAM_ACTION_PROLOGUE; if (!P_CheckForResurrection(self, true)) - A_DoChase (self, false, self->MeleeState, self->MissileState, true, !!(gameinfo.gametype & GAME_Raven), false); + A_DoChase(stack, self, false, self->MeleeState, self->MissileState, true, !!(gameinfo.gametype & GAME_Raven), false); + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ExtChase) { - ACTION_PARAM_START(4); - ACTION_PARAM_BOOL(domelee, 0); - ACTION_PARAM_BOOL(domissile, 1); - ACTION_PARAM_BOOL(playactive, 2); - ACTION_PARAM_BOOL(nightmarefast, 3); + PARAM_ACTION_PROLOGUE; + PARAM_BOOL (domelee); + PARAM_BOOL (domissile); + PARAM_BOOL_OPT (playactive) { playactive = true; } + PARAM_BOOL_OPT (nightmarefast) { nightmarefast = false; } // Now that A_Chase can handle state label parameters, this function has become rather useless... - A_DoChase(self, false, - domelee ? self->MeleeState:NULL, domissile ? self->MissileState:NULL, + A_DoChase(stack, self, false, + domelee ? self->MeleeState : NULL, domissile ? self->MissileState : NULL, playactive, nightmarefast, false); + return 0; } // for internal use -void A_Chase(AActor *self) +void A_Chase(VMFrameStack *stack, AActor *self) { - A_DoChase (self, false, self->MeleeState, self->MissileState, true, !!(gameinfo.gametype & GAME_Raven), false); + A_DoChase(stack, self, false, self->MeleeState, self->MissileState, true, !!(gameinfo.gametype & GAME_Raven), false); } //============================================================================= @@ -2673,8 +2690,7 @@ void A_FaceTarget (AActor *self) } self->flags &= ~MF_AMBUSH; - self->angle = R_PointToAngle2 (self->x, self->y, - self->target->x, self->target->y); + self->angle = R_PointToAngle2 (self->x, self->y, self->target->x, self->target->y); if (self->target->flags & MF_SHADOW) { @@ -2684,7 +2700,9 @@ void A_FaceTarget (AActor *self) DEFINE_ACTION_FUNCTION(AActor, A_FaceTarget) { + PARAM_ACTION_PROLOGUE; A_FaceTarget(self); + return 0; } //=========================================================================== @@ -2696,8 +2714,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FaceTarget) //=========================================================================== DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail) { + PARAM_ACTION_PROLOGUE; + if (!self->target) - return; + return 0; // [RH] Andy Baker's stealth monsters if (self->flags & MF_STEALTH) @@ -2726,10 +2746,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail) } P_RailAttack (self, self->GetMissileDamage (0, 1), 0); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_Scream) { + PARAM_ACTION_PROLOGUE; if (self->DeathSound) { // Check for bosses. @@ -2743,14 +2765,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_Scream) S_Sound (self, CHAN_VOICE, self->DeathSound, 1, ATTN_NORM); } } + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_XScream) { + PARAM_ACTION_PROLOGUE; if (self->player) S_Sound (self, CHAN_VOICE, "*gibbed", 1, ATTN_NORM); else S_Sound (self, CHAN_VOICE, "misc/gibbed", 1, ATTN_NORM); + return 0; } //=========================================================================== @@ -2761,8 +2786,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_XScream) DEFINE_ACTION_FUNCTION(AActor, A_ScreamAndUnblock) { + PARAM_ACTION_PROLOGUE; CALL_ACTION(A_Scream, self); CALL_ACTION(A_NoBlocking, self); + return 0; } //=========================================================================== @@ -2773,10 +2800,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_ScreamAndUnblock) DEFINE_ACTION_FUNCTION(AActor, A_ActiveSound) { + PARAM_ACTION_PROLOGUE; if (self->ActiveSound) { S_Sound (self, CHAN_VOICE, self->ActiveSound, 1, ATTN_NORM); } + return 0; } //=========================================================================== @@ -2787,8 +2816,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_ActiveSound) DEFINE_ACTION_FUNCTION(AActor, A_ActiveAndUnblock) { + PARAM_ACTION_PROLOGUE; CALL_ACTION(A_ActiveSound, self); CALL_ACTION(A_NoBlocking, self); + return 0; } //--------------------------------------------------------------------------- @@ -2921,6 +2952,8 @@ void P_TossItem (AActor *item) DEFINE_ACTION_FUNCTION(AActor, A_Pain) { + PARAM_ACTION_PROLOGUE; + // [RH] Vary player pain sounds depending on health (ala Quake2) if (self->player && self->player->morphTics == 0) { @@ -2962,15 +2995,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_Pain) { S_Sound (self, CHAN_VOICE, self->PainSound, 1, ATTN_NORM); } + return 0; } // killough 11/98: kill an object DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Die) { - ACTION_PARAM_START(1); - ACTION_PARAM_NAME(damagetype, 0); + PARAM_ACTION_PROLOGUE; + PARAM_NAME_OPT (damagetype) { damagetype = NAME_None; } P_DamageMobj (self, NULL, NULL, self->health, damagetype, DMG_FORCED); + return 0; } // @@ -2980,12 +3015,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Die) DEFINE_ACTION_FUNCTION(AActor, A_Detonate) { - int damage = self->GetMissileDamage (0, 1); + PARAM_ACTION_PROLOGUE; + int damage = self->GetMissileDamage(0, 1); P_RadiusAttack (self, self->target, damage, damage, self->DamageType, true); if (self->z <= self->floorz + (damage << FRACBITS)) { P_HitFloor (self); } + return 0; } bool CheckBossDeath (AActor *actor) @@ -3022,7 +3059,7 @@ bool CheckBossDeath (AActor *actor) // A_BossDeath // Possibly trigger special effects if on a boss level // -DEFINE_ACTION_FUNCTION(AActor, A_BossDeath) +void A_BossDeath(AActor *self) { FName mytype = self->GetClass()->TypeName; @@ -3118,6 +3155,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_BossDeath) G_ExitLevel (0, false); } +DEFINE_ACTION_FUNCTION(AActor, A_BossDeath) +{ + PARAM_ACTION_PROLOGUE; + A_BossDeath(self); + return 0; +} + //---------------------------------------------------------------------------- // // PROC P_Massacre @@ -3191,6 +3235,7 @@ bool A_RaiseMobj (AActor *actor, fixed_t speed) DEFINE_ACTION_FUNCTION(AActor, A_ClassBossHealth) { + PARAM_ACTION_PROLOGUE; if (multiplayer && !deathmatch) // co-op only { if (!self->special1) @@ -3199,4 +3244,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_ClassBossHealth) self->special1 = true; // has been initialized } } + return 0; } diff --git a/src/p_enemy.h b/src/p_enemy.h index b26360631..8dc6c5a4b 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -64,9 +64,9 @@ DECLARE_ACTION(A_NoBlocking) DECLARE_ACTION(A_Scream) DECLARE_ACTION(A_FreezeDeath) DECLARE_ACTION(A_FreezeDeathChunks) -DECLARE_ACTION(A_BossDeath) +void A_BossDeath(AActor *self); -void A_Chase(AActor *self); +void A_Chase(VMFrameStack *stack, AActor *self); void A_FaceTarget (AActor *actor); bool A_RaiseMobj (AActor *, fixed_t speed); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index b070adef1..6e9272ca2 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1009,7 +1009,7 @@ bool AActor::Grind(bool items) { if (this->flags4 & MF4_BOSSDEATH) { - CALL_ACTION(A_BossDeath, this); + A_BossDeath(this); } flags &= ~MF_SOLID; flags3 |= MF3_DONTGIB; @@ -1027,7 +1027,7 @@ bool AActor::Grind(bool items) { if (this->flags4 & MF4_BOSSDEATH) { - CALL_ACTION(A_BossDeath, this); + A_BossDeath(this); } const PClass *i = PClass::FindClass("RealGibs"); diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index ee287a8f1..7faf9b1b4 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -424,13 +424,16 @@ enum EWRF_Options DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_WeaponReady) { - ACTION_PARAM_START(1); - ACTION_PARAM_INT(paramflags, 0); + PARAM_ACTION_PROLOGUE; + PARAM_INT_OPT(flags) { flags = 0; } - if (!(paramflags & WRF_NoSwitch)) DoReadyWeaponToSwitch(self); - if ((paramflags & WRF_NoFire) != WRF_NoFire) DoReadyWeaponToFire(self, - (!(paramflags & WRF_NoPrimary)), (!(paramflags & WRF_NoSecondary))); - if (!(paramflags & WRF_NoBob)) DoReadyWeaponToBob(self); + if (!(flags & WRF_NoSwitch)) + DoReadyWeaponToSwitch(self); + if ((flags & WRF_NoFire) != WRF_NoFire) + DoReadyWeaponToFire(self, !(flags & WRF_NoPrimary), !(flags & WRF_NoSecondary)); + if (!(flags & WRF_NoBob)) + DoReadyWeaponToBob(self); + return 0; } //--------------------------------------------------------------------------- @@ -509,11 +512,13 @@ void P_CheckWeaponSwitch (player_t *player) DEFINE_ACTION_FUNCTION(AInventory, A_ReFire) { + PARAM_ACTION_PROLOGUE; + player_t *player = self->player; if (NULL == player) { - return; + return 0; } if ((player->cmd.ucmd.buttons&BT_ATTACK) && !player->ReadyWeapon->bAltFire @@ -535,16 +540,19 @@ DEFINE_ACTION_FUNCTION(AInventory, A_ReFire) player->ReadyWeapon->CheckAmmo (player->ReadyWeapon->bAltFire ? AWeapon::AltFire : AWeapon::PrimaryFire, true); } + return 0; } DEFINE_ACTION_FUNCTION(AInventory, A_ClearReFire) { + PARAM_ACTION_PROLOGUE; player_t *player = self->player; if (NULL != player) { player->refire = 0; } + return 0; } //--------------------------------------------------------------------------- @@ -559,12 +567,15 @@ DEFINE_ACTION_FUNCTION(AInventory, A_ClearReFire) DEFINE_ACTION_FUNCTION(AInventory, A_CheckReload) { + PARAM_ACTION_PROLOGUE; + if (self->player != NULL) { self->player->ReadyWeapon->CheckAmmo ( self->player->ReadyWeapon->bAltFire ? AWeapon::AltFire : AWeapon::PrimaryFire, true); } + return 0; } //--------------------------------------------------------------------------- @@ -575,12 +586,14 @@ DEFINE_ACTION_FUNCTION(AInventory, A_CheckReload) DEFINE_ACTION_FUNCTION(AInventory, A_Lower) { + PARAM_ACTION_PROLOGUE; + player_t *player = self->player; pspdef_t *psp; if (NULL == player) { - return; + return 0; } psp = &player->psprites[ps_weapon]; if (player->morphTics || player->cheats & CF_INSTANTWEAPSWITCH) @@ -593,17 +606,17 @@ DEFINE_ACTION_FUNCTION(AInventory, A_Lower) } if (psp->sy < WEAPONBOTTOM) { // Not lowered all the way yet - return; + return 0; } if (player->playerstate == PST_DEAD) { // Player is dead, so don't bring up a pending weapon psp->sy = WEAPONBOTTOM; - return; + return 0; } if (player->health <= 0) { // Player is dead, so keep the weapon off screen P_SetPsprite (player, ps_weapon, NULL); - return; + return 0; } /* if (player->PendingWeapon != WP_NOCHANGE) { // [RH] Make sure we're actually changing weapons. @@ -612,6 +625,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_Lower) // [RH] Clear the flash state. Only needed for Strife. P_SetPsprite (player, ps_flash, NULL); P_BringUpWeapon (player); + return 0; } //--------------------------------------------------------------------------- @@ -622,27 +636,29 @@ DEFINE_ACTION_FUNCTION(AInventory, A_Lower) DEFINE_ACTION_FUNCTION(AInventory, A_Raise) { + PARAM_ACTION_PROLOGUE; + if (self == NULL) { - return; + return 0; } player_t *player = self->player; pspdef_t *psp; if (NULL == player) { - return; + return 0; } if (player->PendingWeapon != WP_NOCHANGE) { P_SetPsprite (player, ps_weapon, player->ReadyWeapon->GetDownState()); - return; + return 0; } psp = &player->psprites[ps_weapon]; psp->sy -= RAISESPEED; if (psp->sy > WEAPONTOP) { // Not raised all the way yet - return; + return 0; } psp->sy = WEAPONTOP; if (player->ReadyWeapon != NULL) @@ -653,6 +669,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_Raise) { player->psprites[ps_weapon].state = NULL; } + return 0; } @@ -663,11 +680,12 @@ DEFINE_ACTION_FUNCTION(AInventory, A_Raise) // DEFINE_ACTION_FUNCTION(AInventory, A_GunFlash) { + PARAM_ACTION_PROLOGUE; player_t *player = self->player; if (NULL == player) { - return; + return 0; } player->mo->PlayAttacking2 (); @@ -675,6 +693,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_GunFlash) if (player->ReadyWeapon->bAltFire) flash = player->ReadyWeapon->FindState(NAME_AltFlash); if (flash == NULL) flash = player->ReadyWeapon->FindState(NAME_Flash); P_SetPsprite (player, ps_flash, flash); + return 0; } @@ -740,37 +759,47 @@ void P_GunShot (AActor *mo, bool accurate, const PClass *pufftype, angle_t pitch DEFINE_ACTION_FUNCTION(AInventory, A_Light0) { + PARAM_ACTION_PROLOGUE; + if (self->player != NULL) { self->player->extralight = 0; } + return 0; } DEFINE_ACTION_FUNCTION(AInventory, A_Light1) { + PARAM_ACTION_PROLOGUE; + if (self->player != NULL) { self->player->extralight = 1; } + return 0; } DEFINE_ACTION_FUNCTION(AInventory, A_Light2) { + PARAM_ACTION_PROLOGUE; + if (self->player != NULL) { self->player->extralight = 2; } + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_Light) { - ACTION_PARAM_START(1); - ACTION_PARAM_INT(light, 0); + PARAM_ACTION_PROLOGUE; + PARAM_INT(light); if (self->player != NULL) { self->player->extralight = clamp(light, 0, 20); } + return 0; } //------------------------------------------------------------------------ diff --git a/src/p_user.cpp b/src/p_user.cpp index 014d837d4..a99a0d4b5 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -1249,6 +1249,8 @@ void APlayerPawn::TweakSpeeds (int &forward, int &side) DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream) { + PARAM_ACTION_PROLOGUE; + int sound = 0; int chan = CHAN_VOICE; @@ -1262,7 +1264,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream) { S_Sound (self, CHAN_VOICE, "*death", 1, ATTN_NORM); } - return; + return 0; } // Handle the different player death screams @@ -1311,6 +1313,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream) } } S_Sound (self, chan, sound, 1, ATTN_NORM); + return 0; } @@ -1322,17 +1325,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullPop) { - ACTION_PARAM_START(1); - ACTION_PARAM_CLASS(spawntype, 0); + PARAM_ACTION_PROLOGUE; + PARAM_CLASS_OPT(spawntype, APlayerChunk) { spawntype = NULL; } APlayerPawn *mo; player_t *player; // [GRB] Parameterized version - if (!spawntype || !spawntype->IsDescendantOf (RUNTIME_CLASS (APlayerChunk))) + if (spawntype == NULL || !spawntype->IsDescendantOf(RUNTIME_CLASS(APlayerChunk))) { spawntype = PClass::FindClass("BloodySkull"); - if (spawntype == NULL) return; + if (spawntype == NULL) return 0; } self->flags &= ~MF_SOLID; @@ -1357,6 +1360,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullPop) } player->damagecount = 32; } + return 0; } //---------------------------------------------------------------------------- @@ -1367,10 +1371,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullPop) DEFINE_ACTION_FUNCTION(AActor, A_CheckPlayerDone) { + PARAM_ACTION_PROLOGUE; + if (self->player == NULL) { - self->Destroy (); + self->Destroy(); } + return 0; } //=========================================================================== @@ -1384,7 +1391,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckPlayerDone) void P_CheckPlayerSprites() { - for(int i=0; imo; diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 099565925..be1023039 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -802,7 +802,7 @@ static void CalcPolyobjSoundOrg(const FPolyObj *poly, fixed_t *x, fixed_t *y, fi //========================================================================== static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyObj *poly, - const FVector3 *pt, int channel, FSoundID sound_id, float volume, float attenuation) + const FVector3 *pt, int channel, FSoundID sound_id, double volume, double attenuation) { sfxinfo_t *sfx; int chanflags; @@ -860,7 +860,7 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO sfx = &S_sfx[sound_id]; // Scale volume according to SNDINFO data. - volume = MIN(volume * sfx->Volume, 1.f); + volume = MIN(volume * sfx->Volume, 1.0); if (volume <= 0) return NULL; @@ -1037,11 +1037,11 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO { SoundListener listener; S_SetListener(listener, players[consoleplayer].camera); - chan = (FSoundChan*)GSnd->StartSound3D (sfx->data, &listener, volume, rolloff, attenuation, pitch, basepriority, pos, vel, channel, startflags, NULL); + chan = (FSoundChan*)GSnd->StartSound3D (sfx->data, &listener, float(volume), rolloff, float(attenuation), pitch, basepriority, pos, vel, channel, startflags, NULL); } else { - chan = (FSoundChan*)GSnd->StartSound (sfx->data, volume, pitch, startflags, NULL); + chan = (FSoundChan*)GSnd->StartSound (sfx->data, float(volume), pitch, startflags, NULL); } } if (chan == NULL && (chanflags & CHAN_LOOP)) @@ -1063,13 +1063,13 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO chan->OrgID = FSoundID(org_id); chan->SfxInfo = sfx; chan->EntChannel = channel; - chan->Volume = volume; + chan->Volume = float(volume); chan->ChanFlags |= chanflags; chan->NearLimit = near_limit; chan->LimitRange = limit_range; chan->Pitch = pitch; chan->Priority = basepriority; - chan->DistanceScale = attenuation; + chan->DistanceScale = float(attenuation); chan->SourceType = type; switch (type) { @@ -1156,7 +1156,7 @@ void S_RestartSound(FSoundChan *chan) // //========================================================================== -void S_Sound (int channel, FSoundID sound_id, float volume, float attenuation) +void S_Sound (int channel, FSoundID sound_id, double volume, double attenuation) { S_StartSound (NULL, NULL, NULL, NULL, channel, sound_id, volume, attenuation); } @@ -1167,7 +1167,7 @@ void S_Sound (int channel, FSoundID sound_id, float volume, float attenuation) // //========================================================================== -void S_Sound (AActor *ent, int channel, FSoundID sound_id, float volume, float attenuation) +void S_Sound (AActor *ent, int channel, FSoundID sound_id, double volume, double attenuation) { if (ent == NULL || ent->Sector->Flags & SECF_SILENT) return; @@ -1180,7 +1180,7 @@ void S_Sound (AActor *ent, int channel, FSoundID sound_id, float volume, float a // //========================================================================== -void S_Sound (const FPolyObj *poly, int channel, FSoundID sound_id, float volume, float attenuation) +void S_Sound (const FPolyObj *poly, int channel, FSoundID sound_id, double volume, double attenuation) { S_StartSound (NULL, NULL, poly, NULL, channel, sound_id, volume, attenuation); } @@ -1191,7 +1191,7 @@ void S_Sound (const FPolyObj *poly, int channel, FSoundID sound_id, float volume // //========================================================================== -void S_Sound (fixed_t x, fixed_t y, fixed_t z, int channel, FSoundID sound_id, float volume, float attenuation) +void S_Sound (fixed_t x, fixed_t y, fixed_t z, int channel, FSoundID sound_id, double volume, double attenuation) { FVector3 pt(FIXED2FLOAT(x), FIXED2FLOAT(z), FIXED2FLOAT(y)); S_StartSound (NULL, NULL, NULL, &pt, channel, sound_id, volume, attenuation); @@ -1203,7 +1203,7 @@ void S_Sound (fixed_t x, fixed_t y, fixed_t z, int channel, FSoundID sound_id, f // //========================================================================== -void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, float attenuation) +void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, double volume, double attenuation) { S_StartSound (NULL, sec, NULL, NULL, channel, sfxid, volume, attenuation); } diff --git a/src/s_sound.h b/src/s_sound.h index ad0f3c61b..78d450e20 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -217,11 +217,11 @@ void S_PrecacheLevel (); void S_CacheSound (sfxinfo_t *sfx); // Start sound for thing at -void S_Sound (int channel, FSoundID sfxid, float volume, float attenuation); -void S_Sound (AActor *ent, int channel, FSoundID sfxid, float volume, float attenuation); -void S_Sound (const FPolyObj *poly, int channel, FSoundID sfxid, float volume, float attenuation); -void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, float attenuation); -void S_Sound (fixed_t x, fixed_t y, fixed_t z, int channel, FSoundID sfxid, float volume, float attenuation); +void S_Sound (int channel, FSoundID sfxid, double volume, double attenuation); +void S_Sound (AActor *ent, int channel, FSoundID sfxid, double volume, double attenuation); +void S_Sound (const FPolyObj *poly, int channel, FSoundID sfxid, double volume, double attenuation); +void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, double volume, double attenuation); +void S_Sound (fixed_t x, fixed_t y, fixed_t z, int channel, FSoundID sfxid, double volume, double attenuation); // sound channels // channel 0 never willingly overrides diff --git a/src/sound/fmod_wrap.h b/src/sound/fmod_wrap.h index 3068c41d9..eae45c53b 100644 --- a/src/sound/fmod_wrap.h +++ b/src/sound/fmod_wrap.h @@ -47,7 +47,7 @@ namespace FMOD FMOD global system functions (optional). */ inline FMOD_RESULT Memory_Initialize(void *poolmem, int poollen, FMOD_MEMORY_ALLOCCALLBACK useralloc, FMOD_MEMORY_REALLOCCALLBACK userrealloc, FMOD_MEMORY_FREECALLBACK userfree, FMOD_MEMORY_TYPE memtypeflags = (FMOD_MEMORY_NORMAL | FMOD_MEMORY_XBOX360_PHYSICAL)) { return FMOD_Memory_Initialize(poolmem, poollen, useralloc, userrealloc, userfree, memtypeflags); } - inline FMOD_RESULT Memory_GetStats (int *currentalloced, int *maxalloced) { return FMOD_Memory_GetStats(currentalloced, maxalloced); } + //inline FMOD_RESULT Memory_GetStats (int *currentalloced, int *maxalloced) { return FMOD_Memory_GetStats(currentalloced, maxalloced); } inline FMOD_RESULT Debug_SetLevel(FMOD_DEBUGLEVEL level) { return FMOD_Debug_SetLevel(level); } inline FMOD_RESULT Debug_GetLevel(FMOD_DEBUGLEVEL *level) { return FMOD_Debug_GetLevel(level); } inline FMOD_RESULT File_SetDiskBusy(int busy) { return FMOD_File_SetDiskBusy(busy); } diff --git a/src/thingdef/olddecorations.cpp b/src/thingdef/olddecorations.cpp index 5948bc55d..5ab7a2674 100644 --- a/src/thingdef/olddecorations.cpp +++ b/src/thingdef/olddecorations.cpp @@ -234,24 +234,24 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def) { if (extra.bExplosive) { - info->OwnedStates[extra.DeathStart].SetAction(FindGlobalActionFunction("A_Explode")); + info->OwnedStates[extra.DeathStart].SetAction(FindGlobalActionFunction("A_Explode")->Function); } } else { // The first frame plays the death sound and // the second frame makes it nonsolid. - info->OwnedStates[extra.DeathStart].SetAction(FindGlobalActionFunction("A_Scream")); + info->OwnedStates[extra.DeathStart].SetAction(FindGlobalActionFunction("A_Scream")->Function); if (extra.bSolidOnDeath) { } else if (extra.DeathStart + 1 < extra.DeathEnd) { - info->OwnedStates[extra.DeathStart+1].SetAction(FindGlobalActionFunction("A_NoBlocking")); + info->OwnedStates[extra.DeathStart+1].SetAction(FindGlobalActionFunction("A_NoBlocking")->Function); } else { - info->OwnedStates[extra.DeathStart].SetAction(FindGlobalActionFunction("A_ScreamAndUnblock")); + info->OwnedStates[extra.DeathStart].SetAction(FindGlobalActionFunction("A_ScreamAndUnblock")->Function); } if (extra.DeathHeight == 0) extra.DeathHeight = ((AActor*)(type->Defaults))->height; @@ -279,17 +279,17 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def) // The first frame plays the burn sound and // the second frame makes it nonsolid. - info->OwnedStates[extra.FireDeathStart].SetAction(FindGlobalActionFunction("A_ActiveSound")); + info->OwnedStates[extra.FireDeathStart].SetAction(FindGlobalActionFunction("A_ActiveSound")->Function); if (extra.bSolidOnBurn) { } else if (extra.FireDeathStart + 1 < extra.FireDeathEnd) { - info->OwnedStates[extra.FireDeathStart+1].SetAction(FindGlobalActionFunction("A_NoBlocking")); + info->OwnedStates[extra.FireDeathStart+1].SetAction(FindGlobalActionFunction("A_NoBlocking")->Function); } else { - info->OwnedStates[extra.FireDeathStart].SetAction(FindGlobalActionFunction("A_ActiveAndUnblock")); + info->OwnedStates[extra.FireDeathStart].SetAction(FindGlobalActionFunction("A_ActiveAndUnblock")->Function); } if (extra.BurnHeight == 0) extra.BurnHeight = ((AActor*)(type->Defaults))->height; @@ -309,13 +309,13 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def) info->OwnedStates[i].NextState = &info->OwnedStates[info->NumOwnedStates-1]; info->OwnedStates[i].Tics = 5; info->OwnedStates[i].Misc1 = 0; - info->OwnedStates[i].SetAction(FindGlobalActionFunction("A_FreezeDeath")); + info->OwnedStates[i].SetAction(FindGlobalActionFunction("A_FreezeDeath")->Function); i = info->NumOwnedStates - 1; info->OwnedStates[i].NextState = &info->OwnedStates[i]; info->OwnedStates[i].Tics = 1; info->OwnedStates[i].Misc1 = 0; - info->OwnedStates[i].SetAction(FindGlobalActionFunction("A_FreezeDeathChunks")); + info->OwnedStates[i].SetAction(FindGlobalActionFunction("A_FreezeDeathChunks")->Function); bag.statedef.SetStateLabel("Ice", &info->OwnedStates[extra.IceDeathStart]); } else if (extra.bGenericIceDeath) diff --git a/src/thingdef/thingdef.cpp b/src/thingdef/thingdef.cpp index 605f161e5..4e526665d 100644 --- a/src/thingdef/thingdef.cpp +++ b/src/thingdef/thingdef.cpp @@ -302,9 +302,13 @@ static void FinishThingdef() p->Emit(&buildit); delete p; } - // FIXME: Call a real function buildit.Emit(OP_CALL_K, buildit.GetConstantAddress(NULL, ATAG_OBJECT), j, 0); VMScriptFunction *func = buildit.MakeFunction(); + func->NumArgs = tcall->Parameters.Size(); + for (int k = 0; k < tcall->NumStates; ++k) + { + tcall->ActorInfo->OwnedStates[tcall->FirstState + k].SetAction(func); + } #if 1 const char *marks = "======================================================="; char label[64]; @@ -318,10 +322,8 @@ static void FinishThingdef() fprintf(dump, "\nDisassembly:\n"); VMDisasm(dump, func->Code, func->CodeSize, func); #endif - //if(i==6) I_Error("Poop"); } fclose(dump); - I_Error("Poop"); for (i = 0; i < PClass::m_Types.Size(); i++) { diff --git a/src/thingdef/thingdef.h b/src/thingdef/thingdef.h index 43b78c4bd..60ff50620 100644 --- a/src/thingdef/thingdef.h +++ b/src/thingdef/thingdef.h @@ -187,6 +187,7 @@ struct AFuncDesc { const char *Name; actionf_p Function; + VMNativeFunction **VMPointer; }; AFuncDesc *FindFunction(const char * string); @@ -367,26 +368,27 @@ struct StateCallData // Macros to handle action functions. These are here so that I don't have to // change every single use in case the parameters change. -#define DECLARE_ACTION(name) void AF_##name(AActor *self, AActor *stateowner, FState *, int, StateCallData *); +#define DECLARE_ACTION(name) extern VMNativeFunction *name##_VMPtr; // This distinction is here so that CALL_ACTION produces errors when trying to // access a function that requires parameters. #define DEFINE_ACTION_FUNCTION(cls, name) \ - void AF_##name (AActor *self, AActor *stateowner, FState *, int, StateCallData *); \ - static AFuncDesc info_##cls##_##name = { #name, AF_##name }; \ - MSVC_ASEG AFuncDesc *infoptr_##cls##_##name GCC_ASEG = &info_##cls##_##name; \ - void AF_##name (AActor *self, AActor *stateowner, FState *, int, StateCallData *statecall) + static int AF_##name(VM_ARGS); \ + VMNativeFunction *name##_VMPtr; \ + static const AFuncDesc cls##_##name##_Hook = { #name, AF_##name, &name##_VMPtr }; \ + extern AFuncDesc const *const cls##_##name##_HookPtr; \ + MSVC_ASEG AFuncDesc const *const cls##_##name##_HookPtr GCC_ASEG = &cls##_##name##_Hook; \ + static int AF_##name(VM_ARGS) -#define DEFINE_ACTION_FUNCTION_PARAMS(cls, name) \ - void AFP_##name (AActor *self, AActor *stateowner, FState *CallingState, int ParameterIndex, StateCallData *statecall); \ - static AFuncDesc info_##cls##_##name = { #name, AFP_##name }; \ - MSVC_ASEG AFuncDesc *infoptr_##cls##_##name GCC_ASEG = &info_##cls##_##name; \ - void AFP_##name (AActor *self, AActor *stateowner, FState *CallingState, int ParameterIndex, StateCallData *statecall) +#define DEFINE_ACTION_FUNCTION_PARAMS(cls, name) DEFINE_ACTION_FUNCTION(cls, name) -#define DECLARE_PARAMINFO AActor *self, AActor *stateowner, FState *CallingState, int ParameterIndex, StateCallData *statecall -#define PUSH_PARAMINFO self, stateowner, CallingState, ParameterIndex, statecall +//#define DECLARE_PARAMINFO AActor *self, AActor *stateowner, FState *CallingState, int ParameterIndex, StateCallData *statecall +//#define PUSH_PARAMINFO self, stateowner, CallingState, ParameterIndex, statecall -#define CALL_ACTION(name,self) AF_##name(self, self, NULL, 0, NULL) +#define CALL_ACTION(name,self) { /*AF_##name(self, self, NULL, 0, NULL)*/ \ + VMValue params[5] = { self, self, NULL, VMValue(NULL, ATAG_STATE) }; \ + stack->Call(name##_VMPtr, params, countof(params), NULL, 0, NULL); \ + } int EvalExpressionI (DWORD x, AActor *self); @@ -398,6 +400,7 @@ FState *EvalExpressionState (DWORD x, AActor *self); const PClass *EvalExpressionClass (DWORD x, AActor *self); FName EvalExpressionName (DWORD x, AActor *self); +#if 0 #define ACTION_PARAM_START(count) #define ACTION_PARAM_INT(var, i) \ @@ -422,11 +425,12 @@ FName EvalExpressionName (DWORD x, AActor *self); FName var = EvalExpressionName(ParameterIndex+i, self); #define ACTION_PARAM_ANGLE(var,i) \ angle_t var = angle_t(EvalExpressionF(ParameterIndex+i, self)*ANGLE_90/90.f); +#endif #define ACTION_SET_RESULT(v) if (statecall != NULL) statecall->Result = v; // Checks to see what called the current action function -#define ACTION_CALL_FROM_ACTOR() (CallingState == self->state) -#define ACTION_CALL_FROM_WEAPON() (self->player && CallingState != self->state && statecall == NULL) +#define ACTION_CALL_FROM_ACTOR() (callingstate == self->state) +#define ACTION_CALL_FROM_WEAPON() (self->player && callingstate != self->state && statecall == NULL) #define ACTION_CALL_FROM_INVENTORY() (statecall != NULL) #endif diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 39a08cacd..9da7ff3b5 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -142,22 +142,30 @@ bool ACustomInventory::CallStateChain (AActor *actor, FState * State) //========================================================================== DEFINE_ACTION_FUNCTION(AActor, A_SetSolid) { + PARAM_ACTION_PROLOGUE; self->flags |= MF_SOLID; + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_UnsetSolid) { + PARAM_ACTION_PROLOGUE; self->flags &= ~MF_SOLID; + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_SetFloat) { + PARAM_ACTION_PROLOGUE; self->flags |= MF_FLOAT; + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_UnsetFloat) { + PARAM_ACTION_PROLOGUE; self->flags &= ~(MF_FLOAT|MF_INFLOAT); + return 0; } //========================================================================== @@ -204,37 +212,46 @@ static void DoAttack (AActor *self, bool domelee, bool domissile, DEFINE_ACTION_FUNCTION(AActor, A_MeleeAttack) { - int MeleeDamage = self->GetClass()->Meta.GetMetaInt (ACMETA_MeleeDamage, 0); - FSoundID MeleeSound = self->GetClass()->Meta.GetMetaInt (ACMETA_MeleeSound, 0); + PARAM_ACTION_PROLOGUE; + int MeleeDamage = self->GetClass()->Meta.GetMetaInt(ACMETA_MeleeDamage, 0); + FSoundID MeleeSound = self->GetClass()->Meta.GetMetaInt(ACMETA_MeleeSound, 0); DoAttack(self, true, false, MeleeDamage, MeleeSound, NULL, 0); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_MissileAttack) { - const PClass *MissileType=PClass::FindClass((ENamedName) self->GetClass()->Meta.GetMetaInt (ACMETA_MissileName, NAME_None)); - fixed_t MissileHeight= self->GetClass()->Meta.GetMetaFixed (ACMETA_MissileHeight, 32*FRACUNIT); + PARAM_ACTION_PROLOGUE; + const PClass *MissileType = PClass::FindClass(ENamedName(self->GetClass()->Meta.GetMetaInt(ACMETA_MissileName, NAME_None))); + fixed_t MissileHeight = self->GetClass()->Meta.GetMetaFixed(ACMETA_MissileHeight, 32*FRACUNIT); DoAttack(self, false, true, 0, 0, MissileType, MissileHeight); + return 0; } DEFINE_ACTION_FUNCTION(AActor, A_ComboAttack) { - int MeleeDamage = self->GetClass()->Meta.GetMetaInt (ACMETA_MeleeDamage, 0); - FSoundID MeleeSound = self->GetClass()->Meta.GetMetaInt (ACMETA_MeleeSound, 0); - const PClass *MissileType=PClass::FindClass((ENamedName) self->GetClass()->Meta.GetMetaInt (ACMETA_MissileName, NAME_None)); - fixed_t MissileHeight= self->GetClass()->Meta.GetMetaFixed (ACMETA_MissileHeight, 32*FRACUNIT); + PARAM_ACTION_PROLOGUE; + int MeleeDamage = self->GetClass()->Meta.GetMetaInt(ACMETA_MeleeDamage, 0); + FSoundID MeleeSound = self->GetClass()->Meta.GetMetaInt(ACMETA_MeleeSound, 0); + const PClass *MissileType = PClass::FindClass(ENamedName(self->GetClass()->Meta.GetMetaInt(ACMETA_MissileName, NAME_None))); + fixed_t MissileHeight = self->GetClass()->Meta.GetMetaFixed(ACMETA_MissileHeight, 32*FRACUNIT); DoAttack(self, true, true, MeleeDamage, MeleeSound, MissileType, MissileHeight); + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BasicAttack) { - ACTION_PARAM_START(4); - ACTION_PARAM_INT(MeleeDamage, 0); - ACTION_PARAM_SOUND(MeleeSound, 1); - ACTION_PARAM_CLASS(MissileType, 2); - ACTION_PARAM_FIXED(MissileHeight, 3); + PARAM_ACTION_PROLOGUE; + PARAM_INT (melee_damage); + PARAM_SOUND (melee_sound); + PARAM_CLASS (missile_type, AActor); + PARAM_FIXED (missile_height); - if (MissileType == NULL) return; - DoAttack(self, true, true, MeleeDamage, MeleeSound, MissileType, MissileHeight); + if (missile_type != NULL) + { + DoAttack(self, true, true, melee_damage, melee_sound, missile_type, missile_height); + } + return 0; } //========================================================================== @@ -245,12 +262,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BasicAttack) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlaySound) { - ACTION_PARAM_START(5); - ACTION_PARAM_SOUND(soundid, 0); - ACTION_PARAM_INT(channel, 1); - ACTION_PARAM_FLOAT(volume, 2); - ACTION_PARAM_BOOL(looping, 3); - ACTION_PARAM_FLOAT(attenuation, 4); + PARAM_ACTION_PROLOGUE; + PARAM_SOUND_OPT (soundid) { soundid = "weapons/pistol"; } + PARAM_INT_OPT (channel) { channel = CHAN_BODY; } + PARAM_FLOAT_OPT (volume) { volume = 1; } + PARAM_BOOL_OPT (looping) { looping = false; } + PARAM_FLOAT_OPT (attenuation) { attenuation = ATTN_NORM; } if (!looping) { @@ -263,14 +280,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlaySound) S_Sound (self, channel | CHAN_LOOP, soundid, volume, attenuation); } } + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StopSound) { - ACTION_PARAM_START(1); - ACTION_PARAM_INT(slot, 0); + PARAM_ACTION_PROLOGUE; + PARAM_INT_OPT(slot) { slot = CHAN_VOICE; } S_StopSound(self, slot); + return 0; } //========================================================================== @@ -284,19 +303,20 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StopSound) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlayWeaponSound) { - ACTION_PARAM_START(1); - ACTION_PARAM_SOUND(soundid, 0); + PARAM_ACTION_PROLOGUE; + PARAM_SOUND(soundid); - S_Sound (self, CHAN_WEAPON, soundid, 1, ATTN_NORM); + S_Sound(self, CHAN_WEAPON, soundid, 1, ATTN_NORM); + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlaySoundEx) { - 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); + PARAM_ACTION_PROLOGUE; + PARAM_SOUND (soundid); + PARAM_NAME (channel); + PARAM_BOOL_OPT (looping) { looping = false; } + PARAM_INT_OPT (attenuation_raw) { attenuation_raw = 0; } float attenuation; switch (attenuation_raw) @@ -324,17 +344,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlaySoundEx) S_Sound (self, (int(channel) - NAME_Auto) | CHAN_LOOP, soundid, 1, attenuation); } } + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StopSoundEx) { - ACTION_PARAM_START(1); - ACTION_PARAM_NAME(channel, 0); + PARAM_ACTION_PROLOGUE; + PARAM_NAME(channel); if (channel > NAME_Auto && channel <= NAME_SoundSlot7) { S_StopSound (self, int(channel) - NAME_Auto); } + return 0; } //========================================================================== @@ -344,11 +366,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StopSoundEx) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SeekerMissile) { - ACTION_PARAM_START(2); - ACTION_PARAM_INT(ang1, 0); - ACTION_PARAM_INT(ang2, 1); + PARAM_ACTION_PROLOGUE; + PARAM_INT(ang1); + PARAM_INT(ang2); P_SeekerMissile(self, clamp(ang1, 0, 90) * ANGLE_1, clamp(ang2, 0, 90) * ANGLE_1); + return 0; } //========================================================================== @@ -358,11 +381,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SeekerMissile) //========================================================================== DEFINE_ACTION_FUNCTION(AActor, A_BulletAttack) { + PARAM_ACTION_PROLOGUE; + int i; int bangle; int slope; - if (!self->target) return; + if (!self->target) return 0; A_FaceTarget (self); bangle = self->angle; @@ -377,6 +402,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BulletAttack) P_LineAttack(self, angle, MISSILERANGE, slope, damage, NAME_None, NAME_BulletPuff); } + return 0; } @@ -385,7 +411,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BulletAttack) // Do the state jump // //========================================================================== -static void DoJump(AActor * self, FState * CallingState, FState *jumpto, StateCallData *statecall) +static void DoJump(AActor *self, FState *callingstate, FState *jumpto, StateCallData *statecall) { if (jumpto == NULL) return; @@ -393,17 +419,17 @@ static void DoJump(AActor * self, FState * CallingState, FState *jumpto, StateCa { statecall->State = jumpto; } - else if (self->player != NULL && CallingState == self->player->psprites[ps_weapon].state) + else if (self->player != NULL && callingstate == self->player->psprites[ps_weapon].state) { P_SetPsprite(self->player, ps_weapon, jumpto); } - else if (self->player != NULL && CallingState == self->player->psprites[ps_flash].state) + else if (self->player != NULL && callingstate == self->player->psprites[ps_flash].state) { P_SetPsprite(self->player, ps_flash, jumpto); } - else if (CallingState == self->state) + else if (callingstate == self->state) { - self->SetState (jumpto); + self->SetState(jumpto); } else { @@ -414,7 +440,7 @@ static void DoJump(AActor * self, FState * CallingState, FState *jumpto, StateCa // This is just to avoid having to directly reference the internally defined // CallingState and statecall parameters in the code below. -#define ACTION_JUMP(offset) DoJump(self, CallingState, offset, statecall) +#define ACTION_JUMP(offset) DoJump(self, callingstate, offset, statecall) //========================================================================== // @@ -423,17 +449,18 @@ static void DoJump(AActor * self, FState * CallingState, FState *jumpto, StateCa //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Jump) { - ACTION_PARAM_START(3); - ACTION_PARAM_INT(count, 0); - ACTION_PARAM_INT(maxchance, 1); + PARAM_ACTION_PROLOGUE; + PARAM_INT_OPT(maxchance) { maxchance = 256; } - if (count >= 2 && (maxchance >= 256 || pr_cajump() < maxchance)) + int count = numparam - pnum; + if (count > 0 && (maxchance >= 256 || pr_cajump() < maxchance)) { - int jumps = 2 + (count == 2? 0 : (pr_cajump() % (count - 1))); - ACTION_PARAM_STATE(jumpto, jumps); + int jumpnum = (count == 1 ? 0 : (pr_cajump() % count)); + PARAM_STATE_AT(pnum + jumpnum, jumpto); ACTION_JUMP(jumpto); } ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! + return 0; } //========================================================================== @@ -443,13 +470,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Jump) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHealthLower) { - ACTION_PARAM_START(2); - ACTION_PARAM_INT(health, 0); - ACTION_PARAM_STATE(jump, 1); - - if (self->health < health) ACTION_JUMP(jump); + PARAM_ACTION_PROLOGUE; + PARAM_INT (health); + PARAM_STATE (jump); + if (self->health < health) + { + ACTION_JUMP(jump); + } ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! + return 0; } //========================================================================== @@ -459,15 +489,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHealthLower) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfCloser) { - ACTION_PARAM_START(2); - ACTION_PARAM_FIXED(dist, 0); - ACTION_PARAM_STATE(jump, 1); + PARAM_ACTION_PROLOGUE; + PARAM_FIXED (dist); + PARAM_STATE (jump); AActor *target; - if (!self->player) + if (self->player == NULL) { - target=self->target; + target = self->target; } else { @@ -478,7 +508,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfCloser) ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! // No target - no jump - if (target==NULL) return; + if (target == NULL) + return 0; if (P_AproxDistance(self->x-target->x, self->y-target->y) < dist && ( (self->z > target->z && self->z - (target->z + target->height) < dist) || @@ -488,6 +519,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfCloser) { ACTION_JUMP(jump); } + return 0; } //========================================================================== @@ -495,41 +527,46 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfCloser) // State jump function // //========================================================================== -void DoJumpIfInventory(AActor * owner, DECLARE_PARAMINFO) +void DoJumpIfInventory(AActor *owner, AActor *self, StateCallData *statecall, FState *callingstate, VMValue *param, int numparam) { - ACTION_PARAM_START(3); - ACTION_PARAM_CLASS(Type, 0); - ACTION_PARAM_INT(ItemAmount, 1); - ACTION_PARAM_STATE(JumpOffset, 2); + int pnum = NAP; + PARAM_CLASS (itemtype, AInventory); + PARAM_INT (itemamount); + PARAM_STATE (label); ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! - if (!Type || owner == NULL) return; + if (itemtype == NULL || owner == NULL) + return; - AInventory *Item = owner->FindInventory(Type); + AInventory *item = owner->FindInventory(itemtype); - if (Item) + if (item) { - if (ItemAmount > 0) + if (itemamount > 0) { - if (Item->Amount >= ItemAmount) - ACTION_JUMP(JumpOffset); + if (item->Amount >= itemamount) + ACTION_JUMP(label); } - else if (Item->Amount >= Item->MaxAmount) + else if (item->Amount >= item->MaxAmount) { - ACTION_JUMP(JumpOffset); + ACTION_JUMP(label); } } } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInventory) { - DoJumpIfInventory(self, PUSH_PARAMINFO); + PARAM_ACTION_PROLOGUE; + DoJumpIfInventory(self, self, statecall, callingstate, param, numparam); + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetInventory) { - DoJumpIfInventory(self->target, PUSH_PARAMINFO); + PARAM_ACTION_PROLOGUE; + DoJumpIfInventory(self->target, self, statecall, callingstate, param, numparam); + return 0; } //========================================================================== @@ -539,17 +576,18 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetInventory) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfArmorType) { - ACTION_PARAM_START(3); - ACTION_PARAM_NAME(Type, 0); - ACTION_PARAM_STATE(JumpOffset, 1); - ACTION_PARAM_INT(amount, 2); + PARAM_ACTION_PROLOGUE; + PARAM_NAME (type); + PARAM_STATE (label); + PARAM_INT_OPT(amount) { amount = 1; } ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! - ABasicArmor * armor = (ABasicArmor *) self->FindInventory(NAME_BasicArmor); + ABasicArmor *armor = (ABasicArmor *)self->FindInventory(NAME_BasicArmor); - if (armor && armor->ArmorType == Type && armor->Amount >= amount) - ACTION_JUMP(JumpOffset); + if (armor && armor->ArmorType == type && armor->Amount >= amount) + ACTION_JUMP(label); + return 0; } //========================================================================== @@ -560,14 +598,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfArmorType) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Explode) { - ACTION_PARAM_START(7); - ACTION_PARAM_INT(damage, 0); - ACTION_PARAM_INT(distance, 1); - ACTION_PARAM_BOOL(hurtSource, 2); - ACTION_PARAM_BOOL(alert, 3); - ACTION_PARAM_INT(fulldmgdistance, 4); - ACTION_PARAM_INT(nails, 5); - ACTION_PARAM_INT(naildamage, 6); + PARAM_ACTION_PROLOGUE; + PARAM_INT_OPT (damage) { damage = -1; } + PARAM_INT_OPT (distance) { distance = -1; } + PARAM_BOOL_OPT (hurtSource) { hurtSource = true; } + PARAM_BOOL_OPT (alert) { alert = false; } + PARAM_INT_OPT (fulldmgdistance) { fulldmgdistance = 0; } + PARAM_INT_OPT (nails) { nails = 0; } + PARAM_INT_OPT (naildamage) { naildamage = 10; } if (damage < 0) // get parameters from metadata { @@ -606,6 +644,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Explode) validcount++; P_RecursiveSound (self->Sector, self->target, false, 0); } + return 0; } //========================================================================== @@ -616,19 +655,20 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Explode) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusThrust) { - ACTION_PARAM_START(3); - ACTION_PARAM_INT(force, 0); - ACTION_PARAM_FIXED(distance, 1); - ACTION_PARAM_BOOL(affectSource, 2); + PARAM_ACTION_PROLOGUE; + PARAM_INT_OPT (force) { force = 128; } + PARAM_INT_OPT (distance) { distance = 1; } + PARAM_BOOL_OPT (affectSource) { affectSource = true; } if (force <= 0) force = 128; if (distance <= 0) distance = force; P_RadiusAttack (self, self->target, force, distance, self->DamageType, affectSource, false); - if (self->z <= self->floorz + (distance<z <= self->floorz + (distance << FRACBITS)) { P_HitFloor (self); } + return 0; } //========================================================================== @@ -638,17 +678,18 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusThrust) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CallSpecial) { - 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); + PARAM_ACTION_PROLOGUE; + PARAM_INT (special); + PARAM_INT_OPT (arg1) { arg1 = 0; } + PARAM_INT_OPT (arg2) { arg2 = 0; } + PARAM_INT_OPT (arg3) { arg3 = 0; } + PARAM_INT_OPT (arg4) { arg4 = 0; } + PARAM_INT_OPT (arg5) { arg5 = 0; } bool res = !!LineSpecials[special](NULL, self, false, arg1, arg2, arg3, arg4, arg5); ACTION_SET_RESULT(res); + return 0; } //========================================================================== @@ -659,9 +700,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CallSpecial) // with an optional flag // //========================================================================== -inline static bool isMissile(AActor * self, bool precise=true) +inline static bool isMissile(AActor *self, bool precise=true) { - return self->flags&MF_MISSILE || (precise && self->GetDefault()->flags&MF_MISSILE); + return (self->flags & MF_MISSILE) || (precise && (self->GetDefault()->flags & MF_MISSILE)); } //========================================================================== @@ -678,107 +719,108 @@ enum CM_Flags DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) { - 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); + PARAM_ACTION_PROLOGUE; + PARAM_CLASS (ti, AActor); + PARAM_FIXED_OPT (spawnheight) { spawnheight = 32*FRACUNIT; } + PARAM_INT_OPT (spawnofs_xy) { spawnofs_xy = 0; } + PARAM_ANGLE_OPT (angle) { angle = 0; } + PARAM_INT_OPT (flags) { flags = 0; } + PARAM_INT_OPT (pitch) { pitch = 0; } int aimmode = flags & CMF_AIMMODE; AActor * targ; AActor * missile; - if (self->target != NULL || aimmode==2) + if (self->target != NULL || aimmode == 2) { if (ti) { angle_t ang = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT; - fixed_t x = Spawnofs_XY * finecosine[ang]; - fixed_t y = Spawnofs_XY * finesine[ang]; - fixed_t z = SpawnHeight - 32*FRACUNIT + (self->player? self->player->crouchoffset : 0); + fixed_t x = spawnofs_xy * finecosine[ang]; + fixed_t y = spawnofs_xy * finesine[ang]; + fixed_t z = spawnheight - 32*FRACUNIT + (self->player? self->player->crouchoffset : 0); switch (aimmode) { case 0: default: // same adjustment as above (in all 3 directions this time) - for better aiming! - self->x+=x; - self->y+=y; - self->z+=z; + self->x += x; + self->y += y; + self->z += z; missile = P_SpawnMissileXYZ(self->x, self->y, self->z + 32*FRACUNIT, self, self->target, ti, false); - self->x-=x; - self->y-=y; - self->z-=z; + self->x -= x; + self->y -= y; + self->z -= z; break; case 1: - missile = P_SpawnMissileXYZ(self->x+x, self->y+y, self->z+SpawnHeight, self, self->target, ti, false); + missile = P_SpawnMissileXYZ(self->x+x, self->y+y, self->z+spawnheight, self, self->target, ti, false); break; case 2: - self->x+=x; - self->y+=y; - missile = P_SpawnMissileAngleZSpeed(self, self->z+SpawnHeight, ti, self->angle, 0, GetDefaultByType(ti)->Speed, self, false); - self->x-=x; - self->y-=y; + self->x += x; + self->y += y; + missile = P_SpawnMissileAngleZSpeed(self, self->z+spawnheight, ti, self->angle, 0, GetDefaultByType(ti)->Speed, self, false); + self->x -= x; + self->y -= y; // It is not necessary to use the correct angle here. // The only important thing is that the horizontal velocity is correct. // Therefore use 0 as the missile's angle and simplify the calculations accordingly. // The actual velocity vector is set below. - if (missile) + if (missile != NULL) { fixed_t vx = finecosine[pitch>>ANGLETOFINESHIFT]; fixed_t vz = finesine[pitch>>ANGLETOFINESHIFT]; - missile->velx = FixedMul (vx, missile->Speed); + missile->velx = FixedMul(vx, missile->Speed); missile->vely = 0; - missile->velz = FixedMul (vz, missile->Speed); + missile->velz = FixedMul(vz, missile->Speed); } break; } - if (missile) + if (missile != NULL) { // Use the actual velocity instead of the missile's Speed property // so that this can handle missiles with a high vertical velocity // component properly. - FVector3 velocity (missile->velx, missile->vely, 0); + FVector2 velocity (missile->velx, missile->vely); fixed_t missilespeed = (fixed_t)velocity.Length(); - missile->angle += Angle; + missile->angle += angle; ang = missile->angle >> ANGLETOFINESHIFT; - missile->velx = FixedMul (missilespeed, finecosine[ang]); - missile->vely = FixedMul (missilespeed, finesine[ang]); + missile->velx = FixedMul(missilespeed, finecosine[ang]); + missile->vely = FixedMul(missilespeed, finesine[ang]); // handle projectile shooting projectiles - track the // links back to a real owner if (isMissile(self, !!(flags & CMF_TRACKOWNER))) { - AActor * owner=self ;//->target; - while (isMissile(owner, !!(flags & CMF_TRACKOWNER)) && owner->target) owner=owner->target; - targ=owner; - missile->target=owner; + AActor *owner = self;//->target; + while (isMissile(owner, !!(flags & CMF_TRACKOWNER)) && owner->target) + owner = owner->target; + targ = owner; + missile->target = owner; // automatic handling of seeker missiles if (self->flags & missile->flags2 & MF2_SEEKERMISSILE) { - missile->tracer=self->tracer; + missile->tracer = self->tracer; } } - else if (missile->flags2&MF2_SEEKERMISSILE) + else if (missile->flags2 & MF2_SEEKERMISSILE) { // automatic handling of seeker missiles - missile->tracer=self->target; + missile->tracer = self->target; } // set the health value so that the missile works properly - if (missile->flags4&MF4_SPECTRAL) + if (missile->flags4 & MF4_SPECTRAL) { - missile->health=-2; + missile->health = -2; } P_CheckMissileSpawn(missile); } @@ -787,8 +829,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) else if (flags & CMF_CHECKTARGETDEAD) { // Target is dead and the attack shall be aborted. - if (self->SeeState != NULL) self->SetState(self->SeeState); + if (self->SeeState != NULL) + self->SetState(self->SeeState); } + return 0; } //========================================================================== @@ -798,39 +842,39 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack) { - 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); + PARAM_ACTION_PROLOGUE; + PARAM_ANGLE (spread_xy); + PARAM_ANGLE (spread_z); + PARAM_INT (numbullets); + PARAM_INT (damageperbullet); + PARAM_CLASS_OPT (pufftype, AActor) { pufftype = PClass::FindClass(NAME_BulletPuff); } + PARAM_FIXED_OPT (range) { range = MISSILERANGE; } + PARAM_BOOL_OPT (aimfacing) { aimfacing = false; } - if(Range==0) Range=MISSILERANGE; + if (range == 0) + range = MISSILERANGE; int i; int bangle; int bslope; - if (self->target || AimFacing) + if (self->target || aimfacing) { - if (!AimFacing) A_FaceTarget (self); + if (!aimfacing) A_FaceTarget (self); bangle = self->angle; - if (!pufftype) pufftype = PClass::FindClass(NAME_BulletPuff); - bslope = P_AimLineAttack (self, bangle, MISSILERANGE); S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); - for (i=0 ; iDamageType, pufftype); + int angle = bangle + pr_cabullet.Random2() * (spread_xy / 255); + int slope = bslope + pr_cabullet.Random2() * (spread_z / 255); + int damage = ((pr_cabullet()%3)+1) * damageperbullet; + P_LineAttack(self, angle, range, slope, damage, GetDefaultByType(pufftype)->DamageType, pufftype); } } + return 0; } //========================================================================== @@ -840,29 +884,34 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMeleeAttack) { - 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); + PARAM_ACTION_PROLOGUE; + PARAM_INT_OPT (damage) { damage = 0; } + PARAM_SOUND_OPT (meleesound) { meleesound = 0; } + PARAM_SOUND_OPT (misssound) { misssound = 0; } + PARAM_NAME_OPT (damagetype) { damagetype = NAME_None; } + PARAM_BOOL_OPT (bleed) { bleed = true; } - if (DamageType==NAME_None) DamageType = NAME_Melee; // Melee is the default type + if (damagetype == NAME_None) + damagetype = NAME_Melee; // Melee is the default type if (!self->target) - return; + return 0; A_FaceTarget (self); if (self->CheckMeleeRange ()) { - if (MeleeSound) S_Sound (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM); - P_DamageMobj (self->target, self, self, damage, DamageType); - if (bleed) P_TraceBleed (damage, self->target, self); + if (meleesound) + S_Sound (self, CHAN_WEAPON, meleesound, 1, ATTN_NORM); + P_DamageMobj (self->target, self, self, damage, damagetype); + if (bleed) + P_TraceBleed (damage, self->target, self); } else { - if (MissSound) S_Sound (self, CHAN_WEAPON, MissSound, 1, ATTN_NORM); + if (misssound) + S_Sound (self, CHAN_WEAPON, misssound, 1, ATTN_NORM); } + return 0; } //========================================================================== @@ -872,47 +921,51 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMeleeAttack) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomComboAttack) { - 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); + PARAM_ACTION_PROLOGUE; + PARAM_CLASS (ti, AActor); + PARAM_FIXED (spawnheight); + PARAM_INT (damage); + PARAM_SOUND_OPT (meleesound) { meleesound = 0; } + PARAM_NAME_OPT (damagetype) { damagetype = NAME_Melee; } + PARAM_BOOL_OPT (bleed) { bleed = true; } if (!self->target) - return; + return 0; A_FaceTarget (self); - if (self->CheckMeleeRange ()) + if (self->CheckMeleeRange()) { - if (DamageType==NAME_None) DamageType = NAME_Melee; // Melee is the default type - if (MeleeSound) S_Sound (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM); - P_DamageMobj (self->target, self, self, damage, DamageType); - if (bleed) P_TraceBleed (damage, self->target, self); + if (damagetype == NAME_None) + damagetype = NAME_Melee; // Melee is the default type + if (meleesound) + S_Sound (self, CHAN_WEAPON, meleesound, 1, ATTN_NORM); + P_DamageMobj (self->target, self, self, damage, damagetype); + if (bleed) + P_TraceBleed (damage, self->target, self); } else 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; + 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) { // automatic handling of seeker missiles - if (missile->flags2&MF2_SEEKERMISSILE) + if (missile->flags2 & MF2_SEEKERMISSILE) { - missile->tracer=self->target; + missile->tracer = self->target; } // set the health value so that the missile works properly - if (missile->flags4&MF4_SPECTRAL) + if (missile->flags4 & MF4_SPECTRAL) { - missile->health=-2; + missile->health = -2; } P_CheckMissileSpawn(missile); } } + return 0; } //========================================================================== @@ -922,17 +975,18 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomComboAttack) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfNoAmmo) { - ACTION_PARAM_START(1); - ACTION_PARAM_STATE(jump, 0); + PARAM_ACTION_PROLOGUE; + PARAM_STATE(jump); ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! - if (!ACTION_CALL_FROM_WEAPON()) return; + if (!ACTION_CALL_FROM_WEAPON()) + return 0; if (!self->player->ReadyWeapon->CheckAmmo(self->player->ReadyWeapon->bAltFire, false, true)) { ACTION_JUMP(jump); } - + return 0; } @@ -943,56 +997,61 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfNoAmmo) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) { - 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); + PARAM_ACTION_PROLOGUE; + PARAM_ANGLE (spread_xy); + PARAM_ANGLE (spread_z); + PARAM_INT (numbullets); + PARAM_INT (damageperbullet); + PARAM_CLASS_OPT (pufftype, AActor) { pufftype = NULL; } + PARAM_BOOL_OPT (useammo) { useammo = true; } + PARAM_FIXED_OPT (range) { range = 0; } - if (!self->player) return; + if (!self->player) return 0; - player_t * player=self->player; - AWeapon * weapon=player->ReadyWeapon; + player_t *player = self->player; + AWeapon *weapon = player->ReadyWeapon; int i; int bangle; int bslope; - if (UseAmmo && weapon) + if (useammo && weapon) { - if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return; // out of ammo + if (!weapon->DepleteAmmo(weapon->bAltFire, true)) + return 0; // out of ammo } - if (Range == 0) Range = PLAYERMISSILERANGE; + if (range == 0) + range = PLAYERMISSILERANGE; - static_cast(self)->PlayAttacking2 (); + static_cast(self)->PlayAttacking2(); bslope = P_BulletSlope(self); bangle = self->angle; - if (!PuffType) PuffType = PClass::FindClass(NAME_BulletPuff); + if (pufftype == NULL) + pufftype = PClass::FindClass(NAME_BulletPuff); - S_Sound (self, CHAN_WEAPON, weapon->AttackSound, 1, ATTN_NORM); + S_Sound(self, CHAN_WEAPON, weapon->AttackSound, 1, ATTN_NORM); - if ((NumberOfBullets==1 && !player->refire) || NumberOfBullets==0) + if ((numbullets == 1 && !player->refire) || numbullets == 0) { - int damage = ((pr_cwbullet()%3)+1)*DamagePerBullet; - P_LineAttack(self, bangle, Range, bslope, damage, GetDefaultByType(PuffType)->DamageType, PuffType); + int damage = ((pr_cwbullet()%3)+1) * damageperbullet; + P_LineAttack(self, bangle, range, bslope, damage, GetDefaultByType(pufftype)->DamageType, pufftype); } else { - if (NumberOfBullets == -1) NumberOfBullets = 1; - for (i=0 ; iDamageType, PuffType); + int angle = bangle + pr_cwbullet.Random2() * (spread_xy / 255); + int slope = bslope + pr_cwbullet.Random2() * (spread_z / 255); + int damage = ((pr_cwbullet()%3)+1) * damageperbullet; + P_LineAttack(self, angle, range, slope, damage, GetDefaultByType(pufftype)->DamageType, pufftype); } } + return 0; } @@ -1003,58 +1062,62 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile) { - ACTION_PARAM_START(7); - 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); - ACTION_PARAM_ANGLE(pitch, 6); + PARAM_ACTION_PROLOGUE; + PARAM_CLASS (ti, AActor); + PARAM_ANGLE_OPT (angle) { angle = 0; } + PARAM_BOOL_OPT (useammo) { useammo = true; } + PARAM_INT_OPT (spawnofs_xy) { spawnofs_xy = 0; } + PARAM_FIXED_OPT (spawnheight) { spawnheight = 0; } + PARAM_BOOL_OPT (aimatangle) { aimatangle = false; } + PARAM_ANGLE_OPT (pitch) { pitch = 0; } - if (!self->player) return; + if (!self->player) + return 0; - player_t *player=self->player; - AWeapon * weapon=player->ReadyWeapon; + player_t *player = self->player; + AWeapon *weapon = player->ReadyWeapon; AActor *linetarget; - if (UseAmmo && weapon) + if (useammo && weapon) { - if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return; // out of ammo + if (!weapon->DepleteAmmo(weapon->bAltFire, true)) + return 0; // out of ammo } if (ti) { angle_t ang = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT; - fixed_t x = SpawnOfs_XY * finecosine[ang]; - fixed_t y = SpawnOfs_XY * finesine[ang]; - fixed_t z = SpawnHeight; + fixed_t x = spawnofs_xy * finecosine[ang]; + fixed_t y = spawnofs_xy * finesine[ang]; + fixed_t z = spawnheight; fixed_t shootangle = self->angle; - if (AimAtAngle) shootangle+=Angle; + if (aimatangle) shootangle += angle; // Temporarily adjusts the pitch - fixed_t SavedPlayerPitch = self->pitch; + fixed_t saved_player_pitch = self->pitch; self->pitch -= pitch; - AActor * misl=P_SpawnPlayerMissile (self, x, y, z, ti, shootangle, &linetarget); - self->pitch = SavedPlayerPitch; + AActor *misl = P_SpawnPlayerMissile (self, x, y, z, ti, shootangle, &linetarget); + self->pitch = saved_player_pitch; // automatic handling of seeker missiles if (misl) { - if (linetarget && misl->flags2&MF2_SEEKERMISSILE) misl->tracer=linetarget; - if (!AimAtAngle) + if (linetarget && (misl->flags2 & MF2_SEEKERMISSILE)) + misl->tracer = linetarget; + if (!aimatangle) { // This original implementation is to aim straight ahead and then offset // the angle from the resulting direction. FVector3 velocity(misl->velx, misl->vely, 0); fixed_t missilespeed = (fixed_t)velocity.Length(); - misl->angle += Angle; + misl->angle += angle; angle_t an = misl->angle >> ANGLETOFINESHIFT; misl->velx = FixedMul (missilespeed, finecosine[an]); misl->vely = FixedMul (missilespeed, finesine[an]); } } } + return 0; } @@ -1067,49 +1130,52 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile) //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch) { - 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); + PARAM_ACTION_PROLOGUE; + PARAM_INT (damage); + PARAM_BOOL_OPT (norandom) { norandom = false; } + PARAM_BOOL_OPT (useammo) { useammo = true; } + PARAM_CLASS_OPT (pufftype, AActor) { pufftype = NULL; } + PARAM_FIXED_OPT (range) { range = 0; } - if (!self->player) return; + if (!self->player) + return 0; - player_t *player=self->player; - AWeapon * weapon=player->ReadyWeapon; + player_t *player = self->player; + AWeapon *weapon = player->ReadyWeapon; angle_t angle; int pitch; AActor * linetarget; - if (!norandom) Damage *= (pr_cwpunch()%8+1); + if (!norandom) + damage *= pr_cwpunch() % 8 + 1; angle = self->angle + (pr_cwpunch.Random2() << 18); - if (Range == 0) Range = MELEERANGE; - pitch = P_AimLineAttack (self, angle, Range, &linetarget); + if (range == 0) + range = MELEERANGE; + pitch = P_AimLineAttack (self, angle, range, &linetarget); // only use ammo when actually hitting something! - if (UseAmmo && linetarget && weapon) + if (useammo && linetarget && weapon) { - if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return; // out of ammo + if (!weapon->DepleteAmmo(weapon->bAltFire, true)) + return 0; // out of ammo } - if (!PuffType) PuffType = PClass::FindClass(NAME_BulletPuff); + if (pufftype == NULL) + pufftype = PClass::FindClass(NAME_BulletPuff); - P_LineAttack (self, angle, Range, pitch, Damage, GetDefaultByType(PuffType)->DamageType, PuffType, true); + P_LineAttack (self, angle, range, pitch, damage, GetDefaultByType(pufftype)->DamageType, pufftype, true); // turn to face target if (linetarget) { S_Sound (self, CHAN_WEAPON, weapon->AttackSound, 1, ATTN_NORM); - self->angle = R_PointToAngle2 (self->x, - self->y, - linetarget->x, - linetarget->y); + self->angle = R_PointToAngle2 (self->x, self->y, linetarget->x, linetarget->y); } + return 0; } @@ -1126,27 +1192,30 @@ enum //========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack) { - 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_INT(Flags, 5); - ACTION_PARAM_FLOAT(MaxDiff, 6); - ACTION_PARAM_CLASS(PuffType, 7); + PARAM_ACTION_PROLOGUE; + PARAM_INT (damage); + PARAM_INT_OPT (spawnofs_xy) { spawnofs_xy = 0; } + PARAM_BOOL_OPT (useammo) { useammo = true; } + PARAM_COLOR_OPT (color1) { color1 = 0; } + PARAM_COLOR_OPT (color2) { color2 = 0; } + PARAM_INT_OPT (flags) { flags = 0; } + PARAM_FLOAT_OPT (maxdiff) { maxdiff = 0; } + PARAM_CLASS_OPT (pufftype, AActor) { pufftype = PClass::FindClass(NAME_BulletPuff); } - if (!self->player) return; + if (!self->player) + return 0; - AWeapon * weapon=self->player->ReadyWeapon; + AWeapon *weapon = self->player->ReadyWeapon; // only use ammo when actually hitting something! - if (UseAmmo) + if (useammo) { - if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return; // out of ammo + if (!weapon->DepleteAmmo(weapon->bAltFire, true)) + return 0; // out of ammo } - P_RailAttack (self, Damage, Spawnofs_XY, Color1, Color2, MaxDiff, (Flags & RAF_SILENT), PuffType, (!(Flags & RAF_NOPIERCE))); + P_RailAttack (self, damage, spawnofs_xy, color1, color2, float(maxdiff), (flags & RAF_SILENT), pufftype, (!(flags & RAF_NOPIERCE))); + return 0; } //========================================================================== @@ -1163,15 +1232,15 @@ enum DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) { - 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_INT(Flags, 4); - ACTION_PARAM_INT(aim, 5); - ACTION_PARAM_FLOAT(MaxDiff, 6); - ACTION_PARAM_CLASS(PuffType, 7); + PARAM_ACTION_PROLOGUE; + PARAM_INT (damage); + PARAM_INT_OPT (spawnofs_xy) { spawnofs_xy = 0; } + PARAM_COLOR_OPT (color1) { color1 = 0; } + PARAM_COLOR_OPT (color2) { color2 = 0; } + PARAM_INT_OPT (flags) { flags = 0; } + PARAM_INT_OPT (aim) { aim = CRF_DONTAIM; } + PARAM_FLOAT_OPT (maxdiff) { maxdiff = 0; } + PARAM_CLASS_OPT (pufftype, AActor) { pufftype = PClass::FindClass(NAME_BulletPuff); } fixed_t saved_x = self->x; fixed_t saved_y = self->y; @@ -1179,7 +1248,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) if (aim && self->target == NULL) { - return; + return 0; } // [RH] Andy Baker's stealth monsters if (self->flags & MF_STEALTH) @@ -1192,12 +1261,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) if (aim) { - self->angle = R_PointToAngle2 (self->x, self->y, self->target->x, self->target->y); - } self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE); @@ -1213,9 +1280,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) { // Tricky: We must offset to the angle of the current position // but then change the angle again to ensure proper aim. - self->x += Spawnofs_XY * finecosine[self->angle]; - self->y += Spawnofs_XY * finesine[self->angle]; - Spawnofs_XY = 0; + self->x += spawnofs_xy * finecosine[self->angle]; + self->y += spawnofs_xy * finesine[self->angle]; + spawnofs_xy = 0; self->angle = R_PointToAngle2 (self->x, self->y, self->target->x - self->target->velx * 3, self->target->y - self->target->vely * 3); @@ -1231,11 +1298,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) angle_t angle = (self->angle - ANG90) >> ANGLETOFINESHIFT; - P_RailAttack (self, Damage, Spawnofs_XY, Color1, Color2, MaxDiff, (Flags & RAF_SILENT), PuffType, (!(Flags & RAF_NOPIERCE))); + P_RailAttack (self, damage, spawnofs_xy, color1, color2, float(maxdiff), flags & RAF_SILENT, pufftype, !(flags & RAF_NOPIERCE)); self->x = saved_x; self->y = saved_y; self->angle = saved_angle; + return 0; } //=========================================================================== @@ -1244,19 +1312,22 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) // //=========================================================================== -static void DoGiveInventory(AActor * receiver, DECLARE_PARAMINFO) +static void DoGiveInventory(AActor *receiver, StateCallData *statecall, VM_ARGS) { - ACTION_PARAM_START(2); - ACTION_PARAM_CLASS(mi, 0); - ACTION_PARAM_INT(amount, 1); + int pnum = NAP; + PARAM_CLASS (mi, AInventory); + PARAM_INT_OPT (amount) { amount = 1; } - bool res=true; + bool res = true; if (receiver == NULL) return; - if (amount==0) amount=1; + if (amount <= 0) + { + amount = 1; + } if (mi) { - AInventory *item = static_cast(Spawn (mi, 0, 0, 0, NO_REPLACE)); + AInventory *item = static_cast(Spawn(mi, 0, 0, 0, NO_REPLACE)); if (item->IsKindOf(RUNTIME_CLASS(AHealth))) { item->Amount *= amount; @@ -1268,30 +1339,39 @@ static void DoGiveInventory(AActor * receiver, DECLARE_PARAMINFO) item->flags |= MF_DROPPED; if (item->flags & MF_COUNTITEM) { - item->flags&=~MF_COUNTITEM; + item->flags &= ~MF_COUNTITEM; level.total_items--; } - if (!item->CallTryPickup (receiver)) + if (!item->CallTryPickup(receiver)) { - item->Destroy (); + item->Destroy(); res = false; } - else res = true; + else + { + res = true; + } + } + else + { + res = false; } - else res = false; ACTION_SET_RESULT(res); - } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveInventory) { - DoGiveInventory(self, PUSH_PARAMINFO); + PARAM_ACTION_PROLOGUE; + DoGiveInventory(self, statecall, VM_ARGS_NAMES); + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveToTarget) { - DoGiveInventory(self->target, PUSH_PARAMINFO); -} + PARAM_ACTION_PROLOGUE; + DoGiveInventory(self->target, statecall, VM_ARGS_NAMES); + return 0; +} //=========================================================================== // @@ -1299,17 +1379,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveToTarget) // //=========================================================================== -void DoTakeInventory(AActor * receiver, DECLARE_PARAMINFO) +void DoTakeInventory(AActor *receiver, StateCallData *statecall, VM_ARGS) { - ACTION_PARAM_START(2); - ACTION_PARAM_CLASS(item, 0); - ACTION_PARAM_INT(amount, 1); + int pnum = NAP; + PARAM_CLASS (itemtype, AInventory); + PARAM_INT_OPT (amount) { amount = 0; } - if (item == NULL || receiver == NULL) return; + if (itemtype == NULL || receiver == NULL) return; bool res = false; - AInventory * inv = receiver->FindInventory(item); + AInventory *inv = receiver->FindInventory(itemtype); if (inv && !inv->IsKindOf(RUNTIME_CLASS(AHexenArmor))) { @@ -1317,24 +1397,33 @@ void DoTakeInventory(AActor * receiver, DECLARE_PARAMINFO) { res = true; } - if (!amount || amount>=inv->Amount) + if (amount == 0 || amount >= inv->Amount) { - if (inv->ItemFlags&IF_KEEPDEPLETED) inv->Amount=0; - else inv->Destroy(); + if (inv->ItemFlags & IF_KEEPDEPLETED) + inv->Amount = 0; + else + inv->Destroy(); + } + else + { + inv->Amount -= amount; } - else inv->Amount-=amount; } ACTION_SET_RESULT(res); } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_TakeInventory) { - DoTakeInventory(self, PUSH_PARAMINFO); + PARAM_ACTION_PROLOGUE; + DoTakeInventory(self, statecall, VM_ARGS_NAMES); + return 0; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_TakeFromTarget) { - DoTakeInventory(self->target, PUSH_PARAMINFO); + PARAM_ACTION_PROLOGUE; + DoTakeInventory(self->target, statecall, VM_ARGS_NAMES); + return 0; } //=========================================================================== @@ -1441,45 +1530,49 @@ static bool InitSpawnedItem(AActor *self, AActor *mo, int flags) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem) { - 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); + PARAM_ACTION_PROLOGUE; + PARAM_CLASS_OPT (missile, AActor) { missile = PClass::FindClass("Unknown"); } + PARAM_FIXED_OPT (distance) { distance = 0; } + PARAM_FIXED_OPT (zheight) { zheight = 0; } + PARAM_BOOL_OPT (useammo) { useammo = true; } + PARAM_BOOL_OPT (transfer_translation) { transfer_translation = false; } - if (!missile) + if (missile == NULL) { ACTION_SET_RESULT(false); - return; + return 0; } // Don't spawn monsters if this actor has been massacred - if (self->DamageType == NAME_Massacre && GetDefaultByType(missile)->flags3&MF3_ISMONSTER) return; + if (self->DamageType == NAME_Massacre && (GetDefaultByType(missile)->flags3 & MF3_ISMONSTER)) + return 0; - if (distance==0) + if (distance == 0) { // use the minimum distance that does not result in an overlap - distance=(self->radius+GetDefaultByType(missile)->radius)>>FRACBITS; + distance = (self->radius + GetDefaultByType(missile)->radius) >> FRACBITS; } if (ACTION_CALL_FROM_WEAPON()) { - // Used from a weapon so use some ammo - AWeapon * weapon=self->player->ReadyWeapon; + // Used from a weapon, so use some ammo + AWeapon *weapon = self->player->ReadyWeapon; - if (!weapon) return; - if (useammo && !weapon->DepleteAmmo(weapon->bAltFire)) return; + if (weapon == NULL) + return 0; + if (useammo && !weapon->DepleteAmmo(weapon->bAltFire)) + return 0; } - AActor * mo = Spawn( missile, + AActor *mo = Spawn(missile, self->x + FixedMul(distance, finecosine[self->angle>>ANGLETOFINESHIFT]), self->y + FixedMul(distance, finesine[self->angle>>ANGLETOFINESHIFT]), self->z - self->floorclip + zheight, ALLOW_REPLACE); - int flags = (transfer_translation? SIXF_TRANSFERTRANSLATION:0) + (useammo? SIXF_SETMASTER:0); + int flags = (transfer_translation ? SIXF_TRANSFERTRANSLATION : 0) + (useammo ? SIXF_SETMASTER : 0); bool res = InitSpawnedItem(self, mo, flags); ACTION_SET_RESULT(res); // for an inventory item's use state + return 0; } //=========================================================================== @@ -1491,37 +1584,39 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) { - 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(xvel, 4); - ACTION_PARAM_FIXED(yvel, 5); - ACTION_PARAM_FIXED(zvel, 6); - ACTION_PARAM_ANGLE(Angle, 7); - ACTION_PARAM_INT(flags, 8); - ACTION_PARAM_INT(chance, 9); + PARAM_ACTION_PROLOGUE; + PARAM_CLASS (missile, AActor); + PARAM_FIXED_OPT (xofs) { xofs = 0; } + PARAM_FIXED_OPT (yofs) { yofs = 0; } + PARAM_FIXED_OPT (zofs) { zofs = 0; } + PARAM_FIXED_OPT (xvel) { xvel = 0; } + PARAM_FIXED_OPT (yvel) { yvel = 0; } + PARAM_FIXED_OPT (zvel) { zvel = 0; } + PARAM_ANGLE_OPT (angle) { angle = 0; } + PARAM_INT_OPT (flags) { flags = 0; } + PARAM_INT_OPT (chance) { chance = 0; } - if (!missile) + if (missile == NULL) { ACTION_SET_RESULT(false); - return; + return 0; } - if (chance > 0 && pr_spawnitemex() 0 && pr_spawnitemex() < chance) + return 0; // Don't spawn monsters if this actor has been massacred - if (self->DamageType == NAME_Massacre && GetDefaultByType(missile)->flags3&MF3_ISMONSTER) return; + if (self->DamageType == NAME_Massacre && (GetDefaultByType(missile)->flags3 & MF3_ISMONSTER)) + return 0; - fixed_t x,y; + fixed_t x, y; if (!(flags & SIXF_ABSOLUTEANGLE)) { - Angle += self->angle; + angle += self->angle; } - angle_t ang = Angle >> ANGLETOFINESHIFT; + angle_t ang = angle >> ANGLETOFINESHIFT; if (flags & SIXF_ABSOLUTEPOSITION) { @@ -1544,7 +1639,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) xvel = newxvel; } - AActor * mo = Spawn(missile, x, y, self->z - self->floorclip + zofs, ALLOW_REPLACE); + AActor *mo = Spawn(missile, x, y, self->z - self->floorclip + zofs, ALLOW_REPLACE); bool res = InitSpawnedItem(self, mo, flags); ACTION_SET_RESULT(res); // for an inventory item's use state if (mo) @@ -1552,10 +1647,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) mo->velx = xvel; mo->vely = yvel; mo->velz = zvel; - mo->angle = Angle; + mo->angle = angle; if (flags & SIXF_TRANSFERAMBUSHFLAG) - mo->flags = (mo->flags&~MF_AMBUSH) | (self->flags & MF_AMBUSH); + mo->flags = (mo->flags & ~MF_AMBUSH) | (self->flags & MF_AMBUSH); } + return 0; } //=========================================================================== @@ -1567,29 +1663,31 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade) { - ACTION_PARAM_START(5); - ACTION_PARAM_CLASS(missile, 0); - ACTION_PARAM_FIXED(zheight, 1); - ACTION_PARAM_FIXED(xyvel, 2); - ACTION_PARAM_FIXED(zvel, 3); - ACTION_PARAM_BOOL(useammo, 4); + PARAM_ACTION_PROLOGUE; + PARAM_CLASS (missile, AActor); + PARAM_FIXED_OPT (zheight) { zheight = 0; } + PARAM_FIXED_OPT (xyvel) { xyvel = 0; } + PARAM_FIXED_OPT (zvel) { zvel = 0; } + PARAM_BOOL_OPT (useammo) { useammo = true; } - if (missile == NULL) return; + if (missile == NULL) + return 0; if (ACTION_CALL_FROM_WEAPON()) { - // Used from a weapon so use some ammo - AWeapon * weapon=self->player->ReadyWeapon; + // Used from a weapon, so use some ammo + AWeapon *weapon = self->player->ReadyWeapon; - if (!weapon) return; - if (useammo && !weapon->DepleteAmmo(weapon->bAltFire)) return; + if (weapon == NULL) + return 0; + if (useammo && !weapon->DepleteAmmo(weapon->bAltFire)) + return 0; } - - AActor * bo; + AActor *bo; bo = Spawn(missile, self->x, self->y, - self->z - self->floorclip + zheight + 35*FRACUNIT + (self->player? self->player->crouchoffset : 0), + self->z - self->floorclip + zheight + 35*FRACUNIT + (self->player ? self->player->crouchoffset : 0), ALLOW_REPLACE); if (bo) { @@ -1607,7 +1705,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade) bo->target= self; P_CheckMissileSpawn (bo); } - else ACTION_SET_RESULT(false); + else + { + ACTION_SET_RESULT(false); + } + return 0; } @@ -1618,13 +1720,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Recoil) { - ACTION_PARAM_START(1); - ACTION_PARAM_FIXED(xyvel, 0); + PARAM_ACTION_PROLOGUE; + PARAM_FIXED(xyvel); angle_t angle = self->angle + ANG180; angle >>= ANGLETOFINESHIFT; - self->velx += FixedMul (xyvel, finecosine[angle]); - self->vely += FixedMul (xyvel, finesine[angle]); + self->velx += FixedMul(xyvel, finecosine[angle]); + self->vely += FixedMul(xyvel, finesine[angle]); + return 0; } @@ -1635,16 +1738,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Recoil) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SelectWeapon) { - ACTION_PARAM_START(1); - ACTION_PARAM_CLASS(cls, 0); + PARAM_ACTION_PROLOGUE; + PARAM_CLASS(cls, AWeapon); if (cls == NULL || self->player == NULL) { ACTION_SET_RESULT(false); - return; + return 0; } - AWeapon * weaponitem = static_cast(self->FindInventory(cls)); + AWeapon *weaponitem = static_cast(self->FindInventory(cls)); if (weaponitem != NULL && weaponitem->IsKindOf(RUNTIME_CLASS(AWeapon))) { @@ -1653,8 +1756,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SelectWeapon) self->player->PendingWeapon = weaponitem; } } - else ACTION_SET_RESULT(false); - + else + { + ACTION_SET_RESULT(false); + } + return 0; } @@ -1667,13 +1773,13 @@ EXTERN_CVAR(Float, con_midtime) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Print) { - ACTION_PARAM_START(3); - ACTION_PARAM_STRING(text, 0); - ACTION_PARAM_FLOAT(time, 1); - ACTION_PARAM_NAME(fontname, 2); + PARAM_ACTION_PROLOGUE; + PARAM_STRING (text); + PARAM_FLOAT_OPT (time) { time = 0; } + PARAM_NAME_OPT (fontname) { fontname = NAME_None; } if (self->CheckLocalView (consoleplayer) || - (self->target!=NULL && self->target->CheckLocalView (consoleplayer))) + (self->target != NULL && self->target->CheckLocalView (consoleplayer))) { float saved = con_midtime; FFont *font = NULL; @@ -1684,12 +1790,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Print) } if (time > 0) { - con_midtime = time; + con_midtime = float(time); } - C_MidPrint(font != NULL ? font : SmallFont, text); con_midtime = saved; } + return 0; } //=========================================================================== @@ -1700,10 +1806,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Print) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PrintBold) { - ACTION_PARAM_START(3); - ACTION_PARAM_STRING(text, 0); - ACTION_PARAM_FLOAT(time, 1); - ACTION_PARAM_NAME(fontname, 2); + PARAM_ACTION_PROLOGUE; + PARAM_STRING (text); + PARAM_FLOAT_OPT (time) { time = 0; } + PARAM_NAME_OPT (fontname) { fontname = NAME_None; } float saved = con_midtime; FFont *font = NULL; @@ -1714,11 +1820,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PrintBold) } if (time > 0) { - con_midtime = time; + con_midtime = float(time); } - C_MidPrintBold(font != NULL ? font : SmallFont, text); con_midtime = saved; + return 0; } //=========================================================================== @@ -1729,9 +1835,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PrintBold) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Log) { - ACTION_PARAM_START(1); - ACTION_PARAM_STRING(text, 0); + PARAM_ACTION_PROLOGUE; + PARAM_STRING(text); Printf("%s\n", text); + return 0; } //=========================================================================== @@ -1741,15 +1848,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Log) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTranslucent) { - ACTION_PARAM_START(2); - ACTION_PARAM_FIXED(alpha, 0); - ACTION_PARAM_INT(mode, 1); + PARAM_ACTION_PROLOGUE; + PARAM_FIXED (alpha); + PARAM_INT_OPT (mode) { mode = 0; } mode = mode == 0 ? STYLE_Translucent : mode == 2 ? STYLE_Fuzzy : STYLE_Add; self->RenderStyle.Flags &= ~STYLEF_Alpha1; self->alpha = clamp(alpha, 0, FRACUNIT); self->RenderStyle = ERenderStyle(mode); + return 0; } //=========================================================================== @@ -1761,14 +1869,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTranslucent) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FadeIn) { - ACTION_PARAM_START(1); - ACTION_PARAM_FIXED(reduce, 0); + PARAM_ACTION_PROLOGUE; + PARAM_FIXED_OPT(reduce) { reduce = FRACUNIT/10; } - if (reduce == 0) reduce = FRACUNIT/10; + if (reduce == 0) + reduce = FRACUNIT/10; self->RenderStyle.Flags &= ~STYLEF_Alpha1; self->alpha += reduce; - //if (self->alpha<=0) self->Destroy(); + return 0; } //=========================================================================== @@ -1780,15 +1889,18 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FadeIn) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FadeOut) { - ACTION_PARAM_START(2); - ACTION_PARAM_FIXED(reduce, 0); - ACTION_PARAM_BOOL(remove, 1); + PARAM_ACTION_PROLOGUE; + PARAM_FIXED_OPT(reduce) { reduce = FRACUNIT/10; } + PARAM_BOOL_OPT(remove) { remove = true; } - if (reduce == 0) reduce = FRACUNIT/10; + if (reduce == 0) + reduce = FRACUNIT/10; self->RenderStyle.Flags &= ~STYLEF_Alpha1; self->alpha -= reduce; - if (self->alpha<=0 && remove) self->Destroy(); + if (self->alpha<=0 && remove) + self->Destroy(); + return 0; } //=========================================================================== @@ -1798,20 +1910,22 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FadeOut) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris) { + PARAM_ACTION_PROLOGUE; + PARAM_CLASS (debris, AActor); + PARAM_BOOL_OPT (transfer_translation) { transfer_translation = false; } + PARAM_FIXED_OPT (mult_h) { mult_h = FRACUNIT; } + PARAM_FIXED_OPT (mult_v) { mult_v = FRACUNIT; } int i; - AActor * mo; + AActor *mo; - 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); - - if (debris == NULL) return; + if (debris == NULL) + return 0; // only positive values make sense here - if (mult_v<=0) mult_v=FRACUNIT; - if (mult_h<=0) mult_h=FRACUNIT; + if (mult_v <= 0) + mult_v = FRACUNIT; + if (mult_h <= 0) + mult_h = FRACUNIT; for (i = 0; i < GetDefaultByType(debris)->health; i++) { @@ -1830,6 +1944,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris) mo->vely = FixedMul(mult_h, pr_spawndebris.Random2()<<(FRACBITS-6)); } } + return 0; } @@ -1841,18 +1956,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSight) { - ACTION_PARAM_START(1); - ACTION_PARAM_STATE(jump, 0); + PARAM_ACTION_PROLOGUE; + PARAM_STATE(jump); ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! - for (int i=0;iFindInventory(drop); + AInventory *inv = self->FindInventory(drop); if (inv) { self->DropInventory(inv); } } + return 0; } @@ -1884,20 +2001,23 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropInventory) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetBlend) { - ACTION_PARAM_START(4); - ACTION_PARAM_COLOR(color, 0); - ACTION_PARAM_FLOAT(alpha, 1); - ACTION_PARAM_INT(tics, 2); - ACTION_PARAM_COLOR(color2, 3); + PARAM_ACTION_PROLOGUE; + PARAM_COLOR (color); + PARAM_FLOAT (alpha); + PARAM_INT (tics); + PARAM_COLOR_OPT (color2) { color2 = 0; } - if (color == MAKEARGB(255,255,255,255)) color=0; - if (color2 == MAKEARGB(255,255,255,255)) color2=0; - if (!color2.a) + if (color == MAKEARGB(255,255,255,255)) + color = 0; + if (color2 == MAKEARGB(255,255,255,255)) + color2 = 0; + if (color2.a == 0) color2 = color; - new DFlashFader(color.r/255.0f, color.g/255.0f, color.b/255.0f, alpha, - color2.r/255.0f, color2.g/255.0f, color2.b/255.0f, 0, - (float)tics/TICRATE, self); + new DFlashFader(color.r/255.f, color.g/255.f, color.b/255.f, float(alpha), + color2.r/255.f, color2.g/255.f, color2.b/255.f, 0, + float(tics)/TICRATE, self); + return 0; } @@ -1908,13 +2028,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetBlend) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIf) { - ACTION_PARAM_START(2); - ACTION_PARAM_BOOL(expression, 0); - ACTION_PARAM_STATE(jump, 1); + PARAM_ACTION_PROLOGUE; + PARAM_BOOL (condition); + PARAM_STATE (jump); ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! - if (expression) ACTION_JUMP(jump); - + if (condition) + ACTION_JUMP(jump); + return 0; } //=========================================================================== @@ -1924,10 +2045,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIf) //=========================================================================== DEFINE_ACTION_FUNCTION(AActor, A_KillMaster) { + PARAM_ACTION_PROLOGUE; if (self->master != NULL) { P_DamageMobj(self->master, self, self, self->master->health, NAME_None, DMG_NO_ARMOR); } + return 0; } //=========================================================================== @@ -1937,8 +2060,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_KillMaster) //=========================================================================== DEFINE_ACTION_FUNCTION(AActor, A_KillChildren) { + PARAM_ACTION_PROLOGUE; TThinkerIterator it; - AActor * mo; + AActor *mo; while ( (mo = it.Next()) ) { @@ -1947,6 +2071,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KillChildren) P_DamageMobj(mo, self, self, mo->health, NAME_None, DMG_NO_ARMOR); } } + return 0; } //=========================================================================== @@ -1956,8 +2081,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_KillChildren) //=========================================================================== DEFINE_ACTION_FUNCTION(AActor, A_KillSiblings) { + PARAM_ACTION_PROLOGUE; TThinkerIterator it; - AActor * mo; + AActor *mo; while ( (mo = it.Next()) ) { @@ -1966,6 +2092,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KillSiblings) P_DamageMobj(mo, self, self, mo->health, NAME_None, DMG_NO_ARMOR); } } + return 0; } //=========================================================================== @@ -1975,26 +2102,28 @@ DEFINE_ACTION_FUNCTION(AActor, A_KillSiblings) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CountdownArg) { - ACTION_PARAM_START(1); - ACTION_PARAM_INT(cnt, 0); + PARAM_ACTION_PROLOGUE; + PARAM_INT(argnum); - if (cnt<0 || cnt>=5) return; - if (!self->args[cnt]--) + if (argnum > 0 && argnum < countof(self->args)) { - if (self->flags&MF_MISSILE) + if (!self->args[argnum]--) { - P_ExplodeMissile(self, NULL, NULL); - } - else if (self->flags&MF_SHOOTABLE) - { - P_DamageMobj (self, NULL, NULL, self->health, NAME_None, DMG_FORCED); - } - else - { - self->SetState(self->FindState(NAME_Death)); + if (self->flags & MF_MISSILE) + { + P_ExplodeMissile(self, NULL, NULL); + } + else if (self->flags & MF_SHOOTABLE) + { + P_DamageMobj(self, NULL, NULL, self->health, NAME_None, DMG_FORCED); + } + else + { + self->SetState(self->FindState(NAME_Death)); + } } } - + return 0; } //============================================================================ @@ -2005,13 +2134,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CountdownArg) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Burst) { - ACTION_PARAM_START(1); - ACTION_PARAM_CLASS(chunk, 0); + PARAM_ACTION_PROLOGUE; + PARAM_CLASS(chunk, AActor); int i, numChunks; - AActor * mo; + AActor *mo; - if (chunk == NULL) return; + if (chunk == NULL) + return 0; self->velx = self->vely = self->velz = 0; self->height = self->GetDefault()->height; @@ -2048,7 +2178,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Burst) } CALL_ACTION(A_NoBlocking, self); - self->Destroy (); + self->Destroy(); + return 0; } //=========================================================================== @@ -2059,34 +2190,34 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Burst) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFloor) { - ACTION_PARAM_START(1); - ACTION_PARAM_STATE(jump, 0); + PARAM_ACTION_PROLOGUE; + PARAM_STATE(jump); ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! if (self->z <= self->floorz) { ACTION_JUMP(jump); } - + return 0; } //=========================================================================== // // A_CheckCeiling -// [GZ] Totally copied on A_CheckFloor, jumps if actor touches ceiling +// [GZ] Totally copied from A_CheckFloor, jumps if actor touches ceiling // //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckCeiling) { - ACTION_PARAM_START(1); - ACTION_PARAM_STATE(jump, 0); + PARAM_ACTION_PROLOGUE; + PARAM_STATE(jump); ACTION_SET_RESULT(false); - if (self->z+self->height >= self->ceilingz) // Height needs to be counted + if (self->z + self->height >= self->ceilingz) // Height needs to be counted { ACTION_JUMP(jump); } - + return 0; } //=========================================================================== @@ -2097,12 +2228,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckCeiling) //=========================================================================== DEFINE_ACTION_FUNCTION(AActor, A_Stop) { + PARAM_ACTION_PROLOGUE; self->velx = self->vely = self->velz = 0; if (self->player && self->player->mo == self && !(self->player->cheats & CF_PREDICTING)) { self->player->mo->PlayIdle(); self->player->velx = self->player->vely = 0; } + return 0; } static void CheckStopped(AActor *self) @@ -2132,8 +2265,8 @@ enum RS_Flags DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) { - ACTION_PARAM_START(1); - ACTION_PARAM_INT(flags, 0); + PARAM_ACTION_PROLOGUE; + PARAM_INT_OPT(flags) { flags = RSF_FOG; } fixed_t x = self->SpawnPoint[0]; fixed_t y = self->SpawnPoint[1]; @@ -2147,12 +2280,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) if (flags & RSF_TELEFRAG) { // [KS] DIE DIE DIE DIE erm *ahem* =) - if (P_TeleportMove (self, x, y, sec->floorplane.ZatPoint (x, y), true)) oktorespawn = true; + if (P_TeleportMove(self, x, y, sec->floorplane.ZatPoint (x, y), true)) + oktorespawn = true; } else { - self->SetOrigin (x, y, sec->floorplane.ZatPoint (x, y)); - if (P_TestMobjLocation (self)) oktorespawn = true; + self->SetOrigin(x, y, sec->floorplane.ZatPoint (x, y)); + if (P_TestMobjLocation(self)) + oktorespawn = true; } if (oktorespawn) @@ -2171,8 +2306,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) else { // Don't attack yourself (Re: "Marine targets itself after suicide") - if (self->target == self) self->target = NULL; - if (self->lastenemy == self) self->lastenemy = NULL; + if (self->target == self) + self->target = NULL; + if (self->lastenemy == self) + self->lastenemy = NULL; } self->flags = (defs->flags & ~MF_FRIENDLY) | (self->flags & MF_FRIENDLY); @@ -2185,14 +2322,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) if (flags & RSF_FOG) { - Spawn (x, y, self->z + TELEFOGHEIGHT, ALLOW_REPLACE); + Spawn(x, y, self->z + TELEFOGHEIGHT, ALLOW_REPLACE); } - if (self->CountsAsKill()) level.total_monsters++; + if (self->CountsAsKill()) + level.total_monsters++; } else { self->flags &= ~MF_SOLID; } + return 0; } @@ -2204,8 +2343,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlayerSkinCheck) { - ACTION_PARAM_START(1); - ACTION_PARAM_STATE(jump, 0); + PARAM_ACTION_PROLOGUE; + PARAM_STATE(jump); ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! if (self->player != NULL && @@ -2213,6 +2352,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlayerSkinCheck) { ACTION_JUMP(jump); } + return 0; } //=========================================================================== @@ -2222,10 +2362,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlayerSkinCheck) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetGravity) { - ACTION_PARAM_START(1); - ACTION_PARAM_FIXED(val, 0); + PARAM_ACTION_PROLOGUE; + PARAM_FIXED(gravity); - self->gravity = clamp (val, 0, FRACUNIT*10); + self->gravity = clamp(gravity, 0, FRACUNIT*10); + return 0; } @@ -2239,9 +2380,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetGravity) DEFINE_ACTION_FUNCTION(AActor, A_ClearTarget) { + PARAM_ACTION_PROLOGUE; self->target = NULL; self->LastHeard = NULL; self->lastenemy = NULL; + return 0; } //========================================================================== @@ -2259,10 +2402,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_ClearTarget) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) { - ACTION_PARAM_START(3); - ACTION_PARAM_STATE(jump, 0); - ACTION_PARAM_ANGLE(fov, 1); - ACTION_PARAM_BOOL(projtarg, 2); + PARAM_ACTION_PROLOGUE; + PARAM_STATE (jump); + PARAM_ANGLE_OPT (fov) { fov = 0; } + PARAM_BOOL_OPT (projtarg) { projtarg = false; } angle_t an; AActor *target; @@ -2283,22 +2426,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) target = self->target; } - if (!target) return; // [KS] Let's not call P_CheckSight unnecessarily in this case. + if (target == NULL) + return 0; // [KS] Let's not call P_CheckSight unnecessarily in this case. if (!P_CheckSight (self, target, 1)) - return; + return 0; if (fov && (fov < ANGLE_MAX)) { - an = R_PointToAngle2 (self->x, - self->y, - target->x, - target->y) - - self->angle; + an = R_PointToAngle2(self->x, self->y, target->x, target->y) - self->angle; if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2))) { - return; // [KS] Outside of FOV - return + return 0; // [KS] Outside of FOV - return } } @@ -2309,9 +2449,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) P_BulletSlope(self, &target); } - if (!target) return; + if (target == NULL) + return 0; ACTION_JUMP(jump); + return 0; } @@ -2324,10 +2466,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS) { - ACTION_PARAM_START(3); - ACTION_PARAM_STATE(jump, 0); - ACTION_PARAM_ANGLE(fov, 1); - ACTION_PARAM_BOOL(projtarg, 2); + PARAM_ACTION_PROLOGUE; + PARAM_STATE (jump); + PARAM_ANGLE_OPT (fov) { fov = 0; } + PARAM_BOOL_OPT (projtarg) { projtarg = false; } angle_t an; AActor *target; @@ -2346,27 +2488,23 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS) target = self->target; } - if (!target) return; // [KS] Let's not call P_CheckSight unnecessarily in this case. + if (target == NULL) + return 0; // [KS] Let's not call P_CheckSight unnecessarily in this case. if (!P_CheckSight (target, self, 1)) - return; + return 0; if (fov && (fov < ANGLE_MAX)) { - an = R_PointToAngle2 (self->x, - self->y, - target->x, - target->y) - - self->angle; + an = R_PointToAngle2(self->x, self->y, target->x, target->y) - self->angle; if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2))) { - return; // [KS] Outside of FOV - return + return 0; // [KS] Outside of FOV - return } - } - ACTION_JUMP(jump); + return 0; } @@ -2378,15 +2516,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageMaster) { - ACTION_PARAM_START(2); - ACTION_PARAM_INT(amount, 0); - ACTION_PARAM_NAME(DamageType, 1); + PARAM_ACTION_PROLOGUE; + PARAM_INT (amount); + PARAM_NAME_OPT (damagetype) { damagetype = NAME_None; } if (self->master != NULL) { if (amount > 0) { - P_DamageMobj(self->master, self, self, amount, DamageType, DMG_NO_ARMOR); + P_DamageMobj(self->master, self, self, amount, damagetype, DMG_NO_ARMOR); } else if (amount < 0) { @@ -2394,6 +2532,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageMaster) P_GiveBody(self->master, amount); } } + return 0; } //=========================================================================== @@ -2404,12 +2543,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageMaster) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageChildren) { - TThinkerIterator it; - AActor * mo; + PARAM_ACTION_PROLOGUE; + PARAM_INT (amount); + PARAM_NAME_OPT (damagetype) { damagetype = NAME_None; } - ACTION_PARAM_START(2); - ACTION_PARAM_INT(amount, 0); - ACTION_PARAM_NAME(DamageType, 1); + TThinkerIterator it; + AActor *mo; while ( (mo = it.Next()) ) { @@ -2417,7 +2556,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageChildren) { if (amount > 0) { - P_DamageMobj(mo, self, self, amount, DamageType, DMG_NO_ARMOR); + P_DamageMobj(mo, self, self, amount, damagetype, DMG_NO_ARMOR); } else if (amount < 0) { @@ -2426,6 +2565,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageChildren) } } } + return 0; } // [KS] *** End of my modifications *** @@ -2438,12 +2578,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageChildren) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageSiblings) { - TThinkerIterator it; - AActor * mo; + PARAM_ACTION_PROLOGUE; + PARAM_INT (amount); + PARAM_NAME_OPT (damagetype) { damagetype = NAME_None; } - ACTION_PARAM_START(2); - ACTION_PARAM_INT(amount, 0); - ACTION_PARAM_NAME(DamageType, 1); + TThinkerIterator it; + AActor *mo; while ( (mo = it.Next()) ) { @@ -2451,7 +2591,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageSiblings) { if (amount > 0) { - P_DamageMobj(mo, self, self, amount, DamageType, DMG_NO_ARMOR); + P_DamageMobj(mo, self, self, amount, damagetype, DMG_NO_ARMOR); } else if (amount < 0) { @@ -2460,6 +2600,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageSiblings) } } } + return 0; } @@ -2471,20 +2612,22 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageSiblings) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckForReload) { + PARAM_ACTION_PROLOGUE; + if ( self->player == NULL || self->player->ReadyWeapon == NULL ) - return; + return 0; - ACTION_PARAM_START(2); - ACTION_PARAM_INT(count, 0); - ACTION_PARAM_STATE(jump, 1); - ACTION_PARAM_BOOL(dontincrement, 2) + PARAM_INT (count); + PARAM_STATE (jump); + PARAM_BOOL_OPT (dontincrement) { dontincrement = false; } - if (count <= 0) return; + if (count <= 0) + return 0; AWeapon *weapon = self->player->ReadyWeapon; int ReloadCounter = weapon->ReloadCounter; - if(!dontincrement || ReloadCounter != 0) + if (!dontincrement || ReloadCounter != 0) ReloadCounter = (weapon->ReloadCounter+1) % count; else // 0 % 1 = 1? So how do we check if the weapon was never fired? We should only do this when we're not incrementing the counter though. ReloadCounter = 1; @@ -2498,11 +2641,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckForReload) else { // We need to reload. However, don't reload if we're out of ammo. - weapon->CheckAmmo( false, false ); + weapon->CheckAmmo(false, false); } - if(!dontincrement) + if (!dontincrement) weapon->ReloadCounter = ReloadCounter; + return 0; } //=========================================================================== @@ -2513,11 +2657,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckForReload) DEFINE_ACTION_FUNCTION(AActor, A_ResetReloadCounter) { - if ( self->player == NULL || self->player->ReadyWeapon == NULL ) - return; + PARAM_ACTION_PROLOGUE; + + if (self->player == NULL || self->player->ReadyWeapon == NULL) + return 0; AWeapon *weapon = self->player->ReadyWeapon; weapon->ReloadCounter = 0; + return 0; } //=========================================================================== @@ -2527,22 +2674,22 @@ DEFINE_ACTION_FUNCTION(AActor, A_ResetReloadCounter) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeFlag) { - ACTION_PARAM_START(2); - ACTION_PARAM_STRING(flagname, 0); - ACTION_PARAM_BOOL(expression, 1); + PARAM_ACTION_PROLOGUE; + PARAM_STRING (flagname); + PARAM_BOOL (value); - const char *dot = strchr (flagname, '.'); + const char *dot = strchr(flagname, '.'); FFlagDef *fd; const PClass *cls = self->GetClass(); if (dot != NULL) { - FString part1(flagname, dot-flagname); - fd = FindFlag (cls, part1, dot+1); + FString part1(flagname.GetChars(), dot - flagname); + fd = FindFlag(cls, part1, dot + 1); } else { - fd = FindFlag (cls, flagname, NULL); + fd = FindFlag(cls, flagname, NULL); } if (fd != NULL) @@ -2555,7 +2702,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeFlag) if (fd->structoffset == -1) { - HandleDeprecatedFlags(self, cls->ActorInfo, expression, fd->flagbit); + HandleDeprecatedFlags(self, cls->ActorInfo, value, fd->flagbit); } else { @@ -2565,7 +2712,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeFlag) bool linkchange = flagp == &self->flags && (fd->flagbit == MF_NOBLOCKMAP || fd->flagbit == MF_NOSECTOR); if (linkchange) self->UnlinkFromWorld(); - if (expression) + if (value) { *flagp |= fd->flagbit; } @@ -2607,6 +2754,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeFlag) { Printf("Unknown flag '%s' in '%s'\n", flagname, cls->TypeName.GetChars()); } + return 0; } //=========================================================================== @@ -2616,10 +2764,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeFlag) //=========================================================================== DEFINE_ACTION_FUNCTION(AActor, A_RemoveMaster) { - if (self->master != NULL) - { - P_RemoveThing(self->master); - } + PARAM_ACTION_PROLOGUE; + if (self->master != NULL) + { + P_RemoveThing(self->master); + } + return 0; } //=========================================================================== @@ -2629,18 +2779,20 @@ DEFINE_ACTION_FUNCTION(AActor, A_RemoveMaster) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RemoveChildren) { - TThinkerIterator it; - AActor * mo; - ACTION_PARAM_START(1); - ACTION_PARAM_BOOL(removeall,0); + PARAM_ACTION_PROLOGUE; + PARAM_BOOL_OPT(removeall) { removeall = false; } - while ( (mo = it.Next()) ) - { - if ( ( mo->master == self ) && ( ( mo->health <= 0 ) || removeall) ) - { - P_RemoveThing(mo); - } - } + TThinkerIterator it; + AActor *mo; + + while ( (mo = it.Next()) ) + { + if ( ( mo->master == self ) && ( ( mo->health <= 0 ) || removeall) ) + { + P_RemoveThing(mo); + } + } + return 0; } //=========================================================================== @@ -2650,18 +2802,20 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RemoveChildren) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RemoveSiblings) { - TThinkerIterator it; - AActor * mo; - ACTION_PARAM_START(1); - ACTION_PARAM_BOOL(removeall,0); + PARAM_ACTION_PROLOGUE; + PARAM_BOOL_OPT(removeall) { removeall = false; } - while ( (mo = it.Next()) ) - { - if ( ( mo->master == self->master ) && ( mo != self ) && ( ( mo->health <= 0 ) || removeall) ) - { - P_RemoveThing(mo); - } - } + TThinkerIterator it; + AActor *mo; + + while ( (mo = it.Next()) ) + { + if ( ( mo->master == self->master ) && ( mo != self ) && ( ( mo->health <= 0 ) || removeall) ) + { + P_RemoveThing(mo); + } + } + return 0; } //=========================================================================== @@ -2671,10 +2825,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RemoveSiblings) //=========================================================================== DEFINE_ACTION_FUNCTION(AActor, A_RaiseMaster) { - if (self->master != NULL) - { - P_Thing_Raise(self->master); - } + PARAM_ACTION_PROLOGUE; + if (self->master != NULL) + { + P_Thing_Raise(self->master); + } + return 0; } //=========================================================================== @@ -2684,16 +2840,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseMaster) //=========================================================================== DEFINE_ACTION_FUNCTION(AActor, A_RaiseChildren) { - TThinkerIterator it; - AActor * mo; + PARAM_ACTION_PROLOGUE; - while ((mo = it.Next())) - { - if ( mo->master == self ) - { - P_Thing_Raise(mo); - } - } + TThinkerIterator it; + AActor *mo; + + while ((mo = it.Next())) + { + if ( mo->master == self ) + { + P_Thing_Raise(mo); + } + } + return 0; } //=========================================================================== @@ -2703,16 +2862,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseChildren) //=========================================================================== DEFINE_ACTION_FUNCTION(AActor, A_RaiseSiblings) { - TThinkerIterator it; - AActor * mo; + PARAM_ACTION_PROLOGUE; - while ( (mo = it.Next()) ) - { - if ( ( mo->master == self->master ) && ( mo != self ) ) - { - P_Thing_Raise(mo); - } - } + TThinkerIterator it; + AActor *mo; + + while ( (mo = it.Next()) ) + { + if ( ( mo->master == self->master ) && ( mo != self ) ) + { + P_Thing_Raise(mo); + } + } + return 0; } //=========================================================================== @@ -2724,23 +2886,24 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseSiblings) //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MonsterRefire) { - ACTION_PARAM_START(2); - ACTION_PARAM_INT(prob, 0); - ACTION_PARAM_STATE(jump, 1); + PARAM_ACTION_PROLOGUE; + PARAM_INT (prob); + PARAM_STATE (jump); ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! - A_FaceTarget (self); + A_FaceTarget(self); if (pr_monsterrefire() < prob) - return; + return 0; - if (!self->target + if (self->target == NULL || P_HitFriend (self) || self->target->health <= 0 - || !P_CheckSight (self, self->target, 0) ) + || !P_CheckSight(self, self->target, 0) ) { ACTION_JUMP(jump); } + return 0; } //=========================================================================== @@ -2753,9 +2916,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MonsterRefire) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetAngle) { - ACTION_PARAM_START(1); - ACTION_PARAM_ANGLE(angle, 0); + PARAM_ACTION_PROLOGUE; + PARAM_ANGLE_OPT(angle) { angle = 0; } self->angle = angle; + return 0; } //=========================================================================== @@ -2768,9 +2932,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetAngle) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetPitch) { - ACTION_PARAM_START(1); - ACTION_PARAM_ANGLE(pitch, 0); + PARAM_ACTION_PROLOGUE; + PARAM_ANGLE(pitch); self->pitch = pitch; + return 0; } //=========================================================================== @@ -2783,8 +2948,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetPitch) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ScaleVelocity) { - ACTION_PARAM_START(1); - ACTION_PARAM_FIXED(scale, 0); + PARAM_ACTION_PROLOGUE; + PARAM_FIXED(scale); INTBOOL was_moving = self->velx | self->vely | self->velz; @@ -2798,6 +2963,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ScaleVelocity) { CheckStopped(self); } + return 0; } //=========================================================================== @@ -2808,11 +2974,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ScaleVelocity) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeVelocity) { - ACTION_PARAM_START(4); - ACTION_PARAM_FIXED(x, 0); - ACTION_PARAM_FIXED(y, 1); - ACTION_PARAM_FIXED(z, 2); - ACTION_PARAM_INT(flags, 3); + PARAM_ACTION_PROLOGUE; + PARAM_FIXED_OPT (x) { x = 0; } + PARAM_FIXED_OPT (y) { y = 0; } + PARAM_FIXED_OPT (z) { z = 0; } + PARAM_INT_OPT (flags) { flags = 0; } INTBOOL was_moving = self->velx | self->vely | self->velz; @@ -2842,6 +3008,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeVelocity) { CheckStopped(self); } + return 0; } //=========================================================================== @@ -2852,15 +3019,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeVelocity) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetArg) { - ACTION_PARAM_START(2); - ACTION_PARAM_INT(pos, 0); - ACTION_PARAM_INT(value, 1); + PARAM_ACTION_PROLOGUE; + PARAM_INT(pos); + PARAM_INT(value); // Set the value of the specified arg if ((size_t)pos < countof(self->args)) { self->args[pos] = value; } + return 0; } //=========================================================================== @@ -2871,13 +3039,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetArg) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpecial) { - ACTION_PARAM_START(6); - ACTION_PARAM_INT(spec, 0); - ACTION_PARAM_INT(arg0, 1); - ACTION_PARAM_INT(arg1, 2); - ACTION_PARAM_INT(arg2, 3); - ACTION_PARAM_INT(arg3, 4); - ACTION_PARAM_INT(arg4, 5); + PARAM_ACTION_PROLOGUE; + PARAM_INT (spec); + PARAM_INT_OPT (arg0) { arg0 = 0; } + PARAM_INT_OPT (arg1) { arg1 = 0; } + PARAM_INT_OPT (arg2) { arg2 = 0; } + PARAM_INT_OPT (arg3) { arg3 = 0; } + PARAM_INT_OPT (arg4) { arg4 = 0; } self->special = spec; self->args[0] = arg0; @@ -2885,6 +3053,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpecial) self->args[2] = arg2; self->args[3] = arg3; self->args[4] = arg4; + return 0; } //=========================================================================== @@ -2895,15 +3064,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpecial) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserVar) { - ACTION_PARAM_START(2); - ACTION_PARAM_INT(pos, 0); - ACTION_PARAM_INT(value, 1); + PARAM_ACTION_PROLOGUE; + PARAM_INT(pos); + PARAM_INT(value); - if (pos < 0 || pos > 9) - return; + if (pos < 0 || pos >= countof(self->uservar)) + return 0; // Set the value of the specified arg self->uservar[pos] = value; + return 0; } //=========================================================================== @@ -2914,9 +3084,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserVar) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Turn) { - ACTION_PARAM_START(1); - ACTION_PARAM_ANGLE(angle, 0); + PARAM_ACTION_PROLOGUE; + PARAM_ANGLE_OPT(angle); self->angle += angle; + return 0; } //=========================================================================== @@ -2927,15 +3098,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Turn) // //=========================================================================== - void P_TranslateLineDef (line_t *ld, maplinedef_t *mld); DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LineEffect) { - ACTION_PARAM_START(2); - ACTION_PARAM_INT(special, 0); - ACTION_PARAM_INT(tag, 1); + PARAM_ACTION_PROLOGUE; + PARAM_INT_OPT(special) { special = 0; } + PARAM_INT_OPT(tag) { tag = 0; } - line_t junk; maplinedef_t oldjunk; + line_t junk; + maplinedef_t oldjunk; bool res = false; if (!(self->flags6 & MF6_LINEDONE)) // Unless already used up { @@ -2950,4 +3121,5 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LineEffect) } } ACTION_SET_RESULT(res); + return 0; } diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index 8b0ed1a41..b063d98dc 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -590,7 +590,10 @@ void InitThingdef() while (*++probe != NULL) { - AFTable.Push(*(AFuncDesc *)*probe); + AFuncDesc *afunc = (AFuncDesc *)*probe; + assert(afunc->VMPointer != NULL); + *(afunc->VMPointer) = new VMNativeFunction(afunc->Function); + AFTable.Push(*afunc); } AFTable.ShrinkToFit(); qsort(&AFTable[0], AFTable.Size(), sizeof(AFTable[0]), funccmp); diff --git a/src/thingdef/thingdef_parse.cpp b/src/thingdef/thingdef_parse.cpp index fa2b1beec..42d1f0c04 100644 --- a/src/thingdef/thingdef_parse.cpp +++ b/src/thingdef/thingdef_parse.cpp @@ -924,7 +924,7 @@ static void ParseActionDef (FScanner &sc, PClass *cls) { PSymbolActionFunction *sym = new PSymbolActionFunction(funcname); sym->Arguments = args; - sym->Function = afd->Function; + sym->Function = *(afd->VMPointer); if (hasdefaults) { sym->defaultparameterindex = StateParams.Size(); diff --git a/src/thingdef/thingdef_states.cpp b/src/thingdef/thingdef_states.cpp index 82f8dd28c..a27bd48d3 100644 --- a/src/thingdef/thingdef_states.cpp +++ b/src/thingdef/thingdef_states.cpp @@ -98,7 +98,8 @@ bool DoActionSpecials(FScanner &sc, FState & state, Baggage &bag, FStateTempCall sc.ScriptError ("Too many arguments to %s", specname.GetChars()); } - state.SetAction(FindGlobalActionFunction("A_CallSpecial"), false); + //FIXME + //state.SetAction(FindGlobalActionFunction("A_CallSpecial"), false); return true; } return false; @@ -219,7 +220,6 @@ do_stop: state.sprite = GetSpriteIndex(statestring); state.Misc1 = state.Misc2 = 0; - state.ParameterIndex = 0; sc.MustGetString(); statestring = sc.String; @@ -262,7 +262,6 @@ do_stop: if (sym != NULL && sym->SymbolType == SYM_ActionFunction) { PSymbolActionFunction *afd = static_cast(sym); - state.SetAction(afd, false); if (!afd->Arguments.IsEmpty()) { const char *params = afd->Arguments.GetChars(); @@ -278,7 +277,7 @@ do_stop: { if (!sc.CheckString("(")) { - state.ParameterIndex = afd->defaultparameterindex+1; +// state.ParameterIndex = afd->defaultparameterindex+1; goto endofstate; } } diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index 5f2383fee..aa4af6a3d 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -1291,7 +1291,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE nothing, LPSTR cmdline, int n _CrtSetDbgFlag (_CrtSetDbgFlag(0) | _CRTDBG_LEAK_CHECK_DF); // Use this to break at a specific allocation number. - //_crtBreakAlloc = 5501; + //_crtBreakAlloc = 68843; #endif DoMain (hInstance); diff --git a/src/zscript/vm.h b/src/zscript/vm.h index acb4a0688..21a67188e 100644 --- a/src/zscript/vm.h +++ b/src/zscript/vm.h @@ -313,7 +313,7 @@ struct VMValue int i; struct { void *a; int atag; }; double f; - struct { int pad[3]; int Type; }; + struct { int pad[3]; VM_UBYTE Type; }; struct { int foo[4]; } biggest; }; @@ -784,7 +784,6 @@ public: NativeCallType NativeCall; }; - class VMParamFiller { public: @@ -845,4 +844,75 @@ void VMFillParams(VMValue *params, VMFrame *callee, int numparam); void VMDumpConstants(FILE *out, const VMScriptFunction *func); void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction *func); +// Use this in the prototype for a native function. +#define VM_ARGS VMFrameStack *stack, VMValue *param, int numparam, VMReturn *ret, int numret +#define VM_ARGS_NAMES stack, param, numparam, ret, numret + +// Use these to collect the parameters in a native function. +// variable name at position

+ +// For required parameters. +#define PARAM_INT_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_INT); int x = param[p].i; +#define PARAM_BOOL_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_INT); bool x = !!param[p].i; +#define PARAM_NAME_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_INT); FName x = ENamedName(param[p].i); +#define PARAM_SOUND_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_INT); FSoundID x = param[p].i; +#define PARAM_COLOR_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_INT); PalEntry x; x.d = param[p].i; +#define PARAM_FLOAT_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); double x = param[p].f; +#define PARAM_FIXED_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); fixed_t x = fixed_t(param[p].f * 65536.0); +#define PARAM_ANGLE_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); angle_t x = angle_t(param[p].f * (ANGLE_90 / 90.0)); +#define PARAM_STRING_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_STRING); FString x = param[p].s(); +#define PARAM_STATE_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_STATE || param[p].a == NULL)); FState *x = (FState *)param[p].a; +#define PARAM_POINTER_AT(p,x,type) assert((p) < numparam); assert(param[p].Type == REGT_POINTER); type *x = (type *)param[p].a; +#define PARAM_OBJECT_AT(p,x,type) assert((p) < numparam); assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_OBJECT || param[p].a == NULL)); type *x = (type *)param[p].a; +#define PARAM_CLASS_AT(p,x,base) assert((p) < numparam); assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_OBJECT || param[p].a == NULL)); PClass *x = (PClass *)param[p].a; assert(x->IsDescendantOf(RUNTIME_CLASS(base))); + +// For optional paramaters. These have dangling elses for you to fill in the default assignment. e.g.: +// PARAM_INT_OPT(0,myint) { myint = 55; } +// Just make sure to fill it in when using these macros, because the compiler isn't likely +// to give useful error messages if you don't. +#define PARAM_INT_OPT_AT(p,x) int x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_INT); x = param[p].i; } else +#define PARAM_BOOL_OPT_AT(p,x) bool x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_INT); x = !!param[p].i; } else +#define PARAM_NAME_OPT_AT(p,x) FName x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_INT); x = ENamedName(param[p].i); } else +#define PARAM_SOUND_OPT_AT(p,x) FSoundID x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_INT); x = FSoundID(param[p].i); } else +#define PARAM_COLOR_OPT_AT(p,x) PalEntry x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_INT); x.d = param[p].i; } else +#define PARAM_FLOAT_OPT_AT(p,x) double x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_FLOAT); x = param[p].f; } else +#define PARAM_FIXED_OPT_AT(p,x) fixed_t x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_FLOAT); x = fixed_t(param[p].f * 65536.0); } else +#define PARAM_ANGLE_OPT_AT(p,x) angle_t x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_FLOAT); x = angle_t(param[p].f * (ANGLE_90 / 90.0)); } else +#define PARAM_STRING_OPT_AT(p,x) FString x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_STRING); x = param[p].s(); } else +#define PARAM_STATE_OPT_AT(p,x) FState *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_STATE || param[p].a == NULL)); x = (FState *)param[p].a; } else +#define PARAM_POINTER_OPT_AT(p,x,type) type *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER); x = (type *)param[p].a; } else +#define PARAM_OBJECT_OPT_AT(p,x,type) type *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_OBJECT || param[p].a == NULL)); x = (type *)param[p].a; } else +#define PARAM_CLASS_OPT_AT(p,x,base) PClass *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_OBJECT || param[p].a == NULL)); x = (PClass *)param[p].a; assert(x->IsKindOf(RUNTIME_CLASS(base))); } else + +// The above, but with an automatically increasing position index. +#define PARAM_PROLOGUE int pnum = -1; + +#define PARAM_INT(x) ++pnum; PARAM_INT_AT(pnum,x) +#define PARAM_BOOL(x) ++pnum; PARAM_BOOL_AT(pnum,x) +#define PARAM_NAME(x) ++pnum; PARAM_NAME_AT(pnum,x) +#define PARAM_SOUND(x) ++pnum; PARAM_SOUND_AT(pnum,x) +#define PARAM_COLOR(x) ++pnum; PARAM_COLOR_AT(pnum,x) +#define PARAM_FLOAT(x) ++pnum; PARAM_FLOAT_AT(pnum,x) +#define PARAM_FIXED(x) ++pnum; PARAM_FIXED_AT(pnum,x) +#define PARAM_ANGLE(x) ++pnum; PARAM_ANGLE_AT(pnum,x) +#define PARAM_STRING(x) ++pnum; PARAM_STRING_AT(pnum,x) +#define PARAM_STATE(x) ++pnum; PARAM_STATE_AT(pnum,x) +#define PARAM_POINTER(x,type) ++pnum; PARAM_POINTER_AT(pnum,x,type) +#define PARAM_OBJECT(x,type) ++pnum; PARAM_OBJECT_AT(pnum,x,type) +#define PARAM_CLASS(x,base) ++pnum; PARAM_CLASS_AT(pnum,x,base) + +#define PARAM_INT_OPT(x) ++pnum; PARAM_INT_OPT_AT(pnum,x) +#define PARAM_BOOL_OPT(x) ++pnum; PARAM_BOOL_OPT_AT(pnum,x) +#define PARAM_NAME_OPT(x) ++pnum; PARAM_NAME_OPT_AT(pnum,x) +#define PARAM_SOUND_OPT(x) ++pnum; PARAM_SOUND_OPT_AT(pnum,x) +#define PARAM_COLOR_OPT(x) ++pnum; PARAM_COLOR_OPT_AT(pnum,x) +#define PARAM_FLOAT_OPT(x) ++pnum; PARAM_FLOAT_OPT_AT(pnum,x) +#define PARAM_FIXED_OPT(x) ++pnum; PARAM_FIXED_OPT_AT(pnum,x) +#define PARAM_ANGLE_OPT(x) ++pnum; PARAM_ANGLE_OPT_AT(pnum,x) +#define PARAM_STRING_OPT(x) ++pnum; PARAM_STRING_OPT_AT(pnum,x) +#define PARAM_STATE_OPT(x) ++pnum; PARAM_STATE_OPT_AT(pnum,x) +#define PARAM_POINTER_OPT(x,type) ++pnum; PARAM_POINTER_OPT_AT(pnum,x,type) +#define PARAM_OBJECT_OPT(x,type) ++pnum; PARAM_OBJECT_OPT_AT(pnum,x,type) +#define PARAM_CLASS_OPT(x,base) ++pnum; PARAM_CLASS_OPT_AT(pnum,x,base) + #endif diff --git a/src/zscript/vmexec.cpp b/src/zscript/vmexec.cpp index c05ebca92..21f897d0d 100644 --- a/src/zscript/vmexec.cpp +++ b/src/zscript/vmexec.cpp @@ -138,7 +138,7 @@ void VMSelectEngine(EVMEngine engine) // // VMFillParams // -// Takes parameters from the paramater stack and stores them in the callee's +// Takes parameters from the parameter stack and stores them in the callee's // registers. // //=========================================================================== diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 8f66780ff..0bb53fa0a 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -147,7 +147,7 @@ ACTOR Actor native //: Thinker action native A_BishopMissileWeave(); action native A_CStaffMissileSlither(); action native A_PlayerScream(); - action native A_SkullPop(class skulltype = "BloodySkull"); + action native A_SkullPop(class skulltype = "BloodySkull"); action native A_CheckPlayerDone(); action native A_Wander(); @@ -182,7 +182,7 @@ ACTOR Actor native //: Thinker action native A_Jump(int chance = 256, state label, ...); action native A_CustomMissile(class missiletype, float spawnheight = 32, int spawnofs_xy = 0, float angle = 0, int flags = 0, float pitch = 0); action native A_CustomBulletAttack(float spread_xy, float spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", float range = 0, bool aimfacing = false); - action native A_CustomRailgun(int damage, int spawnofs_xy = 0, color color1 = "", color color2 = "", int flags = 0, bool aim = false, float maxdiff = 0, class pufftype = "BulletPuff"); + action native A_CustomRailgun(int damage, int spawnofs_xy = 0, color color1 = "", color color2 = "", int flags = 0, int aim = 0, float maxdiff = 0, class pufftype = "BulletPuff"); action native A_JumpIfHealthLower(int health, state label); action native A_JumpIfCloser(float distance, state label); action native A_JumpIfInventory(class itemtype, int itemamount, state label); @@ -191,8 +191,8 @@ ACTOR Actor native //: Thinker action native A_TakeInventory(class itemtype, int amount = 0); action native A_SpawnItem(class itemtype = "Unknown", float distance = 0, float zheight = 0, bool useammo = true, bool transfer_translation = false); action native A_SpawnItemEx(class itemtype, float xofs = 0, float yofs = 0, float zofs = 0, float xvel = 0, float yvel = 0, float zvel = 0, float angle = 0, int flags = 0, int failchance = 0); - action native A_Print(string whattoprint, float time = 0, string fontname = ""); - action native A_PrintBold(string whattoprint, float time = 0, string fontname = ""); + action native A_Print(string whattoprint, float time = 0, name fontname = ""); + action native A_PrintBold(string whattoprint, float time = 0, name fontname = ""); action native A_Log(string whattoprint); action native A_SetTranslucent(float alpha, int style = 0); action native A_FadeIn(float reduce = 0.1); diff --git a/wadsrc/static/actors/shared/debris.txt b/wadsrc/static/actors/shared/debris.txt index 5d48a2217..6bb3fccdb 100644 --- a/wadsrc/static/actors/shared/debris.txt +++ b/wadsrc/static/actors/shared/debris.txt @@ -11,7 +11,7 @@ ACTOR Rock1 States { Spawn: - ROKK A 20 + ROKK A 20 A_Log("Test") Loop Death: ROKK A 10 diff --git a/wadsrc/static/actors/shared/inventory.txt b/wadsrc/static/actors/shared/inventory.txt index ca73cab29..359fd51fe 100644 --- a/wadsrc/static/actors/shared/inventory.txt +++ b/wadsrc/static/actors/shared/inventory.txt @@ -10,7 +10,7 @@ ACTOR Inventory native action native A_CustomPunch(int damage, bool norandom = false, bool useammo = true, class pufftype = "BulletPuff", float range = 0); action native A_FireBullets(float spread_xy, float spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", bool useammo = true, float range = 0); action native A_FireCustomMissile(class missiletype, float angle = 0, bool useammo = true, int spawnofs_xy = 0, float spawnheight = 0, bool aimatangle = false, float pitch = 0); - action native A_RailAttack(int damage, int spawnofs_xy = 0, int useammo = true, color color1 = "", color color2 = "", int flags = 0, float maxdiff = 0, class pufftype = "BulletPuff"); + action native A_RailAttack(int damage, int spawnofs_xy = 0, bool useammo = true, color color1 = "", color color2 = "", int flags = 0, float maxdiff = 0, class pufftype = "BulletPuff"); action native A_Light(int extralight); action native A_Light0(); action native A_Light1();