]> git.lizzy.rs Git - minetest.git/blobdiff - src/treegen.cpp
Change internal type for seeds to s32
[minetest.git] / src / treegen.cpp
index 1c915ca39052dfbf32654112e67dc203675f1912..36d387c577cb330761d559d6339971fdf9745676 100644 (file)
@@ -31,7 +31,7 @@ namespace treegen
 {
 
 void make_tree(MMVManip &vmanip, v3s16 p0,
-               bool is_apple_tree, INodeDefManager *ndef, int seed)
+               bool is_apple_tree, INodeDefManager *ndef, s32 seed)
 {
        /*
                NOTE: Tree-placing code is currently duplicated in the engine
@@ -149,7 +149,7 @@ treegen::error make_ltree(MMVManip &vmanip, v3s16 p0,
                INodeDefManager *ndef, TreeDef tree_definition)
 {
        MapNode dirtnode(ndef->getId("mapgen_dirt"));
-       int seed;
+       s32 seed;
        if (tree_definition.explicit_seed)
                seed = tree_definition.seed + 14002;
        else
@@ -649,7 +649,7 @@ v3f transposeMatrix(irr::core::matrix4 M, v3f v)
 }
 
 
-void make_jungletree(MMVManip &vmanip, v3s16 p0, INodeDefManager *ndef, int seed)
+void make_jungletree(MMVManip &vmanip, v3s16 p0, INodeDefManager *ndef, s32 seed)
 {
        /*
                NOTE: Tree-placing code is currently duplicated in the engine
@@ -748,16 +748,26 @@ void make_jungletree(MMVManip &vmanip, v3s16 p0, INodeDefManager *ndef, int seed
 }
 
 
-void make_pine_tree(MMVManip &vmanip, v3s16 p0, INodeDefManager *ndef, int seed)
+void make_pine_tree(MMVManip &vmanip, v3s16 p0, INodeDefManager *ndef, s32 seed)
 {
        /*
                NOTE: Tree-placing code is currently duplicated in the engine
                and in games that have saplings; both are deprecated but not
                replaced yet
        */
-       MapNode treenode(ndef->getId("mapgen_pinetree"));
-       MapNode leavesnode(ndef->getId("mapgen_pine_needles"));
-       MapNode snownode(ndef->getId("mapgen_snow"));
+       content_t c_tree   = ndef->getId("mapgen_pine_tree");
+       content_t c_leaves = ndef->getId("mapgen_pine_needles");
+       content_t c_snow = ndef->getId("mapgen_snow");
+       if (c_tree == CONTENT_IGNORE)
+               c_tree = ndef->getId("mapgen_tree");
+       if (c_leaves == CONTENT_IGNORE)
+               c_leaves = ndef->getId("mapgen_leaves");
+       if (c_snow == CONTENT_IGNORE)
+               c_snow = CONTENT_AIR;
+
+       MapNode treenode(c_tree);
+       MapNode leavesnode(c_leaves);
+       MapNode snownode(c_snow);
 
        PseudoRandom pr(seed);
        s16 trunk_h = pr.range(9, 13);