mapgen_v6.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. Minetest
  3. Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #ifndef MAPGENV6_HEADER
  17. #define MAPGENV6_HEADER
  18. #include "mapgen.h"
  19. #define AVERAGE_MUD_AMOUNT 4
  20. /////////////////// Mapgen V6 flags
  21. #define MGV6_JUNGLES 0x01
  22. #define MGV6_BIOMEBLEND 0x02
  23. #define MGV6_MUDFLOW 0x04
  24. extern FlagDesc flagdesc_mapgen_v6[];
  25. enum BiomeType
  26. {
  27. BT_NORMAL,
  28. BT_DESERT
  29. };
  30. struct MapgenV6Params : public MapgenSpecificParams {
  31. u32 spflags;
  32. float freq_desert;
  33. float freq_beach;
  34. NoiseParams np_terrain_base;
  35. NoiseParams np_terrain_higher;
  36. NoiseParams np_steepness;
  37. NoiseParams np_height_select;
  38. NoiseParams np_mud;
  39. NoiseParams np_beach;
  40. NoiseParams np_biome;
  41. NoiseParams np_cave;
  42. NoiseParams np_humidity;
  43. NoiseParams np_trees;
  44. NoiseParams np_apple_trees;
  45. MapgenV6Params();
  46. ~MapgenV6Params() {}
  47. void readParams(Settings *settings);
  48. void writeParams(Settings *settings);
  49. };
  50. class MapgenV6 : public Mapgen {
  51. public:
  52. EmergeManager *emerge;
  53. int ystride;
  54. u32 flags;
  55. u32 spflags;
  56. u32 blockseed;
  57. v3s16 node_min;
  58. v3s16 node_max;
  59. v3s16 full_node_min;
  60. v3s16 full_node_max;
  61. v3s16 central_area_size;
  62. int volume_nodes;
  63. Noise *noise_terrain_base;
  64. Noise *noise_terrain_higher;
  65. Noise *noise_steepness;
  66. Noise *noise_height_select;
  67. Noise *noise_mud;
  68. Noise *noise_beach;
  69. Noise *noise_biome;
  70. NoiseParams *np_cave;
  71. NoiseParams *np_humidity;
  72. NoiseParams *np_trees;
  73. NoiseParams *np_apple_trees;
  74. float freq_desert;
  75. float freq_beach;
  76. content_t c_stone;
  77. content_t c_dirt;
  78. content_t c_dirt_with_grass;
  79. content_t c_sand;
  80. content_t c_water_source;
  81. content_t c_lava_source;
  82. content_t c_gravel;
  83. content_t c_cobble;
  84. content_t c_desert_sand;
  85. content_t c_desert_stone;
  86. content_t c_mossycobble;
  87. content_t c_sandbrick;
  88. content_t c_stair_cobble;
  89. content_t c_stair_sandstone;
  90. MapgenV6(int mapgenid, MapgenParams *params, EmergeManager *emerge);
  91. ~MapgenV6();
  92. void makeChunk(BlockMakeData *data);
  93. int getGroundLevelAtPoint(v2s16 p);
  94. float baseTerrainLevel(float terrain_base, float terrain_higher,
  95. float steepness, float height_select);
  96. virtual float baseTerrainLevelFromNoise(v2s16 p);
  97. virtual float baseTerrainLevelFromMap(v2s16 p);
  98. virtual float baseTerrainLevelFromMap(int index);
  99. s16 find_stone_level(v2s16 p2d);
  100. bool block_is_underground(u64 seed, v3s16 blockpos);
  101. s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
  102. float getHumidity(v2s16 p);
  103. float getTreeAmount(v2s16 p);
  104. bool getHaveAppleTree(v2s16 p);
  105. float getMudAmount(v2s16 p);
  106. virtual float getMudAmount(int index);
  107. bool getHaveBeach(v2s16 p);
  108. bool getHaveBeach(int index);
  109. BiomeType getBiome(v2s16 p);
  110. BiomeType getBiome(int index, v2s16 p);
  111. u32 get_blockseed(u64 seed, v3s16 p);
  112. virtual void calculateNoise();
  113. int generateGround();
  114. void addMud();
  115. void flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos);
  116. void addDirtGravelBlobs();
  117. void growGrass();
  118. void placeTreesAndJungleGrass();
  119. virtual void generateCaves(int max_stone_y);
  120. virtual void generateExperimental() {}
  121. };
  122. struct MapgenFactoryV6 : public MapgenFactory {
  123. Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge) {
  124. return new MapgenV6(mgid, params, emerge);
  125. };
  126. MapgenSpecificParams *createMapgenParams() {
  127. return new MapgenV6Params();
  128. };
  129. };
  130. #endif