Subversion Repositories WoWGM

Rev

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