summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mana.cbp49
-rw-r--r--mana.files15
-rw-r--r--src/CMakeLists.txt13
-rw-r--r--src/Makefile.am13
-rw-r--r--src/being.cpp2
-rw-r--r--src/beingmanager.cpp4
-rw-r--r--src/engine.cpp6
-rw-r--r--src/engine.h2
-rw-r--r--src/game.cpp3
-rw-r--r--src/gui/buddywindow.h2
-rw-r--r--src/gui/guildwindow.cpp10
-rw-r--r--src/gui/inventorywindow.h6
-rw-r--r--src/gui/itemamount.h2
-rw-r--r--src/gui/playerbox.cpp14
-rw-r--r--src/gui/serverdialog.cpp14
-rw-r--r--src/gui/statuswindow.cpp92
-rw-r--r--src/gui/statuswindow.h4
-rw-r--r--src/gui/storagewindow.cpp2
-rw-r--r--src/gui/storagewindow.h6
-rw-r--r--src/gui/table.h2
-rw-r--r--src/gui/tablemodel.h2
-rw-r--r--src/gui/trade.cpp7
-rw-r--r--src/gui/widgets/radiobutton.h2
-rw-r--r--src/inventory.h7
-rw-r--r--src/localplayer.cpp90
-rw-r--r--src/main.cpp11
-rw-r--r--src/main.h10
-rw-r--r--src/net/ea/adminhandler.cpp11
-rw-r--r--src/net/ea/adminhandler.h5
-rw-r--r--src/net/ea/beinghandler.cpp5
-rw-r--r--src/net/ea/beinghandler.h4
-rw-r--r--src/net/ea/buysellhandler.cpp2
-rw-r--r--src/net/ea/buysellhandler.h4
-rw-r--r--src/net/ea/charserverhandler.cpp4
-rw-r--r--src/net/ea/charserverhandler.h6
-rw-r--r--src/net/ea/chathandler.cpp2
-rw-r--r--src/net/ea/chathandler.h5
-rw-r--r--src/net/ea/equipmenthandler.cpp2
-rw-r--r--src/net/ea/equipmenthandler.h4
-rw-r--r--src/net/ea/gamehandler.cpp2
-rw-r--r--src/net/ea/gamehandler.h4
-rw-r--r--src/net/ea/generalhandler.cpp2
-rw-r--r--src/net/ea/generalhandler.h5
-rw-r--r--src/net/ea/inventoryhandler.cpp12
-rw-r--r--src/net/ea/inventoryhandler.h9
-rw-r--r--src/net/ea/itemhandler.cpp2
-rw-r--r--src/net/ea/itemhandler.h4
-rw-r--r--src/net/ea/loginhandler.cpp2
-rw-r--r--src/net/ea/loginhandler.h4
-rw-r--r--src/net/ea/messagehandler.cpp (renamed from src/net/messagehandler.cpp)20
-rw-r--r--src/net/ea/messagehandler.h58
-rw-r--r--src/net/ea/messagein.cpp70
-rw-r--r--src/net/ea/messagein.h51
-rw-r--r--src/net/ea/messageout.cpp126
-rw-r--r--src/net/ea/messageout.h64
-rw-r--r--src/net/ea/network.cpp10
-rw-r--r--src/net/ea/network.h23
-rw-r--r--src/net/ea/npchandler.cpp2
-rw-r--r--src/net/ea/npchandler.h5
-rw-r--r--src/net/ea/partyhandler.cpp2
-rw-r--r--src/net/ea/partyhandler.h5
-rw-r--r--src/net/ea/playerhandler.cpp12
-rw-r--r--src/net/ea/playerhandler.h9
-rw-r--r--src/net/ea/specialhandler.cpp2
-rw-r--r--src/net/ea/specialhandler.h5
-rw-r--r--src/net/ea/tradehandler.cpp2
-rw-r--r--src/net/ea/tradehandler.h5
-rw-r--r--src/net/inventoryhandler.h4
-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
-rw-r--r--src/net/messagehandler.h17
-rw-r--r--src/net/messagein.cpp55
-rw-r--r--src/net/messagein.h40
-rw-r--r--src/net/messageout.cpp139
-rw-r--r--src/net/messageout.h60
-rw-r--r--src/net/net.h4
-rw-r--r--src/net/playerhandler.h4
-rw-r--r--src/playerrelations.h2
-rw-r--r--src/utils/stringutils.cpp17
-rw-r--r--src/utils/stringutils.h10
143 files changed, 1524 insertions, 943 deletions
diff --git a/mana.cbp b/mana.cbp
index fb9bf141..4e692f5f 100644
--- a/mana.cbp
+++ b/mana.cbp
@@ -557,6 +557,30 @@
<Option target="eAthena" />
<Option target="UNIX eAthena" />
</Unit>
+ <Unit filename="src\net\ea\messagehandler.cpp">
+ <Option target="eAthena" />
+ <Option target="UNIX eAthena" />
+ </Unit>
+ <Unit filename="src\net\ea\messagein.cpp">
+ <Option target="eAthena" />
+ <Option target="UNIX eAthena" />
+ </Unit>
+ <Unit filename="src\net\ea\messagein.h">
+ <Option target="eAthena" />
+ <Option target="UNIX eAthena" />
+ </Unit>
+ <Unit filename="src\net\ea\messageout.cpp">
+ <Option target="eAthena" />
+ <Option target="UNIX eAthena" />
+ </Unit>
+ <Unit filename="src\net\ea\messageout.h">
+ <Option target="eAthena" />
+ <Option target="UNIX eAthena" />
+ </Unit>
+ <Unit filename="src\net\ea\messagehandler.h">
+ <Option target="eAthena" />
+ <Option target="UNIX eAthena" />
+ </Unit>
<Unit filename="src\net\ea\network.cpp">
<Option target="eAthena" />
<Option target="UNIX eAthena" />
@@ -801,6 +825,30 @@
<Option target="Manaserv" />
<Option target="Unix Manaserv" />
</Unit>
+ <Unit filename="src\net\manaserv\messagehandler.cpp">
+ <Option target="Manaserv" />
+ <Option target="Unix Manaserv" />
+ </Unit>
+ <Unit filename="src\net\manaserv\messagehandler.h">
+ <Option target="Manaserv" />
+ <Option target="Unix Manaserv" />
+ </Unit>
+ <Unit filename="src\net\manaserv\messagein.cpp">
+ <Option target="Manaserv" />
+ <Option target="Unix Manaserv" />
+ </Unit>
+ <Unit filename="src\net\manaserv\messagein.h">
+ <Option target="Manaserv" />
+ <Option target="Unix Manaserv" />
+ </Unit>
+ <Unit filename="src\net\manaserv\messageout.cpp">
+ <Option target="Manaserv" />
+ <Option target="Unix Manaserv" />
+ </Unit>
+ <Unit filename="src\net\manaserv\messageout.h">
+ <Option target="Manaserv" />
+ <Option target="Unix Manaserv" />
+ </Unit>
<Unit filename="src\net\manaserv\network.cpp">
<Option target="Manaserv" />
<Option target="Unix Manaserv" />
@@ -853,7 +901,6 @@
<Option target="Manaserv" />
<Option target="Unix Manaserv" />
</Unit>
- <Unit filename="src\net\messagehandler.cpp" />
<Unit filename="src\net\messagehandler.h" />
<Unit filename="src\net\messagein.cpp" />
<Unit filename="src\net\messagein.h" />
diff --git a/mana.files b/mana.files
index bb0d6451..6691a806 100644
--- a/mana.files
+++ b/mana.files
@@ -323,6 +323,12 @@ src/net/ea/itemhandler.cpp
src/net/ea/itemhandler.h
src/net/ea/loginhandler.cpp
src/net/ea/loginhandler.h
+src/net/ea/messagehandler.cpp
+src/net/ea/messagehandler.h
+src/net/ea/messagein.cpp
+src/net/ea/messagein.h
+src/net/ea/messageout.cpp
+src/net/ea/messageout.h
src/net/ea/network.cpp
src/net/ea/network.h
src/net/ea/npchandler.cpp
@@ -391,6 +397,12 @@ src/net/manaserv/itemhandler.cpp
src/net/manaserv/itemhandler.h
src/net/manaserv/loginhandler.cpp
src/net/manaserv/loginhandler.h
+src/net/manaserv/messagehandler.cpp
+src/net/manaserv/messagehandler.h
+src/net/manaserv/messagein.cpp
+src/net/manaserv/messagein.h
+src/net/manaserv/messageout.cpp
+src/net/manaserv/messageout.h
src/net/manaserv/network.cpp
src/net/manaserv/network.h
src/net/manaserv/npchandler.cpp
@@ -404,7 +416,6 @@ src/net/manaserv/specialhandler.cpp
src/net/manaserv/specialhandler.h
src/net/manaserv/tradehandler.cpp
src/net/manaserv/tradehandler.h
-src/net/messagehandler.cpp
src/net/messagehandler.h
src/net/messagein.cpp
src/net/messagein.h
@@ -538,4 +549,4 @@ tools/tmxcopy/tostring.h
tools/tmxcopy/xmlutils.cpp
tools/tmxcopy/xmlutils.h
tools/tmxcopy/zlibutils.cpp
-tools/tmxcopy/zlibutils.h \ No newline at end of file
+tools/tmxcopy/zlibutils.h
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4c80f29e..f4b33fa3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -267,7 +267,6 @@ SET(SRCS
net/inventoryhandler.h
net/logindata.h
net/loginhandler.h
- net/messagehandler.cpp
net/messagehandler.h
net/messagein.cpp
net/messagein.h
@@ -464,6 +463,12 @@ SET(SRCS_EA
net/ea/itemhandler.h
net/ea/loginhandler.cpp
net/ea/loginhandler.h
+ net/ea/messagehandler.cpp
+ net/ea/messagehandler.h
+ net/ea/messagein.cpp
+ net/ea/messagein.h
+ net/ea/messageout.cpp
+ net/ea/messageout.h
net/ea/network.cpp
net/ea/network.h
net/ea/npchandler.cpp
@@ -534,6 +539,12 @@ SET(SRCS_MANA
net/manaserv/itemhandler.cpp
net/manaserv/loginhandler.cpp
net/manaserv/loginhandler.h
+ net/manaserv/messagehandler.cpp
+ net/manaserv/messagehandler.h
+ net/manaserv/messagein.cpp
+ net/manaserv/messagein.h
+ net/manaserv/messageout.cpp
+ net/manaserv/messageout.h
net/manaserv/network.cpp
net/manaserv/network.h
net/manaserv/npchandler.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index a4849dfa..5d3d9121 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -216,7 +216,6 @@ mana_SOURCES = gui/widgets/avatar.cpp \
net/inventoryhandler.h \
net/logindata.h \
net/loginhandler.h \
- net/messagehandler.cpp \
net/messagehandler.h \
net/messagein.cpp \
net/messagein.h \
@@ -444,6 +443,12 @@ mana_SOURCES += \
net/manaserv/itemhandler.cpp \
net/manaserv/loginhandler.cpp \
net/manaserv/loginhandler.h \
+ net/manaserv/messagehandler.cpp \
+ net/manaserv/messagehandler.h \
+ net/manaserv/messagein.cpp \
+ net/manaserv/messagein.h \
+ net/manaserv/messageout.cpp \
+ net/manaserv/messageout.h \
net/manaserv/network.cpp \
net/manaserv/network.h \
net/manaserv/npchandler.cpp \
@@ -488,6 +493,12 @@ mana_SOURCES += \
net/ea/itemhandler.h \
net/ea/loginhandler.cpp \
net/ea/loginhandler.h \
+ net/ea/messagehandler.cpp \
+ net/ea/messagehandler.h \
+ net/ea/messagein.cpp \
+ net/ea/messagein.h \
+ net/ea/messageout.cpp \
+ net/ea/messageout.h \
net/ea/network.cpp \
net/ea/network.h \
net/ea/npchandler.cpp \
diff --git a/src/being.cpp b/src/being.cpp
index be98bfdd..69d9293f 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -197,7 +197,7 @@ void Being::setDestination(int dstX, int dstY)
setPath(thisPath);
}
-#endif // MANASERV_SUPPORT
+#endif
void Being::clearPath()
{
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp
index 2ad3f0fd..724ac899 100644
--- a/src/beingmanager.cpp
+++ b/src/beingmanager.cpp
@@ -26,10 +26,6 @@
#include "npc.h"
#include "player.h"
-#ifdef MANASERV_SUPPORT
-#include "net/manaserv/protocol.h"
-#endif
-
#include "utils/dtor.h"
#include <cassert>
diff --git a/src/engine.cpp b/src/engine.cpp
index e8f9503c..d205549b 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -47,7 +47,7 @@
#include <assert.h>
Engine::Engine():
- mCurrentMap(0)
+ mCurrentMap(0), mMapName("")
{
}
@@ -56,7 +56,7 @@ Engine::~Engine()
delete mCurrentMap;
}
-bool Engine::changeMap(const std::string &mapPath)
+void Engine::changeMap(const std::string &mapPath)
{
// Clean up floor items, beings and particles
floorItemManager->clear();
@@ -111,8 +111,6 @@ bool Engine::changeMap(const std::string &mapPath)
mCurrentMap = newMap;
Net::getGameHandler()->mapLoaded(mapPath);
-
- return true;
}
void Engine::logic()
diff --git a/src/engine.h b/src/engine.h
index ae8e1132..290cac3c 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -47,7 +47,7 @@ class Engine
/**
* Sets the currently active map.
*/
- bool changeMap(const std::string &mapName);
+ void changeMap(const std::string &mapName);
/**
* Performs engine logic. This method is called 100 times per second.
diff --git a/src/game.cpp b/src/game.cpp
index 03068769..33833772 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -81,9 +81,6 @@
#include "net/generalhandler.h"
#include "net/net.h"
-#include "net/manaserv/inventoryhandler.h"
-#include "net/ea/inventoryhandler.h"
-
#include "resources/imagewriter.h"
#include "utils/gettext.h"
diff --git a/src/gui/buddywindow.h b/src/gui/buddywindow.h
index fdcfb36b..0057ac1d 100644
--- a/src/gui/buddywindow.h
+++ b/src/gui/buddywindow.h
@@ -57,4 +57,4 @@ class BuddyWindow : public Window, public gcn::ActionListener
std::list<Avatar*> mBuddyList;
};
-#endif /* BUDDYWINDOW_H */
+#endif // BUDDYWINDOW_H
diff --git a/src/gui/guildwindow.cpp b/src/gui/guildwindow.cpp
index 9cebc4e1..83ff12a1 100644
--- a/src/gui/guildwindow.cpp
+++ b/src/gui/guildwindow.cpp
@@ -132,7 +132,7 @@ void GuildWindow::action(const gcn::ActionEvent &event)
short guild = getSelectedGuild();
if (guild)
{
- Net::ChatServer::Guild::quitGuild(guild);
+ ManaServ::ChatServer::Guild::quitGuild(guild);
localChatTab->chatLog(strprintf(_("Guild %s quit."),
mGuildTabs->getSelectedTab()->getCaption().c_str()), BY_SERVER);
}
@@ -146,7 +146,7 @@ void GuildWindow::action(const gcn::ActionEvent &event)
return;
}
// Process guild name to be created, and unfocus.
- Net::ChatServer::Guild::createGuild(name);
+ ManaServ::ChatServer::Guild::createGuild(name);
// Defocus dialog
mFocus = false;
@@ -160,7 +160,7 @@ void GuildWindow::action(const gcn::ActionEvent &event)
short selectedGuild = getSelectedGuild();
// Process invited user to be created and unfocus.
- Net::ChatServer::Guild::invitePlayer(name, selectedGuild);
+ ManaServ::ChatServer::Guild::invitePlayer(name, selectedGuild);
// Defocus dialog
mFocus = false;
@@ -170,7 +170,7 @@ void GuildWindow::action(const gcn::ActionEvent &event)
else if (eventId == "yes")
{
logger->log("Sending invitation acceptance.");
- Net::ChatServer::Guild::acceptInvite(invitedGuild);
+ ManaServ::ChatServer::Guild::acceptInvite(invitedGuild);
}
}
@@ -253,7 +253,7 @@ void GuildWindow::openAcceptDialog(const std::string &inviterName,
void GuildWindow::requestMemberList(short guildId)
{
// Get the list of members for displaying in the guild window.
- Net::ChatServer::Guild::getGuildMembers(guildId);
+ ManaServ::ChatServer::Guild::getGuildMembers(guildId);
}
void GuildWindow::removeTab(int guildId)
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index fbda5ac7..d7e82bd1 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -26,6 +26,9 @@
#include "inventory.h"
+#include "net/inventoryhandler.h"
+#include "net/net.h"
+
#include <guichan/actionlistener.hpp>
#include <guichan/keylistener.hpp>
#include <guichan/selectionlistener.hpp>
@@ -49,7 +52,8 @@ class InventoryWindow : public Window,
/**
* Constructor.
*/
- InventoryWindow(int invSize = (INVENTORY_SIZE));
+ InventoryWindow(int invSize = Net::getInventoryHandler()
+ ->getInventorySize());
/**
* Destructor.
diff --git a/src/gui/itemamount.h b/src/gui/itemamount.h
index 72db3444..20d25562 100644
--- a/src/gui/itemamount.h
+++ b/src/gui/itemamount.h
@@ -101,4 +101,4 @@ class ItemAmountWindow : public Window,
bool mEnabledKeyboard;
};
-#endif /* ITEM_AMOUNT_WINDOW_H */
+#endif // ITEM_AMOUNT_WINDOW_H
diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp
index aecca0c6..70af6690 100644
--- a/src/gui/playerbox.cpp
+++ b/src/gui/playerbox.cpp
@@ -82,21 +82,9 @@ void PlayerBox::draw(gcn::Graphics *graphics)
{
// Draw character
const int bs = getFrameSize();
-//#ifdef MANASERV_SUPPORT
const int x = getWidth() / 2 + bs;
- const int y = getHeight() - bs - 8;
+ const int y = getHeight() - bs;
mPlayer->draw(static_cast<Graphics*>(graphics), x, y);
-/*#else
- const int x = getWidth() / 2 - 16 + bs;
- const int y = getHeight() / 2 + bs;
- for (int i = 0; i < Being::VECTOREND_SPRITE; i++)
- {
- if (mPlayer->getSprite(i))
- {
- mPlayer->getSprite(i)->draw(static_cast<Graphics*>(graphics), x, y);
- }
- }
-#endif*/
}
if (config.getValue("guialpha", 0.8) != mAlpha)
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 9051a5f2..16de45a8 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -350,16 +350,12 @@ void ServerDialog::loadServers()
{
if (xmlStrEqual(server->name, BAD_CAST "server"))
{
- //check wether the version matches
- #ifdef MANASERV_SUPPORT
- if (XML::getProperty(server, "type", "unknown") != "MANASERV")
- continue;
- #endif
-
- #ifdef EATHENA_SUPPORT
- if (XML::getProperty(server, "type", "unknown") != "EATHENA")
+ //check wether the build matches
+ if (compareStrI(XML::getProperty(server, "type", "unknown"),
+ SERVER_BUILD))
+ {
continue;
- #endif
+ }
currentServer.clear();
currentServer.name = XML::getProperty(server, "name", std::string());
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index de70457d..7d4a612d 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -38,10 +38,6 @@
#include "net/net.h"
#include "net/playerhandler.h"
-#ifdef EATHENA_SUPPORT
-#include "net/ea/protocol.h"
-#endif
-
#include "utils/gettext.h"
#include "utils/mathutils.h"
#include "utils/stringutils.h"
@@ -81,9 +77,7 @@ class ChangeDisplay : public AttrDisplay, gcn::ActionListener
int mNeeded;
Label *mPoints;
-#ifdef MANASERV_SUPPORT
Button *mDec;
-#endif
Button *mInc;
};
@@ -131,15 +125,16 @@ StatusWindow::StatusWindow():
// 5, 2 and 6, 2 Job Progress Bar
place(1, 2, mMpBar, 4);
-#ifdef EATHENA_SUPPORT
- mJobLvlLabel = new Label(strprintf(_("Job: %d"), 0));
- mJobLabel = new Label(_("Job:"));
- mJobBar = new ProgressBar(0.0f, 80, 15, gcn::Color(220, 135, 203));
+ if (Net::getPlayerHandler()->getJobLocation() > 0)
+ {
+ mJobLvlLabel = new Label(strprintf(_("Job: %d"), 0));
+ mJobLabel = new Label(_("Job:"));
+ mJobBar = new ProgressBar(0.0f, 80, 15, gcn::Color(220, 135, 203));
- place(5, 0, mJobLvlLabel, 3);
- place(5, 2, mJobLabel).setPadding(3);
- place(6, 2, mJobBar, 5);
-#endif
+ place(5, 0, mJobLvlLabel, 3);
+ place(5, 2, mJobLabel).setPadding(3);
+ place(6, 2, mJobBar, 5);
+ }
// ----------------------
// Stats Part
@@ -163,10 +158,12 @@ StatusWindow::StatusWindow():
mCharacterPointsLabel = new Label("C");
place(0, 6, mCharacterPointsLabel, 5);
-#ifdef MANASERV_SUPPORT
- mCorrectionPointsLabel = new Label("C");
- place(0, 7, mCorrectionPointsLabel, 5);
-#endif
+
+ if (Net::getPlayerHandler()->canCorrectAttributes())
+ {
+ mCorrectionPointsLabel = new Label("C");
+ place(0, 7, mCorrectionPointsLabel, 5);
+ }
loadWindowState();
@@ -176,17 +173,15 @@ StatusWindow::StatusWindow():
update(MONEY);
update(CHAR_POINTS); // This also updates all attributes (none atm)
update(LEVEL);
-#ifdef EATHENA_SUPPORT
- update(JOB);
-#endif
+ int job = Net::getPlayerHandler()->getJobLocation();
+ if (job > 0)
+ {
+ update(job);
+ }
}
std::string StatusWindow::update(int id)
{
- /*/ TODO get rid of this
- if (!player_node)
- return "";*/
-
if (miniStatusWindow)
miniStatusWindow->update(id);
@@ -217,29 +212,28 @@ std::string StatusWindow::update(int id)
return _("Money");
}
-#ifdef EATHENA_SUPPORT
- else if (id == JOB)
+ else if (id == Net::getPlayerHandler()->getJobLocation())
{
mJobLvlLabel->setCaption(strprintf(_("Job: %d"),
- player_node->getAttributeBase(JOB)));
+ player_node->getAttributeBase(id)));
mJobLvlLabel->adjustSize();
- updateProgressBar(mJobBar, JOB, false);
+ updateProgressBar(mJobBar, id, false);
return _("Job");
}
-#endif
else if (id == CHAR_POINTS)
{
mCharacterPointsLabel->setCaption(strprintf(_("Character points: %d"),
player_node->getCharacterPoints()));
mCharacterPointsLabel->adjustSize();
-#ifdef MANASERV_SUPPORT
- mCorrectionPointsLabel->setCaption(strprintf(_("Correction points: %d"),
- player_node->getCorrectionPoints()));
- mCorrectionPointsLabel->adjustSize();
-#endif
+ if (Net::getPlayerHandler()->canCorrectAttributes())
+ {
+ mCorrectionPointsLabel->setCaption(strprintf(_("Correction points: %d"),
+ player_node->getCorrectionPoints()));
+ mCorrectionPointsLabel->adjustSize();
+ }
for (Attrs::iterator it = mAttrs.begin(); it != mAttrs.end(); it++)
{
@@ -490,12 +484,17 @@ ChangeDisplay::ChangeDisplay(int id, const std::string &name):
place(6, 0, mInc);
place(7, 0, mPoints);
-#ifdef MANASERV_SUPPORT
- mDec = new Button(_("-"), "dec", this);
- mDec->setWidth(mInc->getWidth());
+ if (Net::getPlayerHandler()->canCorrectAttributes())
+ {
+ mDec = new Button(_("-"), "dec", this);
+ mDec->setWidth(mInc->getWidth());
- place(3, 0, mDec);
-#endif
+ place(3, 0, mDec);
+ }
+ else
+ {
+ mDec = 0;
+ }
update();
}
@@ -504,9 +503,8 @@ std::string ChangeDisplay::update()
{
mPoints->setCaption(toString(mNeeded));
-#ifdef MANASERV_SUPPORT
- mDec->setEnabled(player_node->getCorrectionPoints());
-#endif
+ if (mDec)
+ mDec->setEnabled(player_node->getCorrectionPoints());
mInc->setEnabled(player_node->getCharacterPoints() >= mNeeded);
return AttrDisplay::update();
@@ -521,8 +519,8 @@ void ChangeDisplay::setPointsNeeded(int needed)
void ChangeDisplay::action(const gcn::ActionEvent &event)
{
-#ifdef MANASERV_SUPPORT
- if (event.getSource() == mDec)
+ if (Net::getPlayerHandler()->canCorrectAttributes() &&
+ event.getSource() == mDec)
{
int newcorpoints = player_node->getCorrectionPoints() - 1;
player_node->setCorrectionPoints(newcorpoints);
@@ -533,9 +531,7 @@ void ChangeDisplay::action(const gcn::ActionEvent &event)
int newmod = player_node->getAttributeEffective(mId) - 1;
player_node->setAttributeEffective(mId, newmod);
Net::getPlayerHandler()->decreaseAttribute(mId);
- } else
-#endif
- if (event.getSource() == mInc)
+ } else if (event.getSource() == mInc)
{
int newpoints = player_node->getCharacterPoints() - 1;
player_node->setCharacterPoints(newpoints);
diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h
index 0706a17e..84c74ee7 100644
--- a/src/gui/statuswindow.h
+++ b/src/gui/statuswindow.h
@@ -79,10 +79,8 @@ class StatusWindow : public Window
gcn::Label *mHpLabel, *mMpLabel, *mXpLabel;
ProgressBar *mHpBar, *mMpBar, *mXpBar;
-#ifdef EATHENA_SUPPORT
gcn::Label *mJobLvlLabel, *mJobLabel;
ProgressBar *mJobBar;
-#endif
VertContainer *mAttrCont;
ScrollArea *mAttrScroll;
@@ -90,9 +88,7 @@ class StatusWindow : public Window
ScrollArea *mDAttrScroll;
gcn::Label *mCharacterPointsLabel;
-#ifdef MANASERV_SUPPORT
gcn::Label *mCorrectionPointsLabel;
-#endif
typedef std::map<int, AttrDisplay*> Attrs;
Attrs mAttrs;
diff --git a/src/gui/storagewindow.cpp b/src/gui/storagewindow.cpp
index f0d00ee7..b0ffa3ff 100644
--- a/src/gui/storagewindow.cpp
+++ b/src/gui/storagewindow.cpp
@@ -38,8 +38,8 @@
#include "localplayer.h"
#include "units.h"
+#include "net/inventoryhandler.h"
#include "net/net.h"
-#include "net/ea/inventoryhandler.h"
#include "resources/iteminfo.h"
diff --git a/src/gui/storagewindow.h b/src/gui/storagewindow.h
index 452ce735..8c890c27 100644
--- a/src/gui/storagewindow.h
+++ b/src/gui/storagewindow.h
@@ -26,6 +26,9 @@
#include "inventory.h"
+#include "net/inventoryhandler.h"
+#include "net/net.h"
+
#include <guichan/actionlistener.hpp>
#include <guichan/selectionlistener.hpp>
@@ -46,7 +49,8 @@ class StorageWindow : public Window, gcn::ActionListener,
/**
* Constructor.
*/
- StorageWindow(int invSize = (STORAGE_SIZE - 1));
+ StorageWindow(int invSize = Net::getInventoryHandler()
+ ->getStorageSize());
/**
* Destructor.
diff --git a/src/gui/table.h b/src/gui/table.h
index 4f3c29c6..d1f445b3 100644
--- a/src/gui/table.h
+++ b/src/gui/table.h
@@ -182,4 +182,4 @@ private:
};
-#endif /* !defined(TABLE_H) */
+#endif // TABLE_H
diff --git a/src/gui/tablemodel.h b/src/gui/tablemodel.h
index ffaa0557..129d2089 100644
--- a/src/gui/tablemodel.h
+++ b/src/gui/tablemodel.h
@@ -143,4 +143,4 @@ protected:
std::vector<int> mWidths;
};
-#endif /* !defined(TABLE_MODEL_H) */
+#endif // TABLE_MODEL_H
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 22eefc14..15a4d7e8 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -38,6 +38,7 @@
#include "gui/widgets/textfield.h"
#include "gui/widgets/layout.h"
+#include "net/inventoryhandler.h"
#include "net/net.h"
#include "net/tradehandler.h"
@@ -56,8 +57,10 @@
TradeWindow::TradeWindow():
Window(_("Trade: You")),
- mMyInventory(new Inventory(INVENTORY_SIZE)),
- mPartnerInventory(new Inventory(INVENTORY_SIZE)),
+ mMyInventory(new Inventory(Net::getInventoryHandler()
+ ->getInventorySize())),
+ mPartnerInventory(new Inventory(Net::getInventoryHandler()
+ ->getInventorySize())),
mStatus(PROPOSING)
{
setWindowName("Trade");
diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h
index 57eb3623..8e61776e 100644
--- a/src/gui/widgets/radiobutton.h
+++ b/src/gui/widgets/radiobutton.h
@@ -76,4 +76,4 @@ class RadioButton : public gcn::RadioButton
static Image *radioCheckedHi;
};
-#endif /* RADIOBUTTON_H */
+#endif // RADIOBUTTON_H
diff --git a/src/inventory.h b/src/inventory.h
index cd57d10e..48283b50 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -24,13 +24,6 @@
class Item;
-#ifdef EATHENA_SUPPORT
-const int INVENTORY_SIZE = 100;
-#else
-const int INVENTORY_SIZE = 50;
-#endif
-const int STORAGE_SIZE = 301;
-
class Inventory
{
public:
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index b6768a2a..22ca20d1 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -57,7 +57,6 @@
#ifdef MANASERV_SUPPORT
#include "guild.h"
-//#include "net/manaserv/gameserver/player.h"
#include "net/manaserv/chatserver/guild.h"
#endif
@@ -106,11 +105,11 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map):
mWalkingDir(0),
mPathSetByMouse(false),
mDestX(0), mDestY(0),
- mInventory(new Inventory(INVENTORY_SIZE)),
+ mInventory(new Inventory(Net::getInventoryHandler()->getInventorySize())),
#ifdef MANASERV_SUPPORT
mLocalWalkTime(-1),
#endif
- mStorage(new Inventory(STORAGE_SIZE)),
+ mStorage(new Inventory(Net::getInventoryHandler()->getStorageSize())),
mMessageTime(0)
{
// Variable to keep the local player from doing certain actions before a map
@@ -132,9 +131,7 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map):
LocalPlayer::~LocalPlayer()
{
delete mInventory;
-#ifdef EATHENA_SUPPORT
delete mStorage;
-#endif
config.removeListener("showownname", this);
@@ -297,7 +294,7 @@ void LocalPlayer::nextStep(unsigned char dir = 0)
Player::nextStep();
-#else // MANASERV_SUPPORT
+#else
if (!mMap || !dir)
return;
@@ -379,7 +376,7 @@ void LocalPlayer::inviteToGuild(Being *being)
{
if (checkInviteRights(itr->second->getName()))
{
- Net::ChatServer::Guild::invitePlayer(being->getName(), itr->second->getId());
+ ManaServ::ChatServer::Guild::invitePlayer(being->getName(), itr->second->getId());
return;
}
}
@@ -635,7 +632,7 @@ void LocalPlayer::startWalking(unsigned char dir)
Net::getPlayerHandler()->setDirection(dir);
setDirection(dir);
}
-#else // MANASERV_SUPPORT
+#else
nextStep(dir);
#endif
}
@@ -687,58 +684,6 @@ void LocalPlayer::emote(Uint8 emotion)
}
#ifdef MANASERV_SUPPORT
-/*
-void LocalPlayer::attack()
-{
- if (mLastAction != -1)
- return;
-
- // Can only attack when standing still
- if (mAction != STAND && mAction != ATTACK)
- return;
-
- //Face direction of the target
- if(mTarget){
- unsigned char dir = 0;
- int x = 0, y = 0;
- Vector plaPos = this->getPosition();
- Vector tarPos = mTarget->getPosition();
- x = plaPos.x - tarPos.x;
- y = plaPos.y - tarPos.y;
- if(abs(x) < abs(y)){
- //Check to see if target is above me or below me
- if(y > 0){
- dir = UP;
- } else {
- dir = DOWN;
- }
- } else {
- //check to see if the target is to the left or right of me
- if(x > 0){
- dir = LEFT;
- } else {
- dir = RIGHT;
- }
- }
- setDirection(dir);
- }
-
- mLastAction = tick_time;
-
- setAction(ATTACK);
-
- if (mEquippedWeapon)
- {
- std::string soundFile = mEquippedWeapon->getSound(EQUIP_EVENT_STRIKE);
- if (soundFile != "") sound.playSfx(soundFile);
- }
- else {
- sound.playSfx("sfx/fist-swish.ogg");
- }
- Net::GameServer::Player::attack(getSpriteDirection());
-}
-*/
-
void LocalPlayer::useSpecial(int special)
{
Net::getSpecialHandler()->use(special);
@@ -751,7 +696,6 @@ void LocalPlayer::setSpecialStatus(int id, int current, int max, int recharge)
mSpecials[id].neededMana = max;
mSpecials[id].recharge = recharge;
}
-
#endif
void LocalPlayer::attack(Being *target, bool keep)
@@ -780,16 +724,7 @@ void LocalPlayer::attack(Being *target, bool keep)
Vector tarPos = mTarget->getPosition();
int dist_x = plaPos.x - tarPos.x;
int dist_y = plaPos.y - tarPos.y;
-#else
- int dist_x = target->getTileX() - getTileX();
- int dist_y = target->getTileY() - getTileY();
- // Must be standing to attack
- if (mAction != STAND)
- return;
-#endif
-
-#ifdef MANASERV_SUPPORT
if (abs(dist_y) >= abs(dist_x))
{
if (dist_y < 0)
@@ -804,7 +739,16 @@ void LocalPlayer::attack(Being *target, bool keep)
else
setDirection(LEFT);
}
+
+ mLastAction = tick_time;
#else
+ int dist_x = target->getTileX() - getTileX();
+ int dist_y = target->getTileY() - getTileY();
+
+ // Must be standing to attack
+ if (mAction != STAND)
+ return;
+
if (abs(dist_y) >= abs(dist_x))
{
if (dist_y > 0)
@@ -819,11 +763,7 @@ void LocalPlayer::attack(Being *target, bool keep)
else
setDirection(LEFT);
}
-#endif
-#ifdef MANASERV_SUPPORT
- mLastAction = tick_time;
-#else
mWalkTime = tick_time;
mTargetTime = tick_time;
#endif
@@ -1187,14 +1127,12 @@ void LocalPlayer::loadTargetCursor(const std::string &filename,
mTargetCursor[index][size] = currentCursor;
}
-#ifdef EATHENA_SUPPORT
void LocalPlayer::setInStorage(bool inStorage)
{
mInStorage = inStorage;
storageWindow->setVisible(inStorage);
}
-#endif
void LocalPlayer::addMessageToQueue(const std::string &message,
Palette::ColorType color)
diff --git a/src/main.cpp b/src/main.cpp
index ce1c9c9b..fc88a1d9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -123,12 +123,6 @@ namespace
static const int defaultSfxVolume = 100;
static const int defaultMusicVolume = 60;
-/*#ifdef MANASERV_SUPPORT
-extern Net::Connection *gameServerConnection;
-extern Net::Connection *chatServerConnection;
-extern Net::Connection *accountServerConnection;
-#endif*/
-
Graphics *graphics;
Game *game = 0;
@@ -925,8 +919,6 @@ int main(int argc, char *argv[])
if (state != oldstate)
{
- //printf("State change: %d to %d\n", oldstate, state);
-
oldstate = state;
// Get rid of the dialog of the previous state
@@ -1300,9 +1292,6 @@ int main(int argc, char *argv[])
}
delete guiPalette;
-/*#ifdef EATHENA_SUPPORT
- delete network;
-#endif*/
logger->log("Quitting");
exitEngine();
diff --git a/src/main.h b/src/main.h
index 69222d4d..21785fff 100644
--- a/src/main.h
+++ b/src/main.h
@@ -61,14 +61,16 @@
#define PACKAGE_VERSION "0.0.29.1"
#endif
-#ifdef PACKAGE_VERSION
#ifdef MANASERV_SUPPORT
-#define FULL_VERSION "v" PACKAGE_VERSION " (manaserv)"
+#define SERVER_BUILD "manaserv"
#else
-#define FULL_VERSION "v" PACKAGE_VERSION " (eAthena)"
+#define SERVER_BUILD "eAthena"
#endif
+
+#ifdef PACKAGE_VERSION
+#define FULL_VERSION "v" PACKAGE_VERSION " (" SERVER_BUILD ")"
#else
-#define FULL_VERSION "Unknown Version"
+#define FULL_VERSION "Unknown Version (" SERVER_BUILD ")"
#endif
#ifndef PKG_DATADIR
diff --git a/src/net/ea/adminhandler.cpp b/src/net/ea/adminhandler.cpp
index e1099a4d..62fe9ea8 100644
--- a/src/net/ea/adminhandler.cpp
+++ b/src/net/ea/adminhandler.cpp
@@ -21,11 +21,10 @@
#include "net/ea/adminhandler.h"
-#include "net/ea/chathandler.h"
-#include "net/ea/protocol.h"
+#include "net/chathandler.h"
+#include "net/net.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
+#include "net/ea/protocol.h"
#include "being.h"
#include "beingmanager.h"
@@ -55,7 +54,7 @@ AdminHandler::AdminHandler()
adminHandler = this;
}
-void AdminHandler::handleMessage(MessageIn &msg)
+void AdminHandler::handleMessage(Net::MessageIn &msg)
{
int id;
switch (msg.getId())
@@ -118,7 +117,7 @@ void AdminHandler::unban(int playerId)
void AdminHandler::unban(const std::string &name)
{
- chatHandler->talk("@unban " + name);
+ Net::getChatHandler()->talk("@unban " + name);
}
void AdminHandler::mute(int playerId, int type, int limit)
diff --git a/src/net/ea/adminhandler.h b/src/net/ea/adminhandler.h
index 6ef4f76a..83d732cc 100644
--- a/src/net/ea/adminhandler.h
+++ b/src/net/ea/adminhandler.h
@@ -23,9 +23,10 @@
#define NET_EA_ADMINHANDLER_H
#include "net/adminhandler.h"
-#include "net/messagehandler.h"
#include "net/net.h"
+#include "net/ea/messagehandler.h"
+
namespace EAthena {
class AdminHandler : public MessageHandler, public Net::AdminHandler
@@ -33,7 +34,7 @@ class AdminHandler : public MessageHandler, public Net::AdminHandler
public:
AdminHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void announce(const std::string &text);
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 2cc93f6e..8a958845 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -23,9 +23,6 @@
#include "net/ea/protocol.h"
-#include "net/messagein.h"
-#include "net/messageout.h"
-
#include "being.h"
#include "beingmanager.h"
#include "effectmanager.h"
@@ -97,7 +94,7 @@ Being *createBeing(int id, short job)
return being;
}
-void BeingHandler::handleMessage(MessageIn &msg)
+void BeingHandler::handleMessage(Net::MessageIn &msg)
{
int id;
short job, speed, gender;
diff --git a/src/net/ea/beinghandler.h b/src/net/ea/beinghandler.h
index 97001579..d1cafc93 100644
--- a/src/net/ea/beinghandler.h
+++ b/src/net/ea/beinghandler.h
@@ -22,7 +22,7 @@
#ifndef NET_EA_BEINGHANDLER_H
#define NET_EA_BEINGHANDLER_H
-#include "net/messagehandler.h"
+#include "net/ea/messagehandler.h"
namespace EAthena {
@@ -31,7 +31,7 @@ class BeingHandler : public MessageHandler
public:
BeingHandler(bool enableSync);
- virtual void handleMessage(MessageIn &msg);
+ virtual void handleMessage(Net::MessageIn &msg);
private:
// Should we honor server "Stop Walking" packets
diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp
index 48e856e4..8dba566d 100644
--- a/src/net/ea/buysellhandler.cpp
+++ b/src/net/ea/buysellhandler.cpp
@@ -54,7 +54,7 @@ BuySellHandler::BuySellHandler()
handledMessages = _messages;
}
-void BuySellHandler::handleMessage(MessageIn &msg)
+void BuySellHandler::handleMessage(Net::MessageIn &msg)
{
int n_items;
switch (msg.getId())
diff --git a/src/net/ea/buysellhandler.h b/src/net/ea/buysellhandler.h
index cddace55..8277c5c9 100644
--- a/src/net/ea/buysellhandler.h
+++ b/src/net/ea/buysellhandler.h
@@ -22,7 +22,7 @@
#ifndef NET_EA_BUYSELLHANDLER_H
#define NET_EA_BUYSELLHANDLER_H
-#include "net/messagehandler.h"
+#include "net/ea/messagehandler.h"
namespace EAthena {
@@ -31,7 +31,7 @@ class BuySellHandler : public MessageHandler
public:
BuySellHandler();
- virtual void handleMessage(MessageIn &msg);
+ virtual void handleMessage(Net::MessageIn &msg);
};
} // namespace EAthena
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp
index f4b82aee..47eddc12 100644
--- a/src/net/ea/charserverhandler.cpp
+++ b/src/net/ea/charserverhandler.cpp
@@ -67,7 +67,7 @@ CharServerHandler::CharServerHandler():
charHandler = this;
}
-void CharServerHandler::handleMessage(MessageIn &msg)
+void CharServerHandler::handleMessage(Net::MessageIn &msg)
{
int count, slot;
LocalPlayer *tempPlayer;
@@ -176,7 +176,7 @@ void CharServerHandler::handleMessage(MessageIn &msg)
}
}
-LocalPlayer *CharServerHandler::readPlayerData(MessageIn &msg, int &slot)
+LocalPlayer *CharServerHandler::readPlayerData(Net::MessageIn &msg, int &slot)
{
const Token &token =
static_cast<LoginHandler*>(Net::getLoginHandler())->getToken();
diff --git a/src/net/ea/charserverhandler.h b/src/net/ea/charserverhandler.h
index 393ec15c..b1e2b797 100644
--- a/src/net/ea/charserverhandler.h
+++ b/src/net/ea/charserverhandler.h
@@ -22,10 +22,10 @@
#ifndef NET_EA_CHARSERVERHANDLER_H
#define NET_EA_CHARSERVERHANDLER_H
-#include "net/messagehandler.h"
#include "net/charhandler.h"
#include "net/serverinfo.h"
+#include "net/ea/messagehandler.h"
#include "net/ea/token.h"
class LoginData;
@@ -40,7 +40,7 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler
public:
CharServerHandler();
- virtual void handleMessage(MessageIn &msg);
+ virtual void handleMessage(Net::MessageIn &msg);
void setCharInfo(LockedArray<LocalPlayer*> *charInfo)
{ mCharInfo = charInfo; }
@@ -72,7 +72,7 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler
CharSelectDialog *mCharSelectDialog;
CharCreateDialog *mCharCreateDialog;
- LocalPlayer *readPlayerData(MessageIn &msg, int &slot);
+ LocalPlayer *readPlayerData(Net::MessageIn &msg, int &slot);
};
} // namespace EAthena
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index 65f1db3c..913cfacf 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -58,7 +58,7 @@ ChatHandler::ChatHandler()
chatHandler = this;
}
-void ChatHandler::handleMessage(MessageIn &msg)
+void ChatHandler::handleMessage(Net::MessageIn &msg)
{
Being *being;
std::string chatMsg;
diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h
index f77b7b80..3396a88b 100644
--- a/src/net/ea/chathandler.h
+++ b/src/net/ea/chathandler.h
@@ -23,9 +23,10 @@
#define NET_EA_CHATHANDLER_H
#include "net/chathandler.h"
-#include "net/messagehandler.h"
#include "net/net.h"
+#include "net/ea/messagehandler.h"
+
namespace EAthena {
class ChatHandler : public MessageHandler, public Net::ChatHandler
@@ -33,7 +34,7 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler
public:
ChatHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void talk(const std::string &text);
diff --git a/src/net/ea/equipmenthandler.cpp b/src/net/ea/equipmenthandler.cpp
index 3520bca5..28a2940c 100644
--- a/src/net/ea/equipmenthandler.cpp
+++ b/src/net/ea/equipmenthandler.cpp
@@ -155,7 +155,7 @@ EquipmentHandler::EquipmentHandler()
memset(equips, 0, sizeof(equips));
}
-void EquipmentHandler::handleMessage(MessageIn &msg)
+void EquipmentHandler::handleMessage(Net::MessageIn &msg)
{
int itemCount;
int index, equipPoint, itemId;
diff --git a/src/net/ea/equipmenthandler.h b/src/net/ea/equipmenthandler.h
index 47c2f803..32ea83c4 100644
--- a/src/net/ea/equipmenthandler.h
+++ b/src/net/ea/equipmenthandler.h
@@ -22,7 +22,7 @@
#ifndef NET_EA_EQUIPMENTHANDLER_H
#define NET_EA_EQUIPMENTHANDLER_H
-#include "net/messagehandler.h"
+#include "net/ea/messagehandler.h"
class Item;
@@ -37,7 +37,7 @@ class EquipmentHandler : public MessageHandler
public:
EquipmentHandler();
- virtual void handleMessage(MessageIn &msg);
+ virtual void handleMessage(Net::MessageIn &msg);
};
} // namespace EAthena
diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp
index 97862883..5becfe1b 100644
--- a/src/net/ea/gamehandler.cpp
+++ b/src/net/ea/gamehandler.cpp
@@ -61,7 +61,7 @@ GameHandler::GameHandler()
gameHandler = this;
}
-void GameHandler::handleMessage(MessageIn &msg)
+void GameHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
diff --git a/src/net/ea/gamehandler.h b/src/net/ea/gamehandler.h
index d8adeeaf..0095ada3 100644
--- a/src/net/ea/gamehandler.h
+++ b/src/net/ea/gamehandler.h
@@ -23,10 +23,10 @@
#define NET_EA_MAPHANDLER_H
#include "net/gamehandler.h"
-#include "net/messagehandler.h"
#include "net/net.h"
#include "net/serverinfo.h"
+#include "net/ea/messagehandler.h"
#include "net/ea/token.h"
namespace EAthena {
@@ -36,7 +36,7 @@ class GameHandler : public MessageHandler, public Net::GameHandler
public:
GameHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void connect();
diff --git a/src/net/ea/generalhandler.cpp b/src/net/ea/generalhandler.cpp
index 62a7c1aa..4ef2f9e2 100644
--- a/src/net/ea/generalhandler.cpp
+++ b/src/net/ea/generalhandler.cpp
@@ -110,7 +110,7 @@ GeneralHandler::~GeneralHandler()
delete mNetwork;
}
-void GeneralHandler::handleMessage(MessageIn &msg)
+void GeneralHandler::handleMessage(Net::MessageIn &msg)
{
int code;
diff --git a/src/net/ea/generalhandler.h b/src/net/ea/generalhandler.h
index b8ea8049..8bbf4f61 100644
--- a/src/net/ea/generalhandler.h
+++ b/src/net/ea/generalhandler.h
@@ -23,10 +23,11 @@
#define NET_EA_GENERALHANDLER_H
#include "net/generalhandler.h"
-#include "net/messagehandler.h"
#include "net/net.h"
#include "net/serverinfo.h"
+#include "net/ea/messagehandler.h"
+
namespace EAthena {
class GeneralHandler : public MessageHandler, public Net::GeneralHandler
@@ -36,7 +37,7 @@ class GeneralHandler : public MessageHandler, public Net::GeneralHandler
~GeneralHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void load();
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 55714a70..8f2b4453 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -72,7 +72,7 @@ InventoryHandler::InventoryHandler()
inventoryHandler = this;
}
-void InventoryHandler::handleMessage(MessageIn &msg)
+void InventoryHandler::handleMessage(Net::MessageIn &msg)
{
int number;
int index, amount, itemId, equipType, arrow;
@@ -374,4 +374,14 @@ void InventoryHandler::moveItem(StorageType source, int slot, int amount,
}
}
+size_t InventoryHandler::getInventorySize() const
+{
+ return 100;
+}
+
+size_t InventoryHandler::getStorageSize() const
+{
+ return 300;
+}
+
} // namespace EAthena
diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h
index 30408dad..e61ee14b 100644
--- a/src/net/ea/inventoryhandler.h
+++ b/src/net/ea/inventoryhandler.h
@@ -23,9 +23,10 @@
#define NET_EA_INVENTORYHANDLER_H
#include "net/inventoryhandler.h"
-#include "net/messagehandler.h"
#include "net/net.h"
+#include "net/ea/messagehandler.h"
+
namespace EAthena {
class InventoryHandler : public MessageHandler, public Net::InventoryHandler
@@ -33,7 +34,7 @@ class InventoryHandler : public MessageHandler, public Net::InventoryHandler
public:
InventoryHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void equipItem(const Item *item);
@@ -55,6 +56,10 @@ class InventoryHandler : public MessageHandler, public Net::InventoryHandler
void moveItem(StorageType source, int slot, int amount,
StorageType destination);
+
+ size_t getInventorySize() const;
+
+ size_t getStorageSize() const;
};
} // namespace EAthena
diff --git a/src/net/ea/itemhandler.cpp b/src/net/ea/itemhandler.cpp
index 95d480f9..f926f8e8 100644
--- a/src/net/ea/itemhandler.cpp
+++ b/src/net/ea/itemhandler.cpp
@@ -41,7 +41,7 @@ ItemHandler::ItemHandler()
handledMessages = _messages;
}
-void ItemHandler::handleMessage(MessageIn &msg)
+void ItemHandler::handleMessage(Net::MessageIn &msg)
{
Uint32 id;
Uint16 x, y;
diff --git a/src/net/ea/itemhandler.h b/src/net/ea/itemhandler.h
index f72e4779..53362190 100644
--- a/src/net/ea/itemhandler.h
+++ b/src/net/ea/itemhandler.h
@@ -22,7 +22,7 @@
#ifndef NET_EA_ITEMHANDLER_H
#define NET_EA_ITEMHANDLER_H
-#include "net/messagehandler.h"
+#include "net/ea/messagehandler.h"
namespace EAthena {
@@ -31,7 +31,7 @@ class ItemHandler : public MessageHandler
public:
ItemHandler();
- virtual void handleMessage(MessageIn &msg);
+ virtual void handleMessage(Net::MessageIn &msg);
};
} // namespace EAthena
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index c48e596e..a57eee8a 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -55,7 +55,7 @@ LoginHandler::LoginHandler()
loginHandler = this;
}
-void LoginHandler::handleMessage(MessageIn &msg)
+void LoginHandler::handleMessage(Net::MessageIn &msg)
{
int code, worldCount;
diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h
index 0d0ef1eb..ac3bf4f4 100644
--- a/src/net/ea/loginhandler.h
+++ b/src/net/ea/loginhandler.h
@@ -23,8 +23,8 @@
#define NET_EA_LOGINHANDLER_H
#include "net/loginhandler.h"
-#include "net/messagehandler.h"
+#include "net/ea/messagehandler.h"
#include "net/ea/token.h"
#include <string>
@@ -38,7 +38,7 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler
public:
LoginHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void connect();
diff --git a/src/net/messagehandler.cpp b/src/net/ea/messagehandler.cpp
index ace223c4..fde65d55 100644
--- a/src/net/messagehandler.cpp
+++ b/src/net/ea/messagehandler.cpp
@@ -19,37 +19,29 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "net/messagehandler.h"
+#include "net/ea/messagehandler.h"
-#ifdef MANASERV_SUPPORT
-#include "net/manaserv/network.h"
-#else
#include "net/ea/network.h"
-#endif
#include <cassert>
+namespace EAthena {
+
MessageHandler::MessageHandler()
-#ifdef EATHENA_SUPPORT
- : mNetwork(0)
-#endif
+ : mNetwork(NULL)
{
}
MessageHandler::~MessageHandler()
{
-#ifdef MANASERV_SUPPORT
- Net::unregisterHandler(this);
-#else
if (mNetwork)
mNetwork->unregisterHandler(this);
-#endif
}
-#ifdef EATHENA_SUPPORT
void MessageHandler::setNetwork(Network *network)
{
assert(!(network && mNetwork));
mNetwork = network;
}
-#endif
+
+}
diff --git a/src/net/ea/messagehandler.h b/src/net/ea/messagehandler.h
new file mode 100644
index 00000000..3f006671
--- /dev/null
+++ b/src/net/ea/messagehandler.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_EA_MESSAGEHANDLER_H
+#define NET_EA_MESSAGEHANDLER_H
+
+#include "net/messagehandler.h"
+#include "net/messagein.h"
+
+#include "net/ea/messageout.h"
+
+#include <SDL_types.h>
+
+#include <memory>
+
+namespace EAthena {
+
+class Network;
+
+/**
+ * \ingroup Network
+ */
+class MessageHandler : public Net::MessageHandler
+{
+ public:
+ MessageHandler();
+
+ ~MessageHandler();
+
+ void setNetwork(Network *network);
+
+ protected:
+ Network *mNetwork;
+};
+
+typedef const std::auto_ptr<MessageHandler> MessageHandlerPtr;
+
+}
+
+#endif // NET_EA_MESSAGEHANDLER_H
diff --git a/src/net/ea/messagein.cpp b/src/net/ea/messagein.cpp
new file mode 100644
index 00000000..0b1ab70a
--- /dev/null
+++ b/src/net/ea/messagein.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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/ea/messagein.h"
+
+#include <SDL.h>
+#include <SDL_endian.h>
+
+#define MAKEWORD(low,high) \
+ ((unsigned short)(((unsigned char)(low)) | \
+ ((unsigned short)((unsigned char)(high))) << 8))
+
+namespace EAthena {
+
+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)
+ {
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ value = SDL_Swap16(*(Sint16*)(mData + mPos));
+#else
+ value = (*(Sint16*)(mData + mPos));
+#endif
+ }
+ mPos += 2;
+ return value;
+}
+
+int MessageIn::readInt32()
+{
+ int value = -1;
+ if (mPos + 4 <= mLength)
+ {
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ value = SDL_Swap32(*(Sint32*)(mData + mPos));
+#else
+ value = (*(Sint32*)(mData + mPos));
+#endif
+ }
+ mPos += 4;
+ return value;
+}
+
+}
diff --git a/src/net/ea/messagein.h b/src/net/ea/messagein.h
new file mode 100644
index 00000000..89a9839f
--- /dev/null
+++ b/src/net/ea/messagein.h
@@ -0,0 +1,51 @@
+/*
+ * 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_EA_MESSAGEIN_H
+#define NET_EA_MESSAGEIN_H
+
+#include "net/messagein.h"
+
+#include <SDL_types.h>
+#include <string>
+
+namespace EAthena {
+
+/**
+ * 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_EA_MESSAGEIN_H
diff --git a/src/net/ea/messageout.cpp b/src/net/ea/messageout.cpp
new file mode 100644
index 00000000..f75dcf7e
--- /dev/null
+++ b/src/net/ea/messageout.cpp
@@ -0,0 +1,126 @@
+/*
+ * 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/ea/messageout.h"
+
+#include "net/ea/network.h"
+
+#include <SDL.h>
+#include <SDL_endian.h>
+
+#include <cstring>
+#include <string>
+
+namespace EAthena {
+
+MessageOut::MessageOut(short id):
+ Net::MessageOut(id)
+{
+ mNetwork = EAthena::Network::instance();
+ mData = mNetwork->mOutBuffer + mNetwork->mOutSize;
+ writeInt16(id);
+}
+
+void MessageOut::expand(size_t bytes)
+{
+ mNetwork->mOutSize += bytes;
+}
+
+void MessageOut::writeInt16(Sint16 value)
+{
+ expand(2);
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ (*(Sint16 *)(mData + mPos)) = SDL_Swap16(value);
+#else
+ (*(Sint16 *)(mData + mPos)) = value;
+#endif
+ mPos += 2;
+}
+
+void MessageOut::writeInt32(Sint32 value)
+{
+ expand(4);
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ (*(Sint32 *)(mData + mPos)) = SDL_Swap32(value);
+#else
+ (*(Sint32 *)(mData + mPos)) = value;
+#endif
+ mPos += 4;
+}
+
+#define LOBYTE(w) ((unsigned char)(w))
+#define HIBYTE(w) ((unsigned char)(((unsigned short)(w)) >> 8))
+
+void MessageOut::writeCoordinates(unsigned short x, unsigned short y,
+ unsigned char direction)
+{
+ char *data = mData + mPos;
+ mNetwork->mOutSize += 3;
+ mPos += 3;
+
+ short temp;
+ temp = x;
+ temp <<= 6;
+ data[0] = 0;
+ data[1] = 1;
+ data[2] = 2;
+ data[0] = HIBYTE(temp);
+ data[1] = (unsigned char) temp;
+ temp = y;
+ temp <<= 4;
+ data[1] |= HIBYTE(temp);
+ data[2] = LOBYTE(temp);
+
+ // Translate direction to eAthena format
+ switch (direction)
+ {
+ case 1:
+ direction = 0;
+ break;
+ case 3:
+ direction = 1;
+ break;
+ case 2:
+ direction = 2;
+ break;
+ case 6:
+ direction = 3;
+ break;
+ case 4:
+ direction = 4;
+ break;
+ case 12:
+ direction = 5;
+ break;
+ case 8:
+ direction = 6;
+ break;
+ case 9:
+ direction = 7;
+ break;
+ default:
+ // OOPSIE! Impossible or unknown
+ direction = (unsigned char) -1;
+ }
+ data[2] |= direction;
+}
+
+}
diff --git a/src/net/ea/messageout.h b/src/net/ea/messageout.h
new file mode 100644
index 00000000..47cd7bd9
--- /dev/null
+++ b/src/net/ea/messageout.h
@@ -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
+ */
+
+#ifndef NET_EA_MESSAGEOUT_H
+#define NET_EA_MESSAGEOUT_H
+
+#include "net/messageout.h"
+
+#include <iosfwd>
+#include <SDL_types.h>
+
+namespace EAthena {
+
+class Network;
+
+/**
+ * Used for building an outgoing message.
+ *
+ * \ingroup Network
+ */
+class MessageOut : public Net::MessageOut
+{
+ public:
+ /**
+ * Constructor.
+ */
+ MessageOut(short id);
+
+ void writeInt16(Sint16 value); /**< Writes a short. */
+ void writeInt32(Sint32 value); /**< Writes a long. */
+
+ /**
+ * Encodes coordinates and direction in 3 bytes.
+ */
+ void writeCoordinates(unsigned short x, unsigned short y,
+ unsigned char direction);
+
+ private:
+ void expand(size_t size);
+
+ Network *mNetwork;
+};
+
+}
+
+#endif // NET_EA_MESSAGEOUT_H
diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp
index d8d27577..c12e1bb9 100644
--- a/src/net/ea/network.cpp
+++ b/src/net/ea/network.cpp
@@ -84,6 +84,8 @@ short packet_lengths[] = {
const unsigned int BUFFER_SIZE = 65536;
+namespace EAthena {
+
int networkThread(void *data)
{
Network *network = static_cast<Network*>(data);
@@ -222,9 +224,13 @@ void Network::dispatchMessages()
MessageHandlerIterator iter = mMessageHandlers.find(msg.getId());
if (iter != mMessageHandlers.end())
+ {
iter->second->handleMessage(msg);
+ }
else
+ {
logger->log("Unhandled packet: %x", msg.getId());
+ }
skip(msg.getLength());
}
@@ -317,7 +323,7 @@ MessageIn Network::getNextMessage()
len = readWord(2);
#ifdef DEBUG
- logger->log("Received packet 0x%x of length %d", msgId, len);
+ logger->log("Received packet 0x%x of length %d\n", msgId, len);
#endif
MessageIn msg(mInBuffer, len);
@@ -464,3 +470,5 @@ Uint16 Network::readWord(int pos)
return (*(Uint16*)(mInBuffer+(pos)));
#endif
}
+
+}
diff --git a/src/net/ea/network.h b/src/net/ea/network.h
index 3b8d09f9..0bbcae0e 100644
--- a/src/net/ea/network.h
+++ b/src/net/ea/network.h
@@ -19,11 +19,15 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef EA_NETWORK_H
-#define EA_NETWORK_H
+#ifndef NET_EA_NETWORK_H
+#define NET_EA_NETWORK_H
#include "net/serverinfo.h"
+#include "net/ea/messagehandler.h"
+#include "net/ea/messagein.h"
+#include "net/ea/messageout.h"
+
#include <SDL_net.h>
#include <SDL_thread.h>
@@ -36,15 +40,11 @@
*/
#define CLIENT_PROTOCOL_VERSION 1
-class MessageHandler;
-class MessageIn;
+namespace EAthena {
class Network
{
public:
- friend int networkThread(void *data);
- friend class MessageOut;
-
Network();
~Network();
@@ -89,7 +89,10 @@ class Network
NET_ERROR
};
- private:
+ protected:
+ friend int networkThread(void *data);
+ friend class MessageOut;
+
static Network *instance();
void setError(const std::string &error);
@@ -122,4 +125,6 @@ class Network
static Network *mInstance;
};
-#endif
+}
+
+#endif // NET_EA_NETWORK_H
diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp
index 41caf226..24d8fb64 100644
--- a/src/net/ea/npchandler.cpp
+++ b/src/net/ea/npchandler.cpp
@@ -55,7 +55,7 @@ NpcHandler::NpcHandler()
npcHandler = this;
}
-void NpcHandler::handleMessage(MessageIn &msg)
+void NpcHandler::handleMessage(Net::MessageIn &msg)
{
int id;
bool resetPlayer = false;
diff --git a/src/net/ea/npchandler.h b/src/net/ea/npchandler.h
index 557b97d9..56802d03 100644
--- a/src/net/ea/npchandler.h
+++ b/src/net/ea/npchandler.h
@@ -22,10 +22,11 @@
#ifndef NET_EA_NPCHANDLER_H
#define NET_EA_NPCHANDLER_H
-#include "net/messagehandler.h"
#include "net/net.h"
#include "net/npchandler.h"
+#include "net/ea/messagehandler.h"
+
namespace EAthena {
class NpcHandler : public MessageHandler, public Net::NpcHandler
@@ -33,7 +34,7 @@ class NpcHandler : public MessageHandler, public Net::NpcHandler
public:
NpcHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void talk(int npcId);
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
index 27e19392..0865f71c 100644
--- a/src/net/ea/partyhandler.cpp
+++ b/src/net/ea/partyhandler.cpp
@@ -69,7 +69,7 @@ PartyHandler::~PartyHandler()
//deletePartyTab();
}
-void PartyHandler::handleMessage(MessageIn &msg)
+void PartyHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h
index a9fe843b..188df2ac 100644
--- a/src/net/ea/partyhandler.h
+++ b/src/net/ea/partyhandler.h
@@ -22,10 +22,11 @@
#ifndef NET_EA_PARTYHANDLER_H
#define NET_EA_PARTYHANDLER_H
-#include "net/messagehandler.h"
#include "net/net.h"
#include "net/partyhandler.h"
+#include "net/ea/messagehandler.h"
+
namespace EAthena {
class PartyHandler : public MessageHandler, public Net::PartyHandler
@@ -35,7 +36,7 @@ class PartyHandler : public MessageHandler, public Net::PartyHandler
~PartyHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void create(const std::string &name = "");
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index ca308bb2..454d6210 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -162,7 +162,7 @@ PlayerHandler::PlayerHandler()
playerHandler = this;
}
-void PlayerHandler::handleMessage(MessageIn &msg)
+void PlayerHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
@@ -570,4 +570,14 @@ bool PlayerHandler::canUseMagic()
return player_node->getAttributeEffective(MATK) > 0;
}
+bool PlayerHandler::canCorrectAttributes()
+{
+ return false;
+}
+
+int PlayerHandler::getJobLocation()
+{
+ return JOB;
+}
+
} // namespace EAthena
diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h
index 78e64a88..61f3b705 100644
--- a/src/net/ea/playerhandler.h
+++ b/src/net/ea/playerhandler.h
@@ -22,10 +22,11 @@
#ifndef NET_EA_PLAYERHANDLER_H
#define NET_EA_PLAYERHANDLER_H
-#include "net/messagehandler.h"
#include "net/net.h"
#include "net/playerhandler.h"
+#include "net/ea/messagehandler.h"
+
namespace EAthena {
class PlayerHandler : public MessageHandler, public Net::PlayerHandler
@@ -33,7 +34,7 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
public:
PlayerHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void attack(int id);
@@ -60,6 +61,10 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
void ignoreAll(bool ignore);
bool canUseMagic();
+
+ bool canCorrectAttributes();
+
+ int getJobLocation();
};
} // namespace EAthena
diff --git a/src/net/ea/specialhandler.cpp b/src/net/ea/specialhandler.cpp
index 528f531e..5def63b7 100644
--- a/src/net/ea/specialhandler.cpp
+++ b/src/net/ea/specialhandler.cpp
@@ -83,7 +83,7 @@ SpecialHandler::SpecialHandler()
specialHandler = this;
}
-void SpecialHandler::handleMessage(MessageIn &msg)
+void SpecialHandler::handleMessage(Net::MessageIn &msg)
{
int skillCount;
int skillId;
diff --git a/src/net/ea/specialhandler.h b/src/net/ea/specialhandler.h
index eac53569..501ea74d 100644
--- a/src/net/ea/specialhandler.h
+++ b/src/net/ea/specialhandler.h
@@ -22,10 +22,11 @@
#ifndef NET_EA_SKILLHANDLER_H
#define NET_EA_SKILLHANDLER_H
-#include "net/messagehandler.h"
#include "net/net.h"
#include "net/specialhandler.h"
+#include "net/ea/messagehandler.h"
+
namespace EAthena {
class SpecialHandler : public MessageHandler, public Net::SpecialHandler
@@ -33,7 +34,7 @@ class SpecialHandler : public MessageHandler, public Net::SpecialHandler
public:
SpecialHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void use(int id);
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index 4f045573..bfd01f89 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -76,7 +76,7 @@ TradeHandler::TradeHandler()
}
-void TradeHandler::handleMessage(MessageIn &msg)
+void TradeHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
{
diff --git a/src/net/ea/tradehandler.h b/src/net/ea/tradehandler.h
index 1d94b849..b8a99421 100644
--- a/src/net/ea/tradehandler.h
+++ b/src/net/ea/tradehandler.h
@@ -22,10 +22,11 @@
#ifndef NET_EA_TRADEHANDLER_H
#define NET_EA_TRADEHANDLER_H
-#include "net/messagehandler.h"
#include "net/net.h"
#include "net/tradehandler.h"
+#include "net/ea/messagehandler.h"
+
namespace EAthena {
class TradeHandler : public MessageHandler, public Net::TradeHandler
@@ -33,7 +34,7 @@ class TradeHandler : public MessageHandler, public Net::TradeHandler
public:
TradeHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg);
void request(Being *being);
diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h
index 19060797..08caf926 100644
--- a/src/net/inventoryhandler.h
+++ b/src/net/inventoryhandler.h
@@ -59,6 +59,10 @@ class InventoryHandler
virtual void moveItem(StorageType source, int slot, int amount,
StorageType destination) = 0;
+
+ virtual size_t getInventorySize() const = 0;
+
+ virtual size_t getStorageSize() const = 0;
};
} // namespace Net
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
diff --git a/src/net/messagehandler.h b/src/net/messagehandler.h
index c89f3dcd..bf022afd 100644
--- a/src/net/messagehandler.h
+++ b/src/net/messagehandler.h
@@ -28,10 +28,7 @@
#include <memory>
-class MessageIn;
-#ifdef EATHENA_SUPPORT
-class Network;
-#endif
+namespace Net {
/**
* \ingroup Network
@@ -41,19 +38,9 @@ class MessageHandler
public:
const Uint16 *handledMessages;
- MessageHandler();
- virtual ~MessageHandler();
-
virtual void handleMessage(MessageIn &msg) = 0;
-
-#ifdef EATHENA_SUPPORT
- void setNetwork(Network *network);
-
- protected:
- Network *mNetwork;
-#endif
};
-typedef const std::auto_ptr<MessageHandler> MessageHandlerPtr;
+}
#endif // NET_MESSAGEHANDLER_H
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 1e85133f..f659fcfc 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -21,24 +21,17 @@
#include "net/messagein.h"
-#ifdef MANASERV_SUPPORT
-#include <enet/enet.h>
-#else
-#include <SDL.h>
-#include <SDL_endian.h>
-#endif
-
#define MAKEWORD(low,high) \
((unsigned short)(((unsigned char)(low)) | \
((unsigned short)((unsigned char)(high))) << 8))
+namespace Net {
+
MessageIn::MessageIn(const char *data, unsigned int length):
mData(data),
mLength(length),
mPos(0)
{
- // Read the message ID
- mId = readInt16();
}
int MessageIn::readInt8()
@@ -52,48 +45,6 @@ int MessageIn::readInt8()
return value;
}
-int MessageIn::readInt16()
-{
- int value = -1;
- if (mPos + 2 <= mLength)
- {
-#ifdef MANASERV_SUPPORT
- uint16_t t;
- memcpy(&t, mData + mPos, 2);
- value = (unsigned short) ENET_NET_TO_HOST_16(t);
-#else
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- value = SDL_Swap16(*(Sint16*)(mData + mPos));
-#else
- value = (*(Sint16*)(mData + mPos));
-#endif
-#endif // MANASERV_SUPPORT
- }
- mPos += 2;
- return value;
-}
-
-int MessageIn::readInt32()
-{
- int value = -1;
- if (mPos + 4 <= mLength)
- {
-#ifdef MANASERV_SUPPORT
- uint32_t t;
- memcpy(&t, mData + mPos, 4);
- value = ENET_NET_TO_HOST_32(t);
-#else
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- value = SDL_Swap32(*(Sint32*)(mData + mPos));
-#else
- value = (*(Sint32*)(mData + mPos));
-#endif
-#endif // MANASERV_SUPPORT
- }
- mPos += 4;
- return value;
-}
-
void MessageIn::readCoordinates(Uint16 &x, Uint16 &y)
{
if (mPos + 3 <= mLength)
@@ -201,3 +152,5 @@ std::string MessageIn::readString(int length)
mPos += length;
return readString;
}
+
+}
diff --git a/src/net/messagein.h b/src/net/messagein.h
index 17a73e2d..6f68c49b 100644
--- a/src/net/messagein.h
+++ b/src/net/messagein.h
@@ -19,12 +19,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef MESSAGEIN_H
-#define MESSAGEIN_H
+#ifndef NET_MESSAGEIN_H
+#define NET_MESSAGEIN_H
#include <SDL_types.h>
#include <string>
+namespace Net {
+
/**
* Used for parsing an incoming message.
*
@@ -34,11 +36,6 @@ class MessageIn
{
public:
/**
- * Constructor.
- */
- MessageIn(const char *data, unsigned int length);
-
- /**
* Returns the message ID.
*/
int getId() const { return mId; }
@@ -53,42 +50,47 @@ class MessageIn
*/
unsigned int getUnreadLength() const { return mLength - mPos; }
- int readInt8(); /**< Reads a byte. */
- int readInt16(); /**< Reads a short. */
- int readInt32(); /**< Reads a long. */
+ virtual int readInt8(); /**< Reads a byte. */
+ virtual int readInt16() = 0; /**< Reads a short. */
+ virtual int readInt32() = 0; /**< Reads a long. */
/**
* Reads a 3-byte block containing tile-based coordinates. Used by
* manaserv.
*/
- void readCoordinates(Uint16 &x, Uint16 &y);
+ virtual void readCoordinates(Uint16 &x, Uint16 &y);
/**
* Reads a special 3 byte block used by eAthena, containing x and y
* coordinates and direction.
*/
- void readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction);
+ virtual void readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction);
/**
* Reads a special 5 byte block used by eAthena, containing a source
* and destination coordinate pair.
*/
- void readCoordinatePair(Uint16 &srcX, Uint16 &srcY,
- Uint16 &dstX, Uint16 &dstY);
+ virtual void readCoordinatePair(Uint16 &srcX, Uint16 &srcY,
+ Uint16 &dstX, Uint16 &dstY);
/**
* Skips a given number of bytes.
*/
- void skip(unsigned int length);
+ virtual void skip(unsigned int length);
/**
* Reads a string. If a length is not given (-1), it is assumed
* that the length of the string is stored in a short at the
* start of the string.
*/
- std::string readString(int length = -1);
+ virtual std::string readString(int length = -1);
+
+ protected:
+ /**
+ * Constructor.
+ */
+ MessageIn(const char *data, unsigned int length);
- private:
const char *mData; /**< The message data. */
unsigned int mLength; /**< The length of the data. */
unsigned short mId; /**< The message ID. */
@@ -101,4 +103,6 @@ class MessageIn
unsigned int mPos;
};
-#endif
+}
+
+#endif // NET_MESSAGEIN_H
diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp
index 7d87a849..4bcf22d0 100644
--- a/src/net/messageout.cpp
+++ b/src/net/messageout.cpp
@@ -21,150 +21,25 @@
#include "net/messageout.h"
-#ifdef MANASERV_SUPPORT
-#include <enet/enet.h>
-#else
-#include "net/ea/network.h"
-
-#include <SDL.h>
-#include <SDL_endian.h>
-#endif
-
#include <cstring>
#include <string>
+namespace Net {
+
MessageOut::MessageOut(short id):
mData(0),
mDataSize(0),
mPos(0)
{
- mID = id;
-#ifdef EATHENA_SUPPORT
- mNetwork = Network::instance();
- mData = mNetwork->mOutBuffer + mNetwork->mOutSize;
-#endif
- writeInt16(id);
-}
-
-#ifdef MANASERV_SUPPORT
-MessageOut::~MessageOut()
-{
- free(mData);
-}
-
-void MessageOut::expand(size_t bytes)
-{
- mData = (char*)realloc(mData, bytes);
- mDataSize = bytes;
}
-#endif
void MessageOut::writeInt8(Sint8 value)
{
-#ifdef MANASERV_SUPPORT
- expand(mPos + 1);
-#else
- mNetwork->mOutSize += 1;
-#endif
+ expand(1);
mData[mPos] = value;
mPos += 1;
}
-void MessageOut::writeInt16(Sint16 value)
-{
-#ifdef MANASERV_SUPPORT
- expand(mPos + 2);
- uint16_t t = ENET_HOST_TO_NET_16(value);
- memcpy(mData + mPos, &t, 2);
-#else
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- (*(Sint16 *)(mData + mPos)) = SDL_Swap16(value);
-#else
- (*(Sint16 *)(mData + mPos)) = value;
-#endif
- mNetwork->mOutSize += 2;
-#endif // MANASERV_SUPPORT
- mPos += 2;
-}
-
-void MessageOut::writeInt32(Sint32 value)
-{
-#ifdef MANASERV_SUPPORT
- expand(mPos + 4);
- uint32_t t = ENET_HOST_TO_NET_32(value);
- memcpy(mData + mPos, &t, 4);
-#else
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- (*(Sint32 *)(mData + mPos)) = SDL_Swap32(value);
-#else
- (*(Sint32 *)(mData + mPos)) = value;
-#endif
- mNetwork->mOutSize += 4;
-#endif // MANASERV_SUPPORT
- mPos += 4;
-}
-
-#ifdef EATHENA_SUPPORT
-
-#define LOBYTE(w) ((unsigned char)(w))
-#define HIBYTE(w) ((unsigned char)(((unsigned short)(w)) >> 8))
-
-void MessageOut::writeCoordinates(unsigned short x, unsigned short y,
- unsigned char direction)
-{
- char *data = mData + mPos;
- mNetwork->mOutSize += 3;
- mPos += 3;
-
- short temp;
- temp = x;
- temp <<= 6;
- data[0] = 0;
- data[1] = 1;
- data[2] = 2;
- data[0] = HIBYTE(temp);
- data[1] = (unsigned char) temp;
- temp = y;
- temp <<= 4;
- data[1] |= HIBYTE(temp);
- data[2] = LOBYTE(temp);
-
- // Translate direction to eAthena format
- switch (direction)
- {
- case 1:
- direction = 0;
- break;
- case 3:
- direction = 1;
- break;
- case 2:
- direction = 2;
- break;
- case 6:
- direction = 3;
- break;
- case 4:
- direction = 4;
- break;
- case 12:
- direction = 5;
- break;
- case 8:
- direction = 6;
- break;
- case 9:
- direction = 7;
- break;
- default:
- // OOPSIE! Impossible or unknown
- direction = (unsigned char) -1;
- }
- data[2] |= direction;
-}
-
-#endif // EATHENA_SUPPORT
-
void MessageOut::writeString(const std::string &string, int length)
{
int stringLength = string.length();
@@ -179,11 +54,7 @@ void MessageOut::writeString(const std::string &string, int length)
// Make sure the length of the string is no longer than specified
stringLength = length;
}
-#ifdef MANASERV_SUPPORT
- expand(mPos + length);
-#else
- mNetwork->mOutSize += length;
-#endif
+ expand(length);
// Write the actual string
memcpy(mData + mPos, string.c_str(), stringLength);
@@ -205,3 +76,5 @@ unsigned int MessageOut::getDataSize() const
{
return mDataSize;
}
+
+}
diff --git a/src/net/messageout.h b/src/net/messageout.h
index b232fdf8..b3fd3a96 100644
--- a/src/net/messageout.h
+++ b/src/net/messageout.h
@@ -19,71 +19,48 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef MESSAGEOUT_H
-#define MESSAGEOUT_H
+#ifndef NET_MESSAGEOUT_H
+#define NET_MESSAGEOUT_H
#include <iosfwd>
#include <SDL_types.h>
-#ifdef EATHENA_SUPPORT
-class Network;
-#endif
+namespace Net {
/**
* Used for building an outgoing message.
*
- * With manaserv, the message is sent using Net::Connection::send() when
- * finished.
- *
* \ingroup Network
*/
class MessageOut
{
public:
- /**
- * Constructor.
- */
- MessageOut(short id);
-
-#ifdef MANASERV_SUPPORT
- /**
- * Destructor.
- */
- ~MessageOut();
-#endif
-
- void writeInt8(Sint8 value); /**< Writes a byte. */
- void writeInt16(Sint16 value); /**< Writes a short. */
- void writeInt32(Sint32 value); /**< Writes a long. */
-
-#ifdef EATHENA_SUPPORT
- /**
- * Encodes coordinates and direction in 3 bytes. Used by eAthena.
- */
- void writeCoordinates(unsigned short x, unsigned short y,
- unsigned char direction);
-#endif
+ virtual void writeInt8(Sint8 value); /**< Writes a byte. */
+ virtual void writeInt16(Sint16 value) = 0; /**< Writes a short. */
+ virtual void writeInt32(Sint32 value) = 0; /**< Writes a long. */
/**
* 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);
+ virtual void writeString(const std::string &string, int length = -1);
/**
* Returns the content of the message.
*/
- char *getData() const;
+ virtual char *getData() const;
/**
* Returns the length of the data.
*/
- unsigned int getDataSize() const;
+ virtual unsigned int getDataSize() const;
- short mID;
+ protected:
+ /**
+ * Constructor.
+ */
+ MessageOut(short id);
- private:
-#ifdef MANASERV_SUPPORT
/**
* Expand the packet data to be able to hold more data.
*
@@ -91,14 +68,13 @@ class MessageOut
* memory in advance instead of expanding size every time more data is
* added.
*/
- void expand(size_t size);
-#else
- Network *mNetwork;
-#endif
+ virtual void expand(size_t size) = 0;
char *mData; /**< Data building up. */
unsigned int mDataSize; /**< Size of data. */
unsigned int mPos; /**< Position in the data. */
};
-#endif
+}
+
+#endif // NET_MESSAGEOUT_H
diff --git a/src/net/net.h b/src/net/net.h
index 7a49121d..5e675df7 100644
--- a/src/net/net.h
+++ b/src/net/net.h
@@ -22,6 +22,10 @@
#ifndef NET_H
#define NET_H
+/**
+ * \defgroup Network Core network layer
+ */
+
class ServerInfo;
namespace Net {
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index a0fd8bac..895e3164 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -56,6 +56,10 @@ class PlayerHandler
virtual void ignoreAll(bool ignore) = 0;
virtual bool canUseMagic() = 0;
+
+ virtual bool canCorrectAttributes() = 0;
+
+ virtual int getJobLocation() = 0;
};
} // namespace Net
diff --git a/src/playerrelations.h b/src/playerrelations.h
index adc6a95f..94d3bf02 100644
--- a/src/playerrelations.h
+++ b/src/playerrelations.h
@@ -237,4 +237,4 @@ private:
extern PlayerRelationsManager player_relations; // singleton representation of player relations
-#endif /* !defined(PLAYER_RELATIONS_H) */
+#endif // PLAYER_RELATIONS_H
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 64d928d6..adcedaa1 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -117,3 +117,20 @@ std::string removeColors(std::string msg)
}
return msg;
}
+
+int compareStrI(const std::string &a, const std::string &b)
+{
+ std::string::const_iterator itA = a.begin();
+ std::string::const_iterator endA = a.end();
+ std::string::const_iterator itB = b.begin();
+ std::string::const_iterator endB = b.end();
+
+ for (; itA < endA, itB < endB; ++itA, ++itB)
+ {
+ int comp = tolower(*itA) - tolower(*itB);
+ if (comp)
+ return comp;
+ }
+
+ return 0;
+}
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index ae105c6c..a0e766fb 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -100,4 +100,14 @@ std::string &removeBadChars(std::string &str);
*/
std::string removeColors(std::string msg);
+/**
+ * Compares the two strings case-insensitively.
+ *
+ * @param a the first string in the comparison
+ * @param b the second string in the comparison
+ * @return 0 if the strings are equal, positive if the first is greater,
+ * negative if the second is greater
+ */
+int compareStrI(const std::string &a, const std::string &b);
+
#endif // UTILS_STRINGUTILS_H