From d494733839e9cf6cb557462326ed21e7a58816c7 Mon Sep 17 00:00:00 2001 From: est31 Date: Tue, 9 Feb 2016 07:08:31 +0100 Subject: Add minetest.register_lbm() to run code on block load only --- src/nodedef.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/nodedef.cpp') diff --git a/src/nodedef.cpp b/src/nodedef.cpp index 1dd5aa537..ba9b4abf2 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -419,7 +419,7 @@ public: inline virtual const ContentFeatures& get(const MapNode &n) const; virtual bool getId(const std::string &name, content_t &result) const; virtual content_t getId(const std::string &name) const; - virtual void getIds(const std::string &name, std::set &result) const; + virtual bool getIds(const std::string &name, std::set &result) const; virtual const ContentFeatures& get(const std::string &name) const; content_t allocateId(); virtual content_t set(const std::string &name, const ContentFeatures &def); @@ -603,22 +603,23 @@ content_t CNodeDefManager::getId(const std::string &name) const } -void CNodeDefManager::getIds(const std::string &name, +bool CNodeDefManager::getIds(const std::string &name, std::set &result) const { //TimeTaker t("getIds", NULL, PRECISION_MICRO); if (name.substr(0,6) != "group:") { content_t id = CONTENT_IGNORE; - if(getId(name, id)) + bool exists = getId(name, id); + if (exists) result.insert(id); - return; + return exists; } std::string group = name.substr(6); std::map::const_iterator i = m_group_to_items.find(group); if (i == m_group_to_items.end()) - return; + return true; const GroupItems &items = i->second; for (GroupItems::const_iterator j = items.begin(); @@ -627,6 +628,7 @@ void CNodeDefManager::getIds(const std::string &name, result.insert((*j).first); } //printf("getIds: %dus\n", t.stop()); + return true; } -- cgit v1.2.3