summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-04-08 17:37:02 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-05-05 22:30:00 +0200
commit96abc4a9658b3318d0052dc5cd31a3c15d76a494 (patch)
treeff1d8e02b5020a08c01ab1605b0474a48eb77c42
parente9eda63dcad0b842d637c13e415ef4f751ea2adf (diff)
downloadmana-client-96abc4a9658b3318d0052dc5cd31a3c15d76a494.tar.gz
mana-client-96abc4a9658b3318d0052dc5cd31a3c15d76a494.tar.bz2
mana-client-96abc4a9658b3318d0052dc5cd31a3c15d76a494.tar.xz
mana-client-96abc4a9658b3318d0052dc5cd31a3c15d76a494.zip
Removed the shared base classes of MessageIn and MessageOut
There wasn't a whole lot gained by sharing a common base class, and it makes extending the manaserv Message{In,Out} classes with a debugging mode unnecessarily complicated. Reviewed-by: Yohann Ferreira
-rw-r--r--mana.cbp4
-rw-r--r--mana.files4
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/gui/charcreatedialog.cpp1
-rw-r--r--src/gui/charselectdialog.cpp1
-rw-r--r--src/net/manaserv/adminhandler.cpp2
-rw-r--r--src/net/manaserv/adminhandler.h2
-rw-r--r--src/net/manaserv/beinghandler.cpp22
-rw-r--r--src/net/manaserv/beinghandler.h18
-rw-r--r--src/net/manaserv/buysellhandler.cpp6
-rw-r--r--src/net/manaserv/buysellhandler.h2
-rw-r--r--src/net/manaserv/charhandler.cpp10
-rw-r--r--src/net/manaserv/charhandler.h10
-rw-r--r--src/net/manaserv/chathandler.cpp22
-rw-r--r--src/net/manaserv/chathandler.h22
-rw-r--r--src/net/manaserv/effecthandler.cpp11
-rw-r--r--src/net/manaserv/effecthandler.h8
-rw-r--r--src/net/manaserv/gamehandler.cpp3
-rw-r--r--src/net/manaserv/gamehandler.h2
-rw-r--r--src/net/manaserv/guildhandler.cpp5
-rw-r--r--src/net/manaserv/guildhandler.h4
-rw-r--r--src/net/manaserv/inventoryhandler.cpp2
-rw-r--r--src/net/manaserv/inventoryhandler.h2
-rw-r--r--src/net/manaserv/itemhandler.cpp2
-rw-r--r--src/net/manaserv/itemhandler.h2
-rw-r--r--src/net/manaserv/loginhandler.cpp10
-rw-r--r--src/net/manaserv/loginhandler.h10
-rw-r--r--src/net/manaserv/messagehandler.cpp2
-rw-r--r--src/net/manaserv/messagehandler.h7
-rw-r--r--src/net/manaserv/messagein.cpp37
-rw-r--r--src/net/manaserv/messagein.h55
-rw-r--r--src/net/manaserv/messageout.cpp38
-rw-r--r--src/net/manaserv/messageout.h46
-rw-r--r--src/net/manaserv/npchandler.cpp2
-rw-r--r--src/net/manaserv/npchandler.h2
-rw-r--r--src/net/manaserv/partyhandler.cpp2
-rw-r--r--src/net/manaserv/partyhandler.h2
-rw-r--r--src/net/manaserv/playerhandler.cpp4
-rw-r--r--src/net/manaserv/playerhandler.h4
-rw-r--r--src/net/manaserv/specialhandler.cpp2
-rw-r--r--src/net/manaserv/specialhandler.h2
-rw-r--r--src/net/manaserv/tradehandler.cpp2
-rw-r--r--src/net/manaserv/tradehandler.h2
-rw-r--r--src/net/messagehandler.h8
-rw-r--r--src/net/messagein.cpp162
-rw-r--r--src/net/messagein.h118
-rw-r--r--src/net/messageout.cpp79
-rw-r--r--src/net/messageout.h90
-rw-r--r--src/net/tmwa/adminhandler.cpp4
-rw-r--r--src/net/tmwa/adminhandler.h2
-rw-r--r--src/net/tmwa/beinghandler.cpp4
-rw-r--r--src/net/tmwa/beinghandler.h2
-rw-r--r--src/net/tmwa/buysellhandler.cpp5
-rw-r--r--src/net/tmwa/buysellhandler.h2
-rw-r--r--src/net/tmwa/charserverhandler.cpp8
-rw-r--r--src/net/tmwa/charserverhandler.h4
-rw-r--r--src/net/tmwa/chathandler.cpp7
-rw-r--r--src/net/tmwa/chathandler.h2
-rw-r--r--src/net/tmwa/gamehandler.cpp7
-rw-r--r--src/net/tmwa/gamehandler.h2
-rw-r--r--src/net/tmwa/generalhandler.cpp6
-rw-r--r--src/net/tmwa/generalhandler.h2
-rw-r--r--src/net/tmwa/guildhandler.cpp3
-rw-r--r--src/net/tmwa/guildhandler.h2
-rw-r--r--src/net/tmwa/inventoryhandler.cpp7
-rw-r--r--src/net/tmwa/inventoryhandler.h2
-rw-r--r--src/net/tmwa/itemhandler.cpp5
-rw-r--r--src/net/tmwa/itemhandler.h2
-rw-r--r--src/net/tmwa/loginhandler.cpp6
-rw-r--r--src/net/tmwa/loginhandler.h2
-rw-r--r--src/net/tmwa/messagehandler.h6
-rw-r--r--src/net/tmwa/messagein.cpp120
-rw-r--r--src/net/tmwa/messagein.h73
-rw-r--r--src/net/tmwa/messageout.cpp45
-rw-r--r--src/net/tmwa/messageout.h48
-rw-r--r--src/net/tmwa/network.cpp2
-rw-r--r--src/net/tmwa/npchandler.cpp6
-rw-r--r--src/net/tmwa/npchandler.h2
-rw-r--r--src/net/tmwa/partyhandler.cpp7
-rw-r--r--src/net/tmwa/partyhandler.h2
-rw-r--r--src/net/tmwa/playerhandler.cpp7
-rw-r--r--src/net/tmwa/playerhandler.h2
-rw-r--r--src/net/tmwa/specialhandler.cpp7
-rw-r--r--src/net/tmwa/specialhandler.h2
-rw-r--r--src/net/tmwa/tradehandler.cpp6
-rw-r--r--src/net/tmwa/tradehandler.h2
86 files changed, 612 insertions, 668 deletions
diff --git a/mana.cbp b/mana.cbp
index 3e0ad895..a1d92c44 100644
--- a/mana.cbp
+++ b/mana.cbp
@@ -443,10 +443,6 @@
<Unit filename="src\net\manaserv\tradehandler.cpp" />
<Unit filename="src\net\manaserv\tradehandler.h" />
<Unit filename="src\net\messagehandler.h" />
- <Unit filename="src\net\messagein.cpp" />
- <Unit filename="src\net\messagein.h" />
- <Unit filename="src\net\messageout.cpp" />
- <Unit filename="src\net\messageout.h" />
<Unit filename="src\net\net.cpp" />
<Unit filename="src\net\net.h" />
<Unit filename="src\net\npchandler.h" />
diff --git a/mana.files b/mana.files
index 636a7b15..b2d0578c 100644
--- a/mana.files
+++ b/mana.files
@@ -389,10 +389,6 @@ src/net/manaserv/specialhandler.h
src/net/manaserv/tradehandler.cpp
src/net/manaserv/tradehandler.h
src/net/messagehandler.h
-src/net/messagein.cpp
-src/net/messagein.h
-src/net/messageout.cpp
-src/net/messageout.h
src/net/net.cpp
src/net/net.h
src/net/npchandler.h
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e0a42478..45b58ac0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -350,10 +350,6 @@ SET(SRCS
net/logindata.h
net/loginhandler.h
net/messagehandler.h
- net/messagein.cpp
- net/messagein.h
- net/messageout.cpp
- net/messageout.h
net/npchandler.h
net/net.cpp
net/net.h
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index 84bce434..8fee148b 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -39,7 +39,6 @@
#include "gui/widgets/textfield.h"
#include "net/charhandler.h"
-#include "net/messageout.h"
#include "net/net.h"
#include "resources/hairdb.h"
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index a806fa96..1850eb9d 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -46,7 +46,6 @@
#include "net/charhandler.h"
#include "net/logindata.h"
#include "net/loginhandler.h"
-#include "net/messageout.h"
#include "net/net.h"
#include "resources/hairdb.h"
diff --git a/src/net/manaserv/adminhandler.cpp b/src/net/manaserv/adminhandler.cpp
index ab49037d..8928a33d 100644
--- a/src/net/manaserv/adminhandler.cpp
+++ b/src/net/manaserv/adminhandler.cpp
@@ -41,7 +41,7 @@ AdminHandler::AdminHandler()
adminHandler = this;
}
-void AdminHandler::handleMessage(Net::MessageIn &msg)
+void AdminHandler::handleMessage(MessageIn &msg)
{
}
diff --git a/src/net/manaserv/adminhandler.h b/src/net/manaserv/adminhandler.h
index 9c68c620..83fbb854 100644
--- a/src/net/manaserv/adminhandler.h
+++ b/src/net/manaserv/adminhandler.h
@@ -33,7 +33,7 @@ class AdminHandler : public Net::AdminHandler, public MessageHandler
public:
AdminHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void announce(const std::string &text);
diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp
index b319fa37..b744e53c 100644
--- a/src/net/manaserv/beinghandler.cpp
+++ b/src/net/manaserv/beinghandler.cpp
@@ -32,9 +32,9 @@
#include "gui/okdialog.h"
#include "net/net.h"
-#include "net/messagein.h"
#include "net/manaserv/inventoryhandler.h"
+#include "net/manaserv/messagein.h"
#include "net/manaserv/playerhandler.h"
#include "net/manaserv/manaserv_protocol.h"
@@ -62,7 +62,7 @@ BeingHandler::BeingHandler()
handledMessages = _messages;
}
-void BeingHandler::handleMessage(Net::MessageIn &msg)
+void BeingHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
@@ -93,7 +93,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
}
}
-static void handleLooks(Being *being, Net::MessageIn &msg)
+static void handleLooks(Being *being, MessageIn &msg)
{
int lookChanges = msg.readInt8();
@@ -109,7 +109,7 @@ static void handleLooks(Being *being, Net::MessageIn &msg)
}
}
-void BeingHandler::handleBeingEnterMessage(Net::MessageIn &msg)
+void BeingHandler::handleBeingEnterMessage(MessageIn &msg)
{
int type = msg.readInt8();
int id = msg.readInt16();
@@ -165,7 +165,7 @@ void BeingHandler::handleBeingEnterMessage(Net::MessageIn &msg)
being->setAction(action);
}
-void BeingHandler::handleBeingLeaveMessage(Net::MessageIn &msg)
+void BeingHandler::handleBeingLeaveMessage(MessageIn &msg)
{
Being *being = actorSpriteManager->findBeing(msg.readInt16());
if (!being)
@@ -174,7 +174,7 @@ void BeingHandler::handleBeingLeaveMessage(Net::MessageIn &msg)
actorSpriteManager->destroy(being);
}
-void BeingHandler::handleBeingsMoveMessage(Net::MessageIn &msg)
+void BeingHandler::handleBeingsMoveMessage(MessageIn &msg)
{
while (msg.getUnreadLength())
{
@@ -233,7 +233,7 @@ void BeingHandler::handleBeingsMoveMessage(Net::MessageIn &msg)
}
}
-void BeingHandler::handleBeingAttackMessage(Net::MessageIn &msg)
+void BeingHandler::handleBeingAttackMessage(MessageIn &msg)
{
Being *being = actorSpriteManager->findBeing(msg.readInt16());
const BeingDirection direction = (BeingDirection) msg.readInt8();
@@ -247,7 +247,7 @@ void BeingHandler::handleBeingAttackMessage(Net::MessageIn &msg)
being->setAction(Being::ATTACK, attackId);
}
-void BeingHandler::handleBeingsDamageMessage(Net::MessageIn &msg)
+void BeingHandler::handleBeingsDamageMessage(MessageIn &msg)
{
while (msg.getUnreadLength())
{
@@ -260,7 +260,7 @@ void BeingHandler::handleBeingsDamageMessage(Net::MessageIn &msg)
}
}
-void BeingHandler::handleBeingActionChangeMessage(Net::MessageIn &msg)
+void BeingHandler::handleBeingActionChangeMessage(MessageIn &msg)
{
Being *being = actorSpriteManager->findBeing(msg.readInt16());
Being::Action action = (Being::Action) msg.readInt8();
@@ -299,7 +299,7 @@ void BeingHandler::handleBeingActionChangeMessage(Net::MessageIn &msg)
}
}
-void BeingHandler::handleBeingLooksChangeMessage(Net::MessageIn &msg)
+void BeingHandler::handleBeingLooksChangeMessage(MessageIn &msg)
{
Being *being = actorSpriteManager->findBeing(msg.readInt16());
if (!being || being->getType() != ActorSprite::PLAYER)
@@ -314,7 +314,7 @@ void BeingHandler::handleBeingLooksChangeMessage(Net::MessageIn &msg)
}
}
-void BeingHandler::handleBeingDirChangeMessage(Net::MessageIn &msg)
+void BeingHandler::handleBeingDirChangeMessage(MessageIn &msg)
{
Being *being = actorSpriteManager->findBeing(msg.readInt16());
if (!being)
diff --git a/src/net/manaserv/beinghandler.h b/src/net/manaserv/beinghandler.h
index f33afbc1..94cf20c4 100644
--- a/src/net/manaserv/beinghandler.h
+++ b/src/net/manaserv/beinghandler.h
@@ -43,17 +43,17 @@ class BeingHandler : public MessageHandler
public:
BeingHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
private:
- void handleBeingAttackMessage(Net::MessageIn &msg);
- void handleBeingEnterMessage(Net::MessageIn &msg);
- void handleBeingLeaveMessage(Net::MessageIn &msg);
- void handleBeingsMoveMessage(Net::MessageIn &msg);
- void handleBeingsDamageMessage(Net::MessageIn &msg);
- void handleBeingActionChangeMessage(Net::MessageIn &msg);
- void handleBeingLooksChangeMessage(Net::MessageIn &msg);
- void handleBeingDirChangeMessage(Net::MessageIn &msg);
+ void handleBeingAttackMessage(MessageIn &msg);
+ void handleBeingEnterMessage(MessageIn &msg);
+ void handleBeingLeaveMessage(MessageIn &msg);
+ void handleBeingsMoveMessage(MessageIn &msg);
+ void handleBeingsDamageMessage(MessageIn &msg);
+ void handleBeingActionChangeMessage(MessageIn &msg);
+ void handleBeingLooksChangeMessage(MessageIn &msg);
+ void handleBeingDirChangeMessage(MessageIn &msg);
};
} // namespace ManaServ
diff --git a/src/net/manaserv/buysellhandler.cpp b/src/net/manaserv/buysellhandler.cpp
index f9ebb147..2e7cf26d 100644
--- a/src/net/manaserv/buysellhandler.cpp
+++ b/src/net/manaserv/buysellhandler.cpp
@@ -28,10 +28,8 @@
#include "gui/buydialog.h"
#include "gui/selldialog.h"
-#include "net/messagein.h"
-
#include "net/manaserv/manaserv_protocol.h"
-
+#include "net/manaserv/messagein.h"
namespace ManaServ {
@@ -45,7 +43,7 @@ BuySellHandler::BuySellHandler()
handledMessages = _messages;
}
-void BuySellHandler::handleMessage(Net::MessageIn &msg)
+void BuySellHandler::handleMessage(MessageIn &msg)
{
Being *being = actorSpriteManager->findBeing(msg.readInt16());
if (!being || being->getType() != ActorSprite::NPC)
diff --git a/src/net/manaserv/buysellhandler.h b/src/net/manaserv/buysellhandler.h
index f7c7e1f7..88432842 100644
--- a/src/net/manaserv/buysellhandler.h
+++ b/src/net/manaserv/buysellhandler.h
@@ -31,7 +31,7 @@ class BuySellHandler : public MessageHandler
public:
BuySellHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
};
} // namespace ManaServ
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp
index c05e9320..e809bfac 100644
--- a/src/net/manaserv/charhandler.cpp
+++ b/src/net/manaserv/charhandler.cpp
@@ -76,7 +76,7 @@ CharHandler::~CharHandler()
clear();
}
-void CharHandler::handleMessage(Net::MessageIn &msg)
+void CharHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
@@ -98,7 +98,7 @@ void CharHandler::handleMessage(Net::MessageIn &msg)
}
}
-void CharHandler::handleCharacterInfo(Net::MessageIn &msg)
+void CharHandler::handleCharacterInfo(MessageIn &msg)
{
CachedCharacterInfo info;
info.slot = msg.readInt8();
@@ -126,7 +126,7 @@ void CharHandler::handleCharacterInfo(Net::MessageIn &msg)
updateCharacters();
}
-void CharHandler::handleCharacterCreateResponse(Net::MessageIn &msg)
+void CharHandler::handleCharacterCreateResponse(MessageIn &msg)
{
const int errMsg = msg.readInt8();
@@ -192,7 +192,7 @@ void CharHandler::handleCharacterCreateResponse(Net::MessageIn &msg)
}
}
-void CharHandler::handleCharacterDeleteResponse(Net::MessageIn &msg)
+void CharHandler::handleCharacterDeleteResponse(MessageIn &msg)
{
int errMsg = msg.readInt8();
if (errMsg == ERRMSG_OK)
@@ -232,7 +232,7 @@ void CharHandler::handleCharacterDeleteResponse(Net::MessageIn &msg)
unlockCharSelectDialog();
}
-void CharHandler::handleCharacterSelectResponse(Net::MessageIn &msg)
+void CharHandler::handleCharacterSelectResponse(MessageIn &msg)
{
int errMsg = msg.readInt8();
diff --git a/src/net/manaserv/charhandler.h b/src/net/manaserv/charhandler.h
index e3098c09..d2159204 100644
--- a/src/net/manaserv/charhandler.h
+++ b/src/net/manaserv/charhandler.h
@@ -44,7 +44,7 @@ class CharHandler : public MessageHandler, public Net::CharHandler
~CharHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void setCharSelectDialog(CharSelectDialog *window);
@@ -108,10 +108,10 @@ class CharHandler : public MessageHandler, public Net::CharHandler
CachedAttributes attribute;
};
- void handleCharacterInfo(Net::MessageIn &msg);
- void handleCharacterCreateResponse(Net::MessageIn &msg);
- void handleCharacterDeleteResponse(Net::MessageIn &msg);
- void handleCharacterSelectResponse(Net::MessageIn &msg);
+ void handleCharacterInfo(MessageIn &msg);
+ void handleCharacterCreateResponse(MessageIn &msg);
+ void handleCharacterDeleteResponse(MessageIn &msg);
+ void handleCharacterSelectResponse(MessageIn &msg);
void updateCharacters();
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index 8241baa7..d777fa35 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -74,7 +74,7 @@ ChatHandler::ChatHandler()
chatHandler = this;
}
-void ChatHandler::handleMessage(Net::MessageIn &msg)
+void ChatHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
@@ -143,7 +143,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
}
}
-void ChatHandler::handleGameChatMessage(Net::MessageIn &msg)
+void ChatHandler::handleGameChatMessage(MessageIn &msg)
{
short id = msg.readInt16();
std::string chatMsg = msg.readString();
@@ -177,7 +177,7 @@ void ChatHandler::handleGameChatMessage(Net::MessageIn &msg)
event.trigger(Event::ChatChannel);
}
-void ChatHandler::handleEnterChannelResponse(Net::MessageIn &msg)
+void ChatHandler::handleEnterChannelResponse(MessageIn &msg)
{
if (msg.readInt8() == ERRMSG_OK)
{
@@ -212,7 +212,7 @@ void ChatHandler::handleEnterChannelResponse(Net::MessageIn &msg)
}
}
-void ChatHandler::handleListChannelsResponse(Net::MessageIn &msg)
+void ChatHandler::handleListChannelsResponse(MessageIn &msg)
{
SERVER_NOTICE(_("Listing channels."))
while (msg.getUnreadLength())
@@ -229,7 +229,7 @@ void ChatHandler::handleListChannelsResponse(Net::MessageIn &msg)
SERVER_NOTICE(_("End of channel list."))
}
-void ChatHandler::handlePrivateMessage(Net::MessageIn &msg)
+void ChatHandler::handlePrivateMessage(MessageIn &msg)
{
std::string userNick = msg.readString();
std::string chatMsg = msg.readString();
@@ -240,7 +240,7 @@ void ChatHandler::handlePrivateMessage(Net::MessageIn &msg)
event.trigger(Event::ChatChannel);
}
-void ChatHandler::handleAnnouncement(Net::MessageIn &msg)
+void ChatHandler::handleAnnouncement(MessageIn &msg)
{
std::string chatMsg = msg.readString();
std::string sender = msg.readString();
@@ -249,7 +249,7 @@ void ChatHandler::handleAnnouncement(Net::MessageIn &msg)
event.trigger(Event::ChatChannel);
}
-void ChatHandler::handleChatMessage(Net::MessageIn &msg)
+void ChatHandler::handleChatMessage(MessageIn &msg)
{
short channelId = msg.readInt16();
std::string userNick = msg.readString();
@@ -266,7 +266,7 @@ void ChatHandler::handleChatMessage(Net::MessageIn &msg)
}
}
-void ChatHandler::handleQuitChannelResponse(Net::MessageIn &msg)
+void ChatHandler::handleQuitChannelResponse(MessageIn &msg)
{
if (msg.readInt8() == ERRMSG_OK)
{
@@ -276,7 +276,7 @@ void ChatHandler::handleQuitChannelResponse(Net::MessageIn &msg)
}
}
-void ChatHandler::handleListChannelUsersResponse(Net::MessageIn &msg)
+void ChatHandler::handleListChannelUsersResponse(MessageIn &msg)
{
std::string channelName = msg.readString();
std::string userNick;
@@ -299,7 +299,7 @@ void ChatHandler::handleListChannelUsersResponse(Net::MessageIn &msg)
}
}
-void ChatHandler::handleChannelEvent(Net::MessageIn &msg)
+void ChatHandler::handleChannelEvent(MessageIn &msg)
{
short channelId = msg.readInt16();
char eventId = msg.readInt8();
@@ -353,7 +353,7 @@ void ChatHandler::handleChannelEvent(Net::MessageIn &msg)
}
}
-void ChatHandler::handleWhoResponse(Net::MessageIn &msg)
+void ChatHandler::handleWhoResponse(MessageIn &msg)
{
std::string userNick;
diff --git a/src/net/manaserv/chathandler.h b/src/net/manaserv/chathandler.h
index e0288412..7ae4227b 100644
--- a/src/net/manaserv/chathandler.h
+++ b/src/net/manaserv/chathandler.h
@@ -37,7 +37,7 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler
/**
* Handle the given message appropriately.
*/
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void connect();
@@ -75,52 +75,52 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler
/**
* Handle chat messages sent from the game server.
*/
- void handleGameChatMessage(Net::MessageIn &msg);
+ void handleGameChatMessage(MessageIn &msg);
/**
* Handle channel entry responses.
*/
- void handleEnterChannelResponse(Net::MessageIn &msg);
+ void handleEnterChannelResponse(MessageIn &msg);
/**
* Handle list channels responses.
*/
- void handleListChannelsResponse(Net::MessageIn &msg);
+ void handleListChannelsResponse(MessageIn &msg);
/**
* Handle private messages.
*/
- void handlePrivateMessage(Net::MessageIn &msg);
+ void handlePrivateMessage(MessageIn &msg);
/**
* Handle announcements.
*/
- void handleAnnouncement(Net::MessageIn &msg);
+ void handleAnnouncement(MessageIn &msg);
/**
* Handle chat messages.
*/
- void handleChatMessage(Net::MessageIn &msg);
+ void handleChatMessage(MessageIn &msg);
/**
* Handle quit channel responses.
*/
- void handleQuitChannelResponse(Net::MessageIn &msg);
+ void handleQuitChannelResponse(MessageIn &msg);
/**
* Handle list channel users responses.
*/
- void handleListChannelUsersResponse(Net::MessageIn &msg);
+ void handleListChannelUsersResponse(MessageIn &msg);
/**
* Handle channel events.
*/
- void handleChannelEvent(Net::MessageIn &msg);
+ void handleChannelEvent(MessageIn &msg);
/**
* Handle who responses.
*/
- void handleWhoResponse(Net::MessageIn &msg);
+ void handleWhoResponse(MessageIn &msg);
};
} // namespace ManaServ
diff --git a/src/net/manaserv/effecthandler.cpp b/src/net/manaserv/effecthandler.cpp
index 06533be6..d0aaf081 100644
--- a/src/net/manaserv/effecthandler.cpp
+++ b/src/net/manaserv/effecthandler.cpp
@@ -27,9 +27,8 @@
#include "gui/viewport.h"
-#include "net/messagein.h"
-
#include "net/manaserv/manaserv_protocol.h"
+#include "net/manaserv/messagein.h"
namespace ManaServ {
@@ -44,7 +43,7 @@ EffectHandler::EffectHandler()
handledMessages = _messages;
}
-void EffectHandler::handleMessage(Net::MessageIn &msg)
+void EffectHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
@@ -62,7 +61,7 @@ void EffectHandler::handleMessage(Net::MessageIn &msg)
}
}
-void EffectHandler::handleCreateEffectPos(Net::MessageIn &msg)
+void EffectHandler::handleCreateEffectPos(MessageIn &msg)
{
int id = msg.readInt16();
uint16_t x = msg.readInt16();
@@ -70,7 +69,7 @@ void EffectHandler::handleCreateEffectPos(Net::MessageIn &msg)
effectManager->trigger(id, x, y);
}
-void EffectHandler::handleCreateEffectBeing(Net::MessageIn &msg)
+void EffectHandler::handleCreateEffectBeing(MessageIn &msg)
{
int eid = msg.readInt16();
int bid = msg.readInt16();
@@ -81,7 +80,7 @@ void EffectHandler::handleCreateEffectBeing(Net::MessageIn &msg)
logger->log("Warning: CreateEffect called for unknown being #%d", bid);
}
-void EffectHandler::handleShake(Net::MessageIn &msg)
+void EffectHandler::handleShake(MessageIn &msg)
{
int16_t intensityX = 0;
int16_t intensityY = 0;
diff --git a/src/net/manaserv/effecthandler.h b/src/net/manaserv/effecthandler.h
index 712bded3..de81fea9 100644
--- a/src/net/manaserv/effecthandler.h
+++ b/src/net/manaserv/effecthandler.h
@@ -31,12 +31,12 @@ class EffectHandler : public MessageHandler
public:
EffectHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
private:
- void handleCreateEffectPos(Net::MessageIn &msg);
- void handleCreateEffectBeing(Net::MessageIn &msg);
- void handleShake(Net::MessageIn &msg);
+ void handleCreateEffectPos(MessageIn &msg);
+ void handleCreateEffectBeing(MessageIn &msg);
+ void handleShake(MessageIn &msg);
};
} // namespace ManaServ
diff --git a/src/net/manaserv/gamehandler.cpp b/src/net/manaserv/gamehandler.cpp
index 89b80e68..265c0d8a 100644
--- a/src/net/manaserv/gamehandler.cpp
+++ b/src/net/manaserv/gamehandler.cpp
@@ -26,6 +26,7 @@
#include "net/manaserv/chathandler.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messagein.h"
#include "net/manaserv/messageout.h"
extern Net::GameHandler *gameHandler;
@@ -50,7 +51,7 @@ GameHandler::GameHandler()
gameHandler = this;
}
-void GameHandler::handleMessage(Net::MessageIn &msg)
+void GameHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
diff --git a/src/net/manaserv/gamehandler.h b/src/net/manaserv/gamehandler.h
index 2d33710e..454cae43 100644
--- a/src/net/manaserv/gamehandler.h
+++ b/src/net/manaserv/gamehandler.h
@@ -36,7 +36,7 @@ class GameHandler : public MessageHandler, public Net::GameHandler
public:
GameHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void connect();
diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp
index 1378d205..cd22fcec 100644
--- a/src/net/manaserv/guildhandler.cpp
+++ b/src/net/manaserv/guildhandler.cpp
@@ -32,7 +32,6 @@
#include "gui/widgets/channeltab.h"
-#include "net/messagein.h"
#include "net/net.h"
#include "net/manaserv/connection.h"
@@ -70,7 +69,7 @@ GuildHandler::GuildHandler()
guildHandler = this;
}
-void GuildHandler::handleMessage(Net::MessageIn &msg)
+void GuildHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
@@ -265,7 +264,7 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
}
}
-void GuildHandler::joinedGuild(Net::MessageIn &msg)
+void GuildHandler::joinedGuild(MessageIn &msg)
{
std::string guildName = msg.readString();
short guildId = msg.readInt16();
diff --git a/src/net/manaserv/guildhandler.h b/src/net/manaserv/guildhandler.h
index 0d3da7bf..d1232a6f 100644
--- a/src/net/manaserv/guildhandler.h
+++ b/src/net/manaserv/guildhandler.h
@@ -35,7 +35,7 @@ public:
bool isSupported() { return true; }
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void create(const std::string &name);
@@ -63,7 +63,7 @@ public:
void endAlliance(int guildId, int otherGuildId);
protected:
- void joinedGuild(Net::MessageIn &msg);
+ void joinedGuild(MessageIn &msg);
};
} // namespace ManaServ
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp
index 0ece6e11..b306869e 100644
--- a/src/net/manaserv/inventoryhandler.cpp
+++ b/src/net/manaserv/inventoryhandler.cpp
@@ -328,7 +328,7 @@ InventoryHandler::InventoryHandler()
listen(Event::ItemChannel);
}
-void InventoryHandler::handleMessage(Net::MessageIn &msg)
+void InventoryHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
diff --git a/src/net/manaserv/inventoryhandler.h b/src/net/manaserv/inventoryhandler.h
index 0a07c38d..808acb96 100644
--- a/src/net/manaserv/inventoryhandler.h
+++ b/src/net/manaserv/inventoryhandler.h
@@ -125,7 +125,7 @@ class InventoryHandler : public MessageHandler, Net::InventoryHandler,
public:
InventoryHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void event(Event::Channel channel, const Event &event);
diff --git a/src/net/manaserv/itemhandler.cpp b/src/net/manaserv/itemhandler.cpp
index 5e46b9eb..4e29bb4f 100644
--- a/src/net/manaserv/itemhandler.cpp
+++ b/src/net/manaserv/itemhandler.cpp
@@ -40,7 +40,7 @@ ItemHandler::ItemHandler()
handledMessages = _messages;
}
-void ItemHandler::handleMessage(Net::MessageIn &msg)
+void ItemHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
diff --git a/src/net/manaserv/itemhandler.h b/src/net/manaserv/itemhandler.h
index fef2fa53..e45db269 100644
--- a/src/net/manaserv/itemhandler.h
+++ b/src/net/manaserv/itemhandler.h
@@ -31,7 +31,7 @@ class ItemHandler : public MessageHandler
public:
ItemHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
};
} // namespace ManaServ
diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp
index 18fea9de..416e9422 100644
--- a/src/net/manaserv/loginhandler.cpp
+++ b/src/net/manaserv/loginhandler.cpp
@@ -59,7 +59,7 @@ LoginHandler::LoginHandler()
loginHandler = this;
}
-void LoginHandler::handleMessage(Net::MessageIn &msg)
+void LoginHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
@@ -250,13 +250,13 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
}
}
-void LoginHandler::handleLoginRandomResponse(Net::MessageIn &msg)
+void LoginHandler::handleLoginRandomResponse(MessageIn &msg)
{
mLoginData->randomSeed = msg.readString();
loginAccountContinue();
}
-void LoginHandler::handleLoginResponse(Net::MessageIn &msg)
+void LoginHandler::handleLoginResponse(MessageIn &msg)
{
const int errMsg = msg.readInt8();
@@ -294,7 +294,7 @@ void LoginHandler::handleLoginResponse(Net::MessageIn &msg)
}
}
-void LoginHandler::handleRegisterResponse(Net::MessageIn &msg)
+void LoginHandler::handleRegisterResponse(MessageIn &msg)
{
const int errMsg = msg.readInt8();
@@ -331,7 +331,7 @@ void LoginHandler::handleRegisterResponse(Net::MessageIn &msg)
}
}
-void LoginHandler::readServerInfo(Net::MessageIn &msg)
+void LoginHandler::readServerInfo(MessageIn &msg)
{
// Safety check for outdated manaserv versions (remove me later)
if (msg.getUnreadLength() == 0)
diff --git a/src/net/manaserv/loginhandler.h b/src/net/manaserv/loginhandler.h
index 3145beab..33cc83ad 100644
--- a/src/net/manaserv/loginhandler.h
+++ b/src/net/manaserv/loginhandler.h
@@ -36,7 +36,7 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler
public:
LoginHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void connect();
@@ -77,11 +77,11 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler
void reconnect();
private:
- void handleLoginRandomResponse(Net::MessageIn &msg);
- void handleLoginResponse(Net::MessageIn &msg);
- void handleRegisterResponse(Net::MessageIn &msg);
+ void handleLoginRandomResponse(MessageIn &msg);
+ void handleLoginResponse(MessageIn &msg);
+ void handleRegisterResponse(MessageIn &msg);
- void readServerInfo(Net::MessageIn &msg);
+ void readServerInfo(MessageIn &msg);
void loginAccountContinue();
diff --git a/src/net/manaserv/messagehandler.cpp b/src/net/manaserv/messagehandler.cpp
index 79d6667c..6ebd8c3c 100644
--- a/src/net/manaserv/messagehandler.cpp
+++ b/src/net/manaserv/messagehandler.cpp
@@ -32,4 +32,4 @@ MessageHandler::~MessageHandler()
unregisterHandler(this);
}
-}
+} // namespace ManaServ
diff --git a/src/net/manaserv/messagehandler.h b/src/net/manaserv/messagehandler.h
index 97708415..6e0221cb 100644
--- a/src/net/manaserv/messagehandler.h
+++ b/src/net/manaserv/messagehandler.h
@@ -24,8 +24,12 @@
#include "net/messagehandler.h"
+#include <memory>
+
namespace ManaServ {
+class MessageIn;
+
/**
* \ingroup Network
*/
@@ -34,10 +38,11 @@ class MessageHandler : public Net::MessageHandler
public:
~MessageHandler();
+ virtual void handleMessage(MessageIn &msg) = 0;
};
typedef const std::auto_ptr<MessageHandler> MessageHandlerPtr;
-}
+} // namespace ManaServ
#endif // NET_MANASERV_MESSAGEHANDLER_H
diff --git a/src/net/manaserv/messagein.cpp b/src/net/manaserv/messagein.cpp
index 4994de4c..aeb02b8d 100644
--- a/src/net/manaserv/messagein.cpp
+++ b/src/net/manaserv/messagein.cpp
@@ -27,12 +27,25 @@
namespace ManaServ {
MessageIn::MessageIn(const char *data, unsigned int length):
- Net::MessageIn(data, length)
+ mData(data),
+ mLength(length),
+ mPos(0)
{
// Read the message ID
mId = readInt16();
}
+uint8_t MessageIn::readInt8()
+{
+ uint8_t value = 0;
+ if (mPos < mLength)
+ {
+ value = mData[mPos];
+ }
+ mPos++;
+ return value;
+}
+
uint16_t MessageIn::readInt16()
{
uint16_t value = 0;
@@ -59,4 +72,26 @@ uint32_t MessageIn::readInt32()
return value;
}
+std::string MessageIn::readString(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;
+ return "";
+ }
+
+ // Read the string
+ char const *stringBeg = mData + mPos;
+ char const *stringEnd = (char const *)memchr(stringBeg, '\0', length);
+ std::string readString(stringBeg,
+ stringEnd ? stringEnd - stringBeg : length);
+ mPos += length;
+ return readString;
}
+
+} // ManaServ
diff --git a/src/net/manaserv/messagein.h b/src/net/manaserv/messagein.h
index 97e68812..ef0c29bf 100644
--- a/src/net/manaserv/messagein.h
+++ b/src/net/manaserv/messagein.h
@@ -22,24 +22,71 @@
#ifndef NET_MANASERV_MESSAGEIN_H
#define NET_MANASERV_MESSAGEIN_H
-#include "net/messagein.h"
+#include <cstdint>
+#include <string>
namespace ManaServ {
/**
- * Used for parsing an incoming message.
+ * Used for parsing an incoming message from manaserv.
*
* \ingroup Network
*/
-class MessageIn : public Net::MessageIn
+class MessageIn
{
public:
MessageIn(const char *data, unsigned int length);
+ /**
+ * Returns the message ID.
+ */
+ uint16_t getId() const { return mId; }
+
+ /**
+ * Returns the message length.
+ */
+ unsigned int getLength() const { return mLength; }
+
+ /**
+ * Returns the length of unread data.
+ */
+ unsigned int getUnreadLength() const { return mLength - mPos; }
+
+ /**
+ * Reads an unsigned 8-bit integer from the message.
+ */
+ uint8_t readInt8();
+
+ /**
+ * Reads an unsigned 16-bit integer from the message.
+ */
uint16_t readInt16();
+
+ /**
+ * Reads an unsigned 32-bit integer from the message.
+ */
uint32_t readInt32();
+
+ /**
+ * Reads a string. If a length is not given (-1), it is assumed
+ * that the length of the string is stored in a short at the
+ * start of the string.
+ */
+ std::string readString(int length = -1);
+
+ private:
+ const char *mData; /**< The message data. */
+ unsigned int mLength; /**< The length of the data. */
+ unsigned short mId; /**< The message ID. */
+
+ /**
+ * Actual position in the packet. From 0 to packet->length.
+ * A value bigger than packet->length means EOP was reached when
+ * reading it.
+ */
+ unsigned int mPos;
};
-}
+} // namespace ManaServ
#endif // NET_MANASERV_MESSAGEIN_H
diff --git a/src/net/manaserv/messageout.cpp b/src/net/manaserv/messageout.cpp
index 6a8482e8..7cecc03d 100644
--- a/src/net/manaserv/messageout.cpp
+++ b/src/net/manaserv/messageout.cpp
@@ -28,7 +28,9 @@
namespace ManaServ {
MessageOut::MessageOut(uint16_t id):
- Net::MessageOut(id)
+ mData(0),
+ mDataSize(0),
+ mPos(0)
{
writeInt16(id);
}
@@ -44,6 +46,13 @@ void MessageOut::expand(size_t bytes)
mDataSize = mPos + bytes;
}
+void MessageOut::writeInt8(uint8_t value)
+{
+ expand(1);
+ mData[mPos] = value;
+ mPos += 1;
+}
+
void MessageOut::writeInt16(uint16_t value)
{
expand(2);
@@ -60,4 +69,31 @@ void MessageOut::writeInt32(uint32_t value)
mPos += 4;
}
+void MessageOut::writeString(const std::string &string, int length)
+{
+ int stringLength = string.length();
+ if (length < 0)
+ {
+ // Write the length at the start if not fixed
+ writeInt16(stringLength);
+ length = stringLength;
+ }
+ else if (length < stringLength)
+ {
+ // Make sure the length of the string is no longer than specified
+ stringLength = length;
+ }
+ expand(length);
+
+ // Write the actual string
+ memcpy(mData + mPos, string.data(), stringLength);
+
+ // Pad remaining space with zeros
+ if (length > stringLength)
+ {
+ memset(mData + mPos + stringLength, '\0', length - stringLength);
+ }
+ mPos += length;
+}
+
} // namespace ManaServ
diff --git a/src/net/manaserv/messageout.h b/src/net/manaserv/messageout.h
index 59fc148f..9a87cf1c 100644
--- a/src/net/manaserv/messageout.h
+++ b/src/net/manaserv/messageout.h
@@ -22,21 +22,55 @@
#ifndef NET_MANASERV_MESSAGEOUT_H
#define NET_MANASERV_MESSAGEOUT_H
-#include "net/messageout.h"
+#include <cstdint>
+#include <string>
namespace ManaServ {
-class MessageOut : public Net::MessageOut
+/**
+ * Used for building an outgoing message to manaserv.
+ *
+ * \ingroup Network
+ */
+class MessageOut
{
public:
MessageOut(uint16_t id);
~MessageOut();
+ /**
+ * Writes an unsigned 8-bit integer to the message.
+ */
+ void writeInt8(uint8_t value);
+
+ /**
+ * Writes an unsigned 16-bit integer to the message.
+ */
void writeInt16(uint16_t value);
+
+ /**
+ * Writes an unsigned 32-bit integer to the message.
+ */
void writeInt32(uint32_t value);
- protected:
+ /**
+ * Writes a string. If a fixed length is not given (-1), it is stored
+ * as a short at the start of the string.
+ */
+ void writeString(const std::string &string, int length = -1);
+
+ /**
+ * Returns the content of the message.
+ */
+ char *getData() const { return mData; }
+
+ /**
+ * Returns the length of the data.
+ */
+ unsigned int getDataSize() const { return mDataSize; }
+
+ private:
/**
* Expand the packet data to be able to hold more data.
*
@@ -45,8 +79,12 @@ class MessageOut : public Net::MessageOut
* added.
*/
void expand(size_t size);
+
+ char *mData; /**< Data building up. */
+ unsigned int mDataSize; /**< Size of data. */
+ unsigned int mPos; /**< Position in the data. */
};
-}
+} // namespace ManaServ
#endif // NET_MANASERV_MESSAGEOUT_H
diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp
index 71b761ab..6b79fb90 100644
--- a/src/net/manaserv/npchandler.cpp
+++ b/src/net/manaserv/npchandler.cpp
@@ -53,7 +53,7 @@ NpcHandler::NpcHandler()
npcHandler = this;
}
-void NpcHandler::handleMessage(Net::MessageIn &msg)
+void NpcHandler::handleMessage(MessageIn &msg)
{
Being *being = actorSpriteManager->findBeing(msg.readInt16());
if (!being || being->getType() != ActorSprite::NPC)
diff --git a/src/net/manaserv/npchandler.h b/src/net/manaserv/npchandler.h
index 29821da5..0f42385d 100644
--- a/src/net/manaserv/npchandler.h
+++ b/src/net/manaserv/npchandler.h
@@ -37,7 +37,7 @@ class NpcHandler : public MessageHandler, public Net::NpcHandler
public:
NpcHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void startShopping(int beingId);
diff --git a/src/net/manaserv/partyhandler.cpp b/src/net/manaserv/partyhandler.cpp
index 2bb688e0..a0d4b6d9 100644
--- a/src/net/manaserv/partyhandler.cpp
+++ b/src/net/manaserv/partyhandler.cpp
@@ -65,7 +65,7 @@ PartyHandler::PartyHandler():
mParty->setName("Party");
}
-void PartyHandler::handleMessage(Net::MessageIn &msg)
+void PartyHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
diff --git a/src/net/manaserv/partyhandler.h b/src/net/manaserv/partyhandler.h
index 4b316bd2..6c526f73 100644
--- a/src/net/manaserv/partyhandler.h
+++ b/src/net/manaserv/partyhandler.h
@@ -37,7 +37,7 @@ class PartyHandler : public MessageHandler, public Net::PartyHandler
public:
PartyHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void create(const std::string &name = "");
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index adb60fb3..841ead56 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -85,7 +85,7 @@ PlayerHandler::PlayerHandler()
playerHandler = this;
}
-void PlayerHandler::handleMessage(Net::MessageIn &msg)
+void PlayerHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
@@ -277,7 +277,7 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
}
}
-void PlayerHandler::handleMapChangeMessage(Net::MessageIn &msg)
+void PlayerHandler::handleMapChangeMessage(MessageIn &msg)
{
const std::string mapName = msg.readString();
const unsigned short x = msg.readInt16();
diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h
index 28342f2d..abb29e9b 100644
--- a/src/net/manaserv/playerhandler.h
+++ b/src/net/manaserv/playerhandler.h
@@ -41,7 +41,7 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
public:
PlayerHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void attack(int id);
void emote(int emoteId);
@@ -73,7 +73,7 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
{ return true; }
private:
- void handleMapChangeMessage(Net::MessageIn &msg);
+ void handleMapChangeMessage(MessageIn &msg);
};
} // namespace ManaServ
diff --git a/src/net/manaserv/specialhandler.cpp b/src/net/manaserv/specialhandler.cpp
index 4cd0ce2b..0a477ff8 100644
--- a/src/net/manaserv/specialhandler.cpp
+++ b/src/net/manaserv/specialhandler.cpp
@@ -37,7 +37,7 @@ SpecialHandler::SpecialHandler()
specialHandler = this;
}
-void SpecialHandler::handleMessage(Net::MessageIn &msg)
+void SpecialHandler::handleMessage(MessageIn &msg)
{
// TODO
}
diff --git a/src/net/manaserv/specialhandler.h b/src/net/manaserv/specialhandler.h
index 29de76bb..ee26b3b7 100644
--- a/src/net/manaserv/specialhandler.h
+++ b/src/net/manaserv/specialhandler.h
@@ -33,7 +33,7 @@ class SpecialHandler : public MessageHandler, public Net::SpecialHandler
public:
SpecialHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void use(int id);
diff --git a/src/net/manaserv/tradehandler.cpp b/src/net/manaserv/tradehandler.cpp
index b5d526ae..ff7849ff 100644
--- a/src/net/manaserv/tradehandler.cpp
+++ b/src/net/manaserv/tradehandler.cpp
@@ -97,7 +97,7 @@ void TradeHandler::setAcceptTradeRequests(bool acceptTradeRequests)
SERVER_NOTICE(_("Ignoring incoming trade requests."))
}
-void TradeHandler::handleMessage(Net::MessageIn &msg)
+void TradeHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
diff --git a/src/net/manaserv/tradehandler.h b/src/net/manaserv/tradehandler.h
index 321b942f..5d20c14e 100644
--- a/src/net/manaserv/tradehandler.h
+++ b/src/net/manaserv/tradehandler.h
@@ -33,7 +33,7 @@ class TradeHandler : public MessageHandler, public Net::TradeHandler
public:
TradeHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
/**
* Returns whether trade requests are accepted.
diff --git a/src/net/messagehandler.h b/src/net/messagehandler.h
index 5a0cc091..3bf6c419 100644
--- a/src/net/messagehandler.h
+++ b/src/net/messagehandler.h
@@ -22,9 +22,7 @@
#ifndef NET_MESSAGEHANDLER_H
#define NET_MESSAGEHANDLER_H
-#include "net/messagein.h"
-
-#include <memory>
+#include <cstdint>
namespace Net {
@@ -36,11 +34,9 @@ class MessageHandler
public:
const uint16_t *handledMessages;
- virtual void handleMessage(MessageIn &msg) = 0;
-
virtual ~MessageHandler() {}
};
-}
+} // namespace Net
#endif // NET_MESSAGEHANDLER_H
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
deleted file mode 100644
index 46d12884..00000000
--- a/src/net/messagein.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * The Mana Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2012 The Mana Developers
- *
- * This file is part of The Mana 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/>.
- */
-
-#include "net/messagein.h"
-
-#define MAKEWORD(low,high) \
- ((unsigned short)(((unsigned char)(low)) | \
- ((unsigned short)((unsigned char)(high))) << 8))
-
-#include <cstring>
-
-namespace Net {
-
-MessageIn::MessageIn(const char *data, unsigned int length):
- mData(data),
- mLength(length),
- mPos(0)
-{
-}
-
-uint8_t MessageIn::readInt8()
-{
- uint8_t value = 0;
- if (mPos < mLength)
- {
- value = mData[mPos];
- }
- mPos++;
- return value;
-}
-
-void MessageIn::readCoordinates(uint16_t &x, uint16_t &y)
-{
- if (mPos + 3 <= mLength)
- {
- unsigned char const *p = reinterpret_cast< unsigned char const * >(mData + mPos);
- x = p[0] | ((p[1] & 0x07) << 8);
- y = (p[1] >> 3) | ((p[2] & 0x3F) << 5);
- }
- mPos += 3;
-}
-
-void MessageIn::readCoordinates(uint16_t &x, uint16_t &y, uint8_t &direction)
-{
- if (mPos + 3 <= mLength)
- {
- const char *data = mData + mPos;
- uint16_t temp;
-
- temp = MAKEWORD(data[1] & 0x00c0, data[0] & 0x00ff);
- x = temp >> 6;
- temp = MAKEWORD(data[2] & 0x00f0, data[1] & 0x003f);
- y = temp >> 4;
-
- direction = data[2] & 0x000f;
-
- // Translate from tmwAthena format
- switch (direction)
- {
- case 0:
- direction = 1;
- break;
- case 1:
- direction = 3;
- break;
- case 2:
- direction = 2;
- break;
- case 3:
- direction = 6;
- break;
- case 4:
- direction = 4;
- break;
- case 5:
- direction = 12;
- break;
- case 6:
- direction = 8;
- break;
- case 7:
- direction = 9;
- break;
- case 8:
- direction = 8;
- break;
- default:
- // OOPSIE! Impossible or unknown
- direction = 0;
- }
- }
- mPos += 3;
-}
-
-void MessageIn::readCoordinatePair(uint16_t &srcX, uint16_t &srcY,
- uint16_t &dstX, uint16_t &dstY)
-{
- if (mPos + 5 <= mLength)
- {
- const char *data = mData + mPos;
- uint16_t temp;
-
- temp = MAKEWORD(data[3], data[2] & 0x000f);
- dstX = temp >> 2;
-
- dstY = MAKEWORD(data[4], data[3] & 0x0003);
-
- temp = MAKEWORD(data[1], data[0]);
- srcX = temp >> 6;
-
- temp = MAKEWORD(data[2], data[1] & 0x003f);
- srcY = temp >> 4;
- }
- mPos += 5;
-}
-
-void MessageIn::skip(unsigned int length)
-{
- mPos += length;
-}
-
-std::string MessageIn::readString(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;
- return "";
- }
-
- // Read the string
- char const *stringBeg = mData + mPos;
- char const *stringEnd = (char const *)memchr(stringBeg, '\0', length);
- std::string readString(stringBeg,
- stringEnd ? stringEnd - stringBeg : length);
- mPos += length;
- return readString;
-}
-
-}
diff --git a/src/net/messagein.h b/src/net/messagein.h
deleted file mode 100644
index 44986f39..00000000
--- a/src/net/messagein.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * The Mana Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2012 The Mana Developers
- *
- * This file is part of The Mana 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_MESSAGEIN_H
-#define NET_MESSAGEIN_H
-
-#include <cstdint>
-#include <string>
-
-namespace Net {
-
-/**
- * Used for parsing an incoming message.
- *
- * \ingroup Network
- */
-class MessageIn
-{
- public:
- /**
- * Returns the message ID.
- */
- uint16_t getId() const { return mId; }
-
- /**
- * Returns the message length.
- */
- unsigned int getLength() const { return mLength; }
-
- /**
- * Returns the length of unread data.
- */
- unsigned int getUnreadLength() const { return mLength - mPos; }
-
- /**
- * Reads an unsigned 8-bit integer from the message.
- */
- virtual uint8_t readInt8();
-
- /**
- * Reads an unsigned 16-bit integer from the message.
- */
- virtual uint16_t readInt16() = 0;
-
- /**
- * Reads an unsigned 32-bit integer from the message.
- */
- virtual uint32_t readInt32() = 0;
-
- /**
- * Reads a 3-byte block containing tile-based coordinates. Used by
- * manaserv.
- */
- virtual void readCoordinates(uint16_t &x, uint16_t &y);
-
- /**
- * Reads a special 3 byte block used by eAthena, containing x and y
- * coordinates and direction.
- */
- virtual void readCoordinates(uint16_t &x, uint16_t &y, uint8_t &direction);
-
- /**
- * Reads a special 5 byte block used by eAthena, containing a source
- * and destination coordinate pair.
- */
- virtual void readCoordinatePair(uint16_t &srcX, uint16_t &srcY,
- uint16_t &dstX, uint16_t &dstY);
-
- /**
- * Skips a given number of bytes.
- */
- virtual void skip(unsigned int length);
-
- /**
- * Reads a string. If a length is not given (-1), it is assumed
- * that the length of the string is stored in a short at the
- * start of the string.
- */
- virtual std::string readString(int length = -1);
-
- virtual ~MessageIn() {}
-
- protected:
- MessageIn(const char *data, unsigned int length);
-
- const char *mData; /**< The message data. */
- unsigned int mLength; /**< The length of the data. */
- unsigned short mId; /**< The message ID. */
-
- /**
- * Actual position in the packet. From 0 to packet->length.
- * A value bigger than packet->length means EOP was reached when
- * reading it.
- */
- unsigned int mPos;
-};
-
-} // namespace Net
-
-#endif // NET_MESSAGEIN_H
diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp
deleted file mode 100644
index 56d1d8b7..00000000
--- a/src/net/messageout.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * The Mana Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2012 The Mana Developers
- *
- * This file is part of The Mana 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/>.
- */
-
-#include "net/messageout.h"
-
-#include <cstring>
-
-namespace Net {
-
-MessageOut::MessageOut(uint16_t id):
- mData(0),
- mDataSize(0),
- mPos(0)
-{
-}
-
-void MessageOut::writeInt8(uint8_t value)
-{
- expand(1);
- mData[mPos] = value;
- mPos += 1;
-}
-
-void MessageOut::writeString(const std::string &string, int length)
-{
- int stringLength = string.length();
- if (length < 0)
- {
- // Write the length at the start if not fixed
- writeInt16(stringLength);
- length = stringLength;
- }
- else if (length < stringLength)
- {
- // Make sure the length of the string is no longer than specified
- stringLength = length;
- }
- expand(length);
-
- // Write the actual string
- memcpy(mData + mPos, string.data(), stringLength);
-
- // Pad remaining space with zeros
- if (length > stringLength)
- {
- memset(mData + mPos + stringLength, '\0', length - stringLength);
- }
- mPos += length;
-}
-
-char *MessageOut::getData() const
-{
- return mData;
-}
-
-unsigned int MessageOut::getDataSize() const
-{
- return mDataSize;
-}
-
-}
diff --git a/src/net/messageout.h b/src/net/messageout.h
deleted file mode 100644
index b8576db2..00000000
--- a/src/net/messageout.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * The Mana Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2012 The Mana Developers
- *
- * This file is part of The Mana 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_MESSAGEOUT_H
-#define NET_MESSAGEOUT_H
-
-#include <cstdint>
-#include <string>
-
-namespace Net {
-
-/**
- * Used for building an outgoing message.
- *
- * \ingroup Network
- */
-class MessageOut
-{
- public:
- /**
- * Writes an unsigned 8-bit integer to the message.
- */
- virtual void writeInt8(uint8_t value);
-
- /**
- * Writes an unsigned 16-bit integer to the message.
- */
- virtual void writeInt16(uint16_t value) = 0;
-
- /**
- * Writes an unsigned 32-bit integer to the message.
- */
- virtual void writeInt32(uint32_t value) = 0;
-
- /**
- * Writes a string. If a fixed length is not given (-1), it is stored
- * as a short at the start of the string.
- */
- virtual void writeString(const std::string &string, int length = -1);
-
- /**
- * Returns the content of the message.
- */
- virtual char *getData() const;
-
- /**
- * Returns the length of the data.
- */
- virtual unsigned int getDataSize() const;
-
- virtual ~MessageOut() {}
-
- protected:
- MessageOut(uint16_t id);
-
- /**
- * Expand the packet data to be able to hold more data.
- *
- * NOTE: For performance enhancements this method could allocate extra
- * memory in advance instead of expanding size every time more data is
- * added.
- */
- virtual void expand(size_t size) = 0;
-
- char *mData; /**< Data building up. */
- unsigned int mDataSize; /**< Size of data. */
- unsigned int mPos; /**< Position in the data. */
-};
-
-}
-
-#endif // NET_MESSAGEOUT_H
diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp
index 9184c761..29202eb7 100644
--- a/src/net/tmwa/adminhandler.cpp
+++ b/src/net/tmwa/adminhandler.cpp
@@ -30,6 +30,8 @@
#include "net/chathandler.h"
#include "net/net.h"
+#include "net/tmwa/messagein.h"
+#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
#include "utils/gettext.h"
@@ -53,7 +55,7 @@ AdminHandler::AdminHandler()
adminHandler = this;
}
-void AdminHandler::handleMessage(Net::MessageIn &msg)
+void AdminHandler::handleMessage(MessageIn &msg)
{
int id;
switch (msg.getId())
diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h
index 9b38fa67..71c37a09 100644
--- a/src/net/tmwa/adminhandler.h
+++ b/src/net/tmwa/adminhandler.h
@@ -34,7 +34,7 @@ class AdminHandler : public MessageHandler, public Net::AdminHandler
public:
AdminHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void announce(const std::string &text);
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index b7d84685..fb01990a 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -33,6 +33,8 @@
#include "party.h"
#include "playerrelations.h"
+#include "net/tmwa/messagein.h"
+#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
#include "resources/hairdb.h"
@@ -146,7 +148,7 @@ static void handlePosMessage(Map *map, Being *dstBeing, Uint16 x, Uint16 y,
}
}
-void BeingHandler::handleMessage(Net::MessageIn &msg)
+void BeingHandler::handleMessage(MessageIn &msg)
{
if (!actorSpriteManager)
return;
diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h
index c1bdbe43..81bbad74 100644
--- a/src/net/tmwa/beinghandler.h
+++ b/src/net/tmwa/beinghandler.h
@@ -31,7 +31,7 @@ class BeingHandler : public MessageHandler
public:
BeingHandler(bool enableSync);
- virtual void handleMessage(Net::MessageIn &msg);
+ virtual void handleMessage(MessageIn &msg);
private:
// Should we honor server "Stop Walking" packets
diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp
index e6ccae56..908e1d6d 100644
--- a/src/net/tmwa/buysellhandler.cpp
+++ b/src/net/tmwa/buysellhandler.cpp
@@ -32,8 +32,7 @@
#include "gui/buyselldialog.h"
#include "gui/selldialog.h"
-#include "net/messagein.h"
-
+#include "net/tmwa/messagein.h"
#include "net/tmwa/protocol.h"
#include "utils/gettext.h"
@@ -54,7 +53,7 @@ BuySellHandler::BuySellHandler()
handledMessages = _messages;
}
-void BuySellHandler::handleMessage(Net::MessageIn &msg)
+void BuySellHandler::handleMessage(MessageIn &msg)
{
int n_items;
diff --git a/src/net/tmwa/buysellhandler.h b/src/net/tmwa/buysellhandler.h
index 18d0294c..b5229e0f 100644
--- a/src/net/tmwa/buysellhandler.h
+++ b/src/net/tmwa/buysellhandler.h
@@ -33,7 +33,7 @@ class BuySellHandler : public MessageHandler
public:
BuySellHandler();
- virtual void handleMessage(Net::MessageIn &msg);
+ virtual void handleMessage(MessageIn &msg);
private:
int mNpcId;
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 8834798f..ce193821 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -29,12 +29,12 @@
#include "gui/okdialog.h"
#include "net/logindata.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
#include "net/net.h"
#include "net/tmwa/gamehandler.h"
#include "net/tmwa/loginhandler.h"
+#include "net/tmwa/messagein.h"
+#include "net/tmwa/messageout.h"
#include "net/tmwa/network.h"
#include "net/tmwa/protocol.h"
@@ -68,7 +68,7 @@ CharServerHandler::CharServerHandler()
charHandler = this;
}
-void CharServerHandler::handleMessage(Net::MessageIn &msg)
+void CharServerHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
@@ -196,7 +196,7 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg)
}
}
-void CharServerHandler::readPlayerData(Net::MessageIn &msg, Net::Character *character)
+void CharServerHandler::readPlayerData(MessageIn &msg, Net::Character *character)
{
const Token &token =
static_cast<LoginHandler*>(Net::getLoginHandler())->getToken();
diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h
index 31b2ba8e..c9f44e0f 100644
--- a/src/net/tmwa/charserverhandler.h
+++ b/src/net/tmwa/charserverhandler.h
@@ -40,7 +40,7 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler
public:
CharServerHandler();
- virtual void handleMessage(Net::MessageIn &msg);
+ virtual void handleMessage(MessageIn &msg);
void setCharSelectDialog(CharSelectDialog *window);
@@ -82,7 +82,7 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler
void connect();
private:
- void readPlayerData(Net::MessageIn &msg, Net::Character *character);
+ void readPlayerData(MessageIn &msg, Net::Character *character);
};
} // namespace TmwAthena
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index 134db59f..9e5e7b19 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -28,9 +28,8 @@
#include "localplayer.h"
#include "playerrelations.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
-
+#include "net/tmwa/messagein.h"
+#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
#include "utils/gettext.h"
@@ -57,7 +56,7 @@ ChatHandler::ChatHandler()
chatHandler = this;
}
-void ChatHandler::handleMessage(Net::MessageIn &msg)
+void ChatHandler::handleMessage(MessageIn &msg)
{
Being *being;
std::string chatMsg;
diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h
index 65db4bec..fa3a8ec3 100644
--- a/src/net/tmwa/chathandler.h
+++ b/src/net/tmwa/chathandler.h
@@ -36,7 +36,7 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler
public:
ChatHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void talk(const std::string &text);
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp
index 93f0b86f..68ed62b0 100644
--- a/src/net/tmwa/gamehandler.cpp
+++ b/src/net/tmwa/gamehandler.cpp
@@ -29,10 +29,9 @@
#include "gui/okdialog.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
-
#include "net/tmwa/loginhandler.h"
+#include "net/tmwa/messagein.h"
+#include "net/tmwa/messageout.h"
#include "net/tmwa/network.h"
#include "net/tmwa/protocol.h"
@@ -60,7 +59,7 @@ GameHandler::GameHandler()
listen(Event::GameChannel);
}
-void GameHandler::handleMessage(Net::MessageIn &msg)
+void GameHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h
index 4f0525b9..a6bcde0a 100644
--- a/src/net/tmwa/gamehandler.h
+++ b/src/net/tmwa/gamehandler.h
@@ -39,7 +39,7 @@ class GameHandler : public MessageHandler, public Net::GameHandler,
public:
GameHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void event(Event::Channel channel, const Event &event);
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 3bbadccd..6c2bcddb 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -32,8 +32,6 @@
#include "gui/socialwindow.h"
#include "gui/statuswindow.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
#include "net/serverinfo.h"
#include "net/tmwa/adminhandler.h"
@@ -46,6 +44,8 @@
#include "net/tmwa/inventoryhandler.h"
#include "net/tmwa/itemhandler.h"
#include "net/tmwa/loginhandler.h"
+#include "net/tmwa/messagein.h"
+#include "net/tmwa/messageout.h"
#include "net/tmwa/network.h"
#include "net/tmwa/npchandler.h"
#include "net/tmwa/partyhandler.h"
@@ -116,7 +116,7 @@ GeneralHandler::~GeneralHandler()
delete mNetwork;
}
-void GeneralHandler::handleMessage(Net::MessageIn &msg)
+void GeneralHandler::handleMessage(MessageIn &msg)
{
int code;
diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h
index 7c8c6037..a34852fd 100644
--- a/src/net/tmwa/generalhandler.h
+++ b/src/net/tmwa/generalhandler.h
@@ -39,7 +39,7 @@ class GeneralHandler : public MessageHandler, public Net::GeneralHandler,
~GeneralHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void load();
diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp
index f34b914e..a3194991 100644
--- a/src/net/tmwa/guildhandler.cpp
+++ b/src/net/tmwa/guildhandler.cpp
@@ -28,6 +28,7 @@
#include "gui/socialwindow.h"
#include "net/tmwa/messagein.h"
+#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
#include "net/tmwa/gui/guildtab.h"
@@ -85,7 +86,7 @@ GuildHandler::~GuildHandler()
guildTab = 0;
}
-void GuildHandler::handleMessage(Net::MessageIn &msg)
+void GuildHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
diff --git a/src/net/tmwa/guildhandler.h b/src/net/tmwa/guildhandler.h
index cc2dd524..4a74a26b 100644
--- a/src/net/tmwa/guildhandler.h
+++ b/src/net/tmwa/guildhandler.h
@@ -34,7 +34,7 @@ class GuildHandler : public Net::GuildHandler, public MessageHandler
~GuildHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void create(const std::string &name);
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index f260110d..256e7159 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -34,9 +34,8 @@
#include "gui/equipmentwindow.h"
#include "gui/widgets/chattab.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
-
+#include "net/tmwa/messagein.h"
+#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
#include "resources/iteminfo.h"
@@ -125,7 +124,7 @@ InventoryHandler::~InventoryHandler()
delete mStorage;
}
-void InventoryHandler::handleMessage(Net::MessageIn &msg)
+void InventoryHandler::handleMessage(MessageIn &msg)
{
int number, flag;
int index, amount, itemId, equipType;
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index 88ab953d..3eefdd9b 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -187,7 +187,7 @@ class InventoryHandler : public MessageHandler, public Net::InventoryHandler,
~InventoryHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void event(Event::Channel channel, const Event &event);
diff --git a/src/net/tmwa/itemhandler.cpp b/src/net/tmwa/itemhandler.cpp
index d1a560f3..f05bb899 100644
--- a/src/net/tmwa/itemhandler.cpp
+++ b/src/net/tmwa/itemhandler.cpp
@@ -21,8 +21,7 @@
#include "net/tmwa/itemhandler.h"
-#include "net/messagein.h"
-
+#include "net/tmwa/messagein.h"
#include "net/tmwa/protocol.h"
#include "actorspritemanager.h"
@@ -42,7 +41,7 @@ ItemHandler::ItemHandler()
handledMessages = _messages;
}
-void ItemHandler::handleMessage(Net::MessageIn &msg)
+void ItemHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
diff --git a/src/net/tmwa/itemhandler.h b/src/net/tmwa/itemhandler.h
index 96557d8b..3f58a172 100644
--- a/src/net/tmwa/itemhandler.h
+++ b/src/net/tmwa/itemhandler.h
@@ -31,7 +31,7 @@ class ItemHandler : public MessageHandler
public:
ItemHandler();
- virtual void handleMessage(Net::MessageIn &msg);
+ virtual void handleMessage(MessageIn &msg);
};
} // namespace TmwAthena
diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp
index 393e712a..51c757cc 100644
--- a/src/net/tmwa/loginhandler.cpp
+++ b/src/net/tmwa/loginhandler.cpp
@@ -25,9 +25,9 @@
#include "log.h"
#include "net/logindata.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
+#include "net/tmwa/messagein.h"
+#include "net/tmwa/messageout.h"
#include "net/tmwa/network.h"
#include "net/tmwa/protocol.h"
@@ -62,7 +62,7 @@ LoginHandler::~LoginHandler()
delete_all(mWorlds);
}
-void LoginHandler::handleMessage(Net::MessageIn &msg)
+void LoginHandler::handleMessage(MessageIn &msg)
{
int code, worldCount;
diff --git a/src/net/tmwa/loginhandler.h b/src/net/tmwa/loginhandler.h
index fcd51e46..fcc7c5cc 100644
--- a/src/net/tmwa/loginhandler.h
+++ b/src/net/tmwa/loginhandler.h
@@ -40,7 +40,7 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler
~LoginHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void connect();
diff --git a/src/net/tmwa/messagehandler.h b/src/net/tmwa/messagehandler.h
index 82bbabbc..2b1f5b7e 100644
--- a/src/net/tmwa/messagehandler.h
+++ b/src/net/tmwa/messagehandler.h
@@ -23,14 +23,12 @@
#define NET_TA_MESSAGEHANDLER_H
#include "net/messagehandler.h"
-#include "net/messagein.h"
-
-#include "net/tmwa/messageout.h"
#include <memory>
namespace TmwAthena {
+class MessageIn;
class Network;
/**
@@ -43,6 +41,8 @@ class MessageHandler : public Net::MessageHandler
~MessageHandler();
+ virtual void handleMessage(MessageIn &msg) = 0;
+
void setNetwork(Network *network);
protected:
diff --git a/src/net/tmwa/messagein.cpp b/src/net/tmwa/messagein.cpp
index c4d083b3..899b135d 100644
--- a/src/net/tmwa/messagein.cpp
+++ b/src/net/tmwa/messagein.cpp
@@ -24,15 +24,32 @@
#include <SDL.h>
#include <SDL_endian.h>
+#define MAKEWORD(low,high) \
+ ((unsigned short)(((unsigned char)(low)) | \
+ ((unsigned short)((unsigned char)(high))) << 8))
+
namespace TmwAthena {
MessageIn::MessageIn(const char *data, unsigned int length):
- Net::MessageIn(data, length)
+ mData(data),
+ mLength(length),
+ mPos(0)
{
// Read the message ID
mId = readInt16();
}
+uint8_t MessageIn::readInt8()
+{
+ uint8_t value = 0;
+ if (mPos < mLength)
+ {
+ value = mData[mPos];
+ }
+ mPos++;
+ return value;
+}
+
uint16_t MessageIn::readInt16()
{
uint16_t value = 0;
@@ -67,4 +84,105 @@ uint32_t MessageIn::readInt32()
return value;
}
+void MessageIn::readCoordinates(uint16_t &x, uint16_t &y, uint8_t &direction)
+{
+ if (mPos + 3 <= mLength)
+ {
+ const char *data = mData + mPos;
+ uint16_t temp;
+
+ temp = MAKEWORD(data[1] & 0x00c0, data[0] & 0x00ff);
+ x = temp >> 6;
+ temp = MAKEWORD(data[2] & 0x00f0, data[1] & 0x003f);
+ y = temp >> 4;
+
+ direction = data[2] & 0x000f;
+
+ // Translate from tmwAthena format
+ switch (direction)
+ {
+ case 0:
+ direction = 1;
+ break;
+ case 1:
+ direction = 3;
+ break;
+ case 2:
+ direction = 2;
+ break;
+ case 3:
+ direction = 6;
+ break;
+ case 4:
+ direction = 4;
+ break;
+ case 5:
+ direction = 12;
+ break;
+ case 6:
+ direction = 8;
+ break;
+ case 7:
+ direction = 9;
+ break;
+ case 8:
+ direction = 8;
+ break;
+ default:
+ // OOPSIE! Impossible or unknown
+ direction = 0;
+ }
+ }
+ mPos += 3;
+}
+
+void MessageIn::readCoordinatePair(uint16_t &srcX, uint16_t &srcY,
+ uint16_t &dstX, uint16_t &dstY)
+{
+ if (mPos + 5 <= mLength)
+ {
+ const char *data = mData + mPos;
+ uint16_t temp;
+
+ temp = MAKEWORD(data[3], data[2] & 0x000f);
+ dstX = temp >> 2;
+
+ dstY = MAKEWORD(data[4], data[3] & 0x0003);
+
+ temp = MAKEWORD(data[1], data[0]);
+ srcX = temp >> 6;
+
+ temp = MAKEWORD(data[2], data[1] & 0x003f);
+ srcY = temp >> 4;
+ }
+ mPos += 5;
+}
+
+void MessageIn::skip(unsigned int length)
+{
+ mPos += length;
+}
+
+std::string MessageIn::readString(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;
+ return "";
+ }
+
+ // Read the string
+ char const *stringBeg = mData + mPos;
+ char const *stringEnd = (char const *)memchr(stringBeg, '\0', length);
+ std::string readString(stringBeg,
+ stringEnd ? stringEnd - stringBeg : length);
+ mPos += length;
+ return readString;
+}
+
} // namespace TmwAthena
diff --git a/src/net/tmwa/messagein.h b/src/net/tmwa/messagein.h
index 714f71bb..48121187 100644
--- a/src/net/tmwa/messagein.h
+++ b/src/net/tmwa/messagein.h
@@ -22,26 +22,89 @@
#ifndef NET_TA_MESSAGEIN_H
#define NET_TA_MESSAGEIN_H
-#include "net/messagein.h"
-
+#include <cstdint>
#include <string>
namespace TmwAthena {
/**
- * Used for parsing an incoming message.
+ * Used for parsing an incoming message from eAthena.
*
* \ingroup Network
*/
- class MessageIn : public Net::MessageIn
+class MessageIn
{
public:
MessageIn(const char *data, unsigned int length);
+ /**
+ * Returns the message ID.
+ */
+ uint16_t getId() const { return mId; }
+
+ /**
+ * Returns the message length.
+ */
+ unsigned int getLength() const { return mLength; }
+
+ /**
+ * Returns the length of unread data.
+ */
+ unsigned int getUnreadLength() const { return mLength - mPos; }
+
+ /**
+ * Reads an unsigned 8-bit integer from the message.
+ */
+ uint8_t readInt8();
+
+ /**
+ * Reads an unsigned 16-bit integer from the message.
+ */
uint16_t readInt16();
+
+ /**
+ * Reads an unsigned 32-bit integer from the message.
+ */
uint32_t readInt32();
+
+ /**
+ * Reads a special 3 byte block used by eAthena, containing x and y
+ * coordinates and direction.
+ */
+ void readCoordinates(uint16_t &x, uint16_t &y, uint8_t &direction);
+
+ /**
+ * Reads a special 5 byte block used by eAthena, containing a source
+ * and destination coordinate pair.
+ */
+ void readCoordinatePair(uint16_t &srcX, uint16_t &srcY,
+ uint16_t &dstX, uint16_t &dstY);
+
+ /**
+ * Skips a given number of bytes.
+ */
+ void skip(unsigned int length);
+
+ /**
+ * Reads a string. If a length is not given (-1), it is assumed
+ * that the length of the string is stored in a short at the
+ * start of the string.
+ */
+ std::string readString(int length = -1);
+
+ private:
+ const char *mData; /**< The message data. */
+ unsigned int mLength; /**< The length of the data. */
+ unsigned short mId; /**< The message ID. */
+
+ /**
+ * Actual position in the packet. From 0 to packet->length.
+ * A value bigger than packet->length means EOP was reached when
+ * reading it.
+ */
+ unsigned int mPos;
};
-}
+} // TmwAthena
#endif // NET_TA_MESSAGEIN_H
diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp
index 7f09ecce..ae5f6dba 100644
--- a/src/net/tmwa/messageout.cpp
+++ b/src/net/tmwa/messageout.cpp
@@ -27,15 +27,16 @@
#include <SDL_endian.h>
#include <cstring>
-#include <string>
namespace TmwAthena {
MessageOut::MessageOut(uint16_t id):
- Net::MessageOut(id)
+ mDataSize(0),
+ mPos(0)
{
mNetwork = TmwAthena::Network::instance();
mData = mNetwork->mOutBuffer + mNetwork->mOutSize;
+
writeInt16(id);
}
@@ -44,11 +45,18 @@ void MessageOut::expand(size_t bytes)
mNetwork->mOutSize += bytes;
}
+void MessageOut::writeInt8(uint8_t value)
+{
+ expand(1);
+ mData[mPos] = value;
+ mPos += 1;
+}
+
void MessageOut::writeInt16(uint16_t value)
{
expand(2);
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- uint16_t swap=SDL_Swap16(value);
+ uint16_t swap = SDL_Swap16(value);
memcpy(mData + mPos, &swap, sizeof(uint16_t));
#else
memcpy(mData + mPos, &value, sizeof(uint16_t));
@@ -60,7 +68,7 @@ void MessageOut::writeInt32(uint32_t value)
{
expand(4);
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- uint32_t swap=SDL_Swap32(value);
+ uint32_t swap = SDL_Swap32(value);
memcpy(mData + mPos, &swap, sizeof(uint32_t));
#else
memcpy(mData + mPos, &value, sizeof(uint32_t));
@@ -68,10 +76,37 @@ void MessageOut::writeInt32(uint32_t value)
mPos += 4;
}
+void MessageOut::writeString(const std::string &string, int length)
+{
+ int stringLength = string.length();
+ if (length < 0)
+ {
+ // Write the length at the start if not fixed
+ writeInt16(stringLength);
+ length = stringLength;
+ }
+ else if (length < stringLength)
+ {
+ // Make sure the length of the string is no longer than specified
+ stringLength = length;
+ }
+ expand(length);
+
+ // Write the actual string
+ memcpy(mData + mPos, string.data(), stringLength);
+
+ // Pad remaining space with zeros
+ if (length > stringLength)
+ {
+ memset(mData + mPos + stringLength, '\0', length - stringLength);
+ }
+ mPos += length;
+}
+
void MessageOut::writeCoordinates(uint16_t x, uint16_t y, uint8_t direction)
{
char *data = mData + mPos;
- mNetwork->mOutSize += 3;
+ expand(3);
mPos += 3;
uint16_t temp = x;
diff --git a/src/net/tmwa/messageout.h b/src/net/tmwa/messageout.h
index d30fd1ec..dd2b84cc 100644
--- a/src/net/tmwa/messageout.h
+++ b/src/net/tmwa/messageout.h
@@ -22,37 +22,77 @@
#ifndef NET_TA_MESSAGEOUT_H
#define NET_TA_MESSAGEOUT_H
-#include "net/messageout.h"
+#include <cstdint>
+#include <string>
namespace TmwAthena {
class Network;
/**
- * Used for building an outgoing message.
+ * Used for building an outgoing message to eAthena.
*
* \ingroup Network
*/
-class MessageOut : public Net::MessageOut
+class MessageOut
{
public:
MessageOut(uint16_t id);
+ /**
+ * Writes an unsigned 8-bit integer to the message.
+ */
+ void writeInt8(uint8_t value);
+
+ /**
+ * Writes an unsigned 16-bit integer to the message.
+ */
void writeInt16(uint16_t value);
+
+ /**
+ * Writes an unsigned 32-bit integer to the message.
+ */
void writeInt32(uint32_t value);
/**
+ * Writes a string. If a fixed length is not given (-1), it is stored
+ * as a short at the start of the string.
+ */
+ void writeString(const std::string &string, int length = -1);
+
+ /**
* Encodes coordinates and direction in 3 bytes.
*/
void writeCoordinates(uint16_t x, uint16_t y,
uint8_t direction);
+ /**
+ * Returns the content of the message.
+ */
+ char *getData() const { return mData; }
+
+ /**
+ * Returns the length of the data.
+ */
+ unsigned int getDataSize() const { return mDataSize; }
+
private:
+ /**
+ * Expand the packet data to be able to hold more data.
+ *
+ * NOTE: For performance enhancements this method could allocate extra
+ * memory in advance instead of expanding size every time more data is
+ * added.
+ */
void expand(size_t size);
Network *mNetwork;
+
+ char *mData; /**< Data building up. */
+ unsigned int mDataSize; /**< Size of data. */
+ unsigned int mPos; /**< Position in the data. */
};
-}
+} // namespace TmwAthena
#endif // NET_TA_MESSAGEOUT_H
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index 5f5d4631..3a02deba 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -24,8 +24,8 @@
#include "log.h"
#include "net/messagehandler.h"
-#include "net/messagein.h"
+#include "net/tmwa/messagein.h"
#include "net/tmwa/protocol.h"
#include "utils/gettext.h"
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index 71f9ba2a..2b0a5b0a 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -25,11 +25,11 @@
#include "event.h"
#include "localplayer.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
#include "net/net.h"
#include "net/npchandler.h"
+#include "net/tmwa/messagein.h"
+#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
#include "utils/stringutils.h"
@@ -68,7 +68,7 @@ NpcHandler::NpcHandler()
npcHandler = this;
}
-void NpcHandler::handleMessage(Net::MessageIn &msg)
+void NpcHandler::handleMessage(MessageIn &msg)
{
if (msg.getId() == SMSG_NPC_CHOICE || msg.getId() == SMSG_NPC_MESSAGE)
{
diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h
index 1c3d99c3..71486a40 100644
--- a/src/net/tmwa/npchandler.h
+++ b/src/net/tmwa/npchandler.h
@@ -37,7 +37,7 @@ class NpcHandler : public MessageHandler, public Net::NpcHandler
public:
NpcHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void startShopping(int beingId);
diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp
index 314136e6..4753dac1 100644
--- a/src/net/tmwa/partyhandler.cpp
+++ b/src/net/tmwa/partyhandler.cpp
@@ -28,9 +28,8 @@
#include "gui/socialwindow.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
-
+#include "net/tmwa/messagein.h"
+#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
#include "net/tmwa/gui/partytab.h"
@@ -74,7 +73,7 @@ PartyHandler::~PartyHandler()
partyTab = 0;
}
-void PartyHandler::handleMessage(Net::MessageIn &msg)
+void PartyHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
diff --git a/src/net/tmwa/partyhandler.h b/src/net/tmwa/partyhandler.h
index bf567bb6..9a3570a8 100644
--- a/src/net/tmwa/partyhandler.h
+++ b/src/net/tmwa/partyhandler.h
@@ -38,7 +38,7 @@ class PartyHandler : public MessageHandler, public Net::PartyHandler
~PartyHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void create(const std::string &name = "");
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index a3651a2f..c598c5f9 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -38,9 +38,8 @@
#include "gui/statuswindow.h"
#include "gui/viewport.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
-
+#include "net/tmwa/messagein.h"
+#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
#include "utils/stringutils.h"
@@ -159,7 +158,7 @@ PlayerHandler::PlayerHandler()
playerHandler = this;
}
-void PlayerHandler::handleMessage(Net::MessageIn &msg)
+void PlayerHandler::handleMessage(MessageIn &msg)
{
if (!local_player)
return;
diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h
index 7e31366b..2c4b6194 100644
--- a/src/net/tmwa/playerhandler.h
+++ b/src/net/tmwa/playerhandler.h
@@ -34,7 +34,7 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
public:
PlayerHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void attack(int id);
void emote(int emoteId);
diff --git a/src/net/tmwa/specialhandler.cpp b/src/net/tmwa/specialhandler.cpp
index b814cd41..7de0aaea 100644
--- a/src/net/tmwa/specialhandler.cpp
+++ b/src/net/tmwa/specialhandler.cpp
@@ -27,9 +27,8 @@
#include "gui/skilldialog.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
-
+#include "net/tmwa/messagein.h"
+#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
#include "utils/gettext.h"
@@ -82,7 +81,7 @@ SpecialHandler::SpecialHandler()
specialHandler = this;
}
-void SpecialHandler::handleMessage(Net::MessageIn &msg)
+void SpecialHandler::handleMessage(MessageIn &msg)
{
int skillCount;
int skillId;
diff --git a/src/net/tmwa/specialhandler.h b/src/net/tmwa/specialhandler.h
index 40223056..bb772ff1 100644
--- a/src/net/tmwa/specialhandler.h
+++ b/src/net/tmwa/specialhandler.h
@@ -34,7 +34,7 @@ class SpecialHandler : public MessageHandler, public Net::SpecialHandler
public:
SpecialHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void use(int id);
diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
index 66772468..40e37594 100644
--- a/src/net/tmwa/tradehandler.cpp
+++ b/src/net/tmwa/tradehandler.cpp
@@ -32,9 +32,9 @@
#include "gui/tradewindow.h"
#include "net/inventoryhandler.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
+#include "net/tmwa/messagein.h"
+#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
#include "resources/iteminfo.h"
@@ -81,7 +81,7 @@ TradeHandler::TradeHandler()
}
-void TradeHandler::handleMessage(Net::MessageIn &msg)
+void TradeHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
diff --git a/src/net/tmwa/tradehandler.h b/src/net/tmwa/tradehandler.h
index 443d763a..60ee4444 100644
--- a/src/net/tmwa/tradehandler.h
+++ b/src/net/tmwa/tradehandler.h
@@ -34,7 +34,7 @@ class TradeHandler : public MessageHandler, public Net::TradeHandler
public:
TradeHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(MessageIn &msg);
void request(Being *being);