summaryrefslogtreecommitdiff
path: root/src/net/tmwa
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-31 19:59:51 +0300
committerAndrei Karas <akaras@inbox.ru>2015-09-01 00:19:20 +0300
commit854c72570f49f7ed57f35fce72bc91ebdc08d2ac (patch)
tree577c1b4ce129c52cabbb8665bf1b562a2e3d4f6c /src/net/tmwa
parent366de9963d24841483e6ed8ff4a88f775a1c2fcf (diff)
downloadManaVerse-854c72570f49f7ed57f35fce72bc91ebdc08d2ac.tar.gz
ManaVerse-854c72570f49f7ed57f35fce72bc91ebdc08d2ac.tar.bz2
ManaVerse-854c72570f49f7ed57f35fce72bc91ebdc08d2ac.tar.xz
ManaVerse-854c72570f49f7ed57f35fce72bc91ebdc08d2ac.zip
Add ability to log received packet names to log file.
Also add arrays with id to package info mapping for inbound packets.
Diffstat (limited to 'src/net/tmwa')
-rw-r--r--src/net/tmwa/messagein.cpp7
-rw-r--r--src/net/tmwa/messagein.h5
-rw-r--r--src/net/tmwa/network.cpp6
-rw-r--r--src/net/tmwa/packets.inc2
-rw-r--r--src/net/tmwa/protocol.h2
-rw-r--r--src/net/tmwa/recvpackets.h28
6 files changed, 42 insertions, 8 deletions
diff --git a/src/net/tmwa/messagein.cpp b/src/net/tmwa/messagein.cpp
index 3bb66c6f2..11dab0d38 100644
--- a/src/net/tmwa/messagein.cpp
+++ b/src/net/tmwa/messagein.cpp
@@ -34,18 +34,19 @@
namespace TmwAthena
{
-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/tmwa/messagein.h b/src/net/tmwa/messagein.h
index 7d27b1188..93cb6e092 100644
--- a/src/net/tmwa/messagein.h
+++ b/src/net/tmwa/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/tmwa/network.cpp b/src/net/tmwa/network.cpp
index 97bbcd9c0..8095c1251 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -24,6 +24,8 @@
#include "logger.h"
+#include "net/packetinfo.h"
+
#include "net/tmwa/messagehandler.h"
#include "net/tmwa/messagein.h"
#include "net/tmwa/packets.h"
@@ -47,6 +49,8 @@ Network::Network() :
{
mInstance = this;
memset(&mMessageHandlers[0], 0, sizeof(MessageHandler*) * 0xffff);
+ mPackets = new PacketInfo[messagesSize];
+#include "net/tmwa/recvpackets.h"
}
Network::~Network()
@@ -109,7 +113,7 @@ void Network::dispatchMessages()
len = readWord(2);
MessageIn msg(mInBuffer, len);
- msg.postInit();
+ msg.postInit(mPackets[msgId].name);
SDL_mutexV(mMutexIn);
BLOCK_END("Network::dispatchMessages 2")
BLOCK_START("Network::dispatchMessages 3")
diff --git a/src/net/tmwa/packets.inc b/src/net/tmwa/packets.inc
index b6402ed2b..3933b8379 100644
--- a/src/net/tmwa/packets.inc
+++ b/src/net/tmwa/packets.inc
@@ -294,3 +294,5 @@ packet(SMSG_BEING_MOVE3, 0x0225);
packet(SMSG_MAP_MUSIC, 0x0227);
packet(SMSG_NPC_CHANGETITLE, 0x0228);
packet(SMSG_SCRIPT_MESSAGE, 0x0229);
+
+#undef packet
diff --git a/src/net/tmwa/protocol.h b/src/net/tmwa/protocol.h
index 564dfb8a7..508507e0e 100644
--- a/src/net/tmwa/protocol.h
+++ b/src/net/tmwa/protocol.h
@@ -27,6 +27,4 @@
#include "net/tmwa/packets.inc"
-#undef packet
-
#endif // NET_TMWA_PROTOCOL_H
diff --git a/src/net/tmwa/recvpackets.h b/src/net/tmwa/recvpackets.h
new file mode 100644
index 000000000..59c12fec2
--- /dev/null
+++ b/src/net/tmwa/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_TMWA_RECVPACKETS_H
+#define NET_TMWA_RECVPACKETS_H
+
+#include "net/recvpacketdefine.h"
+
+#include "net/tmwa/packets.inc"
+
+#endif // NET_TMWA_RECVPACKETS_H