Subversion Repositories WoWGM

Rev

Rev 6 | Rev 31 | 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 "ClientCommands.h"
6 tristanc 5
 
3 tristanc 6
#include <ClientDebugCommands.h>
6 tristanc 7
#include <ClientGMCommands.h>
3 tristanc 8
#include <Console/ConsoleClient.h>
9
#include <FrameScript/FrameScript.h>
10
#include <WowSvcs/ClientServices.h>
11
 
12
/****************************************************************************
13
*
14
*	 Memory addresses
15
*
16
***/
17
 
18
#define INSTALLGAMECONSOLECOMMANDSPTR	0x00407870;
19
#define UNINSTALLGAMECONSOLECOMMANDSPTR	0x00406EF0;
20
 
21
 
22
/****************************************************************************
23
*
24
*	 Function pointers
25
*
26
***/
27
 
28
void (*InstallGameConsoleCommandsPtr)()		= *(void (*)())INSTALLGAMECONSOLECOMMANDSPTR;
29
void (*UninstallGameConsoleCommandsPtr)()	= *(void (*)())UNINSTALLGAMECONSOLECOMMANDSPTR;
30
 
31
 
32
/****************************************************************************
33
*
34
*	Game commands
35
*
36
***/
37
 
38
//===========================================================================
39
BOOL CCommand_GodMode(const char* cmd, const char* arguments)
40
{	
41
	if (arguments && *arguments) {
42
		int enable = atoi(arguments);
43
 
44
		CDataStore msg;
45
		msg.Put(CMSG_GODMODE);
46
		msg.Put(enable);
47
		msg.Finalize();
48
 
49
		ClientServices_Send(&msg);
50
	}
51
	return TRUE;
52
}
53
 
54
 
55
/****************************************************************************
56
*
57
*	Private
58
*
59
***/
60
 
61
//===========================================================================
62
void InstallGameConsoleCommands()
63
{
64
	InstallGameConsoleCommandsPtr();
65
 
66
	// Register our own commands
67
	ConsoleCommandRegister("godmode",CCommand_GodMode,GAME,NOHELP);
68
 
69
	DebugClientCommands::Install();
6 tristanc 70
	GMClientCommands::Install();
3 tristanc 71
}
72
 
73
//===========================================================================
74
void UninstallGameConsoleCommands()
75
{
76
	UninstallGameConsoleCommandsPtr();
77
 
78
	// Unregister our own commands
79
	ConsoleCommandUnregister("godmode");
80
 
81
	DebugClientCommands::Uninstall();
6 tristanc 82
	GMClientCommands::Uninstall();
3 tristanc 83
}
84
 
85
 
86
/****************************************************************************
87
*
88
*	 Detours setup (external functions)
89
*
90
***/
91
 
92
//===========================================================================
93
void WowGM::InstallGameConsoleCommands()
94
{
95
	DETOUR_INIT;
96
	DETOUR_ATTACH(InstallGameConsoleCommandsPtr,::InstallGameConsoleCommands);
97
	DETOUR_ATTACH(UninstallGameConsoleCommandsPtr,::UninstallGameConsoleCommands);
98
	DETOUR_COMMIT;
99
}
100
 
101
//===========================================================================
102
void WowGM::UninstallGameConsoleCommands()
103
{
104
	DETOUR_INIT;	
105
	DETOUR_DETACH(InstallGameConsoleCommandsPtr,::InstallGameConsoleCommands);
106
	DETOUR_DETACH(UninstallGameConsoleCommandsPtr,::UninstallGameConsoleCommands);
107
	DETOUR_COMMIT;
108
}