| 3 |
tristanc |
1 |
#include "pch.h"
|
|
|
2 |
#pragma hdrstop
|
|
|
3 |
|
|
|
4 |
#include "GameUI.h"
|
|
|
5 |
#include <Console/ConsoleClient.h>
|
|
|
6 |
#include <FrameScript/FrameScript.h>
|
|
|
7 |
|
| 32 |
tristanc |
8 |
|
| 3 |
tristanc |
9 |
/****************************************************************************
|
|
|
10 |
*
|
| 31 |
tristanc |
11 |
* Client memory addresses
|
| 3 |
tristanc |
12 |
*
|
|
|
13 |
***/
|
|
|
14 |
|
| 32 |
tristanc |
15 |
#define CGGAMEUI__INITIALIZE 0x0052A980
|
|
|
16 |
#define CGGAMEUI__CANPERFORMACTION 0x005191C0
|
|
|
17 |
#define CGGAMEUI__SHUTDOWN 0x00528F00
|
| 3 |
tristanc |
18 |
|
|
|
19 |
|
|
|
20 |
/****************************************************************************
|
|
|
21 |
*
|
| 31 |
tristanc |
22 |
* Client function pointers
|
| 3 |
tristanc |
23 |
*
|
|
|
24 |
***/
|
|
|
25 |
|
| 31 |
tristanc |
26 |
void (*InitializePtr)() = *(void(*)())CGGAMEUI__INITIALIZE;
|
| 3 |
tristanc |
27 |
|
| 31 |
tristanc |
28 |
bool (*CanPerformActionPtr)(ACTIONTYPE) = *(bool(*)(ACTIONTYPE))CGGAMEUI__CANPERFORMACTION;
|
| 3 |
tristanc |
29 |
|
| 31 |
tristanc |
30 |
void (*ShutdownPtr2)() = *(void(*)())CGGAMEUI__SHUTDOWN;
|
|
|
31 |
|
|
|
32 |
|
| 3 |
tristanc |
33 |
/****************************************************************************
|
|
|
34 |
*
|
| 31 |
tristanc |
35 |
* Private
|
| 3 |
tristanc |
36 |
*
|
|
|
37 |
***/
|
|
|
38 |
|
| 32 |
tristanc |
39 |
static bool s_initialized = false;
|
| 3 |
tristanc |
40 |
static CVar *s_enableTaintEnforcement;
|
|
|
41 |
|
|
|
42 |
//===========================================================================
|
| 32 |
tristanc |
43 |
int CCommand_Script (char const* cmd, char const* arguments) {
|
| 3 |
tristanc |
44 |
FrameScript_Execute(arguments,arguments,NULL);
|
| 32 |
tristanc |
45 |
return 1;
|
| 3 |
tristanc |
46 |
}
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
/****************************************************************************
|
|
|
50 |
*
|
| 31 |
tristanc |
51 |
* CGGameUI class implementation
|
| 3 |
tristanc |
52 |
*
|
|
|
53 |
***/
|
|
|
54 |
|
|
|
55 |
//===========================================================================
|
| 31 |
tristanc |
56 |
bool CGGameUI::CanPerformAction (ACTIONTYPE action) {
|
| 3 |
tristanc |
57 |
if (s_enableTaintEnforcement) {
|
| 32 |
tristanc |
58 |
// Always enable any action if taint enforcement is disabled by the client
|
| 3 |
tristanc |
59 |
if (s_enableTaintEnforcement->m_intValue == 0)
|
|
|
60 |
return true;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
return CanPerformActionPtr(action);
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
//===========================================================================
|
| 32 |
tristanc |
67 |
void CGGameUI::Initialize () {
|
|
|
68 |
if (!s_initialized) {
|
|
|
69 |
DETOUR_INIT;
|
|
|
70 |
DETOUR_ATTACH(InitializePtr,InitializeProc);
|
|
|
71 |
DETOUR_ATTACH(CanPerformActionPtr,CanPerformAction);
|
|
|
72 |
DETOUR_ATTACH(ShutdownPtr2,ShutdownProc);
|
|
|
73 |
DETOUR_COMMIT;
|
|
|
74 |
s_initialized = true;
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
//===========================================================================
|
|
|
79 |
void CGGameUI::InitializeProc () {
|
|
|
80 |
InitializePtr();
|
|
|
81 |
|
|
|
82 |
s_enableTaintEnforcement = CVar::Register("enableTaintEnforcement",
|
|
|
83 |
"Enables enforcement of taint in GM clients",
|
|
|
84 |
NULL,
|
|
|
85 |
"0",
|
|
|
86 |
NULL,
|
|
|
87 |
GAME,
|
|
|
88 |
false,
|
|
|
89 |
NULL,
|
|
|
90 |
false);
|
|
|
91 |
|
|
|
92 |
RegisterScriptFunctions();
|
|
|
93 |
RegisterConsoleCommands();
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
//===========================================================================
|
| 31 |
tristanc |
97 |
void CGGameUI::RegisterConsoleCommands () {
|
| 3 |
tristanc |
98 |
ConsoleCommandRegister("script",CCommand_Script,DEFAULT,NULL);
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
//===========================================================================
|
| 32 |
tristanc |
102 |
void CGGameUI::RegisterScriptFunctions () {
|
|
|
103 |
// Register scripts here
|
| 3 |
tristanc |
104 |
}
|
|
|
105 |
|
|
|
106 |
//===========================================================================
|
| 32 |
tristanc |
107 |
void CGGameUI::Shutdown () {
|
|
|
108 |
if (s_initialized) {
|
|
|
109 |
DETOUR_INIT;
|
|
|
110 |
DETOUR_DETACH(InitializePtr,Initialize);
|
|
|
111 |
DETOUR_DETACH(CanPerformActionPtr,CanPerformAction);
|
|
|
112 |
DETOUR_DETACH(ShutdownPtr2,Shutdown);
|
|
|
113 |
DETOUR_COMMIT;
|
|
|
114 |
s_initialized = false;
|
|
|
115 |
}
|
| 3 |
tristanc |
116 |
}
|
|
|
117 |
|
|
|
118 |
//===========================================================================
|
| 32 |
tristanc |
119 |
void CGGameUI::ShutdownProc () {
|
|
|
120 |
ShutdownPtr2();
|
|
|
121 |
|
|
|
122 |
UnregisterScriptFunctions();
|
|
|
123 |
UnregisterConsoleCommands();
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
//===========================================================================
|
|
|
127 |
void CGGameUI::UnregisterConsoleCommands () {
|
|
|
128 |
ConsoleCommandUnregister("script");
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
//===========================================================================
|
| 31 |
tristanc |
132 |
void CGGameUI::UnregisterScriptFunctions () {
|
| 3 |
tristanc |
133 |
// Unregister scripts here
|
| 31 |
tristanc |
134 |
}
|