summaryrefslogtreecommitdiff
path: root/src/net
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/net
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/net')
-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
7 files changed, 15 insertions, 416 deletions
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: