diff --git a/src/b_game.cpp b/src/b_game.cpp index d21c736e5..1e6e9c43a 100644 --- a/src/b_game.cpp +++ b/src/b_game.cpp @@ -92,6 +92,7 @@ Everything that is changed is marked (maybe commented) with "Added by MC" #include "d_player.h" #include "events.h" #include "vm.h" +#include "g_levellocals.h" static FRandom pr_botspawn ("BotSpawn"); @@ -447,7 +448,7 @@ void FCajunMaster::RemoveAllBots (bool fromlist) // [ZZ] run event hook E_PlayerDisconnected(i); // - FBehavior::StaticStartTypedScripts (SCRIPT_Disconnect, players[i].mo, true, i, true); + level.Behaviors.StartTypedScripts (SCRIPT_Disconnect, players[i].mo, true, i, true); ClearPlayer (i, !fromlist); } } diff --git a/src/g_game.cpp b/src/g_game.cpp index c95b15d36..2ba456f97 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1682,11 +1682,11 @@ void G_DoPlayerPop(int playernum) } // [RH] Make the player disappear - FBehavior::StaticStopMyScripts(players[playernum].mo); + level.Behaviors.StopMyScripts(players[playernum].mo); // [ZZ] fire player disconnect hook E_PlayerDisconnected(playernum); // [RH] Let the scripts know the player left - FBehavior::StaticStartTypedScripts(SCRIPT_Disconnect, players[playernum].mo, true, playernum, true); + level.Behaviors.StartTypedScripts(SCRIPT_Disconnect, players[playernum].mo, true, playernum, true); if (players[playernum].mo != NULL) { P_DisconnectEffect(players[playernum].mo); diff --git a/src/g_level.cpp b/src/g_level.cpp index 11ed6c0c4..93c52a081 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -641,7 +641,7 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill // [RH] Give scripts a chance to do something unloading = true; - FBehavior::StaticStartTypedScripts (SCRIPT_Unloading, NULL, false, 0, true); + level.Behaviors.StartTypedScripts (SCRIPT_Unloading, NULL, false, 0, true); // [ZZ] safe world unload E_WorldUnloaded(); // [ZZ] unsafe world unload (changemap != map) @@ -854,7 +854,7 @@ void G_DoCompleted (void) G_SnapshotLevel (); // Do not free any global strings this level might reference // while it's not loaded. - FBehavior::StaticLockLevelVarStrings(); + level.Behaviors.LockLevelVarStrings(); } else { // Make sure we don't have a snapshot lying around from before. @@ -1089,7 +1089,7 @@ void G_DoLoadLevel (int position, bool autosave, bool newGame) if (fromSnapshot) { // ENTER scripts are being handled when the player gets spawned, this cannot be changed due to its effect on voodoo dolls. - FBehavior::StaticStartTypedScripts(SCRIPT_Return, players[ii].mo, true); + level.Behaviors.StartTypedScripts(SCRIPT_Return, players[ii].mo, true); } } } @@ -1097,7 +1097,7 @@ void G_DoLoadLevel (int position, bool autosave, bool newGame) if (level.FromSnapshot) { // [Nash] run REOPEN scripts upon map re-entry - FBehavior::StaticStartTypedScripts(SCRIPT_Reopen, NULL, false); + level.Behaviors.StartTypedScripts(SCRIPT_Reopen, NULL, false); } StatusBar->AttachToPlayer (&players[consoleplayer]); @@ -1718,7 +1718,7 @@ void G_UnSnapshotLevel (bool hubLoad) if (hubLoad) { // Unlock ACS global strings that were locked when the snapshot was made. - FBehavior::StaticUnlockLevelVarStrings(); + level.Behaviors.UnlockLevelVarStrings(); } } diff --git a/src/g_levellocals.h b/src/g_levellocals.h index f24d448e1..ce2a4f2e0 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -43,6 +43,7 @@ #include "p_blockmap.h" #include "p_local.h" #include "po_man.h" +#include "p_acs.h" #include "p_destructible.h" #include "r_data/r_sections.h" #include "r_data/r_canvastexture.h" @@ -98,6 +99,7 @@ struct FLevelData FPlayerStart playerstarts[MAXPLAYERS]; TArray AllPlayerStarts; + FBehaviorContainer Behaviors; }; struct FLevelLocals : public FLevelData diff --git a/src/g_shared/a_lightning.cpp b/src/g_shared/a_lightning.cpp index 76fdb5de1..cebc3c8ef 100644 --- a/src/g_shared/a_lightning.cpp +++ b/src/g_shared/a_lightning.cpp @@ -157,7 +157,7 @@ void DLightningThinker::LightningFlash () // [ZZ] just in case E_WorldLightning(); // start LIGHTNING scripts - FBehavior::StaticStartTypedScripts (SCRIPT_Lightning, NULL, false); // [RH] Run lightning scripts + level.Behaviors.StartTypedScripts (SCRIPT_Lightning, NULL, false); // [RH] Run lightning scripts // Calculate the next lighting flash if (!NextLightningFlash) diff --git a/src/g_statusbar/sbarinfo_commands.cpp b/src/g_statusbar/sbarinfo_commands.cpp index cd28d8580..cc0c8a5cf 100644 --- a/src/g_statusbar/sbarinfo_commands.cpp +++ b/src/g_statusbar/sbarinfo_commands.cpp @@ -904,7 +904,7 @@ class CommandDrawString : public SBarInfoCommand if(ACS_GlobalVars[valueArgument] != cache) { cache = ACS_GlobalVars[valueArgument]; - str = FBehavior::StaticLookupString(ACS_GlobalVars[valueArgument]); + str = level.Behaviors.LookupString(ACS_GlobalVars[valueArgument]); RealignString(); } break; @@ -912,7 +912,7 @@ class CommandDrawString : public SBarInfoCommand if(ACS_GlobalArrays[valueArgument][consoleplayer] != cache) { cache = ACS_GlobalArrays[valueArgument][consoleplayer]; - str = FBehavior::StaticLookupString(ACS_GlobalArrays[valueArgument][consoleplayer]); + str = level.Behaviors.LookupString(ACS_GlobalArrays[valueArgument][consoleplayer]); RealignString(); } break; diff --git a/src/maploader/edata.cpp b/src/maploader/edata.cpp index 004bef988..30b541f73 100644 --- a/src/maploader/edata.cpp +++ b/src/maploader/edata.cpp @@ -660,6 +660,6 @@ void MapLoader::LoadMapinfoACSLump() if (Level->info->acsName.IsNotEmpty()) { int lump = Wads.CheckNumForName(Level->info->acsName); - if (lump >= 0) FBehavior::StaticLoadModule(lump); + if (lump >= 0) Level->Behaviors.LoadModule(lump); } } diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index 95924285e..ba8414550 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -2825,12 +2825,12 @@ void MapLoader::LoadBehavior(MapData * map) { if (map->Size(ML_BEHAVIOR) > 0) { - FBehavior::StaticLoadModule(-1, &map->Reader(ML_BEHAVIOR), map->Size(ML_BEHAVIOR)); + Level->Behaviors.LoadModule(-1, &map->Reader(ML_BEHAVIOR), map->Size(ML_BEHAVIOR)); } - if (!FBehavior::StaticCheckAllGood()) + if (!Level->Behaviors.CheckAllGood()) { Printf("ACS scripts unloaded.\n"); - FBehavior::StaticUnloadModules(); + Level->Behaviors.UnloadModules(); } } @@ -2881,7 +2881,7 @@ void MapLoader::LoadLevel(MapData *map, const char *lumpname, int position) ForceNodeBuild = gennodes; // [RH] Load in the BEHAVIOR lump - FBehavior::StaticUnloadModules(); + Level->Behaviors.UnloadModules(); if (map->HasBehavior) { LoadBehavior(map); @@ -2941,7 +2941,7 @@ void MapLoader::LoadLevel(MapData *map, const char *lumpname, int position) Level->flags2 |= LEVEL2_DUMMYSWITCHES; } - FBehavior::StaticLoadDefaultModules(); + Level->Behaviors.LoadDefaultModules(); LoadMapinfoACSLump(); @@ -3174,7 +3174,7 @@ void MapLoader::LoadLevel(MapData *map, const char *lumpname, int position) node.len = (float)g_sqrt(fdx * fdx + fdy * fdy); } - InitRenderInfo(); // create hardware independent renderer resources for the level. This must be done BEFORE the PolyObj Spawn!!! + InitRenderInfo(); // create hardware independent renderer resources for the Level-> This must be done BEFORE the PolyObj Spawn!!! P_ClearDynamic3DFloorData(); // CreateVBO must be run on the plain 3D floor data. screen->mVertexData->CreateVBO(); diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 3b7b2d87f..928b94387 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -793,6 +793,7 @@ private: friend class DLevelScript; friend class FBehavior; + friend struct FBehaviorContainer; }; @@ -806,8 +807,6 @@ struct FBehavior::ArrayInfo int32_t *Elements; }; -TArray FBehavior::StaticModules; - //============================================================================ // // uallong @@ -1506,7 +1505,7 @@ void P_CollectACSGlobalStrings() GlobalACSStrings.MarkStringArray(&stack->buffer[0], sp); } } - FBehavior::StaticMarkLevelVarStrings(); + level.Behaviors.MarkLevelVarStrings(); P_MarkWorldVarStrings(); P_MarkGlobalVarStrings(); GlobalACSStrings.PurgeStrings(); @@ -1981,7 +1980,7 @@ void DPlaneWatcher::Tick () // Load user-specified default modules. This must be called after the level's // own behavior is loaded (if it has one). -void FBehavior::StaticLoadDefaultModules () +void FBehaviorContainer::LoadDefaultModules () { // Scan each LOADACS lump and load the specified modules in order int lump, lastlump = 0; @@ -1994,7 +1993,7 @@ void FBehavior::StaticLoadDefaultModules () int acslump = Wads.CheckNumForName (sc.String, ns_acslibrary); if (acslump >= 0) { - StaticLoadModule (acslump); + LoadModule (acslump); } else { @@ -2004,7 +2003,7 @@ void FBehavior::StaticLoadDefaultModules () } } -FBehavior *FBehavior::StaticLoadModule (int lumpnum, FileReader *fr, int len) +FBehavior *FBehaviorContainer::LoadModule (int lumpnum, FileReader *fr, int len) { if (lumpnum == -1 && fr == NULL) return NULL; @@ -2029,7 +2028,7 @@ FBehavior *FBehavior::StaticLoadModule (int lumpnum, FileReader *fr, int len) } } -bool FBehavior::StaticCheckAllGood () +bool FBehaviorContainer::CheckAllGood () { for (unsigned int i = 0; i < StaticModules.Size(); ++i) { @@ -2041,7 +2040,7 @@ bool FBehavior::StaticCheckAllGood () return true; } -void FBehavior::StaticUnloadModules () +void FBehaviorContainer::UnloadModules () { for (unsigned int i = StaticModules.Size(); i-- > 0; ) { @@ -2050,7 +2049,7 @@ void FBehavior::StaticUnloadModules () StaticModules.Clear (); } -FBehavior *FBehavior::StaticGetModule (int lib) +FBehavior *FBehaviorContainer::GetModule (int lib) { if ((size_t)lib >= StaticModules.Size()) { @@ -2059,7 +2058,7 @@ FBehavior *FBehavior::StaticGetModule (int lib) return StaticModules[lib]; } -void FBehavior::StaticMarkLevelVarStrings() +void FBehaviorContainer::MarkLevelVarStrings() { // Mark map variables. for (uint32_t modnum = 0; modnum < StaticModules.Size(); ++modnum) @@ -2076,7 +2075,7 @@ void FBehavior::StaticMarkLevelVarStrings() } } -void FBehavior::StaticLockLevelVarStrings() +void FBehaviorContainer::LockLevelVarStrings() { // Lock map variables. for (uint32_t modnum = 0; modnum < StaticModules.Size(); ++modnum) @@ -2093,7 +2092,7 @@ void FBehavior::StaticLockLevelVarStrings() } } -void FBehavior::StaticUnlockLevelVarStrings() +void FBehaviorContainer::UnlockLevelVarStrings() { GlobalACSStrings.UnlockForLevel(level.levelnum); } @@ -2125,7 +2124,7 @@ void FBehavior::UnlockMapVarStrings() const } } -void FBehavior::StaticSerializeModuleStates (FSerializer &arc) +void FBehaviorContainer::SerializeModuleStates (FSerializer &arc) { auto modnum = StaticModules.Size(); @@ -2342,7 +2341,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) delete[] object; return false; } - LibraryID = StaticModules.Push (this) << LIBRARYID_SHIFT; + LibraryID = level.Behaviors.StaticModules.Push (this) << LIBRARYID_SHIFT; if (fr == NULL) { @@ -2631,7 +2630,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) } else { - module = StaticLoadModule (lump); + module = level.Behaviors.LoadModule (lump); } if (module != NULL) Imports.Push (module); do {;} while (parse[++i]); @@ -3127,7 +3126,7 @@ const ScriptPtr *FBehavior::FindScript (int script) const return ptr; } -const ScriptPtr *FBehavior::StaticFindScript (int script, FBehavior *&module) +const ScriptPtr *FBehaviorContainer::FindScript (int script, FBehavior *&module) { for (uint32_t i = 0; i < StaticModules.Size(); ++i) { @@ -3263,7 +3262,7 @@ uint8_t *FBehavior::NextChunk (uint8_t *chunk) const return NULL; } -const char *FBehavior::StaticLookupString (uint32_t index) +const char *FBehaviorContainer::LookupString (uint32_t index) { uint32_t lib = index >> LIBRARYID_SHIFT; @@ -3302,7 +3301,7 @@ const char *FBehavior::LookupString (uint32_t index) const } } -void FBehavior::StaticStartTypedScripts (uint16_t type, AActor *activator, bool always, int arg1, bool runNow) +void FBehaviorContainer::StartTypedScripts (uint16_t type, AActor *activator, bool always, int arg1, bool runNow) { static const char *const TypeNames[] = { @@ -3358,7 +3357,7 @@ void FBehavior::StartTypedScripts (uint16_t type, AActor *activator, bool always // when a player disconnects. Should this be used in general whenever an // actor is destroyed? -void FBehavior::StaticStopMyScripts (AActor *actor) +void FBehaviorContainer::StopMyScripts (AActor *actor) { DACSThinker *controller = DACSThinker::ActiveThinker; @@ -3551,7 +3550,7 @@ void DLevelScript::Serialize(FSerializer &arc) if (arc.isReading()) { - activeBehavior = FBehavior::StaticGetModule(lib); + activeBehavior = level.Behaviors.GetModule(lib); if (nullptr == activeBehavior) { @@ -3678,7 +3677,7 @@ int DLevelScript::ThingCount (int type, int stringid, int tid, int tag) } else if (stringid >= 0) { - const char *type_name = FBehavior::StaticLookupString (stringid); + const char *type_name = level.Behaviors.LookupString (stringid); if (type_name == NULL) return 0; @@ -3748,7 +3747,7 @@ void DLevelScript::ChangeFlat (int tag, int name, bool floorOrCeiling) { FTextureID flat; int secnum = -1; - const char *flatname = FBehavior::StaticLookupString (name); + const char *flatname = level.Behaviors.LookupString (name); if (flatname == NULL) return; @@ -3778,7 +3777,7 @@ void DLevelScript::SetLineTexture (int lineid, int side, int position, int name) { FTextureID texture; int linenum = -1; - const char *texname = FBehavior::StaticLookupString (name); + const char *texname = level.Behaviors.LookupString (name); if (texname == nullptr) return; @@ -3816,7 +3815,7 @@ void DLevelScript::SetLineTexture (int lineid, int side, int position, int name) int DLevelScript::DoSpawn (int type, const DVector3 &pos, int tid, DAngle angle, bool force) { - PClassActor *info = PClass::FindActor(FBehavior::StaticLookupString (type)); + PClassActor *info = PClass::FindActor(level.Behaviors.LookupString (type)); AActor *actor = NULL; int spawncount = 0; @@ -3985,7 +3984,7 @@ showme: void DLevelScript::DoSetFont (int fontnum) { - const char *fontname = FBehavior::StaticLookupString (fontnum); + const char *fontname = level.Behaviors.LookupString (fontnum); activefont = V_GetFont (fontname); if (activefont == NULL) { @@ -4283,27 +4282,27 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) break; case APROP_SeeSound: - actor->SeeSound = FBehavior::StaticLookupString(value); + actor->SeeSound = level.Behaviors.LookupString(value); break; case APROP_AttackSound: - actor->AttackSound = FBehavior::StaticLookupString(value); + actor->AttackSound = level.Behaviors.LookupString(value); break; case APROP_PainSound: - actor->PainSound = FBehavior::StaticLookupString(value); + actor->PainSound = level.Behaviors.LookupString(value); break; case APROP_DeathSound: - actor->DeathSound = FBehavior::StaticLookupString(value); + actor->DeathSound = level.Behaviors.LookupString(value); break; case APROP_ActiveSound: - actor->ActiveSound = FBehavior::StaticLookupString(value); + actor->ActiveSound = level.Behaviors.LookupString(value); break; case APROP_Species: - actor->Species = FBehavior::StaticLookupString(value); + actor->Species = level.Behaviors.LookupString(value); break; case APROP_Score: @@ -4311,7 +4310,7 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) break; case APROP_NameTag: - actor->SetTag(FBehavior::StaticLookupString(value)); + actor->SetTag(level.Behaviors.LookupString(value)); break; case APROP_DamageFactor: @@ -4389,7 +4388,7 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) break; case APROP_DamageType: - actor->DamageType = FBehavior::StaticLookupString(value); + actor->DamageType = level.Behaviors.LookupString(value); break; default: @@ -4564,7 +4563,7 @@ int DLevelScript::CheckActorProperty (int tid, int property, int value) case APROP_DamageType: string = actor->DamageType; break; } if (string == NULL) string = ""; - return (!stricmp(string, FBehavior::StaticLookupString(value))); + return (!stricmp(string, level.Behaviors.LookupString(value))); } bool DLevelScript::DoCheckActorTexture(int tid, AActor *activator, int string, bool floor) @@ -4574,7 +4573,7 @@ bool DLevelScript::DoCheckActorTexture(int tid, AActor *activator, int string, b { return 0; } - FTextureID tex = TexMan.CheckForTexture(FBehavior::StaticLookupString(string), ETextureType::Flat, + FTextureID tex = TexMan.CheckForTexture(level.Behaviors.LookupString(string), ETextureType::Flat, FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_TryAny|FTextureManager::TEXMAN_DontCreate); if (!tex.Exists()) @@ -4962,7 +4961,7 @@ static void SetUserVariable(AActor *self, FName varname, int index, int value) { if (type == TypeString) { - FString str = FBehavior::StaticLookupString(value); + FString str = level.Behaviors.LookupString(value); type->InitializeValue(addr, &str); } else if (type->isFloat()) @@ -5018,7 +5017,7 @@ static void DoSetCVar(FBaseCVar *cvar, int value, bool is_string, bool force=fal } if (is_string) { - val.String = FBehavior::StaticLookupString(value); + val.String = level.Behaviors.LookupString(value); type = CVAR_String; } else if (cvar->GetRealType() == CVAR_Float) @@ -5260,8 +5259,8 @@ static int ScriptCall(AActor *activator, unsigned argc, int32_t *args) int retval = 0; if (argc >= 2) { - auto clsname = FBehavior::StaticLookupString(args[0]); - auto funcname = FBehavior::StaticLookupString(args[1]); + auto clsname = level.Behaviors.LookupString(args[0]); + auto funcname = level.Behaviors.LookupString(args[1]); auto cls = PClass::FindClass(clsname); if (!cls) @@ -5310,16 +5309,16 @@ static int ScriptCall(AActor *activator, unsigned argc, int32_t *args) } else if (argtype == TypeName) { - params.Push(FName(FBehavior::StaticLookupString(args[i])).GetIndex()); + params.Push(FName(level.Behaviors.LookupString(args[i])).GetIndex()); } else if (argtype == TypeString) { - strings.Push(FBehavior::StaticLookupString(args[i])); + strings.Push(level.Behaviors.LookupString(args[i])); params.Push(&strings.Last()); } else if (argtype == TypeSound) { - params.Push(int(FSoundID(FBehavior::StaticLookupString(args[i])))); + params.Push(int(FSoundID(level.Behaviors.LookupString(args[i])))); } else { @@ -5385,26 +5384,26 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) switch(funcIndex) { case ACSF_GetLineUDMFInt: - return GetUDMFInt(UDMF_Line, LineFromID(args[0]), FBehavior::StaticLookupString(args[1])); + return GetUDMFInt(UDMF_Line, LineFromID(args[0]), level.Behaviors.LookupString(args[1])); case ACSF_GetLineUDMFFixed: - return DoubleToACS(GetUDMFFloat(UDMF_Line, LineFromID(args[0]), FBehavior::StaticLookupString(args[1]))); + return DoubleToACS(GetUDMFFloat(UDMF_Line, LineFromID(args[0]), level.Behaviors.LookupString(args[1]))); case ACSF_GetThingUDMFInt: case ACSF_GetThingUDMFFixed: return 0; // Not implemented yet case ACSF_GetSectorUDMFInt: - return GetUDMFInt(UDMF_Sector, P_FindFirstSectorFromTag(args[0]), FBehavior::StaticLookupString(args[1])); + return GetUDMFInt(UDMF_Sector, P_FindFirstSectorFromTag(args[0]), level.Behaviors.LookupString(args[1])); case ACSF_GetSectorUDMFFixed: - return DoubleToACS(GetUDMFFloat(UDMF_Sector, P_FindFirstSectorFromTag(args[0]), FBehavior::StaticLookupString(args[1]))); + return DoubleToACS(GetUDMFFloat(UDMF_Sector, P_FindFirstSectorFromTag(args[0]), level.Behaviors.LookupString(args[1]))); case ACSF_GetSideUDMFInt: - return GetUDMFInt(UDMF_Side, SideFromID(args[0], args[1]), FBehavior::StaticLookupString(args[2])); + return GetUDMFInt(UDMF_Side, SideFromID(args[0], args[1]), level.Behaviors.LookupString(args[2])); case ACSF_GetSideUDMFFixed: - return DoubleToACS(GetUDMFFloat(UDMF_Side, SideFromID(args[0], args[1]), FBehavior::StaticLookupString(args[2]))); + return DoubleToACS(GetUDMFFloat(UDMF_Side, SideFromID(args[0], args[1]), level.Behaviors.LookupString(args[2]))); case ACSF_GetActorVelX: actor = SingleActorFromTID(args[0], activator); @@ -5483,7 +5482,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) case ACSF_GetChar: { - const char *p = FBehavior::StaticLookupString(args[0]); + const char *p = level.Behaviors.LookupString(args[0]); if (p != NULL && args[1] >= 0 && args[1] < int(strlen(p))) { return p[args[1]]; @@ -5534,7 +5533,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) } else { - FName p(FBehavior::StaticLookupString(args[0])); + FName p(level.Behaviors.LookupString(args[0])); auto armor = players[args[1]].mo->FindInventory(NAME_BasicArmor); if (armor && armor->NameVar(NAME_ArmorType) == p) return armor->IntVar(NAME_Amount); } @@ -5607,7 +5606,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) case ACSF_SetUserVariable: { int cnt = 0; - FName varname(FBehavior::StaticLookupString(args[1]), true); + FName varname(level.Behaviors.LookupString(args[1]), true); if (varname != NAME_None) { if (args[0] == 0) @@ -5634,7 +5633,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) case ACSF_GetUserVariable: { - FName varname(FBehavior::StaticLookupString(args[1]), true); + FName varname(level.Behaviors.LookupString(args[1]), true); if (varname != NAME_None) { AActor *a = SingleActorFromTID(args[0], activator); @@ -5646,7 +5645,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) case ACSF_SetUserArray: { int cnt = 0; - FName varname(FBehavior::StaticLookupString(args[1]), true); + FName varname(level.Behaviors.LookupString(args[1]), true); if (varname != NAME_None) { if (args[0] == 0) @@ -5673,7 +5672,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) case ACSF_GetUserArray: { - FName varname(FBehavior::StaticLookupString(args[1]), true); + FName varname(level.Behaviors.LookupString(args[1]), true); if (varname != NAME_None) { AActor *a = SingleActorFromTID(args[0], activator); @@ -5683,13 +5682,13 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) } case ACSF_Radius_Quake2: - P_StartQuake(activator, args[0], args[1], args[2], args[3], args[4], FBehavior::StaticLookupString(args[5])); + P_StartQuake(activator, args[0], args[1], args[2], args[3], args[4], level.Behaviors.LookupString(args[5])); break; case ACSF_CheckActorClass: { AActor *a = SingleActorFromTID(args[0], activator); - return a == NULL ? false : a->GetClass()->TypeName == FName(FBehavior::StaticLookupString(args[1])); + return a == NULL ? false : a->GetClass()->TypeName == FName(level.Behaviors.LookupString(args[1])); } case ACSF_GetActorClass: @@ -5700,7 +5699,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) case ACSF_SoundSequenceOnActor: { - const char *seqname = FBehavior::StaticLookupString(args[1]); + const char *seqname = level.Behaviors.LookupString(args[1]); if (seqname != NULL) { if (args[0] == 0) @@ -5726,7 +5725,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) case ACSF_SoundSequenceOnSector: { - const char *seqname = FBehavior::StaticLookupString(args[1]); + const char *seqname = level.Behaviors.LookupString(args[1]); int space = args[2] < CHAN_FLOOR || args[2] > CHAN_INTERIOR ? CHAN_FULLHEIGHT : args[2]; if (seqname != NULL) { @@ -5742,7 +5741,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) case ACSF_SoundSequenceOnPolyobj: { - const char *seqname = FBehavior::StaticLookupString(args[1]); + const char *seqname = level.Behaviors.LookupString(args[1]); if (seqname != NULL) { FPolyObj *poly = PO_GetPolyobj(args[0]); @@ -5831,7 +5830,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) case ACSF_ACS_NamedExecuteWithResult: case ACSF_ACS_NamedExecuteAlways: { - int scriptnum = -FName(FBehavior::StaticLookupString(args[0])); + int scriptnum = -FName(level.Behaviors.LookupString(args[0])); int arg1 = argCount > 1 ? args[1] : 0; int arg2 = argCount > 2 ? args[2] : 0; int arg3 = argCount > 3 ? args[3] : 0; @@ -5873,49 +5872,49 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) case ACSF_GetCVarString: if (argCount == 1) { - return DoGetCVar(GetCVar(activator, FBehavior::StaticLookupString(args[0])), true); + return DoGetCVar(GetCVar(activator, level.Behaviors.LookupString(args[0])), true); } break; case ACSF_SetCVar: if (argCount == 2) { - return SetCVar(activator, FBehavior::StaticLookupString(args[0]), args[1], false); + return SetCVar(activator, level.Behaviors.LookupString(args[0]), args[1], false); } break; case ACSF_SetCVarString: if (argCount == 2) { - return SetCVar(activator, FBehavior::StaticLookupString(args[0]), args[1], true); + return SetCVar(activator, level.Behaviors.LookupString(args[0]), args[1], true); } break; case ACSF_GetUserCVar: if (argCount == 2) { - return DoGetCVar(GetUserCVar(args[0], FBehavior::StaticLookupString(args[1])), false); + return DoGetCVar(GetUserCVar(args[0], level.Behaviors.LookupString(args[1])), false); } break; case ACSF_GetUserCVarString: if (argCount == 2) { - return DoGetCVar(GetUserCVar(args[0], FBehavior::StaticLookupString(args[1])), true); + return DoGetCVar(GetUserCVar(args[0], level.Behaviors.LookupString(args[1])), true); } break; case ACSF_SetUserCVar: if (argCount == 3) { - return SetUserCVar(args[0], FBehavior::StaticLookupString(args[1]), args[2], false); + return SetUserCVar(args[0], level.Behaviors.LookupString(args[1]), args[2], false); } break; case ACSF_SetUserCVarString: if (argCount == 3) { - return SetUserCVar(args[0], FBehavior::StaticLookupString(args[1]), args[2], true); + return SetUserCVar(args[0], level.Behaviors.LookupString(args[1]), args[2], true); } break; @@ -5925,8 +5924,8 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) DAngle angle = ACSToAngle(args[1]); DAngle pitch = ACSToAngle(args[2]); int damage = args[3]; - FName pufftype = argCount > 4 && args[4]? FName(FBehavior::StaticLookupString(args[4])) : NAME_BulletPuff; - FName damagetype = argCount > 5 && args[5]? FName(FBehavior::StaticLookupString(args[5])) : NAME_None; + FName pufftype = argCount > 4 && args[4]? FName(level.Behaviors.LookupString(args[4])) : NAME_BulletPuff; + FName damagetype = argCount > 5 && args[5]? FName(level.Behaviors.LookupString(args[5])) : NAME_None; double range = argCount > 6 && args[6]? ACSToDouble(args[6]) : MISSILERANGE; int flags = argCount > 7 && args[7]? args[7] : 0; int pufftid = argCount > 8 && args[8]? args[8] : 0; @@ -5970,7 +5969,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) if (funcIndex == ACSF_PlaySound) { - const char *lookup = FBehavior::StaticLookupString(args[1]); + const char *lookup = level.Behaviors.LookupString(args[1]); if (lookup != NULL) { sid = lookup; @@ -6068,8 +6067,8 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) { return 0; } - a = FBehavior::StaticLookupString(args[0]); - b = FBehavior::StaticLookupString(args[1]); + a = level.Behaviors.LookupString(args[0]); + b = level.Behaviors.LookupString(args[1]); // Don't crash on invalid strings. if (a == NULL) a = ""; @@ -6091,7 +6090,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_StrRight: if (argCount >= 2) { - const char *oldstr = FBehavior::StaticLookupString(args[0]); + const char *oldstr = level.Behaviors.LookupString(args[0]); if (oldstr == NULL || *oldstr == '\0') { return GlobalACSStrings.AddString(""); @@ -6111,7 +6110,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_StrMid: if (argCount >= 3) { - const char *oldstr = FBehavior::StaticLookupString(args[0]); + const char *oldstr = level.Behaviors.LookupString(args[0]); if (oldstr == NULL || *oldstr == '\0') { return GlobalACSStrings.AddString(""); @@ -6148,7 +6147,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) // Returns number of decals spawned (not including spreading) { int count = 0; - const FDecalTemplate *tpl = DecalLibrary.GetDecalByName(FBehavior::StaticLookupString(args[1])); + const FDecalTemplate *tpl = DecalLibrary.GetDecalByName(level.Behaviors.LookupString(args[1])); if (tpl != NULL) { int flags = (argCount > 2) ? args[2] : 0; @@ -6180,11 +6179,11 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_CheckFont: // bool CheckFont(str fontname) - return V_GetFont(FBehavior::StaticLookupString(args[0])) != NULL; + return V_GetFont(level.Behaviors.LookupString(args[0])) != NULL; case ACSF_DropItem: { - const char *type = FBehavior::StaticLookupString(args[1]); + const char *type = level.Behaviors.LookupString(args[1]); int amount = argCount >= 3? args[2] : -1; int chance = argCount >= 4? args[3] : 256; PClassActor *cls = PClass::FindActor(type); @@ -6217,7 +6216,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_DropInventory: { - const char *type = FBehavior::StaticLookupString(args[1]); + const char *type = level.Behaviors.LookupString(args[1]); AActor *inv; if (type != NULL) @@ -6256,14 +6255,14 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) AActor *actor = SingleActorFromTID(args[0], activator); if (actor != NULL) { - return !!CheckActorFlag(actor, FBehavior::StaticLookupString(args[1])); + return !!CheckActorFlag(actor, level.Behaviors.LookupString(args[1])); } break; } case ACSF_QuakeEx: { - return P_StartQuakeXYZ(activator, args[0], args[1], args[2], args[3], args[4], args[5], args[6], FBehavior::StaticLookupString(args[7]), + return P_StartQuakeXYZ(activator, args[0], args[1], args[2], args[3], args[4], args[5], args[6], level.Behaviors.LookupString(args[7]), argCount > 8 ? args[8] : 0, argCount > 9 ? ACSToDouble(args[9]) : 1.0, argCount > 10 ? ACSToDouble(args[10]) : 1.0, @@ -6297,10 +6296,10 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_GetActorPowerupTics: if (argCount >= 2) { - PClassActor *powerupclass = PClass::FindActor(FBehavior::StaticLookupString(args[1])); + PClassActor *powerupclass = PClass::FindActor(level.Behaviors.LookupString(args[1])); if (powerupclass == NULL || !powerupclass->IsDescendantOf(NAME_Powerup)) { - Printf("'%s' is not a type of Powerup.\n", FBehavior::StaticLookupString(args[1])); + Printf("'%s' is not a type of Powerup.\n", level.Behaviors.LookupString(args[1])); return 0; } @@ -6331,7 +6330,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_SetActorTeleFog: if (argCount >= 3) { - SetActorTeleFog(activator, args[0], FBehavior::StaticLookupString(args[1]), FBehavior::StaticLookupString(args[2])); + SetActorTeleFog(activator, args[0], level.Behaviors.LookupString(args[1]), level.Behaviors.LookupString(args[2])); } break; case ACSF_SwapActorTeleFog: @@ -6475,7 +6474,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) if (argCount > 6) { - const char* const statename = FBehavior::StaticLookupString(args[6]); + const char* const statename = level.Behaviors.LookupString(args[6]); if (nullptr != statename) { @@ -6495,7 +6494,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) actor = SingleActorFromTID(args[0], activator); if (actor != NULL) { - return CheckInventory(actor, FBehavior::StaticLookupString(args[1]), true); + return CheckInventory(actor, level.Behaviors.LookupString(args[1]), true); } break; @@ -6509,7 +6508,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) sector_t *sec = &level.sectors[s]; sec->damageamount = args[1]; - sec->damagetype = argCount >= 3 ? FName(FBehavior::StaticLookupString(args[2])) : FName(NAME_None); + sec->damagetype = argCount >= 3 ? FName(level.Behaviors.LookupString(args[2])) : FName(NAME_None); sec->damageinterval = argCount >= 4 ? clamp(args[3], 1, INT_MAX) : 32; sec->leakydamage = argCount >= 5 ? args[4] : 0; } @@ -6521,7 +6520,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) { if (args[1] == sector_t::floor || args[1] == sector_t::ceiling) { - int terrain = P_FindTerrain(FBehavior::StaticLookupString(args[2])); + int terrain = P_FindTerrain(level.Behaviors.LookupString(args[2])); FSectorTagIterator it(args[0]); int s; while ((s = it.Next()) >= 0) @@ -6572,7 +6571,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) { // [zombie] ACS version of A_CheckProximity actor = SingleActorFromTID(args[0], activator); - PClass *classname = PClass::FindClass(FBehavior::StaticLookupString(args[1])); + PClass *classname = PClass::FindClass(level.Behaviors.LookupString(args[1])); double distance = ACSToDouble(args[2]); int count = argCount >= 4 ? args[3] : 1; int flags = argCount >= 5 ? args[4] : 0; @@ -6583,7 +6582,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_CheckActorState: { actor = SingleActorFromTID(args[0], activator); - const char *statename = FBehavior::StaticLookupString(args[1]); + const char *statename = level.Behaviors.LookupString(args[1]); bool exact = (argCount > 2) ? !!args[2] : false; if (actor && statename) { @@ -6594,7 +6593,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_CheckClass: { - const char *clsname = FBehavior::StaticLookupString(args[0]); + const char *clsname = level.Behaviors.LookupString(args[0]); return !!PClass::FindActor(clsname); } @@ -6603,14 +6602,14 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) // (target, ptr_select1, inflictor, ptr_select2, amount, damagetype) AActor* target = COPY_AAPTR(SingleActorFromTID(args[0], activator), args[1]); AActor* inflictor = COPY_AAPTR(SingleActorFromTID(args[2], activator), args[3]); - FName damagetype(FBehavior::StaticLookupString(args[5])); + FName damagetype(level.Behaviors.LookupString(args[5])); return P_DamageMobj(target, inflictor, inflictor, args[4], damagetype); } case ACSF_SetActorFlag: { int tid = args[0]; - FString flagname = FBehavior::StaticLookupString(args[1]); + FString flagname = level.Behaviors.LookupString(args[1]); bool flagvalue = !!args[2]; int count = 0; // Return value; number of actors affected if (tid == 0) @@ -6638,7 +6637,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_SetTranslation: { int tid = args[0]; - const char *trname = FBehavior::StaticLookupString(args[1]); + const char *trname = level.Behaviors.LookupString(args[1]); if (tid == 0) { if (activator != nullptr) @@ -6714,7 +6713,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) } case ACSF_StrArg: - return -FName(FBehavior::StaticLookupString(args[0])); + return -FName(level.Behaviors.LookupString(args[0])); case ACSF_Floor: return args[0] & ~0xffff; @@ -6729,7 +6728,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) return ScriptCall(activator, argCount, args); case ACSF_StartSlideshow: - G_StartSlideshow(FName(FBehavior::StaticLookupString(args[0]))); + G_StartSlideshow(FName(level.Behaviors.LookupString(args[0]))); break; case ACSF_GetSectorHealth: @@ -7227,7 +7226,7 @@ int DLevelScript::RunScript () if(pcd == PCD_CALLSTACK) { funcnum = STACK(1); - module = FBehavior::StaticGetModule(funcnum>>LIBRARYID_SHIFT); + module = level.Behaviors.GetModule(funcnum>>LIBRARYID_SHIFT); --sp; funcnum &= 0xFFFF; // Clear out tag @@ -8399,7 +8398,7 @@ scriptwait: goto scriptwait; case PCD_SCRIPTWAITNAMED: - statedata = -FName(FBehavior::StaticLookupString(STACK(1))); + statedata = -FName(level.Behaviors.LookupString(STACK(1))); sp--; goto scriptwait; @@ -8462,7 +8461,7 @@ scriptwait: case PCD_PRINTSTRING: case PCD_PRINTLOCALIZED: - lookup = FBehavior::StaticLookupString (STACK(1)); + lookup = level.Behaviors.LookupString (STACK(1)); if (pcd == PCD_PRINTLOCALIZED) { lookup = GStrings(lookup); @@ -8650,7 +8649,7 @@ scriptwait: // [GRB] Print key name(s) for a command case PCD_PRINTBIND: - lookup = FBehavior::StaticLookupString (STACK(1)); + lookup = level.Behaviors.LookupString (STACK(1)); if (lookup != NULL) { int key1 = 0, key2 = 0; @@ -8737,7 +8736,7 @@ scriptwait: if (type & HUDMSG_COLORSTRING) { - color = V_FindFontColor(FBehavior::StaticLookupString(Stack[optstart-4])); + color = V_FindFontColor(level.Behaviors.LookupString(Stack[optstart-4])); } else { @@ -8882,7 +8881,7 @@ scriptwait: break; case PCD_MUSICCHANGE: - lookup = FBehavior::StaticLookupString (STACK(2)); + lookup = level.Behaviors.LookupString (STACK(2)); if (lookup != NULL) { S_ChangeMusic (lookup, STACK(1)); @@ -8900,7 +8899,7 @@ scriptwait: break; case PCD_SECTORSOUND: - lookup = FBehavior::StaticLookupString (STACK(2)); + lookup = level.Behaviors.LookupString (STACK(2)); if (lookup != NULL) { if (activationline) @@ -8925,7 +8924,7 @@ scriptwait: break; case PCD_AMBIENTSOUND: - lookup = FBehavior::StaticLookupString (STACK(2)); + lookup = level.Behaviors.LookupString (STACK(2)); if (lookup != NULL) { S_Sound (CHAN_AUTO, @@ -8936,7 +8935,7 @@ scriptwait: break; case PCD_LOCALAMBIENTSOUND: - lookup = FBehavior::StaticLookupString (STACK(2)); + lookup = level.Behaviors.LookupString (STACK(2)); if (lookup != NULL && activator->CheckLocalView (consoleplayer)) { S_Sound (CHAN_AUTO, @@ -8947,7 +8946,7 @@ scriptwait: break; case PCD_ACTIVATORSOUND: - lookup = FBehavior::StaticLookupString (STACK(2)); + lookup = level.Behaviors.LookupString (STACK(2)); if (lookup != NULL) { if (activator != NULL) @@ -8967,7 +8966,7 @@ scriptwait: break; case PCD_SOUNDSEQUENCE: - lookup = FBehavior::StaticLookupString (STACK(1)); + lookup = level.Behaviors.LookupString (STACK(1)); if (lookup != NULL) { if (activationline != NULL) @@ -8985,8 +8984,8 @@ scriptwait: case PCD_REPLACETEXTURES: { - const char *fromname = FBehavior::StaticLookupString(STACK(3)); - const char *toname = FBehavior::StaticLookupString(STACK(2)); + const char *fromname = level.Behaviors.LookupString(STACK(3)); + const char *toname = level.Behaviors.LookupString(STACK(2)); P_ReplaceTextures(fromname, toname, STACK(1)); sp -= 3; @@ -9057,7 +9056,7 @@ scriptwait: if (specnum >= -ACSF_ACS_NamedExecuteAlways && specnum <= -ACSF_ACS_NamedExecute) { specnum = NamedACSToNormalACS[-specnum - ACSF_ACS_NamedExecute]; - arg0 = -FName(FBehavior::StaticLookupString(arg0)); + arg0 = -FName(level.Behaviors.LookupString(arg0)); } FLineIdIterator itr(STACK(7)); @@ -9086,7 +9085,7 @@ scriptwait: if (specnum >= -ACSF_ACS_NamedExecuteAlways && specnum <= -ACSF_ACS_NamedExecute) { specnum = NamedACSToNormalACS[-specnum - ACSF_ACS_NamedExecute]; - arg0 = -FName(FBehavior::StaticLookupString(arg0)); + arg0 = -FName(level.Behaviors.LookupString(arg0)); } if (STACK(7) != 0) @@ -9118,7 +9117,7 @@ scriptwait: break; case PCD_THINGSOUND: - lookup = FBehavior::StaticLookupString (STACK(2)); + lookup = level.Behaviors.LookupString (STACK(2)); if (lookup != NULL) { FActorIterator iterator (STACK(3)); @@ -9214,7 +9213,7 @@ scriptwait: case PCD_GIVEINVENTORY: { - int typeindex = FName(FBehavior::StaticLookupString(STACK(2))).GetIndex(); + int typeindex = FName(level.Behaviors.LookupString(STACK(2))).GetIndex(); ScriptUtil::Exec(NAME_GiveInventory, ScriptUtil::Pointer, activator, ScriptUtil::Int, typeindex, ScriptUtil::Int, STACK(1), ScriptUtil::End); sp -= 2; break; @@ -9222,8 +9221,8 @@ scriptwait: case PCD_GIVEACTORINVENTORY: { - int typeindex = FName(FBehavior::StaticLookupString(STACK(2))).GetIndex(); - FName type = FName(FBehavior::StaticLookupString(STACK(2))); + int typeindex = FName(level.Behaviors.LookupString(STACK(2))).GetIndex(); + FName type = FName(level.Behaviors.LookupString(STACK(2))); if (STACK(3) == 0) { ScriptUtil::Exec(NAME_GiveInventory, ScriptUtil::Pointer, nullptr, ScriptUtil::Int, typeindex, ScriptUtil::Int, STACK(1), ScriptUtil::End); @@ -9243,7 +9242,7 @@ scriptwait: case PCD_GIVEINVENTORYDIRECT: { - int typeindex = FName(FBehavior::StaticLookupString(TAGSTR(uallong(pc[0])))).GetIndex(); + int typeindex = FName(level.Behaviors.LookupString(TAGSTR(uallong(pc[0])))).GetIndex(); ScriptUtil::Exec(NAME_GiveInventory, ScriptUtil::Pointer, activator, ScriptUtil::Int, typeindex, ScriptUtil::Int, uallong(pc[1]), ScriptUtil::End); pc += 2; break; @@ -9251,7 +9250,7 @@ scriptwait: case PCD_TAKEINVENTORY: { - int typeindex = FName(FBehavior::StaticLookupString(STACK(2))).GetIndex(); + int typeindex = FName(level.Behaviors.LookupString(STACK(2))).GetIndex(); ScriptUtil::Exec(NAME_TakeInventory, ScriptUtil::Pointer, activator, ScriptUtil::Int, typeindex, ScriptUtil::Int, STACK(1), ScriptUtil::End); sp -= 2; break; @@ -9259,8 +9258,8 @@ scriptwait: case PCD_TAKEACTORINVENTORY: { - int typeindex = FName(FBehavior::StaticLookupString(STACK(2))).GetIndex(); - FName type = FName(FBehavior::StaticLookupString(STACK(2))); + int typeindex = FName(level.Behaviors.LookupString(STACK(2))).GetIndex(); + FName type = FName(level.Behaviors.LookupString(STACK(2))); if (STACK(3) == 0) { ScriptUtil::Exec(NAME_TakeInventory, ScriptUtil::Pointer, nullptr, ScriptUtil::Int, typeindex, ScriptUtil::Int, STACK(1), ScriptUtil::End); @@ -9280,35 +9279,35 @@ scriptwait: case PCD_TAKEINVENTORYDIRECT: { - int typeindex = FName(FBehavior::StaticLookupString(TAGSTR(uallong(pc[0])))).GetIndex(); + int typeindex = FName(level.Behaviors.LookupString(TAGSTR(uallong(pc[0])))).GetIndex(); ScriptUtil::Exec(NAME_TakeInventory, ScriptUtil::Pointer, activator, ScriptUtil::Int, typeindex, ScriptUtil::Int, uallong(pc[1]), ScriptUtil::End); pc += 2; break; } case PCD_CHECKINVENTORY: - STACK(1) = CheckInventory (activator, FBehavior::StaticLookupString (STACK(1)), false); + STACK(1) = CheckInventory (activator, level.Behaviors.LookupString (STACK(1)), false); break; case PCD_CHECKACTORINVENTORY: STACK(2) = CheckInventory (SingleActorFromTID(STACK(2), NULL), - FBehavior::StaticLookupString (STACK(1)), false); + level.Behaviors.LookupString (STACK(1)), false); sp--; break; case PCD_CHECKINVENTORYDIRECT: - PushToStack (CheckInventory (activator, FBehavior::StaticLookupString (TAGSTR(uallong(pc[0]))), false)); + PushToStack (CheckInventory (activator, level.Behaviors.LookupString (TAGSTR(uallong(pc[0]))), false)); pc += 1; break; case PCD_USEINVENTORY: - STACK(1) = UseInventory (activator, FBehavior::StaticLookupString (STACK(1))); + STACK(1) = UseInventory (activator, level.Behaviors.LookupString (STACK(1))); break; case PCD_USEACTORINVENTORY: { int ret = 0; - const char *type = FBehavior::StaticLookupString(STACK(1)); + const char *type = level.Behaviors.LookupString(STACK(1)); if (STACK(2) == 0) { ret = UseInventory(NULL, type); @@ -9345,7 +9344,7 @@ scriptwait: case PCD_GETAMMOCAPACITY: if (activator != NULL) { - PClass *type = PClass::FindClass (FBehavior::StaticLookupString (STACK(1))); + PClass *type = PClass::FindClass (level.Behaviors.LookupString (STACK(1))); if (type != NULL && type->ParentClass == PClass::FindActor(NAME_Ammo)) { @@ -9373,7 +9372,7 @@ scriptwait: case PCD_SETAMMOCAPACITY: if (activator != NULL) { - PClassActor *type = PClass::FindActor (FBehavior::StaticLookupString (STACK(2))); + PClassActor *type = PClass::FindActor (level.Behaviors.LookupString (STACK(2))); if (type != NULL && type->ParentClass == PClass::FindActor(NAME_Ammo)) { @@ -9397,19 +9396,19 @@ scriptwait: break; case PCD_SETMUSIC: - S_ChangeMusic (FBehavior::StaticLookupString (STACK(3)), STACK(2)); + S_ChangeMusic (level.Behaviors.LookupString (STACK(3)), STACK(2)); sp -= 3; break; case PCD_SETMUSICDIRECT: - S_ChangeMusic (FBehavior::StaticLookupString (TAGSTR(uallong(pc[0]))), uallong(pc[1])); + S_ChangeMusic (level.Behaviors.LookupString (TAGSTR(uallong(pc[0]))), uallong(pc[1])); pc += 3; break; case PCD_LOCALSETMUSIC: if (activator == players[consoleplayer].mo) { - S_ChangeMusic (FBehavior::StaticLookupString (STACK(3)), STACK(2)); + S_ChangeMusic (level.Behaviors.LookupString (STACK(3)), STACK(2)); } sp -= 3; break; @@ -9417,7 +9416,7 @@ scriptwait: case PCD_LOCALSETMUSICDIRECT: if (activator == players[consoleplayer].mo) { - S_ChangeMusic (FBehavior::StaticLookupString (TAGSTR(uallong(pc[0]))), uallong(pc[1])); + S_ChangeMusic (level.Behaviors.LookupString (TAGSTR(uallong(pc[0]))), uallong(pc[1])); } pc += 3; break; @@ -9706,7 +9705,7 @@ scriptwait: } else { - STACK(1) = activator->player->ReadyWeapon->GetClass()->TypeName == FName(FBehavior::StaticLookupString (STACK(1)), true); + STACK(1) = activator->player->ReadyWeapon->GetClass()->TypeName == FName(level.Behaviors.LookupString (STACK(1)), true); } break; @@ -9802,14 +9801,14 @@ scriptwait: case PCD_SPAWNPROJECTILE: // Same, but takes an actor name instead of a spawn ID. - P_Thing_Projectile(STACK(7), activator, 0, FBehavior::StaticLookupString(STACK(6)), STACK(5) * (360. / 256.), + P_Thing_Projectile(STACK(7), activator, 0, level.Behaviors.LookupString(STACK(6)), STACK(5) * (360. / 256.), STACK(4) / 8., STACK(3) / 8., 0, NULL, STACK(2), STACK(1), false); sp -= 7; break; case PCD_STRLEN: { - const char *str = FBehavior::StaticLookupString(STACK(1)); + const char *str = level.Behaviors.LookupString(STACK(1)); if (str != NULL) { STACK(1) = int32_t(strlen(str)); @@ -9827,7 +9826,7 @@ scriptwait: break; case PCD_GETCVAR: - STACK(1) = DoGetCVar(GetCVar(activator, FBehavior::StaticLookupString(STACK(1))), false); + STACK(1) = DoGetCVar(GetCVar(activator, level.Behaviors.LookupString(STACK(1))), false); break; case PCD_SETHUDSIZE: @@ -9861,8 +9860,8 @@ scriptwait: { const char *sky1name, *sky2name; - sky1name = FBehavior::StaticLookupString (STACK(2)); - sky2name = FBehavior::StaticLookupString (STACK(1)); + sky1name = level.Behaviors.LookupString (STACK(2)); + sky2name = level.Behaviors.LookupString (STACK(1)); if (sky1name[0] != 0) { sky1texture = level.skytexture1 = TexMan.GetTextureID(sky1name, ETextureType::Wall, FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_ReturnFirst); @@ -9878,7 +9877,7 @@ scriptwait: case PCD_SETCAMERATOTEXTURE: { - const char *picname = FBehavior::StaticLookupString (STACK(2)); + const char *picname = level.Behaviors.LookupString (STACK(2)); AActor *camera; if (STACK(3) == 0) @@ -9919,7 +9918,7 @@ scriptwait: case PCD_SETACTORSTATE: { - const char *statename = FBehavior::StaticLookupString (STACK(2)); + const char *statename = level.Behaviors.LookupString (STACK(2)); FState *state; if (STACK(3) == 0) @@ -9999,7 +9998,7 @@ scriptwait: case PCD_CHANGELEVEL: { - G_ChangeLevel(FBehavior::StaticLookupString(STACK(4)), STACK(3), STACK(2), STACK(1)); + G_ChangeLevel(level.Behaviors.LookupString(STACK(4)), STACK(3), STACK(2), STACK(1)); sp -= 4; } break; @@ -10008,8 +10007,8 @@ scriptwait: { int tag = STACK(5); int amount = STACK(4); - FName type = FBehavior::StaticLookupString(STACK(3)); - FName protection = FName (FBehavior::StaticLookupString(STACK(2)), true); + FName type = level.Behaviors.LookupString(STACK(3)); + FName protection = FName (level.Behaviors.LookupString(STACK(2)), true); PClassActor *protectClass = PClass::FindActor (protection); int flags = STACK(1); sp -= 5; @@ -10019,7 +10018,7 @@ scriptwait: break; case PCD_THINGDAMAGE2: - STACK(3) = P_Thing_Damage (STACK(3), activator, STACK(2), FName(FBehavior::StaticLookupString(STACK(1)))); + STACK(3) = P_Thing_Damage (STACK(3), activator, STACK(2), FName(level.Behaviors.LookupString(STACK(1)))); sp -= 2; break; @@ -10066,7 +10065,7 @@ scriptwait: case PCD_SETMUGSHOTSTATE: if (!multiplayer || (activator != nullptr && activator->CheckLocalView(consoleplayer))) { - StatusBar->SetMugShotState(FBehavior::StaticLookupString(STACK(1))); + StatusBar->SetMugShotState(level.Behaviors.LookupString(STACK(1))); } sp--; break; @@ -10093,15 +10092,15 @@ scriptwait: case PCD_MORPHACTOR: { int tag = STACK(7); - FName playerclass_name = FBehavior::StaticLookupString(STACK(6)); + FName playerclass_name = level.Behaviors.LookupString(STACK(6)); auto playerclass = PClass::FindActor (playerclass_name); - FName monsterclass_name = FBehavior::StaticLookupString(STACK(5)); + FName monsterclass_name = level.Behaviors.LookupString(STACK(5)); PClassActor *monsterclass = PClass::FindActor(monsterclass_name); int duration = STACK(4); int style = STACK(3); - FName morphflash_name = FBehavior::StaticLookupString(STACK(2)); + FName morphflash_name = level.Behaviors.LookupString(STACK(2)); PClassActor *morphflash = PClass::FindActor(morphflash_name); - FName unmorphflash_name = FBehavior::StaticLookupString(STACK(1)); + FName unmorphflash_name = level.Behaviors.LookupString(STACK(1)); PClassActor *unmorphflash = PClass::FindActor(unmorphflash_name); int changes = 0; @@ -10181,7 +10180,7 @@ scriptwait: index += STACK(6); - lookup = FBehavior::StaticLookupString (STACK(2)); + lookup = level.Behaviors.LookupString (STACK(2)); if (!lookup) { // no data, operation complete @@ -10399,7 +10398,7 @@ void P_DoDeferedScripts () { case acsdefered_t::defexecute: case acsdefered_t::defexealways: - scriptdata = FBehavior::StaticFindScript (def->script, module); + scriptdata = level.Behaviors.FindScript (def->script, module); if (scriptdata) { P_GetScriptGoing ((unsigned)def->playernum < MAXPLAYERS && @@ -10467,7 +10466,7 @@ int P_StartScript (AActor *who, line_t *where, int script, const char *map, cons FBehavior *module = NULL; const ScriptPtr *scriptdata; - if ((scriptdata = FBehavior::StaticFindScript (script, module)) != NULL) + if ((scriptdata = level.Behaviors.FindScript (script, module)) != NULL) { if ((flags & ACS_NET) && netgame && !sv_cheats) { @@ -10609,9 +10608,9 @@ void ACSProfileInfo::AddRun(unsigned int num_instr) void ArrangeScriptProfiles(TArray &profiles) { - for (unsigned int mod_num = 0; mod_num < FBehavior::StaticModules.Size(); ++mod_num) + for (unsigned int mod_num = 0; mod_num < level.Behaviors.StaticModules.Size(); ++mod_num) { - FBehavior *module = FBehavior::StaticModules[mod_num]; + FBehavior *module = level.Behaviors.StaticModules[mod_num]; ProfileCollector prof; prof.Module = module; for (int i = 0; i < module->NumScripts; ++i) @@ -10625,9 +10624,9 @@ void ArrangeScriptProfiles(TArray &profiles) void ArrangeFunctionProfiles(TArray &profiles) { - for (unsigned int mod_num = 0; mod_num < FBehavior::StaticModules.Size(); ++mod_num) + for (unsigned int mod_num = 0; mod_num < level.Behaviors.StaticModules.Size(); ++mod_num) { - FBehavior *module = FBehavior::StaticModules[mod_num]; + FBehavior *module = level.Behaviors.StaticModules[mod_num]; ProfileCollector prof; prof.Module = module; for (int i = 0; i < module->NumFunctions; ++i) diff --git a/src/p_acs.h b/src/p_acs.h index 9115a370b..14e2bb0a4 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -344,6 +344,7 @@ enum enum ACSFormat { ACS_Old, ACS_Enhanced, ACS_LittleEnhanced, ACS_Unknown }; + class FBehavior { public: @@ -381,20 +382,6 @@ public: BoundsCheckingArray MapVars; - static FBehavior *StaticLoadModule (int lumpnum, FileReader *fr = nullptr, int len=0); - static void StaticLoadDefaultModules (); - static void StaticUnloadModules (); - static bool StaticCheckAllGood (); - static FBehavior *StaticGetModule (int lib); - static void StaticSerializeModuleStates (FSerializer &arc); - static void StaticMarkLevelVarStrings(); - static void StaticLockLevelVarStrings(); - static void StaticUnlockLevelVarStrings(); - - static const ScriptPtr *StaticFindScript (int script, FBehavior *&module); - static const char *StaticLookupString (uint32_t index); - static void StaticStartTypedScripts (uint16_t type, AActor *activator, bool always, int arg1=0, bool runNow=false); - static void StaticStopMyScripts (AActor *actor); private: struct ArrayInfo; @@ -421,8 +408,6 @@ private: char ModuleName[9]; TArray JumpPoints; - static TArray StaticModules; - void LoadScriptsDirectory (); static int SortScripts (const void *a, const void *b); @@ -439,6 +424,30 @@ private: friend void ArrangeScriptProfiles(TArray &profiles); friend void ArrangeFunctionProfiles(TArray &profiles); + friend struct FBehaviorContainer; }; +struct FBehaviorContainer +{ + TArray StaticModules; + + FBehavior *LoadModule(int lumpnum, FileReader *fr = nullptr, int len = 0); + void LoadDefaultModules(); + void UnloadModules(); + bool CheckAllGood(); + FBehavior *GetModule(int lib); + void SerializeModuleStates(FSerializer &arc); + void MarkLevelVarStrings(); + void LockLevelVarStrings(); + void UnlockLevelVarStrings(); + + const ScriptPtr *FindScript(int script, FBehavior *&module); + const char *LookupString(uint32_t index); + void StartTypedScripts(uint16_t type, AActor *activator, bool always, int arg1 = 0, bool runNow = false); + void StopMyScripts(AActor *actor); + +}; + + + #endif //__P_ACS_H__ diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 9ec48bec6..ff921aefd 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -352,7 +352,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf // [JM] Fire KILL type scripts for actor. Not needed for players, since they have the "DEATH" script type. if (!player && !(flags7 & MF7_NOKILLSCRIPTS) && ((flags7 & MF7_USEKILLSCRIPTS) || gameinfo.forcekillscripts)) { - FBehavior::StaticStartTypedScripts(SCRIPT_Kill, this, true, 0, true); + level.Behaviors.StartTypedScripts(SCRIPT_Kill, this, true, 0, true); } flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SKULLFLY); @@ -563,7 +563,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf E_PlayerDied(int(player - players)); // Death script execution, care of Skull Tag - FBehavior::StaticStartTypedScripts (SCRIPT_Death, this, true); + level.Behaviors.StartTypedScripts (SCRIPT_Death, this, true); // [RH] Force a delay between death and respawn player->respawn_time = level.time + TICRATE; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index be4789e2f..805f477c9 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5018,7 +5018,7 @@ AActor *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) VMValue params[] = { mobj, oldactor }; VMCall(func, params, 2, nullptr, 0); } - FBehavior::StaticStopMyScripts (oldactor); // cancel all ENTER/RESPAWN scripts for the voodoo doll + level.Behaviors.StopMyScripts (oldactor); // cancel all ENTER/RESPAWN scripts for the voodoo doll } // [GRB] Reset skin @@ -5147,7 +5147,7 @@ AActor *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) { if (state == PST_ENTER || (state == PST_LIVE && !savegamerestore)) { - FBehavior::StaticStartTypedScripts (SCRIPT_Enter, p->mo, true); + level.Behaviors.StartTypedScripts (SCRIPT_Enter, p->mo, true); } else if (state == PST_REBORN) { @@ -5171,7 +5171,7 @@ AActor *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) DObject::StaticPointerSubstitution (oldactor, p->mo); E_PlayerRespawned(int(p - players)); - FBehavior::StaticStartTypedScripts (SCRIPT_Respawn, p->mo, true); + level.Behaviors.StartTypedScripts (SCRIPT_Respawn, p->mo, true); } } return mobj; diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 67e5ca4a5..eea0e18bf 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -992,11 +992,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload) G_AirControlChanged(); } - - - // fixme: This needs to ensure it reads from the correct place. Should be one once there's enough of this code converted to JSON - - FBehavior::StaticSerializeModuleStates(arc); + level.Behaviors.SerializeModuleStates(arc); // The order here is important: First world state, then portal state, then thinkers, and last polyobjects. arc("linedefs", level.lines, level.loadlines); arc("sidedefs", level.sides, level.loadsides); diff --git a/src/p_setup.cpp b/src/p_setup.cpp index d2d76c965..6a022fb06 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -340,7 +340,7 @@ void P_FreeLevelData () DThinker::DestroyAllThinkers (); tagManager.Clear(); - FBehavior::StaticUnloadModules (); + level.Behaviors.UnloadModules (); P_FreeStrifeConversations (); level.ClearLevelData(); diff --git a/src/p_spec.cpp b/src/p_spec.cpp index ce521c42a..45eb32bf9 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -1505,7 +1505,7 @@ void P_SpawnSpecials (MapLoader *ml) } } // [RH] Start running any open scripts on this map - FBehavior::StaticStartTypedScripts (SCRIPT_Open, NULL, false); + level.Behaviors.StartTypedScripts (SCRIPT_Open, NULL, false); } //////////////////////////////////////////////////////////////////////////// diff --git a/src/p_user.cpp b/src/p_user.cpp index 1932ac1b3..55f643783 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -693,7 +693,7 @@ bool player_t::Resurrect() // fire E_PlayerRespawned and start the ACS SCRIPT_Respawn. E_PlayerRespawned(int(this - players)); // - FBehavior::StaticStartTypedScripts(SCRIPT_Respawn, mo, true); + level.Behaviors.StartTypedScripts(SCRIPT_Respawn, mo, true); return true; } diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index 10f10b992..cd7473c4f 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -2368,19 +2368,19 @@ DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, SetClipRect, SBar_SetClipRect) static void GetGlobalACSString(int index, FString *result) { - *result = FBehavior::StaticLookupString(ACS_GlobalVars[index]); + *result = level.Behaviors.LookupString(ACS_GlobalVars[index]); } DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, GetGlobalACSString, GetGlobalACSString) { PARAM_PROLOGUE; PARAM_INT(index); - ACTION_RETURN_STRING(FBehavior::StaticLookupString(ACS_GlobalVars[index])); + ACTION_RETURN_STRING(level.Behaviors.LookupString(ACS_GlobalVars[index])); } static void GetGlobalACSArrayString(int arrayno, int index, FString *result) { - *result = FBehavior::StaticLookupString(ACS_GlobalVars[index]); + *result = level.Behaviors.LookupString(ACS_GlobalVars[index]); } DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, GetGlobalACSArrayString, GetGlobalACSArrayString) @@ -2388,7 +2388,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, GetGlobalACSArrayString, GetGlobal PARAM_PROLOGUE; PARAM_INT(arrayno); PARAM_INT(index); - ACTION_RETURN_STRING(FBehavior::StaticLookupString(ACS_GlobalArrays[arrayno][index])); + ACTION_RETURN_STRING(level.Behaviors.LookupString(ACS_GlobalArrays[arrayno][index])); } static int GetGlobalACSValue(int index) diff --git a/src/scriptutil.cpp b/src/scriptutil.cpp index d233d80fd..bcb5fe9d0 100644 --- a/src/scriptutil.cpp +++ b/src/scriptutil.cpp @@ -62,7 +62,7 @@ void ScriptUtil::BuildParameters(va_list ap) break; case ACSClass: - parameters.Push(VMValue(PClass::FindActor(FBehavior::StaticLookupString(va_arg(ap, int))))); + parameters.Push(VMValue(PClass::FindActor(level.Behaviors.LookupString(va_arg(ap, int))))); break; } }