mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 21:29:19 +02:00
refactor(sonar): merge collapsible nested if statements (cpp:S1066)
Comments that preceded the inner if are kept above the merged statement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -63,14 +63,12 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
|
||||
if( Global.iMultiplayer ) {
|
||||
auto *event = simulation::Events.FindEvent( std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) );
|
||||
if( event != nullptr ) {
|
||||
if( typeid(*event) == typeid(multi_event)
|
||||
if (event != nullptr && (typeid(*event) == typeid(multi_event)
|
||||
|| typeid(*event) == typeid(lights_event)
|
||||
|| event->m_sibling != nullptr ) {
|
||||
// tylko jawne albo niejawne Multiple
|
||||
|| event->m_sibling != nullptr)) {
|
||||
// tylko jawne albo niejawne Multiple
|
||||
command_relay relay;
|
||||
relay.post(user_command::queueevent, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &event->name());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -111,17 +109,17 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
case 5: // ustawienie parametrów
|
||||
{
|
||||
CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " params " + std::to_string(*pRozkaz->iPar) + " rcvd");
|
||||
if (*pRozkaz->iPar == 0) // sprawdzenie czasu
|
||||
if (*pRozkaz->iPar & 1) // ustawienie czasu
|
||||
{
|
||||
auto t = pRozkaz->fPar[1];
|
||||
simulation::Time.data().wDay = static_cast<uint16_t>(std::floor(t)); // niby nie powinno być dnia, ale...
|
||||
if (Global.fMoveLight >= 0)
|
||||
Global.fMoveLight = t; // trzeba by deklinację Słońca przeliczyć
|
||||
simulation::Time.data().wHour = static_cast<uint16_t>(std::floor(24 * t) - 24.0 * simulation::Time.data().wDay);
|
||||
simulation::Time.data().wMinute = static_cast<uint16_t>(std::floor(60 * 24 * t) - 60.0 * (24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour));
|
||||
simulation::Time.data().wSecond = static_cast<uint16_t>(std::floor( 60 * 60 * 24 * t ) - 60.0 * ( 60.0 * ( 24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour ) + simulation::Time.data().wMinute ));
|
||||
}
|
||||
// sprawdzenie czasu
|
||||
if (*pRozkaz->iPar == 0 && *pRozkaz->iPar & 1) // ustawienie czasu
|
||||
{
|
||||
auto t = pRozkaz->fPar[1];
|
||||
simulation::Time.data().wDay = static_cast<uint16_t>(std::floor(t)); // niby nie powinno być dnia, ale...
|
||||
if (Global.fMoveLight >= 0)
|
||||
Global.fMoveLight = t; // trzeba by deklinację Słońca przeliczyć
|
||||
simulation::Time.data().wHour = static_cast<uint16_t>(std::floor(24 * t) - 24.0 * simulation::Time.data().wDay);
|
||||
simulation::Time.data().wMinute = static_cast<uint16_t>(std::floor(60 * 24 * t) - 60.0 * (24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour));
|
||||
simulation::Time.data().wSecond = static_cast<uint16_t>(std::floor( 60 * 60 * 24 * t ) - 60.0 * ( 60.0 * ( 24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour ) + simulation::Time.data().wMinute ));
|
||||
}
|
||||
if (*pRozkaz->iPar & 2)
|
||||
{ // ustawienie flag zapauzowania
|
||||
Global.iPause = static_cast<int>(pRozkaz->fPar[2]); // zakładamy, że wysyłający wie, co robi
|
||||
|
||||
Reference in New Issue
Block a user