mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 16:07:45 +00:00
- removed the remaining level references from p_acs.cpp.
This commit is contained in:
parent
259ae41774
commit
6312c44234
3 changed files with 93 additions and 81 deletions
|
@ -93,68 +93,9 @@ class DAutomapBase;
|
||||||
typedef TMap<int, int> FDialogueIDMap; // maps dialogue IDs to dialogue array index (for ACS)
|
typedef TMap<int, int> FDialogueIDMap; // maps dialogue IDs to dialogue array index (for ACS)
|
||||||
typedef TMap<FName, int> FDialogueMap; // maps actor class names to dialogue array index
|
typedef TMap<FName, int> FDialogueMap; // maps actor class names to dialogue array index
|
||||||
|
|
||||||
struct FLevelData
|
struct FLevelLocals
|
||||||
{
|
{
|
||||||
TArray<vertex_t> vertexes;
|
FLevelLocals() : tagManager(this), Behaviors(this) {}
|
||||||
TArray<sector_t> sectors;
|
|
||||||
TArray<line_t*> linebuffer; // contains the line lists for the sectors.
|
|
||||||
TArray<subsector_t*> subsectorbuffer; // contains the subsector lists for the sectors.
|
|
||||||
TArray<line_t> lines;
|
|
||||||
TArray<side_t> sides;
|
|
||||||
TArray<seg_t *> segbuffer; // contains the seg links for the sidedefs.
|
|
||||||
TArray<seg_t> segs;
|
|
||||||
TArray<subsector_t> subsectors;
|
|
||||||
TArray<node_t> nodes;
|
|
||||||
TArray<subsector_t> gamesubsectors;
|
|
||||||
TArray<node_t> gamenodes;
|
|
||||||
node_t *headgamenode;
|
|
||||||
TArray<uint8_t> rejectmatrix;
|
|
||||||
TArray<zone_t> Zones;
|
|
||||||
TArray<FPolyObj> Polyobjects;
|
|
||||||
|
|
||||||
TArray<FSectorPortal> sectorPortals;
|
|
||||||
TArray<FLinePortal> linePortals;
|
|
||||||
|
|
||||||
// Portal information.
|
|
||||||
FDisplacementTable Displacements;
|
|
||||||
FPortalBlockmap PortalBlockmap;
|
|
||||||
TArray<FLinePortal*> linkedPortals; // only the linked portals, this is used to speed up looking for them in P_CollectConnectedGroups.
|
|
||||||
TArray<FSectorPortalGroup *> portalGroups;
|
|
||||||
TArray<FLinePortalSpan> linePortalSpans;
|
|
||||||
FSectionContainer sections;
|
|
||||||
FCanvasTextureInfo canvasTextureInfo;
|
|
||||||
|
|
||||||
// [ZZ] Destructible geometry information
|
|
||||||
TMap<int, FHealthGroup> healthGroups;
|
|
||||||
|
|
||||||
FBlockmap blockmap;
|
|
||||||
TArray<polyblock_t *> 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<sector_t> loadsectors;
|
|
||||||
TArray<line_t> loadlines;
|
|
||||||
TArray<side_t> loadsides;
|
|
||||||
|
|
||||||
// Maintain single and multi player starting spots.
|
|
||||||
TArray<FPlayerStart> deathmatchstarts;
|
|
||||||
FPlayerStart playerstarts[MAXPLAYERS];
|
|
||||||
TArray<FPlayerStart> AllPlayerStarts;
|
|
||||||
|
|
||||||
FBehaviorContainer Behaviors;
|
|
||||||
AActor *TIDHash[128];
|
|
||||||
|
|
||||||
TArray<FStrifeDialogueNode *> StrifeDialogues;
|
|
||||||
FDialogueIDMap DialogueRoots;
|
|
||||||
FDialogueMap ClassRoots;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct FLevelLocals : public FLevelData
|
|
||||||
{
|
|
||||||
FLevelLocals() : tagManager(this) {}
|
|
||||||
|
|
||||||
friend class MapLoader;
|
friend class MapLoader;
|
||||||
|
|
||||||
|
@ -426,6 +367,58 @@ public:
|
||||||
S_ChangeMusic(Music, musicorder);
|
S_ChangeMusic(Music, musicorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TArray<vertex_t> vertexes;
|
||||||
|
TArray<sector_t> sectors;
|
||||||
|
TArray<line_t*> linebuffer; // contains the line lists for the sectors.
|
||||||
|
TArray<subsector_t*> subsectorbuffer; // contains the subsector lists for the sectors.
|
||||||
|
TArray<line_t> lines;
|
||||||
|
TArray<side_t> sides;
|
||||||
|
TArray<seg_t *> segbuffer; // contains the seg links for the sidedefs.
|
||||||
|
TArray<seg_t> segs;
|
||||||
|
TArray<subsector_t> subsectors;
|
||||||
|
TArray<node_t> nodes;
|
||||||
|
TArray<subsector_t> gamesubsectors;
|
||||||
|
TArray<node_t> gamenodes;
|
||||||
|
node_t *headgamenode;
|
||||||
|
TArray<uint8_t> rejectmatrix;
|
||||||
|
TArray<zone_t> Zones;
|
||||||
|
TArray<FPolyObj> Polyobjects;
|
||||||
|
|
||||||
|
TArray<FSectorPortal> sectorPortals;
|
||||||
|
TArray<FLinePortal> linePortals;
|
||||||
|
|
||||||
|
// Portal information.
|
||||||
|
FDisplacementTable Displacements;
|
||||||
|
FPortalBlockmap PortalBlockmap;
|
||||||
|
TArray<FLinePortal*> linkedPortals; // only the linked portals, this is used to speed up looking for them in P_CollectConnectedGroups.
|
||||||
|
TArray<FSectorPortalGroup *> portalGroups;
|
||||||
|
TArray<FLinePortalSpan> linePortalSpans;
|
||||||
|
FSectionContainer sections;
|
||||||
|
FCanvasTextureInfo canvasTextureInfo;
|
||||||
|
|
||||||
|
// [ZZ] Destructible geometry information
|
||||||
|
TMap<int, FHealthGroup> healthGroups;
|
||||||
|
|
||||||
|
FBlockmap blockmap;
|
||||||
|
TArray<polyblock_t *> 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<sector_t> loadsectors;
|
||||||
|
TArray<line_t> loadlines;
|
||||||
|
TArray<side_t> loadsides;
|
||||||
|
|
||||||
|
// Maintain single and multi player starting spots.
|
||||||
|
TArray<FPlayerStart> deathmatchstarts;
|
||||||
|
FPlayerStart playerstarts[MAXPLAYERS];
|
||||||
|
TArray<FPlayerStart> AllPlayerStarts;
|
||||||
|
|
||||||
|
FBehaviorContainer Behaviors;
|
||||||
|
AActor *TIDHash[128];
|
||||||
|
|
||||||
|
TArray<FStrifeDialogueNode *> StrifeDialogues;
|
||||||
|
FDialogueIDMap DialogueRoots;
|
||||||
|
FDialogueMap ClassRoots;
|
||||||
|
|
||||||
uint8_t md5[16]; // for savegame validation. If the MD5 does not match the savegame won't be loaded.
|
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
|
int time; // time in the hub
|
||||||
|
|
|
@ -1447,7 +1447,10 @@ void P_CollectACSGlobalStrings()
|
||||||
GlobalACSStrings.MarkStringArray(&stack->buffer[0], sp);
|
GlobalACSStrings.MarkStringArray(&stack->buffer[0], sp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
level.Behaviors.MarkLevelVarStrings();
|
for(auto Level : AllLevels())
|
||||||
|
{
|
||||||
|
Level->Behaviors.MarkLevelVarStrings();
|
||||||
|
}
|
||||||
P_MarkWorldVarStrings();
|
P_MarkWorldVarStrings();
|
||||||
P_MarkGlobalVarStrings();
|
P_MarkGlobalVarStrings();
|
||||||
GlobalACSStrings.PurgeStrings();
|
GlobalACSStrings.PurgeStrings();
|
||||||
|
@ -1951,7 +1954,7 @@ FBehavior *FBehaviorContainer::LoadModule (int lumpnum, FileReader *fr, int len)
|
||||||
}
|
}
|
||||||
|
|
||||||
FBehavior * behavior = new FBehavior ();
|
FBehavior * behavior = new FBehavior ();
|
||||||
if (behavior->Init(lumpnum, fr, len))
|
if (behavior->Init(Level, lumpnum, fr, len))
|
||||||
{
|
{
|
||||||
return behavior;
|
return behavior;
|
||||||
}
|
}
|
||||||
|
@ -2001,9 +2004,9 @@ void FBehaviorContainer::MarkLevelVarStrings()
|
||||||
StaticModules[modnum]->MarkMapVarStrings();
|
StaticModules[modnum]->MarkMapVarStrings();
|
||||||
}
|
}
|
||||||
// Mark running scripts' local variables.
|
// 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();
|
script->MarkLocalVarStrings();
|
||||||
}
|
}
|
||||||
|
@ -2018,9 +2021,9 @@ void FBehaviorContainer::LockLevelVarStrings(int levelnum)
|
||||||
StaticModules[modnum]->LockMapVarStrings(levelnum);
|
StaticModules[modnum]->LockMapVarStrings(levelnum);
|
||||||
}
|
}
|
||||||
// Lock running scripts' local variables.
|
// 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);
|
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;
|
uint8_t *object;
|
||||||
int i;
|
int i;
|
||||||
|
@ -2267,7 +2270,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len)
|
||||||
delete[] object;
|
delete[] object;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LibraryID = level.Behaviors.StaticModules.Push (this) << LIBRARYID_SHIFT;
|
LibraryID = Level->Behaviors.StaticModules.Push (this) << LIBRARYID_SHIFT;
|
||||||
|
|
||||||
if (fr == NULL)
|
if (fr == NULL)
|
||||||
{
|
{
|
||||||
|
@ -2556,7 +2559,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
module = level.Behaviors.LoadModule (lump);
|
module = Level->Behaviors.LoadModule (lump);
|
||||||
}
|
}
|
||||||
if (module != NULL) Imports.Push (module);
|
if (module != NULL) Imports.Push (module);
|
||||||
do {;} while (parse[++i]);
|
do {;} while (parse[++i]);
|
||||||
|
@ -3285,7 +3288,7 @@ void FBehavior::StartTypedScripts (uint16_t type, AActor *activator, bool always
|
||||||
|
|
||||||
void FBehaviorContainer::StopMyScripts (AActor *actor)
|
void FBehaviorContainer::StopMyScripts (AActor *actor)
|
||||||
{
|
{
|
||||||
DACSThinker *controller = level.ACSThinker;
|
DACSThinker *controller = actor->Level->ACSThinker;
|
||||||
|
|
||||||
if (controller != NULL)
|
if (controller != NULL)
|
||||||
{
|
{
|
||||||
|
@ -10440,13 +10443,17 @@ FSerializer &Serialize(FSerializer &arc, const char *key, acsdefered_t &defer, a
|
||||||
|
|
||||||
CCMD (scriptstat)
|
CCMD (scriptstat)
|
||||||
{
|
{
|
||||||
if (level.ACSThinker == NULL)
|
for (auto Level : AllLevels())
|
||||||
{
|
{
|
||||||
Printf ("No scripts are running.\n");
|
Printf("Script status for %s", Level->MapName.GetChars());
|
||||||
}
|
if (Level->ACSThinker == nullptr)
|
||||||
else
|
{
|
||||||
{
|
Printf("No scripts are running.\n");
|
||||||
level.ACSThinker->DumpScriptStatus ();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Level->ACSThinker->DumpScriptStatus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10659,7 +10666,7 @@ static void ShowProfileData(TArray<ProfileCollector> &profiles, long ilimit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CCMD(acsprofile)
|
void ACSProfile(FLevelLocals *Level, FCommandLine &argv)
|
||||||
{
|
{
|
||||||
static int (*sort_funcs[])(const void*, const void *) =
|
static int (*sort_funcs[])(const void*, const void *) =
|
||||||
{
|
{
|
||||||
|
@ -10678,8 +10685,9 @@ CCMD(acsprofile)
|
||||||
|
|
||||||
assert(countof(sort_names) == countof(sort_match_len));
|
assert(countof(sort_names) == countof(sort_match_len));
|
||||||
|
|
||||||
level.Behaviors.ArrangeScriptProfiles(ScriptProfiles);
|
Printf("ACS profile for %s\n", Level->MapName.GetChars());
|
||||||
level.Behaviors.ArrangeFunctionProfiles(FuncProfiles);
|
Level->Behaviors.ArrangeScriptProfiles(ScriptProfiles);
|
||||||
|
Level->Behaviors.ArrangeFunctionProfiles(FuncProfiles);
|
||||||
|
|
||||||
if (argv.argc() > 1)
|
if (argv.argc() > 1)
|
||||||
{
|
{
|
||||||
|
@ -10730,6 +10738,14 @@ CCMD(acsprofile)
|
||||||
ShowProfileData(FuncProfiles, limit, sorter, true);
|
ShowProfileData(FuncProfiles, limit, sorter, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCMD(acsprofile)
|
||||||
|
{
|
||||||
|
for (auto Level : AllLevels())
|
||||||
|
{
|
||||||
|
ACSProfile(Level, argv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ADD_STAT(ACS)
|
ADD_STAT(ACS)
|
||||||
{
|
{
|
||||||
return FStringf("ACS time: %f ms", ACSTime.TimeMS());
|
return FStringf("ACS time: %f ms", ACSTime.TimeMS());
|
||||||
|
|
|
@ -349,7 +349,7 @@ class FBehavior
|
||||||
public:
|
public:
|
||||||
FBehavior ();
|
FBehavior ();
|
||||||
~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 ();
|
bool IsGood ();
|
||||||
uint8_t *FindChunk (uint32_t id) const;
|
uint8_t *FindChunk (uint32_t id) const;
|
||||||
|
@ -425,8 +425,11 @@ private:
|
||||||
|
|
||||||
struct FBehaviorContainer
|
struct FBehaviorContainer
|
||||||
{
|
{
|
||||||
|
FLevelLocals *Level;
|
||||||
TArray<FBehavior *> StaticModules;
|
TArray<FBehavior *> StaticModules;
|
||||||
|
|
||||||
|
FBehaviorContainer(FLevelLocals *l) : Level(l) {}
|
||||||
|
|
||||||
FBehavior *LoadModule(int lumpnum, FileReader *fr = nullptr, int len = 0);
|
FBehavior *LoadModule(int lumpnum, FileReader *fr = nullptr, int len = 0);
|
||||||
void LoadDefaultModules();
|
void LoadDefaultModules();
|
||||||
void UnloadModules();
|
void UnloadModules();
|
||||||
|
|
Loading…
Reference in a new issue