summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-04-10 15:16:27 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-04-10 15:16:27 +0300
commit5a4d8ffad3b172eae67844deda6b65273b7c9757 (patch)
tree70b32f31eaf824fec947d890377bf1e40555225c /src/inventory.cpp
parent08bbf9687742c0b159cc1d963ab470796f74c6c8 (diff)
downloadminetest-5a4d8ffad3b172eae67844deda6b65273b7c9757.tar.gz
minetest-5a4d8ffad3b172eae67844deda6b65273b7c9757.tar.bz2
minetest-5a4d8ffad3b172eae67844deda6b65273b7c9757.zip
implemented rats in new system to verify that it works
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index f9b9107a0..b14828ae2 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "debug.h"
#include <sstream>
#include "main.h"
+#include "serverobject.h"
/*
InventoryItem
@@ -90,6 +91,19 @@ InventoryItem* InventoryItem::deSerialize(std::istream &is)
}
}
+ServerActiveObject* InventoryItem::createSAO(ServerEnvironment *env, u16 id, v3f pos)
+{
+ /*
+ Create an ItemSAO
+ */
+ // Get item string
+ std::ostringstream os(std::ios_base::binary);
+ serialize(os);
+ // Create object
+ ServerActiveObject *obj = new ItemSAO(env, 0, pos, os.str());
+ return obj;
+}
+
/*
MaterialItem
*/
@@ -124,6 +138,48 @@ InventoryItem *MaterialItem::createCookResult()
CraftItem
*/
+#ifndef SERVER
+video::ITexture * CraftItem::getImage()
+{
+ if(g_texturesource == NULL)
+ return NULL;
+
+ std::string name;
+
+ if(m_subname == "Stick")
+ name = "stick.png";
+ else if(m_subname == "lump_of_coal")
+ name = "lump_of_coal.png";
+ else if(m_subname == "lump_of_iron")
+ name = "lump_of_iron.png";
+ else if(m_subname == "steel_ingot")
+ name = "steel_ingot.png";
+ else if(m_subname == "rat")
+ name = "rat.png";
+ else
+ name = "cloud.png";
+
+ // Get such a texture
+ //return g_irrlicht->getTexture(name);
+ return g_texturesource->getTextureRaw(name);
+}
+#endif
+
+ServerActiveObject* CraftItem::createSAO(ServerEnvironment *env, u16 id, v3f pos)
+{
+ // Special cases
+ if(m_subname == "rat")
+ {
+ ServerActiveObject *obj = new RatSAO(env, id, pos);
+ return obj;
+ }
+ // Default
+ else
+ {
+ return InventoryItem::createSAO(env, id, pos);
+ }
+}
+
bool CraftItem::isCookable()
{
if(m_subname == "lump_of_iron")
@@ -144,6 +200,7 @@ InventoryItem *CraftItem::createCookResult()
/*
MapBlockObjectItem
+ TODO: Remove
*/
#ifndef SERVER
video::ITexture * MapBlockObjectItem::getImage()