9
9
#include " squirrel/squirrel.h"
10
10
#include " plugins/pluginmanager.h"
11
11
12
- AUTOHOOK_INIT ()
13
-
14
12
CHostState* g_pHostState;
15
13
16
14
std::string sLastMode ;
17
15
18
- VAR_AT (engine.dll + 0x13FA6070 , ConVar*, Cvar_hostport) ;
19
- FUNCTION_AT (engine.dll + 0x1232C0 , void , __fastcall, _Cmd_Exec_f, (const CCommand& arg, bool bOnlyIfExists, bool bUseWhitelists)) ;
16
+ static ConVar* Cvar_hostport = nullptr ;
17
+ static void ( __fastcall* _Cmd_Exec_f) (const CCommand& arg, bool bOnlyIfExists, bool bUseWhitelists) = nullptr ;
20
18
21
19
void ServerStartingOrChangingMap ()
22
20
{
@@ -53,10 +51,8 @@ void ServerStartingOrChangingMap()
53
51
g_pServerAuthentication->m_bStartingLocalSPGame = false ;
54
52
}
55
53
56
- // clang-format off
57
- AUTOHOOK (CHostState__State_NewGame, engine.dll + 0x16E7D0 ,
58
- void , __fastcall, (CHostState* self))
59
- // clang-format on
54
+ static void (__fastcall* o_pCHostState__State_NewGame)(CHostState* self) = nullptr;
55
+ static void __fastcall h_CHostState__State_NewGame (CHostState* self)
60
56
{
61
57
spdlog::info (" HostState: NewGame" );
62
58
@@ -70,7 +66,7 @@ void, __fastcall, (CHostState* self))
70
66
ServerStartingOrChangingMap ();
71
67
72
68
double dStartTime = Plat_FloatTime ();
73
- CHostState__State_NewGame (self);
69
+ o_pCHostState__State_NewGame (self);
74
70
spdlog::info (" loading took {}s" , Plat_FloatTime () - dStartTime);
75
71
76
72
// setup server presence
@@ -82,10 +78,8 @@ void, __fastcall, (CHostState* self))
82
78
g_pServerAuthentication->m_bNeedLocalAuthForNewgame = false ;
83
79
}
84
80
85
- // clang-format off
86
- AUTOHOOK (CHostState__State_LoadGame, engine.dll + 0x16E730 ,
87
- void , __fastcall, (CHostState* self))
88
- // clang-format on
81
+ static void (__fastcall* o_pCHostState__State_LoadGame)(CHostState* self) = nullptr;
82
+ static void __fastcall h_CHostState__State_LoadGame (CHostState* self)
89
83
{
90
84
// singleplayer server starting
91
85
// useless in 99% of cases but without it things could potentially break very much
@@ -100,7 +94,7 @@ void, __fastcall, (CHostState* self))
100
94
g_pServerAuthentication->m_bStartingLocalSPGame = true ;
101
95
102
96
double dStartTime = Plat_FloatTime ();
103
- CHostState__State_LoadGame (self);
97
+ o_pCHostState__State_LoadGame (self);
104
98
spdlog::info (" loading took {}s" , Plat_FloatTime () - dStartTime);
105
99
106
100
// no server presence, can't do it because no map name in hoststate
@@ -109,32 +103,28 @@ void, __fastcall, (CHostState* self))
109
103
g_pServerAuthentication->m_bNeedLocalAuthForNewgame = false ;
110
104
}
111
105
112
- // clang-format off
113
- AUTOHOOK (CHostState__State_ChangeLevelMP, engine.dll + 0x16E520 ,
114
- void , __fastcall, (CHostState* self))
115
- // clang-format on
106
+ static void (__fastcall* o_pCHostState__State_ChangeLevelMP)(CHostState* self) = nullptr;
107
+ static void __fastcall h_CHostState__State_ChangeLevelMP (CHostState* self)
116
108
{
117
109
spdlog::info (" HostState: ChangeLevelMP" );
118
110
119
111
ServerStartingOrChangingMap ();
120
112
121
113
double dStartTime = Plat_FloatTime ();
122
- CHostState__State_ChangeLevelMP (self);
114
+ o_pCHostState__State_ChangeLevelMP (self);
123
115
spdlog::info (" loading took {}s" , Plat_FloatTime () - dStartTime);
124
116
125
117
g_pServerPresence->SetMap (g_pHostState->m_levelName );
126
118
}
127
119
128
- // clang-format off
129
- AUTOHOOK (CHostState__State_GameShutdown, engine.dll + 0x16E640 ,
130
- void , __fastcall, (CHostState* self))
131
- // clang-format on
120
+ static void (__fastcall* o_pCHostState__State_GameShutdown)(CHostState* self) = nullptr;
121
+ static void __fastcall h_CHostState__State_GameShutdown (CHostState* self)
132
122
{
133
123
spdlog::info (" HostState: GameShutdown" );
134
124
135
125
g_pServerPresence->DestroyPresence ();
136
126
137
- CHostState__State_GameShutdown (self);
127
+ o_pCHostState__State_GameShutdown (self);
138
128
139
129
// run gamemode cleanup cfg now instead of when we start next map
140
130
if (sLastMode .length ())
@@ -153,12 +143,10 @@ void, __fastcall, (CHostState* self))
153
143
}
154
144
}
155
145
156
- // clang-format off
157
- AUTOHOOK (CHostState__FrameUpdate, engine.dll + 0x16DB00 ,
158
- void , __fastcall, (CHostState* self, double flCurrentTime, float flFrameTime))
159
- // clang-format on
146
+ static void (__fastcall* o_pCHostState__FrameUpdate)(CHostState* self, double flCurrentTime, float flFrameTime) = nullptr;
147
+ static void __fastcall h_CHostState__FrameUpdate (CHostState* self, double flCurrentTime, float flFrameTime)
160
148
{
161
- CHostState__FrameUpdate (self, flCurrentTime, flFrameTime);
149
+ o_pCHostState__FrameUpdate (self, flCurrentTime, flFrameTime);
162
150
163
151
if (*g_pServerState == server_state_t ::ss_active)
164
152
{
@@ -184,7 +172,23 @@ void, __fastcall, (CHostState* self, double flCurrentTime, float flFrameTime))
184
172
185
173
ON_DLL_LOAD_RELIESON (" engine.dll" , HostState, ConVar, (CModule module))
186
174
{
187
- AUTOHOOK_DISPATCH ()
175
+ o_pCHostState__State_NewGame = module.Offset (0x16E7D0 ).RCast <decltype (o_pCHostState__State_NewGame)>();
176
+ HookAttach (&(PVOID&)o_pCHostState__State_NewGame, (PVOID)h_CHostState__State_NewGame);
177
+
178
+ o_pCHostState__State_LoadGame = module.Offset (0x16E730 ).RCast <decltype (o_pCHostState__State_LoadGame)>();
179
+ HookAttach (&(PVOID&)o_pCHostState__State_LoadGame, (PVOID)h_CHostState__State_LoadGame);
180
+
181
+ o_pCHostState__State_ChangeLevelMP = module.Offset (0x16E520 ).RCast <decltype (o_pCHostState__State_ChangeLevelMP)>();
182
+ HookAttach (&(PVOID&)o_pCHostState__State_ChangeLevelMP, (PVOID)h_CHostState__State_ChangeLevelMP);
183
+
184
+ o_pCHostState__State_GameShutdown = module.Offset (0x16E640 ).RCast <decltype (o_pCHostState__State_GameShutdown)>();
185
+ HookAttach (&(PVOID&)o_pCHostState__State_GameShutdown, (PVOID)h_CHostState__State_GameShutdown);
186
+
187
+ o_pCHostState__FrameUpdate = module.Offset (0x16DB00 ).RCast <decltype (o_pCHostState__FrameUpdate)>();
188
+ HookAttach (&(PVOID&)o_pCHostState__FrameUpdate, (PVOID)h_CHostState__FrameUpdate);
189
+
190
+ Cvar_hostport = module.Offset (0x13FA6070 ).RCast <decltype (Cvar_hostport)>();
191
+ _Cmd_Exec_f = module.Offset (0x1232C0 ).RCast <decltype (_Cmd_Exec_f)>();
188
192
189
193
g_pHostState = module.Offset (0x7CF180 ).RCast <CHostState*>();
190
194
}
0 commit comments