From 20d3752fddd6010c34735e5cda5faf0725d7a4ca Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 25 Nov 2019 17:37:56 +0200 Subject: [PATCH] - exported several Wads.GetLump...() methods to ZScript * GetLumpName() returns 8-characters lump name * GetLumpFullName() returns full name with path and extension * GetLumpNamespace() returns lump's namespace * GetNumLumps() returns total number of lumps https://forum.zdoom.org/viewtopic.php?t=66285 --- src/gamedata/w_wad.cpp | 29 +++++++++++++++++++++++++++++ wadsrc/static/zscript/base.zs | 5 +++++ 2 files changed, 34 insertions(+) diff --git a/src/gamedata/w_wad.cpp b/src/gamedata/w_wad.cpp index d7d9911d8..5c37a5998 100644 --- a/src/gamedata/w_wad.cpp +++ b/src/gamedata/w_wad.cpp @@ -371,6 +371,12 @@ int FWadCollection::GetNumLumps () const return NumLumps; } +DEFINE_ACTION_FUNCTION(_Wads, GetNumLumps) +{ + PARAM_PROLOGUE; + ACTION_RETURN_INT(Wads.GetNumLumps()); +} + //========================================================================== // // GetNumFiles @@ -1220,6 +1226,15 @@ void FWadCollection::GetLumpName(FString &to, int lump) const } } +DEFINE_ACTION_FUNCTION(_Wads, GetLumpName) +{ + PARAM_PROLOGUE; + PARAM_INT(lump); + FString lumpname; + Wads.GetLumpName(lumpname, lump); + ACTION_RETURN_STRING(lumpname); +} + //========================================================================== // // FWadCollection :: GetLumpFullName @@ -1238,6 +1253,13 @@ const char *FWadCollection::GetLumpFullName (int lump) const return LumpInfo[lump].lump->Name; } +DEFINE_ACTION_FUNCTION(_Wads, GetLumpFullName) +{ + PARAM_PROLOGUE; + PARAM_INT(lump); + ACTION_RETURN_STRING(Wads.GetLumpFullName(lump)); +} + //========================================================================== // // FWadCollection :: GetLumpFullPath @@ -1271,6 +1293,13 @@ int FWadCollection::GetLumpNamespace (int lump) const return LumpInfo[lump].lump->Namespace; } +DEFINE_ACTION_FUNCTION(_Wads, GetLumpNamespace) +{ + PARAM_PROLOGUE; + PARAM_INT(lump); + ACTION_RETURN_INT(Wads.GetLumpNamespace(lump)); +} + //========================================================================== // // FWadCollection :: GetLumpIndexNum diff --git a/wadsrc/static/zscript/base.zs b/wadsrc/static/zscript/base.zs index 0f617050a..e3d4c0a32 100644 --- a/wadsrc/static/zscript/base.zs +++ b/wadsrc/static/zscript/base.zs @@ -873,6 +873,11 @@ struct Wads native static int CheckNumForFullName(string name); native static int FindLump(string name, int startlump = 0, FindLumpNamespace ns = GlobalNamespace); native static string ReadLump(int lump); + + native static int GetNumLumps(); + native static string GetLumpName(int lump); + native static string GetLumpFullName(int lump); + native static int GetLumpNamespace(int lump); } struct TerrainDef native