diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 143743e782..31b7bf433d 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -93,68 +93,9 @@ class DAutomapBase; typedef TMap FDialogueIDMap; // maps dialogue IDs to dialogue array index (for ACS) typedef TMap FDialogueMap; // maps actor class names to dialogue array index -struct FLevelData +struct FLevelLocals { - TArray vertexes; - TArray sectors; - TArray linebuffer; // contains the line lists for the sectors. - TArray subsectorbuffer; // contains the subsector lists for the sectors. - TArray lines; - TArray sides; - TArray segbuffer; // contains the seg links for the sidedefs. - TArray segs; - TArray subsectors; - TArray nodes; - TArray gamesubsectors; - TArray gamenodes; - node_t *headgamenode; - TArray rejectmatrix; - TArray Zones; - TArray Polyobjects; - - TArray sectorPortals; - TArray linePortals; - - // Portal information. - FDisplacementTable Displacements; - FPortalBlockmap PortalBlockmap; - TArray linkedPortals; // only the linked portals, this is used to speed up looking for them in P_CollectConnectedGroups. - TArray portalGroups; - TArray linePortalSpans; - FSectionContainer sections; - FCanvasTextureInfo canvasTextureInfo; - - // [ZZ] Destructible geometry information - TMap healthGroups; - - FBlockmap blockmap; - TArray PolyBlockMap; - - // These are copies of the loaded map data that get used by the savegame code to skip unaltered fields - // Without such a mechanism the savegame format would become too slow and large because more than 80-90% are normally still unaltered. - TArray loadsectors; - TArray loadlines; - TArray loadsides; - - // Maintain single and multi player starting spots. - TArray deathmatchstarts; - FPlayerStart playerstarts[MAXPLAYERS]; - TArray AllPlayerStarts; - - FBehaviorContainer Behaviors; - AActor *TIDHash[128]; - - TArray StrifeDialogues; - FDialogueIDMap DialogueRoots; - FDialogueMap ClassRoots; - - -}; - - -struct FLevelLocals : public FLevelData -{ - FLevelLocals() : tagManager(this) {} + FLevelLocals() : tagManager(this), Behaviors(this) {} friend class MapLoader; @@ -426,6 +367,58 @@ public: S_ChangeMusic(Music, musicorder); } + TArray vertexes; + TArray sectors; + TArray linebuffer; // contains the line lists for the sectors. + TArray subsectorbuffer; // contains the subsector lists for the sectors. + TArray lines; + TArray sides; + TArray segbuffer; // contains the seg links for the sidedefs. + TArray segs; + TArray subsectors; + TArray nodes; + TArray gamesubsectors; + TArray gamenodes; + node_t *headgamenode; + TArray rejectmatrix; + TArray Zones; + TArray Polyobjects; + + TArray sectorPortals; + TArray linePortals; + + // Portal information. + FDisplacementTable Displacements; + FPortalBlockmap PortalBlockmap; + TArray linkedPortals; // only the linked portals, this is used to speed up looking for them in P_CollectConnectedGroups. + TArray portalGroups; + TArray linePortalSpans; + FSectionContainer sections; + FCanvasTextureInfo canvasTextureInfo; + + // [ZZ] Destructible geometry information + TMap healthGroups; + + FBlockmap blockmap; + TArray PolyBlockMap; + + // These are copies of the loaded map data that get used by the savegame code to skip unaltered fields + // Without such a mechanism the savegame format would become too slow and large because more than 80-90% are normally still unaltered. + TArray loadsectors; + TArray loadlines; + TArray loadsides; + + // Maintain single and multi player starting spots. + TArray deathmatchstarts; + FPlayerStart playerstarts[MAXPLAYERS]; + TArray AllPlayerStarts; + + FBehaviorContainer Behaviors; + AActor *TIDHash[128]; + + TArray StrifeDialogues; + FDialogueIDMap DialogueRoots; + FDialogueMap ClassRoots; uint8_t md5[16]; // for savegame validation. If the MD5 does not match the savegame won't be loaded. int time; // time in the hub diff --git a/src/p_acs.cpp b/src/p_acs.cpp index c2dd9a3c91..6d2e62082f 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -1447,7 +1447,10 @@ void P_CollectACSGlobalStrings() GlobalACSStrings.MarkStringArray(&stack->buffer[0], sp); } } - level.Behaviors.MarkLevelVarStrings(); + for(auto Level : AllLevels()) + { + Level->Behaviors.MarkLevelVarStrings(); + } P_MarkWorldVarStrings(); P_MarkGlobalVarStrings(); GlobalACSStrings.PurgeStrings(); @@ -1951,7 +1954,7 @@ FBehavior *FBehaviorContainer::LoadModule (int lumpnum, FileReader *fr, int len) } FBehavior * behavior = new FBehavior (); - if (behavior->Init(lumpnum, fr, len)) + if (behavior->Init(Level, lumpnum, fr, len)) { return behavior; } @@ -2001,9 +2004,9 @@ void FBehaviorContainer::MarkLevelVarStrings() StaticModules[modnum]->MarkMapVarStrings(); } // Mark running scripts' local variables. - if (level.ACSThinker != nullptr) + if (Level->ACSThinker != nullptr) { - for (DLevelScript *script = level.ACSThinker->Scripts; script != NULL; script = script->GetNext()) + for (DLevelScript *script = Level->ACSThinker->Scripts; script != NULL; script = script->GetNext()) { script->MarkLocalVarStrings(); } @@ -2018,9 +2021,9 @@ void FBehaviorContainer::LockLevelVarStrings(int levelnum) StaticModules[modnum]->LockMapVarStrings(levelnum); } // Lock running scripts' local variables. - if (level.ACSThinker != nullptr) + if (Level->ACSThinker != nullptr) { - for (DLevelScript *script = level.ACSThinker->Scripts; script != NULL; script = script->GetNext()) + for (DLevelScript *script = Level->ACSThinker->Scripts; script != NULL; script = script->GetNext()) { script->LockLocalVarStrings(levelnum); } @@ -2205,7 +2208,7 @@ FBehavior::FBehavior() } -bool FBehavior::Init(int lumpnum, FileReader * fr, int len) +bool FBehavior::Init(FLevelLocals *Level, int lumpnum, FileReader * fr, int len) { uint8_t *object; int i; @@ -2267,7 +2270,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) delete[] object; return false; } - LibraryID = level.Behaviors.StaticModules.Push (this) << LIBRARYID_SHIFT; + LibraryID = Level->Behaviors.StaticModules.Push (this) << LIBRARYID_SHIFT; if (fr == NULL) { @@ -2556,7 +2559,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) } else { - module = level.Behaviors.LoadModule (lump); + module = Level->Behaviors.LoadModule (lump); } if (module != NULL) Imports.Push (module); do {;} while (parse[++i]); @@ -3285,7 +3288,7 @@ void FBehavior::StartTypedScripts (uint16_t type, AActor *activator, bool always void FBehaviorContainer::StopMyScripts (AActor *actor) { - DACSThinker *controller = level.ACSThinker; + DACSThinker *controller = actor->Level->ACSThinker; if (controller != NULL) { @@ -10440,13 +10443,17 @@ FSerializer &Serialize(FSerializer &arc, const char *key, acsdefered_t &defer, a CCMD (scriptstat) { - if (level.ACSThinker == NULL) + for (auto Level : AllLevels()) { - Printf ("No scripts are running.\n"); - } - else - { - level.ACSThinker->DumpScriptStatus (); + Printf("Script status for %s", Level->MapName.GetChars()); + if (Level->ACSThinker == nullptr) + { + Printf("No scripts are running.\n"); + } + else + { + Level->ACSThinker->DumpScriptStatus(); + } } } @@ -10659,7 +10666,7 @@ static void ShowProfileData(TArray &profiles, long ilimit, } } -CCMD(acsprofile) +void ACSProfile(FLevelLocals *Level, FCommandLine &argv) { static int (*sort_funcs[])(const void*, const void *) = { @@ -10678,8 +10685,9 @@ CCMD(acsprofile) assert(countof(sort_names) == countof(sort_match_len)); - level.Behaviors.ArrangeScriptProfiles(ScriptProfiles); - level.Behaviors.ArrangeFunctionProfiles(FuncProfiles); + Printf("ACS profile for %s\n", Level->MapName.GetChars()); + Level->Behaviors.ArrangeScriptProfiles(ScriptProfiles); + Level->Behaviors.ArrangeFunctionProfiles(FuncProfiles); if (argv.argc() > 1) { @@ -10730,6 +10738,14 @@ CCMD(acsprofile) ShowProfileData(FuncProfiles, limit, sorter, true); } +CCMD(acsprofile) +{ + for (auto Level : AllLevels()) + { + ACSProfile(Level, argv); + } +} + ADD_STAT(ACS) { return FStringf("ACS time: %f ms", ACSTime.TimeMS()); diff --git a/src/p_acs.h b/src/p_acs.h index 5f106fbb19..7eea0c22ad 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -349,7 +349,7 @@ class FBehavior public: FBehavior (); ~FBehavior (); - bool Init(int lumpnum, FileReader * fr = NULL, int len = 0); + bool Init(FLevelLocals *l, int lumpnum, FileReader * fr = NULL, int len = 0); bool IsGood (); uint8_t *FindChunk (uint32_t id) const; @@ -425,8 +425,11 @@ private: struct FBehaviorContainer { + FLevelLocals *Level; TArray StaticModules; + FBehaviorContainer(FLevelLocals *l) : Level(l) {} + FBehavior *LoadModule(int lumpnum, FileReader *fr = nullptr, int len = 0); void LoadDefaultModules(); void UnloadModules();