diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/clientlauncher.cpp | 6 | ||||
-rw-r--r-- | src/client/clientlauncher.h | 54 | ||||
-rw-r--r-- | src/client/inputhandler.h | 48 | ||||
-rw-r--r-- | src/client/joystick_controller.cpp | 7 | ||||
-rw-r--r-- | src/client/joystick_controller.h | 2 | ||||
-rw-r--r-- | src/client/tile.h | 79 |
6 files changed, 71 insertions, 125 deletions
diff --git a/src/client/clientlauncher.cpp b/src/client/clientlauncher.cpp index 1a7970872..9856c1920 100644 --- a/src/client/clientlauncher.cpp +++ b/src/client/clientlauncher.cpp @@ -38,8 +38,8 @@ with this program; if not, write to the Free Software Foundation, Inc., /* mainmenumanager.h */ -gui::IGUIEnvironment *guienv = NULL; -gui::IGUIStaticText *guiroot = NULL; +gui::IGUIEnvironment *guienv = nullptr; +gui::IGUIStaticText *guiroot = nullptr; MainMenuManager g_menumgr; bool isMenuActive() @@ -48,7 +48,7 @@ bool isMenuActive() } // Passed to menus to allow disconnecting and exiting -MainGameCallback *g_gamecallback = NULL; +MainGameCallback *g_gamecallback = nullptr; ClientLauncher::~ClientLauncher() diff --git a/src/client/clientlauncher.h b/src/client/clientlauncher.h index 4ff77bc03..9e0560b14 100644 --- a/src/client/clientlauncher.h +++ b/src/client/clientlauncher.h @@ -28,25 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc., class ClientLauncher { public: - ClientLauncher() : - list_video_modes(false), - skip_main_menu(false), - use_freetype(false), - random_input(false), - address(""), - playername(""), - password(""), - device(NULL), - input(NULL), - receiver(NULL), - skin(NULL), - font(NULL), - simple_singleplayer_mode(false), - current_playername("inv£lid"), - current_password(""), - current_address("does-not-exist"), - current_port(0) - {} + ClientLauncher() {} ~ClientLauncher(); @@ -66,29 +48,29 @@ protected: void speed_tests(); bool print_video_modes(); - bool list_video_modes; - bool skip_main_menu; - bool use_freetype; - bool random_input; - std::string address; - std::string playername; - std::string password; - IrrlichtDevice *device; - InputHandler *input; - MyEventReceiver *receiver; - gui::IGUISkin *skin; - gui::IGUIFont *font; - scene::ISceneManager *smgr; + bool list_video_modes = false; + bool skip_main_menu = false; + bool use_freetype = false; + bool random_input = false; + std::string address = ""; + std::string playername = ""; + std::string password = ""; + IrrlichtDevice *device = nullptr; + InputHandler *input = nullptr; + MyEventReceiver *receiver = nullptr; + gui::IGUISkin *skin = nullptr; + gui::IGUIFont *font = nullptr; + scene::ISceneManager *smgr = nullptr; SubgameSpec gamespec; WorldSpec worldspec; bool simple_singleplayer_mode; // These are set up based on the menu and other things // TODO: Are these required since there's already playername, password, etc - std::string current_playername; - std::string current_password; - std::string current_address; - int current_port; + std::string current_playername = "inv£lid"; + std::string current_password = ""; + std::string current_address = "does-not-exist"; + int current_port = 0; }; #endif diff --git a/src/client/inputhandler.h b/src/client/inputhandler.h index 7c422d189..19733e3ec 100644 --- a/src/client/inputhandler.h +++ b/src/client/inputhandler.h @@ -141,24 +141,23 @@ public: MyEventReceiver() { - clearInput(); #ifdef HAVE_TOUCHSCREENGUI m_touchscreengui = NULL; #endif } - bool leftclicked; - bool rightclicked; - bool leftreleased; - bool rightreleased; + bool leftclicked = false; + bool rightclicked = false; + bool leftreleased = false; + bool rightreleased = false; - bool left_active; - bool middle_active; - bool right_active; + bool left_active = false; + bool middle_active = false; + bool right_active = false; - s32 mouse_wheel; + s32 mouse_wheel = 0; - JoystickController *joystick; + JoystickController *joystick = nullptr; #ifdef HAVE_TOUCHSCREENGUI TouchScreenGUI *m_touchscreengui; @@ -221,7 +220,7 @@ class RealInputHandler : public InputHandler { public: RealInputHandler(IrrlichtDevice *device, MyEventReceiver *receiver) - : m_device(device), m_receiver(receiver), m_mousepos(0, 0) + : m_device(device), m_receiver(receiver) { m_receiver->joystick = &joystick; } @@ -277,24 +276,15 @@ public: } private: - IrrlichtDevice *m_device; - MyEventReceiver *m_receiver; + IrrlichtDevice *m_device = nullptr; + MyEventReceiver *m_receiver = nullptr; v2s32 m_mousepos; }; class RandomInputHandler : public InputHandler { public: - RandomInputHandler() - { - leftdown = false; - rightdown = false; - leftclicked = false; - rightclicked = false; - leftreleased = false; - rightreleased = false; - keydown.clear(); - } + RandomInputHandler() {} virtual bool isKeyDown(const KeyPress &keyCode) { return keydown[keyCode]; } virtual bool wasKeyDown(const KeyPress &keyCode) { return false; } virtual v2s32 getMousePos() { return mousepos; } @@ -390,12 +380,12 @@ private: KeyList keydown; v2s32 mousepos; v2s32 mousespeed; - bool leftdown; - bool rightdown; - bool leftclicked; - bool rightclicked; - bool leftreleased; - bool rightreleased; + bool leftdown = false; + bool rightdown = false; + bool leftclicked = false; + bool rightclicked = false; + bool leftreleased = false; + bool rightreleased = false; }; #endif diff --git a/src/client/joystick_controller.cpp b/src/client/joystick_controller.cpp index 905ca6420..5a3d35d7c 100644 --- a/src/client/joystick_controller.cpp +++ b/src/client/joystick_controller.cpp @@ -154,12 +154,9 @@ JoystickLayout create_xbox_layout() return jlo; } -JoystickController::JoystickController() +JoystickController::JoystickController() : + doubling_dtime(g_settings->getFloat("repeat_joystick_button_time")) { - m_joystick_id = 0; - - doubling_dtime = g_settings->getFloat("repeat_joystick_button_time"); - for (size_t i = 0; i < KeyType::INTERNAL_ENUM_COUNT; i++) { m_past_pressed_time[i] = 0; } diff --git a/src/client/joystick_controller.h b/src/client/joystick_controller.h index 2c0e7b90a..baec4e412 100644 --- a/src/client/joystick_controller.h +++ b/src/client/joystick_controller.h @@ -155,7 +155,7 @@ private: s16 m_axes_vals[JA_COUNT]; - u8 m_joystick_id; + u8 m_joystick_id = 0; std::bitset<KeyType::INTERNAL_ENUM_COUNT> m_pressed_keys; diff --git a/src/client/tile.h b/src/client/tile.h index 23255c461..a810aa8e5 100644 --- a/src/client/tile.h +++ b/src/client/tile.h @@ -69,7 +69,7 @@ void clearTextureNameCache(); namespace irr {namespace scene {class IMesh;}} struct TextureFromMeshParams { - scene::IMesh *mesh; + scene::IMesh *mesh = nullptr; core::dimension2d<u32> dim; std::string rtt_texture_name; bool delete_texture_on_shutdown; @@ -92,7 +92,7 @@ public: ISimpleTextureSource(){} virtual ~ISimpleTextureSource(){} virtual video::ITexture* getTexture( - const std::string &name, u32 *id = NULL) = 0; + const std::string &name, u32 *id = nullptr) = 0; }; class ITextureSource : public ISimpleTextureSource @@ -104,9 +104,9 @@ public: virtual std::string getTextureName(u32 id)=0; virtual video::ITexture* getTexture(u32 id)=0; virtual video::ITexture* getTexture( - const std::string &name, u32 *id = NULL)=0; + const std::string &name, u32 *id = nullptr)=0; virtual video::ITexture* getTextureForMesh( - const std::string &name, u32 *id = NULL) = 0; + const std::string &name, u32 *id = nullptr) = 0; /*! * Returns a palette from the given texture name. * The pointer is valid until the texture source is @@ -132,7 +132,7 @@ public: virtual std::string getTextureName(u32 id)=0; virtual video::ITexture* getTexture(u32 id)=0; virtual video::ITexture* getTexture( - const std::string &name, u32 *id = NULL)=0; + const std::string &name, u32 *id = nullptr)=0; virtual IrrlichtDevice* getDevice()=0; virtual bool isKnownSourceImage(const std::string &name)=0; virtual video::ITexture* generateTextureFromMesh( @@ -180,17 +180,11 @@ enum MaterialType{ */ struct FrameSpec { - FrameSpec(): - texture_id(0), - texture(NULL), - normal_texture(NULL), - flags_texture(NULL) - { - } - u32 texture_id; - video::ITexture *texture; - video::ITexture *normal_texture; - video::ITexture *flags_texture; + FrameSpec() {} + u32 texture_id = 0; + video::ITexture *texture = nullptr; + video::ITexture *normal_texture = nullptr; + video::ITexture *flags_texture = nullptr; }; #define MAX_TILE_LAYERS 2 @@ -198,25 +192,7 @@ struct FrameSpec //! Defines a layer of a tile. struct TileLayer { - TileLayer(): - texture(NULL), - normal_texture(NULL), - flags_texture(NULL), - shader_id(0), - texture_id(0), - animation_frame_length_ms(0), - animation_frame_count(1), - material_type(TILE_MATERIAL_BASIC), - material_flags( - //0 // <- DEBUG, Use the one below - MATERIAL_FLAG_BACKFACE_CULLING | - MATERIAL_FLAG_TILEABLE_HORIZONTAL| - MATERIAL_FLAG_TILEABLE_VERTICAL - ), - has_color(false), - color() - { - } + TileLayer() {} /*! * Two layers are equal if they can be merged. @@ -287,22 +263,26 @@ struct TileLayer // Ordered for size, please do not reorder - video::ITexture *texture; - video::ITexture *normal_texture; - video::ITexture *flags_texture; + video::ITexture *texture = nullptr; + video::ITexture *normal_texture = nullptr; + video::ITexture *flags_texture = nullptr; - u32 shader_id; + u32 shader_id = 0; - u32 texture_id; + u32 texture_id = 0; - u16 animation_frame_length_ms; - u8 animation_frame_count; + u16 animation_frame_length_ms = 0; + u8 animation_frame_count = 1; - u8 material_type; - u8 material_flags; + u8 material_type = TILE_MATERIAL_BASIC; + u8 material_flags = + //0 // <- DEBUG, Use the one below + MATERIAL_FLAG_BACKFACE_CULLING | + MATERIAL_FLAG_TILEABLE_HORIZONTAL| + MATERIAL_FLAG_TILEABLE_VERTICAL; //! If true, the tile has its own color. - bool has_color; + bool has_color = false; std::vector<FrameSpec> frames; @@ -318,10 +298,7 @@ struct TileLayer */ struct TileSpec { - TileSpec(): - rotation(0), - emissive_light(0) - { + TileSpec() { for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) layers[layer] = TileLayer(); } @@ -341,9 +318,9 @@ struct TileSpec && emissive_light == other.emissive_light; } - u8 rotation; + u8 rotation = 0; //! This much light does the tile emit. - u8 emissive_light; + u8 emissive_light = 0; //! The first is base texture, the second is overlay. TileLayer layers[MAX_TILE_LAYERS]; }; |