Skip to content
Permalink
Browse files

Mapgen: Remove unused mgv7 code and some unused biometypes

  • Loading branch information
paramat committed Mar 26, 2018
1 parent 43f98eb commit 2f280cc6724cd9dd0bf0bbe7a0d07bf888efce27
Showing with 0 additions and 178 deletions.
  1. +0 −169 src/mapgen/mapgen_v7.cpp
  2. +0 −5 src/mapgen/mg_biome.h
  3. +0 −4 src/script/lua_api/l_mapgen.cpp
@@ -584,172 +584,3 @@ void MapgenV7::generateRidgeTerrain()
}
}
}


////////////////////////////////////////////////////////////////////////////////
//// Code Boneyard
////
//// Much of the stuff here has potential to become useful again at some point
//// in the future, but we don't want it to get lost or forgotten in version
//// control.
////

#if 0
int MapgenV7::generateMountainTerrain(s16 ymax)
{
MapNode n_stone(c_stone);
u32 j = 0;

for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
u32 vi = vm->m_area.index(node_min.X, y, z);
for (s16 x = node_min.X; x <= node_max.X; x++) {
int index = (z - node_min.Z) * csize.X + (x - node_min.X);
content_t c = vm->m_data[vi].getContent();

if (getMountainTerrainFromMap(j, index, y)
&& (c == CONTENT_AIR || c == c_water_source)) {
vm->m_data[vi] = n_stone;
if (y > ymax)
ymax = y;
}

vi++;
j++;
}
}

return ymax;
}
#endif


#if 0
void MapgenV7::carveRivers() {
MapNode n_air(CONTENT_AIR), n_water_source(c_water_source);
MapNode n_stone(c_stone);
u32 index = 0;

int river_depth = 4;

for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
float terrain_mod = noise_terrain_mod->result[index];
NoiseParams *np = noise_terrain_river->np;
np.persist = noise_terrain_persist->result[index];
float terrain_river = NoisePerlin2DNoTxfm(np, x, z, seed);
float height = terrain_river * (1 - abs(terrain_mod)) *
noise_terrain_river->np.scale;
height = log(height * height); //log(h^3) is pretty interesting for terrain

s16 y = heightmap[index];
if (height < 1.0 && y > river_depth &&
y - river_depth >= node_min.Y && y <= node_max.Y) {

for (s16 ry = y; ry != y - river_depth; ry--) {
u32 vi = vm->m_area.index(x, ry, z);
vm->m_data[vi] = n_air;
}

u32 vi = vm->m_area.index(x, y - river_depth, z);
vm->m_data[vi] = n_water_source;
}
}
}
#endif


#if 0
void MapgenV7::addTopNodes()
{
v3s16 em = vm->m_area.getExtent();
s16 ntopnodes;
u32 index = 0;

for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
Biome *biome = bmgr->biomes[biomemap[index]];

//////////////////// First, add top nodes below the ridge
s16 y = ridge_heightmap[index];

// This cutoff is good enough, but not perfect.
// It will cut off potentially placed top nodes at chunk boundaries
if (y < node_min.Y)
continue;
if (y > node_max.Y) {
y = node_max.Y; // Let's see if we can still go downward anyway
u32 vi = vm->m_area.index(x, y, z);
content_t c = vm->m_data[vi].getContent();
if (ndef->get(c).walkable)
continue;
}

// N.B. It is necessary to search downward since ridge_heightmap[i]
// might not be the actual height, just the lowest part in the chunk
// where a ridge had been carved
u32 i = vm->m_area.index(x, y, z);
for (; y >= node_min.Y; y--) {
content_t c = vm->m_data[i].getContent();
if (ndef->get(c).walkable)
break;
vm->m_area.add_y(em, i, -1);
}

if (y != node_min.Y - 1 && y >= water_level) {
ridge_heightmap[index] = y; //update ridgeheight
ntopnodes = biome->top_depth;
for (; y <= node_max.Y && ntopnodes; y++) {
ntopnodes--;
vm->m_data[i] = MapNode(biome->c_top);
vm->m_area.add_y(em, i, 1);
}
// If dirt, grow grass on it.
if (y > water_level - 10 &&
vm->m_data[i].getContent() == CONTENT_AIR) {
vm->m_area.add_y(em, i, -1);
if (vm->m_data[i].getContent() == c_dirt)
vm->m_data[i] = MapNode(c_dirt_with_grass);
}
}

//////////////////// Now, add top nodes on top of the ridge
y = heightmap[index];
if (y > node_max.Y) {
y = node_max.Y; // Let's see if we can still go downward anyway
u32 vi = vm->m_area.index(x, y, z);
content_t c = vm->m_data[vi].getContent();
if (ndef->get(c).walkable)
continue;
}

i = vm->m_area.index(x, y, z);
for (; y >= node_min.Y; y--) {
content_t c = vm->m_data[i].getContent();
if (ndef->get(c).walkable)
break;
vm->m_area.add_y(em, i, -1);
}

if (y != node_min.Y - 1) {
ntopnodes = biome->top_depth;
// Let's see if we've already added it...
if (y == ridge_heightmap[index] + ntopnodes - 1)
continue;

for (; y <= node_max.Y && ntopnodes; y++) {
ntopnodes--;
vm->m_data[i] = MapNode(biome->c_top);
vm->m_area.add_y(em, i, 1);
}
// If dirt, grow grass on it.
if (y > water_level - 10 &&
vm->m_data[i].getContent() == CONTENT_AIR) {
vm->m_area.add_y(em, i, -1);
if (vm->m_data[i].getContent() == c_dirt)
vm->m_data[i] = MapNode(c_dirt_with_grass);
}
}
}
}
#endif
@@ -36,13 +36,8 @@ typedef u8 biome_t;

#define BIOME_NONE ((biome_t)0)

// TODO(hmmmm): Decide whether this is obsolete or will be used in the future
enum BiomeType {
BIOMETYPE_NORMAL,
BIOMETYPE_LIQUID,
BIOMETYPE_NETHER,
BIOMETYPE_AETHER,
BIOMETYPE_FLAT,
};

class Biome : public ObjDef, public NodeResolver {
@@ -40,10 +40,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
struct EnumString ModApiMapgen::es_BiomeTerrainType[] =
{
{BIOMETYPE_NORMAL, "normal"},
{BIOMETYPE_LIQUID, "liquid"},
{BIOMETYPE_NETHER, "nether"},
{BIOMETYPE_AETHER, "aether"},
{BIOMETYPE_FLAT, "flat"},
{0, NULL},
};

0 comments on commit 2f280cc

Please sign in to comment.