diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-12-03 13:46:19 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-12-03 13:46:19 +0200 |
commit | e494b5d422609b9ed9f79cc39b401f40b6a3ec9a (patch) | |
tree | 27608c569d940616f7a704a473e028d5555365b2 /src/content_cao.cpp | |
parent | fdf7b3bcdfd62aab2563d92b728e98b3518bbc52 (diff) | |
download | minetest-e494b5d422609b9ed9f79cc39b401f40b6a3ec9a.tar.gz minetest-e494b5d422609b9ed9f79cc39b401f40b6a3ec9a.tar.bz2 minetest-e494b5d422609b9ed9f79cc39b401f40b6a3ec9a.zip |
Show infotext for unknown items placed on ground
Diffstat (limited to 'src/content_cao.cpp')
-rw-r--r-- | src/content_cao.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp index da68004ce..0531fe489 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -183,12 +183,16 @@ public: {return &m_selection_box;} v3f getPosition() {return m_position;} + + std::string infoText() + {return m_infotext;} private: core::aabbox3d<f32> m_selection_box; scene::IMeshSceneNode *m_node; v3f m_position; std::string m_inventorystring; + std::string m_infotext; }; /* @@ -530,7 +534,10 @@ ItemCAO::ItemCAO(IGameDef *gamedef, ClientEnvironment *env): m_node(NULL), m_position(v3f(0,10*BS,0)) { - ClientActiveObject::registerType(getType(), create); + if(!gamedef && !env) + { + ClientActiveObject::registerType(getType(), create); + } } ItemCAO::~ItemCAO() @@ -694,6 +701,23 @@ void ItemCAO::initialize(const std::string &data) } updateNodePos(); + + /* + Set infotext to item name if item cannot be deserialized + */ + try{ + InventoryItem *item = NULL; + item = InventoryItem::deSerialize(m_inventorystring, m_gamedef); + if(item){ + if(!item->isKnown()) + m_infotext = "Unknown item: '" + m_inventorystring + "'"; + } + delete item; + } + catch(SerializationError &e) + { + m_infotext = "Unknown item: '" + m_inventorystring + "'"; + } } /* |