Subversion Repositories WoWGM

Rev

Rev 31 | Rev 36 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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