diff --git a/src/d_net.cpp b/src/d_net.cpp index f5ef8aef0..a5b144b86 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2080,11 +2080,6 @@ uint8_t *FDynamicBuffer::GetData (int *len) } -static int KillAll(PClassActor *cls) -{ - return P_Massacre(false, cls); -} - static int RemoveClass(const PClass *cls) { AActor *actor; @@ -2564,11 +2559,11 @@ void Net_DoCommand (int type, uint8_t **stream, int player) if (cls != NULL) { - killcount = KillAll(cls); + killcount = currentUILevel->Massacre(false, cls->TypeName); PClassActor *cls_rep = cls->GetReplacement(); if (cls != cls_rep) { - killcount += KillAll(cls_rep); + killcount += currentUILevel->Massacre(false, cls_rep->TypeName); } Printf ("Killed %d monsters of type %s.\n",killcount, s); } diff --git a/src/g_levellocals.h b/src/g_levellocals.h index e427b15bb..e85877f78 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -203,6 +203,7 @@ public: bool CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line, double speed, double height, int crush, int change, bool hexencrush, bool hereticlower); void DoDeferedScripts(); void AdjustPusher(int tag, int magnitude, int angle, bool wind); + int Massacre(bool baddies = false, FName cls = NAME_None); bool EV_DoPlat(int tag, line_t *line, DPlat::EPlatType type, double height, double speed, int delay, int lip, int change); void EV_StopPlat(int tag, bool remove); diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index 3890e2ea8..3effff3ea 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -319,7 +319,7 @@ void cht_DoCheat (player_t *player, int cheat) case CHT_MASSACRE: case CHT_MASSACRE2: { - int killcount = P_Massacre (cheat == CHT_MASSACRE2); + int killcount = currentUILevel->Massacre (cheat == CHT_MASSACRE2); // killough 3/22/98: make more intelligent about plural // Ty 03/27/98 - string(s) *not* externalized mysnprintf (msgbuild, countof(msgbuild), "%d %s%s Killed", killcount, diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 773313323..aa8eb93d1 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -1201,7 +1201,7 @@ int P_LookForMonsters (AActor *actor) { int count; AActor *mo; - TThinkerIterator iterator; + auto iterator = actor->Level->GetThinkerIterator(); if (!P_CheckSight (players[0].mo, actor, SF_SEEPASTBLOCKEVERYTHING)) { // Player can't see monster @@ -1258,7 +1258,7 @@ AActor *LookForTIDInBlock (AActor *lookee, int index, void *extparams) AActor *link; AActor *other; - for (block = level.blockmap.blocklinks[index]; block != NULL; block = block->NextActor) + for (block = lookee->Level->blockmap.blocklinks[index]; block != NULL; block = block->NextActor) { link = block->Me; @@ -1339,7 +1339,7 @@ int P_LookForTID (AActor *actor, INTBOOL allaround, FLookExParams *params) actor->LastLookActor = nullptr; } - auto iterator = level.GetActorIterator(actor->TIDtoHate, actor->LastLookActor); + auto iterator = actor->Level->GetActorIterator(actor->TIDtoHate, actor->LastLookActor); int c = (pr_look3() & 31) + 7; // Look for between 7 and 38 hatees at a time while ((other = iterator.Next()) != actor->LastLookActor) { @@ -1429,7 +1429,7 @@ AActor *LookForEnemiesInBlock (AActor *lookee, int index, void *extparam) AActor *other; FLookExParams *params = (FLookExParams *)extparam; - for (block = level.blockmap.blocklinks[index]; block != NULL; block = block->NextActor) + for (block = lookee->Level->blockmap.blocklinks[index]; block != NULL; block = block->NextActor) { link = block->Me; @@ -1760,10 +1760,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look) // [RH] Set goal now if appropriate if (self->special == Thing_SetGoal && self->args[0] == 0) { - auto iterator = level.GetActorIterator(NAME_PatrolPoint, self->args[1]); + auto iterator = self->Level->GetActorIterator(NAME_PatrolPoint, self->args[1]); self->special = 0; self->goal = iterator.Next (); - self->reactiontime = self->args[2] * TICRATE + level.maptime; + self->reactiontime = self->args[2] * TICRATE + self->Level->maptime; if (self->args[3] == 0) self->flags5 &= ~MF5_CHASEGOAL; else self->flags5 |= MF5_CHASEGOAL; } @@ -1838,7 +1838,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look) // [RH] Don't start chasing after a goal if it isn't time yet. if (self->target == self->goal) { - if (self->reactiontime > level.maptime) + if (self->reactiontime > self->Level->maptime) self->target = nullptr; } else if (self->SeeSound) @@ -1889,10 +1889,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_LookEx) // [RH] Set goal now if appropriate if (self->special == Thing_SetGoal && self->args[0] == 0) { - auto iterator = level.GetActorIterator(NAME_PatrolPoint, self->args[1]); + auto iterator = self->Level->GetActorIterator(NAME_PatrolPoint, self->args[1]); self->special = 0; self->goal = iterator.Next (); - self->reactiontime = self->args[2] * TICRATE + level.maptime; + self->reactiontime = self->args[2] * TICRATE + self->Level->maptime; if (self->args[3] == 0) self->flags5 &= ~MF5_CHASEGOAL; else @@ -2020,7 +2020,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LookEx) // [RH] Don't start chasing after a goal if it isn't time yet. if (self->target == self->goal) { - if (self->reactiontime > level.maptime) + if (self->reactiontime > self->Level->maptime) self->target = nullptr; } else if (self->SeeSound && !(flags & LOF_NOSEESOUND)) @@ -2150,7 +2150,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look2) if (targ && (targ->flags & MF_SHOOTABLE)) { - if ((level.flags & LEVEL_NOALLIES) || + if ((self->Level->flags & LEVEL_NOALLIES) || (self->flags & MF_FRIENDLY) != (targ->flags & MF_FRIENDLY)) { if (self->flags & MF_AMBUSH) @@ -2372,8 +2372,8 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi if (result) { // reached the goal - auto iterator = level.GetActorIterator(NAME_PatrolPoint, actor->goal->args[0]); - auto specit = level.GetActorIterator(NAME_PatrolSpecial, actor->goal->tid); + auto iterator = actor->Level->GetActorIterator(NAME_PatrolPoint, actor->goal->args[0]); + auto specit = actor->Level->GetActorIterator(NAME_PatrolSpecial, actor->goal->tid); AActor *spec; // Execute the specials of any PatrolSpecials with the same TID @@ -2390,7 +2390,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi if (newgoal != NULL && actor->goal == actor->target) { delay = newgoal->args[1]; - actor->reactiontime = delay * TICRATE + level.maptime; + actor->reactiontime = delay * TICRATE + actor->Level->maptime; } else { @@ -3044,7 +3044,7 @@ int CheckBossDeath (AActor *actor) return false; // no one left alive, so do not end game // Make sure all bosses are dead - TThinkerIterator iterator; + auto iterator = actor->Level->GetThinkerIterator(); AActor *other; while ( (other = iterator.Next ()) ) @@ -3074,7 +3074,7 @@ void A_BossDeath(AActor *self) // Do generic special death actions first bool checked = false; - auto Level = &level; + auto Level = self->Level; for (unsigned i = 0; i < Level->info->specialactions.Size(); i++) { FSpecialAction *sa = &Level->info->specialactions[i]; @@ -3125,7 +3125,7 @@ void A_BossDeath(AActor *self) // victory! if (Level->flags & LEVEL_SPECKILLMONSTERS) { // Kill any remaining monsters - P_Massacre (); + Level->Massacre (); } if (Level->flags & LEVEL_MAP07SPECIAL) { @@ -3174,7 +3174,7 @@ void A_BossDeath(AActor *self) // //---------------------------------------------------------------------------- -int P_Massacre (bool baddies, PClassActor *cls) +int FLevelLocals::Massacre (bool baddies, FName cls) { // jff 02/01/98 'em' cheat - kill all monsters // partially taken from Chi's .46 port @@ -3184,7 +3184,7 @@ int P_Massacre (bool baddies, PClassActor *cls) int killcount = 0; AActor *actor; - TThinkerIterator iterator(cls? cls : RUNTIME_CLASS(AActor)); + auto iterator = GetThinkerIterator(cls); while ( (actor = iterator.Next ()) ) { diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index a2e25d87e..aed5c8a32 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -1510,11 +1510,11 @@ FUNC(LS_Thing_Destroy) if (arg0 == 0 && arg2 == 0) { - P_Massacre (); + Level->Massacre (); } else if (arg0 == 0) { - TThinkerIterator iterator; + auto iterator = Level->GetThinkerIterator(); actor = iterator.Next (); while (actor)