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.
This commit is contained in:
NovaRain
2016-10-18 10:59:10 +08:00
parent 13ee06dee2
commit 3e2a22fad8
4 changed files with 21 additions and 18 deletions
+10 -9
View File
@@ -1088,7 +1088,7 @@ void _stdcall RegisterHook( DWORD script, DWORD id, DWORD procNum )
} }
sScriptProgram *prog = GetGlobalScriptProgram(script); sScriptProgram *prog = GetGlobalScriptProgram(script);
if (prog) { 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; sHookScript hook;
hook.prog = *prog; hook.prog = *prog;
hook.callback = procNum; hook.callback = procNum;
@@ -1102,17 +1102,17 @@ static void LoadHookScript(const char* name, int id) {
char filename[MAX_PATH]; char filename[MAX_PATH];
sprintf(filename, "scripts\\%s.int", name); sprintf(filename, "scripts\\%s.int", name);
bool result; bool fileExist;
__asm { __asm {
lea eax, filename lea eax, filename
call db_access_ call db_access_
mov result, al mov fileExist, al
} }
if (result && !isGameScript(name)) { if (fileExist && !isGameScript(name)) {
sScriptProgram prog; sScriptProgram prog;
dlog("Loading hook script: ", DL_HOOK); dlog(">", DL_HOOK);
dlog(filename, DL_HOOK); dlog(name, DL_HOOK);
LoadScriptProgram(prog, name); LoadScriptProgram(prog, name);
if (prog.ptr) { if (prog.ptr) {
sHookScript hook; sHookScript hook;
@@ -1127,14 +1127,15 @@ static void LoadHookScript(const char* name, int id) {
} }
static void HookScriptInit2() { static void HookScriptInit2() {
dlogr("Initing hook scripts", DL_HOOK|DL_INIT); dlogr("Loading hook scripts", DL_HOOK|DL_INIT);
char* mask = "scripts\\hs_*.int"; char* mask = "scripts\\hs_*.int";
DWORD *filenames; DWORD *filenames;
__asm { __asm {
xor ecx, ecx
xor ebx, ebx xor ebx, ebx
mov eax, mask
lea edx, filenames lea edx, filenames
mov eax, mask
call db_get_file_list_ call db_get_file_list_
} }
@@ -1289,7 +1290,7 @@ static void HookScriptInit2() {
call db_free_file_list_ 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() { void HookScriptClear() {
+5 -3
View File
@@ -1318,14 +1318,15 @@ bool _stdcall isGameScript(const char* filename) {
void LoadGlobalScripts() { void LoadGlobalScripts() {
isGameLoading = false; isGameLoading = false;
HookScriptInit(); HookScriptInit();
dlogr("Loading global scripts", DL_SCRIPT); dlogr("Loading global scripts", DL_SCRIPT|DL_INIT);
char* name = "scripts\\gl*.int"; char* name = "scripts\\gl*.int";
DWORD count, *filenames; DWORD count, *filenames;
__asm { __asm {
xor ecx, ecx
xor ebx, ebx xor ebx, ebx
mov eax, name
lea edx, filenames lea edx, filenames
mov eax, name
call db_get_file_list_ call db_get_file_list_
mov count, eax mov count, eax
} }
@@ -1336,6 +1337,7 @@ void LoadGlobalScripts() {
name = _strlwr((char*)filenames[i]); name = _strlwr((char*)filenames[i]);
name[strlen(name) - 4] = 0; name[strlen(name) - 4] = 0;
if (!isGameScript(name)) { if (!isGameScript(name)) {
dlog(">", DL_SCRIPT);
dlog(name, DL_SCRIPT); dlog(name, DL_SCRIPT);
isGlobalScriptLoading = 1; isGlobalScriptLoading = 1;
LoadScriptProgram(prog, name); LoadScriptProgram(prog, name);
@@ -1357,7 +1359,7 @@ void LoadGlobalScripts() {
lea eax, filenames lea eax, filenames
call db_free_file_list_ call db_free_file_list_
} }
dlogr("Finished loading global scripts", DL_SCRIPT); dlogr("Finished loading global scripts", DL_SCRIPT|DL_INIT);
//ButtonsReload(); //ButtonsReload();
} }
+4 -4
View File
@@ -1002,8 +1002,8 @@ static void __declspec(naked) SetStatMin() {
push eax; push eax;
push edi; push edi;
push eax; push eax;
call SetPCStatMax; call SetPCStatMin;
call SetNPCStatMax; call SetNPCStatMin;
end: end:
pop esi; pop esi;
pop edi; pop edi;
@@ -1071,7 +1071,7 @@ static void __declspec(naked) fSetPCStatMin() {
jnz end; jnz end;
push edi; push edi;
push eax; push eax;
call SetPCStatMax; call SetPCStatMin;
end: end:
pop esi; pop esi;
pop edi; pop edi;
@@ -1139,7 +1139,7 @@ static void __declspec(naked) fSetNPCStatMin() {
jnz end; jnz end;
push edi; push edi;
push eax; push eax;
call SetNPCStatMax; call SetNPCStatMin;
end: end:
pop esi; pop esi;
pop edi; pop edi;
+2 -2
View File
@@ -427,7 +427,7 @@ static void __declspec(naked) removeDatabase() {
mov ecx, ebx mov ecx, ebx
nextPath: nextPath:
mov edx, [esp+0x104+4+4] // path_patches mov edx, [esp+0x104+4+4] // path_patches
mov eax, [ebx+0x0] // database.path mov eax, [ebx] // database.path
call stricmp_ call stricmp_
test eax, eax // found path? test eax, eax // found path?
jz skip // Yes jz skip // Yes
@@ -459,7 +459,7 @@ static void __declspec(naked) game_init_databases_hack2() {
cmp eax, -1 cmp eax, -1
je end je end
mov eax, ds:[_master_db_handle] mov eax, ds:[_master_db_handle]
mov eax, [eax+0x0] // eax = master_patches.path mov eax, [eax] // eax = master_patches.path
call xremovepath_ call xremovepath_
dec eax // remove path (critter_patches == master_patches)? dec eax // remove path (critter_patches == master_patches)?
jz end // Yes jz end // Yes