]> git.lizzy.rs Git - dragonfireclient.git/blob - src/mapgen.h
Merge pull request #482 from proller/liquid
[dragonfireclient.git] / src / mapgen.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 MAPGEN_HEADER
21 #define MAPGEN_HEADER
22
23 #include "irrlichttypes_extrabloated.h"
24 #include "util/container.h" // UniqueQueue
25 #include "gamedef.h"
26 #include "mapnode.h"
27 #include "noise.h"
28 #include "settings.h"
29 #include <map>
30
31 /////////////////// Mapgen flags
32 #define MG_TREES         0x01
33 #define MG_CAVES         0x02
34 #define MG_DUNGEONS      0x04
35 #define MGV6_FORESTS     0x08
36 #define MGV6_BIOME_BLEND 0x10
37 #define MG_FLAT          0x20
38
39 extern FlagDesc flagdesc_mapgen[];
40
41 class BiomeDefManager;
42 class Biome;
43 class EmergeManager;
44 class MapBlock;
45 class ManualMapVoxelManipulator;
46 class VoxelManipulator;
47 class INodeDefManager;
48 class BlockMakeData;
49
50 struct MapgenParams {
51         std::string mg_name;
52         int chunksize;
53         u64 seed;
54         int water_level;
55         u32 flags;
56
57         MapgenParams() {
58                 mg_name     = "v6";
59                 seed        = 0;
60                 water_level = 1;
61                 chunksize   = 5;
62                 flags       = MG_TREES | MG_CAVES | MGV6_BIOME_BLEND;
63         }
64         
65         virtual bool readParams(Settings *settings) = 0;
66         virtual void writeParams(Settings *settings) {};
67 };
68
69 class Mapgen {
70 public:
71         int seed;
72         int water_level;
73         bool generating;
74         int id;
75
76         virtual void makeChunk(BlockMakeData *data) {};
77         virtual int getGroundLevelAtPoint(v2s16 p) = 0;
78
79         //Legacy functions for Farmesh (pending removal)
80         static bool get_have_beach(u64 seed, v2s16 p2d);
81         static double tree_amount_2d(u64 seed, v2s16 p);
82         static s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
83 };
84
85 struct MapgenFactory {
86         virtual Mapgen *createMapgen(int mgid, MapgenParams *params,
87                                                                  EmergeManager *emerge) = 0;
88         virtual MapgenParams *createMapgenParams() = 0;
89 };
90
91 #endif
92