Code modernization: src/m* (part 3)
* empty function * default constructor/destructor * for range-based loops * use emplace_back instead of push_back * remove some unused headers in some cpp variable
This commit is contained in:
parent
b5f7249a7e
commit
d382483fa7
@ -1925,9 +1925,8 @@ void ServerMap::save(ModifiedState save_level)
|
|||||||
// 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;
|
||||||
|
|
||||||
for(std::map<v2s16, MapSector*>::iterator i = m_sectors.begin();
|
for (auto §or_it : m_sectors) {
|
||||||
i != m_sectors.end(); ++i) {
|
ServerMapSector *sector = (ServerMapSector*) sector_it.second;
|
||||||
ServerMapSector *sector = (ServerMapSector*)i->second;
|
|
||||||
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) {
|
||||||
|
@ -30,7 +30,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "mapblock.h"
|
#include "mapblock.h"
|
||||||
#include "mapnode.h"
|
#include "mapnode.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "content_sao.h"
|
|
||||||
#include "nodedef.h"
|
#include "nodedef.h"
|
||||||
#include "voxelalgorithms.h"
|
#include "voxelalgorithms.h"
|
||||||
#include "settings.h" // For g_settings
|
#include "settings.h" // For g_settings
|
||||||
|
@ -455,7 +455,7 @@ void transformNodeBox(const MapNode &n, const NodeBox &nodebox,
|
|||||||
}
|
}
|
||||||
else // NODEBOX_REGULAR
|
else // NODEBOX_REGULAR
|
||||||
{
|
{
|
||||||
boxes.push_back(aabb3f(-BS/2,-BS/2,-BS/2,BS/2,BS/2,BS/2));
|
boxes.emplace_back(-BS/2,-BS/2,-BS/2,BS/2,BS/2,BS/2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,7 +764,7 @@ void MapNode::deSerializeBulk(std::istream &is, int version,
|
|||||||
/*
|
/*
|
||||||
Legacy serialization
|
Legacy serialization
|
||||||
*/
|
*/
|
||||||
void MapNode::deSerialize_pre22(u8 *source, u8 version)
|
void MapNode::deSerialize_pre22(const u8 *source, u8 version)
|
||||||
{
|
{
|
||||||
if(version <= 1)
|
if(version <= 1)
|
||||||
{
|
{
|
||||||
|
@ -300,5 +300,5 @@ struct MapNode
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Deprecated serialization methods
|
// Deprecated serialization methods
|
||||||
void deSerialize_pre22(u8 *source, u8 version);
|
void deSerialize_pre22(const u8 *source, u8 version);
|
||||||
};
|
};
|
||||||
|
@ -32,7 +32,7 @@ struct CachedMapBlockData
|
|||||||
int refcount_from_queue = 0;
|
int refcount_from_queue = 0;
|
||||||
std::time_t last_used_timestamp = std::time(0);
|
std::time_t last_used_timestamp = std::time(0);
|
||||||
|
|
||||||
CachedMapBlockData() {}
|
CachedMapBlockData() = default;
|
||||||
~CachedMapBlockData();
|
~CachedMapBlockData();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ struct QueuedMeshUpdate
|
|||||||
v3s16 crack_pos;
|
v3s16 crack_pos;
|
||||||
MeshMakeData *data = nullptr; // This is generated in MeshUpdateQueue::pop()
|
MeshMakeData *data = nullptr; // This is generated in MeshUpdateQueue::pop()
|
||||||
|
|
||||||
QueuedMeshUpdate(){};
|
QueuedMeshUpdate() = default;
|
||||||
~QueuedMeshUpdate();
|
~QueuedMeshUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ struct MeshUpdateResult
|
|||||||
MapBlockMesh *mesh = nullptr;
|
MapBlockMesh *mesh = nullptr;
|
||||||
bool ack_block_to_server = false;
|
bool ack_block_to_server = false;
|
||||||
|
|
||||||
MeshUpdateResult() {}
|
MeshUpdateResult() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MeshUpdateThread : public UpdateThread
|
class MeshUpdateThread : public UpdateThread
|
||||||
|
@ -18,12 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "metadata.h"
|
#include "metadata.h"
|
||||||
#include "exceptions.h"
|
|
||||||
#include "gamedef.h"
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include <sstream>
|
|
||||||
#include "constants.h" // MAP_BLOCKSIZE
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Metadata
|
Metadata
|
||||||
@ -36,7 +31,7 @@ void Metadata::clear()
|
|||||||
|
|
||||||
bool Metadata::empty() const
|
bool Metadata::empty() const
|
||||||
{
|
{
|
||||||
return m_stringvars.size() == 0;
|
return m_stringvars.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Metadata::size() const
|
size_t Metadata::size() const
|
||||||
@ -54,10 +49,9 @@ bool Metadata::operator==(const Metadata &other) const
|
|||||||
if (size() != other.size())
|
if (size() != other.size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (StringMap::const_iterator it = m_stringvars.begin();
|
for (const auto &sv : m_stringvars) {
|
||||||
it != m_stringvars.end(); ++it) {
|
if (!other.contains(sv.first) ||
|
||||||
if (!other.contains(it->first) ||
|
other.getString(sv.first) != sv.second)
|
||||||
other.getString(it->first) != it->second)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +96,7 @@ const std::string &Metadata::resolveString(const std::string &str, u16 recursion
|
|||||||
{
|
{
|
||||||
if (recursion <= 1 && str.substr(0, 2) == "${" && str[str.length() - 1] == '}') {
|
if (recursion <= 1 && str.substr(0, 2) == "${" && str[str.length() - 1] == '}') {
|
||||||
return getString(str.substr(2, str.length() - 3), recursion + 1);
|
return getString(str.substr(2, str.length() - 3), recursion + 1);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
class Metadata
|
class Metadata
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~Metadata() {}
|
virtual ~Metadata() = default;
|
||||||
|
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
virtual bool empty() const;
|
virtual bool empty() const;
|
||||||
|
@ -64,7 +64,7 @@ public:
|
|||||||
Noise *noise = nullptr;
|
Noise *noise = nullptr;
|
||||||
std::unordered_set<u8> biomes;
|
std::unordered_set<u8> biomes;
|
||||||
|
|
||||||
Ore() {};
|
Ore() = default;;
|
||||||
virtual ~Ore();
|
virtual ~Ore();
|
||||||
|
|
||||||
virtual void resolveNodeNames();
|
virtual void resolveNodeNames();
|
||||||
@ -136,7 +136,7 @@ public:
|
|||||||
class OreManager : public ObjDefManager {
|
class OreManager : public ObjDefManager {
|
||||||
public:
|
public:
|
||||||
OreManager(IGameDef *gamedef);
|
OreManager(IGameDef *gamedef);
|
||||||
virtual ~OreManager() {}
|
virtual ~OreManager() = default;
|
||||||
|
|
||||||
const char *getObjectTitle() const
|
const char *getObjectTitle() const
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ void SchematicManager::clear()
|
|||||||
DecoSchematic *dschem = dynamic_cast<DecoSchematic *>(deco);
|
DecoSchematic *dschem = dynamic_cast<DecoSchematic *>(deco);
|
||||||
if (dschem)
|
if (dschem)
|
||||||
dschem->schematic = NULL;
|
dschem->schematic = NULL;
|
||||||
} catch (std::bad_cast) {
|
} catch (const std::bad_cast &) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,8 +68,7 @@ void SchematicManager::clear()
|
|||||||
|
|
||||||
|
|
||||||
Schematic::Schematic()
|
Schematic::Schematic()
|
||||||
{
|
= default;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Schematic::~Schematic()
|
Schematic::~Schematic()
|
||||||
|
@ -115,7 +115,6 @@ void MinimapUpdateThread::doUpdate()
|
|||||||
|
|
||||||
void MinimapUpdateThread::getMap(v3s16 pos, s16 size, s16 height)
|
void MinimapUpdateThread::getMap(v3s16 pos, s16 size, s16 height)
|
||||||
{
|
{
|
||||||
v3s16 region(size, 0, size);
|
|
||||||
v3s16 pos_min(pos.X - size / 2, pos.Y - height / 2, pos.Z - size / 2);
|
v3s16 pos_min(pos.X - size / 2, pos.Y - height / 2, pos.Z - size / 2);
|
||||||
v3s16 pos_max(pos_min.X + size - 1, pos.Y + height / 2, pos_min.Z + size - 1);
|
v3s16 pos_max(pos_min.X + size - 1, pos.Y + height / 2, pos_min.Z + size - 1);
|
||||||
v3s16 blockpos_min = getNodeBlockPos(pos_min);
|
v3s16 blockpos_min = getNodeBlockPos(pos_min);
|
||||||
|
@ -19,13 +19,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <json/json.h>
|
||||||
#include "mods.h"
|
#include "mods.h"
|
||||||
#include "filesys.h"
|
#include "filesys.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "subgame.h"
|
#include "subgame.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "convert_json.h"
|
|
||||||
#include "exceptions.h"
|
|
||||||
#include "porting.h"
|
#include "porting.h"
|
||||||
|
|
||||||
static bool parseDependsLine(std::istream &is,
|
static bool parseDependsLine(std::istream &is,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user