Subversion Repositories WoWGM

Rev

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