1 /* 2 dungeongen.h 3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com> 4 */ 5 6 /* 7 This file is part of Freeminer. 8 9 Freeminer is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Freeminer is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Freeminer. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 #ifndef DUNGEONGEN_HEADER 24 #define DUNGEONGEN_HEADER 25 26 #include "voxel.h" 27 #include "noise.h" 28 29 #define VMANIP_FLAG_DUNGEON_INSIDE VOXELFLAG_CHECKED1 30 #define VMANIP_FLAG_DUNGEON_PRESERVE VOXELFLAG_CHECKED2 31 #define VMANIP_FLAG_DUNGEON_UNTOUCHABLE (\ 32 VMANIP_FLAG_DUNGEON_INSIDE|VMANIP_FLAG_DUNGEON_PRESERVE) 33 34 class ManualMapVoxelManipulator; 35 class INodeDefManager; 36 class Mapgen; 37 38 v3s16 rand_ortho_dir(PseudoRandom &random, bool diagonal_dirs); 39 v3s16 turn_xz(v3s16 olddir, int t); 40 v3s16 random_turn(PseudoRandom &random, v3s16 olddir); 41 int dir_to_facedir(v3s16 d); 42 43 44 struct DungeonParams { 45 content_t c_water; 46 content_t c_cobble; 47 content_t c_moss; 48 content_t c_stair; 49 50 int notifytype; 51 bool diagonal_dirs; 52 float mossratio; 53 v3s16 holesize; 54 v3s16 roomsize; 55 56 NoiseParams np_rarity; 57 NoiseParams np_wetness; 58 NoiseParams np_density; 59 }; 60 61 class DungeonGen { 62 public: 63 ManualMapVoxelManipulator *vm; 64 Mapgen *mg; 65 u32 blockseed; 66 PseudoRandom random; 67 v3s16 csize; 68 69 content_t c_torch; 70 DungeonParams dp; 71 72 //RoomWalker 73 v3s16 m_pos; 74 v3s16 m_dir; 75 76 DungeonGen(Mapgen *mg, DungeonParams *dparams); 77 void generate(u32 bseed, v3s16 full_node_min, v3s16 full_node_max); 78 79 void makeDungeon(v3s16 start_padding); 80 void makeRoom(v3s16 roomsize, v3s16 roomplace); 81 void makeCorridor(v3s16 doorplace, v3s16 doordir, 82 v3s16 &result_place, v3s16 &result_dir); 83 void makeDoor(v3s16 doorplace, v3s16 doordir); 84 void makeFill(v3s16 place, v3s16 size, u8 avoid_flags, MapNode n, u8 or_flags); 85 void makeHole(v3s16 place); 86 87 bool findPlaceForDoor(v3s16 &result_place, v3s16 &result_dir); 88 bool findPlaceForRoomDoor(v3s16 roomsize, v3s16 &result_doorplace, 89 v3s16 &result_doordir, v3s16 &result_roomplace); 90 randomizeDir()91 void randomizeDir() 92 { 93 m_dir = rand_ortho_dir(random, dp.diagonal_dirs); 94 } 95 }; 96 97 extern NoiseParams nparams_dungeon_rarity; 98 extern NoiseParams nparams_dungeon_wetness; 99 extern NoiseParams nparams_dungeon_density; 100 101 #endif 102