Subversion Repositories WoWGM

Rev

Rev 32 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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