From 7a29b14a20b16b97fd0d97d9f305fe0d53c160bf Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Wed, 16 Nov 2011 14:36:33 +0200 Subject: Improved MaterialItem (stores nodename) --- src/inventory.h | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'src/inventory.h') diff --git a/src/inventory.h b/src/inventory.h index b9de48f9a..32e1cd93e 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -127,11 +127,9 @@ protected: class MaterialItem : public InventoryItem { public: - MaterialItem(IGameDef *gamedef, content_t content, u16 count): - InventoryItem(gamedef, count) - { - m_content = content; - } + MaterialItem(IGameDef *gamedef, std::string nodename, u16 count); + // Legacy constructor + MaterialItem(IGameDef *gamedef, content_t content, u16 count); /* Implementation interface */ @@ -141,16 +139,26 @@ public: } virtual void serialize(std::ostream &os) const { - //os.imbue(std::locale("C")); - os<<"MaterialItem2"; + std::string nodename = m_nodename; + if(nodename == "") + nodename = "unknown_block"; + + os<<"MaterialItem3"; + os<<" \""; + os<getName()) != "MaterialItem") return false; MaterialItem *m = (MaterialItem*)other; - if(m->getMaterial() != m_content) + if(m->m_nodename != m_nodename) return false; return true; } @@ -185,14 +193,13 @@ public: float getCookTime() const; float getBurnTime() const; /* - Special methods + Special properties (not part of virtual interface) */ - content_t getMaterial() - { - return m_content; - } + std::string getNodeName() const + { return m_nodename; } + content_t getMaterial() const; private: - content_t m_content; + std::string m_nodename; }; /* -- cgit v1.2.3