diff --git a/src/actor.h b/src/actor.h index 68eda132b6..15439e7676 100644 --- a/src/actor.h +++ b/src/actor.h @@ -739,7 +739,7 @@ public: if (bloodcls != NULL) { - bloodcls = bloodcls->ActorInfo->GetReplacement()->Class; + bloodcls = bloodcls->GetReplacement(); } return bloodcls; } diff --git a/src/d_net.cpp b/src/d_net.cpp index 9979199634..be592b238a 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -1917,6 +1917,22 @@ BYTE *FDynamicBuffer::GetData (int *len) } +static int KillAll(const PClass *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; + +} // [RH] Execute a special "ticcmd". The type byte should // have already been read, and the stream is positioned // at the beginning of the command's actual data. @@ -2348,18 +2364,17 @@ void Net_DoCommand (int type, BYTE **stream, int player) case DEM_KILLCLASSCHEAT: { - AActor *actor; - TThinkerIterator iterator; - char *classname = ReadString (stream); int killcount = 0; + const PClass *cls = PClass::FindClass(classname); - while ( (actor = iterator.Next ()) ) + if (classname != NULL) { - if (!stricmp (actor->GetClass ()->TypeName.GetChars (), classname)) + killcount = KillAll(cls); + const PClass *cls_rep = cls->GetReplacement(); + if (cls != cls_rep) { - if (!(actor->flags2 & MF2_DORMANT) && (actor->flags3 & MF3_ISMONSTER)) - killcount += actor->Massacre (); + killcount += KillAll(cls_rep); } } diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index cdac259025..f232d81f2b 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -486,6 +486,11 @@ const PClass *PClass::NativeClass() const return cls; } +PClass *PClass::GetReplacement() const +{ + return ActorInfo->GetReplacement()->Class; +} + // Symbol tables ------------------------------------------------------------ PSymbol::~PSymbol() diff --git a/src/dobjtype.h b/src/dobjtype.h index dd35e7e47d..e019299012 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -174,6 +174,7 @@ struct PClass static const PClass *FindClass (ENamedName name) { return FindClass (FName (name)); } static const PClass *FindClass (FName name); const PClass *FindClassTentative (FName name); // not static! + PClass *GetReplacement() const; static TArray m_Types; static TArray m_RuntimeActors; diff --git a/src/g_shared/a_randomspawner.cpp b/src/g_shared/a_randomspawner.cpp index 67bd4b84a2..4c1b5b964c 100644 --- a/src/g_shared/a_randomspawner.cpp +++ b/src/g_shared/a_randomspawner.cpp @@ -71,7 +71,7 @@ class ARandomSpawner : public AActor cls = PClass::FindClass(di->Name); if (cls != NULL) { - const PClass *rep = cls->ActorInfo->GetReplacement()->Class; + const PClass *rep = cls->GetReplacement(); if (rep != NULL) { cls = rep; diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index 0a7928a912..9da1b1ff5f 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -754,8 +754,8 @@ void cht_Give (player_t *player, const char *name, int amount) // Don't give replaced weapons unless the replacement was done by Dehacked. if (type != RUNTIME_CLASS(AWeapon) && type->IsDescendantOf (RUNTIME_CLASS(AWeapon)) && - (type->ActorInfo->GetReplacement() == type->ActorInfo || - type->ActorInfo->GetReplacement()->Class->IsDescendantOf(RUNTIME_CLASS(ADehackedPickup)))) + (type->GetReplacement() == type || + type->GetReplacement()->IsDescendantOf(RUNTIME_CLASS(ADehackedPickup)))) { // Give the weapon only if it belongs to the current game or diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 4aeb0595fd..f04cfbdffe 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -2136,7 +2136,7 @@ do_count: { // Again, with decorate replacements replacemented = true; - PClass *newkind = kind->ActorInfo->GetReplacement()->Class; + PClass *newkind = kind->GetReplacement(); if (newkind != kind) { kind = newkind; diff --git a/src/p_map.cpp b/src/p_map.cpp index 2d105c284c..06483c44e8 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -3352,7 +3352,7 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, (t1->player->ReadyWeapon->flags2 & MF2_THRUGHOST)); // We need to check the defaults of the replacement here - AActor *puffDefaults = GetDefaultByType(pufftype->ActorInfo->GetReplacement()->Class); + AActor *puffDefaults = GetDefaultByType(pufftype->GetReplacement()); // if the puff uses a non-standard damage type this will override default and melee damage type. // All other explicitly passed damage types (currenty only MDK) will be preserved. @@ -3819,7 +3819,7 @@ void P_RailAttack (AActor *source, int damage, int offset, int color1, int color int flags; AActor *puffDefaults = puffclass == NULL? - NULL : GetDefaultByType (puffclass->ActorInfo->GetReplacement()->Class); + NULL : GetDefaultByType (puffclass->GetReplacement()); if (puffDefaults != NULL && puffDefaults->flags6 & MF6_NOTRIGGER) flags = 0; else flags = TRACE_PCross|TRACE_Impact; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 85ca7662e8..9dfa8d5ca2 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1011,7 +1011,7 @@ bool AActor::Grind(bool items) if (i != NULL) { - i = i->ActorInfo->GetReplacement()->Class; + i = i->GetReplacement(); const AActor *defaults = GetDefaultByType (i); if (defaults->SpawnState == NULL || @@ -3461,7 +3461,7 @@ AActor *AActor::StaticSpawn (const PClass *type, fixed_t ix, fixed_t iy, fixed_t } if (allowreplacement) - type = type->ActorInfo->GetReplacement()->Class; + type = type->GetReplacement(); AActor *actor; @@ -4297,7 +4297,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) { // Handle decorate replacements explicitly here // to check for missing frames in the replacement object. - i = i->ActorInfo->GetReplacement()->Class; + i = i->GetReplacement(); const AActor *defaults = GetDefaultByType (i); if (defaults->SpawnState == NULL || diff --git a/src/p_things.cpp b/src/p_things.cpp index cd1540f4fc..6622ac0a78 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -65,7 +65,7 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, angle_t angle, bool fog, return false; // Handle decorate replacements. - kind = kind->ActorInfo->GetReplacement()->Class; + kind = kind->GetReplacement(); if ((GetDefaultByType (kind)->flags3 & MF3_ISMONSTER) && ((dmflags & DF_NO_MONSTERS) || (level.flags2 & LEVEL2_NOMONSTERS))) @@ -200,7 +200,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam // Handle decorate replacements. - kind = kind->ActorInfo->GetReplacement()->Class; + kind = kind->GetReplacement(); defflags3 = GetDefaultByType (kind)->flags3; if ((defflags3 & MF3_ISMONSTER) &&