Subversion Repositories WoWGM

Rev

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

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