summaryrefslogtreecommitdiff
path: root/src/net/manaserv
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/manaserv')
-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.cpp41
-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/manaserv_protocol.h36
-rw-r--r--src/net/manaserv/messagehandler.cpp2
-rw-r--r--src/net/manaserv/messagehandler.h7
-rw-r--r--src/net/manaserv/messagein.cpp85
-rw-r--r--src/net/manaserv/messagein.h59
-rw-r--r--src/net/manaserv/messageout.cpp66
-rw-r--r--src/net/manaserv/messageout.h51
-rw-r--r--src/net/manaserv/npchandler.cpp4
-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.cpp16
-rw-r--r--src/net/manaserv/specialhandler.h2
-rw-r--r--src/net/manaserv/tradehandler.cpp2
-rw-r--r--src/net/manaserv/tradehandler.h2
39 files changed, 427 insertions, 132 deletions
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 a8e662ec..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"
@@ -62,6 +61,7 @@ GuildHandler::GuildHandler()
CPMSG_GUILD_INVITED,
CPMSG_GUILD_REJOIN,
CPMSG_GUILD_QUIT_RESPONSE,
+ CPMSG_GUILD_KICK_NOTIFICATION,
0
};
handledMessages = _messages;
@@ -69,7 +69,7 @@ GuildHandler::GuildHandler()
guildHandler = this;
}
-void GuildHandler::handleMessage(Net::MessageIn &msg)
+void GuildHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
{
@@ -91,11 +91,20 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
case CPMSG_GUILD_INVITE_RESPONSE:
{
logger->log("Received CPMSG_GUILD_INVITE_RESPONSE");
- if (msg.readInt8() == ERRMSG_OK)
+ const unsigned char response = msg.readInt8();
+ if (response == ERRMSG_OK)
{
// TODO - Acknowledge invite was sent
SERVER_NOTICE(_("Invite sent."))
}
+ else if (response == ERRMSG_ALREADY_MEMBER)
+ {
+ SERVER_NOTICE(_("Invited player is already in that guild."));
+ }
+ else if (response == ERRMSG_LIMIT_REACHED)
+ {
+ SERVER_NOTICE(_("Invited player can't join another guild."));
+ }
} break;
case CPMSG_GUILD_ACCEPT_RESPONSE:
@@ -235,10 +244,27 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
}
}
} break;
+ case CPMSG_GUILD_KICK_NOTIFICATION:
+ {
+ logger->log("Received CPMSG_GUILD_KICK_NOTIFICATION");
+
+ const int guildId = msg.readInt16();
+ std::string player = msg.readString();
+ Guild *guild = local_player->getGuild(guildId);
+ if (guild)
+ {
+ Channel *channel = channelManager->findByName(guild->getName());
+ channelManager->removeChannel(channel);
+ local_player->removeGuild(guildId);
+ SERVER_NOTICE(strprintf(
+ _("Player %s kicked you out of guild %s"),
+ player.c_str(), guild->getName().c_str()));
+ }
+ } break;
}
}
-void GuildHandler::joinedGuild(Net::MessageIn &msg)
+void GuildHandler::joinedGuild(MessageIn &msg)
{
std::string guildName = msg.readString();
short guildId = msg.readInt16();
@@ -283,9 +309,10 @@ void GuildHandler::invite(int guildId, Being *being)
void GuildHandler::inviteResponse(int guildId, bool response)
{
- /*MessageOut msg(PCMSG_GUILD_ACCEPT);
- msg.writeString(name);
- chatServerConnection->send(msg);*/
+ MessageOut msg(PCMSG_GUILD_ACCEPT);
+ msg.writeInt16(guildId);
+ msg.writeInt8(response ? 1 : 0);
+ chatServerConnection->send(msg);
}
void GuildHandler::leave(int guildId)
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/manaserv_protocol.h b/src/net/manaserv/manaserv_protocol.h
index aa1976f1..5f94b726 100644
--- a/src/net/manaserv/manaserv_protocol.h
+++ b/src/net/manaserv/manaserv_protocol.h
@@ -26,7 +26,19 @@ namespace ManaServ {
enum {
PROTOCOL_VERSION = 1,
- SUPPORTED_DB_VERSION = 19
+ SUPPORTED_DB_VERSION = 21
+};
+
+/**
+ * The type of a value in a message. Prepended before each value when the
+ * protocol is running in debug mode.
+ */
+enum ValueType {
+ Int8,
+ Int16,
+ Int32,
+ String,
+ Double
};
/**
@@ -43,7 +55,7 @@ enum {
* Components: B byte, W word, D double word, S variable-size string
* C tile-based coordinates (B*3)
*
- * Hosts: P (player's client), A (account server), C (char server),
+ * Hosts: P (player's client), A (account server), C (chat server),
* G (game server)
*
* TODO - Document specific error codes for each packet
@@ -127,8 +139,9 @@ enum {
GPMSG_ITEMS = 0x0281, // { W item id, W*2 position }*
PGMSG_ATTACK = 0x0290, // W being id
GPMSG_BEING_ATTACK = 0x0291, // W being id, B direction, B attack Id
- PGMSG_USE_SPECIAL = 0x0292, // B specialID
+ PGMSG_USE_SPECIAL_ON_BEING = 0x0292, // B specialID, W being id
GPMSG_SPECIAL_STATUS = 0x0293, // { B specialID, D current, D max, D recharge }
+ PGMSG_USE_SPECIAL_ON_POINT = 0x0294, // B specialID, W*2 position
PGMSG_SAY = 0x02A0, // S text
GPMSG_SAY = 0x02A1, // W being id, S text
GPMSG_NPC_CHOICE = 0x02B0, // W being id, { S text }*
@@ -175,7 +188,7 @@ enum {
CPMSG_GUILD_CREATE_RESPONSE = 0x0351, // B error, W guild, B rights, W channel
PCMSG_GUILD_INVITE = 0x0352, // W id, S name
CPMSG_GUILD_INVITE_RESPONSE = 0x0353, // B error
- PCMSG_GUILD_ACCEPT = 0x0354, // W id
+ PCMSG_GUILD_ACCEPT = 0x0354, // W id, B accepted (0 if false, 1 if true)
CPMSG_GUILD_ACCEPT_RESPONSE = 0x0355, // B error, W guild, B rights, W channel
PCMSG_GUILD_GET_MEMBERS = 0x0356, // W id
CPMSG_GUILD_GET_MEMBERS_RESPONSE = 0x0357, // S names, B online
@@ -186,6 +199,7 @@ enum {
CPMSG_GUILD_PROMOTE_MEMBER_RESPONSE = 0x0366, // B error
PCMSG_GUILD_KICK_MEMBER = 0x0370, // W guild, S name
CPMSG_GUILD_KICK_MEMBER_RESPONSE = 0x0371, // B error
+ CPMSG_GUILD_KICK_NOTIFICATION = 0x0372, // W guild, S player that kicked
CPMSG_GUILD_INVITED = 0x0388, // S char name, S guild name, W id
CPMSG_GUILD_REJOIN = 0x0389, // S name, W guild, W rights, W channel, S announce
@@ -230,7 +244,7 @@ enum {
// Inter-server
GAMSG_REGISTER = 0x0500, // S address, W port, S password, D items db revision, { W map id }*
- AGMSG_REGISTER_RESPONSE = 0x0501, // C item version, C password response, { S globalvar_key, S globalvar_value }
+ AGMSG_REGISTER_RESPONSE = 0x0501, // W item version, W password response, { S globalvar_key, S globalvar_value }
AGMSG_ACTIVE_MAP = 0x0502, // W map id, W Number of mapvar_key mapvar_value sent, { S mapvar_key, S mapvar_value }, W Number of map items, { D item Id, W amount, W posX, W posY }
AGMSG_PLAYER_ENTER = 0x0510, // B*32 token, D id, S name, serialised character data
GAMSG_PLAYER_DATA = 0x0520, // D id, serialised character data
@@ -250,7 +264,7 @@ enum {
GAMSG_BAN_PLAYER = 0x0550, // D id, W duration
GAMSG_CHANGE_PLAYER_LEVEL = 0x0555, // D id, W level
GAMSG_CHANGE_ACCOUNT_LEVEL = 0x0556, // D id, W level
- GAMSG_STATISTICS = 0x0560, // { W map id, W thing nb, W monster nb, W player nb, { D character id }* }*
+ GAMSG_STATISTICS = 0x0560, // { W map id, W entity nb, W monster nb, W player nb, { D character id }* }*
CGMSG_CHANGED_PARTY = 0x0590, // D character id, D party id
GCMSG_REQUEST_POST = 0x05A0, // D character id
CGMSG_POST_RESPONSE = 0x05A1, // D receiver id, { S sender name, S letter, W num attachments { W attachment item id, W quantity } }
@@ -261,7 +275,8 @@ enum {
GAMSG_REMOVE_ITEM_ON_MAP = 0x0602, // D map id, D item id, W amount, W pos x, W pos y
GAMSG_ANNOUNCE = 0x0603, // S text, W senderid, S sendername
- XXMSG_INVALID = 0x7FFF
+ XXMSG_DEBUG_FLAG = 0x8000, // Message in debug mode
+ XXMSG_INVALID = 0x7FFF
};
// Generic return values
@@ -278,7 +293,8 @@ enum {
ERRMSG_SERVER_FULL, // the server is overloaded
ERRMSG_TIME_OUT, // data failed to arrive in due time
ERRMSG_LIMIT_REACHED, // limit reached
- ERRMSG_ADMINISTRATIVE_LOGOFF // kicked by server administrator
+ ERRMSG_ADMINISTRATIVE_LOGOFF, // kicked by server administrator
+ ERRMSG_ALREADY_MEMBER // is already member of guild/party
};
// used in AGMSG_REGISTER_RESPONSE to show state of item db
@@ -337,8 +353,8 @@ enum AttribmodResponseCode {
ATTRIBMOD_DENIED
};
-// Object type enumeration
-enum ThingType
+// Entity type enumeration
+enum EntityType
{
// A simple item.
OBJECT_ITEM = 0,
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..8065d313 100644
--- a/src/net/manaserv/messagein.cpp
+++ b/src/net/manaserv/messagein.cpp
@@ -27,15 +27,41 @@
namespace ManaServ {
MessageIn::MessageIn(const char *data, unsigned int length):
- Net::MessageIn(data, length)
+ mData(data),
+ mLength(length),
+ mDebugMode(false),
+ mPos(0)
{
// Read the message ID
mId = readInt16();
+
+ // Read and clear the debug flag
+ mDebugMode = mId & ManaServ::XXMSG_DEBUG_FLAG;
+ mId &= ~ManaServ::XXMSG_DEBUG_FLAG;
+}
+
+uint8_t MessageIn::readInt8()
+{
+ uint8_t value = 0;
+
+ if (!readValueType(ManaServ::Int8))
+ return value;
+
+ if (mPos < mLength)
+ {
+ value = mData[mPos];
+ }
+ mPos++;
+ return value;
}
uint16_t MessageIn::readInt16()
{
uint16_t value = 0;
+
+ if (!readValueType(ManaServ::Int16))
+ return value;
+
if (mPos + 2 <= mLength)
{
uint16_t t;
@@ -49,6 +75,10 @@ uint16_t MessageIn::readInt16()
uint32_t MessageIn::readInt32()
{
uint32_t value = 0;
+
+ if (!readValueType(ManaServ::Int32))
+ return value;
+
if (mPos + 4 <= mLength)
{
uint32_t t;
@@ -59,4 +89,57 @@ uint32_t MessageIn::readInt32()
return value;
}
+std::string MessageIn::readString(int length)
+{
+ if (!readValueType(ManaServ::String))
+ return std::string();
+
+ if (mDebugMode)
+ {
+ int fixedLength = (int16_t) readInt16();
+ if (fixedLength != length)
+ {
+ // String does not have the expected length
+ mPos = mLength + 1;
+ return std::string();
+ }
+ }
+
+ // 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 std::string();
+ }
+
+ // Read the string
+ const char *stringBeg = mData + mPos;
+ const char *stringEnd = (const char *)memchr(stringBeg, '\0', length);
+ std::string readString(stringBeg,
+ stringEnd ? stringEnd - stringBeg : length);
+ mPos += length;
+
+ return readString;
+}
+
+bool MessageIn::readValueType(ManaServ::ValueType type)
+{
+ if (!mDebugMode) // Verification not possible
+ return true;
+
+ if (mPos >= mLength)
+ return false;
+
+ uint8_t t = mData[mPos];
+ ++mPos;
+
+ return t == type;
}
+
+} // ManaServ
diff --git a/src/net/manaserv/messagein.h b/src/net/manaserv/messagein.h
index 97e68812..89ae5ed8 100644
--- a/src/net/manaserv/messagein.h
+++ b/src/net/manaserv/messagein.h
@@ -22,24 +22,75 @@
#ifndef NET_MANASERV_MESSAGEIN_H
#define NET_MANASERV_MESSAGEIN_H
-#include "net/messagein.h"
+#include "net/manaserv/manaserv_protocol.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:
+ bool readValueType(ManaServ::ValueType type);
+
+ const char *mData; /**< The message data. */
+ unsigned int mLength; /**< The length of the data. */
+ unsigned short mId; /**< The message ID. */
+ bool mDebugMode; /**< Includes debugging information. */
+
+ /**
+ * 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..1197176f 100644
--- a/src/net/manaserv/messageout.cpp
+++ b/src/net/manaserv/messageout.cpp
@@ -28,9 +28,17 @@
namespace ManaServ {
MessageOut::MessageOut(uint16_t id):
- Net::MessageOut(id)
+ mData(0),
+ mPos(0),
+ mDataSize(0),
+ mDebugMode(false)
{
+ bool debug = true;
+ if (debug)
+ id |= ManaServ::XXMSG_DEBUG_FLAG;
+
writeInt16(id);
+ mDebugMode = debug;
}
MessageOut::~MessageOut()
@@ -44,8 +52,21 @@ void MessageOut::expand(size_t bytes)
mDataSize = mPos + bytes;
}
+void MessageOut::writeInt8(uint8_t value)
+{
+ if (mDebugMode)
+ writeValueType(ManaServ::Int8);
+
+ expand(1);
+ mData[mPos] = value;
+ mPos += 1;
+}
+
void MessageOut::writeInt16(uint16_t value)
{
+ if (mDebugMode)
+ writeValueType(ManaServ::Int16);
+
expand(2);
uint16_t t = ENET_HOST_TO_NET_16(value);
memcpy(mData + mPos, &t, 2);
@@ -54,10 +75,53 @@ void MessageOut::writeInt16(uint16_t value)
void MessageOut::writeInt32(uint32_t value)
{
+ if (mDebugMode)
+ writeValueType(ManaServ::Int32);
+
expand(4);
uint32_t t = ENET_HOST_TO_NET_32(value);
memcpy(mData + mPos, &t, 4);
mPos += 4;
}
+void MessageOut::writeString(const std::string &string, int length)
+{
+ if (mDebugMode)
+ {
+ writeValueType(ManaServ::String);
+ writeInt16(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);
+
+ if (length > stringLength)
+ {
+ // Pad remaining space with zeros
+ memset(mData + mPos + stringLength, '\0', length - stringLength);
+ }
+ mPos += length;
+}
+
+void MessageOut::writeValueType(ManaServ::ValueType type)
+{
+ expand(1);
+ mData[mPos] = type;
+ mPos += 1;
+}
+
} // namespace ManaServ
diff --git a/src/net/manaserv/messageout.h b/src/net/manaserv/messageout.h
index 59fc148f..d452f784 100644
--- a/src/net/manaserv/messageout.h
+++ b/src/net/manaserv/messageout.h
@@ -22,21 +22,57 @@
#ifndef NET_MANASERV_MESSAGEOUT_H
#define NET_MANASERV_MESSAGEOUT_H
-#include "net/messageout.h"
+#include "net/manaserv/manaserv_protocol.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 +81,15 @@ class MessageOut : public Net::MessageOut
* added.
*/
void expand(size_t size);
+
+ void writeValueType(ManaServ::ValueType type);
+
+ char *mData; /**< Data building up. */
+ unsigned int mPos; /**< Position in the data. */
+ unsigned int mDataSize; /**< Size of data. */
+ bool mDebugMode; /**< Include debugging information. */
};
-}
+} // namespace ManaServ
#endif // NET_MANASERV_MESSAGEOUT_H
diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp
index 71b761ab..502df13d 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)
@@ -108,7 +108,7 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
case GPMSG_NPC_MESSAGE:
event = new Event(Event::Message);
event->setInt("id", npcId);
- event->setString("text", msg.readString(msg.getUnreadLength()));
+ event->setString("text", msg.readString());
event->trigger(Event::NpcChannel);
delete event;
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 fa98cd48..0a477ff8 100644
--- a/src/net/manaserv/specialhandler.cpp
+++ b/src/net/manaserv/specialhandler.cpp
@@ -37,26 +37,34 @@ SpecialHandler::SpecialHandler()
specialHandler = this;
}
-void SpecialHandler::handleMessage(Net::MessageIn &msg)
+void SpecialHandler::handleMessage(MessageIn &msg)
{
// TODO
}
void SpecialHandler::use(int id)
{
- MessageOut msg(PGMSG_USE_SPECIAL);
+ MessageOut msg(PGMSG_USE_SPECIAL_ON_BEING);
msg.writeInt8(id);
+ msg.writeInt16(0);
gameServerConnection->send(msg);
}
void SpecialHandler::use(int id, int level, int beingId)
{
- // TODO
+ MessageOut msg(PGMSG_USE_SPECIAL_ON_BEING);
+ msg.writeInt8(id);
+ msg.writeInt16(beingId);
+ gameServerConnection->send(msg);
}
void SpecialHandler::use(int id, int level, int x, int y)
{
- // TODO
+ MessageOut msg(PGMSG_USE_SPECIAL_ON_POINT);
+ msg.writeInt8(id);
+ msg.writeInt16(x);
+ msg.writeInt16(y);
+ gameServerConnection->send(msg);
}
void SpecialHandler::use(int id, const std::string &map)
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.