summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/commandhandler.cpp3
-rw-r--r--src/gui/equipmentwindow.cpp5
-rw-r--r--src/gui/inventorywindow.cpp6
-rw-r--r--src/gui/itemamount.cpp8
-rw-r--r--src/gui/popupmenu.cpp12
-rw-r--r--src/gui/skill.cpp5
-rw-r--r--src/itemshortcut.cpp11
-rw-r--r--src/localplayer.cpp75
-rw-r--r--src/localplayer.h42
-rw-r--r--src/net/ea/inventoryhandler.cpp4
-rw-r--r--src/net/ea/playerhandler.cpp2
-rw-r--r--src/net/ea/skillhandler.cpp4
-rw-r--r--src/net/ea/tradehandler.cpp12
-rw-r--r--src/net/tmwserv/inventoryhandler.cpp3
-rw-r--r--src/net/tmwserv/playerhandler.cpp3
-rw-r--r--src/net/tmwserv/tradehandler.cpp2
16 files changed, 57 insertions, 140 deletions
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index 6265f350..462cb3b9 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -34,6 +34,7 @@
#include "net/chathandler.h"
#include "net/maphandler.h"
#include "net/net.h"
+#include "net/partyhandler.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -369,7 +370,7 @@ void CommandHandler::handleListChannels(const std::string &args, ChatTab *tab)
void CommandHandler::handleParty(const std::string &args, ChatTab *tab)
{
if (args != "")
- player_node->inviteToParty(args);
+ Net::getPartyHandler()->invite(args);
else
tab->chatLog("Please specify a name.", BY_SERVER);
}
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index aa81361d..44006971 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -33,6 +33,9 @@
#include "item.h"
#include "localplayer.h"
+#include "net/inventoryhandler.h"
+#include "net/net.h"
+
#include "resources/image.h"
#include "resources/iteminfo.h"
#include "resources/resourcemanager.h"
@@ -176,7 +179,7 @@ void EquipmentWindow::action(const gcn::ActionEvent &event)
mInventory->getItem(mEquipment->getEquipment(mSelected)) :
mInventory->getItem(mEquipment->getArrows());
#endif
- player_node->unequipItem(item);
+ Net::getInventoryHandler()->unequipItem(item);
setSelected(-1);
}
}
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 1f03c67ee..d6cd3a84 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -166,12 +166,12 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
if (item->isEquipment())
{
if (item->isEquipped())
- player_node->unequipItem(item);
+ Net::getInventoryHandler()->unequipItem(item);
else
- player_node->equipItem(item);
+ Net::getInventoryHandler()->equipItem(item);
}
else
- player_node->useItem(item);
+ Net::getInventoryHandler()->useItem(item);
}
else if (event.getId() == "drop")
{
diff --git a/src/gui/itemamount.cpp b/src/gui/itemamount.cpp
index 393cd8bc..252daf19 100644
--- a/src/gui/itemamount.cpp
+++ b/src/gui/itemamount.cpp
@@ -33,7 +33,9 @@
#include "gui/widgets/icon.h"
#include "item.h"
-#include "localplayer.h"
+
+#include "net/inventoryhandler.h"
+#include "net/net.h"
#include "utils/gettext.h"
@@ -45,10 +47,10 @@ void ItemAmountWindow::finish(Item *item, int amount, Usage usage)
tradeWindow->tradeItem(item, amount);
break;
case ItemDrop:
- player_node->dropItem(item, amount);
+ Net::getInventoryHandler()->dropItem(item, amount);
break;
case ItemSplit:
- player_node->splitItem(item, amount);
+ Net::getInventoryHandler()->splitItem(item, amount);
break;
case StoreAdd:
storageWindow->addStore(item, amount);
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 46a33d6c..2dcf2628 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -40,6 +40,8 @@
#include "net/adminhandler.h"
#include "net/inventoryhandler.h"
#include "net/net.h"
+#include "net/partyhandler.h"
+#include "net/tradehandler.h"
#include "resources/itemdb.h"
#include "resources/iteminfo.h"
@@ -182,7 +184,7 @@ void PopupMenu::handleLink(const std::string &link)
being &&
being->getType() == Being::PLAYER)
{
- player_node->trade(being);
+ Net::getTradeHandler()->request(being);
tradePartnerName = being->getName();
}
#ifdef EATHENA_SUPPORT
@@ -261,13 +263,13 @@ void PopupMenu::handleLink(const std::string &link)
if (mItem->isEquipment())
{
if (mItem->isEquipped())
- player_node->unequipItem(mItem);
+ Net::getInventoryHandler()->unequipItem(mItem);
else
- player_node->equipItem(mItem);
+ Net::getInventoryHandler()->equipItem(mItem);
}
else
{
- player_node->useItem(mItem);
+ Net::getInventoryHandler()->useItem(mItem);
}
}
@@ -302,7 +304,7 @@ void PopupMenu::handleLink(const std::string &link)
else if (link == "party" && being && being->getType() == Being::PLAYER)
{
- player_node->inviteToParty(dynamic_cast<Player*>(being));
+ Net::getPartyHandler()->invite(dynamic_cast<Player*>(being));
}
else if (link == "name" && being)
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
index b6f6f124..3a4fb75c 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -33,6 +33,9 @@
#include "localplayer.h"
#include "log.h"
+#include "net/net.h"
+#include "net/skillhandler.h"
+
#include "utils/dtor.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -173,7 +176,7 @@ void SkillDialog::action(const gcn::ActionEvent &event)
// Increment skill
int selectedSkill = mTable->getSelectedRow();
if (selectedSkill >= 0)
- player_node->raiseSkill(mSkillList[selectedSkill]->id);
+ Net::getSkillHandler()->up(mSkillList[selectedSkill]->id);
}
else if (event.getId() == "skill" && mTable->getSelectedRow() > -1)
{
diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp
index bd247300..6024e67a 100644
--- a/src/itemshortcut.cpp
+++ b/src/itemshortcut.cpp
@@ -25,6 +25,9 @@
#include "itemshortcut.h"
#include "localplayer.h"
+#include "net/inventoryhandler.h"
+#include "net/net.h"
+
#include "utils/stringutils.h"
ItemShortcut::ItemShortcut *itemShortcut;
@@ -72,16 +75,14 @@ void ItemShortcut::useItem(int index)
{
if (item->isEquipment())
{
-#ifdef EATHENA_SUPPORT
if (item->isEquipped())
- player_node->unequipItem(item);
+ Net::getInventoryHandler()->unequipItem(item);
else
-#endif
- player_node->equipItem(item);
+ Net::getInventoryHandler()->equipItem(item);
}
else
{
- player_node->useItem(item);
+ Net::getInventoryHandler()->useItem(item);
}
}
}
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index b571c4b0..059ccd31 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -336,48 +336,6 @@ void LocalPlayer::setInvItem(int index, int id, int amount)
#endif
-void LocalPlayer::inviteToParty(const std::string &name)
-{
- Net::getPartyHandler()->invite(name);
-}
-
-void LocalPlayer::inviteToParty(Player *player)
-{
- Net::getPartyHandler()->invite(player);
-}
-
-void LocalPlayer::equipItem(Item *item)
-{
- Net::getInventoryHandler()->equipItem(item);
-}
-
-void LocalPlayer::unequipItem(Item *item)
-{
- Net::getInventoryHandler()->unequipItem(item);
-
- // Tidy equipment directly to avoid weapon still shown bug, for instance
-#ifdef TMWSERV_SUPPORT
- mEquipment->setEquipment(item->getInvIndex(), 0);
-#else
- mEquipment->removeEquipment(item->getInvIndex());
-#endif
-}
-
-void LocalPlayer::useItem(Item *item)
-{
- Net::getInventoryHandler()->useItem(item);
-}
-
-void LocalPlayer::dropItem(Item *item, int quantity)
-{
- Net::getInventoryHandler()->dropItem(item, quantity);
-}
-
-void LocalPlayer::splitItem(Item *item, int quantity)
-{
- Net::getInventoryHandler()->splitItem(item, quantity);
-}
-
void LocalPlayer::pickUp(FloorItem *item)
{
#ifdef TMWSERV_SUPPORT
@@ -618,16 +576,6 @@ void LocalPlayer::stopWalking(bool sendToServer)
}
#endif
-#ifdef EATHENA_SUPPORT
-void LocalPlayer::raiseSkill(Uint16 skillId)
-{
- if (mSkillPoint <= 0)
- return;
-
- Net::getSkillHandler()->up(skillId);
-}
-#endif
-
void LocalPlayer::toggleSit()
{
if (mLastAction != -1)
@@ -654,24 +602,6 @@ void LocalPlayer::emote(Uint8 emotion)
Net::getPlayerHandler()->emote(emotion);
}
-void LocalPlayer::tradeReply(bool accept)
-{
- if (!accept)
- mTrading = false;
-
- Net::getTradeHandler()->respond(accept);
-}
-
-void LocalPlayer::trade(Being *being) const
-{
- Net::getTradeHandler()->request(being);
-}
-
-bool LocalPlayer::tradeRequestOk() const
-{
- return !mTrading;
-}
-
#ifdef TMWSERV_SUPPORT
void LocalPlayer::attack()
@@ -801,11 +731,6 @@ void LocalPlayer::stopAttack()
mLastTarget = -1;
}
-void LocalPlayer::revive()
-{
- Net::getPlayerHandler()->respawn();
-}
-
#ifdef TMWSERV_SUPPORT
void LocalPlayer::raiseAttribute(size_t attr)
diff --git a/src/localplayer.h b/src/localplayer.h
index acf2ee63..52e2b74b 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -187,32 +187,6 @@ class LocalPlayer : public Player
void setInvItem(int index, int id, int amount);
#endif
- /**
- * Invite a player to join their party
- */
- void inviteToParty(const std::string &name);
-
- /**
- * Invite a player to join their party
- */
- void inviteToParty(Player *player);
-
- /**
- * Equips an item.
- */
- void equipItem(Item *item);
-
- /**
- * Unequips an item.
- */
- void unequipItem(Item *item);
-
- void useItem(Item *item);
-
- void dropItem(Item *item, int quantity);
-
- void splitItem(Item *item, int quantity);
-
void pickUp(FloorItem *item);
#ifdef EATHENA_SUPPORT
@@ -228,20 +202,10 @@ class LocalPlayer : public Player
int getAttackRange();
/**
- * Sents a trade request to the given being.
- */
- void trade(Being *being) const;
-
- /**
- * Accept or decline a trade offer
- */
- void tradeReply(bool accept);
-
- /**
* Returns true when the player is ready to accept a trade offer.
* Returns false otherwise.
*/
- bool tradeRequestOk() const;
+ bool tradeRequestOk() const { return !mTrading; }
/**
* Sets the trading state of the player, i.e. whether or not he is
@@ -317,7 +281,7 @@ class LocalPlayer : public Player
bool withinAttackRange(Being *target);
#ifdef EATHENA_SUPPORT
- void raiseSkill(Uint16 skillId);
+ //void raiseSkill(Uint16 skillId);
#else
/**
@@ -339,8 +303,6 @@ class LocalPlayer : public Player
void toggleSit();
void emote(Uint8 emotion);
- void revive();
-
/**
* Shows item pickup effect if the player is on a map.
*/
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 1c48aa6c..30c583b8 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -27,6 +27,7 @@
#include "net/messageout.h"
#include "configuration.h"
+#include "equipment.h"
#include "inventory.h"
#include "item.h"
#include "itemshortcut.h"
@@ -318,6 +319,9 @@ void InventoryHandler::unequipItem(const Item *item)
MessageOut outMsg(CMSG_PLAYER_UNEQUIP);
outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET);
+
+ // Tidy equipment directly to avoid weapon still shown bug, for instance
+ player_node->mEquipment->removeEquipment(item->getInvIndex());
}
void InventoryHandler::useItem(const Item *item)
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 3f8fbc09..29f0bac4 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -75,7 +75,7 @@ namespace {
{
void action(const gcn::ActionEvent &event)
{
- player_node->revive();
+ Net::getPlayerHandler()->respawn();
deathNotice = NULL;
buyDialog->setVisible(false);
sellDialog->setVisible(false);
diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp
index 0239a2c8..69b0fd65 100644
--- a/src/net/ea/skillhandler.cpp
+++ b/src/net/ea/skillhandler.cpp
@@ -26,6 +26,7 @@
#include "net/messagein.h"
#include "net/messageout.h"
+#include "localplayer.h"
#include "log.h"
#include "gui/skill.h"
@@ -216,6 +217,9 @@ void SkillHandler::handleMessage(MessageIn &msg)
void SkillHandler::up(int skillId)
{
+ if (player_node->mSkillPoint <= 0)
+ return;
+
MessageOut outMsg(CMSG_SKILL_LEVELUP_REQUEST);
outMsg.writeInt16(skillId);
}
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index ee8e6733..74722332 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -23,6 +23,7 @@
#include "net/ea/protocol.h"
+#include "net/inventoryhandler.h"
#include "net/messagein.h"
#include "net/messageout.h"
@@ -48,7 +49,7 @@ namespace {
{
void action(const gcn::ActionEvent &event)
{
- player_node->tradeReply(event.getId() == "yes");
+ Net::getTradeHandler()->respond(event.getId() == "yes");
}
} listener;
}
@@ -91,7 +92,7 @@ void TradeHandler::handleMessage(MessageIn &msg)
{
if (!player_node->tradeRequestOk())
{
- player_node->tradeReply(false);
+ Net::getTradeHandler()->respond(false);
break;
}
@@ -104,7 +105,7 @@ void TradeHandler::handleMessage(MessageIn &msg)
}
else
{
- player_node->tradeReply(false);
+ Net::getTradeHandler()->respond(false);
break;
}
break;
@@ -183,7 +184,7 @@ void TradeHandler::handleMessage(MessageIn &msg)
// Successfully added item
if (item->isEquipment() && item->isEquipped())
{
- player_node->unequipItem(item);
+ Net::getInventoryHandler()->unequipItem(item);
}
tradeWindow->addItem(item->getId(), true, quantity,
item->isEquipment());
@@ -236,6 +237,9 @@ void TradeHandler::request(Being *being)
void TradeHandler::respond(bool accept)
{
+ if (!accept)
+ player_node->setTrading(false);
+
MessageOut outMsg(CMSG_TRADE_RESPONSE);
outMsg.writeInt8(accept ? 3 : 4);
}
diff --git a/src/net/tmwserv/inventoryhandler.cpp b/src/net/tmwserv/inventoryhandler.cpp
index d78c8318..8110fdd2 100644
--- a/src/net/tmwserv/inventoryhandler.cpp
+++ b/src/net/tmwserv/inventoryhandler.cpp
@@ -100,6 +100,9 @@ void InventoryHandler::unequipItem(const Item *item)
MessageOut msg(PGMSG_UNEQUIP);
msg.writeInt8(item->getInvIndex());
Net::GameServer::connection->send(msg);
+
+ // Tidy equipment directly to avoid weapon still shown bug, for instance
+ player_node->mEquipment->setEquipment(item->getInvIndex(), 0);
}
void InventoryHandler::useItem(const Item *item)
diff --git a/src/net/tmwserv/playerhandler.cpp b/src/net/tmwserv/playerhandler.cpp
index c7769ede..b697e8a8 100644
--- a/src/net/tmwserv/playerhandler.cpp
+++ b/src/net/tmwserv/playerhandler.cpp
@@ -29,6 +29,7 @@
#include "net/messagein.h"
#include "net/messageout.h"
+#include "net/net.h"
#include "effectmanager.h"
#include "engine.h"
@@ -81,7 +82,7 @@ namespace {
{
void action(const gcn::ActionEvent &event)
{
- player_node->revive();
+ Net::getPlayerHandler()->respawn();
deathNotice = NULL;
buyDialog->setVisible(false);
sellDialog->setVisible(false);
diff --git a/src/net/tmwserv/tradehandler.cpp b/src/net/tmwserv/tradehandler.cpp
index 4c462a3f..74789a34 100644
--- a/src/net/tmwserv/tradehandler.cpp
+++ b/src/net/tmwserv/tradehandler.cpp
@@ -167,6 +167,8 @@ void TradeHandler::request(Being *being)
void TradeHandler::respond(bool accept)
{
// TODO
+ if (!accept)
+ player_node->setTrading(false);
}
void TradeHandler::addItem(Item *item, int amount)