You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.2 KiB
53 lines
1.2 KiB
#include <otclient/net/protocolgame.h>
|
|
#include <otclient/core/game.h>
|
|
|
|
ProtocolGame::ProtocolGame()
|
|
{
|
|
m_waitingLoginPacket = false;
|
|
}
|
|
|
|
void ProtocolGame::login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName)
|
|
{
|
|
if(accountName.empty() || accountPassword.empty()) {
|
|
callLuaField("onError", "You must enter an account name and password.");
|
|
return;
|
|
}
|
|
|
|
m_waitingLoginPacket = true;
|
|
m_accountName = accountName;
|
|
m_accountPassword = accountPassword;
|
|
m_characterName = characterName;
|
|
|
|
connect(host, port);
|
|
}
|
|
|
|
void ProtocolGame::onConnect()
|
|
{
|
|
recv();
|
|
}
|
|
|
|
void ProtocolGame::onRecv(InputMessage& inputMessage)
|
|
{
|
|
if(m_waitingLoginPacket) {
|
|
inputMessage.skipBytes(3);
|
|
uint32 timestamp = inputMessage.getU32();
|
|
uint8 unknown = inputMessage.getU8();
|
|
|
|
m_waitingLoginPacket = false;
|
|
enableChecksum();
|
|
sendLoginPacket(timestamp, unknown);
|
|
recv();
|
|
}
|
|
else {
|
|
parseMessage(inputMessage);
|
|
recv();
|
|
}
|
|
}
|
|
|
|
void ProtocolGame::onError(const boost::system::error_code& error)
|
|
{
|
|
// already disconnected, just fire onLogout
|
|
g_game.onLogout();
|
|
}
|
|
|