Generate Notifier: Clear events once after all 'on generated' functions

This commit is contained in:
paramat 2018-03-02 13:39:39 +00:00 committed by paramat
parent b952d42000
commit 07622bf9b4
3 changed files with 14 additions and 6 deletions

@ -585,6 +585,12 @@ MapBlock *EmergeThread::finishGen(v3s16 pos, BlockMakeData *bmdata,
m_server->setAsyncFatalError("Lua: finishGen" + std::string(e.what())); 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)); EMERGE_DBG_OUT("ended up with: " << analyze_block(block));
/* /*

@ -1003,8 +1003,7 @@ bool GenerateNotifier::addEvent(GenNotifyType type, v3s16 pos, u32 id)
void GenerateNotifier::getEvents( void GenerateNotifier::getEvents(
std::map<std::string, std::vector<v3s16> > &event_map, std::map<std::string, std::vector<v3s16> > &event_map)
bool peek_events)
{ {
std::list<GenNotifyEvent>::iterator it; std::list<GenNotifyEvent>::iterator it;
@ -1016,8 +1015,11 @@ void GenerateNotifier::getEvents(
event_map[name].push_back(gn.pos); event_map[name].push_back(gn.pos);
} }
}
if (!peek_events)
void GenerateNotifier::clearEvents()
{
m_notify_events.clear(); m_notify_events.clear();
} }

@ -99,8 +99,8 @@ public:
void setNotifyOnDecoIds(std::set<u32> *notify_on_deco_ids); void setNotifyOnDecoIds(std::set<u32> *notify_on_deco_ids);
bool addEvent(GenNotifyType type, v3s16 pos, u32 id=0); bool addEvent(GenNotifyType type, v3s16 pos, u32 id=0);
void getEvents(std::map<std::string, std::vector<v3s16> > &event_map, void getEvents(std::map<std::string, std::vector<v3s16> > &event_map);
bool peek_events=false); void clearEvents();
private: private:
u32 m_notify_on = 0; u32 m_notify_on = 0;