diff options
Diffstat (limited to 'src')
50 files changed, 331 insertions, 751 deletions
diff --git a/src/ban.cpp b/src/ban.cpp index 5fa430702..7a7fb8c3c 100644 --- a/src/ban.cpp +++ b/src/ban.cpp @@ -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; } @@ -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 diff --git a/src/camera.cpp b/src/camera.cpp index 52a42a3a9..d5e32bf5a 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -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; diff --git a/src/camera.h b/src/camera.h index 1e4800cba..8d213ede7 100644 --- a/src/camera.h +++ b/src/camera.h @@ -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; diff --git a/src/chat.cpp b/src/chat.cpp index ade3fefd3..72abc4669 100644 --- a/src/chat.cpp +++ b/src/chat.cpp @@ -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) { } diff --git a/src/chat.h b/src/chat.h index b7c6b74b9..6a6b7c26f 100644 --- a/src/chat.h +++ b/src/chat.h @@ -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 diff --git a/src/client.cpp b/src/client.cpp index 1f6f64ce0..7a097bc0d 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -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)); diff --git a/src/client.h b/src/client.h index babfe4680..1d5ab1298 100644 --- a/src/client.h +++ b/src/client.h @@ -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 diff --git a/src/clientenvironment.cpp b/src/clientenvironment.cpp index d6af06dde..2a761ee1d 100644 --- a/src/clientenvironment.cpp +++ b/src/clientenvironment.cpp @@ -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; diff --git a/src/clientenvironment.h b/src/clientenvironment.h index 2906553f0..c8b192ee9 100644 --- a/src/clientenvironment.h +++ b/src/clientenvironment.h @@ -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; diff --git a/src/clientiface.h b/src/clientiface.h index edcd91ef3..09855a372 100644 --- a/src/clientiface.h +++ b/src/clientiface.h @@ -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; diff --git a/src/clientmap.cpp b/src/clientmap.cpp index 6cd24ffc6..9186e3cab 100644 --- a/src/clientmap.cpp +++ b/src/clientmap.cpp @@ -67,13 +67,6 @@ ClientMap::ClientMap( ClientMap::~ClientMap() { - /*MutexAutoLock lock(mesh_mutex); - - if(mesh != NULL) - { - mesh->drop(); - mesh = NULL; - }*/ } MapSector * ClientMap::emergeSector(v2s16 p2d) diff --git a/src/clientmap.h b/src/clientmap.h index 84228f4ca..8d2720771 100644 --- a/src/clientmap.h +++ b/src/clientmap.h @@ -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; diff --git a/src/clientmedia.cpp b/src/clientmedia.cpp index 2877d8a2e..ca6f3d563 100644 --- a/src/clientmedia.cpp +++ b/src/clientmedia.cpp @@ -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() diff --git a/src/clientmedia.h b/src/clientmedia.h index 4c0c3c888..1834fb67f 100644 --- a/src/clientmedia.h +++ b/src/clientmedia.h @@ -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 = ""; }; diff --git a/src/clientsimpleobject.h b/src/clientsimpleobject.h index f5b79b64f..3e7704757 100644 --- a/src/clientsimpleobject.h +++ b/src/clientsimpleobject.h @@ -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) {} }; diff --git a/src/clouds.cpp b/src/clouds.cpp index 10a533cae..dc08d1ac0 100644 --- a/src/clouds.cpp +++ b/src/clouds.cpp @@ -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); diff --git a/src/clouds.h b/src/clouds.h index a0bda28df..869f7f7fc 100644 --- a/src/clouds.h +++ b/src/clouds.h @@ -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; }; diff --git a/src/collision.cpp b/src/collision.cpp index c0891c152..61972b2e8 100644 --- a/src/collision.cpp +++ b/src/collision.cpp @@ -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; } } } diff --git a/src/collision.h b/src/collision.h index 1ceaba81c..50755224b 100644 --- a/src/collision.h +++ b/src/collision.h @@ -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 diff --git a/src/content_cao.cpp b/src/content_cao.cpp index a5a55fd7e..0b9df6451 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -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); diff --git a/src/content_cao.h b/src/content_cao.h index e5b23aa35..e353b71de 100644 --- a/src/content_cao.h +++ b/src/content_cao.h @@ -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; diff --git a/src/content_cso.cpp b/src/content_cso.cpp index aca71212b..10d1f498b 100644 --- a/src/content_cso.cpp +++ b/src/content_cso.cpp @@ -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( diff --git a/src/content_nodemeta.cpp b/src/content_nodemeta.cpp index 79a32b6bf..fc2859d27 100644 --- a/src/content_nodemeta.cpp +++ b/src/content_nodemeta.cpp @@ -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 diff --git a/src/content_nodemeta.h b/src/content_nodemeta.h index ebc01d9a8..3c632ed4a 100644 --- a/src/content_nodemeta.h +++ b/src/content_nodemeta.h @@ -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 diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 90d830ce3..c6c00768e 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -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 diff --git a/src/content_sao.h b/src/content_sao.h index bb1a61a19..0a1ae5ecf 100644 --- a/src/content_sao.h +++ b/src/content_sao.h @@ -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 diff --git a/src/craftdef.h b/src/craftdef.h index bdd741f7c..fddff6cef 100644 --- a/src/craftdef.h +++ b/src/craftdef.h @@ -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; }; diff --git a/src/database-postgresql.cpp b/src/database-postgresql.cpp index a6b62bad5..ac25afd48 100644 --- a/src/database-postgresql.cpp +++ b/src/database-postgresql.cpp @@ -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( diff --git a/src/database-postgresql.h b/src/database-postgresql.h index d6f208fd9..8bb72ec6a 100644 --- a/src/database-postgresql.h +++ b/src/database-postgresql.h @@ -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 diff --git a/src/database-redis.h b/src/database-redis.h index fa15dd8a7..1e7909f85 100644 --- a/src/database-redis.h +++ b/src/database-redis.h @@ -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 diff --git a/src/database-sqlite3.cpp b/src/database-sqlite3.cpp index 7bc87a7d0..22765c8d2 100644 --- a/src/database-sqlite3.cpp +++ b/src/database-sqlite3.cpp @@ -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) diff --git a/src/database-sqlite3.h b/src/database-sqlite3.h index 3244facc9..ec7a34ad7 100644 --- a/src/database-sqlite3.h +++ b/src/database-sqlite3.h @@ -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 diff --git a/src/debug.cpp b/src/debug.cpp index 86b727812..a30d6a95f 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -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); diff --git a/src/debug.h b/src/debug.h index 2098942db..415797f43 100644 --- a/src/debug.h +++ b/src/debug.h @@ -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(); diff --git a/src/emerge.cpp b/src/emerge.cpp index 053f4dd45..f5852aaae 100644 --- a/src/emerge.cpp +++ b/src/emerge.cpp @@ -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"); diff --git a/src/emerge.h b/src/emerge.h index cf014a9e8..cf0a27d63 100644 --- a/src/emerge.h +++ b/src/emerge.h @@ -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; diff --git a/src/environment.cpp b/src/environment.cpp index 4e782db81..3a6d1b787 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -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"); diff --git a/src/environment.h b/src/environment.h index 55fc4707c..11c2533ca 100644 --- a/src/environment.h +++ b/src/environment.h @@ -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; diff --git a/src/event.h b/src/event.h index cfc222d5d..7ab139b59 100644 --- a/src/event.h +++ b/src/event.h @@ -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; diff --git a/src/exceptions.h b/src/exceptions.h index 1b39c6725..07fecdaf7 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -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 diff --git a/src/fontengine.cpp b/src/fontengine.cpp index da327c3f6..2c277a04e 100644 --- a/src/fontengine.cpp +++ b/src/fontengine.cpp @@ -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++) { diff --git a/src/fontengine.h b/src/fontengine.h index 9f7266775..0c97ac77b 100644 --- a/src/fontengine.h +++ b/src/fontengine.h @@ -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; }; diff --git a/src/genericobject.h b/src/genericobject.h index d82650f0e..d22d7ef07 100644 --- a/src/genericobject.h +++ b/src/genericobject.h @@ -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, diff --git a/src/guiChatConsole.cpp b/src/guiChatConsole.cpp index 5bb80bbbe..fe11e730d 100644 --- a/src/guiChatConsole.cpp +++ b/src/guiChatConsole.cpp @@ -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"); diff --git a/src/guiChatConsole.h b/src/guiChatConsole.h index 0332678c7..3c39f2da6 100644 --- a/src/guiChatConsole.h +++ b/src/guiChatConsole.h @@ -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; }; diff --git a/src/guiEngine.cpp b/src/guiEngine.cpp index 545187bfc..6363a340a 100644 --- a/src/guiEngine.cpp +++ b/src/guiEngine.cpp @@ -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++) { diff --git a/src/guiEngine.h b/src/guiEngine.h index e7e5ca05d..e6cea6b4f 100644 --- a/src/guiEngine.h +++ b/src/guiEngine.h @@ -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_ */ diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp index e73f02e5c..85d9ef48a 100644 --- a/src/guiFormSpecMenu.cpp +++ b/src/guiFormSpecMenu.cpp @@ -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)) { diff --git a/src/guiFormSpecMenu.h b/src/guiFormSpecMenu.h index d08bb4ab5..66b9b019a 100644 --- a/src/guiFormSpecMenu.h +++ b/src/guiFormSpecMenu.h @@ -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); |