Subversion Repositories WoWGM

Rev

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

Rev 32 Rev 36
Line 1... Line 1...
1
/****************************************************************************
1
/******************************************************************************
2
*
2
*
3
*		ClientDebugCommands.cpp
3
*   ClientDebugCommands.cpp
4
*
4
*
-
 
5
*
5
* 	Written by Tristan Cormier
6
*   By Tristan Cormier - 11/21/2024
6
*		11.20.24
-
 
7
*
7
*
8
***/
8
***/
9
 
9
 
10
 
10
 
11
#include "pch.h"
11
#include "pch.h"
Line 16... Line 16...
16
#include <Console/ConsoleClient.h>
16
#include <Console/ConsoleClient.h>
17
#include <DB/WowClientDB.h>
17
#include <DB/WowClientDB.h>
18
#include <WowSvcs/ClientServices.h>
18
#include <WowSvcs/ClientServices.h>
19
 
19
 
20
 
20
 
21
/****************************************************************************
21
/******************************************************************************
22
*
22
*
23
*   Client Debug Commands
23
*   Private
24
*
24
*
25
***/
25
***/
26
 
26
 
27
//===========================================================================
27
//=============================================================================
28
BOOL CCommand_BootMe (char const* command, char const* arguments) {
28
BOOL CCommand_BootMe (const char * command, const char * arguments) {
29
  CDataStore msg;
29
    CDataStore msg;
30
	msg.Put(CMSG_BOOTME);
30
    msg.Put(CMSG_BOOTME);
31
  msg.Finalize();
31
    msg.Finalize();
32
  
32
    
33
	ClientServices_Send(&msg);
33
    ClientServices_Send(&msg);
34
	
34
    
35
	return TRUE;
35
    return TRUE;
36
}
36
}
37
 
37
 
38
//===========================================================================
38
//=============================================================================
39
BOOL CCommand_CreateItem (char const* command, char const* arguments) {
39
BOOL CCommand_CreateItem (const char * command, const char * arguments) {
40
	char string[256];
40
	char string[256];
41
	SStrCopy(string, arguments, 0xffffffff);
41
	SStrCopy(string, arguments, 0xffffffff);
42
 
42
 
43
	char *token = 0;
43
	char * token = 0;
44
	token = strtok(string, " \t");
44
	token = strtok(string, " \t");
45
 
45
 
46
	int itemId = SStrToInt(token);
46
	int itemId = SStrToInt(token);
47
 
47
 
48
	int quantity = 1;
48
	int quantity = 1;
Line 58... Line 58...
58
	ClientServices_Send(&msg);
58
	ClientServices_Send(&msg);
59
	
59
	
60
	return TRUE;
60
	return TRUE;
61
}
61
}
62
 
62
 
63
//===========================================================================
63
//=============================================================================
64
BOOL CCommand_CreateMonster (char const* command, char const* arguments) {
64
BOOL CCommand_CreateMonster (char const* command, char const* arguments) {
-
 
65
    // Monster type to create: negative for pet
65
  int type = SStrToInt(arguments);
66
    int type = SStrToInt(arguments);
66
 
67
 
67
  CDataStore msg;
68
    CDataStore msg;
68
  msg.Put(CMSG_CREATEMONSTER);
69
    msg.Put(CMSG_CREATEMONSTER);
69
  msg.Put(type);
70
    msg.Put(type);
70
  msg.Finalize();
71
    msg.Finalize();
71
  
72
 
72
	ClientServices_Send(&msg);
73
    ClientServices_Send(&msg);
73
  
74
 
74
	return TRUE;
75
    return TRUE;
75
}
76
}
76
 
77
 
77
//===========================================================================
78
//=============================================================================
78
BOOL CCommand_Decharge (char const* command, char const* arguments) {
79
BOOL CCommand_Decharge (char const* command, char const* arguments) {
79
	CDataStore msg;
80
	CDataStore msg; 
80
	msg.Put(CMSG_DECHARGE);
81
	msg.Put(CMSG_DECHARGE);
81
	msg.Finalize();
82
	msg.Finalize();
82
	
83
	
83
	ClientServices_Send(&msg);
84
	ClientServices_Send(&msg);
84
	
85
	
85
	return TRUE;
86
	return TRUE;
86
}
87
}
87
 
88
 
88
//===========================================================================
89
//=============================================================================
89
BOOL CCommand_Learn (char const* command, char const* arguments) {
90
BOOL CCommand_Learn (const char * command, const char * arguments) {
90
	int spellId = 0;
91
    int spellId = 0;
91
 
-
 
92
	if (isdigit(*arguments)) {
92
    if (isdigit(*arguments)) {
93
		spellId = SStrToInt(arguments);
93
        spellId = SStrToInt(arguments);
94
		if (spellId <= 0)
94
        if (spellId <= 0)
95
			return TRUE;
95
            return TRUE;
96
	}
96
    }
97
	else {
97
    else {
-
 
98
        // TODO:
98
		ConsoleWrite("Learning by spell name is not yet implemented", DEFAULT_COLOR);
99
        ConsoleWrite("Learning spells by name is not yet implemented", DEFAULT_COLOR);
99
		return TRUE;
100
        return TRUE;
100
	}
101
    }
101
 
102
 
102
	CDataStore msg;
103
    CDataStore msg;
103
	msg.Put(CMSG_LEARN_SPELL);
104
    msg.Put(CMSG_LEARN_SPELL);
104
	msg.Put(spellId);
105
    msg.Put(spellId);
105
	msg.Finalize();
106
    msg.Finalize();
106
	
-
 
107
	ClientServices_Send(&msg);
-
 
108
 
107
 
-
 
108
    ClientServices_Send(&msg);
-
 
109
 
109
	return TRUE;
110
    return TRUE;
110
}
111
}
111
 
112
 
112
//===========================================================================
113
//=============================================================================
113
BOOL CCommand_Level (char const* command, char const* arguments) {
114
BOOL CCommand_Level (const char * command, const char * arguments) {
114
	int level = SStrToInt(arguments);
115
    int level = SStrToInt(arguments);
115
 
-
 
116
	if (level <= 0 || level > 100)
116
    if (level <= 0 || level > 100)
117
		ConsoleWrite("Invalid level specified\n", DEFAULT_COLOR);
117
        ConsoleWrite("Invalid level specified\n", DEFAULT_COLOR);
118
	else {
118
    else {
119
		CDataStore msg;
119
        CDataStore msg;
120
		msg.Put(CMSG_LEVEL_CHEAT);
120
        msg.Put(CMSG_LEVEL_CHEAT);
121
		msg.Put(level);
121
        msg.Put(level);
122
		msg.Finalize();
122
        msg.Finalize();
123
 
123
 
124
		ClientServices_Send(&msg);
124
        ClientServices_Send(&msg);
125
	}
125
    }
126
 
126
 
127
	return TRUE;
127
    return TRUE;
128
}
128
}
129
 
129
 
130
//===========================================================================
130
//=============================================================================
131
BOOL CCommand_Recharge (char const* command, char const* arguments) {
131
BOOL CCommand_Recharge (const char * command, const char * arguments) {
132
	CDataStore msg;
132
    CDataStore msg;
133
	msg.Put(CMSG_RECHARGE);
133
    msg.Put(CMSG_RECHARGE);
134
	msg.Finalize();
134
    msg.Finalize();
135
	
135
 
136
	ClientServices_Send(&msg);
136
    ClientServices_Send(&msg);
137
	
137
 
138
	return TRUE;
138
    return TRUE;
139
}
139
}
140
 
140
 
141
 
141
 
142
/****************************************************************************
142
/******************************************************************************
143
*
143
*
144
*   External
144
*   Exports
145
*
145
*
146
***/
146
***/
147
 
147
 
148
//===========================================================================
148
//=============================================================================
149
void DebugClientCommands::Install () {
149
void DebugClientCommands::Install () {
150
  ConsoleCommandRegister("bootme",CCommand_BootMe,DEBUG,NOHELP);
150
    ConsoleCommandRegister("bootme", CCommand_BootMe, DEBUG, NOHELP);
-
 
151
 
-
 
152
    ConsoleCommandRegister(
-
 
153
        "learn",
-
 
154
        CCommand_Learn,
-
 
155
        DEBUG,
151
	ConsoleCommandRegister("learn",CCommand_Learn,DEBUG,"Learn a spell or -1 for all spells");
156
        "Learn a spell or -1 for all spells"
-
 
157
    );
-
 
158
 
152
	ConsoleCommandRegister("ci",CCommand_CreateItem,GAME,NOHELP);
159
    ConsoleCommandRegister("ci", CCommand_CreateItem, GAME, NOHELP);
153
	ConsoleCommandRegister("createitem",CCommand_CreateItem,GAME,NOHELP);
160
    ConsoleCommandRegister("createitem", CCommand_CreateItem, GAME, NOHELP);
-
 
161
 
154
	ConsoleCommandRegister("cm",CCommand_CreateMonster,GAME,NOHELP);
162
    ConsoleCommandRegister("cm", CCommand_CreateMonster, GAME, NOHELP);
155
	ConsoleCommandRegister("createmonster",CCommand_CreateMonster,GAME,NOHELP);
163
    ConsoleCommandRegister("createmonster", CCommand_CreateMonster, GAME, NOHELP);
-
 
164
 
156
	ConsoleCommandRegister("recharge",CCommand_Recharge,GAME,NOHELP);
165
    ConsoleCommandRegister("recharge", CCommand_Recharge, GAME, NOHELP);
157
	ConsoleCommandRegister("decharge",CCommand_Decharge,GAME,NOHELP);
166
    ConsoleCommandRegister("decharge", CCommand_Decharge, GAME, NOHELP);
-
 
167
 
158
	ConsoleCommandRegister("level",CCommand_Level,DEBUG,NOHELP);
168
    ConsoleCommandRegister("level", CCommand_Level, DEBUG, NOHELP);
159
}
169
}
160
 
170
 
161
//===========================================================================
171
//=============================================================================
162
void DebugClientCommands::Uninstall () {
172
void DebugClientCommands::Uninstall () {
163
  ConsoleCommandUnregister("bootme");
173
    ConsoleCommandUnregister("bootme");
164
  ConsoleCommandUnregister("learn");
174
    ConsoleCommandUnregister("learn");
165
  ConsoleCommandUnregister("ci");
175
    ConsoleCommandUnregister("ci");
166
  ConsoleCommandUnregister("createitem");
176
    ConsoleCommandUnregister("createitem");
167
  ConsoleCommandUnregister("cm");
177
    ConsoleCommandUnregister("cm");
168
  ConsoleCommandUnregister("createmonster");
178
    ConsoleCommandUnregister("createmonster");
169
  ConsoleCommandUnregister("recharge");
179
    ConsoleCommandUnregister("recharge");
170
  ConsoleCommandUnregister("decharge");
180
    ConsoleCommandUnregister("decharge");
171
  ConsoleCommandUnregister("level");
181
    ConsoleCommandUnregister("level");
172
}
182
}
173
 
183
 
-
 
184
 
-
 
185
//===================================
-
 
186
// MIT License
-
 
187
//
-
 
188
// Copyright (c) 2024 by Tristan Cormier
-
 
189
//
-
 
190
// Permission is hereby granted, free of charge, to any person obtaining a copy
-
 
191
// of this software and associated documentation files (the "Software"), to deal
-
 
192
// in the Software without restriction, including without limitation the rights
-
 
193
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-
 
194
// copies of the Software, and to permit persons to whom the Software is
-
 
195
// furnished to do so, subject to the following conditions:
-
 
196
//
-
 
197
// The above copyright notice and this permission notice shall be included in
-
 
198
// all copies or substantial portions of the Software.
-
 
199
// 
-
 
200
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-
 
201
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-
 
202
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-
 
203
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-
 
204
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-
 
205
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-
 
206
// THE SOFTWARE.
-
 
207
//===================================
174
 
208