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);
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;
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();
};
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
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;
};
///////////////////////////////////////////////////////////////////////////////
-
-Decoration::Decoration()
-{
- mapseed = 0;
- fill_ratio = 0;
- sidelen = 1;
- flags = 0;
-}
-
-
-Decoration::~Decoration()
-{
-}
-
-
void Decoration::resolveNodeNames()
{
getIdsFromNrBacklog(&c_place_on);
///////////////////////////////////////////////////////////////////////////////
-
-DecoSchematic::DecoSchematic()
-{
- schematic = NULL;
-}
-
-
size_t DecoSchematic::generate(MMVManip *vm, PcgRandom *pr, v3s16 p)
{
// Schematic could have been unloaded but not the decoration
class Decoration : public ObjDef, public NodeResolver {
public:
- Decoration();
- virtual ~Decoration();
+ Decoration() {};
+ virtual ~Decoration() {};
virtual void resolveNodeNames();
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;
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;
};
///////////////////////////////////////////////////////////////////////////////
-
-Ore::Ore()
-{
- flags = 0;
- noise = NULL;
-}
-
-
Ore::~Ore()
{
delete noise;
OrePuff::OrePuff() :
Ore()
{
- noise_puff_top = NULL;
- noise_puff_bottom = NULL;
}
OreVein::OreVein() :
Ore()
{
- noise2 = NULL;
}
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();
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();
static const bool NEEDS_NOISE = true;
float random_factor;
- Noise *noise2;
+ Noise *noise2 = nullptr;
OreVein();
virtual ~OreVein();
case ORE_VEIN:
return new OreVein;
default:
- return NULL;
+ return nullptr;
}
}
SchematicManager::SchematicManager(Server *server) :
- ObjDefManager(server, OBJDEF_SCHEMATIC)
+ ObjDefManager(server, OBJDEF_SCHEMATIC),
+ m_server(server)
{
- m_server = server;
}
Schematic::Schematic()
{
- schemdata = NULL;
- slice_probs = NULL;
- flags = 0;
- size = v3s16(0, 0, 0);
}
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 {
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");
void Minimap::setMinimapShape(MinimapShape shape)
{
MutexAutoLock lock(m_mutex);
-
+
if (shape == MINIMAP_SHAPE_SQUARE)
data->minimap_shape_round = false;
else if (shape == MINIMAP_SHAPE_ROUND)
data->minimap_shape_round = true;
-
+
g_settings->setBool("minimap_shape_round", data->minimap_shape_round);
- m_minimap_update_thread->deferUpdate();
+ m_minimap_update_thread->deferUpdate();
}
MinimapShape Minimap::getMinimapShape()
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 {
bool pushBlockUpdate(v3s16 pos, MinimapMapblock *data);
bool popBlockUpdate(QueuedMinimapUpdate *update);
- MinimapData *data;
+ MinimapData *data = nullptr;
protected:
virtual void doUpdate();
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);
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;
};
#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()
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_)
{}
};
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
m_id_to_name.erase(id);
m_name_to_id.erase(name);
}
+
void eraseName(const std::string &name)
{
u16 id;
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);
}
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;
}
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
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() {}
-
+
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;
};
class NodeTimerList
{
public:
- NodeTimerList(): m_next_trigger_time(-1.), m_time(0.) {}
+ NodeTimerList() {}
~NodeTimerList() {}
-
+
void serialize(std::ostream &os, u8 map_format_version) const;
void deSerialize(std::istream &is, u8 map_format_version);
-
+
// Get timer
NodeTimer get(const v3s16 &p) {
std::map<v3s16, std::multimap<double, NodeTimer>::iterator>::iterator n =
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
this->sy = sy;
this->sz = sz;
- this->persist_buf = NULL;
- this->gradient_buf = NULL;
- this->result = NULL;
-
allocBuffers();
}
#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_,
}
};
-
-// 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;
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();
#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));
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;
m_texpos = texpos;
m_texsize = texsize;
m_animation = anim;
- m_animation_frame = 0;
- m_animation_time = 0.0;
// Color
m_base_color = color;
m_velocity = velocity;
m_acceleration = acceleration;
m_expiration = expirationtime;
- m_time = 0;
m_player = player;
m_size = size;
m_collisiondetection = collisiondetection;
void updateVertices();
video::S3DVertex m_vertices[4];
- float m_time;
+ float m_time = 0.0f;
float m_expiration;
ClientEnvironment *m_env;
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;
};
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);
#include "irrlichttypes_bloated.h"
#include "inventory.h"
+#include "constants.h"
#include <list>
#include <mutex>
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,
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;
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);
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);
class Profiler
{
public:
- Profiler()
- {
- }
+ Profiler() {}
void add(const std::string &name, float value)
{
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;
};
ReflowScan::ReflowScan(Map *map, INodeDefManager *ndef) :
m_map(map),
- m_ndef(ndef),
- m_liquid_queue(nullptr)
+ m_ndef(ndef)
{
}
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;
};
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 =
void setDirty(bool dirty) { m_dirty = true; }
- u16 protocol_version;
+ u16 protocol_version = 0;
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;
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;
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;
struct RollbackNode
{
std::string name;
- int param1;
- int param2;
+ int param1 = 0;
+ int param2 = 0;
std::string meta;
bool operator == (const RollbackNode &other)
}
bool operator != (const RollbackNode &other) { return !(*this == other); }
- RollbackNode():
- param1(0),
- param2(0)
- {}
-
+ RollbackNode() {}
RollbackNode(Map *map, v3s16 p, IGameDef *gamedef);
};
v3s16 p;
RollbackNode n_old;
RollbackNode n_new;
-
+
std::string inventory_location;
std::string inventory_list;
u32 inventory_index;
inventory_add = add_;
inventory_stack = inventory_stack_;
}
-
+
// String should not contain newlines or nulls
std::string toString() const;
-
+
// Eg. flowing water level changes are not important
bool isImportant(IGameDef *gamedef) const;
-
+
bool getPosition(v3s16 *dst) const;
bool applyRevert(Map *map, InventoryManager *imgr, IGameDef *gamedef) const;
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_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_admin_chat(iface)
+{
m_lag = g_settings->getFloat("dedicated_server_step");
if(path_world == "")
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 = "";
bool simple_singleplayer_mode,
bool ipv6,
bool dedicated,
- ChatInterface *iface = NULL
+ ChatInterface *iface = nullptr
);
~Server();
DISABLE_CLASS_COPY(Server);
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;
// 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;
/*
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;
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
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;
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)
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;
};
/*
*/
ABMWithState::ABMWithState(ActiveBlockModifier *abm_):
- abm(abm_),
- timer(0)
+ abm(abm_)
{
// Initialize timer to random value to spread processing
float itv = abm->getTriggerInterval();
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";
struct ABMWithState
{
ActiveBlockModifier *abm;
- float timer;
+ float timer = 0.0f;
ABMWithState(ActiveBlockModifier *abm_);
};
// 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){};
class LBMManager
{
public:
- LBMManager():
- m_query_mode(false)
- {}
-
+ LBMManager() {}
~LBMManager();
// Don't call this after loadIntroductionTimes() ran.
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.
// 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;