Skip to content
Permalink
Browse files

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
  • Loading branch information...
nerzhul committed Jun 21, 2017
1 parent 12aad73 commit 1425c6def156840b359b90b4f32b9c7b8f005731
@@ -24,11 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,

ServerActiveObject::ServerActiveObject(ServerEnvironment *env, v3f pos):
ActiveObject(0),
m_known_by_count(0),
m_removed(false),
m_pending_deactivation(false),
m_static_exists(false),
m_static_block(1337,1337,1337),
m_env(env),
m_base_position(pos)
{
@@ -82,7 +77,7 @@ ItemStack ServerActiveObject::getWieldedItem() const
if(inv)
{
const InventoryList *list = inv->getList(getWieldList());
if(list && (getWieldIndex() < (s32)list->getSize()))
if(list && (getWieldIndex() < (s32)list->getSize()))
return list->getItem(getWieldIndex());
}
return ItemStack();
@@ -204,7 +204,7 @@ class ServerActiveObject : public ActiveObject
deleted until this is 0 to keep the id preserved for the right
object.
*/
u16 m_known_by_count;
u16 m_known_by_count = 0;

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

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

/*
Whether the object's static data has been stored to a block
*/
bool m_static_exists;
bool m_static_exists = false;
/*
The block from which the object was loaded from, and in which
a copy of the static data resides.
*/
v3s16 m_static_block;
v3s16 m_static_block = v3s16(1337,1337,1337);

/*
Queue of messages to be sent to the client
@@ -73,25 +73,20 @@ struct ValueSpec {
};

struct SettingsEntry {
SettingsEntry() :
group(NULL),
is_group(false)
{}
SettingsEntry() {}

SettingsEntry(const std::string &value_) :
value(value_),
group(NULL),
is_group(false)
value(value_)
{}

SettingsEntry(Settings *group_) :
group(group_),
is_group(true)
{}

std::string value;
Settings *group;
bool is_group;
std::string value = "";
Settings *group = nullptr;
bool is_group = false;
};

typedef std::unordered_map<std::string, SettingsEntry> SettingEntries;
@@ -44,16 +44,13 @@ std::string getShaderPath(const std::string &name_of_shader,
const std::string &filename);

struct ShaderInfo {
std::string name;
video::E_MATERIAL_TYPE base_material;
video::E_MATERIAL_TYPE material;
u8 drawtype;
u8 material_type;
s32 user_data;

ShaderInfo(): name(""), base_material(video::EMT_SOLID),
material(video::EMT_SOLID),
drawtype(0), material_type(0) {}
std::string name = "";
video::E_MATERIAL_TYPE base_material = video::EMT_SOLID;
video::E_MATERIAL_TYPE material = video::EMT_SOLID;
u8 drawtype = 0;
u8 material_type = 0;

ShaderInfo() {}
virtual ~ShaderInfo() {}
};

@@ -85,11 +82,11 @@ template <typename T, std::size_t count=1>
class CachedShaderSetting {
const char *m_name;
T m_sent[count];
bool has_been_set;
bool has_been_set = false;
bool is_pixel;
protected:
CachedShaderSetting(const char *name, bool is_pixel) :
m_name(name), has_been_set(false), is_pixel(is_pixel)
m_name(name), is_pixel(is_pixel)
{}
public:
void set(const T value[count], video::IMaterialRendererServices *services)
@@ -14,15 +14,7 @@

Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
ITextureSource *tsrc):
scene::ISceneNode(parent, mgr, id),
m_visible(true),
m_fallback_bg_color(255, 255, 255, 255),
m_first_update(true),
m_brightness(0.5),
m_cloud_brightness(0.5),
m_bgcolor_bright_f(1, 1, 1, 1),
m_skycolor_bright_f(1, 1, 1, 1),
m_cloudcolor_bright_f(1, 1, 1, 1)
scene::ISceneNode(parent, mgr, id)
{
setAutomaticCulling(scene::EAC_OFF);
m_box.MaxEdge.set(0, 0, 0);
@@ -85,8 +77,6 @@ Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
}

m_directional_colored_fog = g_settings->getBool("directional_colored_fog");

m_clouds_enabled = true;
}


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

if (!camera || !driver)
return;

ScopeProfiler sp(g_profiler, "Sky::render()", SPT_AVG);

// Draw perspective skybox
@@ -138,7 +128,7 @@ void Sky::render()
float moonsize = 0.04;
video::SColorf mooncolor_f(0.50, 0.57, 0.65, 1);
video::SColorf mooncolor2_f(0.85, 0.875, 0.9, 1);

float nightlength = 0.415;
float wn = nightlength / 2;
float wicked_time_of_day = 0;
@@ -181,11 +171,11 @@ void Sky::render()
const f32 o = 0.0f;
static const u16 indices[4] = {0, 1, 2, 3};
video::S3DVertex vertices[4];

driver->setMaterial(m_materials[1]);

video::SColor cloudyfogcolor = m_bgcolor;

// Draw far cloudy fog thing blended with skycolor
for (u32 j = 0; j < 4; j++) {
video::SColor c = cloudyfogcolor.getInterpolated(m_skycolor, 0.45);
@@ -361,7 +351,7 @@ void Sky::render()
vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
}
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);

d = moonsize * 1.3;
c = mooncolor;
c.setAlpha(0.15 * 255);
@@ -466,7 +456,7 @@ void Sky::render()
indices, SKY_STAR_COUNT, video::EVT_STANDARD,
scene::EPT_QUADS, video::EIT_16BIT);
} while(0);

// Draw far cloudy fog thing below east and west horizons
for (u32 j = 0; j < 2; j++) {
video::SColor c = cloudyfogcolor;
@@ -510,7 +500,7 @@ void Sky::update(float time_of_day, float time_brightness,
m_time_of_day = time_of_day;
m_time_brightness = time_brightness;
m_sunlight_seen = sunlight_seen;

bool is_dawn = (time_brightness >= 0.20 && time_brightness < 0.35);

/*
@@ -535,7 +525,7 @@ void Sky::update(float time_of_day, float time_brightness,
video::SColorf skycolor_bright_normal_f = video::SColor(255, 140, 186, 250);
video::SColorf skycolor_bright_dawn_f = video::SColor(255, 180, 186, 250);
video::SColorf skycolor_bright_night_f = video::SColor(255, 0, 107, 255);

// pure white: becomes "diffuse light component" for clouds
video::SColorf cloudcolor_bright_normal_f = video::SColor(255, 255, 255, 255);
// 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,
else
m_brightness = m_brightness * 0.98 + direct_brightness * 0.02;
}

m_clouds_visible = true;
float color_change_fraction = 0.98;
if (sunlight_seen) {
@@ -117,25 +117,25 @@ class Sky : public scene::ISceneNode
return result;
}

bool m_visible;
video::SColor m_fallback_bg_color; // Used when m_visible=false
bool m_first_update;
bool m_visible = true;
// Used when m_visible=false
video::SColor m_fallback_bg_color = video::SColor(255, 255, 255, 255);
bool m_first_update = true;
float m_time_of_day;
float m_time_brightness;
bool m_sunlight_seen;
float m_brightness;
float m_cloud_brightness;
float m_brightness = 0.5f;
float m_cloud_brightness = 0.5f;
bool m_clouds_visible; // Whether clouds are disabled due to player underground
bool m_clouds_enabled; // Initialised to true, reset only by set_sky API
bool m_clouds_enabled = true; // Initialised to true, reset only by set_sky API
bool m_directional_colored_fog;
video::SColorf m_bgcolor_bright_f;
video::SColorf m_skycolor_bright_f;
video::SColorf m_cloudcolor_bright_f;
video::SColorf m_bgcolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
video::SColorf m_skycolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
video::SColorf m_cloudcolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
video::SColor m_bgcolor;
video::SColor m_skycolor;
video::SColorf m_cloudcolor_f;
v3f m_stars[SKY_STAR_COUNT];
video::S3DVertex m_star_vertices[SKY_STAR_COUNT * 4];
video::ITexture *m_sun_texture;
video::ITexture *m_moon_texture;
video::ITexture *m_sun_tonemap;
@@ -90,9 +90,7 @@ void sockets_cleanup()

Address::Address()
{
m_addr_family = 0;
memset(&m_address, 0, sizeof(m_address));
m_port = 0;
}

Address::Address(u32 address, u16 port)
@@ -103,13 +103,13 @@ class Address
void print(std::ostream *s) const;
std::string serializeString() const;
private:
unsigned int m_addr_family;
unsigned int m_addr_family = 0;
union
{
struct sockaddr_in ipv4;
struct sockaddr_in6 ipv6;
} m_address;
u16 m_port; // Port is separate from sockaddr structures
u16 m_port = 0; // Port is separate from sockaddr structures
};

class UDPSocket
@@ -29,15 +29,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,

struct StaticObject
{
u8 type;
u8 type = 0;
v3f pos;
std::string data;

StaticObject():
type(0),
pos(0,0,0)
{
}
StaticObject() {}
StaticObject(u8 type_, v3f pos_, const std::string &data_):
type(type_),
pos(pos_),
@@ -88,7 +84,7 @@ class StaticObjectList

void serialize(std::ostream &os);
void deSerialize(std::istream &is);

/*
NOTE: When an object is transformed to active, it is removed
from m_stored and inserted to m_active.
@@ -26,8 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,

class Settings;

#define WORLDNAME_BLACKLISTED_CHARS "/\\"

struct SubgameSpec
{
std::string id; // "" = game does not exist
@@ -37,15 +35,15 @@ struct SubgameSpec
std::string name;
std::string menuicon_path;

SubgameSpec(const std::string &id_="",
const std::string &path_="",
const std::string &gamemods_path_="",
const std::set<std::string> &addon_mods_paths_=std::set<std::string>(),
const std::string &name_="",
const std::string &menuicon_path_=""):
SubgameSpec(const std::string &id_ = "",
const std::string &path_ = "",
const std::string &gamemods_path_ = "",
const std::set<std::string> &addon_mods_paths_ = std::set<std::string>(),
const std::string &name_ = "",
const std::string &menuicon_path_ = ""):
id(id_),
path(path_),
gamemods_path(gamemods_path_),
gamemods_path(gamemods_path_),
addon_mods_paths(addon_mods_paths_),
name(name_),
menuicon_path(menuicon_path_)
Oops, something went wrong.

0 comments on commit 1425c6d

Please sign in to comment.
You can’t perform that action at this time.