mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
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
This commit is contained in:
parent
2b119e1e19
commit
5062b99cb0
19 changed files with 436 additions and 329 deletions
40
src/mapgen.h
40
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue