aboutsummaryrefslogtreecommitdiff
path: root/src/content_nodemeta.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-09-26 11:57:28 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-09-26 11:57:28 +0300
commit0ccc0ac927bdbfcc97c1b5c9d5dc64754946f817 (patch)
tree0db7c756fbcfd18497dee04578d7cb037b2bd7fa /src/content_nodemeta.cpp
parent63eca0feb2a08aa15f8be1164c4815a44246a2e6 (diff)
parent8b875d71d1ab928e9866914b886ff58cf8a38192 (diff)
downloadminetest-0ccc0ac927bdbfcc97c1b5c9d5dc64754946f817.tar.gz
minetest-0ccc0ac927bdbfcc97c1b5c9d5dc64754946f817.tar.bz2
minetest-0ccc0ac927bdbfcc97c1b5c9d5dc64754946f817.zip
Merge remote-tracking branch 'darkrose/master'
Diffstat (limited to 'src/content_nodemeta.cpp')
-rw-r--r--src/content_nodemeta.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/content_nodemeta.cpp b/src/content_nodemeta.cpp
index 1552c8e15..e79ff6d54 100644
--- a/src/content_nodemeta.cpp
+++ b/src/content_nodemeta.cpp
@@ -118,6 +118,70 @@ std::string ChestNodeMetadata::getInventoryDrawSpecString()
}
/*
+ LockingChestNodeMetadata
+*/
+
+// Prototype
+LockingChestNodeMetadata proto_LockingChestNodeMetadata;
+
+LockingChestNodeMetadata::LockingChestNodeMetadata()
+{
+ NodeMetadata::registerType(typeId(), create);
+
+ m_inventory = new Inventory();
+ m_inventory->addList("0", 8*4);
+}
+LockingChestNodeMetadata::~LockingChestNodeMetadata()
+{
+ delete m_inventory;
+}
+u16 LockingChestNodeMetadata::typeId() const
+{
+ return CONTENT_LOCKABLE_CHEST;
+}
+NodeMetadata* LockingChestNodeMetadata::create(std::istream &is)
+{
+ LockingChestNodeMetadata *d = new LockingChestNodeMetadata();
+ d->setOwner(deSerializeString(is));
+ d->m_inventory->deSerialize(is);
+ return d;
+}
+NodeMetadata* LockingChestNodeMetadata::clone()
+{
+ LockingChestNodeMetadata *d = new LockingChestNodeMetadata();
+ *d->m_inventory = *m_inventory;
+ return d;
+}
+void LockingChestNodeMetadata::serializeBody(std::ostream &os)
+{
+ os<<serializeString(m_text);
+ m_inventory->serialize(os);
+}
+std::string LockingChestNodeMetadata::infoText()
+{
+ return "Locking Chest";
+}
+bool LockingChestNodeMetadata::nodeRemovalDisabled()
+{
+ /*
+ Disable removal if chest contains something
+ */
+ InventoryList *list = m_inventory->getList("0");
+ if(list == NULL)
+ return false;
+ if(list->getUsedSlots() == 0)
+ return false;
+ return true;
+}
+std::string LockingChestNodeMetadata::getInventoryDrawSpecString()
+{
+ return
+ "invsize[8,9;]"
+ "list[current_name;0;0,0;8,4;]"
+ "list[current_player;main;0,5;8,4;]";
+}
+
+/*
FurnaceNodeMetadata
*/