Fixed the format of some debug messages (#195)

This commit is contained in:
NovaRain
2021-01-14 11:36:35 +08:00
parent a1c038846a
commit ef89748eda
+27
View File
@@ -373,6 +373,21 @@ static void __declspec(naked) debug_log_hack() {
}
}
const char* scrNameFmt = "\nScript: %s ";
static void __declspec(naked) debugMsg() {
__asm {
mov edx, ds:[FO_VAR_currentProgram];
push [edx]; // script name
push scrNameFmt;
call fo::funcoffs::debug_printf_;
add esp, 8;
jmp fo::funcoffs::debug_printf_;
}
}
//static const DWORD addrNewLine[] = {0x50B244, 0x50B27C, 0x50B2B6, 0x50B2EE}; // ERROR: attempt to reference * var out of range: %d
static void DebugModePatch() {
int dbgMode = iniGetInt("Debugging", "DebugMode", 0, ::sfall::ddrawIni);
if (dbgMode > 0) {
@@ -411,6 +426,18 @@ static void DebugModePatch() {
__int64 data = 0x51DF0415FFF08990; // mov eax, esi; call ds:_debug_func
SafeWriteBytes(0x455419, (BYTE*)&data, 8); // op_display_msg_
// set the position of the debug window
SafeWrite8(0x4DC34D, 15);
// Fix the format of some debug messages
// SafeWriteBatch<BYTE>(0xA, addrNewLine);
HookCalls(debugMsg, {
0x482240, // map_set_global_var_
0x482274, // map_get_global_var_
0x4822A0, // map_set_local_var_
0x4822D4 // map_get_local_var_
});
dlogr(" Done", DL_INIT);
}
}