mirror of
https://github.com/edubart/otclient.git
synced 2025-10-16 12:34:55 +02:00
Protocol 10.72 (Authenticator) Support, Unjustified Points diplay
- Unjustified Points (Better topbar icon would be nice)  - Authenticator token support - adjusted 'can change pvp frame' to 1054 - ...
This commit is contained in:
@@ -399,6 +399,8 @@ namespace Otc
|
||||
GameClientVersion = 64,
|
||||
GameContentRevision = 65,
|
||||
GameExperienceBonus = 66,
|
||||
GameAuthenticator = 67,
|
||||
GameUnjustifiedPoints = 68,
|
||||
|
||||
LastGameFeature = 101
|
||||
};
|
||||
|
@@ -84,6 +84,7 @@ void Game::resetGameStates()
|
||||
m_localPlayer = nullptr;
|
||||
m_pingSent = 0;
|
||||
m_pingReceived = 0;
|
||||
m_unjustifiedPoints = UnjustifiedPoints();
|
||||
|
||||
for(auto& it : m_containers) {
|
||||
const ContainerPtr& container = it.second;
|
||||
@@ -155,6 +156,11 @@ void Game::processLoginWait(const std::string& message, int time)
|
||||
g_lua.callGlobalField("g_game", "onLoginWait", message, time);
|
||||
}
|
||||
|
||||
void Game::processLoginToken(bool unknown)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onLoginToken", unknown);
|
||||
}
|
||||
|
||||
void Game::processLogin()
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onLogin");
|
||||
@@ -528,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)
|
||||
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)
|
||||
{
|
||||
if(m_protocolGame || isOnline())
|
||||
stdext::throw_exception("Unable to login into a world while already online or logging.");
|
||||
@@ -543,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);
|
||||
m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName, authenticatorToken);
|
||||
m_characterName = characterName;
|
||||
m_worldName = worldName;
|
||||
}
|
||||
@@ -1204,6 +1210,31 @@ void Game::setPVPMode(Otc::PVPModes pvpMode)
|
||||
g_lua.callGlobalField("g_game", "onPVPModeChange", pvpMode);
|
||||
}
|
||||
|
||||
void Game::setUnjustifiedPoints(UnjustifiedPoints unjustifiedPoints)
|
||||
{
|
||||
if(!canPerformGameAction())
|
||||
return;
|
||||
if(!getFeature(Otc::GameUnjustifiedPoints))
|
||||
return;
|
||||
if(m_unjustifiedPoints == unjustifiedPoints)
|
||||
return;
|
||||
|
||||
m_unjustifiedPoints = unjustifiedPoints;
|
||||
g_lua.callGlobalField("g_game", "onUnjustifiedPointsChange", unjustifiedPoints);
|
||||
}
|
||||
|
||||
void Game::setOpenPvpSituations(int openPvpSituations)
|
||||
{
|
||||
if(!canPerformGameAction())
|
||||
return;
|
||||
if(m_openPvpSituations == openPvpSituations)
|
||||
return;
|
||||
|
||||
m_openPvpSituations = openPvpSituations;
|
||||
g_lua.callGlobalField("g_game", "onOpenPvpSituationsChange", openPvpSituations);
|
||||
}
|
||||
|
||||
|
||||
void Game::inspectNpcTrade(const ItemPtr& item)
|
||||
{
|
||||
if(!canPerformGameAction() || !item)
|
||||
@@ -1425,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 > 1071))
|
||||
if(version != 0 && (version < 740 || version > 1072))
|
||||
stdext::throw_exception(stdext::format("Protocol version %d not supported", version));
|
||||
|
||||
m_protocolVersion = version;
|
||||
@@ -1443,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 > 1071))
|
||||
if(version != 0 && (version < 740 || version > 1072))
|
||||
stdext::throw_exception(stdext::format("Client version %d not supported", version));
|
||||
|
||||
m_features.reset();
|
||||
@@ -1563,6 +1594,10 @@ void Game::setClientVersion(int version)
|
||||
enableFeature(Otc::GameEnhancedAnimations);
|
||||
}
|
||||
|
||||
if(version >= 1053) {
|
||||
enableFeature(Otc::GameUnjustifiedPoints);
|
||||
}
|
||||
|
||||
if(version >= 1054) {
|
||||
enableFeature(Otc::GameExperienceBonus);
|
||||
}
|
||||
@@ -1575,6 +1610,10 @@ void Game::setClientVersion(int version)
|
||||
enableFeature(Otc::GameContentRevision);
|
||||
}
|
||||
|
||||
if(version >= 1072) {
|
||||
enableFeature(Otc::GameAuthenticator);
|
||||
}
|
||||
|
||||
m_clientVersion = version;
|
||||
|
||||
g_lua.callGlobalField("g_game", "onClientVersionChange", version);
|
||||
|
@@ -36,6 +36,25 @@
|
||||
|
||||
#include <bitset>
|
||||
|
||||
struct UnjustifiedPoints {
|
||||
bool operator==(const UnjustifiedPoints& other) {
|
||||
return killsDay == other.killsDay &&
|
||||
killsDayRemaining == other.killsDayRemaining &&
|
||||
killsWeek == other.killsWeek &&
|
||||
killsWeekRemaining == other.killsWeekRemaining &&
|
||||
killsMonth == other.killsMonth &&
|
||||
killsMonthRemaining == other.killsMonthRemaining &&
|
||||
skullTime == other.skullTime;
|
||||
}
|
||||
uint8 killsDay;
|
||||
uint8 killsDayRemaining;
|
||||
uint8 killsWeek;
|
||||
uint8 killsWeekRemaining;
|
||||
uint8 killsMonth;
|
||||
uint8 killsMonthRemaining;
|
||||
uint8 skullTime;
|
||||
};
|
||||
|
||||
typedef std::tuple<std::string, uint, std::string, int, bool> Vip;
|
||||
|
||||
//@bindsingleton g_game
|
||||
@@ -60,6 +79,7 @@ protected:
|
||||
void processLoginError(const std::string& error);
|
||||
void processLoginAdvice(const std::string& message);
|
||||
void processLoginWait(const std::string& message, int time);
|
||||
void processLoginToken(bool unknown);
|
||||
void processLogin();
|
||||
void processPendingGame();
|
||||
void processEnterGame();
|
||||
@@ -139,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);
|
||||
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 cancelLogin();
|
||||
void forceLogout();
|
||||
void safeLogout();
|
||||
@@ -218,6 +238,12 @@ public:
|
||||
bool isSafeFight() { return m_safeFight; }
|
||||
Otc::PVPModes getPVPMode() { return m_pvpMode; }
|
||||
|
||||
// pvp related
|
||||
void setUnjustifiedPoints(UnjustifiedPoints unjustifiedPoints);
|
||||
UnjustifiedPoints getUnjustifiedPoints() { return m_unjustifiedPoints; };
|
||||
void setOpenPvpSituations(int openPvpSitations);
|
||||
int getOpenPvpSituations() { return m_openPvpSituations; }
|
||||
|
||||
// npc trade related
|
||||
void inspectNpcTrade(const ItemPtr& item);
|
||||
void buyItem(const ItemPtr& item, int amount, bool ignoreCapacity, bool buyWithBackpack);
|
||||
@@ -304,6 +330,8 @@ public:
|
||||
int getServerBeat() { return m_serverBeat; }
|
||||
void setCanReportBugs(bool enable) { m_canReportBugs = enable; }
|
||||
bool canReportBugs() { return m_canReportBugs; }
|
||||
void setExpertPvpMode(bool enable) { m_expertPvpMode = enable; }
|
||||
bool getExpertPvpMode() { return m_expertPvpMode; }
|
||||
LocalPlayerPtr getLocalPlayer() { return m_localPlayer; }
|
||||
ProtocolGamePtr getProtocolGame() { return m_protocolGame; }
|
||||
std::string getCharacterName() { return m_characterName; }
|
||||
@@ -333,6 +361,7 @@ private:
|
||||
bool m_online;
|
||||
bool m_denyBotCall;
|
||||
bool m_dead;
|
||||
bool m_expertPvpMode;
|
||||
int m_serverBeat;
|
||||
ticks_t m_ping;
|
||||
uint m_pingSent;
|
||||
@@ -345,6 +374,8 @@ private:
|
||||
Otc::ChaseModes m_chaseMode;
|
||||
Otc::PVPModes m_pvpMode;
|
||||
Otc::Direction m_lastWalkDir;
|
||||
UnjustifiedPoints m_unjustifiedPoints;
|
||||
int m_openPvpSituations;
|
||||
bool m_safeFight;
|
||||
bool m_canReportBugs;
|
||||
std::vector<uint8> m_gmActions;
|
||||
|
@@ -238,6 +238,10 @@ void Client::registerLuaFunctions()
|
||||
g_lua.bindSingletonFunction("g_game", "getChaseMode", &Game::getChaseMode, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "getFightMode", &Game::getFightMode, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "getPVPMode", &Game::getPVPMode, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "setUnjustifiedPoints", &Game::setUnjustifiedPoints, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "getUnjustifiedPoints", &Game::getUnjustifiedPoints, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "setOpenPvpSituations", &Game::setOpenPvpSituations, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "getOpenPvpSituations", &Game::getOpenPvpSituations, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "isSafeFight", &Game::isSafeFight, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "inspectNpcTrade", &Game::inspectNpcTrade, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "buyItem", &Game::buyItem, &g_game);
|
||||
|
@@ -165,3 +165,45 @@ bool luavalue_cast(int index, Light& light)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int push_luavalue(const UnjustifiedPoints& unjustifiedPoints)
|
||||
{
|
||||
g_lua.createTable(0, 7);
|
||||
g_lua.pushInteger(unjustifiedPoints.killsDay);
|
||||
g_lua.setField("killsDay");
|
||||
g_lua.pushInteger(unjustifiedPoints.killsDayRemaining);
|
||||
g_lua.setField("killsDayRemaining");
|
||||
g_lua.pushInteger(unjustifiedPoints.killsWeek);
|
||||
g_lua.setField("killsWeek");
|
||||
g_lua.pushInteger(unjustifiedPoints.killsWeekRemaining);
|
||||
g_lua.setField("killsWeekRemaining");
|
||||
g_lua.pushInteger(unjustifiedPoints.killsMonth);
|
||||
g_lua.setField("killsMonth");
|
||||
g_lua.pushInteger(unjustifiedPoints.killsMonthRemaining);
|
||||
g_lua.setField("killsMonthRemaining");
|
||||
g_lua.pushInteger(unjustifiedPoints.skullTime);
|
||||
g_lua.setField("skullTime");
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool luavalue_cast(int index, UnjustifiedPoints& unjustifiedPoints)
|
||||
{
|
||||
if(g_lua.isTable(index)) {
|
||||
g_lua.getField("killsDay", index);
|
||||
unjustifiedPoints.killsDay = g_lua.popInteger();
|
||||
g_lua.getField("killsDayRemaining", index);
|
||||
unjustifiedPoints.killsDayRemaining = g_lua.popInteger();
|
||||
g_lua.getField("killsWeek", index);
|
||||
unjustifiedPoints.killsWeek = g_lua.popInteger();
|
||||
g_lua.getField("killsWeekRemaining", index);
|
||||
unjustifiedPoints.killsWeekRemaining = g_lua.popInteger();
|
||||
g_lua.getField("killsMonth", index);
|
||||
unjustifiedPoints.killsMonth = g_lua.popInteger();
|
||||
g_lua.getField("killsMonthRemaining", index);
|
||||
unjustifiedPoints.killsMonthRemaining = g_lua.popInteger();
|
||||
g_lua.getField("skullTime", index);
|
||||
unjustifiedPoints.skullTime = g_lua.popInteger();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -44,4 +44,8 @@ bool luavalue_cast(int index, MarketData& data);
|
||||
int push_luavalue(const Light& light);
|
||||
bool luavalue_cast(int index, Light& light);
|
||||
|
||||
// unjustified points
|
||||
int push_luavalue(const UnjustifiedPoints& unjustifiedPoints);
|
||||
bool luavalue_cast(int index, UnjustifiedPoints& unjustifiedPoints);
|
||||
|
||||
#endif
|
||||
|
@@ -50,6 +50,7 @@ namespace Proto {
|
||||
GameServerLoginAdvice = 21,
|
||||
GameServerLoginWait = 22,
|
||||
GameServerLoginSuccess = 23,
|
||||
GameServerLoginToken = 24,
|
||||
GameServerPingBack = 29,
|
||||
GameServerPing = 30,
|
||||
GameServerChallenge = 31,
|
||||
|
@@ -26,10 +26,11 @@
|
||||
#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)
|
||||
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)
|
||||
{
|
||||
m_accountName = accountName;
|
||||
m_accountPassword = accountPassword;
|
||||
m_authenticatorToken = authenticatorToken;
|
||||
m_characterName = characterName;
|
||||
|
||||
connect(host, port);
|
||||
|
@@ -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);
|
||||
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 send(const OutputMessagePtr& outputMessage);
|
||||
|
||||
void sendExtendedOpcode(uint8 opcode, const std::string& buffer);
|
||||
@@ -143,6 +143,7 @@ private:
|
||||
void parseLoginError(const InputMessagePtr& msg);
|
||||
void parseLoginAdvice(const InputMessagePtr& msg);
|
||||
void parseLoginWait(const InputMessagePtr& msg);
|
||||
void parseLoginToken(const InputMessagePtr& msg);
|
||||
void parsePing(const InputMessagePtr& msg);
|
||||
void parsePingBack(const InputMessagePtr& msg);
|
||||
void parseChallenge(const InputMessagePtr& msg);
|
||||
@@ -246,6 +247,7 @@ private:
|
||||
stdext::boolean<true> m_firstRecv;
|
||||
std::string m_accountName;
|
||||
std::string m_accountPassword;
|
||||
std::string m_authenticatorToken;
|
||||
std::string m_characterName;
|
||||
LocalPlayerPtr m_localPlayer;
|
||||
};
|
||||
|
@@ -79,6 +79,9 @@ void ProtocolGame::parseMessage(const InputMessagePtr& msg)
|
||||
case Proto::GameServerLoginWait:
|
||||
parseLoginWait(msg);
|
||||
break;
|
||||
case Proto::GameServerLoginToken:
|
||||
parseLoginToken(msg);
|
||||
break;
|
||||
case Proto::GameServerPing:
|
||||
case Proto::GameServerPingBack:
|
||||
if((opcode == Proto::GameServerPing && g_game.getFeature(Otc::GameClientPing)) ||
|
||||
@@ -385,11 +388,13 @@ void ProtocolGame::parseLogin(const InputMessagePtr& msg)
|
||||
}
|
||||
bool canReportBugs = msg->getU8();
|
||||
|
||||
if(g_game.getClientVersion() >= 1053)
|
||||
if(g_game.getClientVersion() >= 1054)
|
||||
msg->getU8(); // can change pvp frame option
|
||||
|
||||
if(g_game.getClientVersion() >= 1058)
|
||||
msg->getU8(); // expert mode enabled
|
||||
if(g_game.getClientVersion() >= 1058) {
|
||||
int expertModeEnabled = msg->getU8();
|
||||
g_game.setExpertPvpMode(expertModeEnabled);
|
||||
}
|
||||
|
||||
m_localPlayer->setId(playerId);
|
||||
g_game.setServerBeat(serverBeat);
|
||||
@@ -428,19 +433,23 @@ void ProtocolGame::parsePreset(const InputMessagePtr& msg)
|
||||
|
||||
void ProtocolGame::parseUnjustifiedStats(const InputMessagePtr& msg)
|
||||
{
|
||||
// Unjustified Kills display since 10.55
|
||||
msg->getU8();
|
||||
msg->getU8();
|
||||
msg->getU8();
|
||||
msg->getU8();
|
||||
msg->getU8();
|
||||
msg->getU8();
|
||||
msg->getU8();
|
||||
UnjustifiedPoints unjustifiedPoints;
|
||||
unjustifiedPoints.killsDay = msg->getU8();
|
||||
unjustifiedPoints.killsDayRemaining = msg->getU8();
|
||||
unjustifiedPoints.killsWeek = msg->getU8();
|
||||
unjustifiedPoints.killsWeekRemaining = msg->getU8();
|
||||
unjustifiedPoints.killsMonth = msg->getU8();
|
||||
unjustifiedPoints.killsMonthRemaining = msg->getU8();
|
||||
unjustifiedPoints.skullTime = msg->getU8();
|
||||
|
||||
g_game.setUnjustifiedPoints(unjustifiedPoints);
|
||||
}
|
||||
|
||||
void ProtocolGame::parsePvpSituations(const InputMessagePtr& msg)
|
||||
{
|
||||
msg->getU8(); // amount of open pvp situations
|
||||
uint8 openPvpSituations = msg->getU8();
|
||||
|
||||
g_game.setOpenPvpSituations(openPvpSituations);
|
||||
}
|
||||
|
||||
void ProtocolGame::parsePlayerHelpers(const InputMessagePtr& msg)
|
||||
@@ -501,6 +510,12 @@ void ProtocolGame::parseLoginWait(const InputMessagePtr& msg)
|
||||
g_game.processLoginWait(message, time);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseLoginToken(const InputMessagePtr& msg)
|
||||
{
|
||||
bool unknown = (msg->getU8() == 0);
|
||||
g_game.processLoginToken(unknown);
|
||||
}
|
||||
|
||||
void ProtocolGame::parsePing(const InputMessagePtr& msg)
|
||||
{
|
||||
g_game.processPing();
|
||||
|
@@ -87,6 +87,9 @@ void ProtocolGame::sendLoginPacket(uint challengeTimestamp, uint8 challengeRando
|
||||
msg->addString(m_characterName);
|
||||
msg->addString(m_accountPassword);
|
||||
|
||||
if(g_game.getFeature(Otc::GameAuthenticator))
|
||||
msg->addString(m_authenticatorToken);
|
||||
|
||||
if(g_game.getFeature(Otc::GameChallengeOnLogin)) {
|
||||
msg->addU32(challengeTimestamp);
|
||||
msg->addU8(challengeRandom);
|
||||
|
Reference in New Issue
Block a user