3 Copyright (C) 2017-2019 vlapsley, Vaughan Lapsley <vlapsley@gmail.com>
4 Copyright (C) 2017-2019 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.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "content_sao.h"
31 #include "voxelalgorithms.h"
32 //#include "profiler.h" // For TimeTaker
33 #include "settings.h" // For g_settings
35 #include "dungeongen.h"
39 #include "mg_decoration.h"
40 #include "mapgen_carpathian.h"
43 FlagDesc flagdesc_mapgen_carpathian[] = {
44 {"caverns", MGCARPATHIAN_CAVERNS},
45 {"rivers", MGCARPATHIAN_RIVERS},
50 ///////////////////////////////////////////////////////////////////////////////
53 MapgenCarpathian::MapgenCarpathian(MapgenCarpathianParams *params, EmergeManager *emerge)
54 : MapgenBasic(MAPGEN_CARPATHIAN, params, emerge)
56 base_level = params->base_level;
57 river_width = params->river_width;
58 river_depth = params->river_depth;
59 valley_width = params->valley_width;
61 spflags = params->spflags;
62 cave_width = params->cave_width;
63 large_cave_depth = params->large_cave_depth;
64 small_cave_num_min = params->small_cave_num_min;
65 small_cave_num_max = params->small_cave_num_max;
66 large_cave_num_min = params->large_cave_num_min;
67 large_cave_num_max = params->large_cave_num_max;
68 large_cave_flooded = params->large_cave_flooded;
69 cavern_limit = params->cavern_limit;
70 cavern_taper = params->cavern_taper;
71 cavern_threshold = params->cavern_threshold;
72 dungeon_ymin = params->dungeon_ymin;
73 dungeon_ymax = params->dungeon_ymax;
75 grad_wl = 1 - water_level;
78 noise_filler_depth = new Noise(¶ms->np_filler_depth, seed, csize.X, csize.Z);
79 noise_height1 = new Noise(¶ms->np_height1, seed, csize.X, csize.Z);
80 noise_height2 = new Noise(¶ms->np_height2, seed, csize.X, csize.Z);
81 noise_height3 = new Noise(¶ms->np_height3, seed, csize.X, csize.Z);
82 noise_height4 = new Noise(¶ms->np_height4, seed, csize.X, csize.Z);
83 noise_hills_terrain = new Noise(¶ms->np_hills_terrain, seed, csize.X, csize.Z);
84 noise_ridge_terrain = new Noise(¶ms->np_ridge_terrain, seed, csize.X, csize.Z);
85 noise_step_terrain = new Noise(¶ms->np_step_terrain, seed, csize.X, csize.Z);
86 noise_hills = new Noise(¶ms->np_hills, seed, csize.X, csize.Z);
87 noise_ridge_mnt = new Noise(¶ms->np_ridge_mnt, seed, csize.X, csize.Z);
88 noise_step_mnt = new Noise(¶ms->np_step_mnt, seed, csize.X, csize.Z);
89 if (spflags & MGCARPATHIAN_RIVERS)
90 noise_rivers = new Noise(¶ms->np_rivers, seed, csize.X, csize.Z);
93 // 1 up 1 down overgeneration
94 noise_mnt_var = new Noise(¶ms->np_mnt_var, seed, csize.X, csize.Y + 2, csize.Z);
97 MapgenBasic::np_cave1 = params->np_cave1;
98 MapgenBasic::np_cave2 = params->np_cave2;
99 MapgenBasic::np_cavern = params->np_cavern;
100 MapgenBasic::np_dungeons = params->np_dungeons;
104 MapgenCarpathian::~MapgenCarpathian()
106 delete noise_filler_depth;
107 delete noise_height1;
108 delete noise_height2;
109 delete noise_height3;
110 delete noise_height4;
111 delete noise_hills_terrain;
112 delete noise_ridge_terrain;
113 delete noise_step_terrain;
115 delete noise_ridge_mnt;
116 delete noise_step_mnt;
117 if (spflags & MGCARPATHIAN_RIVERS)
120 delete noise_mnt_var;
124 MapgenCarpathianParams::MapgenCarpathianParams():
125 np_filler_depth (0, 1, v3f(128, 128, 128), 261, 3, 0.7, 2.0),
126 np_height1 (0, 5, v3f(251, 251, 251), 9613, 5, 0.5, 2.0),
127 np_height2 (0, 5, v3f(383, 383, 383), 1949, 5, 0.5, 2.0),
128 np_height3 (0, 5, v3f(509, 509, 509), 3211, 5, 0.5, 2.0),
129 np_height4 (0, 5, v3f(631, 631, 631), 1583, 5, 0.5, 2.0),
130 np_hills_terrain (1, 1, v3f(1301, 1301, 1301), 1692, 5, 0.5, 2.0),
131 np_ridge_terrain (1, 1, v3f(1889, 1889, 1889), 3568, 5, 0.5, 2.0),
132 np_step_terrain (1, 1, v3f(1889, 1889, 1889), 4157, 5, 0.5, 2.0),
133 np_hills (0, 3, v3f(257, 257, 257), 6604, 6, 0.5, 2.0),
134 np_ridge_mnt (0, 12, v3f(743, 743, 743), 5520, 6, 0.7, 2.0),
135 np_step_mnt (0, 8, v3f(509, 509, 509), 2590, 6, 0.6, 2.0),
136 np_rivers (0, 1, v3f(1000, 1000, 1000), 85039, 5, 0.6, 2.0),
137 np_mnt_var (0, 1, v3f(499, 499, 499), 2490, 5, 0.55, 2.0),
138 np_cave1 (0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0),
139 np_cave2 (0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0),
140 np_cavern (0, 1, v3f(384, 128, 384), 723, 5, 0.63, 2.0),
141 np_dungeons (0.9, 0.5, v3f(500, 500, 500), 0, 2, 0.8, 2.0)
146 void MapgenCarpathianParams::readParams(const Settings *settings)
148 settings->getFlagStrNoEx("mgcarpathian_spflags", spflags, flagdesc_mapgen_carpathian);
150 settings->getFloatNoEx("mgcarpathian_base_level", base_level);
151 settings->getFloatNoEx("mgcarpathian_river_width", river_width);
152 settings->getFloatNoEx("mgcarpathian_river_depth", river_depth);
153 settings->getFloatNoEx("mgcarpathian_valley_width", valley_width);
155 settings->getFloatNoEx("mgcarpathian_cave_width", cave_width);
156 settings->getS16NoEx("mgcarpathian_large_cave_depth", large_cave_depth);
157 settings->getU16NoEx("mgcarpathian_small_cave_num_min", small_cave_num_min);
158 settings->getU16NoEx("mgcarpathian_small_cave_num_max", small_cave_num_max);
159 settings->getU16NoEx("mgcarpathian_large_cave_num_min", large_cave_num_min);
160 settings->getU16NoEx("mgcarpathian_large_cave_num_max", large_cave_num_max);
161 settings->getFloatNoEx("mgcarpathian_large_cave_flooded", large_cave_flooded);
162 settings->getS16NoEx("mgcarpathian_cavern_limit", cavern_limit);
163 settings->getS16NoEx("mgcarpathian_cavern_taper", cavern_taper);
164 settings->getFloatNoEx("mgcarpathian_cavern_threshold", cavern_threshold);
165 settings->getS16NoEx("mgcarpathian_dungeon_ymin", dungeon_ymin);
166 settings->getS16NoEx("mgcarpathian_dungeon_ymax", dungeon_ymax);
168 settings->getNoiseParams("mgcarpathian_np_filler_depth", np_filler_depth);
169 settings->getNoiseParams("mgcarpathian_np_height1", np_height1);
170 settings->getNoiseParams("mgcarpathian_np_height2", np_height2);
171 settings->getNoiseParams("mgcarpathian_np_height3", np_height3);
172 settings->getNoiseParams("mgcarpathian_np_height4", np_height4);
173 settings->getNoiseParams("mgcarpathian_np_hills_terrain", np_hills_terrain);
174 settings->getNoiseParams("mgcarpathian_np_ridge_terrain", np_ridge_terrain);
175 settings->getNoiseParams("mgcarpathian_np_step_terrain", np_step_terrain);
176 settings->getNoiseParams("mgcarpathian_np_hills", np_hills);
177 settings->getNoiseParams("mgcarpathian_np_ridge_mnt", np_ridge_mnt);
178 settings->getNoiseParams("mgcarpathian_np_step_mnt", np_step_mnt);
179 settings->getNoiseParams("mgcarpathian_np_rivers", np_rivers);
180 settings->getNoiseParams("mgcarpathian_np_mnt_var", np_mnt_var);
181 settings->getNoiseParams("mgcarpathian_np_cave1", np_cave1);
182 settings->getNoiseParams("mgcarpathian_np_cave2", np_cave2);
183 settings->getNoiseParams("mgcarpathian_np_cavern", np_cavern);
184 settings->getNoiseParams("mgcarpathian_np_dungeons", np_dungeons);
188 void MapgenCarpathianParams::writeParams(Settings *settings) const
190 settings->setFlagStr("mgcarpathian_spflags", spflags, flagdesc_mapgen_carpathian);
192 settings->setFloat("mgcarpathian_base_level", base_level);
193 settings->setFloat("mgcarpathian_river_width", river_width);
194 settings->setFloat("mgcarpathian_river_depth", river_depth);
195 settings->setFloat("mgcarpathian_valley_width", valley_width);
197 settings->setFloat("mgcarpathian_cave_width", cave_width);
198 settings->setS16("mgcarpathian_large_cave_depth", large_cave_depth);
199 settings->setU16("mgcarpathian_small_cave_num_min", small_cave_num_min);
200 settings->setU16("mgcarpathian_small_cave_num_max", small_cave_num_max);
201 settings->setU16("mgcarpathian_large_cave_num_min", large_cave_num_min);
202 settings->setU16("mgcarpathian_large_cave_num_max", large_cave_num_max);
203 settings->setFloat("mgcarpathian_large_cave_flooded", large_cave_flooded);
204 settings->setS16("mgcarpathian_cavern_limit", cavern_limit);
205 settings->setS16("mgcarpathian_cavern_taper", cavern_taper);
206 settings->setFloat("mgcarpathian_cavern_threshold", cavern_threshold);
207 settings->setS16("mgcarpathian_dungeon_ymin", dungeon_ymin);
208 settings->setS16("mgcarpathian_dungeon_ymax", dungeon_ymax);
210 settings->setNoiseParams("mgcarpathian_np_filler_depth", np_filler_depth);
211 settings->setNoiseParams("mgcarpathian_np_height1", np_height1);
212 settings->setNoiseParams("mgcarpathian_np_height2", np_height2);
213 settings->setNoiseParams("mgcarpathian_np_height3", np_height3);
214 settings->setNoiseParams("mgcarpathian_np_height4", np_height4);
215 settings->setNoiseParams("mgcarpathian_np_hills_terrain", np_hills_terrain);
216 settings->setNoiseParams("mgcarpathian_np_ridge_terrain", np_ridge_terrain);
217 settings->setNoiseParams("mgcarpathian_np_step_terrain", np_step_terrain);
218 settings->setNoiseParams("mgcarpathian_np_hills", np_hills);
219 settings->setNoiseParams("mgcarpathian_np_ridge_mnt", np_ridge_mnt);
220 settings->setNoiseParams("mgcarpathian_np_step_mnt", np_step_mnt);
221 settings->setNoiseParams("mgcarpathian_np_rivers", np_rivers);
222 settings->setNoiseParams("mgcarpathian_np_mnt_var", np_mnt_var);
223 settings->setNoiseParams("mgcarpathian_np_cave1", np_cave1);
224 settings->setNoiseParams("mgcarpathian_np_cave2", np_cave2);
225 settings->setNoiseParams("mgcarpathian_np_cavern", np_cavern);
226 settings->setNoiseParams("mgcarpathian_np_dungeons", np_dungeons);
230 void MapgenCarpathianParams::setDefaultSettings(Settings *settings)
232 settings->setDefault("mgcarpathian_spflags", flagdesc_mapgen_carpathian,
233 MGCARPATHIAN_CAVERNS);
236 ////////////////////////////////////////////////////////////////////////////////
240 inline float MapgenCarpathian::getLerp(float noise1, float noise2, float mod)
242 return noise1 + mod * (noise2 - noise1);
246 float MapgenCarpathian::getSteps(float noise)
249 float k = std::floor(noise / w);
250 float f = (noise - k * w) / w;
251 float s = std::fmin(2.f * f, 1.f);
256 ////////////////////////////////////////////////////////////////////////////////
259 void MapgenCarpathian::makeChunk(BlockMakeData *data)
262 assert(data->vmanip);
263 assert(data->nodedef);
264 assert(data->blockpos_requested.X >= data->blockpos_min.X &&
265 data->blockpos_requested.Y >= data->blockpos_min.Y &&
266 data->blockpos_requested.Z >= data->blockpos_min.Z);
267 assert(data->blockpos_requested.X <= data->blockpos_max.X &&
268 data->blockpos_requested.Y <= data->blockpos_max.Y &&
269 data->blockpos_requested.Z <= data->blockpos_max.Z);
271 this->generating = true;
272 this->vm = data->vmanip;
273 this->ndef = data->nodedef;
275 v3s16 blockpos_min = data->blockpos_min;
276 v3s16 blockpos_max = data->blockpos_max;
277 node_min = blockpos_min * MAP_BLOCKSIZE;
278 node_max = (blockpos_max + v3s16(1, 1, 1)) * MAP_BLOCKSIZE - v3s16(1, 1, 1);
279 full_node_min = (blockpos_min - 1) * MAP_BLOCKSIZE;
280 full_node_max = (blockpos_max + 2) * MAP_BLOCKSIZE - v3s16(1, 1, 1);
282 // Create a block-specific seed
283 blockseed = getBlockSeed2(full_node_min, seed);
286 s16 stone_surface_max_y = generateTerrain();
289 updateHeightmap(node_min, node_max);
291 // Init biome generator, place biome-specific nodes, and build biomemap
292 if (flags & MG_BIOMES) {
293 biomegen->calcBiomeNoise(node_min);
297 // Generate tunnels, caverns and large randomwalk caves
298 if (flags & MG_CAVES) {
299 // Generate tunnels first as caverns confuse them
300 generateCavesNoiseIntersection(stone_surface_max_y);
303 bool near_cavern = false;
304 if (spflags & MGCARPATHIAN_CAVERNS)
305 near_cavern = generateCavernsNoise(stone_surface_max_y);
307 // Generate large randomwalk caves
309 // Disable large randomwalk caves in this mapchunk by setting
310 // 'large cave depth' to world base. Avoids excessive liquid in
311 // large caverns and floating blobs of overgenerated liquid.
312 generateCavesRandomWalk(stone_surface_max_y,
313 -MAX_MAP_GENERATION_LIMIT);
315 generateCavesRandomWalk(stone_surface_max_y, large_cave_depth);
318 // Generate the registered ores
319 m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
322 if (flags & MG_DUNGEONS)
323 generateDungeons(stone_surface_max_y);
325 // Generate the registered decorations
326 if (flags & MG_DECORATIONS)
327 m_emerge->decomgr->placeAllDecos(this, blockseed, node_min, node_max);
329 // Sprinkle some dust on top after everything else was generated
330 if (flags & MG_BIOMES)
334 updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);
336 // Calculate lighting
337 if (flags & MG_LIGHT) {
338 calcLighting(node_min - v3s16(0, 1, 0), node_max + v3s16(0, 1, 0),
339 full_node_min, full_node_max);
342 this->generating = false;
346 ////////////////////////////////////////////////////////////////////////////////
349 int MapgenCarpathian::getSpawnLevelAtPoint(v2s16 p)
351 // If rivers are enabled, first check if in a river channel
352 if (spflags & MGCARPATHIAN_RIVERS) {
353 float river = std::fabs(NoisePerlin2D(&noise_rivers->np, p.X, p.Y, seed)) -
356 return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
359 float height1 = NoisePerlin2D(&noise_height1->np, p.X, p.Y, seed);
360 float height2 = NoisePerlin2D(&noise_height2->np, p.X, p.Y, seed);
361 float height3 = NoisePerlin2D(&noise_height3->np, p.X, p.Y, seed);
362 float height4 = NoisePerlin2D(&noise_height4->np, p.X, p.Y, seed);
364 float hterabs = std::fabs(NoisePerlin2D(&noise_hills_terrain->np, p.X, p.Y, seed));
365 float n_hills = NoisePerlin2D(&noise_hills->np, p.X, p.Y, seed);
366 float hill_mnt = hterabs * hterabs * hterabs * n_hills * n_hills;
368 float rterabs = std::fabs(NoisePerlin2D(&noise_ridge_terrain->np, p.X, p.Y, seed));
369 float n_ridge_mnt = NoisePerlin2D(&noise_ridge_mnt->np, p.X, p.Y, seed);
370 float ridge_mnt = rterabs * rterabs * rterabs * (1.0f - std::fabs(n_ridge_mnt));
372 float sterabs = std::fabs(NoisePerlin2D(&noise_step_terrain->np, p.X, p.Y, seed));
373 float n_step_mnt = NoisePerlin2D(&noise_step_mnt->np, p.X, p.Y, seed);
374 float step_mnt = sterabs * sterabs * sterabs * getSteps(n_step_mnt);
379 if ((spflags & MGCARPATHIAN_RIVERS) && node_max.Y >= water_level - 16) {
380 river = std::fabs(NoisePerlin2D(&noise_rivers->np, p.X, p.Y, seed)) - river_width;
381 if (river <= valley_width) {
382 // Within river valley
388 // 0 at river edge, 1 at valley edge.
389 float riversc = river / valley_width;
391 valley = riversc * riversc * (3.0f - 2.0f * riversc);
396 bool solid_below = false;
397 u8 cons_non_solid = 0; // consecutive non-solid nodes
399 for (s16 y = water_level; y <= water_level + 32; y++) {
400 float mnt_var = NoisePerlin3D(&noise_mnt_var->np, p.X, y, p.Y, seed);
401 float hill1 = getLerp(height1, height2, mnt_var);
402 float hill2 = getLerp(height3, height4, mnt_var);
403 float hill3 = getLerp(height3, height2, mnt_var);
404 float hill4 = getLerp(height1, height4, mnt_var);
406 float hilliness = std::fmax(std::fmin(hill1, hill2), std::fmin(hill3, hill4));
407 float hills = hill_mnt * hilliness;
408 float ridged_mountains = ridge_mnt * hilliness;
409 float step_mountains = step_mnt * hilliness;
413 float mountains = hills + ridged_mountains + step_mountains;
414 float surface_level = base_level + mountains + grad;
416 if ((spflags & MGCARPATHIAN_RIVERS) && river <= valley_width) {
419 surface_level = std::fmin(surface_level,
420 water_level - std::sqrt(-valley) * river_depth);
421 } else if (surface_level > water_level) {
423 surface_level = water_level + (surface_level - water_level) * valley;
427 if (y < surface_level) { //TODO '<=' fix from generateTerrain()
434 if (cons_non_solid == 3 && solid_below)
439 return MAX_MAP_GENERATION_LIMIT; // No suitable spawn point found
443 ////////////////////////////////////////////////////////////////////////////////
446 int MapgenCarpathian::generateTerrain()
448 MapNode mn_air(CONTENT_AIR);
449 MapNode mn_stone(c_stone);
450 MapNode mn_water(c_water_source);
452 // Calculate noise for terrain generation
453 noise_height1->perlinMap2D(node_min.X, node_min.Z);
454 noise_height2->perlinMap2D(node_min.X, node_min.Z);
455 noise_height3->perlinMap2D(node_min.X, node_min.Z);
456 noise_height4->perlinMap2D(node_min.X, node_min.Z);
457 noise_hills_terrain->perlinMap2D(node_min.X, node_min.Z);
458 noise_ridge_terrain->perlinMap2D(node_min.X, node_min.Z);
459 noise_step_terrain->perlinMap2D(node_min.X, node_min.Z);
460 noise_hills->perlinMap2D(node_min.X, node_min.Z);
461 noise_ridge_mnt->perlinMap2D(node_min.X, node_min.Z);
462 noise_step_mnt->perlinMap2D(node_min.X, node_min.Z);
463 noise_mnt_var->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z);
465 if (spflags & MGCARPATHIAN_RIVERS)
466 noise_rivers->perlinMap2D(node_min.X, node_min.Z);
469 const v3s16 &em = vm->m_area.getExtent();
470 s16 stone_surface_max_y = -MAX_MAP_GENERATION_LIMIT;
473 for (s16 z = node_min.Z; z <= node_max.Z; z++)
474 for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) {
475 // Hill/Mountain height (hilliness)
476 float height1 = noise_height1->result[index2d];
477 float height2 = noise_height2->result[index2d];
478 float height3 = noise_height3->result[index2d];
479 float height4 = noise_height4->result[index2d];
482 float hterabs = std::fabs(noise_hills_terrain->result[index2d]);
483 float n_hills = noise_hills->result[index2d];
484 float hill_mnt = hterabs * hterabs * hterabs * n_hills * n_hills;
487 float rterabs = std::fabs(noise_ridge_terrain->result[index2d]);
488 float n_ridge_mnt = noise_ridge_mnt->result[index2d];
489 float ridge_mnt = rterabs * rterabs * rterabs *
490 (1.0f - std::fabs(n_ridge_mnt));
492 // Step (terraced) mountains
493 float sterabs = std::fabs(noise_step_terrain->result[index2d]);
494 float n_step_mnt = noise_step_mnt->result[index2d];
495 float step_mnt = sterabs * sterabs * sterabs * getSteps(n_step_mnt);
501 if ((spflags & MGCARPATHIAN_RIVERS) && node_max.Y >= water_level - 16) {
502 river = std::fabs(noise_rivers->result[index2d]) - river_width;
503 if (river <= valley_width) {
504 // Within river valley
510 // 0 at river edge, 1 at valley edge.
511 float riversc = river / valley_width;
513 valley = riversc * riversc * (3.0f - 2.0f * riversc);
518 // Initialise 3D noise index and voxelmanip index to column base
519 u32 index3d = (z - node_min.Z) * zstride_1u1d + (x - node_min.X);
520 u32 vi = vm->m_area.index(x, node_min.Y - 1, z);
522 for (s16 y = node_min.Y - 1; y <= node_max.Y + 1;
525 VoxelArea::add_y(em, vi, 1)) {
526 if (vm->m_data[vi].getContent() != CONTENT_IGNORE)
529 // Combine height noises and apply 3D variation
530 float mnt_var = noise_mnt_var->result[index3d];
531 float hill1 = getLerp(height1, height2, mnt_var);
532 float hill2 = getLerp(height3, height4, mnt_var);
533 float hill3 = getLerp(height3, height2, mnt_var);
534 float hill4 = getLerp(height1, height4, mnt_var);
536 // 'hilliness' determines whether hills/mountains are
539 std::fmax(std::fmin(hill1, hill2), std::fmin(hill3, hill4));
540 float hills = hill_mnt * hilliness;
541 float ridged_mountains = ridge_mnt * hilliness;
542 float step_mountains = step_mnt * hilliness;
544 // Gradient & shallow seabed
545 s32 grad = (y < water_level) ? grad_wl + (water_level - y) * 3 :
548 // Final terrain level
549 float mountains = hills + ridged_mountains + step_mountains;
550 float surface_level = base_level + mountains + grad;
553 if ((spflags & MGCARPATHIAN_RIVERS) && node_max.Y >= water_level - 16 &&
554 river <= valley_width) {
557 surface_level = std::fmin(surface_level,
558 water_level - std::sqrt(-valley) * river_depth);
559 } else if (surface_level > water_level) {
561 surface_level = water_level + (surface_level - water_level) * valley;
565 if (y < surface_level) { //TODO '<='
566 vm->m_data[vi] = mn_stone; // Stone
567 if (y > stone_surface_max_y)
568 stone_surface_max_y = y;
569 } else if (y <= water_level) {
570 vm->m_data[vi] = mn_water; // Sea water
572 vm->m_data[vi] = mn_air; // Air
577 return stone_surface_max_y;