/*
Free all MapSectors
*/
- for(std::map<v2s16, MapSector*>::iterator i = m_sectors.begin();
- i != m_sectors.end(); ++i)
- {
- delete i->second;
+ for (auto §or : m_sectors) {
+ delete sector.second;
}
}
void Map::dispatchEvent(MapEditEvent *event)
{
- for(std::set<MapEventReceiver*>::iterator
- i = m_event_receivers.begin();
- i != m_event_receivers.end(); ++i)
- {
- (*i)->onMapEditEvent(event);
+ for (MapEventReceiver *event_receiver : m_event_receivers) {
+ event_receiver->onMapEditEvent(event);
}
}
std::map<v2s16, MapSector*>::iterator n = m_sectors.find(p);
- if(n == m_sectors.end())
+ if (n == m_sectors.end())
return NULL;
MapSector *sector = n->second;
if (block == NULL) {
if (is_valid_position != NULL)
*is_valid_position = false;
- return MapNode(CONTENT_IGNORE);
+ return {CONTENT_IGNORE};
}
v3s16 relpos = p - blockpos*MAP_BLOCKSIZE;
// Update lighting
std::vector<std::pair<v3s16, MapNode> > oldnodes;
- oldnodes.push_back(std::pair<v3s16, MapNode>(p, oldnode));
+ oldnodes.emplace_back(p, oldnode);
voxalgo::update_lighting_nodes(this, oldnodes, modified_blocks);
- for(std::map<v3s16, MapBlock*>::iterator
- i = modified_blocks.begin();
- i != modified_blocks.end(); ++i)
- {
- i->second->expireDayNightDiff();
+ for (auto &modified_block : modified_blocks) {
+ modified_block.second->expireDayNightDiff();
}
// Report for rollback
Add neighboring liquid nodes and this node to transform queue.
(it's vital for the node itself to get updated last, if it was removed.)
*/
- v3s16 dirs[7] = {
- v3s16(0,0,1), // back
- v3s16(0,1,0), // top
- v3s16(1,0,0), // right
- v3s16(0,0,-1), // front
- v3s16(0,-1,0), // bottom
- v3s16(-1,0,0), // left
- v3s16(0,0,0), // self
- };
- for(u16 i=0; i<7; i++)
- {
- v3s16 p2 = p + dirs[i];
+
+ for (const v3s16 &dir : g_7dirs) {
+ v3s16 p2 = p + dir;
bool is_valid_position;
MapNode n2 = getNodeNoEx(p2, &is_valid_position);
addNodeAndUpdate(p, n, modified_blocks, remove_metadata);
// Copy modified_blocks to event
- for(std::map<v3s16, MapBlock*>::iterator
- i = modified_blocks.begin();
- i != modified_blocks.end(); ++i)
- {
- event.modified_blocks.insert(i->first);
+ for (auto &modified_block : modified_blocks) {
+ event.modified_blocks.insert(modified_block.first);
}
}
catch(InvalidPositionException &e){
removeNodeAndUpdate(p, modified_blocks);
// Copy modified_blocks to event
- for(std::map<v3s16, MapBlock*>::iterator
- i = modified_blocks.begin();
- i != modified_blocks.end(); ++i)
- {
- event.modified_blocks.insert(i->first);
+ for (auto &modified_block : modified_blocks) {
+ event.modified_blocks.insert(modified_block.first);
}
}
catch(InvalidPositionException &e){
// If there is no practical limit, we spare creation of mapblock_queue
if (max_loaded_blocks == U32_MAX) {
- for (std::map<v2s16, MapSector*>::iterator si = m_sectors.begin();
- si != m_sectors.end(); ++si) {
- MapSector *sector = si->second;
+ for (auto §or_it : m_sectors) {
+ MapSector *sector = sector_it.second;
bool all_blocks_deleted = true;
MapBlockVect blocks;
sector->getBlocks(blocks);
- for (MapBlockVect::iterator i = blocks.begin();
- i != blocks.end(); ++i) {
- MapBlock *block = (*i);
-
+ for (MapBlock *block : blocks) {
block->incrementUsageTimer(dtime);
if (block->refGet() == 0
}
if (all_blocks_deleted) {
- sector_deletion_queue.push_back(si->first);
+ sector_deletion_queue.push_back(sector_it.first);
}
}
} else {
std::priority_queue<TimeOrderedMapBlock> mapblock_queue;
- for (std::map<v2s16, MapSector*>::iterator si = m_sectors.begin();
- si != m_sectors.end(); ++si) {
- MapSector *sector = si->second;
+ for (auto §or_it : m_sectors) {
+ MapSector *sector = sector_it.second;
MapBlockVect blocks;
sector->getBlocks(blocks);
- for(MapBlockVect::iterator i = blocks.begin();
- i != blocks.end(); ++i) {
- MapBlock *block = (*i);
-
+ for (MapBlock *block : blocks) {
block->incrementUsageTimer(dtime);
mapblock_queue.push(TimeOrderedMapBlock(sector, block));
}
block_count_all--;
}
// Delete empty sectors
- for (std::map<v2s16, MapSector*>::iterator si = m_sectors.begin();
- si != m_sectors.end(); ++si) {
- if (si->second->empty()) {
- sector_deletion_queue.push_back(si->first);
+ for (auto §or_it : m_sectors) {
+ if (sector_it.second->empty()) {
+ sector_deletion_queue.push_back(sector_it.first);
}
}
}
MapBlock *block = getBlockNoCreateNoEx(blockpos);
if (block != NULL) {
modified_blocks[blockpos] = block;
- changed_nodes.push_back(std::pair<v3s16, MapNode>(p0, n00));
+ changed_nodes.emplace_back(p0, n00);
}
/*
}
//infostream<<"Map::transformLiquids(): loopcount="<<loopcount<<std::endl;
- for (std::deque<v3s16>::iterator iter = must_reflow.begin(); iter != must_reflow.end(); ++iter)
- m_transforming_liquid.push_back(*iter);
+ for (auto &iter : must_reflow)
+ m_transforming_liquid.push_back(iter);
voxalgo::update_lighting_nodes(this, changed_nodes, modified_blocks);
m_savedir = savedir;
m_map_saving_enabled = false;
- try
- {
+ try {
// If directory exists, check contents and load if possible
- if(fs::PathExists(m_savedir))
- {
+ if (fs::PathExists(m_savedir)) {
// If directory is empty, it is safe to save into it.
- if(fs::GetDirListing(m_savedir).size() == 0)
- {
+ if (fs::GetDirListing(m_savedir).empty()) {
infostream<<"ServerMap: Empty save directory is valid."
<<std::endl;
m_map_saving_enabled = true;
data->transforming_liquid.pop_front();
}
- for (std::map<v3s16, MapBlock *>::iterator
- it = changed_blocks->begin();
- it != changed_blocks->end(); ++it) {
- MapBlock *block = it->second;
+ for (auto &changed_block : *changed_blocks) {
+ MapBlock *block = changed_block.second;
if (!block)
continue;
/*
MapBlockVect blocks;
sector->getBlocks(blocks);
- for(MapBlockVect::iterator j = blocks.begin();
- j != blocks.end(); ++j) {
- MapBlock *block = *j;
-
+ for (MapBlock *block : blocks) {
block_count_all++;
if(block->getModified() >= (u32)save_level) {
void ServerMap::listAllLoadedBlocks(std::vector<v3s16> &dst)
{
- for(std::map<v2s16, MapSector*>::iterator si = m_sectors.begin();
- si != m_sectors.end(); ++si)
- {
- MapSector *sector = si->second;
+ for (auto §or_it : m_sectors) {
+ MapSector *sector = sector_it.second;
MapBlockVect blocks;
sector->getBlocks(blocks);
- for(MapBlockVect::iterator i = blocks.begin();
- i != blocks.end(); ++i) {
- v3s16 p = (*i)->getPos();
+ for (MapBlock *block : blocks) {
+ v3s16 p = block->getPos();
dst.push_back(p);
}
}
if (name == "dummy")
return new Database_Dummy();
#if USE_LEVELDB
- else if (name == "leveldb")
+ if (name == "leveldb")
return new Database_LevelDB(savedir);
#endif
#if USE_REDIS
- else if (name == "redis")
+ if (name == "redis")
return new Database_Redis(conf);
#endif
#if USE_POSTGRESQL
- else if (name == "postgresql") {
- std::string connect_string = "";
+ if (name == "postgresql") {
+ std::string connect_string;
conf.getNoEx("pgsql_connection", connect_string);
return new MapDatabasePostgreSQL(connect_string);
}
#endif
- else
- throw BaseException(std::string("Database backend ") + name + " not supported.");
+
+ throw BaseException(std::string("Database backend ") + name + " not supported.");
}
void ServerMap::beginSave()
std::string ret;
dbase->loadBlock(blockpos, &ret);
- if (ret != "") {
+ if (!ret.empty()) {
loadBlock(&ret, blockpos, createSector(p2d), false);
} else {
// Not found in database, try the files
{
}
-MMVManip::~MMVManip()
-{
-}
-
void MMVManip::initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max,
bool load_if_inexistent)
{
/*
Copy data of all blocks
*/
- for(std::map<v3s16, u8>::iterator
- i = m_loaded_blocks.begin();
- i != m_loaded_blocks.end(); ++i)
- {
- v3s16 p = i->first;
+ for (auto &loaded_block : m_loaded_blocks) {
+ v3s16 p = loaded_block.first;
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
- bool existed = !(i->second & VMANIP_BLOCK_DATA_INEXIST);
+ bool existed = !(loaded_block.second & VMANIP_BLOCK_DATA_INEXIST);
if (!existed || (block == NULL) ||
(!overwrite_generated && block->isGenerated()))
continue;
their differing fetch methods.
*/
virtual MapSector * emergeSector(v2s16 p){ return NULL; }
- virtual MapSector * emergeSector(v2s16 p,
- std::map<v3s16, MapBlock*> &changed_blocks){ return NULL; }
// Returns InvalidPositionException if not found
MapBlock * getBlockNoCreate(v3s16 p);
{
public:
MMVManip(Map *map);
- virtual ~MMVManip();
+ virtual ~MMVManip() = default;
virtual void clear()
{
else if(current_light == LIGHT_SUN && nodemgr->get(n).sunlight_propagates)
{
// Do nothing: Sunlight is continued
- }
- else if(nodemgr->get(n).light_propagates == false)
- {
+ } else if (!nodemgr->get(n).light_propagates) {
// A solid object is on the way.
stopped_to_solid_object = true;
if(nodemgr->get(n).light_propagates)
{
if(n.getLight(LIGHTBANK_DAY, nodemgr) == LIGHT_SUN
- && sunlight_should_go_down == false)
+ && !sunlight_should_go_down)
block_below_is_valid = false;
else if(n.getLight(LIGHTBANK_DAY, nodemgr) != LIGHT_SUN
- && sunlight_should_go_down == true)
+ && sunlight_should_go_down)
block_below_is_valid = false;
}
}
flags |= 0x01;
if(getDayNightDiff())
flags |= 0x02;
- if(m_generated == false)
+ if (!m_generated)
flags |= 0x08;
writeU8(os, flags);
if (version >= 27) {
}
u8 flags = readU8(is);
- is_underground = (flags & 0x01) ? true : false;
- m_day_night_differs = (flags & 0x02) ? true : false;
+ is_underground = (flags & 0x01) != 0;
+ m_day_night_differs = (flags & 0x02) != 0;
if (version < 27)
m_lighting_complete = 0xFFFF;
else
m_lighting_complete = readU16(is);
- m_generated = (flags & 0x08) ? false : true;
+ m_generated = (flags & 0x08) == 0;
/*
Bulk node data
} else { // All other versions (10 to 21)
u8 flags;
is.read((char*)&flags, 1);
- is_underground = (flags & 0x01) ? true : false;
- m_day_night_differs = (flags & 0x02) ? true : false;
+ is_underground = (flags & 0x01) != 0;
+ m_day_night_differs = (flags & 0x02) != 0;
if(version >= 18)
- m_generated = (flags & 0x08) ? false : true;
+ m_generated = (flags & 0x08) == 0;
// Uncompress data
std::ostringstream os(std::ios_base::binary);
*valid_position = isValidPosition(x, y, z);
if (!*valid_position)
- return MapNode(CONTENT_IGNORE);
+ return {CONTENT_IGNORE};
return data[z * zstride + y * ystride + x];
}
inline MapNode getNodeNoCheck(s16 x, s16 y, s16 z, bool *valid_position)
{
*valid_position = data != nullptr;
- if (!valid_position)
- return MapNode(CONTENT_IGNORE);
+ if (!*valid_position)
+ return {CONTENT_IGNORE};
return data[z * zstride + y * ystride + x];
}
//// Node Timers
////
- inline NodeTimer getNodeTimer(v3s16 p)
+ inline NodeTimer getNodeTimer(const v3s16 &p)
{
return m_node_timers.get(p);
}
- inline void removeNodeTimer(v3s16 p)
+ inline void removeNodeTimer(const v3s16 &p)
{
m_node_timers.remove(p);
}
/*
Returns the position of the block where the node is located
*/
-inline v3s16 getNodeBlockPos(v3s16 p)
-{
- return getContainerPos(p, MAP_BLOCKSIZE);
-}
-
-inline v2s16 getNodeSectorPos(v2s16 p)
+inline v3s16 getNodeBlockPos(const v3s16 &p)
{
return getContainerPos(p, MAP_BLOCKSIZE);
}
-inline s16 getNodeBlockY(s16 y)
-{
- return getContainerPos(y, MAP_BLOCKSIZE);
-}
-
inline void getNodeBlockPosWithOffset(const v3s16 &p, v3s16 &block, v3s16 &offset)
{
getContainerPosWithOffset(p, MAP_BLOCKSIZE, block, offset);
}
-inline void getNodeSectorPosWithOffset(const v2s16 &p, v2s16 &block, v2s16 &offset)
-{
- getContainerPosWithOffset(p, MAP_BLOCKSIZE, block, offset);
-}
-
/*
Get a quick string to describe what a block actually contains
*/
// Get map for reading neigbhor blocks
Map *map = block->getParent();
- for (u16 i=0; i<26; i++) {
- const v3s16 &dir = g_26dirs[i];
+ for (const v3s16 &dir : g_26dirs) {
v3s16 bp = m_blockpos + dir;
MapBlock *b = map->getBlockNoCreateNoEx(bp);
if(b)
u16 light_day = 0;
u16 light_night = 0;
- for (u32 i = 0; i < 8; i++)
- {
- MapNode n = data->m_vmanip.getNodeNoExNoEmerge(p - dirs8[i]);
+ for (const v3s16 &dir : dirs8) {
+ MapNode n = data->m_vmanip.getNodeNoExNoEmerge(p - dir);
// if it's CONTENT_IGNORE we can't do any light calculations
if (n.getContent() == CONTENT_IGNORE) {
};
static void makeFastFace(const TileSpec &tile, u16 li0, u16 li1, u16 li2, u16 li3,
- v3f p, v3s16 dir, v3f scale, std::vector<FastFace> &dest)
+ const v3f &p, v3s16 dir, v3f scale, std::vector<FastFace> &dest)
{
// Position is at the center of the cube.
v3f pos = p * BS;
);
}
- for(u16 i=0; i<4; i++)
- {
- vertex_pos[i].X *= scale.X;
- vertex_pos[i].Y *= scale.Y;
- vertex_pos[i].Z *= scale.Z;
- vertex_pos[i] += pos;
+ for (v3f &vpos : vertex_pos) {
+ vpos.X *= scale.X;
+ vpos.Y *= scale.Y;
+ vpos.Z *= scale.Z;
+ vpos += pos;
}
f32 abs_scale = 1.0;
bool solidness_differs = (c1 != c2);
bool makes_face = contents_differ && solidness_differs;
- if(makes_face == false)
+ if (!makes_face)
return 0;
if(c1 == 0)
return 2;
}
- if(c1 > c2)
+ if (c1 > c2)
return 1;
- else
- return 2;
+
+ return 2;
}
/*
const ContentFeatures &f = ndef->get(mn);
tile = f.tiles[tileindex];
TileLayer *top_layer = NULL;
- for (int layernum = 0; layernum < MAX_TILE_LAYERS; layernum++) {
- TileLayer *layer = &tile.layers[layernum];
- if (layer->texture_id == 0)
+ for (TileLayer &layer : tile.layers) {
+ if (layer.texture_id == 0)
continue;
- top_layer = layer;
- if (!layer->has_color)
- mn.getColor(f, &(layer->color));
+ top_layer = &layer;
+ if (!layer.has_color)
+ mn.getColor(f, &(layer.color));
}
// Apply temporary crack
if (p == data->m_crack_pos_relative)
// eg. water and glass
if (equivalent) {
- for (int layernum = 0; layernum < MAX_TILE_LAYERS; layernum++)
- tile.layers[layernum].material_flags |=
- MATERIAL_FLAG_BACKFACE_CULLING;
+ for (TileLayer &layer : tile.layers)
+ layer.material_flags |= MATERIAL_FLAG_BACKFACE_CULLING;
}
if (!data->m_smooth_lighting) {
m_last_crack(-1),
m_last_daynight_ratio((u32) -1)
{
- for (int m = 0; m < MAX_TILE_LAYERS; m++)
- m_mesh[m] = new scene::SMesh();
+ for (auto &m : m_mesh)
+ m = new scene::SMesh();
m_enable_shaders = data->m_use_shaders;
m_use_tangent_vertices = data->m_use_tangent_vertices;
m_enable_vbo = g_settings->getBool("enable_vbo");
// (NOTE: probably outdated)
//TimeTaker timer2("MeshCollector building");
- for (u32 i = 0; i < fastfaces_new.size(); i++) {
- FastFace &f = fastfaces_new[i];
-
+ for (const FastFace &f : fastfaces_new) {
const u16 indices[] = {0,1,2,2,3,0};
const u16 indices_alternate[] = {0,1,3,2,3,1};
MapBlockMesh::~MapBlockMesh()
{
- for (int m = 0; m < MAX_TILE_LAYERS; m++) {
- if (m_enable_vbo && m_mesh[m])
- for (u32 i = 0; i < m_mesh[m]->getMeshBufferCount(); i++) {
- scene::IMeshBuffer *buf = m_mesh[m]->getMeshBuffer(i);
+ for (scene::IMesh *m : m_mesh) {
+ if (m_enable_vbo && m)
+ for (u32 i = 0; i < m->getMeshBufferCount(); i++) {
+ scene::IMeshBuffer *buf = m->getMeshBuffer(i);
RenderingEngine::get_video_driver()->removeHardwareBuffer(buf);
}
- m_mesh[m]->drop();
- m_mesh[m] = NULL;
+ m->drop();
+ m = NULL;
}
delete m_minimap_mapblock;
}
m_animation_force_timer = myrand_range(5, 100);
// Cracks
- if(crack != m_last_crack)
- {
- for (std::map<std::pair<u8, u32>, std::string>::iterator i =
- m_crack_materials.begin(); i != m_crack_materials.end(); ++i) {
- scene::IMeshBuffer *buf = m_mesh[i->first.first]->
- getMeshBuffer(i->first.second);
- std::string basename = i->second;
+ if (crack != m_last_crack) {
+ for (auto &crack_material : m_crack_materials) {
+ scene::IMeshBuffer *buf = m_mesh[crack_material.first.first]->
+ getMeshBuffer(crack_material.first.second);
+ std::string basename = crack_material.second;
// Create new texture name from original
std::ostringstream os;
// If the current material is also animated,
// update animation info
- std::map<std::pair<u8, u32>, TileLayer>::iterator anim_iter =
- m_animation_tiles.find(i->first);
+ auto anim_iter = m_animation_tiles.find(crack_material.first);
if (anim_iter != m_animation_tiles.end()){
TileLayer &tile = anim_iter->second;
tile.texture = new_texture;
tile.texture_id = new_texture_id;
// force animation update
- m_animation_frames[i->first] = -1;
+ m_animation_frames[crack_material.first] = -1;
}
}
}
// Texture animation
- for (std::map<std::pair<u8, u32>, TileLayer>::iterator i =
- m_animation_tiles.begin(); i != m_animation_tiles.end(); ++i) {
- const TileLayer &tile = i->second;
+ for (auto &animation_tile : m_animation_tiles) {
+ const TileLayer &tile = animation_tile.second;
// Figure out current frame
- int frameoffset = m_animation_frame_offsets[i->first];
+ int frameoffset = m_animation_frame_offsets[animation_tile.first];
int frame = (int)(time * 1000 / tile.animation_frame_length_ms
+ frameoffset) % tile.animation_frame_count;
// If frame doesn't change, skip
- if(frame == m_animation_frames[i->first])
+ if(frame == m_animation_frames[animation_tile.first])
continue;
- m_animation_frames[i->first] = frame;
+ m_animation_frames[animation_tile.first] = frame;
- scene::IMeshBuffer *buf = m_mesh[i->first.first]->
- getMeshBuffer(i->first.second);
+ scene::IMeshBuffer *buf = m_mesh[animation_tile.first.first]->
+ getMeshBuffer(animation_tile.first.second);
const FrameSpec &animation_frame = (*tile.frames)[frame];
buf->getMaterial().setTexture(0, animation_frame.texture);
{
// Force reload mesh to VBO
if (m_enable_vbo)
- for (int m = 0; m < MAX_TILE_LAYERS; m++)
- m_mesh[m]->setDirty();
+ for (scene::IMesh *m : m_mesh)
+ m->setDirty();
video::SColorf day_color;
get_sunlight_color(&day_color, daynight_ratio);
- for(std::map<std::pair<u8, u32>, std::map<u32, video::SColor > >::iterator
- i = m_daynight_diffs.begin();
- i != m_daynight_diffs.end(); ++i)
- {
- scene::IMeshBuffer *buf = m_mesh[i->first.first]->
- getMeshBuffer(i->first.second);
+
+ for (auto &daynight_diff : m_daynight_diffs) {
+ scene::IMeshBuffer *buf = m_mesh[daynight_diff.first.first]->
+ getMeshBuffer(daynight_diff.first.second);
video::S3DVertex *vertices = (video::S3DVertex *)buf->getVertices();
- for(std::map<u32, video::SColor >::iterator
- j = i->second.begin();
- j != i->second.end(); ++j)
+ for (auto j = daynight_diff.second.begin();
+ j != daynight_diff.second.end(); ++j)
{
final_color_blend(&(vertices[j->first].Color),
j->second, day_color);
void MapBlockMesh::updateCameraOffset(v3s16 camera_offset)
{
if (camera_offset != m_camera_offset) {
- for (u8 layer = 0; layer < 2; layer++) {
- translateMesh(m_mesh[layer],
+ for (scene::IMesh *layer : m_mesh) {
+ translateMesh(layer,
intToFloat(m_camera_offset - camera_offset, BS));
if (m_enable_vbo) {
- m_mesh[layer]->setDirty();
+ layer->setDirty();
}
}
m_camera_offset = camera_offset;
std::vector<PreMeshBuffer> *buffers = &prebuffers[layernum];
PreMeshBuffer *p = NULL;
- for (u32 i = 0; i < buffers->size(); i++) {
- PreMeshBuffer &pp = (*buffers)[i];
+ for (PreMeshBuffer &pp : *buffers) {
if (pp.layer != layer)
continue;
if (pp.indices.size() + numIndices > 65535)
std::vector<PreMeshBuffer> *buffers = &prebuffers[layernum];
PreMeshBuffer *p = NULL;
- for (u32 i = 0; i < buffers->size(); i++) {
- PreMeshBuffer &pp = (*buffers)[i];
+ for (PreMeshBuffer &pp : *buffers) {
if(pp.layer != layer)
continue;
if(pp.indices.size() + numIndices > 65535)
void MeshCollector::applyTileColors()
{
if (m_use_tangent_vertices)
- for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) {
- for (auto &pmb : prebuffers[layer]) {
+ for (auto &prebuffer : prebuffers) {
+ for (PreMeshBuffer &pmb : prebuffer) {
video::SColor tc = pmb.layer.color;
if (tc == video::SColor(0xFFFFFFFF))
continue;
}
}
else
- for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) {
- for (auto &pmb : prebuffers[layer]) {
+ for (auto &prebuffer : prebuffers) {
+ for (PreMeshBuffer &pmb : prebuffer) {
video::SColor tc = pmb.layer.color;
if (tc == video::SColor(0xFFFFFFFF))
continue;
//// Mapgen
////
-Mapgen::Mapgen()
-{
-}
-
-
Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge) :
gennotify(emerge->gen_notify_on, &emerge->gen_notify_on_deco_ids)
{
}
-Mapgen::~Mapgen()
-{
-}
-
-
MapgenType Mapgen::getMapgenType(const std::string &mgname)
{
for (size_t i = 0; i != ARRLEN(g_reg_mapgens); i++) {
MapNode &n = vm->m_data[i];
if (ndef->get(n).walkable)
return -MAX_MAP_GENERATION_LIMIT;
- else if (ndef->get(n).isLiquid())
+
+ if (ndef->get(n).isLiquid())
break;
vm->m_area.add_y(em, i, -1);
//// GenerateNotifier
////
-GenerateNotifier::GenerateNotifier()
-{
-}
-
-
GenerateNotifier::GenerateNotifier(u32 notify_on,
std::set<u32> *notify_on_deco_ids)
{
class GenerateNotifier {
public:
- GenerateNotifier();
+ GenerateNotifier() = default;
GenerateNotifier(u32 notify_on, std::set<u32> *notify_on_deco_ids);
void setNotifyOn(u32 notify_on);
BiomeGen *biomegen = nullptr;
GenerateNotifier gennotify;
- Mapgen();
+ Mapgen() = default;
Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge);
- virtual ~Mapgen();
+ virtual ~Mapgen() = default;
DISABLE_CLASS_COPY(Mapgen);
virtual MapgenType getType() const { return MAPGEN_INVALID; }
s16 level_at_point = terrainLevelAtPoint(p.X, p.Y);
if (level_at_point <= water_level || level_at_point > water_level + 32)
return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
- else
- return level_at_point;
+
+ return level_at_point;
}
NoiseParams np_cave2;
MapgenFlatParams();
- ~MapgenFlatParams() {}
+ ~MapgenFlatParams() = default;
void readParams(const Settings *settings);
void writeParams(Settings *settings) const;
NoiseParams np_cavern;
MapgenV5Params();
- ~MapgenV5Params() {}
+ ~MapgenV5Params() = default;
void readParams(const Settings *settings);
void writeParams(Settings *settings) const;
}
return BT_NORMAL;
- } else {
- if (d > freq_desert)
- return BT_DESERT;
+ }
- if ((spflags & MGV6_BIOMEBLEND) && (d > freq_desert - 0.10) &&
- ((noise2d(p.X, p.Y, seed) + 1.0) > (freq_desert - d) * 20.0))
- return BT_DESERT;
+ if (d > freq_desert)
+ return BT_DESERT;
- if ((spflags & MGV6_JUNGLES) && h > 0.75)
- return BT_JUNGLE;
+ if ((spflags & MGV6_BIOMEBLEND) && (d > freq_desert - 0.10) &&
+ ((noise2d(p.X, p.Y, seed) + 1.0) > (freq_desert - d) * 20.0))
+ return BT_DESERT;
+
+ if ((spflags & MGV6_JUNGLES) && h > 0.75)
+ return BT_JUNGLE;
+
+ return BT_NORMAL;
- return BT_NORMAL;
- }
}
v3s16(-1, 0, 0) // left
};
+const v3s16 g_7dirs[7] =
+{
+ v3s16(0,0,1), // back
+ v3s16(0,1,0), // top
+ v3s16(1,0,0), // right
+ v3s16(0,0,-1), // front
+ v3s16(0,-1,0), // bottom
+ v3s16(-1,0,0), // left
+ v3s16(0,0,0), // self
+};
+
const v3s16 g_26dirs[26] =
{
// +right, +top, +back
extern const v3s16 g_6dirs[6];
+extern const v3s16 g_7dirs[7];
+
extern const v3s16 g_26dirs[26];
// 26th is (0,0,0)