forked from Mirrorlandia_minetest/minetest
Readded and optimized mapgen V6
This commit is contained in:
parent
bddd5f2b98
commit
d5029958b9
@ -1587,7 +1587,7 @@ minetest.register_alias("mapgen_stone_with_iron", "default:stone_with_iron")
|
|||||||
minetest.register_alias("mapgen_mese", "default:mese")
|
minetest.register_alias("mapgen_mese", "default:mese")
|
||||||
|
|
||||||
minetest.register_biome_groups({
|
minetest.register_biome_groups({
|
||||||
0.35, 0.30, 0.20
|
0.35, 0.10, 0.30
|
||||||
})
|
})
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -1619,7 +1619,7 @@ minetest.register_biome({
|
|||||||
num_top_nodes = 5,
|
num_top_nodes = 5,
|
||||||
height_min = -3000,
|
height_min = -3000,
|
||||||
height_max = 3000,
|
height_max = 3000,
|
||||||
heat_min = 60.0,
|
heat_min = 5.0,
|
||||||
heat_max = 100.0,
|
heat_max = 100.0,
|
||||||
humidity_min = 0.0,
|
humidity_min = 0.0,
|
||||||
humidity_max = 100.0,
|
humidity_max = 100.0,
|
||||||
@ -1627,6 +1627,23 @@ minetest.register_biome({
|
|||||||
offset = 5.0,
|
offset = 5.0,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_biome({
|
||||||
|
group_id = 1,
|
||||||
|
name = "Gravel Beach",
|
||||||
|
terrain_type = "normal",
|
||||||
|
node_top = "default:gravel",
|
||||||
|
node_filler = "default:cobble",
|
||||||
|
num_top_nodes = 5,
|
||||||
|
height_min = -3000,
|
||||||
|
height_max = 3000,
|
||||||
|
heat_min = -50.0,
|
||||||
|
heat_max = 5.0,
|
||||||
|
humidity_min = 0.0,
|
||||||
|
humidity_max = 100.0,
|
||||||
|
scale = 5.0,
|
||||||
|
offset = 5.0,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_biome({
|
minetest.register_biome({
|
||||||
group_id = 2,
|
group_id = 2,
|
||||||
name = "Land",
|
name = "Land",
|
||||||
@ -1641,7 +1658,7 @@ minetest.register_biome({
|
|||||||
humidity_min = 0.0,
|
humidity_min = 0.0,
|
||||||
humidity_max = 100.0,
|
humidity_max = 100.0,
|
||||||
scale = 12.0,
|
scale = 12.0,
|
||||||
offset = 10.0,
|
offset = 20.0,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_biome({
|
minetest.register_biome({
|
||||||
@ -1657,8 +1674,8 @@ minetest.register_biome({
|
|||||||
heat_max = 100.0,
|
heat_max = 100.0,
|
||||||
humidity_min = 0.0,
|
humidity_min = 0.0,
|
||||||
humidity_max = 100.0,
|
humidity_max = 100.0,
|
||||||
scale = 70.0,
|
scale = 60.0,
|
||||||
offset = 30.0,
|
offset = 20.0,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,6 +188,7 @@ set(common_SRCS
|
|||||||
log.cpp
|
log.cpp
|
||||||
content_sao.cpp
|
content_sao.cpp
|
||||||
mapgen.cpp
|
mapgen.cpp
|
||||||
|
mapgen_v6.cpp
|
||||||
treegen.cpp
|
treegen.cpp
|
||||||
content_nodemeta.cpp
|
content_nodemeta.cpp
|
||||||
content_mapnode.cpp
|
content_mapnode.cpp
|
||||||
|
@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "biome.h"
|
#include "biome.h"
|
||||||
#include "nodedef.h"
|
#include "nodedef.h"
|
||||||
#include "map.h" //for ManualMapVoxelManipulator
|
#include "map.h" //for ManualMapVoxelManipulator
|
||||||
|
#include "log.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#define BT_NONE 0
|
#define BT_NONE 0
|
||||||
@ -64,15 +65,15 @@ int bg4_biomes[] = {BT_HILLS, BT_EXTREMEHILLS, BT_MOUNTAINS, BT_DESERT, BT_DESE
|
|||||||
float bg5_temps[] = {5.0, 40.0};
|
float bg5_temps[] = {5.0, 40.0};
|
||||||
int bg5_biomes[] = {BT_LAKE, BT_PLAINS, BT_DESERT};*/
|
int bg5_biomes[] = {BT_LAKE, BT_PLAINS, BT_DESERT};*/
|
||||||
|
|
||||||
NoiseParams np_default = {0.0, 20.0, v3f(250., 250., 250.), 82341, 5, 0.6};
|
NoiseParams np_default = {20.0, 15.0, v3f(250., 250., 250.), 82341, 5, 0.6};
|
||||||
|
|
||||||
|
|
||||||
BiomeDefManager::BiomeDefManager(IGameDef *gamedef) {
|
BiomeDefManager::BiomeDefManager(IGameDef *gamedef) {
|
||||||
this->m_gamedef = gamedef;
|
this->m_gamedef = gamedef;
|
||||||
this->ndef = gamedef->ndef();
|
this->ndef = gamedef->ndef();
|
||||||
|
|
||||||
bgroups.push_back(new std::vector<Biome *>); //the initial biome group
|
//the initial biome group
|
||||||
//addDefaultBiomes(); //can't do this in the ctor, too early
|
bgroups.push_back(new std::vector<Biome *>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -106,20 +107,26 @@ void BiomeDefManager::addBiomeGroup(float freq) {
|
|||||||
newfreq += bgroup_freqs[size - 1];
|
newfreq += bgroup_freqs[size - 1];
|
||||||
bgroup_freqs.push_back(newfreq);
|
bgroup_freqs.push_back(newfreq);
|
||||||
bgroups.push_back(new std::vector<Biome *>);
|
bgroups.push_back(new std::vector<Biome *>);
|
||||||
printf("added biome with freq %f\n", newfreq);
|
|
||||||
|
verbosestream << "BiomeDefManager: added biome group with frequency " <<
|
||||||
|
newfreq << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BiomeDefManager::addBiome(int groupid, Biome *b) {
|
void BiomeDefManager::addBiome(Biome *b) {
|
||||||
std::vector<Biome *> *bgroup;
|
std::vector<Biome *> *bgroup;
|
||||||
|
|
||||||
if (groupid >= bgroups.size()) {
|
if (b->groupid >= bgroups.size()) {
|
||||||
printf("blahblahblah");
|
errorstream << "BiomeDefManager: attempted to add biome '" << b->name
|
||||||
|
<< "' to nonexistent biome group " << b->groupid << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bgroup = bgroups[groupid];
|
bgroup = bgroups[b->groupid];
|
||||||
bgroup->push_back(b);
|
bgroup->push_back(b);
|
||||||
|
|
||||||
|
verbosestream << "BiomeDefManager: added biome '" << b->name <<
|
||||||
|
"' to biome group " << b->groupid << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -156,7 +163,7 @@ Biome *BiomeDefManager::getBiome(float bgfreq, float heat, float humidity) {
|
|||||||
|
|
||||||
int nbiomes = bgroup->size();
|
int nbiomes = bgroup->size();
|
||||||
for (i = 0; i != nbiomes; i++) {
|
for (i = 0; i != nbiomes; i++) {
|
||||||
b = bgroup->operator[](i);///////////////////////////
|
b = bgroup->operator[](i);
|
||||||
if (heat >= b->heat_min && heat <= b->heat_max &&
|
if (heat >= b->heat_min && heat <= b->heat_max &&
|
||||||
humidity >= b->humidity_min && humidity <= b->humidity_max)
|
humidity >= b->humidity_min && humidity <= b->humidity_max)
|
||||||
return b;
|
return b;
|
||||||
@ -174,9 +181,24 @@ int Biome::getSurfaceHeight(float noise_terrain) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Biome::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
void Biome::genColumn(MapgenV7 *mg, int x, int z, int y1, int y2) {
|
||||||
int i = (z - mg->node_min.Z) * mg->csize.Z + (x - mg->node_min.X);
|
int i = (z - mg->node_min.Z) * mg->csize.Z + (x - mg->node_min.X);
|
||||||
int surfaceh = np->offset + np->scale * mg->map_terrain[i];
|
int surfaceh = np->offset + np->scale * mg->map_terrain[i];
|
||||||
|
|
||||||
|
/*///experimental
|
||||||
|
if (groupid > 0) {
|
||||||
|
float prevfreq = mg->biomedef->bgroup_freqs[groupid - 1];
|
||||||
|
float range = mg->biomedef->bgroup_freqs[groupid] - prevfreq;
|
||||||
|
float factor = (mg->map_bgroup[i] - prevfreq) / range;
|
||||||
|
|
||||||
|
std::vector<Biome *> *bg = mg->biomedef->bgroups[groupid - 1];
|
||||||
|
Biome *b = (*bg)[0];
|
||||||
|
int h1 = b->np->offset + b->np->scale * mg->map_terrain[i];
|
||||||
|
surfaceh += (int)round((surfaceh - h1) * factor);
|
||||||
|
//printf("h1: %d, surfaceh: %d, factor %f\n", h1, surfaceh, factor);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
int y = y1;
|
int y = y1;
|
||||||
|
|
||||||
i = mg->vmanip->m_area.index(x, y, z);
|
i = mg->vmanip->m_area.index(x, y, z);
|
||||||
@ -189,12 +211,10 @@ void Biome::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////// [ Ocean biome ] /////////////////////////////////
|
///////////////////////////// [ Ocean biome ] /////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
void BiomeLiquid::genColumn(MapgenV7 *mg, int x, int z, int y1, int y2) {
|
||||||
void BiomeLiquid::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
|
||||||
int i = (z - mg->node_min.Z) * mg->csize.Z + (x - mg->node_min.X);
|
int i = (z - mg->node_min.Z) * mg->csize.Z + (x - mg->node_min.X);
|
||||||
int surfaceh = np->offset + np->scale * mg->map_terrain[i];
|
int surfaceh = np->offset + np->scale * mg->map_terrain[i];
|
||||||
int y = y1;
|
int y = y1;
|
||||||
@ -219,7 +239,7 @@ int BiomeHell::getSurfaceHeight(float noise_terrain) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BiomeHell::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
void BiomeHell::genColumn(MapgenV7 *mg, int x, int z, int y1, int y2) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +252,7 @@ int BiomeAether::getSurfaceHeight(float noise_terrain) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BiomeAether::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
void BiomeAether::genColumn(MapgenV7 *mg, int x, int z, int y1, int y2) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,6 +265,15 @@ int BiomeSuperflat::getSurfaceHeight(float noise_terrain) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BiomeSuperflat::genColumn(Mapgen *mg, int x, int z, int y1, int y2) {
|
void BiomeSuperflat::genColumn(MapgenV7 *mg, int x, int z, int y1, int y2) {
|
||||||
|
int surfaceh = ntopnodes;
|
||||||
|
int y = y1;
|
||||||
|
|
||||||
|
int i = mg->vmanip->m_area.index(x, y, z);
|
||||||
|
for (; y <= surfaceh - ntopnodes && y <= y2; y++, i += mg->ystride)
|
||||||
|
mg->vmanip->m_data[i] = n_filler;
|
||||||
|
for (; y <= surfaceh && y <= y2; y++, i += mg->ystride)
|
||||||
|
mg->vmanip->m_data[i] = n_top;
|
||||||
|
for (; y <= y2; y++, i += mg->ystride)
|
||||||
|
mg->vmanip->m_data[i] = mg->n_air;
|
||||||
}
|
}
|
||||||
|
15
src/biome.h
15
src/biome.h
@ -42,7 +42,8 @@ public:
|
|||||||
MapNode n_top;
|
MapNode n_top;
|
||||||
MapNode n_filler;
|
MapNode n_filler;
|
||||||
s16 ntopnodes;
|
s16 ntopnodes;
|
||||||
s16 flags;
|
s8 groupid;
|
||||||
|
s8 flags;
|
||||||
s16 height_min;
|
s16 height_min;
|
||||||
s16 height_max;
|
s16 height_max;
|
||||||
float heat_min;
|
float heat_min;
|
||||||
@ -52,26 +53,26 @@ public:
|
|||||||
std::string name;
|
std::string name;
|
||||||
NoiseParams *np;
|
NoiseParams *np;
|
||||||
|
|
||||||
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
virtual void genColumn(MapgenV7 *mg, int x, int z, int y1, int y2);
|
||||||
virtual int getSurfaceHeight(float noise_terrain);
|
virtual int getSurfaceHeight(float noise_terrain);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BiomeLiquid : public Biome {
|
class BiomeLiquid : public Biome {
|
||||||
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
virtual void genColumn(MapgenV7 *mg, int x, int z, int y1, int y2);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BiomeHell : public Biome {
|
class BiomeHell : public Biome {
|
||||||
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
virtual void genColumn(MapgenV7 *mg, int x, int z, int y1, int y2);
|
||||||
virtual int getSurfaceHeight(float noise_terrain);
|
virtual int getSurfaceHeight(float noise_terrain);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BiomeAether : public Biome {
|
class BiomeAether : public Biome {
|
||||||
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
virtual void genColumn(MapgenV7 *mg, int x, int z, int y1, int y2);
|
||||||
virtual int getSurfaceHeight(float noise_terrain);
|
virtual int getSurfaceHeight(float noise_terrain);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BiomeSuperflat : public Biome {
|
class BiomeSuperflat : public Biome {
|
||||||
virtual void genColumn(Mapgen *mg, int x, int z, int y1, int y2);
|
virtual void genColumn(MapgenV7 *mg, int x, int z, int y1, int y2);
|
||||||
virtual int getSurfaceHeight(float noise_terrain);
|
virtual int getSurfaceHeight(float noise_terrain);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ public:
|
|||||||
Biome *getBiome(float bgfreq, float heat, float humidity);
|
Biome *getBiome(float bgfreq, float heat, float humidity);
|
||||||
|
|
||||||
void addBiomeGroup(float freq);
|
void addBiomeGroup(float freq);
|
||||||
void addBiome(int groupid, Biome *b);
|
void addBiome(Biome *b);
|
||||||
void addDefaultBiomes();
|
void addDefaultBiomes();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -153,6 +153,7 @@ void set_default_settings(Settings *settings)
|
|||||||
|
|
||||||
settings->setDefault("profiler_print_interval", "0");
|
settings->setDefault("profiler_print_interval", "0");
|
||||||
settings->setDefault("enable_mapgen_debug_info", "false");
|
settings->setDefault("enable_mapgen_debug_info", "false");
|
||||||
|
settings->setDefault("use_mapgen_version", "6");
|
||||||
settings->setDefault("active_object_send_range_blocks", "3");
|
settings->setDefault("active_object_send_range_blocks", "3");
|
||||||
settings->setDefault("active_block_range", "2");
|
settings->setDefault("active_block_range", "2");
|
||||||
//settings->setDefault("max_simultaneous_block_sends_per_client", "1");
|
//settings->setDefault("max_simultaneous_block_sends_per_client", "1");
|
||||||
@ -169,6 +170,7 @@ void set_default_settings(Settings *settings)
|
|||||||
settings->setDefault("full_block_send_enable_min_time_from_building", "2.0");
|
settings->setDefault("full_block_send_enable_min_time_from_building", "2.0");
|
||||||
settings->setDefault("dedicated_server_step", "0.1");
|
settings->setDefault("dedicated_server_step", "0.1");
|
||||||
settings->setDefault("ignore_world_load_errors", "false");
|
settings->setDefault("ignore_world_load_errors", "false");
|
||||||
|
settings->setDefault("mgv6_use_smooth_biome_trans", "true"); //temporary
|
||||||
settings->setDefault("congestion_control_aim_rtt", "0.2");
|
settings->setDefault("congestion_control_aim_rtt", "0.2");
|
||||||
settings->setDefault("congestion_control_max_rate", "400");
|
settings->setDefault("congestion_control_max_rate", "400");
|
||||||
settings->setDefault("congestion_control_min_rate", "10");
|
settings->setDefault("congestion_control_min_rate", "10");
|
||||||
|
246
src/map.cpp
246
src/map.cpp
@ -39,13 +39,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
/*
|
/*
|
||||||
SQLite format specification:
|
SQLite format specification:
|
||||||
- Initially only replaces sectors/ and sectors2/
|
- Initially only replaces sectors/ and sectors2/
|
||||||
|
|
||||||
If map.sqlite does not exist in the save dir
|
If map.sqlite does not exist in the save dir
|
||||||
or the block was not found in the database
|
or the block was not found in the database
|
||||||
the map will try to load from sectors folder.
|
the map will try to load from sectors folder.
|
||||||
In either case, map.sqlite will be created
|
In either case, map.sqlite will be created
|
||||||
and all future saves will save there.
|
and all future saves will save there.
|
||||||
|
|
||||||
Structure of map.sqlite:
|
Structure of map.sqlite:
|
||||||
Tables:
|
Tables:
|
||||||
blocks
|
blocks
|
||||||
@ -108,14 +108,14 @@ MapSector * Map::getSectorNoGenerateNoExNoLock(v2s16 p)
|
|||||||
MapSector * sector = m_sector_cache;
|
MapSector * sector = m_sector_cache;
|
||||||
return sector;
|
return sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
core::map<v2s16, MapSector*>::Node *n = m_sectors.find(p);
|
core::map<v2s16, MapSector*>::Node *n = m_sectors.find(p);
|
||||||
|
|
||||||
if(n == NULL)
|
if(n == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
MapSector *sector = n->getValue();
|
MapSector *sector = n->getValue();
|
||||||
|
|
||||||
// Cache the last result
|
// Cache the last result
|
||||||
m_sector_cache_p = p;
|
m_sector_cache_p = p;
|
||||||
m_sector_cache = sector;
|
m_sector_cache = sector;
|
||||||
@ -133,7 +133,7 @@ MapSector * Map::getSectorNoGenerate(v2s16 p)
|
|||||||
MapSector *sector = getSectorNoGenerateNoEx(p);
|
MapSector *sector = getSectorNoGenerateNoEx(p);
|
||||||
if(sector == NULL)
|
if(sector == NULL)
|
||||||
throw InvalidPositionException();
|
throw InvalidPositionException();
|
||||||
|
|
||||||
return sector;
|
return sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ MapBlock * Map::getBlockNoCreateNoEx(v3s16 p3d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MapBlock * Map::getBlockNoCreate(v3s16 p3d)
|
MapBlock * Map::getBlockNoCreate(v3s16 p3d)
|
||||||
{
|
{
|
||||||
MapBlock *block = getBlockNoCreateNoEx(p3d);
|
MapBlock *block = getBlockNoCreateNoEx(p3d);
|
||||||
if(block == NULL)
|
if(block == NULL)
|
||||||
throw InvalidPositionException();
|
throw InvalidPositionException();
|
||||||
@ -248,10 +248,10 @@ void Map::unspreadLight(enum LightBank bank,
|
|||||||
v3s16(0,-1,0), // bottom
|
v3s16(0,-1,0), // bottom
|
||||||
v3s16(-1,0,0), // left
|
v3s16(-1,0,0), // left
|
||||||
};
|
};
|
||||||
|
|
||||||
if(from_nodes.size() == 0)
|
if(from_nodes.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
u32 blockchangecount = 0;
|
u32 blockchangecount = 0;
|
||||||
|
|
||||||
core::map<v3s16, u8> unlighted_nodes;
|
core::map<v3s16, u8> unlighted_nodes;
|
||||||
@ -265,12 +265,12 @@ void Map::unspreadLight(enum LightBank bank,
|
|||||||
MapBlock *block = NULL;
|
MapBlock *block = NULL;
|
||||||
// Cache this a bit, too
|
// Cache this a bit, too
|
||||||
bool block_checked_in_modified = false;
|
bool block_checked_in_modified = false;
|
||||||
|
|
||||||
for(; j.atEnd() == false; j++)
|
for(; j.atEnd() == false; j++)
|
||||||
{
|
{
|
||||||
v3s16 pos = j.getNode()->getKey();
|
v3s16 pos = j.getNode()->getKey();
|
||||||
v3s16 blockpos = getNodeBlockPos(pos);
|
v3s16 blockpos = getNodeBlockPos(pos);
|
||||||
|
|
||||||
// Only fetch a new block if the block position has changed
|
// Only fetch a new block if the block position has changed
|
||||||
try{
|
try{
|
||||||
if(block == NULL || blockpos != blockpos_last){
|
if(block == NULL || blockpos != blockpos_last){
|
||||||
@ -693,7 +693,7 @@ void Map::updateLighting(enum LightBank bank,
|
|||||||
core::map<v3s16, u8> unlight_from;
|
core::map<v3s16, u8> unlight_from;
|
||||||
|
|
||||||
int num_bottom_invalid = 0;
|
int num_bottom_invalid = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
//TimeTaker t("first stuff");
|
//TimeTaker t("first stuff");
|
||||||
|
|
||||||
@ -847,7 +847,7 @@ void Map::updateLighting(enum LightBank bank,
|
|||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
//MapVoxelManipulator vmanip(this);
|
//MapVoxelManipulator vmanip(this);
|
||||||
|
|
||||||
// Make a manual voxel manipulator and load all the blocks
|
// Make a manual voxel manipulator and load all the blocks
|
||||||
// that touch the requested blocks
|
// that touch the requested blocks
|
||||||
ManualMapVoxelManipulator vmanip(this);
|
ManualMapVoxelManipulator vmanip(this);
|
||||||
@ -938,7 +938,7 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
|
|||||||
/*PrintInfo(m_dout);
|
/*PrintInfo(m_dout);
|
||||||
m_dout<<DTIME<<"Map::addNodeAndUpdate(): p=("
|
m_dout<<DTIME<<"Map::addNodeAndUpdate(): p=("
|
||||||
<<p.X<<","<<p.Y<<","<<p.Z<<")"<<std::endl;*/
|
<<p.X<<","<<p.Y<<","<<p.Z<<")"<<std::endl;*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
From this node to nodes underneath:
|
From this node to nodes underneath:
|
||||||
If lighting is sunlight (1.0), unlight neighbours and
|
If lighting is sunlight (1.0), unlight neighbours and
|
||||||
@ -951,7 +951,7 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
|
|||||||
|
|
||||||
bool node_under_sunlight = true;
|
bool node_under_sunlight = true;
|
||||||
core::map<v3s16, bool> light_sources;
|
core::map<v3s16, bool> light_sources;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Collect old node for rollback
|
Collect old node for rollback
|
||||||
*/
|
*/
|
||||||
@ -1440,10 +1440,10 @@ void Map::timerUpdate(float dtime, float unload_timeout,
|
|||||||
core::list<v3s16> *unloaded_blocks)
|
core::list<v3s16> *unloaded_blocks)
|
||||||
{
|
{
|
||||||
bool save_before_unloading = (mapType() == MAPTYPE_SERVER);
|
bool save_before_unloading = (mapType() == MAPTYPE_SERVER);
|
||||||
|
|
||||||
// Profile modified reasons
|
// Profile modified reasons
|
||||||
Profiler modprofiler;
|
Profiler modprofiler;
|
||||||
|
|
||||||
core::list<v2s16> sector_deletion_queue;
|
core::list<v2s16> sector_deletion_queue;
|
||||||
u32 deleted_blocks_count = 0;
|
u32 deleted_blocks_count = 0;
|
||||||
u32 saved_blocks_count = 0;
|
u32 saved_blocks_count = 0;
|
||||||
@ -1461,12 +1461,12 @@ void Map::timerUpdate(float dtime, float unload_timeout,
|
|||||||
|
|
||||||
core::list<MapBlock*> blocks;
|
core::list<MapBlock*> blocks;
|
||||||
sector->getBlocks(blocks);
|
sector->getBlocks(blocks);
|
||||||
|
|
||||||
for(core::list<MapBlock*>::Iterator i = blocks.begin();
|
for(core::list<MapBlock*>::Iterator i = blocks.begin();
|
||||||
i != blocks.end(); i++)
|
i != blocks.end(); i++)
|
||||||
{
|
{
|
||||||
MapBlock *block = (*i);
|
MapBlock *block = (*i);
|
||||||
|
|
||||||
block->incrementUsageTimer(dtime);
|
block->incrementUsageTimer(dtime);
|
||||||
|
|
||||||
if(block->refGet() == 0 && block->getUsageTimer() > unload_timeout)
|
if(block->refGet() == 0 && block->getUsageTimer() > unload_timeout)
|
||||||
@ -1503,10 +1503,10 @@ void Map::timerUpdate(float dtime, float unload_timeout,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
endSave();
|
endSave();
|
||||||
|
|
||||||
// Finally delete the empty sectors
|
// Finally delete the empty sectors
|
||||||
deleteSectors(sector_deletion_queue);
|
deleteSectors(sector_deletion_queue);
|
||||||
|
|
||||||
if(deleted_blocks_count != 0)
|
if(deleted_blocks_count != 0)
|
||||||
{
|
{
|
||||||
PrintInfo(infostream); // ServerMap/ClientMap:
|
PrintInfo(infostream); // ServerMap/ClientMap:
|
||||||
@ -1560,7 +1560,7 @@ void Map::unloadUnusedData(float timeout,
|
|||||||
i != blocks.end(); i++)
|
i != blocks.end(); i++)
|
||||||
{
|
{
|
||||||
MapBlock *block = (*i);
|
MapBlock *block = (*i);
|
||||||
|
|
||||||
if(block->getUsageTimer() > timeout)
|
if(block->getUsageTimer() > timeout)
|
||||||
{
|
{
|
||||||
// Save if modified
|
// Save if modified
|
||||||
@ -1629,7 +1629,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
|
|||||||
|
|
||||||
// list of nodes that due to viscosity have not reached their max level height
|
// list of nodes that due to viscosity have not reached their max level height
|
||||||
UniqueQueue<v3s16> must_reflow;
|
UniqueQueue<v3s16> must_reflow;
|
||||||
|
|
||||||
// List of MapBlocks that will require a lighting update (due to lava)
|
// List of MapBlocks that will require a lighting update (due to lava)
|
||||||
core::map<v3s16, MapBlock*> lighting_modified_blocks;
|
core::map<v3s16, MapBlock*> lighting_modified_blocks;
|
||||||
|
|
||||||
@ -1714,7 +1714,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LIQUID_SOURCE:
|
case LIQUID_SOURCE:
|
||||||
// if this node is not (yet) of a liquid type, choose the first liquid type we encounter
|
// if this node is not (yet) of a liquid type, choose the first liquid type we encounter
|
||||||
if (liquid_kind == CONTENT_AIR)
|
if (liquid_kind == CONTENT_AIR)
|
||||||
liquid_kind = nodemgr->getId(nodemgr->get(nb.n).liquid_alternative_flowing);
|
liquid_kind = nodemgr->getId(nodemgr->get(nb.n).liquid_alternative_flowing);
|
||||||
if (nodemgr->getId(nodemgr->get(nb.n).liquid_alternative_flowing) != liquid_kind) {
|
if (nodemgr->getId(nodemgr->get(nb.n).liquid_alternative_flowing) != liquid_kind) {
|
||||||
@ -1824,7 +1824,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
|
|||||||
n0.param2 = ~(LIQUID_LEVEL_MASK | LIQUID_FLOW_DOWN_MASK);
|
n0.param2 = ~(LIQUID_LEVEL_MASK | LIQUID_FLOW_DOWN_MASK);
|
||||||
}
|
}
|
||||||
n0.setContent(new_node_content);
|
n0.setContent(new_node_content);
|
||||||
|
|
||||||
// Find out whether there is a suspect for this action
|
// Find out whether there is a suspect for this action
|
||||||
std::string suspect;
|
std::string suspect;
|
||||||
if(m_gamedef->rollback()){
|
if(m_gamedef->rollback()){
|
||||||
@ -2021,7 +2021,9 @@ ServerMap::ServerMap(std::string savedir, IGameDef *gamedef, EmergeManager *emer
|
|||||||
}
|
}
|
||||||
emerge->seed = m_seed;
|
emerge->seed = m_seed;
|
||||||
emerge->water_level = g_settings->getS16("default_water_level");
|
emerge->water_level = g_settings->getS16("default_water_level");
|
||||||
//<set noiseparams here>
|
//mapgen version
|
||||||
|
//chunksize
|
||||||
|
//noiseparams
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Experimental and debug stuff
|
Experimental and debug stuff
|
||||||
@ -2149,7 +2151,7 @@ void ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos)
|
|||||||
<<"("<<blockpos.X<<","<<blockpos.Y<<","<<blockpos.Z<<") - "
|
<<"("<<blockpos.X<<","<<blockpos.Y<<","<<blockpos.Z<<") - "
|
||||||
<<"("<<blockpos.X<<","<<blockpos.Y<<","<<blockpos.Z<<")"
|
<<"("<<blockpos.X<<","<<blockpos.Y<<","<<blockpos.Z<<")"
|
||||||
<<std::endl;
|
<<std::endl;
|
||||||
|
|
||||||
//s16 chunksize = 3;
|
//s16 chunksize = 3;
|
||||||
//v3s16 chunk_offset(-1,-1,-1);
|
//v3s16 chunk_offset(-1,-1,-1);
|
||||||
//s16 chunksize = 4;
|
//s16 chunksize = 4;
|
||||||
@ -2172,7 +2174,7 @@ void ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos)
|
|||||||
data->no_op = true;
|
data->no_op = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->no_op = false;
|
data->no_op = false;
|
||||||
data->seed = m_seed;
|
data->seed = m_seed;
|
||||||
data->blockpos_min = blockpos_min;
|
data->blockpos_min = blockpos_min;
|
||||||
@ -2185,7 +2187,7 @@ void ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos)
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
//TimeTaker timer("initBlockMake() create area");
|
//TimeTaker timer("initBlockMake() create area");
|
||||||
|
|
||||||
for(s16 x=blockpos_min.X-extra_borders.X;
|
for(s16 x=blockpos_min.X-extra_borders.X;
|
||||||
x<=blockpos_max.X+extra_borders.X; x++)
|
x<=blockpos_max.X+extra_borders.X; x++)
|
||||||
for(s16 z=blockpos_min.Z-extra_borders.Z;
|
for(s16 z=blockpos_min.Z-extra_borders.Z;
|
||||||
@ -2224,18 +2226,18 @@ void ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Now we have a big empty area.
|
Now we have a big empty area.
|
||||||
|
|
||||||
Make a ManualMapVoxelManipulator that contains this and the
|
Make a ManualMapVoxelManipulator that contains this and the
|
||||||
neighboring blocks
|
neighboring blocks
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// The area that contains this block and it's neighbors
|
// The area that contains this block and it's neighbors
|
||||||
v3s16 bigarea_blocks_min = blockpos_min - extra_borders;
|
v3s16 bigarea_blocks_min = blockpos_min - extra_borders;
|
||||||
v3s16 bigarea_blocks_max = blockpos_max + extra_borders;
|
v3s16 bigarea_blocks_max = blockpos_max + extra_borders;
|
||||||
|
|
||||||
data->vmanip = new ManualMapVoxelManipulator(this);
|
data->vmanip = new ManualMapVoxelManipulator(this);
|
||||||
//data->vmanip->setMap(this);
|
//data->vmanip->setMap(this);
|
||||||
|
|
||||||
@ -2319,7 +2321,7 @@ MapBlock* ServerMap::finishBlockMake(BlockMakeData *data,
|
|||||||
TimeTaker t("finishBlockMake lighting update");
|
TimeTaker t("finishBlockMake lighting update");
|
||||||
|
|
||||||
core::map<v3s16, MapBlock*> lighting_update_blocks;
|
core::map<v3s16, MapBlock*> lighting_update_blocks;
|
||||||
|
|
||||||
// Center blocks
|
// Center blocks
|
||||||
for(s16 x=blockpos_min.X-extra_borders.X;
|
for(s16 x=blockpos_min.X-extra_borders.X;
|
||||||
x<=blockpos_max.X+extra_borders.X; x++)
|
x<=blockpos_max.X+extra_borders.X; x++)
|
||||||
@ -2336,7 +2338,7 @@ MapBlock* ServerMap::finishBlockMake(BlockMakeData *data,
|
|||||||
|
|
||||||
updateLighting(lighting_update_blocks, changed_blocks);
|
updateLighting(lighting_update_blocks, changed_blocks);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Set lighting to non-expired state in all of them.
|
Set lighting to non-expired state in all of them.
|
||||||
This is cheating, but it is not fast enough if all of them
|
This is cheating, but it is not fast enough if all of them
|
||||||
@ -2390,7 +2392,7 @@ MapBlock* ServerMap::finishBlockMake(BlockMakeData *data,
|
|||||||
assert(block);
|
assert(block);
|
||||||
block->setGenerated(true);
|
block->setGenerated(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Save changed parts of map
|
Save changed parts of map
|
||||||
NOTE: Will be saved later.
|
NOTE: Will be saved later.
|
||||||
@ -2434,14 +2436,14 @@ ServerMapSector * ServerMap::createSector(v2s16 p2d)
|
|||||||
DSTACKF("%s: p2d=(%d,%d)",
|
DSTACKF("%s: p2d=(%d,%d)",
|
||||||
__FUNCTION_NAME,
|
__FUNCTION_NAME,
|
||||||
p2d.X, p2d.Y);
|
p2d.X, p2d.Y);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Check if it exists already in memory
|
Check if it exists already in memory
|
||||||
*/
|
*/
|
||||||
ServerMapSector *sector = (ServerMapSector*)getSectorNoGenerateNoEx(p2d);
|
ServerMapSector *sector = (ServerMapSector*)getSectorNoGenerateNoEx(p2d);
|
||||||
if(sector != NULL)
|
if(sector != NULL)
|
||||||
return sector;
|
return sector;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Try to load it from disk (with blocks)
|
Try to load it from disk (with blocks)
|
||||||
*/
|
*/
|
||||||
@ -2474,9 +2476,9 @@ ServerMapSector * ServerMap::createSector(v2s16 p2d)
|
|||||||
/*
|
/*
|
||||||
Generate blank sector
|
Generate blank sector
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sector = new ServerMapSector(this, p2d, m_gamedef);
|
sector = new ServerMapSector(this, p2d, m_gamedef);
|
||||||
|
|
||||||
// Sector position on map in nodes
|
// Sector position on map in nodes
|
||||||
v2s16 nodepos2d = p2d * MAP_BLOCKSIZE;
|
v2s16 nodepos2d = p2d * MAP_BLOCKSIZE;
|
||||||
|
|
||||||
@ -2484,7 +2486,7 @@ ServerMapSector * ServerMap::createSector(v2s16 p2d)
|
|||||||
Insert to container
|
Insert to container
|
||||||
*/
|
*/
|
||||||
m_sectors.insert(p2d, sector);
|
m_sectors.insert(p2d, sector);
|
||||||
|
|
||||||
return sector;
|
return sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2498,20 +2500,20 @@ MapBlock * ServerMap::generateBlock(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
DSTACKF("%s: p=(%d,%d,%d)", __FUNCTION_NAME, p.X, p.Y, p.Z);
|
DSTACKF("%s: p=(%d,%d,%d)", __FUNCTION_NAME, p.X, p.Y, p.Z);
|
||||||
|
|
||||||
/*infostream<<"generateBlock(): "
|
/*infostream<<"generateBlock(): "
|
||||||
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
|
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
|
||||||
<<std::endl;*/
|
<<std::endl;*/
|
||||||
|
|
||||||
bool enable_mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info");
|
bool enable_mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info");
|
||||||
|
|
||||||
TimeTaker timer("generateBlock");
|
TimeTaker timer("generateBlock");
|
||||||
|
|
||||||
//MapBlock *block = original_dummy;
|
//MapBlock *block = original_dummy;
|
||||||
|
|
||||||
v2s16 p2d(p.X, p.Z);
|
v2s16 p2d(p.X, p.Z);
|
||||||
v2s16 p2d_nodes = p2d * MAP_BLOCKSIZE;
|
v2s16 p2d_nodes = p2d * MAP_BLOCKSIZE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Do not generate over-limit
|
Do not generate over-limit
|
||||||
*/
|
*/
|
||||||
@ -2608,7 +2610,7 @@ MapBlock * ServerMap::createBlock(v3s16 p)
|
|||||||
{
|
{
|
||||||
DSTACKF("%s: p=(%d,%d,%d)",
|
DSTACKF("%s: p=(%d,%d,%d)",
|
||||||
__FUNCTION_NAME, p.X, p.Y, p.Z);
|
__FUNCTION_NAME, p.X, p.Y, p.Z);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Do not create over-limit
|
Do not create over-limit
|
||||||
*/
|
*/
|
||||||
@ -2619,7 +2621,7 @@ MapBlock * ServerMap::createBlock(v3s16 p)
|
|||||||
|| p.Z < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
|
|| p.Z < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
|
||||||
|| p.Z > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE)
|
|| p.Z > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE)
|
||||||
throw InvalidPositionException("createBlock(): pos. over limit");
|
throw InvalidPositionException("createBlock(): pos. over limit");
|
||||||
|
|
||||||
v2s16 p2d(p.X, p.Z);
|
v2s16 p2d(p.X, p.Z);
|
||||||
s16 block_y = p.Y;
|
s16 block_y = p.Y;
|
||||||
/*
|
/*
|
||||||
@ -2673,7 +2675,7 @@ MapBlock * ServerMap::emergeBlock(v3s16 p, bool create_blank)
|
|||||||
DSTACKF("%s: p=(%d,%d,%d), create_blank=%d",
|
DSTACKF("%s: p=(%d,%d,%d), create_blank=%d",
|
||||||
__FUNCTION_NAME,
|
__FUNCTION_NAME,
|
||||||
p.X, p.Y, p.Z, create_blank);
|
p.X, p.Y, p.Z, create_blank);
|
||||||
|
|
||||||
{
|
{
|
||||||
MapBlock *block = getBlockNoCreateNoEx(p);
|
MapBlock *block = getBlockNoCreateNoEx(p);
|
||||||
if(block && block->isDummy() == false)
|
if(block && block->isDummy() == false)
|
||||||
@ -2712,7 +2714,7 @@ MapBlock * ServerMap::emergeBlock(v3s16 p, bool create_blank)
|
|||||||
|
|
||||||
// Queue event
|
// Queue event
|
||||||
dispatchEvent(&event);
|
dispatchEvent(&event);
|
||||||
|
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
@ -2756,7 +2758,7 @@ plan_b:
|
|||||||
/*
|
/*
|
||||||
Determine from map generator noise functions
|
Determine from map generator noise functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
s16 level = m_emerge->getGroundLevelAtPoint(p2d);
|
s16 level = m_emerge->getGroundLevelAtPoint(p2d);
|
||||||
return level;
|
return level;
|
||||||
|
|
||||||
@ -2782,48 +2784,48 @@ void ServerMap::createDatabase() {
|
|||||||
void ServerMap::verifyDatabase() {
|
void ServerMap::verifyDatabase() {
|
||||||
if(m_database)
|
if(m_database)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
{
|
{
|
||||||
std::string dbp = m_savedir + DIR_DELIM + "map.sqlite";
|
std::string dbp = m_savedir + DIR_DELIM + "map.sqlite";
|
||||||
bool needs_create = false;
|
bool needs_create = false;
|
||||||
int d;
|
int d;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Open the database connection
|
Open the database connection
|
||||||
*/
|
*/
|
||||||
|
|
||||||
createDirs(m_savedir);
|
createDirs(m_savedir);
|
||||||
|
|
||||||
if(!fs::PathExists(dbp))
|
if(!fs::PathExists(dbp))
|
||||||
needs_create = true;
|
needs_create = true;
|
||||||
|
|
||||||
d = sqlite3_open_v2(dbp.c_str(), &m_database, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
|
d = sqlite3_open_v2(dbp.c_str(), &m_database, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
|
||||||
if(d != SQLITE_OK) {
|
if(d != SQLITE_OK) {
|
||||||
infostream<<"WARNING: Database failed to open: "<<sqlite3_errmsg(m_database)<<std::endl;
|
infostream<<"WARNING: Database failed to open: "<<sqlite3_errmsg(m_database)<<std::endl;
|
||||||
throw FileNotGoodException("Cannot open database file");
|
throw FileNotGoodException("Cannot open database file");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(needs_create)
|
if(needs_create)
|
||||||
createDatabase();
|
createDatabase();
|
||||||
|
|
||||||
d = sqlite3_prepare(m_database, "SELECT `data` FROM `blocks` WHERE `pos`=? LIMIT 1", -1, &m_database_read, NULL);
|
d = sqlite3_prepare(m_database, "SELECT `data` FROM `blocks` WHERE `pos`=? LIMIT 1", -1, &m_database_read, NULL);
|
||||||
if(d != SQLITE_OK) {
|
if(d != SQLITE_OK) {
|
||||||
infostream<<"WARNING: Database read statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
|
infostream<<"WARNING: Database read statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
|
||||||
throw FileNotGoodException("Cannot prepare read statement");
|
throw FileNotGoodException("Cannot prepare read statement");
|
||||||
}
|
}
|
||||||
|
|
||||||
d = sqlite3_prepare(m_database, "REPLACE INTO `blocks` VALUES(?, ?)", -1, &m_database_write, NULL);
|
d = sqlite3_prepare(m_database, "REPLACE INTO `blocks` VALUES(?, ?)", -1, &m_database_write, NULL);
|
||||||
if(d != SQLITE_OK) {
|
if(d != SQLITE_OK) {
|
||||||
infostream<<"WARNING: Database write statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
|
infostream<<"WARNING: Database write statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
|
||||||
throw FileNotGoodException("Cannot prepare write statement");
|
throw FileNotGoodException("Cannot prepare write statement");
|
||||||
}
|
}
|
||||||
|
|
||||||
d = sqlite3_prepare(m_database, "SELECT `pos` FROM `blocks`", -1, &m_database_list, NULL);
|
d = sqlite3_prepare(m_database, "SELECT `pos` FROM `blocks`", -1, &m_database_list, NULL);
|
||||||
if(d != SQLITE_OK) {
|
if(d != SQLITE_OK) {
|
||||||
infostream<<"WARNING: Database list statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
|
infostream<<"WARNING: Database list statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
|
||||||
throw FileNotGoodException("Cannot prepare read statement");
|
throw FileNotGoodException("Cannot prepare read statement");
|
||||||
}
|
}
|
||||||
|
|
||||||
infostream<<"ServerMap: Database opened"<<std::endl;
|
infostream<<"ServerMap: Database opened"<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2928,11 +2930,11 @@ void ServerMap::save(ModifiedState save_level)
|
|||||||
infostream<<"WARNING: Not saving map, saving disabled."<<std::endl;
|
infostream<<"WARNING: Not saving map, saving disabled."<<std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(save_level == MOD_STATE_CLEAN)
|
if(save_level == MOD_STATE_CLEAN)
|
||||||
infostream<<"ServerMap: Saving whole map, this can take time."
|
infostream<<"ServerMap: Saving whole map, this can take time."
|
||||||
<<std::endl;
|
<<std::endl;
|
||||||
|
|
||||||
if(m_map_metadata_changed || save_level == MOD_STATE_CLEAN)
|
if(m_map_metadata_changed || save_level == MOD_STATE_CLEAN)
|
||||||
{
|
{
|
||||||
saveMapMeta();
|
saveMapMeta();
|
||||||
@ -2940,11 +2942,11 @@ void ServerMap::save(ModifiedState save_level)
|
|||||||
|
|
||||||
// Profile modified reasons
|
// Profile modified reasons
|
||||||
Profiler modprofiler;
|
Profiler modprofiler;
|
||||||
|
|
||||||
u32 sector_meta_count = 0;
|
u32 sector_meta_count = 0;
|
||||||
u32 block_count = 0;
|
u32 block_count = 0;
|
||||||
u32 block_count_all = 0; // Number of blocks in memory
|
u32 block_count_all = 0; // Number of blocks in memory
|
||||||
|
|
||||||
// Don't do anything with sqlite unless something is really saved
|
// Don't do anything with sqlite unless something is really saved
|
||||||
bool save_started = false;
|
bool save_started = false;
|
||||||
|
|
||||||
@ -2953,7 +2955,7 @@ void ServerMap::save(ModifiedState save_level)
|
|||||||
{
|
{
|
||||||
ServerMapSector *sector = (ServerMapSector*)i.getNode()->getValue();
|
ServerMapSector *sector = (ServerMapSector*)i.getNode()->getValue();
|
||||||
assert(sector->getId() == MAPSECTOR_SERVER);
|
assert(sector->getId() == MAPSECTOR_SERVER);
|
||||||
|
|
||||||
if(sector->differs_from_disk || save_level == MOD_STATE_CLEAN)
|
if(sector->differs_from_disk || save_level == MOD_STATE_CLEAN)
|
||||||
{
|
{
|
||||||
saveSectorMeta(sector);
|
saveSectorMeta(sector);
|
||||||
@ -2962,11 +2964,11 @@ void ServerMap::save(ModifiedState save_level)
|
|||||||
core::list<MapBlock*> blocks;
|
core::list<MapBlock*> blocks;
|
||||||
sector->getBlocks(blocks);
|
sector->getBlocks(blocks);
|
||||||
core::list<MapBlock*>::Iterator j;
|
core::list<MapBlock*>::Iterator j;
|
||||||
|
|
||||||
for(j=blocks.begin(); j!=blocks.end(); j++)
|
for(j=blocks.begin(); j!=blocks.end(); j++)
|
||||||
{
|
{
|
||||||
MapBlock *block = *j;
|
MapBlock *block = *j;
|
||||||
|
|
||||||
block_count_all++;
|
block_count_all++;
|
||||||
|
|
||||||
if(block->getModified() >= save_level)
|
if(block->getModified() >= save_level)
|
||||||
@ -3042,10 +3044,10 @@ void ServerMap::listAllLoadableBlocks(core::list<v3s16> &dst)
|
|||||||
errorstream<<"Map::listAllLoadableBlocks(): Result will be missing "
|
errorstream<<"Map::listAllLoadableBlocks(): Result will be missing "
|
||||||
<<"all blocks that are stored in flat files"<<std::endl;
|
<<"all blocks that are stored in flat files"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
verifyDatabase();
|
verifyDatabase();
|
||||||
|
|
||||||
while(sqlite3_step(m_database_list) == SQLITE_ROW)
|
while(sqlite3_step(m_database_list) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
sqlite3_int64 block_i = sqlite3_column_int64(m_database_list, 0);
|
sqlite3_int64 block_i = sqlite3_column_int64(m_database_list, 0);
|
||||||
@ -3059,13 +3061,13 @@ void ServerMap::listAllLoadableBlocks(core::list<v3s16> &dst)
|
|||||||
void ServerMap::saveMapMeta()
|
void ServerMap::saveMapMeta()
|
||||||
{
|
{
|
||||||
DSTACK(__FUNCTION_NAME);
|
DSTACK(__FUNCTION_NAME);
|
||||||
|
|
||||||
/*infostream<<"ServerMap::saveMapMeta(): "
|
/*infostream<<"ServerMap::saveMapMeta(): "
|
||||||
<<"seed="<<m_seed
|
<<"seed="<<m_seed
|
||||||
<<std::endl;*/
|
<<std::endl;*/
|
||||||
|
|
||||||
createDirs(m_savedir);
|
createDirs(m_savedir);
|
||||||
|
|
||||||
std::string fullpath = m_savedir + DIR_DELIM + "map_meta.txt";
|
std::string fullpath = m_savedir + DIR_DELIM + "map_meta.txt";
|
||||||
std::ofstream os(fullpath.c_str(), std::ios_base::binary);
|
std::ofstream os(fullpath.c_str(), std::ios_base::binary);
|
||||||
if(os.good() == false)
|
if(os.good() == false)
|
||||||
@ -3074,7 +3076,7 @@ void ServerMap::saveMapMeta()
|
|||||||
<<"could not open"<<fullpath<<std::endl;
|
<<"could not open"<<fullpath<<std::endl;
|
||||||
throw FileNotGoodException("Cannot open chunk metadata");
|
throw FileNotGoodException("Cannot open chunk metadata");
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings params;
|
Settings params;
|
||||||
params.setU64("seed", m_seed);
|
params.setU64("seed", m_seed);
|
||||||
params.setS16("water_level", m_emerge->water_level);
|
params.setS16("water_level", m_emerge->water_level);
|
||||||
@ -3082,14 +3084,14 @@ void ServerMap::saveMapMeta()
|
|||||||
params.writeLines(os);
|
params.writeLines(os);
|
||||||
|
|
||||||
os<<"[end_of_params]\n";
|
os<<"[end_of_params]\n";
|
||||||
|
|
||||||
m_map_metadata_changed = false;
|
m_map_metadata_changed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerMap::loadMapMeta()
|
void ServerMap::loadMapMeta()
|
||||||
{
|
{
|
||||||
DSTACK(__FUNCTION_NAME);
|
DSTACK(__FUNCTION_NAME);
|
||||||
|
|
||||||
/*infostream<<"ServerMap::loadMapMeta(): Loading map metadata"
|
/*infostream<<"ServerMap::loadMapMeta(): Loading map metadata"
|
||||||
<<std::endl;*/
|
<<std::endl;*/
|
||||||
|
|
||||||
@ -3116,7 +3118,7 @@ void ServerMap::loadMapMeta()
|
|||||||
break;
|
break;
|
||||||
params.parseConfigLine(line);
|
params.parseConfigLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_seed = params.getU64("seed");
|
m_seed = params.getU64("seed");
|
||||||
m_emerge->seed = m_seed;
|
m_emerge->seed = m_seed;
|
||||||
m_emerge->water_level = params.getS16("water_level");
|
m_emerge->water_level = params.getS16("water_level");
|
||||||
@ -3134,14 +3136,14 @@ void ServerMap::saveSectorMeta(ServerMapSector *sector)
|
|||||||
v2s16 pos = sector->getPos();
|
v2s16 pos = sector->getPos();
|
||||||
std::string dir = getSectorDir(pos);
|
std::string dir = getSectorDir(pos);
|
||||||
createDirs(dir);
|
createDirs(dir);
|
||||||
|
|
||||||
std::string fullpath = dir + DIR_DELIM + "meta";
|
std::string fullpath = dir + DIR_DELIM + "meta";
|
||||||
std::ofstream o(fullpath.c_str(), std::ios_base::binary);
|
std::ofstream o(fullpath.c_str(), std::ios_base::binary);
|
||||||
if(o.good() == false)
|
if(o.good() == false)
|
||||||
throw FileNotGoodException("Cannot open sector metafile");
|
throw FileNotGoodException("Cannot open sector metafile");
|
||||||
|
|
||||||
sector->serialize(o, version);
|
sector->serialize(o, version);
|
||||||
|
|
||||||
sector->differs_from_disk = false;
|
sector->differs_from_disk = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3180,7 +3182,7 @@ MapSector* ServerMap::loadSectorMeta(std::string sectordir, bool save_after_load
|
|||||||
if(save_after_load)
|
if(save_after_load)
|
||||||
saveSectorMeta(sector);
|
saveSectorMeta(sector);
|
||||||
}
|
}
|
||||||
|
|
||||||
sector->differs_from_disk = false;
|
sector->differs_from_disk = false;
|
||||||
|
|
||||||
return sector;
|
return sector;
|
||||||
@ -3225,7 +3227,7 @@ bool ServerMap::loadSectorMeta(v2s16 p2d)
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3269,7 +3271,7 @@ bool ServerMap::loadSectorFull(v2s16 p2d)
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Load blocks
|
Load blocks
|
||||||
*/
|
*/
|
||||||
@ -3331,8 +3333,8 @@ void ServerMap::saveBlock(MapBlock *block)
|
|||||||
u8 version = SER_FMT_VER_HIGHEST;
|
u8 version = SER_FMT_VER_HIGHEST;
|
||||||
// Get destination
|
// Get destination
|
||||||
v3s16 p3d = block->getPos();
|
v3s16 p3d = block->getPos();
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
v2s16 p2d(p3d.X, p3d.Z);
|
v2s16 p2d(p3d.X, p3d.Z);
|
||||||
std::string sectordir = getSectorDir(p2d);
|
std::string sectordir = getSectorDir(p2d);
|
||||||
@ -3348,21 +3350,21 @@ void ServerMap::saveBlock(MapBlock *block)
|
|||||||
[0] u8 serialization version
|
[0] u8 serialization version
|
||||||
[1] data
|
[1] data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
verifyDatabase();
|
verifyDatabase();
|
||||||
|
|
||||||
std::ostringstream o(std::ios_base::binary);
|
std::ostringstream o(std::ios_base::binary);
|
||||||
|
|
||||||
o.write((char*)&version, 1);
|
o.write((char*)&version, 1);
|
||||||
|
|
||||||
// Write basic data
|
// Write basic data
|
||||||
block->serialize(o, version, true);
|
block->serialize(o, version, true);
|
||||||
|
|
||||||
// Write block to database
|
// Write block to database
|
||||||
|
|
||||||
std::string tmp = o.str();
|
std::string tmp = o.str();
|
||||||
const char *bytes = tmp.c_str();
|
const char *bytes = tmp.c_str();
|
||||||
|
|
||||||
bool success = true;
|
bool success = true;
|
||||||
if(sqlite3_bind_int64(m_database_write, 1, getBlockAsInteger(p3d)) != SQLITE_OK) {
|
if(sqlite3_bind_int64(m_database_write, 1, getBlockAsInteger(p3d)) != SQLITE_OK) {
|
||||||
infostream<<"WARNING: Block position failed to bind: "<<sqlite3_errmsg(m_database)<<std::endl;
|
infostream<<"WARNING: Block position failed to bind: "<<sqlite3_errmsg(m_database)<<std::endl;
|
||||||
@ -3380,7 +3382,7 @@ void ServerMap::saveBlock(MapBlock *block)
|
|||||||
}
|
}
|
||||||
// Make ready for later reuse
|
// Make ready for later reuse
|
||||||
sqlite3_reset(m_database_write);
|
sqlite3_reset(m_database_write);
|
||||||
|
|
||||||
// We just wrote it to the disk so clear modified flag
|
// We just wrote it to the disk so clear modified flag
|
||||||
if (success)
|
if (success)
|
||||||
block->resetModified();
|
block->resetModified();
|
||||||
@ -3396,12 +3398,12 @@ void ServerMap::loadBlock(std::string sectordir, std::string blockfile, MapSecto
|
|||||||
std::ifstream is(fullpath.c_str(), std::ios_base::binary);
|
std::ifstream is(fullpath.c_str(), std::ios_base::binary);
|
||||||
if(is.good() == false)
|
if(is.good() == false)
|
||||||
throw FileNotGoodException("Cannot open block file");
|
throw FileNotGoodException("Cannot open block file");
|
||||||
|
|
||||||
v3s16 p3d = getBlockPos(sectordir, blockfile);
|
v3s16 p3d = getBlockPos(sectordir, blockfile);
|
||||||
v2s16 p2d(p3d.X, p3d.Z);
|
v2s16 p2d(p3d.X, p3d.Z);
|
||||||
|
|
||||||
assert(sector->getPos() == p2d);
|
assert(sector->getPos() == p2d);
|
||||||
|
|
||||||
u8 version = SER_FMT_VER_INVALID;
|
u8 version = SER_FMT_VER_INVALID;
|
||||||
is.read((char*)&version, 1);
|
is.read((char*)&version, 1);
|
||||||
|
|
||||||
@ -3424,14 +3426,14 @@ void ServerMap::loadBlock(std::string sectordir, std::string blockfile, MapSecto
|
|||||||
block = sector->createBlankBlockNoInsert(p3d.Y);
|
block = sector->createBlankBlockNoInsert(p3d.Y);
|
||||||
created_new = true;
|
created_new = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read basic data
|
// Read basic data
|
||||||
block->deSerialize(is, version, true);
|
block->deSerialize(is, version, true);
|
||||||
|
|
||||||
// If it's a new block, insert it to the map
|
// If it's a new block, insert it to the map
|
||||||
if(created_new)
|
if(created_new)
|
||||||
sector->insertBlock(block);
|
sector->insertBlock(block);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Save blocks loaded in old format in new format
|
Save blocks loaded in old format in new format
|
||||||
*/
|
*/
|
||||||
@ -3439,11 +3441,11 @@ void ServerMap::loadBlock(std::string sectordir, std::string blockfile, MapSecto
|
|||||||
if(version < SER_FMT_VER_HIGHEST || save_after_load)
|
if(version < SER_FMT_VER_HIGHEST || save_after_load)
|
||||||
{
|
{
|
||||||
saveBlock(block);
|
saveBlock(block);
|
||||||
|
|
||||||
// Should be in database now, so delete the old file
|
// Should be in database now, so delete the old file
|
||||||
fs::RecursiveDelete(fullpath);
|
fs::RecursiveDelete(fullpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We just loaded it from the disk, so it's up-to-date.
|
// We just loaded it from the disk, so it's up-to-date.
|
||||||
block->resetModified();
|
block->resetModified();
|
||||||
|
|
||||||
@ -3468,7 +3470,7 @@ void ServerMap::loadBlock(std::string *blob, v3s16 p3d, MapSector *sector, bool
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
std::istringstream is(*blob, std::ios_base::binary);
|
std::istringstream is(*blob, std::ios_base::binary);
|
||||||
|
|
||||||
u8 version = SER_FMT_VER_INVALID;
|
u8 version = SER_FMT_VER_INVALID;
|
||||||
is.read((char*)&version, 1);
|
is.read((char*)&version, 1);
|
||||||
|
|
||||||
@ -3491,14 +3493,14 @@ void ServerMap::loadBlock(std::string *blob, v3s16 p3d, MapSector *sector, bool
|
|||||||
block = sector->createBlankBlockNoInsert(p3d.Y);
|
block = sector->createBlankBlockNoInsert(p3d.Y);
|
||||||
created_new = true;
|
created_new = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read basic data
|
// Read basic data
|
||||||
block->deSerialize(is, version, true);
|
block->deSerialize(is, version, true);
|
||||||
|
|
||||||
// If it's a new block, insert it to the map
|
// If it's a new block, insert it to the map
|
||||||
if(created_new)
|
if(created_new)
|
||||||
sector->insertBlock(block);
|
sector->insertBlock(block);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Save blocks loaded in old format in new format
|
Save blocks loaded in old format in new format
|
||||||
*/
|
*/
|
||||||
@ -3507,7 +3509,7 @@ void ServerMap::loadBlock(std::string *blob, v3s16 p3d, MapSector *sector, bool
|
|||||||
// Only save if asked to; no need to update version
|
// Only save if asked to; no need to update version
|
||||||
if(save_after_load)
|
if(save_after_load)
|
||||||
saveBlock(block);
|
saveBlock(block);
|
||||||
|
|
||||||
// We just loaded it from, so it's up-to-date.
|
// We just loaded it from, so it's up-to-date.
|
||||||
block->resetModified();
|
block->resetModified();
|
||||||
|
|
||||||
@ -3517,7 +3519,7 @@ void ServerMap::loadBlock(std::string *blob, v3s16 p3d, MapSector *sector, bool
|
|||||||
errorstream<<"Invalid block data in database"
|
errorstream<<"Invalid block data in database"
|
||||||
<<" ("<<p3d.X<<","<<p3d.Y<<","<<p3d.Z<<")"
|
<<" ("<<p3d.X<<","<<p3d.Y<<","<<p3d.Z<<")"
|
||||||
<<" (SerializationError): "<<e.what()<<std::endl;
|
<<" (SerializationError): "<<e.what()<<std::endl;
|
||||||
|
|
||||||
// TODO: Block should be marked as invalid in memory so that it is
|
// TODO: Block should be marked as invalid in memory so that it is
|
||||||
// not touched but the game can run
|
// not touched but the game can run
|
||||||
|
|
||||||
@ -3539,7 +3541,7 @@ MapBlock* ServerMap::loadBlock(v3s16 blockpos)
|
|||||||
|
|
||||||
if(!loadFromFolders()) {
|
if(!loadFromFolders()) {
|
||||||
verifyDatabase();
|
verifyDatabase();
|
||||||
|
|
||||||
if(sqlite3_bind_int64(m_database_read, 1, getBlockAsInteger(blockpos)) != SQLITE_OK)
|
if(sqlite3_bind_int64(m_database_read, 1, getBlockAsInteger(blockpos)) != SQLITE_OK)
|
||||||
infostream<<"WARNING: Could not bind block position for load: "
|
infostream<<"WARNING: Could not bind block position for load: "
|
||||||
<<sqlite3_errmsg(m_database)<<std::endl;
|
<<sqlite3_errmsg(m_database)<<std::endl;
|
||||||
@ -3548,15 +3550,15 @@ MapBlock* ServerMap::loadBlock(v3s16 blockpos)
|
|||||||
Make sure sector is loaded
|
Make sure sector is loaded
|
||||||
*/
|
*/
|
||||||
MapSector *sector = createSector(p2d);
|
MapSector *sector = createSector(p2d);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Load block
|
Load block
|
||||||
*/
|
*/
|
||||||
const char * data = (const char *)sqlite3_column_blob(m_database_read, 0);
|
const char * data = (const char *)sqlite3_column_blob(m_database_read, 0);
|
||||||
size_t len = sqlite3_column_bytes(m_database_read, 0);
|
size_t len = sqlite3_column_bytes(m_database_read, 0);
|
||||||
|
|
||||||
std::string datastr(data, len);
|
std::string datastr(data, len);
|
||||||
|
|
||||||
loadBlock(&datastr, blockpos, sector, false);
|
loadBlock(&datastr, blockpos, sector, false);
|
||||||
|
|
||||||
sqlite3_step(m_database_read);
|
sqlite3_step(m_database_read);
|
||||||
@ -3566,7 +3568,7 @@ MapBlock* ServerMap::loadBlock(v3s16 blockpos)
|
|||||||
return getBlockNoCreateNoEx(blockpos);
|
return getBlockNoCreateNoEx(blockpos);
|
||||||
}
|
}
|
||||||
sqlite3_reset(m_database_read);
|
sqlite3_reset(m_database_read);
|
||||||
|
|
||||||
// Not found in database, try the files
|
// Not found in database, try the files
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3587,7 +3589,7 @@ MapBlock* ServerMap::loadBlock(v3s16 blockpos)
|
|||||||
loadlayout = 2;
|
loadlayout = 2;
|
||||||
sectordir = getSectorDir(p2d, 2);
|
sectordir = getSectorDir(p2d, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Make sure sector is loaded
|
Make sure sector is loaded
|
||||||
*/
|
*/
|
||||||
@ -3610,7 +3612,7 @@ MapBlock* ServerMap::loadBlock(v3s16 blockpos)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Make sure file exists
|
Make sure file exists
|
||||||
*/
|
*/
|
||||||
@ -3668,7 +3670,7 @@ void MapVoxelManipulator::emerge(VoxelArea a, s32 caller_id)
|
|||||||
n = m_loaded_blocks.find(p);
|
n = m_loaded_blocks.find(p);
|
||||||
if(n != NULL)
|
if(n != NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool block_data_inexistent = false;
|
bool block_data_inexistent = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -3679,7 +3681,7 @@ void MapVoxelManipulator::emerge(VoxelArea a, s32 caller_id)
|
|||||||
<<" wanted area: ";
|
<<" wanted area: ";
|
||||||
a.print(infostream);
|
a.print(infostream);
|
||||||
infostream<<std::endl;*/
|
infostream<<std::endl;*/
|
||||||
|
|
||||||
MapBlock *block = m_map->getBlockNoCreate(p);
|
MapBlock *block = m_map->getBlockNoCreate(p);
|
||||||
if(block->isDummy())
|
if(block->isDummy())
|
||||||
block_data_inexistent = true;
|
block_data_inexistent = true;
|
||||||
@ -3719,12 +3721,12 @@ void MapVoxelManipulator::blitBack
|
|||||||
{
|
{
|
||||||
if(m_area.getExtent() == v3s16(0,0,0))
|
if(m_area.getExtent() == v3s16(0,0,0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//TimeTaker timer1("blitBack");
|
//TimeTaker timer1("blitBack");
|
||||||
|
|
||||||
/*infostream<<"blitBack(): m_loaded_blocks.size()="
|
/*infostream<<"blitBack(): m_loaded_blocks.size()="
|
||||||
<<m_loaded_blocks.size()<<std::endl;*/
|
<<m_loaded_blocks.size()<<std::endl;*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Initialize block cache
|
Initialize block cache
|
||||||
*/
|
*/
|
||||||
@ -3743,9 +3745,9 @@ void MapVoxelManipulator::blitBack
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
MapNode &n = m_data[m_area.index(p)];
|
MapNode &n = m_data[m_area.index(p)];
|
||||||
|
|
||||||
v3s16 blockpos = getNodeBlockPos(p);
|
v3s16 blockpos = getNodeBlockPos(p);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get block
|
// Get block
|
||||||
@ -3754,7 +3756,7 @@ void MapVoxelManipulator::blitBack
|
|||||||
blockpos_last = blockpos;
|
blockpos_last = blockpos;
|
||||||
block_checked_in_modified = false;
|
block_checked_in_modified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate relative position in block
|
// Calculate relative position in block
|
||||||
v3s16 relpos = p - blockpos * MAP_BLOCKSIZE;
|
v3s16 relpos = p - blockpos * MAP_BLOCKSIZE;
|
||||||
|
|
||||||
@ -3764,7 +3766,7 @@ void MapVoxelManipulator::blitBack
|
|||||||
|
|
||||||
//m_map->setNode(m_area.MinEdge + p, n);
|
//m_map->setNode(m_area.MinEdge + p, n);
|
||||||
block->setNode(relpos, n);
|
block->setNode(relpos, n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Make sure block is in modified_blocks
|
Make sure block is in modified_blocks
|
||||||
*/
|
*/
|
||||||
@ -3807,7 +3809,7 @@ void ManualMapVoxelManipulator::initialEmerge(
|
|||||||
|
|
||||||
VoxelArea block_area_nodes
|
VoxelArea block_area_nodes
|
||||||
(p_min*MAP_BLOCKSIZE, (p_max+1)*MAP_BLOCKSIZE-v3s16(1,1,1));
|
(p_min*MAP_BLOCKSIZE, (p_max+1)*MAP_BLOCKSIZE-v3s16(1,1,1));
|
||||||
|
|
||||||
u32 size_MB = block_area_nodes.getVolume()*4/1000000;
|
u32 size_MB = block_area_nodes.getVolume()*4/1000000;
|
||||||
if(size_MB >= 1)
|
if(size_MB >= 1)
|
||||||
{
|
{
|
||||||
@ -3828,7 +3830,7 @@ void ManualMapVoxelManipulator::initialEmerge(
|
|||||||
n = m_loaded_blocks.find(p);
|
n = m_loaded_blocks.find(p);
|
||||||
if(n != NULL)
|
if(n != NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool block_data_inexistent = false;
|
bool block_data_inexistent = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -3869,7 +3871,7 @@ void ManualMapVoxelManipulator::blitBackAll(
|
|||||||
{
|
{
|
||||||
if(m_area.getExtent() == v3s16(0,0,0))
|
if(m_area.getExtent() == v3s16(0,0,0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copy data of all blocks
|
Copy data of all blocks
|
||||||
*/
|
*/
|
||||||
|
@ -52,21 +52,21 @@ Mapgen::Mapgen(BiomeDefManager *biomedef) {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
Mapgen::Mapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed) {
|
MapgenV7::MapgenV7(BiomeDefManager *biomedef, int mapgenid, u64 seed) {
|
||||||
initMapgen(biomedef, mapgenid, seed,
|
init(biomedef, mapgenid, seed,
|
||||||
&nparams_mtdefault, &nparams_def_bgroup,
|
&nparams_mtdefault, &nparams_def_bgroup,
|
||||||
&nparams_def_heat, &nparams_def_humidity);
|
&nparams_def_heat, &nparams_def_humidity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Mapgen::Mapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
MapgenV7::MapgenV7(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
||||||
NoiseParams *np_terrain, NoiseParams *np_bgroup,
|
NoiseParams *np_terrain, NoiseParams *np_bgroup,
|
||||||
NoiseParams *np_heat, NoiseParams *np_humidity) {
|
NoiseParams *np_heat, NoiseParams *np_humidity) {
|
||||||
initMapgen(biomedef, mapgenid, seed,
|
init(biomedef, mapgenid, seed,
|
||||||
np_terrain, np_bgroup, np_heat, np_humidity);
|
np_terrain, np_bgroup, np_heat, np_humidity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mapgen::initMapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
void MapgenV7::init(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
||||||
NoiseParams *np_terrain, NoiseParams *np_bgroup,
|
NoiseParams *np_terrain, NoiseParams *np_bgroup,
|
||||||
NoiseParams *np_heat, NoiseParams *np_humidity) {
|
NoiseParams *np_heat, NoiseParams *np_humidity) {
|
||||||
this->generating = false;
|
this->generating = false;
|
||||||
@ -75,6 +75,7 @@ void Mapgen::initMapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
|||||||
this->biomedef = biomedef;
|
this->biomedef = biomedef;
|
||||||
this->csize = v3s16(5, 5, 5) * MAP_BLOCKSIZE; /////////////////get this from config!
|
this->csize = v3s16(5, 5, 5) * MAP_BLOCKSIZE; /////////////////get this from config!
|
||||||
this->water_level = g_settings->getS16("default_water_level"); ////fix this!
|
this->water_level = g_settings->getS16("default_water_level"); ////fix this!
|
||||||
|
this->ystride = csize.X;
|
||||||
|
|
||||||
this->np_terrain = np_terrain;
|
this->np_terrain = np_terrain;
|
||||||
this->np_bgroup = np_bgroup;
|
this->np_bgroup = np_bgroup;
|
||||||
@ -92,7 +93,7 @@ void Mapgen::initMapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Mapgen::~Mapgen() {
|
MapgenV7::~MapgenV7() {
|
||||||
delete noise_terrain;
|
delete noise_terrain;
|
||||||
delete noise_bgroup;
|
delete noise_bgroup;
|
||||||
delete noise_heat;
|
delete noise_heat;
|
||||||
@ -100,12 +101,10 @@ Mapgen::~Mapgen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Mapgen::makeChunk(BlockMakeData *data) {
|
void MapgenV7::makeChunk(BlockMakeData *data) {
|
||||||
if (data->no_op)
|
if (data->no_op)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//printf("generating...\n");//////////////
|
|
||||||
|
|
||||||
assert(data->vmanip);
|
assert(data->vmanip);
|
||||||
assert(data->nodedef);
|
assert(data->nodedef);
|
||||||
assert(data->blockpos_requested.X >= data->blockpos_min.X &&
|
assert(data->blockpos_requested.X >= data->blockpos_min.X &&
|
||||||
@ -123,6 +122,9 @@ void Mapgen::makeChunk(BlockMakeData *data) {
|
|||||||
this->ystride = em.X;
|
this->ystride = em.X;
|
||||||
this->zstride = em.Y * 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_min = (data->blockpos_min) * MAP_BLOCKSIZE;
|
||||||
node_max = (data->blockpos_max + v3s16(1, 1, 1)) * MAP_BLOCKSIZE - v3s16(1, 1, 1);
|
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;
|
v3s16 full_node_min = (data->blockpos_min - 1) * MAP_BLOCKSIZE;
|
||||||
@ -132,7 +134,7 @@ void Mapgen::makeChunk(BlockMakeData *data) {
|
|||||||
int y2 = node_max.Y;
|
int y2 = node_max.Y;
|
||||||
int x = node_min.X;
|
int x = node_min.X;
|
||||||
int z = node_min.Z;
|
int z = node_min.Z;
|
||||||
//printf("full_node_min.X: %d | full_node_min.Z: %d | MinEdge: %d | MaxEdge: %d\n", node_min.X, node_min.Z, vmanip->m_area.MinEdge.X, vmanip->m_area.MinEdge.Z);
|
|
||||||
TimeTaker timer("Generating terrain");
|
TimeTaker timer("Generating terrain");
|
||||||
map_terrain = noise_terrain->perlinMap2D(x, z);
|
map_terrain = noise_terrain->perlinMap2D(x, z);
|
||||||
map_bgroup = noise_bgroup->perlinMap2D(x, z);
|
map_bgroup = noise_bgroup->perlinMap2D(x, z);
|
||||||
@ -161,11 +163,10 @@ void Mapgen::makeChunk(BlockMakeData *data) {
|
|||||||
updateLighting(node_min, node_max);
|
updateLighting(node_min, node_max);
|
||||||
|
|
||||||
this->generating = false;
|
this->generating = false;
|
||||||
//printf("generated block (%d, %d) to (%d, %d)\n", node_min.X, node_min.Y, node_max.X, node_max.Y);//////////
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Mapgen::updateLiquid(v3s16 node_min, v3s16 node_max) {
|
void MapgenV7::updateLiquid(v3s16 node_min, v3s16 node_max) {
|
||||||
bool isliquid, wasliquid;
|
bool isliquid, wasliquid;
|
||||||
u32 i;
|
u32 i;
|
||||||
|
|
||||||
@ -190,7 +191,7 @@ void Mapgen::updateLiquid(v3s16 node_min, v3s16 node_max) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Mapgen::updateLighting(v3s16 node_min, v3s16 node_max) {
|
void MapgenV7::updateLighting(v3s16 node_min, v3s16 node_max) {
|
||||||
enum LightBank banks[2] = {LIGHTBANK_DAY, LIGHTBANK_NIGHT};
|
enum LightBank banks[2] = {LIGHTBANK_DAY, LIGHTBANK_NIGHT};
|
||||||
|
|
||||||
VoxelArea a(node_min - v3s16(1,0,1) * MAP_BLOCKSIZE,
|
VoxelArea a(node_min - v3s16(1,0,1) * MAP_BLOCKSIZE,
|
||||||
@ -207,30 +208,13 @@ void Mapgen::updateLighting(v3s16 node_min, v3s16 node_max) {
|
|||||||
voxalgo::clearLightAndCollectSources(*vmanip, a, bank, ndef,
|
voxalgo::clearLightAndCollectSources(*vmanip, a, bank, ndef,
|
||||||
light_sources, unlight_from);
|
light_sources, unlight_from);
|
||||||
voxalgo::propagateSunlight(*vmanip, a, sunlight, light_sources, ndef);
|
voxalgo::propagateSunlight(*vmanip, a, sunlight, light_sources, ndef);
|
||||||
printf("light_sources: %d\t\tunlight_from: %d\n", light_sources.size(), unlight_from.size());
|
//printf("light_sources: %d\t\tunlight_from: %d\n", light_sources.size(), unlight_from.size());
|
||||||
vmanip->unspreadLight(bank, unlight_from, light_sources, ndef);
|
vmanip->unspreadLight(bank, unlight_from, light_sources, ndef);
|
||||||
vmanip->spreadLight(bank, light_sources, ndef);
|
vmanip->spreadLight(bank, light_sources, ndef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*class EmergeManager {
|
|
||||||
public:
|
|
||||||
int seed;
|
|
||||||
int water_level;
|
|
||||||
BiomeDefManager *biomedef;
|
|
||||||
|
|
||||||
//mapgen objects here
|
|
||||||
|
|
||||||
void addBlockToQueue();
|
|
||||||
|
|
||||||
|
|
||||||
//mapgen helper methods
|
|
||||||
int getGroundLevelAtPoint(u64 mseed, v2s16 p);
|
|
||||||
bool isBlockUnderground(u64 mseed, v3s16 blockpos);
|
|
||||||
u32 getBlockSeed(u64 mseed, v3s16 p);
|
|
||||||
};*/
|
|
||||||
|
|
||||||
EmergeManager::EmergeManager(IGameDef *gamedef) {
|
EmergeManager::EmergeManager(IGameDef *gamedef) {
|
||||||
this->seed = 0;
|
this->seed = 0;
|
||||||
this->water_level = 0;
|
this->water_level = 0;
|
||||||
@ -279,7 +263,7 @@ bool EmergeManager::isBlockUnderground(v3s16 blockpos) {
|
|||||||
|
|
||||||
//yuck, but then again, should i bother being accurate?
|
//yuck, but then again, should i bother being accurate?
|
||||||
//the height of the nodes in a single block is quite variable
|
//the height of the nodes in a single block is quite variable
|
||||||
return false; //blockpos.Y * (MAP_BLOCKSIZE + 1) <= water_level;
|
return blockpos.Y * (MAP_BLOCKSIZE + 1) <= water_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
101
src/mapgen.h
101
src/mapgen.h
@ -32,8 +32,17 @@ class Biome;
|
|||||||
//struct BlockMakeData;
|
//struct BlockMakeData;
|
||||||
class MapBlock;
|
class MapBlock;
|
||||||
class ManualMapVoxelManipulator;
|
class ManualMapVoxelManipulator;
|
||||||
|
class VoxelManipulator;
|
||||||
class INodeDefManager;
|
class INodeDefManager;
|
||||||
|
|
||||||
|
|
||||||
|
enum BiomeType
|
||||||
|
{
|
||||||
|
BT_NORMAL,
|
||||||
|
BT_DESERT
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct BlockMakeData {
|
struct BlockMakeData {
|
||||||
bool no_op;
|
bool no_op;
|
||||||
ManualMapVoxelManipulator *vmanip;
|
ManualMapVoxelManipulator *vmanip;
|
||||||
@ -48,7 +57,81 @@ struct BlockMakeData {
|
|||||||
~BlockMakeData();
|
~BlockMakeData();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Mapgen {
|
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)
|
||||||
|
static bool get_have_beach(u64 seed, v2s16 p2d);
|
||||||
|
static double tree_amount_2d(u64 seed, v2s16 p);
|
||||||
|
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;
|
||||||
|
Noise *noise_cave;
|
||||||
|
|
||||||
|
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;
|
||||||
|
float *map_cave;
|
||||||
|
|
||||||
|
bool use_smooth_biome_trans;
|
||||||
|
|
||||||
|
MapgenV6(int mapgenid=0, u64 seed=0);
|
||||||
|
~MapgenV6();
|
||||||
|
|
||||||
|
void makeChunk(BlockMakeData *data);
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class MapgenV7 : public Mapgen {
|
||||||
public:
|
public:
|
||||||
BlockMakeData *data;
|
BlockMakeData *data;
|
||||||
ManualMapVoxelManipulator *vmanip;
|
ManualMapVoxelManipulator *vmanip;
|
||||||
@ -59,8 +142,8 @@ public:
|
|||||||
int zstride;
|
int zstride;
|
||||||
|
|
||||||
v3s16 csize;
|
v3s16 csize;
|
||||||
int seed;
|
//int seed;
|
||||||
int water_level;
|
//int water_level;
|
||||||
|
|
||||||
Noise *noise_terrain;
|
Noise *noise_terrain;
|
||||||
Noise *noise_bgroup;
|
Noise *noise_bgroup;
|
||||||
@ -88,23 +171,23 @@ public:
|
|||||||
MapNode n_water;
|
MapNode n_water;
|
||||||
MapNode n_lava;
|
MapNode n_lava;
|
||||||
|
|
||||||
Mapgen(BiomeDefManager *biomedef, int mapgenid=0, u64 seed=0);
|
MapgenV7(BiomeDefManager *biomedef, int mapgenid=0, u64 seed=0);
|
||||||
Mapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
MapgenV7(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
||||||
NoiseParams *np_terrain, NoiseParams *np_bgroup,
|
NoiseParams *np_terrain, NoiseParams *np_bgroup,
|
||||||
NoiseParams *np_heat, NoiseParams *np_humidity);
|
NoiseParams *np_heat, NoiseParams *np_humidity);
|
||||||
void initMapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
void init(BiomeDefManager *biomedef, int mapgenid, u64 seed,
|
||||||
NoiseParams *np_terrain, NoiseParams *np_bgroup,
|
NoiseParams *np_terrain, NoiseParams *np_bgroup,
|
||||||
NoiseParams *np_heat, NoiseParams *np_humidity);
|
NoiseParams *np_heat, NoiseParams *np_humidity);
|
||||||
~Mapgen();
|
~MapgenV7();
|
||||||
|
|
||||||
void makeChunk(BlockMakeData *data);
|
void makeChunk(BlockMakeData *data);
|
||||||
void updateLiquid(v3s16 node_min, v3s16 node_max);
|
void updateLiquid(v3s16 node_min, v3s16 node_max);
|
||||||
void updateLighting(v3s16 node_min, v3s16 node_max);
|
void updateLighting(v3s16 node_min, v3s16 node_max);
|
||||||
|
|
||||||
//Legacy functions for Farmesh (pending removal)
|
//Legacy functions for Farmesh (pending removal)
|
||||||
static bool get_have_beach(u64 seed, v2s16 p2d);
|
// static bool get_have_beach(u64 seed, v2s16 p2d);
|
||||||
static double tree_amount_2d(u64 seed, v2s16 p);
|
// static double tree_amount_2d(u64 seed, v2s16 p);
|
||||||
static s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
|
// static s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
|
||||||
};
|
};
|
||||||
|
|
||||||
class EmergeManager {
|
class EmergeManager {
|
||||||
|
1391
src/mapgen_v6.cpp
Normal file
1391
src/mapgen_v6.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -289,8 +289,8 @@ void Noise::init(NoiseParams *np, int seed, int sx, int sy, int sz) {
|
|||||||
this->noisebuf = NULL;
|
this->noisebuf = NULL;
|
||||||
resizeNoiseBuf(sz > 1);
|
resizeNoiseBuf(sz > 1);
|
||||||
|
|
||||||
this->buf = new float[sx * sy * sz];
|
this->buf = new float[sx * sy * sz];
|
||||||
this->result = new float[sx * sy * sz];
|
this->result = new float[sx * sy * sz];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -311,10 +311,13 @@ void Noise::setSize(int sx, int sy, int sz) {
|
|||||||
this->sy = sy;
|
this->sy = sy;
|
||||||
this->sz = sz;
|
this->sz = sz;
|
||||||
|
|
||||||
|
this->noisebuf = NULL;
|
||||||
resizeNoiseBuf(sz > 1);
|
resizeNoiseBuf(sz > 1);
|
||||||
|
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
delete[] result;
|
delete[] result;
|
||||||
|
this->buf = new float[sx * sy * sz];
|
||||||
|
this->result = new float[sx * sy * sz];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4460,10 +4460,8 @@ static int l_register_biome_groups(lua_State *L)
|
|||||||
{
|
{
|
||||||
luaL_checktype(L, 1, LUA_TTABLE);
|
luaL_checktype(L, 1, LUA_TTABLE);
|
||||||
int index = 1;
|
int index = 1;
|
||||||
if (!lua_istable(L, index)) {
|
if (!lua_istable(L, index))
|
||||||
|
throw LuaError(L, "register_biome_groups: parameter is not a table");
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
BiomeDefManager *bmgr = get_server(L)->getEmergeManager()->biomedef;
|
BiomeDefManager *bmgr = get_server(L)->getEmergeManager()->biomedef;
|
||||||
|
|
||||||
@ -4514,15 +4512,16 @@ static int l_register_biome(lua_State *L)
|
|||||||
b->humidity_min = getfloatfield_default(L, index, "humidity_min", 0.);
|
b->humidity_min = getfloatfield_default(L, index, "humidity_min", 0.);
|
||||||
b->humidity_max = getfloatfield_default(L, index, "humidity_max", 0.);
|
b->humidity_max = getfloatfield_default(L, index, "humidity_max", 0.);
|
||||||
|
|
||||||
//////hrm, what to do about the noiseparams...
|
b->np = new NoiseParams; // should read an entire NoiseParams later on...
|
||||||
b->np = new NoiseParams; /////just a hacky solution
|
|
||||||
getfloatfield(L, index, "scale", b->np->scale);
|
getfloatfield(L, index, "scale", b->np->scale);
|
||||||
getfloatfield(L, index, "offset", b->np->offset);
|
getfloatfield(L, index, "offset", b->np->offset);
|
||||||
//TODO: add configurable spread factor and octaves!?
|
|
||||||
//I'd have to create a Noise for every Biome...
|
|
||||||
bmgr->addBiome(groupid, b);
|
|
||||||
printf(" - added biome '%s' - %d %d\n", b->name.c_str(), b->n_top.param0, b->n_filler.param0);
|
|
||||||
|
|
||||||
|
b->groupid = (s8)groupid;
|
||||||
|
b->flags = 0; //reserved
|
||||||
|
|
||||||
|
bmgr->addBiome(b);
|
||||||
|
|
||||||
|
verbosestream << "register_biome: " << b->name << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,8 +172,12 @@ void * EmergeThread::Thread()
|
|||||||
|
|
||||||
ServerMap &map = ((ServerMap&)m_server->m_env->getMap());
|
ServerMap &map = ((ServerMap&)m_server->m_env->getMap());
|
||||||
EmergeManager *emerge = m_server->m_emerge;
|
EmergeManager *emerge = m_server->m_emerge;
|
||||||
Mapgen *mapgen = new Mapgen( m_server->m_emerge->biomedef,/*mapgenid*/ 0, map.getSeed()); ////////fix this...!
|
|
||||||
|
|
||||||
|
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
|
Get block info from queue, emerge them and send them
|
||||||
to clients.
|
to clients.
|
||||||
|
Loading…
Reference in New Issue
Block a user