diff options
author | David Athay <ko2fan@gmail.com> | 2024-06-25 23:05:31 +0000 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-06-25 23:05:31 +0000 |
commit | 452ebe4c4a0199fd07848a27f176723d3acf5704 (patch) | |
tree | 438fba5b1fa68b79b76cd7dc6a6b3036a22add13 /src/net/tmwa/chathandler.cpp | |
parent | cd6a29b5e50e26d03436e18e52fd0bb7a7f60bb9 (diff) | |
download | mana-452ebe4c4a0199fd07848a27f176723d3acf5704.tar.gz mana-452ebe4c4a0199fd07848a27f176723d3acf5704.tar.bz2 mana-452ebe4c4a0199fd07848a27f176723d3acf5704.tar.xz mana-452ebe4c4a0199fd07848a27f176723d3acf5704.zip |
Added online player list to Social window
The online list refreshes every 18 seconds, which matches ManaVerse
behavior. It's not ideal, but to improve this would mean diving into
TMWA.
The client version was bumped to 8 to get a SMSG_ONLINE_LIST reply.
Further changes needed related to the client version are tracked by #71.
This also changes the TabbedArea to take into account the frame size for
its tab widgets, to make sure those frames are not clipped by the
TabbedArea widget (as happened in the Social window).
The horizontal scroll bar is now disabled in all social tabs, with the
vertical one appearing only when necessary.
Closes #61
Diffstat (limited to 'src/net/tmwa/chathandler.cpp')
-rw-r--r-- | src/net/tmwa/chathandler.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index a1e2d375..5d9a0e21 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -22,11 +22,14 @@ #include "net/tmwa/chathandler.h" #include "actorspritemanager.h" +#include "avatar.h" #include "being.h" #include "event.h" #include "localplayer.h" #include "playerrelations.h" +#include "gui/socialwindow.h" + #include "net/tmwa/loginhandler.h" #include "net/tmwa/messagein.h" #include "net/tmwa/messageout.h" @@ -50,6 +53,7 @@ ChatHandler::ChatHandler() SMSG_WHISPER_RESPONSE, SMSG_GM_CHAT, SMSG_SCRIPT_MESSAGE, + SMSG_ONLINE_LIST, 0 }; handledMessages = _messages; @@ -252,6 +256,31 @@ void ChatHandler::handleMessage(MessageIn &msg) SERVER_NOTICE(msg.readString(chatMsgLength)) break; } + + case SMSG_ONLINE_LIST: + { + int length = msg.readInt16(); + int count = (length - 4) / 31; + std::vector<Avatar*> players; + + for (int i = 0; i < count; i++) + { + msg.readInt32(); // account id + std::string nick = msg.readString(24); + msg.readInt8(); // level + msg.readInt8(); // gm level + msg.readInt8(); // gender + + Avatar *avatar = new Avatar(nick); + avatar->setOnline(true); + players.push_back(avatar); + } + + socialWindow->setPlayersOnline(players); + + break; + } + } } @@ -332,4 +361,9 @@ void ChatHandler::kickUser(int channelId, const std::string &name) SERVER_NOTICE(_("Channels are not supported!")) } +void ChatHandler::requestOnlineList() +{ + MessageOut outMsg(CMSG_ONLINE_LIST); +} + } // namespace TmwAthena |