Skip to content
Permalink
Browse files

Mgv5/mgv7: Add desert temples if desert stone detected in mapchunk

  • Loading branch information...
paramat committed Mar 11, 2015
1 parent 140245a commit 6ce0985f47b874839947e3be503c302bec532206
Showing with 99 additions and 12 deletions.
  1. +40 −5 src/mapgen_v5.cpp
  2. +1 −1 src/mapgen_v5.h
  3. +53 −5 src/mapgen_v7.cpp
  4. +5 −1 src/mapgen_v7.h
@@ -89,6 +89,7 @@ MapgenV5::MapgenV5(int mapgenid, MapgenParams *params, EmergeManager *emerge)
c_gravel = ndef->getId("mapgen_gravel");
c_cobble = ndef->getId("mapgen_cobble");
c_ice = ndef->getId("default:ice");
c_desert_stone = ndef->getId("mapgen_desert_stone");
c_mossycobble = ndef->getId("mapgen_mossycobble");
c_sandbrick = ndef->getId("mapgen_sandstonebrick");
c_stair_cobble = ndef->getId("mapgen_stair_cobble");
@@ -238,15 +239,43 @@ void MapgenV5::makeChunk(BlockMakeData *data)
noise_humidity->result, heightmap, biomemap);

// Actually place the biome-specific nodes
generateBiomes(noise_heat->result, noise_humidity->result);
bool desert_stone = generateBiomes(noise_heat->result, noise_humidity->result);

// Generate caves
if ((flags & MG_CAVES) && (stone_surface_max_y >= node_min.Y))
generateCaves(stone_surface_max_y);

// Generate dungeons and desert temples
if ((flags & MG_DUNGEONS) && (stone_surface_max_y >= node_min.Y)) {
DungeonGen dgen(this, NULL);
DungeonParams dp;

dp.np_rarity = nparams_dungeon_rarity;
dp.np_density = nparams_dungeon_density;
dp.np_wetness = nparams_dungeon_wetness;
dp.c_water = c_water_source;
if (desert_stone) {
dp.c_cobble = c_sandbrick;
dp.c_moss = c_sandbrick; // should make this 'cracked sandstone' later
dp.c_stair = c_stair_sandstone;

dp.diagonal_dirs = true;
dp.mossratio = 0.0;
dp.holesize = v3s16(2, 3, 2);
dp.roomsize = v3s16(2, 5, 2);
dp.notifytype = GENNOTIFY_TEMPLE;
} else {
dp.c_cobble = c_cobble;
dp.c_moss = c_mossycobble;
dp.c_stair = c_stair_cobble;

dp.diagonal_dirs = false;
dp.mossratio = 3.0;
dp.holesize = v3s16(1, 2, 1);
dp.roomsize = v3s16(0, 0, 0);
dp.notifytype = GENNOTIFY_DUNGEON;
}

DungeonGen dgen(this, &dp);
dgen.generate(blockseed, full_node_min, full_node_max);
}

@@ -357,17 +386,18 @@ int MapgenV5::generateBaseTerrain()
}


void MapgenV5::generateBiomes(float *heat_map, float *humidity_map)
bool MapgenV5::generateBiomes(float *heat_map, float *humidity_map)
{
if (node_max.Y < water_level)
return;
return false;

MapNode n_air(CONTENT_AIR);
MapNode n_stone(c_stone);
MapNode n_water(c_water_source);

v3s16 em = vm->m_area.getExtent();
u32 index = 0;
bool desert_stone = false;

for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
@@ -392,6 +422,9 @@ void MapgenV5::generateBiomes(float *heat_map, float *humidity_map)
y0_top = biome->depth_top;
y0_filler = biome->depth_top + dfiller;
depth_water_top = biome->depth_water_top;

if (biome->c_stone == c_desert_stone)
desert_stone = true;
}

if (c == c_stone && have_air) {
@@ -424,7 +457,7 @@ void MapgenV5::generateBiomes(float *heat_map, float *humidity_map)
} else if (c == c_water_source) {
have_air = true;
nplaced = 0;
if(y > water_level - depth_water_top)
if (y > water_level - depth_water_top)
vm->m_data[i] = MapNode(biome->c_water_top);
else
vm->m_data[i] = MapNode(biome->c_water);
@@ -436,6 +469,8 @@ void MapgenV5::generateBiomes(float *heat_map, float *humidity_map)
vm->m_area.add_y(em, i, -1);
}
}

return desert_stone;
}


@@ -93,7 +93,7 @@ class MapgenV5 : public Mapgen {
int getGroundLevelAtPoint(v2s16 p);
void calculateNoise();
int generateBaseTerrain();
void generateBiomes(float *heat_map, float *humidity_map);
bool generateBiomes(float *heat_map, float *humidity_map);
void generateCaves(int max_stone_y);
void dustTopNodes();
};
@@ -96,8 +96,22 @@ MapgenV7::MapgenV7(int mapgenid, MapgenParams *params, EmergeManager *emerge)
c_water_source = ndef->getId("mapgen_water_source");
c_lava_source = ndef->getId("mapgen_lava_source");
c_ice = ndef->getId("default:ice");
c_cobble = ndef->getId("mapgen_cobble");
c_desert_stone = ndef->getId("mapgen_desert_stone");
c_mossycobble = ndef->getId("mapgen_mossycobble");
c_sandbrick = ndef->getId("mapgen_sandstonebrick");
c_stair_cobble = ndef->getId("mapgen_stair_cobble");
c_stair_sandstone = ndef->getId("mapgen_stair_sandstone");
if (c_ice == CONTENT_IGNORE)
c_ice = CONTENT_AIR;
if (c_mossycobble == CONTENT_IGNORE)
c_mossycobble = c_cobble;
if (c_sandbrick == CONTENT_IGNORE)
c_sandbrick = c_desert_stone;
if (c_stair_cobble == CONTENT_IGNORE)
c_stair_cobble = c_cobble;
if (c_stair_sandstone == CONTENT_IGNORE)
c_stair_sandstone = c_sandbrick;
}


@@ -248,13 +262,41 @@ void MapgenV7::makeChunk(BlockMakeData *data)
noise_humidity->result, heightmap, biomemap);

// Actually place the biome-specific nodes
generateBiomes(noise_heat->result, noise_humidity->result);
bool desert_stone = generateBiomes(noise_heat->result, noise_humidity->result);

if (flags & MG_CAVES)
generateCaves(stone_surface_max_y);

if ((flags & MG_DUNGEONS) && (stone_surface_max_y >= node_min.Y)) {
DungeonGen dgen(this, NULL);
DungeonParams dp;

dp.np_rarity = nparams_dungeon_rarity;
dp.np_density = nparams_dungeon_density;
dp.np_wetness = nparams_dungeon_wetness;
dp.c_water = c_water_source;
if (desert_stone) {
dp.c_cobble = c_sandbrick;
dp.c_moss = c_sandbrick; // should make this 'cracked sandstone' later
dp.c_stair = c_stair_sandstone;

dp.diagonal_dirs = true;
dp.mossratio = 0.0;
dp.holesize = v3s16(2, 3, 2);
dp.roomsize = v3s16(2, 5, 2);
dp.notifytype = GENNOTIFY_TEMPLE;
} else {
dp.c_cobble = c_cobble;
dp.c_moss = c_mossycobble;
dp.c_stair = c_stair_cobble;

dp.diagonal_dirs = false;
dp.mossratio = 3.0;
dp.holesize = v3s16(1, 2, 1);
dp.roomsize = v3s16(0, 0, 0);
dp.notifytype = GENNOTIFY_DUNGEON;
}

DungeonGen dgen(this, &dp);
dgen.generate(blockseed, full_node_min, full_node_max);
}

@@ -536,17 +578,18 @@ void MapgenV7::generateRidgeTerrain()
}


void MapgenV7::generateBiomes(float *heat_map, float *humidity_map)
bool MapgenV7::generateBiomes(float *heat_map, float *humidity_map)
{
if (node_max.Y < water_level)
return;
return false;

MapNode n_air(CONTENT_AIR);
MapNode n_stone(c_stone);
MapNode n_water(c_water_source);

v3s16 em = vm->m_area.getExtent();
u32 index = 0;
bool desert_stone = false;

for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
@@ -581,6 +624,9 @@ void MapgenV7::generateBiomes(float *heat_map, float *humidity_map)
y0_top = biome->depth_top;
y0_filler = biome->depth_top + dfiller;
depth_water_top = biome->depth_water_top;

if (biome->c_stone == c_desert_stone)
desert_stone = true;
}

if (c == c_stone && have_air) {
@@ -613,7 +659,7 @@ void MapgenV7::generateBiomes(float *heat_map, float *humidity_map)
} else if (c == c_water_source) {
have_air = true;
nplaced = 0;
if(y > water_level - depth_water_top)
if (y > water_level - depth_water_top)
vm->m_data[i] = MapNode(biome->c_water_top);
else
vm->m_data[i] = MapNode(biome->c_water);
@@ -625,6 +671,8 @@ void MapgenV7::generateBiomes(float *heat_map, float *humidity_map)
vm->m_area.add_y(em, i, -1);
}
}

return desert_stone;
}


@@ -94,6 +94,10 @@ class MapgenV7 : public Mapgen {
content_t c_cobble;
content_t c_desert_sand;
content_t c_desert_stone;
content_t c_mossycobble;
content_t c_sandbrick;
content_t c_stair_cobble;
content_t c_stair_sandstone;

MapgenV7(int mapgenid, MapgenParams *params, EmergeManager *emerge);
~MapgenV7();
@@ -114,7 +118,7 @@ class MapgenV7 : public Mapgen {
int generateMountainTerrain(int ymax);
void generateRidgeTerrain();

void generateBiomes(float *heat_map, float *humidity_map);
bool generateBiomes(float *heat_map, float *humidity_map);
void dustTopNodes();

//void addTopNodes();

0 comments on commit 6ce0985

Please sign in to comment.
You can’t perform that action at this time.