C++11 patchset 9: move hardcoded init parameters to class definitions (part 1) (...
authorLoïc Blot <nerzhul@users.noreply.github.com>
Fri, 16 Jun 2017 09:25:52 +0000 (11:25 +0200)
committerGitHub <noreply@github.com>
Fri, 16 Jun 2017 09:25:52 +0000 (11:25 +0200)
* C++11 patchset 9: move hardcoded init parameters to class definitions

C++11 introduced the possibility to define the default values directly in class definitions, do it on current code

Also remove some unused attributes

* CollisionInfo::bouncy
* collisionMoveResult::collides_xy
* collisionMoveResult::standing_on_unloaded
* Clouds::speed

* More constructor cleanups + some variables removal

* remove only write guiFormSpecMenu::m_old_tooltip
* move header included inside defintions in genericobject.h
* remove some unused since years exception classes
* remove unused & empty debug_stacks_init
* remove unused & empty content_nodemeta_serialize_legacy
* remove forgotten useless bool (bouncy) in collision.cpp code

50 files changed:
src/ban.cpp
src/ban.h
src/camera.cpp
src/camera.h
src/chat.cpp
src/chat.h
src/client.cpp
src/client.h
src/clientenvironment.cpp
src/clientenvironment.h
src/clientiface.h
src/clientmap.cpp
src/clientmap.h
src/clientmedia.cpp
src/clientmedia.h
src/clientsimpleobject.h
src/clouds.cpp
src/clouds.h
src/collision.cpp
src/collision.h
src/content_cao.cpp
src/content_cao.h
src/content_cso.cpp
src/content_nodemeta.cpp
src/content_nodemeta.h
src/content_sao.cpp
src/content_sao.h
src/craftdef.h
src/database-postgresql.cpp
src/database-postgresql.h
src/database-redis.h
src/database-sqlite3.cpp
src/database-sqlite3.h
src/debug.cpp
src/debug.h
src/emerge.cpp
src/emerge.h
src/environment.cpp
src/environment.h
src/event.h
src/exceptions.h
src/fontengine.cpp
src/fontengine.h
src/genericobject.h
src/guiChatConsole.cpp
src/guiChatConsole.h
src/guiEngine.cpp
src/guiEngine.h
src/guiFormSpecMenu.cpp
src/guiFormSpecMenu.h

index 5fa430702724feee2b94fa205559be5759ea50e8..7a7fb8c3c7219af0f9b01439cd94ce6ff32898d6 100644 (file)
@@ -28,14 +28,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "filesys.h"
 
 BanManager::BanManager(const std::string &banfilepath):
-               m_banfilepath(banfilepath),
-               m_modified(false)
+               m_banfilepath(banfilepath)
 {
-       try{
+       try {
                load();
-       }
-       catch(SerializationError &e)
-       {
+       } catch(SerializationError &e) {
                warningstream<<"BanManager: creating "
                                <<m_banfilepath<<std::endl;
        }
index 7c88406d48e79462f13380ffc9a22c610738b4c3..35bf10abb8d5ed4015128cbdc9c517b979f6498d 100644 (file)
--- a/src/ban.h
+++ b/src/ban.h
@@ -44,9 +44,9 @@ public:
 
 private:
        std::mutex m_mutex;
-       std::string m_banfilepath;
+       std::string m_banfilepath = "";
        StringMap m_ips;
-       bool m_modified;
+       bool m_modified = false;
 };
 
 #endif
index 52a42a3a9e6bbb1d8c867c77de953b99d7a7c01f..d5e32bf5ac44281a6a5fadc59a669fc7b2763db2 100644 (file)
@@ -41,36 +41,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
                Client *client):
-       m_playernode(NULL),
-       m_headnode(NULL),
-       m_cameranode(NULL),
-
-       m_wieldmgr(NULL),
-       m_wieldnode(NULL),
-
        m_draw_control(draw_control),
-       m_client(client),
-
-       m_camera_position(0,0,0),
-       m_camera_direction(0,0,0),
-       m_camera_offset(0,0,0),
-
-       m_aspect(1.0),
-       m_fov_x(1.0),
-       m_fov_y(1.0),
-
-       m_view_bobbing_anim(0),
-       m_view_bobbing_state(0),
-       m_view_bobbing_speed(0),
-       m_view_bobbing_fall(0),
-
-       m_digging_anim(0),
-       m_digging_button(-1),
-
-       m_wield_change_timer(0.125),
-       m_wield_item_next(),
-
-       m_camera_mode(CAMERA_MODE_FIRST)
+       m_client(client)
 {
        //dstream<<FUNCTION_NAME<<std::endl;
 
index 1e4800cbad9aabec505741932cc084bfedd9058c..8d213ede7dbe238e90368063eaf56146868542a4 100644 (file)
@@ -168,12 +168,12 @@ public:
 
 private:
        // Nodes
-       scene::ISceneNode* m_playernode;
-       scene::ISceneNode* m_headnode;
-       scene::ICameraSceneNode* m_cameranode;
+       scene::ISceneNode *m_playernode = nullptr;
+       scene::ISceneNode *m_headnode = nullptr;
+       scene::ICameraSceneNode *m_cameranode = nullptr;
 
-       scene::ISceneManager* m_wieldmgr;
-       WieldMeshSceneNode* m_wieldnode;
+       scene::ISceneManager *m_wieldmgr = nullptr;
+       WieldMeshSceneNode *m_wieldnode = nullptr;
 
        // draw control
        MapDrawControl& m_draw_control;
@@ -189,33 +189,33 @@ private:
        v3s16 m_camera_offset;
 
        // Field of view and aspect ratio stuff
-       f32 m_aspect;
-       f32 m_fov_x;
-       f32 m_fov_y;
+       f32 m_aspect = 1.0f;
+       f32 m_fov_x = 1.0f;
+       f32 m_fov_y = 1.0f;
 
        // View bobbing animation frame (0 <= m_view_bobbing_anim < 1)
-       f32 m_view_bobbing_anim;
+       f32 m_view_bobbing_anim = 0.0f;
        // If 0, view bobbing is off (e.g. player is standing).
        // If 1, view bobbing is on (player is walking).
        // If 2, view bobbing is getting switched off.
-       s32 m_view_bobbing_state;
+       s32 m_view_bobbing_state = 0;
        // Speed of view bobbing animation
-       f32 m_view_bobbing_speed;
+       f32 m_view_bobbing_speed = 0.0f;
        // Fall view bobbing
-       f32 m_view_bobbing_fall;
+       f32 m_view_bobbing_fall = 0.0f;
 
        // Digging animation frame (0 <= m_digging_anim < 1)
-       f32 m_digging_anim;
+       f32 m_digging_anim = 0.0f;
        // If -1, no digging animation
        // If 0, left-click digging animation
        // If 1, right-click digging animation
-       s32 m_digging_button;
+       s32 m_digging_button = -1;
 
        // Animation when changing wielded item
-       f32 m_wield_change_timer;
+       f32 m_wield_change_timer = 0.125f;
        ItemStack m_wield_item_next;
 
-       CameraMode m_camera_mode;
+       CameraMode m_camera_mode = CAMERA_MODE_FIRST;
 
        f32 m_cache_fall_bobbing_amount;
        f32 m_cache_view_bobbing_amount;
index ade3fefd3a42cbec629882d143bcb4906384eaa2..72abc466960181b36b1563683c69d70d5b37ff7d 100644 (file)
@@ -27,13 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "util/numeric.h"
 
 ChatBuffer::ChatBuffer(u32 scrollback):
-       m_scrollback(scrollback),
-       m_unformatted(),
-       m_cols(0),
-       m_rows(0),
-       m_scroll(0),
-       m_formatted(),
-       m_empty_formatted_line()
+       m_scrollback(scrollback)
 {
        if (m_scrollback == 0)
                m_scrollback = 1;
@@ -383,16 +377,7 @@ s32 ChatBuffer::getBottomScrollPos() const
 
 ChatPrompt::ChatPrompt(const std::wstring &prompt, u32 history_limit):
        m_prompt(prompt),
-       m_line(L""),
-       m_history(),
-       m_history_index(0),
-       m_history_limit(history_limit),
-       m_cols(0),
-       m_view(0),
-       m_cursor(0),
-       m_cursor_len(0),
-       m_nick_completion_start(0),
-       m_nick_completion_end(0)
+       m_history_limit(history_limit)
 {
 }
 
index b7c6b74b90a8d1594972ea828b6fd55cd8cba8fa..6a6b7c26ff5d93aebd85d4ec3f632ccb3390616c 100644 (file)
@@ -32,21 +32,19 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 struct ChatLine
 {
        // age in seconds
-       f32 age;
+       f32 age = 0.0f;
        // name of sending player, or empty if sent by server
        EnrichedString name;
        // message text
        EnrichedString text;
 
        ChatLine(const std::wstring &a_name, const std::wstring &a_text):
-               age(0.0),
                name(a_name),
                text(a_text)
        {
        }
 
        ChatLine(const EnrichedString &a_name, const EnrichedString &a_text):
-               age(0.0),
                name(a_name),
                text(a_text)
        {
@@ -132,11 +130,11 @@ private:
        std::vector<ChatLine> m_unformatted;
 
        // Number of character columns in console
-       u32 m_cols;
+       u32 m_cols = 0;
        // Number of character rows in console
-       u32 m_rows;
+       u32 m_rows = 0;
        // Scroll position (console's top line index into m_formatted)
-       s32 m_scroll;
+       s32 m_scroll = 0;
        // Array of formatted lines
        std::vector<ChatFormattedLine> m_formatted;
        // Empty formatted line, for error returns
@@ -225,29 +223,29 @@ protected:
 
 private:
        // Prompt prefix
-       std::wstring m_prompt;
+       std::wstring m_prompt = L"";
        // Currently edited line
-       std::wstring m_line;
+       std::wstring m_line = L"";
        // History buffer
        std::vector<std::wstring> m_history;
        // History index (0 <= m_history_index <= m_history.size())
-       u32 m_history_index;
+       u32 m_history_index = 0;
        // Maximum number of history entries
        u32 m_history_limit;
 
        // Number of columns excluding columns reserved for the prompt
-       s32 m_cols;
+       s32 m_cols = 0;
        // Start of visible portion (index into m_line)
-       s32 m_view;
+       s32 m_view = 0;
        // Cursor (index into m_line)
-       s32 m_cursor;
+       s32 m_cursor = 0;
        // Cursor length (length of selected portion of line)
-       s32 m_cursor_len;
+       s32 m_cursor_len = 0;
 
        // Last nick completion start (index into m_line)
-       s32 m_nick_completion_start;
+       s32 m_nick_completion_start = 0;
        // Last nick completion start (index into m_line)
-       s32 m_nick_completion_end;
+       s32 m_nick_completion_end = 0;
 };
 
 class ChatBackend
index 1f6f64ce077cbc2185dc7c976b38b9ae1ba2950e..7a097bc0d34d85481e62e4cf6af6f38da03ae283 100644 (file)
@@ -69,11 +69,6 @@ Client::Client(
                bool ipv6,
                GameUIFlags *game_ui_flags
 ):
-       m_packetcounter_timer(0.0),
-       m_connection_reinit_timer(0.1),
-       m_avg_rtt_timer(0.0),
-       m_playerpos_send_timer(0.0),
-       m_ignore_damage_timer(0.0),
        m_tsrc(tsrc),
        m_shsrc(shsrc),
        m_itemdef(itemdef),
@@ -92,40 +87,13 @@ Client::Client(
        m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, ipv6, this),
        m_address_name(address_name),
        m_device(device),
-       m_camera(NULL),
-       m_minimap(NULL),
-       m_minimap_disabled_by_server(false),
        m_server_ser_ver(SER_FMT_VER_INVALID),
-       m_proto_ver(0),
-       m_playeritem(0),
-       m_inventory_updated(false),
-       m_inventory_from_server(NULL),
-       m_inventory_from_server_age(0.0),
-       m_animation_time(0),
-       m_crack_level(-1),
-       m_crack_pos(0,0,0),
        m_last_chat_message_sent(time(NULL)),
-       m_chat_message_allowance(5.0f),
-       m_map_seed(0),
        m_password(password),
        m_chosen_auth_mech(AUTH_MECHANISM_NONE),
-       m_auth_data(NULL),
-       m_access_denied(false),
-       m_access_denied_reconnect(false),
-       m_itemdef_received(false),
-       m_nodedef_received(false),
        m_media_downloader(new ClientMediaDownloader()),
-       m_time_of_day_set(false),
-       m_last_time_of_day_f(-1),
-       m_time_of_day_update_timer(0),
-       m_recommended_send_interval(0.1),
-       m_removed_sounds_check_timer(0),
        m_state(LC_Created),
-       m_localdb(NULL),
-       m_script(NULL),
-       m_mod_storage_save_timer(10.0f),
-       m_game_ui_flags(game_ui_flags),
-       m_shutdown(false)
+       m_game_ui_flags(game_ui_flags)
 {
        // Add local player
        m_env.setLocalPlayer(new LocalPlayer(this, playername));
index babfe46801772c0bcbdcee061fd098d4f7bbb086..1d5ab1298d603058a281844d59d3495a676ba92e 100644 (file)
@@ -575,11 +575,11 @@ private:
 
        bool canSendChatMessage() const;
 
-       float m_packetcounter_timer;
-       float m_connection_reinit_timer;
-       float m_avg_rtt_timer;
-       float m_playerpos_send_timer;
-       float m_ignore_damage_timer; // Used after server moves player
+       float m_packetcounter_timer = 0.0f;
+       float m_connection_reinit_timer = 0.1f;
+       float m_avg_rtt_timer = 0.0f;
+       float m_playerpos_send_timer = 0.0f;
+       float m_ignore_damage_timer = 0.0f; // Used after server moves player
        IntervalLimiter m_map_timer_and_unload_interval;
 
        IWritableTextureSource *m_tsrc;
@@ -596,9 +596,9 @@ private:
        con::Connection m_con;
        std::string m_address_name;
        IrrlichtDevice *m_device;
-       Camera *m_camera;
-       Minimap *m_minimap;
-       bool m_minimap_disabled_by_server;
+       Camera *m_camera = nullptr;
+       Minimap *m_minimap = nullptr;
+       bool m_minimap_disabled_by_server = false;
        // Server serialization version
        u8 m_server_ser_ver;
 
@@ -607,16 +607,16 @@ private:
        // and aren't accurate. We simply just don't know, because
        // the server didn't send the version back then.
        // If 0, server init hasn't been received yet.
-       u8 m_proto_ver;
+       u8 m_proto_ver = 0;
 
-       u16 m_playeritem;
-       bool m_inventory_updated;
-       Inventory *m_inventory_from_server;
-       float m_inventory_from_server_age;
+       u16 m_playeritem = 0;
+       bool m_inventory_updated = false;
+       Inventory *m_inventory_from_server = nullptr;
+       float m_inventory_from_server_age = 0.0f;
        PacketCounter m_packetcounter;
        // Block mesh animation parameters
-       float m_animation_time;
-       int m_crack_level;
+       float m_animation_time = 0.0f;
+       int m_crack_level = -1;
        v3s16 m_crack_pos;
        // 0 <= m_daynight_i < DAYNIGHT_CACHE_COUNT
        //s32 m_daynight_i;
@@ -624,13 +624,13 @@ private:
        std::queue<std::wstring> m_chat_queue;
        std::queue<std::wstring> m_out_chat_queue;
        u32 m_last_chat_message_sent;
-       float m_chat_message_allowance;
+       float m_chat_message_allowance = 5.0f;
 
        // The authentication methods we can use to enter sudo mode (=change password)
        u32 m_sudo_auth_methods;
 
        // The seed returned by the server in TOCLIENT_INIT is stored here
-       u64 m_map_seed;
+       u64 m_map_seed = 0;
 
        // Auth data
        std::string m_playername;
@@ -639,27 +639,27 @@ private:
        std::string m_new_password;
        // Usable by auth mechanisms.
        AuthMechanism m_chosen_auth_mech;
-       void * m_auth_data;
+       void *m_auth_data = nullptr;
 
 
-       bool m_access_denied;
-       bool m_access_denied_reconnect;
-       std::string m_access_denied_reason;
+       bool m_access_denied = false;
+       bool m_access_denied_reconnect = false;
+       std::string m_access_denied_reason = "";
        std::queue<ClientEvent> m_client_event_queue;
-       bool m_itemdef_received;
-       bool m_nodedef_received;
+       bool m_itemdef_received = false;
+       bool m_nodedef_received = false;
        ClientMediaDownloader *m_media_downloader;
 
        // time_of_day speed approximation for old protocol
-       bool m_time_of_day_set;
-       float m_last_time_of_day_f;
-       float m_time_of_day_update_timer;
+       bool m_time_of_day_set = false;
+       float m_last_time_of_day_f = -1.0f;
+       float m_time_of_day_update_timer = 0.0f;
 
        // An interval for generally sending object positions and stuff
-       float m_recommended_send_interval;
+       float m_recommended_send_interval = 0.1f;
 
        // Sounds
-       float m_removed_sounds_check_timer;
+       float m_removed_sounds_check_timer = 0.0f;
        // Mapping from server sound ids to our sound ids
        std::unordered_map<s32, int> m_sounds_server_to_client;
        // And the other way!
@@ -681,17 +681,17 @@ private:
        LocalClientState m_state;
 
        // Used for saving server map to disk client-side
-       MapDatabase *m_localdb;
+       MapDatabase *m_localdb = nullptr;
        IntervalLimiter m_localdb_save_interval;
        u16 m_cache_save_interval;
 
-       ClientScripting *m_script;
+       ClientScripting *m_script = nullptr;
        bool m_modding_enabled;
        std::unordered_map<std::string, ModMetadata *> m_mod_storages;
-       float m_mod_storage_save_timer;
+       float m_mod_storage_save_timer = 10.0f;
        GameUIFlags *m_game_ui_flags;
 
-       bool m_shutdown;
+       bool m_shutdown = false;
 };
 
 #endif // !CLIENT_HEADER
index d6af06ddebff0c63bcb51aaadc73bc1ff5f322b6..2a761ee1dd43a008e7fcf257bd599e229f42537c 100644 (file)
@@ -41,11 +41,9 @@ ClientEnvironment::ClientEnvironment(ClientMap *map, scene::ISceneManager *smgr,
        IrrlichtDevice *irr):
        Environment(client),
        m_map(map),
-       m_local_player(NULL),
        m_smgr(smgr),
        m_texturesource(texturesource),
        m_client(client),
-       m_script(NULL),
        m_irr(irr)
 {
        char zero = 0;
index 2906553f0427632e53fec234a34046ebf92cc318..c8b192ee99b889d972bdd60c9d0f98525bddb674 100644 (file)
@@ -176,11 +176,11 @@ public:
        v3s16 getCameraOffset() const { return m_camera_offset; }
 private:
        ClientMap *m_map;
-       LocalPlayer *m_local_player;
+       LocalPlayer *m_local_player = nullptr;
        scene::ISceneManager *m_smgr;
        ITextureSource *m_texturesource;
        Client *m_client;
-       ClientScripting *m_script;
+       ClientScripting *m_script = nullptr;
        IrrlichtDevice *m_irr;
        ClientActiveObjectMap m_active_objects;
        std::vector<ClientSimpleObject*> m_simple_objects;
index edcd91ef3010ba26e99fac821afc5b1ae9217bd0..09855a3725327ff9fc9b00bc1e051e89b4752e88 100644 (file)
@@ -226,51 +226,27 @@ public:
        // NOTE: If client is made allowed to exist while peer doesn't,
        //       this has to be set to 0 when there is no peer.
        //       Also, the client must be moved to some other container.
-       u16 peer_id;
+       u16 peer_id = PEER_ID_INEXISTENT;
        // The serialization version to use with the client
-       u8 serialization_version;
+       u8 serialization_version = SER_FMT_VER_INVALID;
        //
-       u16 net_proto_version;
+       u16 net_proto_version = 0;
 
        /* Authentication information */
-       std::string enc_pwd;
-       bool create_player_on_auth_success;
-       AuthMechanism chosen_mech;
-       void * auth_data;
-       u32 allowed_auth_mechs;
-       u32 allowed_sudo_mechs;
+       std::string enc_pwd = "";
+       bool create_player_on_auth_success = false;
+       AuthMechanism chosen_mech  = AUTH_MECHANISM_NONE;
+       void *auth_data = nullptr;
+       u32 allowed_auth_mechs = 0;
+       u32 allowed_sudo_mechs = 0;
 
        bool isSudoMechAllowed(AuthMechanism mech)
        { return allowed_sudo_mechs & mech; }
        bool isMechAllowed(AuthMechanism mech)
        { return allowed_auth_mechs & mech; }
 
-       RemoteClient():
-               peer_id(PEER_ID_INEXISTENT),
-               serialization_version(SER_FMT_VER_INVALID),
-               net_proto_version(0),
-               create_player_on_auth_success(false),
-               chosen_mech(AUTH_MECHANISM_NONE),
-               auth_data(NULL),
-               m_time_from_building(9999),
-               m_pending_serialization_version(SER_FMT_VER_INVALID),
-               m_state(CS_Created),
-               m_nearest_unsent_d(0),
-               m_nearest_unsent_reset_timer(0.0),
-               m_excess_gotblocks(0),
-               m_nothing_to_send_pause_timer(0.0),
-               m_name(""),
-               m_version_major(0),
-               m_version_minor(0),
-               m_version_patch(0),
-               m_full_version("unknown"),
-               m_deployed_compression(0),
-               m_connection_time(porting::getTimeS())
-       {
-       }
-       ~RemoteClient()
-       {
-       }
+       RemoteClient() {}
+       ~RemoteClient() {}
 
        /*
                Finds block that should be sent next to the client.
@@ -317,7 +293,7 @@ public:
        }
 
        // Time from last placing or removing blocks
-       float m_time_from_building;
+       float m_time_from_building = 9999;
 
        /*
                List of active objects that the client knows of.
@@ -361,10 +337,10 @@ public:
        u8 getPatch() const { return m_version_patch; }
 private:
        // Version is stored in here after INIT before INIT2
-       u8 m_pending_serialization_version;
+       u8 m_pending_serialization_version = SER_FMT_VER_INVALID;
 
        /* current state of client */
-       ClientState m_state;
+       ClientState m_state = CS_Created;
 
        /*
                Blocks that have been sent to client.
@@ -376,9 +352,9 @@ private:
                No MapBlock* is stored here because the blocks can get deleted.
        */
        std::set<v3s16> m_blocks_sent;
-       s16 m_nearest_unsent_d;
+       s16 m_nearest_unsent_d = 0;
        v3s16 m_last_center;
-       float m_nearest_unsent_reset_timer;
+       float m_nearest_unsent_reset_timer = 0.0f;
 
        /*
                Blocks that are currently on the line.
@@ -407,31 +383,31 @@ private:
                and the client then sends two GOTBLOCKs.
                This is resetted by PrintInfo()
        */
-       u32 m_excess_gotblocks;
+       u32 m_excess_gotblocks = 0;
 
        // CPU usage optimization
-       float m_nothing_to_send_pause_timer;
+       float m_nothing_to_send_pause_timer = 0.0f;
 
        /*
                name of player using this client
        */
-       std::string m_name;
+       std::string m_name = "";
 
        /*
                client information
         */
-       u8 m_version_major;
-       u8 m_version_minor;
-       u8 m_version_patch;
+       u8 m_version_major = 0;
+       u8 m_version_minor = 0;
+       u8 m_version_patch = 0;
 
-       std::string m_full_version;
+       std::string m_full_version = "unknown";
 
-       u16 m_deployed_compression;
+       u16 m_deployed_compression = 0;
 
        /*
                time this client was created
         */
-       const u64 m_connection_time;
+       const u64 m_connection_time = porting::getTimeS();
 };
 
 typedef std::unordered_map<u16, RemoteClient*> RemoteClientMap;
index 6cd24ffc6e74fe11ce8453a3738105541ea9e02f..9186e3cabadc8dceeae4f1b2690a9c2ccef7470e 100644 (file)
@@ -67,13 +67,6 @@ ClientMap::ClientMap(
 
 ClientMap::~ClientMap()
 {
-       /*MutexAutoLock lock(mesh_mutex);
-
-       if(mesh != NULL)
-       {
-               mesh->drop();
-               mesh = NULL;
-       }*/
 }
 
 MapSector * ClientMap::emergeSector(v2s16 p2d)
index 84228f4ca5d59a8a4a1953337863038d1fe56538..8d272077145bc6b209cee658f00393aba68ca4ab 100644 (file)
@@ -28,30 +28,20 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 struct MapDrawControl
 {
-       MapDrawControl():
-               range_all(false),
-               wanted_range(0),
-               wanted_max_blocks(0),
-               show_wireframe(false),
-               blocks_drawn(0),
-               blocks_would_have_drawn(0),
-               farthest_drawn(0)
-       {
-       }
        // Overrides limits by drawing everything
-       bool range_all;
+       bool range_all = false;
        // Wanted drawing range
-       float wanted_range;
+       float wanted_range = 0.0f;
        // Maximum number of blocks to draw
-       u32 wanted_max_blocks;
+       u32 wanted_max_blocks = 0;
        // show a wire frame for debugging
-       bool show_wireframe;
+       bool show_wireframe = false;
        // Number of blocks rendered is written here by the renderer
-       u32 blocks_drawn;
+       u32 blocks_drawn = 0;
        // Number of blocks that would have been drawn in wanted_range
-       u32 blocks_would_have_drawn;
+       u32 blocks_would_have_drawn = 0;
        // Distance to the farthest block drawn
-       float farthest_drawn;
+       float farthest_drawn = 0;
 };
 
 class Client;
@@ -137,13 +127,14 @@ public:
 private:
        Client *m_client;
 
-       aabb3f m_box;
+       aabb3f m_box = aabb3f(-BS * 1000000, -BS * 1000000, -BS * 1000000,
+               BS * 1000000, BS * 1000000, BS * 1000000);
 
        MapDrawControl &m_control;
 
        v3f m_camera_position;
-       v3f m_camera_direction;
-       f32 m_camera_fov;
+       v3f m_camera_direction = v3f(0,0,1);
+       f32 m_camera_fov = M_PI;
        v3s16 m_camera_offset;
 
        std::map<v3s16, MapBlock*> m_drawlist;
index 2877d8a2e7432026bd00661d23110f945ed05862..ca6f3d563ca57911b07e380ff381bb5b244bbd03 100644 (file)
@@ -43,17 +43,8 @@ static std::string getMediaCacheDir()
 
 ClientMediaDownloader::ClientMediaDownloader():
        m_media_cache(getMediaCacheDir()),
-       m_initial_step_done(false),
-       m_uncached_count(0),
-       m_uncached_received_count(0),
-       m_name_bound("")
+       m_httpfetch_caller(HTTPFETCH_DISCARD)
 {
-       m_httpfetch_caller = HTTPFETCH_DISCARD;
-       m_httpfetch_active = 0;
-       m_httpfetch_active_limit = 0;
-       m_httpfetch_next_id = 0;
-       m_httpfetch_timeout = 0;
-       m_outstanding_hash_sets = 0;
 }
 
 ClientMediaDownloader::~ClientMediaDownloader()
index 4c0c3c8887999fd31e49d40b9f94fe6376017d1c..1834fb67f2524eb85de5b297edc165c051259706 100644 (file)
@@ -123,28 +123,28 @@ private:
 
        // Has an attempt been made to load media files from the file cache?
        // Have hash sets been requested from remote servers?
-       bool m_initial_step_done;
+       bool m_initial_step_done = false;
 
        // Total number of media files to load
-       s32 m_uncached_count;
+       s32 m_uncached_count = 0;
 
        // Number of media files that have been received
-       s32 m_uncached_received_count;
+       s32 m_uncached_received_count = 0;
 
        // Status of remote transfers
        unsigned long m_httpfetch_caller;
-       unsigned long m_httpfetch_next_id;
-       long m_httpfetch_timeout;
-       s32 m_httpfetch_active;
-       s32 m_httpfetch_active_limit;
-       s32 m_outstanding_hash_sets;
+       unsigned long m_httpfetch_next_id = 0;
+       long m_httpfetch_timeout = 0;
+       s32 m_httpfetch_active = 0;
+       s32 m_httpfetch_active_limit = 0;
+       s32 m_outstanding_hash_sets = 0;
        std::unordered_map<unsigned long, std::string> m_remote_file_transfers;
 
        // All files up to this name have either been received from a
        // remote server or failed on all remote servers, so those files
        // don't need to be looked at again
        // (use m_files.upper_bound(m_name_bound) to get an iterator)
-       std::string m_name_bound;
+       std::string m_name_bound = "";
 
 };
 
index f5b79b64f27cbf4f82c8532a177f8a77bb161538..3e770475767771ebd6c544658e605734ccf7e6b4 100644 (file)
@@ -27,9 +27,9 @@ class ClientSimpleObject
 {
 protected:
 public:
-       bool m_to_be_removed;
+       bool m_to_be_removed = false;
 
-       ClientSimpleObject() : m_to_be_removed(false) {}
+       ClientSimpleObject() {}
        virtual ~ClientSimpleObject() {}
        virtual void step(float dtime) {}
 };
index 10a533cae523a26b620fa15fc93a687617110654..dc08d1ac0fdc26b90a87e846a84b24cb8f4b4a6f 100644 (file)
@@ -44,11 +44,7 @@ Clouds::Clouds(
                s16 cloudheight
 ):
        scene::ISceneNode(parent, mgr, id),
-       m_seed(seed),
-       m_camera_pos(0.0f, 0.0f),
-       m_origin(0.0f, 0.0f),
-       m_camera_offset(0.0f, 0.0f, 0.0f),
-       m_color(1.0f, 1.0f, 1.0f, 1.0f)
+       m_seed(seed)
 {
        m_material.setFlag(video::EMF_LIGHTING, false);
        //m_material.setFlag(video::EMF_BACK_FACE_CULLING, false);
index a0bda28df901677355b00a521e64da7b2226bf9c..869f7f7fc8b2980fe447b9bad99b965567d46a6c 100644 (file)
@@ -53,7 +53,7 @@ public:
        virtual void OnRegisterSceneNode();
 
        virtual void render();
-       
+
        virtual const aabb3f &getBoundingBox() const
        {
                return m_box;
@@ -68,7 +68,7 @@ public:
        {
                return m_material;
        }
-       
+
        /*
                Other stuff
        */
@@ -76,7 +76,7 @@ public:
        void step(float dtime);
 
        void update(v2f camera_p, video::SColorf color);
-       
+
        void updateCameraOffset(v3s16 camera_offset)
        {
                m_camera_offset = camera_offset;
@@ -135,9 +135,8 @@ private:
        u32 m_seed;
        v2f m_camera_pos;
        v2f m_origin;
-       v2f m_speed;
        v3s16 m_camera_offset;
-       video::SColorf m_color;
+       video::SColorf m_color = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
        CloudParams m_params;
 
 };
index c0891c15280bcd07780d8c4df811fc1d18a193a0..61972b2e84dbf8aeaffb0fa9e9d2943e6297eb0f 100644 (file)
@@ -39,7 +39,6 @@ struct NearbyCollisionInfo {
        NearbyCollisionInfo(bool is_ul, bool is_obj, int bouncy,
                        const v3s16 &pos, const aabb3f &box) :
                is_unloaded(is_ul),
-               is_step_up(false),
                is_object(is_obj),
                bouncy(bouncy),
                position(pos),
@@ -47,7 +46,7 @@ struct NearbyCollisionInfo {
        {}
 
        bool is_unloaded;
-       bool is_step_up;
+       bool is_step_up = false;
        bool is_object;
        int bouncy;
        v3s16 position;
@@ -469,7 +468,6 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
                                                        d));
 
                        // Get bounce multiplier
-                       bool bouncy = (nearest_info.bouncy >= 1);
                        float bounce = -(float)nearest_info.bouncy / 100.0;
 
                        // Move to the point of collision and reduce dtime by nearest_dtime
@@ -499,7 +497,6 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
                                info.type = COLLISION_NODE;
 
                        info.node_p = nearest_info.position;
-                       info.bouncy = bouncy;
                        info.old_speed = *speed_f;
 
                        // Set the speed component that caused the collision to zero
@@ -513,7 +510,6 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
                                else
                                        speed_f->X = 0;
                                result.collides = true;
-                               result.collides_xz = true;
                        } else if (nearest_collided == 1) { // Y
                                if(fabs(speed_f->Y) > BS * 3)
                                        speed_f->Y *= bounce;
@@ -526,7 +522,6 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
                                else
                                        speed_f->Z = 0;
                                result.collides = true;
-                               result.collides_xz = true;
                        }
 
                        info.new_speed = *speed_f;
@@ -572,8 +567,6 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
 
                                if (box_info.is_object)
                                        result.standing_on_object = true;
-                               if (box_info.is_unloaded)
-                                       result.standing_on_unloaded = true;
                        }
                }
        }
index 1ceaba81c802752859f94da7c091faad90a63a33..50755224b6a10eebadee26c9c395ba30eb9bfe8e 100644 (file)
@@ -36,37 +36,20 @@ enum CollisionType
 
 struct CollisionInfo
 {
-       enum CollisionType type;
-       v3s16 node_p; // COLLISION_NODE
-       bool bouncy;
+       CollisionInfo() {}
+       CollisionType type = COLLISION_NODE;
+       v3s16 node_p = v3s16(-32768,-32768,-32768); // COLLISION_NODE
        v3f old_speed;
        v3f new_speed;
-
-       CollisionInfo():
-               type(COLLISION_NODE),
-               node_p(-32768,-32768,-32768),
-               bouncy(false),
-               old_speed(0,0,0),
-               new_speed(0,0,0)
-       {}
 };
 
 struct collisionMoveResult
 {
-       bool touching_ground;
-       bool collides;
-       bool collides_xz;
-       bool standing_on_unloaded;
-       bool standing_on_object;
+       collisionMoveResult() {}
+       bool touching_ground = false;
+       bool collides = false;
+       bool standing_on_object = false;
        std::vector<CollisionInfo> collisions;
-
-       collisionMoveResult():
-               touching_ground(false),
-               collides(false),
-               collides_xz(false),
-               standing_on_unloaded(false),
-               standing_on_object(false)
-       {}
 };
 
 // Moves using a single iteration; speed should not exceed pos_max_d/dtime
index a5a55fd7e5adc7ee53f18f6e638f61303ca581fe..0b9df64515e27bee79a7c1f36117d4b55f72fbd3 100644 (file)
@@ -51,16 +51,6 @@ struct ToolCapabilities;
 
 std::unordered_map<u16, ClientActiveObject::Factory> ClientActiveObject::m_types;
 
-SmoothTranslator::SmoothTranslator():
-       vect_old(0,0,0),
-       vect_show(0,0,0),
-       vect_aim(0,0,0),
-       anim_counter(0),
-       anim_time(0),
-       anim_time_counter(0),
-       aim_is_end(true)
-{}
-
 void SmoothTranslator::init(v3f vect)
 {
        vect_old = vect;
@@ -72,11 +62,6 @@ void SmoothTranslator::init(v3f vect)
        aim_is_end = true;
 }
 
-void SmoothTranslator::sharpen()
-{
-       init(vect_show);
-}
-
 void SmoothTranslator::update(v3f vect_new, bool is_end_position, float update_interval)
 {
        aim_is_end = is_end_position;
@@ -113,11 +98,6 @@ void SmoothTranslator::translate(f32 dtime)
        vect_show = vect_old + vect_move * moveratio;
 }
 
-bool SmoothTranslator::is_moving()
-{
-       return ((anim_time_counter / anim_time) < 1.4);
-}
-
 /*
        Other stuff
 */
@@ -325,8 +305,6 @@ private:
        std::string m_infotext;
 };
 
-#include "inventory.h"
-
 // Prototype
 ItemCAO proto_ItemCAO(NULL, NULL);
 
@@ -538,49 +516,7 @@ void ItemCAO::initialize(const std::string &data)
 #include "genericobject.h"
 
 GenericCAO::GenericCAO(Client *client, ClientEnvironment *env):
-               ClientActiveObject(0, client, env),
-               //
-               m_is_player(false),
-               m_is_local_player(false),
-               //
-               m_smgr(NULL),
-               m_irr(NULL),
-               m_client(NULL),
-               m_selection_box(-BS/3.,-BS/3.,-BS/3., BS/3.,BS/3.,BS/3.),
-               m_meshnode(NULL),
-               m_animated_meshnode(NULL),
-               m_wield_meshnode(NULL),
-               m_spritenode(NULL),
-               m_nametag(NULL),
-               m_position(v3f(0,10*BS,0)),
-               m_velocity(v3f(0,0,0)),
-               m_acceleration(v3f(0,0,0)),
-               m_yaw(0),
-               m_hp(1),
-               m_tx_size(1,1),
-               m_tx_basepos(0,0),
-               m_initial_tx_basepos_set(false),
-               m_tx_select_horiz_by_yawpitch(false),
-               m_animation_range(v2s32(0,0)),
-               m_animation_speed(15),
-               m_animation_blend(0),
-               m_animation_loop(true),
-               m_bone_position(),
-               m_attachment_bone(""),
-               m_attachment_position(v3f(0,0,0)),
-               m_attachment_rotation(v3f(0,0,0)),
-               m_attached_to_local(false),
-               m_anim_frame(0),
-               m_anim_num_frames(1),
-               m_anim_framelength(0.2),
-               m_anim_timer(0),
-               m_reset_textures_timer(-1),
-               m_previous_texture_modifier(""),
-               m_current_texture_modifier(""),
-               m_visuals_expired(false),
-               m_step_distance_counter(0),
-               m_last_light(255),
-               m_is_visible(false)
+               ClientActiveObject(0, client, env)
 {
        if (client == NULL) {
                ClientActiveObject::registerType(getType(), create);
@@ -639,7 +575,7 @@ void GenericCAO::processInitData(const std::string &data)
        if (version == 1) { // In PROTOCOL_VERSION 14
                m_name = deSerializeString(is);
                m_is_player = readU8(is);
-               m_id = readS16(is);
+               m_id = readU16(is);
                m_position = readV3F1000(is);
                m_yaw = readF1000(is);
                m_hp = readS16(is);
index e5b23aa35d16174ad37fba76a164cebb2d15664b..e353b71de510eacece4dc40c0b51f197fabe2d10 100644 (file)
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "clientobject.h"
 #include "object_properties.h"
 #include "itemgroup.h"
+#include "constants.h"
 
 class Camera;
 class Client;
@@ -39,76 +40,74 @@ struct SmoothTranslator
        v3f vect_old;
        v3f vect_show;
        v3f vect_aim;
-       f32 anim_counter;
+       f32 anim_counter = 0;
        f32 anim_time;
-       f32 anim_time_counter;
-       bool aim_is_end;
+       f32 anim_time_counter = 0;
+       bool aim_is_end = true;
 
-       SmoothTranslator();
+       SmoothTranslator() {};
 
        void init(v3f vect);
 
-       void sharpen();
-
        void update(v3f vect_new, bool is_end_position=false, float update_interval=-1);
 
        void translate(f32 dtime);
-
-       bool is_moving();
 };
 
 class GenericCAO : public ClientActiveObject
 {
 private:
        // Only set at initialization
-       std::string m_name;
-       bool m_is_player;
-       bool m_is_local_player;
+       std::string m_name = "";
+       bool m_is_player = false;
+       bool m_is_local_player = false;
        // Property-ish things
        ObjectProperties m_prop;
        //
-       scene::ISceneManager *m_smgr;
-       IrrlichtDevice *m_irr;
-       Client *m_client;
-       aabb3f m_selection_box;
-       scene::IMeshSceneNode *m_meshnode;
-       scene::IAnimatedMeshSceneNode *m_animated_meshnode;
-       WieldMeshSceneNode *m_wield_meshnode;
-       scene::IBillboardSceneNode *m_spritenode;
-       Nametag* m_nametag;
-       v3f m_position;
+       scene::ISceneManager *m_smgr = nullptr;
+       IrrlichtDevice *m_irr = nullptr;
+       Client *m_client = nullptr;
+       aabb3f m_selection_box = aabb3f(-BS/3.,-BS/3.,-BS/3., BS/3.,BS/3.,BS/3.);
+       scene::IMeshSceneNode *m_meshnode = nullptr;
+       scene::IAnimatedMeshSceneNode *m_animated_meshnode = nullptr;
+       WieldMeshSceneNode *m_wield_meshnode = nullptr;
+       scene::IBillboardSceneNode *m_spritenode = nullptr;
+       Nametag *m_nametag = nullptr;
+       v3f m_position = v3f(0.0f, 10.0f * BS, 0);
        v3f m_velocity;
        v3f m_acceleration;
-       float m_yaw;
-       s16 m_hp;
+       float m_yaw = 0.0f;
+       s16 m_hp = 1;
        SmoothTranslator pos_translator;
        // Spritesheet/animation stuff
-       v2f m_tx_size;
+       v2f m_tx_size = v2f(1,1);
        v2s16 m_tx_basepos;
-       bool m_initial_tx_basepos_set;
-       bool m_tx_select_horiz_by_yawpitch;
+       bool m_initial_tx_basepos_set = false;
+       bool m_tx_select_horiz_by_yawpitch = false;
        v2s32 m_animation_range;
-       int m_animation_speed;
-       int m_animation_blend;
-       bool m_animation_loop;
+       int m_animation_speed = 15;
+       int m_animation_blend = 0;
+       bool m_animation_loop = true;
        // stores position and rotation for each bone name
        std::unordered_map<std::string, core::vector2d<v3f>> m_bone_position;
-       std::string m_attachment_bone;
+       std::string m_attachment_bone = "";
        v3f m_attachment_position;
        v3f m_attachment_rotation;
-       bool m_attached_to_local;
-       int m_anim_frame;
-       int m_anim_num_frames;
-       float m_anim_framelength;
-       float m_anim_timer;
+       bool m_attached_to_local = false;
+       int m_anim_frame = 0;
+       int m_anim_num_frames = 1;
+       float m_anim_framelength = 0.2f;
+       float m_anim_timer = 0.0f;
        ItemGroupList m_armor_groups;
-       float m_reset_textures_timer;
-       std::string m_previous_texture_modifier; // stores texture modifier before punch update
-       std::string m_current_texture_modifier;  // last applied texture modifier
-       bool m_visuals_expired;
-       float m_step_distance_counter;
-       u8 m_last_light;
-       bool m_is_visible;
+       float m_reset_textures_timer = -1.0f;
+       // stores texture modifier before punch update
+       std::string m_previous_texture_modifier = "";
+       // last applied texture modifier
+       std::string m_current_texture_modifier = "";
+       bool m_visuals_expired = false;
+       float m_step_distance_counter = 0.0f;
+       u8 m_last_light = 255;
+       bool m_is_visible = false;
 
        std::vector<u16> m_children;
 
index aca71212b648f5e678456680faab173910db7ea4..10d1f498b82b74fe47d731540dcaa8ef2f55c0ea 100644 (file)
@@ -26,13 +26,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 class SmokePuffCSO: public ClientSimpleObject
 {
-       float m_age;
-       scene::IBillboardSceneNode *m_spritenode;
+       float m_age = 0.0f;
+       scene::IBillboardSceneNode *m_spritenode = nullptr;
 public:
        SmokePuffCSO(scene::ISceneManager *smgr,
-                       ClientEnvironment *env, v3f pos, v2f size):
-               m_age(0),
-               m_spritenode(NULL)
+                       ClientEnvironment *env, v3f pos, v2f size)
        {
                infostream<<"SmokePuffCSO: constructing"<<std::endl;
                m_spritenode = smgr->addBillboardSceneNode(
index 79a32b6bf9a51755850c29db45b200c4fcaec1b6..fc2859d27ac0d891a8134c4a04f56925d7094a91 100644 (file)
@@ -189,12 +189,3 @@ void content_nodemeta_deserialize_legacy(std::istream &is,
                        timers->set(NodeTimer(1., 0., p));
        }
 }
-
-void content_nodemeta_serialize_legacy(std::ostream &os, NodeMetadataList *meta)
-{
-       // Sorry, I was too lazy to implement this. --kahrl
-       writeU16(os, 1); // version
-       writeU16(os, 0); // count
-}
-
-// END
index ebc01d9a884fc882b183d1e49b03c584d6d8a119..3c632ed4a0ca371191a6620d8c8cfcbcf408ef9e 100644 (file)
@@ -34,7 +34,5 @@ void content_nodemeta_deserialize_legacy(std::istream &is,
                NodeMetadataList *meta, NodeTimerList *timers,
                IItemDefManager *item_def_mgr);
 
-void content_nodemeta_serialize_legacy(std::ostream &os, NodeMetadataList *meta);
-
 #endif
 
index 90d830ce3edb65ec37dbe5cb91e67f9ee6d78f6c..c6c00768e0cdc3e80c04dcf9fecf14a87342c29c 100644 (file)
@@ -106,19 +106,7 @@ TestSAO proto_TestSAO(NULL, v3f(0,0,0));
  */
 
 UnitSAO::UnitSAO(ServerEnvironment *env, v3f pos):
-       ServerActiveObject(env, pos),
-       m_hp(-1),
-       m_yaw(0),
-       m_properties_sent(true),
-       m_armor_groups_sent(false),
-       m_animation_range(0,0),
-       m_animation_speed(0),
-       m_animation_blend(0),
-       m_animation_loop(true),
-       m_animation_sent(false),
-       m_bone_position_sent(false),
-       m_attachment_parent_id(0),
-       m_attachment_sent(false)
+       ServerActiveObject(env, pos)
 {
        // Initialize something to armor groups
        m_armor_groups["fleshy"] = 100;
@@ -239,16 +227,7 @@ LuaEntitySAO::LuaEntitySAO(ServerEnvironment *env, v3f pos,
                const std::string &name, const std::string &state):
        UnitSAO(env, pos),
        m_init_name(name),
-       m_init_state(state),
-       m_registered(false),
-       m_velocity(0,0,0),
-       m_acceleration(0,0,0),
-       m_last_sent_yaw(0),
-       m_last_sent_position(0,0,0),
-       m_last_sent_velocity(0,0,0),
-       m_last_sent_position_timer(0),
-       m_last_sent_move_precision(0),
-       m_current_texture_modifier("")
+       m_init_state(state)
 {
        // Only register type if no environment supplied
        if(env == NULL){
@@ -783,29 +762,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id
        UnitSAO(env_, v3f(0,0,0)),
        m_player(player_),
        m_peer_id(peer_id_),
-       m_inventory(NULL),
-       m_damage(0),
-       m_last_good_position(0,0,0),
-       m_time_from_last_teleport(0),
-       m_time_from_last_punch(0),
-       m_nocheat_dig_pos(32767, 32767, 32767),
-       m_nocheat_dig_time(0),
-       m_wield_index(0),
-       m_position_not_sent(false),
-       m_is_singleplayer(is_singleplayer),
-       m_breath(PLAYER_MAX_BREATH),
-       m_pitch(0),
-       m_fov(0),
-       m_wanted_range(0),
-       m_extended_attributes_modified(false),
-       // public
-       m_physics_override_speed(1),
-       m_physics_override_jump(1),
-       m_physics_override_gravity(1),
-       m_physics_override_sneak(true),
-       m_physics_override_sneak_glitch(false),
-       m_physics_override_new_move(true),
-       m_physics_override_sent(false)
+       m_is_singleplayer(is_singleplayer)
 {
        assert(m_peer_id != 0); // pre-condition
 
index bb1a61a1937cd1d7605fff7685d8f9d4d3606aa6..0a1ae5ecfedd56ec9e9896b61d4bde196c4df90a 100644 (file)
@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "serverobject.h"
 #include "itemgroup.h"
 #include "object_properties.h"
+#include "constants.h"
 
 class UnitSAO: public ServerActiveObject
 {
@@ -56,31 +57,31 @@ public:
        ObjectProperties* accessObjectProperties();
        void notifyObjectPropertiesModified();
 protected:
-       s16 m_hp;
-       float m_yaw;
+       s16 m_hp = -1;
+       float m_yaw = 0.0f;
 
-       bool m_properties_sent;
+       bool m_properties_sent = true;
        struct ObjectProperties m_prop;
 
        ItemGroupList m_armor_groups;
-       bool m_armor_groups_sent;
+       bool m_armor_groups_sent = false;
 
        v2f m_animation_range;
-       float m_animation_speed;
-       float m_animation_blend;
-       bool m_animation_loop;
-       bool m_animation_sent;
+       float m_animation_speed = 0.0f;
+       float m_animation_blend = 0.0f;
+       bool m_animation_loop = true;
+       bool m_animation_sent = false;
 
        // Stores position and rotation for each bone name
        std::unordered_map<std::string, core::vector2d<v3f>> m_bone_position;
-       bool m_bone_position_sent;
+       bool m_bone_position_sent = false;
 
-       int m_attachment_parent_id;
+       int m_attachment_parent_id = 0;
        std::unordered_set<int> m_attachment_child_ids;
-       std::string m_attachment_bone;
+       std::string m_attachment_bone = "";
        v3f m_attachment_position;
        v3f m_attachment_rotation;
-       bool m_attachment_sent;
+       bool m_attachment_sent = false;
 };
 
 /*
@@ -133,17 +134,17 @@ private:
 
        std::string m_init_name;
        std::string m_init_state;
-       bool m_registered;
+       bool m_registered = false;
 
        v3f m_velocity;
        v3f m_acceleration;
 
-       float m_last_sent_yaw;
+       float m_last_sent_yaw = 0.0f;
        v3f m_last_sent_position;
        v3f m_last_sent_velocity;
-       float m_last_sent_position_timer;
-       float m_last_sent_move_precision;
-       std::string m_current_texture_modifier;
+       float m_last_sent_position_timer = 0.0f;
+       float m_last_sent_move_precision = 0.0f;
+       std::string m_current_texture_modifier = "";
 };
 
 /*
@@ -152,11 +153,10 @@ private:
 
 class LagPool
 {
-       float m_pool;
-       float m_max;
+       float m_pool = 15.0f;
+       float m_max = 15.0f;
 public:
-       LagPool(): m_pool(15), m_max(15)
-       {}
+       LagPool() {}
 
        void setMax(float new_max)
        {
@@ -368,47 +368,47 @@ private:
        std::string getPropertyPacket();
        void unlinkPlayerSessionAndSave();
 
-       RemotePlayer *m_player;
-       u16 m_peer_id;
-       Inventory *m_inventory;
-       s16 m_damage;
+       RemotePlayer *m_player = nullptr;
+       u16 m_peer_id = 0;
+       Inventory *m_inventory = nullptr;
+       s16 m_damage = 0;
 
        // Cheat prevention
        LagPool m_dig_pool;
        LagPool m_move_pool;
        v3f m_last_good_position;
-       float m_time_from_last_teleport;
-       float m_time_from_last_punch;
-       v3s16 m_nocheat_dig_pos;
-       float m_nocheat_dig_time;
+       float m_time_from_last_teleport = 0.0f;
+       float m_time_from_last_punch = 0.0f;
+       v3s16 m_nocheat_dig_pos = v3s16(32767, 32767, 32767);
+       float m_nocheat_dig_time = 0.0f;
 
        // Timers
        IntervalLimiter m_breathing_interval;
        IntervalLimiter m_drowning_interval;
        IntervalLimiter m_node_hurt_interval;
 
-       int m_wield_index;
-       bool m_position_not_sent;
+       int m_wield_index = 0;
+       bool m_position_not_sent = false;
 
        // Cached privileges for enforcement
        std::set<std::string> m_privs;
        bool m_is_singleplayer;
 
-       u16 m_breath;
-       f32 m_pitch;
-       f32 m_fov;
-       s16 m_wanted_range;
+       u16 m_breath = PLAYER_MAX_BREATH;
+       f32 m_pitch = 0.0f;
+       f32 m_fov = 0.0f;
+       s16 m_wanted_range = 0.0f;
 
        PlayerAttributes m_extra_attributes;
-       bool m_extended_attributes_modified;
+       bool m_extended_attributes_modified = false;
 public:
-       float m_physics_override_speed;
-       float m_physics_override_jump;
-       float m_physics_override_gravity;
-       bool m_physics_override_sneak;
-       bool m_physics_override_sneak_glitch;
-       bool m_physics_override_new_move;
-       bool m_physics_override_sent;
+       float m_physics_override_speed = 1.0f;
+       float m_physics_override_jump = 1.0f;
+       float m_physics_override_gravity = 1.0f;
+       bool m_physics_override_sneak = true;
+       bool m_physics_override_sneak_glitch = false;
+       bool m_physics_override_new_move = true;
+       bool m_physics_override_sent = false;
 };
 
 #endif
index bdd741f7c08293ed4014722d6ae194df351d249b..fddff6cef8c5e240e8a1e1c7eba5e26bb21e3c44 100644 (file)
@@ -70,17 +70,17 @@ const int craft_hash_type_max = (int) CRAFT_HASH_TYPE_UNHASHED;
 */
 struct CraftInput
 {
-       CraftMethod method;
-       unsigned int width;
+       CraftMethod method = CRAFT_METHOD_NORMAL;
+       unsigned int width = 0;
        std::vector<ItemStack> items;
 
-       CraftInput():
-               method(CRAFT_METHOD_NORMAL), width(0), items()
-       {}
+       CraftInput() {}
+
        CraftInput(CraftMethod method_, unsigned int width_,
                        const std::vector<ItemStack> &items_):
                method(method_), width(width_), items(items_)
        {}
+
        std::string dump() const;
 };
 
@@ -90,13 +90,12 @@ struct CraftInput
 struct CraftOutput
 {
        // Used for normal crafting and cooking, itemstring
-       std::string item;
+       std::string item = "";
        // Used for cooking (cook time) and fuel (burn time), seconds
-       float time;
+       float time = 0.0f;
+
+       CraftOutput() {}
 
-       CraftOutput():
-               item(""), time(0)
-       {}
        CraftOutput(const std::string &item_, float time_):
                item(item_), time(time_)
        {}
@@ -171,16 +170,15 @@ public:
 class CraftDefinitionShaped: public CraftDefinition
 {
 public:
-       CraftDefinitionShaped():
-               output(""), width(1), recipe(), hash_inited(false), replacements()
-       {}
+       CraftDefinitionShaped() {}
+
        CraftDefinitionShaped(
                        const std::string &output_,
                        unsigned int width_,
                        const std::vector<std::string> &recipe_,
                        const CraftReplacements &replacements_):
                output(output_), width(width_), recipe(recipe_),
-               hash_inited(false), replacements(replacements_)
+               replacements(replacements_)
        {}
        virtual ~CraftDefinitionShaped(){}
 
@@ -200,15 +198,15 @@ public:
 
 private:
        // Output itemstring
-       std::string output;
+       std::string output = "";
        // Width of recipe
-       unsigned int width;
+       unsigned int width = 1;
        // Recipe matrix (itemstrings)
        std::vector<std::string> recipe;
        // Recipe matrix (item names)
        std::vector<std::string> recipe_names;
        // bool indicating if initHash has been called already
-       bool hash_inited;
+       bool hash_inited = false;
        // Replacement items for decrementInput()
        CraftReplacements replacements;
 };
index a6b62bad58fda188d365a57b598d565c72d828aa..ac25afd4838b8765b2ed68bd4e5c7236645d533f 100644 (file)
@@ -43,9 +43,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "remoteplayer.h"
 
 Database_PostgreSQL::Database_PostgreSQL(const std::string &connect_string) :
-       m_connect_string(connect_string),
-       m_conn(NULL),
-       m_pgversion(0)
+       m_connect_string(connect_string)
 {
        if (m_connect_string.empty()) {
                throw SettingNotFoundException(
index d6f208fd942695cb678215b926e87cac55f3736c..8bb72ec6a607afb532d7b31acf917f91468ce0c4 100644 (file)
@@ -104,8 +104,8 @@ private:
 
        // Attributes
        std::string m_connect_string;
-       PGconn *m_conn;
-       int m_pgversion;
+       PGconn *m_conn = nullptr;
+       int m_pgversion = 0;
 };
 
 class MapDatabasePostgreSQL : private Database_PostgreSQL, public MapDatabase
index fa15dd8a7e8eb021995d8b83617ee458ff166780..1e7909f857b4654fff31302367eb55b932ea0f1e 100644 (file)
@@ -45,8 +45,8 @@ public:
        void listAllLoadableBlocks(std::vector<v3s16> &dst);
 
 private:
-       redisContext *ctx;
-       std::string hash;
+       redisContext *ctx = nullptr;
+       std::string hash = "";
 };
 
 #endif // USE_REDIS
index 7bc87a7d0bb4a7493fdabd356bdb890f07386d5f..22765c8d22cb4e4446080c3295d434810ec80b82 100644 (file)
@@ -114,12 +114,8 @@ int Database_SQLite3::busyHandler(void *data, int count)
 
 
 Database_SQLite3::Database_SQLite3(const std::string &savedir, const std::string &dbname) :
-       m_database(NULL),
-       m_initialized(false),
        m_savedir(savedir),
-       m_dbname(dbname),
-       m_stmt_begin(NULL),
-       m_stmt_end(NULL)
+       m_dbname(dbname)
 {
 }
 
@@ -203,13 +199,8 @@ Database_SQLite3::~Database_SQLite3()
 
 MapDatabaseSQLite3::MapDatabaseSQLite3(const std::string &savedir):
        Database_SQLite3(savedir, "map"),
-       MapDatabase(),
-       m_stmt_read(NULL),
-       m_stmt_write(NULL),
-       m_stmt_list(NULL),
-       m_stmt_delete(NULL)
+       MapDatabase()
 {
-
 }
 
 MapDatabaseSQLite3::~MapDatabaseSQLite3()
@@ -334,24 +325,10 @@ void MapDatabaseSQLite3::listAllLoadableBlocks(std::vector<v3s16> &dst)
 
 PlayerDatabaseSQLite3::PlayerDatabaseSQLite3(const std::string &savedir):
        Database_SQLite3(savedir, "players"),
-       PlayerDatabase(),
-       m_stmt_player_load(NULL),
-       m_stmt_player_add(NULL),
-       m_stmt_player_update(NULL),
-       m_stmt_player_remove(NULL),
-       m_stmt_player_list(NULL),
-       m_stmt_player_load_inventory(NULL),
-       m_stmt_player_load_inventory_items(NULL),
-       m_stmt_player_add_inventory(NULL),
-       m_stmt_player_add_inventory_items(NULL),
-       m_stmt_player_remove_inventory(NULL),
-       m_stmt_player_remove_inventory_items(NULL),
-       m_stmt_player_metadata_load(NULL),
-       m_stmt_player_metadata_remove(NULL),
-       m_stmt_player_metadata_add(NULL)
+       PlayerDatabase()
 {
-
 }
+
 PlayerDatabaseSQLite3::~PlayerDatabaseSQLite3()
 {
        FINALIZE_STATEMENT(m_stmt_player_load)
index 3244facc9958fabb9a7614b1980f003e1b8afd65..ec7a34ad749ca6861a83ebae60216daa37018ad9 100644 (file)
@@ -113,18 +113,18 @@ protected:
        virtual void createDatabase() = 0;
        virtual void initStatements() = 0;
 
-       sqlite3 *m_database;
+       sqlite3 *m_database = nullptr;
 private:
        // Open the database
        void openDatabase();
 
-       bool m_initialized;
+       bool m_initialized = false;
 
-       std::string m_savedir;
-       std::string m_dbname;
+       std::string m_savedir = "";
+       std::string m_dbname = "";
 
-       sqlite3_stmt *m_stmt_begin;
-       sqlite3_stmt *m_stmt_end;
+       sqlite3_stmt *m_stmt_begin = nullptr;
+       sqlite3_stmt *m_stmt_end = nullptr;
 
        s64 m_busy_handler_data[2];
 
@@ -152,10 +152,10 @@ private:
        void bindPos(sqlite3_stmt *stmt, const v3s16 &pos, int index = 1);
 
        // Map
-       sqlite3_stmt *m_stmt_read;
-       sqlite3_stmt *m_stmt_write;
-       sqlite3_stmt *m_stmt_list;
-       sqlite3_stmt *m_stmt_delete;
+       sqlite3_stmt *m_stmt_read = nullptr;
+       sqlite3_stmt *m_stmt_write = nullptr;
+       sqlite3_stmt *m_stmt_list = nullptr;
+       sqlite3_stmt *m_stmt_delete = nullptr;
 };
 
 class PlayerDatabaseSQLite3 : private Database_SQLite3, public PlayerDatabase
@@ -177,20 +177,20 @@ private:
        bool playerDataExists(const std::string &name);
 
        // Players
-       sqlite3_stmt *m_stmt_player_load;
-       sqlite3_stmt *m_stmt_player_add;
-       sqlite3_stmt *m_stmt_player_update;
-       sqlite3_stmt *m_stmt_player_remove;
-       sqlite3_stmt *m_stmt_player_list;
-       sqlite3_stmt *m_stmt_player_load_inventory;
-       sqlite3_stmt *m_stmt_player_load_inventory_items;
-       sqlite3_stmt *m_stmt_player_add_inventory;
-       sqlite3_stmt *m_stmt_player_add_inventory_items;
-       sqlite3_stmt *m_stmt_player_remove_inventory;
-       sqlite3_stmt *m_stmt_player_remove_inventory_items;
-       sqlite3_stmt *m_stmt_player_metadata_load;
-       sqlite3_stmt *m_stmt_player_metadata_remove;
-       sqlite3_stmt *m_stmt_player_metadata_add;
+       sqlite3_stmt *m_stmt_player_load = nullptr;
+       sqlite3_stmt *m_stmt_player_add = nullptr;
+       sqlite3_stmt *m_stmt_player_update = nullptr;
+       sqlite3_stmt *m_stmt_player_remove = nullptr;
+       sqlite3_stmt *m_stmt_player_list = nullptr;
+       sqlite3_stmt *m_stmt_player_load_inventory = nullptr;
+       sqlite3_stmt *m_stmt_player_load_inventory_items = nullptr;
+       sqlite3_stmt *m_stmt_player_add_inventory = nullptr;
+       sqlite3_stmt *m_stmt_player_add_inventory_items = nullptr;
+       sqlite3_stmt *m_stmt_player_remove_inventory = nullptr;
+       sqlite3_stmt *m_stmt_player_remove_inventory_items = nullptr;
+       sqlite3_stmt *m_stmt_player_metadata_load = nullptr;
+       sqlite3_stmt *m_stmt_player_metadata_remove = nullptr;
+       sqlite3_stmt *m_stmt_player_metadata_add = nullptr;
 };
 
 #endif
index 86b7278129c73e84ef70d2aac23cf959bef145f2..a30d6a95f73be45b57ef48a9675d31a05d4bb9cb 100644 (file)
@@ -144,10 +144,6 @@ void DebugStack::print(std::ostream &os, bool everything)
 std::map<std::thread::id, DebugStack*> g_debug_stacks;
 std::mutex g_debug_stacks_mutex;
 
-void debug_stacks_init()
-{
-}
-
 void debug_stacks_print_to(std::ostream &os)
 {
        MutexAutoLock lock(g_debug_stacks_mutex);
index 2098942db7ec17e457fa72fb8e88d50f5e3c9d40..415797f43d56207a63305c74d60235fcf8c8cf77 100644 (file)
@@ -92,7 +92,6 @@ void debug_set_exception_handler();
 #define DEBUG_STACK_SIZE 50
 #define DEBUG_STACK_TEXT_SIZE 300
 
-extern void debug_stacks_init();
 extern void debug_stacks_print_to(std::ostream &os);
 extern void debug_stacks_print();
 
index 053f4dd454d3d9b16a4dbce80981cf3a14e480f4..f5852aaae7de09c640cf7cdc8bd3a57f84d4c387 100644 (file)
@@ -96,12 +96,10 @@ EmergeManager::EmergeManager(Server *server)
        this->oremgr    = new OreManager(server);
        this->decomgr   = new DecorationManager(server);
        this->schemmgr  = new SchematicManager(server);
-       this->gen_notify_on = 0;
 
        // Note that accesses to this variable are not synchronized.
        // This is because the *only* thread ever starting or stopping
        // EmergeThreads should be the ServerThread.
-       this->m_threads_active = false;
 
        enable_mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info");
 
index cf014a9e8e10d32af9223261360da8dbf4848a30..cf0a27d638200ebdd55c08d075f879c777cf2f0b 100644 (file)
@@ -47,20 +47,15 @@ class Server;
 
 // Structure containing inputs/outputs for chunk generation
 struct BlockMakeData {
-       MMVManip *vmanip;
-       u64 seed;
+       MMVManip *vmanip = nullptr;
+       u64 seed = 0;
        v3s16 blockpos_min;
        v3s16 blockpos_max;
        v3s16 blockpos_requested;
        UniqueQueue<v3s16> transforming_liquid;
-       INodeDefManager *nodedef;
-
-       BlockMakeData():
-               vmanip(NULL),
-               seed(0),
-               nodedef(NULL)
-       {}
+       INodeDefManager *nodedef = nullptr;
 
+       BlockMakeData() {}
        ~BlockMakeData() { delete vmanip; }
 };
 
@@ -96,7 +91,7 @@ public:
        bool enable_mapgen_debug_info;
 
        // Generation Notify
-       u32 gen_notify_on;
+       u32 gen_notify_on = 0;
        std::set<u32> gen_notify_on_deco_ids;
 
        // Parameters passed to mapgens owned by ServerMap
@@ -154,7 +149,7 @@ public:
 private:
        std::vector<Mapgen *> m_mapgens;
        std::vector<EmergeThread *> m_threads;
-       bool m_threads_active;
+       bool m_threads_active = false;
 
        std::mutex m_queue_mutex;
        std::map<v3s16, BlockEmergeData> m_blocks_enqueued;
index 4e782db81447f053261a1c32506862295a8837ba..3a6d1b787de4970f88ccc111306b7198ae9e10e8 100644 (file)
@@ -28,13 +28,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 
 Environment::Environment(IGameDef *gamedef):
-       m_time_of_day_speed(0),
-       m_time_of_day(9000),
-       m_time_of_day_f(9000./24000),
-       m_time_conversion_skew(0.0f),
-       m_enable_day_night_ratio_override(false),
-       m_day_night_ratio_override(0.0f),
-       m_gamedef(gamedef)
+       m_gamedef(gamedef),
+       m_time_of_day_speed(0.0f),
+       m_day_count(0)
 {
        m_cache_enable_shaders = g_settings->getBool("enable_shaders");
        m_cache_active_block_mgmt_interval = g_settings->getFloat("active_block_mgmt_interval");
index 55fc4707ce1a8ac5c90d2251d8cd22c032d3e16e..11c2533ca7c9e54489fb3a03c5ab1a87464ae3b5 100644 (file)
@@ -88,15 +88,15 @@ protected:
         * Below: values managed by m_time_lock
        */
        // Time of day in milli-hours (0-23999); determines day and night
-       u32 m_time_of_day;
+       u32 m_time_of_day = 9000;
        // Time of day in 0...1
-       float m_time_of_day_f;
+       float m_time_of_day_f = 9000.0f / 24000.0f;
        // Stores the skew created by the float -> u32 conversion
        // to be applied at next conversion, so that there is no real skew.
-       float m_time_conversion_skew;
+       float m_time_conversion_skew = 0.0f;
        // Overriding the day-night ratio is useful for custom sky visuals
-       bool m_enable_day_night_ratio_override;
-       u32 m_day_night_ratio_override;
+       bool m_enable_day_night_ratio_override = false;
+       u32 m_day_night_ratio_override = 0.0f;
        // Days from the server start, accounts for time shift
        // in game (e.g. /time or bed usage)
        std::atomic<u32> m_day_count;
index cfc222d5d26d9b7539dbb928e1124550202ef6e7..7ab139b5933b5726d575b894eaf92d484fcd3545 100644 (file)
@@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 class MtEvent
 {
 public:
-       virtual ~MtEvent(){};
+       virtual ~MtEvent() {};
        //virtual MtEvent* clone(){ return new IEvent; }
        virtual const char* getType() const = 0;
 
index 1b39c6725a7921a86f2cba8ccfc5b5707f864037..07fecdaf7da9f2fa9accc22310c8514501a962ce 100644 (file)
@@ -37,16 +37,6 @@ protected:
        std::string m_s;
 };
 
-class AsyncQueuedException : public BaseException {
-public:
-       AsyncQueuedException(const std::string &s): BaseException(s) {}
-};
-
-class NotImplementedException : public BaseException {
-public:
-       NotImplementedException(const std::string &s): BaseException(s) {}
-};
-
 class AlreadyExistsException : public BaseException {
 public:
        AlreadyExistsException(const std::string &s): BaseException(s) {}
@@ -77,16 +67,6 @@ public:
        PacketError(const std::string &s): BaseException(s) {}
 };
 
-class LoadError : public BaseException {
-public:
-       LoadError(const std::string &s): BaseException(s) {}
-};
-
-class ContainerFullException : public BaseException {
-public:
-       ContainerFullException(const std::string &s): BaseException(s) {}
-};
-
 class SettingNotFoundException : public BaseException {
 public:
        SettingNotFoundException(const std::string &s): BaseException(s) {}
@@ -97,16 +77,6 @@ public:
        InvalidFilenameException(const std::string &s): BaseException(s) {}
 };
 
-class ProcessingLimitException : public BaseException {
-public:
-       ProcessingLimitException(const std::string &s): BaseException(s) {}
-};
-
-class CommandLineError : public BaseException {
-public:
-       CommandLineError(const std::string &s): BaseException(s) {}
-};
-
 class ItemNotFoundException : public BaseException {
 public:
        ItemNotFoundException(const std::string &s): BaseException(s) {}
@@ -160,21 +130,5 @@ public:
        {}
 };
 
-class TargetInexistentException : public std::exception
-{
-       virtual const char * what() const throw()
-       {
-               return "Somebody tried to refer to something that doesn't exist.";
-       }
-};
-
-class NullPointerException : public std::exception
-{
-       virtual const char * what() const throw()
-       {
-               return "NullPointerException";
-       }
-};
-
 #endif
 
index da327c3f603cc93ffc3398db79591e866d82a0ca..2c277a04e99c8ff99491ddfae0c1b10439cca0a8 100644 (file)
@@ -43,12 +43,7 @@ static void font_setting_changed(const std::string &name, void *userdata)
 /******************************************************************************/
 FontEngine::FontEngine(Settings* main_settings, gui::IGUIEnvironment* env) :
        m_settings(main_settings),
-       m_env(env),
-       m_font_cache(),
-       m_currentMode(FM_Standard),
-       m_lastMode(),
-       m_lastSize(0),
-       m_lastFont(NULL)
+       m_env(env)
 {
 
        for (unsigned int i = 0; i < FM_MaxMode; i++) {
index 9f7266775ac944e515f77ee9bd12704966c3ba16..0c97ac77b3c9b78108f5eeb0fe52dc0e11c43581 100644 (file)
@@ -120,16 +120,16 @@ private:
        unsigned int m_default_size[FM_MaxMode];
 
        /** current font engine mode */
-       FontMode m_currentMode;
+       FontMode m_currentMode = FM_Standard;
 
        /** font mode of last request */
        FontMode m_lastMode;
 
        /** size of last request */
-       unsigned int m_lastSize;
+       unsigned int m_lastSize = 0;
 
        /** last font returned */
-       irr::gui::IGUIFont* m_lastFont;
+       irr::gui::IGUIFont* m_lastFont = nullptr;
 
 };
 
index d82650f0e398534d0372314cb165492a1d5bec26..d22d7ef0707ee9c401a563ab784769c312e07541 100644 (file)
@@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include <string>
 #include "irrlichttypes_bloated.h"
 #include <iostream>
+#include "itemgroup.h"
 
 enum GenericCMD {
        GENERIC_CMD_SET_PROPERTIES,
@@ -64,7 +65,6 @@ std::string gob_cmd_set_sprite(
 
 std::string gob_cmd_punched(s16 damage, s16 result_hp);
 
-#include "itemgroup.h"
 std::string gob_cmd_update_armor_groups(const ItemGroupList &armor_groups);
 
 std::string gob_cmd_update_physics_override(float physics_override_speed,
index 5bb80bbbe1b8c44931d5d7f2725f310b5bbcf718..fe11e730d6433649a8e7f4bb917e9b0b970252d5 100644 (file)
@@ -54,22 +54,7 @@ GUIChatConsole::GUIChatConsole(
        m_chat_backend(backend),
        m_client(client),
        m_menumgr(menumgr),
-       m_screensize(v2u32(0,0)),
-       m_animate_time_old(porting::getTimeMs()),
-       m_open(false),
-       m_close_on_enter(false),
-       m_height(0),
-       m_desired_height(0),
-       m_desired_height_fraction(0.0),
-       m_height_speed(5.0),
-       m_open_inhibited(0),
-       m_cursor_blink(0.0),
-       m_cursor_blink_speed(0.0),
-       m_cursor_height(0.0),
-       m_background(NULL),
-       m_background_color(255, 0, 0, 0),
-       m_font(NULL),
-       m_fontsize(0, 0)
+       m_animate_time_old(porting::getTimeMs())
 {
        // load background settings
        s32 console_alpha = g_settings->getS32("console_alpha");
index 0332678c759667cd9d66ddcac93b22d8094fd4b9..3c39f2da636130acf34f27e93a552a7e650c365e 100644 (file)
@@ -101,35 +101,35 @@ private:
        u64 m_animate_time_old;
 
        // should the console be opened or closed?
-       bool m_open;
+       bool m_open = false;
        // should it close after you press enter?
-       bool m_close_on_enter;
+       bool m_close_on_enter = false;
        // current console height [pixels]
-       s32 m_height;
+       s32 m_height = 0;
        // desired height [pixels]
-       f32 m_desired_height;
+       f32 m_desired_height = 0.0f;
        // desired height [screen height fraction]
-       f32 m_desired_height_fraction;
+       f32 m_desired_height_fraction = 0.0f;
        // console open/close animation speed [screen height fraction / second]
-       f32 m_height_speed;
+       f32 m_height_speed = 5.0f;
        // if nonzero, opening the console is inhibited [milliseconds]
-       u32 m_open_inhibited;
+       u32 m_open_inhibited = 0;
 
        // cursor blink frame (16-bit value)
        // cursor is off during [0,32767] and on during [32768,65535]
-       u32 m_cursor_blink;
+       u32 m_cursor_blink = 0;
        // cursor blink speed [on/off toggles / second]
-       f32 m_cursor_blink_speed;
+       f32 m_cursor_blink_speed = 0.0f;
        // cursor height [line height]
-       f32 m_cursor_height;
+       f32 m_cursor_height = 0.0f;
 
        // background texture
-       video::ITexture* m_background;
+       video::ITexture *m_background = nullptr;
        // background color (including alpha)
-       video::SColor m_background_color;
+       video::SColor m_background_color = video::SColor(255, 0, 0, 0);
 
        // font
-       gui::IGUIFont* m_font;
+       gui::IGUIFont *m_font = nullptr;
        v2u32 m_fontsize;
 };
 
index 545187bfc0ee9f513cde20348afbacc89bc2cb49..6363a340acbaf64dbb8471e568d1cd3608fea087 100644 (file)
@@ -142,18 +142,7 @@ GUIEngine::GUIEngine(      irr::IrrlichtDevice* dev,
        m_menumanager(menumgr),
        m_smgr(smgr),
        m_data(data),
-       m_texture_source(NULL),
-       m_sound_manager(NULL),
-       m_formspecgui(0),
-       m_buttonhandler(0),
-       m_menu(0),
-       m_kill(kill),
-       m_startgame(false),
-       m_script(0),
-       m_scriptdir(""),
-       m_irr_toplefttext(0),
-       m_clouds_enabled(true),
-       m_cloud()
+       m_kill(kill)
 {
        //initialize texture pointers
        for (unsigned int i = 0; i < TEX_LAYER_MAX; i++) {
index e7e5ca05dc30bae22dad0de4ffd7a3df172fd0ed..e6cea6b4fe91691f8b347c079880d1c7c44a46c5 100644 (file)
@@ -203,28 +203,28 @@ private:
        /** pointer to data beeing transfered back to main game handling */
        MainMenuData*            m_data;
        /** pointer to texture source */
-       ISimpleTextureSource*    m_texture_source;
+       ISimpleTextureSource    *m_texture_source = nullptr;
        /** pointer to soundmanager*/
-       ISoundManager*           m_sound_manager;
+       ISoundManager           *m_sound_manager = nullptr;
 
        /** representation of form source to be used in mainmenu formspec */
-       FormspecFormSource*      m_formspecgui;
+       FormspecFormSource      *m_formspecgui = nullptr;
        /** formspec input receiver */
-       TextDestGuiEngine*       m_buttonhandler;
+       TextDestGuiEngine       *m_buttonhandler = nullptr;
        /** the formspec menu */
-       GUIFormSpecMenu*         m_menu;
+       GUIFormSpecMenu         *m_menu = nullptr;
 
        /** reference to kill variable managed by SIGINT handler */
        bool&                    m_kill;
 
        /** variable used to abort menu and return back to main game handling */
-       bool                     m_startgame;
+       bool                     m_startgame = false;
 
        /** scripting interface */
-       MainMenuScripting*       m_script;
+       MainMenuScripting       *m_script = nullptr;
 
        /** script basefolder */
-       std::string              m_scriptdir;
+       std::string              m_scriptdir = "";
 
        /**
         * draw background layer
@@ -272,7 +272,7 @@ private:
        void setTopleftText(const std::string &text);
 
        /** pointer to gui element shown at topleft corner */
-       irr::gui::IGUIStaticText*       m_irr_toplefttext;
+       irr::gui::IGUIStaticText *m_irr_toplefttext = nullptr;
        /** and text that is in it */
        EnrichedString m_toplefttext;
 
@@ -296,7 +296,7 @@ private:
        };
 
        /** is drawing of clouds enabled atm */
-       bool        m_clouds_enabled;
+       bool        m_clouds_enabled = true;
        /** data used to draw clouds */
        clouddata   m_cloud;
 
@@ -308,6 +308,4 @@ private:
 
 };
 
-
-
 #endif /* GUI_ENGINE_H_ */
index e73f02e5cc2dda7d535464089bca891c5513bc66..85d9ef48ad912c52e7aa43fe880d3d41924e80d9 100644 (file)
@@ -89,22 +89,9 @@ GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
        m_invmgr(client),
        m_tsrc(tsrc),
        m_client(client),
-       m_selected_item(NULL),
-       m_selected_amount(0),
-       m_selected_dragging(false),
-       m_tooltip_element(NULL),
-       m_hovered_time(0),
-       m_old_tooltip_id(-1),
-       m_rmouse_auto_place(false),
-       m_allowclose(true),
-       m_lock(false),
        m_form_src(fsrc),
        m_text_dst(tdst),
-       m_formspec_version(0),
-       m_focused_element(""),
        m_joystick(joystick),
-       current_field_enter_pending(""),
-       m_font(NULL),
        m_remap_dbl_click(remap_dbl_click)
 #ifdef __ANDROID__
        , m_JavaDialogFieldName("")
@@ -2629,7 +2616,6 @@ void GUIFormSpecMenu::drawMenu()
                u64 delta = 0;
                if (id == -1) {
                        m_old_tooltip_id = id;
-                       m_old_tooltip = L"";
                } else {
                        if (id == m_old_tooltip_id) {
                                delta = porting::getDeltaMs(m_hovered_time, porting::getTimeMs());
@@ -2673,7 +2659,6 @@ void GUIFormSpecMenu::showTooltip(const std::wstring &text,
 {
        m_tooltip_element->setOverrideColor(color);
        m_tooltip_element->setBackgroundColor(bgcolor);
-       m_old_tooltip = text;
        setStaticText(m_tooltip_element, text.c_str());
 
        // Tooltip size and offset
@@ -3037,7 +3022,6 @@ bool GUIFormSpecMenu::preprocessEvent(const SEvent& event)
                                core::position2d<s32>(x, y));
                if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) {
                        m_old_tooltip_id = -1;
-                       m_old_tooltip = L"";
                }
                if (!isChild(hovered,this)) {
                        if (DoubleClickDetection(event)) {
index d08bb4ab59cdbdebed78c896365a7ea2423c3810..66b9b019a9d234dd624a578f78bd4137100495bc 100644 (file)
@@ -402,9 +402,9 @@ protected:
        std::vector<std::pair<FieldSpec,gui::IGUIScrollBar*> > m_scrollbars;
        std::vector<std::pair<FieldSpec, std::vector<std::string> > > m_dropdowns;
 
-       ItemSpec *m_selected_item;
-       u32 m_selected_amount;
-       bool m_selected_dragging;
+       ItemSpec *m_selected_item = nullptr;
+       u32 m_selected_amount = 0;
+       bool m_selected_dragging = false;
 
        // WARNING: BLACK MAGIC
        // Used to guess and keep up with some special things the server can do.
@@ -414,17 +414,16 @@ protected:
 
        v2s32 m_pointer;
        v2s32 m_old_pointer;  // Mouse position after previous mouse event
-       gui::IGUIStaticText *m_tooltip_element;
+       gui::IGUIStaticText *m_tooltip_element = nullptr;
 
        u64 m_tooltip_show_delay;
-       u64 m_hovered_time;
-       s32 m_old_tooltip_id;
-       std::wstring m_old_tooltip;
+       u64 m_hovered_time = 0;
+       s32 m_old_tooltip_id = -1;
 
-       bool m_rmouse_auto_place;
+       bool m_rmouse_auto_place = false;
 
-       bool m_allowclose;
-       bool m_lock;
+       bool m_allowclose = true;
+       bool m_lock = false;
        v2u32 m_lockscreensize;
 
        bool m_bgfullscreen;
@@ -439,8 +438,8 @@ protected:
 private:
        IFormSource        *m_form_src;
        TextDest           *m_text_dst;
-       unsigned int        m_formspec_version;
-       std::string         m_focused_element;
+       u32                 m_formspec_version = 0;
+       std::string         m_focused_element = "";
        JoystickController *m_joystick;
 
        typedef struct {
@@ -467,7 +466,7 @@ private:
        } fs_key_pendig;
 
        fs_key_pendig current_keys_pending;
-       std::string current_field_enter_pending;
+       std::string current_field_enter_pending = "";
 
        void parseElement(parserData* data, const std::string &element);
 
@@ -531,7 +530,7 @@ private:
        clickpos m_doubleclickdetect[2];
 
        int m_btn_height;
-       gui::IGUIFont *m_font;
+       gui::IGUIFont *m_font = nullptr;
 
        std::wstring getLabelByID(s32 id);
        std::string getNameByID(s32 id);