summaryrefslogtreecommitdiff
path: root/src/net/manaserv
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/manaserv')
-rw-r--r--src/net/manaserv/accountserver/account.cpp27
-rw-r--r--src/net/manaserv/accountserver/account.h8
-rw-r--r--src/net/manaserv/accountserver/accountserver.cpp34
-rw-r--r--src/net/manaserv/accountserver/accountserver.h14
-rw-r--r--src/net/manaserv/accountserver/internal.cpp2
-rw-r--r--src/net/manaserv/accountserver/internal.h8
-rw-r--r--src/net/manaserv/adminhandler.cpp2
-rw-r--r--src/net/manaserv/beinghandler.cpp22
-rw-r--r--src/net/manaserv/beinghandler.h20
-rw-r--r--src/net/manaserv/buysellhandler.cpp2
-rw-r--r--src/net/manaserv/buysellhandler.h4
-rw-r--r--src/net/manaserv/charhandler.cpp19
-rw-r--r--src/net/manaserv/charhandler.h8
-rw-r--r--src/net/manaserv/chathandler.cpp54
-rw-r--r--src/net/manaserv/chathandler.h26
-rw-r--r--src/net/manaserv/chatserver/chatserver.cpp15
-rw-r--r--src/net/manaserv/chatserver/chatserver.h10
-rw-r--r--src/net/manaserv/chatserver/guild.cpp32
-rw-r--r--src/net/manaserv/chatserver/guild.h8
-rw-r--r--src/net/manaserv/chatserver/internal.cpp2
-rw-r--r--src/net/manaserv/chatserver/internal.h8
-rw-r--r--src/net/manaserv/chatserver/party.cpp28
-rw-r--r--src/net/manaserv/chatserver/party.h8
-rw-r--r--src/net/manaserv/connection.cpp24
-rw-r--r--src/net/manaserv/connection.h12
-rw-r--r--src/net/manaserv/effecthandler.cpp6
-rw-r--r--src/net/manaserv/effecthandler.h10
-rw-r--r--src/net/manaserv/gamehandler.cpp7
-rw-r--r--src/net/manaserv/gamehandler.h8
-rw-r--r--src/net/manaserv/gameserver/gameserver.cpp17
-rw-r--r--src/net/manaserv/gameserver/gameserver.h10
-rw-r--r--src/net/manaserv/gameserver/internal.cpp2
-rw-r--r--src/net/manaserv/gameserver/internal.h8
-rw-r--r--src/net/manaserv/gameserver/player.cpp22
-rw-r--r--src/net/manaserv/gameserver/player.h8
-rw-r--r--src/net/manaserv/generalhandler.cpp51
-rw-r--r--src/net/manaserv/generalhandler.h3
-rw-r--r--src/net/manaserv/guildhandler.cpp4
-rw-r--r--src/net/manaserv/guildhandler.h6
-rw-r--r--src/net/manaserv/internal.cpp2
-rw-r--r--src/net/manaserv/internal.h2
-rw-r--r--src/net/manaserv/inventoryhandler.cpp32
-rw-r--r--src/net/manaserv/inventoryhandler.h11
-rw-r--r--src/net/manaserv/itemhandler.cpp4
-rw-r--r--src/net/manaserv/itemhandler.h6
-rw-r--r--src/net/manaserv/loginhandler.cpp26
-rw-r--r--src/net/manaserv/loginhandler.h12
-rw-r--r--src/net/manaserv/messagehandler.cpp35
-rw-r--r--src/net/manaserv/messagehandler.h43
-rw-r--r--src/net/manaserv/messagein.cpp65
-rw-r--r--src/net/manaserv/messagein.h48
-rw-r--r--src/net/manaserv/messageout.cpp64
-rw-r--r--src/net/manaserv/messageout.h58
-rw-r--r--src/net/manaserv/network.cpp28
-rw-r--r--src/net/manaserv/network.h14
-rw-r--r--src/net/manaserv/npchandler.cpp25
-rw-r--r--src/net/manaserv/npchandler.h7
-rw-r--r--src/net/manaserv/partyhandler.cpp14
-rw-r--r--src/net/manaserv/partyhandler.h8
-rw-r--r--src/net/manaserv/playerhandler.cpp32
-rw-r--r--src/net/manaserv/playerhandler.h13
-rw-r--r--src/net/manaserv/specialhandler.cpp8
-rw-r--r--src/net/manaserv/specialhandler.h7
-rw-r--r--src/net/manaserv/tradehandler.cpp24
-rw-r--r--src/net/manaserv/tradehandler.h7
65 files changed, 758 insertions, 396 deletions
diff --git a/src/net/manaserv/accountserver/account.cpp b/src/net/manaserv/accountserver/account.cpp
index f34139da..e680d9d5 100644
--- a/src/net/manaserv/accountserver/account.cpp
+++ b/src/net/manaserv/accountserver/account.cpp
@@ -24,15 +24,14 @@
#include "internal.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/messageout.h"
-
#include "utils/sha256.h"
#include <string>
-void Net::AccountServer::Account::createCharacter(
+void ManaServ::AccountServer::Account::createCharacter(
const std::string &name, char hairStyle, char hairColor, char gender,
short strength, short agility, short vitality,
short intelligence, short dexterity, short willpower)
@@ -50,28 +49,28 @@ void Net::AccountServer::Account::createCharacter(
msg.writeInt16(dexterity);
msg.writeInt16(willpower);
- Net::AccountServer::connection->send(msg);
+ ManaServ::AccountServer::connection->send(msg);
}
-void Net::AccountServer::Account::deleteCharacter(char slot)
+void ManaServ::AccountServer::Account::deleteCharacter(char slot)
{
MessageOut msg(PAMSG_CHAR_DELETE);
msg.writeInt8(slot);
- Net::AccountServer::connection->send(msg);
+ ManaServ::AccountServer::connection->send(msg);
}
-void Net::AccountServer::Account::selectCharacter(char slot)
+void ManaServ::AccountServer::Account::selectCharacter(char slot)
{
MessageOut msg(PAMSG_CHAR_SELECT);
msg.writeInt8(slot);
- Net::AccountServer::connection->send(msg);
+ ManaServ::AccountServer::connection->send(msg);
}
-void Net::AccountServer::Account::unregister(const std::string &username,
+void ManaServ::AccountServer::Account::unregister(const std::string &username,
const std::string &password)
{
MessageOut msg(PAMSG_UNREGISTER);
@@ -79,10 +78,10 @@ void Net::AccountServer::Account::unregister(const std::string &username,
msg.writeString(username);
msg.writeString(sha256(username + password));
- Net::AccountServer::connection->send(msg);
+ ManaServ::AccountServer::connection->send(msg);
}
-void Net::AccountServer::Account::changeEmail(const std::string &email)
+void ManaServ::AccountServer::Account::changeEmail(const std::string &email)
{
MessageOut msg(PAMSG_EMAIL_CHANGE);
@@ -90,10 +89,10 @@ void Net::AccountServer::Account::changeEmail(const std::string &email)
// Encryption is assumed server-side.
msg.writeString(email);
- Net::AccountServer::connection->send(msg);
+ ManaServ::AccountServer::connection->send(msg);
}
-void Net::AccountServer::Account::changePassword(
+void ManaServ::AccountServer::Account::changePassword(
const std::string &username,
const std::string &oldPassword,
const std::string &newPassword)
@@ -104,5 +103,5 @@ void Net::AccountServer::Account::changePassword(
msg.writeString(sha256(username + oldPassword));
msg.writeString(sha256(username + newPassword));
- Net::AccountServer::connection->send(msg);
+ ManaServ::AccountServer::connection->send(msg);
}
diff --git a/src/net/manaserv/accountserver/account.h b/src/net/manaserv/accountserver/account.h
index 03e83881..03453655 100644
--- a/src/net/manaserv/accountserver/account.h
+++ b/src/net/manaserv/accountserver/account.h
@@ -19,12 +19,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef NET_ACCOUNTSERVER_CHARACTER_H
-#define NET_ACCOUNTSERVER_CHARACTER_H
+#ifndef NET_MANASERV_ACCOUNTSERVER_CHARACTER_H
+#define NET_MANASERV_ACCOUNTSERVER_CHARACTER_H
#include <iosfwd>
-namespace Net
+namespace ManaServ
{
namespace AccountServer
{
@@ -51,4 +51,4 @@ namespace Net
}
}
-#endif
+#endif // NET_MANASERV_ACCOUNTSERVER_CHARACTER_H
diff --git a/src/net/manaserv/accountserver/accountserver.cpp b/src/net/manaserv/accountserver/accountserver.cpp
index 72f05aeb..afbee4ab 100644
--- a/src/net/manaserv/accountserver/accountserver.cpp
+++ b/src/net/manaserv/accountserver/accountserver.cpp
@@ -24,18 +24,20 @@
#include "internal.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/messageout.h"
-
#include "utils/sha256.h"
#include <string>
-void Net::AccountServer::login(Net::Connection *connection, int version,
- const std::string &username, const std::string &password)
+namespace ManaServ
+{
+
+void AccountServer::login(Connection *connection,
+ int version, const std::string &username, const std::string &password)
{
- Net::AccountServer::connection = connection;
+ AccountServer::connection = connection;
MessageOut msg(PAMSG_LOGIN);
@@ -43,14 +45,14 @@ void Net::AccountServer::login(Net::Connection *connection, int version,
msg.writeString(username);
msg.writeString(sha256(username + password));
- Net::AccountServer::connection->send(msg);
+ AccountServer::connection->send(msg);
}
-void Net::AccountServer::registerAccount(Net::Connection *connection,
+void AccountServer::registerAccount(Connection *connection,
int version, const std::string &username, const std::string &password,
const std::string &email)
{
- Net::AccountServer::connection = connection;
+ AccountServer::connection = connection;
MessageOut msg(PAMSG_REGISTER);
@@ -62,21 +64,23 @@ void Net::AccountServer::registerAccount(Net::Connection *connection,
msg.writeString(password);
msg.writeString(email);
- Net::AccountServer::connection->send(msg);
+ AccountServer::connection->send(msg);
}
-void Net::AccountServer::logout()
+void AccountServer::logout()
{
MessageOut msg(PAMSG_LOGOUT);
- Net::AccountServer::connection->send(msg);
+ AccountServer::connection->send(msg);
}
-void Net::AccountServer::reconnectAccount(Net::Connection *connection,
- const std::string &passToken)
+void AccountServer::reconnectAccount(Connection *connection,
+ const std::string &passToken)
{
- Net::AccountServer::connection = connection;
+ AccountServer::connection = connection;
MessageOut msg(PAMSG_RECONNECT);
msg.writeString(passToken, 32);
- Net::AccountServer::connection->send(msg);
+ AccountServer::connection->send(msg);
+}
+
}
diff --git a/src/net/manaserv/accountserver/accountserver.h b/src/net/manaserv/accountserver/accountserver.h
index dd62fd25..a1bbb5f5 100644
--- a/src/net/manaserv/accountserver/accountserver.h
+++ b/src/net/manaserv/accountserver/accountserver.h
@@ -19,29 +19,29 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef NET_ACCOUNTSERVER_ACCOUNTSERVER_H
-#define NET_ACCOUNTSERVER_ACCOUNTSERVER_H
+#ifndef NET_MANASERV_ACCOUNTSERVER_ACCOUNTSERVER_H
+#define NET_MANASERV_ACCOUNTSERVER_ACCOUNTSERVER_H
#include <iosfwd>
-namespace Net
+namespace ManaServ
{
class Connection;
namespace AccountServer
{
- void login(Net::Connection *connection, int version,
+ void login(ManaServ::Connection *connection, int version,
const std::string &username, const std::string &password);
- void registerAccount(Net::Connection *connection, int version,
+ void registerAccount(ManaServ::Connection *connection, int version,
const std::string &username, const std::string &password,
const std::string &email);
void logout();
- void reconnectAccount(Net::Connection *connection,
+ void reconnectAccount(ManaServ::Connection *connection,
const std::string &passToken);
}
}
-#endif
+#endif // NET_MANASERV_ACCOUNTSERVER_ACCOUNTSERVER_H
diff --git a/src/net/manaserv/accountserver/internal.cpp b/src/net/manaserv/accountserver/internal.cpp
index de1d412c..e1d105b7 100644
--- a/src/net/manaserv/accountserver/internal.cpp
+++ b/src/net/manaserv/accountserver/internal.cpp
@@ -21,7 +21,7 @@
#include "internal.h"
-namespace Net
+namespace ManaServ
{
class Connection;
diff --git a/src/net/manaserv/accountserver/internal.h b/src/net/manaserv/accountserver/internal.h
index ff741872..af91f692 100644
--- a/src/net/manaserv/accountserver/internal.h
+++ b/src/net/manaserv/accountserver/internal.h
@@ -19,10 +19,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef NET_ACCOUNTSERVER_INTERNAL_H
-#define NET_ACCOUNTSERVER_INTERNAL_H
+#ifndef NET_MANASERV_ACCOUNTSERVER_INTERNAL_H
+#define NET_MANASERV_ACCOUNTSERVER_INTERNAL_H
-namespace Net
+namespace ManaServ
{
class Connection;
@@ -32,4 +32,4 @@ namespace Net
}
}
-#endif
+#endif // NET_MANASERV_ACCOUNTSERVER_INTERNAL_H
diff --git a/src/net/manaserv/adminhandler.cpp b/src/net/manaserv/adminhandler.cpp
index 72ae01d0..abdf86ef 100644
--- a/src/net/manaserv/adminhandler.cpp
+++ b/src/net/manaserv/adminhandler.cpp
@@ -34,7 +34,7 @@ AdminHandler::AdminHandler()
void AdminHandler::announce(const std::string &text)
{
- Net::ChatServer::announce(text);
+ ManaServ::ChatServer::announce(text);
}
void AdminHandler::localAnnounce(const std::string &text)
diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp
index d8508f01..71325fd5 100644
--- a/src/net/manaserv/beinghandler.cpp
+++ b/src/net/manaserv/beinghandler.cpp
@@ -61,7 +61,7 @@ BeingHandler::BeingHandler()
handledMessages = _messages;
}
-void BeingHandler::handleMessage(MessageIn &msg)
+void BeingHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
@@ -92,7 +92,7 @@ void BeingHandler::handleMessage(MessageIn &msg)
}
}
-static void handleLooks(Player *being, MessageIn &msg)
+static void handleLooks(Player *being, Net::MessageIn &msg)
{
// Order of sent slots. Has to be in sync with the server code.
static int const nb_slots = 4;
@@ -120,7 +120,7 @@ static void handleLooks(Player *being, MessageIn &msg)
}
}
-void BeingHandler::handleBeingEnterMessage(MessageIn &msg)
+void BeingHandler::handleBeingEnterMessage(Net::MessageIn &msg)
{
int type = msg.readInt8();
int id = msg.readInt16();
@@ -171,7 +171,7 @@ void BeingHandler::handleBeingEnterMessage(MessageIn &msg)
being->setAction(action);
}
-void BeingHandler::handleBeingLeaveMessage(MessageIn &msg)
+void BeingHandler::handleBeingLeaveMessage(Net::MessageIn &msg)
{
Being *being = beingManager->findBeing(msg.readInt16());
if (!being)
@@ -180,7 +180,7 @@ void BeingHandler::handleBeingLeaveMessage(MessageIn &msg)
beingManager->destroyBeing(being);
}
-void BeingHandler::handleBeingsMoveMessage(MessageIn &msg)
+void BeingHandler::handleBeingsMoveMessage(Net::MessageIn &msg)
{
while (msg.getUnreadLength())
{
@@ -220,7 +220,7 @@ void BeingHandler::handleBeingsMoveMessage(MessageIn &msg)
}
}
-void BeingHandler::handleBeingAttackMessage(MessageIn &msg)
+void BeingHandler::handleBeingAttackMessage(Net::MessageIn &msg)
{
Being *being = beingManager->findBeing(msg.readInt16());
const int direction = msg.readInt8();
@@ -240,7 +240,7 @@ void BeingHandler::handleBeingAttackMessage(MessageIn &msg)
being->setAction(Being::ATTACK, attackType);
}
-void BeingHandler::handleBeingsDamageMessage(MessageIn &msg)
+void BeingHandler::handleBeingsDamageMessage(Net::MessageIn &msg)
{
while (msg.getUnreadLength())
{
@@ -253,7 +253,7 @@ void BeingHandler::handleBeingsDamageMessage(MessageIn &msg)
}
}
-void BeingHandler::handleBeingActionChangeMessage(MessageIn &msg)
+void BeingHandler::handleBeingActionChangeMessage(Net::MessageIn &msg)
{
Being *being = beingManager->findBeing(msg.readInt16());
Being::Action action = (Being::Action) msg.readInt8();
@@ -288,11 +288,11 @@ void BeingHandler::handleBeingActionChangeMessage(MessageIn &msg)
std::string message(deadMsg[rand()%13]);
message.append(std::string(" ") + _("Press OK to respawn."));
OkDialog *dlg = new OkDialog(_("You Died"), message);
- dlg->addActionListener(&(Net::GameServer::Player::respawnListener));
+ dlg->addActionListener(&(ManaServ::GameServer::Player::respawnListener));
}
}
-void BeingHandler::handleBeingLooksChangeMessage(MessageIn &msg)
+void BeingHandler::handleBeingLooksChangeMessage(Net::MessageIn &msg)
{
Being *being = beingManager->findBeing(msg.readInt16());
if (!being || being->getType() != Being::PLAYER)
@@ -307,7 +307,7 @@ void BeingHandler::handleBeingLooksChangeMessage(MessageIn &msg)
}
}
-void BeingHandler::handleBeingDirChangeMessage(MessageIn &msg)
+void BeingHandler::handleBeingDirChangeMessage(Net::MessageIn &msg)
{
Being *being = beingManager->findBeing(msg.readInt16());
if (!being)
diff --git a/src/net/manaserv/beinghandler.h b/src/net/manaserv/beinghandler.h
index 4ece08e1..0da4a296 100644
--- a/src/net/manaserv/beinghandler.h
+++ b/src/net/manaserv/beinghandler.h
@@ -22,7 +22,7 @@
#ifndef NET_MANASERV_BEINGHANDLER_H
#define NET_MANASERV_BEINGHANDLER_H
-#include "net/messagehandler.h"
+#include "net/manaserv/messagehandler.h"
namespace ManaServ {
@@ -31,17 +31,17 @@ class BeingHandler : public MessageHandler
public:
BeingHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
private:
- 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);
+ 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);
};
} // namespace ManaServ
diff --git a/src/net/manaserv/buysellhandler.cpp b/src/net/manaserv/buysellhandler.cpp
index f7dc91a4..9f3e65ad 100644
--- a/src/net/manaserv/buysellhandler.cpp
+++ b/src/net/manaserv/buysellhandler.cpp
@@ -50,7 +50,7 @@ BuySellHandler::BuySellHandler()
handledMessages = _messages;
}
-void BuySellHandler::handleMessage(MessageIn &msg)
+void BuySellHandler::handleMessage(Net::MessageIn &msg)
{
Being *being = beingManager->findBeing(msg.readInt16());
if (!being || being->getType() != Being::NPC)
diff --git a/src/net/manaserv/buysellhandler.h b/src/net/manaserv/buysellhandler.h
index 9d31e739..32e0009b 100644
--- a/src/net/manaserv/buysellhandler.h
+++ b/src/net/manaserv/buysellhandler.h
@@ -22,7 +22,7 @@
#ifndef NET_MANASERV_BUYSELLHANDLER_H
#define NET_MANASERV_BUYSELLHANDLER_H
-#include "net/messagehandler.h"
+#include "net/manaserv/messagehandler.h"
namespace ManaServ {
@@ -31,7 +31,7 @@ class BuySellHandler : public MessageHandler
public:
BuySellHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
};
} // namespace ManaServ
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp
index e7a99e8d..a08799f9 100644
--- a/src/net/manaserv/charhandler.cpp
+++ b/src/net/manaserv/charhandler.cpp
@@ -44,10 +44,6 @@
#include "utils/gettext.h"
-extern Net::Connection *accountServerConnection;
-extern Net::Connection *gameServerConnection;
-extern Net::Connection *chatServerConnection;
-
Net::CharHandler *charHandler;
struct CharInfo {
@@ -67,6 +63,9 @@ CharInfos chars;
namespace ManaServ {
+extern Connection *accountServerConnection;
+extern Connection *gameServerConnection;
+extern Connection *chatServerConnection;
extern std::string netToken;
extern ServerInfo gameServer;
extern ServerInfo chatServer;
@@ -86,7 +85,7 @@ CharHandler::CharHandler():
charHandler = this;
}
-void CharHandler::handleMessage(MessageIn &msg)
+void CharHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
@@ -182,7 +181,7 @@ void CharHandler::handleMessage(MessageIn &msg)
}
}
-void CharHandler::handleCharCreateResponse(MessageIn &msg)
+void CharHandler::handleCharCreateResponse(Net::MessageIn &msg)
{
int errMsg = msg.readInt8();
@@ -243,7 +242,7 @@ void CharHandler::handleCharCreateResponse(MessageIn &msg)
}
-void CharHandler::handleCharSelectResponse(MessageIn &msg)
+void CharHandler::handleCharSelectResponse(Net::MessageIn &msg)
{
int errMsg = msg.readInt8();
@@ -360,13 +359,13 @@ void CharHandler::getCharacters()
void CharHandler::chooseCharacter(int slot, LocalPlayer* character)
{
- Net::AccountServer::Account::selectCharacter(slot);
+ AccountServer::Account::selectCharacter(slot);
}
void CharHandler::newCharacter(const std::string &name, int slot, bool gender,
int hairstyle, int hairColor, std::vector<int> stats)
{
- Net::AccountServer::Account::createCharacter(name, hairstyle, hairColor,
+ AccountServer::Account::createCharacter(name, hairstyle, hairColor,
gender,
stats[0], // STR
stats[1], // AGI
@@ -379,7 +378,7 @@ void CharHandler::newCharacter(const std::string &name, int slot, bool gender,
void CharHandler::deleteCharacter(int slot, LocalPlayer* character)
{
- Net::AccountServer::Account::deleteCharacter(slot);
+ AccountServer::Account::deleteCharacter(slot);
}
void CharHandler::switchCharacter()
diff --git a/src/net/manaserv/charhandler.h b/src/net/manaserv/charhandler.h
index 5fa57faf..6131412b 100644
--- a/src/net/manaserv/charhandler.h
+++ b/src/net/manaserv/charhandler.h
@@ -26,7 +26,7 @@
#include "gui/charselectdialog.h"
-#include "net/messagehandler.h"
+#include "net/manaserv/messagehandler.h"
class LoginData;
@@ -40,7 +40,7 @@ class CharHandler : public MessageHandler, public Net::CharHandler
public:
CharHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void setCharInfo(LockedArray<LocalPlayer*> *charInfo)
{
@@ -69,9 +69,9 @@ class CharHandler : public MessageHandler, public Net::CharHandler
void switchCharacter();
protected:
- void handleCharCreateResponse(MessageIn &msg);
+ void handleCharCreateResponse(Net::MessageIn &msg);
- void handleCharSelectResponse(MessageIn &msg);
+ void handleCharSelectResponse(Net::MessageIn &msg);
LockedArray<LocalPlayer*> *mCharInfo;
CharSelectDialog *mCharSelectDialog;
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index 5b85ed53..c4c86d62 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -22,6 +22,8 @@
#include "net/manaserv/chathandler.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messagein.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
#include "net/manaserv/chatserver/chatserver.h"
@@ -30,9 +32,6 @@
#include "net/manaserv/gameserver/internal.h"
#include "net/manaserv/gameserver/player.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
-
#include "being.h"
#include "beingmanager.h"
#include "channel.h"
@@ -54,10 +53,9 @@ extern Being *player_node;
Net::ChatHandler *chatHandler;
-extern Net::Connection *chatServerConnection;
-
namespace ManaServ {
+extern Connection *chatServerConnection;
extern std::string netToken;
extern ServerInfo chatServer;
@@ -81,7 +79,7 @@ ChatHandler::ChatHandler()
chatHandler = this;
}
-void ChatHandler::handleMessage(MessageIn &msg)
+void ChatHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
@@ -149,7 +147,7 @@ void ChatHandler::handleMessage(MessageIn &msg)
}
}
-void ChatHandler::handleGameChatMessage(MessageIn &msg)
+void ChatHandler::handleGameChatMessage(Net::MessageIn &msg)
{
short id = msg.readInt16();
std::string chatMsg = msg.readString();
@@ -174,7 +172,7 @@ void ChatHandler::handleGameChatMessage(MessageIn &msg)
localChatTab->chatLog(mes, being == player_node ? BY_PLAYER : BY_OTHER);
}
-void ChatHandler::handleEnterChannelResponse(MessageIn &msg)
+void ChatHandler::handleEnterChannelResponse(Net::MessageIn &msg)
{
if(msg.readInt8() == ERRMSG_OK)
{
@@ -209,7 +207,7 @@ void ChatHandler::handleEnterChannelResponse(MessageIn &msg)
}
}
-void ChatHandler::handleListChannelsResponse(MessageIn &msg)
+void ChatHandler::handleListChannelsResponse(Net::MessageIn &msg)
{
localChatTab->chatLog(_("Listing channels."), BY_SERVER);
while(msg.getUnreadLength())
@@ -226,7 +224,7 @@ void ChatHandler::handleListChannelsResponse(MessageIn &msg)
localChatTab->chatLog(_("End of channel list."), BY_SERVER);
}
-void ChatHandler::handlePrivateMessage(MessageIn &msg)
+void ChatHandler::handlePrivateMessage(Net::MessageIn &msg)
{
std::string userNick = msg.readString();
std::string chatMsg = msg.readString();
@@ -234,13 +232,13 @@ void ChatHandler::handlePrivateMessage(MessageIn &msg)
chatWindow->whisper(userNick, chatMsg);
}
-void ChatHandler::handleAnnouncement(MessageIn &msg)
+void ChatHandler::handleAnnouncement(Net::MessageIn &msg)
{
std::string chatMsg = msg.readString();
localChatTab->chatLog(chatMsg, BY_GM);
}
-void ChatHandler::handleChatMessage(MessageIn &msg)
+void ChatHandler::handleChatMessage(Net::MessageIn &msg)
{
short channelId = msg.readInt16();
std::string userNick = msg.readString();
@@ -250,7 +248,7 @@ void ChatHandler::handleChatMessage(MessageIn &msg)
channel->getTab()->chatLog(userNick, chatMsg);
}
-void ChatHandler::handleQuitChannelResponse(MessageIn &msg)
+void ChatHandler::handleQuitChannelResponse(Net::MessageIn &msg)
{
if(msg.readInt8() == ERRMSG_OK)
{
@@ -260,7 +258,7 @@ void ChatHandler::handleQuitChannelResponse(MessageIn &msg)
}
}
-void ChatHandler::handleListChannelUsersResponse(MessageIn &msg)
+void ChatHandler::handleListChannelUsersResponse(Net::MessageIn &msg)
{
std::string channelName = msg.readString();
std::string userNick;
@@ -283,7 +281,7 @@ void ChatHandler::handleListChannelUsersResponse(MessageIn &msg)
}
}
-void ChatHandler::handleChannelEvent(MessageIn &msg)
+void ChatHandler::handleChannelEvent(Net::MessageIn &msg)
{
short channelId = msg.readInt16();
char eventId = msg.readInt8();
@@ -337,7 +335,7 @@ void ChatHandler::handleChannelEvent(MessageIn &msg)
}
}
-void ChatHandler::handleWhoResponse(MessageIn &msg)
+void ChatHandler::handleWhoResponse(Net::MessageIn &msg)
{
std::string userNick;
@@ -354,7 +352,7 @@ void ChatHandler::handleWhoResponse(MessageIn &msg)
void ChatHandler::connect()
{
- Net::ChatServer::connect(chatServerConnection, netToken);
+ ChatServer::connect(chatServerConnection, netToken);
}
bool ChatHandler::isConnected()
@@ -371,7 +369,7 @@ void ChatHandler::talk(const std::string &text)
{
MessageOut msg(PGMSG_SAY);
msg.writeString(text);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void ChatHandler::me(const std::string &text)
@@ -385,13 +383,13 @@ void ChatHandler::privateMessage(const std::string &recipient,
MessageOut msg(PCMSG_PRIVMSG);
msg.writeString(recipient);
msg.writeString(text);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
void ChatHandler::channelList()
{
MessageOut msg(PCMSG_LIST_CHANNELS);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
void ChatHandler::enterChannel(const std::string &channel,
@@ -400,14 +398,14 @@ void ChatHandler::enterChannel(const std::string &channel,
MessageOut msg(PCMSG_ENTER_CHANNEL);
msg.writeString(channel);
msg.writeString(password);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
void ChatHandler::quitChannel(int channelId)
{
MessageOut msg(PCMSG_QUIT_CHANNEL);
msg.writeInt16(channelId);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
void ChatHandler::sendToChannel(int channelId, const std::string &text)
@@ -415,14 +413,14 @@ void ChatHandler::sendToChannel(int channelId, const std::string &text)
MessageOut msg(PCMSG_CHAT);
msg.writeString(text);
msg.writeInt16(channelId);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
void ChatHandler::userList(const std::string &channel)
{
MessageOut msg(PCMSG_LIST_CHANNELUSERS);
msg.writeString(channel);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
void ChatHandler::setChannelTopic(int channelId, const std::string &text)
@@ -430,7 +428,7 @@ void ChatHandler::setChannelTopic(int channelId, const std::string &text)
MessageOut msg(PCMSG_TOPIC_CHANGE);
msg.writeInt16(channelId);
msg.writeString(text);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
void ChatHandler::setUserMode(int channelId, const std::string &name, int mode)
@@ -439,7 +437,7 @@ void ChatHandler::setUserMode(int channelId, const std::string &name, int mode)
msg.writeInt16(channelId);
msg.writeString(name);
msg.writeInt8(mode);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
void ChatHandler::kickUser(int channelId, const std::string &name)
@@ -447,13 +445,13 @@ void ChatHandler::kickUser(int channelId, const std::string &name)
MessageOut msg(PCMSG_KICK_USER);
msg.writeInt16(channelId);
msg.writeString(name);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
void ChatHandler::who()
{
MessageOut msg(PCMSG_WHO);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
} // namespace ManaServ
diff --git a/src/net/manaserv/chathandler.h b/src/net/manaserv/chathandler.h
index 2f6a8d00..cab4d053 100644
--- a/src/net/manaserv/chathandler.h
+++ b/src/net/manaserv/chathandler.h
@@ -23,10 +23,10 @@
#define NET_MANASERV_CHATHANDLER_H
#include "net/chathandler.h"
-#include "net/messagehandler.h"
-
#include "net/serverinfo.h"
+#include "net/manaserv/messagehandler.h"
+
namespace ManaServ {
class ChatHandler : public MessageHandler, public Net::ChatHandler
@@ -37,7 +37,7 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler
/**
* Handle the given message appropriately.
*/
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::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(MessageIn &msg);
+ void handleGameChatMessage(Net::MessageIn &msg);
/**
* Handle channel entry responses.
*/
- void handleEnterChannelResponse(MessageIn &msg);
+ void handleEnterChannelResponse(Net::MessageIn &msg);
/**
* Handle list channels responses.
*/
- void handleListChannelsResponse(MessageIn &msg);
+ void handleListChannelsResponse(Net::MessageIn &msg);
/**
* Handle private messages.
*/
- void handlePrivateMessage(MessageIn &msg);
+ void handlePrivateMessage(Net::MessageIn &msg);
/**
* Handle announcements.
*/
- void handleAnnouncement(MessageIn &msg);
+ void handleAnnouncement(Net::MessageIn &msg);
/**
* Handle chat messages.
*/
- void handleChatMessage(MessageIn &msg);
+ void handleChatMessage(Net::MessageIn &msg);
/**
* Handle quit channel responses.
*/
- void handleQuitChannelResponse(MessageIn &msg);
+ void handleQuitChannelResponse(Net::MessageIn &msg);
/**
* Handle list channel users responses.
*/
- void handleListChannelUsersResponse(MessageIn &msg);
+ void handleListChannelUsersResponse(Net::MessageIn &msg);
/**
* Handle channel events.
*/
- void handleChannelEvent(MessageIn &msg);
+ void handleChannelEvent(Net::MessageIn &msg);
/**
* Handle who responses.
*/
- void handleWhoResponse(MessageIn &msg);
+ void handleWhoResponse(Net::MessageIn &msg);
};
} // namespace ManaServ
diff --git a/src/net/manaserv/chatserver/chatserver.cpp b/src/net/manaserv/chatserver/chatserver.cpp
index f0f5faf2..23eee3e6 100644
--- a/src/net/manaserv/chatserver/chatserver.cpp
+++ b/src/net/manaserv/chatserver/chatserver.cpp
@@ -24,31 +24,34 @@
#include "internal.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/messageout.h"
+namespace ManaServ {
-using Net::ChatServer::connection;
+using ChatServer::connection;
-void Net::ChatServer::connect(Net::Connection *connection,
+void ChatServer::connect(Connection *connection,
const std::string &token)
{
- Net::ChatServer::connection = connection;
+ ChatServer::connection = connection;
MessageOut msg(PCMSG_CONNECT);
msg.writeString(token, 32);
connection->send(msg);
}
-void Net::ChatServer::logout()
+void ChatServer::logout()
{
MessageOut msg(PCMSG_DISCONNECT);
connection->send(msg);
}
-void Net::ChatServer::announce(const std::string &text)
+void ChatServer::announce(const std::string &text)
{
MessageOut msg(PCMSG_ANNOUNCE);
msg.writeString(text);
connection->send(msg);
}
+
+}
diff --git a/src/net/manaserv/chatserver/chatserver.h b/src/net/manaserv/chatserver/chatserver.h
index 18859a2c..18cd5960 100644
--- a/src/net/manaserv/chatserver/chatserver.h
+++ b/src/net/manaserv/chatserver/chatserver.h
@@ -19,18 +19,18 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef NET_CHATSERVER_CHATSERVER_H
-#define NET_CHATSERVER_CHATSERVER_H
+#ifndef NET_MANASERV_CHATSERVER_CHATSERVER_H
+#define NET_MANASERV_CHATSERVER_CHATSERVER_H
#include <iosfwd>
-namespace Net
+namespace ManaServ
{
class Connection;
namespace ChatServer
{
- void connect(Net::Connection *connection, const std::string &token);
+ void connect(Connection *connection, const std::string &token);
void logout();
@@ -41,4 +41,4 @@ namespace Net
}
}
-#endif
+#endif // NET_MANASERV_CHATSERVER_CHATSERVER_H
diff --git a/src/net/manaserv/chatserver/guild.cpp b/src/net/manaserv/chatserver/guild.cpp
index 5973077e..e34b3bc4 100644
--- a/src/net/manaserv/chatserver/guild.cpp
+++ b/src/net/manaserv/chatserver/guild.cpp
@@ -24,23 +24,25 @@
#include "internal.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/messageout.h"
-
#include "log.h"
-void Net::ChatServer::Guild::createGuild(const std::string &name)
+namespace ManaServ
+{
+
+void ChatServer::Guild::createGuild(const std::string &name)
{
logger->log("Sending PCMSG_GUILD_CREATE");
MessageOut msg(PCMSG_GUILD_CREATE);
msg.writeString(name);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
-void Net::ChatServer::Guild::invitePlayer(const std::string &name, short guildId)
+void ChatServer::Guild::invitePlayer(const std::string &name, short guildId)
{
logger->log("Sending PCMSG_GUILD_INVITE");
MessageOut msg(PCMSG_GUILD_INVITE);
@@ -48,30 +50,30 @@ void Net::ChatServer::Guild::invitePlayer(const std::string &name, short guildId
msg.writeInt16(guildId);
msg.writeString(name);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
-void Net::ChatServer::Guild::acceptInvite(const std::string &name)
+void ChatServer::Guild::acceptInvite(const std::string &name)
{
logger->log("Sending PCMSG_GUILD_ACCEPT");
MessageOut msg(PCMSG_GUILD_ACCEPT);
msg.writeString(name);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
-void Net::ChatServer::Guild::getGuildMembers(short guildId)
+void ChatServer::Guild::getGuildMembers(short guildId)
{
logger->log("Sending PCMSG_GUILD_GET_MEMBERS");
MessageOut msg(PCMSG_GUILD_GET_MEMBERS);
msg.writeInt16(guildId);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
-void Net::ChatServer::Guild::promoteMember(const std::string &name,
+void ChatServer::Guild::promoteMember(const std::string &name,
short guildId, short level)
{
logger->log("Sending PCMSG_GUILD_PROMOTE_MEMBER");
@@ -81,15 +83,17 @@ void Net::ChatServer::Guild::promoteMember(const std::string &name,
msg.writeString(name);
msg.writeInt8(level);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
-void Net::ChatServer::Guild::quitGuild(short guildId)
+void ChatServer::Guild::quitGuild(short guildId)
{
logger->log("Sending PCMSG_GUILD_QUIT");
MessageOut msg(PCMSG_GUILD_QUIT);
msg.writeInt16(guildId);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
+}
+
}
diff --git a/src/net/manaserv/chatserver/guild.h b/src/net/manaserv/chatserver/guild.h
index 2e9cf9a6..7b9aef04 100644
--- a/src/net/manaserv/chatserver/guild.h
+++ b/src/net/manaserv/chatserver/guild.h
@@ -19,12 +19,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef NET_CHATSERVER_GUILD_H
-#define NET_CHATSERVER_GUILD_H
+#ifndef NET_MANASERV_CHATSERVER_GUILD_H
+#define NET_MANASERV_CHATSERVER_GUILD_H
#include <iosfwd>
-namespace Net
+namespace ManaServ
{
namespace ChatServer
{
@@ -64,4 +64,4 @@ namespace Net
}
}
-#endif
+#endif // NET_MANASERV_CHATSERVER_GUILD_H
diff --git a/src/net/manaserv/chatserver/internal.cpp b/src/net/manaserv/chatserver/internal.cpp
index 52744804..890cb1f1 100644
--- a/src/net/manaserv/chatserver/internal.cpp
+++ b/src/net/manaserv/chatserver/internal.cpp
@@ -21,7 +21,7 @@
#include "internal.h"
-namespace Net
+namespace ManaServ
{
class Connection;
diff --git a/src/net/manaserv/chatserver/internal.h b/src/net/manaserv/chatserver/internal.h
index 162d54fb..6807f147 100644
--- a/src/net/manaserv/chatserver/internal.h
+++ b/src/net/manaserv/chatserver/internal.h
@@ -19,10 +19,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef NET_CHATSERVER_INTERNAL_H
-#define NET_CHATSERVER_INTERNAL_H
+#ifndef NET_MANASERV_CHATSERVER_INTERNAL_H
+#define NET_MANASERV_CHATSERVER_INTERNAL_H
-namespace Net
+namespace ManaServ
{
class Connection;
@@ -32,4 +32,4 @@ namespace Net
}
}
-#endif
+#endif // NET_MANASERV_CHATSERVER_INTERNAL_H
diff --git a/src/net/manaserv/chatserver/party.cpp b/src/net/manaserv/chatserver/party.cpp
index 26b45346..fdefc59d 100644
--- a/src/net/manaserv/chatserver/party.cpp
+++ b/src/net/manaserv/chatserver/party.cpp
@@ -24,56 +24,60 @@
#include "internal.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/messageout.h"
-
#include "log.h"
-void Net::ChatServer::Party::invitePlayer(const std::string &name)
+namespace ManaServ
+{
+
+void ChatServer::Party::invitePlayer(const std::string &name)
{
logger->log("Sending PCMSG_PARTY_INVITE");
MessageOut msg(PCMSG_PARTY_INVITE);
msg.writeString(name);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
-void Net::ChatServer::Party::acceptInvite(const std::string &name)
+void ChatServer::Party::acceptInvite(const std::string &name)
{
logger->log("Sending PCMSG_PARTY_ACCEPT_INVITE");
MessageOut msg(PCMSG_PARTY_ACCEPT_INVITE);
msg.writeString(name);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
-void Net::ChatServer::Party::rejectInvite(const std::string &name)
+void ChatServer::Party::rejectInvite(const std::string &name)
{
logger->log("Sending PCMSG_PARTY_REJECT_INVITE");
MessageOut msg(PCMSG_PARTY_REJECT_INVITE);
msg.writeString(name);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
}
-void Net::ChatServer::Party::getPartyMembers()
+void ChatServer::Party::getPartyMembers()
{
logger->log("Sending PCMSG_PARTY_GET_MEMBERS");
// MessageOut msg(PCMSG_GUILD_GET_MEMBERS);
// msg.writeInt16(guildId);
-// Net::ChatServer::connection->send(msg);
+// ChatServer::connection->send(msg);
}
-void Net::ChatServer::Party::quitParty()
+void ChatServer::Party::quitParty()
{
logger->log("Sending PCMSG_PARTY_QUIT");
MessageOut msg(PCMSG_PARTY_QUIT);
- Net::ChatServer::connection->send(msg);
+ ChatServer::connection->send(msg);
+}
+
}
diff --git a/src/net/manaserv/chatserver/party.h b/src/net/manaserv/chatserver/party.h
index 3850c283..34f308f7 100644
--- a/src/net/manaserv/chatserver/party.h
+++ b/src/net/manaserv/chatserver/party.h
@@ -19,12 +19,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef NET_CHATSERVER_PARTY_H
-#define NET_CHATSERVER_PARTY_H
+#ifndef NET_MANASERV_CHATSERVER_PARTY_H
+#define NET_MANASERV_CHATSERVER_PARTY_H
#include <iosfwd>
-namespace Net
+namespace ManaServ
{
namespace ChatServer
{
@@ -58,4 +58,4 @@ namespace Net
}
}
-#endif
+#endif // NET_MANASERV_CHATSERVER_PARTY_H
diff --git a/src/net/manaserv/connection.cpp b/src/net/manaserv/connection.cpp
index b73f867f..6ddcf186 100644
--- a/src/net/manaserv/connection.cpp
+++ b/src/net/manaserv/connection.cpp
@@ -22,26 +22,28 @@
#include "net/manaserv/connection.h"
#include "net/manaserv/internal.h"
-
-#include "net/messageout.h"
+#include "net/manaserv/messageout.h"
#include "log.h"
#include <string>
-Net::Connection::Connection(ENetHost *client):
+namespace ManaServ
+{
+
+Connection::Connection(ENetHost *client):
mConnection(0), mClient(client)
{
mPort = 0;
- Net::connections++;
+ connections++;
}
-Net::Connection::~Connection()
+Connection::~Connection()
{
- Net::connections--;
+ connections--;
}
-bool Net::Connection::connect(const std::string &address, short port)
+bool Connection::connect(const std::string &address, short port)
{
logger->log("Net::Connection::connect(%s, %i)", address.c_str(), port);
@@ -72,7 +74,7 @@ bool Net::Connection::connect(const std::string &address, short port)
return true;
}
-void Net::Connection::disconnect()
+void Connection::disconnect()
{
if (!mConnection)
return;
@@ -84,13 +86,13 @@ void Net::Connection::disconnect()
mConnection = 0;
}
-bool Net::Connection::isConnected()
+bool Connection::isConnected()
{
return (mConnection) ?
(mConnection->state == ENET_PEER_STATE_CONNECTED) : false;
}
-void Net::Connection::send(const MessageOut &msg)
+void Connection::send(const ManaServ::MessageOut &msg)
{
if (!isConnected())
{
@@ -103,3 +105,5 @@ void Net::Connection::send(const MessageOut &msg)
ENET_PACKET_FLAG_RELIABLE);
enet_peer_send(mConnection, 0, packet);
}
+
+} // namespace ManaServ
diff --git a/src/net/manaserv/connection.h b/src/net/manaserv/connection.h
index b340546b..e5db8c8e 100644
--- a/src/net/manaserv/connection.h
+++ b/src/net/manaserv/connection.h
@@ -26,10 +26,10 @@
#include <enet/enet.h>
-class MessageOut;
-
-namespace Net
+namespace ManaServ
{
+ class MessageOut;
+
/**
* \ingroup Network
*/
@@ -65,10 +65,10 @@ namespace Net
/**
* Sends a message.
*/
- void send(const MessageOut &msg);
+ void send(const ManaServ::MessageOut &msg);
private:
- friend Connection *Net::getConnection();
+ friend Connection *ManaServ::getConnection();
Connection(ENetHost *client);
short mPort;
@@ -78,4 +78,4 @@ namespace Net
};
}
-#endif
+#endif // NET_MANASERV_CONNECTION_H
diff --git a/src/net/manaserv/effecthandler.cpp b/src/net/manaserv/effecthandler.cpp
index e2121102..f9504ebb 100644
--- a/src/net/manaserv/effecthandler.cpp
+++ b/src/net/manaserv/effecthandler.cpp
@@ -41,7 +41,7 @@ EffectHandler::EffectHandler()
handledMessages = _messages;
}
-void EffectHandler::handleMessage(MessageIn &msg)
+void EffectHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
@@ -56,7 +56,7 @@ void EffectHandler::handleMessage(MessageIn &msg)
}
}
-void EffectHandler::handleCreateEffectPos(MessageIn &msg)
+void EffectHandler::handleCreateEffectPos(Net::MessageIn &msg)
{
int id = msg.readInt16();
Uint16 x = msg.readInt16();
@@ -64,7 +64,7 @@ void EffectHandler::handleCreateEffectPos(MessageIn &msg)
effectManager->trigger(id, x, y);
}
-void EffectHandler::handleCreateEffectBeing(MessageIn &msg)
+void EffectHandler::handleCreateEffectBeing(Net::MessageIn &msg)
{
int eid = msg.readInt16();
int bid = msg.readInt16();
diff --git a/src/net/manaserv/effecthandler.h b/src/net/manaserv/effecthandler.h
index 5c52f121..4eb49f30 100644
--- a/src/net/manaserv/effecthandler.h
+++ b/src/net/manaserv/effecthandler.h
@@ -22,7 +22,7 @@
#ifndef NET_MANASERV_EFFECTSHANDLER_H
#define NET_MANASERV_EFFECTSHANDLER_H
-#include "net/messagehandler.h"
+#include "net/manaserv/messagehandler.h"
namespace ManaServ {
@@ -31,13 +31,13 @@ class EffectHandler : public MessageHandler
public:
EffectHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
private:
- void handleCreateEffectPos(MessageIn &msg);
- void handleCreateEffectBeing(MessageIn &msg);
+ void handleCreateEffectPos(Net::MessageIn &msg);
+ void handleCreateEffectBeing(Net::MessageIn &msg);
};
} // namespace ManaServ
-#endif
+#endif // NET_MANASERV_EFFECTSHANDLER_H
diff --git a/src/net/manaserv/gamehandler.cpp b/src/net/manaserv/gamehandler.cpp
index c7f8eeee..1916d492 100644
--- a/src/net/manaserv/gamehandler.cpp
+++ b/src/net/manaserv/gamehandler.cpp
@@ -34,10 +34,9 @@ Net::GameHandler *gameHandler;
extern ManaServ::ChatHandler *chatHandler;
-extern Net::Connection *gameServerConnection;
-
namespace ManaServ {
+extern Connection *gameServerConnection;
extern std::string netToken;
extern ServerInfo gameServer;
@@ -51,7 +50,7 @@ GameHandler::GameHandler()
gameHandler = this;
}
-void GameHandler::handleMessage(MessageIn &msg)
+void GameHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
@@ -100,7 +99,7 @@ void GameHandler::disconnect()
void GameHandler::inGame()
{
- Net::GameServer::connect(gameServerConnection, netToken);
+ GameServer::connect(gameServerConnection, netToken);
chatHandler->connect();
}
diff --git a/src/net/manaserv/gamehandler.h b/src/net/manaserv/gamehandler.h
index 846eb2ae..aad0651f 100644
--- a/src/net/manaserv/gamehandler.h
+++ b/src/net/manaserv/gamehandler.h
@@ -23,10 +23,10 @@
#define NET_MANASERV_MAPHANDLER_H
#include "net/gamehandler.h"
-#include "net/messagehandler.h"
-
#include "net/serverinfo.h"
+#include "net/manaserv/messagehandler.h"
+
namespace ManaServ {
class GameHandler : public MessageHandler, public Net::GameHandler
@@ -34,7 +34,7 @@ class GameHandler : public MessageHandler, public Net::GameHandler
public:
GameHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void connect();
@@ -57,4 +57,4 @@ class GameHandler : public MessageHandler, public Net::GameHandler
} // namespace ManaServ
-#endif
+#endif // NET_MANASERV_MAPHANDLER_H
diff --git a/src/net/manaserv/gameserver/gameserver.cpp b/src/net/manaserv/gameserver/gameserver.cpp
index 94015c20..ba3bd983 100644
--- a/src/net/manaserv/gameserver/gameserver.cpp
+++ b/src/net/manaserv/gameserver/gameserver.cpp
@@ -24,27 +24,30 @@
#include "internal.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/messageout.h"
+namespace ManaServ
+{
-void Net::GameServer::connect(Net::Connection *connection,
- const std::string &token)
+void GameServer::connect(Connection *connection, const std::string &token)
{
- Net::GameServer::connection = connection;
+ GameServer::connection = connection;
MessageOut msg(PGMSG_CONNECT);
msg.writeString(token, 32);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
-void Net::GameServer::logout(bool reconnectAccount)
+void GameServer::logout(bool reconnectAccount)
{
MessageOut msg(PGMSG_DISCONNECT);
msg.writeInt8((unsigned char) reconnectAccount);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
+}
+
}
diff --git a/src/net/manaserv/gameserver/gameserver.h b/src/net/manaserv/gameserver/gameserver.h
index 6de82c2e..1f9e5b78 100644
--- a/src/net/manaserv/gameserver/gameserver.h
+++ b/src/net/manaserv/gameserver/gameserver.h
@@ -19,21 +19,21 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef NET_GAMESERVER_GAMESERVER_H
-#define NET_GAMESERVER_GAMESERVER_H
+#ifndef NET_MANASERV_GAMESERVER_GAMESERVER_H
+#define NET_MANASERV_GAMESERVER_GAMESERVER_H
#include <iosfwd>
-namespace Net
+namespace ManaServ
{
class Connection;
namespace GameServer
{
- void connect(Net::Connection *connection, const std::string &token);
+ void connect(Connection *connection, const std::string &token);
void logout(bool reconnectAccount);
}
}
-#endif
+#endif // NET_MANASERV_GAMESERVER_GAMESERVER_H
diff --git a/src/net/manaserv/gameserver/internal.cpp b/src/net/manaserv/gameserver/internal.cpp
index 27cb4a47..e998ced9 100644
--- a/src/net/manaserv/gameserver/internal.cpp
+++ b/src/net/manaserv/gameserver/internal.cpp
@@ -21,7 +21,7 @@
#include "internal.h"
-namespace Net
+namespace ManaServ
{
class Connection;
diff --git a/src/net/manaserv/gameserver/internal.h b/src/net/manaserv/gameserver/internal.h
index 6c6e2613..44cd3be2 100644
--- a/src/net/manaserv/gameserver/internal.h
+++ b/src/net/manaserv/gameserver/internal.h
@@ -19,10 +19,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef NET_GAMESERVER_INTERNAL_H
-#define NET_GAMESERVER_INTERNAL_H
+#ifndef NET_MANASERV_GAMESERVER_INTERNAL_H
+#define NET_MANASERV_GAMESERVER_INTERNAL_H
-namespace Net
+namespace ManaServ
{
class Connection;
@@ -32,4 +32,4 @@ namespace Net
}
}
-#endif
+#endif // NET_MANASERV_GAMESERVER_INTERNAL_H
diff --git a/src/net/manaserv/gameserver/player.cpp b/src/net/manaserv/gameserver/player.cpp
index e667c8b9..6fa146d4 100644
--- a/src/net/manaserv/gameserver/player.cpp
+++ b/src/net/manaserv/gameserver/player.cpp
@@ -24,34 +24,38 @@
#include "internal.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/messageout.h"
-
void RespawnRequestListener::action(const gcn::ActionEvent &event)
{
- Net::GameServer::Player::respawn();
+ ManaServ::GameServer::Player::respawn();
}
-void Net::GameServer::Player::walk(int x, int y)
+namespace ManaServ
+{
+
+void GameServer::Player::walk(int x, int y)
{
MessageOut msg(PGMSG_WALK);
msg.writeInt16(x);
msg.writeInt16(y);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
-void Net::GameServer::Player::moveItem(int oldSlot, int newSlot, int amount)
+void GameServer::Player::moveItem(int oldSlot, int newSlot, int amount)
{
MessageOut msg(PGMSG_MOVE_ITEM);
msg.writeInt8(oldSlot);
msg.writeInt8(newSlot);
msg.writeInt8(amount);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
-void Net::GameServer::Player::respawn()
+void GameServer::Player::respawn()
{
MessageOut msg(PGMSG_RESPAWN);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
+}
+
}
diff --git a/src/net/manaserv/gameserver/player.h b/src/net/manaserv/gameserver/player.h
index 9a202c6e..40ba4b2b 100644
--- a/src/net/manaserv/gameserver/player.h
+++ b/src/net/manaserv/gameserver/player.h
@@ -19,8 +19,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef NET_GAMESERVER_PLAYER_H
-#define NET_GAMESERVER_PLAYER_H
+#ifndef NET_MANASERV_GAMESERVER_PLAYER_H
+#define NET_MANASERV_GAMESERVER_PLAYER_H
#include "being.h"
@@ -34,7 +34,7 @@ struct RespawnRequestListener : public gcn::ActionListener
void action(const gcn::ActionEvent &event);
};
-namespace Net
+namespace ManaServ
{
namespace GameServer
{
@@ -48,4 +48,4 @@ namespace Net
}
}
-#endif
+#endif // NET_MANASERV_GAMESERVER_PLAYER_H
diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp
index 0b2eefe2..db1d9013 100644
--- a/src/net/manaserv/generalhandler.cpp
+++ b/src/net/manaserv/generalhandler.cpp
@@ -57,12 +57,11 @@
Net::GeneralHandler *generalHandler = NULL;
-Net::Connection *gameServerConnection = 0;
-Net::Connection *chatServerConnection = 0;
-Net::Connection *accountServerConnection = 0;
-
namespace ManaServ {
+Connection *accountServerConnection = 0;
+Connection *chatServerConnection = 0;
+Connection *gameServerConnection = 0;
std::string netToken = "";
ServerInfo gameServer;
ServerInfo chatServer;
@@ -84,11 +83,11 @@ GeneralHandler::GeneralHandler():
mTradeHandler(new TradeHandler),
mSpecialHandler(new SpecialHandler)
{
- Net::initialize();
+ initialize();
- accountServerConnection = Net::getConnection();
- gameServerConnection = Net::getConnection();
- chatServerConnection = Net::getConnection();
+ accountServerConnection = getConnection();
+ gameServerConnection = getConnection();
+ chatServerConnection = getConnection();
generalHandler = this;
@@ -105,20 +104,20 @@ GeneralHandler::GeneralHandler():
void GeneralHandler::load()
{
- Net::registerHandler(mBeingHandler.get());
- Net::registerHandler(mBuySellHandler.get());
- Net::registerHandler(mCharHandler.get());
- Net::registerHandler(mChatHandler.get());
- Net::registerHandler(mEffectHandler.get());
- Net::registerHandler(mGameHandler.get());
- Net::registerHandler(mGuildHandler.get());
- Net::registerHandler(mInventoryHandler.get());
- Net::registerHandler(mItemHandler.get());
- Net::registerHandler(mLoginHandler.get());
- Net::registerHandler(mNpcHandler.get());
- Net::registerHandler(mPartyHandler.get());
- Net::registerHandler(mPlayerHandler.get());
- Net::registerHandler(mTradeHandler.get());
+ registerHandler(mBeingHandler.get());
+ registerHandler(mBuySellHandler.get());
+ registerHandler(mCharHandler.get());
+ registerHandler(mChatHandler.get());
+ registerHandler(mEffectHandler.get());
+ registerHandler(mGameHandler.get());
+ registerHandler(mGuildHandler.get());
+ registerHandler(mInventoryHandler.get());
+ registerHandler(mItemHandler.get());
+ registerHandler(mLoginHandler.get());
+ registerHandler(mNpcHandler.get());
+ registerHandler(mPartyHandler.get());
+ registerHandler(mPlayerHandler.get());
+ registerHandler(mTradeHandler.get());
}
void GeneralHandler::reload()
@@ -128,7 +127,7 @@ void GeneralHandler::reload()
void GeneralHandler::unload()
{
- Net::clearHandlers();
+ clearHandlers();
if (accountServerConnection)
accountServerConnection->disconnect();
@@ -141,12 +140,12 @@ void GeneralHandler::unload()
delete gameServerConnection;
delete chatServerConnection;
- Net::finalize();
+ finalize();
}
void GeneralHandler::flushNetwork()
{
- Net::flush();
+ flush();
}
bool GeneralHandler::isNetworkConnected()
@@ -184,7 +183,7 @@ void GeneralHandler::guiWindowsUnloaded()
void GeneralHandler::clearHandlers()
{
- Net::clearHandlers();
+ clearHandlers();
}
} // namespace ManaServ
diff --git a/src/net/manaserv/generalhandler.h b/src/net/manaserv/generalhandler.h
index 0017af75..a1010d32 100644
--- a/src/net/manaserv/generalhandler.h
+++ b/src/net/manaserv/generalhandler.h
@@ -24,7 +24,8 @@
#include "net/generalhandler.h"
#include "net/net.h"
-#include "net/messagehandler.h"
+
+#include "net/manaserv/messagehandler.h"
namespace ManaServ {
diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp
index 876de413..9cdc1c72 100644
--- a/src/net/manaserv/guildhandler.cpp
+++ b/src/net/manaserv/guildhandler.cpp
@@ -61,7 +61,7 @@ GuildHandler::GuildHandler()
}
-void GuildHandler::handleMessage(MessageIn &msg)
+void GuildHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
@@ -229,7 +229,7 @@ void GuildHandler::handleMessage(MessageIn &msg)
}
}
-void GuildHandler::joinedGuild(MessageIn &msg)
+void GuildHandler::joinedGuild(Net::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 d1b57e50..edf5eb8f 100644
--- a/src/net/manaserv/guildhandler.h
+++ b/src/net/manaserv/guildhandler.h
@@ -22,7 +22,7 @@
#ifndef NET_MANASERV_GUILDHANDLER_H
#define NET_MANASERV_GUILDHANDLER_H
-#include "net/messagehandler.h"
+#include "net/manaserv/messagehandler.h"
#include <string>
@@ -33,10 +33,10 @@ class GuildHandler : public MessageHandler
public:
GuildHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
protected:
- void joinedGuild(MessageIn &msg);
+ void joinedGuild(Net::MessageIn &msg);
};
} // namespace ManaServ
diff --git a/src/net/manaserv/internal.cpp b/src/net/manaserv/internal.cpp
index 055ce7f2..696bcfc9 100644
--- a/src/net/manaserv/internal.cpp
+++ b/src/net/manaserv/internal.cpp
@@ -21,7 +21,7 @@
#include "net/manaserv/internal.h"
-namespace Net
+namespace ManaServ
{
int connections = 0;
}
diff --git a/src/net/manaserv/internal.h b/src/net/manaserv/internal.h
index 582e4c17..b112159b 100644
--- a/src/net/manaserv/internal.h
+++ b/src/net/manaserv/internal.h
@@ -22,7 +22,7 @@
#ifndef NET_MANASERV_INTERNAL_H
#define NET_MANASERV_INTERNAL_H
-namespace Net
+namespace ManaServ
{
extern int connections;
}
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp
index 6074c8d7..e4fe0ecc 100644
--- a/src/net/manaserv/inventoryhandler.cpp
+++ b/src/net/manaserv/inventoryhandler.cpp
@@ -22,14 +22,13 @@
#include "net/manaserv/inventoryhandler.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messagein.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
#include "net/manaserv/gameserver/internal.h"
#include "net/manaserv/gameserver/player.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
-
#include "equipment.h"
#include "inventory.h"
#include "item.h"
@@ -57,7 +56,7 @@ InventoryHandler::InventoryHandler()
inventoryHandler = this;
}
-void InventoryHandler::handleMessage(MessageIn &msg)
+void InventoryHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
@@ -80,7 +79,7 @@ void InventoryHandler::handleMessage(MessageIn &msg)
{
player_node->mEquipment->setEquipment(slot, id);
}
- else if (slot >= 32 && slot < 32 + INVENTORY_SIZE)
+ else if (slot >= 32 && slot < 32 + getInventorySize())
{
int amount = id ? msg.readInt8() : 0;
player_node->setInvItem(slot - 32, id, amount);
@@ -94,14 +93,14 @@ void InventoryHandler::equipItem(const Item *item)
{
MessageOut msg(PGMSG_EQUIP);
msg.writeInt8(item->getInvIndex());
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void InventoryHandler::unequipItem(const Item *item)
{
MessageOut msg(PGMSG_UNEQUIP);
msg.writeInt8(item->getInvIndex());
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
// Tidy equipment directly to avoid weapon still shown bug, for instance
int equipSlot = item->getInvIndex();
@@ -113,7 +112,7 @@ void InventoryHandler::useItem(const Item *item)
{
MessageOut msg(PGMSG_USE_ITEM);
msg.writeInt8(item->getInvIndex());
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void InventoryHandler::dropItem(const Item *item, int amount)
@@ -121,7 +120,7 @@ void InventoryHandler::dropItem(const Item *item, int amount)
MessageOut msg(PGMSG_DROP);
msg.writeInt8(item->getInvIndex());
msg.writeInt8(amount);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
bool InventoryHandler::canSplit(const Item *item)
@@ -134,8 +133,7 @@ void InventoryHandler::splitItem(const Item *item, int amount)
int newIndex = player_node->getInventory()->getFreeSlot();
if (newIndex > Inventory::NO_SLOT_INDEX)
{
- Net::GameServer::Player::moveItem(
- item->getInvIndex(), newIndex, amount);
+ GameServer::Player::moveItem(item->getInvIndex(), newIndex, amount);
}
}
@@ -144,7 +142,7 @@ void InventoryHandler::moveItem(int oldIndex, int newIndex)
if (oldIndex == newIndex)
return;
- Net::GameServer::Player::moveItem(oldIndex, newIndex,
+ GameServer::Player::moveItem(oldIndex, newIndex,
player_node->getInventory()->getItem(oldIndex)->getQuantity());
}
@@ -164,4 +162,14 @@ void InventoryHandler::moveItem(StorageType source, int slot, int amount,
// TODO
}
+size_t InventoryHandler::getInventorySize() const
+{
+ return 50;
+}
+
+size_t InventoryHandler::getStorageSize() const
+{
+ return 300;
+}
+
} // namespace ManaServ
diff --git a/src/net/manaserv/inventoryhandler.h b/src/net/manaserv/inventoryhandler.h
index b6510d6a..1f937df9 100644
--- a/src/net/manaserv/inventoryhandler.h
+++ b/src/net/manaserv/inventoryhandler.h
@@ -23,7 +23,8 @@
#define NET_MANASERV_INVENTORYHANDLER_H
#include "net/inventoryhandler.h"
-#include "net/messagehandler.h"
+
+#include "net/manaserv/messagehandler.h"
namespace ManaServ {
@@ -32,7 +33,7 @@ class InventoryHandler : public MessageHandler, Net::InventoryHandler
public:
InventoryHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void equipItem(const Item *item);
@@ -54,8 +55,12 @@ class InventoryHandler : public MessageHandler, Net::InventoryHandler
void moveItem(StorageType source, int slot, int amount,
StorageType destination);
+
+ size_t getInventorySize() const;
+
+ size_t getStorageSize() const;
};
} // namespace ManaServ
-#endif
+#endif // NET_MANASERV_INVENTORYHANDLER_H
diff --git a/src/net/manaserv/itemhandler.cpp b/src/net/manaserv/itemhandler.cpp
index 6f25d7df..c63eb5bd 100644
--- a/src/net/manaserv/itemhandler.cpp
+++ b/src/net/manaserv/itemhandler.cpp
@@ -23,7 +23,7 @@
#include "net/manaserv/protocol.h"
-#include "net/messagein.h"
+#include "net/manaserv/messagein.h"
#include "engine.h"
#include "flooritemmanager.h"
@@ -40,7 +40,7 @@ ItemHandler::ItemHandler()
handledMessages = _messages;
}
-void ItemHandler::handleMessage(MessageIn &msg)
+void ItemHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
diff --git a/src/net/manaserv/itemhandler.h b/src/net/manaserv/itemhandler.h
index fde3000d..26334361 100644
--- a/src/net/manaserv/itemhandler.h
+++ b/src/net/manaserv/itemhandler.h
@@ -22,7 +22,7 @@
#ifndef NET_MANASERV_ITEMHANDLER_H
#define NET_MANASERV_ITEMHANDLER_H
-#include "net/messagehandler.h"
+#include "net/manaserv/messagehandler.h"
namespace ManaServ {
@@ -31,9 +31,9 @@ class ItemHandler : public MessageHandler
public:
ItemHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
};
} // namespace ManaServ
-#endif
+#endif // NET_MANASERV_ITEMHANDLER_H
diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp
index 8ae63ce9..d753d8d1 100644
--- a/src/net/manaserv/loginhandler.cpp
+++ b/src/net/manaserv/loginhandler.cpp
@@ -22,13 +22,13 @@
#include "net/manaserv/loginhandler.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messagein.h"
#include "net/manaserv/protocol.h"
#include "net/manaserv/accountserver/account.h"
#include "net/manaserv/accountserver/accountserver.h"
#include "net/logindata.h"
-#include "net/messagein.h"
#include "main.h"
@@ -36,10 +36,11 @@
Net::LoginHandler *loginHandler;
-extern Net::Connection *accountServerConnection;
namespace ManaServ {
+extern Connection *accountServerConnection;
+
LoginHandler::LoginHandler()
{
static const Uint16 _messages[] = {
@@ -56,7 +57,7 @@ LoginHandler::LoginHandler()
loginHandler = this;
}
-void LoginHandler::handleMessage(MessageIn &msg)
+void LoginHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
@@ -209,7 +210,7 @@ void LoginHandler::handleMessage(MessageIn &msg)
}
}
-void LoginHandler::handleLoginResponse(MessageIn &msg)
+void LoginHandler::handleLoginResponse(Net::MessageIn &msg)
{
const int errMsg = msg.readInt8();
@@ -246,7 +247,7 @@ void LoginHandler::handleLoginResponse(MessageIn &msg)
}
}
-void LoginHandler::handleRegisterResponse(MessageIn &msg)
+void LoginHandler::handleRegisterResponse(Net::MessageIn &msg)
{
const int errMsg = msg.readInt8();
@@ -278,7 +279,7 @@ void LoginHandler::handleRegisterResponse(MessageIn &msg)
}
}
-void LoginHandler::readUpdateHost(MessageIn &msg)
+void LoginHandler::readUpdateHost(Net::MessageIn &msg)
{
// Set the update host when included in the message
if (msg.getUnreadLength() > 0)
@@ -290,8 +291,6 @@ void LoginHandler::readUpdateHost(MessageIn &msg)
void LoginHandler::connect()
{
accountServerConnection->connect(mServer.hostname, mServer.port);
- /*if (state == STATE_CONNECT_SERVER)
- state = STATE_LOGIN;*/
}
bool LoginHandler::isConnected()
@@ -307,7 +306,7 @@ void LoginHandler::disconnect()
void LoginHandler::loginAccount(LoginData *loginData)
{
mLoginData = loginData;
- Net::AccountServer::login(accountServerConnection,
+ AccountServer::login(accountServerConnection,
0, // client version
loginData->username,
loginData->password);
@@ -320,15 +319,14 @@ void LoginHandler::logout()
void LoginHandler::changeEmail(const std::string &email)
{
- Net::AccountServer::Account::changeEmail(email);
+ AccountServer::Account::changeEmail(email);
}
void LoginHandler::changePassword(const std::string &username,
const std::string &oldPassword,
const std::string &newPassword)
{
- Net::AccountServer::Account::changePassword(username, oldPassword,
- newPassword);
+ AccountServer::Account::changePassword(username, oldPassword, newPassword);
}
void LoginHandler::chooseServer(unsigned int server)
@@ -338,7 +336,7 @@ void LoginHandler::chooseServer(unsigned int server)
void LoginHandler::registerAccount(LoginData *loginData)
{
- Net::AccountServer::registerAccount(accountServerConnection,
+ AccountServer::registerAccount(accountServerConnection,
0, // client version
loginData->username,
loginData->password,
@@ -348,7 +346,7 @@ void LoginHandler::registerAccount(LoginData *loginData)
void LoginHandler::unregisterAccount(const std::string &username,
const std::string &password)
{
- Net::AccountServer::Account::unregister(username, password);
+ AccountServer::Account::unregister(username, password);
}
Worlds LoginHandler::getWorlds() const
diff --git a/src/net/manaserv/loginhandler.h b/src/net/manaserv/loginhandler.h
index f5013fc2..14c14a53 100644
--- a/src/net/manaserv/loginhandler.h
+++ b/src/net/manaserv/loginhandler.h
@@ -23,10 +23,10 @@
#define NET_MANASERV_LOGINHANDLER_H
#include "net/loginhandler.h"
-#include "net/messagehandler.h"
-
#include "net/serverinfo.h"
+#include "net/manaserv/messagehandler.h"
+
class LoginData;
namespace ManaServ {
@@ -36,7 +36,7 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler
public:
LoginHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void connect();
@@ -71,10 +71,10 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler
Worlds getWorlds() const;
private:
- void handleLoginResponse(MessageIn &msg);
- void handleRegisterResponse(MessageIn &msg);
+ void handleLoginResponse(Net::MessageIn &msg);
+ void handleRegisterResponse(Net::MessageIn &msg);
- void readUpdateHost(MessageIn &msg);
+ void readUpdateHost(Net::MessageIn &msg);
LoginData *mLoginData;
};
diff --git a/src/net/manaserv/messagehandler.cpp b/src/net/manaserv/messagehandler.cpp
new file mode 100644
index 00000000..19bb36c4
--- /dev/null
+++ b/src/net/manaserv/messagehandler.cpp
@@ -0,0 +1,35 @@
+/*
+ * The Mana World
+ * Copyright (C) 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "net/manaserv/messagehandler.h"
+
+#include "net/manaserv/network.h"
+
+#include <cassert>
+
+namespace ManaServ {
+
+MessageHandler::~MessageHandler()
+{
+ unregisterHandler(this);
+}
+
+}
diff --git a/src/net/manaserv/messagehandler.h b/src/net/manaserv/messagehandler.h
new file mode 100644
index 00000000..9579327f
--- /dev/null
+++ b/src/net/manaserv/messagehandler.h
@@ -0,0 +1,43 @@
+/*
+ * The Mana World
+ * Copyright (C) 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef NET_MANASERV_MESSAGEHANDLER_H
+#define NET_MANASERV_MESSAGEHANDLER_H
+
+#include "net/messagehandler.h"
+
+namespace ManaServ {
+
+/**
+ * \ingroup Network
+ */
+class MessageHandler : public Net::MessageHandler
+{
+ public:
+ ~MessageHandler();
+
+};
+
+typedef const std::auto_ptr<MessageHandler> MessageHandlerPtr;
+
+}
+
+#endif // NET_MANASERV_MESSAGEHANDLER_H
diff --git a/src/net/manaserv/messagein.cpp b/src/net/manaserv/messagein.cpp
new file mode 100644
index 00000000..8a7053f8
--- /dev/null
+++ b/src/net/manaserv/messagein.cpp
@@ -0,0 +1,65 @@
+/*
+ * The Mana World
+ * Copyright (C) 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "net/manaserv/messagein.h"
+
+#include <enet/enet.h>
+
+#define MAKEWORD(low,high) \
+ ((unsigned short)(((unsigned char)(low)) | \
+ ((unsigned short)((unsigned char)(high))) << 8))
+
+namespace ManaServ {
+
+MessageIn::MessageIn(const char *data, unsigned int length):
+ Net::MessageIn(data, length)
+{
+ // Read the message ID
+ mId = readInt16();
+}
+
+int MessageIn::readInt16()
+{
+ int value = -1;
+ if (mPos + 2 <= mLength)
+ {
+ uint16_t t;
+ memcpy(&t, mData + mPos, 2);
+ value = (unsigned short) ENET_NET_TO_HOST_16(t);
+ }
+ mPos += 2;
+ return value;
+}
+
+int MessageIn::readInt32()
+{
+ int value = -1;
+ if (mPos + 4 <= mLength)
+ {
+ uint32_t t;
+ memcpy(&t, mData + mPos, 4);
+ value = ENET_NET_TO_HOST_32(t);
+ }
+ mPos += 4;
+ return value;
+}
+
+}
diff --git a/src/net/manaserv/messagein.h b/src/net/manaserv/messagein.h
new file mode 100644
index 00000000..8fb83767
--- /dev/null
+++ b/src/net/manaserv/messagein.h
@@ -0,0 +1,48 @@
+/*
+ * The Mana World
+ * Copyright (C) 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef NET_MANASERV_MESSAGEIN_H
+#define NET_MANASERV_MESSAGEIN_H
+
+#include "net/messagein.h"
+
+namespace ManaServ {
+
+/**
+ * Used for parsing an incoming message.
+ *
+ * \ingroup Network
+ */
+class MessageIn : public Net::MessageIn
+{
+ public:
+ /**
+ * Constructor.
+ */
+ MessageIn(const char *data, unsigned int length);
+
+ int readInt16(); /**< Reads a short. */
+ int readInt32(); /**< Reads a long. */
+};
+
+}
+
+#endif // NET_MANASERV_MESSAGEIN_H
diff --git a/src/net/manaserv/messageout.cpp b/src/net/manaserv/messageout.cpp
new file mode 100644
index 00000000..8d39fe06
--- /dev/null
+++ b/src/net/manaserv/messageout.cpp
@@ -0,0 +1,64 @@
+/*
+ * The Mana World
+ * Copyright (C) 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "net/manaserv/messageout.h"
+
+#include <enet/enet.h>
+
+#include <cstring>
+#include <string>
+
+namespace ManaServ {
+
+MessageOut::MessageOut(short id):
+ Net::MessageOut(id)
+{
+ writeInt16(id);
+}
+
+MessageOut::~MessageOut()
+{
+ free(mData);
+}
+
+void MessageOut::expand(size_t bytes)
+{
+ mData = (char*)realloc(mData, mPos + bytes);
+ mDataSize = mPos + bytes;
+}
+
+void MessageOut::writeInt16(Sint16 value)
+{
+ expand(2);
+ uint16_t t = ENET_HOST_TO_NET_16(value);
+ memcpy(mData + mPos, &t, 2);
+ mPos += 2;
+}
+
+void MessageOut::writeInt32(Sint32 value)
+{
+ expand(4);
+ uint32_t t = ENET_HOST_TO_NET_32(value);
+ memcpy(mData + mPos, &t, 4);
+ mPos += 4;
+}
+
+}
diff --git a/src/net/manaserv/messageout.h b/src/net/manaserv/messageout.h
new file mode 100644
index 00000000..aedf9c37
--- /dev/null
+++ b/src/net/manaserv/messageout.h
@@ -0,0 +1,58 @@
+/*
+ * The Mana World
+ * Copyright (C) 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef NET_MANASERV_MESSAGEOUT_H
+#define NET_MANASERV_MESSAGEOUT_H
+
+#include "net/messageout.h"
+
+namespace ManaServ {
+
+class MessageOut : public Net::MessageOut
+{
+ public:
+ /**
+ * Constructor.
+ */
+ MessageOut(short id);
+
+ /**
+ * Destructor.
+ */
+ ~MessageOut();
+
+ void writeInt16(Sint16 value); /**< Writes a short. */
+ void writeInt32(Sint32 value); /**< Writes a long. */
+
+ protected:
+ /**
+ * 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);
+};
+
+}
+
+#endif // NET_MANASERV_MESSAGEOUT_H
diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp
index 84b9d070..91a7ed6a 100644
--- a/src/net/manaserv/network.cpp
+++ b/src/net/manaserv/network.cpp
@@ -23,9 +23,8 @@
#include "net/manaserv/connection.h"
#include "net/manaserv/internal.h"
-
-#include "net/messagehandler.h"
-#include "net/messagein.h"
+#include "net/manaserv/messagehandler.h"
+#include "net/manaserv/messagein.h"
#include "log.h"
@@ -40,11 +39,14 @@ namespace {
ENetHost *client;
}
+namespace ManaServ
+{
+
typedef std::map<unsigned short, MessageHandler*> MessageHandlers;
typedef MessageHandlers::iterator MessageHandlerIterator;
static MessageHandlers mMessageHandlers;
-void Net::initialize()
+void initialize()
{
if (enet_initialize())
{
@@ -59,12 +61,12 @@ void Net::initialize()
}
}
-void Net::finalize()
+void finalize()
{
if (!client)
return; // Wasn't initialized at all
- if (Net::connections) {
+ if (connections) {
logger->error("Tried to shutdown the network subsystem while there "
"are network connections left!");
}
@@ -73,7 +75,7 @@ void Net::finalize()
enet_deinitialize();
}
-Net::Connection *Net::getConnection()
+Connection *getConnection()
{
if (!client)
{
@@ -81,10 +83,10 @@ Net::Connection *Net::getConnection()
"initializing the network subsystem!");
}
- return new Net::Connection(client);
+ return new Connection(client);
}
-void Net::registerHandler(MessageHandler *handler)
+void registerHandler(MessageHandler *handler)
{
for (const Uint16 *i = handler->handledMessages; *i; i++)
{
@@ -92,7 +94,7 @@ void Net::registerHandler(MessageHandler *handler)
}
}
-void Net::unregisterHandler(MessageHandler *handler)
+void unregisterHandler(MessageHandler *handler)
{
for (const Uint16 *i = handler->handledMessages; *i; i++)
{
@@ -100,7 +102,7 @@ void Net::unregisterHandler(MessageHandler *handler)
}
}
-void Net::clearHandlers()
+void clearHandlers()
{
mMessageHandlers.clear();
}
@@ -133,7 +135,7 @@ namespace
}
}
-void Net::flush()
+void flush()
{
ENetEvent event;
@@ -168,3 +170,5 @@ void Net::flush()
}
}
}
+
+}
diff --git a/src/net/manaserv/network.h b/src/net/manaserv/network.h
index 8b7cedd8..9960f672 100644
--- a/src/net/manaserv/network.h
+++ b/src/net/manaserv/network.h
@@ -25,17 +25,13 @@
#include <iosfwd>
/**
- * \defgroup Network Core network layer
- */
-
-class MessageHandler;
-class MessageOut;
-
-/**
* \ingroup Network
*/
-namespace Net
+namespace ManaServ
{
+ class MessageHandler;
+ class MessageOut;
+
class Connection;
/**
@@ -74,6 +70,6 @@ namespace Net
* registered handlers
*/
void flush();
-}
+} // namespace ManaServ
#endif
diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp
index 2f1a8e4a..7384d18e 100644
--- a/src/net/manaserv/npchandler.cpp
+++ b/src/net/manaserv/npchandler.cpp
@@ -22,14 +22,13 @@
#include "net/manaserv/npchandler.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messagein.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
#include "net/manaserv/gameserver/internal.h"
#include "net/manaserv/gameserver/player.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
-
#include "beingmanager.h"
#include "npc.h"
@@ -56,7 +55,7 @@ NpcHandler::NpcHandler()
npcHandler = this;
}
-void NpcHandler::handleMessage(MessageIn &msg)
+void NpcHandler::handleMessage(Net::MessageIn &msg)
{
Being *being = beingManager->findBeing(msg.readInt16());
if (!being || being->getType() != Being::NPC)
@@ -115,21 +114,21 @@ void NpcHandler::talk(int npcId)
{
MessageOut msg(PGMSG_NPC_TALK);
msg.writeInt16(npcId);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void NpcHandler::nextDialog(int npcId)
{
MessageOut msg(PGMSG_NPC_TALK_NEXT);
msg.writeInt16(npcId);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void NpcHandler::closeDialog(int npcId)
{
MessageOut msg(PGMSG_NPC_TALK_NEXT);
msg.writeInt16(npcId);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
npcDialog->setVisible(false);
npcDialog->setText("");
}
@@ -139,7 +138,7 @@ void NpcHandler::listInput(int npcId, int value)
MessageOut msg(PGMSG_NPC_SELECT);
msg.writeInt16(npcId);
msg.writeInt8(value);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void NpcHandler::integerInput(int npcId, int value)
@@ -147,7 +146,7 @@ void NpcHandler::integerInput(int npcId, int value)
MessageOut msg(PGMSG_NPC_NUMBER);
msg.writeInt16(npcId);
msg.writeInt32(value);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void NpcHandler::stringInput(int npcId, const std::string &value)
@@ -155,7 +154,7 @@ void NpcHandler::stringInput(int npcId, const std::string &value)
MessageOut msg(PGMSG_NPC_STRING);
msg.writeInt16(npcId);
msg.writeString(value);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void NpcHandler::sendLetter(int npcId, const std::string &recipient,
@@ -164,7 +163,7 @@ void NpcHandler::sendLetter(int npcId, const std::string &recipient,
MessageOut msg(PGMSG_NPC_POST_SEND);
msg.writeString(recipient);
msg.writeString(text);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void NpcHandler::startShopping(int beingId)
@@ -187,7 +186,7 @@ void NpcHandler::buyItem(int beingId, int itemId, int amount)
MessageOut msg(PGMSG_NPC_BUYSELL);
msg.writeInt16(itemId);
msg.writeInt16(amount);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void NpcHandler::sellItem(int beingId, int itemId, int amount)
@@ -195,7 +194,7 @@ void NpcHandler::sellItem(int beingId, int itemId, int amount)
MessageOut msg(PGMSG_NPC_BUYSELL);
msg.writeInt16(itemId);
msg.writeInt16(amount);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void NpcHandler::endShopping(int beingId)
diff --git a/src/net/manaserv/npchandler.h b/src/net/manaserv/npchandler.h
index bc0aaee1..b1912ce3 100644
--- a/src/net/manaserv/npchandler.h
+++ b/src/net/manaserv/npchandler.h
@@ -22,9 +22,10 @@
#ifndef NET_MANASERV_NPCHANDLER_H
#define NET_MANASERV_NPCHANDLER_H
-#include "net/messagehandler.h"
#include "net/npchandler.h"
+#include "net/manaserv/messagehandler.h"
+
#include <list>
namespace ManaServ {
@@ -34,7 +35,7 @@ class NpcHandler : public MessageHandler, public Net::NpcHandler
public:
NpcHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void talk(int npcId);
@@ -66,4 +67,4 @@ class NpcHandler : public MessageHandler, public Net::NpcHandler
} // namespace ManaServ
-#endif
+#endif // NET_MANASERV_NPCHANDLER_H
diff --git a/src/net/manaserv/partyhandler.cpp b/src/net/manaserv/partyhandler.cpp
index 9f20f027..ea968649 100644
--- a/src/net/manaserv/partyhandler.cpp
+++ b/src/net/manaserv/partyhandler.cpp
@@ -22,12 +22,12 @@
#include "net/manaserv/partyhandler.h"
#include "net/manaserv/protocol.h"
+#include "net/manaserv/messagein.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/chatserver/chatserver.h"
#include "net/manaserv/chatserver/party.h"
-#include "net/messagein.h"
-
#include "gui/partywindow.h"
#include "gui/widgets/chattab.h"
@@ -60,7 +60,7 @@ PartyHandler::PartyHandler()
partyHandler = this;
}
-void PartyHandler::handleMessage(MessageIn &msg)
+void PartyHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
@@ -140,20 +140,20 @@ void PartyHandler::invite(Player *player)
void PartyHandler::invite(const std::string &name)
{
- Net::ChatServer::Party::invitePlayer(name);
+ ChatServer::Party::invitePlayer(name);
}
void PartyHandler::inviteResponse(const std::string &inviter, bool accept)
{
if (accept)
- Net::ChatServer::Party::acceptInvite(inviter);
+ ChatServer::Party::acceptInvite(inviter);
else
- Net::ChatServer::Party::rejectInvite(inviter);
+ ChatServer::Party::rejectInvite(inviter);
}
void PartyHandler::leave()
{
- Net::ChatServer::Party::quitParty();
+ ChatServer::Party::quitParty();
}
void PartyHandler::kick(Player *player)
diff --git a/src/net/manaserv/partyhandler.h b/src/net/manaserv/partyhandler.h
index c44f7ace..eee17f10 100644
--- a/src/net/manaserv/partyhandler.h
+++ b/src/net/manaserv/partyhandler.h
@@ -22,9 +22,10 @@
#ifndef NET_MANASERV_PARTYHANDLER_H
#define NET_MANASERV_PARTYHANDLER_H
-#include "net/messagehandler.h"
#include "net/partyhandler.h"
+#include "net/manaserv/messagehandler.h"
+
#include <string>
namespace ManaServ {
@@ -34,7 +35,7 @@ class PartyHandler : public MessageHandler, public Net::PartyHandler
public:
PartyHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void create(const std::string &name = "");
@@ -67,5 +68,4 @@ public:
} // namespace ManaServ
-#endif
-
+#endif // NET_MANASERV_PARTYHANDLER_H
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index 91ff6a1c..fabf7c25 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -22,13 +22,13 @@
#include "net/manaserv/playerhandler.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messagein.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
#include "net/manaserv/gameserver/internal.h"
#include "net/manaserv/gameserver/player.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
#include "net/net.h"
#include "effectmanager.h"
@@ -112,7 +112,7 @@ PlayerHandler::PlayerHandler()
playerHandler = this;
}
-void PlayerHandler::handleMessage(MessageIn &msg)
+void PlayerHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
@@ -289,7 +289,7 @@ void PlayerHandler::handleMessage(MessageIn &msg)
}
}
-void PlayerHandler::handleMapChangeMessage(MessageIn &msg)
+void PlayerHandler::handleMapChangeMessage(Net::MessageIn &msg)
{
const std::string mapName = msg.readString();
const unsigned short x = msg.readInt16();
@@ -328,7 +328,7 @@ void PlayerHandler::attack(int id)
{
MessageOut msg(PGMSG_ATTACK);
msg.writeInt16(id);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void PlayerHandler::emote(int emoteId)
@@ -340,14 +340,14 @@ void PlayerHandler::increaseAttribute(size_t attr)
{
MessageOut msg(PGMSG_RAISE_ATTRIBUTE);
msg.writeInt8(attr);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void PlayerHandler::decreaseAttribute(size_t attr)
{
MessageOut msg(PGMSG_LOWER_ATTRIBUTE);
msg.writeInt8(attr);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void PlayerHandler::increaseSkill(int skillId)
@@ -361,14 +361,14 @@ void PlayerHandler::pickUp(FloorItem *floorItem)
MessageOut msg(PGMSG_PICKUP);
msg.writeInt16(id >> 16);
msg.writeInt16(id & 0xFFFF);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void PlayerHandler::setDirection(char direction)
{
MessageOut msg(PGMSG_DIRECTION_CHANGE);
msg.writeInt8(direction);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void PlayerHandler::setDestination(int x, int y, int /* direction */)
@@ -376,7 +376,7 @@ void PlayerHandler::setDestination(int x, int y, int /* direction */)
MessageOut msg(PGMSG_WALK);
msg.writeInt16(x);
msg.writeInt16(y);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void PlayerHandler::changeAction(Being::Action action)
@@ -385,7 +385,7 @@ void PlayerHandler::changeAction(Being::Action action)
MessageOut msg(PGMSG_ACTION_CHANGE);
msg.writeInt8(action);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void PlayerHandler::respawn()
@@ -408,4 +408,14 @@ bool PlayerHandler::canUseMagic()
return true;
}
+bool PlayerHandler::canCorrectAttributes()
+{
+ return true;
+}
+
+int PlayerHandler::getJobLocation()
+{
+ return -1;
+}
+
} // namespace ManaServ
diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h
index 1dd600c8..926f05dd 100644
--- a/src/net/manaserv/playerhandler.h
+++ b/src/net/manaserv/playerhandler.h
@@ -22,9 +22,10 @@
#ifndef NET_MANASERV_PLAYERHANDLER_H
#define NET_MANASERV_PLAYERHANDLER_H
-#include "net/messagehandler.h"
#include "net/playerhandler.h"
+#include "net/manaserv/messagehandler.h"
+
namespace ManaServ {
class PlayerHandler : public MessageHandler, public Net::PlayerHandler
@@ -32,7 +33,7 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
public:
PlayerHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void attack(int id);
@@ -60,10 +61,14 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
bool canUseMagic();
+ bool canCorrectAttributes();
+
+ int getJobLocation();
+
private:
- void handleMapChangeMessage(MessageIn &msg);
+ void handleMapChangeMessage(Net::MessageIn &msg);
};
} // namespace ManaServ
-#endif
+#endif // NET_MANASERV_PLAYERHANDLER_H
diff --git a/src/net/manaserv/specialhandler.cpp b/src/net/manaserv/specialhandler.cpp
index 55ea3ee0..2e152d60 100644
--- a/src/net/manaserv/specialhandler.cpp
+++ b/src/net/manaserv/specialhandler.cpp
@@ -24,10 +24,10 @@
#include "net/manaserv/gameserver/internal.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messagein.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/messageout.h"
-
Net::SpecialHandler *specialHandler;
namespace ManaServ {
@@ -37,7 +37,7 @@ SpecialHandler::SpecialHandler()
specialHandler = this;
}
-void SpecialHandler::handleMessage(MessageIn &msg)
+void SpecialHandler::handleMessage(Net::MessageIn &msg)
{
// TODO
}
@@ -46,7 +46,7 @@ void SpecialHandler::use(int id)
{
MessageOut msg(PGMSG_USE_SPECIAL);
msg.writeInt8(id);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void SpecialHandler::use(int id, int level, int beingId)
diff --git a/src/net/manaserv/specialhandler.h b/src/net/manaserv/specialhandler.h
index 3f61bf4b..6739c872 100644
--- a/src/net/manaserv/specialhandler.h
+++ b/src/net/manaserv/specialhandler.h
@@ -22,9 +22,10 @@
#ifndef NET_MANASERV_SKILLHANDLER_H
#define NET_MANASERV_SKILLHANDLER_H
-#include "net/messagehandler.h"
#include "net/specialhandler.h"
+#include "net/manaserv/messagehandler.h"
+
namespace ManaServ {
class SpecialHandler : public MessageHandler, public Net::SpecialHandler
@@ -32,7 +33,7 @@ class SpecialHandler : public MessageHandler, public Net::SpecialHandler
public:
SpecialHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void use(int id);
@@ -45,4 +46,4 @@ class SpecialHandler : public MessageHandler, public Net::SpecialHandler
} // namespace ManaServ
-#endif
+#endif // NET_MANASERV_SKILLHANDLER_H
diff --git a/src/net/manaserv/tradehandler.cpp b/src/net/manaserv/tradehandler.cpp
index aa2f9ab5..46664193 100644
--- a/src/net/manaserv/tradehandler.cpp
+++ b/src/net/manaserv/tradehandler.cpp
@@ -25,10 +25,10 @@
#include "net/manaserv/gameserver/player.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messagein.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
#include "net/net.h"
#include "beingmanager.h"
@@ -56,9 +56,9 @@ namespace {
{
if (event.getId() == "yes")
{
- MessageOut msg(PGMSG_TRADE_REQUEST);
+ ManaServ::MessageOut msg(PGMSG_TRADE_REQUEST);
msg.writeInt16(tradePartnerID);
- Net::GameServer::connection->send(msg);
+ ManaServ::GameServer::connection->send(msg);
}
else
Net::getTradeHandler()->cancel();
@@ -100,7 +100,7 @@ void TradeHandler::setAcceptTradeRequests(bool acceptTradeRequests)
}
}
-void TradeHandler::handleMessage(MessageIn &msg)
+void TradeHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
@@ -170,13 +170,13 @@ void TradeHandler::request(Being *being)
MessageOut msg(PGMSG_TRADE_REQUEST);
msg.writeInt16(tradePartnerID);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void TradeHandler::respond(bool accept)
{
MessageOut msg(accept ? PGMSG_TRADE_REQUEST : PGMSG_TRADE_CANCEL);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
if (!accept)
player_node->setTrading(false);
@@ -187,7 +187,7 @@ void TradeHandler::addItem(Item *item, int amount)
MessageOut msg(PGMSG_TRADE_ADD_ITEM);
msg.writeInt8(item->getInvIndex());
msg.writeInt8(amount);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
tradeWindow->addItem(item->getId(), true, amount);
item->increaseQuantity(-amount);
@@ -202,25 +202,25 @@ void TradeHandler::setMoney(int amount)
{
MessageOut msg(PGMSG_TRADE_SET_MONEY);
msg.writeInt32(amount);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void TradeHandler::confirm()
{
MessageOut msg(PGMSG_TRADE_CONFIRM);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void TradeHandler::finish()
{
MessageOut msg(PGMSG_TRADE_AGREED);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
void TradeHandler::cancel()
{
MessageOut msg(PGMSG_TRADE_CANCEL);
- Net::GameServer::connection->send(msg);
+ GameServer::connection->send(msg);
}
} // namespace ManaServ
diff --git a/src/net/manaserv/tradehandler.h b/src/net/manaserv/tradehandler.h
index 9041952d..5d23ebd6 100644
--- a/src/net/manaserv/tradehandler.h
+++ b/src/net/manaserv/tradehandler.h
@@ -22,9 +22,10 @@
#ifndef NET_MANASERV_TRADEHANDLER_H
#define NET_MANASERV_TRADEHANDLER_H
-#include "net/messagehandler.h"
#include "net/tradehandler.h"
+#include "net/manaserv/messagehandler.h"
+
namespace ManaServ {
class TradeHandler : public MessageHandler, public Net::TradeHandler
@@ -32,7 +33,7 @@ class TradeHandler : public MessageHandler, public Net::TradeHandler
public:
TradeHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
/**
* Returns whether trade requests are accepted.
@@ -71,4 +72,4 @@ class TradeHandler : public MessageHandler, public Net::TradeHandler
} // namespace ManaServ
-#endif
+#endif // NET_MANASERV_TRADEHANDLER_H