summaryrefslogtreecommitdiff
path: root/src/net/eathena
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/eathena')
-rw-r--r--src/net/eathena/messagein.cpp7
-rw-r--r--src/net/eathena/messagein.h5
-rw-r--r--src/net/eathena/network.cpp6
-rw-r--r--src/net/eathena/packets.inc2
-rw-r--r--src/net/eathena/protocol.h2
-rw-r--r--src/net/eathena/recvpackets.h28
6 files changed, 42 insertions, 8 deletions
diff --git a/src/net/eathena/messagein.cpp b/src/net/eathena/messagein.cpp
index 03b8ddd3a..043f3f387 100644
--- a/src/net/eathena/messagein.cpp
+++ b/src/net/eathena/messagein.cpp
@@ -34,18 +34,19 @@
namespace EAthena
{
-MessageIn::MessageIn(const char *const data, const unsigned int length) :
+MessageIn::MessageIn(const char *const data,
+ const unsigned int length) :
Net::MessageIn(data, length)
{
}
-void MessageIn::postInit()
+void MessageIn::postInit(const char *const str)
{
// Read the message ID
mId = readId();
IGNOREDEBUGLOG;
DEBUGLOG2("Receive packet", 0, "MessageIn");
- readInt16("packet id");
+ readInt16(str);
}
uint16_t MessageIn::readId()
diff --git a/src/net/eathena/messagein.h b/src/net/eathena/messagein.h
index fb20b6db7..72110614f 100644
--- a/src/net/eathena/messagein.h
+++ b/src/net/eathena/messagein.h
@@ -41,11 +41,12 @@ class MessageIn final : public Net::MessageIn
/**
* Constructor.
*/
- MessageIn(const char *const data, const unsigned int length);
+ MessageIn(const char *const data,
+ const unsigned int length);
A_DELETE_COPY(MessageIn)
- void postInit();
+ void postInit(const char *const str);
/**< Reads a short. */
int16_t readInt16(const char *const str) override final;
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp
index 80f0f579b..83dfb0796 100644
--- a/src/net/eathena/network.cpp
+++ b/src/net/eathena/network.cpp
@@ -24,6 +24,8 @@
#include "logger.h"
+#include "net/packetinfo.h"
+
#include "net/eathena/messagehandler.h"
#include "net/eathena/messagein.h"
#include "net/eathena/packets.h"
@@ -47,6 +49,8 @@ Network::Network() :
{
mInstance = this;
memset(&mMessageHandlers[0], 0, sizeof(MessageHandler*) * 0xffff);
+ mPackets = new PacketInfo[messagesSize];
+#include "net/eathena/recvpackets.h"
}
Network::~Network()
@@ -105,7 +109,7 @@ void Network::dispatchMessages()
len = readWord(2);
MessageIn msg(mInBuffer, len);
- msg.postInit();
+ msg.postInit(mPackets[msgId].name);
SDL_mutexV(mMutexIn);
if (len == 0)
diff --git a/src/net/eathena/packets.inc b/src/net/eathena/packets.inc
index 6371807a5..2a2405674 100644
--- a/src/net/eathena/packets.inc
+++ b/src/net/eathena/packets.inc
@@ -729,3 +729,5 @@ packet(CMSG_SEARCHSTORE_CLICK, 0x0835);
packet(CMSG_SET_STATUS, 0x0b0e);
packet(CMSG_ONLINE_LIST, 0x0b0f);
+
+#undef packet
diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h
index 21dab17d7..b1e59d443 100644
--- a/src/net/eathena/protocol.h
+++ b/src/net/eathena/protocol.h
@@ -27,6 +27,4 @@
#include "net/eathena/packets.inc"
-#undef packet
-
#endif // NET_EATHENA_PROTOCOL_H
diff --git a/src/net/eathena/recvpackets.h b/src/net/eathena/recvpackets.h
new file mode 100644
index 000000000..e14b1252b
--- /dev/null
+++ b/src/net/eathena/recvpackets.h
@@ -0,0 +1,28 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NET_EATHENA_RECVPACKETS_H
+#define NET_EATHENA_RECVPACKETS_H
+
+#include "net/recvpacketdefine.h"
+
+#include "net/eathena/packets.inc"
+
+#endif // NET_EATHENA_RECVPACKETS_H