diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 4c809d787b..141fdbc1c2 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -60,6 +60,7 @@ class DSectorMarker; typedef TMap FDialogueIDMap; // maps dialogue IDs to dialogue array index (for ACS) typedef TMap FDialogueMap; // maps actor class names to dialogue array index +typedef TMap FUDMFKeyMap; struct FLevelData { @@ -121,6 +122,8 @@ struct FLevelData int i_compatflags = 0; int i_compatflags2 = 0; + FUDMFKeyMap UDMFKeys[4]; + }; diff --git a/src/maploader/udmf.cpp b/src/maploader/udmf.cpp index b1027c7997..a849a1b743 100644 --- a/src/maploader/udmf.cpp +++ b/src/maploader/udmf.cpp @@ -285,20 +285,6 @@ const char *UDMFParserBase::CheckString(const char *key) // //=========================================================================== -typedef TMap FUDMFKeyMap; - - -static FUDMFKeyMap UDMFKeys[4]; -// Things must be handled differently - -void P_ClearUDMFKeys() -{ - for(int i=0;i<4;i++) - { - UDMFKeys[i].Clear(); - } -} - static int udmfcmp(const void *a, const void *b) { FUDMFKey *A = (FUDMFKey*)a; @@ -346,11 +332,11 @@ FUDMFKey *FUDMFKeys::Find(FName key) // //=========================================================================== -int GetUDMFInt(int type, int index, FName key) +int GetUDMFInt(FLevelLocals *Level, int type, int index, FName key) { assert(type >=0 && type <=3); - FUDMFKeys *pKeys = UDMFKeys[type].CheckKey(index); + FUDMFKeys *pKeys = Level->UDMFKeys[type].CheckKey(index); if (pKeys != NULL) { @@ -363,11 +349,11 @@ int GetUDMFInt(int type, int index, FName key) return 0; } -double GetUDMFFloat(int type, int index, FName key) +double GetUDMFFloat(FLevelLocals *Level, int type, int index, FName key) { assert(type >=0 && type <=3); - FUDMFKeys *pKeys = UDMFKeys[type].CheckKey(index); + FUDMFKeys *pKeys = Level->UDMFKeys[type].CheckKey(index); if (pKeys != NULL) { @@ -380,11 +366,11 @@ double GetUDMFFloat(int type, int index, FName key) return 0; } -FString GetUDMFString(int type, int index, FName key) +FString GetUDMFString(FLevelLocals *Level, int type, int index, FName key) { assert(type >= 0 && type <= 3); - FUDMFKeys *pKeys = UDMFKeys[type].CheckKey(index); + FUDMFKeys *pKeys = Level->UDMFKeys[type].CheckKey(index); if (pKeys != NULL) { @@ -459,7 +445,7 @@ public: } void AddUserKey(FName key, int kind, int index) { - FUDMFKeys &keyarray = UDMFKeys[kind][index]; + FUDMFKeys &keyarray = Level->UDMFKeys[kind][index]; for(unsigned i=0; i < keyarray.Size(); i++) { diff --git a/src/p_acs.cpp b/src/p_acs.cpp index d6e990a598..d637e7117f 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -5311,26 +5311,26 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) switch(funcIndex) { case ACSF_GetLineUDMFInt: - return GetUDMFInt(UDMF_Line, LineFromID(args[0]), Level->Behaviors.LookupString(args[1])); + return GetUDMFInt(Level, UDMF_Line, LineFromID(args[0]), Level->Behaviors.LookupString(args[1])); case ACSF_GetLineUDMFFixed: - return DoubleToACS(GetUDMFFloat(UDMF_Line, LineFromID(args[0]), Level->Behaviors.LookupString(args[1]))); + return DoubleToACS(GetUDMFFloat(Level, 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, Level->tagManager.FindFirstSectorFromTag(args[0]), Level->Behaviors.LookupString(args[1])); + return GetUDMFInt(Level, UDMF_Sector, Level->tagManager.FindFirstSectorFromTag(args[0]), Level->Behaviors.LookupString(args[1])); case ACSF_GetSectorUDMFFixed: - return DoubleToACS(GetUDMFFloat(UDMF_Sector, Level->tagManager.FindFirstSectorFromTag(args[0]), Level->Behaviors.LookupString(args[1]))); + return DoubleToACS(GetUDMFFloat(Level, UDMF_Sector, Level->tagManager.FindFirstSectorFromTag(args[0]), Level->Behaviors.LookupString(args[1]))); case ACSF_GetSideUDMFInt: - return GetUDMFInt(UDMF_Side, SideFromID(args[0], args[1]), Level->Behaviors.LookupString(args[2])); + return GetUDMFInt(Level, 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]), Level->Behaviors.LookupString(args[2]))); + return DoubleToACS(GetUDMFFloat(Level, UDMF_Side, SideFromID(args[0], args[1]), Level->Behaviors.LookupString(args[2]))); case ACSF_GetActorVelX: actor = SingleActorFromTID(args[0], activator); diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 98d8a5780e..3f747fffe5 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -73,8 +73,6 @@ #include "p_acs.h" #include "fragglescript/t_script.h" -void P_ClearUDMFKeys(); - extern unsigned int R_OldBlend; static void P_Shutdown (); @@ -261,6 +259,11 @@ void FLevelLocals::ClearLevelData() total_monsters = total_items = total_secrets = killed_monsters = found_items = found_secrets = wminfo.maxfrags = 0; + + for (int i = 0; i < 4; i++) + { + UDMFKeys[i].Clear(); + } SN_StopAllSequences(this); @@ -352,7 +355,6 @@ void P_FreeLevelData () // [ZZ] delete per-map event handlers E_Shutdown(true); R_FreePastViewers(); - P_ClearUDMFKeys(); level.ClearLevelData(); } diff --git a/src/p_setup.h b/src/p_setup.h index 46082dab04..587fc96ea9 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -160,9 +160,9 @@ void P_LoadTranslator(const char *lumpname); void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid = -1); int P_TranslateSectorSpecial (int); -int GetUDMFInt(int type, int index, FName key); -double GetUDMFFloat(int type, int index, FName key); -FString GetUDMFString(int type, int index, FName key); +int GetUDMFInt(FLevelLocals *Level, int type, int index, FName key); +double GetUDMFFloat(FLevelLocals *Level, int type, int index, FName key); +FString GetUDMFString(FLevelLocals *Level, int type, int index, FName key); void FixMinisegReferences(); void FixHoles(); diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index cd9d9a4f23..48960d7469 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -2534,7 +2534,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetAutomapPosition, GetAutomapPositi static int ZGetUDMFInt(FLevelLocals *self, int type, int index, int key) { - return GetUDMFInt(type, index, ENamedName(key)); + return GetUDMFInt(self,type, index, ENamedName(key)); } DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFInt, ZGetUDMFInt) @@ -2543,12 +2543,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFInt, ZGetUDMFInt) PARAM_INT(type); PARAM_INT(index); PARAM_NAME(key); - ACTION_RETURN_INT(GetUDMFInt(type, index, key)); + ACTION_RETURN_INT(GetUDMFInt(self, type, index, key)); } static double ZGetUDMFFloat(FLevelLocals *self, int type, int index, int key) { - return GetUDMFFloat(type, index, ENamedName(key)); + return GetUDMFFloat(self, type, index, ENamedName(key)); } DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFFloat, ZGetUDMFFloat) @@ -2557,12 +2557,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFFloat, ZGetUDMFFloat) PARAM_INT(type); PARAM_INT(index); PARAM_NAME(key); - ACTION_RETURN_FLOAT(GetUDMFFloat(type, index, key)); + ACTION_RETURN_FLOAT(GetUDMFFloat(self, type, index, key)); } static void ZGetUDMFString(FLevelLocals *self, int type, int index, int key, FString *result) { - *result = GetUDMFString(type, index, ENamedName(key)); + *result = GetUDMFString(self, type, index, ENamedName(key)); } DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFString, ZGetUDMFString) @@ -2571,7 +2571,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFString, ZGetUDMFString) PARAM_INT(type); PARAM_INT(index); PARAM_NAME(key); - ACTION_RETURN_STRING(GetUDMFString(type, index, key)); + ACTION_RETURN_STRING(GetUDMFString(self, type, index, key)); } DEFINE_ACTION_FUNCTION(FLevelLocals, GetChecksum)