Subversion Repositories WoWGM

Rev

Rev 31 | Rev 36 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
32 tristanc 1
/****************************************************************************
2
*
3
*		ClientDebugCommands.cpp
4
*
5
* 	Written by Tristan Cormier
6
*		11.20.24
7
*
8
***/
9
 
10
 
3 tristanc 11
#include "pch.h"
12
#pragma hdrstop
13
 
14
#include "ClientDebugCommands.h"
6 tristanc 15
 
3 tristanc 16
#include <Console/ConsoleClient.h>
7 tristanc 17
#include <DB/WowClientDB.h>
3 tristanc 18
#include <WowSvcs/ClientServices.h>
19
 
31 tristanc 20
 
3 tristanc 21
/****************************************************************************
22
*
31 tristanc 23
*   Client Debug Commands
3 tristanc 24
*
25
***/
26
 
27
//===========================================================================
32 tristanc 28
BOOL CCommand_BootMe (char const* command, char const* arguments) {
3 tristanc 29
  CDataStore msg;
32 tristanc 30
	msg.Put(CMSG_BOOTME);
3 tristanc 31
  msg.Finalize();
32 tristanc 32
 
33
	ClientServices_Send(&msg);
34
 
35
	return TRUE;
3 tristanc 36
}
37
 
7 tristanc 38
//===========================================================================
31 tristanc 39
BOOL CCommand_CreateItem (char const* command, char const* arguments) {
15 tristanc 40
	char string[256];
41
	SStrCopy(string, arguments, 0xffffffff);
32 tristanc 42
 
15 tristanc 43
	char *token = 0;
44
	token = strtok(string, " \t");
32 tristanc 45
 
19 tristanc 46
	int itemId = SStrToInt(token);
32 tristanc 47
 
15 tristanc 48
	int quantity = 1;
32 tristanc 49
	if (token = strtok(NULL, "\r\n"))
19 tristanc 50
		quantity = SStrToInt(token);
32 tristanc 51
 
15 tristanc 52
	CDataStore msg;
53
	msg.Put(CMSG_CREATEITEM);
54
	msg.Put(itemId);
55
	msg.Put(quantity);
56
	msg.Finalize();
32 tristanc 57
 
15 tristanc 58
	ClientServices_Send(&msg);
32 tristanc 59
 
15 tristanc 60
	return TRUE;
61
}
62
 
63
//===========================================================================
25 tristanc 64
BOOL CCommand_CreateMonster (char const* command, char const* arguments) {
65
  int type = SStrToInt(arguments);
66
 
67
  CDataStore msg;
68
  msg.Put(CMSG_CREATEMONSTER);
69
  msg.Put(type);
70
  msg.Finalize();
32 tristanc 71
 
72
	ClientServices_Send(&msg);
73
 
74
	return TRUE;
25 tristanc 75
}
76
 
77
//===========================================================================
23 tristanc 78
BOOL CCommand_Decharge (char const* command, char const* arguments) {
79
	CDataStore msg;
80
	msg.Put(CMSG_DECHARGE);
81
	msg.Finalize();
32 tristanc 82
 
23 tristanc 83
	ClientServices_Send(&msg);
32 tristanc 84
 
23 tristanc 85
	return TRUE;
86
}
87
 
88
//===========================================================================
32 tristanc 89
BOOL CCommand_Learn (char const* command, char const* arguments) {
7 tristanc 90
	int spellId = 0;
32 tristanc 91
 
7 tristanc 92
	if (isdigit(*arguments)) {
19 tristanc 93
		spellId = SStrToInt(arguments);
32 tristanc 94
		if (spellId <= 0)
7 tristanc 95
			return TRUE;
96
	}
97
	else {
98
		ConsoleWrite("Learning by spell name is not yet implemented", DEFAULT_COLOR);
99
		return TRUE;
100
	}
3 tristanc 101
 
7 tristanc 102
	CDataStore msg;
103
	msg.Put(CMSG_LEARN_SPELL);
104
	msg.Put(spellId);
105
	msg.Finalize();
32 tristanc 106
 
7 tristanc 107
	ClientServices_Send(&msg);
32 tristanc 108
 
7 tristanc 109
	return TRUE;
110
}
111
 
22 tristanc 112
//===========================================================================
24 tristanc 113
BOOL CCommand_Level (char const* command, char const* arguments) {
32 tristanc 114
	int level = SStrToInt(arguments);
24 tristanc 115
 
32 tristanc 116
	if (level <= 0 || level > 100)
24 tristanc 117
		ConsoleWrite("Invalid level specified\n", DEFAULT_COLOR);
118
	else {
119
		CDataStore msg;
120
		msg.Put(CMSG_LEVEL_CHEAT);
121
		msg.Put(level);
122
		msg.Finalize();
32 tristanc 123
 
24 tristanc 124
		ClientServices_Send(&msg);
125
	}
32 tristanc 126
 
24 tristanc 127
	return TRUE;
128
}
129
 
130
//===========================================================================
22 tristanc 131
BOOL CCommand_Recharge (char const* command, char const* arguments) {
132
	CDataStore msg;
133
	msg.Put(CMSG_RECHARGE);
134
	msg.Finalize();
32 tristanc 135
 
22 tristanc 136
	ClientServices_Send(&msg);
32 tristanc 137
 
22 tristanc 138
	return TRUE;
139
}
7 tristanc 140
 
22 tristanc 141
 
3 tristanc 142
/****************************************************************************
143
*
31 tristanc 144
*   External
3 tristanc 145
*
146
***/
147
 
148
//===========================================================================
31 tristanc 149
void DebugClientCommands::Install () {
3 tristanc 150
  ConsoleCommandRegister("bootme",CCommand_BootMe,DEBUG,NOHELP);
32 tristanc 151
	ConsoleCommandRegister("learn",CCommand_Learn,DEBUG,"Learn a spell or -1 for all spells");
152
	ConsoleCommandRegister("ci",CCommand_CreateItem,GAME,NOHELP);
153
	ConsoleCommandRegister("createitem",CCommand_CreateItem,GAME,NOHELP);
154
	ConsoleCommandRegister("cm",CCommand_CreateMonster,GAME,NOHELP);
155
	ConsoleCommandRegister("createmonster",CCommand_CreateMonster,GAME,NOHELP);
156
	ConsoleCommandRegister("recharge",CCommand_Recharge,GAME,NOHELP);
157
	ConsoleCommandRegister("decharge",CCommand_Decharge,GAME,NOHELP);
158
	ConsoleCommandRegister("level",CCommand_Level,DEBUG,NOHELP);
3 tristanc 159
}
160
 
161
//===========================================================================
31 tristanc 162
void DebugClientCommands::Uninstall () {
3 tristanc 163
  ConsoleCommandUnregister("bootme");
7 tristanc 164
  ConsoleCommandUnregister("learn");
15 tristanc 165
  ConsoleCommandUnregister("ci");
166
  ConsoleCommandUnregister("createitem");
25 tristanc 167
  ConsoleCommandUnregister("cm");
168
  ConsoleCommandUnregister("createmonster");
22 tristanc 169
  ConsoleCommandUnregister("recharge");
23 tristanc 170
  ConsoleCommandUnregister("decharge");
24 tristanc 171
  ConsoleCommandUnregister("level");
3 tristanc 172
}
32 tristanc 173