Skip to content

Commit

Permalink
Print error if invalid mapgen alias was detected (#9579)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuzzy2 committed Apr 10, 2020
1 parent 35e778e commit aa3cf40
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/mapgen/mapgen.cpp
Expand Up @@ -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;
}


Expand Down
15 changes: 15 additions & 0 deletions src/mapgen/mapgen_v6.cpp
Expand Up @@ -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;
}


Expand Down
17 changes: 17 additions & 0 deletions src/mapgen/treegen.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit aa3cf40

Please sign in to comment.