Skip to content

Commit 4faaadc

Browse files
authoredJun 18, 2017
Cpp11 patchset 11: continue working on constructor style migration (#6004)
1 parent 8f77857 commit 4faaadc

39 files changed

+201
-397
lines changed
 

‎src/mesh_generator_thread.cpp

-18
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2828
CachedMapBlockData
2929
*/
3030

31-
CachedMapBlockData::CachedMapBlockData():
32-
p(-1337,-1337,-1337),
33-
data(NULL),
34-
refcount_from_queue(0),
35-
last_used_timestamp(time(0))
36-
{
37-
}
38-
3931
CachedMapBlockData::~CachedMapBlockData()
4032
{
4133
assert(refcount_from_queue == 0);
@@ -47,16 +39,6 @@ CachedMapBlockData::~CachedMapBlockData()
4739
QueuedMeshUpdate
4840
*/
4941

50-
QueuedMeshUpdate::QueuedMeshUpdate():
51-
p(-1337,-1337,-1337),
52-
ack_block_to_server(false),
53-
urgent(false),
54-
crack_level(-1),
55-
crack_pos(0,0,0),
56-
data(NULL)
57-
{
58-
}
59-
6042
QueuedMeshUpdate::~QueuedMeshUpdate()
6143
{
6244
delete data;

‎src/mesh_generator_thread.h

+15-18
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2727

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

35-
CachedMapBlockData();
35+
CachedMapBlockData() {}
3636
~CachedMapBlockData();
3737
};
3838

3939
struct QueuedMeshUpdate
4040
{
41-
v3s16 p;
42-
bool ack_block_to_server;
43-
bool urgent;
44-
int crack_level;
41+
v3s16 p = v3s16(-1337, -1337, -1337);
42+
bool ack_block_to_server = false;
43+
bool urgent = false;
44+
int crack_level = -1;
4545
v3s16 crack_pos;
46-
MeshMakeData *data; // This is generated in MeshUpdateQueue::pop()
46+
MeshMakeData *data = nullptr; // This is generated in MeshUpdateQueue::pop()
4747

48-
QueuedMeshUpdate();
48+
QueuedMeshUpdate(){};
4949
~QueuedMeshUpdate();
5050
};
5151

@@ -101,14 +101,11 @@ class MeshUpdateQueue
101101

102102
struct MeshUpdateResult
103103
{
104-
v3s16 p;
105-
MapBlockMesh *mesh;
106-
bool ack_block_to_server;
104+
v3s16 p = v3s16(-1338, -1338, -1338);
105+
MapBlockMesh *mesh = nullptr;
106+
bool ack_block_to_server = false;
107107

108-
MeshUpdateResult()
109-
: p(-1338, -1338, -1338), mesh(NULL), ack_block_to_server(false)
110-
{
111-
}
108+
MeshUpdateResult() {}
112109
};
113110

114111
class MeshUpdateThread : public UpdateThread

‎src/mg_biome.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ class BiomeGen {
117117
virtual Biome *getBiomeAtIndex(size_t index, s16 y) const = 0;
118118

119119
// Result of calcBiomes bulk computation.
120-
biome_t *biomemap;
120+
biome_t *biomemap = nullptr;
121121

122122
protected:
123-
BiomeManager *m_bmgr;
123+
BiomeManager *m_bmgr = nullptr;
124124
v3s16 m_pmin;
125125
v3s16 m_csize;
126126
};

‎src/mg_decoration.cpp

-22
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,6 @@ size_t DecorationManager::placeAllDecos(Mapgen *mg, u32 blockseed,
6767

6868
///////////////////////////////////////////////////////////////////////////////
6969

70-
71-
Decoration::Decoration()
72-
{
73-
mapseed = 0;
74-
fill_ratio = 0;
75-
sidelen = 1;
76-
flags = 0;
77-
}
78-
79-
80-
Decoration::~Decoration()
81-
{
82-
}
83-
84-
8570
void Decoration::resolveNodeNames()
8671
{
8772
getIdsFromNrBacklog(&c_place_on);
@@ -330,13 +315,6 @@ int DecoSimple::getHeight()
330315

331316
///////////////////////////////////////////////////////////////////////////////
332317

333-
334-
DecoSchematic::DecoSchematic()
335-
{
336-
schematic = NULL;
337-
}
338-
339-
340318
size_t DecoSchematic::generate(MMVManip *vm, PcgRandom *pr, v3s16 p)
341319
{
342320
// Schematic could have been unloaded but not the decoration

‎src/mg_decoration.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ struct CutoffData {
6464

6565
class Decoration : public ObjDef, public NodeResolver {
6666
public:
67-
Decoration();
68-
virtual ~Decoration();
67+
Decoration() {};
68+
virtual ~Decoration() {};
6969

7070
virtual void resolveNodeNames();
7171

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

79-
u32 flags;
80-
int mapseed;
79+
u32 flags = 0;
80+
int mapseed = 0;
8181
std::vector<content_t> c_place_on;
82-
s16 sidelen;
82+
s16 sidelen = 1;
8383
s16 y_min;
8484
s16 y_max;
85-
float fill_ratio;
85+
float fill_ratio = 0.0f;
8686
NoiseParams np;
8787
std::vector<content_t> c_spawnby;
8888
s16 nspawnby;
@@ -104,13 +104,13 @@ class DecoSimple : public Decoration {
104104

105105
class DecoSchematic : public Decoration {
106106
public:
107-
DecoSchematic();
107+
DecoSchematic() {};
108108

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

112112
Rotation rotation;
113-
Schematic *schematic;
113+
Schematic *schematic = nullptr;
114114
};
115115

116116

‎src/mg_ore.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,6 @@ void OreManager::clear()
7272

7373
///////////////////////////////////////////////////////////////////////////////
7474

75-
76-
Ore::Ore()
77-
{
78-
flags = 0;
79-
noise = NULL;
80-
}
81-
82-
8375
Ore::~Ore()
8476
{
8577
delete noise;
@@ -232,8 +224,6 @@ void OreSheet::generate(MMVManip *vm, int mapseed, u32 blockseed,
232224
OrePuff::OrePuff() :
233225
Ore()
234226
{
235-
noise_puff_top = NULL;
236-
noise_puff_bottom = NULL;
237227
}
238228

239229

@@ -385,7 +375,6 @@ void OreBlob::generate(MMVManip *vm, int mapseed, u32 blockseed,
385375
OreVein::OreVein() :
386376
Ore()
387377
{
388-
noise2 = NULL;
389378
}
390379

391380

‎src/mg_ore.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ class Ore : public ObjDef, public NodeResolver {
6262
s16 y_min;
6363
s16 y_max;
6464
u8 ore_param2; // to set node-specific attributes
65-
u32 flags; // attributes for this ore
65+
u32 flags = 0; // attributes for this ore
6666
float nthresh; // threshold for noise at which an ore is placed
6767
NoiseParams np; // noise for distribution of clusters (NULL for uniform scattering)
68-
Noise *noise;
68+
Noise *noise = nullptr;
6969
std::unordered_set<u8> biomes;
7070

71-
Ore();
71+
Ore() {};
7272
virtual ~Ore();
7373

7474
virtual void resolveNodeNames();
@@ -104,8 +104,8 @@ class OrePuff : public Ore {
104104

105105
NoiseParams np_puff_top;
106106
NoiseParams np_puff_bottom;
107-
Noise *noise_puff_top;
108-
Noise *noise_puff_bottom;
107+
Noise *noise_puff_top = nullptr;
108+
Noise *noise_puff_bottom = nullptr;
109109

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

129129
float random_factor;
130-
Noise *noise2;
130+
Noise *noise2 = nullptr;
131131

132132
OreVein();
133133
virtual ~OreVein();
@@ -160,7 +160,7 @@ class OreManager : public ObjDefManager {
160160
case ORE_VEIN:
161161
return new OreVein;
162162
default:
163-
return NULL;
163+
return nullptr;
164164
}
165165
}
166166

‎src/mg_schematic.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3737

3838

3939
SchematicManager::SchematicManager(Server *server) :
40-
ObjDefManager(server, OBJDEF_SCHEMATIC)
40+
ObjDefManager(server, OBJDEF_SCHEMATIC),
41+
m_server(server)
4142
{
42-
m_server = server;
4343
}
4444

4545

@@ -69,10 +69,6 @@ void SchematicManager::clear()
6969

7070
Schematic::Schematic()
7171
{
72-
schemdata = NULL;
73-
slice_probs = NULL;
74-
flags = 0;
75-
size = v3s16(0, 0, 0);
7672
}
7773

7874

‎src/mg_schematic.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ class Schematic : public ObjDef, public NodeResolver {
117117
std::vector<std::pair<s16, u8> > *splist);
118118

119119
std::vector<content_t> c_nodes;
120-
u32 flags;
120+
u32 flags = 0;
121121
v3s16 size;
122-
MapNode *schemdata;
123-
u8 *slice_probs;
122+
MapNode *schemdata = nullptr;
123+
u8 *slice_probs = nullptr;
124124
};
125125

126126
class SchematicManager : public ObjDefManager {

‎src/minimap.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ Minimap::Minimap(IrrlichtDevice *device, Client *client)
204204
data->mode = MINIMAP_MODE_OFF;
205205
data->is_radar = false;
206206
data->map_invalidated = true;
207-
data->heightmap_image = NULL;
208-
data->minimap_image = NULL;
209207
data->texture = NULL;
210208
data->heightmap_texture = NULL;
211209
data->minimap_shape_round = g_settings->getBool("minimap_shape_round");
@@ -275,14 +273,14 @@ void Minimap::toggleMinimapShape()
275273
void Minimap::setMinimapShape(MinimapShape shape)
276274
{
277275
MutexAutoLock lock(m_mutex);
278-
276+
279277
if (shape == MINIMAP_SHAPE_SQUARE)
280278
data->minimap_shape_round = false;
281279
else if (shape == MINIMAP_SHAPE_ROUND)
282280
data->minimap_shape_round = true;
283-
281+
284282
g_settings->setBool("minimap_shape_round", data->minimap_shape_round);
285-
m_minimap_update_thread->deferUpdate();
283+
m_minimap_update_thread->deferUpdate();
286284
}
287285

288286
MinimapShape Minimap::getMinimapShape()

‎src/minimap.h

+10-12
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,19 @@ struct MinimapData {
7878
MinimapPixel minimap_scan[MINIMAP_MAX_SX * MINIMAP_MAX_SY];
7979
bool map_invalidated;
8080
bool minimap_shape_round;
81-
video::IImage *minimap_image;
82-
video::IImage *heightmap_image;
83-
video::IImage *minimap_mask_round;
84-
video::IImage *minimap_mask_square;
85-
video::ITexture *texture;
86-
video::ITexture *heightmap_texture;
87-
video::ITexture *minimap_overlay_round;
88-
video::ITexture *minimap_overlay_square;
89-
video::ITexture *player_marker;
90-
video::ITexture *object_marker_red;
81+
video::IImage *minimap_mask_round = nullptr;
82+
video::IImage *minimap_mask_square = nullptr;
83+
video::ITexture *texture = nullptr;
84+
video::ITexture *heightmap_texture = nullptr;
85+
video::ITexture *minimap_overlay_round = nullptr;
86+
video::ITexture *minimap_overlay_square = nullptr;
87+
video::ITexture *player_marker = nullptr;
88+
video::ITexture *object_marker_red = nullptr;
9189
};
9290

9391
struct QueuedMinimapUpdate {
9492
v3s16 pos;
95-
MinimapMapblock *data;
93+
MinimapMapblock *data = nullptr;
9694
};
9795

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

108-
MinimapData *data;
106+
MinimapData *data = nullptr;
109107

110108
protected:
111109
virtual void doUpdate();

‎src/modalMenu.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ class GUIModalMenu : public gui::IGUIElement
4848
IGUIElement(gui::EGUIET_ELEMENT, env, parent, id,
4949
core::rect<s32>(0,0,100,100))
5050
{
51-
//m_force_regenerate_gui = false;
52-
5351
m_menumgr = menumgr;
54-
m_allow_focus_removal = false;
55-
m_screensize_old = v2u32(0,0);
5652

5753
setVisible(true);
5854
Environment->setFocus(this);
@@ -142,7 +138,7 @@ class GUIModalMenu : public gui::IGUIElement
142138
IMenuManager *m_menumgr;
143139
// This might be necessary to expose to the implementation if it
144140
// wants to launch other menus
145-
bool m_allow_focus_removal;
141+
bool m_allow_focus_removal = false;
146142
};
147143

148144

‎src/mods.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,8 @@ Json::Value getModstoreUrl(const std::string &url)
385385
#endif
386386

387387
ModMetadata::ModMetadata(const std::string &mod_name):
388-
m_mod_name(mod_name),
389-
m_modified(false)
388+
m_mod_name(mod_name)
390389
{
391-
m_stringvars.clear();
392390
}
393391

394392
void ModMetadata::clear()

0 commit comments

Comments
 (0)
Please sign in to comment.