diff --git a/src/networkmessage.h b/src/networkmessage.h index b588f5a..7d11153 100644 --- a/src/networkmessage.h +++ b/src/networkmessage.h @@ -37,7 +37,6 @@ class NetworkMessage // 2 bytes for encrypted message size static constexpr MsgSize_t INITIAL_BUFFER_POSITION = 4; enum { HEADER_LENGTH = 2 }; - enum { CHECKSUM_LENGTH = 4 }; enum { XTEA_MULTIPLE = 8 }; enum { MAX_BODY_LENGTH = NETWORKMESSAGE_MAXSIZE - HEADER_LENGTH - XTEA_MULTIPLE }; enum { MAX_PROTOCOL_BODY_LENGTH = MAX_BODY_LENGTH - 10 }; diff --git a/src/outputmessage.h b/src/outputmessage.h index 09f5435..3dde508 100644 --- a/src/outputmessage.h +++ b/src/outputmessage.h @@ -43,7 +43,7 @@ public: add_header(info.length); } - void addCryptoHeader(bool addChecksum) { + void addCryptoHeader() { writeMessageLength(); } diff --git a/src/protocol.cpp b/src/protocol.cpp index 00c7ebe..e443ef0 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -33,7 +33,7 @@ void Protocol::onSendMessage(const OutputMessage_ptr& msg) const if (encryptionEnabled) { XTEA_encrypt(*msg); - msg->addCryptoHeader(checksumEnabled); + msg->addCryptoHeader(); } } } diff --git a/src/protocol.h b/src/protocol.h index 76bf5d1..89039c9 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -75,9 +75,6 @@ protected: void setXTEAKey(xtea::key key) { this->key = std::move(key); } - void disableChecksum() { - checksumEnabled = false; - } static bool RSA_decrypt(NetworkMessage& msg); @@ -98,7 +95,6 @@ private: const ConnectionWeak_ptr connection; xtea::key key; bool encryptionEnabled = false; - bool checksumEnabled = true; bool rawMessages = false; }; diff --git a/src/protocolgame.cpp b/src/protocolgame.cpp index 3714984..b690a9c 100644 --- a/src/protocolgame.cpp +++ b/src/protocolgame.cpp @@ -441,8 +441,6 @@ void ProtocolGame::parsePacket(NetworkMessage& msg) void ProtocolGame::GetTileDescription(const Tile* tile, NetworkMessage& msg) { - msg.add(0x00); //environmental effects - int32_t count; Item* ground = tile->getGround(); if (ground) { @@ -1509,7 +1507,8 @@ void ProtocolGame::sendAddCreature(const Creature* creature, const Position& pos msg.addByte(0x0A); msg.add(player->getID()); - msg.add(0x32); // beat duration (50) + msg.addByte(0x32); // beat duration (50) + msg.addByte(0x00); // can report bugs? if (player->getAccountType() >= ACCOUNT_TYPE_TUTOR) { @@ -1533,16 +1532,9 @@ void ProtocolGame::sendAddCreature(const Creature* creature, const Position& pos sendMagicEffect(pos, CONST_ME_TELEPORT); } - sendInventoryItem(CONST_SLOT_HEAD, player->getInventoryItem(CONST_SLOT_HEAD)); - sendInventoryItem(CONST_SLOT_NECKLACE, player->getInventoryItem(CONST_SLOT_NECKLACE)); - sendInventoryItem(CONST_SLOT_BACKPACK, player->getInventoryItem(CONST_SLOT_BACKPACK)); - sendInventoryItem(CONST_SLOT_ARMOR, player->getInventoryItem(CONST_SLOT_ARMOR)); - sendInventoryItem(CONST_SLOT_RIGHT, player->getInventoryItem(CONST_SLOT_RIGHT)); - sendInventoryItem(CONST_SLOT_LEFT, player->getInventoryItem(CONST_SLOT_LEFT)); - sendInventoryItem(CONST_SLOT_LEGS, player->getInventoryItem(CONST_SLOT_LEGS)); - sendInventoryItem(CONST_SLOT_FEET, player->getInventoryItem(CONST_SLOT_FEET)); - sendInventoryItem(CONST_SLOT_RING, player->getInventoryItem(CONST_SLOT_RING)); - sendInventoryItem(CONST_SLOT_AMMO, player->getInventoryItem(CONST_SLOT_AMMO)); + for (int i = CONST_SLOT_FIRST; i <= CONST_SLOT_LAST; ++i) { + sendInventoryItem(static_cast(i), player->getInventoryItem(static_cast(i))); + } sendStats(); sendSkills(); @@ -1837,39 +1829,23 @@ void ProtocolGame::AddPlayerStats(NetworkMessage& msg) msg.add(std::min(player->getHealth(), std::numeric_limits::max())); msg.add(std::min(player->getMaxHealth(), std::numeric_limits::max())); - msg.add(player->getFreeCapacity()); - msg.add(player->getCapacity()); + + msg.add(player->getFreeCapacity() / 100); - msg.add(player->getExperience()); + msg.add(std::min(player->getExperience(), 0x7FFFFFFF)); msg.add(player->getLevel()); - msg.addByte(player->getLevelPercent()); - msg.add(100); // base xp gain rate - msg.add(0); // xp voucher - msg.add(0); // low level bonus - msg.add(0); // xp boost - msg.add(100); // stamina multiplier (100 = x1.0) - - msg.add(std::min(player->getMana(), std::numeric_limits::max())); msg.add(std::min(player->getMaxMana(), std::numeric_limits::max())); msg.addByte(std::min(player->getMagicLevel(), std::numeric_limits::max())); - msg.addByte(std::min(player->getBaseMagicLevel(), std::numeric_limits::max())); msg.addByte(player->getMagicLevelPercent()); msg.addByte(player->getSoul()); msg.add(player->getStaminaMinutes()); - - msg.add(player->getBaseSpeed() / 2); - - Condition* condition = player->getCondition(CONDITION_REGENERATION); - msg.add(condition ? condition->getTicks() / 1000 : 0x00); - - msg.add(0); // xp boost time (seconds) } void ProtocolGame::AddPlayerSkills(NetworkMessage& msg) diff --git a/src/protocolgame.h b/src/protocolgame.h index 42c919d..aca3e38 100644 --- a/src/protocolgame.h +++ b/src/protocolgame.h @@ -52,7 +52,6 @@ class ProtocolGame final : public Protocol // static protocol information enum { server_sends_first = true }; enum { protocol_identifier = 0 }; // Not required as we send first - enum { use_checksum = true }; static const char* protocol_name() { return "gameworld protocol"; diff --git a/src/protocollogin.h b/src/protocollogin.h index 3b75851..a45898f 100644 --- a/src/protocollogin.h +++ b/src/protocollogin.h @@ -31,7 +31,6 @@ class ProtocolLogin : public Protocol // static protocol information enum {server_sends_first = false}; enum {protocol_identifier = 0x01}; - enum {use_checksum = true}; static const char* protocol_name() { return "login protocol"; } diff --git a/src/protocolstatus.h b/src/protocolstatus.h index c9fef5a..2e6cae2 100644 --- a/src/protocolstatus.h +++ b/src/protocolstatus.h @@ -29,7 +29,6 @@ class ProtocolStatus final : public Protocol // static protocol information enum {server_sends_first = false}; enum {protocol_identifier = 0xFF}; - enum {use_checksum = false}; static const char* protocol_name() { return "status protocol"; } diff --git a/src/tools.cpp b/src/tools.cpp index 05be137..c6f68b7 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -835,32 +835,6 @@ std::string getSkillName(uint8_t skillid) } } -uint32_t adlerChecksum(const uint8_t* data, size_t length) -{ - if (length > NETWORKMESSAGE_MAXSIZE) { - return 0; - } - - const uint16_t adler = 65521; - - uint32_t a = 1, b = 0; - - while (length > 0) { - size_t tmp = length > 5552 ? 5552 : length; - length -= tmp; - - do { - a += *data++; - b += a; - } while (--tmp); - - a %= adler; - b %= adler; - } - - return (b << 16) | a; -} - std::string ucfirst(std::string str) { diff --git a/src/tools.h b/src/tools.h index b615af3..8f05a93 100644 --- a/src/tools.h +++ b/src/tools.h @@ -84,8 +84,6 @@ std::string getCombatName(CombatType_t combatType); std::string getSkillName(uint8_t skillid); -uint32_t adlerChecksum(const uint8_t* data, size_t length); - std::string ucfirst(std::string str); std::string ucwords(std::string str); bool booleanString(const std::string& str);