summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-07-27 15:51:23 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-07-27 15:51:23 +0200
commit000979800f13964ba70507ee569f458a7fdd270a (patch)
tree29c90d4d908b51ba7489e79260e3070d47c0578f
parent92b7eecfb56c0f2e26d2cdd7eafad2f7fd88808a (diff)
downloadmanaserv-000979800f13964ba70507ee569f458a7fdd270a.tar.gz
manaserv-000979800f13964ba70507ee569f458a7fdd270a.tar.bz2
manaserv-000979800f13964ba70507ee569f458a7fdd270a.tar.xz
manaserv-000979800f13964ba70507ee569f458a7fdd270a.zip
Finished the inventory check, by dropping items
in oversized inventories.
-rw-r--r--src/game-server/inventory.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/game-server/inventory.cpp b/src/game-server/inventory.cpp
index f0a6fcc1..4f08fc67 100644
--- a/src/game-server/inventory.cpp
+++ b/src/game-server/inventory.cpp
@@ -25,6 +25,7 @@
#include "game-server/inventory.h"
#include "game-server/item.h"
#include "game-server/itemmanager.h"
+#include "game-server/state.h"
#include "net/messageout.h"
#include "utils/logger.h"
@@ -145,9 +146,9 @@ void Inventory::checkInventorySize()
/*
* Check that the inventory size is greater than or equal to the size
* needed.
- * If not, forcibly delete (drop?) items from the end until it is.
+ * If not, forcibly drop items from the end until it is.
* Check that inventory capacity is greater than or equal to zero.
- * If not, forcibly delete (drop?) items from the end until it is.
+ * If not, forcibly drop items from the end until it is.
*/
while (mPoss->inventory.size() > INVENTORY_SLOTS
|| mCharacter->getModifiedAttribute(ATTR_INV_CAPACITY) < 0)
@@ -161,9 +162,24 @@ void Inventory::checkInventorySize()
<< "' of character '"
<< mCharacter->getName()
<< "'!");
- // FIXME Should probably be dropped rather than deleted.
+
+ // Remove the items from inventory
removeFromSlot(mPoss->inventory.rbegin()->first,
mPoss->inventory.rbegin()->second.amount);
+
+ // Drop them on the floor
+ ItemClass *ic = itemManager->getItem(mPoss->inventory.rbegin()->first);
+ int nb = mPoss->inventory.rbegin()->second.amount;
+ Item *item = new Item(ic, nb);
+ item->setMap(mCharacter->getMap());
+ item->setPosition(mCharacter->getPosition());
+ if (!GameState::insert(item))
+ {
+ // Warn about drop failure
+ LOG_WARN("Impossible to drop " << nb << " item(s) id: "
+ << ic->getDatabaseID() << " for character: '"
+ << mCharacter->getName() << "'!");
+ }
}
}