summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-05-17 01:03:34 +0300
committerAndrei Karas <akaras@inbox.ru>2016-05-17 01:03:34 +0300
commit5d77b00cba5398482c4eb9422ae4f06ae3509b8f (patch)
treeea8c4b6a012d4c9e27e227621197330f8fc2eacd
parent0c5402def993b1df930cda7fcdaff4f865a84fdb (diff)
downloadplus-5d77b00cba5398482c4eb9422ae4f06ae3509b8f.tar.gz
plus-5d77b00cba5398482c4eb9422ae4f06ae3509b8f.tar.bz2
plus-5d77b00cba5398482c4eb9422ae4f06ae3509b8f.tar.xz
plus-5d77b00cba5398482c4eb9422ae4f06ae3509b8f.zip
Fix sending packets for version 20151001 and bigger.
-rw-r--r--src/net/eathena/charserverhandler.cpp65
-rw-r--r--src/net/eathena/chathandler.cpp46
-rw-r--r--src/net/eathena/guildhandler.cpp15
-rw-r--r--src/net/eathena/packetsout.inc4
-rw-r--r--src/net/eathena/partyhandler.cpp15
5 files changed, 113 insertions, 32 deletions
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index 328546909..3eb355caa 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -38,6 +38,8 @@
#include "debug.h"
extern Net::CharServerHandler *charServerHandler;
+extern int packetVersion;
+extern int serverVersion;
namespace EAthena
{
@@ -80,23 +82,58 @@ void CharServerHandler::newCharacter(const std::string &name, const int slot,
{
createOutPacket(CMSG_CHAR_CREATE);
outMsg.writeString(name, 24, "login");
-
- outMsg.writeInt8(CAST_U8(slot), "slot");
- outMsg.writeInt16(CAST_S16(hairColor), "hair color");
- outMsg.writeInt16(CAST_S16(hairstyle), "hair style");
- if (serverFeatures->haveRaceSelection())
- outMsg.writeInt16(CAST_S16(race), "race");
- if (serverFeatures->haveCreateCharGender())
+ if (serverVersion > 0)
+ {
+ outMsg.writeInt8(CAST_U8(slot), "slot");
+ outMsg.writeInt16(CAST_S16(hairColor), "hair color");
+ outMsg.writeInt16(CAST_S16(hairstyle), "hair style");
+ if (serverFeatures->haveRaceSelection())
+ outMsg.writeInt16(CAST_S16(race), "race");
+ if (serverFeatures->haveCreateCharGender())
+ {
+ uint8_t sex = 0;
+ if (gender == Gender::UNSPECIFIED)
+ sex = 99;
+ else
+ sex = Being::genderToInt(gender);
+ outMsg.writeInt8(sex, "gender");
+ }
+ if (serverFeatures->haveLookSelection())
+ outMsg.writeInt16(CAST_S16(look), "look");
+ }
+ else
{
- uint8_t sex = 0;
- if (gender == Gender::UNSPECIFIED)
- sex = 99;
+ if (packetVersion >= 20151001)
+ {
+ outMsg.writeInt8(CAST_U8(slot), "slot");
+ outMsg.writeInt16(CAST_S16(hairstyle), "hair style");
+ outMsg.writeInt16(CAST_S16(0), "starting job id");
+ outMsg.writeInt16(0, "unknown");
+ outMsg.writeInt16(0, "unknown");
+ uint8_t sex = 0;
+ if (gender == Gender::UNSPECIFIED)
+ sex = 99;
+ else
+ sex = Being::genderToInt(gender);
+ outMsg.writeInt8(sex, "gender");
+ }
+ else if (packetVersion >= 20120307)
+ {
+ outMsg.writeInt8(CAST_U8(slot), "slot");
+ outMsg.writeInt16(CAST_S16(hairstyle), "hair style");
+ }
else
- sex = Being::genderToInt(gender);
- outMsg.writeInt8(sex, "gender");
+ { // < 20120307
+ // +++ here need send stat points
+ // sending 5 for each stat for now
+ for (int i = 0; i < 6; i++)
+ outMsg.writeInt8(CAST_U8(5), "stat");
+
+ outMsg.writeInt8(CAST_U8(slot), "slot");
+ outMsg.writeInt16(CAST_S16(hairColor), "hair color");
+ outMsg.writeInt16(CAST_S16(hairstyle), "hair style");
+ }
}
- if (serverFeatures->haveLookSelection())
- outMsg.writeInt16(CAST_S16(look), "look");
}
void CharServerHandler::deleteCharacter(Net::Character *const character,
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp
index 3c4ab0040..bbfc1af3e 100644
--- a/src/net/eathena/chathandler.cpp
+++ b/src/net/eathena/chathandler.cpp
@@ -39,6 +39,7 @@
#include "debug.h"
extern Net::ChatHandler *chatHandler;
+extern int packetVersion;
namespace EAthena
{
@@ -59,9 +60,17 @@ void ChatHandler::talk(const std::string &restrict text,
" : ").append(text);
createOutPacket(CMSG_CHAT_MESSAGE);
- // Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len");
- outMsg.writeString(mes, CAST_S32(mes.length() + 1), "message");
+ if (packetVersion >= 20151001)
+ {
+ outMsg.writeInt16(CAST_S16(mes.length() + 4), "len");
+ outMsg.writeString(mes, CAST_S32(mes.length()), "message");
+ }
+ else
+ {
+ // Added + 1 in order to let eAthena parse admin commands correctly
+ outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len");
+ outMsg.writeString(mes, CAST_S32(mes.length() + 1), "message");
+ }
}
void ChatHandler::talkRaw(const std::string &mes) const
@@ -75,10 +84,19 @@ void ChatHandler::privateMessage(const std::string &restrict recipient,
const std::string &restrict text) const
{
createOutPacket(CMSG_CHAT_WHISPER);
- outMsg.writeInt16(CAST_S16(text.length() + 28 + 1), "len");
- outMsg.writeString(recipient, 24, "recipient nick");
- outMsg.writeString(text, CAST_S32(text.length()), "message");
- outMsg.writeInt8(0, "null char");
+ if (packetVersion >= 20151001)
+ {
+ outMsg.writeInt16(CAST_S16(text.length() + 28), "len");
+ outMsg.writeString(recipient, 24, "recipient nick");
+ outMsg.writeString(text, CAST_S32(text.length()), "message");
+ }
+ else
+ {
+ outMsg.writeInt16(CAST_S16(text.length() + 28 + 1), "len");
+ outMsg.writeString(recipient, 24, "recipient nick");
+ outMsg.writeString(text, CAST_S32(text.length()), "message");
+ outMsg.writeInt8(0, "null char");
+ }
Ea::ChatRecv::mSentWhispers.push(recipient);
}
@@ -219,9 +237,17 @@ void ChatHandler::battleTalk(const std::string &text) const
" : ").append(text);
createOutPacket(CMSG_BATTLE_CHAT_MESSAGE);
- // Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len");
- outMsg.writeString(mes, CAST_S32(mes.length() + 1), "message");
+ if (packetVersion >= 20151001)
+ {
+ outMsg.writeInt16(CAST_S16(mes.length() + 4), "len");
+ outMsg.writeString(mes, CAST_S32(mes.length()), "message");
+ }
+ else
+ {
+ // Added + 1 in order to let eAthena parse admin commands correctly
+ outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len");
+ outMsg.writeString(mes, CAST_S32(mes.length() + 1), "message");
+ }
}
void ChatHandler::joinChat(const ChatObject *const chat,
diff --git a/src/net/eathena/guildhandler.cpp b/src/net/eathena/guildhandler.cpp
index 3da443dda..9d5e15f48 100644
--- a/src/net/eathena/guildhandler.cpp
+++ b/src/net/eathena/guildhandler.cpp
@@ -34,6 +34,7 @@
#include "debug.h"
extern Net::GuildHandler *guildHandler;
+extern int packetVersion;
namespace EAthena
{
@@ -125,9 +126,17 @@ void GuildHandler::chat(const std::string &text) const
const std::string str = std::string(localPlayer->getName()).append(
" : ").append(text);
createOutPacket(CMSG_GUILD_MESSAGE);
- outMsg.writeInt16(CAST_U16(str.size() + 4 + 1), "len");
- outMsg.writeString(str, CAST_S32(str.length()), "message");
- outMsg.writeInt8(0, "zero byte");
+ if (packetVersion >= 20151001)
+ {
+ outMsg.writeInt16(CAST_U16(str.size() + 4), "len");
+ outMsg.writeString(str, CAST_S32(str.length()), "message");
+ }
+ else
+ {
+ outMsg.writeInt16(CAST_U16(str.size() + 4 + 1), "len");
+ outMsg.writeString(str, CAST_S32(str.length()), "message");
+ outMsg.writeInt8(0, "zero byte");
+ }
}
void GuildHandler::memberList() const
diff --git a/src/net/eathena/packetsout.inc b/src/net/eathena/packetsout.inc
index 32d1e6c3f..a44966def 100644
--- a/src/net/eathena/packetsout.inc
+++ b/src/net/eathena/packetsout.inc
@@ -37,7 +37,7 @@ packet(CMSG_NAME_REQUEST, 0x0094, 6, clif->pGetCharNameRequest
packet(CMSG_CHAR_PASSWORD_CHANGE, 0x0061, 0, nullptr);
packet(CMSG_CHAR_SERVER_CONNECT, 0x0065, 0, nullptr);
packet(CMSG_CHAR_SELECT, 0x0066, 0, nullptr);
-packet(CMSG_CHAR_CREATE, 0x0970, 0, nullptr);
+packet(CMSG_CHAR_CREATE, 0x0067, 0, nullptr);
packet(CMSG_CHAR_DELETE, 0x0068, 0, nullptr);
packet(CMSG_CHAR_CREATE_PIN, 0x08ba, 0, nullptr);
packet(CMSG_CHAR_CHECK_RENAME, 0x08fc, 0, nullptr);
@@ -406,6 +406,7 @@ if (packetVersion >= 20120307)
packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
packet(CMSG_SEARCHSTORE_SEARCH, 0x0884, -1, clif->pSearchStoreInfo);
packet(CMSG_MAP_SERVER_CONNECT, 0x086A, 19, clif->pWantToConnection);
+ packet(CMSG_CHAR_CREATE, 0x0970, 0, nullptr);
}
// 20120410
@@ -774,6 +775,7 @@ if (packetVersion >= 20151001)
packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
+ packet(CMSG_CHAR_CREATE, 0x0a39, 0, nullptr);
}
// 20151104
diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp
index 67a86c14c..7de6dcd9c 100644
--- a/src/net/eathena/partyhandler.cpp
+++ b/src/net/eathena/partyhandler.cpp
@@ -125,10 +125,17 @@ void PartyHandler::chat(const std::string &text) const
createOutPacket(CMSG_PARTY_MESSAGE);
const std::string mes = std::string(localPlayer->getName()).append(
" : ").append(text);
-
- outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len");
- outMsg.writeString(mes, CAST_S32(mes.length()), "nick : message");
- outMsg.writeInt8(0, "null char");
+ if (packetVersion >= 20151001)
+ {
+ outMsg.writeInt16(CAST_S16(mes.length() + 4), "len");
+ outMsg.writeString(mes, CAST_S32(mes.length()), "nick : message");
+ }
+ else
+ {
+ outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len");
+ outMsg.writeString(mes, CAST_S32(mes.length()), "nick : message");
+ outMsg.writeInt8(0, "null char");
+ }
}
// +++ must be 3 types item, exp, pickup