Add find_surface_nodes_in_area LUA call which permit to only get the nodes which...
[oweals/minetest.git] / src / dungeongen.cpp
index ff0a39e9ed5934bdca1ed224de10d3ef3c4e3932..eb452a196a534e03c68ae398ca185af690bd1841 100644 (file)
@@ -31,12 +31,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 //#define DGEN_USE_TORCHES
 
-NoiseParams nparams_dungeon_rarity = 
-       {0.0, 1.0, v3f(500.0, 500.0, 500.0), 0, 2, 0.8};
-NoiseParams nparams_dungeon_wetness =
-       {0.0, 1.0, v3f(40.0, 40.0, 40.0), 32474, 4, 1.1};
-NoiseParams nparams_dungeon_density =
-       {0.0, 1.0, v3f(2.5, 2.5, 2.5), 0, 2, 1.4};
+NoiseParams nparams_dungeon_rarity(0.0, 1.0, v3f(500.0, 500.0, 500.0), 0, 2, 0.8, 2.0);
+NoiseParams nparams_dungeon_wetness(0.0, 1.0, v3f(40.0, 40.0, 40.0), 32474, 4, 1.1, 2.0);
+NoiseParams nparams_dungeon_density(0.0, 1.0, v3f(2.5, 2.5, 2.5), 0, 2, 1.4, 2.0);
 
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -49,7 +46,7 @@ DungeonGen::DungeonGen(Mapgen *mapgen, DungeonParams *dparams) {
 #ifdef DGEN_USE_TORCHES
        c_torch  = ndef->getId("default:torch");
 #endif
-       
+
        if (dparams) {
                memcpy(&dp, dparams, sizeof(dp));
        } else {
@@ -73,10 +70,7 @@ DungeonGen::DungeonGen(Mapgen *mapgen, DungeonParams *dparams) {
 
 void DungeonGen::generate(u32 bseed, v3s16 nmin, v3s16 nmax) {
        //TimeTaker t("gen dungeons");
-       int approx_groundlevel = 10 + mg->water_level;
-
-       if ((nmin.Y + nmax.Y) / 2 >= approx_groundlevel ||
-               NoisePerlin3D(&dp.np_rarity, nmin.X, nmin.Y, nmin.Z, mg->seed) < 0.2)
+       if (NoisePerlin3D(&dp.np_rarity, nmin.X, nmin.Y, nmin.Z, mg->seed) < 0.2)
                return;
 
        this->blockseed = bseed;
@@ -98,7 +92,7 @@ void DungeonGen::generate(u32 bseed, v3s16 nmin, v3s16 nmax) {
                        }
                }
        }
-       
+
        // Add it
        makeDungeon(v3s16(1,1,1) * MAP_BLOCKSIZE);
 
@@ -118,7 +112,7 @@ void DungeonGen::generate(u32 bseed, v3s16 nmin, v3s16 nmax) {
                        }
                }
        }
-       
+
        //printf("== gen dungeons: %dms\n", t.stop());
 }
 
@@ -147,7 +141,7 @@ void DungeonGen::makeDungeon(v3s16 start_padding)
                        random.range(0,areasize.X-roomsize.X-1-start_padding.X),
                        random.range(0,areasize.Y-roomsize.Y-1-start_padding.Y),
                        random.range(0,areasize.Z-roomsize.Z-1-start_padding.Z));
-                       
+
                /*
                        Check that we're not putting the room to an unknown place,
                        otherwise it might end up floating in the air
@@ -184,10 +178,7 @@ void DungeonGen::makeDungeon(v3s16 start_padding)
                makeRoom(roomsize, roomplace);
 
                v3s16 room_center = roomplace + v3s16(roomsize.X / 2, 1, roomsize.Z / 2);
-               if (mg->gennotify & (1 << dp.notifytype)) {
-                       std::vector <v3s16> *nvec = mg->gen_notifications[dp.notifytype];
-                       nvec->push_back(room_center);
-               }
+               mg->gennotify.addEvent(dp.notifytype, room_center);
 
 #ifdef DGEN_USE_TORCHES
                // Place torch at room center (for testing)
@@ -215,7 +206,7 @@ void DungeonGen::makeDungeon(v3s16 start_padding)
                // Create walker and find a place for a door
                v3s16 doorplace;
                v3s16 doordir;
-               
+
                m_pos = walker_start_place;
                if (!findPlaceForDoor(doorplace, doordir))
                        return;
@@ -256,7 +247,7 @@ void DungeonGen::makeRoom(v3s16 roomsize, v3s16 roomplace)
 {
        MapNode n_cobble(dp.c_cobble);
        MapNode n_air(CONTENT_AIR);
-       
+
        // Make +-X walls
        for (s16 z = 0; z < roomsize.Z; z++)
        for (s16 y = 0; y < roomsize.Y; y++)
@@ -396,10 +387,10 @@ void DungeonGen::makeCorridor(v3s16 doorplace,
        u32 partlength = random.range(1, 13);
        u32 partcount = 0;
        s16 make_stairs = 0;
-       
+
        if (random.next() % 2 == 0 && partlength >= 3)
                make_stairs = random.next() % 2 ? 1 : -1;
-       
+
        for (u32 i = 0; i < length; i++) {
                v3s16 p = p0 + dir;
                if (partcount != 0)
@@ -412,7 +403,7 @@ void DungeonGen::makeCorridor(v3s16 doorplace,
                                                VMANIP_FLAG_DUNGEON_UNTOUCHABLE, MapNode(dp.c_cobble), 0);
                                makeHole(p);
                                makeHole(p - dir);
-                               
+
                                // TODO: fix stairs code so it works 100% (quite difficult)
 
                                // exclude stairs from the bottom step
@@ -422,11 +413,11 @@ void DungeonGen::makeCorridor(v3s16 doorplace,
                                        ((make_stairs == -1) && i != length - 1))) {
                                        // rotate face 180 deg if making stairs backwards
                                        int facedir = dir_to_facedir(dir * make_stairs);
-                                       
+
                                        u32 vi = vm->m_area.index(p.X - dir.X, p.Y - 1, p.Z - dir.Z);
                                        if (vm->m_data[vi].getContent() == dp.c_cobble)
                                                vm->m_data[vi] = MapNode(dp.c_stair, 0, facedir);
-                                       
+
                                        vi = vm->m_area.index(p.X, p.Y, p.Z);
                                        if (vm->m_data[vi].getContent() == dp.c_cobble)
                                                vm->m_data[vi] = MapNode(dp.c_stair, 0, facedir);