C++11 cleanup on constructors (#6000)
authorVincent Glize <vincentglize@hotmail.fr>
Mon, 19 Jun 2017 21:54:58 +0000 (23:54 +0200)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Mon, 19 Jun 2017 21:54:58 +0000 (23:54 +0200)
* C++11 cleanup on constructors dir script

40 files changed:
src/script/cpp_api/s_async.cpp
src/script/cpp_api/s_async.h
src/script/cpp_api/s_base.cpp
src/script/cpp_api/s_base.h
src/script/lua_api/l_areastore.cpp
src/script/lua_api/l_areastore.h
src/script/lua_api/l_camera.cpp
src/script/lua_api/l_camera.h
src/script/lua_api/l_itemstackmeta.h
src/script/lua_api/l_localplayer.cpp
src/script/lua_api/l_localplayer.h
src/script/lua_api/l_minimap.cpp
src/script/lua_api/l_minimap.h
src/script/lua_api/l_nodemeta.cpp
src/script/lua_api/l_nodemeta.h
src/script/lua_api/l_nodetimer.h
src/script/lua_api/l_object.h
src/script/lua_api/l_settings.cpp
src/script/lua_api/l_settings.h
src/script/lua_api/l_storage.h
src/script/lua_api/l_vmanip.cpp
src/script/lua_api/l_vmanip.h
src/threading/thread.cpp
src/threading/thread.h
src/unittest/test.cpp
src/unittest/test_connection.cpp
src/util/areastore.cpp
src/util/areastore.h
src/util/auth.cpp
src/util/enriched_string.cpp
src/util/enriched_string.h
src/util/numeric.h
src/util/pointedthing.cpp
src/util/pointedthing.h
src/util/serialize.cpp
src/util/serialize.h
src/util/sha1.cpp
src/util/sha1.h
src/util/timetaker.cpp
src/util/timetaker.h

index 7223590666525df1b567091551cea8d247baa9a4..5cca5fc03778f2b27bc050cb43d8cd51375946d8 100644 (file)
@@ -33,13 +33,6 @@ extern "C" {
 #include "porting.h"
 #include "common/c_internal.h"
 
-/******************************************************************************/
-AsyncEngine::AsyncEngine() :
-       initDone(false),
-       jobIdCounter(0)
-{
-}
-
 /******************************************************************************/
 AsyncEngine::~AsyncEngine()
 {
index 45f935d0a20ed1cdd5c15463e93e224b97bfd4a2..94b55db6e5a23cf2f72f0176671a043cdc7bd944 100644 (file)
@@ -39,24 +39,18 @@ class AsyncEngine;
 // Data required to queue a job
 struct LuaJobInfo
 {
-       LuaJobInfo() :
-               serializedFunction(""),
-               serializedParams(""),
-               serializedResult(""),
-               id(0),
-               valid(false)
-       {}
+       LuaJobInfo() {};
 
        // Function to be called in async environment
-       std::string serializedFunction;
+       std::string serializedFunction = "";
        // Parameter to be passed to function
-       std::string serializedParams;
+       std::string serializedParams = "";
        // Result of function call
-       std::string serializedResult;
+       std::string serializedResult = "";
        // JobID used to identify a job and match it to callback
-       unsigned int id;
+       unsigned int id = 0;
 
-       bool valid;
+       bool valid = false;
 };
 
 // Asynchronous working environment
@@ -68,7 +62,7 @@ public:
        void *run();
 
 private:
-       AsyncEngine *jobDispatcher;
+       AsyncEngine *jobDispatcher = nullptr;
 };
 
 // Asynchornous thread and job management
@@ -76,7 +70,7 @@ class AsyncEngine {
        friend class AsyncWorkerThread;
        typedef void (*StateInitializer)(lua_State *L, int top);
 public:
-       AsyncEngine();
+       AsyncEngine() {};
        ~AsyncEngine();
 
        /**
@@ -137,13 +131,13 @@ protected:
 
 private:
        // Variable locking the engine against further modification
-       bool initDone;
+       bool initDone = false;
 
        // Internal store for registred state initializers
        std::vector<StateInitializer> stateInitializers;
 
        // Internal counter to create job IDs
-       unsigned int jobIdCounter;
+       unsigned int jobIdCounter = 0;
 
        // Mutex to protect job queue
        std::mutex jobQueueMutex;
index 4d7461c5ba5d3b30302b922a3876803da1921c48..aaf26a9c3bec9d0dabff9992caf11bc0a48c35ea 100644 (file)
@@ -71,9 +71,7 @@ public:
        ScriptApiBase
 */
 
-ScriptApiBase::ScriptApiBase() :
-       m_luastackmutex(),
-       m_gamedef(NULL)
+ScriptApiBase::ScriptApiBase()
 {
 #ifdef SCRIPTAPI_LOCK_DEBUG
        m_lock_recursion_count = 0;
@@ -111,14 +109,6 @@ ScriptApiBase::ScriptApiBase() :
 
        lua_pushstring(m_luastack, porting::getPlatformName());
        lua_setglobal(m_luastack, "PLATFORM");
-
-       // m_secure gets set to true inside
-       // ScriptApiSecurity::initializeSecurity(), if neccessary.
-       // Default to false otherwise
-       m_secure = false;
-
-       m_environment = NULL;
-       m_guiengine = NULL;
 }
 
 ScriptApiBase::~ScriptApiBase()
index ed056db31b7f49f30b7859fbcfe5d58ea9e75e5b..38ee9901baa5ba2f9ea0af699d8efc0b285218d7 100644 (file)
@@ -119,7 +119,7 @@ protected:
 
        std::recursive_mutex m_luastackmutex;
        std::string     m_last_run_mod;
-       bool            m_secure;
+       bool            m_secure = false;
 #ifdef SCRIPTAPI_LOCK_DEBUG
        int             m_lock_recursion_count;
        std::thread::id m_owning_thread;
@@ -128,11 +128,11 @@ protected:
 private:
        static int luaPanic(lua_State *L);
 
-       lua_State*      m_luastack;
+       lua_State      *m_luastack = nullptr;
 
-       IGameDef*       m_gamedef;
-       Environment*    m_environment;
-       GUIEngine*      m_guiengine;
+       IGameDef       *m_gamedef = nullptr;
+       Environment    *m_environment = nullptr;
+       GUIEngine      *m_guiengine = nullptr;
 };
 
 #endif /* S_BASE_H_ */
index b81985a7f66129bec05cd9578f6cef20ed4a8ddf..1e30e704ef0810086ad8b012189cf5fed997d9aa 100644 (file)
@@ -300,20 +300,19 @@ int LuaAreaStore::l_from_file(lua_State *L)
        return deserialization_helper(L, o->as, is);
 }
 
-LuaAreaStore::LuaAreaStore()
+LuaAreaStore::LuaAreaStore() : as(AreaStore::getOptimalImplementation())
 {
-       this->as = AreaStore::getOptimalImplementation();
 }
 
 LuaAreaStore::LuaAreaStore(const std::string &type)
 {
 #if USE_SPATIAL
        if (type == "LibSpatial") {
-               this->as = new SpatialAreaStore();
+               as = new SpatialAreaStore();
        } else
 #endif
        {
-               this->as = new VectorAreaStore();
+               as = new VectorAreaStore();
        }
 }
 
index 8292e7712e761b6c0aaca2fc51c19f0ded08054f..9cb6249d0603851f9c6ca4bcb2fd155d3cbc707e 100644 (file)
@@ -49,7 +49,7 @@ private:
        static int l_from_file(lua_State *L);
 
 public:
-       AreaStore *as;
+       AreaStore *as = nullptr;
 
        LuaAreaStore();
        LuaAreaStore(const std::string &type);
index 86238419880bd7da6917604c7e73a195522630d5..ef842a222633d8530f854e310a5d2cee1bbf3e8f 100644 (file)
@@ -4,9 +4,8 @@
 #include "content_cao.h"
 #include "camera.h"
 
-LuaCamera::LuaCamera(Camera *m)
+LuaCamera::LuaCamera(Camera *m) : m_camera(m)
 {
-       m_camera = m;
 }
 
 void LuaCamera::create(lua_State *L, Camera *m)
index 04921ad03aa3b72f6b2066eadbcd7ab7727c759f..c4a0f877c260af846db5a824a50e55d7b10969e0 100644 (file)
@@ -26,7 +26,7 @@ private:
        static int l_get_look_horizontal(lua_State *L);
        static int l_get_aspect_ratio(lua_State *L);
 
-       Camera *m_camera;
+       Camera *m_camera = nullptr;
 
 public:
        LuaCamera(Camera *m);
index 4ef64a91ef71805efe031664ad17ffc0c91a414d..6e841d2dc85065ccdd8390ed902e714237307b2e 100644 (file)
@@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 class ItemStackMetaRef : public MetaDataRef
 {
 private:
-       ItemStack *istack;
+       ItemStack *istack = nullptr;
 
        static const char className[];
        static const luaL_Reg methods[];
index 7ec4eaa62c060c84e87bf15f95eff70ee1d6900e..7f932cbca2b86082412dc2c76c5e19bc0248e94c 100644 (file)
@@ -21,9 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "l_internal.h"
 #include "script/common/c_converter.h"
 
-LuaLocalPlayer::LuaLocalPlayer(LocalPlayer *m)
+LuaLocalPlayer::LuaLocalPlayer(LocalPlayer *m) : m_localplayer(m)
 {
-       m_localplayer = m;
 }
 
 void LuaLocalPlayer::create(lua_State *L, LocalPlayer *m)
index e56ec808fd6ca0b269dcdc83a43c3ba349c2e608..e618e6be5df5ee1420ba2505281dcfbc4b3bf100 100644 (file)
@@ -67,7 +67,7 @@ private:
 
        static int l_get_movement(lua_State *L);
 
-       LocalPlayer *m_localplayer;
+       LocalPlayer *m_localplayer = nullptr;
 
 public:
        LuaLocalPlayer(LocalPlayer *m);
index afb3766fbf71be68bc30267f17c6fc54c2619ab5..be981c88449546c59207ca122e87f15faefbc72d 100644 (file)
@@ -24,9 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "minimap.h"
 #include "settings.h"
 
-LuaMinimap::LuaMinimap(Minimap *m)
+LuaMinimap::LuaMinimap(Minimap *m) : m_minimap(m)
 {
-       m_minimap = m;
 }
 
 void LuaMinimap::create(lua_State *L, Minimap *m)
index ba702b0b1433b5bad659007d4bc1a26addc52650..d4fbf6330c363680b2f2448d318b6c1e1fd84368 100644 (file)
@@ -48,7 +48,7 @@ private:
        static int l_set_shape(lua_State *L);
        static int l_get_shape(lua_State *L);
 
-       Minimap *m_minimap;
+       Minimap *m_minimap = nullptr;
 
 public:
        LuaMinimap(Minimap *m);
index 5dfa6d52e97928bd57f4b2e447db644deb657ab7..aa8d1c453c184642544d369cdb5227414048b164 100644 (file)
@@ -171,14 +171,12 @@ bool NodeMetaRef::handleFromTable(lua_State *L, int table, Metadata *_meta)
 
 NodeMetaRef::NodeMetaRef(v3s16 p, ServerEnvironment *env):
        m_p(p),
-       m_env(env),
-       m_is_local(false)
+       m_env(env)
 {
 }
 
 NodeMetaRef::NodeMetaRef(Metadata *meta):
-       m_meta(meta),
-       m_is_local(true)
+       m_meta(meta)
 {
 }
 
index dd4260ff92979d42f3673c60a02351f123920d85..72d26ef36261fc14bdb65c693c19adad4dcdc6bf 100644 (file)
@@ -34,9 +34,9 @@ class NodeMetadata;
 class NodeMetaRef : public MetaDataRef {
 private:
        v3s16 m_p;
-       ServerEnvironment *m_env;
-       Metadata *m_meta;
-       bool m_is_local;
+       ServerEnvironment *m_env = nullptr;
+       Metadata *m_meta = nullptr;
+       bool m_is_local = false;
 
        static const char className[];
        static const luaL_Reg methodsServer[];
index ae362d8b3ed5397b1e38e896eec0032ec586bc1d..df77ed98f10ef6d74581bddaec6c4ba4ad6587fe 100644 (file)
@@ -29,7 +29,7 @@ class NodeTimerRef : public ModApiBase
 {
 private:
        v3s16 m_p;
-       ServerEnvironment *m_env;
+       ServerEnvironment *m_env = nullptr;
 
        static const char className[];
        static const luaL_Reg methods[];
index 9801ce02b3b5c2c7b7a839d741bba5f57d840dd6..77874f00c6e7638b81e50a1ee45871b81f1b4e98 100644 (file)
@@ -33,16 +33,29 @@ class RemotePlayer;
 */
 
 class ObjectRef : public ModApiBase {
-private:
-       ServerActiveObject *m_object;
-
-       static const char className[];
-       static const luaL_Reg methods[];
 public:
+       ObjectRef(ServerActiveObject *object);
+
+       ~ObjectRef();
+
+       // Creates an ObjectRef and leaves it on top of stack
+       // Not callable from Lua; all references are created on the C side.
+       static void create(lua_State *L, ServerActiveObject *object);
+
+       static void set_null(lua_State *L);
+
+       static void Register(lua_State *L);
+
        static ObjectRef *checkobject(lua_State *L, int narg);
 
        static ServerActiveObject* getobject(ObjectRef *ref);
 private:
+       ServerActiveObject *m_object = nullptr;
+
+       static const char className[];
+       static const luaL_Reg methods[];
+
+
        static LuaEntitySAO* getluaobject(ObjectRef *ref);
 
        static PlayerSAO* getplayersao(ObjectRef *ref);
@@ -319,18 +332,6 @@ private:
        // get_nametag_attributes(self)
        static int l_get_nametag_attributes(lua_State *L);
 
-public:
-       ObjectRef(ServerActiveObject *object);
-
-       ~ObjectRef();
-
-       // Creates an ObjectRef and leaves it on top of stack
-       // Not callable from Lua; all references are created on the C side.
-       static void create(lua_State *L, ServerActiveObject *object);
-
-       static void set_null(lua_State *L);
-
-       static void Register(lua_State *L);
 };
 
 #endif /* L_OBJECT_H_ */
index 70807f3d204a365410846f2153f5be4624de5186..3dc5c95748782afb020e3d64a47b576c4aa0b4f1 100644 (file)
@@ -32,9 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 LuaSettings::LuaSettings(Settings *settings, const std::string &filename) :
        m_settings(settings),
-       m_filename(filename),
-       m_is_own_settings(false),
-       m_write_allowed(true)
+       m_filename(filename)
 {
 }
 
index 54b003ab3b4fc174e499a9417b0fe85cfdf558b5..a664b449416179fcb0bee28e2832e48548344509 100644 (file)
@@ -57,10 +57,10 @@ private:
        // to_table(self) -> {[key1]=value1,...}
        static int l_to_table(lua_State *L);
 
-       Settings *m_settings;
+       Settings *m_settings = nullptr;
        std::string m_filename;
-       bool m_is_own_settings;
-       bool m_write_allowed;
+       bool m_is_own_settings = false;
+       bool m_write_allowed = true;
 
 public:
        LuaSettings(Settings *settings, const std::string &filename);
index ec6f8d94174a1a3a56fa8c5277b27463eb94d56b..eaf7ec9f6cb2bffbb489eb2a9ff5406042b53aed 100644 (file)
@@ -38,7 +38,7 @@ public:
 class StorageRef : public MetaDataRef
 {
 private:
-       ModMetadata *m_object;
+       ModMetadata *m_object = nullptr;
 
        static const char className[];
        static const luaL_Reg methods[];
index 254a7e5a64fbfaf92455576d3aefeeb11a3d445a..ed5042bcfd0cd585c432a16a1f47538e8436b684 100644 (file)
@@ -365,22 +365,17 @@ int LuaVoxelManip::l_get_emerged_area(lua_State *L)
        return 2;
 }
 
-LuaVoxelManip::LuaVoxelManip(MMVManip *mmvm, bool is_mg_vm)
+LuaVoxelManip::LuaVoxelManip(MMVManip *mmvm, bool is_mg_vm) : vm(mmvm), is_mapgen_vm(is_mg_vm)
 {
-       this->vm           = mmvm;
-       this->is_mapgen_vm = is_mg_vm;
 }
 
-LuaVoxelManip::LuaVoxelManip(Map *map)
+LuaVoxelManip::LuaVoxelManip(Map *map) : vm(new MMVManip(map))
 {
-       this->vm = new MMVManip(map);
-       this->is_mapgen_vm = false;
 }
 
 LuaVoxelManip::LuaVoxelManip(Map *map, v3s16 p1, v3s16 p2)
 {
-       this->vm = new MMVManip(map);
-       this->is_mapgen_vm = false;
+       vm = new MMVManip(map);
 
        v3s16 bp1 = getNodeBlockPos(p1);
        v3s16 bp2 = getNodeBlockPos(p2);
index b6a69f36a4ef80a9f580da65da4fa3d7c653243a..e706f3727d0ec4d82be1ed039240fea5286026d9 100644 (file)
@@ -35,7 +35,7 @@ class LuaVoxelManip : public ModApiBase
 {
 private:
        std::map<v3s16, MapBlock *> modified_blocks;
-       bool is_mapgen_vm;
+       bool is_mapgen_vm = false;
 
        static const char className[];
        static const luaL_Reg methods[];
@@ -65,7 +65,7 @@ private:
        static int l_get_emerged_area(lua_State *L);
 
 public:
-       MMVManip *vm;
+       MMVManip *vm = nullptr;
 
        LuaVoxelManip(MMVManip *mmvm, bool is_mapgen_vm);
        LuaVoxelManip(Map *map, v3s16 p1, v3s16 p2);
index cc4d65656f6dae7dc68f490917d2c730f17cbf55..8f54fb76286669838c74c7c326d3c1ea1633bcf0 100644 (file)
@@ -60,8 +60,6 @@ DEALINGS IN THE SOFTWARE.
 
 Thread::Thread(const std::string &name) :
        m_name(name),
-       m_retval(NULL),
-       m_joinable(false),
        m_request_stop(false),
        m_running(false)
 {
@@ -130,7 +128,7 @@ bool Thread::wait()
        m_thread_obj->join();
 
        delete m_thread_obj;
-       m_thread_obj = NULL;
+       m_thread_obj = nullptr;
 
        assert(m_running == false);
        m_joinable = false;
@@ -162,7 +160,7 @@ bool Thread::kill()
        wait();
 #endif
 
-       m_retval       = NULL;
+       m_retval       = nullptr;
        m_joinable     = false;
        m_request_stop = false;
 
index 284c8e46c4555ccf93f57eaa4884d3fa946e719e..dab5d0ec7aea3ddff8bfd02c843f1c9f585dda5a 100644 (file)
@@ -145,8 +145,8 @@ private:
 
        static void threadProc(Thread *thr);
 
-       void *m_retval;
-       bool m_joinable;
+       void *m_retval = nullptr;
+       bool m_joinable = false;
        std::atomic<bool> m_request_stop;
        std::atomic<bool> m_running;
        std::mutex m_mutex;
index 570807ba7626bb8be941d808383dd4a27e23b09a..911b647f7cfe0d8640b097ed97e708a2952b1b64 100644 (file)
@@ -70,16 +70,16 @@ public:
        virtual void unregisterModStorage(const std::string &name) {}
 
 private:
-       IItemDefManager *m_itemdef;
-       INodeDefManager *m_nodedef;
-       ICraftDefManager *m_craftdef;
-       ITextureSource *m_texturesrc;
-       IShaderSource *m_shadersrc;
-       ISoundManager *m_soundmgr;
-       MtEventManager *m_eventmgr;
-       scene::ISceneManager *m_scenemgr;
-       IRollbackManager *m_rollbackmgr;
-       EmergeManager *m_emergemgr;
+       IItemDefManager *m_itemdef = nullptr;
+       INodeDefManager *m_nodedef = nullptr;
+       ICraftDefManager *m_craftdef = nullptr;
+       ITextureSource *m_texturesrc = nullptr;
+       IShaderSource *m_shadersrc = nullptr;
+       ISoundManager *m_soundmgr = nullptr;
+       MtEventManager *m_eventmgr = nullptr;
+       scene::ISceneManager *m_scenemgr = nullptr;
+       IRollbackManager *m_rollbackmgr = nullptr;
+       EmergeManager *m_emergemgr = nullptr;
 };
 
 
index d63322d6902829e43fc7692ad68bd637505827fc..3ea3d74447982490c3a76426357e07a67fded464 100644 (file)
@@ -53,12 +53,7 @@ void TestConnection::runTests(IGameDef *gamedef)
 
 struct Handler : public con::PeerHandler
 {
-       Handler(const char *a_name)
-       {
-               count = 0;
-               last_id = 0;
-               name = a_name;
-       }
+       Handler(const char *a_name) : name(a_name) {}
 
        void peerAdded(con::Peer *peer)
        {
@@ -76,8 +71,8 @@ struct Handler : public con::PeerHandler
                count--;
        }
 
-       s32 count;
-       u16 last_id;
+       s32 count = 0;
+       u16 last_id = 0;
        const char *name;
 };
 
index cef67da2ce243378e24f7ba3b857ce7c09c25938..c660502f62f319b1f1af064cd1a999f0d012c079 100644 (file)
@@ -58,7 +58,7 @@ const Area *AreaStore::getArea(u32 id) const
 {
        AreaMap::const_iterator it = areas_map.find(id);
        if (it == areas_map.end())
-               return NULL;
+               return nullptr;
        return &it->second;
 }
 
@@ -239,7 +239,7 @@ bool SpatialAreaStore::insertArea(Area *a)
        if (!areas_map.insert(std::make_pair(a->id, *a)).second)
                // ID is not unique
                return false;
-       m_tree->insertData(0, NULL, get_spatial_region(a->minedge, a->maxedge), a->id);
+       m_tree->insertData(0, nullptr, get_spatial_region(a->minedge, a->maxedge), a->id);
        invalidateCache();
        return true;
 }
index bebecfd78d4d332967b7f98bf69c658455bd4c14..8c22c3ad75523ab55141aa3ac1ba140be0361c17 100644 (file)
@@ -38,14 +38,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 
 struct Area {
-       Area() : id(U32_MAX) {}
+       Area() {}
        Area(const v3s16 &mine, const v3s16 &maxe) :
-               id(U32_MAX), minedge(mine), maxedge(maxe)
+               minedge(mine), maxedge(maxe)
        {
                sortBoxVerticies(minedge, maxedge);
        }
 
-       u32 id;
+       u32 id = U32_MAX;
        v3s16 minedge, maxedge;
        std::string data;
 };
@@ -54,10 +54,7 @@ struct Area {
 class AreaStore {
 public:
        AreaStore() :
-               m_cache_enabled(true),
-               m_cacheblock_radius(64),
-               m_res_cache(1000, &cacheMiss, this),
-               m_next_id(0)
+               m_res_cache(1000, &cacheMiss, this)
        {}
 
        virtual ~AreaStore() {}
@@ -123,13 +120,13 @@ private:
        /// Called by the cache when a value isn't found in the cache.
        static void cacheMiss(void *data, const v3s16 &mpos, std::vector<Area *> *dest);
 
-       bool m_cache_enabled;
+       bool m_cache_enabled = true;
        /// Range, in nodes, of the getAreasForPos cache.
        /// If you modify this, call invalidateCache()
-       u8 m_cacheblock_radius;
+       u8 m_cacheblock_radius = 64;
        LRUCache<v3s16, std::vector<Area *> > m_res_cache;
 
-       u32 m_next_id;
+       u32 m_next_id = 0;
 };
 
 
@@ -165,8 +162,8 @@ protected:
        virtual void getAreasForPosImpl(std::vector<Area *> *result, v3s16 pos);
 
 private:
-       SpatialIndex::ISpatialIndex *m_tree;
-       SpatialIndex::IStorageManager *m_storagemanager;
+       SpatialIndex::ISpatialIndex *m_tree = nullptr;
+       SpatialIndex::IStorageManager *m_storagemanager = nullptr;
 
        class VectorResultVisitor : public SpatialIndex::IVisitor {
        public:
@@ -194,8 +191,8 @@ private:
                }
 
        private:
-               SpatialAreaStore *m_store;
-               std::vector<Area *> *m_result;
+               SpatialAreaStore *m_store = nullptr;
+               std::vector<Area *> *m_result = nullptr;
        };
 };
 
index 912987259623c9f4c35b887b7a5684565b35bec6..c329e36e6cf50757adf557eaf1066c1fd93fda36 100644 (file)
@@ -71,7 +71,7 @@ std::string generate_srp_verifier(const std::string &name,
        // get modified if &salt_ptr isn't NULL.
        char *salt_ptr = (char *)salt.c_str();
 
-       char *bytes_v = NULL;
+       char *bytes_v = nullptr;
        size_t verifier_len = 0;
        gen_srp_v(name, password, &salt_ptr, &salt_len, &bytes_v, &verifier_len);
        std::string verifier = std::string(bytes_v, verifier_len);
@@ -84,9 +84,9 @@ void generate_srp_verifier_and_salt(const std::string &name,
        const std::string &password, std::string *verifier,
        std::string *salt)
 {
-       char *bytes_v = NULL;
+       char *bytes_v = nullptr;
        size_t verifier_len;
-       char *salt_ptr = NULL;
+       char *salt_ptr = nullptr;
        size_t salt_len;
        gen_srp_v(name, password, &salt_ptr, &salt_len, &bytes_v, &verifier_len);
        *verifier = std::string(bytes_v, verifier_len);
index a7fc3a828255a5bcb1b14c2483bde7faf803b9dd..05d7b8c25a6356c4cc1c4c3d31f9875d364f8913 100644 (file)
@@ -30,8 +30,7 @@ EnrichedString::EnrichedString()
 EnrichedString::EnrichedString(const std::wstring &string,
                const std::vector<SColor> &colors):
        m_string(string),
-       m_colors(colors),
-       m_has_background(false)
+       m_colors(colors)
 {}
 
 EnrichedString::EnrichedString(const std::wstring &s, const SColor &color)
index 1aca8948ae6160720b6c899d14e0a0389148a421..a3b8feb2a6264e8927c96ab71e2444fe29770082 100644 (file)
@@ -84,7 +84,7 @@ public:
 private:
        std::wstring m_string;
        std::vector<irr::video::SColor> m_colors;
-       bool m_has_background;
+       bool m_has_background = false;
        irr::video::SColor m_background;
 };
 
index 3b1b85f64640adf4b1be8fb18db683908a1e1508..5143c92e6e56c52bbf7822023819abc2569ba0ea 100644 (file)
@@ -282,7 +282,7 @@ inline aabb3f getNodeBox(v3s16 p, float d)
 class IntervalLimiter
 {
 public:
-       IntervalLimiter() : m_accumulator(0) {}
+       IntervalLimiter() {}
        /*
                dtime: time from last call to this method
                wanted_interval: interval wanted
@@ -300,7 +300,7 @@ public:
        }
 
 private:
-       float m_accumulator;
+       float m_accumulator = 0.0f;
 };
 
 
index ed3d4bb672c6400b05b68a163477421975833476..f1f1d3f2090773ab21cec3ecdfb741816fa7e12a 100644 (file)
@@ -23,16 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "../exceptions.h"
 #include <sstream>
 
-PointedThing::PointedThing():
-       type(POINTEDTHING_NOTHING),
-       node_undersurface(0,0,0),
-       node_abovesurface(0,0,0),
-       node_real_undersurface(0,0,0),
-       intersection_point(0,0,0),
-       intersection_normal(0,0,0),
-       object_id(-1)
-{}
-
 std::string PointedThing::dump() const
 {
        std::ostringstream os(std::ios::binary);
index f695a4ebded52ab3c660abda9656a4584164f6f3..92c33968fc431ae47784ff5f39509b71a828e8b9 100644 (file)
@@ -36,7 +36,7 @@ enum PointedThingType
 struct PointedThing
 {
        //! The type of the pointed object.
-       PointedThingType type;
+       PointedThingType type = POINTEDTHING_NOTHING;
        /*!
         * Only valid if type is POINTEDTHING_NODE.
         * The coordinates of the node which owns the
@@ -74,9 +74,9 @@ struct PointedThing
         * Only valid if type is POINTEDTHING_OBJECT.
         * The ID of the object the ray hit.
         */
-       s16 object_id;
+       s16 object_id = -1;
 
-       PointedThing();
+       PointedThing() {};
        std::string dump() const;
        void serialize(std::ostream &os) const;
        void deSerialize(std::istream &is);
index 61d369bc487f3a5ae8099c228cb09568237bc47d..75843cb1be11ae212d84d90d097421df54041acc 100644 (file)
@@ -422,7 +422,7 @@ bool deSerializeStringToStruct(std::string valstr,
 
        char *fmtpos, *fmt = &format[0];
        while ((f = strtok_r(fmt, ",", &fmtpos)) && s) {
-               fmt = NULL;
+               fmt = nullptr;
 
                bool is_unsigned = false;
                int width = 0;
@@ -510,7 +510,7 @@ bool deSerializeStringToStruct(std::string valstr,
                                bufpos += sizeof(std::string *);
                                strs_alloced.push_back(str);
 
-                               s = *snext ? snext + 1 : NULL;
+                               s = *snext ? snext + 1 : nullptr;
                                break;
                        case 'v':
                                while (*s == ' ' || *s == '\t')
@@ -582,7 +582,7 @@ bool serializeStructToString(std::string *out,
        char *bufpos = (char *) value;
        char *fmtpos, *fmt = &format[0];
        while ((f = strtok_r(fmt, ",", &fmtpos))) {
-               fmt = NULL;
+               fmt = nullptr;
                bool is_unsigned = false;
                int width = 0;
                char valtype = *f;
index e224341918480ed1531ab1acaa31068fcea5ea36..f434805578304fcbf791fa4a7b5a588312776452 100644 (file)
@@ -454,8 +454,7 @@ class BufReader {
 public:
        BufReader(const u8 *data_, size_t size_) :
                data(data_),
-               size(size_),
-               pos(0)
+               size(size_)
        {
        }
 
@@ -515,7 +514,7 @@ public:
 
        const u8 *data;
        size_t size;
-       size_t pos;
+       size_t pos = 0;
 };
 
 #undef MAKE_BUFREADER_GET_FXN
index 6ed7385d51fa255b719eee7a1ec634319fda0148..c04b6c0c039f8e7e02d482a4cde15569c72f86ac 100644 (file)
@@ -66,15 +66,6 @@ SHA1::SHA1()
 {
        // make sure that the data type is the right size
        assert( sizeof( Uint32 ) * 5 == 20 );
-       
-       // initialize
-       H0 = 0x67452301;
-       H1 = 0xefcdab89;
-       H2 = 0x98badcfe;
-       H3 = 0x10325476;
-       H4 = 0xc3d2e1f0;
-       unprocessedBytes = 0;
-       size = 0;
 }
 
 // Destructor ********************************************************
index 0ac08c67b9fb76217c0650d2da2c02fc5b7b123a..a55f94f44488adad6331429745c55f7aa24b1ec2 100644 (file)
@@ -31,10 +31,14 @@ class SHA1
 {
 private:
        // fields
-       Uint32 H0, H1, H2, H3, H4;
+       Uint32 H0 = 0x67452301;
+       Uint32 H1 = 0xefcdab89;
+       Uint32 H2 = 0x98badcfe;
+       Uint32 H3 = 0x10325476;
+       Uint32 H4 = 0xc3d2e1f0;
        unsigned char bytes[64];
-       int unprocessedBytes;
-       Uint32 size;
+       int unprocessedBytes = 0;
+       Uint32 size = 0;
        void process();
 
 public:
index ac686c3a36828f096a02af3f0ae541e6745a7e2f..6079e5cca87feed8f5ce0d9ccb8bec0dfca69831 100644 (file)
@@ -27,7 +27,6 @@ TimeTaker::TimeTaker(const std::string &name, u64 *result, TimePrecision prec)
 {
        m_name = name;
        m_result = result;
-       m_running = true;
        m_precision = prec;
        m_time1 = porting::getTime(prec);
 }
@@ -36,7 +35,7 @@ u64 TimeTaker::stop(bool quiet)
 {
        if (m_running) {
                u64 dtime = porting::getTime(m_precision) - m_time1;
-               if (m_result != NULL) {
+               if (m_result != nullptr) {
                        (*m_result) += dtime;
                } else {
                        if (!quiet) {
index c10f4f535d32f3c9e20e06e53632ad7b414a34c9..34564ee4bbd9a5c9bd705ebb48c6f20696b016e7 100644 (file)
@@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 class TimeTaker
 {
 public:
-       TimeTaker(const std::string &name, u64 *result=NULL,
+       TimeTaker(const std::string &name, u64 *result=nullptr,
                TimePrecision prec=PRECISION_MILLI);
 
        ~TimeTaker()
@@ -45,9 +45,9 @@ public:
 private:
        std::string m_name;
        u64 m_time1;
-       bool m_running;
+       bool m_running = true;
        TimePrecision m_precision;
-       u64 *m_result;
+       u64 *m_result = nullptr;
 };
 
 #endif