tibia-client/src/otclient/net/protocolgamesend.cpp

112 lines
2.0 KiB
C++
Raw Normal View History

2011-08-15 16:11:24 +02:00
#include "protocolgame.h"
2011-08-16 02:30:31 +02:00
#include <framework/net/rsa.h>
void ProtocolGame::sendLoginPacket(uint32 timestamp, uint8 unknown)
{
OutputMessage oMsg;
2011-08-16 05:27:46 +02:00
oMsg.addU8(0x0A); // protocol id
oMsg.addU16(0x02); // os
oMsg.addU16(862); // client version
2011-08-16 02:30:31 +02:00
2011-08-16 05:27:46 +02:00
oMsg.addU8(0); // first RSA byte must be 0
2011-08-16 02:30:31 +02:00
2011-08-16 05:27:46 +02:00
// xtea key
generateXteaKey();
oMsg.addU32(m_xteaKey[0]);
oMsg.addU32(m_xteaKey[1]);
oMsg.addU32(m_xteaKey[2]);
oMsg.addU32(m_xteaKey[3]);
2011-08-16 02:30:31 +02:00
oMsg.addU8(0); // is gm set?
2011-08-16 05:27:46 +02:00
oMsg.addString(m_accountName);
oMsg.addString(m_characterName);
oMsg.addString(m_accountPassword);
2011-08-16 02:30:31 +02:00
2011-08-16 05:27:46 +02:00
oMsg.addU32(timestamp);
oMsg.addU8(unknown);
2011-08-16 02:30:31 +02:00
2011-08-16 06:24:20 +02:00
// complete the 128 bytes for rsa encryption with zeros
2011-08-16 02:30:31 +02:00
oMsg.addPaddingBytes(128 - (29 + m_accountName.length() + m_characterName.length() + m_accountPassword.length()));
2011-08-16 05:27:46 +02:00
// encrypt with RSA
2011-08-16 02:30:31 +02:00
if(!Rsa::encrypt((char*)oMsg.getBuffer() + 6 + oMsg.getMessageSize() - 128, 128, OTSERV_PUBLIC_RSA))
return;
send(oMsg);
2011-08-16 05:27:46 +02:00
enableXteaEncryption();
2011-08-16 02:30:31 +02:00
}
2011-08-15 16:11:24 +02:00
void ProtocolGame::sendLogout()
{
OutputMessage oMsg;
oMsg.addU8(0x14);
send(oMsg);
}
void ProtocolGame::sendPing()
{
OutputMessage oMsg;
oMsg.addU8(0x1E);
send(oMsg);
}
void ProtocolGame::sendWalkNorth()
{
OutputMessage oMsg;
oMsg.addU8(0x65);
send(oMsg);
}
void ProtocolGame::sendWalkEast()
{
OutputMessage oMsg;
oMsg.addU8(0x66);
send(oMsg);
}
void ProtocolGame::sendWalkSouth()
{
OutputMessage oMsg;
oMsg.addU8(0x67);
send(oMsg);
}
void ProtocolGame::sendWalkWest()
{
OutputMessage oMsg;
oMsg.addU8(0x68);
send(oMsg);
}
void ProtocolGame::sendTurnNorth()
{
OutputMessage oMsg;
oMsg.addU8(0x6F);
send(oMsg);
}
void ProtocolGame::sendTurnEast()
{
OutputMessage oMsg;
oMsg.addU8(0x70);
send(oMsg);
}
void ProtocolGame::sendTurnSouth()
{
OutputMessage oMsg;
oMsg.addU8(0x71);
send(oMsg);
}
void ProtocolGame::sendTurnWest()
{
OutputMessage oMsg;
oMsg.addU8(0x72);
send(oMsg);
}