]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/inventory.cpp
easier notice on old version
[dragonfireclient.git] / src / inventory.cpp
index fec51a759e581617db89f43eef9bb494ef82f949..ca050614fd5254de05a16729718354d009a40ff4 100644 (file)
@@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "content_mapnode.h"
 #include "content_inventory.h"
 #include "content_sao.h"
+#include "player.h"
 
 /*
        InventoryItem
@@ -61,7 +62,7 @@ InventoryItem* InventoryItem::deSerialize(std::istream &is)
                is>>material;
                u16 count;
                is>>count;
-               if(material > 255)
+               if(material > MAX_CONTENT)
                        throw SerializationError("Too large material number");
                return new MaterialItem(material, count);
        }
@@ -168,6 +169,20 @@ InventoryItem *CraftItem::createCookResult()
        return item_craft_create_cook_result(m_subname);
 }
 
+bool CraftItem::use(ServerEnvironment *env, Player *player)
+{
+       if(item_craft_is_eatable(m_subname))
+       {
+               s16 hp_change = item_craft_eat_hp_change(m_subname);
+               if(player->hp + hp_change > 20)
+                       player->hp = 20;
+               else
+                       player->hp += hp_change;
+               return true;
+       }
+       return false;
+}
+
 /*
        MapBlockObjectItem DEPRECATED
        TODO: Remove