From 45200eba58f13b32959e5c1778d988835b3209b0 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Thu, 17 Nov 2016 18:17:25 +0100 Subject: [PATCH] [Localization] Load language specific files --- src/Components/Modules/Localization.cpp | 15 +++++++++++---- src/Game/Functions.hpp | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Components/Modules/Localization.cpp b/src/Components/Modules/Localization.cpp index 6375912a..2628ef01 100644 --- a/src/Components/Modules/Localization.cpp +++ b/src/Components/Modules/Localization.cpp @@ -133,8 +133,17 @@ namespace Components DWORD Localization::SELoadLanguageStub() { - //'official' iw4x localized strings - Game::SE_Load("localizedstrings/iw4x.str", 0); + if (ZoneBuilder::IsEnabled()) + { + if (FileSystem::File(fmt::sprintf("localizedstrings/iw4x_%s.str", Game::Win_GetLanguage())).Exists()) + { + Game::SE_Load(Utils::String::VA("localizedstrings/iw4x_%s.str", Game::Win_GetLanguage()), 0); + } + else + { + Game::SE_Load("localizedstrings/iw4x_english.str", 0); + } + } return Utils::Hook::Call(0x629E20)(); } @@ -161,10 +170,8 @@ namespace Components // Resolving hook Utils::Hook(0x629B90, Localization::Get, HOOK_JUMP).Install()->Quick(); -#ifdef DEBUG // Set loading entry point Utils::Hook(0x41D859, Localization::SELoadLanguageStub, HOOK_CALL).Install()->Quick(); -#endif // Overwrite SetString Utils::Hook(0x4CE5EE, Localization::SetStringStub, HOOK_CALL).Install()->Quick(); diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 4b05eadf..41e151ed 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -458,7 +458,7 @@ namespace Game typedef int(__cdecl * Script_CleanString_t)(char* buffer); extern Script_CleanString_t Script_CleanString; - typedef char* (__cdecl * SE_Load_t)(char* file, int Unk); + typedef char* (__cdecl * SE_Load_t)(const char* file, int Unk); extern SE_Load_t SE_Load; typedef char* (__cdecl * SEH_StringEd_GetString_t)(const char* string);