/*
Minetest
Copyright (C) 2010-2015 celeron55, Perttu Ahola <celeron55@gmail.com>
+Copyright (C) 2013-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
+Copyright (C) 2014-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
/////////////////////////////////////////////////////////////////////////////
-MapgenV6::MapgenV6(int mapgenid, MapgenParams *params, EmergeManager *emerge)
+MapgenV6::MapgenV6(int mapgenid, MapgenV6Params *params, EmergeManager *emerge)
: Mapgen(mapgenid, params, emerge)
{
this->m_emerge = emerge;
this->heightmap = new s16[csize.X * csize.Z];
- MapgenV6Params *sp = (MapgenV6Params *)params->sparams;
- this->spflags = sp->spflags;
- this->freq_desert = sp->freq_desert;
- this->freq_beach = sp->freq_beach;
+ this->spflags = params->spflags;
+ this->freq_desert = params->freq_desert;
+ this->freq_beach = params->freq_beach;
- np_cave = &sp->np_cave;
- np_humidity = &sp->np_humidity;
- np_trees = &sp->np_trees;
- np_apple_trees = &sp->np_apple_trees;
+ np_cave = ¶ms->np_cave;
+ np_humidity = ¶ms->np_humidity;
+ np_trees = ¶ms->np_trees;
+ np_apple_trees = ¶ms->np_apple_trees;
//// Create noise objects
- noise_terrain_base = new Noise(&sp->np_terrain_base, seed, csize.X, csize.Y);
- noise_terrain_higher = new Noise(&sp->np_terrain_higher, seed, csize.X, csize.Y);
- noise_steepness = new Noise(&sp->np_steepness, seed, csize.X, csize.Y);
- noise_height_select = new Noise(&sp->np_height_select, seed, csize.X, csize.Y);
- noise_mud = new Noise(&sp->np_mud, seed, csize.X, csize.Y);
- noise_beach = new Noise(&sp->np_beach, seed, csize.X, csize.Y);
- noise_biome = new Noise(&sp->np_biome, seed,
+ noise_terrain_base = new Noise(¶ms->np_terrain_base, seed, csize.X, csize.Y);
+ noise_terrain_higher = new Noise(¶ms->np_terrain_higher, seed, csize.X, csize.Y);
+ noise_steepness = new Noise(¶ms->np_steepness, seed, csize.X, csize.Y);
+ noise_height_select = new Noise(¶ms->np_height_select, seed, csize.X, csize.Y);
+ noise_mud = new Noise(¶ms->np_mud, seed, csize.X, csize.Y);
+ noise_beach = new Noise(¶ms->np_beach, seed, csize.X, csize.Y);
+ noise_biome = new Noise(¶ms->np_biome, seed,
csize.X + 2 * MAP_BLOCKSIZE, csize.Y + 2 * MAP_BLOCKSIZE);
- noise_humidity = new Noise(&sp->np_humidity, seed,
+ noise_humidity = new Noise(¶ms->np_humidity, seed,
csize.X + 2 * MAP_BLOCKSIZE, csize.Y + 2 * MAP_BLOCKSIZE);
//// Resolve nodes to be used
c_snowblock = ndef->getId("mapgen_snowblock");
c_ice = ndef->getId("mapgen_ice");
- c_cobble = ndef->getId("mapgen_cobble");
- c_stair_cobble = ndef->getId("mapgen_stair_cobble");
- c_mossycobble = ndef->getId("mapgen_mossycobble");
-
- if (c_desert_sand == CONTENT_IGNORE)
- c_desert_sand = c_sand;
+ if (c_gravel == CONTENT_IGNORE)
+ c_gravel = c_stone;
if (c_desert_stone == CONTENT_IGNORE)
c_desert_stone = c_stone;
- if (c_mossycobble == CONTENT_IGNORE)
- c_mossycobble = c_cobble;
- if (c_stair_cobble == CONTENT_IGNORE)
- c_stair_cobble = c_cobble;
+ if (c_desert_sand == CONTENT_IGNORE)
+ c_desert_sand = c_sand;
if (c_dirt_with_snow == CONTENT_IGNORE)
c_dirt_with_snow = c_dirt_with_grass;
if (c_snow == CONTENT_IGNORE)
c_snowblock = c_dirt_with_grass;
if (c_ice == CONTENT_IGNORE)
c_ice = c_water_source;
+
+ c_cobble = ndef->getId("mapgen_cobble");
+ c_mossycobble = ndef->getId("mapgen_mossycobble");
+ c_stair_cobble = ndef->getId("mapgen_stair_cobble");
+ c_stair_desert_stone = ndef->getId("mapgen_stair_desert_stone");
+
+ if (c_mossycobble == CONTENT_IGNORE)
+ c_mossycobble = c_cobble;
+ if (c_stair_cobble == CONTENT_IGNORE)
+ c_stair_cobble = c_cobble;
+ if (c_stair_desert_stone == CONTENT_IGNORE)
+ c_stair_desert_stone = c_desert_stone;
}
float MapgenV6::baseTerrainLevelFromNoise(v2s16 p)
{
- if ((spflags & MGV6_FLAT) || (flags & MG_FLAT))
+ if (spflags & MGV6_FLAT)
return water_level;
float terrain_base = NoisePerlin2D_PO(&noise_terrain_base->np,
float MapgenV6::baseTerrainLevelFromMap(int index)
{
- if ((spflags & MGV6_FLAT) || (flags & MG_FLAT))
+ if (spflags & MGV6_FLAT)
return water_level;
float terrain_base = noise_terrain_base->result[index];
float MapgenV6::getMudAmount(int index)
{
- if ((spflags & MGV6_FLAT) || (flags & MG_FLAT))
+ if (spflags & MGV6_FLAT)
return MGV6_AVERAGE_MUD_AMOUNT;
/*return ((float)AVERAGE_MUD_AMOUNT + 2.0 * noise2d_perlin(
if ((flags & MG_DUNGEONS) && (stone_surface_max_y >= node_min.Y)) {
DungeonParams dp;
- dp.seed = seed;
- dp.c_water = c_water_source;
- dp.c_river_water = c_water_source;
- dp.rooms_min = 2;
- dp.rooms_max = 16;
- dp.y_min = -MAX_MAP_GENERATION_LIMIT;
- dp.y_max = MAX_MAP_GENERATION_LIMIT;
- dp.np_density = NoiseParams(0.9, 0.5, v3f(500.0, 500.0, 500.0), 0, 2, 0.8, 2.0);
- dp.np_alt_wall = NoiseParams(-0.4, 1.0, v3f(40.0, 40.0, 40.0), 32474, 6, 1.1, 2.0);
+ dp.seed = seed;
+ dp.c_water = c_water_source;
+ dp.c_river_water = c_water_source;
+
+ dp.only_in_ground = true;
+ dp.corridor_len_min = 1;
+ dp.corridor_len_max = 13;
+ dp.rooms_min = 2;
+ dp.rooms_max = 16;
+ dp.y_min = -MAX_MAP_GENERATION_LIMIT;
+ dp.y_max = MAX_MAP_GENERATION_LIMIT;
+
+ dp.np_density
+ = NoiseParams(0.9, 0.5, v3f(500.0, 500.0, 500.0), 0, 2, 0.8, 2.0);
+ dp.np_alt_wall
+ = NoiseParams(-0.4, 1.0, v3f(40.0, 40.0, 40.0), 32474, 6, 1.1, 2.0);
if (getBiome(0, v2s16(node_min.X, node_min.Z)) == BT_DESERT) {
- dp.c_wall = c_desert_stone;
- dp.c_alt_wall = CONTENT_IGNORE;
- dp.c_stair = c_desert_stone;
-
- dp.diagonal_dirs = true;
- dp.holesize = v3s16(2, 3, 2);
- dp.roomsize = v3s16(2, 5, 2);
- dp.notifytype = GENNOTIFY_TEMPLE;
+ dp.c_wall = c_desert_stone;
+ dp.c_alt_wall = CONTENT_IGNORE;
+ dp.c_stair = c_stair_desert_stone;
+
+ dp.diagonal_dirs = true;
+ dp.holesize = v3s16(2, 3, 2);
+ dp.room_size_min = v3s16(6, 9, 6);
+ dp.room_size_max = v3s16(10, 11, 10);
+ dp.room_size_large_min = v3s16(10, 13, 10);
+ dp.room_size_large_max = v3s16(18, 21, 18);
+ dp.notifytype = GENNOTIFY_TEMPLE;
} else {
- dp.c_wall = c_cobble;
- dp.c_alt_wall = c_mossycobble;
- dp.c_stair = c_stair_cobble;
-
- dp.diagonal_dirs = false;
- dp.holesize = v3s16(1, 2, 1);
- dp.roomsize = v3s16(0, 0, 0);
- dp.notifytype = GENNOTIFY_DUNGEON;
+ dp.c_wall = c_cobble;
+ dp.c_alt_wall = c_mossycobble;
+ dp.c_stair = c_stair_cobble;
+
+ dp.diagonal_dirs = false;
+ dp.holesize = v3s16(1, 2, 1);
+ dp.room_size_min = v3s16(4, 4, 4);
+ dp.room_size_max = v3s16(8, 6, 8);
+ dp.room_size_large_min = v3s16(8, 8, 8);
+ dp.room_size_large_max = v3s16(16, 16, 16);
+ dp.notifytype = GENNOTIFY_DUNGEON;
}
DungeonGen dgen(ndef, &gennotify, &dp);
growGrass();
// Generate some trees, and add grass, if a jungle
- if ((spflags & MGV6_TREES) || (flags & MG_TREES))
+ if (spflags & MGV6_TREES)
placeTreesAndJungleGrass();
// Generate the registered decorations
int fx = full_node_min.X;
int fz = full_node_min.Z;
- if (!((spflags & MGV6_FLAT) || (flags & MG_FLAT))) {
+ if (!(spflags & MGV6_FLAT)) {
noise_terrain_base->perlinMap2D_PO(x, 0.5, z, 0.5);
noise_terrain_higher->perlinMap2D_PO(x, 0.5, z, 0.5);
noise_steepness->perlinMap2D_PO(x, 0.5, z, 0.5);
v3s16(-1, 0, 0), // left
};
- // Check that upper is air or doesn't exist.
- // Cancel dropping if upper keeps it in place
+ // Check that upper is walkable. Cancel
+ // dropping if upper keeps it in place.
u32 i3 = i;
vm->m_area.add_y(em, i3, 1);
- if (vm->m_area.contains(i3) == true &&
- ndef->get(vm->m_data[i3]).walkable)
- continue;
+ MapNode *n3 = NULL;
+
+ if (vm->m_area.contains(i3)) {
+ n3 = &vm->m_data[i3];
+ if (ndef->get(*n3).walkable)
+ continue;
+ }
// Drop mud on side
for (u32 di = 0; di < 4; di++) {
if (!dropped_to_unknown) {
*n2 = *n;
// Set old place to be air (or water)
- if (old_is_water)
+ if (old_is_water) {
*n = MapNode(c_water_source);
- else
+ } else {
*n = MapNode(CONTENT_AIR);
+ // Upper (n3) is not walkable or is NULL. If it is
+ // not NULL and not air and not water it is a
+ // decoration that needs removing, to avoid
+ // unsupported decorations.
+ if (n3 && n3->getContent() != CONTENT_AIR &&
+ n3->getContent() != c_water_source)
+ *n3 = MapNode(CONTENT_AIR);
+ }
}
// Done
continue;
v3s16 p(x, y, z);
- // Trees grow only on mud and grass and snowblock
+ // Trees grow only on mud and grass
{
u32 i = vm->m_area.index(p);
content_t c = vm->m_data[i].getContent();
if (c != c_dirt &&
c != c_dirt_with_grass &&
- c != c_dirt_with_snow &&
- c != c_snowblock)
+ c != c_dirt_with_snow)
continue;
}
p.Y++;
content_t c = vm->m_data[i].getContent();
if (surface_y >= water_level - 20) {
if (bt == BT_TAIGA && c == c_dirt) {
- vm->m_data[i] = n_snowblock;
- vm->m_area.add_y(em, i, -1);
vm->m_data[i] = n_dirt_with_snow;
} else if (bt == BT_TUNDRA) {
if (c == c_dirt) {
+ vm->m_data[i] = n_snowblock;
+ vm->m_area.add_y(em, i, -1);
vm->m_data[i] = n_dirt_with_snow;
} else if (c == c_stone && surface_y < node_max.Y) {
vm->m_area.add_y(em, i, 1);
- vm->m_data[i] = n_snow;
+ vm->m_data[i] = n_snowblock;
}
} else if (c == c_dirt) {
vm->m_data[i] = n_dirt_with_grass;