Skip to content

Commit

Permalink
Implemented proper handling of game start-end events. (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiranDMC authored Dec 3, 2023
1 parent 5035fda commit 9fa9b50
Show file tree
Hide file tree
Showing 10 changed files with 272 additions and 229 deletions.
9 changes: 4 additions & 5 deletions cleo_sdk/CLEO.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,8 @@ const char DIR_MODULES[] = "modules:"; // game\cleo\modules directory
// argument of CLEO_RegisterCallback
enum class eCallbackId : DWORD
{
ScmInit1, // void WINAPI OnScmInit1();
ScmInit2, // void WINAPI OnScmInit2();
ScmInit3, // void WINAPI OnScmInit3();
GameBegin, // void WINAPI OnGameBegin(DWORD saveSlot); // -1 if not started from save
GameEnd, // void WINAPI OnGameEnd();
ScriptsLoaded, // void WINAPI OnScriptsLoaded();
ScriptsFinalize, // void WINAPI OnScriptsFinalize();
ScriptRegister, // void WINAPI OnScriptRegister(CRunningScript* pScript); // called after script creation
Expand All @@ -266,8 +265,8 @@ enum class eLogLevel : DWORD
{
None,
Error, // errors and warnings
Debug, // debug mode related
Default // all
Debug, // debug mode / user traces
Default // all log messages
};

typedef int SCRIPT_HANDLE;
Expand Down
4 changes: 2 additions & 2 deletions source/CCodeInjector.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ namespace CLEO
void CloseReadWriteAccess();

template<typename T>
void ReplaceFunction(T *funcPtr, memory_pointer Position)
void ReplaceFunction(T *funcPtr, memory_pointer Position, T** origFuncPtr = nullptr)
{
TRACE("Replacing call: 0x%08X", (DWORD)Position);
MemCall((size_t)Position, (size_t)funcPtr); // *whistle*
MemCall((size_t)Position, (size_t)funcPtr, (size_t*)origFuncPtr); // *whistle*
}

template<typename T>
Expand Down
4 changes: 4 additions & 0 deletions source/CGameVersionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ namespace CLEO
{ 0x00A44B68, memory_und, 0x00A44B68, 0x00A471E8, 0x00AB9C98 }, // MA_NUM_SCRIPT_TEXTS
{ 0x0058FCE4, memory_und, 0x0058FCE4, 0x005904B4, 0x0059E73C }, // MA_CALL_DRAW_SCRIPT_TEXTS_BEFORE_FADE
{ 0x0058D552, memory_und, 0x0058D552, 0x0058DD22, 0x0059BAD4 }, // MA_CALL_DRAW_SCRIPT_TEXTS_AFTER_FADE
{ 0x00748E6B, memory_und, memory_und, memory_und, memory_und }, // MA_CALL_GAME_SHUTDOWN TODO: find for other versions
{ 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

// GV_US10, GV_US11, GV_EU10, GV_EU11, GV_STEAM
{ 0x008A6168, memory_und, 0x008A6168, 0x008A7450, 0x00913C20 }, // MA_OPCODE_HANDLER,
Expand Down
4 changes: 4 additions & 0 deletions source/CGameVersionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ namespace CLEO
MA_NUM_SCRIPT_TEXTS,
MA_CALL_DRAW_SCRIPT_TEXTS_BEFORE_FADE,
MA_CALL_DRAW_SCRIPT_TEXTS_AFTER_FADE,
MA_CALL_GAME_SHUTDOWN,
MA_CALL_GAME_RESTART_1,
MA_CALL_GAME_RESTART_2,
MA_CALL_GAME_RESTART_3,

// CustomOpcodeSystem
MA_OPCODE_HANDLER,
Expand Down
Loading

0 comments on commit 9fa9b50

Please sign in to comment.