some protocol changes for more compatibility
This commit is contained in:
parent
5584bfdd99
commit
d586bb5e93
|
@ -41,7 +41,7 @@
|
|||
|
||||
Creature::Creature() : Thing()
|
||||
{
|
||||
m_id = 0;
|
||||
m_id = 1;
|
||||
m_healthPercent = 100;
|
||||
m_speed = 200;
|
||||
m_direction = Otc::South;
|
||||
|
|
|
@ -49,6 +49,7 @@ void Game::resetGameStates()
|
|||
m_safeFight = true;
|
||||
m_followingCreature = nullptr;
|
||||
m_attackingCreature = nullptr;
|
||||
m_localPlayer = nullptr;
|
||||
|
||||
for(auto& it : m_containers) {
|
||||
const ContainerPtr& container = it.second;
|
||||
|
@ -76,11 +77,8 @@ void Game::processConnectionError(const boost::system::error_code& error)
|
|||
|
||||
void Game::processDisconnect()
|
||||
{
|
||||
if(isOnline()) {
|
||||
m_localPlayer = nullptr;
|
||||
|
||||
if(isOnline())
|
||||
processGameEnd();
|
||||
}
|
||||
|
||||
if(m_protocolGame) {
|
||||
m_protocolGame->disconnect();
|
||||
|
@ -144,28 +142,6 @@ void Game::processGMActions(const std::vector<uint8>& actions)
|
|||
g_lua.callGlobalField("g_game", "onGMActions", actions);
|
||||
}
|
||||
|
||||
void Game::processPlayerStats(double health, double maxHealth,
|
||||
double freeCapacity, double experience,
|
||||
double level, double levelPercent,
|
||||
double mana, double maxMana,
|
||||
double magicLevel, double magicLevelPercent,
|
||||
double soul, double stamina)
|
||||
{
|
||||
if(!m_localPlayer) {
|
||||
logTraceError("there is no local player");
|
||||
return;
|
||||
}
|
||||
|
||||
m_localPlayer->setHealth(health, maxHealth);
|
||||
m_localPlayer->setFreeCapacity(freeCapacity);
|
||||
m_localPlayer->setExperience(experience);
|
||||
m_localPlayer->setLevel(level, levelPercent);
|
||||
m_localPlayer->setMana(mana, maxMana);
|
||||
m_localPlayer->setMagicLevel(magicLevel, magicLevelPercent);
|
||||
m_localPlayer->setStamina(stamina);
|
||||
m_localPlayer->setSoul(soul);
|
||||
}
|
||||
|
||||
void Game::processPing()
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onPing");
|
||||
|
|
|
@ -53,13 +53,6 @@ protected:
|
|||
void processDeath(int penality);
|
||||
|
||||
void processGMActions(const std::vector<uint8>& actions);
|
||||
void processPlayerStats(double health, double maxHealth,
|
||||
double freeCapacity, double experience,
|
||||
double level, double levelPercent,
|
||||
double mana, double maxMana,
|
||||
double magicLevel, double magicLevelPercent,
|
||||
double soul, double stamina);
|
||||
|
||||
void processInventoryChange(int slot, const ItemPtr& item);
|
||||
void processCreatureMove(const CreaturePtr& creature, const Position& oldPos, const Position& newPos);
|
||||
void processCreatureTeleport(const CreaturePtr& creature);
|
||||
|
|
|
@ -52,6 +52,20 @@ namespace Proto {
|
|||
constexpr int ClientVersion = PROTOCOL;
|
||||
constexpr int PicSignature = 0x4E119CBF;
|
||||
|
||||
enum OsTypes {
|
||||
OsWindows = 1,
|
||||
OsLinux = 2,
|
||||
OsMac = 3
|
||||
};
|
||||
|
||||
#ifdef OSTYPE
|
||||
constexpr int ClientOs = OSTYPE;
|
||||
#elif defined WIN32
|
||||
constexpr int ClientOs = OsWindows;
|
||||
#else
|
||||
constexpr int ClientOs = OsLinux;
|
||||
#endif
|
||||
|
||||
#if PROTOCOL>=860
|
||||
constexpr int NumViolationReasons = 20;
|
||||
#elif PROTOCOL>=854
|
||||
|
@ -60,13 +74,6 @@ namespace Proto {
|
|||
constexpr int NumViolationReasons = 32;
|
||||
#endif
|
||||
|
||||
enum OsTypes {
|
||||
OsWindows = 1,
|
||||
OsLinux = 2,
|
||||
OsMac = 3,
|
||||
OsBrowser = 4
|
||||
};
|
||||
|
||||
enum LoginServerOpts {
|
||||
LoginServerError = 10,
|
||||
LoginServerMotd = 20,
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <otclient/core/game.h>
|
||||
#include <otclient/core/player.h>
|
||||
#include <otclient/core/item.h>
|
||||
#include <otclient/core/localplayer.h>
|
||||
|
||||
void ProtocolGame::login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName)
|
||||
{
|
||||
|
@ -43,6 +44,9 @@ void ProtocolGame::onConnect()
|
|||
{
|
||||
recv();
|
||||
|
||||
// must create local player before parsing anything
|
||||
m_localPlayer = LocalPlayerPtr(new LocalPlayer);
|
||||
|
||||
#if PROTOCOL>=854
|
||||
m_waitingLoginPacket = true;
|
||||
#else
|
||||
|
|
|
@ -196,6 +196,7 @@ private:
|
|||
|
||||
private:
|
||||
Boolean<false> m_waitingLoginPacket;
|
||||
Boolean<true> m_firstPacket;
|
||||
std::string m_accountName;
|
||||
std::string m_accountPassword;
|
||||
std::string m_characterName;
|
||||
|
|
|
@ -42,6 +42,12 @@ void ProtocolGame::parseMessage(InputMessage& msg)
|
|||
while(!msg.eof()) {
|
||||
opcode = msg.getU8();
|
||||
|
||||
if(m_firstPacket) {
|
||||
if(opcode != Proto::GameServerInitGame)
|
||||
logWarning("first server network opcode is not GameServerInitGame");
|
||||
m_firstPacket = false;
|
||||
}
|
||||
|
||||
switch(opcode) {
|
||||
case Proto::GameServerInitGame:
|
||||
parseInitGame(msg);
|
||||
|
@ -271,7 +277,7 @@ void ProtocolGame::parseMessage(InputMessage& msg)
|
|||
parseExtendedOpcode(msg);
|
||||
break;
|
||||
default:
|
||||
Fw::throwException("unknown opcode ", opcode, ", previous opcode is ", prevOpcode);
|
||||
Fw::throwException("unknown opcode");
|
||||
break;
|
||||
}
|
||||
prevOpcode = opcode;
|
||||
|
@ -287,9 +293,7 @@ void ProtocolGame::parseInitGame(InputMessage& msg)
|
|||
int serverBeat = msg.getU16();
|
||||
bool canReportBugs = msg.getU8();
|
||||
|
||||
m_localPlayer = LocalPlayerPtr(new LocalPlayer);
|
||||
m_localPlayer->setId(playerId);
|
||||
|
||||
g_game.processGameStart(m_localPlayer, serverBeat, canReportBugs);
|
||||
}
|
||||
|
||||
|
@ -595,7 +599,12 @@ void ProtocolGame::parseWorldLight(InputMessage& msg)
|
|||
void ProtocolGame::parseMagicEffect(InputMessage& msg)
|
||||
{
|
||||
Position pos = parsePosition(msg);
|
||||
#if PROTOCOL>=854
|
||||
// newer tibia decreased the max effects number, why???
|
||||
int effectId = msg.getU8();
|
||||
#else
|
||||
int effectId = msg.getU16();
|
||||
#endif
|
||||
|
||||
EffectPtr effect = EffectPtr(new Effect());
|
||||
effect->setId(effectId);
|
||||
|
@ -781,12 +790,14 @@ void ProtocolGame::parsePlayerStats(InputMessage& msg)
|
|||
double soul = msg.getU8();
|
||||
double stamina = msg.getU16();
|
||||
|
||||
g_game.processPlayerStats(health, maxHealth,
|
||||
freeCapacity, experience,
|
||||
level, levelPercent,
|
||||
mana, maxMana,
|
||||
magicLevel, magicLevelPercent,
|
||||
soul, stamina);
|
||||
m_localPlayer->setHealth(health, maxHealth);
|
||||
m_localPlayer->setFreeCapacity(freeCapacity);
|
||||
m_localPlayer->setExperience(experience);
|
||||
m_localPlayer->setLevel(level, levelPercent);
|
||||
m_localPlayer->setMana(mana, maxMana);
|
||||
m_localPlayer->setMagicLevel(magicLevel, magicLevelPercent);
|
||||
m_localPlayer->setStamina(stamina);
|
||||
m_localPlayer->setSoul(soul);
|
||||
}
|
||||
|
||||
void ProtocolGame::parsePlayerSkills(InputMessage& msg)
|
||||
|
|
|
@ -28,13 +28,7 @@ void ProtocolGame::sendLoginPacket(uint timestamp, uint8 unknown)
|
|||
OutputMessage msg;
|
||||
|
||||
msg.addU8(Proto::ClientEnterGame);
|
||||
|
||||
#ifdef WIN32
|
||||
msg.addU16(Proto::OsWindows);
|
||||
#else
|
||||
msg.addU16(Proto::OsLinux);
|
||||
#endif
|
||||
|
||||
msg.addU16(Proto::ClientOs);
|
||||
msg.addU16(Proto::ClientVersion);
|
||||
|
||||
int paddingBytes = 128;
|
||||
|
|
|
@ -86,11 +86,7 @@ void ProtocolLogin::sendLoginPacket()
|
|||
OutputMessage msg;
|
||||
|
||||
msg.addU8(Proto::ClientEnterAccount);
|
||||
#ifdef WIN32
|
||||
msg.addU16(Proto::OsWindows);
|
||||
#else
|
||||
msg.addU16(Proto::OsLinux);
|
||||
#endif
|
||||
msg.addU16(Proto::ClientOs);
|
||||
msg.addU16(Proto::ClientVersion);
|
||||
|
||||
msg.addU32(g_thingsType.getSignature()); // data signature
|
||||
|
|
Loading…
Reference in New Issue