Subversion Repositories WoWGM

Rev

Rev 31 | Go to most recent revision | Details | Last modification | View Log | RSS feed

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