From 31f9ca0afc250f493ad58958414f3b53c53daf23 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Sat, 4 Jul 2026 05:39:03 +0200 Subject: [PATCH] reformat: remove redundant parentheses --- network/network.cpp | 2 +- utilities/utilities.h | 2 +- vr/openvr_imp.cpp | 14 ++++++------ widgets/cameraview_extcam.cpp | 2 +- widgets/map.cpp | 4 ++-- widgets/map_objects.h | 4 ++-- widgets/perfgraphs.cpp | 2 +- widgets/trainingcard.cpp | 24 ++++++++++---------- widgets/vehicleparams.cpp | 42 +++++++++++++++++++++++++---------- 9 files changed, 57 insertions(+), 39 deletions(-) diff --git a/network/network.cpp b/network/network.cpp index a377404a..c9de1b16 100644 --- a/network/network.cpp +++ b/network/network.cpp @@ -193,7 +193,7 @@ std::tuple network::client::get_nex if (counter == 1 && size < MAX_BUFFER_SIZE * 2.0f) { last_target = last_target * TARGET_MIX + - (std::min(TARGET_MIN + jitteriness * JITTERINESS_MULTIPIER, MAX_BUFFER_SIZE)) * (1.0f - TARGET_MIX); + std::min(TARGET_MIN + jitteriness * JITTERINESS_MULTIPIER, MAX_BUFFER_SIZE) * (1.0f - TARGET_MIX); const float diff = size - last_target; jitteriness = std::max(jitteriness * JITTERINESS_MIX, std::abs(diff)); diff --git a/utilities/utilities.h b/utilities/utilities.h index 591b71f3..e9a438e2 100644 --- a/utilities/utilities.h +++ b/utilities/utilities.h @@ -256,7 +256,7 @@ template bool is_equal(T const &Left, T const &Right, T const Epsil template constexpr Type_ safe_clamp( Type_ const Value, Type_ const Lo, Type_ const Hi ) { - return ( Hi < Lo ) + return Hi < Lo ? std::clamp( Value, Hi, Lo ) : std::clamp( Value, Lo, Hi ); } diff --git a/vr/openvr_imp.cpp b/vr/openvr_imp.cpp index 8425a3c4..6c37ff3c 100644 --- a/vr/openvr_imp.cpp +++ b/vr/openvr_imp.cpp @@ -32,7 +32,7 @@ vr_openvr::vr_openvr() std::unique_ptr vr_openvr::create_hiddenarea_model(eye_e e) { - vr::HiddenAreaMesh_t mesh = vr_system->GetHiddenAreaMesh((e == eye_left) ? vr::Eye_Left : vr::Eye_Right, vr::k_eHiddenAreaMesh_Standard); + vr::HiddenAreaMesh_t mesh = vr_system->GetHiddenAreaMesh(e == eye_left ? vr::Eye_Left : vr::Eye_Right, vr::k_eHiddenAreaMesh_Standard); if (!mesh.unTriangleCount) return nullptr; @@ -66,7 +66,7 @@ glm::ivec2 vr_openvr::get_target_size() viewport_proj_config vr_openvr::get_proj_config(eye_e e) { - vr::EVREye eye = (e == eye_left) ? vr::Eye_Left : vr::Eye_Right; + vr::EVREye eye = e == eye_left ? vr::Eye_Left : vr::Eye_Right; float left, right, top, bottom; // tangents of half-angles from center view axis vr_system->GetProjectionRaw(eye, &left, &right, &top, &bottom); @@ -85,7 +85,7 @@ viewport_proj_config vr_openvr::get_proj_config(eye_e e) glm::mat4 vr_openvr::get_matrix(const vr::HmdMatrix34_t &src) { - return glm::mat4(glm::transpose(glm::make_mat3x4((float*)(src.m)))); + return glm::mat4(glm::transpose(glm::make_mat3x4((float*)src.m))); } void vr_openvr::begin_frame() @@ -273,8 +273,8 @@ texture_done: vr::InputDigitalActionData_t actiondata_sec; vr::VRInput()->GetDigitalActionData(secondary_action, &actiondata_sec, sizeof(actiondata_sec), vr::k_ulInvalidInputValueHandle); - bool any_changed = (actiondata_pri.bChanged || actiondata_sec.bChanged); - bool any_active = (actiondata_pri.bState || actiondata_sec.bState); + bool any_changed = actiondata_pri.bChanged || actiondata_sec.bChanged; + bool any_active = actiondata_pri.bState || actiondata_sec.bState; if (command_active == user_command::none && any_changed) { bool primary = actiondata_pri.bState; @@ -343,10 +343,10 @@ bool vr_openvr::update_component(const std::string &rendermodel, vr::VRInputValu vr::VRRenderModels()->GetComponentStateForDevicePath(rendermodel.c_str(), component->pName.c_str(), handle, &state, &component_state); const glm::mat4 component_pose = get_matrix(component_state.mTrackingToComponentRenderModel); - bool visible = (component_state.uProperties & vr::VRComponentProperty_IsVisible); + bool visible = component_state.uProperties & vr::VRComponentProperty_IsVisible; component->ReplaceMatrix(component_pose); - component->iVisible = (visible ? 1 : 0); + component->iVisible = visible ? 1 : 0; return !(component_state.uProperties & vr::VRComponentProperty_IsStatic); } diff --git a/widgets/cameraview_extcam.cpp b/widgets/cameraview_extcam.cpp index c41abc50..36116a9c 100644 --- a/widgets/cameraview_extcam.cpp +++ b/widgets/cameraview_extcam.cpp @@ -113,7 +113,7 @@ void ui::cameraview_panel::render_contents() } const ImVec2 surface_size = ImGui::GetContentRegionAvail(); - ImGui::Image((ImTextureID)(intptr_t)(texture->id), surface_size); + ImGui::Image((ImTextureID)(intptr_t)texture->id, surface_size); } void ui::cameraview_panel::capture_func() diff --git a/widgets/map.cpp b/widgets/map.cpp index f58fa3c9..897cd22c 100644 --- a/widgets/map.cpp +++ b/widgets/map.cpp @@ -299,7 +299,7 @@ void ui::map_panel::render_contents() ImVec2 window_origin = ImGui::GetCursorPos(); ImVec2 screen_origin = ImGui::GetCursorScreenPos(); - ImGui::ImageButton((ImTextureID)(intptr_t)(m_tex->id), surface_size_im, ImVec2(0, surface_size.y / fb_size), ImVec2(surface_size.x / fb_size, 0), 0); + ImGui::ImageButton((ImTextureID)(intptr_t)m_tex->id, surface_size_im, ImVec2(0, surface_size.y / fb_size), ImVec2(surface_size.x / fb_size, 0), 0); if (ImGui::IsItemHovered()) { @@ -565,7 +565,7 @@ void ui::track_switch_window::render_content() m_relay.post(user_command::queueevent, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &m_switch->action[i]->name()); if (ImGui::IsItemHovered()) { for (size_t j = 0; j < 4; j++) { - if ((names[i][0] - 'a') != j && (names[i][1] - 'a') != j) + if (names[i][0] - 'a' != j && names[i][1] - 'a' != j) continue; highlight.push_back(std::make_pair(m_switch->track[j], m_switch->preview[i][j] == '1' ? 1 : 0)); } diff --git a/widgets/map_objects.h b/widgets/map_objects.h index 4de5e301..bfc98f4a 100644 --- a/widgets/map_objects.h +++ b/widgets/map_objects.h @@ -30,9 +30,9 @@ struct semaphore : public map_object TMemCell *memcell = nullptr; virtual gfx::basic_vertex vertex() override { - const bool stop_signal = memcell->IsVelocity() && (memcell->Value1() == 0.0); + const bool stop_signal = memcell->IsVelocity() && memcell->Value1() == 0.0; return gfx::basic_vertex(location, glm::vec3(), - (!stop_signal) ? glm::vec2(0.0f, 0.2f) : glm::vec2(0.2f, 0.4f)); + !stop_signal ? glm::vec2(0.0f, 0.2f) : glm::vec2(0.2f, 0.4f)); } }; diff --git a/widgets/perfgraphs.cpp b/widgets/perfgraphs.cpp index bff56356..3b30c79b 100644 --- a/widgets/perfgraphs.cpp +++ b/widgets/perfgraphs.cpp @@ -10,7 +10,7 @@ void perfgraph_panel::render_contents() { { for (size_t i = 0; i < (size_t)TIMER_MAX; i++) { - const bool is_selected = (current_timer == (timers_e)i); + const bool is_selected = current_timer == (timers_e)i; if (ImGui::Selectable(timer_label[i].c_str(), is_selected)) current_timer = (timers_e)i; if (is_selected) diff --git a/widgets/trainingcard.cpp b/widgets/trainingcard.cpp index 64ee7c6a..70fb2111 100644 --- a/widgets/trainingcard.cpp +++ b/widgets/trainingcard.cpp @@ -46,7 +46,7 @@ void trainingcard_panel::clear() void trainingcard_panel::save_thread_func() { - std::tm *tm = std::localtime(&(*start_time_wall)); + std::tm *tm = std::localtime(&*start_time_wall); std::string date = std::to_string(tm->tm_year + 1900) + "-" + std::to_string(tm->tm_mon + 1) + "-" + std::to_string(tm->tm_mday); std::string from = std::to_string(tm->tm_hour) + ":" + std::to_string(tm->tm_min); std::time_t now = std::time(nullptr); @@ -62,17 +62,17 @@ void trainingcard_panel::save_thread_func() const std::string magic("{{CONTENT}}"); if (in_line.compare(0, magic.size(), magic) == 0) { - temp << "
Miejsce: " << (std::string(place.c_str())) << "

" << std::endl; - temp << "
Data: " << (date) << "

" << std::endl; - temp << "
Czas: " << (from) << " - " << (to) << "

" << std::endl; - temp << "
Imię (imiona) i nazwisko szkolonego: " << (trainee_name) << "

" << std::endl; - temp << "
Data urodzenia: " << (trainee_birthdate) << "

" << std::endl; - temp << "
Firma: " << (trainee_company) << "

" << std::endl; - temp << "
Imię i nazwisko instruktora: " << (instructor_name) << "

" << std::endl; - temp << "
Odcinek trasy: " << (track_segment) << "

" << std::endl; + temp << "
Miejsce: " << std::string(place.c_str()) << "

" << std::endl; + temp << "
Data: " << date << "

" << std::endl; + temp << "
Czas: " << from << " - " << to << "

" << std::endl; + temp << "
Imię (imiona) i nazwisko szkolonego: " << trainee_name << "

" << std::endl; + temp << "
Data urodzenia: " << trainee_birthdate << "

" << std::endl; + temp << "
Firma: " << trainee_company << "

" << std::endl; + temp << "
Imię i nazwisko instruktora: " << instructor_name << "

" << std::endl; + temp << "
Odcinek trasy: " << track_segment << "

" << std::endl; if (distance > 0.0f) temp << "
Przebyta odległość: " << std::round(distance) << " km

" << std::endl; - temp << "
Uwagi:
" << (remarks) << "
" << std::endl; + temp << "
Uwagi:
" << remarks << "
" << std::endl; } else { @@ -121,7 +121,7 @@ void trainingcard_panel::render_contents() if (start_time_wall) { - const std::tm *tm = std::localtime(&(*start_time_wall)); + const std::tm *tm = std::localtime(&*start_time_wall); const std::string rep = "Czas rozpoczęcia: " + std::to_string(tm->tm_year + 1900) + "-" + std::to_string(tm->tm_mon + 1) + "-" + std::to_string(tm->tm_mday) + " " + std::to_string(tm->tm_hour) + ":" + std::to_string(tm->tm_min); ImGui::TextUnformatted(rep.c_str()); @@ -159,7 +159,7 @@ void trainingcard_panel::render_contents() if (ImGui::Button("Rozpocznij szkolenie")) { start_time_wall = std::time(nullptr); - const std::tm *tm = std::localtime(&(*start_time_wall)); + const std::tm *tm = std::localtime(&*start_time_wall); recording_timestamp = std::to_string(tm->tm_year + 1900) + std::to_string(tm->tm_mon + 1) + std::to_string(tm->tm_mday) + std::to_string(tm->tm_hour) + std::to_string(tm->tm_min) + "_" + std::string(trainee_name.c_str()) + "_" + std::string(instructor_name.c_str()); diff --git a/widgets/vehicleparams.cpp b/widgets/vehicleparams.cpp index cb7f6caa..a85b4f00 100644 --- a/widgets/vehicleparams.cpp +++ b/widgets/vehicleparams.cpp @@ -142,19 +142,37 @@ void ui::vehicleparams_panel::render_contents() std::vector lines; std::array buffer; - auto const isdieselenginepowered{(mover.EngineType == TEngineType::DieselElectric) || (mover.EngineType == TEngineType::DieselEngine)}; + auto const isdieselenginepowered{mover.EngineType == TEngineType::DieselElectric || mover.EngineType == TEngineType::DieselEngine}; auto const isdieselinshuntmode{mover.ShuntMode && mover.EngineType == TEngineType::DieselElectric}; std::snprintf(buffer.data(), buffer.size(), STR_C("Devices: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nPower transfers: %.0f@%.0f%s%s%s%.0f@%.0f"), // devices - (mover.Battery ? 'B' : '.'), (mover.Mains ? 'M' : '.'), (mover.FuseFlag ? '!' : '.'), (mover.Pantographs[rear].is_active ? (mover.PantRearVolt > 0.0 ? 'O' : 'o') : '.'), - (mover.Pantographs[front].is_active ? (mover.PantFrontVolt > 0.0 ? 'P' : 'p') : '.'), (mover.PantPressLockActive ? '!' : (mover.PantPressSwitchActive ? '*' : '.')), - (mover.WaterPump.is_active ? 'W' : (false == mover.WaterPump.breaker ? '-' : (mover.WaterPump.is_enabled ? 'w' : '.'))), - (true == mover.WaterHeater.is_damaged ? '!' : (mover.WaterHeater.is_active ? 'H' : (false == mover.WaterHeater.breaker ? '-' : (mover.WaterHeater.is_enabled ? 'h' : '.')))), - (mover.FuelPump.is_active ? 'F' : (mover.FuelPump.is_enabled ? 'f' : '.')), (mover.OilPump.is_active ? 'O' : (mover.OilPump.is_enabled ? 'o' : '.')), - (false == mover.ConverterAllowLocal ? '-' : (mover.ConverterAllow ? (mover.ConverterFlag ? 'X' : 'x') : '.')), (mover.ConvOvldFlag ? '!' : '.'), - (mover.CompressorFlag ? 'C' : (false == mover.CompressorAllowLocal ? '-' : ((mover.CompressorAllow || mover.CompressorStart == start_t::automatic) ? 'c' : '.'))), - (mover.CompressorGovernorLock ? '!' : '.'), "", std::string(isdieselenginepowered ? STR(" oil pressure: ") + to_string(mover.OilPump.pressure, 2) : "").c_str(), + mover.Battery ? 'B' : '.', mover.Mains ? 'M' : '.', mover.FuseFlag ? '!' : '.', mover.Pantographs[rear].is_active ? (mover.PantRearVolt > 0.0 ? 'O' : 'o') : '.', + mover.Pantographs[front].is_active ? (mover.PantFrontVolt > 0.0 ? 'P' : 'p') : '.', mover.PantPressLockActive ? '!' : + mover.PantPressSwitchActive ? '*' : + '.', + mover.WaterPump.is_active ? 'W' : + false == mover.WaterPump.breaker ? '-' : + mover.WaterPump.is_enabled ? 'w' : + '.', + true == mover.WaterHeater.is_damaged ? '!' : + mover.WaterHeater.is_active ? 'H' : + false == mover.WaterHeater.breaker ? '-' : + mover.WaterHeater.is_enabled ? 'h' : + '.', + mover.FuelPump.is_active ? 'F' : + mover.FuelPump.is_enabled ? 'f' : + '.', mover.OilPump.is_active ? 'O' : + mover.OilPump.is_enabled ? 'o' : + '.', + false == mover.ConverterAllowLocal ? '-' : + mover.ConverterAllow ? (mover.ConverterFlag ? 'X' : 'x') : + '.', mover.ConvOvldFlag ? '!' : '.', + mover.CompressorFlag ? 'C' : + false == mover.CompressorAllowLocal ? '-' : + mover.CompressorAllow || mover.CompressorStart == start_t::automatic ? 'c' : + '.', + mover.CompressorGovernorLock ? '!' : '.', "", std::string(isdieselenginepowered ? STR(" oil pressure: ") + to_string(mover.OilPump.pressure, 2) : "").c_str(), // power transfers mover.Couplers[front].power_high.voltage, mover.Couplers[front].power_high.current, std::string(mover.Couplers[front].power_high.is_local ? "" : "-").c_str(), std::string(vehicle.DirectionGet() ? ":<<:" : ":>>:").c_str(), std::string(mover.Couplers[rear].power_high.is_local ? "" : "-").c_str(), @@ -179,7 +197,7 @@ void ui::vehicleparams_panel::render_contents() if (isdieselenginepowered) { std::snprintf(buffer.data(), buffer.size(), STR_C("\nTemperatures:\n engine: %.2f, oil: %.2f, water: %.2f%c%.2f"), mover.dizel_heat.Ts, mover.dizel_heat.To, mover.dizel_heat.temperatura1, - (mover.WaterCircuitsLink ? '-' : '|'), mover.dizel_heat.temperatura2); + mover.WaterCircuitsLink ? '-' : '|', mover.dizel_heat.temperatura2); ImGui::TextUnformatted(buffer.data()); } @@ -212,7 +230,7 @@ void ui::vehicleparams_panel::render_contents() if (mover.EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { - std::snprintf(buffer.data(), buffer.size(), STR_C(" pantograph: %.2f%cMT"), mover.PantPress, (mover.bPantKurek3 ? '-' : '|')); + std::snprintf(buffer.data(), buffer.size(), STR_C(" pantograph: %.2f%cMT"), mover.PantPress, mover.bPantKurek3 ? '-' : '|'); ImGui::TextUnformatted(buffer.data()); } @@ -225,7 +243,7 @@ void ui::vehicleparams_panel::render_contents() vehicle.ctOwner ? vehicle.ctOwner->Controlling()->CabActive : 1) + 0.001f, - mover.Fb * 0.001f, mover.Adhesive(mover.RunningTrack.friction), (mover.SlippingWheels ? " (!)" : ""), + mover.Fb * 0.001f, mover.Adhesive(mover.RunningTrack.friction), mover.SlippingWheels ? " (!)" : "", // acceleration mover.AccSVBased, mover.AccN + 0.001f, std::string(std::abs(mover.RunningShape.R) > 10000.0 ? "~0" : to_string(mover.RunningShape.R, 0)).c_str(), // velocity