Skip to content

Commit 1425c6d

Browse files
authoredJun 21, 2017
Cpp11 initializers: last src root changeset (#6022)
* Cpp11 initializers: last src root changeset Finish to migrate all src root folder files to C++11 constructor initializers
1 parent 12aad73 commit 1425c6d

20 files changed

+129
-225
lines changed
 

Diff for: ‎src/serverobject.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2424

2525
ServerActiveObject::ServerActiveObject(ServerEnvironment *env, v3f pos):
2626
ActiveObject(0),
27-
m_known_by_count(0),
28-
m_removed(false),
29-
m_pending_deactivation(false),
30-
m_static_exists(false),
31-
m_static_block(1337,1337,1337),
3227
m_env(env),
3328
m_base_position(pos)
3429
{
@@ -82,7 +77,7 @@ ItemStack ServerActiveObject::getWieldedItem() const
8277
if(inv)
8378
{
8479
const InventoryList *list = inv->getList(getWieldList());
85-
if(list && (getWieldIndex() < (s32)list->getSize()))
80+
if(list && (getWieldIndex() < (s32)list->getSize()))
8681
return list->getItem(getWieldIndex());
8782
}
8883
return ItemStack();

Diff for: ‎src/serverobject.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class ServerActiveObject : public ActiveObject
204204
deleted until this is 0 to keep the id preserved for the right
205205
object.
206206
*/
207-
u16 m_known_by_count;
207+
u16 m_known_by_count = 0;
208208

209209
/*
210210
- Whether this object is to be removed when nobody knows about
@@ -215,7 +215,7 @@ class ServerActiveObject : public ActiveObject
215215
to be deleted.
216216
- This can be set to true by anything else too.
217217
*/
218-
bool m_removed;
218+
bool m_removed = false;
219219

220220
/*
221221
This is set to true when an object should be removed from the active
@@ -226,17 +226,17 @@ class ServerActiveObject : public ActiveObject
226226
m_known_by_count is true, object is deleted from the active object
227227
list.
228228
*/
229-
bool m_pending_deactivation;
229+
bool m_pending_deactivation = false;
230230

231231
/*
232232
Whether the object's static data has been stored to a block
233233
*/
234-
bool m_static_exists;
234+
bool m_static_exists = false;
235235
/*
236236
The block from which the object was loaded from, and in which
237237
a copy of the static data resides.
238238
*/
239-
v3s16 m_static_block;
239+
v3s16 m_static_block = v3s16(1337,1337,1337);
240240

241241
/*
242242
Queue of messages to be sent to the client

Diff for: ‎src/settings.h

+5-10
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,20 @@ struct ValueSpec {
7373
};
7474

7575
struct SettingsEntry {
76-
SettingsEntry() :
77-
group(NULL),
78-
is_group(false)
79-
{}
76+
SettingsEntry() {}
8077

8178
SettingsEntry(const std::string &value_) :
82-
value(value_),
83-
group(NULL),
84-
is_group(false)
79+
value(value_)
8580
{}
8681

8782
SettingsEntry(Settings *group_) :
8883
group(group_),
8984
is_group(true)
9085
{}
9186

92-
std::string value;
93-
Settings *group;
94-
bool is_group;
87+
std::string value = "";
88+
Settings *group = nullptr;
89+
bool is_group = false;
9590
};
9691

9792
typedef std::unordered_map<std::string, SettingsEntry> SettingEntries;

Diff for: ‎src/shader.h

+9-12
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,13 @@ std::string getShaderPath(const std::string &name_of_shader,
4444
const std::string &filename);
4545

4646
struct ShaderInfo {
47-
std::string name;
48-
video::E_MATERIAL_TYPE base_material;
49-
video::E_MATERIAL_TYPE material;
50-
u8 drawtype;
51-
u8 material_type;
52-
s32 user_data;
53-
54-
ShaderInfo(): name(""), base_material(video::EMT_SOLID),
55-
material(video::EMT_SOLID),
56-
drawtype(0), material_type(0) {}
47+
std::string name = "";
48+
video::E_MATERIAL_TYPE base_material = video::EMT_SOLID;
49+
video::E_MATERIAL_TYPE material = video::EMT_SOLID;
50+
u8 drawtype = 0;
51+
u8 material_type = 0;
52+
53+
ShaderInfo() {}
5754
virtual ~ShaderInfo() {}
5855
};
5956

@@ -85,11 +82,11 @@ template <typename T, std::size_t count=1>
8582
class CachedShaderSetting {
8683
const char *m_name;
8784
T m_sent[count];
88-
bool has_been_set;
85+
bool has_been_set = false;
8986
bool is_pixel;
9087
protected:
9188
CachedShaderSetting(const char *name, bool is_pixel) :
92-
m_name(name), has_been_set(false), is_pixel(is_pixel)
89+
m_name(name), is_pixel(is_pixel)
9390
{}
9491
public:
9592
void set(const T value[count], video::IMaterialRendererServices *services)

Diff for: ‎src/sky.cpp

+11-21
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,7 @@
1414

1515
Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
1616
ITextureSource *tsrc):
17-
scene::ISceneNode(parent, mgr, id),
18-
m_visible(true),
19-
m_fallback_bg_color(255, 255, 255, 255),
20-
m_first_update(true),
21-
m_brightness(0.5),
22-
m_cloud_brightness(0.5),
23-
m_bgcolor_bright_f(1, 1, 1, 1),
24-
m_skycolor_bright_f(1, 1, 1, 1),
25-
m_cloudcolor_bright_f(1, 1, 1, 1)
17+
scene::ISceneNode(parent, mgr, id)
2618
{
2719
setAutomaticCulling(scene::EAC_OFF);
2820
m_box.MaxEdge.set(0, 0, 0);
@@ -85,8 +77,6 @@ Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
8577
}
8678

8779
m_directional_colored_fog = g_settings->getBool("directional_colored_fog");
88-
89-
m_clouds_enabled = true;
9080
}
9181

9282

@@ -109,7 +99,7 @@ void Sky::render()
10999

110100
if (!camera || !driver)
111101
return;
112-
102+
113103
ScopeProfiler sp(g_profiler, "Sky::render()", SPT_AVG);
114104

115105
// Draw perspective skybox
@@ -138,7 +128,7 @@ void Sky::render()
138128
float moonsize = 0.04;
139129
video::SColorf mooncolor_f(0.50, 0.57, 0.65, 1);
140130
video::SColorf mooncolor2_f(0.85, 0.875, 0.9, 1);
141-
131+
142132
float nightlength = 0.415;
143133
float wn = nightlength / 2;
144134
float wicked_time_of_day = 0;
@@ -181,11 +171,11 @@ void Sky::render()
181171
const f32 o = 0.0f;
182172
static const u16 indices[4] = {0, 1, 2, 3};
183173
video::S3DVertex vertices[4];
184-
174+
185175
driver->setMaterial(m_materials[1]);
186-
176+
187177
video::SColor cloudyfogcolor = m_bgcolor;
188-
178+
189179
// Draw far cloudy fog thing blended with skycolor
190180
for (u32 j = 0; j < 4; j++) {
191181
video::SColor c = cloudyfogcolor.getInterpolated(m_skycolor, 0.45);
@@ -361,7 +351,7 @@ void Sky::render()
361351
vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
362352
}
363353
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
364-
354+
365355
d = moonsize * 1.3;
366356
c = mooncolor;
367357
c.setAlpha(0.15 * 255);
@@ -466,7 +456,7 @@ void Sky::render()
466456
indices, SKY_STAR_COUNT, video::EVT_STANDARD,
467457
scene::EPT_QUADS, video::EIT_16BIT);
468458
} while(0);
469-
459+
470460
// Draw far cloudy fog thing below east and west horizons
471461
for (u32 j = 0; j < 2; j++) {
472462
video::SColor c = cloudyfogcolor;
@@ -510,7 +500,7 @@ void Sky::update(float time_of_day, float time_brightness,
510500
m_time_of_day = time_of_day;
511501
m_time_brightness = time_brightness;
512502
m_sunlight_seen = sunlight_seen;
513-
503+
514504
bool is_dawn = (time_brightness >= 0.20 && time_brightness < 0.35);
515505

516506
/*
@@ -535,7 +525,7 @@ void Sky::update(float time_of_day, float time_brightness,
535525
video::SColorf skycolor_bright_normal_f = video::SColor(255, 140, 186, 250);
536526
video::SColorf skycolor_bright_dawn_f = video::SColor(255, 180, 186, 250);
537527
video::SColorf skycolor_bright_night_f = video::SColor(255, 0, 107, 255);
538-
528+
539529
// pure white: becomes "diffuse light component" for clouds
540530
video::SColorf cloudcolor_bright_normal_f = video::SColor(255, 255, 255, 255);
541531
// dawn-factoring version of pure white (note: R is above 1.0)
@@ -555,7 +545,7 @@ void Sky::update(float time_of_day, float time_brightness,
555545
else
556546
m_brightness = m_brightness * 0.98 + direct_brightness * 0.02;
557547
}
558-
548+
559549
m_clouds_visible = true;
560550
float color_change_fraction = 0.98;
561551
if (sunlight_seen) {

Diff for: ‎src/sky.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,25 @@ class Sky : public scene::ISceneNode
117117
return result;
118118
}
119119

120-
bool m_visible;
121-
video::SColor m_fallback_bg_color; // Used when m_visible=false
122-
bool m_first_update;
120+
bool m_visible = true;
121+
// Used when m_visible=false
122+
video::SColor m_fallback_bg_color = video::SColor(255, 255, 255, 255);
123+
bool m_first_update = true;
123124
float m_time_of_day;
124125
float m_time_brightness;
125126
bool m_sunlight_seen;
126-
float m_brightness;
127-
float m_cloud_brightness;
127+
float m_brightness = 0.5f;
128+
float m_cloud_brightness = 0.5f;
128129
bool m_clouds_visible; // Whether clouds are disabled due to player underground
129-
bool m_clouds_enabled; // Initialised to true, reset only by set_sky API
130+
bool m_clouds_enabled = true; // Initialised to true, reset only by set_sky API
130131
bool m_directional_colored_fog;
131-
video::SColorf m_bgcolor_bright_f;
132-
video::SColorf m_skycolor_bright_f;
133-
video::SColorf m_cloudcolor_bright_f;
132+
video::SColorf m_bgcolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
133+
video::SColorf m_skycolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
134+
video::SColorf m_cloudcolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
134135
video::SColor m_bgcolor;
135136
video::SColor m_skycolor;
136137
video::SColorf m_cloudcolor_f;
137138
v3f m_stars[SKY_STAR_COUNT];
138-
video::S3DVertex m_star_vertices[SKY_STAR_COUNT * 4];
139139
video::ITexture *m_sun_texture;
140140
video::ITexture *m_moon_texture;
141141
video::ITexture *m_sun_tonemap;

Diff for: ‎src/socket.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ void sockets_cleanup()
9090

9191
Address::Address()
9292
{
93-
m_addr_family = 0;
9493
memset(&m_address, 0, sizeof(m_address));
95-
m_port = 0;
9694
}
9795

9896
Address::Address(u32 address, u16 port)

Diff for: ‎src/socket.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ class Address
103103
void print(std::ostream *s) const;
104104
std::string serializeString() const;
105105
private:
106-
unsigned int m_addr_family;
106+
unsigned int m_addr_family = 0;
107107
union
108108
{
109109
struct sockaddr_in ipv4;
110110
struct sockaddr_in6 ipv6;
111111
} m_address;
112-
u16 m_port; // Port is separate from sockaddr structures
112+
u16 m_port = 0; // Port is separate from sockaddr structures
113113
};
114114

115115
class UDPSocket

Diff for: ‎src/staticobject.h

+3-7
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2929

3030
struct StaticObject
3131
{
32-
u8 type;
32+
u8 type = 0;
3333
v3f pos;
3434
std::string data;
3535

36-
StaticObject():
37-
type(0),
38-
pos(0,0,0)
39-
{
40-
}
36+
StaticObject() {}
4137
StaticObject(u8 type_, v3f pos_, const std::string &data_):
4238
type(type_),
4339
pos(pos_),
@@ -88,7 +84,7 @@ class StaticObjectList
8884

8985
void serialize(std::ostream &os);
9086
void deSerialize(std::istream &is);
91-
87+
9288
/*
9389
NOTE: When an object is transformed to active, it is removed
9490
from m_stored and inserted to m_active.

Diff for: ‎src/subgame.h

+7-9
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2626

2727
class Settings;
2828

29-
#define WORLDNAME_BLACKLISTED_CHARS "/\\"
30-
3129
struct SubgameSpec
3230
{
3331
std::string id; // "" = game does not exist
@@ -37,15 +35,15 @@ struct SubgameSpec
3735
std::string name;
3836
std::string menuicon_path;
3937

40-
SubgameSpec(const std::string &id_="",
41-
const std::string &path_="",
42-
const std::string &gamemods_path_="",
43-
const std::set<std::string> &addon_mods_paths_=std::set<std::string>(),
44-
const std::string &name_="",
45-
const std::string &menuicon_path_=""):
38+
SubgameSpec(const std::string &id_ = "",
39+
const std::string &path_ = "",
40+
const std::string &gamemods_path_ = "",
41+
const std::set<std::string> &addon_mods_paths_ = std::set<std::string>(),
42+
const std::string &name_ = "",
43+
const std::string &menuicon_path_ = ""):
4644
id(id_),
4745
path(path_),
48-
gamemods_path(gamemods_path_),
46+
gamemods_path(gamemods_path_),
4947
addon_mods_paths(addon_mods_paths_),
5048
name(name_),
5149
menuicon_path(menuicon_path_)

0 commit comments

Comments
 (0)
Please sign in to comment.