Subversion Repositories WoWGM

Rev

Rev 31 | Rev 36 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/****************************************************************************
*
*               ClientDebugCommands.cpp
*
*       Written by Tristan Cormier
*               11.20.24
*
***/


#include "pch.h"
#pragma hdrstop

#include "ClientDebugCommands.h"

#include <Console/ConsoleClient.h>
#include <DB/WowClientDB.h>
#include <WowSvcs/ClientServices.h>


/****************************************************************************
*
*   Client Debug Commands
*
***/

//===========================================================================
BOOL CCommand_BootMe (char const* command, char const* arguments) {
  CDataStore msg;
        msg.Put(CMSG_BOOTME);
  msg.Finalize();
  
        ClientServices_Send(&msg);
        
        return TRUE;
}

//===========================================================================
BOOL CCommand_CreateItem (char const* command, char const* arguments) {
        char string[256];
        SStrCopy(string, arguments, 0xffffffff);

        char *token = 0;
        token = strtok(string, " \t");

        int itemId = SStrToInt(token);

        int quantity = 1;
        if (token = strtok(NULL, "\r\n"))
                quantity = SStrToInt(token);

        CDataStore msg;
        msg.Put(CMSG_CREATEITEM);
        msg.Put(itemId);
        msg.Put(quantity);
        msg.Finalize();
        
        ClientServices_Send(&msg);
        
        return TRUE;
}

//===========================================================================
BOOL CCommand_CreateMonster (char const* command, char const* arguments) {
  int type = SStrToInt(arguments);

  CDataStore msg;
  msg.Put(CMSG_CREATEMONSTER);
  msg.Put(type);
  msg.Finalize();
  
        ClientServices_Send(&msg);
  
        return TRUE;
}

//===========================================================================
BOOL CCommand_Decharge (char const* command, char const* arguments) {
        CDataStore msg;
        msg.Put(CMSG_DECHARGE);
        msg.Finalize();
        
        ClientServices_Send(&msg);
        
        return TRUE;
}

//===========================================================================
BOOL CCommand_Learn (char const* command, char const* arguments) {
        int spellId = 0;

        if (isdigit(*arguments)) {
                spellId = SStrToInt(arguments);
                if (spellId <= 0)
                        return TRUE;
        }
        else {
                ConsoleWrite("Learning by spell name is not yet implemented", DEFAULT_COLOR);
                return TRUE;
        }

        CDataStore msg;
        msg.Put(CMSG_LEARN_SPELL);
        msg.Put(spellId);
        msg.Finalize();
        
        ClientServices_Send(&msg);

        return TRUE;
}

//===========================================================================
BOOL CCommand_Level (char const* command, char const* arguments) {
        int level = SStrToInt(arguments);

        if (level <= 0 || level > 100)
                ConsoleWrite("Invalid level specified\n", DEFAULT_COLOR);
        else {
                CDataStore msg;
                msg.Put(CMSG_LEVEL_CHEAT);
                msg.Put(level);
                msg.Finalize();

                ClientServices_Send(&msg);
        }

        return TRUE;
}

//===========================================================================
BOOL CCommand_Recharge (char const* command, char const* arguments) {
        CDataStore msg;
        msg.Put(CMSG_RECHARGE);
        msg.Finalize();
        
        ClientServices_Send(&msg);
        
        return TRUE;
}


/****************************************************************************
*
*   External
*
***/

//===========================================================================
void DebugClientCommands::Install () {
  ConsoleCommandRegister("bootme",CCommand_BootMe,DEBUG,NOHELP);
        ConsoleCommandRegister("learn",CCommand_Learn,DEBUG,"Learn a spell or -1 for all spells");
        ConsoleCommandRegister("ci",CCommand_CreateItem,GAME,NOHELP);
        ConsoleCommandRegister("createitem",CCommand_CreateItem,GAME,NOHELP);
        ConsoleCommandRegister("cm",CCommand_CreateMonster,GAME,NOHELP);
        ConsoleCommandRegister("createmonster",CCommand_CreateMonster,GAME,NOHELP);
        ConsoleCommandRegister("recharge",CCommand_Recharge,GAME,NOHELP);
        ConsoleCommandRegister("decharge",CCommand_Decharge,GAME,NOHELP);
        ConsoleCommandRegister("level",CCommand_Level,DEBUG,NOHELP);
}

//===========================================================================
void DebugClientCommands::Uninstall () {
  ConsoleCommandUnregister("bootme");
  ConsoleCommandUnregister("learn");
  ConsoleCommandUnregister("ci");
  ConsoleCommandUnregister("createitem");
  ConsoleCommandUnregister("cm");
  ConsoleCommandUnregister("createmonster");
  ConsoleCommandUnregister("recharge");
  ConsoleCommandUnregister("decharge");
  ConsoleCommandUnregister("level");
}