summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/manaserv.xml9
-rw-r--r--src/game-server/item.cpp22
-rw-r--r--src/game-server/item.hpp11
3 files changed, 35 insertions, 7 deletions
diff --git a/docs/manaserv.xml b/docs/manaserv.xml
index 2203097d..13be95d2 100644
--- a/docs/manaserv.xml
+++ b/docs/manaserv.xml
@@ -1,9 +1,11 @@
<?xml version="1.0"?>
<!--
An example configuration file for ~/.manaserv.xml
- If you add any parameters to this configuration file make sure to update
- the wiki documentation at:
- http://wiki.themanaworld.org/index.php/Manaserv.xml
+
+ Documentation: http://doc.manasource.org/manaserv.xml
+
+ Developers: If you add any new parameters read from this configuration file
+ don't forget to update the wiki documentation!
-->
<configuration>
@@ -77,6 +79,7 @@
<option name="respawnX" value="1000"/>
<option name="respawnY" value="1000"/>
<option name="defaultPvp" value="free" />
+ <option name="floorItemDecayTime" value="60" />
<!-- Network-related config options-->
<option name="net_maxClients" value="1000"/>
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);
+ }
+ }
+}
diff --git a/src/game-server/item.hpp b/src/game-server/item.hpp
index 777f5057..4aa84c9c 100644
--- a/src/game-server/item.hpp
+++ b/src/game-server/item.hpp
@@ -269,12 +269,14 @@ class ItemClass
unsigned mAttackRange; /**< Attack range when used as a weapon */
};
+/**
+* Class for an item stack laying on the floor in the game world
+*/
+
class Item : public Actor
{
public:
- Item(ItemClass *type, int amount)
- : Actor(OBJECT_ITEM), mType(type), mAmount(amount)
- {}
+ Item(ItemClass *type, int amount);
ItemClass *getItemClass() const
{ return mType; }
@@ -282,11 +284,12 @@ class Item : public Actor
int getAmount() const
{ return mAmount; }
- virtual void update() {}
+ virtual void update();
private:
ItemClass *mType;
unsigned char mAmount;
+ int mLifetime;
};
#endif