summaryrefslogtreecommitdiff
path: root/src/mapgen.h
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2014-12-06 04:18:04 -0500
committerkwolekr <kwolekr@minetest.net>2014-12-06 13:53:35 -0500
commit5062b99cb0d252d9e377ff4560f7ecc9e66fd558 (patch)
tree3474c0734aac243cabfcf3af763becb4025da35b /src/mapgen.h
parent2b119e1e192ead701e69e261fe94ccb7382dbee7 (diff)
downloadminetest-5062b99cb0d252d9e377ff4560f7ecc9e66fd558.tar.gz
minetest-5062b99cb0d252d9e377ff4560f7ecc9e66fd558.tar.bz2
minetest-5062b99cb0d252d9e377ff4560f7ecc9e66fd558.zip
Rewrite generate notification mechanism
Add support for notify-on-decoration Clean up mapgen constructors Clean up mapgen.cpp code style somewhat Remove trailing whitespace from some files
Diffstat (limited to 'src/mapgen.h')
-rw-r--r--src/mapgen.h40
1 files changed, 33 insertions, 7 deletions
diff --git a/src/mapgen.h b/src/mapgen.h
index cf2120a7a..9cdb157e1 100644
--- a/src/mapgen.h
+++ b/src/mapgen.h
@@ -34,8 +34,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define MG_FLAT 0x08
#define MG_LIGHT 0x10
-#define NUM_GEN_NOTIFY 6
-
class Settings;
class ManualMapVoxelManipulator;
class INodeDefManager;
@@ -61,13 +59,39 @@ enum MapgenObject {
MGOBJ_GENNOTIFY
};
-enum GenNotify {
+enum GenNotifyType {
GENNOTIFY_DUNGEON,
GENNOTIFY_TEMPLE,
GENNOTIFY_CAVE_BEGIN,
GENNOTIFY_CAVE_END,
GENNOTIFY_LARGECAVE_BEGIN,
- GENNOTIFY_LARGECAVE_END
+ GENNOTIFY_LARGECAVE_END,
+ GENNOTIFY_DECORATION,
+ NUM_GENNOTIFY_TYPES
+};
+
+struct GenNotifyEvent {
+ GenNotifyType type;
+ v3s16 pos;
+ u32 id;
+};
+
+class GenerateNotifier {
+public:
+ GenerateNotifier();
+ GenerateNotifier(u32 notify_on, std::set<u32> *notify_on_deco_ids);
+
+ void setNotifyOn(u32 notify_on);
+ 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);
+
+private:
+ u32 m_notify_on;
+ std::set<u32> *m_notify_on_deco_ids;
+ std::list<GenNotifyEvent> m_notify_events;
};
struct MapgenSpecificParams {
@@ -85,7 +109,8 @@ struct MapgenParams {
MapgenSpecificParams *sparams;
- MapgenParams() {
+ MapgenParams()
+ {
mg_name = DEFAULT_MAPGEN;
seed = 0;
water_level = 1;
@@ -99,6 +124,7 @@ class Mapgen {
public:
int seed;
int water_level;
+ u32 flags;
bool generating;
int id;
ManualMapVoxelManipulator *vm;
@@ -108,10 +134,10 @@ public:
u8 *biomemap;
v3s16 csize;
- u32 gennotify;
- std::vector<v3s16> *gen_notifications[NUM_GEN_NOTIFY];
+ GenerateNotifier gennotify;
Mapgen();
+ Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge);
virtual ~Mapgen();
s16 findGroundLevelFull(v2s16 p2d);