Subversion Repositories WoWGM

Rev

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

#include "pch.h"
#pragma hdrstop

#include "ClientCommands.h"

#include <ClientDebugCommands.h>
#include <ClientGMCommands.h>
#include <Console/ConsoleClient.h>
#include <FrameScript/FrameScript.h>
#include <WowSvcs/ClientServices.h>


/****************************************************************************
*
*   Client memory addresses
*
***/

#define  INSTALLGAMECONSOLECOMMANDSPTR    0x00407870
#define  UNINSTALLGAMECONSOLECOMMANDSPTR  0x00406EF0


/****************************************************************************
*
*   Client function pointers
*
***/

void (*InstallGameConsoleCommandsPtr)() = *(void (*)())INSTALLGAMECONSOLECOMMANDSPTR;

void (*UninstallGameConsoleCommandsPtr)()       = *(void (*)())UNINSTALLGAMECONSOLECOMMANDSPTR;


/****************************************************************************
*
*   Client Game Commands
*
***/

//===========================================================================
BOOL CCommand_GodMode (const char* cmd, const char* arguments) {        
        if (arguments && *arguments) {
                int enable = atoi(arguments);

                CDataStore msg;
                msg.Put(CMSG_GODMODE);
                msg.Put(enable);
                msg.Finalize();

                ClientServices_Send(&msg);
        }

        return TRUE;
}


/****************************************************************************
*
*   Private
*
***/

//===========================================================================
void InstallGameConsoleCommands () {
        InstallGameConsoleCommandsPtr();

        // Register our own commands
        ConsoleCommandRegister("godmode",CCommand_GodMode,GAME,NOHELP);

        DebugClientCommands::Install();
        GMClientCommands::Install();
}

//===========================================================================
void UninstallGameConsoleCommands () {
        UninstallGameConsoleCommandsPtr();
        
        // Unregister our own commands
        ConsoleCommandUnregister("godmode");

        DebugClientCommands::Uninstall();
        GMClientCommands::Uninstall();
}


/****************************************************************************
*
*   Detours setup
*
***/

//===========================================================================
void WowGM::InstallGameConsoleCommands () {
        DETOUR_INIT;
        DETOUR_ATTACH(InstallGameConsoleCommandsPtr,::InstallGameConsoleCommands);
        DETOUR_ATTACH(UninstallGameConsoleCommandsPtr,::UninstallGameConsoleCommands);
        DETOUR_COMMIT;
}

//===========================================================================
void WowGM::UninstallGameConsoleCommands () {
        DETOUR_INIT;    
        DETOUR_DETACH(InstallGameConsoleCommandsPtr,::InstallGameConsoleCommands);
        DETOUR_DETACH(UninstallGameConsoleCommandsPtr,::UninstallGameConsoleCommands);
        DETOUR_COMMIT;
}