1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-12-22 23:58:48 -05:00

Clean up EmergeManager, do initial work on Mapgen configuration

This commit is contained in:
kwolekr 2012-12-26 03:15:16 -05:00 committed by Perttu Ahola
parent d5029958b9
commit cde3d38766
6 changed files with 328 additions and 150 deletions

View File

@ -2019,8 +2019,8 @@ ServerMap::ServerMap(std::string savedir, IGameDef *gamedef, EmergeManager *emer
{
m_seed = g_settings->getU64("fixed_map_seed");
}
emerge->seed = m_seed;
emerge->water_level = g_settings->getS16("default_water_level");
//emerge->params.seed = m_seed;
//emerge->params.water_level = g_settings->getS16("default_water_level");
//mapgen version
//chunksize
//noiseparams
@ -3078,8 +3078,31 @@ void ServerMap::saveMapMeta()
}
Settings params;
params.setU64("seed", m_seed);
params.setS16("water_level", m_emerge->water_level);
params.setS16("mg_version", m_emerge->mg_version);
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("flags", m_emerge->params->flags);
switch (m_emerge->mg_version) {
case 6:
{
MapgenV6Params *v6params = m_emerge->params;
params.setFloat("freq_desert", v6params->freq_desert);
params.setFloat("freq_beach", v6params->freq_beach);
break;
}
case 7:
{
MapgenV7Params *v7params = m_emerge->params;
break;
}
default:
; //complain here
}
params.writeLines(os);
@ -3119,10 +3142,36 @@ void ServerMap::loadMapMeta()
params.parseConfigLine(line);
}
m_seed = params.getU64("seed");
m_emerge->seed = m_seed;
m_emerge->water_level = params.getS16("water_level");
//m_emerge->np = ;
m_emerge->mg_version = params.getS16("mg_version");
m_emerge->setMapgenParams();
m_emerge->params->seed = params.getU64("seed");
m_emerge->params->water_level = params.getS16("water_level");
m_emerge->params->chunksize = params.getS16("chunksize");
m_emerge->params->flags = params.getS32("flags");
m_seed = m_emerge->params->seed;
switch (m_emerge->mg_version) {
case 6:
{
MapgenV6Params *v6params = m_emerge->params;
v6params->freq_desert = params.getFloat("freq_desert");
v6params->freq_beach = params.getFloat("freq_beach");
break;
}
case 7:
{
MapgenV7Params *v6params = m_emerge->params;
break;
}
default:
; //complain here
}
verbosestream<<"ServerMap::loadMapMeta(): "<<"seed="<<m_seed<<std::endl;
}

View File

@ -34,57 +34,45 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "main.h" // For g_profiler
#include "treegen.h"
NoiseParams nparams_mtdefault =
{10.0, 12.0, v3f(350., 350., 350.), 82341, 5, 0.6}; //terrain
NoiseParams nparams_def_bgroup =
{0.5, 1/(2*1.6), v3f(350., 350., 350.), 5923, 2, 0.60}; //0 to 1
NoiseParams nparams_def_heat =
{25.0, 50.0, v3f(500., 500., 500.), 35293, 1, 0.00}; //-25 to 75
NoiseParams nparams_def_humidity =
{50, 100/(2*1.6), v3f(750., 750., 750.), 12094, 2, 0.60}; //0 to 100
/*
MapgenV7Params mg_def_params_v7 = {
0,
1,
5,
MG_TREES | MG_CAVES | MG_DUNGEONS,
&nparams_v7_def_terrain,
&nparams_v7_def_bgroup,
&nparams_v7_def_heat,
&nparams_v7_def_humidity
};*/
///////////////////////////////////////////////////////////////////////////////
/*
Mapgen::Mapgen(BiomeDefManager *biomedef) {
Mapgen(0, 0, biomedef);
}*/
MapgenV7::MapgenV7(BiomeDefManager *biomedef, int mapgenid, u64 seed) {
init(biomedef, mapgenid, seed,
&nparams_mtdefault, &nparams_def_bgroup,
&nparams_def_heat, &nparams_def_humidity);
}
MapgenV7::MapgenV7(BiomeDefManager *biomedef, int mapgenid, u64 seed,
NoiseParams *np_terrain, NoiseParams *np_bgroup,
NoiseParams *np_heat, NoiseParams *np_humidity) {
init(biomedef, mapgenid, seed,
np_terrain, np_bgroup, np_heat, np_humidity);
}
void MapgenV7::init(BiomeDefManager *biomedef, int mapgenid, u64 seed,
NoiseParams *np_terrain, NoiseParams *np_bgroup,
NoiseParams *np_heat, NoiseParams *np_humidity) {
MapgenV7::MapgenV7(BiomeDefManager *biomedef, int mapgenid, MapgenV7Params *params) {
this->generating = false;
this->id = mapgenid;
this->seed = (int)seed;
this->biomedef = biomedef;
this->csize = v3s16(5, 5, 5) * MAP_BLOCKSIZE; /////////////////get this from config!
this->water_level = g_settings->getS16("default_water_level"); ////fix this!
this->ystride = csize.X;
this->seed = params->seed;
this->csize = v3s16(1, 1, 1) * params->chunksize * MAP_BLOCKSIZE; /////////////////get this from config!
this->water_level = params->water_level;
//g_settings->getS16("default_water_level");
/*
this->np_terrain = np_terrain;
this->np_bgroup = np_bgroup;
this->np_heat = np_heat;
this->np_humidity = np_humidity;
noise_terrain = new Noise(np_terrain, seed, csize.X, csize.Y);
noise_bgroup = new Noise(np_bgroup, seed, csize.X, csize.Y);
noise_heat = new Noise(np_heat, seed, csize.X, csize.Y);
noise_humidity = new Noise(np_humidity, seed, csize.X, csize.Y);
*/
noise_terrain = new Noise(params->np_terrain, seed, csize.X, csize.Y);
noise_bgroup = new Noise(params->np_bgroup, seed, csize.X, csize.Y);
noise_heat = new Noise(params->np_heat, seed, csize.X, csize.Y);
noise_humidity = new Noise(params->np_humidity, seed, csize.X, csize.Y);
this->ndef = biomedef->ndef;
n_air = MapNode(ndef->getId("mapgen_air"));
@ -122,9 +110,6 @@ void MapgenV7::makeChunk(BlockMakeData *data) {
this->ystride = em.X;
this->zstride = em.Y * em.X;
if (node_max.X - node_min.X != 80)
printf("uhoh, diff = %d, ystride = %d\n", node_max.X - node_min.X, ystride);
node_min = (data->blockpos_min) * MAP_BLOCKSIZE;
node_max = (data->blockpos_max + v3s16(1, 1, 1)) * MAP_BLOCKSIZE - v3s16(1, 1, 1);
v3s16 full_node_min = (data->blockpos_min - 1) * MAP_BLOCKSIZE;
@ -166,18 +151,18 @@ void MapgenV7::makeChunk(BlockMakeData *data) {
}
void MapgenV7::updateLiquid(v3s16 node_min, v3s16 node_max) {
void MapgenV7::updateLiquid(v3s16 nmin, v3s16 nmax) {
bool isliquid, wasliquid;
u32 i;
for (s16 z = node_min.Z; z <= node_max.Z; z++) {
for (s16 x = node_min.X; x <= node_max.X; x++) {
for (s16 z = nmin.Z; z <= nmax.Z; z++) {
for (s16 x = nmin.X; x <= nmax.X; x++) {
v2s16 p2d(x, z);
wasliquid = true;
v3s16 em = vmanip->m_area.getExtent();
i = vmanip->m_area.index(v3s16(p2d.X, node_max.Y, p2d.Y));
i = vmanip->m_area.index(v3s16(p2d.X, nmax.Y, p2d.Y));
for (s16 y = node_max.Y; y >= node_min.Y; y--) {
for (s16 y = nmax.Y; y >= nmin.Y; y--) {
isliquid = ndef->get(vmanip->m_data[i]).isLiquid();
//there was a change between liquid and nonliquid, add to queue
if (isliquid != wasliquid)
@ -191,12 +176,12 @@ void MapgenV7::updateLiquid(v3s16 node_min, v3s16 node_max) {
}
void MapgenV7::updateLighting(v3s16 node_min, v3s16 node_max) {
void MapgenV7::updateLighting(v3s16 nmin, v3s16 nmax) {
enum LightBank banks[2] = {LIGHTBANK_DAY, LIGHTBANK_NIGHT};
VoxelArea a(node_min - v3s16(1,0,1) * MAP_BLOCKSIZE,
node_max + v3s16(1,0,1) * MAP_BLOCKSIZE);
bool block_is_underground = (water_level > node_max.Y);
VoxelArea a(nmin - v3s16(1,0,1) * MAP_BLOCKSIZE,
nmax + v3s16(1,0,1) * MAP_BLOCKSIZE);
bool block_is_underground = (water_level > nmax.Y);
bool sunlight = !block_is_underground;
ScopeProfiler sp(g_profiler, "EmergeThread: mapgen lighting update", SPT_AVG);
@ -215,20 +200,55 @@ void MapgenV7::updateLighting(v3s16 node_min, v3s16 node_max) {
}
EmergeManager::EmergeManager(IGameDef *gamedef) {
this->seed = 0;
this->water_level = 0;
this->np_terrain = &nparams_mtdefault;
this->np_bgroup = &nparams_def_bgroup;
this->np_heat = &nparams_def_heat;
this->np_humidity = &nparams_def_humidity;
EmergeManager::EmergeManager(IGameDef *gamedef, int mg_version) {
this->mg_version = mg_version;
this->biomedef = new BiomeDefManager(gamedef);
this->biomedef = new BiomeDefManager(gamedef);
this->params = NULL;
setMapgenParams();
}
EmergeManager::~EmergeManager() {
delete biomedef;
delete params;
}
Mapgen *EmergeManager::getMapgen() {
if (!mapgen) {
switch (mg_version) {
case 6:
mapgen = new MapgenV6(0, params);
break;
case 7:
mapgen = new MapgenV7(biomedef, 0, params);
break;
default:
errorstream << "EmergeManager: Unsupported mapgen version "
<< mg_version << ", falling back to V6" << std::endl;
mg_version = 6;
mapgen = new MapgenV6(0, mgv6params);
}
}
return mapgen;
}
void EmergeManager::setMapgenParams() {
if (params)
delete params;
switch (mg_version) {
case 6:
params = new MapgenV6Params();
break;
case 7:
params = new MapgenV7Params();
break;
default: //////do something here!
;
}
}

View File

@ -58,18 +58,110 @@ struct BlockMakeData {
};
class Mapgen {
public:
/////////////////// Mapgen flags
#define MG_TREES 0x01
#define MG_CAVES 0x02
#define MG_DUNGEONS 0x04
#define MGV6_FORESTS 0x08
#define MGV6_BIOME_BLEND 0x10
#define AVERAGE_MUD_AMOUNT 4
/////////////////// 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), 85309, 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};
/////////////////// Mapgen V7 perlin noise default values
NoiseParams nparams_v7_def_terrain =
{10.0, 12.0, v3f(350., 350., 350.), 82341, 5, 0.6}; //terrain
NoiseParams nparams_v7_def_bgroup =
{0.5, 1/(2*1.6), v3f(350., 350., 350.), 5923, 2, 0.60}; //0 to 1
NoiseParams nparams_v7_def_heat =
{25.0, 50.0, v3f(500., 500., 500.), 35293, 1, 0.00}; //-25 to 75
NoiseParams nparams_v7_def_humidity =
{50, 100/(2*1.6), v3f(750., 750., 750.), 12094, 2, 0.60}; //0 to 100
struct MapgenParams {
int seed;
int water_level;
int chunksize;
u32 flags;
MapgenParams() {
seed = 0;
water_level = 1;
chunksize = 5;
flags = MG_TREES | MG_CAVES | MGV6_BIOME_BLEND;
}
};
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;
}
};
struct MapgenV7Params : public MapgenParams {
NoiseParams *np_terrain;
NoiseParams *np_bgroup;
NoiseParams *np_heat;
NoiseParams *np_humidity;
MapgenV7Params() {
np_terrain = &nparams_v7_def_terrain;
np_bgroup = &nparams_v7_def_bgroup;
np_heat = &nparams_v7_def_heat;
np_humidity = &nparams_v7_def_humidity;
}
};
class Mapgen {
public:
int seed;
int water_level;
bool generating;
int id;
//virtual Mapgen(BiomeDefManager *biomedef, int mapgenid=0, u64 seed=0);
//virtual ~Mapgen();
virtual void makeChunk(BlockMakeData *data) {};
//Legacy functions for Farmesh (pending removal)
@ -109,9 +201,11 @@ public:
float *map_biome;
float *map_cave;
bool use_smooth_biome_trans;
u32 flags;
float freq_desert;
float freq_beach;
MapgenV6(int mapgenid=0, u64 seed=0);
MapgenV6(int mapgenid, MapgenV6Params *params);
~MapgenV6();
void makeChunk(BlockMakeData *data);
@ -142,8 +236,6 @@ public:
int zstride;
v3s16 csize;
//int seed;
//int water_level;
Noise *noise_terrain;
Noise *noise_bgroup;
@ -160,24 +252,20 @@ public:
bool generating;
int id;
u32 flags;
/*
NoiseParams *np_terrain;
NoiseParams *np_bgroup;
NoiseParams *np_heat;
NoiseParams *np_humidity;
NoiseParams *np_humidity;*/
//should these be broken off into a "commonly used nodes" class?
MapNode n_air;
MapNode n_water;
MapNode n_lava;
MapgenV7(BiomeDefManager *biomedef, int mapgenid=0, u64 seed=0);
MapgenV7(BiomeDefManager *biomedef, int mapgenid, u64 seed,
NoiseParams *np_terrain, NoiseParams *np_bgroup,
NoiseParams *np_heat, NoiseParams *np_humidity);
void init(BiomeDefManager *biomedef, int mapgenid, u64 seed,
NoiseParams *np_terrain, NoiseParams *np_bgroup,
NoiseParams *np_heat, NoiseParams *np_humidity);
MapgenV7(BiomeDefManager *biomedef, int mapgenid, MapgenV7Params *params);
~MapgenV7();
void makeChunk(BlockMakeData *data);
@ -193,24 +281,22 @@ public:
class EmergeManager {
public:
//settings
u64 seed;
int water_level;
NoiseParams *np_terrain;
NoiseParams *np_bgroup;
NoiseParams *np_heat;
NoiseParams *np_humidity;
int mg_version;
MapgenParams *params;
//mapgen objects here
Mapgen *mapgen;
//biome manager
BiomeDefManager *biomedef;
//mapgen objects here
EmergeManager(IGameDef *gamedef);
EmergeManager(IGameDef *gamedef, int mg_version=6);
~EmergeManager();
Mapgen *getMapgen();
void setMapgenParams();
void addBlockToQueue();
//mapgen helper methods
Biome *getBiomeAtPoint(v3s16 p);
int getGroundLevelAtPoint(v2s16 p);

View File

@ -32,9 +32,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h" // For g_settings
#include "main.h" // For g_profiler
/*
#define AVERAGE_MUD_AMOUNT 4
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 =
@ -51,42 +51,54 @@ 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};
NoiseParams nparams_v6_def_cave =
{6.0, 6.0, v3f(250.0, 250.0, 250.0), 34329, 3, 0.50};
NoiseParams *np_terrain_base = &nparams_v6_def_terrain_base;
NoiseParams *np_terrain_higher = &nparams_v6_def_terrain_higher;
NoiseParams *np_steepness = &nparams_v6_def_steepness;
NoiseParams *np_height_select = &nparams_v6_def_height_select;
NoiseParams *np_trees = &nparams_v6_def_trees;
NoiseParams *np_mud = &nparams_v6_def_mud;
NoiseParams *np_beach = &nparams_v6_def_beach;
NoiseParams *np_biome = &nparams_v6_def_biome;
//NoiseParams *np_cave = &nparams_v6_def_cave;
MapgenV6Params mg_def_params_v6 = {
0,
1,
5,
MG_TREES | MG_CAVES | MGV6_BIOME_BLEND,
0.45,
0.15,
&nparams_v6_def_terrain_base,
&nparams_v6_def_terrain_higher,
&nparams_v6_def_steepness,
&nparams_v6_def_height_select,
&nparams_v6_def_trees,
&nparams_v6_def_mud,
&nparams_v6_def_beach,
&nparams_v6_def_biome,
&nparams_v6_def_cave
};
*/
///////////////////////////////////////////////////////////////////////////////
MapgenV6::MapgenV6(int mapgenid, u64 seed) {
MapgenV6::MapgenV6(int mapgenid, MapgenV6Params *params) {
this->generating = false;
this->id = mapgenid;
this->seed = (int)seed;
this->water_level = 1;
this->seed = params->seed;
this->water_level = params->water_level;
this->flags = flags;
this->csize = v3s16(1, 1, 1) * params->chunksize * MAP_BLOCKSIZE;
this->csize = v3s16(5, 5, 5) * MAP_BLOCKSIZE; /////////////////get this from config!
this->ystride = csize.X;
this->freq_desert = params->freq_desert;
this->freq_beach = params->freq_beach;
this->use_smooth_biome_trans = g_settings->getBool("mgv6_use_smooth_biome_trans");
this->ystride = csize.X; //////fix this
noise_terrain_base = new Noise(np_terrain_base, seed, csize.X, csize.Y);
noise_terrain_higher = new Noise(np_terrain_higher, seed, csize.X, csize.Y);
noise_steepness = new Noise(np_steepness, seed, csize.X, csize.Y);
noise_height_select = new Noise(np_height_select, seed, csize.X, csize.Y);
noise_trees = new Noise(np_trees, seed, csize.X, csize.Y);
noise_mud = new Noise(np_mud, seed, csize.X, csize.Y);
noise_beach = new Noise(np_beach, seed, csize.X, csize.Y);
noise_biome = new Noise(np_biome, seed, csize.X, csize.Y);
//noise_cave = new Noise(np_cave, seed, csize.X, csize.Y);
noise_terrain_base = new Noise(params->np_terrain_base, seed, csize.X, csize.Y);
noise_terrain_higher = new Noise(params->np_terrain_higher, seed, csize.X, csize.Y);
noise_steepness = new Noise(params->np_steepness, seed, csize.X, csize.Y);
noise_height_select = new Noise(params->np_height_select, seed, csize.X, csize.Y);
noise_trees = new Noise(params->np_trees, seed, csize.X, csize.Y);
noise_mud = new Noise(params->np_mud, seed, csize.X, csize.Y);
noise_beach = new Noise(params->np_beach, seed, csize.X, csize.Y);
noise_biome = new Noise(params->np_biome, seed, csize.X, csize.Y);
map_terrain_base = noise_terrain_base->result;
map_terrain_higher = noise_terrain_higher->result;
@ -96,7 +108,6 @@ MapgenV6::MapgenV6(int mapgenid, u64 seed) {
map_mud = noise_mud->result;
map_beach = noise_beach->result;
map_biome = noise_biome->result;
//map_cave = noise_cave->result;
}
@ -294,9 +305,7 @@ double MapgenV6::base_rock_level_2d(u64 seed, v2s16 p)
0.5+(float)p.X/250., 0.5+(float)p.Y/250.,
seed+82341, 5, 0.6);*/
double base = water_level + map_terrain_base[index];
//return base;
//printf("%f ", base);
//return base;
// Higher ground level
/*double higher = (double)WATER_LEVEL + 20. + 16. * noise2d_perlin(
0.5+(float)p.X/500., 0.5+(float)p.Y/500.,
@ -316,6 +325,7 @@ double MapgenV6::base_rock_level_2d(u64 seed, v2s16 p)
b = pow(b, 7);
b *= 5;
b = rangelim(b, 0.5, 1000.0);
// Values 1.5...100 give quite horrible looking slopes
if(b > 1.5 && b < 100.0){
if(b < 10.0)
@ -323,22 +333,19 @@ double MapgenV6::base_rock_level_2d(u64 seed, v2s16 p)
else
b = 100.0;
}
//dstream<<"b="<<b<<std::endl;
//double b = 20;
//b = 0.25;
// Offset to more low
double a_off = -0.20;
// High/low selector
/*double a = (double)0.5 + b * (a_off + noise2d_perlin(
0.5+(float)p.X/250., 0.5+(float)p.Y/250.,
seed+4213, 5, 0.69));*/
double a = 0.5 + b * (a_off + map_height_select[index]);
// Limit
a = rangelim(a, 0.0, 1.0);
//dstream<<"a="<<a<<std::endl;
double h = base*(1.0-a) + higher*a;
return h;
@ -367,7 +374,7 @@ bool MapgenV6::get_have_beach(u64 seed, v2s16 p2d)
int index = (p2d.Y - node_min.Z) * ystride + (p2d.X - node_min.X);
double sandnoise = map_beach[index];
return (sandnoise > 0.15);
return (sandnoise > freq_beach);
}
BiomeType MapgenV6::get_biome(u64 seed, v2s16 p2d)
@ -378,10 +385,11 @@ BiomeType MapgenV6::get_biome(u64 seed, v2s16 p2d)
seed+9130, 3, 0.50);*/
int index = (p2d.Y - node_min.Z) * ystride + (p2d.X - node_min.X);
double d = map_biome[index];
if(d > 0.45)
if(d > freq_desert)
return BT_DESERT;
if (use_smooth_biome_trans) {
if(d > 0.35 && (noise2d( p2d.X, p2d.Y, int(seed) ) + 1.0) > ( 0.45 - d ) * 20.0 )
if (flags & MGV6_BIOME_BLEND) {
if(d > freq_desert - 0.10 &&
(noise2d(p2d.X, p2d.Y, seed) + 1.0) > (freq_desert - d) * 20.0)
return BT_DESERT;
}
return BT_NORMAL;
@ -485,6 +493,10 @@ void MapgenV6::makeChunk(BlockMakeData *data)
x + 0.5 * noise_height_select->np->spread.X,
z + 0.5 * noise_height_select->np->spread.Z);
noise_trees->perlinMap2D(
x + 0.5 * noise_trees->np->spread.X,
z + 0.5 * noise_trees->np->spread.Z);
noise_mud->perlinMap2D(
x + 0.5 * noise_mud->np->spread.X,
z + 0.5 * noise_mud->np->spread.Z);
@ -497,11 +509,6 @@ void MapgenV6::makeChunk(BlockMakeData *data)
noise_biome->perlinMap2D(
x + 0.6 * noise_biome->np->spread.X,
z + 0.2 * noise_biome->np->spread.Z);
/* noise_cave->perlinMap2D(
x + 0.5 * noise_cave->np->spread.X,
z + 0.5 * noise_cave->np->spread.Z);
noise_cave->transformNoiseMap();*/
}
@ -625,9 +632,14 @@ void MapgenV6::makeChunk(BlockMakeData *data)
Loop this part, it will make stuff look older and newer nicely
*/
double cave_amount = 6.0 + 6.0 * noise2d_perlin(
/*double cave_amount = 6.0 + 6.0 * noise2d_perlin(
0.5+(double)node_min.X/250, 0.5+(double)node_min.Y/250,
data->seed+34329, 3, 0.50);
data->seed+34329, 3, 0.50);*/
double cave_amount = np_cave->offset + np_cave->scale * noise2d_perlin(
0.5 + (double)node_min.X / np_cave->spread.X,
0.5 + (double)node_min.Y / np_cave->spread.Y,
data->seed + np_cave->seed, np_cave->octaves, np_cave->persist);
const u32 age_loops = 2;
for(u32 i_age=0; i_age<age_loops; i_age++)
@ -651,12 +663,17 @@ void MapgenV6::makeChunk(BlockMakeData *data)
PseudoRandom ps2(blockseed+1032);
if(ps.range(1, 6) == 1)
bruises_count = ps.range(0, ps.range(0, 2));
if(get_biome(data->seed, v2s16(node_min.X, node_min.Y)) == BT_DESERT){
if(get_biome(data->seed, v2s16(node_min.X, node_min.Z)) == BT_DESERT){
caves_count /= 3;
bruises_count /= 3;
}
for(u32 jj=0; jj<caves_count+bruises_count; jj++)
{
int avg_height = (int)
((base_rock_level_2d(data->seed, v2s16(node_min.X, node_min.Z)) +
base_rock_level_2d(data->seed, v2s16(node_max.X, node_max.Z))) / 2);
if ((node_max.Y + node_min.Y) / 2 > avg_height)
break;
bool large_cave = (jj >= caves_count);
s16 min_tunnel_diameter = 2;
s16 max_tunnel_diameter = ps.range(2,6);
@ -984,7 +1001,7 @@ void MapgenV6::makeChunk(BlockMakeData *data)
/*
Add blobs of dirt and gravel underground
*/
if(get_biome(data->seed, v2s16(node_min.X, node_min.Y)) == BT_NORMAL)
if(get_biome(data->seed, v2s16(node_min.X, node_min.Z)) == BT_NORMAL)
{
PseudoRandom pr(blockseed+983);
for(int i=0; i<volume_nodes/10/10/10; i++)

View File

@ -4464,6 +4464,10 @@ static int l_register_biome_groups(lua_State *L)
throw LuaError(L, "register_biome_groups: parameter is not a table");
BiomeDefManager *bmgr = get_server(L)->getEmergeManager()->biomedef;
if (!bmgr) {
verbosestream << "register_biome_groups: BiomeDefManager not active" << std::endl;
return 0;
}
lua_pushnil(L);
for (int i = 1; lua_next(L, index) != 0; i++) {
@ -4484,6 +4488,10 @@ static int l_register_biome(lua_State *L)
IWritableNodeDefManager *ndef = get_server(L)->getWritableNodeDefManager();
BiomeDefManager *bmgr = get_server(L)->getEmergeManager()->biomedef;
if (!bmgr) {
verbosestream << "register_biome: BiomeDefManager not active" << std::endl;
return 0;
}
groupid = getintfield_default(L, index, "group_id", 0);

View File

@ -172,12 +172,8 @@ void * EmergeThread::Thread()
ServerMap &map = ((ServerMap&)m_server->m_env->getMap());
EmergeManager *emerge = m_server->m_emerge;
Mapgen *mapgen = emerge->getMapgen();
Mapgen *mapgen;
if (g_settings->getS16("use_mapgen_version") == 7) ////////this is okay for now, fix later
mapgen = new MapgenV7( m_server->m_emerge->biomedef,/*mapgenid*/ 0, map.getSeed());
else
mapgen = new MapgenV6(0, map.getSeed());
/*
Get block info from queue, emerge them and send them
to clients.
@ -800,6 +796,7 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime,
} else {
if(nearest_emergefull_d == -1)
nearest_emergefull_d = d;
goto queue_full_break;
}
// get next one.
@ -988,7 +985,7 @@ Server::Server(
infostream<<"- game: "<<m_gamespec.path<<std::endl;
// Create emerge manager
m_emerge = new EmergeManager(this);
m_emerge = new EmergeManager(this, g_settings->getS16("use_mapgen_version"));
// Create rollback manager
std::string rollback_path = m_path_world+DIR_DELIM+"rollback.txt";
@ -1097,7 +1094,8 @@ Server::Server(
m_nodedef->updateAliases(m_itemdef);
// Add default biomes after nodedef had its aliases added
m_emerge->biomedef->addDefaultBiomes();
if (m_emerge->biomedef)
m_emerge->biomedef->addDefaultBiomes();
// Initialize Environment