From b4b6686320a7779f14a838d0479cfef8491ac644 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Sat, 4 Jul 2026 05:50:57 +0200 Subject: [PATCH] reformat: remove redundant 'else' keyword --- McZapkie/Mover.cpp | 33 +++---- McZapkie/Oerlikon_ESt.cpp | 25 +++--- McZapkie/hamulce.cpp | 93 ++++++++++++------- imgui/imgui.cpp | 43 +++++++-- imgui/imgui.h | 16 +++- imgui/imstb_truetype.h | 171 ++++++++++++++++++++--------------- stb/stb_image.h | 8 +- utilities/comparison.h | 48 ++++++++-- vehicle/Driver.cpp | 12 ++- world/Event.cpp | 34 ++++--- world/Track.cpp | 185 +++++++++++++++++++------------------- world/Traction.cpp | 31 ++++--- world/TrkFoll.cpp | 92 +++++++++---------- world/mtable.cpp | 22 +++-- 14 files changed, 482 insertions(+), 331 deletions(-) diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 145f8e34..f15d8e3a 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -1133,6 +1133,7 @@ double TMoverParameters::PipeRatio(void) double pr; if (DeltaPipePress > 0) + { if (false) // SPKS!! no to jak nie wchodzimy to po co branch? { if (3.0 * PipePress > HighPipePress + LowPipePress + LowPipePress) @@ -1145,8 +1146,8 @@ double TMoverParameters::PipeRatio(void) // if (Compressor > 0.5) // then pr : = pr * 1.333; // dziwny rapid wywalamy } - else - pr = (HighPipePress - std::max(LowPipePress, std::min(HighPipePress, PipePress))) / DeltaPipePress; + pr = (HighPipePress - std::max(LowPipePress, std::min(HighPipePress, PipePress))) / DeltaPipePress; + } else pr = 0; return pr; @@ -9830,22 +9831,24 @@ bool TMoverParameters::LoadFIZ(std::string chkpath) continue; } - else if (issection("BuffCoupl1.", inputline)) + else { + if (issection("BuffCoupl1.", inputline)) + { - startBPT = false; - fizlines.emplace("BuffCoupl1", inputline); - LoadFIZ_BuffCoupl(inputline, 1); - continue; - } + startBPT = false; + fizlines.emplace("BuffCoupl1", inputline); + LoadFIZ_BuffCoupl(inputline, 1); + continue; + } + if (issection("BuffCoupl2.", inputline)) + { - else if (issection("BuffCoupl2.", inputline)) - { - - startBPT = false; - fizlines.emplace("BuffCoupl2", inputline); - LoadFIZ_BuffCoupl(inputline, 2); - continue; + startBPT = false; + fizlines.emplace("BuffCoupl2", inputline); + LoadFIZ_BuffCoupl(inputline, 2); + continue; + } } if (issection("TurboPos:", inputline)) diff --git a/McZapkie/Oerlikon_ESt.cpp b/McZapkie/Oerlikon_ESt.cpp index 768bd729..f0d89f46 100644 --- a/McZapkie/Oerlikon_ESt.cpp +++ b/McZapkie/Oerlikon_ESt.cpp @@ -394,10 +394,12 @@ double TNESt3::CVs(double const BP) // napelniacz sterujacego // przeplyw ZS <-> PG if (MPP < CVP - 0.17) return 0.0; - else if (MPP > CVP - 0.08) - return Nozzles[dSd]; else - return Nozzles[dSm]; + { + if (MPP > CVP - 0.08) + return Nozzles[dSd]; + return Nozzles[dSm]; + } } double TNESt3::BVs(double const BCP) // napelniacz pomocniczego @@ -408,14 +410,17 @@ double TNESt3::BVs(double const BCP) // napelniacz pomocniczego // przeplyw ZP <-> rozdzielacz if (MPP < CVP - 0.3) return Nozzles[dP]; - else if( BCP < 0.5 ) { - if( true == Zamykajacy ) - return Nozzles[ dPm ]; // 1.25 - else - return Nozzles[ dPd ]; - } else - return 0.0; + { + if (BCP < 0.5) + { + if (true == Zamykajacy) + return Nozzles[dPm]; // 1.25 + else + return Nozzles[dPd]; + } + return 0.0; + } } void TNESt3::PLC(double const mass) diff --git a/McZapkie/hamulce.cpp b/McZapkie/hamulce.cpp index c06aa7ba..81d4a1ad 100644 --- a/McZapkie/hamulce.cpp +++ b/McZapkie/hamulce.cpp @@ -63,10 +63,12 @@ double PF_old(double P1, double P2, double S) const double PL = P1 + P2 - PH + 2; if (PH - PL < 0.0001) return 0; - else if (PH - PL < 0.05) - return 20 * (PH - PL) * (PH + 1) * 222 * S * (P2 - P1) / (1.13 * PH - PL); else + { + if (PH - PL < 0.05) + return 20 * (PH - PL) * (PH + 1) * 222 * S * (P2 - P1) / (1.13 * PH - PL); return (PH + 1) * 222 * S * (P2 - P1) / (1.13 * PH - PL); + } } /// @@ -86,11 +88,12 @@ double PF(double const P1, double const P2, double const S, double const DP) double const sg = PL / PH; // bezwymiarowy stosunek cisnien double const FM = PH * 197.0 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem if (sg > 0.5) // jesli ponizej stosunku krytycznego + { if (PH - PL < DP) // niewielka roznica cisnien return (1.0 - sg) / DPL * FM * 2.0 * std::sqrt(DP * (PH - DP)); // return 1/DPL*(PH-PL)*fm*2*SQRT((sg)*(1-sg)); - else - return FM * 2.0 * std::sqrt(sg * (1.0 - sg)); + return FM * 2.0 * std::sqrt(sg * (1.0 - sg)); + } else // powyzej stosunku krytycznego return FM; } @@ -112,10 +115,11 @@ double PF1(double const P1, double const P2, double const S) double const sg = PL / PH; // bezwymiarowy stosunek cisnien double const FM = PH * 197.0 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem if (sg > 0.5) // jesli ponizej stosunku krytycznego + { if (sg < DPS) // niewielka roznica cisnien return (1.0 - sg) / DPS * FM * 2.0 * std::sqrt(DPS * (1.0 - DPS)); - else - return FM * 2.0 * std::sqrt(sg * (1.0 - sg)); + return FM * 2.0 * std::sqrt(sg * (1.0 - sg)); + } else // powyzej stosunku krytycznego return FM; } @@ -144,10 +148,12 @@ double PFVa(double PH, double PL, double const S, double LIM, double const DP) if (LIM - PL < DP) FM = FM * (LIM - PL) / DP; // jesli jestesmy przy nastawieniu, to zawor sie przymyka if (sg > 0.5) // jesli ponizej stosunku krytycznego + { if (PH - PL < DPL) // niewielka roznica cisnien return (PH - PL) / DPL * FM * 2 * std::sqrt(sg * (1 - sg)); // BUG: (1-sg) can be < 0, leading to sqrt(-x) - else - return FM * 2 * std::sqrt(sg * (1 - sg)); // BUG: (1-sg) can be < 0, leading to sqrt(-x) + return FM * 2 * std::sqrt(sg * (1 - sg)); + } + // BUG: (1-sg) can be < 0, leading to sqrt(-x) else // powyzej stosunku krytycznego return FM; } @@ -178,10 +184,11 @@ double PFVd(double PH, double PL, double const S, double LIM, double const DP) if (PH - LIM < 0.1) FM = FM * (PH - LIM) / DP; // jesli jestesmy przy nastawieniu, to zawor sie przymyka if (sg > 0.5) // jesli ponizej stosunku krytycznego + { if (PH - PL < DPL) // niewielka roznica cisnien return (PH - PL) / DPL * FM * 2.0 * std::sqrt(sg * (1.0 - sg)); - else - return FM * 2.0 * std::sqrt(sg * (1.0 - sg)); + return FM * 2.0 * std::sqrt(sg * (1.0 - sg)); + } else // powyzej stosunku krytycznego return FM; } @@ -307,10 +314,13 @@ double TBrakeCyl::P() // P:=VtoC; if (VtoC < VS) return VtoC * pS / VS; // objetosc szkodliwa - else if (VtoC > VD) - return VtoC - cD; // caly silownik; else - return pS + (VtoC - VS) / (VD - VS) * (pD - pS); // wysuwanie tloka + { + if (VtoC > VD) + return VtoC - cD; // caly silownik; + return pS + (VtoC - VS) / (VD - VS) * (pD - pS); + } + // wysuwanie tloka } //*) //---HAMULEC--- @@ -940,15 +950,19 @@ double TESt::CVs(double const BP) // przeplyw ZS <-> PG if (VVP < CVP - 0.12 || BVP < CVP - 0.3 || BP > 0.4) return 0; - else if (VVP > CVP + 0.4) - if (BVP > CVP + 0.2) - return 0.23; - else - return 0.05; - else if (BVP > CVP - 0.1) - return 1; else - return 0.3; + { + if (VVP > CVP + 0.4) + { + if (BVP > CVP + 0.2) + return 0.23; + return 0.05; + } + if (BVP > CVP - 0.1) + return 1; + else + return 0.3; + } } /// @@ -971,13 +985,16 @@ double TESt::BVs(double const BCP) // przeplyw ZP <-> rozdzielacz if (BVP < CVP - 0.3) return 0.6; - else if (BCP < 0.5) - if (VVP > CVP + 0.4) - return 0.1; - else - return 0.3; else + { + if (BCP < 0.5) + { + if (VVP > CVP + 0.4) + return 0.1; + return 0.3; + } return 0; + } } /// @@ -2217,10 +2234,12 @@ double TCV1::BVs(double const BCP) // przeplyw ZP <-> rozdzielacz if (BVP < CVP - 0.1) return 1; - else if (BCP > 0.05) - return 0; else + { + if (BCP > 0.05) + return 0; return 0.2 * (1.5 - int(BVP > VVP)); + } } /// @@ -2591,10 +2610,12 @@ double TKE::CVs(double const BP) // przeplyw ZS <-> PG if (BP > 0.2) return 0; - else if (VVP > CVP + 0.4) - return 0.05; else + { + if (VVP > CVP + 0.4) + return 0.05; return 0.23; + } } /// @@ -2617,10 +2638,12 @@ double TKE::BVs(double const BCP) // przeplyw ZP <-> rozdzielacz if (BVP > VVP) return 0; - else if (BVP < CVP - 0.3) - return 0.6; else + { + if (BVP < CVP - 0.3) + return 0.6; return 0.13; + } } /// @@ -3429,10 +3452,12 @@ double TMHZ_EN57::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji; { if (pos > 8.5) return 5.0 - 0.15 * pos - 0.35; - else if (pos > 0.5) - return 5.0 - 0.15 * pos - 0.1; else + { + if (pos > 0.5) + return 5.0 - 0.15 * pos - 0.1; return 5.0; + } } /// diff --git a/imgui/imgui.cpp b/imgui/imgui.cpp index dae7426a..0738b018 100644 --- a/imgui/imgui.cpp +++ b/imgui/imgui.cpp @@ -9819,14 +9819,41 @@ void ImGui::ShowMetricsWindow(bool* p_open) static ImRect GetWindowRect(ImGuiWindow* window, int rect_type) { if (rect_type == WRT_OuterRect) { return window->Rect(); } - else if (rect_type == WRT_OuterRectClipped) { return window->OuterRectClipped; } - else if (rect_type == WRT_InnerRect) { return window->InnerRect; } - else if (rect_type == WRT_InnerClipRect) { return window->InnerClipRect; } - else if (rect_type == WRT_WorkRect) { return window->WorkRect; } - else if (rect_type == WRT_Contents) { - const ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); } - else if (rect_type == WRT_ContentsRegionRect) { return window->ContentsRegionRect; } - IM_ASSERT(0); + else + { + if (rect_type == WRT_OuterRectClipped) + { + return window->OuterRectClipped; + } + if (rect_type == WRT_InnerRect) + { + return window->InnerRect; + } + else + { + if (rect_type == WRT_InnerClipRect) + { + return window->InnerClipRect; + } + if (rect_type == WRT_WorkRect) + { + return window->WorkRect; + } + else + { + if (rect_type == WRT_Contents) + { + const ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; + return ImRect(min, min + window->ContentSize); + } + if (rect_type == WRT_ContentsRegionRect) + { + return window->ContentsRegionRect; + } + } + } + } + IM_ASSERT(0); return ImRect(); } diff --git a/imgui/imgui.h b/imgui/imgui.h index 5b07d517..4b9e7f1b 100644 --- a/imgui/imgui.h +++ b/imgui/imgui.h @@ -1280,8 +1280,20 @@ struct ImVector inline T* erase_unsorted(const T* it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; if (it < Data+Size-1) memcpy(Data + off, Data + Size - 1, sizeof(T)); Size--; return Data + off; } inline T* insert(const T* it, const T& v) { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(T)); memcpy(&Data[off], &v, sizeof(v)); Size++; return Data + off; } inline bool contains(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; } - inline T* find(const T& v) { T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; } - inline const T* find(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; } + inline T* find(const T& v) { T* data = Data; const T* data_end = Data + Size; while (data < data_end) + { + if (*data == v) + break; + ++data; + } + return data; } + inline const T* find(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) + { + if (*data == v) + break; + ++data; + } + return data; } inline bool find_erase(const T& v) { const T* it = find(v); if (it < Data + Size) { erase(it); return true; } return false; } inline bool find_erase_unsorted(const T& v) { const T* it = find(v); if (it < Data + Size) { erase_unsorted(it); return true; } return false; } inline int index_from_ptr(const T* it) const { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; return (int)off; } diff --git a/imgui/imstb_truetype.h b/imgui/imstb_truetype.h index 0ce05714..69038b17 100644 --- a/imgui/imstb_truetype.h +++ b/imgui/imstb_truetype.h @@ -1188,10 +1188,20 @@ static stbtt_uint32 stbtt__cff_int(stbtt__buf *b) { const int b0 = stbtt__buf_get8(b); if (b0 >= 32 && b0 <= 246) return b0 - 139; - else if (b0 >= 247 && b0 <= 250) return (b0 - 247)*256 + stbtt__buf_get8(b) + 108; - else if (b0 >= 251 && b0 <= 254) return -(b0 - 251)*256 - stbtt__buf_get8(b) - 108; - else if (b0 == 28) return stbtt__buf_get16(b); - else if (b0 == 29) return stbtt__buf_get32(b); + else + { + if (b0 >= 247 && b0 <= 250) + return (b0 - 247) * 256 + stbtt__buf_get8(b) + 108; + if (b0 >= 251 && b0 <= 254) + return -(b0 - 251) * 256 - stbtt__buf_get8(b) - 108; + else + { + if (b0 == 28) + return stbtt__buf_get16(b); + if (b0 == 29) + return stbtt__buf_get32(b); + } + } STBTT_assert(0); return 0; } @@ -1469,82 +1479,99 @@ STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codep if (unicode_codepoint < bytes-6) return ttBYTE(data + index_map + 6 + unicode_codepoint); return 0; - } else if (format == 6) { - const stbtt_uint32 first = ttUSHORT(data + index_map + 6); - const stbtt_uint32 count = ttUSHORT(data + index_map + 8); - if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count) - return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2); - return 0; - } else if (format == 2) { - STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean - return 0; - } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges - const stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1; - stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1; - stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10); - const stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1; + } else + { + if (format == 6) + { + const stbtt_uint32 first = ttUSHORT(data + index_map + 6); + const stbtt_uint32 count = ttUSHORT(data + index_map + 8); + if ((stbtt_uint32)unicode_codepoint >= first && (stbtt_uint32)unicode_codepoint < first + count) + return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first) * 2); + return 0; + } + if (format == 2) + { + STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean + return 0; + } + else + { + if (format == 4) + { // standard mapping for windows fonts: binary search collection of ranges + const stbtt_uint16 segcount = ttUSHORT(data + index_map + 6) >> 1; + stbtt_uint16 searchRange = ttUSHORT(data + index_map + 8) >> 1; + stbtt_uint16 entrySelector = ttUSHORT(data + index_map + 10); + const stbtt_uint16 rangeShift = ttUSHORT(data + index_map + 12) >> 1; - // do a binary search of the segments - const stbtt_uint32 endCount = index_map + 14; - stbtt_uint32 search = endCount; + // do a binary search of the segments + const stbtt_uint32 endCount = index_map + 14; + stbtt_uint32 search = endCount; - if (unicode_codepoint > 0xffff) - return 0; + if (unicode_codepoint > 0xffff) + return 0; - // they lie from endCount .. endCount + segCount - // but searchRange is the nearest power of two, so... - if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2)) - search += rangeShift*2; + // they lie from endCount .. endCount + segCount + // but searchRange is the nearest power of two, so... + if (unicode_codepoint >= ttUSHORT(data + search + rangeShift * 2)) + search += rangeShift * 2; - // now decrement to bias correctly to find smallest - search -= 2; - while (entrySelector) { - stbtt_uint16 end; - searchRange >>= 1; - end = ttUSHORT(data + search + searchRange*2); - if (unicode_codepoint > end) - search += searchRange*2; - --entrySelector; - } - search += 2; + // now decrement to bias correctly to find smallest + search -= 2; + while (entrySelector) + { + stbtt_uint16 end; + searchRange >>= 1; + end = ttUSHORT(data + search + searchRange * 2); + if (unicode_codepoint > end) + search += searchRange * 2; + --entrySelector; + } + search += 2; - { - stbtt_uint16 offset, start; - const stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1); + { + stbtt_uint16 offset, start; + const stbtt_uint16 item = (stbtt_uint16)((search - endCount) >> 1); - STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2*item)); - start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item); - if (unicode_codepoint < start) - return 0; + STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2 * item)); + start = ttUSHORT(data + index_map + 14 + segcount * 2 + 2 + 2 * item); + if (unicode_codepoint < start) + return 0; - offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item); - if (offset == 0) - return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item)); + offset = ttUSHORT(data + index_map + 14 + segcount * 6 + 2 + 2 * item); + if (offset == 0) + return (stbtt_uint16)(unicode_codepoint + ttSHORT(data + index_map + 14 + segcount * 4 + 2 + 2 * item)); - return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item); - } - } else if (format == 12 || format == 13) { - const stbtt_uint32 ngroups = ttULONG(data+index_map+12); - stbtt_int32 low,high; - low = 0; high = (stbtt_int32)ngroups; - // Binary search the right group. - while (low < high) { - const stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high - const stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12); - const stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4); - if ((stbtt_uint32) unicode_codepoint < start_char) - high = mid; - else if ((stbtt_uint32) unicode_codepoint > end_char) - low = mid+1; - else { - const stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8); - if (format == 12) - return start_glyph + unicode_codepoint-start_char; - else // format == 13 - return start_glyph; - } - } - return 0; // not found + return ttUSHORT(data + offset + (unicode_codepoint - start) * 2 + index_map + 14 + segcount * 6 + 2 + 2 * item); + } + } + if (format == 12 || format == 13) + { + const stbtt_uint32 ngroups = ttULONG(data + index_map + 12); + stbtt_int32 low, high; + low = 0; + high = (stbtt_int32)ngroups; + // Binary search the right group. + while (low < high) + { + const stbtt_int32 mid = low + ((high - low) >> 1); // rounds down, so low <= mid < high + const stbtt_uint32 start_char = ttULONG(data + index_map + 16 + mid * 12); + const stbtt_uint32 end_char = ttULONG(data + index_map + 16 + mid * 12 + 4); + if ((stbtt_uint32)unicode_codepoint < start_char) + high = mid; + else if ((stbtt_uint32)unicode_codepoint > end_char) + low = mid + 1; + else + { + const stbtt_uint32 start_glyph = ttULONG(data + index_map + 16 + mid * 12 + 8); + if (format == 12) + return start_glyph + unicode_codepoint - start_char; + else // format == 13 + return start_glyph; + } + } + return 0; // not found + } + } } // @TODO STBTT_assert(0); diff --git a/stb/stb_image.h b/stb/stb_image.h index ce6c72f0..0e99b01c 100644 --- a/stb/stb_image.h +++ b/stb/stb_image.h @@ -7612,10 +7612,12 @@ static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) maxv = stbi__pnm_getinteger(s, &c); // read max value if (maxv > 65535) return stbi__err("max value > 65535", "PPM image supports only 8-bit and 16-bit images"); - else if (maxv > 255) - return 16; else - return 8; + { + if (maxv > 255) + return 16; + return 8; + } } static int stbi__pnm_is16(stbi__context *s) diff --git a/utilities/comparison.h b/utilities/comparison.h index 84f797a5..03d092d7 100644 --- a/utilities/comparison.h +++ b/utilities/comparison.h @@ -55,23 +55,53 @@ inline comparison_pass comparison_pass_from_string( std::string const Input ) { if( Input == "all" ) { return comparison_pass::all; } - else if( Input == "any" ) { return comparison_pass::any; } - else if( Input == "none" ) { return comparison_pass::none; } + else + { + if (Input == "any") + { + return comparison_pass::any; + } + if (Input == "none") + { + return comparison_pass::none; + } + } - return comparison_pass::all; // legacy default + return comparison_pass::all; // legacy default } inline comparison_operator comparison_operator_from_string( std::string const Input ) { if( Input == "==" ) { return comparison_operator::equal; } - else if( Input == "!=" ) { return comparison_operator::not_equal; } - else if( Input == "<" ) { return comparison_operator::lt; } - else if( Input == ">" ) { return comparison_operator::gt; } - else if( Input == "<=" ) { return comparison_operator::lt_eq; } - else if( Input == ">=" ) { return comparison_operator::gt_eq; } + else + { + if (Input == "!=") + { + return comparison_operator::not_equal; + } + if (Input == "<") + { + return comparison_operator::lt; + } + else + { + if (Input == ">") + { + return comparison_operator::gt; + } + if (Input == "<=") + { + return comparison_operator::lt_eq; + } + else if (Input == ">=") + { + return comparison_operator::gt_eq; + } + } + } - return comparison_operator::equal; // legacy default + return comparison_operator::equal; // legacy default } //--------------------------------------------------------------------------- diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index c10aaae4..976b1758 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -348,14 +348,12 @@ std::string TSpeedPos::GetName() const { if( iFlags & spTrack ) // jeśli tor return trTrack->name(); - else if( iFlags & spEvent ) // jeśli event - return - evEvent->m_name - + " [" + std::to_string( static_cast( evEvent->input_value( 1 ) ) ) - + ", " + std::to_string( static_cast( evEvent->input_value( 2 ) ) ) - + "]"; else - return ""; + { + if (iFlags & spEvent) // jeśli event + return evEvent->m_name + " [" + std::to_string(static_cast(evEvent->input_value(1))) + ", " + std::to_string(static_cast(evEvent->input_value(2))) + "]"; + return ""; + } } std::string TSpeedPos::TableText() const diff --git a/world/Event.cpp b/world/Event.cpp index ac578b01..b2604444 100644 --- a/world/Event.cpp +++ b/world/Event.cpp @@ -2302,21 +2302,27 @@ event_manager::insert( basic_event *Event ) { return false; } // tymczasowo wyjątki: - else if( Event->m_name.ends_with("lineinfo:") ) { - // tymczasowa utylizacja duplikatów W5 - return false; - } - else if( Event->m_name.ends_with("_warning") ) { - // tymczasowa utylizacja duplikatu z trąbieniem - return false; - } - else if( Event->m_name.ends_with("_shp") ) { - // nie podlegają logowaniu - // tymczasowa utylizacja duplikatu SHP - return false; - } + else + { + if (Event->m_name.ends_with("lineinfo:")) + { + // tymczasowa utylizacja duplikatów W5 + return false; + } + if (Event->m_name.ends_with("_warning")) + { + // tymczasowa utylizacja duplikatu z trąbieniem + return false; + } + else if (Event->m_name.ends_with("_shp")) + { + // nie podlegają logowaniu + // tymczasowa utylizacja duplikatu SHP + return false; + } + } - auto *duplicate = m_events[ lookup->second ]; + auto *duplicate = m_events[ lookup->second ]; if( Global.bJoinEvents ) { // doczepka (taki wirtualny multiple bez warunków) duplicate->append( Event ); diff --git a/world/Track.cpp b/world/Track.cpp index f915084c..a6bb4487 100644 --- a/world/Track.cpp +++ b/world/Track.cpp @@ -1787,97 +1787,100 @@ bool TTrack::SetConnections(int i) bool TTrack::Switch(int i, float const t, float const d) { // przełączenie torów z uruchomieniem animacji if (SwitchExtension) // tory przełączalne mają doklejkę - if (eType == tt_Switch) - { // przekładanie zwrotnicy jak zwykle - if (t > 0.f) // prędkość liniowa ruchu iglic - SwitchExtension->fOffsetSpeed = t; // prędkość łatwiej zgrać z animacją modelu - if (d >= 0.f) // dodatkowy ruch drugiej iglicy (zamknięcie nastawnicze) - SwitchExtension->fOffsetDelay = d; - i &= 1; // ograniczenie błędów !!!! - SwitchExtension->fDesiredOffset = - i ? fMaxOffset + SwitchExtension->fOffsetDelay : -SwitchExtension->fOffsetDelay; - SwitchExtension->CurrentIndex = i; - Segment = SwitchExtension->Segments[i]; // wybranie aktywnej drogi - potrzebne to? - trNext = SwitchExtension->pNexts[i]; // przełączenie końców - trPrev = SwitchExtension->pPrevs[i]; - iNextDirection = SwitchExtension->iNextDirection[i]; - iPrevDirection = SwitchExtension->iPrevDirection[i]; - fRadius = fRadiusTable[i]; // McZapkie: wybor promienia toru - if( SwitchExtension->fVelocity <= -2 ) { - //-1 oznacza maksymalną prędkość, a dalsze ujemne to ograniczenie na bok - fVelocity = i ? -SwitchExtension->fVelocity : -1; - } - else { - fVelocity = SwitchExtension->fVelocity; - } - if (SwitchExtension->pOwner ? SwitchExtension->pOwner->RaTrackAnimAdd(this) : - true) // jeśli nie dodane do animacji - { // nie ma się co bawić - SwitchExtension->fOffset = SwitchExtension->fDesiredOffset; - // przeliczenie położenia iglic; czy zadziała na niewyświetlanym sektorze w VBO? - RaAnimate(); - } - return true; - } - else if (eType == tt_Table) - { // blokowanie (0, szukanie torów) lub odblokowanie (1, rozłączenie) obrotnicy - if (i) // NOTE: this condition seems opposite to intention/comment? TODO: investigate this - { // 0: rozłączenie sąsiednich torów od obrotnicy - if (trPrev) // jeśli jest tor od Point1 obrotnicy - if (iPrevDirection) // 0:dołączony Point1, 1:dołączony Point2 - trPrev->trNext = nullptr; // rozłączamy od Point2 - else - trPrev->trPrev = nullptr; // rozłączamy od Point1 - if (trNext) // jeśli jest tor od Point2 obrotnicy - if (iNextDirection) // 0:dołączony Point1, 1:dołączony Point2 - trNext->trNext = nullptr; // rozłączamy od Point2 - else - trNext->trPrev = nullptr; // rozłączamy od Point1 - trNext = trPrev = nullptr; // na końcu rozłączamy obrotnicę (wkaźniki do sąsiadów już niepotrzebne) - fVelocity = 0.0; // AI, nie ruszaj się! - if (SwitchExtension->pOwner) - SwitchExtension->pOwner->RaTrackAnimAdd(this); // dodanie do listy animacyjnej - // TODO: unregister path ends in the owner cell - } - else - { // 1: ustalenie finalnego położenia (gdy nie było animacji) - RaAnimate(); // ostatni etap animowania - // zablokowanie pozycji i połączenie do sąsiednich torów - // TODO: register new position of the path endpoints with the region - simulation::Region->TrackJoin( this ); - if (trNext || trPrev) - { - fVelocity = 6.0; // jazda dozwolona - if( trPrev - && trPrev->fVelocity == 0.0 ) { - // ustawienie 0 da możliwość zatrzymania AI na obrotnicy - trPrev->VelocitySet( 6.0 ); // odblokowanie dołączonego toru do jazdy - } - if( trNext - && trNext->fVelocity == 0.0 ) { - trNext->VelocitySet( 6.0 ); - } - if( SwitchExtension->evPlus ) { // w starych sceneriach może nie być - // potwierdzenie wykonania (np. odpala WZ) - simulation::Events.AddToQuery( SwitchExtension->evPlus, nullptr ); - } - } - } - SwitchExtension->CurrentIndex = i; // zapamiętanie stanu zablokowania - return true; - } - else if (eType == tt_Cross) - { // to jest przydatne tylko do łączenia odcinków - i &= 1; - SwitchExtension->CurrentIndex = i; - Segment = SwitchExtension->Segments[i]; // wybranie aktywnej drogi - potrzebne to? - trNext = SwitchExtension->pNexts[i]; // przełączenie końców - trPrev = SwitchExtension->pPrevs[i]; - iNextDirection = SwitchExtension->iNextDirection[i]; - iPrevDirection = SwitchExtension->iPrevDirection[i]; - return true; - } - if (iCategoryFlag == 1) + { + if (eType == tt_Switch) + { // przekładanie zwrotnicy jak zwykle + if (t > 0.f) // prędkość liniowa ruchu iglic + SwitchExtension->fOffsetSpeed = t; // prędkość łatwiej zgrać z animacją modelu + if (d >= 0.f) // dodatkowy ruch drugiej iglicy (zamknięcie nastawnicze) + SwitchExtension->fOffsetDelay = d; + i &= 1; // ograniczenie błędów !!!! + SwitchExtension->fDesiredOffset = i ? fMaxOffset + SwitchExtension->fOffsetDelay : -SwitchExtension->fOffsetDelay; + SwitchExtension->CurrentIndex = i; + Segment = SwitchExtension->Segments[i]; // wybranie aktywnej drogi - potrzebne to? + trNext = SwitchExtension->pNexts[i]; // przełączenie końców + trPrev = SwitchExtension->pPrevs[i]; + iNextDirection = SwitchExtension->iNextDirection[i]; + iPrevDirection = SwitchExtension->iPrevDirection[i]; + fRadius = fRadiusTable[i]; // McZapkie: wybor promienia toru + if (SwitchExtension->fVelocity <= -2) + { + //-1 oznacza maksymalną prędkość, a dalsze ujemne to ograniczenie na bok + fVelocity = i ? -SwitchExtension->fVelocity : -1; + } + else + { + fVelocity = SwitchExtension->fVelocity; + } + if (SwitchExtension->pOwner ? SwitchExtension->pOwner->RaTrackAnimAdd(this) : true) // jeśli nie dodane do animacji + { // nie ma się co bawić + SwitchExtension->fOffset = SwitchExtension->fDesiredOffset; + // przeliczenie położenia iglic; czy zadziała na niewyświetlanym sektorze w VBO? + RaAnimate(); + } + return true; + } + if (eType == tt_Table) + { // blokowanie (0, szukanie torów) lub odblokowanie (1, rozłączenie) obrotnicy + if (i) // NOTE: this condition seems opposite to intention/comment? TODO: investigate this + { // 0: rozłączenie sąsiednich torów od obrotnicy + if (trPrev) // jeśli jest tor od Point1 obrotnicy + if (iPrevDirection) // 0:dołączony Point1, 1:dołączony Point2 + trPrev->trNext = nullptr; // rozłączamy od Point2 + else + trPrev->trPrev = nullptr; // rozłączamy od Point1 + if (trNext) // jeśli jest tor od Point2 obrotnicy + if (iNextDirection) // 0:dołączony Point1, 1:dołączony Point2 + trNext->trNext = nullptr; // rozłączamy od Point2 + else + trNext->trPrev = nullptr; // rozłączamy od Point1 + trNext = trPrev = nullptr; // na końcu rozłączamy obrotnicę (wkaźniki do sąsiadów już niepotrzebne) + fVelocity = 0.0; // AI, nie ruszaj się! + if (SwitchExtension->pOwner) + SwitchExtension->pOwner->RaTrackAnimAdd(this); // dodanie do listy animacyjnej + // TODO: unregister path ends in the owner cell + } + else + { // 1: ustalenie finalnego położenia (gdy nie było animacji) + RaAnimate(); // ostatni etap animowania + // zablokowanie pozycji i połączenie do sąsiednich torów + // TODO: register new position of the path endpoints with the region + simulation::Region->TrackJoin(this); + if (trNext || trPrev) + { + fVelocity = 6.0; // jazda dozwolona + if (trPrev && trPrev->fVelocity == 0.0) + { + // ustawienie 0 da możliwość zatrzymania AI na obrotnicy + trPrev->VelocitySet(6.0); // odblokowanie dołączonego toru do jazdy + } + if (trNext && trNext->fVelocity == 0.0) + { + trNext->VelocitySet(6.0); + } + if (SwitchExtension->evPlus) + { // w starych sceneriach może nie być + // potwierdzenie wykonania (np. odpala WZ) + simulation::Events.AddToQuery(SwitchExtension->evPlus, nullptr); + } + } + } + SwitchExtension->CurrentIndex = i; // zapamiętanie stanu zablokowania + return true; + } + else if (eType == tt_Cross) + { // to jest przydatne tylko do łączenia odcinków + i &= 1; + SwitchExtension->CurrentIndex = i; + Segment = SwitchExtension->Segments[i]; // wybranie aktywnej drogi - potrzebne to? + trNext = SwitchExtension->pNexts[i]; // przełączenie końców + trPrev = SwitchExtension->pPrevs[i]; + iNextDirection = SwitchExtension->iNextDirection[i]; + iPrevDirection = SwitchExtension->iPrevDirection[i]; + return true; + } + } + if (iCategoryFlag == 1) iDamageFlag = (iDamageFlag & 127) + 128 * (i & 1); // przełączanie wykolejenia else Error("Cannot switch normal track"); diff --git a/world/Traction.cpp b/world/Traction.cpp index f5ca973b..575ab172 100644 --- a/world/Traction.cpp +++ b/world/Traction.cpp @@ -504,20 +504,27 @@ double TTraction::VoltageGet(double u, double i) i1 = psPower[1]->CurrentGet(r1g); return (i0 + i1) * res; } - else if (r0t >= 0.0) - return psPower[0]->CurrentGet(res + r0t) * res; - else if (r1t >= 0.0) - return psPower[1]->CurrentGet(res + r1t) * res; else - return 0.0; // co z tym zrobić? + { + if (r0t >= 0.0) + return psPower[0]->CurrentGet(res + r0t) * res; + if (r1t >= 0.0) + return psPower[1]->CurrentGet(res + r1t) * res; + else + return 0.0; + } + // co z tym zrobić? } - else if (psPower[0] && r0t >= 0.0) - { // jeśli odcinek podłączony jest tylko z jednej strony - return psPower[0]->CurrentGet(res + r0t) * res; - } - else if (psPower[1] && r1t >= 0.0) - return psPower[1]->CurrentGet(res + r1t) * res; - return 0.0; // gdy nie podłączony wcale? + else + { + if (psPower[0] && r0t >= 0.0) + { // jeśli odcinek podłączony jest tylko z jednej strony + return psPower[0]->CurrentGet(res + r0t) * res; + } + if (psPower[1] && r1t >= 0.0) + return psPower[1]->CurrentGet(res + r1t) * res; + } + return 0.0; // gdy nie podłączony wcale? }; glm::vec3 diff --git a/world/TrkFoll.cpp b/world/TrkFoll.cpp index e01147be..1bd8b679 100644 --- a/world/TrkFoll.cpp +++ b/world/TrkFoll.cpp @@ -215,53 +215,55 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) } continue; } - else if (s > pCurrentSegment->GetLength()) - { // jeśli przekroczenie toru od strony Point2 - bCanSkip = bPrimary && pCurrentTrack->CheckDynamicObject(Owner); - if (bCanSkip) // tylko główna oś przenosi pojazd do innego toru - Owner->MyTrack->RemoveDynamicObject(Owner); // zdejmujemy pojazd z dotychczasowego toru - fDistance = s - pCurrentSegment->GetLength(); - dir = fDirection; - if (pCurrentTrack->eType == tt_Cross) - { - if (!SetCurrentTrack(pCurrentTrack->Connected(iSegment, fDirection), 1)) - return false; // wyjście z błędem - } - else if (!SetCurrentTrack(pCurrentTrack->Connected(1, fDirection), 1)) // ustawia fDirection - return false; // wyjście z błędem - if (dir != fDirection) //(pCurrentTrack->iNextDirection) - { // gdy zmiana kierunku toru (Point2->Point2) - fDistance = -fDistance; //(s-pCurrentSegment->GetLength()); - fCurrentDistance = pCurrentSegment->GetLength(); - } - else // gdy kierunek bez zmiany (Point2->Point1) - fCurrentDistance = 0; - if (bCanSkip) - { // jak główna oś, to dodanie pojazdu do nowego toru - pCurrentTrack->AddDynamicObject(Owner); - iEventFlag = 3; // McZapkie-020602: umozliwienie uruchamiania event1,2 po zmianie toru - iEventallFlag = 3; - if (!Owner->MyTrack) - return false; - } - continue; - } else - { // gdy zostaje na tym samym torze (przesuwanie już nie zmienia toru) - if (bPrimary) - { // tylko gdy początkowe ustawienie, dodajemy eventy stania do kolejki - if (Owner->MoverParameters->CabOccupied != 0) { + { + if (s > pCurrentSegment->GetLength()) + { // jeśli przekroczenie toru od strony Point2 + bCanSkip = bPrimary && pCurrentTrack->CheckDynamicObject(Owner); + if (bCanSkip) // tylko główna oś przenosi pojazd do innego toru + Owner->MyTrack->RemoveDynamicObject(Owner); // zdejmujemy pojazd z dotychczasowego toru + fDistance = s - pCurrentSegment->GetLength(); + dir = fDirection; + if (pCurrentTrack->eType == tt_Cross) + { + if (!SetCurrentTrack(pCurrentTrack->Connected(iSegment, fDirection), 1)) + return false; // wyjście z błędem + } + else if (!SetCurrentTrack(pCurrentTrack->Connected(1, fDirection), 1)) // ustawia fDirection + return false; // wyjście z błędem + if (dir != fDirection) //(pCurrentTrack->iNextDirection) + { // gdy zmiana kierunku toru (Point2->Point2) + fDistance = -fDistance; //(s-pCurrentSegment->GetLength()); + fCurrentDistance = pCurrentSegment->GetLength(); + } + else // gdy kierunek bez zmiany (Point2->Point1) + fCurrentDistance = 0; + if (bCanSkip) + { // jak główna oś, to dodanie pojazdu do nowego toru + pCurrentTrack->AddDynamicObject(Owner); + iEventFlag = 3; // McZapkie-020602: umozliwienie uruchamiania event1,2 po zmianie toru + iEventallFlag = 3; + if (!Owner->MyTrack) + return false; + } + continue; + } + // gdy zostaje na tym samym torze (przesuwanie już nie zmienia toru) + if (bPrimary) + { // tylko gdy początkowe ustawienie, dodajemy eventy stania do kolejki + if (Owner->MoverParameters->CabOccupied != 0) + { - pCurrentTrack->QueueEvents( pCurrentTrack->m_events1, Owner, -1.0 ); - pCurrentTrack->QueueEvents( pCurrentTrack->m_events2, Owner, -1.0 ); - } - pCurrentTrack->QueueEvents( pCurrentTrack->m_events1all, Owner, -1.0 ); - pCurrentTrack->QueueEvents( pCurrentTrack->m_events2all, Owner, -1.0 ); - } - fCurrentDistance = s; - return ComputatePosition(); // przeliczenie XYZ, true o ile nie wyjechał na NULL - } - } + pCurrentTrack->QueueEvents(pCurrentTrack->m_events1, Owner, -1.0); + pCurrentTrack->QueueEvents(pCurrentTrack->m_events2, Owner, -1.0); + } + pCurrentTrack->QueueEvents(pCurrentTrack->m_events1all, Owner, -1.0); + pCurrentTrack->QueueEvents(pCurrentTrack->m_events2all, Owner, -1.0); + } + fCurrentDistance = s; + return ComputatePosition(); // przeliczenie XYZ, true o ile nie wyjechał na NULL + } + } }; bool TTrackFollower::ComputatePosition() diff --git a/world/mtable.cpp b/world/mtable.cpp index d0db6705..19b58748 100644 --- a/world/mtable.cpp +++ b/world/mtable.cpp @@ -169,15 +169,19 @@ bool TTrainParameters::IsTimeToGo(double hh, double mm) { if (StationIndex < 1) return true; // przed pierwszą jechać - else if (StationIndex < StationCount) - { // oprócz ostatniego przystanku - if (TimeTable[StationIndex].Ah < 0) // odjazd z poprzedniego - return true; // czas przyjazdu nie był podany - przelot - else - return CompareTime(hh, mm, TimeTable[StationIndex].Dh, TimeTable[StationIndex].Dm) <= 0; - } - else // gdy rozkład się skończył - return false; // dalej nie jechać + else + { + if (StationIndex < StationCount) + { // oprócz ostatniego przystanku + if (TimeTable[StationIndex].Ah < 0) // odjazd z poprzedniego + return true; // czas przyjazdu nie był podany - przelot + else + return CompareTime(hh, mm, TimeTable[StationIndex].Dh, TimeTable[StationIndex].Dm) <= 0; + } + // gdy rozkład się skończył + return false; + } + // dalej nie jechać } // returns: difference between specified time and scheduled departure from current stop, in seconds