Skip to content

Commit

Permalink
Fixed the format of some debug messages (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
NovaRain committed Jan 14, 2021
1 parent a1c0388 commit ef89748
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions sfall/Modules/DebugEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit ef89748

Please sign in to comment.