Subversion Repositories WoWGM

Rev

Rev 3 | Rev 32 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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