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