Skip to content

Commit

Permalink
Generate Notifier: Clear events once after all 'on generated' functions
Browse files Browse the repository at this point in the history
  • Loading branch information
paramat committed Mar 3, 2018
1 parent b952d42 commit 07622bf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/emerge.cpp
Expand Up @@ -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));

/*
Expand Down
10 changes: 6 additions & 4 deletions src/mapgen/mapgen.cpp
Expand Up @@ -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;

Expand All @@ -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();
}


Expand Down
4 changes: 2 additions & 2 deletions src/mapgen/mapgen.h
Expand Up @@ -99,8 +99,8 @@ class GenerateNotifier {
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;
Expand Down

0 comments on commit 07622bf

Please sign in to comment.