From b16e95ca94b709f6a19abedb51e2fb313422a4d5 Mon Sep 17 00:00:00 2001 From: David Athay Date: Mon, 15 Apr 2024 00:31:42 +0100 Subject: WIP: Create avatars and populate the online player list - Currently names are blank or mangled --- src/net/tmwa/playerlisthandler.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/net') diff --git a/src/net/tmwa/playerlisthandler.cpp b/src/net/tmwa/playerlisthandler.cpp index 530af4c7..fe0b7bab 100644 --- a/src/net/tmwa/playerlisthandler.cpp +++ b/src/net/tmwa/playerlisthandler.cpp @@ -24,8 +24,11 @@ #include "net/tmwa/messageout.h" #include "net/tmwa/protocol.h" +#include "gui/socialwindow.h" + #include "utils/gettext.h" +#include "avatar.h" #include "event.h" #include "log.h" @@ -53,8 +56,25 @@ void PlayerListHandler::handleMessage(MessageIn &msg) { case SMSG_ONLINE_LIST: { - SERVER_NOTICE(_("RECEIVED SMSG_ONLINE_LIST")) - logger->log("GOT SMSG_ONLINE_LIST"); + int length = msg.readInt16(); + int count = (length - 4) / 31; + std::vector onlineUsers; + + SERVER_NOTICE(strprintf(_("%d players online."), count)) + for (int i = 0; i < count; i++) + { + int id = msg.readInt32(); + std::string nick = msg.readString(24); + msg.readInt32(); // level + msg.readInt32(); // gm level + msg.readInt8(); // gender + + Avatar *avatar = new Avatar(nick); + avatar->setOnline(true); + onlineUsers.push_back(avatar); + } + + socialWindow->setPlayersOnline(onlineUsers); } break; } -- cgit v1.2.3-70-g09d2