Skip to content

Commit

Permalink
DrawingFinished hook updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
MiranDMC committed Jan 28, 2025
1 parent 7720599 commit 02a2762
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
4 changes: 2 additions & 2 deletions source/CGameVersionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ namespace CLEO
{ 0x0053C758, memory_und, memory_und, memory_und, memory_und }, // MA_CALL_GAME_RESTART_1 TODO: find for other versions
{ 0x00748E04, memory_und, memory_und, memory_und, memory_und }, // MA_CALL_GAME_RESTART_2 TODO: find for other versions
{ 0x00748E3E, memory_und, memory_und, memory_und, memory_und }, // MA_CALL_GAME_RESTART_3 TODO: find for other versions
{ 0x00532260, memory_und, memory_und, memory_und, memory_und }, // MA_DEBUG_DISPLAY_TEXT_BUFFER TODO: find for other versions

{ 0x0053EBE4, memory_und, memory_und, memory_und, memory_und }, // MA_CALL_DEBUG_DISPLAY_TEXT_BUFFER_IDLE TODO: find for other versions
{ 0x0053E86C, memory_und, memory_und, memory_und, memory_und }, // MA_CALL_DEBUG_DISPLAY_TEXT_BUFFER_FRONTEND TODO: find for other versions
// GV_US10, GV_US11, GV_EU10, GV_EU11, GV_STEAM
{ 0x008A6168, memory_und, 0x008A6168, 0x008A7450, 0x00913C20 }, // MA_OPCODE_HANDLER,
{ 0x00469FEE, memory_und, 0x00469FEE, 0x0046A06E, 0x0046F75C }, // MA_OPCODE_HANDLER_REF,
Expand Down
3 changes: 2 additions & 1 deletion source/CGameVersionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ namespace CLEO
MA_CALL_GAME_RESTART_1,
MA_CALL_GAME_RESTART_2,
MA_CALL_GAME_RESTART_3,
MA_DEBUG_DISPLAY_TEXT_BUFFER, // empty function called after everything else is drawn
MA_CALL_DEBUG_DISPLAY_TEXT_BUFFER_IDLE,
MA_CALL_DEBUG_DISPLAY_TEXT_BUFFER_FRONTEND,

// CustomOpcodeSystem
MA_OPCODE_HANDLER,
Expand Down
18 changes: 10 additions & 8 deletions source/CleoBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,16 @@ namespace CLEO
_asm jmp oriFunc
}

void __declspec(naked) CCleoInstance::OnDebugDisplayTextBuffer()
void __cdecl CCleoInstance::OnDebugDisplayTextBuffer_Idle()
{
CleoInstance.GameRestartDebugDisplayTextBuffer_IdleOrig(); // call original
CleoInstance.CallCallbacks(eCallbackId::DrawingFinished); // execute registered callbacks
}

void __cdecl CCleoInstance::OnDebugDisplayTextBuffer_Frontend()
{
CleoInstance.GameRestartDebugDisplayTextBuffer_FrontendOrig(); // call original
CleoInstance.CallCallbacks(eCallbackId::DrawingFinished); // execute registered callbacks
static DWORD oriFunc;
oriFunc = (DWORD)(CleoInstance.DebugDisplayTextBuffer_Orig);
if (oriFunc != (DWORD)nullptr)
_asm jmp oriFunc
else
_asm ret
}

void CCleoInstance::Start(InitStage stage)
Expand Down Expand Up @@ -157,7 +158,8 @@ namespace CLEO
{
TRACE("CLEO initialization: Phase 2");

CodeInjector.ReplaceJump(OnDebugDisplayTextBuffer, VersionManager.TranslateMemoryAddress(MA_DEBUG_DISPLAY_TEXT_BUFFER), &DebugDisplayTextBuffer_Orig);
CodeInjector.ReplaceFunction(OnDebugDisplayTextBuffer_Idle, VersionManager.TranslateMemoryAddress(MA_CALL_DEBUG_DISPLAY_TEXT_BUFFER_IDLE), &GameRestartDebugDisplayTextBuffer_IdleOrig);
CodeInjector.ReplaceFunction(OnDebugDisplayTextBuffer_Frontend, VersionManager.TranslateMemoryAddress(MA_CALL_DEBUG_DISPLAY_TEXT_BUFFER_FRONTEND), &GameRestartDebugDisplayTextBuffer_FrontendOrig);

PluginSystem.LogLoadedPlugins();
}
Expand Down
10 changes: 7 additions & 3 deletions source/CleoBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,13 @@ namespace CLEO
static void OnGameRestart2();
static void OnGameRestart3();

// empty function called after everything else is drawn
memory_pointer DebugDisplayTextBuffer_Orig = nullptr;
static void OnDebugDisplayTextBuffer();
// calls to CDebug::DebugDisplayTextBuffer()
void(__cdecl* GameRestartDebugDisplayTextBuffer_IdleOrig)() = nullptr;
static void OnDebugDisplayTextBuffer_Idle();

void(__cdecl* GameRestartDebugDisplayTextBuffer_FrontendOrig)() = nullptr;
static void OnDebugDisplayTextBuffer_Frontend();


private:
InitStage m_initStage = InitStage::None;
Expand Down

0 comments on commit 02a2762

Please sign in to comment.