16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 21:49:19 +02:00

reformat: remove redundant parentheses

This commit is contained in:
jerrrrycho
2026-07-04 05:39:03 +02:00
parent cf9fb07800
commit 31f9ca0afc
9 changed files with 57 additions and 39 deletions

View File

@@ -193,7 +193,7 @@ std::tuple<double, double, command_queue::commands_map> 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));

View File

@@ -256,7 +256,7 @@ template <typename T> bool is_equal(T const &Left, T const &Right, T const Epsil
template <typename Type_>
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 );
}

View File

@@ -32,7 +32,7 @@ vr_openvr::vr_openvr()
std::unique_ptr<TModel3d> 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);
}

View File

@@ -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()

View File

@@ -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));
}

View File

@@ -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));
}
};

View File

@@ -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)

View File

@@ -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 << "<div><b>Miejsce: </b>" << (std::string(place.c_str())) << "</div><br />" << std::endl;
temp << "<div><b>Data: </b>" << (date) << "</div><br />" << std::endl;
temp << "<div><b>Czas: </b>" << (from) << " - " << (to) << "</div><br />" << std::endl;
temp << "<div><b>Imię (imiona) i nazwisko szkolonego: </b>" << (trainee_name) << "</div><br />" << std::endl;
temp << "<div><b>Data urodzenia: </b>" << (trainee_birthdate) << "</div><br />" << std::endl;
temp << "<div><b>Firma: </b>" << (trainee_company) << "</div><br />" << std::endl;
temp << "<div><b>Imię i nazwisko instruktora: </b>" << (instructor_name) << "</div><br />" << std::endl;
temp << "<div><b>Odcinek trasy: </b>" << (track_segment) << "</div><br />" << std::endl;
temp << "<div><b>Miejsce: </b>" << std::string(place.c_str()) << "</div><br />" << std::endl;
temp << "<div><b>Data: </b>" << date << "</div><br />" << std::endl;
temp << "<div><b>Czas: </b>" << from << " - " << to << "</div><br />" << std::endl;
temp << "<div><b>Imię (imiona) i nazwisko szkolonego: </b>" << trainee_name << "</div><br />" << std::endl;
temp << "<div><b>Data urodzenia: </b>" << trainee_birthdate << "</div><br />" << std::endl;
temp << "<div><b>Firma: </b>" << trainee_company << "</div><br />" << std::endl;
temp << "<div><b>Imię i nazwisko instruktora: </b>" << instructor_name << "</div><br />" << std::endl;
temp << "<div><b>Odcinek trasy: </b>" << track_segment << "</div><br />" << std::endl;
if (distance > 0.0f)
temp << "<div><b>Przebyta odległość: </b>" << std::round(distance) << " km</div><br />" << std::endl;
temp << "<div><b>Uwagi: </b><br />" << (remarks) << "</div>" << std::endl;
temp << "<div><b>Uwagi: </b><br />" << remarks << "</div>" << 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());

View File

@@ -142,19 +142,37 @@ void ui::vehicleparams_panel::render_contents()
std::vector<text_line> lines;
std::array<char, 1024> 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