Full protocol 10.74 support (session key), entergame style fixes

This commit is contained in:
TheSumm
2015-01-27 23:44:37 +01:00
parent 64e9406488
commit 71931b961a
12 changed files with 160 additions and 60 deletions

View File

@@ -401,6 +401,7 @@ namespace Otc
GameExperienceBonus = 66,
GameAuthenticator = 67,
GameUnjustifiedPoints = 68,
GameSessionKey = 69,
LastGameFeature = 101
};

View File

@@ -534,7 +534,7 @@ void Game::processWalkCancel(Otc::Direction direction)
m_localPlayer->cancelWalk(direction);
}
void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName, const std::string& authenticatorToken)
void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName, const std::string& authenticatorToken, const std::string& sessionKey)
{
if(m_protocolGame || isOnline())
stdext::throw_exception("Unable to login into a world while already online or logging.");
@@ -549,7 +549,7 @@ void Game::loginWorld(const std::string& account, const std::string& password, c
m_localPlayer->setName(characterName);
m_protocolGame = ProtocolGamePtr(new ProtocolGame);
m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName, authenticatorToken);
m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName, authenticatorToken, sessionKey);
m_characterName = characterName;
m_worldName = worldName;
}
@@ -1456,7 +1456,7 @@ void Game::setProtocolVersion(int version)
if(isOnline())
stdext::throw_exception("Unable to change protocol version while online");
if(version != 0 && (version < 740 || version > 1073))
if(version != 0 && (version < 740 || version > 1074))
stdext::throw_exception(stdext::format("Protocol version %d not supported", version));
m_protocolVersion = version;
@@ -1474,7 +1474,7 @@ void Game::setClientVersion(int version)
if(isOnline())
stdext::throw_exception("Unable to change client version while online");
if(version != 0 && (version < 740 || version > 1073))
if(version != 0 && (version < 740 || version > 1074))
stdext::throw_exception(stdext::format("Client version %d not supported", version));
m_features.reset();
@@ -1614,6 +1614,10 @@ void Game::setClientVersion(int version)
enableFeature(Otc::GameAuthenticator);
}
if(version >= 1074) {
enableFeature(Otc::GameSessionKey);
}
m_clientVersion = version;
g_lua.callGlobalField("g_game", "onClientVersionChange", version);

View File

@@ -159,7 +159,7 @@ protected:
public:
// login related
void loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName, const std::string& authenticatorToken);
void loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName, const std::string& authenticatorToken, const std::string& sessionKey);
void cancelLogin();
void forceLogout();
void safeLogout();

View File

@@ -26,11 +26,12 @@
#include "item.h"
#include "localplayer.h"
void ProtocolGame::login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName, const std::string& authenticatorToken)
void ProtocolGame::login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName, const std::string& authenticatorToken, const std::string& sessionKey)
{
m_accountName = accountName;
m_accountPassword = accountPassword;
m_authenticatorToken = authenticatorToken;
m_sessionKey = sessionKey;
m_characterName = characterName;
connect(host, port);

View File

@@ -31,7 +31,7 @@
class ProtocolGame : public Protocol
{
public:
void login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName, const std::string& authenticatorToken);
void login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName, const std::string& authenticatorToken, const std::string& sessionKey);
void send(const OutputMessagePtr& outputMessage);
void sendExtendedOpcode(uint8 opcode, const std::string& buffer);
@@ -248,6 +248,7 @@ private:
std::string m_accountName;
std::string m_accountPassword;
std::string m_authenticatorToken;
std::string m_sessionKey;
std::string m_characterName;
LocalPlayerPtr m_localPlayer;
};

View File

@@ -79,16 +79,21 @@ void ProtocolGame::sendLoginPacket(uint challengeTimestamp, uint8 challengeRando
msg->addU8(0); // is gm set?
}
if(g_game.getFeature(Otc::GameAccountNames))
msg->addString(m_accountName);
else
msg->addU32(stdext::from_string<uint32>(m_accountName));
if(g_game.getFeature(Otc::GameSessionKey)) {
msg->addString(m_sessionKey);
msg->addString(m_characterName);
} else {
if(g_game.getFeature(Otc::GameAccountNames))
msg->addString(m_accountName);
else
msg->addU32(stdext::from_string<uint32>(m_accountName));
msg->addString(m_characterName);
msg->addString(m_accountPassword);
msg->addString(m_characterName);
msg->addString(m_accountPassword);
if(g_game.getFeature(Otc::GameAuthenticator))
msg->addString(m_authenticatorToken);
if(g_game.getFeature(Otc::GameAuthenticator))
msg->addString(m_authenticatorToken);
}
if(g_game.getFeature(Otc::GameChallengeOnLogin)) {
msg->addU32(challengeTimestamp);