From 68c483c041f883a95a0ab96579b41f9560666afb Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Fri, 17 Jun 2016 09:26:33 +0200 Subject: [PATCH] Renamed the weapon action function caller check to ACTION_CALL_FROM_PSPRITE to avoid confusion This was always checking for every psprites rather than just weapon layers --- src/g_doom/a_doomweaps.cpp | 28 ++++++++++++++-------------- src/g_hexen/a_blastradius.cpp | 2 +- src/thingdef/thingdef.h | 2 +- src/thingdef/thingdef_codeptr.cpp | 16 ++++++++-------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index bf95b58be0..a35a31b61f 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -38,7 +38,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch) if (self->player != NULL) { AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != NULL && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_WEAPON()) + if (weapon != NULL && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire)) return 0; @@ -76,7 +76,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePistol) if (self->player != nullptr) { AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != nullptr && ACTION_CALL_FROM_WEAPON()) + if (weapon != nullptr && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) return 0; @@ -160,7 +160,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw) slope = P_AimLineAttack (self, angle, range, &t) + spread_z * (pr_saw.Random2() / 255.); AWeapon *weapon = self->player->ReadyWeapon; - if ((weapon != NULL) && !(flags & SF_NOUSEAMMO) && !(!t.linetarget && (flags & SF_NOUSEAMMOMISS)) && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_WEAPON()) + if ((weapon != NULL) && !(flags & SF_NOUSEAMMO) && !(!t.linetarget && (flags & SF_NOUSEAMMOMISS)) && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire)) return 0; @@ -269,7 +269,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun) S_Sound (self, CHAN_WEAPON, "weapons/shotgf", 1, ATTN_NORM); AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != nullptr && ACTION_CALL_FROM_WEAPON()) + if (weapon != nullptr && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) return 0; @@ -305,7 +305,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2) S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM); AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != nullptr && ACTION_CALL_FROM_WEAPON()) + if (weapon != nullptr && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, 2)) return 0; @@ -421,7 +421,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCGun) } AWeapon *weapon = player->ReadyWeapon; - if (weapon != nullptr && ACTION_CALL_FROM_WEAPON()) + if (weapon != nullptr && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) return 0; @@ -465,7 +465,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMissile) return 0; } AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != NULL && ACTION_CALL_FROM_WEAPON()) + if (weapon != NULL && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) return 0; @@ -492,7 +492,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireSTGrenade) return 0; } AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != NULL && ACTION_CALL_FROM_WEAPON()) + if (weapon != NULL && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire)) return 0; @@ -520,7 +520,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePlasma) return 0; } AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != NULL && ACTION_CALL_FROM_WEAPON()) + if (weapon != NULL && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) return 0; @@ -575,21 +575,21 @@ static void FireRailgun(AActor *self, int offset_xy, bool fromweapon) DEFINE_ACTION_FUNCTION(AActor, A_FireRailgun) { PARAM_ACTION_PROLOGUE; - FireRailgun(self, 0, ACTION_CALL_FROM_WEAPON()); + FireRailgun(self, 0, ACTION_CALL_FROM_PSPRITE()); return 0; } DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunRight) { PARAM_ACTION_PROLOGUE; - FireRailgun(self, 10, ACTION_CALL_FROM_WEAPON()); + FireRailgun(self, 10, ACTION_CALL_FROM_PSPRITE()); return 0; } DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunLeft) { PARAM_ACTION_PROLOGUE; - FireRailgun(self, -10, ACTION_CALL_FROM_WEAPON()); + FireRailgun(self, -10, ACTION_CALL_FROM_PSPRITE()); return 0; } @@ -615,7 +615,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireBFG) } AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != NULL && ACTION_CALL_FROM_WEAPON()) + if (weapon != NULL && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, deh.BFGCells)) return 0; @@ -751,7 +751,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireOldBFG) } AWeapon *weapon = self->player->ReadyWeapon; - if (!ACTION_CALL_FROM_WEAPON()) weapon = NULL; + if (!ACTION_CALL_FROM_PSPRITE()) weapon = NULL; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) diff --git a/src/g_hexen/a_blastradius.cpp b/src/g_hexen/a_blastradius.cpp index 58ff083acc..f906d247c1 100644 --- a/src/g_hexen/a_blastradius.cpp +++ b/src/g_hexen/a_blastradius.cpp @@ -106,7 +106,7 @@ DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_Blast) AActor *mo; TThinkerIterator iterator; - if (self->player && (blastflags & BF_USEAMMO) && ACTION_CALL_FROM_WEAPON()) + if (self->player && (blastflags & BF_USEAMMO) && ACTION_CALL_FROM_PSPRITE()) { AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL && !weapon->DepleteAmmo(weapon->bAltFire)) diff --git a/src/thingdef/thingdef.h b/src/thingdef/thingdef.h index 21ab33dfb0..8ad28f0985 100644 --- a/src/thingdef/thingdef.h +++ b/src/thingdef/thingdef.h @@ -361,6 +361,6 @@ int MatchString (const char *in, const char **strings); // Checks to see what called the current action function #define ACTION_CALL_FROM_ACTOR() (stateinfo == nullptr || stateinfo->mStateType == STATE_Actor) -#define ACTION_CALL_FROM_WEAPON() (self->player && stateinfo != nullptr && stateinfo->mStateType == STATE_Psprite) +#define ACTION_CALL_FROM_PSPRITE() (self->player && stateinfo != nullptr && stateinfo->mStateType == STATE_Psprite) #define ACTION_CALL_FROM_INVENTORY() (stateinfo != nullptr && stateinfo->mStateType == STATE_StateChain) #endif diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index e13d3e92fe..7a0dd207ee 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1740,7 +1740,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfNoAmmo) PARAM_ACTION_PROLOGUE; PARAM_STATE(jump); - if (!ACTION_CALL_FROM_WEAPON()) + if (!ACTION_CALL_FROM_PSPRITE()) { ACTION_RETURN_STATE(NULL); } @@ -1789,7 +1789,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) DAngle bslope = 0.; int laflags = (flags & FBF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0; - if ((flags & FBF_USEAMMO) && weapon && ACTION_CALL_FROM_WEAPON()) + if ((flags & FBF_USEAMMO) && weapon && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return 0; // out of ammo @@ -1880,7 +1880,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile) FTranslatedLineTarget t; // Only use ammo if called from a weapon - if (useammo && ACTION_CALL_FROM_WEAPON() && weapon) + if (useammo && ACTION_CALL_FROM_PSPRITE() && weapon) { if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return 0; // out of ammo @@ -1972,7 +1972,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch) pitch = P_AimLineAttack (self, angle, range, &t); // only use ammo when actually hitting something! - if ((flags & CPF_USEAMMO) && t.linetarget && weapon && ACTION_CALL_FROM_WEAPON()) + if ((flags & CPF_USEAMMO) && t.linetarget && weapon && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return 0; // out of ammo @@ -2073,7 +2073,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack) AWeapon *weapon = self->player->ReadyWeapon; // only use ammo when actually hitting something! - if (useammo && weapon != NULL && ACTION_CALL_FROM_WEAPON()) + if (useammo && weapon != NULL && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return 0; // out of ammo @@ -2660,7 +2660,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem) ACTION_RETURN_BOOL(true); } - if (ACTION_CALL_FROM_WEAPON()) + if (ACTION_CALL_FROM_PSPRITE()) { // Used from a weapon, so use some ammo AWeapon *weapon = self->player->ReadyWeapon; @@ -2785,7 +2785,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade) { ACTION_RETURN_BOOL(true); } - if (ACTION_CALL_FROM_WEAPON()) + if (ACTION_CALL_FROM_PSPRITE()) { // Used from a weapon, so use some ammo AWeapon *weapon = self->player->ReadyWeapon; @@ -5838,7 +5838,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTics) PARAM_ACTION_PROLOGUE; PARAM_INT(tics_to_set); - if (ACTION_CALL_FROM_WEAPON()) + if (ACTION_CALL_FROM_PSPRITE()) { DPSprite *pspr = self->player->FindPSprite(stateinfo->mPSPIndex); if (pspr != nullptr)