Cpp11 patchset 11: continue working on constructor style migration (#6004)

This commit is contained in:
Loïc Blot 2017-06-18 19:55:15 +02:00 committed by GitHub
parent 8f7785771b
commit 4faaadc8d5
39 changed files with 200 additions and 396 deletions

@ -28,14 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
CachedMapBlockData CachedMapBlockData
*/ */
CachedMapBlockData::CachedMapBlockData():
p(-1337,-1337,-1337),
data(NULL),
refcount_from_queue(0),
last_used_timestamp(time(0))
{
}
CachedMapBlockData::~CachedMapBlockData() CachedMapBlockData::~CachedMapBlockData()
{ {
assert(refcount_from_queue == 0); assert(refcount_from_queue == 0);
@ -47,16 +39,6 @@ CachedMapBlockData::~CachedMapBlockData()
QueuedMeshUpdate 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() QueuedMeshUpdate::~QueuedMeshUpdate()
{ {
delete data; delete data;

@ -27,25 +27,25 @@ with this program; if not, write to the Free Software Foundation, Inc.,
struct CachedMapBlockData struct CachedMapBlockData
{ {
v3s16 p; v3s16 p = v3s16(-1337, -1337, -1337);
MapNode *data; // A copy of the MapBlock's data member MapNode *data = nullptr; // A copy of the MapBlock's data member
int refcount_from_queue; int refcount_from_queue = 0;
int last_used_timestamp; int last_used_timestamp = std::time(0);
CachedMapBlockData(); CachedMapBlockData() {}
~CachedMapBlockData(); ~CachedMapBlockData();
}; };
struct QueuedMeshUpdate struct QueuedMeshUpdate
{ {
v3s16 p; v3s16 p = v3s16(-1337, -1337, -1337);
bool ack_block_to_server; bool ack_block_to_server = false;
bool urgent; bool urgent = false;
int crack_level; int crack_level = -1;
v3s16 crack_pos; v3s16 crack_pos;
MeshMakeData *data; // This is generated in MeshUpdateQueue::pop() MeshMakeData *data = nullptr; // This is generated in MeshUpdateQueue::pop()
QueuedMeshUpdate(); QueuedMeshUpdate(){};
~QueuedMeshUpdate(); ~QueuedMeshUpdate();
}; };
@ -101,14 +101,11 @@ private:
struct MeshUpdateResult struct MeshUpdateResult
{ {
v3s16 p; v3s16 p = v3s16(-1338, -1338, -1338);
MapBlockMesh *mesh; MapBlockMesh *mesh = nullptr;
bool ack_block_to_server; bool ack_block_to_server = false;
MeshUpdateResult() MeshUpdateResult() {}
: p(-1338, -1338, -1338), mesh(NULL), ack_block_to_server(false)
{
}
}; };
class MeshUpdateThread : public UpdateThread class MeshUpdateThread : public UpdateThread

@ -117,10 +117,10 @@ public:
virtual Biome *getBiomeAtIndex(size_t index, s16 y) const = 0; virtual Biome *getBiomeAtIndex(size_t index, s16 y) const = 0;
// Result of calcBiomes bulk computation. // Result of calcBiomes bulk computation.
biome_t *biomemap; biome_t *biomemap = nullptr;
protected: protected:
BiomeManager *m_bmgr; BiomeManager *m_bmgr = nullptr;
v3s16 m_pmin; v3s16 m_pmin;
v3s16 m_csize; v3s16 m_csize;
}; };

@ -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() void Decoration::resolveNodeNames()
{ {
getIdsFromNrBacklog(&c_place_on); getIdsFromNrBacklog(&c_place_on);
@ -330,13 +315,6 @@ int DecoSimple::getHeight()
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
DecoSchematic::DecoSchematic()
{
schematic = NULL;
}
size_t DecoSchematic::generate(MMVManip *vm, PcgRandom *pr, v3s16 p) size_t DecoSchematic::generate(MMVManip *vm, PcgRandom *pr, v3s16 p)
{ {
// Schematic could have been unloaded but not the decoration // Schematic could have been unloaded but not the decoration

@ -64,8 +64,8 @@ struct CutoffData {
class Decoration : public ObjDef, public NodeResolver { class Decoration : public ObjDef, public NodeResolver {
public: public:
Decoration(); Decoration() {};
virtual ~Decoration(); virtual ~Decoration() {};
virtual void resolveNodeNames(); virtual void resolveNodeNames();
@ -76,13 +76,13 @@ public:
virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p) = 0; virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p) = 0;
virtual int getHeight() = 0; virtual int getHeight() = 0;
u32 flags; u32 flags = 0;
int mapseed; int mapseed = 0;
std::vector<content_t> c_place_on; std::vector<content_t> c_place_on;
s16 sidelen; s16 sidelen = 1;
s16 y_min; s16 y_min;
s16 y_max; s16 y_max;
float fill_ratio; float fill_ratio = 0.0f;
NoiseParams np; NoiseParams np;
std::vector<content_t> c_spawnby; std::vector<content_t> c_spawnby;
s16 nspawnby; s16 nspawnby;
@ -104,13 +104,13 @@ public:
class DecoSchematic : public Decoration { class DecoSchematic : public Decoration {
public: public:
DecoSchematic(); DecoSchematic() {};
virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p); virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p);
virtual int getHeight(); virtual int getHeight();
Rotation rotation; Rotation rotation;
Schematic *schematic; Schematic *schematic = nullptr;
}; };

@ -72,14 +72,6 @@ void OreManager::clear()
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
Ore::Ore()
{
flags = 0;
noise = NULL;
}
Ore::~Ore() Ore::~Ore()
{ {
delete noise; delete noise;
@ -232,8 +224,6 @@ void OreSheet::generate(MMVManip *vm, int mapseed, u32 blockseed,
OrePuff::OrePuff() : OrePuff::OrePuff() :
Ore() Ore()
{ {
noise_puff_top = NULL;
noise_puff_bottom = NULL;
} }
@ -385,7 +375,6 @@ void OreBlob::generate(MMVManip *vm, int mapseed, u32 blockseed,
OreVein::OreVein() : OreVein::OreVein() :
Ore() Ore()
{ {
noise2 = NULL;
} }

@ -62,13 +62,13 @@ public:
s16 y_min; s16 y_min;
s16 y_max; s16 y_max;
u8 ore_param2; // to set node-specific attributes 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 float nthresh; // threshold for noise at which an ore is placed
NoiseParams np; // noise for distribution of clusters (NULL for uniform scattering) NoiseParams np; // noise for distribution of clusters (NULL for uniform scattering)
Noise *noise; Noise *noise = nullptr;
std::unordered_set<u8> biomes; std::unordered_set<u8> biomes;
Ore(); Ore() {};
virtual ~Ore(); virtual ~Ore();
virtual void resolveNodeNames(); virtual void resolveNodeNames();
@ -104,8 +104,8 @@ public:
NoiseParams np_puff_top; NoiseParams np_puff_top;
NoiseParams np_puff_bottom; NoiseParams np_puff_bottom;
Noise *noise_puff_top; Noise *noise_puff_top = nullptr;
Noise *noise_puff_bottom; Noise *noise_puff_bottom = nullptr;
OrePuff(); OrePuff();
virtual ~OrePuff(); virtual ~OrePuff();
@ -127,7 +127,7 @@ public:
static const bool NEEDS_NOISE = true; static const bool NEEDS_NOISE = true;
float random_factor; float random_factor;
Noise *noise2; Noise *noise2 = nullptr;
OreVein(); OreVein();
virtual ~OreVein(); virtual ~OreVein();
@ -160,7 +160,7 @@ public:
case ORE_VEIN: case ORE_VEIN:
return new OreVein; return new OreVein;
default: default:
return NULL; return nullptr;
} }
} }

@ -37,9 +37,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
SchematicManager::SchematicManager(Server *server) : SchematicManager::SchematicManager(Server *server) :
ObjDefManager(server, OBJDEF_SCHEMATIC) ObjDefManager(server, OBJDEF_SCHEMATIC),
m_server(server)
{ {
m_server = server;
} }
@ -69,10 +69,6 @@ void SchematicManager::clear()
Schematic::Schematic() Schematic::Schematic()
{ {
schemdata = NULL;
slice_probs = NULL;
flags = 0;
size = v3s16(0, 0, 0);
} }

@ -117,10 +117,10 @@ public:
std::vector<std::pair<s16, u8> > *splist); std::vector<std::pair<s16, u8> > *splist);
std::vector<content_t> c_nodes; std::vector<content_t> c_nodes;
u32 flags; u32 flags = 0;
v3s16 size; v3s16 size;
MapNode *schemdata; MapNode *schemdata = nullptr;
u8 *slice_probs; u8 *slice_probs = nullptr;
}; };
class SchematicManager : public ObjDefManager { class SchematicManager : public ObjDefManager {

@ -204,8 +204,6 @@ Minimap::Minimap(IrrlichtDevice *device, Client *client)
data->mode = MINIMAP_MODE_OFF; data->mode = MINIMAP_MODE_OFF;
data->is_radar = false; data->is_radar = false;
data->map_invalidated = true; data->map_invalidated = true;
data->heightmap_image = NULL;
data->minimap_image = NULL;
data->texture = NULL; data->texture = NULL;
data->heightmap_texture = NULL; data->heightmap_texture = NULL;
data->minimap_shape_round = g_settings->getBool("minimap_shape_round"); data->minimap_shape_round = g_settings->getBool("minimap_shape_round");

@ -78,21 +78,19 @@ struct MinimapData {
MinimapPixel minimap_scan[MINIMAP_MAX_SX * MINIMAP_MAX_SY]; MinimapPixel minimap_scan[MINIMAP_MAX_SX * MINIMAP_MAX_SY];
bool map_invalidated; bool map_invalidated;
bool minimap_shape_round; bool minimap_shape_round;
video::IImage *minimap_image; video::IImage *minimap_mask_round = nullptr;
video::IImage *heightmap_image; video::IImage *minimap_mask_square = nullptr;
video::IImage *minimap_mask_round; video::ITexture *texture = nullptr;
video::IImage *minimap_mask_square; video::ITexture *heightmap_texture = nullptr;
video::ITexture *texture; video::ITexture *minimap_overlay_round = nullptr;
video::ITexture *heightmap_texture; video::ITexture *minimap_overlay_square = nullptr;
video::ITexture *minimap_overlay_round; video::ITexture *player_marker = nullptr;
video::ITexture *minimap_overlay_square; video::ITexture *object_marker_red = nullptr;
video::ITexture *player_marker;
video::ITexture *object_marker_red;
}; };
struct QueuedMinimapUpdate { struct QueuedMinimapUpdate {
v3s16 pos; v3s16 pos;
MinimapMapblock *data; MinimapMapblock *data = nullptr;
}; };
class MinimapUpdateThread : public UpdateThread { class MinimapUpdateThread : public UpdateThread {
@ -105,7 +103,7 @@ public:
bool pushBlockUpdate(v3s16 pos, MinimapMapblock *data); bool pushBlockUpdate(v3s16 pos, MinimapMapblock *data);
bool popBlockUpdate(QueuedMinimapUpdate *update); bool popBlockUpdate(QueuedMinimapUpdate *update);
MinimapData *data; MinimapData *data = nullptr;
protected: protected:
virtual void doUpdate(); virtual void doUpdate();

@ -48,11 +48,7 @@ public:
IGUIElement(gui::EGUIET_ELEMENT, env, parent, id, IGUIElement(gui::EGUIET_ELEMENT, env, parent, id,
core::rect<s32>(0,0,100,100)) core::rect<s32>(0,0,100,100))
{ {
//m_force_regenerate_gui = false;
m_menumgr = menumgr; m_menumgr = menumgr;
m_allow_focus_removal = false;
m_screensize_old = v2u32(0,0);
setVisible(true); setVisible(true);
Environment->setFocus(this); Environment->setFocus(this);
@ -142,7 +138,7 @@ private:
IMenuManager *m_menumgr; IMenuManager *m_menumgr;
// This might be necessary to expose to the implementation if it // This might be necessary to expose to the implementation if it
// wants to launch other menus // wants to launch other menus
bool m_allow_focus_removal; bool m_allow_focus_removal = false;
}; };

@ -385,10 +385,8 @@ Json::Value getModstoreUrl(const std::string &url)
#endif #endif
ModMetadata::ModMetadata(const std::string &mod_name): ModMetadata::ModMetadata(const std::string &mod_name):
m_mod_name(mod_name), m_mod_name(mod_name)
m_modified(false)
{ {
m_stringvars.clear();
} }
void ModMetadata::clear() void ModMetadata::clear()

@ -42,19 +42,13 @@ struct ModSpec
std::unordered_set<std::string> optdepends; std::unordered_set<std::string> optdepends;
std::unordered_set<std::string> unsatisfied_depends; std::unordered_set<std::string> unsatisfied_depends;
bool part_of_modpack; bool part_of_modpack = false;
bool is_modpack; bool is_modpack = false;
// if modpack: // if modpack:
std::map<std::string,ModSpec> modpack_content; std::map<std::string,ModSpec> modpack_content;
ModSpec(const std::string &name_="", const std::string &path_=""): ModSpec(const std::string &name_="", const std::string &path_=""):
name(name_), name(name_),
path(path_), path(path_)
depends(),
optdepends(),
unsatisfied_depends(),
part_of_modpack(false),
is_modpack(false),
modpack_content()
{} {}
}; };
@ -235,7 +229,7 @@ public:
virtual bool setString(const std::string &name, const std::string &var); virtual bool setString(const std::string &name, const std::string &var);
private: private:
std::string m_mod_name; std::string m_mod_name;
bool m_modified; bool m_modified = false;
}; };
#endif #endif

@ -56,6 +56,7 @@ public:
m_id_to_name.erase(id); m_id_to_name.erase(id);
m_name_to_id.erase(name); m_name_to_id.erase(name);
} }
void eraseName(const std::string &name) void eraseName(const std::string &name)
{ {
u16 id; u16 id;

@ -1923,11 +1923,6 @@ bool CNodeDefManager::nodeboxConnects(MapNode from, MapNode to, u8 connect_face)
NodeResolver::NodeResolver() NodeResolver::NodeResolver()
{ {
m_ndef = NULL;
m_nodenames_idx = 0;
m_nnlistsizes_idx = 0;
m_resolve_done = false;
m_nodenames.reserve(16); m_nodenames.reserve(16);
m_nnlistsizes.reserve(4); m_nnlistsizes.reserve(4);
} }

@ -207,24 +207,18 @@ enum PlantlikeStyle {
struct TileDef struct TileDef
{ {
std::string name; std::string name = "";
bool backface_culling; // Takes effect only in special cases bool backface_culling = true; // Takes effect only in special cases
bool tileable_horizontal; bool tileable_horizontal = true;
bool tileable_vertical; bool tileable_vertical = true;
//! If true, the tile has its own color. //! If true, the tile has its own color.
bool has_color; bool has_color = false;
//! The color of the tile. //! The color of the tile.
video::SColor color; video::SColor color = video::SColor(0xFFFFFFFF);
struct TileAnimationParams animation; struct TileAnimationParams animation;
TileDef() : TileDef()
name(""),
backface_culling(true),
tileable_horizontal(true),
tileable_vertical(true),
has_color(false),
color(video::SColor(0xFFFFFFFF))
{ {
animation.type = TAT_NONE; animation.type = TAT_NONE;
} }
@ -514,12 +508,12 @@ public:
void nodeResolveInternal(); void nodeResolveInternal();
u32 m_nodenames_idx; u32 m_nodenames_idx = 0;
u32 m_nnlistsizes_idx; u32 m_nnlistsizes_idx = 0;
std::vector<std::string> m_nodenames; std::vector<std::string> m_nodenames;
std::vector<size_t> m_nnlistsizes; std::vector<size_t> m_nnlistsizes;
INodeDefManager *m_ndef; INodeDefManager *m_ndef = nullptr;
bool m_resolve_done; bool m_resolve_done = false;
}; };
#endif #endif

@ -36,9 +36,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class NodeTimer class NodeTimer
{ {
public: public:
NodeTimer(): timeout(0.), elapsed(0.) {} NodeTimer() {}
NodeTimer(const v3s16 &position_): NodeTimer(const v3s16 &position_):
timeout(0.), elapsed(0.), position(position_) {} position(position_) {}
NodeTimer(f32 timeout_, f32 elapsed_, v3s16 position_): NodeTimer(f32 timeout_, f32 elapsed_, v3s16 position_):
timeout(timeout_), elapsed(elapsed_), position(position_) {} timeout(timeout_), elapsed(elapsed_), position(position_) {}
~NodeTimer() {} ~NodeTimer() {}
@ -46,8 +46,8 @@ public:
void serialize(std::ostream &os) const; void serialize(std::ostream &os) const;
void deSerialize(std::istream &is); void deSerialize(std::istream &is);
f32 timeout; f32 timeout = 0.0f;
f32 elapsed; f32 elapsed = 0.0f;
v3s16 position; v3s16 position;
}; };
@ -58,7 +58,7 @@ public:
class NodeTimerList class NodeTimerList
{ {
public: public:
NodeTimerList(): m_next_trigger_time(-1.), m_time(0.) {} NodeTimerList() {}
~NodeTimerList() {} ~NodeTimerList() {}
void serialize(std::ostream &os, u8 map_format_version) const; void serialize(std::ostream &os, u8 map_format_version) const;
@ -128,8 +128,8 @@ public:
private: private:
std::multimap<double, NodeTimer> m_timers; std::multimap<double, NodeTimer> m_timers;
std::map<v3s16, std::multimap<double, NodeTimer>::iterator> m_iterators; std::map<v3s16, std::multimap<double, NodeTimer>::iterator> m_iterators;
double m_next_trigger_time; double m_next_trigger_time = -1.0;
double m_time; double m_time = 0.0;
}; };
#endif #endif

@ -433,10 +433,6 @@ Noise::Noise(NoiseParams *np_, s32 seed, u32 sx, u32 sy, u32 sz)
this->sy = sy; this->sy = sy;
this->sz = sz; this->sz = sz;
this->persist_buf = NULL;
this->gradient_buf = NULL;
this->result = NULL;
allocBuffers(); allocBuffers();
} }

@ -102,26 +102,16 @@ private:
#define NOISE_FLAG_SIMPLEX 0x10 #define NOISE_FLAG_SIMPLEX 0x10
struct NoiseParams { struct NoiseParams {
float offset; float offset = 0.0f;
float scale; float scale = 1.0f;
v3f spread; v3f spread = v3f(250, 250, 250);
s32 seed; s32 seed = 12345;
u16 octaves; u16 octaves = 3;
float persist; float persist = 0.6f;
float lacunarity; float lacunarity = 2.0f;
u32 flags; u32 flags = NOISE_FLAG_DEFAULTS;
NoiseParams() NoiseParams() {}
{
offset = 0.0f;
scale = 1.0f;
spread = v3f(250, 250, 250);
seed = 12345;
octaves = 3;
persist = 0.6f;
lacunarity = 2.0f;
flags = NOISE_FLAG_DEFAULTS;
}
NoiseParams(float offset_, float scale_, v3f spread_, s32 seed_, NoiseParams(float offset_, float scale_, v3f spread_, s32 seed_,
u16 octaves_, float persist_, float lacunarity_, u16 octaves_, float persist_, float lacunarity_,
@ -138,13 +128,6 @@ struct NoiseParams {
} }
}; };
// Convenience macros for getting/setting NoiseParams in Settings as a string
// WARNING: Deprecated, use Settings::getNoiseParamsFromValue() instead
#define NOISEPARAMS_FMT_STR "f,f,v3,s32,u16,f"
//#define getNoiseParams(x, y) getStruct((x), NOISEPARAMS_FMT_STR, &(y), sizeof(y))
//#define setNoiseParams(x, y) setStruct((x), NOISEPARAMS_FMT_STR, &(y))
class Noise { class Noise {
public: public:
NoiseParams np; NoiseParams np;
@ -152,10 +135,10 @@ public:
u32 sx; u32 sx;
u32 sy; u32 sy;
u32 sz; u32 sz;
float *noise_buf; float *noise_buf = nullptr;
float *gradient_buf; float *gradient_buf = nullptr;
float *persist_buf; float *persist_buf = nullptr;
float *result; float *result = nullptr;
Noise(NoiseParams *np, s32 seed, u32 sx, u32 sy, u32 sz=1); Noise(NoiseParams *np, s32 seed, u32 sx, u32 sy, u32 sz=1);
~Noise(); ~Noise();

@ -24,27 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/basic_macros.h" #include "util/basic_macros.h"
#include <sstream> #include <sstream>
ObjectProperties::ObjectProperties(): ObjectProperties::ObjectProperties()
hp_max(1),
physical(false),
collideWithObjects(true),
weight(5),
collisionbox(-0.5,-0.5,-0.5, 0.5,0.5,0.5),
visual("sprite"),
mesh(""),
visual_size(1,1),
spritediv(1,1),
initial_sprite_basepos(0,0),
is_visible(true),
makes_footstep_sound(false),
automatic_rotate(0),
stepheight(0),
automatic_face_movement_dir(false),
automatic_face_movement_dir_offset(0.0),
backface_culling(true),
nametag(""),
nametag_color(255, 255, 255, 255),
automatic_face_movement_max_rotation_per_sec(-1)
{ {
textures.push_back("unknown_object.png"); textures.push_back("unknown_object.png");
colors.push_back(video::SColor(255,255,255,255)); colors.push_back(video::SColor(255,255,255,255));

@ -29,28 +29,28 @@ with this program; if not, write to the Free Software Foundation, Inc.,
struct ObjectProperties struct ObjectProperties
{ {
// Values are BS=1 // Values are BS=1
s16 hp_max; s16 hp_max = 1;
bool physical; bool physical = false;
bool collideWithObjects; bool collideWithObjects = true;
float weight; float weight = 5.0f;
aabb3f collisionbox; aabb3f collisionbox = aabb3f(-0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f);
std::string visual; std::string visual = "sprite";
std::string mesh; std::string mesh = "";
v2f visual_size; v2f visual_size = v2f(1, 1);
std::vector<std::string> textures; std::vector<std::string> textures;
std::vector<video::SColor> colors; std::vector<video::SColor> colors;
v2s16 spritediv; v2s16 spritediv = v2s16(1, 1);
v2s16 initial_sprite_basepos; v2s16 initial_sprite_basepos;
bool is_visible; bool is_visible = true;
bool makes_footstep_sound; bool makes_footstep_sound = false;
float automatic_rotate; float automatic_rotate = 0.0f;
f32 stepheight; f32 stepheight = 0.0f;
bool automatic_face_movement_dir; bool automatic_face_movement_dir = false;
f32 automatic_face_movement_dir_offset; f32 automatic_face_movement_dir_offset = 0.0f;
bool backface_culling; bool backface_culling = true;
std::string nametag; std::string nametag = "";
video::SColor nametag_color; video::SColor nametag_color = video::SColor(255, 255, 255, 255);
f32 automatic_face_movement_max_rotation_per_sec; f32 automatic_face_movement_max_rotation_per_sec = -1.0f;
std::string infotext; std::string infotext;
//! For dropped items, this contains item information. //! For dropped items, this contains item information.
std::string wield_item; std::string wield_item;

@ -76,8 +76,6 @@ Particle::Particle(
m_texpos = texpos; m_texpos = texpos;
m_texsize = texsize; m_texsize = texsize;
m_animation = anim; m_animation = anim;
m_animation_frame = 0;
m_animation_time = 0.0;
// Color // Color
m_base_color = color; m_base_color = color;
@ -88,7 +86,6 @@ Particle::Particle(
m_velocity = velocity; m_velocity = velocity;
m_acceleration = acceleration; m_acceleration = acceleration;
m_expiration = expirationtime; m_expiration = expirationtime;
m_time = 0;
m_player = player; m_player = player;
m_size = size; m_size = size;
m_collisiondetection = collisiondetection; m_collisiondetection = collisiondetection;

@ -86,7 +86,7 @@ private:
void updateVertices(); void updateVertices();
video::S3DVertex m_vertices[4]; video::S3DVertex m_vertices[4];
float m_time; float m_time = 0.0f;
float m_expiration; float m_expiration;
ClientEnvironment *m_env; ClientEnvironment *m_env;
@ -110,8 +110,8 @@ private:
bool m_vertical; bool m_vertical;
v3s16 m_camera_offset; v3s16 m_camera_offset;
struct TileAnimationParams m_animation; struct TileAnimationParams m_animation;
float m_animation_time; float m_animation_time = 0.0f;
int m_animation_frame; int m_animation_frame = 0;
u8 m_glow; u8 m_glow;
}; };

@ -30,11 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Player::Player(const char *name, IItemDefManager *idef): Player::Player(const char *name, IItemDefManager *idef):
inventory(idef), inventory(idef)
peer_id(PEER_ID_INEXISTENT),
keyPressed(0),
// protected
m_speed(0,0,0)
{ {
strlcpy(m_name, name, PLAYERNAME_SIZE); strlcpy(m_name, name, PLAYERNAME_SIZE);

@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irrlichttypes_bloated.h" #include "irrlichttypes_bloated.h"
#include "inventory.h" #include "inventory.h"
#include "constants.h"
#include <list> #include <list>
#include <mutex> #include <mutex>
@ -32,22 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
struct PlayerControl struct PlayerControl
{ {
PlayerControl() PlayerControl() {}
{
up = false;
down = false;
left = false;
right = false;
jump = false;
aux1 = false;
sneak = false;
LMB = false;
RMB = false;
pitch = 0;
yaw = 0;
sidew_move_joystick_axis = .0f;
forw_move_joystick_axis = .0f;
}
PlayerControl( PlayerControl(
bool a_up, bool a_up,
@ -81,20 +67,20 @@ struct PlayerControl
sidew_move_joystick_axis = a_sidew_move_joystick_axis; sidew_move_joystick_axis = a_sidew_move_joystick_axis;
forw_move_joystick_axis = a_forw_move_joystick_axis; forw_move_joystick_axis = a_forw_move_joystick_axis;
} }
bool up; bool up = false;
bool down; bool down = false;
bool left; bool left = false;
bool right; bool right = false;
bool jump; bool jump = false;
bool aux1; bool aux1 = false;
bool sneak; bool sneak = false;
bool zoom; bool zoom = false;
bool LMB; bool LMB = false;
bool RMB; bool RMB = false;
float pitch; float pitch = 0.0f;
float yaw; float yaw = 0.0f;
float sidew_move_joystick_axis; float sidew_move_joystick_axis = 0.0f;
float forw_move_joystick_axis; float forw_move_joystick_axis = 0.0f;
}; };
class Map; class Map;
@ -161,14 +147,14 @@ public:
v2s32 local_animations[4]; v2s32 local_animations[4];
float local_animation_speed; float local_animation_speed;
u16 peer_id; u16 peer_id = PEER_ID_INEXISTENT;
std::string inventory_formspec; std::string inventory_formspec;
PlayerControl control; PlayerControl control;
const PlayerControl& getPlayerControl() { return control; } const PlayerControl& getPlayerControl() { return control; }
u32 keyPressed; u32 keyPressed = 0;
HudElement* getHud(u32 id); HudElement* getHud(u32 id);
u32 addHud(HudElement* hud); u32 addHud(HudElement* hud);

@ -23,7 +23,7 @@ static Profiler main_profiler;
Profiler *g_profiler = &main_profiler; Profiler *g_profiler = &main_profiler;
ScopeProfiler::ScopeProfiler( ScopeProfiler::ScopeProfiler(
Profiler *profiler, const std::string &name, ScopeProfilerType type) Profiler *profiler, const std::string &name, ScopeProfilerType type)
: m_profiler(profiler), m_name(name), m_timer(NULL), m_type(type) : m_profiler(profiler), m_name(name), m_type(type)
{ {
if (m_profiler) if (m_profiler)
m_timer = new TimeTaker(m_name); m_timer = new TimeTaker(m_name);

@ -42,9 +42,7 @@ extern Profiler *g_profiler;
class Profiler class Profiler
{ {
public: public:
Profiler() Profiler() {}
{
}
void add(const std::string &name, float value) void add(const std::string &name, float value)
{ {
@ -195,9 +193,9 @@ public:
ScopeProfilerType type = SPT_ADD); ScopeProfilerType type = SPT_ADD);
~ScopeProfiler(); ~ScopeProfiler();
private: private:
Profiler *m_profiler; Profiler *m_profiler = nullptr;
std::string m_name; std::string m_name;
TimeTaker *m_timer; TimeTaker *m_timer = nullptr;
enum ScopeProfilerType m_type; enum ScopeProfilerType m_type;
}; };

@ -26,8 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
ReflowScan::ReflowScan(Map *map, INodeDefManager *ndef) : ReflowScan::ReflowScan(Map *map, INodeDefManager *ndef) :
m_map(map), m_map(map),
m_ndef(ndef), m_ndef(ndef)
m_liquid_queue(nullptr)
{ {
} }

@ -39,10 +39,10 @@ private:
void scanColumn(int x, int z); void scanColumn(int x, int z);
private: private:
Map *m_map; Map *m_map = nullptr;
INodeDefManager *m_ndef; INodeDefManager *m_ndef = nullptr;
v3s16 m_block_pos, m_rel_block_pos; v3s16 m_block_pos, m_rel_block_pos;
UniqueQueue<v3s16> *m_liquid_queue; UniqueQueue<v3s16> *m_liquid_queue = nullptr;
MapBlock *m_lookup[3 * 3 * 3]; MapBlock *m_lookup[3 * 3 * 3];
u32 m_lookup_state_bitset; u32 m_lookup_state_bitset;
}; };

@ -36,15 +36,7 @@ float RemotePlayer::m_setting_chat_message_limit_per_10sec = 0.0f;
u16 RemotePlayer::m_setting_chat_message_limit_trigger_kick = 0; u16 RemotePlayer::m_setting_chat_message_limit_trigger_kick = 0;
RemotePlayer::RemotePlayer(const char *name, IItemDefManager *idef): RemotePlayer::RemotePlayer(const char *name, IItemDefManager *idef):
Player(name, idef), Player(name, idef)
protocol_version(0),
m_sao(NULL),
m_dirty(false),
m_last_chat_message_sent(time(NULL)),
m_chat_message_allowance(5.0f),
m_message_rate_overhead(0),
hud_hotbar_image(""),
hud_hotbar_selected_image("")
{ {
if (!RemotePlayer::m_setting_cache_loaded) { if (!RemotePlayer::m_setting_cache_loaded) {
RemotePlayer::m_setting_chat_message_limit_per_10sec = RemotePlayer::m_setting_chat_message_limit_per_10sec =

@ -134,7 +134,7 @@ public:
void setDirty(bool dirty) { m_dirty = true; } void setDirty(bool dirty) { m_dirty = true; }
u16 protocol_version; u16 protocol_version = 0;
private: private:
/* /*
@ -145,21 +145,21 @@ private:
void serialize(std::ostream &os); void serialize(std::ostream &os);
void serializeExtraAttributes(std::string &output); void serializeExtraAttributes(std::string &output);
PlayerSAO *m_sao; PlayerSAO *m_sao = nullptr;
bool m_dirty; bool m_dirty = false;
static bool m_setting_cache_loaded; static bool m_setting_cache_loaded;
static float m_setting_chat_message_limit_per_10sec; static float m_setting_chat_message_limit_per_10sec;
static u16 m_setting_chat_message_limit_trigger_kick; static u16 m_setting_chat_message_limit_trigger_kick;
u32 m_last_chat_message_sent; u32 m_last_chat_message_sent = std::time(0);
float m_chat_message_allowance; float m_chat_message_allowance = 5.0f;
u16 m_message_rate_overhead; u16 m_message_rate_overhead = 0;
bool m_day_night_ratio_do_override; bool m_day_night_ratio_do_override;
float m_day_night_ratio; float m_day_night_ratio;
std::string hud_hotbar_image; std::string hud_hotbar_image = "";
std::string hud_hotbar_selected_image; std::string hud_hotbar_selected_image = "";
std::string m_sky_type; std::string m_sky_type;
video::SColor m_sky_bgcolor; video::SColor m_sky_bgcolor;

@ -91,8 +91,7 @@ struct Entity {
RollbackManager::RollbackManager(const std::string & world_path, RollbackManager::RollbackManager(const std::string & world_path,
IGameDef * gamedef_) : IGameDef * gamedef_) :
gamedef(gamedef_), gamedef(gamedef_)
current_actor_is_guess(false)
{ {
verbosestream << "RollbackManager::RollbackManager(" << world_path verbosestream << "RollbackManager::RollbackManager(" << world_path
<< ")" << std::endl; << ")" << std::endl;

@ -80,10 +80,10 @@ private:
time_t suspect_t, v3s16 action_p, time_t action_t); time_t suspect_t, v3s16 action_p, time_t action_t);
IGameDef * gamedef; IGameDef *gamedef = nullptr;
std::string current_actor; std::string current_actor;
bool current_actor_is_guess; bool current_actor_is_guess = false;
std::list<RollbackAction> action_todisk_buffer; std::list<RollbackAction> action_todisk_buffer;
std::list<RollbackAction> action_latest_buffer; std::list<RollbackAction> action_latest_buffer;

@ -35,8 +35,8 @@ class InventoryManager;
struct RollbackNode struct RollbackNode
{ {
std::string name; std::string name;
int param1; int param1 = 0;
int param2; int param2 = 0;
std::string meta; std::string meta;
bool operator == (const RollbackNode &other) bool operator == (const RollbackNode &other)
@ -46,11 +46,7 @@ struct RollbackNode
} }
bool operator != (const RollbackNode &other) { return !(*this == other); } bool operator != (const RollbackNode &other) { return !(*this == other); }
RollbackNode(): RollbackNode() {}
param1(0),
param2(0)
{}
RollbackNode(Map *map, v3s16 p, IGameDef *gamedef); RollbackNode(Map *map, v3s16 p, IGameDef *gamedef);
}; };

@ -156,41 +156,19 @@ Server::Server(
m_simple_singleplayer_mode(simple_singleplayer_mode), m_simple_singleplayer_mode(simple_singleplayer_mode),
m_dedicated(dedicated), m_dedicated(dedicated),
m_async_fatal_error(""), m_async_fatal_error(""),
m_env(NULL),
m_con(PROTOCOL_ID, m_con(PROTOCOL_ID,
512, 512,
CONNECTION_TIMEOUT, CONNECTION_TIMEOUT,
ipv6, ipv6,
this), this),
m_banmanager(NULL),
m_rollback(NULL),
m_enable_rollback_recording(false),
m_emerge(NULL),
m_script(NULL),
m_itemdef(createItemDefManager()), m_itemdef(createItemDefManager()),
m_nodedef(createNodeDefManager()), m_nodedef(createNodeDefManager()),
m_craftdef(createCraftDefManager()), m_craftdef(createCraftDefManager()),
m_event(new EventManager()), m_event(new EventManager()),
m_thread(NULL),
m_time_of_day_send_timer(0),
m_uptime(0), m_uptime(0),
m_clients(&m_con), m_clients(&m_con),
m_shutdown_requested(false), m_admin_chat(iface)
m_shutdown_ask_reconnect(false),
m_shutdown_timer(0.0f),
m_admin_chat(iface),
m_ignore_map_edit_events(false),
m_ignore_map_edit_events_peer_id(0),
m_next_sound_id(0),
m_mod_storage_save_timer(10.0f)
{ {
m_liquid_transform_timer = 0.0;
m_liquid_transform_every = 1.0;
m_masterserver_timer = 0.0;
m_emergethread_trigger_timer = 0.0;
m_savemap_timer = 0.0;
m_step_dtime = 0.0;
m_lag = g_settings->getFloat("dedicated_server_step"); m_lag = g_settings->getFloat("dedicated_server_step");
if(path_world == "") if(path_world == "")

@ -113,8 +113,8 @@ struct ServerSoundParams
float fade = 0.0f; float fade = 0.0f;
float pitch = 1.0f; float pitch = 1.0f;
bool loop = false; bool loop = false;
float max_hear_distance = 32*BS; float max_hear_distance = 32 * BS;
v3f pos = v3f(0, 0, 0); v3f pos;
u16 object = 0; u16 object = 0;
std::string to_player = ""; std::string to_player = "";
@ -142,7 +142,7 @@ public:
bool simple_singleplayer_mode, bool simple_singleplayer_mode,
bool ipv6, bool ipv6,
bool dedicated, bool dedicated,
ChatInterface *iface = NULL ChatInterface *iface = nullptr
); );
~Server(); ~Server();
DISABLE_CLASS_COPY(Server); DISABLE_CLASS_COPY(Server);
@ -521,32 +521,32 @@ private:
MutexedVariable<std::string> m_async_fatal_error; MutexedVariable<std::string> m_async_fatal_error;
// Some timers // Some timers
float m_liquid_transform_timer; float m_liquid_transform_timer = 0.0f;
float m_liquid_transform_every; float m_liquid_transform_every = 1.0f;
float m_masterserver_timer; float m_masterserver_timer = 0.0f;
float m_emergethread_trigger_timer; float m_emergethread_trigger_timer = 0.0f;
float m_savemap_timer; float m_savemap_timer = 0.0f;
IntervalLimiter m_map_timer_and_unload_interval; IntervalLimiter m_map_timer_and_unload_interval;
// Environment // Environment
ServerEnvironment *m_env; ServerEnvironment *m_env = nullptr;
// server connection // server connection
con::Connection m_con; con::Connection m_con;
// Ban checking // Ban checking
BanManager *m_banmanager; BanManager *m_banmanager = nullptr;
// Rollback manager (behind m_env_mutex) // Rollback manager (behind m_env_mutex)
IRollbackManager *m_rollback; IRollbackManager *m_rollback = nullptr;
bool m_enable_rollback_recording; // Updated once in a while bool m_enable_rollback_recording = false; // Updated once in a while
// Emerge manager // Emerge manager
EmergeManager *m_emerge; EmergeManager *m_emerge = nullptr;
// Scripting // Scripting
// Envlock and conlock should be locked when using Lua // Envlock and conlock should be locked when using Lua
ServerScripting *m_script; ServerScripting *m_script = nullptr;
// Item definition manager // Item definition manager
IWritableItemDefManager *m_itemdef; IWritableItemDefManager *m_itemdef;
@ -569,21 +569,21 @@ private:
// A buffer for time steps // A buffer for time steps
// step() increments and AsyncRunStep() run by m_thread reads it. // step() increments and AsyncRunStep() run by m_thread reads it.
float m_step_dtime; float m_step_dtime = 0.0f;
std::mutex m_step_dtime_mutex; std::mutex m_step_dtime_mutex;
// current server step lag counter // current server step lag counter
float m_lag; float m_lag;
// The server mainly operates in this thread // The server mainly operates in this thread
ServerThread *m_thread; ServerThread *m_thread = nullptr;
/* /*
Time related stuff Time related stuff
*/ */
// Timer for sending time of day over network // Timer for sending time of day over network
float m_time_of_day_send_timer; float m_time_of_day_send_timer = 0.0f;
// Uptime of server in seconds // Uptime of server in seconds
MutexedVariable<double> m_uptime; MutexedVariable<double> m_uptime;
/* /*
@ -602,10 +602,10 @@ private:
Random stuff Random stuff
*/ */
bool m_shutdown_requested; bool m_shutdown_requested = false;
std::string m_shutdown_msg; std::string m_shutdown_msg;
bool m_shutdown_ask_reconnect; bool m_shutdown_ask_reconnect = false;
float m_shutdown_timer; float m_shutdown_timer = 0.0f;
ChatInterface *m_admin_chat; ChatInterface *m_admin_chat;
std::string m_admin_nick; std::string m_admin_nick;
@ -629,7 +629,7 @@ private:
all sending of information by itself. all sending of information by itself.
This is behind m_env_mutex This is behind m_env_mutex
*/ */
bool m_ignore_map_edit_events; bool m_ignore_map_edit_events = false;
/* /*
If a non-empty area, map edit events contained within are left If a non-empty area, map edit events contained within are left
unsent. Done at map generation time to speed up editing of the unsent. Done at map generation time to speed up editing of the
@ -642,7 +642,7 @@ private:
this peed id as the disabled recipient this peed id as the disabled recipient
This is behind m_env_mutex This is behind m_env_mutex
*/ */
u16 m_ignore_map_edit_events_peer_id; u16 m_ignore_map_edit_events_peer_id = 0;
// media files known to server // media files known to server
std::unordered_map<std::string, MediaInfo> m_media; std::unordered_map<std::string, MediaInfo> m_media;
@ -651,7 +651,7 @@ private:
Sounds Sounds
*/ */
std::unordered_map<s32, ServerPlayingSound> m_playing_sounds; std::unordered_map<s32, ServerPlayingSound> m_playing_sounds;
s32 m_next_sound_id; s32 m_next_sound_id = 0;
/* /*
Detached inventories (behind m_env_mutex) Detached inventories (behind m_env_mutex)
@ -662,7 +662,7 @@ private:
std::map<std::string, std::string> m_detached_inventories_player; std::map<std::string, std::string> m_detached_inventories_player;
std::unordered_map<std::string, ModMetadata *> m_mod_storages; std::unordered_map<std::string, ModMetadata *> m_mod_storages;
float m_mod_storage_save_timer; float m_mod_storage_save_timer = 10.0f;
}; };
/* /*

@ -54,8 +54,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
ABMWithState::ABMWithState(ActiveBlockModifier *abm_): ABMWithState::ABMWithState(ActiveBlockModifier *abm_):
abm(abm_), abm(abm_)
timer(0)
{ {
// Initialize timer to random value to spread processing // Initialize timer to random value to spread processing
float itv = abm->getTriggerInterval(); float itv = abm->getTriggerInterval();
@ -365,15 +364,7 @@ ServerEnvironment::ServerEnvironment(ServerMap *map,
m_map(map), m_map(map),
m_script(scriptIface), m_script(scriptIface),
m_server(server), m_server(server),
m_path_world(path_world), m_path_world(path_world)
m_send_recommended_timer(0),
m_active_block_interval_overload_skip(0),
m_game_time(0),
m_game_time_fraction_counter(0),
m_last_clear_objects_time(0),
m_recommended_send_interval(0.1),
m_max_lag_estimate(0.1),
m_player_database(NULL)
{ {
// Determine which database backend to use // Determine which database backend to use
std::string conf_path = path_world + DIR_DELIM + "world.mt"; std::string conf_path = path_world + DIR_DELIM + "world.mt";

@ -70,7 +70,7 @@ public:
struct ABMWithState struct ABMWithState
{ {
ActiveBlockModifier *abm; ActiveBlockModifier *abm;
float timer; float timer = 0.0f;
ABMWithState(ActiveBlockModifier *abm_); ABMWithState(ActiveBlockModifier *abm_);
}; };
@ -80,7 +80,7 @@ struct LoadingBlockModifierDef
// Set of contents to trigger on // Set of contents to trigger on
std::set<std::string> trigger_contents; std::set<std::string> trigger_contents;
std::string name; std::string name;
bool run_at_every_load; bool run_at_every_load = false;
virtual ~LoadingBlockModifierDef() {} virtual ~LoadingBlockModifierDef() {}
virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n){}; virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n){};
@ -104,10 +104,7 @@ struct LBMContentMapping
class LBMManager class LBMManager
{ {
public: public:
LBMManager(): LBMManager() {}
m_query_mode(false)
{}
~LBMManager(); ~LBMManager();
// Don't call this after loadIntroductionTimes() ran. // Don't call this after loadIntroductionTimes() ran.
@ -128,7 +125,7 @@ public:
private: private:
// Once we set this to true, we can only query, // Once we set this to true, we can only query,
// not modify // not modify
bool m_query_mode; bool m_query_mode = false;
// For m_query_mode == false: // For m_query_mode == false:
// The key of the map is the LBM def's name. // The key of the map is the LBM def's name.
@ -399,35 +396,35 @@ private:
// Outgoing network message buffer for active objects // Outgoing network message buffer for active objects
std::queue<ActiveObjectMessage> m_active_object_messages; std::queue<ActiveObjectMessage> m_active_object_messages;
// Some timers // Some timers
float m_send_recommended_timer; float m_send_recommended_timer = 0.0f;
IntervalLimiter m_object_management_interval; IntervalLimiter m_object_management_interval;
// List of active blocks // List of active blocks
ActiveBlockList m_active_blocks; ActiveBlockList m_active_blocks;
IntervalLimiter m_active_blocks_management_interval; IntervalLimiter m_active_blocks_management_interval;
IntervalLimiter m_active_block_modifier_interval; IntervalLimiter m_active_block_modifier_interval;
IntervalLimiter m_active_blocks_nodemetadata_interval; IntervalLimiter m_active_blocks_nodemetadata_interval;
int m_active_block_interval_overload_skip; int m_active_block_interval_overload_skip = 0;
// Time from the beginning of the game in seconds. // Time from the beginning of the game in seconds.
// Incremented in step(). // Incremented in step().
u32 m_game_time; u32 m_game_time = 0;
// A helper variable for incrementing the latter // A helper variable for incrementing the latter
float m_game_time_fraction_counter; float m_game_time_fraction_counter = 0.0f;
// Time of last clearObjects call (game time). // Time of last clearObjects call (game time).
// When a mapblock older than this is loaded, its objects are cleared. // When a mapblock older than this is loaded, its objects are cleared.
u32 m_last_clear_objects_time; u32 m_last_clear_objects_time = 0;
// Active block modifiers // Active block modifiers
std::vector<ABMWithState> m_abms; std::vector<ABMWithState> m_abms;
LBMManager m_lbm_mgr; LBMManager m_lbm_mgr;
// An interval for generally sending object positions and stuff // An interval for generally sending object positions and stuff
float m_recommended_send_interval; float m_recommended_send_interval = 0.1f;
// Estimate for general maximum lag as determined by server. // Estimate for general maximum lag as determined by server.
// Can raise to high values like 15s with eg. map generation mods. // Can raise to high values like 15s with eg. map generation mods.
float m_max_lag_estimate; float m_max_lag_estimate = 0.1f;
// peer_ids in here should be unique, except that there may be many 0s // peer_ids in here should be unique, except that there may be many 0s
std::vector<RemotePlayer*> m_players; std::vector<RemotePlayer*> m_players;
PlayerDatabase *m_player_database; PlayerDatabase *m_player_database = nullptr;
// Particles // Particles
IntervalLimiter m_particle_management_interval; IntervalLimiter m_particle_management_interval;