Skip to content

Commit

Permalink
Cpp11 patchset 11: continue working on constructor style migration (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nerzhul committed Jun 18, 2017
1 parent 8f77857 commit 4faaadc
Show file tree
Hide file tree
Showing 39 changed files with 201 additions and 397 deletions.
18 changes: 0 additions & 18 deletions src/mesh_generator_thread.cpp
Expand Up @@ -28,14 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
CachedMapBlockData
*/

CachedMapBlockData::CachedMapBlockData():
p(-1337,-1337,-1337),
data(NULL),
refcount_from_queue(0),
last_used_timestamp(time(0))
{
}

CachedMapBlockData::~CachedMapBlockData()
{
assert(refcount_from_queue == 0);
Expand All @@ -47,16 +39,6 @@ CachedMapBlockData::~CachedMapBlockData()
QueuedMeshUpdate
*/

QueuedMeshUpdate::QueuedMeshUpdate():
p(-1337,-1337,-1337),
ack_block_to_server(false),
urgent(false),
crack_level(-1),
crack_pos(0,0,0),
data(NULL)
{
}

QueuedMeshUpdate::~QueuedMeshUpdate()
{
delete data;
Expand Down
33 changes: 15 additions & 18 deletions src/mesh_generator_thread.h
Expand Up @@ -27,25 +27,25 @@ with this program; if not, write to the Free Software Foundation, Inc.,

struct CachedMapBlockData
{
v3s16 p;
MapNode *data; // A copy of the MapBlock's data member
int refcount_from_queue;
int last_used_timestamp;
v3s16 p = v3s16(-1337, -1337, -1337);
MapNode *data = nullptr; // A copy of the MapBlock's data member
int refcount_from_queue = 0;
int last_used_timestamp = std::time(0);

CachedMapBlockData();
CachedMapBlockData() {}
~CachedMapBlockData();
};

struct QueuedMeshUpdate
{
v3s16 p;
bool ack_block_to_server;
bool urgent;
int crack_level;
v3s16 p = v3s16(-1337, -1337, -1337);
bool ack_block_to_server = false;
bool urgent = false;
int crack_level = -1;
v3s16 crack_pos;
MeshMakeData *data; // This is generated in MeshUpdateQueue::pop()
MeshMakeData *data = nullptr; // This is generated in MeshUpdateQueue::pop()

QueuedMeshUpdate();
QueuedMeshUpdate(){};
~QueuedMeshUpdate();
};

Expand Down Expand Up @@ -101,14 +101,11 @@ class MeshUpdateQueue

struct MeshUpdateResult
{
v3s16 p;
MapBlockMesh *mesh;
bool ack_block_to_server;
v3s16 p = v3s16(-1338, -1338, -1338);
MapBlockMesh *mesh = nullptr;
bool ack_block_to_server = false;

MeshUpdateResult()
: p(-1338, -1338, -1338), mesh(NULL), ack_block_to_server(false)
{
}
MeshUpdateResult() {}
};

class MeshUpdateThread : public UpdateThread
Expand Down
4 changes: 2 additions & 2 deletions src/mg_biome.h
Expand Up @@ -117,10 +117,10 @@ class BiomeGen {
virtual Biome *getBiomeAtIndex(size_t index, s16 y) const = 0;

// Result of calcBiomes bulk computation.
biome_t *biomemap;
biome_t *biomemap = nullptr;

protected:
BiomeManager *m_bmgr;
BiomeManager *m_bmgr = nullptr;
v3s16 m_pmin;
v3s16 m_csize;
};
Expand Down
22 changes: 0 additions & 22 deletions src/mg_decoration.cpp
Expand Up @@ -67,21 +67,6 @@ size_t DecorationManager::placeAllDecos(Mapgen *mg, u32 blockseed,

///////////////////////////////////////////////////////////////////////////////


Decoration::Decoration()
{
mapseed = 0;
fill_ratio = 0;
sidelen = 1;
flags = 0;
}


Decoration::~Decoration()
{
}


void Decoration::resolveNodeNames()
{
getIdsFromNrBacklog(&c_place_on);
Expand Down Expand Up @@ -330,13 +315,6 @@ int DecoSimple::getHeight()

///////////////////////////////////////////////////////////////////////////////


DecoSchematic::DecoSchematic()
{
schematic = NULL;
}


size_t DecoSchematic::generate(MMVManip *vm, PcgRandom *pr, v3s16 p)
{
// Schematic could have been unloaded but not the decoration
Expand Down
16 changes: 8 additions & 8 deletions src/mg_decoration.h
Expand Up @@ -64,8 +64,8 @@ struct CutoffData {

class Decoration : public ObjDef, public NodeResolver {
public:
Decoration();
virtual ~Decoration();
Decoration() {};
virtual ~Decoration() {};

virtual void resolveNodeNames();

Expand All @@ -76,13 +76,13 @@ class Decoration : public ObjDef, public NodeResolver {
virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p) = 0;
virtual int getHeight() = 0;

u32 flags;
int mapseed;
u32 flags = 0;
int mapseed = 0;
std::vector<content_t> c_place_on;
s16 sidelen;
s16 sidelen = 1;
s16 y_min;
s16 y_max;
float fill_ratio;
float fill_ratio = 0.0f;
NoiseParams np;
std::vector<content_t> c_spawnby;
s16 nspawnby;
Expand All @@ -104,13 +104,13 @@ class DecoSimple : public Decoration {

class DecoSchematic : public Decoration {
public:
DecoSchematic();
DecoSchematic() {};

virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p);
virtual int getHeight();

Rotation rotation;
Schematic *schematic;
Schematic *schematic = nullptr;
};


Expand Down
11 changes: 0 additions & 11 deletions src/mg_ore.cpp
Expand Up @@ -72,14 +72,6 @@ void OreManager::clear()

///////////////////////////////////////////////////////////////////////////////


Ore::Ore()
{
flags = 0;
noise = NULL;
}


Ore::~Ore()
{
delete noise;
Expand Down Expand Up @@ -232,8 +224,6 @@ void OreSheet::generate(MMVManip *vm, int mapseed, u32 blockseed,
OrePuff::OrePuff() :
Ore()
{
noise_puff_top = NULL;
noise_puff_bottom = NULL;
}


Expand Down Expand Up @@ -385,7 +375,6 @@ void OreBlob::generate(MMVManip *vm, int mapseed, u32 blockseed,
OreVein::OreVein() :
Ore()
{
noise2 = NULL;
}


Expand Down
14 changes: 7 additions & 7 deletions src/mg_ore.h
Expand Up @@ -62,13 +62,13 @@ class Ore : public ObjDef, public NodeResolver {
s16 y_min;
s16 y_max;
u8 ore_param2; // to set node-specific attributes
u32 flags; // attributes for this ore
u32 flags = 0; // attributes for this ore
float nthresh; // threshold for noise at which an ore is placed
NoiseParams np; // noise for distribution of clusters (NULL for uniform scattering)
Noise *noise;
Noise *noise = nullptr;
std::unordered_set<u8> biomes;

Ore();
Ore() {};
virtual ~Ore();

virtual void resolveNodeNames();
Expand Down Expand Up @@ -104,8 +104,8 @@ class OrePuff : public Ore {

NoiseParams np_puff_top;
NoiseParams np_puff_bottom;
Noise *noise_puff_top;
Noise *noise_puff_bottom;
Noise *noise_puff_top = nullptr;
Noise *noise_puff_bottom = nullptr;

OrePuff();
virtual ~OrePuff();
Expand All @@ -127,7 +127,7 @@ class OreVein : public Ore {
static const bool NEEDS_NOISE = true;

float random_factor;
Noise *noise2;
Noise *noise2 = nullptr;

OreVein();
virtual ~OreVein();
Expand Down Expand Up @@ -160,7 +160,7 @@ class OreManager : public ObjDefManager {
case ORE_VEIN:
return new OreVein;
default:
return NULL;
return nullptr;
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/mg_schematic.cpp
Expand Up @@ -37,9 +37,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,


SchematicManager::SchematicManager(Server *server) :
ObjDefManager(server, OBJDEF_SCHEMATIC)
ObjDefManager(server, OBJDEF_SCHEMATIC),
m_server(server)
{
m_server = server;
}


Expand Down Expand Up @@ -69,10 +69,6 @@ void SchematicManager::clear()

Schematic::Schematic()
{
schemdata = NULL;
slice_probs = NULL;
flags = 0;
size = v3s16(0, 0, 0);
}


Expand Down
6 changes: 3 additions & 3 deletions src/mg_schematic.h
Expand Up @@ -117,10 +117,10 @@ class Schematic : public ObjDef, public NodeResolver {
std::vector<std::pair<s16, u8> > *splist);

std::vector<content_t> c_nodes;
u32 flags;
u32 flags = 0;
v3s16 size;
MapNode *schemdata;
u8 *slice_probs;
MapNode *schemdata = nullptr;
u8 *slice_probs = nullptr;
};

class SchematicManager : public ObjDefManager {
Expand Down
8 changes: 3 additions & 5 deletions src/minimap.cpp
Expand Up @@ -204,8 +204,6 @@ Minimap::Minimap(IrrlichtDevice *device, Client *client)
data->mode = MINIMAP_MODE_OFF;
data->is_radar = false;
data->map_invalidated = true;
data->heightmap_image = NULL;
data->minimap_image = NULL;
data->texture = NULL;
data->heightmap_texture = NULL;
data->minimap_shape_round = g_settings->getBool("minimap_shape_round");
Expand Down Expand Up @@ -275,14 +273,14 @@ void Minimap::toggleMinimapShape()
void Minimap::setMinimapShape(MinimapShape shape)
{
MutexAutoLock lock(m_mutex);

if (shape == MINIMAP_SHAPE_SQUARE)
data->minimap_shape_round = false;
else if (shape == MINIMAP_SHAPE_ROUND)
data->minimap_shape_round = true;

g_settings->setBool("minimap_shape_round", data->minimap_shape_round);
m_minimap_update_thread->deferUpdate();
m_minimap_update_thread->deferUpdate();
}

MinimapShape Minimap::getMinimapShape()
Expand Down
22 changes: 10 additions & 12 deletions src/minimap.h
Expand Up @@ -78,21 +78,19 @@ struct MinimapData {
MinimapPixel minimap_scan[MINIMAP_MAX_SX * MINIMAP_MAX_SY];
bool map_invalidated;
bool minimap_shape_round;
video::IImage *minimap_image;
video::IImage *heightmap_image;
video::IImage *minimap_mask_round;
video::IImage *minimap_mask_square;
video::ITexture *texture;
video::ITexture *heightmap_texture;
video::ITexture *minimap_overlay_round;
video::ITexture *minimap_overlay_square;
video::ITexture *player_marker;
video::ITexture *object_marker_red;
video::IImage *minimap_mask_round = nullptr;
video::IImage *minimap_mask_square = nullptr;
video::ITexture *texture = nullptr;
video::ITexture *heightmap_texture = nullptr;
video::ITexture *minimap_overlay_round = nullptr;
video::ITexture *minimap_overlay_square = nullptr;
video::ITexture *player_marker = nullptr;
video::ITexture *object_marker_red = nullptr;
};

struct QueuedMinimapUpdate {
v3s16 pos;
MinimapMapblock *data;
MinimapMapblock *data = nullptr;
};

class MinimapUpdateThread : public UpdateThread {
Expand All @@ -105,7 +103,7 @@ class MinimapUpdateThread : public UpdateThread {
bool pushBlockUpdate(v3s16 pos, MinimapMapblock *data);
bool popBlockUpdate(QueuedMinimapUpdate *update);

MinimapData *data;
MinimapData *data = nullptr;

protected:
virtual void doUpdate();
Expand Down
6 changes: 1 addition & 5 deletions src/modalMenu.h
Expand Up @@ -48,11 +48,7 @@ class GUIModalMenu : public gui::IGUIElement
IGUIElement(gui::EGUIET_ELEMENT, env, parent, id,
core::rect<s32>(0,0,100,100))
{
//m_force_regenerate_gui = false;

m_menumgr = menumgr;
m_allow_focus_removal = false;
m_screensize_old = v2u32(0,0);

setVisible(true);
Environment->setFocus(this);
Expand Down Expand Up @@ -142,7 +138,7 @@ class GUIModalMenu : public gui::IGUIElement
IMenuManager *m_menumgr;
// This might be necessary to expose to the implementation if it
// wants to launch other menus
bool m_allow_focus_removal;
bool m_allow_focus_removal = false;
};


Expand Down
4 changes: 1 addition & 3 deletions src/mods.cpp
Expand Up @@ -385,10 +385,8 @@ Json::Value getModstoreUrl(const std::string &url)
#endif

ModMetadata::ModMetadata(const std::string &mod_name):
m_mod_name(mod_name),
m_modified(false)
m_mod_name(mod_name)
{
m_stringvars.clear();
}

void ModMetadata::clear()
Expand Down

0 comments on commit 4faaadc

Please sign in to comment.