diff --git a/source/common/engine/i_interface.h b/source/common/engine/i_interface.h index 80cc3b1e9..7bcdab763 100644 --- a/source/common/engine/i_interface.h +++ b/source/common/engine/i_interface.h @@ -22,6 +22,8 @@ struct SystemCallbacks void (*MenuDim)(); FString(*GetPlayerName)(int i); bool (*DispatchEvent)(event_t* ev); + bool (*CheckGame)(const char* nm); + int (*GetGender)(); }; extern SystemCallbacks sysCallbacks; diff --git a/source/common/engine/stringtable.cpp b/source/common/engine/stringtable.cpp index 8927011dc..56b5b6390 100644 --- a/source/common/engine/stringtable.cpp +++ b/source/common/engine/stringtable.cpp @@ -39,6 +39,7 @@ #include "filesystem.h" #include "sc_man.h" #include "printf.h" +#include "i_interface.h" //========================================================================== // @@ -237,12 +238,12 @@ bool FStringTable::ParseLanguageCSV(int lumpnum, const TArray &buffer) if (filterstr.IsNotEmpty()) { bool ok = false; - if (callbacks && callbacks->ValidFilter) + if (sysCallbacks.CheckGame) { auto filter = filterstr.Split(" ", FString::TOK_SKIPEMPTY); for (auto& entry : filter) { - if (callbacks->ValidFilter(entry)) + if (sysCallbacks.CheckGame(entry)) { ok = true; break; @@ -356,7 +357,7 @@ void FStringTable::LoadLanguage (int lumpnum, const TArray &buffer) sc.MustGetStringName("ifgame"); sc.MustGetStringName("("); sc.MustGetString(); - skip |= (!callbacks || !callbacks->ValidFilter || !callbacks->ValidFilter(sc.String)); + skip |= (!sysCallbacks.CheckGame || !sysCallbacks.CheckGame(sc.String)); sc.MustGetStringName(")"); sc.MustGetString(); @@ -564,7 +565,7 @@ const char *FStringTable::GetString(const char *name, uint32_t *langtable, int g { return nullptr; } - if (gender == -1 && callbacks && callbacks->GetPlayerGender) gender = callbacks->GetPlayerGender(); + if (gender == -1 && sysCallbacks.GetGender) gender = sysCallbacks.GetGender(); if (gender < 0 || gender > 3) gender = 0; FName nm(name, true); if (nm != NAME_None) @@ -597,7 +598,7 @@ const char *FStringTable::GetLanguageString(const char *name, uint32_t langtable { return nullptr; } - if (gender == -1 && callbacks && callbacks->GetPlayerGender) gender = callbacks->GetPlayerGender(); + if (gender == -1 && sysCallbacks.GetGender) gender = sysCallbacks.GetGender(); if (gender < 0 || gender > 3) gender = 0; FName nm(name, true); if (nm != NAME_None) diff --git a/source/common/engine/stringtable.h b/source/common/engine/stringtable.h index 6562834b5..0467b27ed 100644 --- a/source/common/engine/stringtable.h +++ b/source/common/engine/stringtable.h @@ -50,13 +50,6 @@ #include "name.h" -struct StringtableCallbacks -{ - // These two functions would create a dependency on the game code so they are installed as callbacks. - bool (*ValidFilter)(const char* str); - int (*GetPlayerGender)(); -}; - struct TableElement { int filenum; @@ -108,7 +101,6 @@ public: return GetString(name, nullptr); } bool exists(const char *name); - void SetCallbacks(StringtableCallbacks* cb) { callbacks = cb; } void InsertString(int lumpnum, int langid, FName label, const FString& string); @@ -118,8 +110,7 @@ private: StringMacroMap allMacros; LangMap allStrings; TArray> currentLanguageSet; - StringtableCallbacks* callbacks = nullptr; - + void LoadLanguage (int lumpnum, const TArray &buffer); TArray> parseCSV(const TArray &buffer); bool ParseLanguageCSV(int lumpnum, const TArray &buffer); diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 2e24955ff..b54b71f0c 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -159,12 +159,6 @@ int StrTable_GetGender() bool validFilter(const char* str); -static StringtableCallbacks stblcb = -{ - validFilter, - StrTable_GetGender -}; - extern int chatmodeon; bool System_WantGuiCapture() @@ -516,6 +510,8 @@ int GameMain() nullptr, nullptr, System_DispatchEvent, + validFilter, + StrTable_GetGender, }; try diff --git a/source/core/menu/menudef.cpp b/source/core/menu/menudef.cpp index b3d23397b..9a5375aab 100644 --- a/source/core/menu/menudef.cpp +++ b/source/core/menu/menudef.cpp @@ -175,13 +175,7 @@ FTextureID GetMenuTexture(const char* const name) static void SkipSubBlock(FScanner &sc) { sc.MustGetStringName("{"); - int depth = 1; - while (depth > 0) - { - sc.MustGetString(); - if (sc.Compare("{")) depth++; - if (sc.Compare("}")) depth--; - } + sc.SkipToEndOfBlock(); } //=============================================================================