summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-09-01 23:08:32 +0300
committerAndrei Karas <akaras@inbox.ru>2015-09-01 23:16:32 +0300
commit53eede04dc83830481fa0981f47339e2c8072b42 (patch)
treec84798a327ee988afb9239cf27781ca538d18250
parent83915bb5c10c8b694e633b8e3089603d3281b8a0 (diff)
downloadmv-53eede04dc83830481fa0981f47339e2c8072b42.tar.gz
mv-53eede04dc83830481fa0981f47339e2c8072b42.tar.bz2
mv-53eede04dc83830481fa0981f47339e2c8072b42.tar.xz
mv-53eede04dc83830481fa0981f47339e2c8072b42.zip
Use packet sizes from packetsin.inc
-rw-r--r--src/net/eathena/network.cpp16
-rw-r--r--src/net/eathena/packetsin.inc2
-rw-r--r--src/net/recvpacketdefine.h3
-rw-r--r--src/net/tmwa/network.cpp7
4 files changed, 11 insertions, 17 deletions
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp
index ed6f6f1f7..75a737ad2 100644
--- a/src/net/eathena/network.cpp
+++ b/src/net/eathena/network.cpp
@@ -38,8 +38,7 @@
namespace EAthena
{
-static const unsigned int packet_lengths_size
- = static_cast<unsigned int>(sizeof(packet_lengths) / sizeof(int16_t));
+static const unsigned int packet_lengths_size = 0xFFFFU;
static const unsigned int messagesSize = 0xFFFFU;
Network *Network::mInstance = nullptr;
@@ -103,8 +102,7 @@ void Network::dispatchMessages()
const unsigned int msgId = readWord(0);
int len = -1;
if (msgId < packet_lengths_size)
- len = packet_lengths[msgId];
-
+ len = mPackets[msgId].len;
if (len == -1)
len = readWord(2);
@@ -144,14 +142,10 @@ bool Network::messageReady()
if (mInSize >= 2)
{
const int msgId = readWord(0);
- if (msgId == SMSG_SERVER_VERSION_RESPONSE)
- {
- len = 10;
- }
- else if (msgId >= 0 && static_cast<unsigned int>(msgId)
- < packet_lengths_size)
+ if (msgId >= 0 &&
+ static_cast<unsigned int>(msgId) < packet_lengths_size)
{
- len = packet_lengths[msgId];
+ len = mPackets[msgId].len;
}
if (len == -1 && mInSize > 4)
diff --git a/src/net/eathena/packetsin.inc b/src/net/eathena/packetsin.inc
index fc90d90e0..54f1ad2b9 100644
--- a/src/net/eathena/packetsin.inc
+++ b/src/net/eathena/packetsin.inc
@@ -381,7 +381,7 @@ packet(SMSG_SEARCHSTORE_OPEN, 0x083a, 5);
packet(SMSG_SEARCHSTORE_SEARCH_ACK, 0x0836, 0);
packet(SMSG_SEARCHSTORE_SEARCH_FAILED, 0x0837, 0);
packet(SMSG_SERVER_PING, 0x007f, 6);
-packet(SMSG_SERVER_VERSION_RESPONSE, 0x7531, 10);
+packet(SMSG_SERVER_VERSION_RESPONSE, 0x7531, -1);
packet(SMSG_SKILL_ARROW_CREATE_LIST, 0x01ad, -1);
packet(SMSG_SKILL_AUTO_CAST, 0x0147, 39);
packet(SMSG_SKILL_CASTING, 0x07fb, 25);
diff --git a/src/net/recvpacketdefine.h b/src/net/recvpacketdefine.h
index f043c2364..1e282d09c 100644
--- a/src/net/recvpacketdefine.h
+++ b/src/net/recvpacketdefine.h
@@ -21,6 +21,7 @@
#ifndef NET_RECVPACKETDEFINE_H
#define NET_RECVPACKETDEFINE_H
-#define packet(pname, pid, sz) mPackets[pid].name = #pname
+#define packet(pname, pid, sz) mPackets[pid].name = #pname; \
+ mPackets[pid].len = sz
#endif // NET_RECVPACKETDEFINE_H
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index 64f5047fe..0f9a43ef8 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -38,8 +38,7 @@
namespace TmwAthena
{
-static const unsigned int packet_lengths_size
- = static_cast<unsigned int>(sizeof(packet_lengths) / sizeof(int16_t));
+static const unsigned int packet_lengths_size = 0x0230U;
static const unsigned int messagesSize = 0xFFFFU;
Network *Network::mInstance = nullptr;
@@ -107,7 +106,7 @@ void Network::dispatchMessages()
if (msgId == SMSG_SERVER_VERSION_RESPONSE)
len = 10;
else if (msgId < packet_lengths_size)
- len = packet_lengths[msgId];
+ len = mPackets[msgId].len;
if (len == -1)
len = readWord(2);
@@ -164,7 +163,7 @@ bool Network::messageReady()
if (msgId >= 0 && static_cast<unsigned int>(msgId)
< packet_lengths_size)
{
- len = packet_lengths[msgId];
+ len = mPackets[msgId].len;
}
}