From 3e2a22fad84850dd33abd6e0e7057c2f027d8652 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Tue, 18 Oct 2016 10:59:10 +0800 Subject: [PATCH] Fixed bugs in set*_stat_min functions that set max values instead of min. Unified the style of global/hook script log entries. Updated the code of "reading global/hook scripts from DAT files" with Crafty's newer code base. --- sfall/HookScripts.cpp | 19 ++++++++++--------- sfall/ScriptExtender.cpp | 8 +++++--- sfall/ScriptOps/StatsOp.hpp | 8 ++++---- sfall/main.cpp | 4 ++-- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/sfall/HookScripts.cpp b/sfall/HookScripts.cpp index 8c482b88..adb77ebe 100644 --- a/sfall/HookScripts.cpp +++ b/sfall/HookScripts.cpp @@ -1088,7 +1088,7 @@ void _stdcall RegisterHook( DWORD script, DWORD id, DWORD procNum ) } sScriptProgram *prog = GetGlobalScriptProgram(script); if (prog) { - dlog_f( "Global script %8x registered as hook id %d ", DL_HOOK, script, id); + dlog_f(" (Global script %08x registered as hook id %d)", DL_HOOK, script, id); sHookScript hook; hook.prog = *prog; hook.callback = procNum; @@ -1102,17 +1102,17 @@ static void LoadHookScript(const char* name, int id) { char filename[MAX_PATH]; sprintf(filename, "scripts\\%s.int", name); - bool result; + bool fileExist; __asm { lea eax, filename call db_access_ - mov result, al + mov fileExist, al } - if (result && !isGameScript(name)) { + if (fileExist && !isGameScript(name)) { sScriptProgram prog; - dlog("Loading hook script: ", DL_HOOK); - dlog(filename, DL_HOOK); + dlog(">", DL_HOOK); + dlog(name, DL_HOOK); LoadScriptProgram(prog, name); if (prog.ptr) { sHookScript hook; @@ -1127,14 +1127,15 @@ static void LoadHookScript(const char* name, int id) { } static void HookScriptInit2() { - dlogr("Initing hook scripts", DL_HOOK|DL_INIT); + dlogr("Loading hook scripts", DL_HOOK|DL_INIT); char* mask = "scripts\\hs_*.int"; DWORD *filenames; __asm { + xor ecx, ecx xor ebx, ebx - mov eax, mask lea edx, filenames + mov eax, mask call db_get_file_list_ } @@ -1289,7 +1290,7 @@ static void HookScriptInit2() { call db_free_file_list_ } - dlogr("Completed hook script init", DL_HOOK|DL_INIT); + dlogr("Finished loading hook scripts", DL_HOOK|DL_INIT); } void HookScriptClear() { diff --git a/sfall/ScriptExtender.cpp b/sfall/ScriptExtender.cpp index 5523e712..96eeb72c 100644 --- a/sfall/ScriptExtender.cpp +++ b/sfall/ScriptExtender.cpp @@ -1318,14 +1318,15 @@ bool _stdcall isGameScript(const char* filename) { void LoadGlobalScripts() { isGameLoading = false; HookScriptInit(); - dlogr("Loading global scripts", DL_SCRIPT); + dlogr("Loading global scripts", DL_SCRIPT|DL_INIT); char* name = "scripts\\gl*.int"; DWORD count, *filenames; __asm { + xor ecx, ecx xor ebx, ebx - mov eax, name lea edx, filenames + mov eax, name call db_get_file_list_ mov count, eax } @@ -1336,6 +1337,7 @@ void LoadGlobalScripts() { name = _strlwr((char*)filenames[i]); name[strlen(name) - 4] = 0; if (!isGameScript(name)) { + dlog(">", DL_SCRIPT); dlog(name, DL_SCRIPT); isGlobalScriptLoading = 1; LoadScriptProgram(prog, name); @@ -1357,7 +1359,7 @@ void LoadGlobalScripts() { lea eax, filenames call db_free_file_list_ } - dlogr("Finished loading global scripts", DL_SCRIPT); + dlogr("Finished loading global scripts", DL_SCRIPT|DL_INIT); //ButtonsReload(); } diff --git a/sfall/ScriptOps/StatsOp.hpp b/sfall/ScriptOps/StatsOp.hpp index 626e640c..b5d8916d 100644 --- a/sfall/ScriptOps/StatsOp.hpp +++ b/sfall/ScriptOps/StatsOp.hpp @@ -1002,8 +1002,8 @@ static void __declspec(naked) SetStatMin() { push eax; push edi; push eax; - call SetPCStatMax; - call SetNPCStatMax; + call SetPCStatMin; + call SetNPCStatMin; end: pop esi; pop edi; @@ -1071,7 +1071,7 @@ static void __declspec(naked) fSetPCStatMin() { jnz end; push edi; push eax; - call SetPCStatMax; + call SetPCStatMin; end: pop esi; pop edi; @@ -1139,7 +1139,7 @@ static void __declspec(naked) fSetNPCStatMin() { jnz end; push edi; push eax; - call SetNPCStatMax; + call SetNPCStatMin; end: pop esi; pop edi; diff --git a/sfall/main.cpp b/sfall/main.cpp index ed463e67..6c47c423 100644 --- a/sfall/main.cpp +++ b/sfall/main.cpp @@ -427,7 +427,7 @@ static void __declspec(naked) removeDatabase() { mov ecx, ebx nextPath: mov edx, [esp+0x104+4+4] // path_patches - mov eax, [ebx+0x0] // database.path + mov eax, [ebx] // database.path call stricmp_ test eax, eax // found path? jz skip // Yes @@ -459,7 +459,7 @@ static void __declspec(naked) game_init_databases_hack2() { cmp eax, -1 je end mov eax, ds:[_master_db_handle] - mov eax, [eax+0x0] // eax = master_patches.path + mov eax, [eax] // eax = master_patches.path call xremovepath_ dec eax // remove path (critter_patches == master_patches)? jz end // Yes