aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map.cpp35
-rw-r--r--src/map.h8
-rw-r--r--src/mapgen.cpp177
-rw-r--r--src/mapgen.h136
-rw-r--r--src/mapgen_v6.cpp22
-rw-r--r--src/mapgen_v6.h141
-rw-r--r--src/server.cpp13
7 files changed, 296 insertions, 236 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 6a058bb51..ea82194b8 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "gamedef.h"
#include "util/directiontables.h"
#include "rollback_interface.h"
+#include "mapgen_v6.h"
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
@@ -1993,10 +1994,9 @@ void Map::removeNodeTimer(v3s16 p)
/*
ServerMap
*/
-ServerMap::ServerMap(std::string savedir, IGameDef *gamedef):
+ServerMap::ServerMap(std::string savedir, IGameDef *gamedef, EmergeManager *emerge):
Map(dout_server, gamedef),
m_seed(0),
- m_emerge(NULL),
m_map_metadata_changed(true),
m_database(NULL),
m_database_read(NULL),
@@ -2004,9 +2004,8 @@ ServerMap::ServerMap(std::string savedir, IGameDef *gamedef):
{
verbosestream<<__FUNCTION_NAME<<std::endl;
- //m_chunksize = 8; // Takes a few seconds
-
- m_mgparams = MapgenParams::getParamsFromSettings(g_settings);
+ m_emerge = emerge;
+ m_mgparams = m_emerge->getParamsFromSettings(g_settings);
if (!m_mgparams)
m_mgparams = new MapgenV6Params();
@@ -3080,32 +3079,12 @@ void ServerMap::saveMapMeta()
Settings params;
params.set("mg_name", m_emerge->params->mg_name);
-
params.setU64("seed", m_emerge->params->seed);
params.setS16("water_level", m_emerge->params->water_level);
params.setS16("chunksize", m_emerge->params->chunksize);
params.setS32("mg_flags", m_emerge->params->flags);
-/* switch (m_emerge->params->mg_version) {
- case 6:
- {*/
- MapgenV6Params *v6params = (MapgenV6Params *)m_emerge->params;
-
- params.setFloat("mgv6_freq_desert", v6params->freq_desert);
- params.setFloat("mgv6_freq_beach", v6params->freq_beach);
- params.setNoiseParams("mgv6_np_terrain_base", v6params->np_terrain_base);
- params.setNoiseParams("mgv6_np_terrain_higher", v6params->np_terrain_higher);
- params.setNoiseParams("mgv6_np_steepness", v6params->np_steepness);
- params.setNoiseParams("mgv6_np_height_select", v6params->np_height_select);
- params.setNoiseParams("mgv6_np_trees", v6params->np_trees);
- params.setNoiseParams("mgv6_np_mud", v6params->np_mud);
- params.setNoiseParams("mgv6_np_beach", v6params->np_beach);
- params.setNoiseParams("mgv6_np_biome", v6params->np_biome);
- params.setNoiseParams("mgv6_np_cave", v6params->np_cave);
- /* break;
- }
- default:
- ; //complain here
- }*/
+
+ m_emerge->params->writeParams(&params);
params.writeLines(os);
@@ -3145,7 +3124,7 @@ void ServerMap::loadMapMeta()
params.parseConfigLine(line);
}
- MapgenParams *mgparams = MapgenParams::getParamsFromSettings(&params);
+ MapgenParams *mgparams = m_emerge->getParamsFromSettings(&params);
if (mgparams) {
if (m_mgparams)
delete m_mgparams;
diff --git a/src/map.h b/src/map.h
index 760b23de5..420fc29ca 100644
--- a/src/map.h
+++ b/src/map.h
@@ -358,7 +358,7 @@ public:
/*
savedir: directory to which map data should be saved
*/
- ServerMap(std::string savedir, IGameDef *gamedef);
+ ServerMap(std::string savedir, IGameDef *gamedef, EmergeManager *emerge);
~ServerMap();
s32 mapType() const
@@ -480,16 +480,12 @@ public:
MapgenParams *getMapgenParams(){ return m_mgparams; }
- void setEmerge(EmergeManager *emerge){ m_emerge = emerge; }
-
// Parameters fed to the Mapgen
MapgenParams *m_mgparams;
private:
// Seed used for all kinds of randomness in generation
u64 m_seed;
-
-
-
+
// Emerge manager
EmergeManager *m_emerge;
diff --git a/src/mapgen.cpp b/src/mapgen.cpp
index c86743459..f2745bdb4 100644
--- a/src/mapgen.cpp
+++ b/src/mapgen.cpp
@@ -33,66 +33,53 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h" // For g_settings
#include "main.h" // For g_profiler
#include "treegen.h"
-
-/////////////////// Mapgen V6 perlin noise default values
-NoiseParams nparams_v6_def_terrain_base =
- {-AVERAGE_MUD_AMOUNT, 20.0, v3f(250.0, 250.0, 250.0), 82341, 5, 0.6};
-NoiseParams nparams_v6_def_terrain_higher =
- {20.0, 16.0, v3f(500.0, 500.0, 500.0), 85039, 5, 0.6};
-NoiseParams nparams_v6_def_steepness =
- {0.85, 0.5, v3f(125.0, 125.0, 125.0), -932, 5, 0.7};
-NoiseParams nparams_v6_def_height_select =
- {0.5, 1.0, v3f(250.0, 250.0, 250.0), 4213, 5, 0.69};
-NoiseParams nparams_v6_def_trees =
- {0.0, 1.0, v3f(125.0, 125.0, 125.0), 2, 4, 0.66};
-NoiseParams nparams_v6_def_mud =
- {AVERAGE_MUD_AMOUNT, 2.0, v3f(200.0, 200.0, 200.0), 91013, 3, 0.55};
-NoiseParams nparams_v6_def_beach =
- {0.0, 1.0, v3f(250.0, 250.0, 250.0), 59420, 3, 0.50};
-NoiseParams nparams_v6_def_biome =
- {0.0, 1.0, v3f(250.0, 250.0, 250.0), 9130, 3, 0.50};
-NoiseParams nparams_v6_def_cave =
- {6.0, 6.0, v3f(250.0, 250.0, 250.0), 34329, 3, 0.50};
+#include "mapgen_v6.h"
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////// Emerge Manager ////////////////////////////////
-
-EmergeManager::EmergeManager(IGameDef *gamedef, BiomeDefManager *bdef,
- MapgenParams *mgparams) {
+EmergeManager::EmergeManager(IGameDef *gamedef, BiomeDefManager *bdef) {
+ //register built-in mapgens
+ registerMapgen("v6", new MapgenFactoryV6());
+
//the order of these assignments is pretty important
this->biomedef = bdef ? bdef : new BiomeDefManager(gamedef);
- this->params = mgparams;
+ this->params = NULL;
this->mapgen = NULL;
- this->mapgen = getMapgen();
}
EmergeManager::~EmergeManager() {
delete biomedef;
+ delete mapgen;
delete params;
}
+void EmergeManager::initMapgens(MapgenParams *mgparams) {
+ if (mapgen)
+ return;
+
+ this->params = mgparams;
+ this->mapgen = getMapgen(); //only one mapgen for now!
+}
+
+
Mapgen *EmergeManager::getMapgen() {
if (!mapgen) {
- /*switch (params->mg_version) {
- case 6:*/
- mapgen = new MapgenV6(0, (MapgenV6Params *)params);
- /* break;
- default:
- errorstream << "EmergeManager: Unsupported mapgen version "
- << params->mg_version << ", falling back to V6" << std::endl;
- params->mg_version = 6;
- mapgen = new MapgenV6(0, (MapgenV6Params *)params);
- }*/
+ mapgen = createMapgen(params->mg_name, 0, params, this);
+ if (!mapgen) {
+ infostream << "EmergeManager: falling back to mapgen v6" << std::endl;
+ delete params;
+ params = createMapgenParams("v6");
+ mapgen = createMapgen("v6", 0, params, this);
+ }
}
return mapgen;
}
-
void EmergeManager::addBlockToQueue() {
//STUB
}
@@ -127,60 +114,94 @@ u32 EmergeManager::getBlockSeed(v3s16 p) {
}
-MapgenParams *MapgenParams::createMapgenParams(std::string &mgstr) {
- return new MapgenV6Params(); // this will be fixed later
- /*switch (mgver) {
- case 6:
- return new MapgenV6Params();
- default: //instead of complaining, default to 6
- return new MapgenV6Params();
- }*/
+Mapgen *EmergeManager::createMapgen(std::string mgname, int mgid,
+ MapgenParams *mgparams, EmergeManager *emerge) {
+ std::map<std::string, MapgenFactory *>::const_iterator iter = mglist.find(mgname);
+ if (iter == mglist.end()) {
+ errorstream << "EmergeManager; mapgen " << mgname <<
+ " not registered" << std::endl;
+ return NULL;
+ }
+
+ MapgenFactory *mgfactory = iter->second;
+ return mgfactory->createMapgen(mgid, mgparams, emerge);
+}
+
+
+MapgenParams *EmergeManager::createMapgenParams(std::string mgname) {
+ std::map<std::string, MapgenFactory *>::const_iterator iter = mglist.find(mgname);
+ if (iter == mglist.end()) {
+ errorstream << "EmergeManager: mapgen " << mgname <<
+ " not registered" << std::endl;
+ return NULL;
+ }
+
+ MapgenFactory *mgfactory = iter->second;
+ return mgfactory->createMapgenParams();
}
-MapgenParams *MapgenParams::getParamsFromSettings(Settings *settings) {
+MapgenParams *EmergeManager::getParamsFromSettings(Settings *settings) {
std::string mg_name = settings->get("mg_name");
- MapgenParams *mgparams = MapgenParams::createMapgenParams(mg_name);
+ MapgenParams *mgparams = createMapgenParams(mg_name);
+
mgparams->mg_name = mg_name;
mgparams->seed = settings->getU64(settings == g_settings ? "fixed_map_seed" : "seed");
mgparams->water_level = settings->getS16("water_level");
mgparams->chunksize = settings->getS16("chunksize");
mgparams->flags = settings->getS32("mg_flags");
-/* switch (mg_version) {
- case 6:
- {*/
- MapgenV6Params *v6params = (MapgenV6Params *)mgparams;
-
- v6params->freq_desert = settings->getFloat("mgv6_freq_desert");
- v6params->freq_beach = settings->getFloat("mgv6_freq_beach");
- v6params->np_terrain_base = settings->getNoiseParams("mgv6_np_terrain_base");
- v6params->np_terrain_higher = settings->getNoiseParams("mgv6_np_terrain_higher");
- v6params->np_steepness = settings->getNoiseParams("mgv6_np_steepness");
- v6params->np_height_select = settings->getNoiseParams("mgv6_np_height_select");
- v6params->np_trees = settings->getNoiseParams("mgv6_np_trees");
- v6params->np_mud = settings->getNoiseParams("mgv6_np_mud");
- v6params->np_beach = settings->getNoiseParams("mgv6_np_beach");
- v6params->np_biome = settings->getNoiseParams("mgv6_np_biome");
- v6params->np_cave = settings->getNoiseParams("mgv6_np_cave");
-
- if (!v6params->np_terrain_base || !v6params->np_terrain_higher ||
- !v6params->np_steepness || !v6params->np_height_select ||
- !v6params->np_trees || !v6params->np_mud ||
- !v6params->np_beach || !v6params->np_biome || !v6params->np_cave) {
- delete mgparams;
- return NULL;
- }
-/*
- break;
- }
- default:
- delete mgparams;
- return NULL;
- }*/
-
+ if (!mgparams->readParams(settings)) {
+ delete mgparams;
+ return NULL;
+ }
return mgparams;
+}
+
+
+bool EmergeManager::registerMapgen(std::string mgname, MapgenFactory *mgfactory) {
+ mglist.insert(std::make_pair(mgname, mgfactory));
+ infostream << "EmergeManager: registered mapgen " << mgname << std::endl;
+}
+
+
+/////////////////////
+
+bool MapgenV6Params::readParams(Settings *settings) {
+ freq_desert = settings->getFloat("mgv6_freq_desert");
+ freq_beach = settings->getFloat("mgv6_freq_beach");
+
+ np_terrain_base = settings->getNoiseParams("mgv6_np_terrain_base");
+ np_terrain_higher = settings->getNoiseParams("mgv6_np_terrain_higher");
+ np_steepness = settings->getNoiseParams("mgv6_np_steepness");
+ np_height_select = settings->getNoiseParams("mgv6_np_height_select");
+ np_trees = settings->getNoiseParams("mgv6_np_trees");
+ np_mud = settings->getNoiseParams("mgv6_np_mud");
+ np_beach = settings->getNoiseParams("mgv6_np_beach");
+ np_biome = settings->getNoiseParams("mgv6_np_biome");
+ np_cave = settings->getNoiseParams("mgv6_np_cave");
+
+ bool success =
+ np_terrain_base && np_terrain_higher && np_steepness &&
+ np_height_select && np_trees && np_mud &&
+ np_beach && np_biome && np_cave;
+ return success;
+}
+
+void MapgenV6Params::writeParams(Settings *settings) {
+ settings->setFloat("mgv6_freq_desert", freq_desert);
+ settings->setFloat("mgv6_freq_beach", freq_beach);
+
+ settings->setNoiseParams("mgv6_np_terrain_base", np_terrain_base);
+ settings->setNoiseParams("mgv6_np_terrain_higher", np_terrain_higher);
+ settings->setNoiseParams("mgv6_np_steepness", np_steepness);
+ settings->setNoiseParams("mgv6_np_height_select", np_height_select);
+ settings->setNoiseParams("mgv6_np_trees", np_trees);
+ settings->setNoiseParams("mgv6_np_mud", np_mud);
+ settings->setNoiseParams("mgv6_np_beach", np_beach);
+ settings->setNoiseParams("mgv6_np_biome", np_biome);
+ settings->setNoiseParams("mgv6_np_cave", np_cave);
}
diff --git a/src/mapgen.h b/src/mapgen.h
index d508d37a8..728290ffc 100644
--- a/src/mapgen.h
+++ b/src/mapgen.h
@@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapnode.h"
#include "noise.h"
#include "settings.h"
+#include <map>
/////////////////// Mapgen flags
#define MG_TREES 0x01
@@ -34,39 +35,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define MGV6_FORESTS 0x08
#define MGV6_BIOME_BLEND 0x10
-#define AVERAGE_MUD_AMOUNT 4
-
class BiomeDefManager;
class Biome;
-
-//struct BlockMakeData;
+class EmergeManager;
class MapBlock;
class ManualMapVoxelManipulator;
class VoxelManipulator;
class INodeDefManager;
-extern NoiseParams nparams_v6_def_terrain_base;
-extern NoiseParams nparams_v6_def_terrain_higher;
-extern NoiseParams nparams_v6_def_steepness;
-extern NoiseParams nparams_v6_def_height_select;
-extern NoiseParams nparams_v6_def_trees;
-extern NoiseParams nparams_v6_def_mud;
-extern NoiseParams nparams_v6_def_beach;
-extern NoiseParams nparams_v6_def_biome;
-extern NoiseParams nparams_v6_def_cave;
-
-extern NoiseParams nparams_v7_def_terrain;
-extern NoiseParams nparams_v7_def_bgroup;
-extern NoiseParams nparams_v7_def_heat;
-extern NoiseParams nparams_v7_def_humidity;
-
-enum BiomeType
-{
- BT_NORMAL,
- BT_DESERT
-};
-
-
struct BlockMakeData {
bool no_op;
ManualMapVoxelManipulator *vmanip;
@@ -81,7 +57,6 @@ struct BlockMakeData {
~BlockMakeData();
};
-
struct MapgenParams {
std::string mg_name;
int chunksize;
@@ -96,41 +71,11 @@ struct MapgenParams {
chunksize = 5;
flags = MG_TREES | MG_CAVES | MGV6_BIOME_BLEND;
}
-
- static MapgenParams *createMapgenParams(std::string &mgname);
- static MapgenParams *getParamsFromSettings(Settings *settings);
-
-};
-
-struct MapgenV6Params : public MapgenParams {
- float freq_desert;
- float freq_beach;
- NoiseParams *np_terrain_base;
- NoiseParams *np_terrain_higher;
- NoiseParams *np_steepness;
- NoiseParams *np_height_select;
- NoiseParams *np_trees;
- NoiseParams *np_mud;
- NoiseParams *np_beach;
- NoiseParams *np_biome;
- NoiseParams *np_cave;
-
- MapgenV6Params() {
- freq_desert = 0.45;
- freq_beach = 0.15;
- np_terrain_base = &nparams_v6_def_terrain_base;
- np_terrain_higher = &nparams_v6_def_terrain_higher;
- np_steepness = &nparams_v6_def_steepness;
- np_height_select = &nparams_v6_def_height_select;
- np_trees = &nparams_v6_def_trees;
- np_mud = &nparams_v6_def_mud;
- np_beach = &nparams_v6_def_beach;
- np_biome = &nparams_v6_def_biome;
- np_cave = &nparams_v6_def_cave;
- }
+
+ virtual bool readParams(Settings *settings) = 0;
+ virtual void writeParams(Settings *settings) {};
};
-
class Mapgen {
public:
int seed;
@@ -147,64 +92,16 @@ public:
static s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
};
-
-class MapgenV6 : public Mapgen {
-public:
- //ManualMapVoxelManipulator &vmanip;
-
- int ystride;
- v3s16 csize;
-
- v3s16 node_min;
- v3s16 node_max;
-
- Noise *noise_terrain_base;
- Noise *noise_terrain_higher;
- Noise *noise_steepness;
- Noise *noise_height_select;
- Noise *noise_trees;
- Noise *noise_mud;
- Noise *noise_beach;
- Noise *noise_biome;
-
- float *map_terrain_base;
- float *map_terrain_higher;
- float *map_steepness;
- float *map_height_select;
- float *map_trees;
- float *map_mud;
- float *map_beach;
- float *map_biome;
-
- NoiseParams *np_cave;
-
- u32 flags;
- float freq_desert;
- float freq_beach;
-
- MapgenV6(int mapgenid, MapgenV6Params *params);
- ~MapgenV6();
-
- void makeChunk(BlockMakeData *data);
- int getGroundLevelAtPoint(v2s16 p);
-
- double baseRockLevelFromNoise(v2s16 p);
- static s16 find_ground_level(VoxelManipulator &vmanip, v2s16 p2d, INodeDefManager *ndef);
- static s16 find_stone_level(VoxelManipulator &vmanip, v2s16 p2d, INodeDefManager *ndef);
- void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0, bool is_apple_tree, INodeDefManager *ndef);
- double tree_amount_2d(u64 seed, v2s16 p);
- bool block_is_underground(u64 seed, v3s16 blockpos);
- double base_rock_level_2d(u64 seed, v2s16 p);
- s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
- double get_mud_add_amount(u64 seed, v2s16 p);
- bool get_have_beach(u64 seed, v2s16 p2d);
- BiomeType get_biome(u64 seed, v2s16 p2d);
- u32 get_blockseed(u64 seed, v3s16 p);
+struct MapgenFactory {
+ virtual Mapgen *createMapgen(int mgid, MapgenParams *params,
+ EmergeManager *emerge) = 0;
+ virtual MapgenParams *createMapgenParams() = 0;
};
-
class EmergeManager {
public:
+ std::map<std::string, MapgenFactory *> mglist;
+
//settings
MapgenParams *params;
@@ -214,12 +111,19 @@ public:
//biome manager
BiomeDefManager *biomedef;
- EmergeManager(IGameDef *gamedef, BiomeDefManager *bdef, MapgenParams *mgparams);
+ EmergeManager(IGameDef *gamedef, BiomeDefManager *bdef);
~EmergeManager();
+ void initMapgens(MapgenParams *mgparams);
+ Mapgen *createMapgen(std::string mgname, int mgid,
+ MapgenParams *mgparams, EmergeManager *emerge);
+ MapgenParams *createMapgenParams(std::string mgname);
Mapgen *getMapgen();
void addBlockToQueue();
-
+
+ bool registerMapgen(std::string name, MapgenFactory *mgfactory);
+ MapgenParams *getParamsFromSettings(Settings *settings);
+
//mapgen helper methods
Biome *getBiomeAtPoint(v3s16 p);
int getGroundLevelAtPoint(v2s16 p);
diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp
index a86edcca9..30df1673c 100644
--- a/src/mapgen_v6.cpp
+++ b/src/mapgen_v6.cpp
@@ -31,6 +31,27 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "profiler.h"
#include "settings.h" // For g_settings
#include "main.h" // For g_profiler
+#include "mapgen_v6.h"
+
+/////////////////// Mapgen V6 perlin noise default values
+NoiseParams nparams_v6_def_terrain_base =
+ {-AVERAGE_MUD_AMOUNT, 20.0, v3f(250.0, 250.0, 250.0), 82341, 5, 0.6};
+NoiseParams nparams_v6_def_terrain_higher =
+ {20.0, 16.0, v3f(500.0, 500.0, 500.0), 85039, 5, 0.6};
+NoiseParams nparams_v6_def_steepness =
+ {0.85, 0.5, v3f(125.0, 125.0, 125.0), -932, 5, 0.7};
+NoiseParams nparams_v6_def_height_select =
+ {0.5, 1.0, v3f(250.0, 250.0, 250.0), 4213, 5, 0.69};
+NoiseParams nparams_v6_def_trees =
+ {0.0, 1.0, v3f(125.0, 125.0, 125.0), 2, 4, 0.66};
+NoiseParams nparams_v6_def_mud =
+ {AVERAGE_MUD_AMOUNT, 2.0, v3f(200.0, 200.0, 200.0), 91013, 3, 0.55};
+NoiseParams nparams_v6_def_beach =
+ {0.0, 1.0, v3f(250.0, 250.0, 250.0), 59420, 3, 0.50};
+NoiseParams nparams_v6_def_biome =
+ {0.0, 1.0, v3f(250.0, 250.0, 250.0), 9130, 3, 0.50};
+NoiseParams nparams_v6_def_cave =
+ {6.0, 6.0, v3f(250.0, 250.0, 250.0), 34329, 3, 0.50};
///////////////////////////////////////////////////////////////////////////////
@@ -397,7 +418,6 @@ int MapgenV6::getGroundLevelAtPoint(v2s16 p) {
return baseRockLevelFromNoise(p) + AVERAGE_MUD_AMOUNT;
}
-
#define VMANIP_FLAG_CAVE VOXELFLAG_CHECKED1
void MapgenV6::makeChunk(BlockMakeData *data)
diff --git a/src/mapgen_v6.h b/src/mapgen_v6.h
new file mode 100644
index 000000000..9a2a0287d
--- /dev/null
+++ b/src/mapgen_v6.h
@@ -0,0 +1,141 @@
+/*
+Minetest-c55
+Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef MAPGENV6_HEADER
+#define MAPGENV6_HEADER
+
+#include "mapgen.h"
+
+#define AVERAGE_MUD_AMOUNT 4
+
+enum BiomeType
+{
+ BT_NORMAL,
+ BT_DESERT
+};
+
+extern NoiseParams nparams_v6_def_terrain_base;
+extern NoiseParams nparams_v6_def_terrain_higher;
+extern NoiseParams nparams_v6_def_steepness;
+extern NoiseParams nparams_v6_def_height_select;
+extern NoiseParams nparams_v6_def_trees;
+extern NoiseParams nparams_v6_def_mud;
+extern NoiseParams nparams_v6_def_beach;
+extern NoiseParams nparams_v6_def_biome;
+extern NoiseParams nparams_v6_def_cave;
+
+struct MapgenV6Params : public MapgenParams {
+ float freq_desert;
+ float freq_beach;
+ NoiseParams *np_terrain_base;
+ NoiseParams *np_terrain_higher;
+ NoiseParams *np_steepness;
+ NoiseParams *np_height_select;
+ NoiseParams *np_trees;
+ NoiseParams *np_mud;
+ NoiseParams *np_beach;
+ NoiseParams *np_biome;
+ NoiseParams *np_cave;
+
+ MapgenV6Params() {
+ freq_desert = 0.45;
+ freq_beach = 0.15;
+ np_terrain_base = &nparams_v6_def_terrain_base;
+ np_terrain_higher = &nparams_v6_def_terrain_higher;
+ np_steepness = &nparams_v6_def_steepness;
+ np_height_select = &nparams_v6_def_height_select;
+ np_trees = &nparams_v6_def_trees;
+ np_mud = &nparams_v6_def_mud;
+ np_beach = &nparams_v6_def_beach;
+ np_biome = &nparams_v6_def_biome;
+ np_cave = &nparams_v6_def_cave;
+ }
+
+ bool readParams(Settings *settings);
+ void writeParams(Settings *settings);
+};
+
+class MapgenV6 : public Mapgen {
+public:
+ //ManualMapVoxelManipulator &vmanip;
+
+ int ystride;
+ v3s16 csize;
+
+ v3s16 node_min;
+ v3s16 node_max;
+
+ Noise *noise_terrain_base;
+ Noise *noise_terrain_higher;
+ Noise *noise_steepness;
+ Noise *noise_height_select;
+ Noise *noise_trees;
+ Noise *noise_mud;
+ Noise *noise_beach;
+ Noise *noise_biome;
+
+ float *map_terrain_base;
+ float *map_terrain_higher;
+ float *map_steepness;
+ float *map_height_select;
+ float *map_trees;
+ float *map_mud;
+ float *map_beach;
+ float *map_biome;
+
+ NoiseParams *np_cave;
+
+ u32 flags;
+ float freq_desert;
+ float freq_beach;
+
+ MapgenV6(int mapgenid, MapgenV6Params *params);
+ ~MapgenV6();
+
+ void makeChunk(BlockMakeData *data);
+ int getGroundLevelAtPoint(v2s16 p);
+
+ double baseRockLevelFromNoise(v2s16 p);
+ static s16 find_ground_level(VoxelManipulator &vmanip,
+ v2s16 p2d, INodeDefManager *ndef);
+ static s16 find_stone_level(VoxelManipulator &vmanip,
+ v2s16 p2d, INodeDefManager *ndef);
+ void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
+ bool is_apple_tree, INodeDefManager *ndef);
+ double tree_amount_2d(u64 seed, v2s16 p);
+ bool block_is_underground(u64 seed, v3s16 blockpos);
+ double base_rock_level_2d(u64 seed, v2s16 p);
+ s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
+ double get_mud_add_amount(u64 seed, v2s16 p);
+ bool get_have_beach(u64 seed, v2s16 p2d);
+ BiomeType get_biome(u64 seed, v2s16 p2d);
+ u32 get_blockseed(u64 seed, v3s16 p);
+};
+
+struct MapgenFactoryV6 : public MapgenFactory {
+ Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge) {
+ return new MapgenV6(mgid, (MapgenV6Params *)params);
+ };
+
+ MapgenParams *createMapgenParams() {
+ return new MapgenV6Params();
+ };
+};
+
+#endif
diff --git a/src/server.cpp b/src/server.cpp
index d227474aa..a8640ad10 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -1097,15 +1097,14 @@ Server::Server(
// Add default biomes after nodedef had its aliases added
m_biomedef->addDefaultBiomes();
- // Initialize Environment
- ServerMap *servermap = new ServerMap(path_world, this);
- m_env = new ServerEnvironment(servermap, m_lua, this, this);
-
// Create emerge manager
- m_emerge = new EmergeManager(this, m_biomedef, servermap->getMapgenParams());
+ m_emerge = new EmergeManager(this, m_biomedef);
- // Give map pointer to the emerge manager
- servermap->setEmerge(m_emerge);
+ // Initialize Environment
+ ServerMap *servermap = new ServerMap(path_world, this, m_emerge);
+ m_env = new ServerEnvironment(servermap, m_lua, this, this);
+
+ m_emerge->initMapgens(servermap->getMapgenParams());
// Give environment reference to scripting api
scriptapi_add_environment(m_lua, m_env);