Code:
00769100 ConsoleCommandRegister
BOOL ConsoleCommandRegister(char const* command, int (*)(char const*, char const*) callback, CATEGORY category, char const* help);
007689E0 ConsoleCommandUnregister
ConsoleCommandUnregister(char const* command)
enum CommandCategory
{
CATEGORY_Debug = 0x0,
CATEGORY_Graphics = 0x1,
CATEGORY_Console = 0x2,
CATEGORY_Combat = 0x3,
CATEGORY_Game = 0x4,
CATEGORY_Default = 0x5,
CATEGORY_Net = 0x6,
CATEGORY_Sound = 0x7,
CATEGORY_Gm = 0x8,
};
struct CDataStore
{
void *vTable;
unsigned __int8 *m_buffer;
unsigned int m_base;
unsigned int m_alloc;
unsigned int m_size;
unsigned int m_read;
};
void __cdecl GameClientCommands::Install()
{
ConsoleCommandRegister("port", CCommand_Teleport, CATEGORY_Debug, 0);
ConsoleCommandRegister("charmport", CCommand_CharmTeleport, CATEGORY_Debug, 0);
ConsoleCommandRegister("worldport", CCommand_WorldTeleport, CATEGORY_Debug, 0);
ConsoleCommandRegister("setrawpos", CCommand_SetRawPos, CATEGORY_Debug, 0);
ConsoleCommandRegister("showplayer", CCommand_TogglePlayer, CATEGORY_Graphics, 0);
ConsoleCommandRegister("togglehelm", CCommand_ToggleHelm, CATEGORY_Game, 0);
ConsoleCommandRegister("togglecloak", CCommand_ToggleCloak, CATEGORY_Game, 0);
}
void __cdecl GameClientCommands::Uninstall()
{
ConsoleCommandUnregister("port");
ConsoleCommandUnregister("charmport");
ConsoleCommandUnregister("worldport");
ConsoleCommandUnregister("setrawpos");
ConsoleCommandUnregister("showplayer");
ConsoleCommandUnregister("togglehelm");
ConsoleCommandUnregister("togglecloak");
}
int __cdecl CCommand_WorldTeleport(char *cmd, char *args)
{
double v2; // st7@0
WGUID guid; // qax@1
void *pPlayer; // ebx@1
WorldSafeLocsRec *v5; // edi@1
int result; // eax@2
DWORD map; // esi@6
C3Vector *v8; // eax@6
float v9; // ecx@6
float v10; // edx@6
float v11; // eax@6
int v12; // eax@15
int v13; // esi@15
int v14; // ebx@16
char *area; // ecx@24
int ticks; // ebx@29
QWORD v17; // ST10_8@29
int v18; // [sp+4h] [bp-88h]@1
char v19[64]; // [sp+10h] [bp-7Ch]@4
CDataStore data; // [sp+50h] [bp-3Ch]@29
C3Vector v21; // [sp+68h] [bp-24h]@6
float x; // [sp+74h] [bp-18h]@6
float y; // [sp+78h] [bp-14h]@6
float z; // [sp+7Ch] [bp-10h]@6
char v25[4]; // [sp+80h] [bp-Ch]@1
float v26; // [sp+88h] [bp-4h]@1
strcpy(v25, "\t\r\n\" ");
guid = ClntObjMgrGetActivePlayerGuid();
pPlayer = ClntObjMgrObjectPtr(guid, TYPEMASK_PLAYER, ".../Player_C.h", 160);
v5 = 0;
LODWORD(v26) = pPlayer;
if ( !pPlayer )
return 1;
if ( IsNumeric(*args) )
{
SStrTokenize(&args, v19, 64, v25, 0);
if ( !v19[0] )
{
ConsoleWrite("Usage: worldport <continentID> [x y z] [facing]", 4);
return 0;
}
map = SStrToUnsigned(v19);
v8 = (*(*pPlayer + 44))(pPlayer, &v21, v18); // pPlayer->GetPosition(&pos);
v9 = v8->X;
v10 = v8->Y;
v11 = v8->Z;
x = v9;
y = v10;
z = v11;
SStrTokenize(&args, v19, 64, v25, 0);
if ( v19[0] )
{
v2 = SStrToFloat(v19);
x = v2;
}
SStrTokenize(&args, v19, 64, v25, 0);
if ( v19[0] )
{
v2 = SStrToFloat(v19);
y = v2;
}
SStrTokenize(&args, v19, 64, v25, 0);
if ( v19[0] )
{
v2 = SStrToFloat(v19);
z = v2;
}
SStrTokenize(&args, v19, 64, v25, 0);
if ( v19[0] )
v2 = SStrToFloat(v19) * 0.017453292;
else
(*(*pPlayer + 52))(pPlayer); // o = pPlayer->GetOrientation();
}
else
{
v12 = g_WorldSafeLocsDB.numRows;
v13 = 0;
if ( g_WorldSafeLocsDB.numRows <= 0 )
{
LABEL_23:
ConsolePrintf("Could not find location: %s", args);
return 1;
}
v14 = 0;
while ( 1 )
{
if ( v13 >= v5 && v13 < v12 )
v5 = &g_WorldSafeLocsDB.FirstRow[v14];
if ( sub_76F770(v5->m_AreaName_lang, args) )// compare string
break;
v12 = g_WorldSafeLocsDB.numRows;
++v13;
v14 += 6;
if ( v13 >= g_WorldSafeLocsDB.numRows )
goto LABEL_23;
v5 = 0;
}
area = v5->m_AreaName_lang;
map = v5->m_continent;
x = v5->m_locX;
y = v5->m_locY;
v2 = v5->m_locZ;
z = v5->m_locZ;
ConsolePrintf("Porting to %s", area);
(*(*LODWORD(v26) + 52))(v18); // o = pPlayer->GetOrientation();
v5 = 0;
}
v26 = v2;
if ( map >= g_MapDB.minIndex && map <= g_MapDB.maxIndex && g_MapDB.Rows[map - g_MapDB.minIndex] != v5 )
{
ticks = PerformanceCounter();
CDataStore::GenPacket(&data);
CDataStore::PutInt32(&data, CMSG_WORLD_TELEPORT);
CDataStore::PutInt32(&data, ticks);
CDataStore::PutInt32(&data, map);
HIDWORD(v17) = v5; // v5 is 0 ?
LODWORD(v17) = v5; // v5 is 0 ?
CDataStore::PutInt64(&data, v17); // may be player guid?
CDataStore::PutFloat(&data, x);
CDataStore::PutFloat(&data, y);
CDataStore::PutFloat(&data, z);
CDataStore::PutFloat(&data, v26); // o
data.m_read = v5; // v5 is 0 ?
ClientServices::SendPacket(&data);
CDataStore::Release(&data);
result = 1;
}
else
{
ConsoleWriteA("Bad world number: %i\n", 3, map);
result = 0;
}
return result;
}
signed int __cdecl CCommand_SetRawPos(char *cmd, char *args)
{
WGUID guid; // qax@1
CGPlayer_C *pPlayer; // esi@1
double v4; // st7@8
double v5; // st7@10
char v7[64]; // [sp+8h] [bp-7Ch]@5
CDataStore data; // [sp+48h] [bp-3Ch]@16
C3Vector v9; // [sp+60h] [bp-24h]@10
C3Vector pos; // [sp+6Ch] [bp-18h]@1
char v11[4]; // [sp+78h] [bp-Ch]@1
float o; // [sp+80h] [bp-4h]@16
pos.X = 0.0;
pos.Y = 0.0;
pos.Z = 0.0;
strcpy(v11, "\t\r\n\" ,");
guid = ClntObjMgrGetActivePlayerGuid();
pPlayer = ClntObjMgrObjectPtr(guid, TYPEMASK_PLAYER, ".../Player_C.h", 160);
if ( !pPlayer )
return 1;
if ( !*args || !IsNumeric(*args) && *args != '-' )
{
ConsoleWrite("Usage: setrawpos [x y z] [facing]", 4);
return 0;
}
SStrTokenize(&args, v7, 64, v11, 0);
if ( !v7[0] || (pos.X = SStrToFloat(v7), SStrTokenize(&args, v7, 64, v11, 0), !v7[0]) )
return 0;
pos.Y = SStrToFloat(v7);
SStrTokenize(&args, v7, 64, v11, 0);
if ( v7[0] )
v4 = SStrToFloat(v7);
else
v4 = 0.0;
pos.Z = v4;
CMovement::GetPosition(pPlayer->UnitBase.movementInfo, &v9, &pos);
v5 = 0.0;
if ( !World::IsValidPosition(&v9, 0.0) )
{
ConsoleWrite("Coordinates out of range\n", 0);
return 1;
}
SStrTokenize(&args, v7, 64, v11, 0);
if ( v7[0] )
v5 = SStrToFloat(v7) * 0.017453292;
else
(*(pPlayer->UnitBase.ObjectBase.vtable + 14))(pPlayer);
o = v5;
CDataStore::GenPacket(&data);
CDataStore::PutInt32(&data, CMSG_MOVE_SET_RAW_POSITION);
CDataStore::PutVector3(&data, &pos);
CDataStore::PutFloat(&data, o);
data.m_read = 0;
ClientServices::SendPacket(&data);
CDataStore::Release(&data);
return 1;
}
int __cdecl CCommand_ToggleHelm(char *cmd, char *args)
{
WGUID guid; // qax@1
CGPlayer_C *pPlayer; // esi@1
CDataStore data; // [sp+8h] [bp-18h]@2
guid = ClntObjMgrGetActivePlayerGuid();
pPlayer = ClntObjMgrObjectPtr(guid, TYPEMASK_PLAYER, ".../Player_C.h", 160);
if ( pPlayer )
{
CDataStore::GenPacket(&data);
CDataStore::PutInt32(&data, CMSG_SHOWING_HELM);
CDataStore::PutInt8(&data, (pPlayer->PlayerData->PLAYER_FLAGS >> 10) & 1);
data.m_read = 0;
ClientServices::SendPacket(&data);
CDataStore::Release(&data);
}
return 1;
}
int __cdecl CCommand_ToggleCloak(char *cmd, char *args)
{
WGUID guid; // qax@1
CGPlayer_C *pPlayer; // esi@1
CDataStore data; // [sp+8h] [bp-18h]@2
guid = ClntObjMgrGetActivePlayerGuid();
pPlayer = ClntObjMgrObjectPtr(guid, TYPEMASK_PLAYER, ".../Player_C.h", 160);
if ( pPlayer )
{
CDataStore::GenPacket(&data);
CDataStore::PutInt32(&data, CMSG_SHOWING_CLOAK);
CDataStore::PutInt8(&data, (pPlayer->PlayerData->PLAYER_FLAGS >> 11) & 1);
data.m_read = 0;
ClientServices::SendPacket(&data);
CDataStore::Release(&data);
}
return 1;
}