#endif
// Update configuration file
- if (g_settings_path != "")
+ if (!g_settings_path.empty())
g_settings->updateConfigFile(g_settings_path.c_str());
print_modified_quicktune_values();
static void print_allowed_options(const OptionList &allowed_options)
{
- for (OptionList::const_iterator i = allowed_options.begin();
- i != allowed_options.end(); ++i) {
+ for (const auto &allowed_option : allowed_options) {
std::ostringstream os1(std::ios::binary);
- os1 << " --" << i->first;
- if (i->second.type != VALUETYPE_FLAG)
+ os1 << " --" << allowed_option.first;
+ if (allowed_option.second.type != VALUETYPE_FLAG)
os1 << _(" <value>");
std::cout << padStringRight(os1.str(), 30);
- if (i->second.help)
- std::cout << i->second.help;
+ if (allowed_option.second.help)
+ std::cout << allowed_option.second.help;
std::cout << std::endl;
}
static void list_game_ids()
{
std::set<std::string> gameids = getAvailableGameIds();
- for (std::set<std::string>::const_iterator i = gameids.begin();
- i != gameids.end(); ++i)
- std::cout << (*i) <<std::endl;
+ for (const std::string &gameid : gameids)
+ std::cout << gameid <<std::endl;
}
static void list_worlds()
static void print_worldspecs(const std::vector<WorldSpec> &worldspecs,
std::ostream &os)
{
- for (size_t i = 0; i < worldspecs.size(); i++) {
- std::string name = worldspecs[i].name;
- std::string path = worldspecs[i].path;
- if (name.find(" ") != std::string::npos)
+ for (const WorldSpec &worldspec : worldspecs) {
+ std::string name = worldspec.name;
+ std::string path = worldspec.path;
+ if (name.find(' ') != std::string::npos)
name = std::string("'") + name + "'";
path = std::string("'") + path + "'";
name = padStringRight(name, 14);
bool header_printed = false;
std::vector<std::string> names = getQuicktuneNames();
- for (u32 i = 0; i < names.size(); i++) {
- QuicktuneValue val = getQuicktuneValue(names[i]);
+ for (const std::string &name : names) {
+ QuicktuneValue val = getQuicktuneValue(name);
if (!val.modified)
continue;
if (!header_printed) {
dstream << "Modified quicktune values:" << std::endl;
header_printed = true;
}
- dstream << names[i] << " = " << val.getString() << std::endl;
+ dstream << name << " = " << val.getString() << std::endl;
}
}
DIR_DELIM + ".." + DIR_DELIM + ".." + DIR_DELIM + "minetest.conf");
#endif
- for (size_t i = 0; i < filenames.size(); i++) {
- bool r = g_settings->readConfigFile(filenames[i].c_str());
+ for (const std::string &filename : filenames) {
+ bool r = g_settings->readConfigFile(filename.c_str());
if (r) {
- g_settings_path = filenames[i];
+ g_settings_path = filename;
break;
}
}
// If no path found, use the first one (menu creates the file)
- if (g_settings_path == "")
+ if (g_settings_path.empty())
g_settings_path = filenames[0];
}
verbosestream << "log_filename = " << log_filename << std::endl;
- file_log_output.open(log_filename.c_str());
+ file_log_output.open(log_filename);
g_logger.addOutputMaxLevel(&file_log_output, log_level);
}
{
if (get_world_from_cmdline(game_params, cmd_args))
return true;
+
if (get_world_from_config(game_params, cmd_args))
return true;
static bool get_world_from_cmdline(GameParams *game_params, const Settings &cmd_args)
{
- std::string commanded_world = "";
+ std::string commanded_world;
// World name
- std::string commanded_worldname = "";
+ std::string commanded_worldname;
if (cmd_args.exists("worldname"))
commanded_worldname = cmd_args.get("worldname");
// If a world name was specified, convert it to a path
- if (commanded_worldname != "") {
+ if (!commanded_worldname.empty()) {
// Get information about available worlds
std::vector<WorldSpec> worldspecs = getAvailableWorlds();
bool found = false;
- for (u32 i = 0; i < worldspecs.size(); i++) {
- std::string name = worldspecs[i].name;
+ for (const WorldSpec &worldspec : worldspecs) {
+ std::string name = worldspec.name;
if (name == commanded_worldname) {
dstream << _("Using world specified by --worldname on the "
"command line") << std::endl;
- commanded_world = worldspecs[i].path;
+ commanded_world = worldspec.path;
found = true;
break;
}
}
game_params->world_path = get_clean_world_path(commanded_world);
- return commanded_world != "";
+ return !commanded_world.empty();
}
if (cmd_args.exists("world"))
commanded_world = cmd_args.get("nonopt0");
game_params->world_path = get_clean_world_path(commanded_world);
- return commanded_world != "";
+ return !commanded_world.empty();
}
static bool get_world_from_config(GameParams *game_params, const Settings &cmd_args)
{
// World directory
- std::string commanded_world = "";
+ std::string commanded_world;
if (g_settings->exists("map-dir"))
commanded_world = g_settings->get("map-dir");
game_params->world_path = get_clean_world_path(commanded_world);
- return commanded_world != "";
+ return !commanded_world.empty();
}
static bool auto_select_world(GameParams *game_params)
verbosestream << _("Determining gameid/gamespec") << std::endl;
// If world doesn't exist
- if (game_params->world_path != ""
- && !getWorldExists(game_params->world_path)) {
+ if (!game_params->world_path.empty()
+ && !getWorldExists(game_params->world_path)) {
// Try to take gamespec from command line
if (game_params->game_spec.isValid()) {
gamespec = game_params->game_spec;
// Database migration
if (cmd_args.exists("migrate"))
return migrate_map_database(game_params, cmd_args);
- else if (cmd_args.exists("migrate-players"))
+
+ if (cmd_args.exists("migrate-players"))
return ServerEnvironment::migratePlayersDatabase(game_params, cmd_args);
if (cmd_args.exists("terminal")) {
public:
virtual void createdMenu(gui::IGUIElement *menu)
{
- for(std::list<gui::IGUIElement*>::iterator
- i = m_stack.begin();
- i != m_stack.end(); ++i)
- {
- assert(*i != menu);
+ for (gui::IGUIElement *i : m_stack) {
+ assert(i != menu);
}
if(!m_stack.empty())
bool pausesGame()
{
- for(std::list<gui::IGUIElement*>::iterator
- i = m_stack.begin(); i != m_stack.end(); ++i)
- {
- GUIModalMenu *mm = dynamic_cast<GUIModalMenu*>(*i);
+ for (gui::IGUIElement *i : m_stack) {
+ GUIModalMenu *mm = dynamic_cast<GUIModalMenu*>(i);
if (mm && mm->pausesGame())
return true;
}
class MainGameCallback : public IGameCallback
{
public:
- MainGameCallback() {}
- virtual ~MainGameCallback() {}
+ MainGameCallback() = default;
+ virtual ~MainGameCallback() = default;
virtual void exitToOS()
{
void Map::deleteSectors(std::vector<v2s16> §orList)
{
- for(std::vector<v2s16>::iterator j = sectorList.begin();
- j != sectorList.end(); ++j) {
- MapSector *sector = m_sectors[*j];
+ for (v2s16 j : sectorList) {
+ MapSector *sector = m_sectors[j];
// If sector is in sector cache, remove it from there
if(m_sector_cache == sector)
m_sector_cache = NULL;
// Remove from map and delete
- m_sectors.erase(*j);
+ m_sectors.erase(j);
delete sector;
}
}
{
MapBlock *block = getBlockNoCreateNoEx(p);
- if(block && block->isDummy() == false)
+ if (block && !block->isDummy())
return block;
}
void ServerMap::createDirs(std::string path)
{
- if(fs::CreateAllDirs(path) == false)
- {
+ if (!fs::CreateAllDirs(path)) {
m_dout<<"ServerMap: Failed to create directory "
<<"\""<<path<<"\""<<std::endl;
throw BaseException("ServerMap failed to create directory");
void ServerMap::save(ModifiedState save_level)
{
DSTACK(FUNCTION_NAME);
- if(m_map_saving_enabled == false) {
+ if (!m_map_saving_enabled) {
warningstream<<"Not saving map, saving disabled."<<std::endl;
return;
}
std::string fullpath = sectordir + DIR_DELIM + "meta";
std::ifstream is(fullpath.c_str(), std::ios_base::binary);
- if(is.good() == false)
- {
+ if (!is.good()) {
// If the directory exists anyway, it probably is in some old
// format. Just go ahead and create the sector.
if(fs::PathExists(sectordir))
*/
std::string blockfilename = getBlockFilename(blockpos);
- if (fs::PathExists(sectordir + DIR_DELIM + blockfilename) == false)
+ if (!fs::PathExists(sectordir + DIR_DELIM + blockfilename))
return NULL;
/*
v3s16 p = i->first;
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
bool existed = !(i->second & VMANIP_BLOCK_DATA_INEXIST);
- if ((existed == false) || (block == NULL) ||
- (overwrite_generated == false && block->isGenerated() == true))
+ if (!existed || (block == NULL) ||
+ (!overwrite_generated && block->isGenerated()))
continue;
block->copyFrom(*this);
std::set<v3s16> modified_blocks;
u16 already_known_by_peer = 0;
- MapEditEvent() {}
+ MapEditEvent() = default;
MapEditEvent * clone()
{
case MEET_OTHER:
{
VoxelArea a;
- for(std::set<v3s16>::iterator
- i = modified_blocks.begin();
- i != modified_blocks.end(); ++i)
- {
- v3s16 p = *i;
+ for (v3s16 p : modified_blocks) {
v3s16 np1 = p*MAP_BLOCKSIZE;
v3s16 np2 = np1 + v3s16(1,1,1)*MAP_BLOCKSIZE - v3s16(1,1,1);
a.addPoint(np1);
bool removeNodeWithEvent(v3s16 p);
// Call these before and after saving of many blocks
- virtual void beginSave() { return; }
- virtual void endSave() { return; }
+ virtual void beginSave() {}
+ virtual void endSave() {}
virtual void save(ModifiedState save_level) { FATAL_ERROR("FIXME"); }
m_pos_relative(pos * MAP_BLOCKSIZE),
m_gamedef(gamedef)
{
- if(dummy == false)
+ if (!dummy)
reallocate();
}
bool MapBlock::isValidPositionParent(v3s16 p)
{
- if(isValidPosition(p))
- {
+ if (isValidPosition(p)) {
return true;
}
- else{
- return m_parent->isValidPosition(getPosRelative() + p);
- }
+
+ return m_parent->isValidPosition(getPosRelative() + p);
}
MapNode MapBlock::getNodeParent(v3s16 p, bool *is_valid_position)
{
- if (isValidPosition(p) == false)
+ if (!isValidPosition(p))
return m_parent->getNodeNoEx(getPosRelative() + p, is_valid_position);
if (!data) {
if (is_valid_position)
*is_valid_position = false;
- return MapNode(CONTENT_IGNORE);
+ return {CONTENT_IGNORE};
}
if (is_valid_position)
*is_valid_position = true;
else
{
MapNode n = getNodeNoEx(v3s16(x, MAP_BLOCKSIZE-1, z));
- if(m_gamedef->ndef()->get(n).sunlight_propagates == false)
- {
+ if (!m_gamedef->ndef()->get(n).sunlight_propagates) {
no_sunlight = true;
}
}
for(; y>=0; y--)
{
MapNode n = getNodeRef(p2d.X, y, p2d.Y);
- if(m_gamedef->ndef()->get(n).walkable)
- {
+ if (m_gamedef->ndef()->get(n).walkable) {
if(y == MAP_BLOCKSIZE-1)
return -2;
- else
- return y;
+
+ return y;
}
}
return -1;
// Update the MapNode
nodes[i].setContent(id);
}
- for(std::set<content_t>::const_iterator
- i = unknown_contents.begin();
- i != unknown_contents.end(); ++i){
- errorstream<<"getBlockNodeIdMapping(): IGNORING ERROR: "
- <<"Name for node id "<<(*i)<<" not known"<<std::endl;
+ for (u16 unknown_content : unknown_contents) {
+ errorstream << "getBlockNodeIdMapping(): IGNORING ERROR: "
+ << "Name for node id " << unknown_content << " not known" << std::endl;
}
}
// Correct ids in the block to match nodedef based on names.
};
struct MapgenParams {
- MapgenParams() {}
+ MapgenParams() = default;
virtual ~MapgenParams();
MapgenType mgtype = MAPGEN_DEFAULT;
NoiseParams np_cavern;
MapgenCarpathianParams();
- ~MapgenCarpathianParams() {}
+ ~MapgenCarpathianParams() = default;
void readParams(const Settings *settings);
void writeParams(Settings *settings) const;
if (ground_level < water_level) // Ocean world, allow spawn in water
return MYMAX(level_at_point, water_level);
- else if (level_at_point > water_level)
+
+ if (level_at_point > water_level)
return level_at_point; // Spawn on land
- else
- return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
+
+ return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
}
NoiseParams np_cave2;
MapgenFractalParams();
- ~MapgenFractalParams() {}
+ ~MapgenFractalParams() = default;
void readParams(const Settings *settings);
void writeParams(Settings *settings) const;
}
-MapgenSinglenode::~MapgenSinglenode()
-{
-}
-
-
//////////////////////// Map generator
void MapgenSinglenode::makeChunk(BlockMakeData *data)
struct MapgenSinglenodeParams : public MapgenParams
{
- MapgenSinglenodeParams() {}
- ~MapgenSinglenodeParams() {}
+ MapgenSinglenodeParams() = default;
+ ~MapgenSinglenodeParams() = default;
void readParams(const Settings *settings) {}
void writeParams(Settings *settings) const {}
u8 set_light;
MapgenSinglenode(int mapgenid, MapgenParams *params, EmergeManager *emerge);
- ~MapgenSinglenode();
+ ~MapgenSinglenode() = default;
virtual MapgenType getType() const { return MAPGEN_SINGLENODE; }
if (n_ground * f > y - h) { // If solid
if (y < water_level || y > max_spawn_y)
return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
- else
- // y + 2 because y is surface and due to biome 'dust' nodes.
- return y + 2;
+
+ // y + 2 because y is surface and due to biome 'dust' nodes.
+ return y + 2;
}
}
// Unsuitable spawn position, no ground found
if(blockpos.Y * MAP_BLOCKSIZE + MAP_BLOCKSIZE <= minimum_groundlevel)
return true;
- else
- return false;
+
+ return false;
}
if (level_at_point <= water_level ||
level_at_point > water_level + 16)
return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
- else
- return level_at_point;
+
+ return level_at_point;
}
float zeroval = -0.39;
if (noise < zeroval)
return 0;
- else
- return 0.04 * (noise - zeroval) / (1.0 - zeroval);
+
+ return 0.04 * (noise - zeroval) / (1.0 - zeroval);
}
if (d > MGV6_FREQ_HOT + blend) {
if (h > MGV6_FREQ_JUNGLE + blend)
return BT_JUNGLE;
- else
- return BT_DESERT;
- } else if (d < MGV6_FREQ_SNOW + blend) {
+
+ return BT_DESERT;
+ }
+
+ if (d < MGV6_FREQ_SNOW + blend) {
if (h > MGV6_FREQ_TAIGA + blend)
return BT_TAIGA;
- else
- return BT_TUNDRA;
- } else {
- return BT_NORMAL;
+
+ return BT_TUNDRA;
}
+
+ return BT_NORMAL;
} else {
if (d > freq_desert)
return BT_DESERT;
if ((spflags & MGV6_JUNGLES) && h > 0.75)
return BT_JUNGLE;
- else
- return BT_NORMAL;
+
+ return BT_NORMAL;
}
}
u32 i2 = i;
vm->m_area.add_y(em, i2, -1);
// Cancel if out of area
- if (vm->m_area.contains(i2) == false)
+ if (!vm->m_area.contains(i2))
continue;
MapNode *n2 = &vm->m_data[i2];
if (n2->getContent() != c_dirt &&
}
// Drop mud on side
- for (u32 di = 0; di < 4; di++) {
- v3s16 dirp = dirs4[di];
+ for (const v3s16 &dirp : dirs4) {
u32 i2 = i;
// Move to side
vm->m_area.add_p(em, i2, dirp);
// Fail if out of area
- if (vm->m_area.contains(i2) == false)
+ if (!vm->m_area.contains(i2))
continue;
// Check that side is air
MapNode *n2 = &vm->m_data[i2];
continue;
// Check that under side is air
vm->m_area.add_y(em, i2, -1);
- if (vm->m_area.contains(i2) == false)
+ if (!vm->m_area.contains(i2))
continue;
n2 = &vm->m_data[i2];
if (ndef->get(*n2).walkable)
vm->m_area.add_y(em, i2, -1);
n2 = &vm->m_data[i2];
// if out of known area
- if (vm->m_area.contains(i2) == false ||
+ if (!vm->m_area.contains(i2) ||
n2->getContent() == CONTENT_IGNORE) {
dropped_to_unknown = true;
break;
}
- } while (ndef->get(*n2).walkable == false);
+ } while (!ndef->get(*n2).walkable);
// Loop one up so that we're in air
vm->m_area.add_y(em, i2, 1);
NoiseParams np_apple_trees;
MapgenV6Params();
- ~MapgenV6Params() {}
+ ~MapgenV6Params() = default;
void readParams(const Settings *settings);
void writeParams(Settings *settings) const;
if (!(spflags & MGV7_MOUNTAINS)) {
if (y < water_level || y > max_spawn_y)
return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
- else
- // y + 2 because y is surface level and due to biome 'dust'
- return y + 2;
+
+ // y + 2 because y is surface level and due to biome 'dust'
+ return y + 2;
}
// Search upwards for first node without mountain terrain
if (!getMountainTerrainAtPoint(p.X, y + 1, p.Y)) {
if (y <= water_level || y > max_spawn_y)
return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
- else
- // y + 1 due to biome 'dust'
- return y + 1;
+
+ // y + 1 due to biome 'dust'
+ return y + 1;
}
y++;
iters--;
NoiseParams np_cave2;
MapgenV7Params();
- ~MapgenV7Params() {}
+ ~MapgenV7Params() = default;
void readParams(const Settings *settings);
void writeParams(Settings *settings) const;
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;
}
// Saves some time.
if (y > terrain + 10)
continue;
- else if (y < terrain - 40)
+
+ if (y < terrain - 40)
underground = true;
// Dig massive caves.
NoiseParams np_valley_profile;
MapgenValleysParams();
- ~MapgenValleysParams() {}
+ ~MapgenValleysParams() = default;
void readParams(const Settings *settings);
void writeParams(Settings *settings) const;
int facedir = n.getFaceDir(nodemgr);
u8 axisdir = facedir>>2;
facedir&=0x03;
- for(std::vector<aabb3f>::const_iterator
- i = fixed.begin();
- i != fixed.end(); ++i)
- {
- aabb3f box = *i;
-
+ for (aabb3f box : fixed) {
if (nodebox.type == NODEBOX_LEVELED) {
box.MaxEdge.Y = -BS/2 + BS*((float)1/LEVELED_MAX) * n.getLevel(nodemgr);
}
- switch (axisdir)
- {
+ switch (axisdir) {
case 0:
if(facedir == 1)
{
nodebox.wall_side.MaxEdge
};
- for(s32 i=0; i<2; i++)
- {
+ for (v3f &vertice : vertices) {
if(dir == v3s16(-1,0,0))
- vertices[i].rotateXZBy(0);
+ vertice.rotateXZBy(0);
if(dir == v3s16(1,0,0))
- vertices[i].rotateXZBy(180);
+ vertice.rotateXZBy(180);
if(dir == v3s16(0,0,-1))
- vertices[i].rotateXZBy(90);
+ vertice.rotateXZBy(90);
if(dir == v3s16(0,0,1))
- vertices[i].rotateXZBy(-90);
+ vertice.rotateXZBy(-90);
}
aabb3f box = aabb3f(vertices[0]);
}
static inline void getNeighborConnectingFace(
- v3s16 p, INodeDefManager *nodedef,
+ const v3s16 &p, INodeDefManager *nodedef,
Map *map, MapNode n, u8 bitmask, u8 *neighbors)
{
MapNode n2 = map->getNodeNoEx(p);
if(!ser_ver_supported(version))
throw VersionMismatchException("ERROR: MapNode format not supported");
- if(version == 0)
+ if (version == 0)
return 1;
- else if(version <= 9)
+
+ if (version <= 9)
return 2;
- else if(version <= 23)
+
+ if (version <= 23)
return 3;
- else
- return 4;
+
+ return 4;
}
void MapNode::serialize(u8 *dest, u8 version)
{
*/
u8 param2;
- MapNode()
- { }
+ MapNode() = default;
MapNode(content_t content, u8 a_param1=0, u8 a_param2=0)
: param0(content),
m_block_cache = nullptr;
// Delete all
- for (std::unordered_map<s16, MapBlock*>::iterator i = m_blocks.begin();
- i != m_blocks.end(); ++i) {
- delete i->second;
+ for (auto &block : m_blocks) {
+ delete block.second;
}
// Clear container
void MapSector::getBlocks(MapBlockVect &dest)
{
- for (std::unordered_map<s16, MapBlock*>::iterator bi = m_blocks.begin();
- bi != m_blocks.end(); ++bi) {
- dest.push_back(bi->second);
+ for (auto &block : m_blocks) {
+ dest.push_back(block.second);
}
}
{
}
-ServerMapSector::~ServerMapSector()
-{
-}
-
void ServerMapSector::serialize(std::ostream &os, u8 version)
{
if(!ser_ver_supported(version))
assert(sector->getId() == MAPSECTOR_SERVER);
return (ServerMapSector*)sector;
}
- else
- {
- sector = new ServerMapSector(parent, p2d, gamedef);
- sectors[p2d] = sector;
- }
+
+ sector = new ServerMapSector(parent, p2d, gamedef);
+ sectors[p2d] = sector;
/*
Set stuff in sector
MapSector(parent, pos, gamedef)
{
}
-
-ClientMapSector::~ClientMapSector()
-{
-}
-
#endif // !SERVER
//END
{
public:
ServerMapSector(Map *parent, v2s16 pos, IGameDef *gamedef);
- ~ServerMapSector();
+ ~ServerMapSector() = default;
u32 getId() const
{
{
public:
ClientMapSector(Map *parent, v2s16 pos, IGameDef *gamedef);
- ~ClientMapSector();
+ ~ClientMapSector() = default;
u32 getId() const
{
video::SColor c(255,255,255,255);
- for (std::vector<aabb3f>::const_iterator
- i = boxes.begin();
- i != boxes.end(); ++i)
- {
- aabb3f box = *i;
+ for (aabb3f box : boxes) {
box.repair();
box.MinEdge.X -= expand;
public:
f_lru(vcache *v, tcache *t): vc(v), tc(t)
{
- for (u16 i = 0; i < cachesize; i++)
- {
- cache[i] = -1;
+ for (int &i : cache) {
+ i = -1;
}
}
}
// Update triangle scores
- for (u16 i = 0; i < cachesize; i++)
- {
- if (cache[i] == -1)
+ for (int i : cache) {
+ if (i == -1)
break;
- const u16 trisize = vc[cache[i]].tris.size();
+ const u16 trisize = vc[i].tris.size();
for (u16 t = 0; t < trisize; t++)
{
- tcache *tri = &tc[vc[cache[i]].tris[t]];
+ tcache *tri = &tc[vc[i].tris[t]];
tri->score =
vc[tri->ind[0]].score +
if (tri->score > hiscore)
{
hiscore = tri->score;
- highest = vc[cache[i]].tris[t];
+ highest = vc[i].tris[t];
}
}
}
tc[highest].drawn = true;
- for (u16 j = 0; j < 3; j++)
- {
- vcache *vert = &vc[tc[highest].ind[j]];
+ for (u16 j : tc[highest].ind) {
+ vcache *vert = &vc[j];
for (u16 t = 0; t < vert->tris.size(); t++)
{
if (highest == vert->tris[t])
tc[highest].drawn = true;
- for (u16 j = 0; j < 3; j++)
- {
- vcache *vert = &vc[tc[highest].ind[j]];
+ for (u16 j : tc[highest].ind) {
+ vcache *vert = &vc[j];
for (u16 t = 0; t < vert->tris.size(); t++)
{
if (highest == vert->tris[t])
tc[highest].drawn = true;
- for (u16 j = 0; j < 3; j++)
- {
- vcache *vert = &vc[tc[highest].ind[j]];
+ for (u16 j : tc[highest].ind) {
+ vcache *vert = &vc[j];
for (u16 t = 0; t < vert->tris.size(); t++)
{
if (highest == vert->tris[t])
{
MutexAutoLock lock(m_mutex);
- for (std::map<v3s16, CachedMapBlockData *>::iterator i = m_cache.begin();
- i != m_cache.end(); ++i) {
- delete i->second;
+ for (auto &i : m_cache) {
+ delete i.second;
}
- for (std::vector<QueuedMeshUpdate*>::iterator i = m_queue.begin();
- i != m_queue.end(); ++i) {
- QueuedMeshUpdate *q = *i;
+ for (QueuedMeshUpdate *q : m_queue) {
delete q;
}
}
Find if block is already in queue.
If it is, update the data and quit.
*/
- for (std::vector<QueuedMeshUpdate*>::iterator i = m_queue.begin();
- i != m_queue.end(); ++i) {
- QueuedMeshUpdate *q = *i;
+ for (QueuedMeshUpdate *q : m_queue) {
if (q->p == p) {
// NOTE: We are not adding a new position to the queue, thus
// refcount_from_queue stays the same.
m_queue.push_back(q);
// This queue entry is a new reference to the cached blocks
- for (size_t i=0; i<cached_blocks.size(); i++) {
- cached_blocks[i]->refcount_from_queue++;
+ for (CachedMapBlockData *cached_block : cached_blocks) {
+ cached_block->refcount_from_queue++;
}
}
cached_block->data = NULL;
}
return cached_block;
- } else {
- // Not yet in cache
- CachedMapBlockData *cached_block = new CachedMapBlockData();
- m_cache[p] = cached_block;
- MapBlock *b = map->getBlockNoCreateNoEx(p);
- if (b) {
- cached_block->data =
- new MapNode[MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE];
- memcpy(cached_block->data, b->getData(),
- MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE * sizeof(MapNode));
- }
- return cached_block;
}
+
+ // Not yet in cache
+ CachedMapBlockData *cached_block = new CachedMapBlockData();
+ m_cache[p] = cached_block;
+ MapBlock *b = map->getBlockNoCreateNoEx(p);
+ if (b) {
+ cached_block->data =
+ new MapNode[MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE];
+ memcpy(cached_block->data, b->getData(),
+ MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE * sizeof(MapNode));
+ }
+ return cached_block;
}
CachedMapBlockData* MeshUpdateQueue::getCachedBlock(const v3s16 &p)
b->heat_point = 0.0;
b->humidity_point = 0.0;
- b->m_nodenames.push_back("mapgen_stone");
- b->m_nodenames.push_back("mapgen_stone");
- b->m_nodenames.push_back("mapgen_stone");
- b->m_nodenames.push_back("mapgen_water_source");
- b->m_nodenames.push_back("mapgen_water_source");
- b->m_nodenames.push_back("mapgen_river_water_source");
- b->m_nodenames.push_back("mapgen_stone");
- b->m_nodenames.push_back("ignore");
+ b->m_nodenames.emplace_back("mapgen_stone");
+ b->m_nodenames.emplace_back("mapgen_stone");
+ b->m_nodenames.emplace_back("mapgen_stone");
+ b->m_nodenames.emplace_back("mapgen_water_source");
+ b->m_nodenames.emplace_back("mapgen_water_source");
+ b->m_nodenames.emplace_back("mapgen_river_water_source");
+ b->m_nodenames.emplace_back("mapgen_stone");
+ b->m_nodenames.emplace_back("ignore");
m_ndef->pendNodeResolve(b);
add(b);
}
-BiomeManager::~BiomeManager()
-{
-}
-
-
void BiomeManager::clear()
{
EmergeManager *emerge = m_server->getEmergeManager();
struct BiomeParams {
virtual void readParams(const Settings *settings) = 0;
virtual void writeParams(Settings *settings) const = 0;
- virtual ~BiomeParams() {}
+ virtual ~BiomeParams() = default;
s32 seed;
};
class BiomeGen {
public:
- virtual ~BiomeGen() {}
+ virtual ~BiomeGen() = default;
+
virtual BiomeGenType getType() const = 0;
// Calculates the biome at the exact position provided. This function can
class BiomeManager : public ObjDefManager {
public:
BiomeManager(Server *server);
- virtual ~BiomeManager();
+ virtual ~BiomeManager() = default;
const char *getObjectTitle() const
{
class Decoration : public ObjDef, public NodeResolver {
public:
- Decoration() {};
- virtual ~Decoration() {};
+ Decoration() = default;
+ virtual ~Decoration() = default;
virtual void resolveNodeNames();
class DecoSchematic : public Decoration {
public:
- DecoSchematic() {};
+ DecoSchematic() = default;
virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p);
virtual int getHeight();
class DecorationManager : public ObjDefManager {
public:
DecorationManager(IGameDef *gamedef);
- virtual ~DecorationManager() {}
+ virtual ~DecorationManager() = default;
const char *getObjectTitle() const
{
void OreManager::clear()
{
- for (size_t i = 0; i < m_objects.size(); i++) {
- Ore *ore = (Ore *)m_objects[i];
+ for (ObjDef *object : m_objects) {
+ Ore *ore = (Ore *) object;
delete ore;
}
m_objects.clear();
///////////////////////////////////////////////////////////////////////////////
-
-OrePuff::OrePuff() :
- Ore()
-{
-}
-
-
OrePuff::~OrePuff()
{
delete noise_puff_top;
///////////////////////////////////////////////////////////////////////////////
-
-OreVein::OreVein() :
- Ore()
-{
-}
-
-
OreVein::~OreVein()
{
delete noise2;
Noise *noise_puff_top = nullptr;
Noise *noise_puff_bottom = nullptr;
- OrePuff();
+ OrePuff() = default;
virtual ~OrePuff();
virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
float random_factor;
Noise *noise2 = nullptr;
- OreVein();
+ OreVein() = default;
virtual ~OreVein();
virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
class SchematicManager : public ObjDefManager {
public:
SchematicManager(Server *server);
- virtual ~SchematicManager() {}
+ virtual ~SchematicManager() = default;
virtual void clear();
// Find if block is already in queue.
// If it is, update the data and quit.
- for (std::deque<QueuedMinimapUpdate>::iterator
- it = m_update_queue.begin();
- it != m_update_queue.end(); ++it) {
- QueuedMinimapUpdate &q = *it;
+ for (QueuedMinimapUpdate &q : m_update_queue) {
if (q.pos == pos) {
delete q.data;
q.data = data;
{
if (data->minimap_shape_round) {
return MINIMAP_SHAPE_ROUND;
- } else {
- return MINIMAP_SHAPE_SQUARE;
}
+
+ return MINIMAP_SHAPE_SQUARE;
}
void Minimap::setMinimapMode(MinimapMode mode)
cos(m_angle * core::DEGTORAD),
sin(m_angle * core::DEGTORAD),
1.0);
- } else {
- return v3f(1.0, 0.0, 1.0);
}
+
+ return v3f(1.0, 0.0, 1.0);
}
scene::SMeshBuffer *Minimap::getMinimapMeshBuffer()
m_active_markers.clear();
- for (std::list<Nametag *>::const_iterator i = nametags.begin();
- i != nametags.end(); ++i) {
- v3s16 pos = floatToInt((*i)->parent_node->getPosition() +
+ for (Nametag *nametag : nametags) {
+ v3s16 pos = floatToInt(nametag->parent_node->getPosition() +
intToFloat(client->getCamera()->getOffset(), BS), BS);
pos -= data->pos - v3s16(data->map_size / 2,
data->scan_height / 2,
if (!mask_col.getAlpha()) {
continue;
}
- m_active_markers.push_back(v2f(((float)pos.X / (float)MINIMAP_MAX_SX) - 0.5,
- (1.0 - (float)pos.Z / (float)MINIMAP_MAX_SY) - 0.5));
+
+ m_active_markers.emplace_back(((float)pos.X / (float)MINIMAP_MAX_SX) - 0.5,
+ (1.0 - (float)pos.Z / (float)MINIMAP_MAX_SY) - 0.5);
}
}
{
const core::list<gui::IGUIElement*> &children = getChildren();
core::list<gui::IGUIElement*> children_copy;
- for(core::list<gui::IGUIElement*>::ConstIterator
- i = children.begin(); i != children.end(); i++)
- {
- children_copy.push_back(*i);
+ for (gui::IGUIElement *i : children) {
+ children_copy.push_back(i);
}
- for(core::list<gui::IGUIElement*>::Iterator
- i = children_copy.begin();
- i != children_copy.end(); i++)
- {
- (*i)->remove();
+
+ for (gui::IGUIElement *i : children_copy) {
+ i->remove();
}
}
--pos;
}
dep = trim(dep.substr(0, pos));
- return dep != "";
+ return !dep.empty();
}
void parseModContents(ModSpec &spec)
std::map<std::string, ModSpec> result;
std::vector<fs::DirListNode> dirlist = fs::GetDirListing(path);
- for(u32 j=0; j<dirlist.size(); j++){
- if(!dirlist[j].dir)
+ for (const fs::DirListNode &dln : dirlist) {
+ if(!dln.dir)
continue;
- std::string modname = dirlist[j].name;
+ const std::string &modname = dln.name;
// Ignore all directories beginning with a ".", especially
// VCS directories like ".git" or ".svn"
- if(modname[0] == '.')
+ if (modname[0] == '.')
continue;
std::string modpath = path + DIR_DELIM + modname;
std::vector<ModSpec> flattenMods(std::map<std::string, ModSpec> mods)
{
std::vector<ModSpec> result;
- for(std::map<std::string,ModSpec>::iterator it = mods.begin();
- it != mods.end(); ++it)
- {
- ModSpec mod = (*it).second;
- if(mod.is_modpack)
- {
+ for (const auto &it : mods) {
+ const ModSpec &mod = it.second;
+ if (mod.is_modpack) {
std::vector<ModSpec> content = flattenMods(mod.modpack_content);
result.reserve(result.size() + content.size());
result.insert(result.end(),content.begin(),content.end());
return result;
}
-ModConfiguration::ModConfiguration(const std::string &worldpath):
- m_unsatisfied_mods(),
- m_sorted_mods(),
- m_name_conflicts()
+ModConfiguration::ModConfiguration(const std::string &worldpath)
{
}
void ModConfiguration::printUnsatisfiedModsError() const
{
- for (std::vector<ModSpec>::const_iterator it = m_unsatisfied_mods.begin();
- it != m_unsatisfied_mods.end(); ++it) {
- ModSpec mod = *it;
+ for (const ModSpec &mod : m_unsatisfied_mods) {
errorstream << "mod \"" << mod.name << "\" has unsatisfied dependencies: ";
- for (std::unordered_set<std::string>::iterator dep_it =
- mod.unsatisfied_depends.begin();
- dep_it != mod.unsatisfied_depends.end(); ++dep_it)
- errorstream << " \"" << *dep_it << "\"";
+ for (const std::string &unsatisfied_depend : mod.unsatisfied_depends)
+ errorstream << " \"" << unsatisfied_depend << "\"";
errorstream << std::endl;
}
}
std::set<std::string> seen_this_iteration;
- for (std::vector<ModSpec>::const_iterator it = new_mods.begin();
- it != new_mods.end(); ++it) {
- const ModSpec &mod = *it;
- if(mod.part_of_modpack != (bool)want_from_modpack)
+ for (const ModSpec &mod : new_mods) {
+ if (mod.part_of_modpack != (bool)want_from_modpack)
continue;
- if(existing_mods.count(mod.name) == 0){
+
+ if (existing_mods.count(mod.name) == 0) {
// GOOD CASE: completely new mod.
m_unsatisfied_mods.push_back(mod);
existing_mods[mod.name] = m_unsatisfied_mods.size() - 1;
- }
- else if(seen_this_iteration.count(mod.name) == 0){
+ } else if(seen_this_iteration.count(mod.name) == 0) {
// BAD CASE: name conflict in different levels.
u32 oldindex = existing_mods[mod.name];
const ModSpec &oldmod = m_unsatisfied_mods[oldindex];
// If there was a "VERY BAD CASE" name conflict
// in an earlier level, ignore it.
m_name_conflicts.erase(mod.name);
- }
- else{
+ } else {
// VERY BAD CASE: name conflict in the same level.
u32 oldindex = existing_mods[mod.name];
const ModSpec &oldmod = m_unsatisfied_mods[oldindex];
m_unsatisfied_mods[oldindex] = mod;
m_name_conflicts.insert(mod.name);
}
+
seen_this_iteration.insert(mod.name);
}
}
conf.readConfigFile(settings_path.c_str());
std::vector<std::string> names = conf.getNames();
- for (std::vector<std::string>::iterator it = names.begin();
- it != names.end(); ++it) {
- std::string name = *it;
+ for (const std::string &name : names) {
if (name.compare(0,9,"load_mod_")==0 && conf.getBool(name))
load_mod_names.insert(name.substr(9));
}
std::vector<ModSpec> addon_mods;
- for (std::set<std::string>::const_iterator i = mods.begin();
- i != mods.end(); ++i) {
- std::vector<ModSpec> addon_mods_in_path = flattenMods(getModsInPath(*i));
+ for (const std::string &i : mods) {
+ std::vector<ModSpec> addon_mods_in_path = flattenMods(getModsInPath(i));
for (std::vector<ModSpec>::const_iterator it = addon_mods_in_path.begin();
it != addon_mods_in_path.end(); ++it) {
const ModSpec& mod = *it;
checkConflictsAndDeps();
// complain about mods declared to be loaded, but not found
- for (std::vector<ModSpec>::iterator it = addon_mods.begin();
- it != addon_mods.end(); ++it)
- load_mod_names.erase((*it).name);
- std::vector<ModSpec> UnsatisfiedMods = getUnsatisfiedMods();
- for (std::vector<ModSpec>::iterator it = UnsatisfiedMods.begin();
- it != UnsatisfiedMods.end(); ++it)
- load_mod_names.erase((*it).name);
+ for (const ModSpec &addon_mod : addon_mods)
+ load_mod_names.erase(addon_mod.name);
+
+ std::vector<ModSpec> unsatisfiedMods = getUnsatisfiedMods();
+
+ for (const ModSpec &unsatisfiedMod : unsatisfiedMods)
+ load_mod_names.erase(unsatisfiedMod.name);
+
if (!load_mod_names.empty()) {
errorstream << "The following mods could not be found:";
- for (std::set<std::string>::iterator it = load_mod_names.begin();
- it != load_mod_names.end(); ++it)
- errorstream << " \"" << (*it) << "\"";
+ for (const std::string &mod : load_mod_names)
+ errorstream << " \"" << mod << "\"";
errorstream << std::endl;
}
}
{
// Step 1: Compile a list of the mod names we're working with
std::set<std::string> modnames;
- for(std::vector<ModSpec>::iterator it = m_unsatisfied_mods.begin();
- it != m_unsatisfied_mods.end(); ++it){
- modnames.insert((*it).name);
+ for (const ModSpec &mod : m_unsatisfied_mods) {
+ modnames.insert(mod.name);
}
// Step 2: get dependencies (including optional dependencies)
// of each mod, split mods into satisfied and unsatisfied
std::list<ModSpec> satisfied;
std::list<ModSpec> unsatisfied;
- for (std::vector<ModSpec>::iterator it = m_unsatisfied_mods.begin();
- it != m_unsatisfied_mods.end(); ++it) {
- ModSpec mod = *it;
+ for (ModSpec mod : m_unsatisfied_mods) {
mod.unsatisfied_depends = mod.depends;
// check which optional dependencies actually exist
- for (std::unordered_set<std::string>::iterator it_optdep = mod.optdepends.begin();
- it_optdep != mod.optdepends.end(); ++it_optdep) {
- std::string optdep = *it_optdep;
+ for (const std::string &optdep : mod.optdepends) {
if (modnames.count(optdep) != 0)
mod.unsatisfied_depends.insert(optdep);
}
ModSpec mod = satisfied.back();
m_sorted_mods.push_back(mod);
satisfied.pop_back();
- for(std::list<ModSpec>::iterator it = unsatisfied.begin();
- it != unsatisfied.end(); ){
+ for (auto it = unsatisfied.begin(); it != unsatisfied.end(); ) {
ModSpec& mod2 = *it;
mod2.unsatisfied_depends.erase(mod.name);
- if(mod2.unsatisfied_depends.empty()){
+ if (mod2.unsatisfied_depends.empty()) {
satisfied.push_back(mod2);
it = unsatisfied.erase(it);
- }
- else{
+ } else {
++it;
}
}
}
const Json::Value::Members attr_list = root.getMemberNames();
- for (Json::Value::Members::const_iterator it = attr_list.begin();
- it != attr_list.end(); ++it) {
- Json::Value attr_value = root[*it];
- m_stringvars[*it] = attr_value.asString();
+ for (const auto &it : attr_list) {
+ Json::Value attr_value = root[it];
+ m_stringvars[it] = attr_value.asString();
}
return true;
std::unordered_set<std::string> m_name_conflicts;
// Deleted default constructor
- ModConfiguration() {}
+ ModConfiguration() = default;
};
{
public:
ModMetadata(const std::string &mod_name);
- ~ModMetadata() {}
+ ~ModMetadata() = default;
virtual void clear();