Skip to content

Commit 07622bf

Browse files
committedMar 3, 2018
Generate Notifier: Clear events once after all 'on generated' functions
1 parent b952d42 commit 07622bf

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed
 

‎src/emerge.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,12 @@ MapBlock *EmergeThread::finishGen(v3s16 pos, BlockMakeData *bmdata,
585585
m_server->setAsyncFatalError("Lua: finishGen" + std::string(e.what()));
586586
}
587587

588+
/*
589+
Clear generate notifier events
590+
*/
591+
Mapgen *mg = m_emerge->getCurrentMapgen();
592+
mg->gennotify.clearEvents();
593+
588594
EMERGE_DBG_OUT("ended up with: " << analyze_block(block));
589595

590596
/*

‎src/mapgen/mapgen.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -1003,8 +1003,7 @@ bool GenerateNotifier::addEvent(GenNotifyType type, v3s16 pos, u32 id)
10031003

10041004

10051005
void GenerateNotifier::getEvents(
1006-
std::map<std::string, std::vector<v3s16> > &event_map,
1007-
bool peek_events)
1006+
std::map<std::string, std::vector<v3s16> > &event_map)
10081007
{
10091008
std::list<GenNotifyEvent>::iterator it;
10101009

@@ -1016,9 +1015,12 @@ void GenerateNotifier::getEvents(
10161015

10171016
event_map[name].push_back(gn.pos);
10181017
}
1018+
}
1019+
10191020

1020-
if (!peek_events)
1021-
m_notify_events.clear();
1021+
void GenerateNotifier::clearEvents()
1022+
{
1023+
m_notify_events.clear();
10221024
}
10231025

10241026

‎src/mapgen/mapgen.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ class GenerateNotifier {
9999
void setNotifyOnDecoIds(std::set<u32> *notify_on_deco_ids);
100100

101101
bool addEvent(GenNotifyType type, v3s16 pos, u32 id=0);
102-
void getEvents(std::map<std::string, std::vector<v3s16> > &event_map,
103-
bool peek_events=false);
102+
void getEvents(std::map<std::string, std::vector<v3s16> > &event_map);
103+
void clearEvents();
104104

105105
private:
106106
u32 m_notify_on = 0;

0 commit comments

Comments
 (0)
Please sign in to comment.