From 1a844e4e7d15e4c1afb68654002e4430283dd7ca Mon Sep 17 00:00:00 2001 From: NovaRain Date: Mon, 3 Jun 2024 09:28:36 +0800 Subject: [PATCH] Fixed possible crash in BoxBarCount Edits to ddraw.ini and comments in Message.cpp. --- artifacts/ddraw.ini | 2 +- sfall/Modules/BarBoxes.cpp | 2 +- sfall/Modules/Message.cpp | 13 +++++-------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index caade86f..5437e1f1 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -384,7 +384,7 @@ TownMapHotkeysFix=1 DisableHorrigan=0 ;Set to 1 to disable the random element in party member leveling -;This will prevent party members from randomly leveling up 'earlier' and instead level them up at defined regular intervals +;This will prevent party members from randomly leveling up early and instead level them up at defined intervals PartyMemberNonRandomLevelUp=0 ;Change the initial starting location and world map viewport diff --git a/sfall/Modules/BarBoxes.cpp b/sfall/Modules/BarBoxes.cpp index 51856375..87eda430 100644 --- a/sfall/Modules/BarBoxes.cpp +++ b/sfall/Modules/BarBoxes.cpp @@ -263,7 +263,7 @@ static void __declspec(naked) refresh_box_bar_win_hack() { void BarBoxes::init() { initCount += IniReader::GetConfigInt("Misc", "BoxBarCount", 5); - if (initCount < 5) initCount = 5; // exclude the influence of negative values from the config + if (initCount < 6) initCount = 6; // minimum of one extra box if (initCount > 100) initCount = 100; actualBoxCount = initCount - 5; diff --git a/sfall/Modules/Message.cpp b/sfall/Modules/Message.cpp index 6e60420d..94056246 100644 --- a/sfall/Modules/Message.cpp +++ b/sfall/Modules/Message.cpp @@ -183,7 +183,6 @@ static long __fastcall MessageFindHook(fo::MessageList** list, long num, DWORD* return fo::func::message_find(*list, num, outIndex); } - static void __fastcall MessageExitHook(fo::MessageList* list) { // Delete fallback message file. auto& listIt = messageListMap.find(list); @@ -203,9 +202,8 @@ static void __declspec(naked) message_load__db_fopen_hook() { __asm { push esi; // message list push ebp; // relative path - // edx - mode mov ecx, eax; // full path - call MessageLoadHook; + call MessageLoadHook; // edx - mode retn; } } @@ -213,10 +211,9 @@ static void __declspec(naked) message_load__db_fopen_hook() { static void __declspec(naked) message_search__message_find_hook() { __asm { push ecx; // save msg list - push ebx; // out index - // edx - msg num + push ebx; // out index lea ecx, [esp + 4]; // msg list ** - call MessageFindHook; + call MessageFindHook; // edx - msg num pop ecx; // restore, possibly modified list ptr retn; } @@ -224,10 +221,10 @@ static void __declspec(naked) message_search__message_find_hook() { static void __declspec(naked) message_exit__mem_free_hook() { __asm { - push eax; + push eax; // save msgList->nodes mov ecx, ebx; // message list call MessageExitHook; - pop eax; + pop eax; // restore jmp fo::funcoffs::mem_free_; } }