summaryrefslogtreecommitdiff
path: root/src/game-server/item.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <mana@crushnet.org>2010-05-09 17:03:47 +0200
committerPhilipp Sehmisch <mana@crushnet.org>2010-05-09 17:03:47 +0200
commitcfff8488b15d00d6f7e3e7bf6cf9723c1fe91d0b (patch)
treef1e0e62fa8c06d859f3d9d4b9c8b5cf4cbdbd013 /src/game-server/item.cpp
parent1ef56bda12f9f18f0c91903b330e0422cfd98793 (diff)
downloadmanaserv-cfff8488b15d00d6f7e3e7bf6cf9723c1fe91d0b.tar.gz
manaserv-cfff8488b15d00d6f7e3e7bf6cf9723c1fe91d0b.tar.bz2
manaserv-cfff8488b15d00d6f7e3e7bf6cf9723c1fe91d0b.tar.xz
manaserv-cfff8488b15d00d6f7e3e7bf6cf9723c1fe91d0b.zip
Floor items are now removed after a (configurable) time.
Reviewed-by: Thorbjorn Lindeijer
Diffstat (limited to 'src/game-server/item.cpp')
-rw-r--r--src/game-server/item.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/game-server/item.cpp b/src/game-server/item.cpp
index 2737be04..91d847d7 100644
--- a/src/game-server/item.cpp
+++ b/src/game-server/item.cpp
@@ -24,9 +24,12 @@
#include "game-server/item.hpp"
+#include "common/configuration.hpp"
#include "game-server/being.hpp"
+#include "game-server/state.hpp"
#include "scripting/script.hpp"
+
ItemType itemTypeFromString (const std::string &name)
{
static std::map<const std::string, ItemType> table;
@@ -130,3 +133,22 @@ bool ItemClass::use(Being *itemUser)
mModifiers.applyAttributes(itemUser);
return true;
}
+
+
+Item::Item(ItemClass *type, int amount)
+ : Actor(OBJECT_ITEM), mType(type), mAmount(amount)
+{
+ mLifetime = Configuration::getValue("floorItemDecayTime", 0) * 10;
+}
+
+void Item::update()
+{
+ if (mLifetime)
+ {
+ mLifetime--;
+ if (!mLifetime)
+ {
+ GameState::enqueueRemove(this);
+ }
+ }
+}