diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-02-20 15:35:36 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-02-20 15:35:36 +0300 |
commit | 130ad803401e9d582a2118d9bc92b984222b00f1 (patch) | |
tree | 007c13fcabe6754c3fb50265fa665f6bd616e938 /src | |
parent | 16121e499c734c00c714abd0998c24f4845329c3 (diff) | |
download | manaverse-130ad803401e9d582a2118d9bc92b984222b00f1.tar.gz manaverse-130ad803401e9d582a2118d9bc92b984222b00f1.tar.bz2 manaverse-130ad803401e9d582a2118d9bc92b984222b00f1.tar.xz manaverse-130ad803401e9d582a2118d9bc92b984222b00f1.zip |
eathena: add support for online list packets.
Diffstat (limited to 'src')
-rw-r--r-- | src/net/ea/playerhandler.cpp | 63 | ||||
-rw-r--r-- | src/net/ea/playerhandler.h | 2 | ||||
-rw-r--r-- | src/net/eathena/packets.h | 2 | ||||
-rw-r--r-- | src/net/eathena/playerhandler.cpp | 6 | ||||
-rw-r--r-- | src/net/eathena/protocol.h | 7 | ||||
-rw-r--r-- | src/net/eathena/serverfeatures.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 65 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.h | 1 |
8 files changed, 78 insertions, 70 deletions
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index b8210219d..a2833eee3 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -22,20 +22,24 @@ #include "net/ea/playerhandler.h" +#include "configuration.h" #include "game.h" #include "party.h" #include "notifymanager.h" #include "soundmanager.h" #include "units.h" +#include "being/beingflag.h" #include "being/localplayer.h" #include "enums/being/attributes.h" +#include "gui/onlineplayer.h" #include "gui/viewport.h" #include "gui/windows/skilldialog.h" #include "gui/windows/statuswindow.h" +#include "gui/windows/whoisonline.h" #include "resources/notifytypes.h" @@ -471,4 +475,63 @@ void PlayerHandler::processMapMusic(Net::MessageIn &msg) map->setMusicFile(music); } +void PlayerHandler::processOnlineList(Net::MessageIn &msg) +{ + if (!whoIsOnline) + return; + + BLOCK_START("PlayerHandler::processOnlineList") + const int size = msg.readInt16("len") - 4; + std::vector<OnlinePlayer*> arr; + + if (!size) + { + if (whoIsOnline) + whoIsOnline->loadList(arr); + BLOCK_END("PlayerHandler::processOnlineList") + return; + } + + char *const start = reinterpret_cast<char*>(msg.readBytes(size, "nicks")); + if (!start) + { + BLOCK_END("PlayerHandler::processOnlineList") + return; + } + + const char *buf = start; + + int addVal = 3; + + while (buf - start + 1 < size + && *(buf + static_cast<size_t>(addVal))) + { + unsigned char status = *buf; + buf ++; + unsigned char level = *buf; + buf ++; + unsigned char ver = *buf; + buf ++; + + unsigned char gender = Gender::UNSPECIFIED; + if (config.getBoolValue("showgender")) + { + if (status & BeingFlag::GENDER_MALE) + gender = Gender::MALE; + else if (status & BeingFlag::GENDER_OTHER) + gender = Gender::OTHER; + else + gender = Gender::FEMALE; + } + arr.push_back(new OnlinePlayer(static_cast<const char*>(buf), + status, level, gender, ver)); + buf += strlen(buf) + 1; + } + + if (whoIsOnline) + whoIsOnline->loadList(arr); + delete [] start; + BLOCK_END("PlayerHandler::processOnlineList") +} + } // namespace Ea diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h index 322f038b6..6b5d0d0b8 100644 --- a/src/net/ea/playerhandler.h +++ b/src/net/ea/playerhandler.h @@ -76,6 +76,8 @@ class PlayerHandler notfinal : public Net::PlayerHandler static void processMapMask(Net::MessageIn &msg); static void processMapMusic(Net::MessageIn &msg); + + static void processOnlineList(Net::MessageIn &msg); }; } // namespace Ea diff --git a/src/net/eathena/packets.h b/src/net/eathena/packets.h index af745449c..d096fd2c8 100644 --- a/src/net/eathena/packets.h +++ b/src/net/eathena/packets.h @@ -282,7 +282,7 @@ int16_t packet_lengths[] = //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // #0x0B00 16, -1, 10, -1, -1, -1, -1, 0, 27, 0, -1, -1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // #0x0B40 diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp index 03dbb2cf5..b5bc87dcf 100644 --- a/src/net/eathena/playerhandler.cpp +++ b/src/net/eathena/playerhandler.cpp @@ -62,6 +62,7 @@ PlayerHandler::PlayerHandler() : SMSG_PLAYER_SKILL_MESSAGE, SMSG_MAP_MASK, SMSG_MAP_MUSIC, + SMSG_ONLINE_LIST, 0 }; handledMessages = _messages; @@ -141,6 +142,10 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) processMapMusic(msg); break; + case SMSG_ONLINE_LIST: + processOnlineList(msg); + break; + default: break; } @@ -249,6 +254,7 @@ void PlayerHandler::respawn() const void PlayerHandler::requestOnlineList() const { + createOutPacket(CMSG_ONLINE_LIST); } void PlayerHandler::updateStatus(const uint8_t status) const diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h index 73357f562..a9ab76092 100644 --- a/src/net/eathena/protocol.h +++ b/src/net/eathena/protocol.h @@ -291,8 +291,7 @@ #define SMSG_MAP_TYPE_PROPERTY2 0x099b #define SMSG_MAP_TYPE 0x01d6 #define SMSG_IGNORE_ALL_RESPONSE 0x00d2 -// unused for now -#define SMSG_ONLINE_LIST 0x0211 + #define SMSG_NPC_COMMAND 0x0B00 #define SMSG_MAP_ACCOUNT_ID 0x0283 @@ -348,6 +347,8 @@ #define SMSG_SEARCHSTORE_OPEN 0x083a #define SMSG_SEARCHSTORE_CLICK_ACK 0x083d +#define SMSG_ONLINE_LIST 0x0b10 + /********************************** * Packets from client to server * **********************************/ @@ -575,4 +576,6 @@ #define CMSG_SET_STATUS 0x0b0e +#define CMSG_ONLINE_LIST 0x0b0f + #endif // NET_EATHENA_PROTOCOL_H diff --git a/src/net/eathena/serverfeatures.cpp b/src/net/eathena/serverfeatures.cpp index 182c97186..beb042279 100644 --- a/src/net/eathena/serverfeatures.cpp +++ b/src/net/eathena/serverfeatures.cpp @@ -37,7 +37,7 @@ ServerFeatures::ServerFeatures() bool ServerFeatures::haveServerOnlineList() const { - return false; + return serverVersion >= 5; } bool ServerFeatures::haveOnlineList() const diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index e7b5deb6c..f5ccad489 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -22,17 +22,11 @@ #include "net/tmwa/playerhandler.h" -#include "configuration.h" - -#include "being/beingflag.h" #include "being/localplayer.h" #include "enums/being/attributes.h" -#include "gui/onlineplayer.h" - #include "gui/windows/statuswindow.h" -#include "gui/windows/whoisonline.h" #include "net/tmwa/inventoryhandler.h" #include "net/tmwa/messageout.h" @@ -247,65 +241,6 @@ void PlayerHandler::setMemo() const { } -void PlayerHandler::processOnlineList(Net::MessageIn &msg) -{ - if (!whoIsOnline) - return; - - BLOCK_START("PlayerHandler::processOnlineList") - const int size = msg.readInt16("len") - 4; - std::vector<OnlinePlayer*> arr; - - if (!size) - { - if (whoIsOnline) - whoIsOnline->loadList(arr); - BLOCK_END("PlayerHandler::processOnlineList") - return; - } - - char *const start = reinterpret_cast<char*>(msg.readBytes(size, "nicks")); - if (!start) - { - BLOCK_END("PlayerHandler::processOnlineList") - return; - } - - const char *buf = start; - - int addVal = 3; - - while (buf - start + 1 < size - && *(buf + static_cast<size_t>(addVal))) - { - unsigned char status = *buf; - buf ++; - unsigned char level = *buf; - buf ++; - unsigned char ver = *buf; - buf ++; - - unsigned char gender = Gender::UNSPECIFIED; - if (config.getBoolValue("showgender")) - { - if (status & BeingFlag::GENDER_MALE) - gender = Gender::MALE; - else if (status & BeingFlag::GENDER_OTHER) - gender = Gender::OTHER; - else - gender = Gender::FEMALE; - } - arr.push_back(new OnlinePlayer(static_cast<const char*>(buf), - status, level, gender, ver)); - buf += strlen(buf) + 1; - } - - if (whoIsOnline) - whoIsOnline->loadList(arr); - delete [] start; - BLOCK_END("PlayerHandler::processOnlineList") -} - void PlayerHandler::updateStatus(const uint8_t status) const { createOutPacket(CMSG_SET_STATUS); diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h index b2d103a65..1ca4c0ab8 100644 --- a/src/net/tmwa/playerhandler.h +++ b/src/net/tmwa/playerhandler.h @@ -52,7 +52,6 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler const int direction) const override final; void changeAction(const BeingAction::Action &action) const override final; - static void processOnlineList(Net::MessageIn &msg); void requestOnlineList() const override final; void updateStatus(const uint8_t status) const override final; |