mapgen_v6.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. Minetest
  3. Copyright (C) 2010-2018 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. Copyright (C) 2013-2018 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
  5. Copyright (C) 2014-2018 paramat
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU Lesser General Public License as published by
  8. the Free Software Foundation; either version 2.1 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU Lesser General Public License for more details.
  14. You should have received a copy of the GNU Lesser General Public License along
  15. with this program; if not, write to the Free Software Foundation, Inc.,
  16. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #pragma once
  19. #include "mapgen.h"
  20. #include "noise.h"
  21. #define MGV6_AVERAGE_MUD_AMOUNT 4
  22. #define MGV6_DESERT_STONE_BASE -32
  23. #define MGV6_ICE_BASE 0
  24. #define MGV6_FREQ_HOT 0.4
  25. #define MGV6_FREQ_SNOW -0.4
  26. #define MGV6_FREQ_TAIGA 0.5
  27. #define MGV6_FREQ_JUNGLE 0.5
  28. //////////// Mapgen V6 flags
  29. #define MGV6_JUNGLES 0x01
  30. #define MGV6_BIOMEBLEND 0x02
  31. #define MGV6_MUDFLOW 0x04
  32. #define MGV6_SNOWBIOMES 0x08
  33. #define MGV6_FLAT 0x10
  34. #define MGV6_TREES 0x20
  35. #define MGV6_TEMPLES 0x40
  36. extern FlagDesc flagdesc_mapgen_v6[];
  37. enum BiomeV6Type
  38. {
  39. BT_NORMAL,
  40. BT_DESERT,
  41. BT_JUNGLE,
  42. BT_TUNDRA,
  43. BT_TAIGA,
  44. };
  45. struct MapgenV6Params : public MapgenParams {
  46. float freq_desert = 0.45f;
  47. float freq_beach = 0.15f;
  48. s16 dungeon_ymin = -31000;
  49. s16 dungeon_ymax = 31000;
  50. NoiseParams np_terrain_base;
  51. NoiseParams np_terrain_higher;
  52. NoiseParams np_steepness;
  53. NoiseParams np_height_select;
  54. NoiseParams np_mud;
  55. NoiseParams np_beach;
  56. NoiseParams np_biome;
  57. NoiseParams np_cave;
  58. NoiseParams np_humidity;
  59. NoiseParams np_trees;
  60. NoiseParams np_apple_trees;
  61. MapgenV6Params();
  62. ~MapgenV6Params() = default;
  63. void readParams(const Settings *settings);
  64. void writeParams(Settings *settings) const;
  65. void setDefaultSettings(Settings *settings);
  66. };
  67. class MapgenV6 : public Mapgen {
  68. public:
  69. int ystride;
  70. u32 spflags;
  71. v3s16 node_min;
  72. v3s16 node_max;
  73. v3s16 full_node_min;
  74. v3s16 full_node_max;
  75. v3s16 central_area_size;
  76. Noise *noise_terrain_base;
  77. Noise *noise_terrain_higher;
  78. Noise *noise_steepness;
  79. Noise *noise_height_select;
  80. Noise *noise_mud;
  81. Noise *noise_beach;
  82. Noise *noise_biome;
  83. Noise *noise_humidity;
  84. NoiseParams *np_cave;
  85. NoiseParams *np_humidity;
  86. NoiseParams *np_trees;
  87. NoiseParams *np_apple_trees;
  88. NoiseParams np_dungeons;
  89. float freq_desert;
  90. float freq_beach;
  91. s16 dungeon_ymin;
  92. s16 dungeon_ymax;
  93. content_t c_stone;
  94. content_t c_dirt;
  95. content_t c_dirt_with_grass;
  96. content_t c_sand;
  97. content_t c_water_source;
  98. content_t c_lava_source;
  99. content_t c_gravel;
  100. content_t c_desert_stone;
  101. content_t c_desert_sand;
  102. content_t c_dirt_with_snow;
  103. content_t c_snow;
  104. content_t c_snowblock;
  105. content_t c_ice;
  106. content_t c_cobble;
  107. content_t c_mossycobble;
  108. content_t c_stair_cobble;
  109. content_t c_stair_desert_stone;
  110. MapgenV6(MapgenV6Params *params, EmergeParams *emerge);
  111. ~MapgenV6();
  112. virtual MapgenType getType() const { return MAPGEN_V6; }
  113. void makeChunk(BlockMakeData *data);
  114. int getGroundLevelAtPoint(v2s16 p);
  115. int getSpawnLevelAtPoint(v2s16 p);
  116. float baseTerrainLevel(float terrain_base, float terrain_higher,
  117. float steepness, float height_select);
  118. virtual float baseTerrainLevelFromNoise(v2s16 p);
  119. virtual float baseTerrainLevelFromMap(v2s16 p);
  120. virtual float baseTerrainLevelFromMap(int index);
  121. s16 find_stone_level(v2s16 p2d);
  122. bool block_is_underground(u64 seed, v3s16 blockpos);
  123. float getHumidity(v2s16 p);
  124. float getTreeAmount(v2s16 p);
  125. bool getHaveAppleTree(v2s16 p);
  126. float getMudAmount(int index);
  127. bool getHaveBeach(int index);
  128. BiomeV6Type getBiome(v2s16 p);
  129. BiomeV6Type getBiome(int index, v2s16 p);
  130. u32 get_blockseed(u64 seed, v3s16 p);
  131. virtual void calculateNoise();
  132. int generateGround();
  133. void addMud();
  134. void flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos);
  135. void moveMud(u32 remove_index, u32 place_index,
  136. u32 above_remove_index, v2s16 pos, v3s16 em);
  137. void growGrass();
  138. void placeTreesAndJungleGrass();
  139. virtual void generateCaves(int max_stone_y);
  140. };