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)
committerparamat <mat.gregory@virginmedia.com>
Sat, 3 Mar 2018 22:59:49 +0000 (22:59 +0000)
src/emerge.cpp
src/mapgen/mapgen.cpp
src/mapgen/mapgen.h

index ffe387f636c6d42b37e0e301a3929b129548056f..2778410531245d55182c177916f89c2e20f5de41 100644 (file)
@@ -585,6 +585,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 5e581086f5399f3aa9a773fd0d9fab09595dde4d..5f7a9d6cff9dea03475cd7fe6bda0ed9b1baa83d 100644 (file)
@@ -1003,8 +1003,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;
 
@@ -1016,9 +1015,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 6ca907573e2055b726f91b52136832ee4acdb7c7..2ebba68eab311d5f317f3c2f0732791c2fa7f5d4 100644 (file)
@@ -99,8 +99,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 = 0;