From abc7113e0987c05b109d67d5a9ee1c2b68d26db7 Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Fri, 17 Jun 2016 09:19:30 +0200 Subject: [PATCH 1/4] Removed the INSTATECALL flag because it is now unused and was replaced by stateinfo --- src/actor.h | 2 +- src/thingdef/thingdef_codeptr.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/actor.h b/src/actor.h index 0336c4185..ea4d15ad9 100644 --- a/src/actor.h +++ b/src/actor.h @@ -283,7 +283,7 @@ enum ActorFlag4 enum ActorFlag5 { MF5_DONTDRAIN = 0x00000001, // cannot be drained health from. - MF5_INSTATECALL = 0x00000002, // This actor is being run through CallStateChain + /* FREE SLOT 0x00000002*/ MF5_NODROPOFF = 0x00000004, // cannot drop off under any circumstances. MF5_NOFORWARDFALL = 0x00000008, // Does not make any actor fall forward by being damaged by this MF5_COUNTSECRET = 0x00000010, // From Doom 64: actor acts like a secret diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 77c2fcbd1..e13d3e92f 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -120,7 +120,6 @@ bool ACustomInventory::CallStateChain (AActor *actor, FState *state) ret[0].PointerAt((void **)&nextstate); ret[1].IntAt(&retval); - this->flags5 |= MF5_INSTATECALL; FState *savedstate = this->state; while (state != NULL) @@ -191,7 +190,6 @@ bool ACustomInventory::CallStateChain (AActor *actor, FState *state) } state = nextstate; } - this->flags5 &= ~MF5_INSTATECALL; this->state = savedstate; return !!result; } From 68c483c041f883a95a0ab96579b41f9560666afb Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Fri, 17 Jun 2016 09:26:33 +0200 Subject: [PATCH 2/4] 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 bf95b58be..a35a31b61 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 58ff083ac..f906d247c 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 21ab33dfb..8ad28f098 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 e13d3e92f..7a0dd207e 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) From 24c73071f438cb6d536b27bfdfc79fe2de4c268f Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Fri, 17 Jun 2016 09:35:10 +0200 Subject: [PATCH 3/4] Fixed a crash with A_JumpIfNoAmmo Non-weapon layers can pass the caller check even when there is no ReadyWeapon --- src/thingdef/thingdef_codeptr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 7a0dd207e..610b6b17e 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_PSPRITE()) + if (!ACTION_CALL_FROM_PSPRITE() || self->player->ReadyWeapon == nullptr) { ACTION_RETURN_STATE(NULL); } From 56508a2d820811aaf46ef9dc2c9d4dfdef1ce897 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 17 Jun 2016 23:09:34 +0200 Subject: [PATCH 4/4] - Avoid issues with misused Strife actions. --- src/g_strife/a_strifestuff.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index 983acb1d3..8b5788d44 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -352,18 +352,22 @@ DEFINE_ACTION_FUNCTION(AActor, A_ItBurnsItBurns) if (self->player != nullptr && self->player->mo == self) { - DPSprite *psp = self->player->GetPSprite(PSP_STRIFEHANDS); - if (psp != nullptr) + FState *firehands = self->FindState("FireHands"); + if (firehands != NULL) { - psp->SetState(self->FindState("FireHands")); - psp->Flags &= PSPF_ADDWEAPON | PSPF_ADDBOB; - psp->y = WEAPONTOP; - } + DPSprite *psp = self->player->GetPSprite(PSP_STRIFEHANDS); + if (psp != nullptr) + { + psp->SetState(firehands); + psp->Flags &= PSPF_ADDWEAPON | PSPF_ADDBOB; + psp->y = WEAPONTOP; + } - self->player->ReadyWeapon = nullptr; - self->player->PendingWeapon = WP_NOCHANGE; - self->player->playerstate = PST_LIVE; - self->player->extralight = 3; + self->player->ReadyWeapon = nullptr; + self->player->PendingWeapon = WP_NOCHANGE; + self->player->playerstate = PST_LIVE; + self->player->extralight = 3; + } } return 0; } @@ -388,7 +392,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrispyPlayer) DPSprite *psp; psp = self->player->GetPSprite(PSP_STRIFEHANDS); - psp->SetState(psp->GetState() + (self->FindState("FireHandsLower") - self->FindState("FireHands"))); + FState *firehandslower = self->FindState("FireHandsLower"); + FState *firehands = self->FindState("FireHands"); + if (firehandslower != NULL && firehands != NULL && firehands < firehandslower) + psp->SetState(psp->GetState() + (firehandslower - firehands)); } return 0; }