425 changes: 302 additions & 123 deletions src/mapgen_v7.cpp

Large diffs are not rendered by default.

41 changes: 29 additions & 12 deletions src/mapgen_v7.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,34 @@ with this program; if not, write to the Free Software Foundation, Inc.,

extern NoiseParams nparams_v7_def_terrain_base;
extern NoiseParams nparams_v7_def_terrain_alt;
extern NoiseParams nparams_v7_def_terrain_mod;
extern NoiseParams nparams_v7_def_terrain_persist;
extern NoiseParams nparams_v7_def_height_select;
extern NoiseParams nparams_v7_def_filler_depth;
extern NoiseParams nparams_v7_def_mount_height;
extern NoiseParams nparams_v7_def_ridge_uwater;
extern NoiseParams nparams_v7_def_mountain;
extern NoiseParams nparams_v7_def_ridge;

struct MapgenV7Params : public MapgenParams {
NoiseParams np_terrain_base;
NoiseParams np_terrain_alt;
NoiseParams np_terrain_mod;
NoiseParams np_terrain_persist;
NoiseParams np_height_select;
NoiseParams np_filler_depth;
NoiseParams np_mount_height;
NoiseParams np_ridge_uwater;
NoiseParams np_mountain;
NoiseParams np_ridge;

MapgenV7Params() {
np_terrain_base = nparams_v7_def_terrain_base;
np_terrain_alt = nparams_v7_def_terrain_alt;
np_terrain_mod = nparams_v7_def_terrain_mod;
np_terrain_persist = nparams_v7_def_terrain_persist;
np_height_select = nparams_v7_def_height_select;
np_filler_depth = nparams_v7_def_filler_depth;
np_mount_height = nparams_v7_def_mount_height;
np_ridge_uwater = nparams_v7_def_ridge_uwater;
np_mountain = nparams_v7_def_mountain;
np_ridge = nparams_v7_def_ridge;
}

Expand All @@ -58,8 +67,8 @@ class MapgenV7 : public Mapgen {
BiomeDefManager *bmgr;

int ystride;
int zstride;
u32 flags;
bool ridges;

u32 blockseed;
v3s16 node_min;
Expand All @@ -71,10 +80,12 @@ class MapgenV7 : public Mapgen {

Noise *noise_terrain_base;
Noise *noise_terrain_alt;
Noise *noise_terrain_mod;
Noise *noise_terrain_persist;
Noise *noise_height_select;

Noise *noise_filler_depth;
Noise *noise_mount_height;
Noise *noise_ridge_uwater;
Noise *noise_mountain;
Noise *noise_ridge;

Noise *noise_heat;
Expand All @@ -86,6 +97,7 @@ class MapgenV7 : public Mapgen {
content_t c_sand;
content_t c_water_source;
content_t c_lava_source;
content_t c_ice;
content_t c_gravel;
content_t c_cobble;
content_t c_desert_sand;
Expand All @@ -100,15 +112,20 @@ class MapgenV7 : public Mapgen {

float baseTerrainLevelAtPoint(int x, int z);
float baseTerrainLevelFromMap(int index);
bool getMountainTerrainAtPoint(int x, int y, int z);
bool getMountainTerrainFromMap(int idx_xyz, int idx_xz, int y);

void calculateNoise();
int calcHeightMap();

virtual void generateTerrain();
void carveRidges();
//void carveRivers(); //experimental
virtual int generateTerrain();
int generateBaseTerrain();
void generateMountainTerrain();
void generateRidgeTerrain();

void generateBiomes();
void dustTopNodes();

void testBiomes();
void addTopNodes();
//void addTopNodes();

void generateCaves(int max_stone_y);
};
Expand Down
40 changes: 27 additions & 13 deletions src/script/lua_api/luaapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,33 @@ int ModApiBasic::l_register_biome(lua_State *L)
"terrain_type", es_BiomeTerrainType, BIOME_TERRAIN_NORMAL);
Biome *b = bmgr->createBiome(terrain);

b->name = getstringfield_default(L, index, "name", "");
b->top_nodename = getstringfield_default(L, index, "top_node", "");
b->top_depth = getintfield_default(L, index, "top_depth", 0);
b->filler_nodename = getstringfield_default(L, index, "filler_node", "");
b->filler_height = getintfield_default(L, index, "filler_height", 0);
b->height_min = getintfield_default(L, index, "height_min", 0);
b->height_max = getintfield_default(L, index, "height_max", 0);
b->heat_point = getfloatfield_default(L, index, "heat_point", 0.);
b->humidity_point = getfloatfield_default(L, index, "humidity_point", 0.);

b->flags = 0; //reserved
b->c_top = CONTENT_IGNORE;
b->c_filler = CONTENT_IGNORE;
b->name = getstringfield_default(L, index, "name",
"<no name>");
b->nname_top = getstringfield_default(L, index, "node_top",
"mapgen_dirt_with_grass");
b->nname_filler = getstringfield_default(L, index, "node_filler",
"mapgen_dirt");
b->nname_water = getstringfield_default(L, index, "node_water",
"mapgen_water_source");
b->nname_dust = getstringfield_default(L, index, "node_dust",
"air");
b->nname_dust_water = getstringfield_default(L, index, "node_dust_water",
"mapgen_water_source");

b->depth_top = getintfield_default(L, index, "depth_top", 1);
b->depth_filler = getintfield_default(L, index, "depth_filler", 3);
b->height_min = getintfield_default(L, index, "height_min", 0);
b->height_max = getintfield_default(L, index, "height_max", 0);
b->heat_point = getfloatfield_default(L, index, "heat_point", 0.);
b->humidity_point = getfloatfield_default(L, index, "humidity_point", 0.);

b->flags = 0; //reserved
b->c_top = CONTENT_IGNORE;
b->c_filler = CONTENT_IGNORE;
b->c_water = CONTENT_IGNORE;
b->c_dust = CONTENT_IGNORE;
b->c_dust_water = CONTENT_IGNORE;

verbosestream << "register_biome: " << b->name << std::endl;
bmgr->addBiome(b);

Expand Down