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);
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() {
+5 -3
View File
@@ -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();
}
+4 -4
View File
@@ -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;
+2 -2
View File
@@ -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