summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/manaserv/playerhandler.cpp5
-rw-r--r--src/net/manaserv/playerhandler.h2
-rw-r--r--src/net/messagein.cpp25
-rw-r--r--src/net/messagein.h2
-rw-r--r--src/net/playerhandler.h2
-rw-r--r--src/net/tmwa/network.cpp2
-rw-r--r--src/net/tmwa/playerhandler.cpp41
-rw-r--r--src/net/tmwa/playerhandler.h2
-rw-r--r--src/net/tmwa/protocol.h2
9 files changed, 82 insertions, 1 deletions
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index da8958044..925938161 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -443,4 +443,9 @@ Vector PlayerHandler::getDefaultWalkSpeed() const
return ManaServ::BeingHandler::giveSpeedInPixelsPerTicks(6.0f);
}
+void PlayerHandler::requestOnlineList()
+{
+
+}
+
} // namespace ManaServ
diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h
index 21bbac516..c33eddc84 100644
--- a/src/net/manaserv/playerhandler.h
+++ b/src/net/manaserv/playerhandler.h
@@ -70,6 +70,8 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
int getJobLocation() const;
int getAttackLocation() const;
+ void requestOnlineList();
+
Vector getDefaultWalkSpeed() const;
private:
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 0fbf7162b..19453b745 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -241,4 +241,29 @@ std::string MessageIn::readRawString(int length)
return str;
}
+char *MessageIn::readBytes(int length)
+{
+ // Get string length
+ if (length < 0)
+ length = readInt16();
+
+ // Make sure the string isn't erroneous
+ if (length < 0 || mPos + length > mLength)
+ {
+ mPos = mLength + 1;
+ DEBUGLOG("readBytesString error");
+ return nullptr;
+ }
+
+ char *buf = new char[length + 2];
+
+ memcpy (buf, mData + mPos, length);
+ buf[length] = 0;
+ buf[length + 1] = 0;
+ mPos += length;
+
+ PacketCounters::incInBytes(length);
+ return buf;
+}
+
}
diff --git a/src/net/messagein.h b/src/net/messagein.h
index 6d7038d4a..ed143a213 100644
--- a/src/net/messagein.h
+++ b/src/net/messagein.h
@@ -95,6 +95,8 @@ class MessageIn
virtual std::string readRawString(int length);
+ char *readBytes(int length);
+
virtual ~MessageIn()
{ }
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index 47d666036..4f1ed8f00 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -71,6 +71,8 @@ class PlayerHandler
virtual int getAttackLocation() const = 0;
virtual Vector getDefaultWalkSpeed() const = 0;
+
+ virtual void requestOnlineList() = 0;
};
} // namespace Net
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index 3181ec898..db006c5c0 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -83,7 +83,7 @@ short packet_lengths[] =
-1, -1, 20, 10, 32, 9, 34, 14, 2, 6, 48, 56, -1, 4, 5, 10,
// #0x0200
26, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 19, 10, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-1, 122, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
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
diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h
index bf8e861ff..898bdae3d 100644
--- a/src/net/tmwa/playerhandler.h
+++ b/src/net/tmwa/playerhandler.h
@@ -51,6 +51,8 @@ class PlayerHandler : public MessageHandler, public Ea::PlayerHandler
void setDirection(char direction);
void setDestination(int x, int y, int direction = -1);
void changeAction(Being::Action action);
+ void processOnlineList(Net::MessageIn &msg);
+ void requestOnlineList();
void respawn();
};
diff --git a/src/net/tmwa/protocol.h b/src/net/tmwa/protocol.h
index caf3c8e53..37f036ca8 100644
--- a/src/net/tmwa/protocol.h
+++ b/src/net/tmwa/protocol.h
@@ -333,5 +333,7 @@ enum
#define SMSG_PVP_SET 0x019a
#define CMSG_IGNORE_ALL 0x00d0
#define SMSG_IGNORE_ALL_RESPONSE 0x00d2
+#define CMSG_ONLINE_LIST 0x0210
+#define SMSG_ONLINE_LIST 0x0211
#endif