Rev 7 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#include "pch.h"
#pragma hdrstop
#include "CGlueMgr.h"
#include <Engine/Base/CDataStore.h>
#include <Console/ConsoleClient.h>
#include <FrameScript/FrameScript.h>
#include <WowSvcs/ClientServices.h>
/****************************************************************************
*
* Memory addresses
*
***/
#define CGLUEMGR__RESUME 0x004DA5F0
#define CGLUEMGR__SUSPEND 0x004D8930
#define CGLUEMGR__SHUTDOWN 0x004DBBC0
/****************************************************************************
*
* Function pointers
*
***/
void (__cdecl* ResumePtr) (int unknown) = *(void (__cdecl*)(int))CGLUEMGR__RESUME;
void (__cdecl* SuspendPtr) () = *(void (__cdecl*)())CGLUEMGR__SUSPEND;
void (__cdecl* ShutdownPtr) () = *(void (__cdecl*)())CGLUEMGR__SHUTDOWN;
/****************************************************************************
*
* Detours setup
*
***/
//===========================================================================
void WowGM::CGlueMgr::Initialize () {
DETOUR_INIT;
DETOUR_ATTACH(ResumePtr,::CGlueMgr::Resume);
DETOUR_ATTACH(SuspendPtr,::CGlueMgr::Suspend);
DETOUR_ATTACH(ShutdownPtr,::CGlueMgr::Shutdown);
DETOUR_COMMIT;
}
//===========================================================================
void WowGM::CGlueMgr::Shutdown () {
DETOUR_INIT;
DETOUR_DETACH(ResumePtr,::CGlueMgr::Resume);
DETOUR_DETACH(SuspendPtr,::CGlueMgr::Suspend);
DETOUR_DETACH(ShutdownPtr,::CGlueMgr::Shutdown);
DETOUR_COMMIT;
}
//===========================================================================
void WowGM::CGlueMgr::RegisterConsoleCommands() {
::CGlueMgr::RegisterConsoleCommands();
}
//===========================================================================
void WowGM::CGlueMgr::UnregisterConsoleCommands () {
::CGlueMgr::UnregisterConsoleCommands();
}
/****************************************************************************
*
* Commands
*
***/
//===========================================================================
int __cdecl CCommand_Script2 (const char* cmd,
const char* arguments) {
FrameScript_Execute(arguments, arguments, NULL);
return 0;
}
int __cdecl CCommand_MoveCharacter (const char* command, const char* arguments) {
if ((*(int*)0x00B6A9E0)) { // CGlueMgr::m_currentScreen == 2
int characterIndex = (*(int*)0x00AC436C); //CCharacterSelection::s_selectionIndex
int numCharacters = (*(int*)0x00B6B23C);
int sumtingwong = (*(int*)0xB6B240);
unsigned long long guid = *(unsigned long long*)(sumtingwong + 408 * characterIndex);
CDataStore netMsg;
netMsg.Put(CMSG_MOVE_CHARACTER_CHEAT);
netMsg.Put(NULL);
netMsg.Put(1);
netMsg.Put(guid);
netMsg.Put(16310.325195f);
netMsg.Put(16268.939453f);
netMsg.Put(69.444290f);
netMsg.Put(0.00f);
netMsg.Finalize();
ClientServices_SendOnConnection(&netMsg);
FrameScript_Execute("GetCharacterListUpdate()", "GetCharacterListUpdate()", NULL);
//ClientConnection::GetCharacterList();
}
else {
ConsoleWrite("You can only use this command on the character selection screen", ERROR_COLOR);
}
return 0;
}
//===========================================================================
int __cdecl Script_DebugTest (lua_State* L) {
ConsoleWrite("Hello from Script_DebugTest!",ADMIN_COLOR);
return TRUE;
}
/****************************************************************************
*
* CGlueMgr class implementation
*
***/
//===========================================================================
void __cdecl CGlueMgr::Resume (int initialized) {
ResumePtr(initialized);
RegisterConsoleCommands();
}
//===========================================================================
void __cdecl CGlueMgr::Suspend () {
SuspendPtr();
UnregisterConsoleCommands();
}
//===========================================================================
void __cdecl CGlueMgr::Shutdown () {
ShutdownPtr();
}
//===========================================================================
void __cdecl CGlueMgr::RegisterConsoleCommands()
{
ConsoleCommandRegister("script", CCommand_Script2, DEFAULT, 0);
ConsoleCommandRegister("movecharacter", CCommand_MoveCharacter, GAME, NOHELP);
ConsoleCommandRegister("worldport", CCommand_MoveCharacter, GAME, NOHELP);
// TODO: Move the below line under FrameScript.cpp (see FrameScript_Initialize)
//ConsoleCommandRegister("signalevent", CCommand_SignalEvent, DEFAULT, 0);
FrameScript_RegisterFunction("debugtest",Script_DebugTest);
}
//===========================================================================
void __cdecl CGlueMgr::UnregisterConsoleCommands() {
ConsoleCommandUnregister("script");
ConsoleCommandUnregister("movecharacter");
ConsoleCommandUnregister("worldport");
//ConsoleCommandUnregister("signalevent");
FrameScript_UnregisterFunction("debugtest");
}