| 3 |
tristanc |
1 |
#include "pch.h"
|
|
|
2 |
#pragma hdrstop
|
|
|
3 |
|
|
|
4 |
#include "CGlueMgr.h"
|
|
|
5 |
#include <Engine/Base/CDataStore.h>
|
|
|
6 |
#include <Console/ConsoleClient.h>
|
|
|
7 |
#include <FrameScript/FrameScript.h>
|
|
|
8 |
#include <WowSvcs/ClientServices.h>
|
|
|
9 |
|
|
|
10 |
/****************************************************************************
|
|
|
11 |
*
|
|
|
12 |
* Memory addresses
|
|
|
13 |
*
|
|
|
14 |
***/
|
|
|
15 |
|
|
|
16 |
#define CGLUEMGR__RESUME 0x004DA5F0
|
|
|
17 |
#define CGLUEMGR__SUSPEND 0x004D8930
|
|
|
18 |
#define CGLUEMGR__SHUTDOWN 0x004DBBC0
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
/****************************************************************************
|
|
|
22 |
*
|
|
|
23 |
* Function pointers
|
|
|
24 |
*
|
|
|
25 |
***/
|
|
|
26 |
|
|
|
27 |
void (__cdecl* ResumePtr) (int unknown) = *(void (__cdecl*)(int))CGLUEMGR__RESUME;
|
|
|
28 |
void (__cdecl* SuspendPtr) () = *(void (__cdecl*)())CGLUEMGR__SUSPEND;
|
|
|
29 |
void (__cdecl* ShutdownPtr) () = *(void (__cdecl*)())CGLUEMGR__SHUTDOWN;
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
/****************************************************************************
|
|
|
33 |
*
|
|
|
34 |
* Detours setup
|
|
|
35 |
*
|
|
|
36 |
***/
|
|
|
37 |
|
|
|
38 |
//===========================================================================
|
|
|
39 |
void WowGM::CGlueMgr::Initialize () {
|
|
|
40 |
DETOUR_INIT;
|
|
|
41 |
|
|
|
42 |
DETOUR_ATTACH(ResumePtr,::CGlueMgr::Resume);
|
|
|
43 |
DETOUR_ATTACH(SuspendPtr,::CGlueMgr::Suspend);
|
|
|
44 |
DETOUR_ATTACH(ShutdownPtr,::CGlueMgr::Shutdown);
|
|
|
45 |
|
|
|
46 |
DETOUR_COMMIT;
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
//===========================================================================
|
|
|
50 |
void WowGM::CGlueMgr::Shutdown () {
|
|
|
51 |
DETOUR_INIT;
|
|
|
52 |
|
|
|
53 |
DETOUR_DETACH(ResumePtr,::CGlueMgr::Resume);
|
|
|
54 |
DETOUR_DETACH(SuspendPtr,::CGlueMgr::Suspend);
|
|
|
55 |
DETOUR_DETACH(ShutdownPtr,::CGlueMgr::Shutdown);
|
|
|
56 |
|
|
|
57 |
DETOUR_COMMIT;
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
//===========================================================================
|
|
|
61 |
void WowGM::CGlueMgr::RegisterConsoleCommands() {
|
|
|
62 |
::CGlueMgr::RegisterConsoleCommands();
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
//===========================================================================
|
|
|
66 |
void WowGM::CGlueMgr::UnregisterConsoleCommands () {
|
|
|
67 |
::CGlueMgr::UnregisterConsoleCommands();
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
/****************************************************************************
|
|
|
72 |
*
|
|
|
73 |
* Commands
|
|
|
74 |
*
|
|
|
75 |
***/
|
|
|
76 |
|
|
|
77 |
//===========================================================================
|
|
|
78 |
int __cdecl CCommand_Script2 (const char* cmd,
|
|
|
79 |
const char* arguments) {
|
|
|
80 |
FrameScript_Execute(arguments, arguments, NULL);
|
|
|
81 |
return 0;
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
int __cdecl CCommand_MoveCharacter (const char* command, const char* arguments) {
|
|
|
85 |
if ((*(int*)0x00B6A9E0)) { // CGlueMgr::m_currentScreen == 2
|
|
|
86 |
int characterIndex = (*(int*)0x00AC436C); //CCharacterSelection::s_selectionIndex
|
|
|
87 |
int numCharacters = (*(int*)0x00B6B23C);
|
|
|
88 |
int sumtingwong = (*(int*)0xB6B240);
|
|
|
89 |
|
|
|
90 |
unsigned long long guid = *(unsigned long long*)(sumtingwong + 408 * characterIndex);
|
|
|
91 |
|
|
|
92 |
CDataStore netMsg;
|
|
|
93 |
netMsg.Put(CMSG_MOVE_CHARACTER_CHEAT);
|
|
|
94 |
netMsg.Put(NULL);
|
|
|
95 |
netMsg.Put(1);
|
|
|
96 |
netMsg.Put(guid);
|
|
|
97 |
netMsg.Put(16310.325195f);
|
|
|
98 |
netMsg.Put(16268.939453f);
|
|
|
99 |
netMsg.Put(69.444290f);
|
|
|
100 |
netMsg.Put(0.00f);
|
|
|
101 |
netMsg.Finalize();
|
|
|
102 |
ClientServices_SendOnConnection(&netMsg);
|
|
|
103 |
FrameScript_Execute("GetCharacterListUpdate()", "GetCharacterListUpdate()", NULL);
|
|
|
104 |
//ClientConnection::GetCharacterList();
|
|
|
105 |
}
|
|
|
106 |
else {
|
|
|
107 |
ConsoleWrite("You can only use this command on the character selection screen", ERROR_COLOR);
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
return 0;
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
//===========================================================================
|
|
|
114 |
int __cdecl Script_DebugTest (lua_State* L) {
|
|
|
115 |
ConsoleWrite("Hello from Script_DebugTest!",ADMIN_COLOR);
|
|
|
116 |
return TRUE;
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
/****************************************************************************
|
|
|
121 |
*
|
|
|
122 |
* CGlueMgr class implementation
|
|
|
123 |
*
|
|
|
124 |
***/
|
|
|
125 |
|
|
|
126 |
//===========================================================================
|
|
|
127 |
void __cdecl CGlueMgr::Resume (int initialized) {
|
|
|
128 |
ResumePtr(initialized);
|
|
|
129 |
RegisterConsoleCommands();
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
//===========================================================================
|
|
|
133 |
void __cdecl CGlueMgr::Suspend () {
|
|
|
134 |
SuspendPtr();
|
|
|
135 |
UnregisterConsoleCommands();
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
//===========================================================================
|
|
|
139 |
void __cdecl CGlueMgr::Shutdown () {
|
|
|
140 |
ShutdownPtr();
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
//===========================================================================
|
|
|
144 |
void __cdecl CGlueMgr::RegisterConsoleCommands()
|
|
|
145 |
{
|
|
|
146 |
ConsoleCommandRegister("script", CCommand_Script2, DEFAULT, 0);
|
|
|
147 |
ConsoleCommandRegister("movecharacter", CCommand_MoveCharacter, GAME, NOHELP);
|
|
|
148 |
ConsoleCommandRegister("worldport", CCommand_MoveCharacter, GAME, NOHELP);
|
|
|
149 |
|
|
|
150 |
// TODO: Move the below line under FrameScript.cpp (see FrameScript_Initialize)
|
|
|
151 |
//ConsoleCommandRegister("signalevent", CCommand_SignalEvent, DEFAULT, 0);
|
|
|
152 |
FrameScript_RegisterFunction("debugtest",Script_DebugTest);
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
//===========================================================================
|
|
|
156 |
void __cdecl CGlueMgr::UnregisterConsoleCommands() {
|
|
|
157 |
ConsoleCommandUnregister("script");
|
|
|
158 |
ConsoleCommandUnregister("movecharacter");
|
|
|
159 |
ConsoleCommandUnregister("worldport");
|
|
|
160 |
|
|
|
161 |
//ConsoleCommandUnregister("signalevent");
|
|
|
162 |
FrameScript_UnregisterFunction("debugtest");
|
|
|
163 |
}
|