X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fmapgen.h;h=8c34a9719bb106c4f676c640c6ee0ad204fbfd26;hb=5f489efc69e5e8e31891481d412ad569a6e1bcf8;hp=b18bfb9309d480a562c8f45191e35b9306fa5297;hpb=38abc91802ec12996d4fbb1e2f0ba4365d86b545;p=oweals%2Fminetest.git diff --git a/src/mapgen.h b/src/mapgen.h index b18bfb930..8c34a9719 100644 --- a/src/mapgen.h +++ b/src/mapgen.h @@ -1,6 +1,8 @@ /* Minetest -Copyright (C) 2010-2013 celeron55, Perttu Ahola +Copyright (C) 2010-2015 celeron55, Perttu Ahola +Copyright (C) 2013-2016 kwolekr, Ryan Kwolek +Copyright (C) 2015-2017 paramat This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -17,12 +19,10 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef MAPGEN_HEADER -#define MAPGEN_HEADER +#pragma once #include "noise.h" #include "nodedef.h" -#include "mapnode.h" #include "util/string.h" #include "util/container.h" @@ -77,11 +77,11 @@ enum GenNotifyType { NUM_GENNOTIFY_TYPES }; -// TODO(hmmmm/paramat): make stone type selection dynamic enum MgStoneType { MGSTONE_STONE, MGSTONE_DESERT_STONE, MGSTONE_SANDSTONE, + MGSTONE_OTHER, }; struct GenNotifyEvent { @@ -92,7 +92,7 @@ struct GenNotifyEvent { class GenerateNotifier { public: - GenerateNotifier(); + GenerateNotifier() = default; GenerateNotifier(u32 notify_on, std::set *notify_on_deco_ids); void setNotifyOn(u32 notify_on); @@ -103,7 +103,7 @@ public: bool peek_events=false); private: - u32 m_notify_on; + u32 m_notify_on = 0; std::set *m_notify_on_deco_ids; std::list m_notify_events; }; @@ -116,32 +116,38 @@ enum MapgenType { MAPGEN_FRACTAL, MAPGEN_VALLEYS, MAPGEN_SINGLENODE, + MAPGEN_CARPATHIAN, MAPGEN_INVALID, }; struct MapgenParams { - MapgenType mgtype; - s16 chunksize; - u64 seed; - s16 water_level; - u32 flags; - - BiomeParams *bparams; - - MapgenParams() : - mgtype(MAPGEN_DEFAULT), - chunksize(5), - seed(0), - water_level(1), - flags(MG_CAVES | MG_LIGHT | MG_DECORATIONS), - bparams(NULL) - { - } - + MapgenParams() = default; virtual ~MapgenParams(); + MapgenType mgtype = MAPGEN_DEFAULT; + s16 chunksize = 5; + u64 seed = 0; + s16 water_level = 1; + s16 mapgen_limit = MAX_MAP_GENERATION_LIMIT; + u32 flags = MG_CAVES | MG_LIGHT | MG_DECORATIONS; + + BiomeParams *bparams = nullptr; + + s16 mapgen_edge_min = -MAX_MAP_GENERATION_LIMIT; + s16 mapgen_edge_max = MAX_MAP_GENERATION_LIMIT; + virtual void readParams(const Settings *settings); virtual void writeParams(Settings *settings) const; + + bool saoPosOverLimit(const v3f &p); + s32 getSpawnRangeMax(); + +private: + void calcMapgenEdges(); + + float m_sao_limit_min = -MAX_MAP_GENERATION_LIMIT * BS; + float m_sao_limit_max = MAX_MAP_GENERATION_LIMIT * BS; + bool m_mapgen_edges_calculated = false; }; @@ -156,26 +162,28 @@ struct MapgenParams { */ class Mapgen { public: - s32 seed; - int water_level; - u32 flags; - bool generating; - int id; + s32 seed = 0; + int water_level = 0; + int mapgen_limit = 0; + u32 flags = 0; + bool generating = false; + int id = -1; - MMVManip *vm; - INodeDefManager *ndef; + MMVManip *vm = nullptr; + INodeDefManager *ndef = nullptr; u32 blockseed; - s16 *heightmap; - biome_t *biomemap; + s16 *heightmap = nullptr; + biome_t *biomemap = nullptr; v3s16 csize; - BiomeGen *biomegen; + BiomeGen *biomegen = nullptr; GenerateNotifier gennotify; - Mapgen(); + Mapgen() = default; Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge); - virtual ~Mapgen(); + virtual ~Mapgen() = default; + DISABLE_CLASS_COPY(Mapgen); virtual MapgenType getType() const { return MAPGEN_INVALID; } @@ -217,7 +225,6 @@ private: // that checks whether there are floodable nodes without liquid beneath // the node at index vi. inline bool isLiquidHorizontallyFlowable(u32 vi, v3s16 em); - DISABLE_CLASS_COPY(Mapgen); }; /* @@ -240,8 +247,11 @@ public: virtual ~MapgenBasic(); virtual void generateCaves(s16 max_stone_y, s16 large_cave_depth); - virtual void generateDungeons(s16 max_stone_y, MgStoneType stone_type); - virtual MgStoneType generateBiomes(); + virtual bool generateCaverns(s16 max_stone_y); + virtual void generateDungeons(s16 max_stone_y, + MgStoneType stone_type, content_t biome_stone); + virtual void generateBiomes(MgStoneType *mgstone_type, + content_t *biome_stone, s16 biome_zero_level); virtual void dustTopNodes(); protected: @@ -257,17 +267,19 @@ protected: // Content required for generateBiomes content_t c_stone; - content_t c_water_source; - content_t c_river_water_source; content_t c_desert_stone; content_t c_sandstone; + content_t c_water_source; + content_t c_river_water_source; + content_t c_lava_source; // Content required for generateDungeons content_t c_cobble; content_t c_stair_cobble; content_t c_mossycobble; + content_t c_stair_desert_stone; content_t c_sandstonebrick; - content_t c_stair_sandstonebrick; + content_t c_stair_sandstone_block; int ystride; int zstride; @@ -278,7 +290,10 @@ protected: NoiseParams np_cave1; NoiseParams np_cave2; + NoiseParams np_cavern; float cave_width; + float cavern_limit; + float cavern_taper; + float cavern_threshold; + int lava_depth; }; - -#endif