summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-07-31 21:29:00 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-07-31 21:29:00 +0000
commit36d28236321b6a2824ad4f394faeabbf79626808 (patch)
tree7d2475acf84852f2a21cc29eecbf7524cd58ff52 /src
parentc9f930c759004e179545c3b82992e3f8a12345f2 (diff)
downloadmana-client-36d28236321b6a2824ad4f394faeabbf79626808.tar.gz
mana-client-36d28236321b6a2824ad4f394faeabbf79626808.tar.bz2
mana-client-36d28236321b6a2824ad4f394faeabbf79626808.tar.xz
mana-client-36d28236321b6a2824ad4f394faeabbf79626808.zip
Removed legacy inventory code. Added display of equipment.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/equipment.cpp23
-rw-r--r--src/equipment.h36
-rw-r--r--src/game.cpp3
-rw-r--r--src/game.h1
-rw-r--r--src/gui/equipmentwindow.cpp13
-rw-r--r--src/gui/inventorywindow.cpp14
-rw-r--r--src/gui/itemcontainer.cpp2
-rw-r--r--src/gui/popupmenu.cpp14
-rw-r--r--src/gui/trade.cpp8
-rw-r--r--src/gui/trade.h2
-rw-r--r--src/inventory.cpp11
-rw-r--r--src/inventory.h4
-rw-r--r--src/item.cpp10
-rw-r--r--src/item.h33
-rw-r--r--src/localplayer.cpp17
-rw-r--r--src/localplayer.h4
-rw-r--r--src/net/buysellhandler.cpp8
-rw-r--r--src/net/equipmenthandler.cpp214
-rw-r--r--src/net/equipmenthandler.h37
-rw-r--r--src/net/inventoryhandler.cpp95
-rw-r--r--src/net/protocol.h69
-rw-r--r--src/net/skillhandler.cpp6
-rw-r--r--src/net/tradehandler.cpp2
24 files changed, 60 insertions, 568 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 92c1b1b2..0ccdd777 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -142,8 +142,6 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \
net/chathandler.cpp \
net/connection.h \
net/connection.cpp \
- net/equipmenthandler.h \
- net/equipmenthandler.cpp \
net/internal.h \
net/internal.cpp \
net/inventoryhandler.h \
diff --git a/src/equipment.cpp b/src/equipment.cpp
index 6cd4d967..1dfc7d02 100644
--- a/src/equipment.cpp
+++ b/src/equipment.cpp
@@ -21,29 +21,12 @@
* $Id$
*/
-#include "equipment.h"
-
#include <algorithm>
-#include "item.h"
-
-Equipment::Equipment():
- mArrows(0)
-{
- std::fill_n(mEquipment, EQUIPMENT_SIZE, (Item*)0);
-}
+#include "equipment.h"
-void
-Equipment::removeEquipment(Item *item)
+Equipment::Equipment()
{
- Item **i = std::find(mEquipment, mEquipment+EQUIPMENT_SIZE, item);
- if (i != mEquipment+EQUIPMENT_SIZE) {
- *i = 0;
- }
+ std::fill_n(mEquipment, EQUIPMENT_SIZE, 0);
}
-void Equipment::setEquipment(int index, Item *item)
-{
- mEquipment[index] = item;
- item->setEquipped(true);
-}
diff --git a/src/equipment.h b/src/equipment.h
index db9cf27d..f178e0ca 100644
--- a/src/equipment.h
+++ b/src/equipment.h
@@ -39,41 +39,17 @@ class Equipment
/**
* Get equipment at the given slot.
*/
- Item*
- getEquipment(int index) { return mEquipment[index]; }
+ int getEquipment(int index)
+ { return mEquipment[index]; }
/**
* Set equipment at the given slot.
*/
- void
- setEquipment(int index, Item *item);
+ void setEquipment(int index, int id)
+ { mEquipment[index] = id; }
- /**
- * Remove equipment from the given slot.
- */
- void
- removeEquipment(int index) { mEquipment[index] = 0; }
-
- /**
- * Remove the given item from equipment.
- */
- void removeEquipment(Item *item);
-
- /**
- * Get the item used in the arrow slot.
- */
- Item*
- getArrows() { return mArrows; }
-
- /**
- * Set the item used in the arrow slot.
- */
- void
- setArrows(Item *arrows) { mArrows = arrows; }
-
- protected:
- Item *mEquipment[EQUIPMENT_SIZE];
- Item *mArrows;
+ private:
+ int mEquipment[EQUIPMENT_SIZE];
};
#endif
diff --git a/src/game.cpp b/src/game.cpp
index 7385549b..495f9a8d 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -69,7 +69,6 @@
#include "net/beinghandler.h"
#include "net/buysellhandler.h"
#include "net/chathandler.h"
-#include "net/equipmenthandler.h"
#include "net/inventoryhandler.h"
#include "net/itemhandler.h"
#include "net/network.h"
@@ -227,7 +226,6 @@ Game::Game():
mBeingHandler(new BeingHandler()),
mBuySellHandler(new BuySellHandler()),
mChatHandler(new ChatHandler()),
- mEquipmentHandler(new EquipmentHandler()),
mInventoryHandler(new InventoryHandler()),
mItemHandler(new ItemHandler()),
mNpcHandler(new NPCHandler()),
@@ -271,7 +269,6 @@ Game::Game():
Net::registerHandler(mBeingHandler.get());
Net::registerHandler(mBuySellHandler.get());
Net::registerHandler(mChatHandler.get());
- Net::registerHandler(mEquipmentHandler.get());
Net::registerHandler(mInventoryHandler.get());
Net::registerHandler(mItemHandler.get());
Net::registerHandler(mNpcHandler.get());
diff --git a/src/game.h b/src/game.h
index 408b933b..d1b438bd 100644
--- a/src/game.h
+++ b/src/game.h
@@ -63,7 +63,6 @@ class Game : public ConfigListener
MessageHandlerPtr mBeingHandler;
MessageHandlerPtr mBuySellHandler;
MessageHandlerPtr mChatHandler;
- MessageHandlerPtr mEquipmentHandler;
MessageHandlerPtr mInventoryHandler;
MessageHandlerPtr mItemHandler;
MessageHandlerPtr mNpcHandler;
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 1ae887bc..27c97ea0 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -50,9 +50,6 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
// Draw window graphics
Window::draw(graphics);
- Item *item;
- Image *image;
-
// Rectangles around items are black
graphics->setColor(gcn::Color(0, 0, 0));
@@ -60,17 +57,17 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
graphics->drawRectangle(gcn::Rectangle(10 + 36 * (i % 4),
36 * (i / 4) + 25, 32, 32));
- if (!(item = mEquipment->getEquipment(i))) {
- continue;
- }
+ int item = mEquipment->getEquipment(i);
+ if (!item) continue;
- image = item->getInfo().getImage();
+ Image *image = Item(item).getInfo().getImage();
static_cast<Graphics*>(graphics)->
drawImage(image, 36 * (i % 4) + 10, 36 * (i / 4) + 25);
}
graphics->drawRectangle(gcn::Rectangle(160, 25, 32, 32));
+ /*
if (!(item = mEquipment->getArrows())) {
return;
}
@@ -80,4 +77,6 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
static_cast<Graphics*>(graphics)->drawImage(image, 160, 25);
graphics->drawText(toString(item->getQuantity()), 170, 62,
gcn::Graphics::CENTER);
+ */
+ return;
}
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 2018c75a..2ad35095 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -109,12 +109,7 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
if (event.getId() == "use") {
if (item->isEquipment()) {
- if (item->isEquipped()) {
- player_node->unequipItem(item);
- }
- else {
- player_node->equipItem(item);
- }
+ player_node->equipItem(item);
}
else {
player_node->useItem(item);
@@ -215,12 +210,7 @@ void InventoryWindow::updateButtons()
if ((item = mItems->getItem()) && item->isEquipment())
{
- if (item->isEquipped()) {
- mUseButton->setCaption("Unequip");
- }
- else {
- mUseButton->setCaption("Equip");
- }
+ mUseButton->setCaption("Equip");
}
else {
mUseButton ->setCaption("Use");
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index 0e5bcce9..444be2a2 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -116,7 +116,7 @@ ItemContainer::draw(gcn::Graphics *graphics)
// Draw item caption
graphics->drawText(
- (item->isEquipped() ? "Eq." : toString(item->getQuantity())),
+ toString(item->getQuantity()),
itemX + gridWidth / 2,
itemY + gridHeight - 11,
gcn::Graphics::CENTER);
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index cc764d35..f308bbfd 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -168,14 +168,7 @@ void PopupMenu::handleLink(const std::string& link)
assert(mItem);
if (mItem->isEquipment())
{
- if (mItem->isEquipped())
- {
- player_node->unequipItem(mItem);
- }
- else
- {
- player_node->equipItem(mItem);
- }
+ player_node->equipItem(mItem);
}
else
{
@@ -221,10 +214,7 @@ void PopupMenu::showPopup(int x, int y, Item *item)
if (item->isEquipment())
{
- if (item->isEquipped())
- mBrowserBox->addRow("@@use|Unequip@@");
- else
- mBrowserBox->addRow("@@use|Equip@@");
+ mBrowserBox->addRow("@@use|Equip@@");
}
else
mBrowserBox->addRow("@@use|Use@@");
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 37faafdf..337bd7ea 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -137,12 +137,12 @@ void TradeWindow::addMoney(int amount)
mMoneyLabel->adjustSize();
}
-void TradeWindow::addItem(int id, bool own, int quantity, bool equipment)
+void TradeWindow::addItem(int id, bool own, int quantity)
{
if (own) {
- mMyInventory->addItem(id, quantity, equipment);
+ mMyInventory->addItem(id, quantity);
} else {
- mPartnerInventory->addItem(id, quantity, equipment);
+ mPartnerInventory->addItem(id, quantity);
}
}
@@ -217,7 +217,7 @@ void TradeWindow::receivedOk(bool own)
void TradeWindow::tradeItem(Item *item, int quantity)
{
Net::GameServer::Player::tradeItem(item->getInvIndex(), quantity);
- addItem(item->getId(), true, quantity, item->isEquipment());
+ addItem(item->getId(), true, quantity);
item->increaseQuantity(-quantity);
}
diff --git a/src/gui/trade.h b/src/gui/trade.h
index 1c64c255..bffda13f 100644
--- a/src/gui/trade.h
+++ b/src/gui/trade.h
@@ -64,7 +64,7 @@ class TradeWindow : public Window, gcn::ActionListener, SelectionListener
/**
* Add an item to the trade window.
*/
- void addItem(int id, bool own, int quantity, bool equipment);
+ void addItem(int id, bool own, int quantity);
/**
* Remove a item from the trade window.
diff --git a/src/inventory.cpp b/src/inventory.cpp
index ac0bce18..11c52421 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -49,7 +49,7 @@ Inventory::~Inventory()
Item* Inventory::getItem(int index)
{
- if (index < 0 || index > INVENTORY_SIZE)
+ if (index < 0 || index >= INVENTORY_SIZE)
{
return 0;
}
@@ -57,16 +57,15 @@ Item* Inventory::getItem(int index)
return &mItems[index];
}
-void Inventory::addItem(int id, int quantity, bool equipment)
+void Inventory::addItem(int id, int quantity)
{
- addItem(getFreeSlot(), id, quantity, equipment);
+ addItem(getFreeSlot(), id, quantity);
}
-void Inventory::addItem(int index, int id, int quantity, bool equipment)
+void Inventory::addItem(int index, int id, int quantity)
{
mItems[index].setId(id);
mItems[index].increaseQuantity(quantity);
- mItems[index].setEquipment(equipment);
}
@@ -75,7 +74,6 @@ void Inventory::clear()
for (int i = 0; i < INVENTORY_SIZE; i++) {
mItems[i].setId(-1);
mItems[i].setQuantity(0);
- mItems[i].setEquipped(false);
}
}
@@ -85,7 +83,6 @@ void Inventory::removeItem(int id)
if (mItems[i].getId() == id) {
mItems[i].setId(-1);
mItems[i].setQuantity(0);
- mItems[i].setEquipped(false);
}
}
}
diff --git a/src/inventory.h b/src/inventory.h
index 32ae393e..ce537f34 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -49,12 +49,12 @@ class Inventory
/**
* Adds a new item in a free slot.
*/
- void addItem(int id, int quantity, bool equipment);
+ void addItem(int id, int quantity);
/**
* Adds a new item at a given position.
*/
- void addItem(int index, int id, int quantity, bool equipment);
+ void addItem(int index, int id, int quantity);
/**
* Remove a item from the inventory.
diff --git a/src/item.cpp b/src/item.cpp
index 3cea30e5..487f17da 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -21,3 +21,13 @@
* $Id$
*/
+#include "item.h"
+
+Item::Item(int id, int quantity) :
+ mId(id),
+ mQuantity(quantity)
+{
+ // Either type or slot, both are unused anyway. -- silene
+ mEquipment = getInfo().getType();
+}
+
diff --git a/src/item.h b/src/item.h
index 47cdb1a9..2a60bf3a 100644
--- a/src/item.h
+++ b/src/item.h
@@ -35,19 +35,7 @@ class Item
/**
* Constructor.
*/
- Item(int id = -1, int quantity = 0,
- bool equipment = false, bool equipped = false):
- mId(id),
- mQuantity(quantity),
- mEquipment(equipment),
- mEquipped(equipped)
- {
- }
-
- /**
- * Destructor.
- */
- ~Item() {}
+ Item(int id = -1, int quantity = 0);
/**
* Sets the item id, identifying the item type.
@@ -80,30 +68,12 @@ class Item
getQuantity() const { return mQuantity; }
/**
- * Sets whether this item is considered equipment.
- */
- void
- setEquipment(bool equipment) { mEquipment = equipment; }
-
- /**
* Returns whether this item is considered equipment.
*/
bool
isEquipment() const { return mEquipment; }
/**
- * Sets whether this item is equipped.
- */
- void
- setEquipped(bool equipped) { mEquipped = equipped; }
-
- /**
- * Returns whether this item is equipped.
- */
- bool
- isEquipped() const { return mEquipped; }
-
- /**
* Sets the inventory index of this item.
*/
void
@@ -125,7 +95,6 @@ class Item
int mId; /**< Item type id. */
int mQuantity; /**< Number of items. */
bool mEquipment; /**< Item is equipment. */
- bool mEquipped; /**< Item is equipped. */
int mInvIndex; /**< Inventory index. */
};
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 5945127f..b4fc5957 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -95,16 +95,6 @@ void LocalPlayer::clearInventory()
mInventory->clear();
}
-void LocalPlayer::addInvItem(int id, int quantity, bool equipment)
-{
- mInventory->addItem(id, quantity, equipment);
-}
-
-void LocalPlayer::addInvItem(int index, int id, int quantity, bool equipment)
-{
- mInventory->addItem(index, id, quantity, equipment);
-}
-
Item* LocalPlayer::getInvItem(int index)
{
return mInventory->getItem(index);
@@ -115,11 +105,8 @@ void LocalPlayer::equipItem(Item *item)
Net::GameServer::Player::equip(item->getInvIndex());
}
-void LocalPlayer::unequipItem(Item *item)
+void LocalPlayer::unequipItem(int slot)
{
- if (!item)
- return;
-
// XXX Convert for new server
/*
MessageOut outMsg(CMSG_PLAYER_UNEQUIP);
@@ -127,7 +114,7 @@ void LocalPlayer::unequipItem(Item *item)
*/
// Tidy equipment directly to avoid weapon still shown bug, by instance
- mEquipment->removeEquipment(item);
+ mEquipment->setEquipment(slot, 0);
}
void LocalPlayer::useItem(Item *item)
diff --git a/src/localplayer.h b/src/localplayer.h
index c3a74b52..edadd7a0 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -134,8 +134,6 @@ class LocalPlayer : public Player
virtual Type getType() const;
void clearInventory();
- void addInvItem(int id, int quantity, bool equipment);
- void addInvItem(int index, int id, int quantity, bool equipment);
Item* getInvItem(int index);
/**
@@ -146,7 +144,7 @@ class LocalPlayer : public Player
/**
* Unequips an item.
*/
- void unequipItem(Item *item);
+ void unequipItem(int slot);
void useItem(Item *item);
void dropItem(Item *item, int quantity);
diff --git a/src/net/buysellhandler.cpp b/src/net/buysellhandler.cpp
index 45dfb9ad..2f22b0e6 100644
--- a/src/net/buysellhandler.cpp
+++ b/src/net/buysellhandler.cpp
@@ -44,11 +44,6 @@ extern Window *buySellDialog;
BuySellHandler::BuySellHandler()
{
static const Uint16 _messages[] = {
- SMSG_NPC_BUY_SELL_CHOICE,
- SMSG_NPC_BUY,
- SMSG_NPC_SELL,
- SMSG_NPC_BUY_RESPONSE,
- SMSG_NPC_SELL_RESPONSE,
0
};
handledMessages = _messages;
@@ -56,9 +51,9 @@ BuySellHandler::BuySellHandler()
void BuySellHandler::handleMessage(MessageIn &msg)
{
- int n_items;
switch (msg.getId())
{
+#if 0
case SMSG_NPC_BUY_SELL_CHOICE:
buyDialog->setVisible(false);
buyDialog->reset();
@@ -126,5 +121,6 @@ void BuySellHandler::handleMessage(MessageIn &msg)
chatWindow->chatLog("Unable to sell", BY_SERVER);
}
break;
+#endif
}
}
diff --git a/src/net/equipmenthandler.cpp b/src/net/equipmenthandler.cpp
deleted file mode 100644
index c0072a45..00000000
--- a/src/net/equipmenthandler.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World 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.
- *
- * The Mana World 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 The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#include "equipmenthandler.h"
-
-#include "messagein.h"
-#include "protocol.h"
-
-#include "../being.h"
-#include "../beingmanager.h"
-#include "../equipment.h"
-#include "../item.h"
-#include "../localplayer.h"
-#include "../log.h"
-
-#include "../gui/chat.h"
-
-EquipmentHandler::EquipmentHandler()
-{
- static const Uint16 _messages[] = {
- SMSG_PLAYER_EQUIPMENT,
- SMSG_PLAYER_EQUIP,
- 0x01d7,
- SMSG_PLAYER_UNEQUIP,
- SMSG_PLAYER_ARROW_EQUIP,
- SMSG_PLAYER_ATTACK_RANGE,
- 0
- };
- handledMessages = _messages;
-}
-
-void EquipmentHandler::handleMessage(MessageIn &msg)
-{
- Sint32 itemCount;
- Sint16 index, equipPoint, itemId;
- Sint8 type;
- int mask, position;
- Being *being;
- Item *item;
-
- switch (msg.getId())
- {
- case SMSG_PLAYER_EQUIPMENT:
- msg.readShort(); // length
- itemCount = (msg.getLength() - 4) / 20;
-
- for (int loop = 0; loop < itemCount; loop++)
- {
- index = msg.readShort();
- itemId = msg.readShort();
- msg.readByte(); // type
- msg.readByte(); // identify flag
- msg.readShort(); // equip type
- equipPoint = msg.readShort();
- msg.readByte(); // attribute
- msg.readByte(); // refine
-
- player_node->addInvItem(index, itemId, 1, true);
-
- if (equipPoint)
- {
- mask = 1;
- position = 0;
- while (!(equipPoint & mask))
- {
- mask <<= 1;
- position++;
- }
- item = player_node->getInvItem(index);
- player_node->mEquipment->setEquipment(position, item);
- }
- }
- break;
-
- case SMSG_PLAYER_EQUIP:
- index = msg.readShort();
- equipPoint = msg.readShort();
- type = msg.readByte();
-
- logger->log("Equipping: %i %i %i", index, equipPoint, type);
-
- if (!type) {
- chatWindow->chatLog("Unable to equip.", BY_SERVER);
- break;
- }
-
- if (!equipPoint) {
- // No point given, no point in searching
- break;
- }
-
- // Unequip any existing equipped item in this position
- mask = 1;
- position = 0;
- while (!(equipPoint & mask)) {
- mask <<= 1;
- position++;
- }
- logger->log("Position %i", position);
- item = player_node->mEquipment->getEquipment(position);
- if (item) {
- item->setEquipped(false);
- }
-
- item = player_node->getInvItem(index);
- player_node->mEquipment->setEquipment(position, item);
- player_node->setWeaponById(item->getId());
- break;
-
- case 0x01d7:
- // Equipment related
- being = beingManager->findBeing(msg.readLong());
- msg.readByte(); // equip point
- itemId = msg.readShort();
- msg.readShort(); // item id 2
-
- if (!being)
- break;
-
- being->setWeaponById(itemId);
- break;
-
- case SMSG_PLAYER_UNEQUIP:
- index = msg.readShort();
- equipPoint = msg.readShort();
- type = msg.readByte();
-
- if (!type) {
- chatWindow->chatLog("Unable to unequip.", BY_SERVER);
- break;
- }
-
- if (!equipPoint) {
- // No point given, no point in searching
- break;
- }
-
- mask = 1;
- position = 0;
- while (!(equipPoint & mask)) {
- mask <<= 1;
- position++;
- }
-
- item = player_node->getInvItem(index);
-
- if (!item)
- break;
-
- item->setEquipped(false);
-
- switch (item->getId()) {
- case 529:
- case 1199:
- player_node->mEquipment->setArrows(NULL);
- break;
- case 521:
- case 522:
- case 530:
- case 536:
- case 1200:
- case 1201:
- player_node->setWeapon(0);
- // TODO: Why this break? Shouldn't a weapon be
- // unequipped in inventory too?
- break;
- default:
- player_node->mEquipment->removeEquipment(position);
- break;
- }
- logger->log("Unequipping: %i %i(%i) %i",
- index, equipPoint, type, position);
- break;
-
- case SMSG_PLAYER_ATTACK_RANGE:
- player_node->setAttackRange(msg.readShort());
- break;
-
- case SMSG_PLAYER_ARROW_EQUIP:
- itemId = msg.readShort();
-
- if (itemId <= 1)
- break;
-
- item = player_node->getInvItem(itemId);
- if (!item)
- break;
-
- item->setEquipped(true);
- player_node->mEquipment->setArrows(item);
- logger->log("Arrows equipped: %i", itemId);
- break;
- }
-}
diff --git a/src/net/equipmenthandler.h b/src/net/equipmenthandler.h
deleted file mode 100644
index c9c65d67..00000000
--- a/src/net/equipmenthandler.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World 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.
- *
- * The Mana World 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 The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#ifndef _TMW_NET_EQUIPMENTHANDLER_H
-#define _TMW_NET_EQUIPMENTHANDLER_H
-
-#include "messagehandler.h"
-
-class EquipmentHandler : public MessageHandler
-{
- public:
- EquipmentHandler();
-
- void handleMessage(MessageIn &msg);
-};
-
-#endif
diff --git a/src/net/inventoryhandler.cpp b/src/net/inventoryhandler.cpp
index 40febee2..ce01c3dc 100644
--- a/src/net/inventoryhandler.cpp
+++ b/src/net/inventoryhandler.cpp
@@ -28,22 +28,17 @@
#include "messagein.h"
#include "protocol.h"
-#include "../resources/iteminfo.h"
+#include "../equipment.h"
+#include "../inventory.h"
#include "../item.h"
#include "../localplayer.h"
#include "../gui/chat.h"
+#include "../resources/iteminfo.h"
InventoryHandler::InventoryHandler()
{
static const Uint16 _messages[] = {
- /*
- SMSG_PLAYER_INVENTORY,
- SMSG_PLAYER_INVENTORY_ADD,
- SMSG_PLAYER_INVENTORY_REMOVE,
- SMSG_PLAYER_INVENTORY_USE,
- SMSG_ITEM_USE_RESPONSE,
- */
GPMSG_INVENTORY_FULL,
GPMSG_INVENTORY,
0
@@ -64,90 +59,18 @@ void InventoryHandler::handleMessage(MessageIn &msg)
{
int slot = msg.readByte();
int id = msg.readShort();
- if (slot >= 32)
+ if (slot < EQUIPMENT_SIZE)
+ {
+ player_node->mEquipment->setEquipment(slot, id);
+ }
+ else if (slot >= 32 && slot < 32 + INVENTORY_SIZE)
{
- int amount = msg.readByte();
+ int amount = id ? msg.readByte() : 0;
Item *it = player_node->getInvItem(slot - 32);
it->setId(id);
it->setQuantity(amount);
}
};
break;
-
-
-#if 0
- case SMSG_PLAYER_INVENTORY:
- // Only called on map load / warp. First reset all items
- // to not load them twice on map change.
- player_node->clearInventory();
- msg.readShort(); // length
- number = (msg.getLength() - 4) / 18;
-
- for (int loop = 0; loop < number; loop++)
- {
- index = msg.readShort();
- itemId = msg.readShort();
- msg.readByte(); // type
- msg.readByte(); // identify flag
- amount = msg.readShort();
-
- player_node->addInvItem(index, itemId, amount, false);
-
- // Trick because arrows are not considered equipment
- if (itemId == 1199 || itemId == 529)
- {
- player_node->getInvItem(index)->setEquipment(true);
- }
- }
- break;
-
- case SMSG_PLAYER_INVENTORY_ADD:
- index = msg.readShort();
- amount = msg.readShort();
- itemId = msg.readShort();
- msg.readByte(); // identify flag
- msg.readByte(); // attribute
- msg.readByte(); // refine
- equipType = msg.readShort();
- msg.readByte(); // type
-
- if (msg.readByte()> 0) {
- chatWindow->chatLog("Unable to pick up item", BY_SERVER);
- } else {
- const ItemInfo &itemInfo = ItemDB::get(itemId);
- chatWindow->chatLog("You picked up a " +
- itemInfo.getName(), BY_SERVER);
- player_node->addInvItem(index, itemId, amount, equipType != 0);
- }
- break;
-
- case SMSG_PLAYER_INVENTORY_REMOVE:
- index = msg.readShort();
- amount = msg.readShort();
- player_node->getInvItem(index)->increaseQuantity(-amount);
- break;
-
- case SMSG_PLAYER_INVENTORY_USE:
- index = msg.readShort();
- msg.readShort(); // item id
- msg.readLong(); // id
- amount = msg.readShort();
- msg.readByte(); // type
-
- player_node->getInvItem(index)->setQuantity(amount);
- break;
-
- case SMSG_ITEM_USE_RESPONSE:
- index = msg.readShort();
- amount = msg.readShort();
-
- if (msg.readByte() == 0) {
- chatWindow->chatLog("Failed to use item", BY_SERVER);
- } else {
- player_node->getInvItem(index)->setQuantity(amount);
- }
- break;
-#endif
-
}
}
diff --git a/src/net/protocol.h b/src/net/protocol.h
index 8af31dbb..a524304a 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -24,74 +24,6 @@
#ifndef _TMW_PROTOCOL_
#define _TMW_PROTOCOL_
-// Packets from server to client
-#define SMSG_LOGIN_SUCCESS 0x0073 /**< Contains starting location */
-#define SMSG_PLAYER_UPDATE_1 0x01d8
-#define SMSG_PLAYER_UPDATE_2 0x01d9
-#define SMSG_PLAYER_MOVE 0x01da /**< A nearby player moves */
-#define SMSG_PLAYER_STAT_UPDATE_1 0x00b0
-#define SMSG_PLAYER_STAT_UPDATE_2 0x00b1
-#define SMSG_PLAYER_STAT_UPDATE_3 0x0141
-#define SMSG_PLAYER_STAT_UPDATE_4 0x00bc
-#define SMSG_PLAYER_STAT_UPDATE_5 0x00bd
-#define SMSG_PLAYER_STAT_UPDATE_6 0x00be
-#define SMSG_WHO_ANSWER 0x00c2
-#define SMSG_PLAYER_WARP 0x0091 /**< Warp player to map/location */
-#define SMSG_PLAYER_INVENTORY 0x01ee
-#define SMSG_PLAYER_INVENTORY_ADD 0x00a0
-#define SMSG_PLAYER_INVENTORY_REMOVE 0x00af
-#define SMSG_PLAYER_INVENTORY_USE 0x01c8
-#define SMSG_PLAYER_EQUIPMENT 0x00a4
-#define SMSG_PLAYER_EQUIP 0x00aa
-#define SMSG_PLAYER_UNEQUIP 0x00ac
-#define SMSG_PLAYER_ATTACK_RANGE 0x013a
-#define SMSG_PLAYER_ARROW_EQUIP 0x013c
-#define SMSG_PLAYER_ARROW_MESSAGE 0x013b
-#define SMSG_PLAYER_SKILLS 0x010f
-#define SMSG_SKILL_FAILED 0x0110
-#define SMSG_ITEM_USE_RESPONSE 0x00a8
-#define SMSG_ITEM_VISIBLE 0x009d /**< An item is on the floor */
-#define SMSG_ITEM_DROPPED 0x009e /**< An item is dropped */
-#define SMSG_ITEM_REMOVE 0x00a1 /**< An item disappers */
-#define SMSG_BEING_VISIBLE 0x0078
-#define SMSG_BEING_MOVE 0x007b /**< A nearby monster moves */
-#define SMSG_BEING_REMOVE 0x0080
-#define SMSG_BEING_CHANGE_LOOKS 0x00c3
-#define SMSG_BEING_LEVELUP 0x019b
-#define SMSG_BEING_EMOTION 0x00c0
-#define SMSG_BEING_ACTION 0x008a /**< Attack, sit, stand up, ... */
-#define SMSG_BEING_CHAT 0x008d /**< A being talks */
-#define SMSG_BEING_NAME_RESPONSE 0x0095 /**< Has to be requested */
-#define SMSG_NPC_MESSAGE 0x00b4
-#define SMSG_NPC_NEXT 0x00b5
-#define SMSG_NPC_CLOSE 0x00b6
-#define SMSG_NPC_CHOICE 0x00b7 /**< Display a choice */
-#define SMSG_NPC_BUY_SELL_CHOICE 0x00c4
-#define SMSG_NPC_BUY 0x00c6
-#define SMSG_NPC_SELL 0x00c7
-#define SMSG_NPC_BUY_RESPONSE 0x00ca
-#define SMSG_NPC_SELL_RESPONSE 0x00cb
-#define SMSG_PLAYER_CHAT 0x008e /**< Player talks */
-#define SMSG_GM_CHAT 0x009a /**< GM announce */
-#define SMSG_WALK_RESPONSE 0x0087
-
-// Packets from client to server
-#define CMSG_ITEM_PICKUP 0x009f
-#define CMSG_MAP_LOADED 0x007d
-#define CMSG_NPC_BUY_REQUEST 0x00c8
-#define CMSG_NPC_BUY_SELL_REQUEST 0x00c5
-#define CMSG_CHAT_MESSAGE 0x008c
-#define CMSG_NPC_LIST_CHOICE 0x00b8
-#define CMSG_NPC_NEXT_REQUEST 0x00b9
-#define CMSG_NPC_SELL_REQUEST 0x00c9
-#define CMSG_SKILL_LEVELUP_REQUEST 0x0112
-#define CMSG_STAT_UPDATE_REQUEST 0x00bb
-#define CMSG_NPC_TALK 0x0090
-#define CMSG_PLAYER_INVENTORY_USE 0x00a7
-#define CMSG_PLAYER_INVENTORY_DROP 0x00a2
-#define CMSG_PLAYER_EQUIP 0x00a9
-#define CMSG_PLAYER_UNEQUIP 0x00ab
-
/**
* Enumerated type for communicated messages
* - PAMSG_*: from client to account server
@@ -146,6 +78,7 @@ enum {
PGMSG_PICKUP = 0x0110, // W*2 position
PGMSG_DROP = 0x0111, // B slot, B amount
PGMSG_EQUIP = 0x0112, // B slot
+ PGMSG_UNEQUIP = 0x0113, // B slot
GPMSG_INVENTORY = 0x0120, // { B slot, W item id [, B amount] }*
GPMSG_INVENTORY_FULL = 0x0121, // { B slot, W item id [, B amount] }*
GPMSG_PLAYER_ATTRIBUTE_UPDATE = 0x0130, // { W attribute, W value }*
diff --git a/src/net/skillhandler.cpp b/src/net/skillhandler.cpp
index 17dea606..50150ca8 100644
--- a/src/net/skillhandler.cpp
+++ b/src/net/skillhandler.cpp
@@ -34,8 +34,6 @@
SkillHandler::SkillHandler()
{
static const Uint16 _messages[] = {
- SMSG_PLAYER_SKILLS,
- SMSG_SKILL_FAILED,
0
};
handledMessages = _messages;
@@ -43,10 +41,9 @@ SkillHandler::SkillHandler()
void SkillHandler::handleMessage(MessageIn &msg)
{
- int skillCount;
-
switch (msg.getId())
{
+#if 0
case SMSG_PLAYER_SKILLS:
msg.readShort(); // length
skillCount = (msg.getLength() - 4) / 37;
@@ -91,5 +88,6 @@ void SkillHandler::handleMessage(MessageIn &msg)
}
chatWindow->chatLog(action);
break;
+#endif
}
}
diff --git a/src/net/tradehandler.cpp b/src/net/tradehandler.cpp
index 3bf312fc..edf1dff7 100644
--- a/src/net/tradehandler.cpp
+++ b/src/net/tradehandler.cpp
@@ -220,7 +220,7 @@ void TradeHandler::handleMessage(MessageIn &msg)
{
int type = msg.readShort();
int amount = msg.readByte();
- tradeWindow->addItem(type, false, amount, false);
+ tradeWindow->addItem(type, false, amount);
} break;
case GPMSG_TRADE_START: