diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-11-30 18:13:03 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-11-30 20:09:16 +0300 |
commit | 7c6621108b54fd66fbb7aa87be067a34abcc3ced (patch) | |
tree | 5859964db8917a35ebb244a0114d5d3cf6578ae0 /src/net/tmwa/playerhandler.cpp | |
parent | 8871ef8ba38a11213de3cc7f35f5f9f0f3000dc0 (diff) | |
download | mv-7c6621108b54fd66fbb7aa87be067a34abcc3ced.tar.gz mv-7c6621108b54fd66fbb7aa87be067a34abcc3ced.tar.bz2 mv-7c6621108b54fd66fbb7aa87be067a34abcc3ced.tar.xz mv-7c6621108b54fd66fbb7aa87be067a34abcc3ced.zip |
Add server side online players list support.
Diffstat (limited to 'src/net/tmwa/playerhandler.cpp')
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index c34c661e8..20156d8cb 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -30,6 +30,8 @@ #include "net/tmwa/npchandler.h" #include "net/tmwa/inventoryhandler.h" +#include "gui/whoisonline.h" + #include "debug.h" extern Net::PlayerHandler *playerHandler; @@ -50,6 +52,7 @@ PlayerHandler::PlayerHandler() SMSG_PLAYER_STAT_UPDATE_5, SMSG_PLAYER_STAT_UPDATE_6, SMSG_PLAYER_ARROW_MESSAGE, + SMSG_ONLINE_LIST, 0 }; handledMessages = _messages; @@ -97,6 +100,9 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) processPlayerArrowMessage(msg); break; + case SMSG_ONLINE_LIST: + processOnlineList(msg); + default: break; } @@ -201,4 +207,39 @@ void PlayerHandler::respawn() outMsg.writeInt8(0); } +void PlayerHandler::requestOnlineList() +{ + MessageOut outMsg(CMSG_ONLINE_LIST); +} + +void PlayerHandler::processOnlineList(Net::MessageIn &msg) +{ + if (!whoIsOnline) + return; + + int size = msg.readInt16() - 4; + std::vector<std::string> arr; + + if (!size) + { + if (whoIsOnline) + whoIsOnline->loadList(arr); + return; + } + + const char *start = msg.readBytes(size); + const char *buf = start; + + while (buf - start + 1 < size && *(buf + 1)) + { + char status = *buf; // now unused + buf ++; + arr.push_back(buf); + buf += strlen(buf) + 1; + } + + if (whoIsOnline) + whoIsOnline->loadList(arr); +} + } // namespace TmwAthena |