Added default path fallback for splash screens

* before the game loaded splash screens only from art\<language>\splash\
if the game language is not English, ignoring the default art\splash\.

Added a global boolean to replace individual game language checks.
This commit is contained in:
NovaRain
2025-08-25 12:10:44 +08:00
parent a7850bd54a
commit abdfd94806
6 changed files with 48 additions and 6 deletions
+2 -3
View File
@@ -178,7 +178,7 @@ static __declspec(naked) void ShowCreditsHook() {
}
}
// Loads the credits from the 'english' folder if it does not exist in the current language directory
// Loads the credits from the 'english' folder if not found in the current language directory
static __declspec(naked) void CreditsFileHook() {
__asm {
mov ebx, edx; // keep mode
@@ -202,8 +202,7 @@ noFile:
}
static void FallbackEnglishCredits() {
const char* lang;
if (fo::func::get_game_config_string(&lang, "system", "language") && _stricmp(lang, "english") != 0) {
if (nonEngLang) {
HookCall(0x42C900, CreditsFileHook);
}
}
+40 -1
View File
@@ -585,10 +585,44 @@ artNotExist:
}
}
static __declspec(naked) void game_splash_screen_hack() {
__asm {
mov nonEngLang, 1;
// overwritten engine code
mov ecx, [esp + 0xA4 - 0x24 + 4];
retn;
}
}
static __declspec(naked) void game_splash_screen_hook() {
__asm {
call fo::funcoffs::db_fopen_;
cmp nonEngLang, 0;
jne checkFile;
retn;
checkFile:
test eax, eax;
jz noFile;
retn;
noFile:
mov eax, dword ptr [esp + 0xA4 - 0x20 + 4]; // splash value
push eax;
push 0x5023E8; // "art\splash\"
push 0x502404; // "%ssplash%d.rix"
lea ebx, [esp + 0xA4 - 0x64 + 16]; // fullname
push ebx;
call fo::funcoffs::sprintf_;
add esp, 16;
mov edx, edi; // mode
mov eax, ebx; // fullname
jmp fo::funcoffs::db_fopen_;
}
}
static fo::DbFile* __fastcall LoadFont(const char* font, const char* mode) {
char file[128];
const char* lang;
if (fo::func::get_game_config_string(&lang, "system", "language") && _stricmp(lang, "english") != 0) {
if (fo::func::get_game_config_string(&lang, "system", "language") && nonEngLang) {
std::sprintf(file, "fonts\\%s\\%s", lang, font);
return fo::func::db_fopen(file, mode);
}
@@ -682,6 +716,11 @@ void LoadOrder::init() {
MakeCall(0x47FB80, SlotMap2Game_hack); // load game
MakeCall(0x47FBBF, SlotMap2Game_hack_attr, 1);
// Set sfall global boolean if the game language is not English
MakeCall(0x4443F2, game_splash_screen_hack, 2);
// Load splash screens from the default path if not found in the art\<language>\splash\ directory
HookCall(0x44444E, game_splash_screen_hook);
// Load fonts based on the game language
HookCalls(load_font_hook, {
0x4D5621, // load_font_
+1 -1
View File
@@ -302,7 +302,7 @@ static void FallbackEnglishLoadMsgFiles() {
const char* lang;
if (fo::func::get_game_config_string(&lang, "system", "language")) {
strncpy_s(gameLanguage, lang, _TRUNCATE);
if (_stricmp(lang, "english") != 0) {
if (nonEngLang) {
HookCall(0x484B18, message_load_hook_db_fopen);
HookCall(0x484C4B, message_search_hook_message_find);
HookCall(0x4849B9, message_exit_hook_mem_free);
+1 -1
View File
@@ -39,7 +39,7 @@ static const char* __fastcall GetLangPremadePath(const char* premadePath) {
isDefault = true;
return nullptr;
}
isDefault = (_stricmp(Message::GameLanguage(), "english") == 0);
isDefault = !nonEngLang;
if (isDefault) return nullptr;
std::strncpy(premadeLangPath, premadePath, 8);
+2
View File
@@ -102,6 +102,8 @@ bool versionCHI = false;
bool extWrapper = false;
bool nonEngLang = false;
static char falloutConfigName[65];
static void InitModules() {
+2
View File
@@ -85,6 +85,8 @@ extern bool versionCHI;
extern bool extWrapper;
extern bool nonEngLang;
__inline long GetIntHRPValue(DWORD addr) {
return *reinterpret_cast<DWORD*>(HRP::Setting::GetAddress(addr));
}