From c63faf395f80e6e905015e698a31edb9e77a521c Mon Sep 17 00:00:00 2001 From: Benau Date: Fri, 25 Feb 2022 11:20:52 +0800 Subject: [PATCH] Remove unneeded character saving, we always get it from translated string if needed It causes undefined behavior in C++20, see #4735 --- src/input/binding.cpp | 14 -------------- src/input/binding.hpp | 6 ++---- src/input/device_config.cpp | 5 ++--- src/input/device_config.hpp | 3 +-- src/input/device_manager.cpp | 2 -- .../options/options_screen_device.cpp | 6 ++---- 6 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/input/binding.cpp b/src/input/binding.cpp index 937765599..6214f79d2 100644 --- a/src/input/binding.cpp +++ b/src/input/binding.cpp @@ -32,11 +32,6 @@ void Binding::save(std::ofstream& stream) const stream << "event=\"" << m_type << "\" "; stream << "id=\"" << m_id << "\" "; - if (m_type == Input::IT_KEYBOARD) - { - stream << "character=\"" << m_character << "\" "; - } - // Only serialize the direction and the range for stick motions if (m_type == Input::IT_STICKMOTION) { @@ -58,12 +53,6 @@ bool Binding::load(const XMLNode *action) // Default settings for button m_range = Input::AR_HALF; m_dir = Input::AD_NEUTRAL; - m_character = 0; - // XMLNode only supports stringw, not wchar_t* - core::stringw s; - action->get("character", &s); - if(s.size()>0) - m_character = s[0]; // If the action is not a stick motion (button or key) if (m_type == Input::IT_STICKMOTION) @@ -97,9 +86,6 @@ irr::core::stringw Binding::getAsString() const break; case Input::IT_KEYBOARD: s = "?"; - if(m_character) - s[0]=m_character; - switch(m_id) { //I18N: input configuration screen: mouse button diff --git a/src/input/binding.hpp b/src/input/binding.hpp index 78a82ec66..c523d9139 100644 --- a/src/input/binding.hpp +++ b/src/input/binding.hpp @@ -40,7 +40,6 @@ private: int m_id; Input::AxisDirection m_dir; Input::AxisRange m_range; - wchar_t m_character; public: /** Returns the type of device this binding is using. */ Input::InputType getType() const {return m_type; } @@ -57,10 +56,9 @@ public: /** Defines all values of this binding. */ void set(Input::InputType type, int id, Input::AxisDirection dir, - Input::AxisRange range, - wchar_t character) + Input::AxisRange range) { - m_type = type; m_id=id; m_dir=dir; m_range=range; m_character=character; + m_type = type; m_id=id; m_dir=dir; m_range=range; } // set // ------------------------------------------------------------------------ diff --git a/src/input/device_config.cpp b/src/input/device_config.cpp index 998c5f840..4b79e54e9 100644 --- a/src/input/device_config.cpp +++ b/src/input/device_config.cpp @@ -179,10 +179,9 @@ void DeviceConfig::setBinding ( const PlayerAction action, const Input::InputType type, const int id, Input::AxisDirection direction, - Input::AxisRange range, - wchar_t character) + Input::AxisRange range) { - m_bindings[action].set(type, id, direction, range, character); + m_bindings[action].set(type, id, direction, range); } // setBinding //------------------------------------------------------------------------------ diff --git a/src/input/device_config.hpp b/src/input/device_config.hpp index e1eb90ef8..d88fb34fc 100644 --- a/src/input/device_config.hpp +++ b/src/input/device_config.hpp @@ -89,8 +89,7 @@ public: const Input::InputType type, const int id, Input::AxisDirection direction = Input::AD_NEUTRAL, - Input::AxisRange range = Input::AR_HALF, - wchar_t character=0); + Input::AxisRange range = Input::AR_HALF); bool getMenuAction(Input::InputType type, const int id, int* value, diff --git a/src/input/device_manager.cpp b/src/input/device_manager.cpp index e61836a7b..c56f88182 100644 --- a/src/input/device_manager.cpp +++ b/src/input/device_manager.cpp @@ -563,8 +563,6 @@ void DeviceManager::save() configfile << "