Generate Notifier: Clear events once after all 'on generated' functions
authorparamat <paramat@users.noreply.github.com>
Fri, 2 Mar 2018 13:39:39 +0000 (13:39 +0000)
committerSmallJoker <mk939@ymail.com>
Sun, 3 Jun 2018 15:32:00 +0000 (17:32 +0200)
src/emerge.cpp
src/mapgen.cpp
src/mapgen.h

index d24971e44a099490dfaeca4938d7c618e0c3343d..f7f6ff603832d4f3ee15ba4f9557310e288e7bc8 100644 (file)
@@ -570,6 +570,12 @@ MapBlock *EmergeThread::finishGen(v3s16 pos, BlockMakeData *bmdata,
                m_server->setAsyncFatalError("Lua: finishGen" + std::string(e.what()));
        }
 
+       /*
+               Clear generate notifier events
+       */
+       Mapgen *mg = m_emerge->getCurrentMapgen();
+       mg->gennotify.clearEvents();
+
        EMERGE_DBG_OUT("ended up with: " << analyze_block(block));
 
        /*
index cb0100722ef8a616245894a922a4fde20941b64a..6fe2906bbb9452492ded51912f3fd3c0b6e2d31a 100644 (file)
@@ -982,8 +982,7 @@ bool GenerateNotifier::addEvent(GenNotifyType type, v3s16 pos, u32 id)
 
 
 void GenerateNotifier::getEvents(
-       std::map<std::string, std::vector<v3s16> > &event_map,
-       bool peek_events)
+       std::map<std::string, std::vector<v3s16> > &event_map)
 {
        std::list<GenNotifyEvent>::iterator it;
 
@@ -995,9 +994,12 @@ void GenerateNotifier::getEvents(
 
                event_map[name].push_back(gn.pos);
        }
+}
+
 
-       if (!peek_events)
-               m_notify_events.clear();
+void GenerateNotifier::clearEvents()
+{
+       m_notify_events.clear();
 }
 
 
index d1845d598f1deb6380b05cc1608e4dca32f41201..4e0d75b39ff3bafb5c75304bdc60596413c8a792 100644 (file)
@@ -101,8 +101,8 @@ public:
        void setNotifyOnDecoIds(std::set<u32> *notify_on_deco_ids);
 
        bool addEvent(GenNotifyType type, v3s16 pos, u32 id=0);
-       void getEvents(std::map<std::string, std::vector<v3s16> > &event_map,
-               bool peek_events=false);
+       void getEvents(std::map<std::string, std::vector<v3s16> > &event_map);
+       void clearEvents();
 
 private:
        u32 m_notify_on;