summaryrefslogtreecommitdiff
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
parent7c74a98fb966213ccbdba6e397a6d8a9502f2b17 (diff)
downloadmv-aa4ebcf4adcd283b24317495655060abfb01ed55.tar.gz
mv-aa4ebcf4adcd283b24317495655060abfb01ed55.tar.bz2
mv-aa4ebcf4adcd283b24317495655060abfb01ed55.tar.xz
mv-aa4ebcf4adcd283b24317495655060abfb01ed55.zip
Add support for online list in legacy server.
-rw-r--r--src/net/tmwa/packetsin.inc1
-rw-r--r--src/net/tmwa/packetsout.inc2
-rw-r--r--src/net/tmwa/playerhandler.cpp1
-rw-r--r--src/net/tmwa/playerrecv.cpp59
-rw-r--r--src/net/tmwa/playerrecv.h1
-rw-r--r--src/net/tmwa/serverfeatures.cpp2
6 files changed, 65 insertions, 1 deletions
diff --git a/src/net/tmwa/packetsin.inc b/src/net/tmwa/packetsin.inc
index 5681a2792..22d2df0b4 100644
--- a/src/net/tmwa/packetsin.inc
+++ b/src/net/tmwa/packetsin.inc
@@ -145,3 +145,4 @@ packet(SMSG_WHO_ANSWER, 0x00c2, 6, &Ea::GameRecv::processWh
packet(SMSG_MAP_MASK, 0x0226, 10, &Ea::PlayerRecv::processMapMask, 0);
packet(SMSG_PLAYER_CLIENT_COMMAND, 0x0230, -1, &Ea::PlayerRecv::processPlayerClientCommand, 0);
packet(SMSG_MAP_SET_TILES_TYPE, 0x0231, 34, &Ea::MapRecv::processSetTilesType, 0);
+packet(SMSG_ONLINE_LIST, 0x0211, -1, &PlayerRecv::processOnlineList, 0);
diff --git a/src/net/tmwa/packetsout.inc b/src/net/tmwa/packetsout.inc
index eceb2da78..814f87caa 100644
--- a/src/net/tmwa/packetsout.inc
+++ b/src/net/tmwa/packetsout.inc
@@ -105,6 +105,8 @@ packet(CMSG_IGNORE_NICK, 0x00cf, 0, nullptr);
packet(CMSG_CLIENT_DISCONNECT, 0x7532, 0, nullptr);
packet(CMSG_IGNORE_ALL, 0x00d0, 0, nullptr);
+packet(CMSG_ONLINE_LIST, 0x0210, 0, nullptr);
+
#ifdef PACKETS_UPDATE
// condition code here
#endif
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index 834b75e1d..301f851a9 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -162,6 +162,7 @@ void PlayerHandler::respawn() const
void PlayerHandler::requestOnlineList() const
{
+ createOutPacket(CMSG_ONLINE_LIST);
}
void PlayerHandler::removeOption() const
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
diff --git a/src/net/tmwa/playerrecv.h b/src/net/tmwa/playerrecv.h
index fb4998028..4a49f0254 100644
--- a/src/net/tmwa/playerrecv.h
+++ b/src/net/tmwa/playerrecv.h
@@ -34,6 +34,7 @@ namespace TmwAthena
{
void processPlayerStatUpdate5(Net::MessageIn &msg);
void processWalkResponse(Net::MessageIn &msg);
+ void processOnlineList(Net::MessageIn &msg);
} // namespace PlayerRecv
} // namespace TmwAthena
diff --git a/src/net/tmwa/serverfeatures.cpp b/src/net/tmwa/serverfeatures.cpp
index db70d836f..caa5c2785 100644
--- a/src/net/tmwa/serverfeatures.cpp
+++ b/src/net/tmwa/serverfeatures.cpp
@@ -35,7 +35,7 @@ ServerFeatures::ServerFeatures() :
bool ServerFeatures::haveServerOnlineList() const
{
- return false;
+ return tmwServerVersion > 0x120b0b;
}
bool ServerFeatures::haveServerHp() const