Subversion Repositories WoWGM

Rev

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