From a14b0c58bf345d499115ccb1a96a0364c074016b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 27 Nov 2018 00:14:51 +0100 Subject: [PATCH] - re-fixed the massacre fix for Dehacked-modified inventory items. Instead of overriding the Massacre method it is preferable to clear the flags causing the bad behavior, most notably ISMONSTER. # Conflicts: # src/g_inventory/a_pickups.cpp # src/g_inventory/a_pickups.h --- src/d_net.cpp | 15 ++------------- src/g_inventory/a_pickups.cpp | 14 -------------- src/g_inventory/a_pickups.h | 1 - src/p_enemy.cpp | 4 ++-- src/p_enemy.h | 2 +- wadsrc/static/zscript/inventory/inventory.txt | 3 +++ 6 files changed, 8 insertions(+), 31 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index 4c9f09fb3..fcfe4e7d7 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -52,6 +52,7 @@ #include "teaminfo.h" #include "p_conversation.h" #include "d_event.h" +#include "p_enemy.h" #include "m_argv.h" #include "p_lnspec.h" #include "p_spec.h" @@ -2079,19 +2080,7 @@ uint8_t *FDynamicBuffer::GetData (int *len) static int KillAll(PClassActor *cls) { - AActor *actor; - int killcount = 0; - TThinkerIterator iterator(cls); - while ( (actor = iterator.Next ()) ) - { - if (actor->IsA(cls)) - { - if (!(actor->flags2 & MF2_DORMANT) && (actor->flags3 & MF3_ISMONSTER)) - killcount += actor->Massacre (); - } - } - return killcount; - + return P_Massacre(false, cls); } static int RemoveClass(const PClass *cls) diff --git a/src/g_inventory/a_pickups.cpp b/src/g_inventory/a_pickups.cpp index c1bd3c701..53689157a 100644 --- a/src/g_inventory/a_pickups.cpp +++ b/src/g_inventory/a_pickups.cpp @@ -141,20 +141,6 @@ void AInventory::Serialize(FSerializer &arc) ("droptime", DropTime, def->DropTime); } -//=========================================================================== -// -// AInventory :: Massacre -// -// This is a countermeasure for Dehacked modifications mainly. -// -//=========================================================================== - -bool AInventory::Massacre() -{ - if (Owner == nullptr) return Super::Massacre(); - return false; -} - //=========================================================================== // // diff --git a/src/g_inventory/a_pickups.h b/src/g_inventory/a_pickups.h index 61d764c62..4981e81c3 100644 --- a/src/g_inventory/a_pickups.h +++ b/src/g_inventory/a_pickups.h @@ -72,7 +72,6 @@ public: virtual void Serialize(FSerializer &arc) override; virtual void Tick() override; - virtual bool Massacre() override; bool CallTryPickup(AActor *toucher, AActor **toucher_return = NULL); // Wrapper for script function. diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index a54603d8f..21fd6b1c0 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -3465,7 +3465,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BossDeath) // //---------------------------------------------------------------------------- -int P_Massacre (bool baddies) +int P_Massacre (bool baddies, PClassActor *cls) { // jff 02/01/98 'em' cheat - kill all monsters // partially taken from Chi's .46 port @@ -3475,7 +3475,7 @@ int P_Massacre (bool baddies) int killcount = 0; AActor *actor; - TThinkerIterator iterator; + TThinkerIterator iterator(cls); while ( (actor = iterator.Next ()) ) { diff --git a/src/p_enemy.h b/src/p_enemy.h index 4dff6f810..d101fceef 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -67,7 +67,7 @@ void A_FaceTarget(AActor *actor); void A_Face(AActor *self, AActor *other, DAngle max_turn = 0., DAngle max_pitch = 270., DAngle ang_offset = 0., DAngle pitch_offset = 0., int flags = 0, double z_add = 0); bool CheckBossDeath (AActor *); -int P_Massacre (bool baddies = false); +int P_Massacre (bool baddies = false, PClassActor *cls = nullptr); bool P_CheckMissileRange (AActor *actor); #define SKULLSPEED (20.) diff --git a/wadsrc/static/zscript/inventory/inventory.txt b/wadsrc/static/zscript/inventory/inventory.txt index 4898f63ea..c76d7ec9c 100644 --- a/wadsrc/static/zscript/inventory/inventory.txt +++ b/wadsrc/static/zscript/inventory/inventory.txt @@ -212,6 +212,9 @@ class Inventory : Actor native } ChangeTid(0); bSpecial = false; + // if the item was turned into a monster through Dehacked, undo that here. + bCountkill = false; + bIsMonster = false; ChangeStatNum(STAT_INVENTORY); // stop all sounds this item is playing. for(int i = 1;i<=7;i++) A_StopSound(i);