blob: 39fb931d59b18211acc3f0d68369267e1b9ee4c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include "pch.h"
#include "gameutils.h"
#include "host_state.h"
#include "sv_rcon.h"
#include "cl_rcon.h"
#include "dedicated.h"
typedef void (*CHostState_FrameUpdateType)(CHostState* thisptr);
CHostState_FrameUpdateType CHostState__FrameUpdate;
CHostState* g_pHostState;
void CHostState__FrameUpdateHook(CHostState* thisptr)
{
static bool bInitialized = false;
if (!bInitialized)
{
if (IsDedicated())
{
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec rcon_server", cmd_source_t::kCommandSrcCode);
Cbuf_Execute();
RCONServer()->Init();
}
else
{
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec rcon_client", cmd_source_t::kCommandSrcCode);
Cbuf_Execute();
RCONClient()->Init();
}
bInitialized = true;
}
if (IsDedicated())
{
RCONServer()->RunFrame();
}
else
{
RCONClient()->RunFrame();
}
CHostState__FrameUpdate(thisptr);
}
void InitializeCHostStateHooks(HMODULE baseAddress)
{
g_pHostState = (CHostState*)((char*)baseAddress + 0x7CF180);
HookEnabler hook;
ENABLER_CREATEHOOK(
hook, (char*)baseAddress + 0x16DB00, &CHostState__FrameUpdateHook, reinterpret_cast<LPVOID*>(&CHostState__FrameUpdate));
}
|