summaryrefslogtreecommitdiff
path: root/src/net/tmwa/playerrecv.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-11-12 20:54:12 +0300
committerAndrei Karas <akaras@inbox.ru>2018-11-12 20:54:12 +0300
commitaa4ebcf4adcd283b24317495655060abfb01ed55 (patch)
tree1ccc3779c44f32700263f791a006292415ef69c0 /src/net/tmwa/playerrecv.cpp
parent7c74a98fb966213ccbdba6e397a6d8a9502f2b17 (diff)
downloadplus-aa4ebcf4adcd283b24317495655060abfb01ed55.tar.gz
plus-aa4ebcf4adcd283b24317495655060abfb01ed55.tar.bz2
plus-aa4ebcf4adcd283b24317495655060abfb01ed55.tar.xz
plus-aa4ebcf4adcd283b24317495655060abfb01ed55.zip
Add support for online list in legacy server.
Diffstat (limited to 'src/net/tmwa/playerrecv.cpp')
-rw-r--r--src/net/tmwa/playerrecv.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/net/tmwa/playerrecv.cpp b/src/net/tmwa/playerrecv.cpp
index 844297b92..fb25aad2a 100644
--- a/src/net/tmwa/playerrecv.cpp
+++ b/src/net/tmwa/playerrecv.cpp
@@ -22,13 +22,21 @@
#include "net/tmwa/playerrecv.h"
+#include "configuration.h"
+
+#include "being/beingflag.h"
#include "being/localplayer.h"
#include "being/playerinfo.h"
+#include "gui/onlineplayer.h"
+
#include "gui/windows/statuswindow.h"
+#include "gui/windows/whoisonline.h"
#include "net/messagein.h"
+#include "resources/db/groupdb.h"
+
#include "debug.h"
namespace TmwAthena
@@ -185,4 +193,55 @@ void PlayerRecv::processWalkResponse(Net::MessageIn &msg)
BLOCK_END("PlayerRecv::processWalkResponse")
}
+void PlayerRecv::processOnlineList(Net::MessageIn &msg)
+{
+ if (whoIsOnline == nullptr)
+ return;
+
+ BLOCK_START("PlayerRecv::processOnlineList")
+ const int count = (msg.readInt16("len") - 4) / 31;
+ STD_VECTOR<OnlinePlayer*> arr;
+
+ if (count == 0)
+ {
+ if (whoIsOnline != nullptr)
+ whoIsOnline->loadList(arr);
+ BLOCK_END("PlayerRecv::processOnlineList")
+ return;
+ }
+
+ for (int f = 0; f < count; f ++)
+ {
+ msg.readBeingId("account id");
+ const std::string name = msg.readString(24, "name");
+ const unsigned char level = msg.readUInt8("level");
+ const unsigned char group = msg.readUInt8("group");
+ GenderT gender = static_cast<GenderT>(msg.readUInt8("gender"));
+ unsigned char status = 0;
+ switch (gender)
+ {
+ case Gender::MALE:
+ status |= BeingFlag::GENDER_MALE;
+ break;
+ case Gender::HIDDEN:
+ status |= BeingFlag::GENDER_HIDDEN;
+ break;
+ case Gender::FEMALE:
+ case Gender::UNSPECIFIED:
+ default:
+ break;
+ }
+ if (GroupDb::getShowBadge(group))
+ status |= BeingFlag::GM;
+ if (!config.getBoolValue("showgender"))
+ gender = Gender::UNSPECIFIED;
+ arr.push_back(new OnlinePlayer(name,
+ status, level, gender, 0));
+ }
+
+ if (whoIsOnline != nullptr)
+ whoIsOnline->loadList(arr);
+ BLOCK_END("PlayerRecv::processOnlineList")
+}
+
} // namespace TmwAthena