5
5
#include < Windows.h>
6
6
#include < stdio.h>
7
7
#include < mutex>
8
- #include < sol/sol.hpp>
9
8
#include " Delegates/IInputDelegate.h"
10
9
11
10
namespace DriverNG
@@ -24,6 +23,7 @@ namespace DriverNG
24
23
static constexpr uintptr_t kStepLuaOrigAddress = 0x005E4A70 ;
25
24
26
25
static constexpr uintptr_t ksafe_vsprintfOrigAdress = 0x00903EBA ;
26
+ static constexpr uintptr_t kgameLuaStateAddr = 0x0122B498 ;
27
27
}
28
28
29
29
namespace Globals
@@ -57,35 +57,38 @@ namespace DriverNG
57
57
Globals::InitializeLuaStateBindings (state);
58
58
}
59
59
60
- void StepLua_Hooked (lua_State* state, bool paused )
60
+ void StepLua_Hooked (bool consolePaused )
61
61
{
62
- typedef void (*StepLua_t)(lua_State*, bool );
62
+ typedef void (*StepLua_t)(bool );
63
63
auto origStepLua = (StepLua_t)Consts::kStepLuaOrigAddress ;
64
64
65
65
{
66
66
// std::lock_guard g(Globals::g_drawMutex[1]);
67
- origStepLua (state, paused );
67
+ origStepLua (consolePaused );
68
68
}
69
69
70
- auto callLuaFunc = Globals::g_luaDelegate.GetCallLuaFunction ();
70
+ if (!consolePaused)
71
+ {
72
+ auto callLuaFunc = Globals::g_luaDelegate.GetCallLuaFunction ();
71
73
72
- if (callLuaFunc && state )
73
- {
74
- std::lock_guard g (Globals::g_drawMutex[0 ]);
74
+ if (callLuaFunc)
75
+ {
76
+ std::lock_guard g (Globals::g_drawMutex[0 ]);
75
77
76
- Globals::g_dataDrawn = false ;
78
+ Globals::g_dataDrawn = false ;
77
79
78
- Globals::g_luaDelegate.BeginRender ();
80
+ Globals::g_luaDelegate.BeginRender ();
79
81
80
- bool shouldBlockUI = false ;
81
- callLuaFunc (" ImGui_RenderUpdate" , " >b" , &shouldBlockUI);
82
- Globals::g_pInputDelegate->setGameInputBlocked (shouldBlockUI);
82
+ bool shouldBlockUI = false ;
83
+ callLuaFunc (" ImGui_RenderUpdate" , " >b" , &shouldBlockUI);
84
+ Globals::g_pInputDelegate->setGameInputBlocked (shouldBlockUI);
83
85
84
- Globals::g_luaDelegate.EndRender ();
85
- }
86
+ Globals::g_luaDelegate.EndRender ();
87
+ }
86
88
87
- // do commands after
88
- Globals::g_luaDelegate.DoCommands ();
89
+ // do commands after
90
+ Globals::g_luaDelegate.DoCommands (*reinterpret_cast <lua_State**>(Consts::kgameLuaStateAddr));
91
+ }
89
92
}
90
93
91
94
void DeleteLuaState_Hooked (lua_State* state)
@@ -159,7 +162,7 @@ namespace DriverNG
159
162
return false ;
160
163
}
161
164
162
- m_stepLuaHook = HF::Hook::HookFunction<void (*)(lua_State*, bool ), kStepLuaPatchSize >(
165
+ m_stepLuaHook = HF::Hook::HookFunction<void (*)(bool ), kStepLuaPatchSize >(
163
166
process,
164
167
Consts::kStepLuaCallAddress ,
165
168
&Callbacks::StepLua_Hooked,
0 commit comments