summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-04-02 22:37:35 -0600
committerJared Adams <jaxad0127@gmail.com>2009-04-02 22:37:35 -0600
commitd13b3eaca82e3547c84f60b9b135464ff3a51cf0 (patch)
treee4ede7c58a991b85ff208a7155d0b74236f23bac /src
parent4916370e6130bfee7eb9ae486f03391d2214ecf4 (diff)
downloadmana-client-d13b3eaca82e3547c84f60b9b135464ff3a51cf0.tar.gz
mana-client-d13b3eaca82e3547c84f60b9b135464ff3a51cf0.tar.bz2
mana-client-d13b3eaca82e3547c84f60b9b135464ff3a51cf0.tar.xz
mana-client-d13b3eaca82e3547c84f60b9b135464ff3a51cf0.zip
Start TMWServ's PlayerHandler and InventoryHandler
Diffstat (limited to 'src')
-rw-r--r--src/gui/equipmentwindow.cpp2
-rw-r--r--src/localplayer.cpp22
-rw-r--r--src/net/ea/playerhandler.cpp2
-rw-r--r--src/net/ea/playerhandler.h2
-rw-r--r--src/net/playerhandler.h2
-rw-r--r--src/net/tmwserv/inventoryhandler.cpp43
-rw-r--r--src/net/tmwserv/inventoryhandler.h20
-rw-r--r--src/net/tmwserv/playerhandler.cpp63
-rw-r--r--src/net/tmwserv/playerhandler.h25
9 files changed, 164 insertions, 17 deletions
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 7111e7fc..46e68ef8 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -174,7 +174,7 @@ void EquipmentWindow::action(const gcn::ActionEvent &event)
{
if (event.getId() == "unequip" && mSelected > -1)
{
-#ifdef TMWSERV_SUPPORT
+#ifdef TMWSERV_SUPPORT // TODO: merge these!
player_node->unequipItem(mSelected);
#else
Item* item = (mSelected != EQUIP_AMMO_SLOT) ?
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index a154e6a0..031ff342 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -354,7 +354,7 @@ void LocalPlayer::moveInvItem(Item *item, int newIndex)
void LocalPlayer::equipItem(Item *item)
{
// Net::getInventoryHandler()->equipItem(item);
-#ifdef TMWSERV_SUPPORT
+#ifdef TMWSERV_SUPPORT // Ready for replacement
Net::GameServer::Player::equip(item->getInvIndex());
#else
inventoryHandler->equipItem(item);
@@ -376,7 +376,7 @@ void LocalPlayer::unequipItem(int slot)
void LocalPlayer::unequipItem(Item *item)
{
// Net::getInventoryHandler()->unequipItem(item);
-#ifdef TMWSERV_SUPPORT
+#ifdef TMWSERV_SUPPORT // Ready for replacement
Net::GameServer::Player::unequip(item->getInvIndex());
#else
inventoryHandler->unequipItem(item);
@@ -391,7 +391,7 @@ void LocalPlayer::unequipItem(Item *item)
void LocalPlayer::useItem(Item *item)
{
// Net::getInventoryHandler()->useItem(item);
-#ifdef TMWSERV_SUPPORT
+#ifdef TMWSERV_SUPPORT // Ready for replacement
Net::GameServer::Player::useItem(item->getInvIndex());
#else
inventoryHandler->useItem(item);
@@ -401,7 +401,7 @@ void LocalPlayer::useItem(Item *item)
void LocalPlayer::dropItem(Item *item, int quantity)
{
// Net::getInventoryHandler()->dropItem(item, quantity);
-#ifdef TMWSERV_SUPPORT
+#ifdef TMWSERV_SUPPORT // Ready for replacement
Net::GameServer::Player::drop(item->getInvIndex(), quantity);
#else
inventoryHandler->dropItem(item, quantity);
@@ -433,7 +433,7 @@ void LocalPlayer::pickUp(FloorItem *item)
if (dx * dx + dy * dy < 4)
{
// Net::getPlayerHandler()->pickUp(item);
-#ifdef TMWSERV_SUPPORT
+#ifdef TMWSERV_SUPPORT // Ready for replacement
int id = item->getId();
Net::GameServer::Player::pickUp(id >> 16, id & 0xFFFF);
#else
@@ -550,7 +550,8 @@ void LocalPlayer::walk(unsigned char dir)
else if (dir)
{
// If the being can't move, just change direction
-#ifdef TMWSERV_SUPPORT
+ // Net::getPlayerHandler()->setDirection(dir);
+#ifdef TMWSERV_SUPPORT // Ready for replacement
Net::GameServer::Player::changeDir(dir);
#else
// TODO: Communicate this to the server
@@ -631,7 +632,7 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y)
mDestY = y;
// Net::getPlayerHandler()->setDestination(x, y, mDirection);
-#ifdef TMWSERV_SUPPORT
+#ifdef TMWSERV_SUPPORT // Ready for replacement
Net::GameServer::Player::walk(x, y);
//Debugging fire burst
effectManager->trigger(15,x,y);
@@ -701,8 +702,7 @@ void LocalPlayer::toggleSit()
}
// Net::getPlayerHandler()->changeAction(newAction);
-
-#ifdef TMWSERV_SUPPORT
+#ifdef TMWSERV_SUPPORT // Ready for replacement
setAction(newAction);
Net::GameServer::Player::changeAction(newAction);
#else
@@ -717,7 +717,7 @@ void LocalPlayer::emote(Uint8 emotion)
mLastAction = tick_time;
// Net::getPlayerHandler()->emote(emotion);
-#ifdef EATHENA_SUPPORT
+#ifdef EATHENA_SUPPORT // Ready for replacement
playerHandler->emote(emotion);
#endif
}
@@ -884,7 +884,7 @@ void LocalPlayer::stopAttack()
void LocalPlayer::revive()
{
// Net::getPlayerHandler()->respawn();
-#ifdef EATHENA_SUPPORT
+#ifdef EATHENA_SUPPORT // Ready for replacement
playerHandler->respawn();
#endif
}
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index f0876a6e..29900730 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -487,7 +487,7 @@ void PlayerHandler::pickUp(FloorItem *floorItem)
outMsg.writeInt32(floorItem->getId());
}
-void PlayerHandler::setDirection(int direction)
+void PlayerHandler::setDirection(char direction)
{
// TODO
}
diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h
index cc84dec0..22f6a132 100644
--- a/src/net/ea/playerhandler.h
+++ b/src/net/ea/playerhandler.h
@@ -43,7 +43,7 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
void pickUp(FloorItem *floorItem);
- void setDirection(int direction);
+ void setDirection(char direction);
void setDestination(int x, int y, int direction = -1);
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index 6e277dc3..63a1ea3d 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -41,7 +41,7 @@ class PlayerHandler
virtual void pickUp(FloorItem *floorItem) = 0;
- virtual void setDirection(int direction) = 0;
+ virtual void setDirection(char direction) = 0;
virtual void setDestination(int x, int y, int direction = -1) = 0;
diff --git a/src/net/tmwserv/inventoryhandler.cpp b/src/net/tmwserv/inventoryhandler.cpp
index f6522128..a342c1d3 100644
--- a/src/net/tmwserv/inventoryhandler.cpp
+++ b/src/net/tmwserv/inventoryhandler.cpp
@@ -23,6 +23,8 @@
#include "net/tmwserv/protocol.h"
+#include "net/tmwserv/gameserver/player.h"
+
#include "net/messagein.h"
#include "equipment.h"
@@ -77,3 +79,44 @@ void InventoryHandler::handleMessage(MessageIn &msg)
break;
}
}
+
+void InventoryHandler::equipItem(Item *item)
+{
+ Net::GameServer::Player::equip(item->getInvIndex());
+}
+
+void InventoryHandler::unequipItem(Item *item)
+{
+ Net::GameServer::Player::unequip(item->getInvIndex());
+}
+
+void InventoryHandler::useItem(Item *item)
+{
+ Net::GameServer::Player::useItem(item->getInvIndex());
+}
+
+void InventoryHandler::dropItem(Item *item, int amount)
+{
+ Net::GameServer::Player::drop(item->getInvIndex(), amount);
+}
+
+void InventoryHandler::splitItem(Item *item, int amount)
+{
+ // TODO
+}
+
+void InventoryHandler::openStorage()
+{
+ // TODO
+}
+
+void InventoryHandler::closeStorage()
+{
+ // TODO
+}
+
+void InventoryHandler::moveItem(StorageType source, int slot, int amount,
+ StorageType destination)
+{
+ // TODO
+}
diff --git a/src/net/tmwserv/inventoryhandler.h b/src/net/tmwserv/inventoryhandler.h
index 4144d89c..3d7fce1a 100644
--- a/src/net/tmwserv/inventoryhandler.h
+++ b/src/net/tmwserv/inventoryhandler.h
@@ -22,14 +22,32 @@
#ifndef NET_TMWSERV_INVENTORYHANDLER_H
#define NET_TMWSERV_INVENTORYHANDLER_H
+#include "net/inventoryhandler.h"
#include "net/messagehandler.h"
-class InventoryHandler : public MessageHandler
+class InventoryHandler : public MessageHandler, Net::InventoryHandler
{
public:
InventoryHandler();
void handleMessage(MessageIn &msg);
+
+ void equipItem(Item *item);
+
+ void unequipItem(Item *item);
+
+ void useItem(Item *item);
+
+ void dropItem(Item *item, int amount);
+
+ void splitItem(Item *item, int amount);
+
+ void openStorage();
+
+ void closeStorage();
+
+ void moveItem(StorageType source, int slot, int amount,
+ StorageType destination);
};
#endif
diff --git a/src/net/tmwserv/playerhandler.cpp b/src/net/tmwserv/playerhandler.cpp
index 106894a1..4643dd8a 100644
--- a/src/net/tmwserv/playerhandler.cpp
+++ b/src/net/tmwserv/playerhandler.cpp
@@ -23,8 +23,11 @@
#include "net/tmwserv/protocol.h"
+#include "net/tmwserv/gameserver/player.h"
+
#include "net/messagein.h"
+#include "effectmanager.h"
#include "engine.h"
#include "localplayer.h"
#include "log.h"
@@ -325,3 +328,63 @@ void PlayerHandler::handleMapChangeMessage(MessageIn &msg)
(int) scrollOffsetY);
viewport->scrollBy(scrollOffsetX, scrollOffsetY);
}
+
+void PlayerHandler::attack(Being *being)
+{
+ // TODO
+}
+
+void PlayerHandler::emote(int emoteId)
+{
+ // TODO
+}
+
+void PlayerHandler::increaseStat(LocalPlayer::Attribute attr)
+{
+ // TODO
+}
+
+void PlayerHandler::decreaseStat(LocalPlayer::Attribute attr)
+{
+ // TODO
+}
+
+void PlayerHandler::pickUp(FloorItem *floorItem)
+{
+ int id = floorItem->getId();
+ Net::GameServer::Player::pickUp(id >> 16, id & 0xFFFF);
+}
+
+void PlayerHandler::setDirection(char direction)
+{
+ Net::GameServer::Player::changeDir(direction);
+}
+
+void PlayerHandler::setDestination(int x, int y, int direction)
+{
+ Net::GameServer::Player::walk(x, y);
+ //Debugging fire burst
+ effectManager->trigger(15, x, y);
+}
+
+void PlayerHandler::changeAction(Being::Action action)
+{
+ if (action == Being::SIT)
+ player_node->setAction(action);
+ Net::GameServer::Player::changeAction(action);
+}
+
+void PlayerHandler::respawn()
+{
+ // TODO
+}
+
+void PlayerHandler::ingorePlayer(const std::string &player, bool ignore)
+{
+ // TODO
+}
+
+void PlayerHandler::ingoreAll(bool ignore)
+{
+ // TODO
+}
diff --git a/src/net/tmwserv/playerhandler.h b/src/net/tmwserv/playerhandler.h
index c8eacc38..572c8712 100644
--- a/src/net/tmwserv/playerhandler.h
+++ b/src/net/tmwserv/playerhandler.h
@@ -23,14 +23,37 @@
#define NET_TMWSERV_PLAYERHANDLER_H
#include "net/messagehandler.h"
+#include "net/playerhandler.h"
-class PlayerHandler : public MessageHandler
+class PlayerHandler : public MessageHandler, public Net::PlayerHandler
{
public:
PlayerHandler();
void handleMessage(MessageIn &msg);
+ void attack(Being *being);
+
+ void emote(int emoteId);
+
+ void increaseStat(LocalPlayer::Attribute attr);
+
+ void decreaseStat(LocalPlayer::Attribute attr);
+
+ void pickUp(FloorItem *floorItem);
+
+ void setDirection(char direction);
+
+ void setDestination(int x, int y, int direction = -1);
+
+ void changeAction(Being::Action action);
+
+ void respawn();
+
+ void ingorePlayer(const std::string &player, bool ignore);
+
+ void ingoreAll(bool ignore);
+
private:
void handleMapChangeMessage(MessageIn &msg);
};