mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 05:09:20 +02:00
refactor(sonar): scope single-use variables in if init-statements (cpp:S6004)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -817,8 +817,7 @@ command_queue::push( command_data const &Command, uint32_t const Recipient ) {
|
||||
}
|
||||
|
||||
void command_queue::push_direct(const command_data &Command, const uint32_t Recipient) {
|
||||
auto const &desc = simulation::Commands_descriptions[ static_cast<std::size_t>( Command.command ) ];
|
||||
if (desc.mode == command_mode::continuous)
|
||||
if (auto const &desc = simulation::Commands_descriptions[ static_cast<std::size_t>( Command.command ) ]; desc.mode == command_mode::continuous)
|
||||
{
|
||||
if (Command.action == GLFW_PRESS)
|
||||
m_active_continuous.emplace(std::make_pair(Command.command, Recipient));
|
||||
@@ -855,9 +854,8 @@ command_queue::pop( command_data &Command, uint32_t const Recipient ) {
|
||||
}
|
||||
|
||||
bool command_queue::is_network_target(uint32_t const Recipient) const {
|
||||
const command_target target = (command_target)(Recipient & ~0xffff);
|
||||
|
||||
if (target == command_target::entity)
|
||||
if (const command_target target = (command_target)(Recipient & ~0xffff); target == command_target::entity)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -171,8 +171,7 @@ drivermouse_input::recall_bindings() {
|
||||
|
||||
std::string filePath = "eu07_input-mouse.ini";
|
||||
|
||||
fs::path appPath = user_config_path("eu07_input-mouse.ini");
|
||||
if (!appPath.empty() && fs::exists(appPath))
|
||||
if (fs::path appPath = user_config_path("eu07_input-mouse.ini"); !appPath.empty() && fs::exists(appPath))
|
||||
filePath = appPath.string();
|
||||
|
||||
cParser bindingparser(filePath.c_str(), cParser::buffer_FILE);
|
||||
|
||||
@@ -51,8 +51,7 @@ gamepad_input::init() {
|
||||
m_inputbuttons.clear();
|
||||
// NOTE: we're only checking for joystick_1 and rely for it to stay connected throughout.
|
||||
// not exactly flexible, but for quick hack it'll do
|
||||
auto const name = glfwGetJoystickName( GLFW_JOYSTICK_1 );
|
||||
if( name != nullptr ) {
|
||||
if( auto const name = glfwGetJoystickName( GLFW_JOYSTICK_1 ); name != nullptr ) {
|
||||
WriteLog( "Connected gamepad: " + std::string( name ) );
|
||||
m_deviceid = GLFW_JOYSTICK_1;
|
||||
}
|
||||
@@ -154,8 +153,7 @@ bool
|
||||
gamepad_input::recall_bindings() {
|
||||
std::string filePath = "eu07_input-gamepad.ini";
|
||||
|
||||
fs::path appPath = user_config_path("eu07_input-gamepad.ini");
|
||||
if (!appPath.empty() && fs::exists(appPath))
|
||||
if (fs::path appPath = user_config_path("eu07_input-gamepad.ini"); !appPath.empty() && fs::exists(appPath))
|
||||
filePath = appPath.string();
|
||||
|
||||
// bindingparser tworzony zawsze, z wybran<61> <20>cie<69>k<EFBFBD>
|
||||
@@ -211,8 +209,7 @@ gamepad_input::recall_bindings() {
|
||||
std::string key {};
|
||||
entryparser >> key;
|
||||
// check for potential mode indicator
|
||||
auto const splitkey { split_string_and_number( key ) };
|
||||
if( splitkey.first == "mode" ) {
|
||||
if( auto const splitkey { split_string_and_number( key ) }; splitkey.first == "mode" ) {
|
||||
// indicate we'll be processing specified mode
|
||||
controlmode = splitkey.second;
|
||||
continue;
|
||||
|
||||
@@ -239,8 +239,7 @@ void keyboard_input::dump_bindings() const
|
||||
stream << simulation::Commands_descriptions[static_cast<std::size_t>(binding.first)].name << ' ';
|
||||
|
||||
int keycode = std::get<int>(binding.second);
|
||||
auto it = keytonamemap.find(keycode & 0xFFFF);
|
||||
if (it != keytonamemap.end()) {
|
||||
if (auto it = keytonamemap.find(keycode & 0xFFFF); it != keytonamemap.end()) {
|
||||
if (keycode & keymodifier::control)
|
||||
stream << "ctrl ";
|
||||
if (keycode & keymodifier::shift)
|
||||
@@ -298,8 +297,7 @@ keyboard_input::key( int const Key, int const Action ) {
|
||||
| ( modifier ? 0 : input::key_ctrl ? keymodifier::control : 0 );
|
||||
|
||||
if( Action == GLFW_RELEASE ) {
|
||||
auto const stored = m_modsforkeys.find( Key );
|
||||
if( stored != m_modsforkeys.end() ) {
|
||||
if( auto const stored = m_modsforkeys.find( Key ); stored != m_modsforkeys.end() ) {
|
||||
key = stored->second;
|
||||
}
|
||||
m_modsforkeys.erase( Key );
|
||||
|
||||
Reference in New Issue
Block a user