Skip to content
Permalink
Browse files

Print error if invalid mapgen alias was detected (#9579)

  • Loading branch information
Wuzzy2 committed Apr 10, 2020
1 parent 35e778e commit aa3cf400e2ca4096517e926dbae5b6337b2f1876
Showing with 39 additions and 0 deletions.
  1. +7 −0 src/mapgen/mapgen.cpp
  2. +15 −0 src/mapgen/mapgen_v6.cpp
  3. +17 −0 src/mapgen/treegen.cpp
@@ -629,6 +629,13 @@ MapgenBasic::MapgenBasic(int mapgenid, MapgenParams *params, EmergeManager *emer
// Lava falls back to water as both are suitable as cave liquids.
if (c_lava_source == CONTENT_IGNORE)
c_lava_source = c_water_source;

if (c_stone == CONTENT_IGNORE)
errorstream << "Mapgen: Mapgen alias 'mapgen_stone' is invalid!" << std::endl;
if (c_water_source == CONTENT_IGNORE)
errorstream << "Mapgen: Mapgen alias 'mapgen_water_source' is invalid!" << std::endl;
if (c_river_water_source == CONTENT_IGNORE)
warningstream << "Mapgen: Mapgen alias 'mapgen_river_water_source' is invalid!" << std::endl;
}


@@ -132,6 +132,21 @@ MapgenV6::MapgenV6(MapgenV6Params *params, EmergeManager *emerge)
c_stair_cobble = c_cobble;
if (c_stair_desert_stone == CONTENT_IGNORE)
c_stair_desert_stone = c_desert_stone;

if (c_stone == CONTENT_IGNORE)
errorstream << "Mapgen v6: Mapgen alias 'mapgen_stone' is invalid!" << std::endl;
if (c_dirt == CONTENT_IGNORE)
errorstream << "Mapgen v6: Mapgen alias 'mapgen_dirt' is invalid!" << std::endl;
if (c_dirt_with_grass == CONTENT_IGNORE)
errorstream << "Mapgen v6: Mapgen alias 'mapgen_dirt_with_grass' is invalid!" << std::endl;
if (c_sand == CONTENT_IGNORE)
errorstream << "Mapgen v6: Mapgen alias 'mapgen_sand' is invalid!" << std::endl;
if (c_water_source == CONTENT_IGNORE)
errorstream << "Mapgen v6: Mapgen alias 'mapgen_water_source' is invalid!" << std::endl;
if (c_lava_source == CONTENT_IGNORE)
errorstream << "Mapgen v6: Mapgen alias 'mapgen_lava_source' is invalid!" << std::endl;
if (c_cobble == CONTENT_IGNORE)
errorstream << "Mapgen v6: Mapgen alias 'mapgen_cobble' is invalid!" << std::endl;
}


@@ -44,6 +44,12 @@ void make_tree(MMVManip &vmanip, v3s16 p0, bool is_apple_tree,
MapNode treenode(ndef->getId("mapgen_tree"));
MapNode leavesnode(ndef->getId("mapgen_leaves"));
MapNode applenode(ndef->getId("mapgen_apple"));
if (treenode == CONTENT_IGNORE)
errorstream << "Treegen: Mapgen alias 'mapgen_tree' is invalid!" << std::endl;
if (leavesnode == CONTENT_IGNORE)
errorstream << "Treegen: Mapgen alias 'mapgen_leaves' is invalid!" << std::endl;
if (applenode == CONTENT_IGNORE)
errorstream << "Treegen: Mapgen alias 'mapgen_apple' is invalid!" << std::endl;

PseudoRandom pr(seed);
s16 trunk_h = pr.range(4, 5);
@@ -145,6 +151,9 @@ treegen::error make_ltree(MMVManip &vmanip, v3s16 p0,
const NodeDefManager *ndef, TreeDef tree_definition)
{
MapNode dirtnode(ndef->getId("mapgen_dirt"));
if (dirtnode == CONTENT_IGNORE)
errorstream << "Treegen (make_ltree): Mapgen alias 'mapgen_dirt' is invalid!" << std::endl;

s32 seed;
if (tree_definition.explicit_seed)
seed = tree_definition.seed + 14002;
@@ -662,6 +671,10 @@ void make_jungletree(MMVManip &vmanip, v3s16 p0, const NodeDefManager *ndef,
c_tree = ndef->getId("mapgen_tree");
if (c_leaves == CONTENT_IGNORE)
c_leaves = ndef->getId("mapgen_leaves");
if (c_tree == CONTENT_IGNORE)
errorstream << "Treegen: Mapgen alias 'mapgen_jungletree' is invalid!" << std::endl;
if (c_leaves == CONTENT_IGNORE)
errorstream << "Treegen: Mapgen alias 'mapgen_jungleleaves' is invalid!" << std::endl;

MapNode treenode(c_tree);
MapNode leavesnode(c_leaves);
@@ -765,6 +778,10 @@ void make_pine_tree(MMVManip &vmanip, v3s16 p0, const NodeDefManager *ndef,
c_leaves = ndef->getId("mapgen_leaves");
if (c_snow == CONTENT_IGNORE)
c_snow = CONTENT_AIR;
if (c_tree == CONTENT_IGNORE)
errorstream << "Treegen: Mapgen alias 'mapgen_pine_tree' is invalid!" << std::endl;
if (c_leaves == CONTENT_IGNORE)
errorstream << "Treegen: Mapgen alias 'mapgen_pine_needles' is invalid!" << std::endl;

MapNode treenode(c_tree);
MapNode leavesnode(c_leaves);

0 comments on commit aa3cf40

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