aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-06-21 11:51:29 +0200
committerGitHub <noreply@github.com>2017-06-21 11:51:29 +0200
commit1425c6def156840b359b90b4f32b9c7b8f005731 (patch)
tree0390ed5ad9bcf481416061446f859b3f48955422
parent12aad731adef495dec03f384d10b4f8f57b6a1d3 (diff)
downloadminetest-1425c6def156840b359b90b4f32b9c7b8f005731.tar.gz
minetest-1425c6def156840b359b90b4f32b9c7b8f005731.tar.bz2
minetest-1425c6def156840b359b90b4f32b9c7b8f005731.zip
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
-rw-r--r--src/serverobject.cpp7
-rw-r--r--src/serverobject.h10
-rw-r--r--src/settings.h15
-rw-r--r--src/shader.h21
-rw-r--r--src/sky.cpp32
-rw-r--r--src/sky.h20
-rw-r--r--src/socket.cpp2
-rw-r--r--src/socket.h4
-rw-r--r--src/staticobject.h10
-rw-r--r--src/subgame.h16
-rw-r--r--src/terminal_chat_console.h22
-rw-r--r--src/tool.h23
-rw-r--r--src/touchscreengui.cpp22
-rw-r--r--src/touchscreengui.h36
-rw-r--r--src/voxel.cpp8
-rw-r--r--src/voxel.h41
-rw-r--r--src/voxelalgorithms.cpp9
-rw-r--r--src/voxelalgorithms.h6
-rw-r--r--src/wieldmesh.cpp34
-rw-r--r--src/wieldmesh.h16
20 files changed, 129 insertions, 225 deletions
diff --git a/src/serverobject.cpp b/src/serverobject.cpp
index 191247829..f477700dd 100644
--- a/src/serverobject.cpp
+++ b/src/serverobject.cpp
@@ -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();
diff --git a/src/serverobject.h b/src/serverobject.h
index 3041910d1..cd1922c87 100644
--- a/src/serverobject.h
+++ b/src/serverobject.h
@@ -204,7 +204,7 @@ public:
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 @@ public:
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 @@ public:
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
diff --git a/src/settings.h b/src/settings.h
index d1edca6b6..c4b94d67d 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -73,15 +73,10 @@ 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_) :
@@ -89,9 +84,9 @@ struct SettingsEntry {
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;
diff --git a/src/shader.h b/src/shader.h
index 4d31f705f..979318c95 100644
--- a/src/shader.h
+++ b/src/shader.h
@@ -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)
diff --git a/src/sky.cpp b/src/sky.cpp
index b739fe1ad..3176ea936 100644
--- a/src/sky.cpp
+++ b/src/sky.cpp
@@ -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) {
diff --git a/src/sky.h b/src/sky.h
index a014a920b..1fa25bd93 100644
--- a/src/sky.h
+++ b/src/sky.h
@@ -117,25 +117,25 @@ private:
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;
diff --git a/src/socket.cpp b/src/socket.cpp
index 17fa1924d..d0ab16cab 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -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)
diff --git a/src/socket.h b/src/socket.h
index 8d1ad70ff..77ce31921 100644
--- a/src/socket.h
+++ b/src/socket.h
@@ -103,13 +103,13 @@ public:
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
diff --git a/src/staticobject.h b/src/staticobject.h
index 208fb2cc8..fb73befd3 100644
--- a/src/staticobject.h
+++ b/src/staticobject.h
@@ -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 @@ public:
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.
diff --git a/src/subgame.h b/src/subgame.h
index f3633ce2f..dda249a98 100644
--- a/src/subgame.h
+++ b/src/subgame.h
@@ -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_)
diff --git a/src/terminal_chat_console.h b/src/terminal_chat_console.h
index 2111b7ecb..8f6abe295 100644
--- a/src/terminal_chat_console.h
+++ b/src/terminal_chat_console.h
@@ -52,13 +52,7 @@ class TerminalChatConsole : public Thread {
public:
TerminalChatConsole() :
- Thread("TerminalThread"),
- m_log_level(LL_ACTION),
- m_utf8_bytes_to_wait(0),
- m_kill_requested(NULL),
- m_esc_mode(false),
- m_game_time(0),
- m_time_of_day(0)
+ Thread("TerminalThread")
{}
void setup(
@@ -74,7 +68,7 @@ public:
virtual void *run();
// Highly required!
- void clearKillStatus() { m_kill_requested = NULL; }
+ void clearKillStatus() { m_kill_requested = nullptr; }
void stopAndWaitforThread();
@@ -102,10 +96,10 @@ private:
~CursesInitHelper() { cons->deInitOfCurses(); }
};
- int m_log_level;
+ int m_log_level = LL_ACTION;
std::string m_nick;
- u8 m_utf8_bytes_to_wait;
+ u8 m_utf8_bytes_to_wait = 0;
std::string m_pending_utf8_bytes;
std::list<std::string> m_nicks;
@@ -114,16 +108,16 @@ private:
int m_rows;
bool m_can_draw_text;
- bool *m_kill_requested;
+ bool *m_kill_requested = nullptr;
ChatBackend m_chat_backend;
ChatInterface *m_chat_interface;
TermLogOutput m_log_output;
- bool m_esc_mode;
+ bool m_esc_mode = false;
- u64 m_game_time;
- u32 m_time_of_day;
+ u64 m_game_time = 0;
+ u32 m_time_of_day = 0;
};
extern TerminalChatConsole g_term_console;
diff --git a/src/tool.h b/src/tool.h
index 083328d06..67631fe79 100644
--- a/src/tool.h
+++ b/src/tool.h
@@ -28,13 +28,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
struct ToolGroupCap
{
std::unordered_map<int, float> times;
- int maxlevel;
- int uses;
+ int maxlevel = 1;
+ int uses = 20;
- ToolGroupCap():
- maxlevel(1),
- uses(20)
- {}
+ ToolGroupCap() {}
bool getTime(int rating, float *time) const
{
@@ -118,15 +115,11 @@ HitParams getHitParams(const ItemGroupList &armor_groups,
struct PunchDamageResult
{
- bool did_punch;
- int damage;
- int wear;
-
- PunchDamageResult():
- did_punch(false),
- damage(0),
- wear(0)
- {}
+ bool did_punch = false;
+ int damage = 0;
+ int wear = 0;
+
+ PunchDamageResult() {}
};
struct ItemStack;
diff --git a/src/touchscreengui.cpp b/src/touchscreengui.cpp
index 0139b8c4f..9a1ef4086 100644
--- a/src/touchscreengui.cpp
+++ b/src/touchscreengui.cpp
@@ -130,19 +130,10 @@ static void load_button_texture(button_info* btn, const char* path,
AutoHideButtonBar::AutoHideButtonBar(IrrlichtDevice *device,
IEventReceiver* receiver) :
- m_texturesource(NULL),
m_driver(device->getVideoDriver()),
m_guienv(device->getGUIEnvironment()),
- m_receiver(receiver),
- m_active(false),
- m_visible(true),
- m_timeout(0),
- m_timeout_value(3),
- m_initialized(false),
- m_dir(AHBB_Dir_Right_Left)
+ m_receiver(receiver)
{
- m_screensize = device->getVideoDriver()->getScreenSize();
-
}
void AutoHideButtonBar::init(ISimpleTextureSource* tsrc,
@@ -416,16 +407,7 @@ void AutoHideButtonBar::show()
TouchScreenGUI::TouchScreenGUI(IrrlichtDevice *device, IEventReceiver* receiver):
m_device(device),
m_guienv(device->getGUIEnvironment()),
- m_camera_yaw_change(0.0),
- m_camera_pitch(0.0),
- m_visible(false),
- m_move_id(-1),
m_receiver(receiver),
- m_move_has_really_moved(false),
- m_move_downtime(0),
- m_move_sent_as_mouse_event(false),
- // use some downlocation way off screen as init value to avoid invalid behaviour
- m_move_downlocation(v2s32(-10000, -10000)),
m_settingsbar(device, receiver),
m_rarecontrolsbar(device, receiver)
{
@@ -474,8 +456,6 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
u32 button_size = getGuiButtonSize();
m_visible = true;
m_texturesource = tsrc;
- m_control_pad_rect = rect<s32>(0, m_screensize.Y - 3 * button_size,
- 3 * button_size, m_screensize.Y);
/*
draw control pad
0 1 2
diff --git a/src/touchscreengui.h b/src/touchscreengui.h
index a8c59fa9a..7d3e4e83b 100644
--- a/src/touchscreengui.h
+++ b/src/touchscreengui.h
@@ -76,7 +76,7 @@ struct button_info
float repeatdelay;
irr::EKEY_CODE keycode;
std::vector<int> ids;
- IGUIButton *guibutton = NULL;
+ IGUIButton *guibutton = nullptr;
bool immediate_release;
};
@@ -114,11 +114,10 @@ public:
void show();
private:
- ISimpleTextureSource *m_texturesource;
+ ISimpleTextureSource *m_texturesource = nullptr;
irr::video::IVideoDriver *m_driver;
IGUIEnvironment *m_guienv;
IEventReceiver *m_receiver;
- v2u32 m_screensize;
button_info m_starter;
std::vector<button_info *> m_buttons;
@@ -126,15 +125,15 @@ private:
v2s32 m_lower_right;
/* show settings bar */
- bool m_active;
+ bool m_active = false;
- bool m_visible;
+ bool m_visible = true;
/* settings bar timeout */
- float m_timeout;
- float m_timeout_value;
- bool m_initialized;
- autohide_button_bar_dir m_dir;
+ float m_timeout = 0.0f;
+ float m_timeout_value = 3.0f;
+ bool m_initialized = false;
+ autohide_button_bar_dir m_dir = AHBB_Dir_Right_Left;
};
class TouchScreenGUI
@@ -177,18 +176,16 @@ private:
bool m_visible; // is the gui visible
/* value in degree */
- double m_camera_yaw_change;
- double m_camera_pitch;
+ double m_camera_yaw_change = 0.0;
+ double m_camera_pitch = 0.0;
line3d<f32> m_shootline;
- rect<s32> m_control_pad_rect;
-
- int m_move_id;
- bool m_move_has_really_moved;
- s64 m_move_downtime;
- bool m_move_sent_as_mouse_event;
- v2s32 m_move_downlocation;
+ int m_move_id = -1;
+ bool m_move_has_really_moved = false;
+ s64 m_move_downtime = 0;
+ bool m_move_sent_as_mouse_event = false;
+ v2s32 m_move_downlocation = v2s32(-10000, -10000);
button_info m_buttons[after_last_element_id];
@@ -206,9 +203,6 @@ private:
std::wstring caption, bool immediate_release,
float repeat_delay = BUTTON_REPEAT_DELAY);
- /* load texture */
- void loadButtonTexture(button_info *btn, const char *path, rect<s32> button_rect);
-
struct id_status
{
int id;
diff --git a/src/voxel.cpp b/src/voxel.cpp
index 78efde5bb..08765c98e 100644
--- a/src/voxel.cpp
+++ b/src/voxel.cpp
@@ -33,9 +33,7 @@ u64 emerge_load_time = 0;
u64 clearflag_time = 0;
-VoxelManipulator::VoxelManipulator():
- m_data(NULL),
- m_flags(NULL)
+VoxelManipulator::VoxelManipulator()
{
}
@@ -49,9 +47,9 @@ void VoxelManipulator::clear()
// Reset area to volume=0
m_area = VoxelArea();
delete[] m_data;
- m_data = NULL;
+ m_data = nullptr;
delete[] m_flags;
- m_flags = NULL;
+ m_flags = nullptr;
}
void VoxelManipulator::print(std::ostream &o, INodeDefManager *ndef,
diff --git a/src/voxel.h b/src/voxel.h
index 3a64ccc79..8a7ad30ae 100644
--- a/src/voxel.h
+++ b/src/voxel.h
@@ -60,11 +60,8 @@ class VoxelArea
{
public:
// Starts as zero sized
- VoxelArea():
- MinEdge(1,1,1),
- MaxEdge(0,0,0)
- {
- }
+ VoxelArea() {}
+
VoxelArea(v3s16 min_edge, v3s16 max_edge):
MinEdge(min_edge),
MaxEdge(max_edge)
@@ -325,22 +322,22 @@ public:
}
// Edges are inclusive
- v3s16 MinEdge;
+ v3s16 MinEdge = v3s16(1,1,1);
v3s16 MaxEdge;
};
-// unused
-#define VOXELFLAG_UNUSED (1<<0)
+// unused
+#define VOXELFLAG_UNUSED (1 << 0)
// no data about that node
-#define VOXELFLAG_NO_DATA (1<<1)
+#define VOXELFLAG_NO_DATA (1 << 1)
// Algorithm-dependent
-#define VOXELFLAG_CHECKED1 (1<<2)
+#define VOXELFLAG_CHECKED1 (1 << 2)
// Algorithm-dependent
-#define VOXELFLAG_CHECKED2 (1<<3)
+#define VOXELFLAG_CHECKED2 (1 << 3)
// Algorithm-dependent
-#define VOXELFLAG_CHECKED3 (1<<4)
+#define VOXELFLAG_CHECKED3 (1 << 4)
// Algorithm-dependent
-#define VOXELFLAG_CHECKED4 (1<<5)
+#define VOXELFLAG_CHECKED4 (1 << 5)
enum VoxelPrintMode
{
@@ -570,29 +567,17 @@ public:
VoxelArea m_area;
/*
- NULL if data size is 0 (extent (0,0,0))
+ nullptr if data size is 0 (extent (0,0,0))
Data is stored as [z*h*w + y*h + x]
*/
- MapNode *m_data;
+ MapNode *m_data = nullptr;
/*
Flags of all nodes
*/
- u8 *m_flags;
+ u8 *m_flags = nullptr;
static const MapNode ContentIgnoreNode;
-
- //TODO: Use these or remove them
- //TODO: Would these make any speed improvement?
- //bool m_pressure_route_valid;
- //v3s16 m_pressure_route_surface;
-
- /*
- Some settings
- */
- //bool m_disable_water_climb;
-
-private:
};
#endif
diff --git a/src/voxelalgorithms.cpp b/src/voxelalgorithms.cpp
index 40f8595a7..cea339557 100644
--- a/src/voxelalgorithms.cpp
+++ b/src/voxelalgorithms.cpp
@@ -1402,14 +1402,9 @@ void repair_block_light(ServerMap *map, MapBlock *block,
modified_blocks);
}
-VoxelLineIterator::VoxelLineIterator(
- const v3f &start_position,
- const v3f &line_vector) :
+VoxelLineIterator::VoxelLineIterator(const v3f &start_position, const v3f &line_vector) :
m_start_position(start_position),
- m_line_vector(line_vector),
- m_next_intersection_multi(10000.0f, 10000.0f, 10000.0f),
- m_intersection_multi_inc(10000.0f, 10000.0f, 10000.0f),
- m_step_directions(1.0f, 1.0f, 1.0f)
+ m_line_vector(line_vector)
{
m_current_node_pos = floatToInt(m_start_position, 1);
diff --git a/src/voxelalgorithms.h b/src/voxelalgorithms.h
index 699624612..6e5fd5253 100644
--- a/src/voxelalgorithms.h
+++ b/src/voxelalgorithms.h
@@ -123,17 +123,17 @@ public:
* which multiplying the line's vector gives a vector that ends
* on the intersection of two nodes.
*/
- v3f m_next_intersection_multi;
+ v3f m_next_intersection_multi = v3f(10000.0f, 10000.0f, 10000.0f);
/*!
* Each component stores the smallest positive number, by which
* m_next_intersection_multi's components can be increased.
*/
- v3f m_intersection_multi_inc;
+ v3f m_intersection_multi_inc = v3f(10000.0f, 10000.0f, 10000.0f);
/*!
* Direction of the line. Each component can be -1 or 1 (if a
* component of the line's vector is 0, then there will be 1).
*/
- v3s16 m_step_directions;
+ v3s16 m_step_directions = v3s16(1, 1, 1);
//! Position of the current node.
v3s16 m_current_node_pos;
//! If true, the next node will intersect the line, too.
diff --git a/src/wieldmesh.cpp b/src/wieldmesh.cpp
index 7736ec2a2..7da030df4 100644
--- a/src/wieldmesh.cpp
+++ b/src/wieldmesh.cpp
@@ -199,10 +199,8 @@ WieldMeshSceneNode::WieldMeshSceneNode(
bool lighting
):
scene::ISceneNode(parent, mgr, id),
- m_meshnode(NULL),
m_material_type(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF),
- m_lighting(lighting),
- m_bounding_box(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
+ m_lighting(lighting)
{
m_enable_shaders = g_settings->getBool("enable_shaders");
m_anisotropic_filter = g_settings->getBool("anisotropic_filter");
@@ -211,7 +209,7 @@ WieldMeshSceneNode::WieldMeshSceneNode(
// If this is the first wield mesh scene node, create a cache
// for extrusion meshes (and a cube mesh), otherwise reuse it
- if (g_extrusion_mesh_cache == NULL)
+ if (!g_extrusion_mesh_cache)
g_extrusion_mesh_cache = new ExtrusionMeshCache();
else
g_extrusion_mesh_cache->grab();
@@ -232,11 +230,11 @@ WieldMeshSceneNode::~WieldMeshSceneNode()
{
sanity_check(g_extrusion_mesh_cache);
if (g_extrusion_mesh_cache->drop())
- g_extrusion_mesh_cache = NULL;
+ g_extrusion_mesh_cache = nullptr;
}
void WieldMeshSceneNode::setCube(const ContentFeatures &f,
- v3f wield_scale, ITextureSource *tsrc)
+ v3f wield_scale)
{
scene::IMesh *cubemesh = g_extrusion_mesh_cache->createCube();
scene::SMesh *copy = cloneMesh(cubemesh);
@@ -252,7 +250,7 @@ void WieldMeshSceneNode::setExtruded(const std::string &imagename,
{
video::ITexture *texture = tsrc->getTexture(imagename);
if (!texture) {
- changeToMesh(NULL);
+ changeToMesh(nullptr);
return;
}
@@ -335,13 +333,13 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client)
def.wield_scale * WIELD_SCALE_FACTOR
/ (BS * f.visual_scale));
} else if (f.drawtype == NDT_AIRLIKE) {
- changeToMesh(NULL);
+ changeToMesh(nullptr);
} else if (f.drawtype == NDT_PLANTLIKE) {
setExtruded(tsrc->getTextureName(f.tiles[0].layers[0].texture_id),
def.wield_scale, tsrc,
f.tiles[0].layers[0].animation_frame_count);
} else if (f.drawtype == NDT_NORMAL || f.drawtype == NDT_ALLFACES) {
- setCube(f, def.wield_scale, tsrc);
+ setCube(f, def.wield_scale);
} else {
MeshMakeData mesh_make_data(client, false);
MapNode mesh_make_node(id, 255, 0);
@@ -373,14 +371,14 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client)
}
// no wield mesh found
- changeToMesh(NULL);
+ changeToMesh(nullptr);
}
void WieldMeshSceneNode::setColor(video::SColor c)
{
assert(!m_lighting);
- scene::IMesh *mesh=m_meshnode->getMesh();
- if (mesh == NULL)
+ scene::IMesh *mesh = m_meshnode->getMesh();
+ if (!mesh)
return;
u8 red = c.getRed();
@@ -408,7 +406,7 @@ void WieldMeshSceneNode::render()
void WieldMeshSceneNode::changeToMesh(scene::IMesh *mesh)
{
- if (mesh == NULL) {
+ if (!mesh) {
scene::IMesh *dummymesh = g_extrusion_mesh_cache->createCube();
m_meshnode->setVisible(false);
m_meshnode->setMesh(dummymesh);
@@ -438,7 +436,7 @@ void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result)
g_extrusion_mesh_cache->grab();
}
- scene::SMesh *mesh = NULL;
+ scene::SMesh *mesh = nullptr;
// Shading is on by default
result->needs_shading = true;
@@ -499,20 +497,18 @@ void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result)
rotateMeshXZby(mesh, -45);
rotateMeshYZby(mesh, -30);
- postProcessNodeMesh(mesh, f, false, false, NULL,
- &result->buffer_colors);
+ postProcessNodeMesh(mesh, f, false, false, nullptr, &result->buffer_colors);
}
result->mesh = mesh;
}
-scene::SMesh * getExtrudedMesh(ITextureSource *tsrc,
- const std::string &imagename)
+scene::SMesh *getExtrudedMesh(ITextureSource *tsrc, const std::string &imagename)
{
video::ITexture *texture = tsrc->getTextureForMesh(imagename);
if (!texture) {
- return NULL;
+ return nullptr;
}
core::dimension2d<u32> dim = texture->getSize();
diff --git a/src/wieldmesh.h b/src/wieldmesh.h
index faedce484..8ef155dfd 100644
--- a/src/wieldmesh.h
+++ b/src/wieldmesh.h
@@ -38,13 +38,13 @@ struct ItemPartColor
* will be used instead of the specific color of the
* buffer.
*/
- bool override_base;
+ bool override_base = false;
/*!
* The color of the buffer.
*/
- video::SColor color;
+ video::SColor color = 0;
- ItemPartColor() : override_base(false), color(0) {}
+ ItemPartColor() {}
ItemPartColor(bool override, video::SColor color)
: override_base(override), color(color)
@@ -54,7 +54,7 @@ struct ItemPartColor
struct ItemMesh
{
- scene::IMesh *mesh;
+ scene::IMesh *mesh = nullptr;
/*!
* Stores the color of each mesh buffer.
*/
@@ -63,9 +63,9 @@ struct ItemMesh
* If false, all faces of the item should have the same brightness.
* Disables shading based on normal vectors.
*/
- bool needs_shading;
+ bool needs_shading = true;
- ItemMesh() : mesh(NULL), buffer_colors(), needs_shading(true) {}
+ ItemMesh() {}
};
/*
@@ -78,7 +78,7 @@ public:
s32 id = -1, bool lighting = false);
virtual ~WieldMeshSceneNode();
- void setCube(const ContentFeatures &f, v3f wield_scale, ITextureSource *tsrc);
+ void setCube(const ContentFeatures &f, v3f wield_scale);
void setExtruded(const std::string &imagename, v3f wield_scale,
ITextureSource *tsrc, u8 num_frames);
void setItem(const ItemStack &item, Client *client);
@@ -97,7 +97,7 @@ private:
void changeToMesh(scene::IMesh *mesh);
// Child scene node with the current wield mesh
- scene::IMeshSceneNode *m_meshnode;
+ scene::IMeshSceneNode *m_meshnode = nullptr;
video::E_MATERIAL_TYPE m_material_type;
// True if EMF_LIGHTING should be enabled.