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