aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/gameutils.cpp
blob: 642c44e61a5317e461d337f9d4eff6b73a3ee3ed (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "pch.h"
#include "gameutils.h"
#include "convar.h"
#include "concommand.h"

// memory
IMemAlloc* g_pMemAllocSingleton;
typedef IMemAlloc* (*CreateGlobalMemAllocType)();
CreateGlobalMemAllocType CreateGlobalMemAlloc;

// cmd.h
Cbuf_GetCurrentPlayerType Cbuf_GetCurrentPlayer;
Cbuf_AddTextType Cbuf_AddText;
Cbuf_ExecuteType Cbuf_Execute;

// hoststate stuff
CHostState* g_pHostState;

// cengine stuff
CEngine* g_pEngine;

// network stuff
ConVar* Cvar_hostport;

// playlist stuff
GetCurrentPlaylistType GetCurrentPlaylistName;
SetCurrentPlaylistType SetCurrentPlaylist;
SetPlaylistVarOverrideType SetPlaylistVarOverride;
GetCurrentPlaylistVarType GetCurrentPlaylistVar;

// server entity stuff
Server_GetEntityByIndexType Server_GetEntityByIndex;

// server tickrate stuff
ConVar* Cvar_base_tickinterval_mp;
ConVar* Cvar_base_tickinterval_sp;

// auth
char* g_LocalPlayerUserID;
char* g_LocalPlayerOriginToken;

// misc stuff
ConVar* Cvar_match_defaultMap;
ConVar* Cvar_communities_hostname;
ErrorType Error;
CommandLineType CommandLine;
Plat_FloatTimeType Plat_FloatTime;

void InitialiseEngineGameUtilFunctions(HMODULE baseAddress)
{
	Cbuf_GetCurrentPlayer = (Cbuf_GetCurrentPlayerType)((char*)baseAddress + 0x120630);
	Cbuf_AddText = (Cbuf_AddTextType)((char*)baseAddress + 0x1203B0);
	Cbuf_Execute = (Cbuf_ExecuteType)((char*)baseAddress + 0x1204B0);

	g_pHostState = (CHostState*)((char*)baseAddress + 0x7CF180);
	g_pEngine = *(CEngine**)((char*)baseAddress + 0x7D70C8);

	Cvar_hostport = (ConVar*)((char*)baseAddress + 0x13FA6070);

	GetCurrentPlaylistName = (GetCurrentPlaylistType)((char*)baseAddress + 0x18C640);
	SetCurrentPlaylist = (SetCurrentPlaylistType)((char*)baseAddress + 0x18EB20);
	SetPlaylistVarOverride = (SetPlaylistVarOverrideType)((char*)baseAddress + 0x18ED00);
	GetCurrentPlaylistVar = (GetCurrentPlaylistVarType)((char*)baseAddress + 0x18C680);

	g_LocalPlayerUserID = (char*)baseAddress + 0x13F8E688;
	g_LocalPlayerOriginToken = (char*)baseAddress + 0x13979C80;

	Cvar_match_defaultMap = (ConVar*)((char*)baseAddress + 0x8AB530);
	Cvar_communities_hostname = (ConVar*)((char*)baseAddress + 0x13157E50);
}

void InitialiseServerGameUtilFunctions(HMODULE baseAddress)
{
	Server_GetEntityByIndex = (Server_GetEntityByIndexType)((char*)baseAddress + 0xFB820);
	Cvar_base_tickinterval_mp = (ConVar*)((char*)baseAddress + 0xBFC360);
	Cvar_base_tickinterval_sp = (ConVar*)((char*)baseAddress + 0xBFBEA0);
}

void InitialiseTier0GameUtilFunctions(HMODULE baseAddress)
{
	baseAddress = GetModuleHandleA("tier0.dll");

	CreateGlobalMemAlloc = (CreateGlobalMemAllocType)GetProcAddress(baseAddress, "CreateGlobalMemAlloc");
	g_pMemAllocSingleton = CreateGlobalMemAlloc();

	Error = (ErrorType)GetProcAddress(baseAddress, "Error");
	CommandLine = (CommandLineType)GetProcAddress(baseAddress, "CommandLine");
	Plat_FloatTime = (Plat_FloatTimeType)GetProcAddress(baseAddress, "Plat_FloatTime");
}