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():
p(-1337,-1337,-1337),
data(NULL),
refcount_from_queue(0),
last_used_timestamp(time(0))
{
}
CachedMapBlockData::~CachedMapBlockData()
{
assert(refcount_from_queue == 0);
@ -47,16 +39,6 @@ CachedMapBlockData::~CachedMapBlockData()
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()
{
delete data;

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

@ -117,10 +117,10 @@ public:
virtual Biome *getBiomeAtIndex(size_t index, s16 y) const = 0;
// Result of calcBiomes bulk computation.
biome_t *biomemap;
biome_t *biomemap = nullptr;
protected:
BiomeManager *m_bmgr;
BiomeManager *m_bmgr = nullptr;
v3s16 m_pmin;
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()
{
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)
{
// Schematic could have been unloaded but not the decoration

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

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

@ -62,13 +62,13 @@ public:
s16 y_min;
s16 y_max;
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
NoiseParams np; // noise for distribution of clusters (NULL for uniform scattering)
Noise *noise;
Noise *noise = nullptr;
std::unordered_set<u8> biomes;
Ore();
Ore() {};
virtual ~Ore();
virtual void resolveNodeNames();
@ -104,8 +104,8 @@ public:
NoiseParams np_puff_top;
NoiseParams np_puff_bottom;
Noise *noise_puff_top;
Noise *noise_puff_bottom;
Noise *noise_puff_top = nullptr;
Noise *noise_puff_bottom = nullptr;
OrePuff();
virtual ~OrePuff();
@ -127,7 +127,7 @@ public:
static const bool NEEDS_NOISE = true;
float random_factor;
Noise *noise2;
Noise *noise2 = nullptr;
OreVein();
virtual ~OreVein();
@ -160,7 +160,7 @@ public:
case ORE_VEIN:
return new OreVein;
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) :
ObjDefManager(server, OBJDEF_SCHEMATIC)
ObjDefManager(server, OBJDEF_SCHEMATIC),
m_server(server)
{
m_server = server;
}
@ -69,10 +69,6 @@ void SchematicManager::clear()
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<content_t> c_nodes;
u32 flags;
u32 flags = 0;
v3s16 size;
MapNode *schemdata;
u8 *slice_probs;
MapNode *schemdata = nullptr;
u8 *slice_probs = nullptr;
};
class SchematicManager : public ObjDefManager {

@ -204,8 +204,6 @@ Minimap::Minimap(IrrlichtDevice *device, Client *client)
data->mode = MINIMAP_MODE_OFF;
data->is_radar = false;
data->map_invalidated = true;
data->heightmap_image = NULL;
data->minimap_image = NULL;
data->texture = NULL;
data->heightmap_texture = NULL;
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];
bool map_invalidated;
bool minimap_shape_round;
video::IImage *minimap_image;
video::IImage *heightmap_image;
video::IImage *minimap_mask_round;
video::IImage *minimap_mask_square;
video::ITexture *texture;
video::ITexture *heightmap_texture;
video::ITexture *minimap_overlay_round;
video::ITexture *minimap_overlay_square;
video::ITexture *player_marker;
video::ITexture *object_marker_red;
video::IImage *minimap_mask_round = nullptr;
video::IImage *minimap_mask_square = nullptr;
video::ITexture *texture = nullptr;
video::ITexture *heightmap_texture = nullptr;
video::ITexture *minimap_overlay_round = nullptr;
video::ITexture *minimap_overlay_square = nullptr;
video::ITexture *player_marker = nullptr;
video::ITexture *object_marker_red = nullptr;
};
struct QueuedMinimapUpdate {
v3s16 pos;
MinimapMapblock *data;
MinimapMapblock *data = nullptr;
};
class MinimapUpdateThread : public UpdateThread {
@ -105,7 +103,7 @@ public:
bool pushBlockUpdate(v3s16 pos, MinimapMapblock *data);
bool popBlockUpdate(QueuedMinimapUpdate *update);
MinimapData *data;
MinimapData *data = nullptr;
protected:
virtual void doUpdate();

@ -48,11 +48,7 @@ public:
IGUIElement(gui::EGUIET_ELEMENT, env, parent, id,
core::rect<s32>(0,0,100,100))
{
//m_force_regenerate_gui = false;
m_menumgr = menumgr;
m_allow_focus_removal = false;
m_screensize_old = v2u32(0,0);
setVisible(true);
Environment->setFocus(this);
@ -142,7 +138,7 @@ private:
IMenuManager *m_menumgr;
// This might be necessary to expose to the implementation if it
// 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
ModMetadata::ModMetadata(const std::string &mod_name):
m_mod_name(mod_name),
m_modified(false)
m_mod_name(mod_name)
{
m_stringvars.clear();
}
void ModMetadata::clear()

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

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

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

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

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

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

@ -102,26 +102,16 @@ private:
#define NOISE_FLAG_SIMPLEX 0x10
struct NoiseParams {
float offset;
float scale;
v3f spread;
s32 seed;
u16 octaves;
float persist;
float lacunarity;
u32 flags;
float offset = 0.0f;
float scale = 1.0f;
v3f spread = v3f(250, 250, 250);
s32 seed = 12345;
u16 octaves = 3;
float persist = 0.6f;
float lacunarity = 2.0f;
u32 flags = NOISE_FLAG_DEFAULTS;
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() {}
NoiseParams(float offset_, float scale_, v3f spread_, s32 seed_,
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 {
public:
NoiseParams np;
@ -152,10 +135,10 @@ public:
u32 sx;
u32 sy;
u32 sz;
float *noise_buf;
float *gradient_buf;
float *persist_buf;
float *result;
float *noise_buf = nullptr;
float *gradient_buf = nullptr;
float *persist_buf = nullptr;
float *result = nullptr;
Noise(NoiseParams *np, s32 seed, u32 sx, u32 sy, u32 sz=1);
~Noise();

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

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

@ -86,7 +86,7 @@ private:
void updateVertices();
video::S3DVertex m_vertices[4];
float m_time;
float m_time = 0.0f;
float m_expiration;
ClientEnvironment *m_env;
@ -110,8 +110,8 @@ private:
bool m_vertical;
v3s16 m_camera_offset;
struct TileAnimationParams m_animation;
float m_animation_time;
int m_animation_frame;
float m_animation_time = 0.0f;
int m_animation_frame = 0;
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):
inventory(idef),
peer_id(PEER_ID_INEXISTENT),
keyPressed(0),
// protected
m_speed(0,0,0)
inventory(idef)
{
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 "inventory.h"
#include "constants.h"
#include <list>
#include <mutex>
@ -32,22 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
struct 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,
@ -81,20 +67,20 @@ struct PlayerControl
sidew_move_joystick_axis = a_sidew_move_joystick_axis;
forw_move_joystick_axis = a_forw_move_joystick_axis;
}
bool up;
bool down;
bool left;
bool right;
bool jump;
bool aux1;
bool sneak;
bool zoom;
bool LMB;
bool RMB;
float pitch;
float yaw;
float sidew_move_joystick_axis;
float forw_move_joystick_axis;
bool up = false;
bool down = false;
bool left = false;
bool right = false;
bool jump = false;
bool aux1 = false;
bool sneak = false;
bool zoom = false;
bool LMB = false;
bool RMB = false;
float pitch = 0.0f;
float yaw = 0.0f;
float sidew_move_joystick_axis = 0.0f;
float forw_move_joystick_axis = 0.0f;
};
class Map;
@ -161,14 +147,14 @@ public:
v2s32 local_animations[4];
float local_animation_speed;
u16 peer_id;
u16 peer_id = PEER_ID_INEXISTENT;
std::string inventory_formspec;
PlayerControl control;
const PlayerControl& getPlayerControl() { return control; }
u32 keyPressed;
u32 keyPressed = 0;
HudElement* getHud(u32 id);
u32 addHud(HudElement* hud);

@ -23,7 +23,7 @@ static Profiler main_profiler;
Profiler *g_profiler = &main_profiler;
ScopeProfiler::ScopeProfiler(
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)
m_timer = new TimeTaker(m_name);

@ -42,9 +42,7 @@ extern Profiler *g_profiler;
class Profiler
{
public:
Profiler()
{
}
Profiler() {}
void add(const std::string &name, float value)
{
@ -195,9 +193,9 @@ public:
ScopeProfilerType type = SPT_ADD);
~ScopeProfiler();
private:
Profiler *m_profiler;
Profiler *m_profiler = nullptr;
std::string m_name;
TimeTaker *m_timer;
TimeTaker *m_timer = nullptr;
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) :
m_map(map),
m_ndef(ndef),
m_liquid_queue(nullptr)
m_ndef(ndef)
{
}

@ -39,10 +39,10 @@ private:
void scanColumn(int x, int z);
private:
Map *m_map;
INodeDefManager *m_ndef;
Map *m_map = nullptr;
INodeDefManager *m_ndef = nullptr;
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];
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;
RemotePlayer::RemotePlayer(const char *name, IItemDefManager *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("")
Player(name, idef)
{
if (!RemotePlayer::m_setting_cache_loaded) {
RemotePlayer::m_setting_chat_message_limit_per_10sec =

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

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

@ -80,10 +80,10 @@ private:
time_t suspect_t, v3s16 action_p, time_t action_t);
IGameDef * gamedef;
IGameDef *gamedef = nullptr;
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_latest_buffer;

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

@ -156,41 +156,19 @@ Server::Server(
m_simple_singleplayer_mode(simple_singleplayer_mode),
m_dedicated(dedicated),
m_async_fatal_error(""),
m_env(NULL),
m_con(PROTOCOL_ID,
512,
CONNECTION_TIMEOUT,
ipv6,
this),
m_banmanager(NULL),
m_rollback(NULL),
m_enable_rollback_recording(false),
m_emerge(NULL),
m_script(NULL),
m_itemdef(createItemDefManager()),
m_nodedef(createNodeDefManager()),
m_craftdef(createCraftDefManager()),
m_event(new EventManager()),
m_thread(NULL),
m_time_of_day_send_timer(0),
m_uptime(0),
m_clients(&m_con),
m_shutdown_requested(false),
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_admin_chat(iface)
{
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");
if(path_world == "")

@ -113,8 +113,8 @@ struct ServerSoundParams
float fade = 0.0f;
float pitch = 1.0f;
bool loop = false;
float max_hear_distance = 32*BS;
v3f pos = v3f(0, 0, 0);
float max_hear_distance = 32 * BS;
v3f pos;
u16 object = 0;
std::string to_player = "";
@ -142,7 +142,7 @@ public:
bool simple_singleplayer_mode,
bool ipv6,
bool dedicated,
ChatInterface *iface = NULL
ChatInterface *iface = nullptr
);
~Server();
DISABLE_CLASS_COPY(Server);
@ -521,32 +521,32 @@ private:
MutexedVariable<std::string> m_async_fatal_error;
// Some timers
float m_liquid_transform_timer;
float m_liquid_transform_every;
float m_masterserver_timer;
float m_emergethread_trigger_timer;
float m_savemap_timer;
float m_liquid_transform_timer = 0.0f;
float m_liquid_transform_every = 1.0f;
float m_masterserver_timer = 0.0f;
float m_emergethread_trigger_timer = 0.0f;
float m_savemap_timer = 0.0f;
IntervalLimiter m_map_timer_and_unload_interval;
// Environment
ServerEnvironment *m_env;
ServerEnvironment *m_env = nullptr;
// server connection
con::Connection m_con;
// Ban checking
BanManager *m_banmanager;
BanManager *m_banmanager = nullptr;
// Rollback manager (behind m_env_mutex)
IRollbackManager *m_rollback;
bool m_enable_rollback_recording; // Updated once in a while
IRollbackManager *m_rollback = nullptr;
bool m_enable_rollback_recording = false; // Updated once in a while
// Emerge manager
EmergeManager *m_emerge;
EmergeManager *m_emerge = nullptr;
// Scripting
// Envlock and conlock should be locked when using Lua
ServerScripting *m_script;
ServerScripting *m_script = nullptr;
// Item definition manager
IWritableItemDefManager *m_itemdef;
@ -569,21 +569,21 @@ private:
// A buffer for time steps
// 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;
// current server step lag counter
float m_lag;
// The server mainly operates in this thread
ServerThread *m_thread;
ServerThread *m_thread = nullptr;
/*
Time related stuff
*/
// 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
MutexedVariable<double> m_uptime;
/*
@ -602,10 +602,10 @@ private:
Random stuff
*/
bool m_shutdown_requested;
bool m_shutdown_requested = false;
std::string m_shutdown_msg;
bool m_shutdown_ask_reconnect;
float m_shutdown_timer;
bool m_shutdown_ask_reconnect = false;
float m_shutdown_timer = 0.0f;
ChatInterface *m_admin_chat;
std::string m_admin_nick;
@ -629,7 +629,7 @@ private:
all sending of information by itself.
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
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 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
std::unordered_map<std::string, MediaInfo> m_media;
@ -651,7 +651,7 @@ private:
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)
@ -662,7 +662,7 @@ private:
std::map<std::string, std::string> m_detached_inventories_player;
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_):
abm(abm_),
timer(0)
abm(abm_)
{
// Initialize timer to random value to spread processing
float itv = abm->getTriggerInterval();
@ -365,15 +364,7 @@ ServerEnvironment::ServerEnvironment(ServerMap *map,
m_map(map),
m_script(scriptIface),
m_server(server),
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)
m_path_world(path_world)
{
// Determine which database backend to use
std::string conf_path = path_world + DIR_DELIM + "world.mt";

@ -70,7 +70,7 @@ public:
struct ABMWithState
{
ActiveBlockModifier *abm;
float timer;
float timer = 0.0f;
ABMWithState(ActiveBlockModifier *abm_);
};
@ -80,7 +80,7 @@ struct LoadingBlockModifierDef
// Set of contents to trigger on
std::set<std::string> trigger_contents;
std::string name;
bool run_at_every_load;
bool run_at_every_load = false;
virtual ~LoadingBlockModifierDef() {}
virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n){};
@ -104,10 +104,7 @@ struct LBMContentMapping
class LBMManager
{
public:
LBMManager():
m_query_mode(false)
{}
LBMManager() {}
~LBMManager();
// Don't call this after loadIntroductionTimes() ran.
@ -128,7 +125,7 @@ public:
private:
// Once we set this to true, we can only query,
// not modify
bool m_query_mode;
bool m_query_mode = false;
// For m_query_mode == false:
// The key of the map is the LBM def's name.
@ -399,35 +396,35 @@ private:
// Outgoing network message buffer for active objects
std::queue<ActiveObjectMessage> m_active_object_messages;
// Some timers
float m_send_recommended_timer;
float m_send_recommended_timer = 0.0f;
IntervalLimiter m_object_management_interval;
// List of active blocks
ActiveBlockList m_active_blocks;
IntervalLimiter m_active_blocks_management_interval;
IntervalLimiter m_active_block_modifier_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.
// Incremented in step().
u32 m_game_time;
u32 m_game_time = 0;
// 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).
// 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
std::vector<ABMWithState> m_abms;
LBMManager m_lbm_mgr;
// 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.
// 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
std::vector<RemotePlayer*> m_players;
PlayerDatabase *m_player_database;
PlayerDatabase *m_player_database = nullptr;
// Particles
IntervalLimiter m_particle_management_interval;