mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-05-02 02:29:21 +02:00
geri pataisymai. Ieskoti bugu reikia per otlcient
This commit is contained in:
parent
3d05566759
commit
ba1409dbe6
@ -37,7 +37,6 @@ class NetworkMessage
|
|||||||
// 2 bytes for encrypted message size
|
// 2 bytes for encrypted message size
|
||||||
static constexpr MsgSize_t INITIAL_BUFFER_POSITION = 4;
|
static constexpr MsgSize_t INITIAL_BUFFER_POSITION = 4;
|
||||||
enum { HEADER_LENGTH = 2 };
|
enum { HEADER_LENGTH = 2 };
|
||||||
enum { CHECKSUM_LENGTH = 4 };
|
|
||||||
enum { XTEA_MULTIPLE = 8 };
|
enum { XTEA_MULTIPLE = 8 };
|
||||||
enum { MAX_BODY_LENGTH = NETWORKMESSAGE_MAXSIZE - HEADER_LENGTH - XTEA_MULTIPLE };
|
enum { MAX_BODY_LENGTH = NETWORKMESSAGE_MAXSIZE - HEADER_LENGTH - XTEA_MULTIPLE };
|
||||||
enum { MAX_PROTOCOL_BODY_LENGTH = MAX_BODY_LENGTH - 10 };
|
enum { MAX_PROTOCOL_BODY_LENGTH = MAX_BODY_LENGTH - 10 };
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
add_header(info.length);
|
add_header(info.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addCryptoHeader(bool addChecksum) {
|
void addCryptoHeader() {
|
||||||
writeMessageLength();
|
writeMessageLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ void Protocol::onSendMessage(const OutputMessage_ptr& msg) const
|
|||||||
|
|
||||||
if (encryptionEnabled) {
|
if (encryptionEnabled) {
|
||||||
XTEA_encrypt(*msg);
|
XTEA_encrypt(*msg);
|
||||||
msg->addCryptoHeader(checksumEnabled);
|
msg->addCryptoHeader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,9 +75,6 @@ protected:
|
|||||||
void setXTEAKey(xtea::key key) {
|
void setXTEAKey(xtea::key key) {
|
||||||
this->key = std::move(key);
|
this->key = std::move(key);
|
||||||
}
|
}
|
||||||
void disableChecksum() {
|
|
||||||
checksumEnabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool RSA_decrypt(NetworkMessage& msg);
|
static bool RSA_decrypt(NetworkMessage& msg);
|
||||||
|
|
||||||
@ -98,7 +95,6 @@ private:
|
|||||||
const ConnectionWeak_ptr connection;
|
const ConnectionWeak_ptr connection;
|
||||||
xtea::key key;
|
xtea::key key;
|
||||||
bool encryptionEnabled = false;
|
bool encryptionEnabled = false;
|
||||||
bool checksumEnabled = true;
|
|
||||||
bool rawMessages = false;
|
bool rawMessages = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -441,8 +441,6 @@ void ProtocolGame::parsePacket(NetworkMessage& msg)
|
|||||||
|
|
||||||
void ProtocolGame::GetTileDescription(const Tile* tile, NetworkMessage& msg)
|
void ProtocolGame::GetTileDescription(const Tile* tile, NetworkMessage& msg)
|
||||||
{
|
{
|
||||||
msg.add<uint16_t>(0x00); //environmental effects
|
|
||||||
|
|
||||||
int32_t count;
|
int32_t count;
|
||||||
Item* ground = tile->getGround();
|
Item* ground = tile->getGround();
|
||||||
if (ground) {
|
if (ground) {
|
||||||
@ -1509,7 +1507,8 @@ void ProtocolGame::sendAddCreature(const Creature* creature, const Position& pos
|
|||||||
msg.addByte(0x0A);
|
msg.addByte(0x0A);
|
||||||
|
|
||||||
msg.add<uint32_t>(player->getID());
|
msg.add<uint32_t>(player->getID());
|
||||||
msg.add<uint16_t>(0x32); // beat duration (50)
|
msg.addByte(0x32); // beat duration (50)
|
||||||
|
msg.addByte(0x00);
|
||||||
|
|
||||||
// can report bugs?
|
// can report bugs?
|
||||||
if (player->getAccountType() >= ACCOUNT_TYPE_TUTOR) {
|
if (player->getAccountType() >= ACCOUNT_TYPE_TUTOR) {
|
||||||
@ -1533,16 +1532,9 @@ void ProtocolGame::sendAddCreature(const Creature* creature, const Position& pos
|
|||||||
sendMagicEffect(pos, CONST_ME_TELEPORT);
|
sendMagicEffect(pos, CONST_ME_TELEPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendInventoryItem(CONST_SLOT_HEAD, player->getInventoryItem(CONST_SLOT_HEAD));
|
for (int i = CONST_SLOT_FIRST; i <= CONST_SLOT_LAST; ++i) {
|
||||||
sendInventoryItem(CONST_SLOT_NECKLACE, player->getInventoryItem(CONST_SLOT_NECKLACE));
|
sendInventoryItem(static_cast<slots_t>(i), player->getInventoryItem(static_cast<slots_t>(i)));
|
||||||
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));
|
|
||||||
|
|
||||||
sendStats();
|
sendStats();
|
||||||
sendSkills();
|
sendSkills();
|
||||||
@ -1837,39 +1829,23 @@ void ProtocolGame::AddPlayerStats(NetworkMessage& msg)
|
|||||||
|
|
||||||
msg.add<uint16_t>(std::min<int32_t>(player->getHealth(), std::numeric_limits<uint16_t>::max()));
|
msg.add<uint16_t>(std::min<int32_t>(player->getHealth(), std::numeric_limits<uint16_t>::max()));
|
||||||
msg.add<uint16_t>(std::min<int32_t>(player->getMaxHealth(), std::numeric_limits<uint16_t>::max()));
|
msg.add<uint16_t>(std::min<int32_t>(player->getMaxHealth(), std::numeric_limits<uint16_t>::max()));
|
||||||
msg.add<uint32_t>(player->getFreeCapacity());
|
|
||||||
msg.add<uint32_t>(player->getCapacity());
|
msg.add<uint16_t>(player->getFreeCapacity() / 100);
|
||||||
|
|
||||||
msg.add<uint64_t>(player->getExperience());
|
msg.add<uint32_t>(std::min<uint32_t>(player->getExperience(), 0x7FFFFFFF));
|
||||||
|
|
||||||
msg.add<uint16_t>(player->getLevel());
|
msg.add<uint16_t>(player->getLevel());
|
||||||
|
|
||||||
msg.addByte(player->getLevelPercent());
|
msg.addByte(player->getLevelPercent());
|
||||||
|
|
||||||
msg.add<uint16_t>(100); // base xp gain rate
|
|
||||||
msg.add<uint16_t>(0); // xp voucher
|
|
||||||
msg.add<uint16_t>(0); // low level bonus
|
|
||||||
msg.add<uint16_t>(0); // xp boost
|
|
||||||
msg.add<uint16_t>(100); // stamina multiplier (100 = x1.0)
|
|
||||||
|
|
||||||
|
|
||||||
msg.add<uint16_t>(std::min<int32_t>(player->getMana(), std::numeric_limits<uint16_t>::max()));
|
msg.add<uint16_t>(std::min<int32_t>(player->getMana(), std::numeric_limits<uint16_t>::max()));
|
||||||
msg.add<uint16_t>(std::min<int32_t>(player->getMaxMana(), std::numeric_limits<uint16_t>::max()));
|
msg.add<uint16_t>(std::min<int32_t>(player->getMaxMana(), std::numeric_limits<uint16_t>::max()));
|
||||||
|
|
||||||
msg.addByte(std::min<uint32_t>(player->getMagicLevel(), std::numeric_limits<uint8_t>::max()));
|
msg.addByte(std::min<uint32_t>(player->getMagicLevel(), std::numeric_limits<uint8_t>::max()));
|
||||||
msg.addByte(std::min<uint32_t>(player->getBaseMagicLevel(), std::numeric_limits<uint8_t>::max()));
|
|
||||||
msg.addByte(player->getMagicLevelPercent());
|
msg.addByte(player->getMagicLevelPercent());
|
||||||
|
|
||||||
msg.addByte(player->getSoul());
|
msg.addByte(player->getSoul());
|
||||||
|
|
||||||
msg.add<uint16_t>(player->getStaminaMinutes());
|
msg.add<uint16_t>(player->getStaminaMinutes());
|
||||||
|
|
||||||
msg.add<uint16_t>(player->getBaseSpeed() / 2);
|
|
||||||
|
|
||||||
Condition* condition = player->getCondition(CONDITION_REGENERATION);
|
|
||||||
msg.add<uint16_t>(condition ? condition->getTicks() / 1000 : 0x00);
|
|
||||||
|
|
||||||
msg.add<uint16_t>(0); // xp boost time (seconds)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::AddPlayerSkills(NetworkMessage& msg)
|
void ProtocolGame::AddPlayerSkills(NetworkMessage& msg)
|
||||||
|
@ -52,7 +52,6 @@ class ProtocolGame final : public Protocol
|
|||||||
// static protocol information
|
// static protocol information
|
||||||
enum { server_sends_first = true };
|
enum { server_sends_first = true };
|
||||||
enum { protocol_identifier = 0 }; // Not required as we send first
|
enum { protocol_identifier = 0 }; // Not required as we send first
|
||||||
enum { use_checksum = true };
|
|
||||||
|
|
||||||
static const char* protocol_name() {
|
static const char* protocol_name() {
|
||||||
return "gameworld protocol";
|
return "gameworld protocol";
|
||||||
|
@ -31,7 +31,6 @@ class ProtocolLogin : public Protocol
|
|||||||
// static protocol information
|
// static protocol information
|
||||||
enum {server_sends_first = false};
|
enum {server_sends_first = false};
|
||||||
enum {protocol_identifier = 0x01};
|
enum {protocol_identifier = 0x01};
|
||||||
enum {use_checksum = true};
|
|
||||||
static const char* protocol_name() {
|
static const char* protocol_name() {
|
||||||
return "login protocol";
|
return "login protocol";
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ class ProtocolStatus final : public Protocol
|
|||||||
// static protocol information
|
// static protocol information
|
||||||
enum {server_sends_first = false};
|
enum {server_sends_first = false};
|
||||||
enum {protocol_identifier = 0xFF};
|
enum {protocol_identifier = 0xFF};
|
||||||
enum {use_checksum = false};
|
|
||||||
static const char* protocol_name() {
|
static const char* protocol_name() {
|
||||||
return "status protocol";
|
return "status protocol";
|
||||||
}
|
}
|
||||||
|
@ -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)
|
std::string ucfirst(std::string str)
|
||||||
{
|
{
|
||||||
|
@ -84,8 +84,6 @@ std::string getCombatName(CombatType_t combatType);
|
|||||||
|
|
||||||
std::string getSkillName(uint8_t skillid);
|
std::string getSkillName(uint8_t skillid);
|
||||||
|
|
||||||
uint32_t adlerChecksum(const uint8_t* data, size_t length);
|
|
||||||
|
|
||||||
std::string ucfirst(std::string str);
|
std::string ucfirst(std::string str);
|
||||||
std::string ucwords(std::string str);
|
std::string ucwords(std::string str);
|
||||||
bool booleanString(const std::string& str);
|
bool booleanString(const std::string& str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user