Fix MapgenV6::generateCaves possible division by 0 and misc. cosmetic fixes
authorkwolekr <kwolekr@minetest.net>
Sun, 31 Mar 2013 01:24:37 +0000 (21:24 -0400)
committerkwolekr <kwolekr@minetest.net>
Sun, 31 Mar 2013 01:24:37 +0000 (21:24 -0400)
src/mapgen_v6.cpp
src/nodedef.cpp
src/scriptapi.cpp

index 0b419617d22bb2d8a54986c1600386fa3fa4ec65..275d4b78fdd13993e2ab20917f46d83c181bb2b7 100644 (file)
@@ -928,20 +928,20 @@ void MapgenV6::growGrass() {
 
 void MapgenV6::defineCave(Cave &cave, PseudoRandom ps,
                                                 v3s16 node_min, bool large_cave) {
-               cave.min_tunnel_diameter = 2;
-               cave.max_tunnel_diameter = ps.range(2,6);
-               cave.dswitchint = ps.range(1,14);
-               cave.flooded = true; //large_cave && ps.range(0,4);
-               if(large_cave){
-                       cave.part_max_length_rs = ps.range(2,4);
-                       cave.tunnel_routepoints = ps.range(5, ps.range(15,30));
-                       cave.min_tunnel_diameter = 5;
-                       cave.max_tunnel_diameter = ps.range(7, ps.range(8,24));
-               } else {
-                       cave.part_max_length_rs = ps.range(2,9);
-                       cave.tunnel_routepoints = ps.range(10, ps.range(15,30));
-               }
-               cave.large_cave_is_flat = (ps.range(0,1) == 0);
+       cave.min_tunnel_diameter = 2;
+       cave.max_tunnel_diameter = ps.range(2,6);
+       cave.dswitchint = ps.range(1,14);
+       cave.flooded = true; //large_cave && ps.range(0,4);
+       if (large_cave){
+               cave.part_max_length_rs = ps.range(2,4);
+               cave.tunnel_routepoints = ps.range(5, ps.range(15,30));
+               cave.min_tunnel_diameter = 5;
+               cave.max_tunnel_diameter = ps.range(7, ps.range(8,24));
+       } else {
+               cave.part_max_length_rs = ps.range(2,9);
+               cave.tunnel_routepoints = ps.range(10, ps.range(15,30));
+       }
+       cave.large_cave_is_flat = (ps.range(0,1) == 0);
 }
 
 
@@ -1120,7 +1120,13 @@ void MapgenV6::generateCaves(int max_stone_y) {
                                rp.Z = ar.Z-1;
                        vec = rp - orp;
 
-                       for(float f=0; f<1.0; f+=1.0/vec.getLength())
+                       float veclen = vec.getLength();
+                       // As odd as it sounds, veclen is *exactly*
+                       // 0.0 sometimes, causing a FPE
+                       if (veclen == 0.0)
+                               veclen = 1.0;
+
+                       for(float f=0; f<1.0; f+=1.0/veclen)
                        {
                                v3f fp = orp + vec * f;
                                fp.X += 0.1*ps.range(-10,10);
index 59db68a3629ec1e416c019bf1583d524797e547f..ca889890781128a34da81eb0dc0a8a05dc159bc9 100644 (file)
@@ -822,6 +822,7 @@ private:
        std::map<std::string, content_t> m_name_id_mapping_with_aliases;
        // A mapping from groups to a list of content_ts (and their levels)
        // that belong to it.  Necessary for a direct lookup in getIds().
+       // Note: Not serialized.
        std::map<std::string, GroupItems> m_group_to_items;
 };
 
index 80abffa2b900fbfe5d7c909f40442b795aeddf0e..81fcc08d3a40f5b1073b4cf62da993d0e5ca8987 100644 (file)
@@ -727,7 +727,7 @@ static int l_register_ore(lua_State *L)
        
        if (ore->clust_scarcity <= 0 || ore->clust_num_ores <= 0) {
                errorstream << "register_ore: clust_scarcity and clust_num_ores"
-                       "must be greater than 0";
+                       " must be greater than 0" << std::endl;
                delete ore;
                return 0;
        }