From 1b1e2ef7d287a5f65eafbb37c809aa94ad2c4cca Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 11 Jan 2019 01:43:43 +0100 Subject: [PATCH] - added a level parameter to the thinker iterator. Not used yet, but will be when the thinker lists are moved into FLevelLocals. --- src/am_map.cpp | 8 ++-- src/b_think.cpp | 2 +- src/c_cmds.cpp | 45 ++++++++++++++----- src/d_net.cpp | 8 ++-- src/dthinker.cpp | 4 +- src/dthinker.h | 21 ++++----- src/events.cpp | 2 +- src/fragglescript/t_func.cpp | 8 ++-- src/fragglescript/t_prepro.cpp | 4 +- src/g_game.cpp | 10 +++-- src/g_level.cpp | 6 +-- src/g_shared/a_decals.cpp | 22 +++++---- src/g_shared/a_dynlight.cpp | 40 ++++++++++------- src/g_shared/a_lightning.cpp | 10 ++--- src/g_shared/a_lightning.h | 2 +- src/g_shared/a_quake.cpp | 2 +- src/p_acs.cpp | 4 +- src/p_actionfunctions.cpp | 20 ++++----- src/p_ceiling.cpp | 4 +- src/p_effect.cpp | 2 +- src/p_enemy.cpp | 25 ++++++----- src/p_lights.cpp | 2 +- src/p_lnspec.cpp | 4 +- src/p_map.cpp | 2 +- src/p_mobj.cpp | 2 +- src/p_plats.cpp | 4 +- src/p_pusher.cpp | 2 +- src/p_scroll.cpp | 6 +-- src/p_setup.cpp | 4 +- src/p_spec.cpp | 4 +- src/p_switch.cpp | 2 +- src/p_teleport.cpp | 2 +- src/p_things.cpp | 2 +- src/p_tick.cpp | 2 +- src/p_xlat.cpp | 2 +- src/portal.cpp | 2 +- src/s_sound.cpp | 2 +- src/scripting/backend/codegen.cpp | 2 +- src/scripting/vmiterators.cpp | 14 +++--- src/statistics.cpp | 2 +- wadsrc/static/zscript/actor_inventory.txt | 8 ++-- wadsrc/static/zscript/base.txt | 6 ++- wadsrc/static/zscript/doom/bossbrain.txt | 2 +- wadsrc/static/zscript/doom/keen.txt | 2 +- wadsrc/static/zscript/doom/painelemental.txt | 2 +- wadsrc/static/zscript/hexen/blastradius.txt | 2 +- wadsrc/static/zscript/raven/minotaur.txt | 4 +- wadsrc/static/zscript/shared/bridge.txt | 2 +- .../static/zscript/shared/soundsequence.txt | 2 +- .../static/zscript/strife/alienspectres.txt | 2 +- wadsrc/static/zscript/strife/oracle.txt | 2 +- wadsrc/static/zscript/strife/strifeitems.txt | 2 +- wadsrc/static/zscript/strife/svestuff.txt | 2 +- 53 files changed, 197 insertions(+), 152 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 811d62876b..e630081046 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -2941,13 +2941,13 @@ void AM_drawPlayers () // //============================================================================= -void AM_drawKeys () +void AM_drawKeys (FLevelLocals *Level) { AMColor color; mpoint_t p; DAngle angle; - TThinkerIterator it(NAME_Key); + TThinkerIterator it(Level, NAME_Key); AActor *key; while ((key = it.Next()) != NULL) @@ -3171,7 +3171,7 @@ void AM_drawAuthorMarkers (FLevelLocals *Level) // [RH] Draw any actors derived from AMapMarker on the automap. // If args[0] is 0, then the actor's sprite is drawn at its own location. // Otherwise, its sprite is drawn at the location of any actors whose TIDs match args[0]. - TThinkerIterator it ("MapMarker", STAT_MAPMARKER); + TThinkerIterator it (Level, "MapMarker", STAT_MAPMARKER); AActor *mark; while ((mark = it.Next()) != NULL) @@ -3289,7 +3289,7 @@ void AM_Drawer (FLevelLocals *Level, int bottom) AM_drawWalls(Level, allmap); AM_drawPlayers(); if (G_SkillProperty(SKILLP_EasyKey)) - AM_drawKeys(); + AM_drawKeys(Level); if ((am_cheat >= 2 && am_cheat != 4) || allthings) AM_drawThings(Level); diff --git a/src/b_think.cpp b/src/b_think.cpp index 82954d83e1..04d33cc054 100644 --- a/src/b_think.cpp +++ b/src/b_think.cpp @@ -289,7 +289,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd) r = pr_botmove(); if (r < 128) { - TThinkerIterator it (NAME_Inventory, MAX_STATNUM+1, bglobal.firstthing); + TThinkerIterator it (player->mo->Level, NAME_Inventory, MAX_STATNUM+1, bglobal.firstthing); auto item = it.Next(); if (item != NULL || (item = it.Next()) != NULL) diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 812c17bb3c..9fae6e720e 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -919,13 +919,14 @@ static bool IsActor(AActor *mo) } // [SP] modified - now allows showing count only, new arg must be passed. Also now still counts regardless, if lists are printed. -static void PrintFilteredActorList(const ActorTypeChecker IsActorType, const char *FilterName, bool countOnly) +static void PrintFilteredActorList(FLevelLocals *Level, const ActorTypeChecker IsActorType, const char *FilterName, bool countOnly) { AActor *mo; const PClass *FilterClass = NULL; int counter = 0; int tid = 0; + Printf("%s:\n", Level->MapName.GetChars()); if (FilterName != NULL) { FilterClass = PClass::FindActor(FilterName); @@ -940,7 +941,7 @@ static void PrintFilteredActorList(const ActorTypeChecker IsActorType, const cha } } } - TThinkerIterator it; + TThinkerIterator it(Level); while ( (mo = it.Next()) ) { @@ -972,14 +973,20 @@ CCMD(actorlist) // [SP] print all actors (this can get quite big?) { if (CheckCheatmode ()) return; - PrintFilteredActorList(IsActor, argv.argc() > 1 ? argv[1] : NULL, false); + ForAllLevels([&](FLevelLocals *Level) + { + PrintFilteredActorList(Level, IsActor, argv.argc() > 1 ? argv[1] : NULL, false); + }); } CCMD(actornum) // [SP] count all actors { if (CheckCheatmode ()) return; - PrintFilteredActorList(IsActor, argv.argc() > 1 ? argv[1] : NULL, true); + ForAllLevels([&](FLevelLocals *Level) + { + PrintFilteredActorList(Level, IsActor, argv.argc() > 1 ? argv[1] : NULL, true); + }); } //----------------------------------------------------------------------------- @@ -991,14 +998,20 @@ CCMD(monster) { if (CheckCheatmode ()) return; - PrintFilteredActorList(IsActorAMonster, argv.argc() > 1 ? argv[1] : NULL, false); + ForAllLevels([&](FLevelLocals *Level) + { + PrintFilteredActorList(Level, IsActorAMonster, argv.argc() > 1 ? argv[1] : NULL, false); + }); } CCMD(monsternum) // [SP] count monsters { if (CheckCheatmode ()) return; - PrintFilteredActorList(IsActorAMonster, argv.argc() > 1 ? argv[1] : NULL, true); + ForAllLevels([&](FLevelLocals *Level) + { + PrintFilteredActorList(Level, IsActorAMonster, argv.argc() > 1 ? argv[1] : NULL, true); + }); } //----------------------------------------------------------------------------- @@ -1010,14 +1023,20 @@ CCMD(items) { if (CheckCheatmode ()) return; - PrintFilteredActorList(IsActorAnItem, argv.argc() > 1 ? argv[1] : NULL, false); + ForAllLevels([&](FLevelLocals *Level) + { + PrintFilteredActorList(Level, IsActorAnItem, argv.argc() > 1 ? argv[1] : NULL, false); + }); } CCMD(itemsnum) // [SP] # of any items { if (CheckCheatmode ()) return; - PrintFilteredActorList(IsActorAnItem, argv.argc() > 1 ? argv[1] : NULL, true); + ForAllLevels([&](FLevelLocals *Level) + { + PrintFilteredActorList(Level, IsActorAnItem, argv.argc() > 1 ? argv[1] : NULL, true); + }); } //----------------------------------------------------------------------------- @@ -1029,14 +1048,20 @@ CCMD(countitems) { if (CheckCheatmode ()) return; - PrintFilteredActorList(IsActorACountItem, argv.argc() > 1 ? argv[1] : NULL, false); + ForAllLevels([&](FLevelLocals *Level) + { + PrintFilteredActorList(Level, IsActorACountItem, argv.argc() > 1 ? argv[1] : NULL, false); + }); } CCMD(countitemsnum) // [SP] # of counted items { if (CheckCheatmode ()) return; - PrintFilteredActorList(IsActorACountItem, argv.argc() > 1 ? argv[1] : NULL, true); + ForAllLevels([&](FLevelLocals *Level) + { + PrintFilteredActorList(Level, IsActorACountItem, argv.argc() > 1 ? argv[1] : NULL, true); + }); } //----------------------------------------------------------------------------- diff --git a/src/d_net.cpp b/src/d_net.cpp index 094b3ee66d..34ac2f1b1e 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2085,12 +2085,12 @@ static int KillAll(PClassActor *cls) return P_Massacre(false, cls); } -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); + TThinkerIterator iterator(Level, cls); while ((actor = iterator.Next())) { if (actor->IsA(cls)) @@ -2589,11 +2589,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(players[player].mo->Level, cls); const PClass *cls_rep = cls->GetReplacement(); if (cls != cls_rep) { - removecount += RemoveClass(cls_rep); + removecount += RemoveClass(players[player].mo->Level, cls_rep); } Printf("Removed %d actors of type %s.\n", removecount, s); } diff --git a/src/dthinker.cpp b/src/dthinker.cpp index 5c9badfae9..674d16e0ed 100644 --- a/src/dthinker.cpp +++ b/src/dthinker.cpp @@ -878,7 +878,7 @@ size_t DThinker::PropagateMark() // //========================================================================== -FThinkerIterator::FThinkerIterator (const PClass *type, int statnum) +FThinkerIterator::FThinkerIterator (FLevelLocals *Level, const PClass *type, int statnum) { if ((unsigned)statnum > MAX_STATNUM) { @@ -901,7 +901,7 @@ FThinkerIterator::FThinkerIterator (const PClass *type, int statnum) // //========================================================================== -FThinkerIterator::FThinkerIterator (const PClass *type, int statnum, DThinker *prev) +FThinkerIterator::FThinkerIterator (FLevelLocals *Level, const PClass *type, int statnum, DThinker *prev) { if ((unsigned)statnum > MAX_STATNUM) { diff --git a/src/dthinker.h b/src/dthinker.h index a22b6de544..43d89b33fc 100644 --- a/src/dthinker.h +++ b/src/dthinker.h @@ -128,10 +128,11 @@ private: uint8_t m_Stat; bool m_SearchStats; bool m_SearchingFresh; + FLevelLocals *Level; public: - FThinkerIterator (const PClass *type, int statnum=MAX_STATNUM+1); - FThinkerIterator (const PClass *type, int statnum, DThinker *prev); + FThinkerIterator (FLevelLocals *Level, const PClass *type, int statnum=MAX_STATNUM+1); + FThinkerIterator (FLevelLocals *Level, const PClass *type, int statnum, DThinker *prev); DThinker *Next (bool exact = false); void Reinit (); @@ -142,28 +143,28 @@ protected: template class TThinkerIterator : public FThinkerIterator { public: - TThinkerIterator (int statnum=MAX_STATNUM+1) : FThinkerIterator (RUNTIME_CLASS(T), statnum) + TThinkerIterator (FLevelLocals *Level, int statnum=MAX_STATNUM+1) : FThinkerIterator (Level, RUNTIME_CLASS(T), statnum) { } - TThinkerIterator (int statnum, DThinker *prev) : FThinkerIterator (RUNTIME_CLASS(T), statnum, prev) + TThinkerIterator (FLevelLocals *Level, int statnum, DThinker *prev) : FThinkerIterator (Level, RUNTIME_CLASS(T), statnum, prev) { } - TThinkerIterator (const PClass *subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(subclass, statnum) + TThinkerIterator (FLevelLocals *Level, const PClass *subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(Level, subclass, statnum) { } - TThinkerIterator (FName subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(PClass::FindClass(subclass), statnum) + TThinkerIterator (FLevelLocals *Level, FName subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(Level, PClass::FindClass(subclass), statnum) { } - TThinkerIterator (ENamedName subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(PClass::FindClass(subclass), statnum) + TThinkerIterator (FLevelLocals *Level, ENamedName subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(Level, PClass::FindClass(subclass), statnum) { } - TThinkerIterator (FName subclass, int statnum, DThinker *prev) : FThinkerIterator(PClass::FindClass(subclass), statnum, prev) + TThinkerIterator (FLevelLocals *Level, FName subclass, int statnum, DThinker *prev) : FThinkerIterator(Level, PClass::FindClass(subclass), statnum, prev) { } - TThinkerIterator (ENamedName subclass, int statnum, DThinker *prev) : FThinkerIterator(PClass::FindClass(subclass), statnum, prev) + TThinkerIterator (FLevelLocals *Level, ENamedName subclass, int statnum, DThinker *prev) : FThinkerIterator(Level, PClass::FindClass(subclass), statnum, prev) { } - TThinkerIterator (const char *subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(PClass::FindClass(subclass), statnum) + TThinkerIterator (FLevelLocals *Level, const char *subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(Level, PClass::FindClass(subclass), statnum) { } T *Next (bool exact = false) diff --git a/src/events.cpp b/src/events.cpp index 86595f19dc..7499c57137 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -712,7 +712,7 @@ static FWorldEvent E_SetupWorldEvent() { FWorldEvent e; e.IsSaveGame = savegamerestore; - e.IsReopen = currentSession->Levelinfo[0]->FromSnapshot && !savegamerestore; // each one by itself isnt helpful, but with hub load we have savegamerestore==0 and level.FromSnapshot==1. + e.IsReopen = currentSession->Levelinfo[0]->FromSnapshot && !savegamerestore; // each one by itself isnt helpful, but with hub load we have savegamerestore==0 and FromSnapshot==1. e.DamageAngle = 0.0; return e; } diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 1985433554..4214cf7ac4 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -2098,7 +2098,7 @@ void FParser::SF_LineTrigger() mld.special=intvalue(t_argv[0]); mld.tag=t_argc > 1 ? intvalue(t_argv[1]) : 0; P_TranslateLineDef(&line, &mld); - P_ExecuteSpecial(line.special, NULL, Script->trigger, false, + P_ExecuteSpecial(Level, line.special, NULL, Script->trigger, false, line.args[0],line.args[1],line.args[2],line.args[3],line.args[4]); } } @@ -3645,7 +3645,7 @@ void FParser::SF_ThingCount(void) pClass = pClass->GetReplacement(); again: - TThinkerIterator it; + TThinkerIterator it(Level); if (t_argc<2 || intvalue(t_argv[1])==0 || pClass->IsDescendantOf(NAME_Inventory)) { @@ -3786,7 +3786,7 @@ void FParser::SF_KillInSector() { if (CheckArgs(1)) { - TThinkerIterator it; + TThinkerIterator it(Level); AActor * mo; int tag=intvalue(t_argv[0]); @@ -3848,7 +3848,7 @@ void FParser::RunLineSpecial(const FLineSpecial *spec) if (t_argc>i) args[i]=intvalue(t_argv[i]); else args[i] = 0; } - t_return.value.i = P_ExecuteSpecial(spec->number, NULL,Script->trigger,false, args[0],args[1],args[2],args[3],args[4]); + t_return.value.i = P_ExecuteSpecial(Level, spec->number, NULL,Script->trigger,false, args[0],args[1],args[2],args[3],args[4]); } } diff --git a/src/fragglescript/t_prepro.cpp b/src/fragglescript/t_prepro.cpp index d5667d7c7b..b692bdece7 100644 --- a/src/fragglescript/t_prepro.cpp +++ b/src/fragglescript/t_prepro.cpp @@ -339,7 +339,7 @@ void DFsScript::DryRunScript() char *rover = data; // allocate space for the tokens - FParser parse(&level, this); + FParser parse(Level, this); try { while(rover < end && *rover) @@ -429,7 +429,7 @@ void DFsScript::ParseInclude(char *lumpname) ProcessFindChar(lump, 0); // now parse the lump - FParser parse(&level, this); + FParser parse(Level, this); parse.Run(lump, lump, lump+lumplen); // free the lump diff --git a/src/g_game.cpp b/src/g_game.cpp index 6650763cdd..28faf69a9f 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1103,7 +1103,7 @@ void G_Ticker () uint32_t rngsum = FRandom::StaticSumSeeds (); //Added by MC: For some of that bot stuff. The main bot function. - bglobal.Main (&level); + bglobal.Main (currentSession->Levelinfo[0]); for (i = 0; i < MAXPLAYERS; i++) { @@ -1429,7 +1429,7 @@ static FPlayerStart *SelectRandomDeathmatchSpot (FLevelLocals *Level, int player DEFINE_ACTION_FUNCTION(DObject, G_PickDeathmatchStart) { PARAM_PROLOGUE; - auto Level = &level; + auto Level = currentSession->Levelinfo[0]; unsigned int selections = Level->deathmatchstarts.Size(); DVector3 pos; int angle; @@ -1600,7 +1600,7 @@ static void G_QueueBody (AActor *body) EXTERN_CVAR(Bool, sv_singleplayerrespawn) void G_DoReborn (int playernum, bool freshbot) { - auto Level = &level; + auto Level = currentSession->Levelinfo[0]; if (!multiplayer && !(Level->flags2 & LEVEL2_ALLOWRESPAWN) && !sv_singleplayerrespawn && !G_SkillProperty(SKILLP_PlayerRespawn)) { @@ -2718,10 +2718,12 @@ void G_DoPlayDemo (void) { G_InitNew (mapname, false); } - else if (level.sectors.Size() == 0) + /* + else if (!currentSession || currenlevel.sectors.Size() == 0) { I_Error("Cannot play demo without its savegame\n"); } + */ C_HideConsole (); demonew = false; precache = true; diff --git a/src/g_level.cpp b/src/g_level.cpp index 09c713b567..893293355d 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -387,7 +387,7 @@ void G_NewInit () int i; // Destory all old player refrences that may still exist - TThinkerIterator it(NAME_PlayerPawn, STAT_TRAVELLING); + TThinkerIterator it(currentSession->Levelinfo[0], NAME_PlayerPawn, STAT_TRAVELLING); AActor *pawn, *next; next = it.Next(); @@ -1380,7 +1380,7 @@ void G_StartTravel () int G_FinishTravel () { - TThinkerIterator it (NAME_PlayerPawn, STAT_TRAVELLING); + TThinkerIterator it (currentSession->Levelinfo[0], NAME_PlayerPawn, STAT_TRAVELLING); AActor *pawn, *pawndup, *oldpawn, *next; AActor *inv; FPlayerStart *start; @@ -1744,7 +1744,7 @@ void G_UnSnapshotLevel (bool hubLoad) arc.SetLevel(nullptr); level.FromSnapshot = true; - TThinkerIterator it(NAME_PlayerPawn); + TThinkerIterator it(currentSession->Levelinfo[0], NAME_PlayerPawn); AActor *pawn, *next; next = it.Next(); diff --git a/src/g_shared/a_decals.cpp b/src/g_shared/a_decals.cpp index c7a70e3b5c..03a7d3cfbc 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) @@ -675,18 +673,24 @@ DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, double ix, doubl CCMD (countdecals) { - Printf ("%d impact decals\n", ImpactCount); + ForAllLevels([](FLevelLocals *Level) + { + Printf("%d impact decals\n", Level->ImpactDecalCount); + }); } -CCMD (countdecalsreal) +CCMD(countdecalsreal) { - TThinkerIterator iterator (STAT_AUTODECAL); - int count = 0; + ForAllLevels([](FLevelLocals *Level) + { + TThinkerIterator iterator(Level, STAT_AUTODECAL); + int count = 0; - while (iterator.Next()) - count++; + while (iterator.Next()) + count++; - Printf ("Counted %d impact decals\n", count); + Printf("Counted %d impact decals\n", count); + }); } CCMD (spray) diff --git a/src/g_shared/a_dynlight.cpp b/src/g_shared/a_dynlight.cpp index d9bab1e7da..399dd9b17e 100644 --- a/src/g_shared/a_dynlight.cpp +++ b/src/g_shared/a_dynlight.cpp @@ -835,13 +835,16 @@ void AActor::DeleteAttachedLights() void AActor::DeleteAllAttachedLights() { - TThinkerIterator it; - AActor * a; - - while ((a=it.Next())) + ForAllLevels([](FLevelLocals *Level) { - a->DeleteAttachedLights(); - } + TThinkerIterator it(Level); + AActor * a; + + while ((a = it.Next())) + { + a->DeleteAttachedLights(); + } + }); } //========================================================================== @@ -852,20 +855,23 @@ void AActor::DeleteAllAttachedLights() void AActor::RecreateAllAttachedLights() { - TThinkerIterator it; - AActor * a; - - while ((a=it.Next())) + ForAllLevels([](FLevelLocals *Level) { - if (a->IsKindOf(NAME_DynamicLight)) + TThinkerIterator it(Level); + AActor * a; + + while ((a = it.Next())) { - ::AttachLight(a); + if (a->IsKindOf(NAME_DynamicLight)) + { + ::AttachLight(a); + } + else + { + a->SetDynamicLights(); + } } - else - { - a->SetDynamicLights(); - } - } + }); } //========================================================================== diff --git a/src/g_shared/a_lightning.cpp b/src/g_shared/a_lightning.cpp index a23934b6e1..ec519605ae 100644 --- a/src/g_shared/a_lightning.cpp +++ b/src/g_shared/a_lightning.cpp @@ -197,9 +197,9 @@ void DLightningThinker::ForceLightning (int mode) } } -static DLightningThinker *LocateLightning () +static DLightningThinker *LocateLightning (FLevelLocals *Level) { - TThinkerIterator iterator (STAT_LIGHTNING); + TThinkerIterator iterator (Level, STAT_LIGHTNING); return iterator.Next (); } @@ -231,16 +231,16 @@ void P_StartLightning (FLevelLocals *Level) } } - DLightningThinker *lightning = LocateLightning (); + DLightningThinker *lightning = LocateLightning (Level); if (lightning == NULL) { Create(); } } -void P_ForceLightning (int mode) +void P_ForceLightning (FLevelLocals *Level, int mode) { - DLightningThinker *lightning = LocateLightning (); + DLightningThinker *lightning = LocateLightning (Level); if (lightning == NULL) { lightning = Create(); diff --git a/src/g_shared/a_lightning.h b/src/g_shared/a_lightning.h index cbc277c8f3..845902cd5a 100644 --- a/src/g_shared/a_lightning.h +++ b/src/g_shared/a_lightning.h @@ -28,6 +28,6 @@ protected: }; void P_StartLightning (FLevelLocals *Level); -void P_ForceLightning (int mode); +void P_ForceLightning (FLevelLocals *Level, int mode); #endif //__A_LIGHTNING_H__ diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 5c35ef7676..9e3e170a8d 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -300,7 +300,7 @@ int DEarthquake::StaticGetQuakeIntensities(double ticFrac, AActor *victim, FQuak return 0; } - TThinkerIterator iterator(STAT_EARTHQUAKE); + TThinkerIterator iterator(victim->Level, STAT_EARTHQUAKE); DEarthquake *quake; int count = 0; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 831d6a86a6..089a2a2357 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -3639,7 +3639,7 @@ do_count: } else { - TThinkerIterator iterator; + TThinkerIterator iterator(Level); while ( (actor = iterator.Next ()) ) { if (actor->health > 0 && @@ -9364,7 +9364,7 @@ scriptwait: case PCD_CANCELFADE: { - TThinkerIterator iterator; + TThinkerIterator iterator(Level); DFlashFader *fader; while ( (fader = iterator.Next()) ) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 0734cc9fef..c47b6e4788 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -2663,7 +2663,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseChildren) PARAM_SELF_PROLOGUE(AActor); PARAM_INT(flags); - TThinkerIterator it; + TThinkerIterator it(self->Level); AActor *mo; while ((mo = it.Next()) != NULL) @@ -2686,7 +2686,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseSiblings) PARAM_SELF_PROLOGUE(AActor); PARAM_INT(flags); - TThinkerIterator it; + TThinkerIterator it(self->Level); AActor *mo; if (self->master != NULL) @@ -3288,7 +3288,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LineEffect) { oldjunk.tag = tag; // Sector tag for linedef P_TranslateLineDef(&junk, &oldjunk); // Turn into native type - res = !!P_ExecuteSpecial(junk.special, NULL, self, false, junk.args[0], + res = !!P_ExecuteSpecial(self->Level, junk.special, NULL, self, false, junk.args[0], junk.args[1], junk.args[2], junk.args[3], junk.args[4]); if (res && !(junk.flags & ML_REPEAT_SPECIAL)) // If only once, self->flags6 |= MF6_LINEDONE; // no more for this thing @@ -3696,7 +3696,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RadiusGive) int given = 0; if (flags & RGF_MISSILES) { - TThinkerIterator it; + TThinkerIterator it(self->Level); while ((thing = it.Next()) && ((unlimited) || (given < limit))) { given += DoRadiusGive(self, thing, item, amount, distance, flags, filter, species, mindist); @@ -3925,7 +3925,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DamageChildren) AActor *source = COPY_AAPTR(self, src); AActor *inflictor = COPY_AAPTR(self, inflict); - TThinkerIterator it; + TThinkerIterator it(self->Level); AActor *mo; while ( (mo = it.Next()) ) @@ -3955,7 +3955,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DamageSiblings) AActor *source = COPY_AAPTR(self, src); AActor *inflictor = COPY_AAPTR(self, inflict); - TThinkerIterator it; + TThinkerIterator it(self->Level); AActor *mo; if (self->master != NULL) @@ -4106,7 +4106,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KillChildren) AActor *source = COPY_AAPTR(self, src); AActor *inflictor = COPY_AAPTR(self, inflict); - TThinkerIterator it; + TThinkerIterator it(self->Level); AActor *mo; while ( (mo = it.Next()) ) @@ -4137,7 +4137,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KillSiblings) AActor *source = COPY_AAPTR(self, src); AActor *inflictor = COPY_AAPTR(self, inflict); - TThinkerIterator it; + TThinkerIterator it(self->Level); AActor *mo; if (self->master != NULL) @@ -4265,7 +4265,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RemoveChildren) PARAM_CLASS(filter, AActor); PARAM_NAME(species); - TThinkerIterator it; + TThinkerIterator it(self->Level); AActor *mo; while ((mo = it.Next()) != NULL) @@ -4291,7 +4291,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RemoveSiblings) PARAM_CLASS(filter, AActor); PARAM_NAME(species); - TThinkerIterator it; + TThinkerIterator it(self->Level); AActor *mo; if (self->master != NULL) diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp index a1b112e08e..a2886c5124 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -539,7 +539,7 @@ bool EV_DoCeiling (FLevelLocals *Level, DCeiling::ECeiling type, line_t *line, void P_ActivateInStasisCeiling (FLevelLocals *Level, int tag) { DCeiling *scan; - TThinkerIterator iterator; + TThinkerIterator iterator(Level); while ( (scan = iterator.Next ()) ) { @@ -563,7 +563,7 @@ bool EV_CeilingCrushStop (FLevelLocals *Level, int tag, bool remove) { bool rtn = false; DCeiling *scan; - TThinkerIterator iterator; + TThinkerIterator iterator(Level); scan = iterator.Next(); while (scan != nullptr) diff --git a/src/p_effect.cpp b/src/p_effect.cpp index 1166d8e83a..dbbf51e6d3 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -326,7 +326,7 @@ void P_RunEffects (FLevelLocals *Level) int pnum = players[consoleplayer].camera->Sector->Index() * Level->sectors.Size(); AActor *actor; - TThinkerIterator iterator; + TThinkerIterator iterator(Level); while ( (actor = iterator.Next ()) ) { diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 326634a47c..feb4da30ef 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; + TThinkerIterator iterator(actor->Level); if (!P_CheckSight (players[0].mo, actor, SF_SEEPASTBLOCKEVERYTHING)) { // Player can't see monster @@ -2389,7 +2389,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi // as the goal. while ( (spec = specit.Next()) ) { - P_ExecuteSpecial(spec->special, NULL, actor, false, spec->args[0], + P_ExecuteSpecial(actor->Level, spec->special, NULL, actor, false, spec->args[0], spec->args[1], spec->args[2], spec->args[3], spec->args[4]); } @@ -3053,7 +3053,7 @@ int CheckBossDeath (AActor *actor) return false; // no one left alive, so do not end game // Make sure all bosses are dead - TThinkerIterator iterator; + TThinkerIterator iterator(actor->Level); AActor *other; while ( (other = iterator.Next ()) ) @@ -3096,7 +3096,7 @@ void A_BossDeath(AActor *self) } checked = true; - P_ExecuteSpecial(sa->Action, NULL, self, false, + P_ExecuteSpecial(self->Level, sa->Action, NULL, self, false, sa->Args[0], sa->Args[1], sa->Args[2], sa->Args[3], sa->Args[4]); } } @@ -3192,16 +3192,19 @@ int P_Massacre (bool baddies, PClassActor *cls) // fixed lost soul bug (LSs left behind when PEs are killed) int killcount = 0; - AActor *actor; - TThinkerIterator iterator(cls? cls : RUNTIME_CLASS(AActor)); - - while ( (actor = iterator.Next ()) ) + ForAllLevels([&](FLevelLocals *Level) { - if (!(actor->flags2 & MF2_DORMANT) && (actor->flags3 & MF3_ISMONSTER) && (!baddies || !(actor->flags & MF_FRIENDLY))) + AActor *actor; + TThinkerIterator iterator(Level, cls ? cls : RUNTIME_CLASS(AActor)); + + while ((actor = iterator.Next())) { - killcount += actor->Massacre(); + if (!(actor->flags2 & MF2_DORMANT) && (actor->flags3 & MF3_ISMONSTER) && (!baddies || !(actor->flags & MF_FRIENDLY))) + { + killcount += actor->Massacre(); + } } - } + }); return killcount; } diff --git a/src/p_lights.cpp b/src/p_lights.cpp index af34820b15..f945dc36fc 100644 --- a/src/p_lights.cpp +++ b/src/p_lights.cpp @@ -984,7 +984,7 @@ DPhased::DPhased (sector_t *sector, int baselevel, int phase) void EV_StopLightEffect (FLevelLocals *Level, int tag) { - TThinkerIterator iterator; + TThinkerIterator iterator(Level); DLighting *effect; while ((effect = iterator.Next()) != NULL) diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 5df36503c1..ffad736c88 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -1515,7 +1515,7 @@ FUNC(LS_Thing_Destroy) } else if (arg0 == 0) { - TThinkerIterator iterator; + TThinkerIterator iterator(Level); actor = iterator.Next (); while (actor) @@ -2070,7 +2070,7 @@ FUNC(LS_Elevator_LowerToNearest) FUNC(LS_Light_ForceLightning) // Light_ForceLightning (mode) { - P_ForceLightning (arg0); + P_ForceLightning (Level, arg0); return true; } diff --git a/src/p_map.cpp b/src/p_map.cpp index cac17d2ea8..4bf518b1e1 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -6836,7 +6836,7 @@ bool P_ActivateThingSpecial(AActor * thing, AActor * trigger, bool death) // Run the special, if any if (thing->special) { - res = !!P_ExecuteSpecial(thing->special, NULL, + res = !!P_ExecuteSpecial(thing->Level, thing->special, NULL, // TriggerActs overrides the level flag, which only concerns thing activated by death (((death && Level->flags & LEVEL_ACTOWNSPECIAL && !(thing->activationtype & THINGSPEC_TriggerActs)) || (thing->activationtype & THINGSPEC_ThingActs)) // Who triggers? diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 58ae72ab9e..f2a6cc9cb4 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5153,7 +5153,7 @@ AActor *P_SpawnPlayer (FLevelLocals *Level, FPlayerStart *mthing, int playernum, // monsters who last targeted this player will wake up immediately // after the player has respawned. AActor *th; - TThinkerIterator it; + TThinkerIterator it(Level); while ((th = it.Next())) { if (th->LastHeard == oldactor) th->LastHeard = nullptr; diff --git a/src/p_plats.cpp b/src/p_plats.cpp index 5afd0853b4..2345458873 100644 --- a/src/p_plats.cpp +++ b/src/p_plats.cpp @@ -403,7 +403,7 @@ void DPlat::Reactivate () void P_ActivateInStasis (FLevelLocals *Level, int tag) { DPlat *scan; - TThinkerIterator iterator; + TThinkerIterator iterator(Level); while ( (scan = iterator.Next ()) ) { @@ -421,7 +421,7 @@ void DPlat::Stop () void EV_StopPlat (FLevelLocals *Level, int tag, bool remove) { DPlat *scan; - TThinkerIterator iterator; + TThinkerIterator iterator(Level); scan = iterator.Next(); while (scan != nullptr) diff --git a/src/p_pusher.cpp b/src/p_pusher.cpp index 6868a1273b..d03c39cc22 100644 --- a/src/p_pusher.cpp +++ b/src/p_pusher.cpp @@ -422,7 +422,7 @@ void AdjustPusher (FLevelLocals *Level, int tag, int magnitude, int angle, bool // Find pushers already attached to the sector, and change their parameters. TArray Collection; { - TThinkerIterator iterator; + TThinkerIterator iterator(Level); FThinkerCollection collect; while ( (collect.Obj = iterator.Next ()) ) diff --git a/src/p_scroll.cpp b/src/p_scroll.cpp index fb93ce573e..d4fa3835b5 100644 --- a/src/p_scroll.cpp +++ b/src/p_scroll.cpp @@ -640,7 +640,7 @@ void SetWallScroller (FLevelLocals *Level, int id, int sidechoice, double dx, do if (dx == 0 && dy == 0) { // Special case: Remove the scroller, because the deltas are both 0. - TThinkerIterator iterator (STAT_SCROLLER); + TThinkerIterator iterator (Level, STAT_SCROLLER); DScroller *scroller; while ( (scroller = iterator.Next ()) ) @@ -659,7 +659,7 @@ void SetWallScroller (FLevelLocals *Level, int id, int sidechoice, double dx, do // their rates. TArray Collection; { - TThinkerIterator iterator (STAT_SCROLLER); + TThinkerIterator iterator (Level, STAT_SCROLLER); DScroller *scroll; while ( (scroll = iterator.Next ()) ) @@ -698,7 +698,7 @@ void SetWallScroller (FLevelLocals *Level, int id, int sidechoice, double dx, do void SetScroller (FLevelLocals *Level, int tag, EScroll type, double dx, double dy) { - TThinkerIterator iterator (STAT_SCROLLER); + TThinkerIterator iterator (Level, STAT_SCROLLER); DScroller *scroller; int i; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 89dbcfcd5a..e5f69e860b 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -138,7 +138,7 @@ static void PrecacheLevel(FLevelLocals *Level) memset(hitlist.Data(), 0, cnt); AActor *actor; - TThinkerIterator iterator; + TThinkerIterator iterator(Level); while ((actor = iterator.Next())) { @@ -480,7 +480,7 @@ void P_SetupLevel(FLevelLocals *Level, const char *lumpname, int position, bool // Don't count monsters in end-of-level sectors if option is on if (dmflags2 & DF2_NOCOUNTENDMONST) { - TThinkerIterator it; + TThinkerIterator it(Level); AActor * mo; while ((mo = it.Next())) diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 7b45db4f1c..0f1c72c682 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -924,7 +924,7 @@ static void SetupCeilingPortal (AActor *point) void P_SetupPortals(FLevelLocals *Level) { - TThinkerIterator it("StackPoint"); + TThinkerIterator it(Level, "StackPoint"); AActor *pt; TArray points; @@ -1306,7 +1306,7 @@ void P_SpawnSpecials (MapLoader *ml) P_SpawnFriction(Level); // phares 3/12/98: New friction model using linedefs P_SpawnPushers(Level); // phares 3/20/98: New pusher model using linedefs - TThinkerIterator it2("SkyCamCompat"); + TThinkerIterator it2(Level, "SkyCamCompat"); AActor *pt2; while ((pt2 = it2.Next())) { diff --git a/src/p_switch.cpp b/src/p_switch.cpp index c50cc70ae7..7b7e76aa68 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -86,7 +86,7 @@ protected: static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, const DVector2 &pos, bool useagain) { DActiveButton *button; - TThinkerIterator iterator; + TThinkerIterator iterator(side->sector->Level); // See if button is already pressed while ( (button = iterator.Next ()) ) diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 062c0e2af7..47802410a0 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -317,7 +317,7 @@ static AActor *SelectTeleDest (FLevelLocals *Level, int tid, int tag, bool noran // teleport destination. This means if 50 sectors have a matching tag and // only the last one has a destination, *every* actor is scanned at least 49 // times. Yuck. - TThinkerIterator it2(NAME_TeleportDest); + TThinkerIterator it2(Level, NAME_TeleportDest); while ((searcher = it2.Next()) != NULL) { if (searcher->Sector == &Level->sectors[secnum]) diff --git a/src/p_things.cpp b/src/p_things.cpp index 2a5806ed2b..c430cfdf7c 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -754,7 +754,7 @@ int P_Thing_CheckProximity(AActor *self, PClass *classname, double distance, int const bool ptrWillChange = !!(flags & (CPXF_SETTARGET | CPXF_SETMASTER | CPXF_SETTRACER)); const bool ptrDistPref = !!(flags & (CPXF_CLOSEST | CPXF_FARTHEST)); - TThinkerIterator it; + TThinkerIterator it(self->Level); AActor *mo, *dist = nullptr; // [MC] Process of elimination, I think, will get through this as quickly and diff --git a/src/p_tick.cpp b/src/p_tick.cpp index 85e23de987..01bb119e5e 100644 --- a/src/p_tick.cpp +++ b/src/p_tick.cpp @@ -117,7 +117,7 @@ void P_Ticker (void) } // Reset all actor interpolations for all actors before the current thinking turn so that indirect actor movement gets properly interpolated. - TThinkerIterator it; + TThinkerIterator it(Level); AActor *ac; while ((ac = it.Next())) diff --git a/src/p_xlat.cpp b/src/p_xlat.cpp index 7b13a08ce6..5b6a4a5218 100644 --- a/src/p_xlat.cpp +++ b/src/p_xlat.cpp @@ -299,7 +299,7 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid) void FLevelLocals::TranslateTeleportThings () { AActor *dest; - TThinkerIterator iterator(NAME_TeleportDest); + TThinkerIterator iterator(this, NAME_TeleportDest); bool foundSomething = false; while ( (dest = iterator.Next()) ) diff --git a/src/portal.cpp b/src/portal.cpp index d9e76dadab..60f9cab36f 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -1141,7 +1141,7 @@ void P_CreateLinkedPortals(FLevelLocals *Level) if (Level->linkedPortals.Size() > 0) { // We need to relink all actors that may touch a linked line portal - TThinkerIterator it; + TThinkerIterator it(Level); AActor *actor; while ((actor = it.Next())) { diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 879a2fcbea..4104809e20 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -488,7 +488,7 @@ void S_PrecacheLevel (TArray &levelsounds) } AActor *actor; - TThinkerIterator iterator; + TThinkerIterator iterator(SoundMainLevel); // Precache all sounds known to be used by the currently spawned actors. while ( (actor = iterator.Next()) != NULL ) diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index 1078b3d6cb..ace2eca1ad 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -8624,7 +8624,7 @@ FxExpression *FxActionSpecialCall::Resolve(FCompileContext& ctx) int BuiltinCallLineSpecial(int special, AActor *activator, int arg1, int arg2, int arg3, int arg4, int arg5) { - return P_ExecuteSpecial(activator ? activator->Level : currentSession->LevelInfo[0], special, nullptr, activator, 0, arg1, arg2, arg3, arg4, arg5); + return P_ExecuteSpecial(activator ? activator->Level : currentSession->Levelinfo[0], special, nullptr, activator, 0, arg1, arg2, arg3, arg4, arg5); } DEFINE_ACTION_FUNCTION_NATIVE(DObject, BuiltinCallLineSpecial, BuiltinCallLineSpecial) diff --git a/src/scripting/vmiterators.cpp b/src/scripting/vmiterators.cpp index dab686e1ff..1042067f5a 100644 --- a/src/scripting/vmiterators.cpp +++ b/src/scripting/vmiterators.cpp @@ -42,25 +42,25 @@ class DThinkerIterator : public DObject, public FThinkerIterator DECLARE_ABSTRACT_CLASS(DThinkerIterator, DObject) public: - DThinkerIterator(PClass *cls, int statnum = MAX_STATNUM + 1) - : FThinkerIterator(cls, statnum) + DThinkerIterator(FLevelLocals *Level, PClass *cls, int statnum = MAX_STATNUM + 1) + : FThinkerIterator(Level, cls, statnum) { } }; IMPLEMENT_CLASS(DThinkerIterator, true, false); -static DThinkerIterator *CreateThinkerIterator(PClass *type, int statnum) +static DThinkerIterator *CreateThinkerIterator(FLevelLocals *Level, PClass *type, int statnum) { - return Create(type, statnum); + return Create(Level, type, statnum); } -DEFINE_ACTION_FUNCTION_NATIVE(DThinkerIterator, Create, CreateThinkerIterator) +DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, CreateThinkerIterator, CreateThinkerIterator) { - PARAM_PROLOGUE; + PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); PARAM_CLASS(type, DThinker); PARAM_INT(statnum); - ACTION_RETURN_OBJECT(Create(type, statnum)); + ACTION_RETURN_OBJECT(CreateThinkerIterator(self, type, statnum)); } static DThinker *NextThinker(DThinkerIterator *self, bool exact) diff --git a/src/statistics.cpp b/src/statistics.cpp index 6c3a9c80e8..bc08f86ec1 100644 --- a/src/statistics.cpp +++ b/src/statistics.cpp @@ -413,7 +413,7 @@ static void StoreLevelStats(FLevelLocals *Level) // Check for living monsters. On some maps it can happen // that the counter misses some. - TThinkerIterator it; + TThinkerIterator it(Level); AActor *ac; int mc = 0; diff --git a/wadsrc/static/zscript/actor_inventory.txt b/wadsrc/static/zscript/actor_inventory.txt index a75fca5b61..4fd514ed75 100644 --- a/wadsrc/static/zscript/actor_inventory.txt +++ b/wadsrc/static/zscript/actor_inventory.txt @@ -457,7 +457,7 @@ extend class Actor int A_GiveToChildren(class itemtype, int amount = 0) { - let it = ThinkerIterator.Create('Actor'); + let it = Level.CreateThinkerIterator('Actor'); Actor mo; int count = 0; @@ -473,7 +473,7 @@ extend class Actor int A_GiveToSiblings(class itemtype, int amount = 0) { - let it = ThinkerIterator.Create('Actor'); + let it = Level.CreateThinkerIterator('Actor'); Actor mo; int count = 0; @@ -528,7 +528,7 @@ extend class Actor int A_TakeFromChildren(class itemtype, int amount = 0) { - let it = ThinkerIterator.Create('Actor'); + let it = Level.CreateThinkerIterator('Actor'); Actor mo; int count = 0; @@ -544,7 +544,7 @@ extend class Actor int A_TakeFromSiblings(class itemtype, int amount = 0) { - let it = ThinkerIterator.Create('Actor'); + let it = Level.CreateThinkerIterator('Actor'); Actor mo; int count = 0; diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index cef0a289f5..4ae1ce79b5 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -479,7 +479,10 @@ class Thinker : Object native play class ThinkerIterator : Object native { - native static ThinkerIterator Create(class type = "Actor", int statnum=Thinker.MAX_STATNUM+1); + deprecated("3.8") static ThinkerIterator Create(class type = "Actor", int statnum=Thinker.MAX_STATNUM+1) + { + return currentSession.LevelInfo[0].CreateThinkerIterator(type, statnum); + } native Thinker Next(bool exact = false); native void Reinit(); } @@ -758,6 +761,7 @@ struct LevelLocals native native SectorTagIterator CreateSectorTagIterator(int tag, line defline = null); native LineIdIterator CreateLineIdIterator(int tag); native ActorIterator CreateActorIterator(int tid, class type = "Actor"); + native ThinkerIterator CreateThinkerIterator(class type = "Actor", int statnum=Thinker.MAX_STATNUM+1); String TimeFormatted(bool totals = false) diff --git a/wadsrc/static/zscript/doom/bossbrain.txt b/wadsrc/static/zscript/doom/bossbrain.txt index 4bd10e4e77..9ed794093b 100644 --- a/wadsrc/static/zscript/doom/bossbrain.txt +++ b/wadsrc/static/zscript/doom/bossbrain.txt @@ -194,7 +194,7 @@ extend class Actor if (sv_killbossmonst) { int count; // Repeat until we have no more boss-spawned monsters. - ThinkerIterator it = ThinkerIterator.Create("Actor"); + ThinkerIterator it = Level.CreateThinkerIterator("Actor"); do // (e.g. Pain Elementals can spawn more to kill upon death.) { Actor mo; diff --git a/wadsrc/static/zscript/doom/keen.txt b/wadsrc/static/zscript/doom/keen.txt index 083df92b48..e2eee03c75 100644 --- a/wadsrc/static/zscript/doom/keen.txt +++ b/wadsrc/static/zscript/doom/keen.txt @@ -64,7 +64,7 @@ extend class Actor A_NoBlocking(false); // scan the remaining thinkers to see if all Keens are dead - ThinkerIterator it = ThinkerIterator.Create(GetClass()); + ThinkerIterator it = Level.CreateThinkerIterator(GetClass()); Actor mo; while (mo = Actor(it.Next(true))) { diff --git a/wadsrc/static/zscript/doom/painelemental.txt b/wadsrc/static/zscript/doom/painelemental.txt index 7995eae1be..8c4b0cdf61 100644 --- a/wadsrc/static/zscript/doom/painelemental.txt +++ b/wadsrc/static/zscript/doom/painelemental.txt @@ -96,7 +96,7 @@ extend class Actor // count total number of skulls currently on the level // if there are already 21 skulls on the level, don't spit another one int count = limit; - ThinkerIterator it = ThinkerIterator.Create(spawntype); + ThinkerIterator it = Level.CreateThinkerIterator(spawntype); Thinker othink; while ( (othink = it.Next ()) ) diff --git a/wadsrc/static/zscript/hexen/blastradius.txt b/wadsrc/static/zscript/hexen/blastradius.txt index 0f50948922..8dfe2526af 100644 --- a/wadsrc/static/zscript/hexen/blastradius.txt +++ b/wadsrc/static/zscript/hexen/blastradius.txt @@ -119,7 +119,7 @@ extend class Actor { SoundAlert (self); } - ThinkerIterator it = ThinkerIterator.Create("Actor"); + ThinkerIterator it = Level.CreateThinkerIterator("Actor"); Actor mo; while ( (mo = Actor(it.Next ())) ) { diff --git a/wadsrc/static/zscript/raven/minotaur.txt b/wadsrc/static/zscript/raven/minotaur.txt index 47fa38a2c2..e5b42c1e5d 100644 --- a/wadsrc/static/zscript/raven/minotaur.txt +++ b/wadsrc/static/zscript/raven/minotaur.txt @@ -472,7 +472,7 @@ class Minotaur : Actor if (!target) // Normal monster search { - ThinkerIterator it = ThinkerIterator.Create("Actor"); + ThinkerIterator it = Level.CreateThinkerIterator("Actor"); while ((mo = Actor(it.Next())) != null) { @@ -619,7 +619,7 @@ class MinotaurFriend : Minotaur if (tracer && tracer.health > 0 && tracer.player) { // Search thinker list for minotaur - ThinkerIterator it = ThinkerIterator.Create("MinotaurFriend"); + ThinkerIterator it = Level.CreateThinkerIterator("MinotaurFriend"); MinotaurFriend mo; while ((mo = MinotaurFriend(it.Next())) != null) diff --git a/wadsrc/static/zscript/shared/bridge.txt b/wadsrc/static/zscript/shared/bridge.txt index cbaf49925c..43e876c91b 100644 --- a/wadsrc/static/zscript/shared/bridge.txt +++ b/wadsrc/static/zscript/shared/bridge.txt @@ -121,7 +121,7 @@ class CustomBridge : Actor // But this is not safe with custom bridge balls that do not necessarily call that function. // So the best course of action is to look for all bridge balls here and destroy them ourselves. - let it = ThinkerIterator.Create("Actor"); + let it = Level.CreateThinkerIterator("Actor"); Actor thing; while ((thing = Actor(it.Next()))) diff --git a/wadsrc/static/zscript/shared/soundsequence.txt b/wadsrc/static/zscript/shared/soundsequence.txt index 9f2d0c3d70..04c4bc3286 100644 --- a/wadsrc/static/zscript/shared/soundsequence.txt +++ b/wadsrc/static/zscript/shared/soundsequence.txt @@ -139,7 +139,7 @@ class SoundSequence : Actor if (slot != 'none') { // This is a slotted sound, so add it to the master for that slot SoundSequenceSlot master; - let locator = ThinkerIterator.Create("SoundSequenceSlot"); + let locator = Level.CreateThinkerIterator("SoundSequenceSlot"); while ((master = SoundSequenceSlot(locator.Next ()))) { diff --git a/wadsrc/static/zscript/strife/alienspectres.txt b/wadsrc/static/zscript/strife/alienspectres.txt index 726c8a05e8..ba9343a8e2 100644 --- a/wadsrc/static/zscript/strife/alienspectres.txt +++ b/wadsrc/static/zscript/strife/alienspectres.txt @@ -116,7 +116,7 @@ class AlienSpectre1 : SpectralMonster { Console.MidPrint("SmallFont", "$TXT_KILLED_ORACLE"); // If there are any Oracles still alive, kill them. - ThinkerIterator it = ThinkerIterator.Create("Oracle"); + ThinkerIterator it = Level.CreateThinkerIterator("Oracle"); Actor oracle; while ( (oracle = Actor(it.Next())) != null) diff --git a/wadsrc/static/zscript/strife/oracle.txt b/wadsrc/static/zscript/strife/oracle.txt index 740a7b69a3..7e4017b6ba 100644 --- a/wadsrc/static/zscript/strife/oracle.txt +++ b/wadsrc/static/zscript/strife/oracle.txt @@ -36,7 +36,7 @@ class Oracle : Actor void A_WakeOracleSpectre () { - ThinkerIterator it = ThinkerIterator.Create("AlienSpectre3"); + ThinkerIterator it = Level.CreateThinkerIterator("AlienSpectre3"); Actor spectre = Actor(it.Next()); if (spectre != NULL && spectre.health > 0 && self.target != spectre) diff --git a/wadsrc/static/zscript/strife/strifeitems.txt b/wadsrc/static/zscript/strife/strifeitems.txt index c65b6c9215..b3e014b623 100644 --- a/wadsrc/static/zscript/strife/strifeitems.txt +++ b/wadsrc/static/zscript/strife/strifeitems.txt @@ -612,7 +612,7 @@ class RaiseAlarm : DummyStrifeItem { toucher.SoundAlert (toucher); - ThinkerIterator it = ThinkerIterator.Create("AlienSpectre3"); + ThinkerIterator it = Level.CreateThinkerIterator("AlienSpectre3"); Actor spectre = Actor(it.Next()); if (spectre != NULL && spectre.health > 0 && toucher != spectre) diff --git a/wadsrc/static/zscript/strife/svestuff.txt b/wadsrc/static/zscript/strife/svestuff.txt index 1e52df1b5e..a015393a57 100644 --- a/wadsrc/static/zscript/strife/svestuff.txt +++ b/wadsrc/static/zscript/strife/svestuff.txt @@ -160,7 +160,7 @@ class SVEOreSpawner : Actor } if(!inrange) return; - let it = ThinkerIterator.Create("DegninOre"); + let it = Level.CreateThinkerIterator("DegninOre"); Thinker ac; int numores = 0;