Subversion Repositories WoWGM

Rev

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

#include "pch.h"
#pragma hdrstop

#include "ClientDebugCommands.h"

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

/****************************************************************************
*
*       Command definitions
*
***/

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

//===========================================================================
BOOL CCommand_Bug(char const* command, char const* args) {
  //TODO:
  //ASSERT(command);

  unsigned int category;

  if (!SStrCmpI(command, "bug"))
    category = 0;
  else if (!SStrCmpI(command, "suggestion"))
    category = 1;

  if (ClientServices_Report(category, args))
    ConsolePrintf("%s submitted", command);
  else
    ConsolePrintf("%s submission failed", command);

  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(const char* command, const char* 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 functions
*
***/

//===========================================================================
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");
}