summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-04-06 08:12:03 -0600
committerJared Adams <jaxad0127@gmail.com>2009-04-06 08:14:37 -0600
commitffe62a721cf3c17b815da591af753e1424003a77 (patch)
tree6b3bd4dcec199ef10e138b7755d1c853db85a7d7 /src/net
parent004b2853d37a18a67c348c29e4500f3ef68337b5 (diff)
downloadmana-ffe62a721cf3c17b815da591af753e1424003a77.tar.gz
mana-ffe62a721cf3c17b815da591af753e1424003a77.tar.bz2
mana-ffe62a721cf3c17b815da591af753e1424003a77.tar.xz
mana-ffe62a721cf3c17b815da591af753e1424003a77.zip
Add TMWServ's SkillHandler
Also namespace both Player- and TradeHandlers
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/playerhandler.cpp6
-rw-r--r--src/net/ea/playerhandler.h4
-rw-r--r--src/net/ea/skillhandler.cpp21
-rw-r--r--src/net/ea/skillhandler.h10
-rw-r--r--src/net/ea/tradehandler.cpp6
-rw-r--r--src/net/ea/tradehandler.h4
-rw-r--r--src/net/net.cpp16
-rw-r--r--src/net/skillhandler.h8
-rw-r--r--src/net/tmwserv/playerhandler.cpp4
-rw-r--r--src/net/tmwserv/playerhandler.h4
-rw-r--r--src/net/tmwserv/skillhandler.cpp53
-rw-r--r--src/net/tmwserv/skillhandler.h45
-rw-r--r--src/net/tmwserv/tradehandler.cpp6
-rw-r--r--src/net/tmwserv/tradehandler.h4
14 files changed, 169 insertions, 22 deletions
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 29900730..8c9b6f5e 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -148,7 +148,9 @@ static const char *randomDeathMessage()
return gettext(deadMsg[random]);
}
-PlayerHandler *playerHandler;
+Net::PlayerHandler *playerHandler;
+
+namespace EAthena {
PlayerHandler::PlayerHandler()
{
@@ -522,3 +524,5 @@ void PlayerHandler::ingoreAll(bool ignore)
{
// TODO
}
+
+} // namespace EAthena
diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h
index 22f6a132..94ae952f 100644
--- a/src/net/ea/playerhandler.h
+++ b/src/net/ea/playerhandler.h
@@ -26,6 +26,8 @@
#include "net/net.h"
#include "net/playerhandler.h"
+namespace EAthena {
+
class PlayerHandler : public MessageHandler, public Net::PlayerHandler
{
public:
@@ -56,6 +58,6 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
void ingoreAll(bool ignore);
};
-extern PlayerHandler *playerHandler;
+} // namespace EAthena
#endif // NET_EA_PLAYERHANDLER_H
diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp
index 0475c057..0239a2c8 100644
--- a/src/net/ea/skillhandler.cpp
+++ b/src/net/ea/skillhandler.cpp
@@ -66,7 +66,9 @@
/** should always be zero if failed */
#define SKILL_FAILED 0x00
-SkillHandler *skillHandler;
+Net::SkillHandler *skillHandler;
+
+namespace EAthena {
SkillHandler::SkillHandler()
{
@@ -217,3 +219,20 @@ void SkillHandler::up(int skillId)
MessageOut outMsg(CMSG_SKILL_LEVELUP_REQUEST);
outMsg.writeInt16(skillId);
}
+
+void SkillHandler::use(int skillId, int level, int beingId)
+{
+ // TODO
+}
+
+void SkillHandler::use(int skillId, int level, int x, int y)
+{
+ // TODO
+}
+
+void SkillHandler::use(int skillId, const std::string &map)
+{
+ // TODO
+}
+
+} // namespace EAthena
diff --git a/src/net/ea/skillhandler.h b/src/net/ea/skillhandler.h
index b4e464ed..c1965213 100644
--- a/src/net/ea/skillhandler.h
+++ b/src/net/ea/skillhandler.h
@@ -26,6 +26,8 @@
#include "net/net.h"
#include "net/skillhandler.h"
+namespace EAthena {
+
class SkillHandler : public MessageHandler, public Net::SkillHandler
{
public:
@@ -34,8 +36,14 @@ class SkillHandler : public MessageHandler, public Net::SkillHandler
void handleMessage(MessageIn &msg);
void up(int skillId);
+
+ void use(int skillId, int level, int beingId);
+
+ void use(int skillId, int level, int x, int y);
+
+ void use(int skillId, const std::string &map);
};
-extern SkillHandler *skillHandler;
+} // namespace EAthena
#endif // NET_EA_SKILLHANDLER_H
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index b7f8e369..1bf7e303 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -53,7 +53,9 @@ namespace {
} listener;
}
-TradeHandler *tradeHandler;
+Net::TradeHandler *tradeHandler;
+
+namespace EAthena {
TradeHandler::TradeHandler()
{
@@ -271,3 +273,5 @@ void TradeHandler::cancel()
{
MessageOut outMsg(CMSG_TRADE_CANCEL_REQUEST);
}
+
+} // namespace EAthena
diff --git a/src/net/ea/tradehandler.h b/src/net/ea/tradehandler.h
index 451939f9..1d94b849 100644
--- a/src/net/ea/tradehandler.h
+++ b/src/net/ea/tradehandler.h
@@ -26,6 +26,8 @@
#include "net/net.h"
#include "net/tradehandler.h"
+namespace EAthena {
+
class TradeHandler : public MessageHandler, public Net::TradeHandler
{
public:
@@ -50,6 +52,6 @@ class TradeHandler : public MessageHandler, public Net::TradeHandler
void cancel();
};
-extern TradeHandler *tradeHandler;
+} // namespace EAthena
#endif // NET_EA_TRADEHANDLER_H
diff --git a/src/net/net.cpp b/src/net/net.cpp
index 255b6ab9..b2fe7225 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -40,25 +40,26 @@
#include "net/tmwserv/inventoryhandler.h"
#include "net/tmwserv/maphandler.h"
#include "net/tmwserv/npchandler.h"
+#include "net/tmwserv/playerhandler.h"
+#include "net/tmwserv/skillhandler.h"
+#include "net/tmwserv/tradehandler.h"
#include "net/ea/adminhandler.h"
#include "net/ea/inventoryhandler.h"
#include "net/ea/maphandler.h"
#include "net/ea/npchandler.h"
-
-#ifdef TMWSERV_SUPPORT
-#include "net/tmwserv/playerhandler.h"
-#include "net/tmwserv/tradehandler.h"
-#else
#include "net/ea/playerhandler.h"
+#include "net/ea/skillhandler.h"
#include "net/ea/tradehandler.h"
-#endif
extern Net::AdminHandler *adminHandler;
extern Net::ChatHandler *chatHandler;
extern Net::InventoryHandler *inventoryHandler;
extern Net::MapHandler *mapHandler;
extern Net::NpcHandler *npcHandler;
+extern Net::PlayerHandler *playerHandler;
+extern Net::SkillHandler *skillHandler;
+extern Net::TradeHandler *tradeHandler;
Net::AdminHandler *Net::getAdminHandler()
{
@@ -122,8 +123,7 @@ Net::PlayerHandler *Net::getPlayerHandler()
Net::SkillHandler *Net::getSkillHandler()
{
- // TODO
- return 0;
+ return skillHandler;
}
Net::TradeHandler *Net::getTradeHandler()
diff --git a/src/net/skillhandler.h b/src/net/skillhandler.h
index d0e6cd23..9db6ac5b 100644
--- a/src/net/skillhandler.h
+++ b/src/net/skillhandler.h
@@ -28,13 +28,13 @@ namespace Net {
class SkillHandler
{
public:
- virtual void up(int skillId) {}
+ virtual void up(int skillId) = 0;
- virtual void use(int skillId, int level, int beingId) {}
+ virtual void use(int skillId, int level, int beingId) = 0;
- virtual void use(int skillId, int level, int x, int y) {}
+ virtual void use(int skillId, int level, int x, int y) = 0;
- virtual void use(int skillId, const std::string &map) {}
+ virtual void use(int skillId, const std::string &map) = 0;
};
}
diff --git a/src/net/tmwserv/playerhandler.cpp b/src/net/tmwserv/playerhandler.cpp
index a02c9a29..f13484eb 100644
--- a/src/net/tmwserv/playerhandler.cpp
+++ b/src/net/tmwserv/playerhandler.cpp
@@ -95,6 +95,8 @@ namespace {
Net::PlayerHandler *playerHandler;
+namespace TmwServ {
+
PlayerHandler::PlayerHandler()
{
static const Uint16 _messages[] = {
@@ -391,3 +393,5 @@ void PlayerHandler::ingoreAll(bool ignore)
{
// TODO
}
+
+} // namespace TmwServ
diff --git a/src/net/tmwserv/playerhandler.h b/src/net/tmwserv/playerhandler.h
index 17b1f684..5524415e 100644
--- a/src/net/tmwserv/playerhandler.h
+++ b/src/net/tmwserv/playerhandler.h
@@ -25,6 +25,8 @@
#include "net/messagehandler.h"
#include "net/playerhandler.h"
+namespace TmwServ {
+
class PlayerHandler : public MessageHandler, public Net::PlayerHandler
{
public:
@@ -58,6 +60,6 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
void handleMapChangeMessage(MessageIn &msg);
};
-extern Net::PlayerHandler *playerHandler;
+} // namespace TmwServ
#endif
diff --git a/src/net/tmwserv/skillhandler.cpp b/src/net/tmwserv/skillhandler.cpp
new file mode 100644
index 00000000..e35b896a
--- /dev/null
+++ b/src/net/tmwserv/skillhandler.cpp
@@ -0,0 +1,53 @@
+/*
+ * 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/tmwserv/skillhandler.h"
+
+Net::SkillHandler *skillHandler;
+
+namespace TmwServ {
+
+SkillHandler::SkillHandler()
+{
+ skillHandler = this;
+}
+
+void SkillHandler::up(int skillId)
+{
+ // TODO
+}
+
+void SkillHandler::use(int skillId, int level, int beingId)
+{
+ // TODO
+}
+
+void SkillHandler::use(int skillId, int level, int x, int y)
+{
+ // TODO
+}
+
+void SkillHandler::use(int skillId, const std::string &map)
+{
+ // TODO
+}
+
+} // namespace TmwServ
diff --git a/src/net/tmwserv/skillhandler.h b/src/net/tmwserv/skillhandler.h
new file mode 100644
index 00000000..8c459c4f
--- /dev/null
+++ b/src/net/tmwserv/skillhandler.h
@@ -0,0 +1,45 @@
+/*
+ * 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_TMWSERV_SKILLHANDLER_H
+#define NET_TMWSERV_SKILLHANDLER_H
+
+#include "net/skillhandler.h"
+
+namespace TmwServ {
+
+class SkillHandler : public Net::SkillHandler
+{
+ public:
+ SkillHandler();
+
+ void up(int skillId);
+
+ void use(int skillId, int level, int beingId);
+
+ void use(int skillId, int level, int x, int y);
+
+ void use(int skillId, const std::string &map);
+};
+
+} // namespace TmwServ
+
+#endif
diff --git a/src/net/tmwserv/tradehandler.cpp b/src/net/tmwserv/tradehandler.cpp
index 07ed81e6..17a45a19 100644
--- a/src/net/tmwserv/tradehandler.cpp
+++ b/src/net/tmwserv/tradehandler.cpp
@@ -56,6 +56,8 @@ namespace {
Net::TradeHandler *tradeHandler;
+namespace TmwServ {
+
TradeHandler::TradeHandler():
mAcceptTradeRequests(true)
{
@@ -142,8 +144,6 @@ void TradeHandler::handleMessage(MessageIn &msg)
void TradeHandler::request(Being *being)
{
- extern std::string tradePartnerName;
- extern int tradePartnerID;
tradePartnerName = being->getName();
tradePartnerID = being->getId();
Net::GameServer::Player::requestTrade(tradePartnerID);
@@ -185,3 +185,5 @@ void TradeHandler::cancel()
{
Net::GameServer::Player::acceptTrade(false);
}
+
+} // namespace TmwServ
diff --git a/src/net/tmwserv/tradehandler.h b/src/net/tmwserv/tradehandler.h
index 1abb30e3..dc9e070a 100644
--- a/src/net/tmwserv/tradehandler.h
+++ b/src/net/tmwserv/tradehandler.h
@@ -25,6 +25,8 @@
#include "net/messagehandler.h"
#include "net/tradehandler.h"
+namespace TmwServ {
+
class TradeHandler : public MessageHandler, public Net::TradeHandler
{
public:
@@ -67,6 +69,6 @@ class TradeHandler : public MessageHandler, public Net::TradeHandler
bool mAcceptTradeRequests;
};
-extern Net::TradeHandler *tradeHandler;
+} // namespace TmwServ
#endif