summaryrefslogtreecommitdiff
path: root/src/game-server/gamehandler.cpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-01-05 09:47:12 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-01-05 09:47:12 +0000
commit7465e9bf8fe03961c02b360002439c1072090bf0 (patch)
tree9e25884ea13a29e370625ddf51c7eedb6326931b /src/game-server/gamehandler.cpp
parent59e483ca6d2ec680f438787b4b3213534380c871 (diff)
downloadmanaserv-7465e9bf8fe03961c02b360002439c1072090bf0.tar.gz
manaserv-7465e9bf8fe03961c02b360002439c1072090bf0.tar.bz2
manaserv-7465e9bf8fe03961c02b360002439c1072090bf0.tar.xz
manaserv-7465e9bf8fe03961c02b360002439c1072090bf0.zip
Implemented item dropping.
Diffstat (limited to 'src/game-server/gamehandler.cpp')
-rw-r--r--src/game-server/gamehandler.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index 6c9786ff..4d963129 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -26,6 +26,7 @@
#include "game-server/gamehandler.hpp"
#include "game-server/item.hpp"
+#include "game-server/itemmanager.hpp"
#include "game-server/map.hpp"
#include "game-server/mapcomposite.hpp"
#include "game-server/state.hpp"
@@ -252,15 +253,33 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
if (o->getType() == OBJECT_ITEM && opos.x == x && opos.y == y)
{
result.writeShort(GPMSG_INVENTORY);
- ItemClass *item = static_cast< Item * >(o)->getItemClass();
- Inventory(computer.character, result).insert(item->getDatabaseID(), 1);
- gameState->remove(o);
+ Item *item = static_cast< Item * >(o);
+ ItemClass *ic = item->getItemClass();
+ Inventory(computer.character, result)
+ .insert(ic->getDatabaseID(), item->getAmount());
+ gameState->remove(item);
break;
}
}
}
} break;
+ case PGMSG_DROP:
+ {
+ int slot = message.readByte();
+ int amount = message.readByte();
+ Inventory inv(computer.character, result);
+ if (ItemClass *ic = itemManager->getItem(inv.getItem(slot)))
+ {
+ result.writeShort(GPMSG_INVENTORY);
+ int nb = inv.removeFromSlot(slot, amount);
+ Item *item = new Item(ic, amount - nb);
+ item->setMapId(computer.character->getMapId());
+ item->setPosition(computer.character->getPosition());
+ gameState->insert(item);
+ }
+ } break;
+
case PGMSG_WALK:
{
int x = message.readShort();