Mapgen *mapgen;
bool enable_mapgen_debug_info;
int id;
-
+
Event qevent;
std::queue<v3s16> blockqueue;
-
+
EmergeThread(Server *server, int ethreadid):
SimpleThread(),
m_server(server),
this->ndef = gamedef->getNodeDefManager();
this->biomedef = new BiomeDefManager();
this->params = NULL;
-
+
this->luaoverride_params = NULL;
this->luaoverride_params_modified = 0;
this->luaoverride_flagmask = 0;
-
+
mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info");
-
+
int nthreads;
if (g_settings->get("num_emerge_threads").empty()) {
int nprocs = porting::getNumberOfProcessors();
}
if (nthreads < 1)
nthreads = 1;
-
+
qlimit_total = g_settings->getU16("emergequeue_limit_total");
qlimit_diskonly = g_settings->get("emergequeue_limit_diskonly").empty() ?
nthreads * 5 + 1 :
qlimit_generate = g_settings->get("emergequeue_limit_generate").empty() ?
nthreads + 1 :
g_settings->getU16("emergequeue_limit_generate");
-
+
for (int i = 0; i != nthreads; i++)
emergethread.push_back(new EmergeThread((Server *)gamedef, i));
-
+
infostream << "EmergeManager: using " << nthreads << " threads" << std::endl;
}
for (unsigned int i = 0; i < decorations.size(); i++)
delete decorations[i];
decorations.clear();
-
+
for (std::map<std::string, MapgenFactory *>::iterator iter = mglist.begin();
iter != mglist.end(); iter ++) {
delete iter->second;
void EmergeManager::initMapgens(MapgenParams *mgparams) {
Mapgen *mg;
-
+
if (mapgen.size())
return;
-
+
// Resolve names of nodes for things that were registered
// (at this point, the registration period is over)
biomedef->resolveNodeNames(ndef);
-
+
for (size_t i = 0; i != ores.size(); i++)
ores[i]->resolveNodeNames(ndef);
-
+
for (size_t i = 0; i != decorations.size(); i++)
decorations[i]->resolveNodeNames(ndef);
-
+
// Apply mapgen parameter overrides from Lua
if (luaoverride_params) {
- if (luaoverride_params_modified & MGPARAMS_SET_MGNAME)
- mgparams->mg_name = luaoverride_params->mg_name;
-
+ if (luaoverride_params_modified & MGPARAMS_SET_MGNAME) {
+ MapgenParams *mgp = setMapgenType(mgparams, luaoverride_params->mg_name);
+ if (!mgp) {
+ errorstream << "EmergeManager: Failed to set new mapgen name"
+ << std::endl;
+ } else {
+ mgparams = mgp;
+ }
+ }
+
if (luaoverride_params_modified & MGPARAMS_SET_SEED)
mgparams->seed = luaoverride_params->seed;
-
+
if (luaoverride_params_modified & MGPARAMS_SET_WATER_LEVEL)
mgparams->water_level = luaoverride_params->water_level;
-
+
if (luaoverride_params_modified & MGPARAMS_SET_FLAGS) {
mgparams->flags &= ~luaoverride_flagmask;
mgparams->flags |= luaoverride_params->flags;
}
-
+
delete luaoverride_params;
luaoverride_params = NULL;
}
-
+
// Create the mapgens
this->params = mgparams;
for (size_t i = 0; i != emergethread.size(); i++) {
- mg = createMapgen(params->mg_name, 0, params);
+ mg = createMapgen(params->mg_name, i, params);
if (!mg) {
- infostream << "EmergeManager: falling back to mapgen v6" << std::endl;
- delete params;
- params = createMapgenParams("v6");
- mg = createMapgen("v6", 0, params);
+ infostream << "EmergeManager: Falling back to Mapgen V6" << std::endl;
+
+ params = setMapgenType(params, "v6");
+ mg = createMapgen(params->mg_name, i, params);
+ if (!mg) {
+ errorstream << "EmergeManager: CRITICAL ERROR: Failed to fall"
+ "back to Mapgen V6, not generating map" << std::endl;
+ }
}
mapgen.push_back(mg);
}
}
+MapgenParams *EmergeManager::setMapgenType(MapgenParams *mgparams,
+ std::string newname) {
+ MapgenParams *newparams = createMapgenParams(newname);
+ if (!newparams) {
+ errorstream << "EmergeManager: Mapgen override failed" << std::endl;
+ return NULL;
+ }
+
+ newparams->mg_name = newname;
+ newparams->seed = mgparams->seed;
+ newparams->water_level = mgparams->water_level;
+ newparams->chunksize = mgparams->chunksize;
+ newparams->flags = mgparams->flags;
+
+ if (!newparams->readParams(g_settings)) {
+ errorstream << "EmergeManager: Mapgen override failed" << std::endl;
+ delete newparams;
+ return NULL;
+ }
+
+ delete mgparams;
+ return newparams;
+}
+
+
Mapgen *EmergeManager::getCurrentMapgen() {
for (unsigned int i = 0; i != emergethread.size(); i++) {
if (emergethread[i]->IsSameThread())
return emergethread[i]->mapgen;
}
-
+
return NULL;
}
emergethread[i]->trigger();
}
+
bool EmergeManager::enqueueBlockEmerge(u16 peer_id, v3s16 p, bool allow_generate) {
std::map<v3s16, BlockEmergeData *>::const_iterator iter;
BlockEmergeData *bedata;
u16 count;
u8 flags = 0;
int idx = 0;
-
+
if (allow_generate)
flags |= BLOCK_EMERGE_ALLOWGEN;
{
JMutexAutoLock queuelock(queuemutex);
-
+
count = blocks_enqueued.size();
if (count >= qlimit_total)
return false;
u16 qlimit_peer = allow_generate ? qlimit_generate : qlimit_diskonly;
if (count >= qlimit_peer)
return false;
-
+
iter = blocks_enqueued.find(p);
if (iter != blocks_enqueued.end()) {
bedata = iter->second;
bedata->flags = flags;
bedata->peer_requested = peer_id;
blocks_enqueued.insert(std::make_pair(p, bedata));
-
+
peer_queue_count[peer_id] = count + 1;
-
+
// insert into the EmergeThread queue with the least items
int lowestitems = emergethread[0]->blockqueue.size();
for (unsigned int i = 1; i != emergethread.size(); i++) {
lowestitems = nitems;
}
}
-
+
emergethread[idx]->blockqueue.push(p);
}
emergethread[idx]->qevent.signal();
-
+
return true;
}
int EmergeManager::getGroundLevelAtPoint(v2s16 p) {
if (mapgen.size() == 0 || !mapgen[0]) {
errorstream << "EmergeManager: getGroundLevelAtPoint() called"
- " before mapgen initialized" << std::endl;
+ " before mapgen initialized" << std::endl;
return 0;
}
-
+
return mapgen[0]->getGroundLevelAtPoint(p);
}
" not registered" << std::endl;
return NULL;
}
-
+
MapgenFactory *mgfactory = iter->second;
return mgfactory->createMapgen(mgid, mgparams, this);
}
" not registered" << std::endl;
return NULL;
}
-
+
MapgenFactory *mgfactory = iter->second;
return mgfactory->createMapgenParams();
}
MapgenParams *mgparams = createMapgenParams(mg_name);
if (!mgparams)
return NULL;
-
+
std::string seedstr = settings->get(settings == g_settings ?
"fixed_map_seed" : "seed");
-
+
mgparams->mg_name = mg_name;
mgparams->seed = read_seed(seedstr.c_str());
mgparams->water_level = settings->getS16("water_level");
return false;
v3s16 p = blockqueue.front();
blockqueue.pop();
-
+
*pos = p;
-
+
iter = emerge->blocks_enqueued.find(p);
if (iter == emerge->blocks_enqueued.end())
return false; //uh oh, queue and map out of sync!!
BlockEmergeData *bedata = iter->second;
*flags = bedata->flags;
-
+
emerge->peer_queue_count[bedata->peer_requested]--;
delete bedata;
emerge->blocks_enqueued.erase(iter);
-
+
return true;
}
v2s16 p2d(p.X, p.Z);
//envlock: usually takes <=1ms, sometimes 90ms or ~400ms to acquire
JMutexAutoLock envlock(m_server->m_env_mutex);
-
+
// Load sector if it isn't loaded
if (map->getSectorNoGenerateNoEx(p2d) == NULL)
map->loadSectorMeta(p2d);
*b = block;
return map->initBlockMake(data, p);
}
-
+
*b = block;
return false;
}
v3s16 last_tried_pos(-32768,-32768,-32768); // For error output
v3s16 p;
u8 flags;
-
+
map = (ServerMap *)&(m_server->m_env->getMap());
emerge = m_server->m_emerge;
mapgen = emerge->mapgen[id];
enable_mapgen_debug_info = emerge->mapgen_debug_info;
-
+
while (getRun())
try {
if (!popBlockEmerge(&p, &flags)) {
bool allow_generate = flags & BLOCK_EMERGE_ALLOWGEN;
EMERGE_DBG_OUT("p=" PP(p) " allow_generate=" << allow_generate);
-
+
/*
Try to fetch block from memory or disk.
If not found and asked to generate, initialize generator.
BlockMakeData data;
MapBlock *block = NULL;
std::map<v3s16, MapBlock *> modified_blocks;
-
- if (getBlockOrStartGen(p, &block, &data, allow_generate)) {
+
+ if (getBlockOrStartGen(p, &block, &data, allow_generate) && mapgen) {
{
ScopeProfiler sp(g_profiler, "EmergeThread: Mapgen::makeChunk", SPT_AVG);
TimeTaker t("mapgen::make_block()");
"Mapgen::makeChunk (envlock)", SPT_AVG);
map->finishBlockMake(&data, modified_blocks);
-
+
block = map->getBlockNoCreateNoEx(p);
if (block) {
/*
}
EMERGE_DBG_OUT("ended up with: " << analyze_block(block));
-
+
m_server->m_env->activateBlock(block, 0);
}
}
err << "You can ignore this using [ignore_world_load_errors = true]."<<std::endl;
m_server->setAsyncFatalError(err.str());
}
-
+
END_DEBUG_EXCEPTION_HANDLER(errorstream)
log_deregister_thread();
return NULL;
INodeDefManager *ndef;
std::map<std::string, MapgenFactory *> mglist;
-
+
std::vector<Mapgen *> mapgen;
std::vector<EmergeThread *> emergethread;
-
+
//settings
MapgenParams *params;
bool mapgen_debug_info;
u16 qlimit_total;
u16 qlimit_diskonly;
u16 qlimit_generate;
-
+
MapgenParams *luaoverride_params;
u32 luaoverride_params_modified;
u32 luaoverride_flagmask;
-
+
//block emerge queue data structures
JMutex queuemutex;
std::map<v3s16, BlockEmergeData *> blocks_enqueued;
~EmergeManager();
void initMapgens(MapgenParams *mgparams);
+ MapgenParams *setMapgenType(MapgenParams *mgparams, std::string newname);
Mapgen *getCurrentMapgen();
Mapgen *createMapgen(std::string mgname, int mgid,
MapgenParams *mgparams);
MapgenParams *createMapgenParams(std::string mgname);
void triggerAllThreads();
bool enqueueBlockEmerge(u16 peer_id, v3s16 p, bool allow_generate);
-
+
void registerMapgen(std::string name, MapgenFactory *mgfactory);
MapgenParams *getParamsFromSettings(Settings *settings);
void setParamsToSettings(Settings *settings);
-
+
//mapgen helper methods
Biome *getBiomeAtPoint(v3s16 p);
int getGroundLevelAtPoint(v2s16 p);
int x0 = pr.range(nmin.X, nmax.X - csize + 1);
int y0 = pr.range(nmin.Y, nmax.Y - csize + 1);
int z0 = pr.range(nmin.Z, nmax.Z - csize + 1);
-
+
if (np && (NoisePerlin3D(np, x0, y0, z0, seed) < nthresh))
continue;
void Decoration::resolveNodeNames(INodeDefManager *ndef) {
this->ndef = ndef;
-
+
if (c_place_on == CONTENT_IGNORE)
c_place_on = ndef->getId(place_on_name);
}
"sidelen; setting sidelen to " << carea_size << std::endl;
sidelen = carea_size;
}
-
+
s16 divlen = carea_size / sidelen;
int area = sidelen * sidelen;
s16 z = ps.range(p2d_min.Y, p2d_max.Y);
int mapindex = carea_size * (z - nmin.Z) + (x - nmin.X);
-
- s16 y = mg->heightmap ?
+
+ s16 y = mg->heightmap ?
mg->heightmap[mapindex] :
mg->findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y);
-
+
if (y < nmin.Y || y > nmax.Y)
continue;
if (mg->biomemap) {
std::set<u8>::iterator iter;
-
+
if (biomes.size()) {
iter = biomes.find(mg->biomemap[mapindex]);
if (iter == biomes.end())
void Decoration::placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) {
PseudoRandom pr(blockseed + 53);
std::vector<CutoffData> handled_cutoffs;
-
+
// Copy over the cutoffs we're interested in so we don't needlessly hold a lock
{
JMutexAutoLock cutofflock(cutoff_mutex);
continue;
if (p.Y + height < nmin.Y || p.Y > nmax.Y)
continue;
-
+
handled_cutoffs.push_back(cutoff);
}
}
-
+
// Generate the cutoffs
for (size_t i = 0; i != handled_cutoffs.size(); i++) {
v3s16 p = handled_cutoffs[i].p;
s16 height = handled_cutoffs[i].height;
-
+
if (p.Y + height > nmax.Y) {
//printf("Decoration at (%d %d %d) cut off again!\n", p.X, p.Y, p.Z);
cuttoffs.push_back(v3s16(p.X, p.Y, p.Z));
}
-
+
generate(mg, &pr, nmax.Y, nmin.Y - p.Y, v3s16(p.X, nmin.Y, p.Z));
}
-
+
// Remove cutoffs that were handled from the cutoff list
{
JMutexAutoLock cutofflock(cutoff_mutex);
for (std::list<CutoffData>::iterator i = cutoffs.begin();
i != cutoffs.end(); ++i) {
-
+
for (size_t j = 0; j != handled_cutoffs.size(); j++) {
CutoffData coff = *i;
if (coff.p == handled_cutoffs[j].p)
i = cutoffs.erase(i);
}
}
- }
+ }
}
#endif
void DecoSimple::resolveNodeNames(INodeDefManager *ndef) {
Decoration::resolveNodeNames(ndef);
-
+
if (c_deco == CONTENT_IGNORE && !decolist_names.size()) {
c_deco = ndef->getId(deco_name);
if (c_deco == CONTENT_IGNORE) {
c_spawnby = CONTENT_AIR;
}
}
-
+
if (c_decolist.size())
return;
-
- for (size_t i = 0; i != decolist_names.size(); i++) {
+
+ for (size_t i = 0; i != decolist_names.size(); i++) {
content_t c = ndef->getId(decolist_names[i]);
if (c == CONTENT_IGNORE) {
errorstream << "DecoSimple::resolveNodeNames: decolist node '"
if (vm->m_data[vi].getContent() != c_place_on &&
c_place_on != CONTENT_IGNORE)
return;
-
+
if (nspawnby != -1) {
int nneighs = 0;
v3s16 dirs[8] = { // a Moore neighborhood
v3s16(-1, 0, -1),
v3s16( 1, 0, -1)
};
-
+
for (int i = 0; i != 8; i++) {
u32 index = vm->m_area.index(p + dirs[i]);
if (vm->m_area.contains(index) &&
vm->m_data[index].getContent() == c_spawnby)
nneighs++;
}
-
+
if (nneighs < nspawnby)
return;
}
-
+
size_t ndecos = c_decolist.size();
content_t c_place = ndecos ? c_decolist[pr->range(0, ndecos - 1)] : c_deco;
pr->range(deco_height, deco_height_max) : deco_height;
height = MYMIN(height, max_y - p.Y);
-
+
v3s16 em = vm->m_area.getExtent();
for (int i = 0; i < height; i++) {
vm->m_area.add_y(em, vi, 1);
-
+
content_t c = vm->m_data[vi].getContent();
if (c != CONTENT_AIR && c != CONTENT_IGNORE)
break;
-
+
vm->m_data[vi] = MapNode(c_place);
}
}
void DecoSchematic::resolveNodeNames(INodeDefManager *ndef) {
Decoration::resolveNodeNames(ndef);
-
+
if (filename.empty())
return;
-
+
if (!node_names) {
errorstream << "DecoSchematic::resolveNodeNames: node name list was "
"not created" << std::endl;
return;
}
-
+
for (size_t i = 0; i != node_names->size(); i++) {
std::string name = node_names->at(i);
-
+
std::map<std::string, std::string>::iterator it;
it = replacements.find(name);
if (it != replacements.end())
name = it->second;
-
+
content_t c = ndef->getId(name);
if (c == CONTENT_IGNORE) {
errorstream << "DecoSchematic::resolveNodeNames: node '"
<< name << "' not defined" << std::endl;
c = CONTENT_AIR;
}
-
+
c_nodes.push_back(c);
}
-
+
for (int i = 0; i != size.X * size.Y * size.Z; i++)
schematic[i].setContent(c_nodes[schematic[i].getContent()]);
-
+
delete node_names;
node_names = NULL;
}
p.Y -= (size.Y + 1) / 2;
if (flags & DECO_PLACE_CENTER_Z)
p.Z -= (size.Z + 1) / 2;
-
+
u32 vi = vm->m_area.index(p);
if (vm->m_data[vi].getContent() != c_place_on &&
c_place_on != CONTENT_IGNORE)
return;
-
+
Rotation rot = (rotation == ROTATE_RAND) ?
(Rotation)pr->range(ROTATE_0, ROTATE_270) : rotation;
-
+
blitToVManip(p, vm, rot, false);
}
Rotation rot = (rotation == ROTATE_RAND) ?
(Rotation)myrand_range(ROTATE_0, ROTATE_270) : rotation;
-
+
v3s16 s = (rot == ROTATE_90 || rot == ROTATE_270) ?
v3s16(size.Z, size.Y, size.X) : size;
p.Y -= (s.Y + 1) / 2;
if (flags & DECO_PLACE_CENTER_Z)
p.Z -= (s.Z + 1) / 2;
-
+
v3s16 bp1 = getNodeBlockPos(p);
v3s16 bp2 = getNodeBlockPos(p + s - v3s16(1,1,1));
vm->initialEmerge(bp1, bp2);
-
+
blitToVManip(p, vm, rot, true);
-
+
std::map<v3s16, MapBlock *> lighting_modified_blocks;
std::map<v3s16, MapBlock *> modified_blocks;
vm->blitBackAll(&modified_blocks);
-
+
// TODO: Optimize this by using Mapgen::calcLighting() instead
lighting_modified_blocks.insert(modified_blocks.begin(), modified_blocks.end());
map->updateLighting(lighting_modified_blocks, modified_blocks);
it = modified_blocks.begin();
it != modified_blocks.end(); ++it)
event.modified_blocks.insert(it->first);
-
+
map->dispatchEvent(&event);
}
bool DecoSchematic::loadSchematicFile() {
content_t cignore = CONTENT_IGNORE;
bool have_cignore = false;
-
+
std::ifstream is(filename.c_str(), std::ios_base::binary);
u32 signature = readU32(is);
"file" << std::endl;
return false;
}
-
+
u16 version = readU16(is);
if (version > MTSCHEM_FILE_VER_HIGHEST_READ) {
errorstream << "loadSchematicFile: unsupported schematic "
}
int nodecount = size.X * size.Y * size.Z;
-
+
u16 nidmapcount = readU16(is);
-
+
node_names = new std::vector<std::string>;
for (int i = 0; i != nidmapcount; i++) {
std::string name = deSerializeString(is);
schematic = new MapNode[nodecount];
MapNode::deSerializeBulk(is, SER_FMT_VER_HIGHEST_READ, schematic,
nodecount, 2, 2, true);
-
+
if (version == 1) { // fix up the probability values
for (int i = 0; i != nodecount; i++) {
if (schematic[i].param1 == 0)
schematic[i].param1 = MTSCHEM_PROB_NEVER;
}
}
-
+
return true;
}
For each node in schematic:
[u8] param2
}
-
+
Version changes:
1 - Initial version
2 - Fixed messy never/always place; 0 probability is now never, 0xFF is always
std::vector<content_t> usednodes;
int nodecount = size.X * size.Y * size.Z;
build_nnlist_and_update_ids(schematic, nodecount, &usednodes);
-
+
u16 numids = usednodes.size();
writeU16(ss, numids); // name count
for (int i = 0; i != numids; i++)
ss << serializeString(ndef->get(usednodes[i]).name); // node names
-
+
// compressed bulk node data
MapNode::serializeBulk(ss, SER_FMT_VER_HIGHEST_WRITE, schematic,
nodecount, 2, 2, true);
std::vector<content_t> *usednodes) {
std::map<content_t, content_t> nodeidmap;
content_t numids = 0;
-
+
for (u32 i = 0; i != nodecount; i++) {
content_t id;
content_t c = nodes[i].getContent();
v3s16 bp1 = getNodeBlockPos(p1);
v3s16 bp2 = getNodeBlockPos(p2);
vm->initialEmerge(bp1, bp2);
-
+
size = p2 - p1 + 1;
slice_probs = new u8[size.Y];
slice_probs[y] = MTSCHEM_PROB_ALWAYS;
schematic = new MapNode[size.X * size.Y * size.Z];
-
+
u32 i = 0;
for (s16 z = p1.Z; z <= p2.Z; z++)
for (s16 y = p1.Y; y <= p2.Y; y++) {
if (index < size.Z * size.Y * size.X) {
u8 prob = (*plist)[i].second;
schematic[index].param1 = prob;
-
+
// trim unnecessary node names from schematic
if (prob == MTSCHEM_PROB_NEVER)
schematic[index].setContent(CONTENT_AIR);
s16 y_nodes_min = vm->m_area.MinEdge.Y;
u32 i = vm->m_area.index(p2d.X, y_nodes_max, p2d.Y);
s16 y;
-
+
for (y = y_nodes_max; y >= y_nodes_min; y--) {
MapNode &n = vm->m_data[i];
if (ndef->get(n).walkable)
v3s16 em = vm->m_area.getExtent();
u32 i = vm->m_area.index(p2d.X, ymax, p2d.Y);
s16 y;
-
+
for (y = ymax; y >= ymin; y--) {
MapNode &n = vm->m_data[i];
if (ndef->get(n).walkable)
void Mapgen::updateHeightmap(v3s16 nmin, v3s16 nmax) {
if (!heightmap)
return;
-
+
//TimeTaker t("Mapgen::updateHeightmap", NULL, PRECISION_MICRO);
int index = 0;
for (s16 z = nmin.Z; z <= nmax.Z; z++) {
continue;
if (y == nmin.Y - 1 && heightmap[index] < nmin.Y)
continue;
-
+
heightmap[index] = y;
}
}
continue;
}
vm->m_area.add_y(em, i, -1);
-
+
for (int y = a.MaxEdge.Y; y >= a.MinEdge.Y; y--) {
MapNode &n = vm->m_data[i];
if (!ndef->get(n).sunlight_propagates)
vm->spreadLight(bank, light_sources, ndef);
}
}
-
-
+
+
//////////////////////// Mapgen V6 parameter read/write
-
+
bool MapgenV6Params::readParams(Settings *settings) {
freq_desert = settings->getFloat("mgv6_freq_desert");
freq_beach = settings->getFloat("mgv6_freq_beach");
- bool success =
+ bool success =
settings->getNoiseParams("mgv6_np_terrain_base", np_terrain_base) &&
settings->getNoiseParams("mgv6_np_terrain_higher", np_terrain_higher) &&
settings->getNoiseParams("mgv6_np_steepness", np_steepness) &&
settings->getNoiseParams("mgv6_np_apple_trees", np_apple_trees);
return success;
}
-
-
+
+
void MapgenV6Params::writeParams(Settings *settings) {
settings->setFloat("mgv6_freq_desert", freq_desert);
settings->setFloat("mgv6_freq_beach", freq_beach);
-
+
settings->setNoiseParams("mgv6_np_terrain_base", np_terrain_base);
settings->setNoiseParams("mgv6_np_terrain_higher", np_terrain_higher);
settings->setNoiseParams("mgv6_np_steepness", np_steepness);
bool MapgenV7Params::readParams(Settings *settings) {
- bool success =
+ bool success =
settings->getNoiseParams("mgv7_np_terrain_base", np_terrain_base) &&
settings->getNoiseParams("mgv7_np_terrain_alt", np_terrain_alt) &&
settings->getNoiseParams("mgv7_np_terrain_persist", np_terrain_persist) &&
/////////////////// Ore generation flags
// Use absolute value of height to determine ore placement
-#define OREFLAG_ABSHEIGHT 0x01
+#define OREFLAG_ABSHEIGHT 0x01
// Use 3d noise to get density of ore placement, instead of just the position
#define OREFLAG_DENSITY 0x02 // not yet implemented
// For claylike ore types, place ore if the number of surrounding
chunksize = 5;
flags = MG_TREES | MG_CAVES | MGV6_BIOME_BLEND;
}
-
+
virtual bool readParams(Settings *settings) { return true; }
virtual void writeParams(Settings *settings) {}
virtual ~MapgenParams() {}
int id;
ManualMapVoxelManipulator *vm;
INodeDefManager *ndef;
-
+
s16 *heightmap;
u8 *biomemap;
v3s16 csize;
s16 height_max;
u8 ore_param2; // to set node-specific attributes
u32 flags; // attributes for this ore
- float nthresh; // threshhold for noise at which an ore is placed
+ float nthresh; // threshhold for noise at which an ore is placed
NoiseParams *np; // noise for distribution of clusters (NULL for uniform scattering)
Noise *noise;
-
+
Ore() {
ore = CONTENT_IGNORE;
np = NULL;
noise = NULL;
}
-
+
virtual ~Ore();
-
+
void resolveNodeNames(INodeDefManager *ndef);
void placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
virtual void generate(ManualMapVoxelManipulator *vm, int seed,
//v3s16 p;
//v3s16 size;
//s16 height;
-
+
CutoffData(s16 x, s16 y, s16 z, s16 h) {
p = v3s16(x, y, z);
height = h;
class Decoration {
public:
INodeDefManager *ndef;
-
+
int mapseed;
std::string place_on_name;
content_t c_place_on;
s16 sidelen;
float fill_ratio;
NoiseParams *np;
-
+
std::set<u8> biomes;
//std::list<CutoffData> cutoffs;
//JMutex cutoff_mutex;
Decoration();
virtual ~Decoration();
-
+
virtual void resolveNodeNames(INodeDefManager *ndef);
void placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
void placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
-
+
virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p) = 0;
virtual int getHeight() = 0;
virtual std::string getName() = 0;
s16 deco_height;
s16 deco_height_max;
s16 nspawnby;
-
+
std::vector<std::string> decolist_names;
std::vector<content_t> c_decolist;
~DecoSimple() {}
-
+
void resolveNodeNames(INodeDefManager *ndef);
virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
virtual int getHeight();
class DecoSchematic : public Decoration {
public:
std::string filename;
-
+
std::vector<std::string> *node_names;
std::vector<content_t> c_nodes;
std::map<std::string, std::string> replacements;
DecoSchematic();
~DecoSchematic();
-
+
void resolveNodeNames(INodeDefManager *ndef);
virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
virtual int getHeight();
virtual std::string getName();
-
+
void blitToVManip(v3s16 p, ManualMapVoxelManipulator *vm,
Rotation rot, bool force_placement);
-
+
bool loadSchematicFile();
void saveSchematicFile(INodeDefManager *ndef);
-
+
bool getSchematicFromMap(Map *map, v3s16 p1, v3s16 p2);
void placeStructure(Map *map, v3s16 p);
void applyProbabilities(v3s16 p0,