diff --git a/src/actor.h b/src/actor.h index d6657a83e..2436cdaaa 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1422,8 +1422,6 @@ public: int ApplyDamageFactor(FName damagetype, int damage) const; int GetModifiedDamage(FName damagetype, int damage, bool passive); void DeleteAttachedLights(); - static void DeleteAllAttachedLights(); - static void RecreateAllAttachedLights(); bool isFrozen(); bool hasmodel; diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 43f84a0d7..fac4ff6a3 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -945,7 +945,8 @@ static void PrintFilteredActorList(const ActorTypeChecker IsActorType, const cha } } } - TThinkerIterator it; + // This only works on the primary level. + auto it = currentUILevel->GetThinkerIterator(); while ( (mo = it.Next()) ) { diff --git a/src/d_net.cpp b/src/d_net.cpp index 33a6a3f3c..bd7504098 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2080,12 +2080,12 @@ uint8_t *FDynamicBuffer::GetData (int *len) } -static int RemoveClass(const PClass *cls) +static int RemoveClass(FLevelLocals *Level, const PClass *cls) { AActor *actor; int removecount = 0; bool player = false; - TThinkerIterator iterator(cls); + auto iterator = Level->GetThinkerIterator(cls->TypeName); while ((actor = iterator.Next())) { if (actor->IsA(cls)) @@ -2581,11 +2581,11 @@ void Net_DoCommand (int type, uint8_t **stream, int player) PClassActor *cls = PClass::FindActor(s); if (cls != NULL && cls->IsDescendantOf(RUNTIME_CLASS(AActor))) { - removecount = RemoveClass(cls); + removecount = RemoveClass(&level, cls); const PClass *cls_rep = cls->GetReplacement(); if (cls != cls_rep) { - removecount += RemoveClass(cls_rep); + removecount += RemoveClass(&leve, cls_rep); } Printf("Removed %d actors of type %s.\n", removecount, s); } diff --git a/src/g_levellocals.h b/src/g_levellocals.h index a8d1486dc..d4e236b64 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -232,6 +232,9 @@ public: void SecretExitLevel(int position); void DoLoadLevel(const FString &nextmapname, int position, bool autosave, bool newGame); + void DeleteAllAttachedLights(); + void RecreateAllAttachedLights(); + private: // Work data for CollectConnectedGroups. diff --git a/src/g_shared/a_decals.cpp b/src/g_shared/a_decals.cpp index 5546aef08..a0a27aacd 100644 --- a/src/g_shared/a_decals.cpp +++ b/src/g_shared/a_decals.cpp @@ -54,8 +54,6 @@ struct SpreadInfo TArray SpreadStack; }; -static int ImpactCount; - CVAR (Bool, cl_spreaddecals, true, CVAR_ARCHIVE) IMPLEMENT_CLASS(DBaseDecal, false, true) @@ -652,18 +650,16 @@ DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, double ix, doubl CCMD (countdecals) { - Printf ("%d impact decals\n", ImpactCount); -} + for (auto Level : AllLevels()) + { + auto iterator = Level->GetThinkerIterator(NAME_None, STAT_AUTODECAL); + int count = 0; -CCMD (countdecalsreal) -{ - TThinkerIterator iterator (STAT_AUTODECAL); - int count = 0; + while (iterator.Next()) + count++; - while (iterator.Next()) - count++; - - Printf ("Counted %d impact decals\n", count); + Printf("%s: Counted %d impact decals\n", Level->MapName.GetChars(), count); + } } CCMD (spray) diff --git a/src/g_shared/a_dynlight.cpp b/src/g_shared/a_dynlight.cpp index a24a82bfe..92720cddc 100644 --- a/src/g_shared/a_dynlight.cpp +++ b/src/g_shared/a_dynlight.cpp @@ -71,8 +71,11 @@ static FRandom randLight; CUSTOM_CVAR (Bool, gl_lights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { - if (self) AActor::RecreateAllAttachedLights(); - else AActor::DeleteAllAttachedLights(); + for (auto Level : AllLevels()) + { + if (self) Level->RecreateAllAttachedLights(); + else Level->DeleteAllAttachedLights(); + } } CVAR (Bool, gl_attachedlights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); @@ -833,9 +836,9 @@ void AActor::DeleteAttachedLights() // //========================================================================== -void AActor::DeleteAllAttachedLights() +void FLevelLocals::DeleteAllAttachedLights() { - TThinkerIterator it; + auto it = GetThinkerIterator(); AActor * a; while ((a=it.Next())) @@ -850,9 +853,9 @@ void AActor::DeleteAllAttachedLights() // //========================================================================== -void AActor::RecreateAllAttachedLights() +void FLevelLocals::RecreateAllAttachedLights() { - TThinkerIterator it; + auto it = GetThinkerIterator(); AActor * a; while ((a=it.Next())) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 00a4f3460..38a0ad604 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -116,7 +116,6 @@ void FGLRenderer::Initialize(int width, int height) FGLRenderer::~FGLRenderer() { FlushModels(); - AActor::DeleteAllAttachedLights(); TexMan.FlushAll(); if (mShaderManager != nullptr) delete mShaderManager; if (mSamplerManager != nullptr) delete mSamplerManager; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index a51343c7f..23d685677 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -2213,6 +2213,7 @@ bool FBehavior::Init(FLevelLocals *Level, int lumpnum, FileReader * fr, int len) uint8_t *object; int i; + this->Level = Level; LumpNum = lumpnum; // Now that everything is set up, record this module as being among the loaded modules. @@ -3270,7 +3271,7 @@ void FBehavior::StartTypedScripts (uint16_t type, AActor *activator, bool always ptr = &Scripts[i]; if (ptr->Type == type) { - DLevelScript *runningScript = P_GetScriptGoing (&level, activator, NULL, ptr->Number, + DLevelScript *runningScript = P_GetScriptGoing (Level, activator, NULL, ptr->Number, ptr, this, &arg1, 1, always ? ACS_ALWAYS : 0); if (nullptr != runningScript && runNow) { diff --git a/src/p_acs.h b/src/p_acs.h index 7eea0c22a..6fae24de9 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -387,6 +387,7 @@ private: ACSFormat Format; + FLevelLocals *Level; int LumpNum; uint8_t *Data; int DataSize; diff --git a/src/p_effect.cpp b/src/p_effect.cpp index a621d1961..20312ced3 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -329,7 +329,7 @@ void P_RunEffects (FLevelLocals *Level) int pnum = players[consoleplayer].camera->Sector->Index() * Level->sectors.Size(); AActor *actor; - TThinkerIterator iterator; + auto iterator = Level->GetThinkerIterator(); while ( (actor = iterator.Next ()) ) {