From 3f1c9720fbbc626bad8784ef7160a4a8bb33bbb2 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Sat, 10 Oct 2026 15:05:42 +0200 Subject: [PATCH] refactor(sonar): prefer using over typedef (cpp:S5416) --- McZapkie/MOVER.h | 16 ++++++++-------- McZapkie/hamulce.h | 2 +- global_include/interfaces/ITexture.h | 2 +- input/command.h | 6 +++--- input/drivermouseinput.h | 2 +- model/MdlMngr.h | 4 ++-- rendering/lightarray.h | 2 +- rendering/openglmatrixstack.h | 2 +- vehicle/Train.h | 8 ++++---- world/mtable.h | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index accbbbaa..67f85413 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -764,7 +764,7 @@ enum class TLocalBrake HydraulicBrake }; /// Brake delay parameter table (apply/release for passenger and freight). -typedef double TBrakeDelayTable[4]; +using TBrakeDelayTable = double[4]; /// One row of the brake pressure / pipe pressure / flow-speed table for a brake handle position. struct TBrakePressure @@ -780,7 +780,7 @@ struct TBrakePressure }; /// Brake pressure table indexed by handle position. -typedef std::map TBrakePressureTable; +using TBrakePressureTable = std::map; /// Engine / drive type. enum class TEngineType @@ -1048,7 +1048,7 @@ struct TScheme bool AutoSwitch = false; /*czy dana pozycja nastawniana jest recznie czy autom.*/ int ScndAct = 0; /*jesli ma bocznik w nastawniku, to ktory bocznik na ktorej pozycji*/ }; -typedef TScheme TSchemeTable[ResArraySize + 1]; /*tablica rezystorow rozr.*/ +using TSchemeTable = TScheme[ResArraySize + 1]; /*tablica rezystorow rozr.*/ struct TDEScheme { double RPM = 0.0; /*obroty diesla*/ @@ -1056,13 +1056,13 @@ struct TDEScheme double Umax = 0.0; /*napiecie maksymalne*/ double Imax = 0.0; /*prad maksymalny*/ }; -typedef TDEScheme TDESchemeTable[33]; /*tablica WWList dla silnikow spalinowych*/ +using TDESchemeTable = TDEScheme[33]; /*tablica WWList dla silnikow spalinowych*/ struct TFFScheme { double v = 0.0; // parametr wejsciowy double freq = 0.0; // wyjscie: czestotliwosc falownika }; -typedef TFFScheme TFFSchemeTable[33]; +using TFFSchemeTable = TFFScheme[33]; struct TWiperScheme { @@ -1071,7 +1071,7 @@ struct TWiperScheme double interval = 0.0; // interwal pracy wycieraczki double outBackDelay = 0.0; // czas po jakim wycieraczka zacznie wracac z konca do poczatku }; -typedef TWiperScheme TWiperSchemeTable[16]; +using TWiperSchemeTable = TWiperScheme[16]; struct TShuntScheme { @@ -1080,13 +1080,13 @@ struct TShuntScheme double Pmin = 0.0; double Pmax = 0.0; }; -typedef TShuntScheme TShuntSchemeTable[33]; +using TShuntSchemeTable = TShuntScheme[33]; struct TMPTRelay { /*lista przekaznikow bocznikowania*/ double Iup = 0.0; double Idown = 0.0; }; -typedef TMPTRelay TMPTRelayTable[MotorParametersArraySize + 1]; // indexed like MotorParam +using TMPTRelayTable = TMPTRelay[MotorParametersArraySize + 1]; // indexed like MotorParam struct TMotorParameters { diff --git a/McZapkie/hamulce.h b/McZapkie/hamulce.h index 7f833f9c..802929da 100644 --- a/McZapkie/hamulce.h +++ b/McZapkie/hamulce.h @@ -275,7 +275,7 @@ class TReservoir }; /// Pointer typedef for a reservoir instance. -typedef TReservoir *PReservoir; +using PReservoir = TReservoir *; /// /// Brake cylinder reservoir — overrides pressure functions to model the diff --git a/global_include/interfaces/ITexture.h b/global_include/interfaces/ITexture.h index c7b5934e..10e40417 100644 --- a/global_include/interfaces/ITexture.h +++ b/global_include/interfaces/ITexture.h @@ -1,6 +1,6 @@ #pragma once -typedef int texture_handle; +using texture_handle = int; #define null_handle (0) diff --git a/input/command.h b/input/command.h index 7ff5b272..1d963289 100644 --- a/input/command.h +++ b/input/command.h @@ -455,8 +455,8 @@ class command_queue { public: // types - typedef std::deque commanddata_sequence; - typedef std::unordered_map commands_map; + using commanddata_sequence = std::deque; + using commands_map = std::unordered_map; // methods // posts specified command for specified recipient into m_intercept_queue void @@ -511,7 +511,7 @@ void add_to_dequemap(std::unordered_map> &lhs, const std::unord // but realistically it's not like we're going to run more than one simulation at a time namespace simulation { -typedef std::vector commanddescription_sequence; +using commanddescription_sequence = std::vector; extern command_queue Commands; // TODO: add name to command map, and wrap these two into helper object diff --git a/input/drivermouseinput.h b/input/drivermouseinput.h index 142ef99c..c64797c5 100644 --- a/input/drivermouseinput.h +++ b/input/drivermouseinput.h @@ -84,7 +84,7 @@ private: user_command down; }; - typedef std::unordered_map buttonbindings_map; + using buttonbindings_map = std::unordered_map; // methods void diff --git a/model/MdlMngr.h b/model/MdlMngr.h index 94baf3d4..1424f08d 100644 --- a/model/MdlMngr.h +++ b/model/MdlMngr.h @@ -26,8 +26,8 @@ public: private: // types: - typedef std::deque modelcontainer_sequence; - typedef std::unordered_map stringmodelcontainerindex_map; + using modelcontainer_sequence = std::deque; + using stringmodelcontainerindex_map = std::unordered_map; // members: static modelcontainer_sequence m_models; static stringmodelcontainerindex_map m_modelsmap; diff --git a/rendering/lightarray.h b/rendering/lightarray.h index d7459fe9..a136dfbc 100644 --- a/rendering/lightarray.h +++ b/rendering/lightarray.h @@ -36,7 +36,7 @@ public: update(); // types - typedef std::vector lightrecord_array; + using lightrecord_array = std::vector; // members lightrecord_array data; diff --git a/rendering/openglmatrixstack.h b/rendering/openglmatrixstack.h index 9ba2fa41..ea3be535 100644 --- a/rendering/openglmatrixstack.h +++ b/rendering/openglmatrixstack.h @@ -90,7 +90,7 @@ private: }; enum stack_mode { gl_modelview = 0, gl_projection = 1, gl_texture = 2 }; -typedef std::vector openglstack_array; +using openglstack_array = std::vector; public: // constructors: diff --git a/vehicle/Train.h b/vehicle/Train.h index 87641954..b863199c 100644 --- a/vehicle/Train.h +++ b/vehicle/Train.h @@ -59,7 +59,7 @@ private: }; class control_mapper { - typedef std::unordered_map< TSubModel const *, std::string> submodelstring_map; + using submodelstring_map = std::unordered_map< TSubModel const *, std::string>; submodelstring_map m_controlnames; using stringset = std::unordered_set; stringset m_names; // names of registered controls @@ -142,7 +142,7 @@ class TTrain { bool deserialize_mapping( cParser &Input ); }; - typedef std::vector screenentry_sequence; + using screenentry_sequence = std::vector; // methods bool CabChange(int iDirection); @@ -181,8 +181,8 @@ class TTrain { private: // types - typedef void( *command_handler )( TTrain *Train, command_data const &Command ); - typedef std::unordered_map commandhandler_map; + using command_handler = void (*)( TTrain *Train, command_data const &Command ); + using commandhandler_map = std::unordered_map; // methods // clears state of all cabin controls void clear_cab_controls(); diff --git a/world/mtable.h b/world/mtable.h index c58d120f..06595ef0 100644 --- a/world/mtable.h +++ b/world/mtable.h @@ -42,7 +42,7 @@ struct TMTableLine sound_source name_sound{ sound_placement::engine }; }; -typedef TMTableLine TMTable[MaxTTableSize + 1]; +using TMTable = TMTableLine[MaxTTableSize + 1]; // typedef TTrainParameters *PTrainParameters;