Fix i18n of some strings.
[oweals/minetest.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 v3s16 rand_ortho_dir(PseudoRandom &random);
35 v3s16 turn_xz(v3s16 olddir, int t);
36 v3s16 random_turn(PseudoRandom &random, v3s16 olddir);
37 int dir_to_facedir(v3s16 d);
38
39 class DungeonGen {
40 public:
41         u32 blockseed;
42         u64 mapseed;
43         ManualMapVoxelManipulator *vmanip;
44         INodeDefManager *ndef;
45         PseudoRandom random;
46         v3s16 csize;
47         s16 water_level;
48         
49         NoiseParams *np_rarity;
50         NoiseParams *np_wetness;
51         NoiseParams *np_density;
52         
53         content_t cid_water_source;
54         content_t cid_cobble;
55         content_t cid_mossycobble;
56         content_t cid_torch;
57         content_t cid_cobblestair;
58         
59         //RoomWalker
60         v3s16 m_pos;
61         v3s16 m_dir;
62
63         DungeonGen(INodeDefManager *ndef, u64 seed, s16 waterlevel);
64         void generate(ManualMapVoxelManipulator *vm, u32 bseed,
65                                   v3s16 full_node_min, v3s16 full_node_max);
66         //void generate(v3s16 full_node_min, v3s16 full_node_max, u32 bseed);
67         
68         void makeDungeon(v3s16 start_padding);
69         void makeRoom(v3s16 roomsize, v3s16 roomplace);
70         void makeCorridor(v3s16 doorplace, v3s16 doordir,
71                                           v3s16 &result_place, v3s16 &result_dir);
72         void makeDoor(v3s16 doorplace, v3s16 doordir);
73         void makeFill(v3s16 place, v3s16 size, u8 avoid_flags, MapNode n, u8 or_flags);
74         void makeHole(v3s16 place);
75
76         bool findPlaceForDoor(v3s16 &result_place, v3s16 &result_dir);
77         bool findPlaceForRoomDoor(v3s16 roomsize, v3s16 &result_doorplace,
78                         v3s16 &result_doordir, v3s16 &result_roomplace);
79                         
80         void randomizeDir()
81         {
82                 m_dir = rand_ortho_dir(random);
83         }
84 };
85
86 class RoomWalker
87 {
88 public:
89
90         RoomWalker(VoxelManipulator &vmanip_, v3s16 pos, PseudoRandom &random,
91                         INodeDefManager *ndef):
92                         vmanip(vmanip_),
93                         m_pos(pos),
94                         m_random(random),
95                         m_ndef(ndef)
96         {
97                 randomizeDir();
98         }
99
100         void randomizeDir()
101         {
102                 m_dir = rand_ortho_dir(m_random);
103         }
104
105         void setPos(v3s16 pos)
106         {
107                 m_pos = pos;
108         }
109
110         void setDir(v3s16 dir)
111         {
112                 m_dir = dir;
113         }
114
115         //bool findPlaceForDoor(v3s16 &result_place, v3s16 &result_dir);
116         //bool findPlaceForRoomDoor(v3s16 roomsize, v3s16 &result_doorplace,
117         //              v3s16 &result_doordir, v3s16 &result_roomplace);
118
119 private:
120         VoxelManipulator &vmanip;
121         v3s16 m_pos;
122         v3s16 m_dir;
123         PseudoRandom &m_random;
124         INodeDefManager *m_ndef;
125 };
126
127
128 #endif