diff options
author | paramat <mat.gregory@virginmedia.com> | 2014-12-28 05:20:42 +0000 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2014-12-28 21:37:43 -0500 |
commit | 570c2042b1b11fc1581dceb22c74cf47bb217134 (patch) | |
tree | 5f9823b69b595a2d2ecaf499dbebabcac98b477f /src | |
parent | 61dfa912f5f37f435e41b3c7d8cdb6244562e597 (diff) | |
download | minetest-570c2042b1b11fc1581dceb22c74cf47bb217134.tar.gz minetest-570c2042b1b11fc1581dceb22c74cf47bb217134.tar.bz2 minetest-570c2042b1b11fc1581dceb22c74cf47bb217134.zip |
Biome API: Add shore top and shore filler nodes, underwater node, water top node. Add water top depth and shore height parameters. Remove water dust node
Diffstat (limited to 'src')
-rw-r--r-- | src/mapgen_v5.cpp | 42 | ||||
-rw-r--r-- | src/mapgen_v7.cpp | 41 | ||||
-rw-r--r-- | src/mg_biome.cpp | 30 | ||||
-rw-r--r-- | src/mg_biome.h | 7 | ||||
-rw-r--r-- | src/script/lua_api/l_mapgen.cpp | 33 |
5 files changed, 91 insertions, 62 deletions
diff --git a/src/mapgen_v5.cpp b/src/mapgen_v5.cpp index 9723c987b..a7d9698d5 100644 --- a/src/mapgen_v5.cpp +++ b/src/mapgen_v5.cpp @@ -417,10 +417,12 @@ void MapgenV5::generateBiomes() { 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 = (Biome *)bmgr->get(biomemap[index]); - s16 dfiller = biome->depth_filler + noise_filler_depth->result[index]; - s16 y0_top = biome->depth_top; - s16 y0_filler = biome->depth_top + dfiller; + Biome *biome = (Biome *)bmgr->get(biomemap[index]); + s16 dfiller = biome->depth_filler + noise_filler_depth->result[index]; + s16 y0_top = biome->depth_top; + s16 y0_filler = biome->depth_top + dfiller; + s16 shore_max = water_level + biome->height_shore; + s16 depth_water_top = biome->depth_water_top; s16 nplaced = 0; u32 i = vm->m_area.index(x, node_max.Y, z); @@ -439,15 +441,20 @@ void MapgenV5::generateBiomes() { if (c_below != CONTENT_AIR) { if (nplaced < y0_top) { - // A hack to prevent dirt_with_grass from being - // placed below water. TODO: fix later - content_t c_place = ((y < water_level) && - (biome->c_top == c_dirt_with_grass)) ? - c_dirt : biome->c_top; - vm->m_data[i] = MapNode(c_place); + if(y < water_level) + vm->m_data[i] = MapNode(biome->c_underwater); + else if(y <= shore_max) + vm->m_data[i] = MapNode(biome->c_shore_top); + else + vm->m_data[i] = MapNode(biome->c_top); nplaced++; } else if (nplaced < y0_filler && nplaced >= y0_top) { - vm->m_data[i] = MapNode(biome->c_filler); + if(y < water_level) + vm->m_data[i] = MapNode(biome->c_underwater); + else if(y <= shore_max) + vm->m_data[i] = MapNode(biome->c_shore_filler); + else + vm->m_data[i] = MapNode(biome->c_filler); nplaced++; } else if (c == c_stone) { have_air = false; @@ -469,7 +476,10 @@ void MapgenV5::generateBiomes() { } else if (c == c_water_source) { have_air = true; nplaced = 0; - vm->m_data[i] = MapNode(biome->c_water); + 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); } else if (c == CONTENT_AIR) { have_air = true; nplaced = 0; @@ -480,6 +490,7 @@ void MapgenV5::generateBiomes() { } } + void MapgenV5::dustTopNodes() { v3s16 em = vm->m_area.getExtent(); u32 index = 0; @@ -504,12 +515,7 @@ void MapgenV5::dustTopNodes() { } content_t c = vm->m_data[vi].getContent(); - if (c == biome->c_water && biome->c_dust_water != CONTENT_IGNORE) { - if (y < node_min.Y - 1) - continue; - - vm->m_data[vi] = MapNode(biome->c_dust_water); - } else if (!ndef->get(c).buildable_to && c != CONTENT_IGNORE + if (!ndef->get(c).buildable_to && c != CONTENT_IGNORE && c != biome->c_dust) { if (y == node_max.Y + 1) continue; diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp index 2f55964d8..06a47971e 100644 --- a/src/mapgen_v7.cpp +++ b/src/mapgen_v7.cpp @@ -516,10 +516,12 @@ void MapgenV7::generateBiomes() { 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 = (Biome *)bmgr->get(biomemap[index]); - s16 dfiller = biome->depth_filler + noise_filler_depth->result[index]; - s16 y0_top = biome->depth_top; - s16 y0_filler = biome->depth_top + dfiller; + Biome *biome = (Biome *)bmgr->get(biomemap[index]); + s16 dfiller = biome->depth_filler + noise_filler_depth->result[index]; + s16 y0_top = biome->depth_top; + s16 y0_filler = biome->depth_top + dfiller; + s16 shore_max = water_level + biome->height_shore; + s16 depth_water_top = biome->depth_water_top; s16 nplaced = 0; u32 i = vm->m_area.index(x, node_max.Y, z); @@ -545,15 +547,20 @@ void MapgenV7::generateBiomes() { if (c_below != CONTENT_AIR) { if (nplaced < y0_top) { - // A hack to prevent dirt_with_grass from being - // placed below water. TODO: fix later - content_t c_place = ((y < water_level) && - (biome->c_top == c_dirt_with_grass)) ? - c_dirt : biome->c_top; - vm->m_data[i] = MapNode(c_place); + if(y < water_level) + vm->m_data[i] = MapNode(biome->c_underwater); + else if(y <= shore_max) + vm->m_data[i] = MapNode(biome->c_shore_top); + else + vm->m_data[i] = MapNode(biome->c_top); nplaced++; } else if (nplaced < y0_filler && nplaced >= y0_top) { - vm->m_data[i] = MapNode(biome->c_filler); + if(y < water_level) + vm->m_data[i] = MapNode(biome->c_underwater); + else if(y <= shore_max) + vm->m_data[i] = MapNode(biome->c_shore_filler); + else + vm->m_data[i] = MapNode(biome->c_filler); nplaced++; } else if (c == c_stone) { have_air = false; @@ -575,7 +582,10 @@ void MapgenV7::generateBiomes() { } else if (c == c_water_source) { have_air = true; nplaced = 0; - vm->m_data[i] = MapNode(biome->c_water); + 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); } else if (c == CONTENT_AIR) { have_air = true; nplaced = 0; @@ -611,12 +621,7 @@ void MapgenV7::dustTopNodes() { } content_t c = vm->m_data[vi].getContent(); - if (c == biome->c_water && biome->c_dust_water != CONTENT_IGNORE) { - if (y < node_min.Y) - continue; - - vm->m_data[vi] = MapNode(biome->c_dust_water); - } else if (!ndef->get(c).buildable_to && c != CONTENT_IGNORE) { + if (!ndef->get(c).buildable_to && c != CONTENT_IGNORE) { if (y == node_max.Y) continue; diff --git a/src/mg_biome.cpp b/src/mg_biome.cpp index 763bef1bc..0492980ee 100644 --- a/src/mg_biome.cpp +++ b/src/mg_biome.cpp @@ -38,23 +38,28 @@ BiomeManager::BiomeManager(IGameDef *gamedef) : // Create default biome to be used in case none exist Biome *b = new Biome; - b->id = 0; - b->name = "Default"; - b->flags = 0; - b->depth_top = 0; - b->depth_filler = 0; - b->height_min = -MAP_GENERATION_LIMIT; - b->height_max = MAP_GENERATION_LIMIT; - b->heat_point = 0.0; - b->humidity_point = 0.0; + b->id = 0; + b->name = "Default"; + b->flags = 0; + b->depth_top = 0; + b->depth_filler = 0; + b->height_shore = 0; + b->depth_water_top = 0; + b->height_min = -MAP_GENERATION_LIMIT; + b->height_max = MAP_GENERATION_LIMIT; + b->heat_point = 0.0; + b->humidity_point = 0.0; NodeResolveInfo *nri = new NodeResolveInfo(b); nri->nodenames.push_back("air"); nri->nodenames.push_back("air"); + nri->nodenames.push_back("air"); + nri->nodenames.push_back("air"); + nri->nodenames.push_back("air"); nri->nodenames.push_back("mapgen_stone"); nri->nodenames.push_back("mapgen_water_source"); - nri->nodenames.push_back("air"); nri->nodenames.push_back("mapgen_water_source"); + nri->nodenames.push_back("air"); m_ndef->pendNodeResolve(nri); add(b); @@ -121,9 +126,12 @@ void Biome::resolveNodeNames(NodeResolveInfo *nri) { m_ndef->getIdFromResolveInfo(nri, "mapgen_dirt_with_grass", CONTENT_AIR, c_top); m_ndef->getIdFromResolveInfo(nri, "mapgen_dirt", CONTENT_AIR, c_filler); + m_ndef->getIdFromResolveInfo(nri, "mapgen_sand", CONTENT_AIR, c_shore_top); + m_ndef->getIdFromResolveInfo(nri, "mapgen_sand", CONTENT_AIR, c_shore_filler); + m_ndef->getIdFromResolveInfo(nri, "mapgen_sand", CONTENT_AIR, c_underwater); m_ndef->getIdFromResolveInfo(nri, "mapgen_stone", CONTENT_AIR, c_stone); + m_ndef->getIdFromResolveInfo(nri, "mapgen_water_source", CONTENT_AIR, c_water_top); m_ndef->getIdFromResolveInfo(nri, "mapgen_water_source", CONTENT_AIR, c_water); m_ndef->getIdFromResolveInfo(nri, "air", CONTENT_IGNORE, c_dust); - m_ndef->getIdFromResolveInfo(nri, "mapgen_water_source", CONTENT_IGNORE, c_dust_water); } diff --git a/src/mg_biome.h b/src/mg_biome.h index 870c11961..f5a5deae3 100644 --- a/src/mg_biome.h +++ b/src/mg_biome.h @@ -39,13 +39,18 @@ public: content_t c_top; content_t c_filler; + content_t c_shore_top; + content_t c_shore_filler; + content_t c_underwater; content_t c_stone; + content_t c_water_top; content_t c_water; content_t c_dust; - content_t c_dust_water; s16 depth_top; s16 depth_filler; + s16 height_shore; + s16 depth_water_top; s16 height_min; s16 height_max; diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index c0a58305b..a2e5d31d1 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -422,14 +422,16 @@ int ModApiMapgen::l_register_biome(lua_State *L) es_BiomeTerrainType, BIOME_TYPE_NORMAL); Biome *b = bmgr->create(biometype); - b->name = getstringfield_default(L, index, "name", ""); - 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->name = getstringfield_default(L, index, "name", ""); + b->depth_top = getintfield_default(L, index, "depth_top", 1); + b->depth_filler = getintfield_default(L, index, "depth_filler", 3); + b->height_shore = getintfield_default(L, index, "height_shore", 3); + b->depth_water_top = getintfield_default(L, index, "depth_water_top", 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 u32 id = bmgr->add(b); if (id == (u32)-1) { @@ -439,12 +441,15 @@ int ModApiMapgen::l_register_biome(lua_State *L) NodeResolveInfo *nri = new NodeResolveInfo(b); std::list<std::string> &nnames = nri->nodenames; - nnames.push_back(getstringfield_default(L, index, "node_top", "")); - nnames.push_back(getstringfield_default(L, index, "node_filler", "")); - nnames.push_back(getstringfield_default(L, index, "node_stone", "")); - nnames.push_back(getstringfield_default(L, index, "node_water", "")); - nnames.push_back(getstringfield_default(L, index, "node_dust", "")); - nnames.push_back(getstringfield_default(L, index, "node_dust_water", "")); + nnames.push_back(getstringfield_default(L, index, "node_top", "")); + nnames.push_back(getstringfield_default(L, index, "node_filler", "")); + nnames.push_back(getstringfield_default(L, index, "node_shore_top", "")); + nnames.push_back(getstringfield_default(L, index, "node_shore_filler", "")); + nnames.push_back(getstringfield_default(L, index, "node_underwater", "")); + nnames.push_back(getstringfield_default(L, index, "node_stone", "")); + nnames.push_back(getstringfield_default(L, index, "node_water_top", "")); + nnames.push_back(getstringfield_default(L, index, "node_water", "")); + nnames.push_back(getstringfield_default(L, index, "node_dust", "")); ndef->pendNodeResolve(nri); verbosestream << "register_biome: " << b->name << std::endl; |