diff --git a/src/p_setup.h b/src/p_setup.h index 3d8c021a74..13bfad72e7 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -118,8 +118,8 @@ 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, const char *key); -double GetUDMFFloat(int type, int index, const char *key); +int GetUDMFInt(int type, int index, FName key); +double GetUDMFFloat(int type, int index, FName key); bool P_LoadGLNodes(MapData * map); bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime); diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index 515905b273..a13c24e631 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -342,7 +342,7 @@ FUDMFKey *FUDMFKeys::Find(FName key) // //=========================================================================== -int GetUDMFInt(int type, int index, const char *key) +int GetUDMFInt(int type, int index, FName key) { assert(type >=0 && type <=3); @@ -359,7 +359,16 @@ int GetUDMFInt(int type, int index, const char *key) return 0; } -double GetUDMFFloat(int type, int index, const char *key) +DEFINE_ACTION_FUNCTION(FLevelLocals, GetUDMFInt) +{ + PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); + PARAM_INT(type); + PARAM_INT(index); + PARAM_NAME(key); + ACTION_RETURN_INT(GetUDMFInt(type, index, key)); +} + +double GetUDMFFloat(int type, int index, FName key) { assert(type >=0 && type <=3); @@ -376,6 +385,41 @@ double GetUDMFFloat(int type, int index, const char *key) return 0; } +DEFINE_ACTION_FUNCTION(FLevelLocals, GetUDMFFloat) +{ + PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); + PARAM_INT(type); + PARAM_INT(index); + PARAM_NAME(key); + ACTION_RETURN_FLOAT(GetUDMFFloat(type, index, key)); +} + +FString GetUDMFString(int type, int index, FName key) +{ + assert(type >= 0 && type <= 3); + + FUDMFKeys *pKeys = UDMFKeys[type].CheckKey(index); + + if (pKeys != NULL) + { + FUDMFKey *pKey = pKeys->Find(key); + if (pKey != NULL) + { + return pKey->StringVal; + } + } + return ""; +} + +DEFINE_ACTION_FUNCTION(FLevelLocals, GetUDMFString) +{ + PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); + PARAM_INT(type); + PARAM_INT(index); + PARAM_NAME(key); + ACTION_RETURN_STRING(GetUDMFString(type, index, key)); +} + //=========================================================================== // diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 22bbcc790c..bffee91f01 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -418,6 +418,14 @@ class SpotState : Object native struct LevelLocals native { + enum EUDMF + { + UDMF_Line, + UDMF_Side, + UDMF_Sector, + //UDMF_Thing // not implemented + }; + native readonly int time; native readonly int maptime; native readonly int totaltime; @@ -457,6 +465,11 @@ struct LevelLocals native native bool frozen; native bool infinite_flight; // level_info_t *info cannot be done yet. + + native String GetUDMFString(int type, int index, Name key); + native int GetUDMFInt(int type, int index, Name key); + native double GetUDMFFloat(int type, int index, Name key); + } struct StringTable native diff --git a/wadsrc/static/zscript/mapdata.txt b/wadsrc/static/zscript/mapdata.txt index b7589f8d4f..5a216ea5eb 100644 --- a/wadsrc/static/zscript/mapdata.txt +++ b/wadsrc/static/zscript/mapdata.txt @@ -84,6 +84,20 @@ struct Side native native Vertex V2(); native int Index(); + + int GetUDMFInt(Name nm) + { + return Level.GetUDMFInt(LevelLocals.UDMF_Side, Index(), nm); + } + double GetUDMFFloat(Name nm) + { + return Level.GetUDMFFloat(LevelLocals.UDMF_Side, Index(), nm); + } + String GetUDMFString(Name nm) + { + return Level.GetUDMFString(LevelLocals.UDMF_Side, Index(), nm); + } + }; struct Line native @@ -142,6 +156,19 @@ struct Line native native Line getPortalDestination(); native int getPortalAlignment(); native int Index(); + + int GetUDMFInt(Name nm) + { + return Level.GetUDMFInt(LevelLocals.UDMF_Line, Index(), nm); + } + double GetUDMFFloat(Name nm) + { + return Level.GetUDMFFloat(LevelLocals.UDMF_Line, Index(), nm); + } + String GetUDMFString(Name nm) + { + return Level.GetUDMFString(LevelLocals.UDMF_Line, Index(), nm); + } } struct SecPlane native @@ -398,4 +425,18 @@ struct Sector native { Flags &= ~SECF_SECRET; } + + int GetUDMFInt(Name nm) + { + return Level.GetUDMFInt(LevelLocals.UDMF_Sector, Index(), nm); + } + double GetUDMFFloat(Name nm) + { + return Level.GetUDMFFloat(LevelLocals.UDMF_Sector, Index(), nm); + } + String GetUDMFString(Name nm) + { + return Level.GetUDMFString(LevelLocals.UDMF_Sector, Index(), nm); + } + }