Subversion Repositories WoWGM

Rev

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

Rev Author Line No. Line
36 tristanc 1
/******************************************************************************
32 tristanc 2
*
36 tristanc 3
*   ClientDebugCommands.cpp
32 tristanc 4
*
5
*
36 tristanc 6
*   By Tristan Cormier - 11/21/2024
7
*
32 tristanc 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
 
36 tristanc 21
/******************************************************************************
3 tristanc 22
*
36 tristanc 23
*   Private
3 tristanc 24
*
25
***/
26
 
36 tristanc 27
//=============================================================================
28
BOOL CCommand_BootMe (const char * command, const char * arguments) {
29
    CDataStore msg;
30
    msg.Put(CMSG_BOOTME);
31
    msg.Finalize();
32
 
33
    ClientServices_Send(&msg);
34
 
35
    return TRUE;
3 tristanc 36
}
37
 
36 tristanc 38
//=============================================================================
39
BOOL CCommand_CreateItem (const char * command, const char * arguments) {
15 tristanc 40
	char string[256];
41
	SStrCopy(string, arguments, 0xffffffff);
32 tristanc 42
 
36 tristanc 43
	char * token = 0;
15 tristanc 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
 
36 tristanc 63
//=============================================================================
25 tristanc 64
BOOL CCommand_CreateMonster (char const* command, char const* arguments) {
36 tristanc 65
    // Monster type to create: negative for pet
66
    int type = SStrToInt(arguments);
25 tristanc 67
 
36 tristanc 68
    CDataStore msg;
69
    msg.Put(CMSG_CREATEMONSTER);
70
    msg.Put(type);
71
    msg.Finalize();
72
 
73
    ClientServices_Send(&msg);
74
 
75
    return TRUE;
25 tristanc 76
}
77
 
36 tristanc 78
//=============================================================================
23 tristanc 79
BOOL CCommand_Decharge (char const* command, char const* arguments) {
36 tristanc 80
	CDataStore msg; 
23 tristanc 81
	msg.Put(CMSG_DECHARGE);
82
	msg.Finalize();
32 tristanc 83
 
23 tristanc 84
	ClientServices_Send(&msg);
32 tristanc 85
 
23 tristanc 86
	return TRUE;
87
}
88
 
36 tristanc 89
//=============================================================================
90
BOOL CCommand_Learn (const char * command, const char * arguments) {
91
    int spellId = 0;
92
    if (isdigit(*arguments)) {
93
        spellId = SStrToInt(arguments);
94
        if (spellId <= 0)
95
            return TRUE;
96
    }
97
    else {
98
        // TODO:
99
        ConsoleWrite("Learning spells by name is not yet implemented", DEFAULT_COLOR);
100
        return TRUE;
101
    }
32 tristanc 102
 
36 tristanc 103
    CDataStore msg;
104
    msg.Put(CMSG_LEARN_SPELL);
105
    msg.Put(spellId);
106
    msg.Finalize();
3 tristanc 107
 
36 tristanc 108
    ClientServices_Send(&msg);
32 tristanc 109
 
36 tristanc 110
    return TRUE;
7 tristanc 111
}
112
 
36 tristanc 113
//=============================================================================
114
BOOL CCommand_Level (const char * command, const char * arguments) {
115
    int level = SStrToInt(arguments);
116
    if (level <= 0 || level > 100)
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();
24 tristanc 123
 
36 tristanc 124
        ClientServices_Send(&msg);
125
    }
32 tristanc 126
 
36 tristanc 127
    return TRUE;
24 tristanc 128
}
129
 
36 tristanc 130
//=============================================================================
131
BOOL CCommand_Recharge (const char * command, const char * arguments) {
132
    CDataStore msg;
133
    msg.Put(CMSG_RECHARGE);
134
    msg.Finalize();
135
 
136
    ClientServices_Send(&msg);
137
 
138
    return TRUE;
22 tristanc 139
}
7 tristanc 140
 
22 tristanc 141
 
36 tristanc 142
/******************************************************************************
3 tristanc 143
*
36 tristanc 144
*   Exports
3 tristanc 145
*
146
***/
147
 
36 tristanc 148
//=============================================================================
31 tristanc 149
void DebugClientCommands::Install () {
36 tristanc 150
    ConsoleCommandRegister("bootme", CCommand_BootMe, DEBUG, NOHELP);
151
 
152
    ConsoleCommandRegister(
153
        "learn",
154
        CCommand_Learn,
155
        DEBUG,
156
        "Learn a spell or -1 for all spells"
157
    );
158
 
159
    ConsoleCommandRegister("ci", CCommand_CreateItem, GAME, NOHELP);
160
    ConsoleCommandRegister("createitem", CCommand_CreateItem, GAME, NOHELP);
161
 
162
    ConsoleCommandRegister("cm", CCommand_CreateMonster, GAME, NOHELP);
163
    ConsoleCommandRegister("createmonster", CCommand_CreateMonster, GAME, NOHELP);
164
 
165
    ConsoleCommandRegister("recharge", CCommand_Recharge, GAME, NOHELP);
166
    ConsoleCommandRegister("decharge", CCommand_Decharge, GAME, NOHELP);
167
 
168
    ConsoleCommandRegister("level", CCommand_Level, DEBUG, NOHELP);
3 tristanc 169
}
170
 
36 tristanc 171
//=============================================================================
31 tristanc 172
void DebugClientCommands::Uninstall () {
36 tristanc 173
    ConsoleCommandUnregister("bootme");
174
    ConsoleCommandUnregister("learn");
175
    ConsoleCommandUnregister("ci");
176
    ConsoleCommandUnregister("createitem");
177
    ConsoleCommandUnregister("cm");
178
    ConsoleCommandUnregister("createmonster");
179
    ConsoleCommandUnregister("recharge");
180
    ConsoleCommandUnregister("decharge");
181
    ConsoleCommandUnregister("level");
3 tristanc 182
}
32 tristanc 183
 
36 tristanc 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
//===================================