Subversion Repositories WoWGM

Rev

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

Rev Author Line No. Line
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>
7 tristanc 9
#include <DB/WowClientDB.h>
3 tristanc 10
 
7 tristanc 11
 
12
CVar* g_password = NULL;
13
 
14
 
3 tristanc 15
/****************************************************************************
16
*
31 tristanc 17
*   Client memory addresses
3 tristanc 18
*
19
***/
20
 
31 tristanc 21
#define  CGLUEMGR_NETDISCONNECTHANDLER  0x004DA9D0
22
#define  CGLUEMGR__RESUME               0x004DA5F0
23
#define  CGLUEMGR__SUSPEND              0x004D8930
24
#define  CGLUEMGR__SHUTDOWN             0x004DBBC0
3 tristanc 25
 
26
 
27
/****************************************************************************
28
*
31 tristanc 29
*   Client function pointers
3 tristanc 30
*
31
***/
32
 
31 tristanc 33
void (*NetDisconnectHandlerPtr)(void const*,void*) = *(void(*)(void const*,void*))CGLUEMGR_NETDISCONNECTHANDLER;
3 tristanc 34
 
31 tristanc 35
void (*ResumePtr)(int) = *(void (*)(int))CGLUEMGR__RESUME;
3 tristanc 36
 
31 tristanc 37
void (*SuspendPtr)() = *(void (*)())CGLUEMGR__SUSPEND;
38
 
39
void (*ShutdownPtr)() = *(void (*)())CGLUEMGR__SHUTDOWN;
40
 
41
 
3 tristanc 42
/****************************************************************************
43
*
31 tristanc 44
*   Detours setup
3 tristanc 45
*
46
***/
47
 
48
//===========================================================================
49
void WowGM::CGlueMgr::Shutdown () {
50
	DETOUR_INIT;
51
 
7 tristanc 52
	DETOUR_DETACH(NetDisconnectHandlerPtr,::CGlueMgr::NetDisconnectHandler);
3 tristanc 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
//===========================================================================
32 tristanc 61
void WowGM::CGlueMgr::RegisterConsoleCommands () {
3 tristanc 62
	::CGlueMgr::RegisterConsoleCommands();
63
}
64
 
65
//===========================================================================
66
void WowGM::CGlueMgr::UnregisterConsoleCommands () {
67
	::CGlueMgr::UnregisterConsoleCommands();
68
}
69
 
70
 
71
/****************************************************************************
72
*
31 tristanc 73
*   Console commands and scripts
3 tristanc 74
*
75
***/
76
 
77
//===========================================================================
32 tristanc 78
int CCommand_Script2 (char const* cmd, char const* arguments) {
3 tristanc 79
	FrameScript_Execute(arguments, arguments, NULL);
80
	return 0;
81
}
82
 
31 tristanc 83
//===========================================================================
32 tristanc 84
int CCommand_MoveCharacter (char const* command, char const* arguments) {
3 tristanc 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
 
32 tristanc 90
		unsigned long long guid = *(unsigned long long*)(sumtingwong + 408 * characterIndex);
3 tristanc 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();
32 tristanc 102
 
103
		ClientServices_SendOnConnection(&netMsg);
104
 
105
		FrameScript_Execute("GetCharacterListUpdate()", "GetCharacterListUpdate()", NULL);
3 tristanc 106
    //ClientConnection::GetCharacterList();
107
  }
32 tristanc 108
  else
3 tristanc 109
    ConsoleWrite("You can only use this command on the character selection screen", ERROR_COLOR);
110
 
111
  return 0;
112
}
113
 
114
//===========================================================================
31 tristanc 115
int Script_DebugTest (lua_State* L) {
7 tristanc 116
	ConsoleWrite("Hello from Script_DebugTest!",DEFAULT_COLOR);
3 tristanc 117
	return TRUE;
118
}
119
 
120
 
121
/****************************************************************************
122
*
31 tristanc 123
*   CGlueMgr class implementation
3 tristanc 124
*
125
***/
126
 
127
//===========================================================================
32 tristanc 128
void CGlueMgr::Initialize () {
129
  DETOUR_INIT;
130
  DETOUR_ATTACH(NetDisconnectHandlerPtr,CGlueMgr::NetDisconnectHandler);
131
  DETOUR_ATTACH(ResumePtr,CGlueMgr::Resume);
132
  DETOUR_ATTACH(SuspendPtr,CGlueMgr::Suspend);
133
  DETOUR_ATTACH(ShutdownPtr,CGlueMgr::Shutdown);
134
  DETOUR_COMMIT;
135
}
136
 
137
//===========================================================================
138
int CGlueMgr::NetDisconnectHandler (void const* a1, void* a2) {
7 tristanc 139
	NetDisconnectHandlerPtr(a1, a2);
140
	WowGM::CGlueMgr::SetLoginPassword();
141
	return 1;
142
}
143
 
144
//===========================================================================
31 tristanc 145
void CGlueMgr::Resume (int initialized) {
3 tristanc 146
	ResumePtr(initialized);
147
	RegisterConsoleCommands();
148
}
149
 
150
//===========================================================================
32 tristanc 151
void WowGM::CGlueMgr::SetLoginPassword () {
7 tristanc 152
	char command[256] = {};
153
 
154
	// TODO: Call SStrPrintF here
155
	sprintf_s(command,
32 tristanc 156
						sizeof(command),
157
						"AccountLoginPasswordEdit:SetText(\"%s\")",
158
						g_password->m_stringValue.m_string);
159
 
7 tristanc 160
	FrameScript_Execute(command,command,NULL);
161
}
162
 
163
//===========================================================================
31 tristanc 164
void CGlueMgr::Suspend () {
3 tristanc 165
	SuspendPtr();
166
	UnregisterConsoleCommands();
167
}
168
 
169
//===========================================================================
31 tristanc 170
void CGlueMgr::Shutdown () {
3 tristanc 171
	ShutdownPtr();
172
}
173
 
174
//===========================================================================
31 tristanc 175
void CGlueMgr::RegisterConsoleCommands ()  {
3 tristanc 176
	ConsoleCommandRegister("script", CCommand_Script2, DEFAULT, 0);
177
  ConsoleCommandRegister("movecharacter", CCommand_MoveCharacter, GAME, NOHELP);
178
  ConsoleCommandRegister("worldport", CCommand_MoveCharacter, GAME, NOHELP);
179
 
180
	// TODO: Move the below line under FrameScript.cpp (see FrameScript_Initialize)
181
	//ConsoleCommandRegister("signalevent", CCommand_SignalEvent, DEFAULT, 0);
182
	FrameScript_RegisterFunction("debugtest",Script_DebugTest);
183
}
184
 
185
//===========================================================================
31 tristanc 186
void CGlueMgr::UnregisterConsoleCommands () {
3 tristanc 187
	ConsoleCommandUnregister("script");
188
  ConsoleCommandUnregister("movecharacter");
189
  ConsoleCommandUnregister("worldport");
190
 
191
	//ConsoleCommandUnregister("signalevent");
192
	FrameScript_UnregisterFunction("debugtest");
193
}
32 tristanc 194