diff --git a/Console.cpp b/Console.cpp index 13534c28..b4b49b81 100644 --- a/Console.cpp +++ b/Console.cpp @@ -60,7 +60,7 @@ TKeyTrans Console::ktTable[4 * 256]; // Ra: bajer do migania LED-ami w klawiaturze void SetLedState( unsigned char Code, bool bOn ) { #ifdef _WIN32 - if( bOn != ( ::GetKeyState( Code ) != 0 ) ) { + if( bOn != ( GetKeyState( Code ) != 0 ) ) { keybd_event( Code, MapVirtualKey( Code, 0 ), KEYEVENTF_EXTENDEDKEY | 0, 0 ); keybd_event( Code, MapVirtualKey( Code, 0 ), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 ); } @@ -89,7 +89,7 @@ Console::Console() Console::~Console() { - Console::Off(); + Off(); }; void Console::ModeSet(int m, int h) diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index cd046eba..c90f06ed 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -624,7 +624,7 @@ struct TCommand /// Second numeric argument. double Value2 = 0.0; /// Coupling flag controlling how the command propagates between vehicles. - int Coupling{coupling::control}; // coupler flag used to determine command propagation + int Coupling{control}; // coupler flag used to determine command propagation /// World-space location associated with the command. TLocation Location; }; @@ -1210,10 +1210,10 @@ struct TCoupling double FmaxC = 1000.0; double beta = 0.0; TCouplerType CouplerType = TCouplerType::NoCoupler; /*typ sprzegu*/ - int AutomaticCouplingFlag = coupling::coupler; - int AllowedFlag = coupling::coupler | coupling::brakehose; // Ra: maska dostępnych - int PowerFlag = coupling::power110v | coupling::power24v; - int PowerCoupling = coupling::permanent; // type of coupling required for power transfer + int AutomaticCouplingFlag = coupler; + int AllowedFlag = coupler | brakehose; // Ra: maska dostępnych + int PowerFlag = power110v | power24v; + int PowerCoupling = permanent; // type of coupling required for power transfer /*zmienne*/ bool AutomaticCouplingAllowed{true}; // whether automatic coupling can be currently performed int CouplingFlag = 0; /*0 - wirtualnie, 1 - sprzegi, 2 - pneumatycznie, 4 - sterowanie, 8 - kabel mocy*/ @@ -1424,10 +1424,10 @@ class TMoverParameters struct door_data { // config - control_t open_control{control_t::passenger}; + control_t open_control{passenger}; float open_rate{1.f}; float open_delay{0.f}; - control_t close_control{control_t::passenger}; + control_t close_control{passenger}; float close_rate{1.f}; float close_delay{0.f}; int type{2}; @@ -2317,7 +2317,7 @@ class TMoverParameters double ShowEngineRotation(int VehN); // Q ******************************************************************************************* - double GetTrainsetVoltage(int const Coupling = coupling::heating | coupling::highvoltage) const; + double GetTrainsetVoltage(int const Coupling = heating | highvoltage) const; double GetTrainsetHighVoltage() const; bool switch_physics(bool const State); double LocalBrakeRatio(void); @@ -2330,10 +2330,10 @@ class TMoverParameters double EngineMaxRPM() const; /*! przesylanie komend sterujacych*/ - bool SendCtrlToNext(std::string const CtrlCommand, double const ctrlvalue, double const dir, int const Couplertype = coupling::control); - bool SetInternalCommand(std::string NewCommand, double NewValue1, double NewValue2, int const Couplertype = coupling::control); + bool SendCtrlToNext(std::string const CtrlCommand, double const ctrlvalue, double const dir, int const Couplertype = control); + bool SetInternalCommand(std::string NewCommand, double NewValue1, double NewValue2, int const Couplertype = control); double GetExternalCommand(std::string &Command); - bool RunCommand(std::string Command, double CValue1, double CValue2, int const Couplertype = coupling::control); + bool RunCommand(std::string Command, double CValue1, double CValue2, int const Couplertype = control); bool RunInternalCommand(); void PutCommand(std::string NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation); bool CabActivisation(bool const Enforce = false); diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index e6efa436..145f8e34 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -587,7 +587,7 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters * // Ra: zwykle wykonywane dwukrotnie, dla każdego pojazdu oddzielnie // Ra: trzeba by odróżnić wymóg dociśnięcia od uszkodzenia sprzęgu przy podczepianiu AI do składu - if (ConnectTo == nullptr || CouplingType == coupling::faux) + if (ConnectTo == nullptr || CouplingType == faux) { return false; } @@ -604,7 +604,7 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters * } // stykaja sie zderzaki i kompatybilne typy sprzegow, chyba że łączenie na starcie - if (coupler.CouplingFlag == coupling::faux) + if (coupler.CouplingFlag == faux) { // jeśli wcześniej nie było połączone, ustalenie z której strony rysować sprzęg coupler.Render = true; // tego rysować @@ -624,10 +624,10 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters * if (true == Audible && couplingchange != 0) { // set sound event flag - int soundflag{sound::none}; - std::vector> const soundmappings = {{coupling::coupler, sound::attachcoupler}, {coupling::brakehose, sound::attachbrakehose}, - {coupling::mainhose, sound::attachmainhose}, {coupling::control, sound::attachcontrol}, - {coupling::gangway, sound::attachgangway}, {coupling::heating, sound::attachheating}}; + int soundflag{none}; + std::vector> const soundmappings = {{coupling::coupler, attachcoupler}, {brakehose, attachbrakehose}, + {mainhose, attachmainhose}, {control, attachcontrol}, + {gangway, attachgangway}, {heating, attachheating}}; for (auto const &soundmapping : soundmappings) { if ((couplingchange & soundmapping.first) != 0) @@ -674,7 +674,7 @@ bool TMoverParameters::Dettach(int ConnectNo) { // gdy scisniete zderzaki, chyba ze zerwany sprzeg (wirtualnego nie odpinamy z drugiej strony) std::tie(coupler.Connected, coupler.ConnectedNr, coupler.CouplingFlag) = std::tie(othercoupler.Connected, othercoupler.ConnectedNr, othercoupler.CouplingFlag) = - std::make_tuple(nullptr, -1, coupling::faux); + std::make_tuple(nullptr, -1, faux); } else if (couplingstate > 0) { // odłączamy węże i resztę, pozostaje sprzęg fizyczny, który wymaga dociśnięcia (z wirtualnym nic) @@ -685,10 +685,10 @@ bool TMoverParameters::Dettach(int ConnectNo) couplingchange ^= coupler.CouplingFlag; // remaining bits were removed from coupling if (couplingchange != 0) { - int soundflag{sound::detach}; // HACK: use detach flag to indicate removal of listed coupling - std::vector> const soundmappings = {{coupling::coupler, sound::attachcoupler}, {coupling::brakehose, sound::attachbrakehose}, - {coupling::mainhose, sound::attachmainhose}, {coupling::control, sound::attachcontrol}, - {coupling::gangway, sound::attachgangway}, {coupling::heating, sound::attachheating}}; + int soundflag{detach}; // HACK: use detach flag to indicate removal of listed coupling + std::vector> const soundmappings = {{coupling::coupler, attachcoupler}, {brakehose, attachbrakehose}, + {mainhose, attachmainhose}, {control, attachcontrol}, + {gangway, attachgangway}, {heating, attachheating}}; for (auto const &soundmapping : soundmappings) { if ((couplingchange & soundmapping.first) != 0) @@ -709,7 +709,7 @@ bool TMoverParameters::DirectionForward() return false; } - if (MainCtrlPosNo > 0 && DirActive < 1 && (CabActive != 0 || (InactiveCabFlag & activation::neutraldirection) == 0)) + if (MainCtrlPosNo > 0 && DirActive < 1 && (CabActive != 0 || (InactiveCabFlag & neutraldirection) == 0)) { ++DirActive; DirAbsolute = DirActive * CabActive; @@ -843,7 +843,7 @@ void TMoverParameters::UpdatePantVolume(double dt) // check the pantograph compressor while at it // TODO: move the check to a separate method // automatic start if the pressure is too low - PantCompFlag |= PantPress < 4.2 && true == (Pantographs[end::front].is_active | Pantographs[end::rear].is_active) // TODO: any_pantograph_is_active method + PantCompFlag |= PantPress < 4.2 && true == (Pantographs[front].is_active | Pantographs[rear].is_active) // TODO: any_pantograph_is_active method && (PantographCompressorStart == start_t::automatic || PantographCompressorStart == start_t::manualwithautofallback); auto const lowvoltagepower{Power24vIsAvailable || Power110vIsAvailable}; @@ -1196,7 +1196,7 @@ void TMoverParameters::CollisionDetect(int const End, double const dt) auto velocity{V}; auto othervehiclevelocity{othervehicle->V}; // calculate collision force and new velocities for involved vehicles - auto const VirtualCoupling{(coupler.CouplingFlag == coupling::faux)}; + auto const VirtualCoupling{(coupler.CouplingFlag == faux)}; auto CCF{0.0}; switch (End) @@ -1225,7 +1225,7 @@ void TMoverParameters::CollisionDetect(int const End, double const dt) damage_coupler(End); } - if (coupler.CouplingFlag == coupling::faux || true == TestFlag(othervehicle->DamageFlag, dtrain_out)) + if (coupler.CouplingFlag == faux || true == TestFlag(othervehicle->DamageFlag, dtrain_out)) { // HACK: limit excessive speed derailment checks to vehicles which aren't part of the same consist auto const safevelocitylimit{15.0}; auto const velocitydifference{glm::length(glm::angleAxis(Rot.Rz, glm::dvec3{0, 1, 0}) * V - glm::angleAxis(othervehicle->Rot.Rz, glm::dvec3{0, 1, 0}) * othervehicle->V) * @@ -1286,7 +1286,7 @@ void TMoverParameters::damage_coupler(int const End) if (SetFlag(DamageFlag, dtrain_coupling)) EventFlag = true; - if ((coupler.CouplingFlag & coupling::brakehose) == coupling::brakehose) + if ((coupler.CouplingFlag & brakehose) == brakehose) { // hamowanie nagle - zerwanie przewodow hamulcowych AlarmChainFlag = true; @@ -1301,12 +1301,12 @@ void TMoverParameters::damage_coupler(int const End) // break connection with other vehicle, if there's any case 0: { - coupler.Connected->Couplers[end::rear].CouplingFlag = coupling::faux; + coupler.Connected->Couplers[rear].CouplingFlag = faux; break; } case 1: { - coupler.Connected->Couplers[end::front].CouplingFlag = coupling::faux; + coupler.Connected->Couplers[front].CouplingFlag = faux; break; } default: @@ -1593,7 +1593,7 @@ void TMoverParameters::compute_movement_(double const Deltatime) { if (AutoRelayCheck()) { - SetFlag(SoundFlag, sound::relay); + SetFlag(SoundFlag, relay); } } @@ -1601,7 +1601,7 @@ void TMoverParameters::compute_movement_(double const Deltatime) { if (dizel_Update(Deltatime)) { - SetFlag(SoundFlag, sound::relay); + SetFlag(SoundFlag, relay); } } @@ -1645,13 +1645,13 @@ void TMoverParameters::compute_movement_(double const Deltatime) UpdateBatteryVoltage(Deltatime); UpdateScndPipePressure(Deltatime); // druga rurka, youBy - if ((DCEMUED_CC & 1) != 0 && (Couplers[end::front].CouplingFlag & coupling::control) != 0) + if ((DCEMUED_CC & 1) != 0 && (Couplers[front].CouplingFlag & control) != 0) { - DynamicBrakeEMUStatus &= Couplers[end::front].Connected->DynamicBrakeEMUStatus; + DynamicBrakeEMUStatus &= Couplers[front].Connected->DynamicBrakeEMUStatus; } - if ((DCEMUED_CC & 2) != 0 && (Couplers[end::rear].CouplingFlag & coupling::control) != 0) + if ((DCEMUED_CC & 2) != 0 && (Couplers[rear].CouplingFlag & control) != 0) { - DynamicBrakeEMUStatus &= Couplers[end::rear].Connected->DynamicBrakeEMUStatus; + DynamicBrakeEMUStatus &= Couplers[rear].Connected->DynamicBrakeEMUStatus; } if (BrakeSlippingTimer > 0.8 && ASBType != 128) @@ -1665,13 +1665,13 @@ void TMoverParameters::compute_movement_(double const Deltatime) m_plc.update(Deltatime); - PowerCouplersCheck(Deltatime, coupling::highvoltage); - PowerCouplersCheck(Deltatime, coupling::power110v); - PowerCouplersCheck(Deltatime, coupling::power24v); + PowerCouplersCheck(Deltatime, highvoltage); + PowerCouplersCheck(Deltatime, power110v); + PowerCouplersCheck(Deltatime, power24v); - Power24vVoltage = std::max(PowerCircuits[0].first, GetTrainsetVoltage(coupling::power24v)); + Power24vVoltage = std::max(PowerCircuits[0].first, GetTrainsetVoltage(power24v)); Power24vIsAvailable = Power24vVoltage > 0; - Power110vIsAvailable = PowerCircuits[1].first > 0 || GetTrainsetVoltage(coupling::power110v) > 0; + Power110vIsAvailable = PowerCircuits[1].first > 0 || GetTrainsetVoltage(power110v) > 0; } void TMoverParameters::MainsCheck(double const Deltatime) @@ -1760,7 +1760,7 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const switch (Coupling) { - case coupling::highvoltage: + case highvoltage: { // heating power sources if (Heating) @@ -1805,7 +1805,7 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const break; } - case coupling::power110v: + case power110v: { if (ConverterFlag) { @@ -1816,7 +1816,7 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const break; } - case coupling::power24v: + case power24v: { if (Battery) { @@ -1842,7 +1842,7 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const auto &coupler{Couplers[side]}; // NOTE: in the loop we actually update the state of the coupler on the opposite end of the vehicle - auto &oppositecoupler{Couplers[(side == end::front ? end::rear : end::front)]}; + auto &oppositecoupler{Couplers[(side == front ? rear : front)]}; bool oppositecouplingispresent; bool localpowerexportisenabled; @@ -1850,26 +1850,26 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const switch (Coupling) { - case coupling::highvoltage: + case highvoltage: { - auto const oppositehighvoltagecoupling{(oppositecoupler.CouplingFlag & coupling::highvoltage) != 0}; - auto const oppositeheatingcoupling{(oppositecoupler.CouplingFlag & coupling::heating) != 0}; + auto const oppositehighvoltagecoupling{(oppositecoupler.CouplingFlag & highvoltage) != 0}; + auto const oppositeheatingcoupling{(oppositecoupler.CouplingFlag & heating) != 0}; oppositecouplingispresent = oppositehighvoltagecoupling || oppositeheatingcoupling; localpowerexportisenabled = oppositehighvoltagecoupling || (oppositeheatingcoupling && localpowersource && Heating); break; } - case coupling::power110v: + case power110v: { - oppositecouplingispresent = TestFlag(oppositecoupler.CouplingFlag, oppositecoupler.PowerCoupling) && (oppositecoupler.PowerFlag & coupling::power110v) != 0; + oppositecouplingispresent = TestFlag(oppositecoupler.CouplingFlag, oppositecoupler.PowerCoupling) && (oppositecoupler.PowerFlag & power110v) != 0; localpowerexportisenabled = oppositecouplingispresent; break; } - case coupling::power24v: + case power24v: { - oppositecouplingispresent = TestFlag(oppositecoupler.CouplingFlag, oppositecoupler.PowerCoupling) && (oppositecoupler.PowerFlag & coupling::power24v) != 0; + oppositecouplingispresent = TestFlag(oppositecoupler.CouplingFlag, oppositecoupler.PowerCoupling) && (oppositecoupler.PowerFlag & power24v) != 0; localpowerexportisenabled = oppositecouplingispresent; break; } @@ -1880,13 +1880,13 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const } } - auto const *coupling = Coupling == coupling::highvoltage ? &coupler.power_high : - Coupling == coupling::power110v ? &coupler.power_110v : - Coupling == coupling::power24v ? &coupler.power_24v : + auto const *coupling = Coupling == highvoltage ? &coupler.power_high : + Coupling == power110v ? &coupler.power_110v : + Coupling == power24v ? &coupler.power_24v : nullptr; - auto *oppositecoupling = Coupling == coupling::highvoltage ? &oppositecoupler.power_high : - Coupling == coupling::power110v ? &oppositecoupler.power_110v : - Coupling == coupling::power24v ? &oppositecoupler.power_24v : + auto *oppositecoupling = Coupling == highvoltage ? &oppositecoupler.power_high : + Coupling == power110v ? &oppositecoupler.power_110v : + Coupling == power24v ? &oppositecoupler.power_24v : nullptr; // start with base voltage @@ -1897,9 +1897,9 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const if (coupler.Connected != nullptr) { auto const &connectedcoupler{coupler.Connected->Couplers[coupler.ConnectedNr]}; - auto const *connectedcoupling = Coupling == coupling::highvoltage ? &connectedcoupler.power_high : - Coupling == coupling::power110v ? &connectedcoupler.power_110v : - Coupling == coupling::power24v ? &connectedcoupler.power_24v : + auto const *connectedcoupling = Coupling == highvoltage ? &connectedcoupler.power_high : + Coupling == power110v ? &connectedcoupler.power_110v : + Coupling == power24v ? &connectedcoupler.power_24v : nullptr; auto const connectedvoltage{(connectedcoupling->is_live ? connectedcoupling->voltage : 0.0)}; oppositecoupling->voltage = std::max(oppositecoupling->voltage, connectedvoltage - coupling->current * 0.02); @@ -1917,19 +1917,19 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const auto couplervoltage{0}; switch (Coupling) { - case coupling::highvoltage: + case highvoltage: { - couplervoltage = Couplers[end::front].power_high.voltage + Couplers[end::rear].power_high.voltage; + couplervoltage = Couplers[front].power_high.voltage + Couplers[rear].power_high.voltage; break; } - case coupling::power110v: + case power110v: { - couplervoltage = Couplers[end::front].power_110v.voltage + Couplers[end::rear].power_110v.voltage; + couplervoltage = Couplers[front].power_110v.voltage + Couplers[rear].power_110v.voltage; break; } - case coupling::power24v: + case power24v: { - couplervoltage = Couplers[end::front].power_24v.voltage + Couplers[end::rear].power_24v.voltage; + couplervoltage = Couplers[front].power_24v.voltage + Couplers[rear].power_24v.voltage; break; } default: @@ -1938,18 +1938,18 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const } } - auto *totalcurrent = Coupling == coupling::highvoltage ? &TotalCurrent : - Coupling == coupling::power110v ? &PowerCircuits[1].second : - Coupling == coupling::power24v ? &PowerCircuits[0].second : + auto *totalcurrent = Coupling == highvoltage ? &TotalCurrent : + Coupling == power110v ? &PowerCircuits[1].second : + Coupling == power24v ? &PowerCircuits[0].second : nullptr; for (auto side = 0; side < 2; ++side) { auto &coupler{Couplers[side]}; - auto *coupling = Coupling == coupling::highvoltage ? &coupler.power_high : - Coupling == coupling::power110v ? &coupler.power_110v : - Coupling == coupling::power24v ? &coupler.power_24v : + auto *coupling = Coupling == highvoltage ? &coupler.power_high : + Coupling == power110v ? &coupler.power_110v : + Coupling == power24v ? &coupler.power_24v : nullptr; coupling->current = 0.0; @@ -1959,12 +1959,12 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const continue; } - auto const &connectedothercoupler{coupler.Connected->Couplers[(coupler.ConnectedNr == end::front ? end::rear : end::front)]}; - auto const *connectedothercoupling = Coupling == coupling::highvoltage ? &connectedothercoupler.power_high : - Coupling == coupling::power110v ? &connectedothercoupler.power_110v : - Coupling == coupling::power24v ? &connectedothercoupler.power_24v : + auto const &connectedothercoupler{coupler.Connected->Couplers[(coupler.ConnectedNr == front ? rear : front)]}; + auto const *connectedothercoupling = Coupling == highvoltage ? &connectedothercoupler.power_high : + Coupling == power110v ? &connectedothercoupler.power_110v : + Coupling == power24v ? &connectedothercoupler.power_24v : nullptr; - auto const extracurrent = Coupling == coupling::highvoltage ? std::abs(Itot) * IsVehicleEIMBrakingFactor() : 0.0; + auto const extracurrent = Coupling == highvoltage ? std::abs(Itot) * IsVehicleEIMBrakingFactor() : 0.0; if (false == localpowersource) { @@ -1998,15 +1998,15 @@ double TMoverParameters::ShowEngineRotation(int VehN) return std::abs(enrot); case 2: for (b = 0; b <= 1; ++b) - if (TestFlag(Couplers[b].CouplingFlag, coupling::control)) + if (TestFlag(Couplers[b].CouplingFlag, control)) if (Couplers[b].Connected->Power > 0.01) return fabs(Couplers[b].Connected->enrot); break; case 3: // to nie uwzględnia ewentualnego odwrócenia pojazdu w środku for (b = 0; b <= 1; ++b) - if (TestFlag(Couplers[b].CouplingFlag, coupling::control)) + if (TestFlag(Couplers[b].CouplingFlag, control)) if (Couplers[b].Connected->Power > 0.01) - if (TestFlag(Couplers[b].Connected->Couplers[b].CouplingFlag, coupling::control)) + if (TestFlag(Couplers[b].Connected->Couplers[b].CouplingFlag, control)) if (Couplers[b].Connected->Couplers[b].Connected->Power > 0.01) return fabs(Couplers[b].Connected->Couplers[b].Connected->enrot); break; @@ -2902,7 +2902,7 @@ bool TMoverParameters::CabActivisation(bool const Enforce) SecuritySystem.set_enabled(true); // activate the alerter TODO: make it part of control based cab selection SendCtrlToNext("CabActivisation", 1, CabActive); SendCtrlToNext("Direction", DirAbsolute, CabActive); - if (InactiveCabFlag & activation::springbrakeoff) + if (InactiveCabFlag & springbrakeoff) { SpringBrakeActivate(false); } @@ -2927,20 +2927,20 @@ bool TMoverParameters::CabDeactivisation(bool const Enforce) OK = Enforce || IsCabMaster(); // o ile obsada jest w kabinie ze sterowaniem if (OK) { - if (InactiveCabFlag & activation::springbrakeon) + if (InactiveCabFlag & springbrakeon) { SpringBrakeActivate(true); } - if (InactiveCabFlag & activation::pantographsup) + if (InactiveCabFlag & pantographsup) { InactiveCabPantsCheck = true; } - if (InactiveCabFlag & activation::doorpermition) + if (InactiveCabFlag & doorpermition) { - PermitDoors(side::right, true, range_t::consist); - PermitDoors(side::left, true, range_t::consist); + PermitDoors(right, true, range_t::consist); + PermitDoors(left, true, range_t::consist); } - if (InactiveCabFlag & activation::neutraldirection) + if (InactiveCabFlag & neutraldirection) { DirActive = 0; SendCtrlToNext("Direction", 0, CabActive); @@ -3084,7 +3084,7 @@ bool TMoverParameters::Sandbox(bool const State, range_t const Notify) if (Notify != range_t::local) { // if requested pass the command on - auto const couplingtype = Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control; + auto const couplingtype = Notify == range_t::unit ? control | permanent : control; if (State == true) { @@ -3163,8 +3163,8 @@ bool TMoverParameters::BatterySwitch(bool State, range_t const Notify) // switching batteries does not require activation if (Notify != range_t::local) { - SendCtrlToNext("BatterySwitch", State ? 1 : 0, 1, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); - SendCtrlToNext("BatterySwitch", State ? 1 : 0, -1, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("BatterySwitch", State ? 1 : 0, 1, Notify == range_t::unit ? control | permanent : control); + SendCtrlToNext("BatterySwitch", State ? 1 : 0, -1, Notify == range_t::unit ? control | permanent : control); } return Battery != initialstate; @@ -3252,7 +3252,7 @@ bool TMoverParameters::DirectionBackward(void) { return true; } - if (MainCtrlPosNo > 0 && DirActive > -1 && (CabActive != 0 || (InactiveCabFlag & activation::neutraldirection) == 0)) + if (MainCtrlPosNo > 0 && DirActive > -1 && (CabActive != 0 || (InactiveCabFlag & neutraldirection) == 0)) { if (EngineType == TEngineType::WheelsDriven) --CabActive; @@ -3302,7 +3302,7 @@ bool TMoverParameters::WaterPumpBreakerSwitch(bool State, range_t const Notify) if (Notify != range_t::local) { - SendCtrlToNext("WaterPumpBreakerSwitch", WaterPump.breaker ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("WaterPumpBreakerSwitch", WaterPump.breaker ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return WaterPump.breaker != initialstate; @@ -3324,7 +3324,7 @@ bool TMoverParameters::WaterPumpSwitch(bool State, range_t const Notify) if (Notify != range_t::local) { - SendCtrlToNext("WaterPumpSwitch", WaterPump.is_enabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("WaterPumpSwitch", WaterPump.is_enabled ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return WaterPump.is_enabled != initialstate; @@ -3346,7 +3346,7 @@ bool TMoverParameters::WaterPumpSwitchOff(bool State, range_t const Notify) if (Notify != range_t::local) { - SendCtrlToNext("WaterPumpSwitchOff", WaterPump.is_disabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("WaterPumpSwitchOff", WaterPump.is_disabled ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return WaterPump.is_disabled != initialstate; @@ -3367,7 +3367,7 @@ bool TMoverParameters::WaterHeaterBreakerSwitch(bool State, range_t const Notify if (Notify != range_t::local) { - SendCtrlToNext("WaterHeaterBreakerSwitch", WaterHeater.breaker ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("WaterHeaterBreakerSwitch", WaterHeater.breaker ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return WaterHeater.breaker != initialstate; @@ -3388,7 +3388,7 @@ bool TMoverParameters::WaterHeaterSwitch(bool State, range_t const Notify) if (Notify != range_t::local) { - SendCtrlToNext("WaterHeaterSwitch", WaterHeater.is_enabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("WaterHeaterSwitch", WaterHeater.is_enabled ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return WaterHeater.is_enabled != initialstate; @@ -3410,7 +3410,7 @@ bool TMoverParameters::WaterCircuitsLinkSwitch(bool State, range_t const Notify) if (Notify != range_t::local) { - SendCtrlToNext("WaterCircuitsLinkSwitch", WaterCircuitsLink ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("WaterCircuitsLinkSwitch", WaterCircuitsLink ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return WaterCircuitsLink != initialstate; @@ -3432,7 +3432,7 @@ bool TMoverParameters::FuelPumpSwitch(bool State, range_t const Notify) if (Notify != range_t::local) { - SendCtrlToNext("FuelPumpSwitch", FuelPump.is_enabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("FuelPumpSwitch", FuelPump.is_enabled ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return FuelPump.is_enabled != initialstate; @@ -3453,7 +3453,7 @@ bool TMoverParameters::FuelPumpSwitchOff(bool State, range_t const Notify) if (Notify != range_t::local) { - SendCtrlToNext("FuelPumpSwitchOff", FuelPump.is_disabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("FuelPumpSwitchOff", FuelPump.is_disabled ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return FuelPump.is_disabled != initialstate; @@ -3475,7 +3475,7 @@ bool TMoverParameters::OilPumpSwitch(bool State, range_t const Notify) if (Notify != range_t::local) { - SendCtrlToNext("OilPumpSwitch", OilPump.is_enabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("OilPumpSwitch", OilPump.is_enabled ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return OilPump.is_enabled != initialstate; @@ -3496,7 +3496,7 @@ bool TMoverParameters::OilPumpSwitchOff(bool State, range_t const Notify) if (Notify != range_t::local) { - SendCtrlToNext("OilPumpSwitchOff", OilPump.is_disabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("OilPumpSwitchOff", OilPump.is_disabled ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return OilPump.is_disabled != initialstate; @@ -3519,8 +3519,8 @@ bool TMoverParameters::MotorBlowersSwitch(bool State, end const Side, range_t co if (Notify != range_t::local) { - SendCtrlToNext(Side == end::front ? "MotorBlowersFrontSwitch" : "MotorBlowersRearSwitch", fan.is_enabled ? 1 : 0, CabActive, - Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext(Side == front ? "MotorBlowersFrontSwitch" : "MotorBlowersRearSwitch", fan.is_enabled ? 1 : 0, CabActive, + Notify == range_t::unit ? control | permanent : control); } return fan.is_enabled != initialstate; @@ -3543,8 +3543,8 @@ bool TMoverParameters::MotorBlowersSwitchOff(bool State, end const Side, range_t if (Notify != range_t::local) { - SendCtrlToNext(Side == end::front ? "MotorBlowersFrontSwitchOff" : "MotorBlowersRearSwitchOff", fan.is_disabled ? 1 : 0, CabActive, - Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext(Side == front ? "MotorBlowersFrontSwitchOff" : "MotorBlowersRearSwitchOff", fan.is_disabled ? 1 : 0, CabActive, + Notify == range_t::unit ? control | permanent : control); } return fan.is_disabled != initialstate; @@ -3565,7 +3565,7 @@ bool TMoverParameters::CompartmentLightsSwitch(bool State, range_t const Notify) if (Notify != range_t::local) { - SendCtrlToNext("CompartmentLightsSwitch", CompartmentLights.is_enabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("CompartmentLightsSwitch", CompartmentLights.is_enabled ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return CompartmentLights.is_enabled != initialstate; @@ -3587,7 +3587,7 @@ bool TMoverParameters::CompartmentLightsSwitchOff(bool State, range_t const Noti if (Notify != range_t::local) { - SendCtrlToNext("CompartmentLightsSwitchOff", CompartmentLights.is_disabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("CompartmentLightsSwitchOff", CompartmentLights.is_disabled ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return CompartmentLights.is_disabled != initialstate; @@ -3608,7 +3608,7 @@ bool TMoverParameters::MainSwitch(bool const State, range_t const Notify) { // pass the command to other vehicles // TBD: pass the requested state, or the actual state? - SendCtrlToNext("MainSwitch", State ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("MainSwitch", State ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return (Mains || dizel_startup) != initialstate; @@ -3710,7 +3710,7 @@ bool TMoverParameters::ConverterSwitch(bool State, range_t const Notify) if (Notify != range_t::local) { - SendCtrlToNext("ConverterSwitch", State ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("ConverterSwitch", State ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return ConverterAllow != initialstate; @@ -3738,7 +3738,7 @@ bool TMoverParameters::CompressorSwitch(bool State, range_t const Notify) if (Notify != range_t::local) { - SendCtrlToNext("CompressorSwitch", State ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("CompressorSwitch", State ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return CompressorAllow != initialstate; @@ -3753,7 +3753,7 @@ bool TMoverParameters::ChangeCompressorPreset(int const State, range_t const Not if (Notify != range_t::local) { - SendCtrlToNext("CompressorPreset", State, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("CompressorPreset", State, CabActive, Notify == range_t::unit ? control | permanent : control); } return CompressorListPos != initialstate; @@ -3770,7 +3770,7 @@ bool TMoverParameters::HeatingSwitch(bool const State, range_t const Notify) { // pass the command to other vehicles // TBD: pass the requested state, or the actual state? - SendCtrlToNext("HeatingSwitch", State ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("HeatingSwitch", State ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return HeatingAllow != initialstate; @@ -4011,7 +4011,7 @@ bool TMoverParameters::DynamicBrakeSwitch(bool Switch) DBS = true; for (int b = 0; b < 2; b++) // with Couplers[b] do - if (TestFlag(Couplers[b].CouplingFlag, coupling::control)) + if (TestFlag(Couplers[b].CouplingFlag, control)) Couplers[b].Connected->DynamicBrakeFlag = Switch; // end; // if (DynamicBrakeType=dbrake_passive) and (TrainType=dt_ET42) then @@ -4135,12 +4135,12 @@ bool TMoverParameters::UniversalBrakeButton(int button, int state) Hamulec->SetUniversalFlag(flag); Handle->SetUniversalFlag(flag); LocHandle->SetUniversalFlag(flag); - UnlockPipe = (flag & TUniversalBrake::ub_UnlockPipe) > 0; + UnlockPipe = (flag & ub_UnlockPipe) > 0; // if the releaser can be activated by switch - if (TestFlag(UniversalBrakeButtonFlag[0] & UniversalBrakeButtonFlag[1] & UniversalBrakeButtonFlag[2], TUniversalBrake::ub_Release)) + if (TestFlag(UniversalBrakeButtonFlag[0] & UniversalBrakeButtonFlag[1] & UniversalBrakeButtonFlag[2], ub_Release)) { - BrakeReleaser(TestFlag(flag, TUniversalBrake::ub_Release) ? 1 : 0); + BrakeReleaser(TestFlag(flag, ub_Release) ? 1 : 0); } return OK; } @@ -4351,10 +4351,10 @@ void TMoverParameters::CompressorCheck(double dt) Compressor = CompressedVolume / VeselVolume; // assorted operational logic - auto const MaxCompressorF{CompressorList[TCompressorList::cl_MaxFactor][CompressorListPos] * MaxCompressor}; - auto const MinCompressorF{CompressorList[TCompressorList::cl_MinFactor][CompressorListPos] * MinCompressor}; - auto const CompressorSpeedF{CompressorList[TCompressorList::cl_SpeedFactor][CompressorListPos] * CompressorSpeed}; - auto const AllowFactor{CompressorList[TCompressorList::cl_Allow][CompressorListPos]}; + auto const MaxCompressorF{CompressorList[cl_MaxFactor][CompressorListPos] * MaxCompressor}; + auto const MinCompressorF{CompressorList[cl_MinFactor][CompressorListPos] * MinCompressor}; + auto const CompressorSpeedF{CompressorList[cl_SpeedFactor][CompressorListPos] * CompressorSpeed}; + auto const AllowFactor{CompressorList[cl_Allow][CompressorListPos]}; // checking the impact on the compressor allowance if (AllowFactor > 0.5) { @@ -4396,8 +4396,8 @@ void TMoverParameters::CompressorCheck(double dt) // NOTE: this is crude implementation, limited only to adjacent vehicles // TODO: re-implement when a more elegant/flexible system is in place auto const coupledgovernorlock{ - (Couplers[end::rear].Connected != nullptr && true == TestFlag(Couplers[end::rear].CouplingFlag, coupling::permanent) && Couplers[end::rear].Connected->CompressorGovernorLock) || - (Couplers[end::front].Connected != nullptr && true == TestFlag(Couplers[end::front].CouplingFlag, coupling::permanent) && Couplers[end::front].Connected->CompressorGovernorLock)}; + (Couplers[rear].Connected != nullptr && true == TestFlag(Couplers[rear].CouplingFlag, permanent) && Couplers[rear].Connected->CompressorGovernorLock) || + (Couplers[front].Connected != nullptr && true == TestFlag(Couplers[front].CouplingFlag, permanent) && Couplers[front].Connected->CompressorGovernorLock)}; auto const governorlock{CompressorGovernorLock || coupledgovernorlock}; auto const compressorflag{CompressorFlag}; @@ -4436,7 +4436,7 @@ void TMoverParameters::CompressorCheck(double dt) if (pressureistoohigh && (false == governorlockispresent || CompressorPower == 3)) { // vent some air out if there's no governor lock to stop the compressor from exceeding acceptable pressure level - SetFlag(SoundFlag, sound::relay | sound::loud); + SetFlag(SoundFlag, relay | loud); CompressedVolume *= false == governorlockispresent ? 0.80 : // arbitrary amount CompressorTankValve ? MinCompressorF / MaxCompressorF : // drop to mincompressor level 0.999; // HACK: drop a tiny bit so the sound doesn't trigger repeatedly @@ -4580,7 +4580,7 @@ void TMoverParameters::UpdatePipePressure(double dt) // (if it's supposed to be broken coupler, such event sets alarmchainflag instead when appropriate) || ( true == TestFlag( EngDmgFlag, 32 ) ) */ - || (0 == CabActive && InactiveCabFlag & activation::emergencybrake) || (SpringBrakeDriveEmergencyVel >= 0 && Vel > SpringBrakeDriveEmergencyVel && SpringBrake.IsActive)) + || (0 == CabActive && InactiveCabFlag & emergencybrake) || (SpringBrakeDriveEmergencyVel >= 0 && Vel > SpringBrakeDriveEmergencyVel && SpringBrake.IsActive)) { EmergencyValveFlow = PF(0, PipePress, 0.15) * dt; } @@ -4935,7 +4935,7 @@ void TMoverParameters::ComputeConstans(void) // drag calculation { // NOTE: draft effect of previous vehicle is simplified and doesn't have much to do with reality - auto const *previousvehicle{Couplers[(V >= 0.0 ? end::front : end::rear)].Connected}; + auto const *previousvehicle{Couplers[(V >= 0.0 ? front : rear)].Connected}; auto dragarea{Dim.W * Dim.H}; if (previousvehicle) { @@ -5005,11 +5005,11 @@ void TMoverParameters::ComputeTotalForce(double dt) { auto const vehicleisactive{CabActive != 0 || Vel > 0.0001 || std::abs(AccS) > 0.0001 || LastSwitchingTime < 5 || TrainType == dt_EZT || TrainType == dt_DMU}; - auto const movingvehicleahead{Neighbours[end::front].vehicle != nullptr && - (Neighbours[end::front].vehicle->MoverParameters->Vel > 0.0001 || std::abs(Neighbours[end::front].vehicle->MoverParameters->AccS) > 0.0001)}; + auto const movingvehicleahead{Neighbours[front].vehicle != nullptr && + (Neighbours[front].vehicle->MoverParameters->Vel > 0.0001 || std::abs(Neighbours[front].vehicle->MoverParameters->AccS) > 0.0001)}; - auto const movingvehiclebehind{Neighbours[end::rear].vehicle != nullptr && - (Neighbours[end::rear].vehicle->MoverParameters->Vel > 0.0001 || std::abs(Neighbours[end::rear].vehicle->MoverParameters->AccS) > 0.0001)}; + auto const movingvehiclebehind{Neighbours[rear].vehicle != nullptr && + (Neighbours[rear].vehicle->MoverParameters->Vel > 0.0001 || std::abs(Neighbours[rear].vehicle->MoverParameters->AccS) > 0.0001)}; auto const calculatephysics{vehicleisactive || movingvehicleahead || movingvehiclebehind}; @@ -5116,7 +5116,7 @@ void TMoverParameters::ComputeTotalForce(double dt) } nrot_eps = (abs(nrot) - old_nrot) / dt; // doliczenie sił z innych pojazdów - for (int end = end::front; end <= end::rear; ++end) + for (int end = front; end <= rear; ++end) { if (Neighbours[end].vehicle != nullptr) { @@ -5328,7 +5328,7 @@ double TMoverParameters::CouplerForce(int const End, double dt) auto const othervehiclemove{(othervehicle->dMoveLen * DirPatch(End, otherend))}; auto const initialdistance{Neighbours[End].distance}; // odległość od sprzęgu sąsiada - auto const distancedelta{(End == end::front ? othervehiclemove - dMoveLen : dMoveLen - othervehiclemove)}; + auto const distancedelta{(End == front ? othervehiclemove - dMoveLen : dMoveLen - othervehiclemove)}; auto const newdistance{initialdistance + 10.0 * distancedelta}; @@ -5339,12 +5339,12 @@ double TMoverParameters::CouplerForce(int const End, double dt) if (newdistance < 0.0 && coupler.Dist > newdistance && dV < -0.1 && false == coupler.has_adapter()) { // HACK: with adapter present we presume buffers won't clash // 090503: dzwieki pracy zderzakow - SetFlag(coupler.sounds, absdV > 5.0 ? sound::bufferclash | sound::loud : sound::bufferclash); + SetFlag(coupler.sounds, absdV > 5.0 ? bufferclash | loud : bufferclash); } - else if (coupler.CouplingFlag != coupling::faux && newdistance > 0.001 && coupler.Dist <= 0.001 && absdV > 0.005 && Vel > 1.0) + else if (coupler.CouplingFlag != faux && newdistance > 0.001 && coupler.Dist <= 0.001 && absdV > 0.005 && Vel > 1.0) { // 090503: dzwieki pracy sprzegu - SetFlag(coupler.sounds, absdV > 0.035 ? sound::couplerstretch | sound::loud : sound::couplerstretch); + SetFlag(coupler.sounds, absdV > 0.035 ? couplerstretch | loud : couplerstretch); } coupler.CheckCollision = false; @@ -5352,13 +5352,13 @@ double TMoverParameters::CouplerForce(int const End, double dt) double CF{0.0}; - if (coupler.CouplingFlag == coupling::faux && initialdistance > 0.05) + if (coupler.CouplingFlag == faux && initialdistance > 0.05) { // arbitrary distance // potentially reset auto coupling lock coupler.AutomaticCouplingAllowed = true; } - if (coupler.CouplingFlag != coupling::faux || initialdistance < 0) + if (coupler.CouplingFlag != faux || initialdistance < 0) { coupler.Dist = std::clamp(newdistance, coupler.has_adapter() ? 0 : -coupler.DmaxB, coupler.DmaxC); @@ -5366,7 +5366,7 @@ double TMoverParameters::CouplerForce(int const End, double dt) double BetaAvg = 0; double Fmax = 0; - if (coupler.CouplingFlag == coupling::faux) + if (coupler.CouplingFlag == faux) { BetaAvg = coupler.beta; @@ -5435,7 +5435,7 @@ double TMoverParameters::CouplerForce(int const End, double dt) } if (-newdistance >= std::min(collisiondistance, dEpsilon)) { - if (coupler.type() == TCouplerType::Automatic && coupler.type() == othercoupler.type() && coupler.CouplingFlag == coupling::faux && + if (coupler.type() == TCouplerType::Automatic && coupler.type() == othercoupler.type() && coupler.CouplingFlag == faux && coupler.AutomaticCouplingAllowed && othercoupler.AutomaticCouplingAllowed) { @@ -5444,13 +5444,13 @@ double TMoverParameters::CouplerForce(int const End, double dt) // potentially exclude incompatible control coupling if (coupler.control_type != othercoupler.control_type) { - couplingtype &= ~coupling::control; + couplingtype &= ~control; } if (Attach(End, otherend, othervehicle, couplingtype)) { // HACK: we're reusing sound enum to mark whether vehicle was connected to another - SetFlag(AIFlag, sound::attachcoupler); + SetFlag(AIFlag, attachcoupler); coupler.AutomaticCouplingAllowed = false; othercoupler.AutomaticCouplingAllowed = false; } @@ -5463,7 +5463,7 @@ double TMoverParameters::CouplerForce(int const End, double dt) } } - if (coupler.CouplingFlag != coupling::faux) + if (coupler.CouplingFlag != faux) { // uzgadnianie prawa Newtona othervehicle->Couplers[1 - End].CForce = -CF; @@ -6219,7 +6219,7 @@ double TMoverParameters::TractionForce(double dt) if (ScndCtrlPos != shuntfieldstate) { - SetFlag(SoundFlag, sound::relay | sound::shuntfield); + SetFlag(SoundFlag, relay | shuntfield); } } } @@ -6314,8 +6314,8 @@ double TMoverParameters::TractionForce(double dt) // zalaczenia hamulca elektrodynamicznego - ED jest sterowany wlasnym nastawnikiem auto const dynbrakectrlactive{SplitEDPneumaticBrake && DynamicBrakeRatio() > 0.01 && DynamicBrakeAvailable()}; auto const localbrakeforED{SplitEDPneumaticBrake ? false : localbrakeactive}; - if (false == Doors.instances[side::left].is_closed || false == Doors.instances[side::right].is_closed || - (Doors.permit_needed && (Doors.instances[side::left].open_permit || Doors.instances[side::right].open_permit))) + if (false == Doors.instances[left].is_closed || false == Doors.instances[right].is_closed || + (Doors.permit_needed && (Doors.instances[left].open_permit || Doors.instances[right].open_permit))) { DynamicBrakeFlag = true; } @@ -6595,7 +6595,7 @@ bool TMoverParameters::FuseFlagCheck(void) const FFC = FuseFlag; else // pobor pradu jezeli niema mocy for (int b = 0; b < 2; b++) - if (TestFlag(Couplers[b].CouplingFlag, coupling::control)) + if (TestFlag(Couplers[b].CouplingFlag, control)) if (Couplers[b].Connected->Power > 0.01) FFC = Couplers[b].Connected->FuseFlagCheck(); @@ -6608,7 +6608,7 @@ bool TMoverParameters::FuseFlagCheck(void) const // ************************************************************************************************* bool TMoverParameters::FuseOn(range_t const Notify) { - auto const result{RelayReset(relay_t::maincircuitground | relay_t::tractionnmotoroverload, Notify)}; + auto const result{RelayReset(maincircuitground | tractionnmotoroverload, Notify)}; return result; } @@ -6623,7 +6623,7 @@ void TMoverParameters::FuseOff(void) { FuseFlag = true; EventFlag = true; - SetFlag(SoundFlag, sound::relay | sound::loud); + SetFlag(SoundFlag, relay | loud); } } @@ -6655,7 +6655,7 @@ bool TMoverParameters::RelayReset(int const Relays, range_t const Notify) auto const lowvoltagepower{Power24vIsAvailable || Power110vIsAvailable}; bool reset{false}; - if (TestFlag(Relays, relay_t::maincircuitground)) + if (TestFlag(Relays, maincircuitground)) { if ((EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric) && (GroundRelayStart == start_t::manual || GroundRelayStart == start_t::manualwithautofallback) && IsMainCtrlNoPowerPos() && ScndCtrlPos == 0 && DirActive != 0 && @@ -6667,7 +6667,7 @@ bool TMoverParameters::RelayReset(int const Relays, range_t const Notify) } } - if (TestFlag(Relays, relay_t::tractionnmotoroverload)) + if (TestFlag(Relays, tractionnmotoroverload)) { if ((EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric) && IsMainCtrlNoPowerPos() && ScndCtrlPos == 0 && DirActive != 0 && !TestFlag(EngDmgFlag, 1)) @@ -6680,7 +6680,7 @@ bool TMoverParameters::RelayReset(int const Relays, range_t const Notify) } } - if (TestFlag(Relays, relay_t::primaryconverteroverload)) + if (TestFlag(Relays, primaryconverteroverload)) { if (ConverterOverloadRelayStart == start_t::manual // && ( false == Mains ) @@ -6696,12 +6696,12 @@ bool TMoverParameters::RelayReset(int const Relays, range_t const Notify) if (reset) { - SetFlag(SoundFlag, sound::relay | sound::loud); + SetFlag(SoundFlag, relay | loud); } if (Notify != range_t::local) { - SendCtrlToNext("RelayReset", Relays, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("RelayReset", Relays, CabActive, Notify == range_t::unit ? control | permanent : control); } return reset; @@ -6796,7 +6796,7 @@ bool TMoverParameters::MaxCurrentSwitch(bool State, range_t const Notify) if (Notify != range_t::local) { - SendCtrlToNext("MaxCurrentSwitch", State ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("MaxCurrentSwitch", State ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return State != initialstate; @@ -6843,7 +6843,7 @@ bool TMoverParameters::ResistorsFlagCheck(void) const else // pobor pradu jezeli niema mocy { for (int b = 0; b < 2; b++) - if (TestFlag(Couplers[b].CouplingFlag, coupling::control)) + if (TestFlag(Couplers[b].CouplingFlag, control)) if (Couplers[b].Connected->Power > 0.01) RFC = Couplers[b].Connected->ResistorsFlagCheck(); } @@ -6916,7 +6916,7 @@ bool TMoverParameters::AutoRelayCheck(void) if (LastRelayTime > CtrlDelay && ARFASI2) { ++ScndCtrlActualPos; - SetFlag(SoundFlag, sound::shuntfield); + SetFlag(SoundFlag, shuntfield); OK = true; } } @@ -6925,7 +6925,7 @@ bool TMoverParameters::AutoRelayCheck(void) if (LastRelayTime > CtrlDownDelay && TrainType != dt_EZT) { --ScndCtrlActualPos; - SetFlag(SoundFlag, sound::shuntfield); + SetFlag(SoundFlag, shuntfield); OK = true; } } @@ -6968,7 +6968,7 @@ bool TMoverParameters::AutoRelayCheck(void) } if (RList[MainCtrlActualPos].R == 0) { - SetFlag(SoundFlag, sound::parallel | sound::loud); + SetFlag(SoundFlag, parallel | loud); OK = true; } } @@ -7008,12 +7008,12 @@ bool TMoverParameters::AutoRelayCheck(void) if (RList[MainCtrlActualPos].R == 0 && MainCtrlActualPos != MainCtrlPosNo) { // wejscie na bezoporowa - SetFlag(SoundFlag, sound::parallel | sound::loud); + SetFlag(SoundFlag, parallel | loud); } else if (RList[MainCtrlActualPos].R > 0 && RList[MainCtrlActualPos - 1].R == 0) { // wejscie na drugi uklad - SetFlag(SoundFlag, sound::parallel); + SetFlag(SoundFlag, parallel); } } } @@ -7028,7 +7028,7 @@ bool TMoverParameters::AutoRelayCheck(void) OK = true; if (RList[MainCtrlActualPos].R == 0) { - SetFlag(SoundFlag, sound::parallel); + SetFlag(SoundFlag, parallel); } } else if (LastRelayTime > CtrlDownDelay) @@ -7042,7 +7042,7 @@ bool TMoverParameters::AutoRelayCheck(void) if (RList[MainCtrlActualPos].R == 0) { // dzwieki schodzenia z bezoporowej} - SetFlag(SoundFlag, sound::parallel); + SetFlag(SoundFlag, parallel); } } } @@ -7051,7 +7051,7 @@ bool TMoverParameters::AutoRelayCheck(void) if (LastRelayTime > CtrlDownDelay) { --ScndCtrlActualPos; // boczniki nie dzialaja na poz. oporowych - SetFlag(SoundFlag, sound::shuntfield); + SetFlag(SoundFlag, shuntfield); OK = true; } } @@ -7072,7 +7072,7 @@ bool TMoverParameters::AutoRelayCheck(void) StLinFlag = true; MainCtrlActualPos = 1; DelayCtrlFlag = false; - SetFlag(SoundFlag, sound::relay | sound::loud); + SetFlag(SoundFlag, relay | loud); OK = true; } } @@ -7111,7 +7111,7 @@ bool TMoverParameters::AutoRelayCheck(void) { // potem boki ++ScndCtrlActualPos; - SetFlag(SoundFlag, sound::shuntfield); + SetFlag(SoundFlag, shuntfield); } else { @@ -7131,7 +7131,7 @@ bool TMoverParameters::AutoRelayCheck(void) if (ScndCtrlActualPos > 0) { --ScndCtrlActualPos; - SetFlag(SoundFlag, sound::shuntfield); + SetFlag(SoundFlag, shuntfield); } else { @@ -7238,7 +7238,7 @@ bool TMoverParameters::OperatePantographsValve(operation_t const State, range_t if (Notify != range_t::local) { - SendCtrlToNext("PantsValve", static_cast(State), CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("PantsValve", static_cast(State), CabActive, Notify == range_t::unit ? control | permanent : control); } return true; @@ -7300,8 +7300,8 @@ bool TMoverParameters::OperatePantographValve(end const End, operation_t const S SendCtrlToNext("PantValve", // HACK: pack the state, pantograph index and sender cab into 8-bit value // with high bit storing front/rear pantograph, and 7th bit storing sender cab - static_cast(0x80 * (End == end::front ? 0 : 1) + 0x40 * (CabActive != -1 ? 1 : 0) + static_cast(State)), CabActive, - Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + static_cast(0x80 * (End == front ? 0 : 1) + 0x40 * (CabActive != -1 ? 1 : 0) + static_cast(State)), CabActive, + Notify == range_t::unit ? control | permanent : control); } return true; @@ -7316,7 +7316,7 @@ bool TMoverParameters::DropAllPantographs(bool const State, range_t const Notify if (Notify != range_t::local) { - SendCtrlToNext("PantAllDown", State ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("PantAllDown", State ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return State != initialstate; @@ -7489,7 +7489,7 @@ void TMoverParameters::CheckEIMIC(double dt) auto const eimicpowerenabled{(true == Mains || Power == 0.0) && (!SpringBrake.IsActive || !SpringBrakeCutsOffDrive) && !LockPipe && DirAbsolute != 0}; auto const eimicdoorenabled{(SpringBrake.IsActive && ReleaseParkingBySpringBrakeWhenDoorIsOpen)}; double eimic_max = 0.0; - if (Doors.instances[side::left].open_permit == false && Doors.instances[side::right].open_permit == false) + if (Doors.instances[left].open_permit == false && Doors.instances[right].open_permit == false) { if (eimicpowerenabled) { @@ -8431,22 +8431,22 @@ bool TMoverParameters::AssignLoad(std::string const &Name, float const Amount) { if (DoubleTr == 1) { - OperatePantographValve(end::front, operation_t::enable, range_t::local); + OperatePantographValve(front, operation_t::enable, range_t::local); } else { - OperatePantographValve(end::rear, operation_t::enable, range_t::local); + OperatePantographValve(rear, operation_t::enable, range_t::local); } } if (pantographsetup & 1 << 1) { if (DoubleTr == 1) { - OperatePantographValve(end::rear, operation_t::enable, range_t::local); + OperatePantographValve(rear, operation_t::enable, range_t::local); } else { - OperatePantographValve(end::front, operation_t::enable, range_t::local); + OperatePantographValve(front, operation_t::enable, range_t::local); } } return true; @@ -8569,8 +8569,8 @@ bool TMoverParameters::ChangeDoorPermitPreset(int const Change, range_t const No auto const permitleft{((doors & 1) != 0)}; auto const permitright{((doors & 2) != 0)}; - PermitDoors(CabActive > 0 ? side::left : side::right, permitleft, Notify); - PermitDoors(CabActive > 0 ? side::right : side::left, permitright, Notify); + PermitDoors(CabActive > 0 ? left : right, permitleft, Notify); + PermitDoors(CabActive > 0 ? right : left, permitright, Notify); } return Doors.permit_preset != initialstate; @@ -8585,7 +8585,7 @@ bool TMoverParameters::PermitDoorStep(bool const State, range_t const Notify) if (Notify != range_t::local) { // wysłanie wyłączenia do pozostałych? - SendCtrlToNext("DoorStep", State == true ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("DoorStep", State == true ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return Doors.step_enabled != initialstate; @@ -8603,10 +8603,10 @@ bool TMoverParameters::PermitDoors(side const Door, bool const State, range_t co SendCtrlToNext("DoorPermit", (State ? 1 : -1) // positive: grant, negative: revoke - * (Door == (CabActive > 0 ? side::left : side::right) ? // 1=lewe, 2=prawe (swap if reversed) + * (Door == (CabActive > 0 ? left : right) ? // 1=lewe, 2=prawe (swap if reversed) 1 : 2), - CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + CabActive, Notify == range_t::unit ? control | permanent : control); } return Doors.instances[Door].open_permit != initialstate; @@ -8617,7 +8617,7 @@ void TMoverParameters::PermitDoors_(side const Door, bool const State) if (State && State != Doors.instances[Door].open_permit) { - SetFlag(SoundFlag, sound::doorpermit); + SetFlag(SoundFlag, doorpermit); } Doors.instances[Door].open_permit = State; } @@ -8631,15 +8631,15 @@ bool TMoverParameters::ChangeDoorControlMode(bool const State, range_t const Not if (Notify != range_t::local) { // wysłanie wyłączenia do pozostałych? - SendCtrlToNext("DoorMode", State == true ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("DoorMode", State == true ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } if (true == State) { // when door are put in remote control mode they're automatically open // TBD, TODO: make it dependant on config switch? - OperateDoors(side::left, true); - OperateDoors(side::right, true); + OperateDoors(left, true); + OperateDoors(right, true); } return Doors.remote_only != initialstate; @@ -8679,10 +8679,10 @@ bool TMoverParameters::OperateDoors(side const Door, bool const State, range_t c { SendCtrlToNext(State == true ? "DoorOpen" : "DoorClose", - Door == (CabActive > 0 ? side::left : side::right) ? // 1=lewe, 2=prawe (swap if reversed) + Door == (CabActive > 0 ? left : right) ? // 1=lewe, 2=prawe (swap if reversed) 1 : 2, - CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + CabActive, Notify == range_t::unit ? control | permanent : control); } return result; @@ -8698,7 +8698,7 @@ bool TMoverParameters::LockDoors(bool const State, range_t const Notify) if (Notify != range_t::local) { // wysłanie wyłączenia do pozostałych? - SendCtrlToNext("DoorLock", State == true ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("DoorLock", State == true ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return Doors.lock_enabled != initialstate; @@ -8718,7 +8718,7 @@ bool TMoverParameters::signal_departure(bool const State, range_t const Notify) if (Notify != range_t::local) { // wysłanie wyłączenia do pozostałych? - SendCtrlToNext("DepartureSignal", State == true ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control); + SendCtrlToNext("DepartureSignal", State == true ? 1 : 0, CabActive, Notify == range_t::unit ? control | permanent : control); } return true; @@ -8734,10 +8734,10 @@ void TMoverParameters::update_doors(double const Deltatime) } // HACK: crude way to distinguish vehicles with actual doors // NBMX Obsluga drzwi, MC: zuniwersalnione - auto const localopencontrol{false == Doors.remote_only && (Doors.open_control == control_t::passenger || Doors.open_control == control_t::mixed)}; - auto const remoteopencontrol{Doors.open_control == control_t::driver || Doors.open_control == control_t::conductor || Doors.open_control == control_t::mixed}; - auto const localclosecontrol{false == Doors.remote_only && (Doors.close_control == control_t::passenger || Doors.close_control == control_t::mixed)}; - auto const remoteclosecontrol{Doors.close_control == control_t::driver || Doors.close_control == control_t::conductor || Doors.close_control == control_t::mixed}; + auto const localopencontrol{false == Doors.remote_only && (Doors.open_control == passenger || Doors.open_control == mixed)}; + auto const remoteopencontrol{Doors.open_control == driver || Doors.open_control == conductor || Doors.open_control == mixed}; + auto const localclosecontrol{false == Doors.remote_only && (Doors.close_control == passenger || Doors.close_control == mixed)}; + auto const remoteclosecontrol{Doors.close_control == driver || Doors.close_control == conductor || Doors.close_control == mixed}; Doors.is_locked = true == Doors.has_lock && true == Doors.lock_enabled && Vel >= Doors.doorLockSpeed; @@ -8758,7 +8758,7 @@ void TMoverParameters::update_doors(double const Deltatime) door.local_close = door.local_close && false == door.is_closed && (false == remoteopencontrol || false == door.remote_open); door.remote_close = door.remote_close && false == door.is_closed && (false == localopencontrol || false == door.local_open); - auto const autoopenrequest{Doors.open_control == control_t::autonomous && (false == Doors.permit_needed || door.open_permit)}; + auto const autoopenrequest{Doors.open_control == autonomous && (false == Doors.permit_needed || door.open_permit)}; auto const openrequest{(localopencontrol && door.local_open) || (remoteopencontrol && door.remote_open) || (autoopenrequest && false == door.is_open)}; auto const autocloserequest{(Doors.auto_velocity != -1.f && Vel > Doors.auto_velocity) || (door.auto_timer != -1.f && door.auto_timer <= 0.f) || @@ -8828,7 +8828,7 @@ void TMoverParameters::update_doors(double const Deltatime) } } - if (false == Doors.instances[side::right].is_open && false == Doors.instances[side::left].is_open) + if (false == Doors.instances[right].is_open && false == Doors.instances[left].is_open) { return; } @@ -8971,7 +8971,7 @@ double TMoverParameters::GetTrainsetVoltage(int const Coupling) const { // ABu: funkcja zwracajaca napiecie dla calego skladu, przydatna dla EZT // TBD, TODO: call once per vehicle update, return cached results? double voltages[] = {0.0, 0.0}; - for (int end = end::front; end <= end::rear; ++end) + for (int end = front; end <= rear; ++end) { if (Couplers[end].Connected == nullptr) { @@ -8983,22 +8983,22 @@ double TMoverParameters::GetTrainsetVoltage(int const Coupling) const { continue; } - const auto *connectedpowercoupling = (Coupling & (coupling::highvoltage | coupling::heating)) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_high : - (Coupling & coupling::power110v) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_110v : - (Coupling & coupling::power24v) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_24v : + const auto *connectedpowercoupling = (Coupling & (highvoltage | heating)) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_high : + (Coupling & power110v) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_110v : + (Coupling & power24v) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_24v : nullptr; if (connectedpowercoupling != nullptr && connectedpowercoupling->is_live) { voltages[end] = connectedpowercoupling->voltage; } } - return std::max(voltages[end::front], voltages[end::rear]); + return std::max(voltages[front], voltages[rear]); } double TMoverParameters::GetTrainsetHighVoltage() const { - return std::max(GetTrainsetVoltage(coupling::highvoltage), HeatingAllow ? GetTrainsetVoltage(coupling::heating) : 0.0); + return std::max(GetTrainsetVoltage(highvoltage), HeatingAllow ? GetTrainsetVoltage(heating) : 0.0); } // ************************************************************************************************* @@ -10538,16 +10538,16 @@ void TMoverParameters::LoadFIZ_Doors(std::string const &line) { std::map doorcontrols{ - {"Passenger", control_t::passenger}, {"AutomaticCtrl", control_t::autonomous}, {"DriverCtrl", control_t::driver}, {"Conductor", control_t::conductor}, {"Mixed", control_t::mixed}}; + {"Passenger", passenger}, {"AutomaticCtrl", autonomous}, {"DriverCtrl", driver}, {"Conductor", conductor}, {"Mixed", mixed}}; // opening method { const auto lookup = doorcontrols.find(extract_value("OpenCtrl", line)); - Doors.open_control = lookup != doorcontrols.end() ? lookup->second : control_t::passenger; + Doors.open_control = lookup != doorcontrols.end() ? lookup->second : passenger; } // closing method { const auto lookup = doorcontrols.find(extract_value("CloseCtrl", line)); - Doors.close_control = lookup != doorcontrols.end() ? lookup->second : control_t::passenger; + Doors.close_control = lookup != doorcontrols.end() ? lookup->second : passenger; } // automatic closing conditions extract_value(Doors.auto_duration, "DoorStayOpen", line, ""); @@ -10594,7 +10594,7 @@ void TMoverParameters::LoadFIZ_Doors(std::string const &line) extract_value(Doors.has_lock, "DoorBlocked", line, ""); extract_value(Doors.doorLockSpeed, "DoorLockSpeed", line, ""); { - auto const remotedoorcontrol{Doors.open_control == control_t::driver || Doors.open_control == control_t::conductor || Doors.open_control == control_t::mixed}; + auto const remotedoorcontrol{Doors.open_control == driver || Doors.open_control == conductor || Doors.open_control == mixed}; extract_value(Doors.voltage, "DoorVoltage", line, remotedoorcontrol ? "24" : "0"); } @@ -10646,7 +10646,7 @@ void TMoverParameters::LoadFIZ_BuffCoupl(std::string const &line, int const Inde extract_value(coupler->AllowedFlag, "AllowedFlag", line, ""); if (coupler->AllowedFlag < 0) { - coupler->AllowedFlag = -coupler->AllowedFlag | coupling::permanent; + coupler->AllowedFlag = -coupler->AllowedFlag | permanent; } extract_value(coupler->PowerCoupling, "PowerCoupling", line, ""); extract_value(coupler->PowerFlag, "PowerFlag", line, ""); @@ -10963,7 +10963,7 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line) // traction motor fans { auto lookup = starts.find(extract_value("MotorBlowersStart", line)); - MotorBlowers[end::front].start_type = MotorBlowers[end::rear].start_type = lookup != starts.end() ? lookup->second : start_t::manual; + MotorBlowers[front].start_type = MotorBlowers[rear].start_type = lookup != starts.end() ? lookup->second : start_t::manual; } // compartment lights { @@ -11360,10 +11360,10 @@ void TMoverParameters::LoadFIZ_Engine(std::string const &Input) } // traction motors - extract_value(MotorBlowers[end::front].speed, "MotorBlowersSpeed", Input, ""); - extract_value(MotorBlowers[end::front].sustain_time, "MotorBlowersSustainTime", Input, ""); - extract_value(MotorBlowers[end::front].min_start_velocity, "MotorBlowersStartVelocity", Input, ""); - MotorBlowers[end::rear] = MotorBlowers[end::front]; + extract_value(MotorBlowers[front].speed, "MotorBlowersSpeed", Input, ""); + extract_value(MotorBlowers[front].sustain_time, "MotorBlowersSustainTime", Input, ""); + extract_value(MotorBlowers[front].min_start_velocity, "MotorBlowersStartVelocity", Input, ""); + MotorBlowers[rear] = MotorBlowers[front]; // pressure switch extract_value(HasControlPressureSwitch, "PressureSwitch", Input, TrainType != dt_EZT ? "yes" : "no"); } @@ -11607,13 +11607,13 @@ void TMoverParameters::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparamete std::string PantType = ""; extract_value(PantType, "PantType", Line, ""); if (PantType == "AKP_4E") - collectorparameters.PantographType = TPantType::AKP_4E; + collectorparameters.PantographType = AKP_4E; if (PantType.size() >= 3 && PantType.compare(0, 3, "DSA") == 0) - collectorparameters.PantographType = TPantType::DSAx; + collectorparameters.PantographType = DSAx; if (PantType == "EC160" || PantType == "EC200") - collectorparameters.PantographType = TPantType::EC160_200; + collectorparameters.PantographType = EC160_200; if (PantType == "WBL85") - collectorparameters.PantographType = TPantType::WBL85; + collectorparameters.PantographType = WBL85; extract_value(collectorparameters.CollectorsNo, "CollectorsNo", Line, ""); extract_value(collectorparameters.MinH, "MinH", Line, ""); @@ -11949,8 +11949,8 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) WriteLog("Ready to depart"); CompressedVolume = VeselVolume * MinCompressor * 9.8 / 10.0; ScndPipePress = VeselVolume > 0.0 ? CompressedVolume / VeselVolume : - (Couplers[end::front].AllowedFlag & coupling::mainhose) != 0 ? 5.0 : - (Couplers[end::rear].AllowedFlag & coupling::mainhose) != 0 ? 5.0 : + (Couplers[front].AllowedFlag & mainhose) != 0 ? 5.0 : + (Couplers[rear].AllowedFlag & mainhose) != 0 ? 5.0 : 0.0; PipePress = CntrlPipePress; BrakePress = 0.0; @@ -11981,8 +11981,8 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) ScndPipePress = 5.1; */ ScndPipePress = VeselVolume > 0.0 ? CompressedVolume / VeselVolume : - (Couplers[end::front].AllowedFlag & coupling::mainhose) != 0 ? 5.1 : - (Couplers[end::rear].AllowedFlag & coupling::mainhose) != 0 ? 5.1 : + (Couplers[front].AllowedFlag & mainhose) != 0 ? 5.1 : + (Couplers[rear].AllowedFlag & mainhose) != 0 ? 5.1 : 0.0; PipePress = LowPipePress; PipeBrakePress = MaxBrakePress[3] * 0.5; @@ -12352,37 +12352,37 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV } else if (Command == "MotorBlowersFrontSwitch") { - if (MotorBlowers[end::front].start_type != start_t::manual && MotorBlowers[end::front].start_type != start_t::manualwithautofallback) + if (MotorBlowers[front].start_type != start_t::manual && MotorBlowers[front].start_type != start_t::manualwithautofallback) { // automatic device ignores 'manual' state commands - MotorBlowers[end::front].is_enabled = CValue1 == 1; + MotorBlowers[front].is_enabled = CValue1 == 1; } OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } else if (Command == "MotorBlowersFrontSwitchOff") { - if (MotorBlowers[end::front].start_type != start_t::manual && MotorBlowers[end::front].start_type != start_t::manualwithautofallback) + if (MotorBlowers[front].start_type != start_t::manual && MotorBlowers[front].start_type != start_t::manualwithautofallback) { // automatic device ignores 'manual' state commands - MotorBlowers[end::front].is_disabled = CValue1 == 1; + MotorBlowers[front].is_disabled = CValue1 == 1; } OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } else if (Command == "MotorBlowersRearSwitch") { - if (MotorBlowers[end::rear].start_type != start_t::manual && MotorBlowers[end::rear].start_type != start_t::manualwithautofallback) + if (MotorBlowers[rear].start_type != start_t::manual && MotorBlowers[rear].start_type != start_t::manualwithautofallback) { // automatic device ignores 'manual' state commands - MotorBlowers[end::rear].is_enabled = CValue1 == 1; + MotorBlowers[rear].is_enabled = CValue1 == 1; } OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } else if (Command == "MotorBlowersRearSwitchOff") { - if (MotorBlowers[end::rear].start_type != start_t::manual && MotorBlowers[end::rear].start_type != start_t::manualwithautofallback) + if (MotorBlowers[rear].start_type != start_t::manual && MotorBlowers[rear].start_type != start_t::manualwithautofallback) { // automatic device ignores 'manual' state commands - MotorBlowers[end::rear].is_disabled = CValue1 == 1; + MotorBlowers[rear].is_disabled = CValue1 == 1; } OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } @@ -12511,7 +12511,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV } else if (Command == "DoorOpen") /*NBMX*/ { // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów - if (Doors.open_control == control_t::conductor || Doors.open_control == control_t::driver || Doors.open_control == control_t::mixed) + if (Doors.open_control == conductor || Doors.open_control == driver || Doors.open_control == mixed) { // ignore remote command if the door is only operated locally if (Power24vIsAvailable || Power110vIsAvailable) @@ -12536,7 +12536,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV } else if (Command == "DoorClose") /*NBMX*/ { // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów - if (Doors.close_control == control_t::conductor || Doors.close_control == control_t::driver || Doors.close_control == control_t::mixed) + if (Doors.close_control == conductor || Doors.close_control == driver || Doors.close_control == mixed) { // ignore remote command if the door is only operated locally if (Power24vIsAvailable || Power110vIsAvailable) @@ -12585,7 +12585,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV auto const inputcab{(static_cast(CValue1) & 0x40) != 0 ? 1 : 0}; auto const inputoperation{static_cast(CValue1) & ~(0x80 | 0x40)}; auto const noswap{TrainType == dt_EZT || TrainType == dt_ET41}; - auto swap{false == noswap && TestFlag(Couplers[(CValue2 == -1 ? end::rear : end::front)].CouplingFlag, coupling::control)}; + auto swap{false == noswap && TestFlag(Couplers[(CValue2 == -1 ? rear : front)].CouplingFlag, control)}; auto const reversed{inputcab != (CabActive != -1 ? 1 : 0)}; if (reversed) { @@ -12778,7 +12778,7 @@ double TMoverParameters::ShowCurrentP(int AmpN) const int current = 0; for (b = 0; b < 2; b++) // with Couplers[b] do - if (TestFlag(Couplers[b].CouplingFlag, coupling::control)) + if (TestFlag(Couplers[b].CouplingFlag, control)) if (Couplers[b].Connected->Power > 0.01) current = static_cast(Couplers[b].Connected->ShowCurrent(AmpN)); return current; diff --git a/McZapkie/hamulce.cpp b/McZapkie/hamulce.cpp index 8009474a..c06aa7ba 100644 --- a/McZapkie/hamulce.cpp +++ b/McZapkie/hamulce.cpp @@ -1715,7 +1715,7 @@ double TLSt::GetPF(double const PP, double const dt, double const Vel) SoundFlag |= sf_CylU; } // equivalent of checkreleaser() in the base class? - const bool is_releasing = BrakeStatus & b_rls || UniversalFlag & TUniversalBrake::ub_Release; + const bool is_releasing = BrakeStatus & b_rls || UniversalFlag & ub_Release; if (is_releasing) { if (CVP < 0.0) @@ -1779,7 +1779,7 @@ double TLSt::GetPF(double const PP, double const dt, double const Vel) if (EDFlag > 0.2) temp = 10000; double tempasb = 0; - if ((UniversalFlag & TUniversalBrake::ub_AntiSlipBrake) > 0 || (BrakeStatus & b_asb_unbrake) == b_asb_unbrake) + if ((UniversalFlag & ub_AntiSlipBrake) > 0 || (BrakeStatus & b_asb_unbrake) == b_asb_unbrake) tempasb = ASBP; // powtarzacz — podwojny zawor zwrotny temp = std::max(((CVP - BCP) * BVM + tempasb) / temp, LBP); @@ -2001,7 +2001,7 @@ double TEStED::GetPF(double const PP, double const dt, double const Vel) // powtarzacz — podwojny zawor zwrotny temp = std::max(LoadC * BCP / temp * std::clamp(1 - EDFlag, 0., 1.), LBP); - if ((UniversalFlag & TUniversalBrake::ub_AntiSlipBrake) > 0) + if ((UniversalFlag & ub_AntiSlipBrake) > 0) temp = std::max(temp, ASBP); double speed = 1; @@ -3304,7 +3304,7 @@ double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep ActFlowSpeed = 4; double uop = UnbrakeOverPressure; // unbrake over pressure in actual state - ManualOvrldActive = UniversalFlag & TUniversalBrake::ub_HighPressure; // button is pressed + ManualOvrldActive = UniversalFlag & ub_HighPressure; // button is pressed if (ManualOvrld && !ManualOvrldActive) // no overpressure for not pressed button if it does not exists uop = 0; @@ -3329,7 +3329,7 @@ double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep else dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4); - if ((EQ(i_bcp, -1) && AutoOvrld) || (i_bcp < 0.5 && UniversalFlag & TUniversalBrake::ub_Overload)) + if ((EQ(i_bcp, -1) && AutoOvrld) || (i_bcp < 0.5 && UniversalFlag & ub_Overload)) { if (TP < 5) TP = TP + dt; // 5/10 @@ -3522,7 +3522,7 @@ double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep) CP = CP + 9 * std::min(abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy double uop = UnbrakeOverPressure; // unbrake over pressure in actual state - ManualOvrldActive = UniversalFlag & TUniversalBrake::ub_HighPressure; // button is pressed + ManualOvrldActive = UniversalFlag & ub_HighPressure; // button is pressed if (ManualOvrld && !ManualOvrldActive) // no overpressure for not pressed button if it does not exists uop = 0; @@ -3546,7 +3546,7 @@ double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep) else dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4); - if ((EQ(i_bcp, -1) && AutoOvrld) || (i_bcp < 0.5 && UniversalFlag & TUniversalBrake::ub_Overload)) + if ((EQ(i_bcp, -1) && AutoOvrld) || (i_bcp < 0.5 && UniversalFlag & ub_Overload)) { if (TP < OverloadMaxPressure) TP = TP + 0.03 * dt; @@ -3707,7 +3707,7 @@ double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep) dpPipe = std::min(HP, CP + TP + RedAdj); double uop = UnbrakeOverPressure; // unbrake over pressure in actual state - ManualOvrldActive = UniversalFlag & TUniversalBrake::ub_HighPressure; // button is pressed + ManualOvrldActive = UniversalFlag & ub_HighPressure; // button is pressed if (ManualOvrld && !ManualOvrldActive) // no overpressure for not pressed button if it does not exists uop = 0; @@ -3729,7 +3729,7 @@ double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep) else dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4); - if ((EQ(i_bcp, -1) && AutoOvrld) || (i_bcp < 0.5 && UniversalFlag & TUniversalBrake::ub_Overload)) + if ((EQ(i_bcp, -1) && AutoOvrld) || (i_bcp < 0.5 && UniversalFlag & ub_Overload)) { if (TP < OverloadMaxPressure) TP = TP + 0.03 * dt; diff --git a/application/application.cpp b/application/application.cpp index 9c469ac6..150f0c30 100644 --- a/application/application.cpp +++ b/application/application.cpp @@ -222,7 +222,7 @@ void eu07_application::DiscordRPCService() while (!glfwWindowShouldClose(m_windows.front()) && !m_modestack.empty() && !Global.applicationQuitOrder) { const auto currentMode = m_modestack.top(); - if (currentMode == mode::launcher) + if (currentMode == launcher) { // in launcher mode @@ -236,7 +236,7 @@ void eu07_application::DiscordRPCService() std::this_thread::sleep_for(std::chrono::milliseconds(5000)); // update RPC every 5 secs continue; } - else if (currentMode == mode::scenarioloader) + else if (currentMode == scenarioloader) { std::string rpcScnName = Global.SceneryFile; if (rpcScnName[0] == '$') @@ -261,7 +261,7 @@ void eu07_application::DiscordRPCService() continue; } - if (currentMode != mode::driver) + if (currentMode != driver) continue; // Discord RPC updater @@ -1009,7 +1009,7 @@ void eu07_application::init_debug() void eu07_application::init_console() { #ifdef _WIN32 - HWND consoleWnd = ::GetConsoleWindow(); + HWND consoleWnd = GetConsoleWindow(); const bool hadConsole = consoleWnd != nullptr; if (Global.ShowSystemConsole) @@ -1019,7 +1019,7 @@ void eu07_application::init_console() // no console inherited (e.g. WINDOWS subsystem build, or launched // detached) -- create one and wire stdio to it so printf in // utilities/Logs.cpp actually reaches the user - if (::AllocConsole()) + if (AllocConsole()) { FILE *fp = nullptr; freopen_s(&fp, "CONOUT$", "w", stdout); @@ -1031,7 +1031,7 @@ void eu07_application::init_console() std::cerr.clear(); std::clog.clear(); std::cin.clear(); - consoleWnd = ::GetConsoleWindow(); + consoleWnd = GetConsoleWindow(); } } @@ -1047,7 +1047,7 @@ void eu07_application::init_console() // as text ("←[32m" etc). Open CONOUT$ directly to get the real screen // buffer handle, then flip VT on it. auto enable_vt = [](const char *devName) { - const HANDLE h = ::CreateFileA( + const HANDLE h = CreateFileA( devName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, @@ -1058,11 +1058,11 @@ void eu07_application::init_console() if (h == INVALID_HANDLE_VALUE) return; DWORD mode = 0; - if (::GetConsoleMode(h, &mode)) + if (GetConsoleMode(h, &mode)) { - ::SetConsoleMode(h, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING | ENABLE_PROCESSED_OUTPUT); + SetConsoleMode(h, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING | ENABLE_PROCESSED_OUTPUT); } - ::CloseHandle(h); + CloseHandle(h); }; // CONOUT$ is the console's active screen buffer; enabling VT on it // affects everything that ends up being written there, regardless of @@ -1071,9 +1071,9 @@ void eu07_application::init_console() if (consoleWnd) { - ::ShowWindow(consoleWnd, SW_SHOW); + ShowWindow(consoleWnd, SW_SHOW); // give the console a recognisable title - ::SetConsoleTitleA("MaSzyna log"); + SetConsoleTitleA("MaSzyna log"); } } else @@ -1081,7 +1081,7 @@ void eu07_application::init_console() // user wants no console window -- hide whatever we have if (consoleWnd) { - ::ShowWindow(consoleWnd, SW_HIDE); + ShowWindow(consoleWnd, SW_HIDE); } // if we'd allocated one ourselves on a previous run path we'd FreeConsole here, // but on first init the console (if any) was inherited from the launcher and @@ -1298,7 +1298,7 @@ int eu07_application::init_glfw() Hwnd = glfwGetWin32Window(mainwindow); BaseWindowProc = (WNDPROC)::SetWindowLongPtr(Hwnd, GWLP_WNDPROC, (LONG_PTR)WndProc); // switch off the topmost flag - ::SetWindowPos(Hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + SetWindowPos(Hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); #endif return 0; @@ -1431,9 +1431,9 @@ int eu07_application::init_modes() // activate the default mode if (Global.SceneryFile.empty()) - push_mode(mode::launcher); + push_mode(launcher); else - push_mode(mode::scenarioloader); + push_mode(scenarioloader); return 0; } diff --git a/application/application.h b/application/application.h index 11415603..8f611597 100644 --- a/application/application.h +++ b/application/application.h @@ -59,7 +59,7 @@ public: bool pop_mode(); bool - push_mode( eu07_application::mode const Mode ); + push_mode( mode const Mode ); void set_title( std::string const &Title ); void @@ -96,7 +96,7 @@ public: private: // types - using modeptr_array = std::array, static_cast( mode::count_ )>; + using modeptr_array = std::array, static_cast( count_ )>; using mode_stack = std::stack; // methods bool needs_ogl() const; diff --git a/application/driverhints.cpp b/application/driverhints.cpp index afa654cf..5d207472 100644 --- a/application/driverhints.cpp +++ b/application/driverhints.cpp @@ -268,48 +268,48 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::frontpantographvalveon: { if( AIControllFlag ) { - mvOccupied->OperatePantographValve( end::front, operation_t::enable ); + mvOccupied->OperatePantographValve( front, operation_t::enable ); } remove_hint( driver_hint::frontpantographvalveoff ); hint( Action, [ this ]( float const Parameter ) -> bool { - return mvPantographUnit->Pantographs[end::front].valve.is_active == true || (Parameter > 0 && mvOccupied->Vel > Parameter); }, + return mvPantographUnit->Pantographs[front].valve.is_active == true || (Parameter > 0 && mvOccupied->Vel > Parameter); }, Actionparameter ); break; } case driver_hint::frontpantographvalveoff: { if( AIControllFlag ) { - mvOccupied->OperatePantographValve( end::front, operation_t::disable ); + mvOccupied->OperatePantographValve( front, operation_t::disable ); } remove_hint( driver_hint::frontpantographvalveon ); hint( Action, [this](float const Parameter) -> bool { - return mvPantographUnit->Pantographs[end::front].valve.is_active == false; } ); + return mvPantographUnit->Pantographs[front].valve.is_active == false; } ); break; } case driver_hint::rearpantographvalveon: { if( AIControllFlag ) { - mvOccupied->OperatePantographValve( end::rear, operation_t::enable ); + mvOccupied->OperatePantographValve( rear, operation_t::enable ); } remove_hint( driver_hint::rearpantographvalveoff ); hint( Action, [ this ]( float const Parameter ) -> bool { - return mvPantographUnit->Pantographs[end::rear].valve.is_active == true || (Parameter > 0 && mvOccupied->Vel > Parameter); }, + return mvPantographUnit->Pantographs[rear].valve.is_active == true || (Parameter > 0 && mvOccupied->Vel > Parameter); }, Actionparameter ); break; } case driver_hint::rearpantographvalveoff: { if( AIControllFlag ) { - mvOccupied->OperatePantographValve( end::rear, operation_t::disable ); + mvOccupied->OperatePantographValve( rear, operation_t::disable ); } remove_hint( driver_hint::rearpantographvalveon ); hint( Action, [this](float const Parameter) -> bool { - return mvPantographUnit->Pantographs[end::rear].valve.is_active == false; } ); + return mvPantographUnit->Pantographs[rear].valve.is_active == false; } ); break; } // converter @@ -338,7 +338,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) // relays case driver_hint::primaryconverteroverloadreset: { if( AIControllFlag ) { - mvOccupied->RelayReset( relay_t::primaryconverteroverload ); + mvOccupied->RelayReset( primaryconverteroverload ); } hint( Action, @@ -348,7 +348,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::maincircuitgroundreset: { if( AIControllFlag ) { - mvOccupied->RelayReset( relay_t::maincircuitground ); + mvOccupied->RelayReset( maincircuitground ); } hint( Action, @@ -358,7 +358,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::tractionnmotoroverloadreset: { if( AIControllFlag ) { - mvOccupied->RelayReset( relay_t::tractionnmotoroverload ); + mvOccupied->RelayReset( tractionnmotoroverload ); } hint( Action, @@ -415,27 +415,27 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::frontmotorblowerson: { if( AIControllFlag ) { - mvOccupied->MotorBlowersSwitchOff( false, end::front ); - mvOccupied->MotorBlowersSwitch( true, end::front ); + mvOccupied->MotorBlowersSwitchOff( false, front ); + mvOccupied->MotorBlowersSwitch( true, front ); } remove_hint( driver_hint::frontmotorblowersoff ); hint( Action, [this]( float const Parameter ) -> bool { - auto const &device { mvOccupied->MotorBlowers[ end::front ] }; + auto const &device { mvOccupied->MotorBlowers[ front ] }; return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false); } ); break; } case driver_hint::rearmotorblowerson: { if( AIControllFlag ) { - mvOccupied->MotorBlowersSwitchOff( false, end::rear ); - mvOccupied->MotorBlowersSwitch( true, end::rear ); + mvOccupied->MotorBlowersSwitchOff( false, rear ); + mvOccupied->MotorBlowersSwitch( true, rear ); } remove_hint( driver_hint::rearmotorblowersoff ); hint( Action, [this]( float const Parameter ) -> bool { - auto const &device { mvOccupied->MotorBlowers[ end::rear ] }; + auto const &device { mvOccupied->MotorBlowers[ rear ] }; return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false); } ); break; } @@ -1049,94 +1049,94 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) // consist doors case driver_hint::doorrightopen: { if( AIControllFlag - || pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) { - pVehicle->MoverParameters->OperateDoors( side::right, true ); + || pVehicle->MoverParameters->Doors.open_control == conductor ) { + pVehicle->MoverParameters->OperateDoors( right, true ); } remove_hint( driver_hint::doorrightclose ); hint( Action, [this](float const Parameter) -> bool { - return IsAnyDoorOpen[side::right] == true; } ); + return IsAnyDoorOpen[right] == true; } ); break; } case driver_hint::doorrightclose: { if( AIControllFlag - || pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) { - pVehicle->MoverParameters->OperateDoors( side::right, false ); + || pVehicle->MoverParameters->Doors.open_control == conductor ) { + pVehicle->MoverParameters->OperateDoors( right, false ); } remove_hint( driver_hint::doorrightopen ); hint( Action, [this](float const Parameter) -> bool { - return IsAnyDoorOpen[side::right] == false; } ); + return IsAnyDoorOpen[right] == false; } ); break; } case driver_hint::doorleftopen: { if( AIControllFlag - || pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) { - pVehicle->MoverParameters->OperateDoors( side::left, true ); + || pVehicle->MoverParameters->Doors.open_control == conductor ) { + pVehicle->MoverParameters->OperateDoors( left, true ); } remove_hint( driver_hint::doorleftclose ); hint( Action, [this](float const Parameter) -> bool { - return IsAnyDoorOpen[side::left] == true; } ); + return IsAnyDoorOpen[left] == true; } ); break; } case driver_hint::doorleftclose: { if( AIControllFlag - || pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) { - pVehicle->MoverParameters->OperateDoors( side::left, false ); + || pVehicle->MoverParameters->Doors.open_control == conductor ) { + pVehicle->MoverParameters->OperateDoors( left, false ); } remove_hint( driver_hint::doorleftopen ); hint( Action, [this](float const Parameter) -> bool { - return IsAnyDoorOpen[side::left] == false; } ); + return IsAnyDoorOpen[left] == false; } ); break; } case driver_hint::doorrightpermiton: { if( AIControllFlag ) { - pVehicle->MoverParameters->PermitDoors( side::right, true ); + pVehicle->MoverParameters->PermitDoors( right, true ); } remove_hint( driver_hint::doorrightpermitoff ); hint( Action, [this](float const Parameter) -> bool { - return IsAnyDoorPermitActive[side::right] == true; } ); + return IsAnyDoorPermitActive[right] == true; } ); break; } case driver_hint::doorrightpermitoff: { if( AIControllFlag ) { - pVehicle->MoverParameters->PermitDoors( side::right, false ); + pVehicle->MoverParameters->PermitDoors( right, false ); } remove_hint( driver_hint::doorrightpermiton ); hint( Action, [this](float const Parameter) -> bool { - return IsAnyDoorPermitActive[side::right] == false; } ); + return IsAnyDoorPermitActive[right] == false; } ); break; } case driver_hint::doorleftpermiton: { if( AIControllFlag ) { - pVehicle->MoverParameters->PermitDoors( side::left, true ); + pVehicle->MoverParameters->PermitDoors( left, true ); } remove_hint( driver_hint::doorleftpermitoff ); hint( Action, [this](float const Parameter) -> bool { - return IsAnyDoorPermitActive[side::left] == true; } ); + return IsAnyDoorPermitActive[left] == true; } ); break; } case driver_hint::doorleftpermitoff: { if( AIControllFlag ) { - pVehicle->MoverParameters->PermitDoors( side::left, false ); + pVehicle->MoverParameters->PermitDoors( left, false ); } remove_hint( driver_hint::doorleftpermiton ); hint( Action, [this](float const Parameter) -> bool { - return IsAnyDoorPermitActive[side::left] == false; } ); + return IsAnyDoorPermitActive[left] == false; } ); break; } // consist lights @@ -1215,30 +1215,30 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) case driver_hint::couplingadapterattach: { // TODO: run also for potential settings-based virtual assistant if( AIControllFlag ) { - pVehicles[ end::front ]->attach_coupler_adapter( Actionparameter ); + pVehicles[ front ]->attach_coupler_adapter( Actionparameter ); } hint( Action, [this](float const Parameter) -> bool { - auto const &device { pVehicles[ end::front ]->MoverParameters->Couplers[ static_cast( Parameter ) ] }; + auto const &device { pVehicles[ front ]->MoverParameters->Couplers[ static_cast( Parameter ) ] }; return device.type() == TCouplerType::Automatic; } ); break; } case driver_hint::couplingadapterremove: { if( AIControllFlag || Global.AITrainman ) { - pVehicles[ end::front ]->remove_coupler_adapter( Actionparameter ); + pVehicles[ front ]->remove_coupler_adapter( Actionparameter ); } hint( Action, [this](float const Parameter) -> bool { - auto const &device { pVehicles[ end::front ]->MoverParameters->Couplers[ static_cast( Parameter ) ] }; + auto const &device { pVehicles[ front ]->MoverParameters->Couplers[ static_cast( Parameter ) ] }; return false == device.has_adapter(); } ); break; } // lights case driver_hint::headcodepc1: { if( AIControllFlag ) { - pVehicles[ end::front ]->RaLightsSet( light::headlight_left | light::headlight_right | light::headlight_upper, -1 ); + pVehicles[ front ]->RaLightsSet( headlight_left | headlight_right | headlight_upper, -1 ); } remove_hint( driver_hint::headcodepc2 ); remove_hint( driver_hint::headcodetb1 ); @@ -1246,12 +1246,12 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const Parameter) -> bool { - return pVehicles[end::front]->has_signal_pc1_on(); } ); + return pVehicles[front]->has_signal_pc1_on(); } ); break; } case driver_hint::headcodepc2: { if( AIControllFlag ) { - pVehicles[ end::front ]->RaLightsSet( light::redmarker_left | light::headlight_right | light::headlight_upper, -1 ); + pVehicles[ front ]->RaLightsSet( redmarker_left | headlight_right | headlight_upper, -1 ); } remove_hint( driver_hint::headcodepc1 ); remove_hint( driver_hint::headcodetb1 ); @@ -1259,15 +1259,15 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const Parameter) -> bool { - return pVehicles[end::front]->has_signal_pc2_on(); } ); + return pVehicles[front]->has_signal_pc2_on(); } ); break; } case driver_hint::headcodetb1: { // HACK: the 'front' and 'rear' of the consist is determined by current consist direction // since direction shouldn't affect Tb1 light configuration, we 'counter' this behaviour by virtually swapping end vehicles if( AIControllFlag ) { - if( mvOccupied->DirActive >= 0 ) { Lights( light::headlight_right, light::headlight_left ); } - else { Lights( light::headlight_left, light::headlight_right ); } + if( mvOccupied->DirActive >= 0 ) { Lights( headlight_right, headlight_left ); } + else { Lights( headlight_left, headlight_right ); } } remove_hint( driver_hint::headcodepc1 ); remove_hint( driver_hint::headcodepc2 ); @@ -1276,22 +1276,22 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const Parameter) -> bool { - auto const activeend { mvOccupied->CabActive >= 0 ? end::front : end::rear }; - auto const consistfront { mvOccupied->DirActive >= 0 ? end::front : end::rear }; - return pVehicles[consistfront]->has_signal_on(activeend, light::headlight_right) && pVehicles[1 - consistfront]->has_signal_on(1 - activeend, light::headlight_left); } ); + auto const activeend { mvOccupied->CabActive >= 0 ? front : rear }; + auto const consistfront { mvOccupied->DirActive >= 0 ? front : rear }; + return pVehicles[consistfront]->has_signal_on(activeend, headlight_right) && pVehicles[1 - consistfront]->has_signal_on(1 - activeend, headlight_left); } ); break; } case driver_hint::headcodepc5: { if( AIControllFlag - || ( Global.AITrainman && false == pVehicles[end::rear]->is_connected(pVehicle, coupling::control) ) ) { - pVehicles[ end::rear ]->RaLightsSet( -1, light::redmarker_left | light::redmarker_right | light::rearendsignals ); + || ( Global.AITrainman && false == pVehicles[rear]->is_connected(pVehicle, control) ) ) { + pVehicles[ rear ]->RaLightsSet( -1, redmarker_left | redmarker_right | rearendsignals ); } remove_hint( driver_hint::headcodetb1 ); remove_hint( driver_hint::lightsoff ); hint( Action, [this](float const Parameter) -> bool { - return pVehicles[end::rear]->has_signal_pc5_on(); } ); + return pVehicles[rear]->has_signal_pc5_on(); } ); break; } case driver_hint::lightsoff: { @@ -1305,8 +1305,8 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const Parameter) -> bool { - auto const activeend { mvOccupied->CabActive >= 0 ? end::front : end::rear }; - auto const consistfront { mvOccupied->DirActive >= 0 ? end::front : end::rear }; + auto const activeend { mvOccupied->CabActive >= 0 ? front : rear }; + auto const consistfront { mvOccupied->DirActive >= 0 ? front : rear }; return pVehicles[consistfront]->has_signal_on(activeend, 0) && pVehicles[1 - consistfront]->has_signal_on(1 - activeend, 0); } ); break; } diff --git a/application/drivermode.cpp b/application/drivermode.cpp index bb051ad5..98b80f04 100644 --- a/application/drivermode.cpp +++ b/application/drivermode.cpp @@ -1087,7 +1087,7 @@ void driver_mode::ExternalView() if (true == m_externalview) { // we're already in some external view mode, so select next one on the list - m_externalviewmode = clamp_circular(++m_externalviewmode, static_cast(view::count_)); + m_externalviewmode = clamp_circular(++m_externalviewmode, static_cast(count_)); } FreeFlyModeFlag = true; @@ -1097,10 +1097,10 @@ void driver_mode::ExternalView() // configure camera placement for the selected view mode switch (m_externalviewmode) { - case view::consistfront: + case consistfront: { // bind camera with the vehicle - auto *owner{vehicle->Mechanik->Vehicle(end::front)}; + auto *owner{vehicle->Mechanik->Vehicle(front)}; Camera.m_owner = owner; @@ -1127,10 +1127,10 @@ void driver_mode::ExternalView() break; } - case view::consistrear: + case consistrear: { // bind camera with the vehicle - auto *owner{vehicle->Mechanik->Vehicle(end::rear)}; + auto *owner{vehicle->Mechanik->Vehicle(rear)}; Camera.m_owner = owner; @@ -1156,9 +1156,9 @@ void driver_mode::ExternalView() Camera.Angle.z = shakeangles.first; // hustanie kamery na boki break; } - case view::bogie: + case bogie: { - auto *owner{vehicle->Mechanik->Vehicle(end::front)}; + auto *owner{vehicle->Mechanik->Vehicle(front)}; Camera.m_owner = owner; @@ -1185,7 +1185,7 @@ void driver_mode::ExternalView() break; } - case view::driveby: + case driveby: { DistantView(false); break; diff --git a/application/drivermode.h b/application/drivermode.h index 66ff6936..f1ce888b 100644 --- a/application/drivermode.h +++ b/application/drivermode.h @@ -104,9 +104,9 @@ private: std::array KeyEvents { nullptr }; // eventy wyzwalane z klawiaury TCamera Camera; TCamera DebugCamera; - int m_externalviewmode { view::consistfront }; // selected external view mode + int m_externalviewmode { consistfront }; // selected external view mode bool m_externalview { true }; - std::array m_externalviewconfigs; + std::array m_externalviewconfigs; TDynamicObject *pDynamicNearest { nullptr }; // vehicle nearest to the active camera. TODO: move to camera double fTime50Hz { 0.0 }; // bufor czasu dla komunikacji z PoKeys double const m_primaryupdaterate { 1.0 / 100.0 }; diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index 97bd91fb..ff6bf916 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -364,9 +364,9 @@ timetable_panel::update() { //odejmij lokomotywy czynne, a przynajmniej aktualną consistmass -= owner->pVehicle->MoverParameters->TotalMass; // subtract potential other half of a two-part vehicle - auto const *previous { owner->pVehicle->Prev( coupling::permanent ) }; + auto const *previous { owner->pVehicle->Prev( permanent ) }; if( previous != nullptr ) { consistmass -= previous->MoverParameters->TotalMass; } - auto const *next { owner->pVehicle->Next( coupling::permanent ) }; + auto const *next { owner->pVehicle->Next( permanent ) }; if( next != nullptr ) { consistmass -= next->MoverParameters->TotalMass; } } std::snprintf( @@ -781,8 +781,8 @@ debug_panel::update_section_vehicle( std::vector &Output ) { mover.EngineDescription( 0 ).c_str(), // TODO: put wheel flat reporting in the enginedescription() std::string( mover.WheelFlat > 0.01 ? " Flat: " + to_string( mover.WheelFlat, 1 ) + " mm" : "" ).c_str(), - update_vehicle_coupler( end::front ).c_str(), - update_vehicle_coupler( end::rear ).c_str() ); + update_vehicle_coupler( front ).c_str(), + update_vehicle_coupler( rear ).c_str() ); Output.emplace_back( std::string{ m_buffer.data() }, Global.UITextColor ); @@ -792,11 +792,11 @@ debug_panel::update_section_vehicle( std::vector &Output ) { // devices mover.Battery ? 'B' : '.', mover.PantsValve.is_active ? '+' : '.', - mover.Pantographs[end::rear].valve.is_active ? 'O' : - mover.Pantographs[end::rear].valve.is_enabled ? 'o' : + mover.Pantographs[rear].valve.is_active ? 'O' : + mover.Pantographs[rear].valve.is_enabled ? 'o' : '.', - mover.Pantographs[end::front].valve.is_active ? 'P' : - mover.Pantographs[end::front].valve.is_enabled ? 'p' : + mover.Pantographs[front].valve.is_active ? 'P' : + mover.Pantographs[front].valve.is_enabled ? 'p' : '.', mover.PantPressLockActive ? '!' : mover.PantPressSwitchActive ? '*' : @@ -840,21 +840,21 @@ debug_panel::update_section_vehicle( std::vector &Output ) { std::string( isdieselenginepowered ? STR(" oil pressure: ") + to_string( mover.OilPump.pressure, 2 ) : "" ).c_str(), // power transfers // 3000v - mover.Couplers[ end::front ].power_high.voltage, - mover.Couplers[ end::front ].power_high.current, - std::string( mover.Couplers[ end::front ].power_high.is_local ? ":" : ":=" ).c_str(), + mover.Couplers[ front ].power_high.voltage, + mover.Couplers[ front ].power_high.current, + std::string( mover.Couplers[ front ].power_high.is_local ? ":" : ":=" ).c_str(), mover.EngineVoltage, - std::string( mover.Couplers[ end::rear ].power_high.is_local ? ":" : "=:" ).c_str(), - mover.Couplers[ end::rear ].power_high.voltage, - mover.Couplers[ end::rear ].power_high.current, + std::string( mover.Couplers[ rear ].power_high.is_local ? ":" : "=:" ).c_str(), + mover.Couplers[ rear ].power_high.voltage, + mover.Couplers[ rear ].power_high.current, // 110v - mover.Couplers[ end::front ].power_110v.voltage, - mover.Couplers[ end::front ].power_110v.current, - std::string( mover.Couplers[ end::front ].power_110v.is_local ? ":" : ":=" ).c_str(), + mover.Couplers[ front ].power_110v.voltage, + mover.Couplers[ front ].power_110v.current, + std::string( mover.Couplers[ front ].power_110v.is_local ? ":" : ":=" ).c_str(), mover.PowerCircuits[ 1 ].first, - std::string( mover.Couplers[ end::rear ].power_110v.is_local ? ":" : "=:" ).c_str(), - mover.Couplers[ end::rear ].power_110v.voltage, - mover.Couplers[ end::rear ].power_110v.current ); + std::string( mover.Couplers[ rear ].power_110v.is_local ? ":" : "=:" ).c_str(), + mover.Couplers[ rear ].power_110v.voltage, + mover.Couplers[ rear ].power_110v.current ); Output.emplace_back( m_buffer.data(), Global.UITextColor ); @@ -872,8 +872,8 @@ debug_panel::update_section_vehicle( std::vector &Output ) { std::abs( mover.enrot ) * 60, std::abs( mover.nrot ) * mover.Transmision.Ratio * 60, mover.RventRot * 60, - std::abs( mover.MotorBlowers[end::front].revolutions ), - std::abs( mover.MotorBlowers[end::rear].revolutions ), + std::abs( mover.MotorBlowers[front].revolutions ), + std::abs( mover.MotorBlowers[rear].revolutions ), mover.dizel_heat.rpmw, mover.dizel_heat.rpmw2 ); diff --git a/audio/audio.cpp b/audio/audio.cpp index 7c558674..0d86a47d 100644 --- a/audio/audio.cpp +++ b/audio/audio.cpp @@ -97,20 +97,20 @@ buffer_manager::~buffer_manager() { for( auto &buffer : m_buffers ) { if( buffer.id != null_resource ) { - ::alDeleteBuffers( 1, &buffer.id ); + alDeleteBuffers( 1, &buffer.id ); } } } // creates buffer object out of data stored in specified file. returns: handle to the buffer or null_handle if creation failed -audio::buffer_handle +buffer_handle buffer_manager::create( std::string const &Filename ) { auto filename { ToLower( Filename ) }; erase_extension( filename ); - audio::buffer_handle lookup { null_handle }; + buffer_handle lookup { null_handle }; std::string filelookup; if( false == Global.asCurrentDynamicPath.empty() ) { // try dynamic-specific sounds first @@ -149,14 +149,14 @@ buffer_manager::create( std::string const &Filename ) { } // provides direct access to a specified buffer -audio::openal_buffer const & -buffer_manager::buffer( audio::buffer_handle const Buffer ) const { +openal_buffer const & +buffer_manager::buffer( buffer_handle const Buffer ) const { return m_buffers[ Buffer ]; } // places in the bank a buffer containing data stored in specified file. returns: handle to the buffer -audio::buffer_handle +buffer_handle buffer_manager::emplace( std::string Filename ) { buffer_handle const handle { m_buffers.size() }; @@ -171,7 +171,7 @@ buffer_manager::emplace( std::string Filename ) { return handle; } -audio::buffer_handle +buffer_handle buffer_manager::find_buffer( std::string const &Buffername ) const { auto const lookup = m_buffermappings.find( Buffername ); diff --git a/audio/audio.h b/audio/audio.h index 9d6285ec..5d616731 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -54,8 +54,8 @@ public: buffer_handle create( std::string const &Filename ); // provides direct access to a specified buffer - audio::openal_buffer const & - buffer( audio::buffer_handle const Buffer ) const; + openal_buffer const & + buffer( buffer_handle const Buffer ) const; private: // types diff --git a/audio/audiorenderer.cpp b/audio/audiorenderer.cpp index 4bbf20d3..34aa5472 100644 --- a/audio/audiorenderer.cpp +++ b/audio/audiorenderer.cpp @@ -39,12 +39,12 @@ limit_velocity( glm::vec3 const &Velocity ) { void openal_source::play() { - if( id == audio::null_resource ) { return; } // no implementation-side source to match, no point + if( id == null_resource ) { return; } // no implementation-side source to match, no point - ::alSourcePlay( id ); + alSourcePlay( id ); ALint state; - ::alGetSourcei( id, AL_SOURCE_STATE, &state ); + alGetSourcei( id, AL_SOURCE_STATE, &state ); is_playing = state == AL_PLAYING; } @@ -52,16 +52,16 @@ openal_source::play() { void openal_source::stop() { - if( id == audio::null_resource ) { return; } // no implementation-side source to match, no point + if( id == null_resource ) { return; } // no implementation-side source to match, no point loop( false ); // NOTE: workaround for potential edge cases where ::alSourceStop() doesn't set source which wasn't yet started to AL_STOPPED int state; - ::alGetSourcei( id, AL_SOURCE_STATE, &state ); + alGetSourcei( id, AL_SOURCE_STATE, &state ); if( state == AL_INITIAL ) { play(); } - ::alSourceStop( id ); + alSourceStop( id ); is_playing = false; } @@ -80,29 +80,29 @@ openal_source::update( double const Deltatime, glm::vec3 const &Listenervelocity stop(); } */ - if( id != audio::null_resource ) { + if( id != null_resource ) { sound_change = false; - ::alGetSourcei( id, AL_BUFFERS_PROCESSED, &sound_index ); + alGetSourcei( id, AL_BUFFERS_PROCESSED, &sound_index ); // for multipart sounds trim away processed buffers until only one remains, the last one may be set to looping by the controller // TBD, TODO: instead of change flag move processed buffer ids to separate queue, for accurate tracking of longer buffer sequences ALuint discard; while( sound_index > 0 && sounds.size() > 1 ) { - ::alSourceUnqueueBuffers( id, 1, &discard ); + alSourceUnqueueBuffers( id, 1, &discard ); sounds.erase( std::begin( sounds ) ); --sound_index; sound_change = true; // potentially adjust starting point of the last buffer (to reduce chance of reverb effect with multiple, looping copies playing) if( controller->start() > 0.f && sounds.size() == 1 ) { ALint bufferid; - ::alGetSourcei( + alGetSourcei( id, AL_BUFFER, &bufferid ); ALint buffersize; - ::alGetBufferi( bufferid, AL_SIZE, &buffersize ); - ::alSourcei( + alGetBufferi( bufferid, AL_SIZE, &buffersize ); + alSourcei( id, AL_SAMPLE_OFFSET, static_cast( controller->start() * ( buffersize / sizeof( std::int16_t ) ) ) ); @@ -110,7 +110,7 @@ openal_source::update( double const Deltatime, glm::vec3 const &Listenervelocity } int state; - ::alGetSourcei( id, AL_SOURCE_STATE, &state ); + alGetSourcei( id, AL_SOURCE_STATE, &state ); is_playing = state == AL_PLAYING; } @@ -122,7 +122,7 @@ openal_source::update( double const Deltatime, glm::vec3 const &Listenervelocity void openal_source::sync_with( sound_properties const &State ) { - if( id == audio::null_resource ) { + if( id == null_resource ) { // no implementation-side source to match, return sync error so the controller can clean up on its end sync = sync_state::bad_resource; return; @@ -135,7 +135,7 @@ openal_source::sync_with( sound_properties const &State ) { sound_velocity = limit_velocity( ( State.location - properties.location ) / update_deltatime ); } // NOTE: velocity at this point can be either listener velocity for global sounds, actual sound velocity, or 0 if sound position is yet unknown - ::alSourcefv( id, AL_VELOCITY, glm::value_ptr( sound_velocity ) ); + alSourcefv( id, AL_VELOCITY, glm::value_ptr( sound_velocity ) ); // location sound_distance = State.location - renderer.cached_camerapos; @@ -151,11 +151,11 @@ openal_source::sync_with( sound_properties const &State ) { } } if( sound_range >= 0 ) { - ::alSourcefv( id, AL_POSITION, glm::value_ptr( sound_distance ) ); + alSourcefv( id, AL_POSITION, glm::value_ptr( sound_distance ) ); } else { // sounds with 'unlimited' or negative range are positioned on top of the listener - ::alSourcefv( id, AL_POSITION, glm::value_ptr( glm::vec3() ) ); + alSourcefv( id, AL_POSITION, glm::value_ptr( glm::vec3() ) ); } // gain auto const gain { @@ -167,14 +167,14 @@ openal_source::sync_with( sound_properties const &State ) { 1.f ) }; if( State.gain != properties.gain || State.soundproofing_stamp != properties.soundproofing_stamp - || audio::event_volume_change ) { + || event_volume_change ) { // gain value has changed - ::alSourcef( id, AL_GAIN, gain ); + alSourcef( id, AL_GAIN, gain ); auto const range { ( sound_range >= 0 ? sound_range : 5 ) }; // range of -1 means sound of unlimited range, positioned at the listener - ::alSourcef( id, AL_REFERENCE_DISTANCE, range * ( 1.f / 16.f ) * State.soundproofing ); + alSourcef( id, AL_REFERENCE_DISTANCE, range * ( 1.f / 16.f ) * State.soundproofing ); } if( sound_range != -1 ) { auto const rangesquared { sound_range * sound_range }; @@ -189,14 +189,14 @@ openal_source::sync_with( sound_properties const &State ) { 1.f, 0.f, std::clamp( ( distancesquared - rangesquared ) / ( fadedistance * fadedistance ), 0.f, 1.f ) ) }; - ::alSourcef( id, AL_GAIN, gain * rangefactor ); + alSourcef( id, AL_GAIN, gain * rangefactor ); } is_in_range = distancesquared <= rangesquared; } // pitch if( State.pitch != properties.pitch ) { // pitch value has changed - ::alSourcef( id, AL_PITCH, std::clamp( State.pitch * pitch_variation, 0.1f, 10.f ) ); + alSourcef( id, AL_PITCH, std::clamp( State.pitch * pitch_variation, 0.1f, 10.f ) ); } // all synced up properties = State; @@ -210,14 +210,14 @@ openal_source::range( float const Range ) { // NOTE: we cache actual specified range, as we'll be giving 'unlimited' range special treatment sound_range = Range; - if( id == audio::null_resource ) { return; } // no implementation-side source to match, no point + if( id == null_resource ) { return; } // no implementation-side source to match, no point auto const range { ( Range >= 0 ? Range : 5 ) }; // range of -1 means sound of unlimited range, positioned at the listener - ::alSourcef( id, AL_REFERENCE_DISTANCE, range * ( 1.f / 16.f ) ); - ::alSourcef( id, AL_ROLLOFF_FACTOR, 1.75f ); + alSourcef( id, AL_REFERENCE_DISTANCE, range * ( 1.f / 16.f ) ); + alSourcef( id, AL_ROLLOFF_FACTOR, 1.75f ); } // sets modifier applied to the pitch of sounds emitted by the source @@ -233,11 +233,11 @@ openal_source::pitch( float const Pitch ) { void openal_source::loop( bool const State ) { - if( id == audio::null_resource ) { return; } // no implementation-side source to match, no point + if( id == null_resource ) { return; } // no implementation-side source to match, no point if( is_looping == State ) { return; } is_looping = State; - ::alSourcei( + alSourcei( id, AL_LOOPING, State ? AL_TRUE : AL_FALSE); @@ -248,7 +248,7 @@ openal_source::loop( bool const State ) { void openal_source::clear() { - if( id != audio::null_resource ) { + if( id != null_resource ) { // unqueue bound buffers: // ensure no buffer is in use... stop(); @@ -256,7 +256,7 @@ openal_source::clear() { std::vector bufferids; bufferids.resize( sounds.size() ); // ...release the buffers... - ::alSourceUnqueueBuffers( id, bufferids.size(), bufferids.data() ); + alSourceUnqueueBuffers( id, bufferids.size(), bufferids.data() ); } // ...and reset reset the properties, except for the id of the allocated source // NOTE: not strictly necessary since except for the id the source data typically get discarded in next step @@ -269,21 +269,21 @@ openal_source::clear() { openal_renderer::~openal_renderer() { - ::alcMakeContextCurrent( nullptr ); + alcMakeContextCurrent( nullptr ); - if( m_context != nullptr ) { ::alcDestroyContext( m_context ); } - if( m_device != nullptr ) { ::alcCloseDevice( m_device ); } + if( m_context != nullptr ) { alcDestroyContext( m_context ); } + if( m_device != nullptr ) { alcCloseDevice( m_device ); } } -audio::buffer_handle +buffer_handle openal_renderer::fetch_buffer( std::string const &Filename ) { return m_buffers.create( Filename ); } // provides direct access to a specified buffer -audio::openal_buffer const & -openal_renderer::buffer( audio::buffer_handle const Buffer ) const { +openal_buffer const & +openal_renderer::buffer( buffer_handle const Buffer ) const { return m_buffers.buffer( Buffer ); } @@ -300,8 +300,8 @@ openal_renderer::init() { // basic initialization failed return false; } - ::alDistanceModel( AL_INVERSE_DISTANCE_CLAMPED ); - ::alDopplerFactor( 0.25f ); + alDistanceModel( AL_INVERSE_DISTANCE_CLAMPED ); + alDopplerFactor( 0.25f ); // all done m_ready = true; return true; @@ -316,7 +316,7 @@ openal_renderer::erase( sound_source const *Controller ) { if( source->controller == Controller ) { // if the controller is the one specified, kill it source->clear(); - if( source->id != audio::null_resource ) { + if( source->id != null_resource ) { // keep around functional sources, but no point in doing it with the above-the-limit ones m_sourcespares.push( source->id ); } @@ -349,7 +349,7 @@ openal_renderer::update( double const Deltatime ) { errname = "AL_OUT_OF_MEMORY"; else errname = "unknown"; - + ErrorLog("sound: al error: " + errname); } @@ -365,7 +365,7 @@ openal_renderer::update( double const Deltatime ) { // update listener // gain - ::alListenerf( AL_GAIN, Global.AudioVolume ); + alListenerf( AL_GAIN, Global.AudioVolume ); // orientation glm::dmat4 cameramatrix; Global.pCamera.SetMatrix( cameramatrix ); @@ -375,7 +375,7 @@ openal_renderer::update( double const Deltatime ) { glm::vec3 const orientation[] = { glm::vec3{ 0, 0,-1 } * rotationmatrix , glm::vec3{ 0, 1, 0 } * rotationmatrix }; - ::alListenerfv( AL_ORIENTATION, reinterpret_cast( orientation ) ); + alListenerfv( AL_ORIENTATION, reinterpret_cast( orientation ) ); // velocity if( Deltatime > 0 ) { auto cameramove { cameraposition - cached_camerapos }; @@ -402,7 +402,7 @@ openal_renderer::update( double const Deltatime ) { } m_listenervelocity = limit_velocity( cameramove / Deltatime ); - ::alListenerfv( AL_VELOCITY, reinterpret_cast( glm::value_ptr( m_listenervelocity ) ) ); + alListenerfv( AL_VELOCITY, reinterpret_cast( glm::value_ptr( m_listenervelocity ) ) ); } // update active emitters @@ -413,7 +413,7 @@ openal_renderer::update( double const Deltatime ) { // if after the update the source isn't playing, put it away on the spare stack, it's done if( false == source->is_playing ) { source->clear(); - if( source->id != audio::null_resource ) { + if( source->id != null_resource ) { // keep around functional sources, but no point in doing it with the above-the-limit ones m_sourcespares.push( source->id ); } @@ -426,7 +426,7 @@ openal_renderer::update( double const Deltatime ) { } // reset potentially used volume change flag - audio::event_volume_change = false; + event_volume_change = false; if (alProcessUpdatesSOFT) { @@ -436,20 +436,20 @@ openal_renderer::update( double const Deltatime ) { } // returns an instance of implementation-side part of the sound emitter -audio::openal_source +openal_source openal_renderer::fetch_source() { - audio::openal_source newsource; + openal_source newsource; if( false == m_sourcespares.empty() ) { // reuse (a copy of) already allocated source newsource.id = m_sourcespares.top(); m_sourcespares.pop(); } - if( newsource.id == audio::null_resource ) { + if( newsource.id == null_resource ) { // if there's no source to reuse, try to generate a new one - ::alGenSources( 1, &newsource.id ); + alGenSources( 1, &newsource.id ); } - if( newsource.id == audio::null_resource ) { + if( newsource.id == null_resource ) { alGetError(); // if we still don't have a working source, see if we can sacrifice an already active one // under presumption it's more important to play new sounds than keep the old ones going @@ -460,7 +460,7 @@ openal_renderer::fetch_source() { for( auto source { std::begin( m_sources ) }; source != std::cend( m_sources ); ++source ) { - if( source->id == audio::null_resource + if( source->id == null_resource || true == source->is_multipart || false == source->is_playing ) { @@ -488,12 +488,12 @@ openal_renderer::fetch_source() { } } - if( newsource.id == audio::null_resource ) { + if( newsource.id == null_resource ) { // for sources with functional emitter reset emitter parameters from potential last use - ::alSourcef( newsource.id, AL_PITCH, 1.f ); - ::alSourcef( newsource.id, AL_GAIN, 1.f ); - ::alSourcefv( newsource.id, AL_POSITION, glm::value_ptr( glm::vec3{ 0.f } ) ); - ::alSourcefv( newsource.id, AL_VELOCITY, glm::value_ptr( glm::vec3{ 0.f } ) ); + alSourcef( newsource.id, AL_PITCH, 1.f ); + alSourcef( newsource.id, AL_GAIN, 1.f ); + alSourcefv( newsource.id, AL_POSITION, glm::value_ptr( glm::vec3{ 0.f } ) ); + alSourcefv( newsource.id, AL_VELOCITY, glm::value_ptr( glm::vec3{ 0.f } ) ); } return newsource; @@ -502,10 +502,10 @@ openal_renderer::fetch_source() { bool openal_renderer::init_caps() { - if( ::alcIsExtensionPresent( nullptr, "ALC_ENUMERATION_EXT" ) == AL_TRUE ) { + if( alcIsExtensionPresent( nullptr, "ALC_ENUMERATION_EXT" ) == AL_TRUE ) { // enumeration supported WriteLog( "available audio devices:" ); - auto const *devices { ::alcGetString( nullptr, ALC_DEVICE_SPECIFIER ) }; + auto const *devices { alcGetString( nullptr, ALC_DEVICE_SPECIFIER ) }; auto const *device { devices }, *next { devices + 1 }; @@ -518,18 +518,18 @@ openal_renderer::init_caps() { } // NOTE: default value of audio renderer variable is empty string, meaning argument of NULL i.e. 'preferred' device - m_device = ::alcOpenDevice( Global.AudioRenderer.c_str() ); + m_device = alcOpenDevice( Global.AudioRenderer.c_str() ); if( m_device == nullptr ) { ErrorLog( "Failed to obtain audio device" ); return false; } ALCint versionmajor, versionminor; - ::alcGetIntegerv( m_device, ALC_MAJOR_VERSION, 1, &versionmajor ); - ::alcGetIntegerv( m_device, ALC_MINOR_VERSION, 1, &versionminor ); + alcGetIntegerv( m_device, ALC_MAJOR_VERSION, 1, &versionmajor ); + alcGetIntegerv( m_device, ALC_MINOR_VERSION, 1, &versionminor ); auto const oalversion { std::to_string( versionmajor ) + "." + std::to_string( versionminor ) }; - const std::string al_renderer((char *)::alcGetString( m_device, ALC_DEVICE_SPECIFIER )); + const std::string al_renderer((char *)alcGetString( m_device, ALC_DEVICE_SPECIFIER )); crashreport_add_info("openal_renderer", al_renderer); crashreport_add_info("openal_version", oalversion); @@ -537,11 +537,11 @@ openal_renderer::init_caps() { "Audio Renderer: " + al_renderer + " OpenAL Version: " + oalversion ); - WriteLog( "Supported extensions: " + std::string{ (char *)::alcGetString( m_device, ALC_EXTENSIONS ) } ); + WriteLog( "Supported extensions: " + std::string{ (char *)alcGetString( m_device, ALC_EXTENSIONS ) } ); const ALCint attr[3] = { ALC_MONO_SOURCES, Global.audio_max_sources, 0 }; // request more sounds - m_context = ::alcCreateContext( m_device, attr ); + m_context = alcCreateContext( m_device, attr ); if( m_context == nullptr ) { ErrorLog( "Failed to create audio context" ); return false; diff --git a/audio/audiorenderer.h b/audio/audiorenderer.h index 13978fd0..6661a1f5 100644 --- a/audio/audiorenderer.h +++ b/audio/audiorenderer.h @@ -52,10 +52,10 @@ struct openal_source { friend class openal_renderer; // types - using buffer_sequence = std::vector; + using buffer_sequence = std::vector; // members - ALuint id { audio::null_resource }; // associated AL resource + ALuint id { null_resource }; // associated AL resource sound_source *controller { nullptr }; // source controller uint32_sequence sounds; // // buffer_sequence buffers; // sequence of samples the source will emit @@ -122,11 +122,11 @@ public: // methods // buffer methods // returns handle to a buffer containing audio data from specified file - audio::buffer_handle + buffer_handle fetch_buffer( std::string const &Filename ); // provides direct access to a specified buffer - audio::openal_buffer const & - buffer( audio::buffer_handle const Buffer ) const; + openal_buffer const & + buffer( buffer_handle const Buffer ) const; // core methods // initializes the service bool @@ -147,13 +147,13 @@ public: private: // types - using source_list = std::list; + using source_list = std::list; using source_sequence = std::stack; // methods bool init_caps(); // returns an instance of implementation-side part of the sound emitter - audio::openal_source + openal_source fetch_source(); // members ALCdevice * m_device { nullptr }; diff --git a/audio/audiorenderer_extra.h b/audio/audiorenderer_extra.h index 430f594b..b7bbfd5c 100644 --- a/audio/audiorenderer_extra.h +++ b/audio/audiorenderer_extra.h @@ -11,27 +11,27 @@ openal_source::bind( sound_source *Controller, uint32_sequence Sounds, Iterator_ std::vector buffers; std::for_each( First, Last, - [&]( audio::buffer_handle const &bufferhandle ) { - auto const &buffer { audio::renderer.buffer( bufferhandle ) }; + [&]( buffer_handle const &bufferhandle ) { + auto const &buffer { renderer.buffer( bufferhandle ) }; if (buffer.id != null_resource) buffers.emplace_back( buffer.id ); } ); is_multipart = buffers.size() > 1; - if( id != audio::null_resource && !buffers.empty()) { - ::alSourceQueueBuffers( id, static_cast( buffers.size() ), buffers.data() ); - ::alSourceRewind( id ); + if( id != null_resource && !buffers.empty()) { + alSourceQueueBuffers( id, static_cast( buffers.size() ), buffers.data() ); + alSourceRewind( id ); // sound controller can potentially request playback to start from certain buffer point // for multipart sounds the offset is applied only to last piece during playback // for single sound we also make sure not to apply the offset to optional bookends if( controller->start() == 0.f || is_multipart || controller->is_bookend( buffers.front() ) ) { // regular case with no offset, reset bound source just in case - ::alSourcei( id, AL_SAMPLE_OFFSET, 0 ); + alSourcei( id, AL_SAMPLE_OFFSET, 0 ); } else { // move playback start to specified point in 0-1 range ALint buffersize; - ::alGetBufferi( buffers.front(), AL_SIZE, &buffersize ); - ::alSourcei( + alGetBufferi( buffers.front(), AL_SIZE, &buffersize ); + alSourcei( id, AL_SAMPLE_OFFSET, static_cast( controller->start() * ( buffersize / sizeof( std::int16_t ) ) ) ); diff --git a/audio/sound.cpp b/audio/sound.cpp index 7b054b1a..f8a6b9da 100644 --- a/audio/sound.cpp +++ b/audio/sound.cpp @@ -122,14 +122,14 @@ sound_source::deserialize( cParser &Input, sound_type const Legacytype, int cons Input >> m_range; } } - if( Legacyparameters & sound_parameters::amplitude ) { + if( Legacyparameters & amplitude ) { if( Input.getTokens( 2, false ) ) { Input >> m_amplitudefactor >> m_amplitudeoffset; } } - if( Legacyparameters & sound_parameters::frequency ) { + if( Legacyparameters & frequency ) { if( Input.getTokens( 2, false ) ) { Input >> m_frequencyfactor @@ -161,16 +161,16 @@ sound_source::deserialize_mapping( cParser &Input ) { // if not block end then the key is followed by assigned value or sub-block if( key == "soundmain:" ) { - sound( sound_id::main ).buffer = audio::renderer.fetch_buffer( deserialize_random_set( Input, "\n\r\t ,;" ) ); + sound( main ).buffer = audio::renderer.fetch_buffer( deserialize_random_set( Input, "\n\r\t ,;" ) ); } else if( key == "soundset:" ) { deserialize_soundset( Input ); } else if( key == "soundbegin:" ) { - sound( sound_id::begin ).buffer = audio::renderer.fetch_buffer( deserialize_random_set( Input, "\n\r\t ,;" ) ); + sound( begin ).buffer = audio::renderer.fetch_buffer( deserialize_random_set( Input, "\n\r\t ,;" ) ); } else if( key == "soundend:" ) { - sound( sound_id::end ).buffer = audio::renderer.fetch_buffer( deserialize_random_set( Input, "\n\r\t ,;" ) ); + sound( end ).buffer = audio::renderer.fetch_buffer( deserialize_random_set( Input, "\n\r\t ,;" ) ); } else if( key == "soundproofing:" ) { // custom soundproofing in format [ p1, p2, p3, p4, p5, p6 ] @@ -286,9 +286,9 @@ sound_source::deserialize_soundset( cParser &Input ) { auto const soundset { deserialize_random_set( Input, "\n\r\t ,;" ) }; // split retrieved set cParser setparser( soundset ); - sound( sound_id::begin ).buffer = audio::renderer.fetch_buffer( setparser.getToken( true, "|" ) ); - sound( sound_id::main ).buffer = audio::renderer.fetch_buffer( setparser.getToken( true, "|" ) ); - sound( sound_id::end ).buffer = audio::renderer.fetch_buffer( setparser.getToken( true, "|" ) ); + sound( begin ).buffer = audio::renderer.fetch_buffer( setparser.getToken( true, "|" ) ); + sound( main ).buffer = audio::renderer.fetch_buffer( setparser.getToken( true, "|" ) ); + sound( end ).buffer = audio::renderer.fetch_buffer( setparser.getToken( true, "|" ) ); } // sends content of the class in legacy (text) format to provided stream @@ -296,7 +296,7 @@ sound_source::deserialize_soundset( cParser &Input ) { void sound_source::export_as_text( std::ostream &Output ) const { - if( sound( sound_id::main ).buffer == null_handle ) { return; } + if( sound( main ).buffer == null_handle ) { return; } // generic node header Output @@ -315,7 +315,7 @@ sound_source::export_as_text( std::ostream &Output ) const { << m_offset.y << ' ' << m_offset.z << ' '; // sound data - auto soundfile { audio::renderer.buffer( sound( sound_id::main ).buffer ).name }; + auto soundfile { audio::renderer.buffer( sound( main ).buffer ).name }; if( soundfile.find( paths::sounds ) == 0 ) { // don't include 'sounds/' in the path soundfile.erase( 0, std::string{ paths::sounds }.size() ); @@ -383,7 +383,7 @@ sound_source::play( int const Flags ) { // TBD, TODO: user-configurable m_properties.category = m_owner ? sound_category::vehicle : m_range < 0 ? sound_category::ambient : sound_category::local; - if( sound( sound_id::main ).buffer != null_handle ) { + if( sound( main ).buffer != null_handle ) { // basic variant: single main sound, with optional bookends play_basic(); } @@ -399,20 +399,20 @@ sound_source::play_basic() { if( false == is_playing() ) { // dispatch appropriate sound if( true == m_playbeginning - && sound(sound_id::begin).buffer != null_handle) { - std::vector sounds { sound_id::begin, sound_id::main }; + && sound(begin).buffer != null_handle) { + std::vector sounds { begin, main }; insert( std::begin( sounds ), std::end( sounds ) ); m_playbeginning = false; } else { - insert( sound_id::main ); + insert( main ); } } else { // for single part non-looping samples we allow spawning multiple instances, if not prevented by set flags - if( (m_flags & (sound_flags::exclusive | sound_flags::looping)) == 0 - && sound(sound_id::begin).buffer == null_handle) { - insert( sound_id::main ); + if( (m_flags & (exclusive | looping)) == 0 + && sound(begin).buffer == null_handle) { + insert( main ); } } } @@ -430,35 +430,35 @@ sound_source::play_combined() { if( soundpoint < soundchunk.second.fadein ) { break; } if( soundpoint >= soundchunk.second.fadeout ) { continue; } - if( soundchunk.first.buffer == null_handle || ( (m_flags & (sound_flags::exclusive | sound_flags::looping)) != 0 + if( soundchunk.first.buffer == null_handle || ( (m_flags & (exclusive | looping)) != 0 && soundchunk.first.playing > 0 ) ) { // combined sounds only play looped, single copy of each activated chunk continue; } if( idx > 0 ) { - insert( sound_id::chunk | idx ); + insert( chunk | idx ); } else { // initial chunk requires some safety checks if the optional bookend is present, // so we don't queue another instance while the bookend is still playing - if( sound( sound_id::begin ).buffer == null_handle ) { + if( sound( begin ).buffer == null_handle ) { // no bookend, safe to play the chunk - insert( sound_id::chunk | idx ); + insert( chunk | idx ); } else { // branches: // beginning requested, not playing; queue beginning and chunk // beginning not requested, not playing; queue chunk // otherwise skip, one instance is already in the audio queue - if( sound( sound_id::begin ).playing == 0 ) { + if( sound( begin ).playing == 0 ) { if( true == m_playbeginning ) { - std::vector sounds{ sound_id::begin, sound_id::chunk | idx }; + std::vector sounds{ begin, chunk | idx }; insert( std::begin( sounds ), std::end( sounds ) ); m_playbeginning = false; } else { - insert( sound_id::chunk | idx ); + insert( chunk | idx ); } } } @@ -482,7 +482,7 @@ sound_source::compute_combined_point() const { void sound_source::play_event() { - if( true == TestFlag( m_flags, sound_flags::event | sound_flags::looping ) ) { + if( true == TestFlag( m_flags, event | looping ) ) { // events can potentially start scenery sounds out of the sound's audible range // such sounds are stopped on renderer side, but unless stopped by the simulation keep their activation flags // we use this to discern event-started sounds which should be re-activated if the listener gets close enough @@ -504,11 +504,11 @@ sound_source::stop( bool const Skipend ) { m_stop = true; if( false == Skipend - && sound(sound_id::end).buffer != null_handle + && sound(end).buffer != null_handle /* && ( sound( sound_id::end ).buffer != sound( sound_id::main ).buffer ) */ // end == main can happen in malformed legacy cases - && sound(sound_id::end).playing < 2 ) { // allows potential single extra instance to account for longer overlapping sounds + && sound(end).playing < 2 ) { // allows potential single extra instance to account for longer overlapping sounds // spawn potentially defined sound end sample, if the emitter is currently active - insert( sound_id::end ); + insert( end ); } } @@ -523,7 +523,7 @@ sound_source::update( audio::openal_source &Source ) { m_stop = true; } - if( sound( sound_id::main ).buffer != null_handle ) { + if( sound( main ).buffer != null_handle ) { // basic variant: single main sound, with optional bookends update_basic( Source ); return; @@ -542,21 +542,21 @@ sound_source::update_basic( audio::openal_source &Source ) { auto const soundhandle { Source.sounds[ Source.sound_index ] }; - if( sound( sound_id::begin ).buffer != null_handle ) { + if( sound( begin ).buffer != null_handle ) { // potentially a multipart sound // detect the moment when the sound moves from startup sample to the main if( true == Source.sound_change ) { // when it happens update active sample counters, and potentially activate the looping - if( soundhandle == sound_id::main ) { - update_counter( sound_id::begin, -1 ); + if( soundhandle == main ) { + update_counter( begin, -1 ); } update_counter( soundhandle, 1 ); - Source.loop( soundhandle == sound_id::main ? TestFlag(m_flags, sound_flags::looping) : false ); + Source.loop( soundhandle == main ? TestFlag(m_flags, looping) : false ); } } if( true == m_stop - && soundhandle != sound_id::end ) { + && soundhandle != end ) { // kill the sound if stop was requested, unless it's sound bookend sample update_counter( soundhandle, -1 ); Source.stop(); @@ -593,7 +593,7 @@ sound_source::update_basic( audio::openal_source &Source ) { auto const soundhandle { Source.sounds[ Source.sound_index ] }; // emitter initialization // main sample can be optionally set to loop - Source.loop( soundhandle == sound_id::main ? TestFlag(m_flags, sound_flags::looping) : false ); + Source.loop( soundhandle == main ? TestFlag(m_flags, looping) : false ); Source.range( m_range ); Source.pitch( m_pitchvariation ); update_location(); @@ -638,19 +638,19 @@ sound_source::update_combined( audio::openal_source &Source ) { auto const soundhandle { Source.sounds[ Source.sound_index ] }; - if( sound( sound_id::begin ).buffer != null_handle ) { + if( sound( begin ).buffer != null_handle ) { // potentially a multipart sound // detect the moment when the sound moves from startup sample to the main if( true == Source.sound_change ) { // when it happens update active sample counters, and activate the looping - update_counter( sound_id::begin, -1 ); + update_counter( begin, -1 ); update_counter( soundhandle, 1 ); Source.loop( true ); } } if( true == m_stop - && soundhandle != sound_id::end ) { + && soundhandle != end ) { // kill the sound if stop was requested, unless it's sound bookend sample Source.stop(); update_counter( soundhandle, -1 ); @@ -671,11 +671,11 @@ sound_source::update_combined( audio::openal_source &Source ) { return; } */ - if( ( soundhandle & sound_id::chunk ) != 0 ) { + if( ( soundhandle & chunk ) != 0 ) { // for sound chunks, test whether the chunk should still be active given current value of the controlling variable - if( ( m_flags & ( sound_flags::exclusive | sound_flags::looping ) ) != 0 ) { + if( ( m_flags & ( exclusive | looping ) ) != 0 ) { auto const soundpoint { compute_combined_point() }; - auto const &soundchunk { m_soundchunks[ soundhandle ^ sound_id::chunk ] }; + auto const &soundchunk { m_soundchunks[ soundhandle ^ chunk ] }; if( soundpoint < soundchunk.second.fadein || soundpoint >= soundchunk.second.fadeout ) { Source.stop(); @@ -709,9 +709,9 @@ sound_source::update_combined( audio::openal_source &Source ) { // the emitter wasn't yet started auto const soundhandle { Source.sounds[ Source.sound_index ] }; // emitter initialization - if( soundhandle != sound_id::begin - && soundhandle != sound_id::end - && true == TestFlag(m_flags, sound_flags::looping) ) { + if( soundhandle != begin + && soundhandle != end + && true == TestFlag(m_flags, looping) ) { // main sample can be optionally set to loop Source.loop( true ); } @@ -747,7 +747,7 @@ sound_source::update_combined( audio::openal_source &Source ) { void sound_source::update_crossfade( sound_handle const Chunk ) { - if( ( Chunk & sound_id::chunk ) == 0 ) { + if( ( Chunk & chunk ) == 0 ) { // bookend sounds are played at their base pitch m_properties.pitch = 1.f; return; @@ -756,7 +756,7 @@ sound_source::update_crossfade( sound_handle const Chunk ) { auto const soundpoint { compute_combined_point() }; // NOTE: direct access to implementation details ahead, kinda fugly - auto const chunkindex { Chunk ^ sound_id::chunk }; + auto const chunkindex { Chunk ^ chunk }; auto const &chunkdata { m_soundchunks[ chunkindex ].second }; // relative pitch adjustment @@ -862,14 +862,14 @@ bool sound_source::empty() const { // NOTE: we test only the main sound, won't bother playing potential bookends if this is missing - return sound(sound_id::main).buffer == null_handle && m_soundchunksempty; + return sound(main).buffer == null_handle && m_soundchunksempty; } // returns true if the source is emitting any sound bool sound_source::is_playing( bool const Includesoundends ) const { - auto isplaying { sound(sound_id::begin).playing > 0 || sound(sound_id::main).playing > 0 }; + auto isplaying { sound(begin).playing > 0 || sound(main).playing > 0 }; if( false == isplaying && false == m_soundchunks.empty() ) { // for emitters with sample tables check also if any of the chunks is active @@ -887,21 +887,21 @@ sound_source::is_playing( bool const Includesoundends ) const { bool sound_source::is_combined() const { - return !m_soundchunks.empty() && sound(sound_id::main).buffer == null_handle; + return !m_soundchunks.empty() && sound(main).buffer == null_handle; } // returns true if specified buffer is one of the optional bookends bool sound_source::is_bookend( audio::buffer_handle const Buffer ) const { - return sound(sound_id::begin).buffer == Buffer || sound(sound_id::end).buffer == Buffer; + return sound(begin).buffer == Buffer || sound(end).buffer == Buffer; } // returns true if the source has optional bookends bool sound_source::has_bookends() const { - return sound(sound_id::begin).buffer != null_handle && sound(sound_id::end).buffer != null_handle; + return sound(begin).buffer != null_handle && sound(end).buffer != null_handle; } // returns location of the sound source in simulation region space @@ -1023,11 +1023,11 @@ sound_source::insert( sound_handle const Sound ) { sound_source::sound_data & sound_source::sound( sound_handle const Sound ) { - return (Sound & sound_id::chunk) == sound_id::chunk ? m_soundchunks[Sound ^ sound_id::chunk].first : m_sounds[Sound]; + return (Sound & chunk) == chunk ? m_soundchunks[Sound ^ chunk].first : m_sounds[Sound]; } sound_source::sound_data const & sound_source::sound( sound_handle const Sound ) const { - return (Sound & sound_id::chunk) == sound_id::chunk ? m_soundchunks[Sound ^ sound_id::chunk].first : m_sounds[Sound]; + return (Sound & chunk) == chunk ? m_soundchunks[Sound ^ chunk].first : m_sounds[Sound]; } diff --git a/gl/buffer.cpp b/gl/buffer.cpp index 0fd37aee..36c251e9 100644 --- a/gl/buffer.cpp +++ b/gl/buffer.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "buffer.h" -GLenum gl::buffer::glenum_target(gl::buffer::targets target) +GLenum gl::buffer::glenum_target(targets target) { static GLenum mapping[13] = { diff --git a/gl/pbo.cpp b/gl/pbo.cpp index 37505916..fb18ebe6 100644 --- a/gl/pbo.cpp +++ b/gl/pbo.cpp @@ -54,12 +54,12 @@ bool gl::pbo::is_busy() void* gl::pbo::map(GLuint mode, targets target) { bind(target); - return glMapBuffer(buffer::glenum_target(target), mode); + return glMapBuffer(glenum_target(target), mode); } void gl::pbo::unmap(targets target) { bind(target); - glUnmapBuffer(buffer::glenum_target(target)); + glUnmapBuffer(glenum_target(target)); sync.emplace(); } diff --git a/gl/postfx.cpp b/gl/postfx.cpp index 6587475a..e99455a0 100644 --- a/gl/postfx.cpp +++ b/gl/postfx.cpp @@ -12,7 +12,7 @@ gl::postfx::postfx(const std::string &s) : postfx(shader("postfx_" + s + ".frag" gl::postfx::postfx(const shader &s) { if (!vertex) - vertex = std::make_shared("quad.vert"); + vertex = std::make_shared("quad.vert"); if (!vao) vao = std::make_shared(); diff --git a/gl/postfx.h b/gl/postfx.h index cc0c5450..5e151435 100644 --- a/gl/postfx.h +++ b/gl/postfx.h @@ -10,9 +10,9 @@ namespace gl class postfx { private: - gl::program program; - static std::shared_ptr vertex; - static std::shared_ptr vao; + program program; + static std::shared_ptr vertex; + static std::shared_ptr vao; public: postfx(const std::string &s); diff --git a/gl/shader.cpp b/gl/shader.cpp index 3df2433d..bf89a7f4 100644 --- a/gl/shader.cpp +++ b/gl/shader.cpp @@ -226,7 +226,7 @@ void gl::shader::parse_texture_entries(std::string &str) { if (name.empty()) log_error("empty name"); - else if (conf.id >= gl::MAX_TEXTURES) + else if (conf.id >= MAX_TEXTURES) log_error("invalid texture binding: " + std::to_string(conf.id)); else texture_conf.emplace(std::make_pair(name, conf)); @@ -283,7 +283,7 @@ void gl::shader::parse_param_entries(std::string &str) { if (name.empty()) log_error("empty name"); - else if (conf.location >= gl::MAX_PARAMS) + else if (conf.location >= MAX_PARAMS) log_error("invalid param binding: " + std::to_string(conf.location)); else if (conf.offset > 3) log_error("invalid offset: " + std::to_string(conf.offset)); @@ -346,9 +346,9 @@ void gl::program::init() glUniform1i(loc, e.id); } - glUniform1i(glGetUniformLocation(*this, "shadowmap"), gl::SHADOW_TEX); - glUniform1i(glGetUniformLocation(*this, "envmap"), gl::ENV_TEX); - glUniform1i(glGetUniformLocation(*this, "headlightmap"), gl::HEADLIGHT_TEX); + glUniform1i(glGetUniformLocation(*this, "shadowmap"), SHADOW_TEX); + glUniform1i(glGetUniformLocation(*this, "envmap"), ENV_TEX); + glUniform1i(glGetUniformLocation(*this, "headlightmap"), HEADLIGHT_TEX); GLuint index; @@ -370,14 +370,14 @@ gl::program::program() **this = glCreateProgram(); } -gl::program::program(std::vector> shaders) : program() +gl::program::program(std::vector> shaders) : program() { - for (const gl::shader &s : shaders) + for (const shader &s : shaders) attach(s); link(); } -void gl::program::attach(const gl::shader &s) +void gl::program::attach(const shader &s) { for (auto it : s.texture_conf) texture_conf.emplace(std::make_pair(it.first, std::move(it.second))); diff --git a/gl/shader.h b/gl/shader.h index 4cd25f07..16e54f27 100644 --- a/gl/shader.h +++ b/gl/shader.h @@ -85,7 +85,7 @@ namespace gl { public: program(); - program(std::vector>); + program(std::vector>); ~program(); using bindable::bind; diff --git a/gl/ubo.cpp b/gl/ubo.cpp index cecf84f0..10288b01 100644 --- a/gl/ubo.cpp +++ b/gl/ubo.cpp @@ -3,17 +3,17 @@ gl::ubo::ubo(size_t size, int idx, GLenum hint) { - allocate(buffer::UNIFORM_BUFFER, size, hint); + allocate(UNIFORM_BUFFER, size, hint); index = idx; bind_uniform(); } void gl::ubo::bind_uniform() { - bind_base(buffer::UNIFORM_BUFFER, index); + bind_base(UNIFORM_BUFFER, index); } void gl::ubo::update(const uint8_t *data, int offset, GLsizeiptr size) { - upload(buffer::UNIFORM_BUFFER, data, offset, size); + upload(UNIFORM_BUFFER, data, offset, size); } diff --git a/gl/vao.cpp b/gl/vao.cpp index 6d1e055d..54bb5fde 100644 --- a/gl/vao.cpp +++ b/gl/vao.cpp @@ -20,7 +20,7 @@ gl::vao::~vao() glDeleteVertexArrays(1, *this); } -void gl::vao::setup_attrib(gl::buffer &buffer, int attrib, int size, int type, int stride, int offset) +void gl::vao::setup_attrib(buffer &buffer, int attrib, int size, int type, int stride, int offset) { if (use_vao) { bind(); @@ -61,7 +61,7 @@ void gl::vao::bind() } else { for (attrib_params ¶m : params) { - param.buffer.bind(gl::buffer::ARRAY_BUFFER); + param.buffer.bind(buffer::ARRAY_BUFFER); glVertexAttribPointer(param.attrib, param.size, param.type, GL_FALSE, param.stride, reinterpret_cast(param.offset)); glEnableVertexAttribArray(param.attrib); } @@ -70,9 +70,9 @@ void gl::vao::bind() glDisableVertexAttribArray(i); if (ebo) - ebo->bind(gl::buffer::ELEMENT_ARRAY_BUFFER); + ebo->bind(buffer::ELEMENT_ARRAY_BUFFER); else - gl::buffer::unbind(gl::buffer::ELEMENT_ARRAY_BUFFER); + buffer::unbind(buffer::ELEMENT_ARRAY_BUFFER); } } diff --git a/gl/vao.h b/gl/vao.h index a4415d03..7f2ef4f2 100644 --- a/gl/vao.h +++ b/gl/vao.h @@ -10,7 +10,7 @@ namespace gl { struct attrib_params { // TBD: should be shared_ptr? (when buffer is destroyed by owner VAO could still potentially exist) - gl::buffer &buffer; + buffer &buffer; int attrib; int size; diff --git a/imgui/imgui.cpp b/imgui/imgui.cpp index 28fb8e38..dae7426a 100644 --- a/imgui/imgui.cpp +++ b/imgui/imgui.cpp @@ -3904,20 +3904,20 @@ void ImGui::UpdateDebugToolItemPicker() if (g.DebugItemPickerActive) { const ImGuiID hovered_id = g.HoveredIdPreviousFrame; - ImGui::SetMouseCursor(ImGuiMouseCursor_Hand); - if (ImGui::IsKeyPressedMap(ImGuiKey_Escape)) + SetMouseCursor(ImGuiMouseCursor_Hand); + if (IsKeyPressedMap(ImGuiKey_Escape)) g.DebugItemPickerActive = false; - if (ImGui::IsMouseClicked(0) && hovered_id) + if (IsMouseClicked(0) && hovered_id) { g.DebugItemPickerBreakID = hovered_id; g.DebugItemPickerActive = false; } - ImGui::SetNextWindowBgAlpha(0.60f); - ImGui::BeginTooltip(); - ImGui::Text("HoveredId: 0x%08X", hovered_id); - ImGui::Text("Press ESC to abort picking."); - ImGui::TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!"); - ImGui::EndTooltip(); + SetNextWindowBgAlpha(0.60f); + BeginTooltip(); + Text("HoveredId: 0x%08X", hovered_id); + Text("Press ESC to abort picking."); + TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!"); + EndTooltip(); } } @@ -9635,43 +9635,43 @@ static const char* GetClipboardTextFn_DefaultImpl(void*) { static ImVector buf_local; buf_local.clear(); - if (!::OpenClipboard(NULL)) + if (!OpenClipboard(NULL)) return NULL; - const HANDLE wbuf_handle = ::GetClipboardData(CF_UNICODETEXT); + const HANDLE wbuf_handle = GetClipboardData(CF_UNICODETEXT); if (wbuf_handle == NULL) { - ::CloseClipboard(); + CloseClipboard(); return NULL; } - if (const auto wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle)) + if (const auto wbuf_global = (ImWchar*)GlobalLock(wbuf_handle)) { const int buf_len = ImTextCountUtf8BytesFromStr(wbuf_global, NULL) + 1; buf_local.resize(buf_len); ImTextStrToUtf8(buf_local.Data, buf_len, wbuf_global, NULL); } - ::GlobalUnlock(wbuf_handle); - ::CloseClipboard(); + GlobalUnlock(wbuf_handle); + CloseClipboard(); return buf_local.Data; } static void SetClipboardTextFn_DefaultImpl(void*, const char* text) { - if (!::OpenClipboard(NULL)) + if (!OpenClipboard(NULL)) return; const int wbuf_length = ImTextCountCharsFromUtf8(text, NULL) + 1; - const HGLOBAL wbuf_handle = ::GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length * sizeof(ImWchar)); + const HGLOBAL wbuf_handle = GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length * sizeof(ImWchar)); if (wbuf_handle == NULL) { - ::CloseClipboard(); + CloseClipboard(); return; } - const auto wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle); + const auto wbuf_global = (ImWchar*)GlobalLock(wbuf_handle); ImTextStrFromUtf8(wbuf_global, wbuf_length, text, NULL); - ::GlobalUnlock(wbuf_handle); - ::EmptyClipboard(); - if (::SetClipboardData(CF_UNICODETEXT, wbuf_handle) == NULL) - ::GlobalFree(wbuf_handle); - ::CloseClipboard(); + GlobalUnlock(wbuf_handle); + EmptyClipboard(); + if (SetClipboardData(CF_UNICODETEXT, wbuf_handle) == NULL) + GlobalFree(wbuf_handle); + CloseClipboard(); } #elif defined(__APPLE__) && TARGET_OS_OSX && defined(IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS) @@ -9760,14 +9760,14 @@ static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y) // Notify OS Input Method Editor of text input position const ImGuiIO & io = ImGui::GetIO(); if (const auto hwnd = (HWND)io.ImeWindowHandle) - if (const HIMC himc = ::ImmGetContext(hwnd)) + if (const HIMC himc = ImmGetContext(hwnd)) { COMPOSITIONFORM cf; cf.ptCurrentPos.x = x; cf.ptCurrentPos.y = y; cf.dwStyle = CFS_FORCE_POSITION; - ::ImmSetCompositionWindow(himc, &cf); - ::ImmReleaseContext(hwnd, himc); + ImmSetCompositionWindow(himc, &cf); + ImmReleaseContext(hwnd, himc); } } @@ -9784,9 +9784,9 @@ static void ImeSetInputScreenPosFn_DefaultImpl(int, int) {} #ifndef IMGUI_DISABLE_METRICS_WINDOW void ImGui::ShowMetricsWindow(bool* p_open) { - if (!ImGui::Begin("Dear ImGui Metrics", p_open)) + if (!Begin("Dear ImGui Metrics", p_open)) { - ImGui::End(); + End(); return; } @@ -9800,13 +9800,13 @@ void ImGui::ShowMetricsWindow(bool* p_open) // Basic info ImGuiContext& g = *GImGui; - const ImGuiIO & io = ImGui::GetIO(); - ImGui::Text("Dear ImGui %s", ImGui::GetVersion()); - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); - ImGui::Text("%d vertices, %d indices (%d triangles)", io.MetricsRenderVertices, io.MetricsRenderIndices, io.MetricsRenderIndices / 3); - ImGui::Text("%d active windows (%d visible)", io.MetricsActiveWindows, io.MetricsRenderWindows); - ImGui::Text("%d active allocations", io.MetricsActiveAllocations); - ImGui::Separator(); + const ImGuiIO & io = GetIO(); + Text("Dear ImGui %s", GetVersion()); + Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); + Text("%d vertices, %d indices (%d triangles)", io.MetricsRenderVertices, io.MetricsRenderIndices, io.MetricsRenderIndices / 3); + Text("%d active windows (%d visible)", io.MetricsActiveWindows, io.MetricsRenderWindows); + Text("%d active allocations", io.MetricsActiveAllocations); + Separator(); // Helper functions to display common structures: // - NodeDrawList @@ -9832,12 +9832,12 @@ void ImGui::ShowMetricsWindow(bool* p_open) static void NodeDrawList(ImGuiWindow* window, ImDrawList* draw_list, const char* label) { - const bool node_open = ImGui::TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, draw_list->CmdBuffer.Size); - if (draw_list == ImGui::GetWindowDrawList()) + const bool node_open = TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, draw_list->CmdBuffer.Size); + if (draw_list == GetWindowDrawList()) { - ImGui::SameLine(); - ImGui::TextColored(ImVec4(1.0f,0.4f,0.4f,1.0f), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered) - if (node_open) ImGui::TreePop(); + SameLine(); + TextColored(ImVec4(1.0f,0.4f,0.4f,1.0f), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered) + if (node_open) TreePop(); return; } @@ -9848,7 +9848,7 @@ void ImGui::ShowMetricsWindow(bool* p_open) return; if (window && !window->WasActive) - ImGui::Text("(Note: owning Window is inactive: DrawList is not being rendered!)"); + Text("(Note: owning Window is inactive: DrawList is not being rendered!)"); int elem_offset = 0; for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.begin(); pcmd < draw_list->CmdBuffer.end(); elem_offset += pcmd->ElemCount, pcmd++) @@ -9857,15 +9857,15 @@ void ImGui::ShowMetricsWindow(bool* p_open) continue; if (pcmd->UserCallback) { - ImGui::BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData); + BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData); continue; } const ImDrawIdx * idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; char buf[300]; ImFormatString(buf, IM_ARRAYSIZE(buf), "Draw %4d triangles, tex 0x%p, clip_rect (%4.0f,%4.0f)-(%4.0f,%4.0f)", pcmd->ElemCount/3, (void*)(intptr_t)pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); - const bool pcmd_node_open = ImGui::TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf); - if (show_drawcmd_clip_rects && fg_draw_list && ImGui::IsItemHovered()) + const bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf); + if (show_drawcmd_clip_rects && fg_draw_list && IsItemHovered()) { ImRect clip_rect = pcmd->ClipRect; ImRect vtxs_rect; @@ -9878,7 +9878,7 @@ void ImGui::ShowMetricsWindow(bool* p_open) continue; // Display individual triangles/vertices. Hover on to get the corresponding triangle highlighted. - ImGui::Text("ElemCount: %d, ElemCount/3: %d, VtxOffset: +%d, IdxOffset: +%d", pcmd->ElemCount, pcmd->ElemCount/3, pcmd->VtxOffset, pcmd->IdxOffset); + Text("ElemCount: %d, ElemCount/3: %d, VtxOffset: +%d, IdxOffset: +%d", pcmd->ElemCount, pcmd->ElemCount/3, pcmd->VtxOffset, pcmd->IdxOffset); ImGuiListClipper clipper(pcmd->ElemCount/3); // Manually coarse clip our print out of individual vertices to save CPU, only items that may be visible. while (clipper.Step()) for (int prim = clipper.DisplayStart, idx_i = elem_offset + clipper.DisplayStart*3; prim < clipper.DisplayEnd; prim++) @@ -9893,8 +9893,8 @@ void ImGui::ShowMetricsWindow(bool* p_open) buf_p += ImFormatString(buf_p, buf_end - buf_p, "%s %04d: pos (%8.2f,%8.2f), uv (%.6f,%.6f), col %08X\n", (n == 0) ? "elem" : " ", idx_i, v.pos.x, v.pos.y, v.uv.x, v.uv.y, v.col); } - ImGui::Selectable(buf, false); - if (fg_draw_list && ImGui::IsItemHovered()) + Selectable(buf, false); + if (fg_draw_list && IsItemHovered()) { const ImDrawListFlags backup_flags = fg_draw_list->Flags; fg_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines at is more readable for very large and thin triangles. @@ -9902,66 +9902,66 @@ void ImGui::ShowMetricsWindow(bool* p_open) fg_draw_list->Flags = backup_flags; } } - ImGui::TreePop(); + TreePop(); } - ImGui::TreePop(); + TreePop(); } static void NodeColumns(const ImGuiColumns* columns) { - if (!ImGui::TreeNode((void*)(uintptr_t)columns->ID, "Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns->ID, columns->Count, columns->Flags)) + if (!TreeNode((void*)(uintptr_t)columns->ID, "Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns->ID, columns->Count, columns->Flags)) return; - ImGui::BulletText("Width: %.1f (MinX: %.1f, MaxX: %.1f)", columns->OffMaxX - columns->OffMinX, columns->OffMinX, columns->OffMaxX); + BulletText("Width: %.1f (MinX: %.1f, MaxX: %.1f)", columns->OffMaxX - columns->OffMinX, columns->OffMinX, columns->OffMaxX); for (int column_n = 0; column_n < columns->Columns.Size; column_n++) - ImGui::BulletText("Column %02d: OffsetNorm %.3f (= %.1f px)", column_n, columns->Columns[column_n].OffsetNorm, GetColumnOffsetFromNorm(columns, columns->Columns[column_n].OffsetNorm)); - ImGui::TreePop(); + BulletText("Column %02d: OffsetNorm %.3f (= %.1f px)", column_n, columns->Columns[column_n].OffsetNorm, GetColumnOffsetFromNorm(columns, columns->Columns[column_n].OffsetNorm)); + TreePop(); } static void NodeWindows(ImVector& windows, const char* label) { - if (!ImGui::TreeNode(label, "%s (%d)", label, windows.Size)) + if (!TreeNode(label, "%s (%d)", label, windows.Size)) return; for (int i = 0; i < windows.Size; i++) - Funcs::NodeWindow(windows[i], "Window"); - ImGui::TreePop(); + NodeWindow(windows[i], "Window"); + TreePop(); } static void NodeWindow(ImGuiWindow* window, const char* label) { if (window == NULL) { - ImGui::BulletText("%s: NULL", label); + BulletText("%s: NULL", label); return; } - if (!ImGui::TreeNode(window, "%s '%s', %d @ 0x%p", label, window->Name, (window->Active || window->WasActive), window)) + if (!TreeNode(window, "%s '%s', %d @ 0x%p", label, window->Name, (window->Active || window->WasActive), window)) return; const ImGuiWindowFlags flags = window->Flags; NodeDrawList(window, window->DrawList, "DrawList"); - ImGui::BulletText("Pos: (%.1f,%.1f), Size: (%.1f,%.1f), ContentSize (%.1f,%.1f)", window->Pos.x, window->Pos.y, window->Size.x, window->Size.y, window->ContentSize.x, window->ContentSize.y); - ImGui::BulletText("Flags: 0x%08X (%s%s%s%s%s%s%s%s%s..)", flags, + BulletText("Pos: (%.1f,%.1f), Size: (%.1f,%.1f), ContentSize (%.1f,%.1f)", window->Pos.x, window->Pos.y, window->Size.x, window->Size.y, window->ContentSize.x, window->ContentSize.y); + BulletText("Flags: 0x%08X (%s%s%s%s%s%s%s%s%s..)", flags, (flags & ImGuiWindowFlags_ChildWindow) ? "Child " : "", (flags & ImGuiWindowFlags_Tooltip) ? "Tooltip " : "", (flags & ImGuiWindowFlags_Popup) ? "Popup " : "", (flags & ImGuiWindowFlags_Modal) ? "Modal " : "", (flags & ImGuiWindowFlags_ChildMenu) ? "ChildMenu " : "", (flags & ImGuiWindowFlags_NoSavedSettings) ? "NoSavedSettings " : "", (flags & ImGuiWindowFlags_NoMouseInputs)? "NoMouseInputs":"", (flags & ImGuiWindowFlags_NoNavInputs) ? "NoNavInputs" : "", (flags & ImGuiWindowFlags_AlwaysAutoResize) ? "AlwaysAutoResize" : ""); - ImGui::BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f)", window->Scroll.x, window->ScrollMax.x, window->Scroll.y, window->ScrollMax.y); - ImGui::BulletText("Active: %d/%d, WriteAccessed: %d, BeginOrderWithinContext: %d", window->Active, window->WasActive, window->WriteAccessed, (window->Active || window->WasActive) ? window->BeginOrderWithinContext : -1); - ImGui::BulletText("Appearing: %d, Hidden: %d (CanSkip %d Cannot %d), SkipItems: %d", window->Appearing, window->Hidden, window->HiddenFramesCanSkipItems, window->HiddenFramesCannotSkipItems, window->SkipItems); - ImGui::BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask); - ImGui::BulletText("NavLastChildNavWindow: %s", window->NavLastChildNavWindow ? window->NavLastChildNavWindow->Name : "NULL"); + BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f)", window->Scroll.x, window->ScrollMax.x, window->Scroll.y, window->ScrollMax.y); + BulletText("Active: %d/%d, WriteAccessed: %d, BeginOrderWithinContext: %d", window->Active, window->WasActive, window->WriteAccessed, (window->Active || window->WasActive) ? window->BeginOrderWithinContext : -1); + BulletText("Appearing: %d, Hidden: %d (CanSkip %d Cannot %d), SkipItems: %d", window->Appearing, window->Hidden, window->HiddenFramesCanSkipItems, window->HiddenFramesCannotSkipItems, window->SkipItems); + BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask); + BulletText("NavLastChildNavWindow: %s", window->NavLastChildNavWindow ? window->NavLastChildNavWindow->Name : "NULL"); if (!window->NavRectRel[0].IsInverted()) - ImGui::BulletText("NavRectRel[0]: (%.1f,%.1f)(%.1f,%.1f)", window->NavRectRel[0].Min.x, window->NavRectRel[0].Min.y, window->NavRectRel[0].Max.x, window->NavRectRel[0].Max.y); + BulletText("NavRectRel[0]: (%.1f,%.1f)(%.1f,%.1f)", window->NavRectRel[0].Min.x, window->NavRectRel[0].Min.y, window->NavRectRel[0].Max.x, window->NavRectRel[0].Max.y); else - ImGui::BulletText("NavRectRel[0]: "); + BulletText("NavRectRel[0]: "); if (window->RootWindow != window) NodeWindow(window->RootWindow, "RootWindow"); if (window->ParentWindow != NULL) NodeWindow(window->ParentWindow, "ParentWindow"); if (window->DC.ChildWindows.Size > 0) NodeWindows(window->DC.ChildWindows, "ChildWindows"); - if (window->ColumnsStorage.Size > 0 && ImGui::TreeNode("Columns", "Columns sets (%d)", window->ColumnsStorage.Size)) + if (window->ColumnsStorage.Size > 0 && TreeNode("Columns", "Columns sets (%d)", window->ColumnsStorage.Size)) { for (int n = 0; n < window->ColumnsStorage.Size; n++) NodeColumns(&window->ColumnsStorage[n]); - ImGui::TreePop(); + TreePop(); } - ImGui::BulletText("Storage: %d bytes", window->StateStorage.Data.size_in_bytes()); - ImGui::TreePop(); + BulletText("Storage: %d bytes", window->StateStorage.Data.size_in_bytes()); + TreePop(); } static void NodeTabBar(ImGuiTabBar* tab_bar) @@ -9970,46 +9970,46 @@ void ImGui::ShowMetricsWindow(bool* p_open) char buf[256]; char* p = buf; const char* buf_end = buf + IM_ARRAYSIZE(buf); - ImFormatString(p, buf_end - p, "TabBar (%d tabs)%s", tab_bar->Tabs.Size, (tab_bar->PrevFrameVisible < ImGui::GetFrameCount() - 2) ? " *Inactive*" : ""); - if (ImGui::TreeNode(tab_bar, "%s", buf)) + ImFormatString(p, buf_end - p, "TabBar (%d tabs)%s", tab_bar->Tabs.Size, (tab_bar->PrevFrameVisible < GetFrameCount() - 2) ? " *Inactive*" : ""); + if (TreeNode(tab_bar, "%s", buf)) { for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) { const ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; - ImGui::PushID(tab); - if (ImGui::SmallButton("<")) { TabBarQueueChangeTabOrder(tab_bar, tab, -1); } ImGui::SameLine(0, 2); - if (ImGui::SmallButton(">")) { TabBarQueueChangeTabOrder(tab_bar, tab, +1); } ImGui::SameLine(); - ImGui::Text("%02d%c Tab 0x%08X", tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID); - ImGui::PopID(); + PushID(tab); + if (SmallButton("<")) { TabBarQueueChangeTabOrder(tab_bar, tab, -1); } SameLine(0, 2); + if (SmallButton(">")) { TabBarQueueChangeTabOrder(tab_bar, tab, +1); } SameLine(); + Text("%02d%c Tab 0x%08X", tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID); + PopID(); } - ImGui::TreePop(); + TreePop(); } } }; Funcs::NodeWindows(g.Windows, "Windows"); - if (ImGui::TreeNode("DrawList", "Active DrawLists (%d)", g.DrawDataBuilder.Layers[0].Size)) + if (TreeNode("DrawList", "Active DrawLists (%d)", g.DrawDataBuilder.Layers[0].Size)) { for (int i = 0; i < g.DrawDataBuilder.Layers[0].Size; i++) Funcs::NodeDrawList(NULL, g.DrawDataBuilder.Layers[0][i], "DrawList"); - ImGui::TreePop(); + TreePop(); } - if (ImGui::TreeNode("Popups", "Popups (%d)", g.OpenPopupStack.Size)) + if (TreeNode("Popups", "Popups (%d)", g.OpenPopupStack.Size)) { for (int i = 0; i < g.OpenPopupStack.Size; i++) { const ImGuiWindow * window = g.OpenPopupStack[i].Window; - ImGui::BulletText("PopupID: %08x, Window: '%s'%s%s", g.OpenPopupStack[i].PopupId, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? " ChildWindow" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? " ChildMenu" : ""); + BulletText("PopupID: %08x, Window: '%s'%s%s", g.OpenPopupStack[i].PopupId, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? " ChildWindow" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? " ChildMenu" : ""); } - ImGui::TreePop(); + TreePop(); } - if (ImGui::TreeNode("TabBars", "Tab Bars (%d)", g.TabBars.Data.Size)) + if (TreeNode("TabBars", "Tab Bars (%d)", g.TabBars.Data.Size)) { for (int n = 0; n < g.TabBars.Data.Size; n++) Funcs::NodeTabBar(g.TabBars.GetByIndex(n)); - ImGui::TreePop(); + TreePop(); } #if 0 @@ -10026,50 +10026,50 @@ void ImGui::ShowMetricsWindow(bool* p_open) } #endif - if (ImGui::TreeNode("Internal state")) + if (TreeNode("Internal state")) { const char* input_source_names[] = { "None", "Mouse", "Nav", "NavKeyboard", "NavGamepad" }; IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT); - ImGui::Text("HoveredWindow: '%s'", g.HoveredWindow ? g.HoveredWindow->Name : "NULL"); - ImGui::Text("HoveredRootWindow: '%s'", g.HoveredRootWindow ? g.HoveredRootWindow->Name : "NULL"); - ImGui::Text("HoveredId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredId, g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Data is "in-flight" so depending on when the Metrics window is called we may see current frame information or not - ImGui::Text("ActiveId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d, Source: %s", g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdTimer, g.ActiveIdAllowOverlap, input_source_names[g.ActiveIdSource]); - ImGui::Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL"); - ImGui::Text("MovingWindow: '%s'", g.MovingWindow ? g.MovingWindow->Name : "NULL"); - ImGui::Text("NavWindow: '%s'", g.NavWindow ? g.NavWindow->Name : "NULL"); - ImGui::Text("NavId: 0x%08X, NavLayer: %d", g.NavId, g.NavLayer); - ImGui::Text("NavInputSource: %s", input_source_names[g.NavInputSource]); - ImGui::Text("NavActive: %d, NavVisible: %d", g.IO.NavActive, g.IO.NavVisible); - ImGui::Text("NavActivateId: 0x%08X, NavInputId: 0x%08X", g.NavActivateId, g.NavInputId); - ImGui::Text("NavDisableHighlight: %d, NavDisableMouseHover: %d", g.NavDisableHighlight, g.NavDisableMouseHover); - ImGui::Text("NavWindowingTarget: '%s'", g.NavWindowingTarget ? g.NavWindowingTarget->Name : "NULL"); - ImGui::Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize); - ImGui::TreePop(); + Text("HoveredWindow: '%s'", g.HoveredWindow ? g.HoveredWindow->Name : "NULL"); + Text("HoveredRootWindow: '%s'", g.HoveredRootWindow ? g.HoveredRootWindow->Name : "NULL"); + Text("HoveredId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredId, g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Data is "in-flight" so depending on when the Metrics window is called we may see current frame information or not + Text("ActiveId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d, Source: %s", g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdTimer, g.ActiveIdAllowOverlap, input_source_names[g.ActiveIdSource]); + Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL"); + Text("MovingWindow: '%s'", g.MovingWindow ? g.MovingWindow->Name : "NULL"); + Text("NavWindow: '%s'", g.NavWindow ? g.NavWindow->Name : "NULL"); + Text("NavId: 0x%08X, NavLayer: %d", g.NavId, g.NavLayer); + Text("NavInputSource: %s", input_source_names[g.NavInputSource]); + Text("NavActive: %d, NavVisible: %d", g.IO.NavActive, g.IO.NavVisible); + Text("NavActivateId: 0x%08X, NavInputId: 0x%08X", g.NavActivateId, g.NavInputId); + Text("NavDisableHighlight: %d, NavDisableMouseHover: %d", g.NavDisableHighlight, g.NavDisableMouseHover); + Text("NavWindowingTarget: '%s'", g.NavWindowingTarget ? g.NavWindowingTarget->Name : "NULL"); + Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize); + TreePop(); } - if (ImGui::TreeNode("Tools")) + if (TreeNode("Tools")) { // The Item Picker tool is super useful to visually select an item and break into the call-stack of where it was submitted. - if (ImGui::Button("Item Picker..")) - ImGui::DebugStartItemPicker(); + if (Button("Item Picker..")) + DebugStartItemPicker(); - ImGui::Checkbox("Show windows begin order", &show_windows_begin_order); - ImGui::Checkbox("Show windows rectangles", &show_windows_rects); - ImGui::SameLine(); - ImGui::SetNextItemWidth(ImGui::GetFontSize() * 12); - show_windows_rects |= ImGui::Combo("##show_windows_rect_type", &show_windows_rect_type, wrt_rects_names, WRT_Count); + Checkbox("Show windows begin order", &show_windows_begin_order); + Checkbox("Show windows rectangles", &show_windows_rects); + SameLine(); + SetNextItemWidth(GetFontSize() * 12); + show_windows_rects |= Combo("##show_windows_rect_type", &show_windows_rect_type, wrt_rects_names, WRT_Count); if (show_windows_rects && g.NavWindow) { - ImGui::BulletText("'%s':", g.NavWindow->Name); - ImGui::Indent(); + BulletText("'%s':", g.NavWindow->Name); + Indent(); for (int rect_n = 0; rect_n < WRT_Count; rect_n++) { ImRect r = Funcs::GetWindowRect(g.NavWindow, rect_n); - ImGui::Text("(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), wrt_rects_names[rect_n]); + Text("(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), wrt_rects_names[rect_n]); } - ImGui::Unindent(); + Unindent(); } - ImGui::Checkbox("Show clipping rectangle when hovering ImDrawCmd node", &show_drawcmd_clip_rects); - ImGui::TreePop(); + Checkbox("Show clipping rectangle when hovering ImDrawCmd node", &show_drawcmd_clip_rects); + TreePop(); } // Tool: Display windows Rectangles and Begin Order @@ -10090,13 +10090,13 @@ void ImGui::ShowMetricsWindow(bool* p_open) { char buf[32]; ImFormatString(buf, IM_ARRAYSIZE(buf), "%d", window->BeginOrderWithinContext); - const float font_size = ImGui::GetFontSize(); + const float font_size = GetFontSize(); draw_list->AddRectFilled(window->Pos, window->Pos + ImVec2(font_size, font_size), IM_COL32(200, 100, 100, 255)); draw_list->AddText(window->Pos, IM_COL32(255, 255, 255, 255), buf); } } } - ImGui::End(); + End(); } #else diff --git a/imgui/imgui_demo.cpp b/imgui/imgui_demo.cpp index c3357fa4..a5352c6e 100644 --- a/imgui/imgui_demo.cpp +++ b/imgui/imgui_demo.cpp @@ -152,25 +152,25 @@ static void HelpMarker(const char* desc) // Helper to display basic user controls. void ImGui::ShowUserGuide() { - const ImGuiIO & io = ImGui::GetIO(); - ImGui::BulletText("Double-click on title bar to collapse window."); - ImGui::BulletText("Click and drag on lower right corner to resize window\n(double-click to auto fit window to its contents)."); - ImGui::BulletText("Click and drag on any empty space to move window."); - ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields."); - ImGui::BulletText("CTRL+Click on a slider or drag box to input value as text."); + const ImGuiIO & io = GetIO(); + BulletText("Double-click on title bar to collapse window."); + BulletText("Click and drag on lower right corner to resize window\n(double-click to auto fit window to its contents)."); + BulletText("Click and drag on any empty space to move window."); + BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields."); + BulletText("CTRL+Click on a slider or drag box to input value as text."); if (io.FontAllowUserScaling) - ImGui::BulletText("CTRL+Mouse Wheel to zoom window contents."); - ImGui::BulletText("Mouse Wheel to scroll."); - ImGui::BulletText("While editing text:\n"); - ImGui::Indent(); - ImGui::BulletText("Hold SHIFT or use mouse to select text."); - ImGui::BulletText("CTRL+Left/Right to word jump."); - ImGui::BulletText("CTRL+A or double-click to select all."); - ImGui::BulletText("CTRL+X,CTRL+C,CTRL+V to use clipboard."); - ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo."); - ImGui::BulletText("ESCAPE to revert."); - ImGui::BulletText("You can apply arithmetic operators +,*,/ on numerical values.\nUse +- to subtract."); - ImGui::Unindent(); + BulletText("CTRL+Mouse Wheel to zoom window contents."); + BulletText("Mouse Wheel to scroll."); + BulletText("While editing text:\n"); + Indent(); + BulletText("Hold SHIFT or use mouse to select text."); + BulletText("CTRL+Left/Right to word jump."); + BulletText("CTRL+A or double-click to select all."); + BulletText("CTRL+X,CTRL+C,CTRL+V to use clipboard."); + BulletText("CTRL+Z,CTRL+Y to undo/redo."); + BulletText("ESCAPE to revert."); + BulletText("You can apply arithmetic operators +,*,/ on numerical values.\nUse +- to subtract."); + Unindent(); } //----------------------------------------------------------------------------- @@ -222,9 +222,9 @@ void ImGui::ShowDemoWindow(bool* p_open) static bool show_app_style_editor = false; static bool show_app_about = false; - if (show_app_metrics) { ImGui::ShowMetricsWindow(&show_app_metrics); } - if (show_app_style_editor) { ImGui::Begin("Style Editor", &show_app_style_editor); ImGui::ShowStyleEditor(); ImGui::End(); } - if (show_app_about) { ImGui::ShowAboutWindow(&show_app_about); } + if (show_app_metrics) { ShowMetricsWindow(&show_app_metrics); } + if (show_app_style_editor) { Begin("Style Editor", &show_app_style_editor); ShowStyleEditor(); End(); } + if (show_app_about) { ShowAboutWindow(&show_app_about); } // Demonstrate the various window flags. Typically you would just use the default! static bool no_titlebar = false; @@ -251,154 +251,154 @@ void ImGui::ShowDemoWindow(bool* p_open) if (no_close) p_open = NULL; // Don't pass our bool* to Begin // We specify a default position/size in case there's no data in the .ini file. Typically this isn't required! We only do it to make the Demo applications a little more welcoming. - ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); - ImGui::SetNextWindowSize(ImVec2(550, 680), ImGuiCond_FirstUseEver); + SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); + SetNextWindowSize(ImVec2(550, 680), ImGuiCond_FirstUseEver); // Main body of the Demo window starts here. - if (!ImGui::Begin("Dear ImGui Demo", p_open, window_flags)) + if (!Begin("Dear ImGui Demo", p_open, window_flags)) { // Early out if the window is collapsed, as an optimization. - ImGui::End(); + End(); return; } // Most "big" widgets share a common width settings by default. //ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.65f); // Use 2/3 of the space for widgets and 1/3 for labels (default) - ImGui::PushItemWidth(ImGui::GetFontSize() * -12); // Use fixed width for labels (by passing a negative value), the rest goes to widgets. We choose a width proportional to our font size. + PushItemWidth(GetFontSize() * -12); // Use fixed width for labels (by passing a negative value), the rest goes to widgets. We choose a width proportional to our font size. // Menu Bar - if (ImGui::BeginMenuBar()) + if (BeginMenuBar()) { - if (ImGui::BeginMenu("Menu")) + if (BeginMenu("Menu")) { ShowExampleMenuFile(); - ImGui::EndMenu(); + EndMenu(); } - if (ImGui::BeginMenu("Examples")) + if (BeginMenu("Examples")) { - ImGui::MenuItem("Main menu bar", NULL, &show_app_main_menu_bar); - ImGui::MenuItem("Console", NULL, &show_app_console); - ImGui::MenuItem("Log", NULL, &show_app_log); - ImGui::MenuItem("Simple layout", NULL, &show_app_layout); - ImGui::MenuItem("Property editor", NULL, &show_app_property_editor); - ImGui::MenuItem("Long text display", NULL, &show_app_long_text); - ImGui::MenuItem("Auto-resizing window", NULL, &show_app_auto_resize); - ImGui::MenuItem("Constrained-resizing window", NULL, &show_app_constrained_resize); - ImGui::MenuItem("Simple overlay", NULL, &show_app_simple_overlay); - ImGui::MenuItem("Manipulating window titles", NULL, &show_app_window_titles); - ImGui::MenuItem("Custom rendering", NULL, &show_app_custom_rendering); - ImGui::MenuItem("Documents", NULL, &show_app_documents); - ImGui::EndMenu(); + MenuItem("Main menu bar", NULL, &show_app_main_menu_bar); + MenuItem("Console", NULL, &show_app_console); + MenuItem("Log", NULL, &show_app_log); + MenuItem("Simple layout", NULL, &show_app_layout); + MenuItem("Property editor", NULL, &show_app_property_editor); + MenuItem("Long text display", NULL, &show_app_long_text); + MenuItem("Auto-resizing window", NULL, &show_app_auto_resize); + MenuItem("Constrained-resizing window", NULL, &show_app_constrained_resize); + MenuItem("Simple overlay", NULL, &show_app_simple_overlay); + MenuItem("Manipulating window titles", NULL, &show_app_window_titles); + MenuItem("Custom rendering", NULL, &show_app_custom_rendering); + MenuItem("Documents", NULL, &show_app_documents); + EndMenu(); } - if (ImGui::BeginMenu("Help")) + if (BeginMenu("Help")) { - ImGui::MenuItem("Metrics", NULL, &show_app_metrics); - ImGui::MenuItem("Style Editor", NULL, &show_app_style_editor); - ImGui::MenuItem("About Dear ImGui", NULL, &show_app_about); - ImGui::EndMenu(); + MenuItem("Metrics", NULL, &show_app_metrics); + MenuItem("Style Editor", NULL, &show_app_style_editor); + MenuItem("About Dear ImGui", NULL, &show_app_about); + EndMenu(); } - ImGui::EndMenuBar(); + EndMenuBar(); } - ImGui::Text("dear imgui says hello. (%s)", IMGUI_VERSION); - ImGui::Spacing(); + Text("dear imgui says hello. (%s)", IMGUI_VERSION); + Spacing(); - if (ImGui::CollapsingHeader("Help")) + if (CollapsingHeader("Help")) { - ImGui::Text("PROGRAMMER GUIDE:"); - ImGui::BulletText("Please see the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!"); - ImGui::BulletText("Please see the comments in imgui.cpp."); - ImGui::BulletText("Please see the examples/ in application."); - ImGui::BulletText("Enable 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls."); - ImGui::BulletText("Enable 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls."); - ImGui::Separator(); + Text("PROGRAMMER GUIDE:"); + BulletText("Please see the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!"); + BulletText("Please see the comments in imgui.cpp."); + BulletText("Please see the examples/ in application."); + BulletText("Enable 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls."); + BulletText("Enable 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls."); + Separator(); - ImGui::Text("USER GUIDE:"); - ImGui::ShowUserGuide(); + Text("USER GUIDE:"); + ShowUserGuide(); } - if (ImGui::CollapsingHeader("Configuration")) + if (CollapsingHeader("Configuration")) { - ImGuiIO& io = ImGui::GetIO(); + ImGuiIO& io = GetIO(); - if (ImGui::TreeNode("Configuration##2")) + if (TreeNode("Configuration##2")) { - ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard); - ImGui::CheckboxFlags("io.ConfigFlags: NavEnableGamepad", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad); - ImGui::SameLine(); HelpMarker("Required back-end to feed in gamepad inputs in io.NavInputs[] and set io.BackendFlags |= ImGuiBackendFlags_HasGamepad.\n\nRead instructions in imgui.cpp for details."); - ImGui::CheckboxFlags("io.ConfigFlags: NavEnableSetMousePos", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableSetMousePos); - ImGui::SameLine(); HelpMarker("Instruct navigation to move the mouse cursor. See comment for ImGuiConfigFlags_NavEnableSetMousePos."); - ImGui::CheckboxFlags("io.ConfigFlags: NoMouse", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NoMouse); + CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard); + CheckboxFlags("io.ConfigFlags: NavEnableGamepad", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad); + SameLine(); HelpMarker("Required back-end to feed in gamepad inputs in io.NavInputs[] and set io.BackendFlags |= ImGuiBackendFlags_HasGamepad.\n\nRead instructions in imgui.cpp for details."); + CheckboxFlags("io.ConfigFlags: NavEnableSetMousePos", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableSetMousePos); + SameLine(); HelpMarker("Instruct navigation to move the mouse cursor. See comment for ImGuiConfigFlags_NavEnableSetMousePos."); + CheckboxFlags("io.ConfigFlags: NoMouse", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NoMouse); if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) // Create a way to restore this flag otherwise we could be stuck completely! { - if (fmodf((float)ImGui::GetTime(), 0.40f) < 0.20f) + if (fmodf((float)GetTime(), 0.40f) < 0.20f) { - ImGui::SameLine(); - ImGui::Text("<>"); + SameLine(); + Text("<>"); } - if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Space))) + if (IsKeyPressed(GetKeyIndex(ImGuiKey_Space))) io.ConfigFlags &= ~ImGuiConfigFlags_NoMouse; } - ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange); - ImGui::SameLine(); HelpMarker("Instruct back-end to not alter mouse cursor shape and visibility."); - ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputTextCursorBlink); - ImGui::SameLine(); HelpMarker("Set to false to disable blinking cursor, for users who consider it distracting"); - ImGui::Checkbox("io.ConfigWindowsResizeFromEdges", &io.ConfigWindowsResizeFromEdges); - ImGui::SameLine(); HelpMarker("Enable resizing of windows from their edges and from the lower-left corner.\nThis requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback."); - ImGui::Checkbox("io.ConfigWindowsMoveFromTitleBarOnly", &io.ConfigWindowsMoveFromTitleBarOnly); - ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor); - ImGui::SameLine(); HelpMarker("Instruct Dear ImGui to render a mouse cursor for you. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something)."); - ImGui::TreePop(); - ImGui::Separator(); + CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange); + SameLine(); HelpMarker("Instruct back-end to not alter mouse cursor shape and visibility."); + Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputTextCursorBlink); + SameLine(); HelpMarker("Set to false to disable blinking cursor, for users who consider it distracting"); + Checkbox("io.ConfigWindowsResizeFromEdges", &io.ConfigWindowsResizeFromEdges); + SameLine(); HelpMarker("Enable resizing of windows from their edges and from the lower-left corner.\nThis requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback."); + Checkbox("io.ConfigWindowsMoveFromTitleBarOnly", &io.ConfigWindowsMoveFromTitleBarOnly); + Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor); + SameLine(); HelpMarker("Instruct Dear ImGui to render a mouse cursor for you. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something)."); + TreePop(); + Separator(); } - if (ImGui::TreeNode("Backend Flags")) + if (TreeNode("Backend Flags")) { HelpMarker("Those flags are set by the back-ends (imgui_impl_xxx files) to specify their capabilities."); ImGuiBackendFlags backend_flags = io.BackendFlags; // Make a local copy to avoid modifying actual back-end flags. - ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasGamepad); - ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasMouseCursors); - ImGui::CheckboxFlags("io.BackendFlags: HasSetMousePos", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasSetMousePos); - ImGui::CheckboxFlags("io.BackendFlags: RendererHasVtxOffset", (unsigned int *)&backend_flags, ImGuiBackendFlags_RendererHasVtxOffset); - ImGui::TreePop(); - ImGui::Separator(); + CheckboxFlags("io.BackendFlags: HasGamepad", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasGamepad); + CheckboxFlags("io.BackendFlags: HasMouseCursors", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasMouseCursors); + CheckboxFlags("io.BackendFlags: HasSetMousePos", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasSetMousePos); + CheckboxFlags("io.BackendFlags: RendererHasVtxOffset", (unsigned int *)&backend_flags, ImGuiBackendFlags_RendererHasVtxOffset); + TreePop(); + Separator(); } - if (ImGui::TreeNode("Style")) + if (TreeNode("Style")) { - ImGui::ShowStyleEditor(); - ImGui::TreePop(); - ImGui::Separator(); + ShowStyleEditor(); + TreePop(); + Separator(); } - if (ImGui::TreeNode("Capture/Logging")) + if (TreeNode("Capture/Logging")) { - ImGui::TextWrapped("The logging API redirects all text output so you can easily capture the content of a window or a block. Tree nodes can be automatically expanded."); + TextWrapped("The logging API redirects all text output so you can easily capture the content of a window or a block. Tree nodes can be automatically expanded."); HelpMarker("Try opening any of the contents below in this window and then click one of the \"Log To\" button."); - ImGui::LogButtons(); - ImGui::TextWrapped("You can also call ImGui::LogText() to output directly to the log without a visual output."); - if (ImGui::Button("Copy \"Hello, world!\" to clipboard")) + LogButtons(); + TextWrapped("You can also call ImGui::LogText() to output directly to the log without a visual output."); + if (Button("Copy \"Hello, world!\" to clipboard")) { - ImGui::LogToClipboard(); - ImGui::LogText("Hello, world!"); - ImGui::LogFinish(); + LogToClipboard(); + LogText("Hello, world!"); + LogFinish(); } - ImGui::TreePop(); + TreePop(); } } - if (ImGui::CollapsingHeader("Window options")) + if (CollapsingHeader("Window options")) { - ImGui::Checkbox("No titlebar", &no_titlebar); ImGui::SameLine(150); - ImGui::Checkbox("No scrollbar", &no_scrollbar); ImGui::SameLine(300); - ImGui::Checkbox("No menu", &no_menu); - ImGui::Checkbox("No move", &no_move); ImGui::SameLine(150); - ImGui::Checkbox("No resize", &no_resize); ImGui::SameLine(300); - ImGui::Checkbox("No collapse", &no_collapse); - ImGui::Checkbox("No close", &no_close); ImGui::SameLine(150); - ImGui::Checkbox("No nav", &no_nav); ImGui::SameLine(300); - ImGui::Checkbox("No background", &no_background); - ImGui::Checkbox("No bring to front", &no_bring_to_front); + Checkbox("No titlebar", &no_titlebar); SameLine(150); + Checkbox("No scrollbar", &no_scrollbar); SameLine(300); + Checkbox("No menu", &no_menu); + Checkbox("No move", &no_move); SameLine(150); + Checkbox("No resize", &no_resize); SameLine(300); + Checkbox("No collapse", &no_collapse); + Checkbox("No close", &no_close); SameLine(150); + Checkbox("No nav", &no_nav); SameLine(300); + Checkbox("No background", &no_background); + Checkbox("No bring to front", &no_bring_to_front); } // All demo contents @@ -409,7 +409,7 @@ void ImGui::ShowDemoWindow(bool* p_open) ShowDemoWindowMisc(); // End of ShowDemoWindow() - ImGui::End(); + End(); } static void ShowDemoWindowWidgets() @@ -1016,7 +1016,7 @@ static void ShowDemoWindowWidgets() static bool MyInputTextMultiline(const char* label, ImVector* my_str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0) { IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); - return ImGui::InputTextMultiline(label, my_str->begin(), (size_t)my_str->size(), size, flags | ImGuiInputTextFlags_CallbackResize, Funcs::MyResizeCallback, (void*)my_str); + return ImGui::InputTextMultiline(label, my_str->begin(), (size_t)my_str->size(), size, flags | ImGuiInputTextFlags_CallbackResize, MyResizeCallback, (void*)my_str); } }; @@ -2879,32 +2879,32 @@ static void ShowDemoWindowMisc() void ImGui::ShowAboutWindow(bool* p_open) { - if (!ImGui::Begin("About Dear ImGui", p_open, ImGuiWindowFlags_AlwaysAutoResize)) + if (!Begin("About Dear ImGui", p_open, ImGuiWindowFlags_AlwaysAutoResize)) { - ImGui::End(); + End(); return; } - ImGui::Text("Dear ImGui %s", ImGui::GetVersion()); - ImGui::Separator(); - ImGui::Text("By Omar Cornut and all dear imgui contributors."); - ImGui::Text("Dear ImGui is licensed under the MIT License, see LICENSE for more information."); + Text("Dear ImGui %s", GetVersion()); + Separator(); + Text("By Omar Cornut and all dear imgui contributors."); + Text("Dear ImGui is licensed under the MIT License, see LICENSE for more information."); static bool show_config_info = false; - ImGui::Checkbox("Config/Build Information", &show_config_info); + Checkbox("Config/Build Information", &show_config_info); if (show_config_info) { - const ImGuiIO & io = ImGui::GetIO(); - const ImGuiStyle & style = ImGui::GetStyle(); + const ImGuiIO & io = GetIO(); + const ImGuiStyle & style = GetStyle(); - const bool copy_to_clipboard = ImGui::Button("Copy to clipboard"); - ImGui::BeginChildFrame(ImGui::GetID("cfginfos"), ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * 18), ImGuiWindowFlags_NoMove); + const bool copy_to_clipboard = Button("Copy to clipboard"); + BeginChildFrame(GetID("cfginfos"), ImVec2(0, GetTextLineHeightWithSpacing() * 18), ImGuiWindowFlags_NoMove); if (copy_to_clipboard) - ImGui::LogToClipboard(); + LogToClipboard(); - ImGui::Text("Dear ImGui %s (%d)", IMGUI_VERSION, IMGUI_VERSION_NUM); - ImGui::Separator(); - ImGui::Text("sizeof(size_t): %d, sizeof(ImDrawIdx): %d, sizeof(ImDrawVert): %d", (int)sizeof(size_t), (int)sizeof(ImDrawIdx), (int)sizeof(ImDrawVert)); - ImGui::Text("define: __cplusplus=%d", (int)__cplusplus); + Text("Dear ImGui %s (%d)", IMGUI_VERSION, IMGUI_VERSION_NUM); + Separator(); + Text("sizeof(size_t): %d, sizeof(ImDrawIdx): %d, sizeof(ImDrawVert): %d", (int)sizeof(size_t), (int)sizeof(ImDrawIdx), (int)sizeof(ImDrawVert)); + Text("define: __cplusplus=%d", (int)__cplusplus); #ifdef IMGUI_DISABLE_OBSOLETE_FUNCTIONS ImGui::Text("define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS"); #endif @@ -2930,10 +2930,10 @@ void ImGui::ShowAboutWindow(bool* p_open) ImGui::Text("define: IMGUI_USE_BGRA_PACKED_COLOR"); #endif #ifdef _WIN32 - ImGui::Text("define: _WIN32"); + Text("define: _WIN32"); #endif #ifdef _WIN64 - ImGui::Text("define: _WIN64"); + Text("define: _WIN64"); #endif #ifdef __linux__ ImGui::Text("define: __linux__"); @@ -2942,7 +2942,7 @@ void ImGui::ShowAboutWindow(bool* p_open) ImGui::Text("define: __APPLE__"); #endif #ifdef _MSC_VER - ImGui::Text("define: _MSC_VER=%d", _MSC_VER); + Text("define: _MSC_VER=%d", _MSC_VER); #endif #ifdef __MINGW32__ ImGui::Text("define: __MINGW32__"); @@ -2956,44 +2956,44 @@ void ImGui::ShowAboutWindow(bool* p_open) #ifdef __clang_version__ ImGui::Text("define: __clang_version__=%s", __clang_version__); #endif - ImGui::Separator(); - ImGui::Text("io.BackendPlatformName: %s", io.BackendPlatformName ? io.BackendPlatformName : "NULL"); - ImGui::Text("io.BackendRendererName: %s", io.BackendRendererName ? io.BackendRendererName : "NULL"); - ImGui::Text("io.ConfigFlags: 0x%08X", io.ConfigFlags); - if (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) ImGui::Text(" NavEnableKeyboard"); - if (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) ImGui::Text(" NavEnableGamepad"); - if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) ImGui::Text(" NavEnableSetMousePos"); - if (io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard) ImGui::Text(" NavNoCaptureKeyboard"); - if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) ImGui::Text(" NoMouse"); - if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) ImGui::Text(" NoMouseCursorChange"); - if (io.MouseDrawCursor) ImGui::Text("io.MouseDrawCursor"); - if (io.ConfigMacOSXBehaviors) ImGui::Text("io.ConfigMacOSXBehaviors"); - if (io.ConfigInputTextCursorBlink) ImGui::Text("io.ConfigInputTextCursorBlink"); - if (io.ConfigWindowsResizeFromEdges) ImGui::Text("io.ConfigWindowsResizeFromEdges"); - if (io.ConfigWindowsMoveFromTitleBarOnly) ImGui::Text("io.ConfigWindowsMoveFromTitleBarOnly"); - ImGui::Text("io.BackendFlags: 0x%08X", io.BackendFlags); - if (io.BackendFlags & ImGuiBackendFlags_HasGamepad) ImGui::Text(" HasGamepad"); - if (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) ImGui::Text(" HasMouseCursors"); - if (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos) ImGui::Text(" HasSetMousePos"); - if (io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) ImGui::Text(" RendererHasVtxOffset"); - ImGui::Separator(); - ImGui::Text("io.Fonts: %d fonts, Flags: 0x%08X, TexSize: %d,%d", io.Fonts->Fonts.Size, io.Fonts->Flags, io.Fonts->TexWidth, io.Fonts->TexHeight); - ImGui::Text("io.DisplaySize: %.2f,%.2f", io.DisplaySize.x, io.DisplaySize.y); - ImGui::Text("io.DisplayFramebufferScale: %.2f,%.2f", io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y); - ImGui::Separator(); - ImGui::Text("style.WindowPadding: %.2f,%.2f", style.WindowPadding.x, style.WindowPadding.y); - ImGui::Text("style.WindowBorderSize: %.2f", style.WindowBorderSize); - ImGui::Text("style.FramePadding: %.2f,%.2f", style.FramePadding.x, style.FramePadding.y); - ImGui::Text("style.FrameRounding: %.2f", style.FrameRounding); - ImGui::Text("style.FrameBorderSize: %.2f", style.FrameBorderSize); - ImGui::Text("style.ItemSpacing: %.2f,%.2f", style.ItemSpacing.x, style.ItemSpacing.y); - ImGui::Text("style.ItemInnerSpacing: %.2f,%.2f", style.ItemInnerSpacing.x, style.ItemInnerSpacing.y); + Separator(); + Text("io.BackendPlatformName: %s", io.BackendPlatformName ? io.BackendPlatformName : "NULL"); + Text("io.BackendRendererName: %s", io.BackendRendererName ? io.BackendRendererName : "NULL"); + Text("io.ConfigFlags: 0x%08X", io.ConfigFlags); + if (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) Text(" NavEnableKeyboard"); + if (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) Text(" NavEnableGamepad"); + if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) Text(" NavEnableSetMousePos"); + if (io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard) Text(" NavNoCaptureKeyboard"); + if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) Text(" NoMouse"); + if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) Text(" NoMouseCursorChange"); + if (io.MouseDrawCursor) Text("io.MouseDrawCursor"); + if (io.ConfigMacOSXBehaviors) Text("io.ConfigMacOSXBehaviors"); + if (io.ConfigInputTextCursorBlink) Text("io.ConfigInputTextCursorBlink"); + if (io.ConfigWindowsResizeFromEdges) Text("io.ConfigWindowsResizeFromEdges"); + if (io.ConfigWindowsMoveFromTitleBarOnly) Text("io.ConfigWindowsMoveFromTitleBarOnly"); + Text("io.BackendFlags: 0x%08X", io.BackendFlags); + if (io.BackendFlags & ImGuiBackendFlags_HasGamepad) Text(" HasGamepad"); + if (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) Text(" HasMouseCursors"); + if (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos) Text(" HasSetMousePos"); + if (io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) Text(" RendererHasVtxOffset"); + Separator(); + Text("io.Fonts: %d fonts, Flags: 0x%08X, TexSize: %d,%d", io.Fonts->Fonts.Size, io.Fonts->Flags, io.Fonts->TexWidth, io.Fonts->TexHeight); + Text("io.DisplaySize: %.2f,%.2f", io.DisplaySize.x, io.DisplaySize.y); + Text("io.DisplayFramebufferScale: %.2f,%.2f", io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y); + Separator(); + Text("style.WindowPadding: %.2f,%.2f", style.WindowPadding.x, style.WindowPadding.y); + Text("style.WindowBorderSize: %.2f", style.WindowBorderSize); + Text("style.FramePadding: %.2f,%.2f", style.FramePadding.x, style.FramePadding.y); + Text("style.FrameRounding: %.2f", style.FrameRounding); + Text("style.FrameBorderSize: %.2f", style.FrameBorderSize); + Text("style.ItemSpacing: %.2f,%.2f", style.ItemSpacing.x, style.ItemSpacing.y); + Text("style.ItemInnerSpacing: %.2f,%.2f", style.ItemInnerSpacing.x, style.ItemInnerSpacing.y); if (copy_to_clipboard) - ImGui::LogFinish(); - ImGui::EndChildFrame(); + LogFinish(); + EndChildFrame(); } - ImGui::End(); + End(); } //----------------------------------------------------------------------------- @@ -3005,13 +3005,13 @@ void ImGui::ShowAboutWindow(bool* p_open) bool ImGui::ShowStyleSelector(const char* label) { static int style_idx = -1; - if (ImGui::Combo(label, &style_idx, "Classic\0Dark\0Light\0")) + if (Combo(label, &style_idx, "Classic\0Dark\0Light\0")) { switch (style_idx) { - case 0: ImGui::StyleColorsClassic(); break; - case 1: ImGui::StyleColorsDark(); break; - case 2: ImGui::StyleColorsLight(); break; + case 0: StyleColorsClassic(); break; + case 1: StyleColorsDark(); break; + case 2: StyleColorsLight(); break; } return true; } @@ -3022,21 +3022,21 @@ bool ImGui::ShowStyleSelector(const char* label) // Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one. void ImGui::ShowFontSelector(const char* label) { - ImGuiIO& io = ImGui::GetIO(); - const ImFont * font_current = ImGui::GetFont(); - if (ImGui::BeginCombo(label, font_current->GetDebugName())) + ImGuiIO& io = GetIO(); + const ImFont * font_current = GetFont(); + if (BeginCombo(label, font_current->GetDebugName())) { for (int n = 0; n < io.Fonts->Fonts.Size; n++) { ImFont* font = io.Fonts->Fonts[n]; - ImGui::PushID((void*)font); - if (ImGui::Selectable(font->GetDebugName(), font == font_current)) + PushID((void*)font); + if (Selectable(font->GetDebugName(), font == font_current)) io.FontDefault = font; - ImGui::PopID(); + PopID(); } - ImGui::EndCombo(); + EndCombo(); } - ImGui::SameLine(); + SameLine(); HelpMarker( "- Load additional fonts with io.Fonts->AddFontFromFileTTF().\n" "- The font atlas is built when calling io.Fonts->GetTexDataAsXXXX() or io.Fonts->Build().\n" @@ -3047,7 +3047,7 @@ void ImGui::ShowFontSelector(const char* label) void ImGui::ShowStyleEditor(ImGuiStyle* ref) { // You can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it compares to an internally stored reference) - ImGuiStyle& style = ImGui::GetStyle(); + ImGuiStyle& style = GetStyle(); static ImGuiStyle ref_saved_style; // Default to using internal storage as reference @@ -3058,155 +3058,155 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref) if (ref == NULL) ref = &ref_saved_style; - ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.50f); + PushItemWidth(GetWindowWidth() * 0.50f); - if (ImGui::ShowStyleSelector("Colors##Selector")) + if (ShowStyleSelector("Colors##Selector")) ref_saved_style = style; - ImGui::ShowFontSelector("Fonts##Selector"); + ShowFontSelector("Fonts##Selector"); // Simplified Settings - if (ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f")) + if (SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f")) style.GrabRounding = style.FrameRounding; // Make GrabRounding always the same value as FrameRounding - { bool window_border = (style.WindowBorderSize > 0.0f); if (ImGui::Checkbox("WindowBorder", &window_border)) style.WindowBorderSize = window_border ? 1.0f : 0.0f; } - ImGui::SameLine(); - { bool frame_border = (style.FrameBorderSize > 0.0f); if (ImGui::Checkbox("FrameBorder", &frame_border)) style.FrameBorderSize = frame_border ? 1.0f : 0.0f; } - ImGui::SameLine(); - { bool popup_border = (style.PopupBorderSize > 0.0f); if (ImGui::Checkbox("PopupBorder", &popup_border)) style.PopupBorderSize = popup_border ? 1.0f : 0.0f; } + { bool window_border = (style.WindowBorderSize > 0.0f); if (Checkbox("WindowBorder", &window_border)) style.WindowBorderSize = window_border ? 1.0f : 0.0f; } + SameLine(); + { bool frame_border = (style.FrameBorderSize > 0.0f); if (Checkbox("FrameBorder", &frame_border)) style.FrameBorderSize = frame_border ? 1.0f : 0.0f; } + SameLine(); + { bool popup_border = (style.PopupBorderSize > 0.0f); if (Checkbox("PopupBorder", &popup_border)) style.PopupBorderSize = popup_border ? 1.0f : 0.0f; } // Save/Revert button - if (ImGui::Button("Save Ref")) + if (Button("Save Ref")) *ref = ref_saved_style = style; - ImGui::SameLine(); - if (ImGui::Button("Revert Ref")) + SameLine(); + if (Button("Revert Ref")) style = *ref; - ImGui::SameLine(); + SameLine(); HelpMarker("Save/Revert in local non-persistent storage. Default Colors definition are not affected. Use \"Export Colors\" below to save them somewhere."); - ImGui::Separator(); + Separator(); - if (ImGui::BeginTabBar("##tabs", ImGuiTabBarFlags_None)) + if (BeginTabBar("##tabs", ImGuiTabBarFlags_None)) { - if (ImGui::BeginTabItem("Sizes")) + if (BeginTabItem("Sizes")) { - ImGui::Text("Main"); - ImGui::SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("ItemSpacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f"); - ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f"); - ImGui::SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f"); - ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f"); - ImGui::Text("Borders"); - ImGui::SliderFloat("WindowBorderSize", &style.WindowBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::SliderFloat("ChildBorderSize", &style.ChildBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::SliderFloat("PopupBorderSize", &style.PopupBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::Text("Rounding"); - ImGui::SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("ChildRounding", &style.ChildRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("TabRounding", &style.TabRounding, 0.0f, 12.0f, "%.0f"); - ImGui::Text("Alignment"); - ImGui::SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f"); - ImGui::Combo("WindowMenuButtonPosition", (int*)&style.WindowMenuButtonPosition, "Left\0Right\0"); - ImGui::SliderFloat2("ButtonTextAlign", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f"); ImGui::SameLine(); HelpMarker("Alignment applies when a button is larger than its text content."); - ImGui::SliderFloat2("SelectableTextAlign", (float*)&style.SelectableTextAlign, 0.0f, 1.0f, "%.2f"); ImGui::SameLine(); HelpMarker("Alignment applies when a selectable is larger than its text content."); - ImGui::Text("Safe Area Padding"); ImGui::SameLine(); HelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured)."); - ImGui::SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f"); - ImGui::EndTabItem(); + Text("Main"); + SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f"); + SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f"); + SliderFloat2("ItemSpacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f"); + SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f"); + SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f"); + SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f"); + SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f"); + SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f"); + Text("Borders"); + SliderFloat("WindowBorderSize", &style.WindowBorderSize, 0.0f, 1.0f, "%.0f"); + SliderFloat("ChildBorderSize", &style.ChildBorderSize, 0.0f, 1.0f, "%.0f"); + SliderFloat("PopupBorderSize", &style.PopupBorderSize, 0.0f, 1.0f, "%.0f"); + SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f, "%.0f"); + SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f"); + Text("Rounding"); + SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 12.0f, "%.0f"); + SliderFloat("ChildRounding", &style.ChildRounding, 0.0f, 12.0f, "%.0f"); + SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"); + SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 12.0f, "%.0f"); + SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f"); + SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f"); + SliderFloat("TabRounding", &style.TabRounding, 0.0f, 12.0f, "%.0f"); + Text("Alignment"); + SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f"); + Combo("WindowMenuButtonPosition", (int*)&style.WindowMenuButtonPosition, "Left\0Right\0"); + SliderFloat2("ButtonTextAlign", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f"); SameLine(); HelpMarker("Alignment applies when a button is larger than its text content."); + SliderFloat2("SelectableTextAlign", (float*)&style.SelectableTextAlign, 0.0f, 1.0f, "%.2f"); SameLine(); HelpMarker("Alignment applies when a selectable is larger than its text content."); + Text("Safe Area Padding"); SameLine(); HelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured)."); + SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f"); + EndTabItem(); } - if (ImGui::BeginTabItem("Colors")) + if (BeginTabItem("Colors")) { static int output_dest = 0; static bool output_only_modified = true; - if (ImGui::Button("Export Unsaved")) + if (Button("Export Unsaved")) { if (output_dest == 0) - ImGui::LogToClipboard(); + LogToClipboard(); else - ImGui::LogToTTY(); - ImGui::LogText("ImVec4* colors = ImGui::GetStyle().Colors;" IM_NEWLINE); + LogToTTY(); + LogText("ImVec4* colors = ImGui::GetStyle().Colors;" IM_NEWLINE); for (int i = 0; i < ImGuiCol_COUNT; i++) { const ImVec4& col = style.Colors[i]; - const char* name = ImGui::GetStyleColorName(i); + const char* name = GetStyleColorName(i); if (!output_only_modified || memcmp(&col, &ref->Colors[i], sizeof(ImVec4)) != 0) - ImGui::LogText("colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 23 - (int)strlen(name), "", col.x, col.y, col.z, col.w); + LogText("colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 23 - (int)strlen(name), "", col.x, col.y, col.z, col.w); } - ImGui::LogFinish(); + LogFinish(); } - ImGui::SameLine(); ImGui::SetNextItemWidth(120); ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0"); - ImGui::SameLine(); ImGui::Checkbox("Only Modified Colors", &output_only_modified); + SameLine(); SetNextItemWidth(120); Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0"); + SameLine(); Checkbox("Only Modified Colors", &output_only_modified); static ImGuiTextFilter filter; - filter.Draw("Filter colors", ImGui::GetFontSize() * 16); + filter.Draw("Filter colors", GetFontSize() * 16); static ImGuiColorEditFlags alpha_flags = 0; - ImGui::RadioButton("Opaque", &alpha_flags, 0); ImGui::SameLine(); - ImGui::RadioButton("Alpha", &alpha_flags, ImGuiColorEditFlags_AlphaPreview); ImGui::SameLine(); - ImGui::RadioButton("Both", &alpha_flags, ImGuiColorEditFlags_AlphaPreviewHalf); ImGui::SameLine(); + RadioButton("Opaque", &alpha_flags, 0); SameLine(); + RadioButton("Alpha", &alpha_flags, ImGuiColorEditFlags_AlphaPreview); SameLine(); + RadioButton("Both", &alpha_flags, ImGuiColorEditFlags_AlphaPreviewHalf); SameLine(); HelpMarker("In the color list:\nLeft-click on colored square to open color picker,\nRight-click to open edit options menu."); - ImGui::BeginChild("##colors", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened); - ImGui::PushItemWidth(-160); + BeginChild("##colors", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened); + PushItemWidth(-160); for (int i = 0; i < ImGuiCol_COUNT; i++) { - const char* name = ImGui::GetStyleColorName(i); + const char* name = GetStyleColorName(i); if (!filter.PassFilter(name)) continue; - ImGui::PushID(i); - ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags); + PushID(i); + ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags); if (memcmp(&style.Colors[i], &ref->Colors[i], sizeof(ImVec4)) != 0) { // Tips: in a real user application, you may want to merge and use an icon font into the main font, so instead of "Save"/"Revert" you'd use icons. // Read the FAQ and misc/fonts/README.txt about using icon fonts. It's really easy and super convenient! - ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Save")) ref->Colors[i] = style.Colors[i]; - ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Revert")) style.Colors[i] = ref->Colors[i]; + SameLine(0.0f, style.ItemInnerSpacing.x); if (Button("Save")) ref->Colors[i] = style.Colors[i]; + SameLine(0.0f, style.ItemInnerSpacing.x); if (Button("Revert")) style.Colors[i] = ref->Colors[i]; } - ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); - ImGui::TextUnformatted(name); - ImGui::PopID(); + SameLine(0.0f, style.ItemInnerSpacing.x); + TextUnformatted(name); + PopID(); } - ImGui::PopItemWidth(); - ImGui::EndChild(); + PopItemWidth(); + EndChild(); - ImGui::EndTabItem(); + EndTabItem(); } - if (ImGui::BeginTabItem("Fonts")) + if (BeginTabItem("Fonts")) { - ImGuiIO& io = ImGui::GetIO(); + ImGuiIO& io = GetIO(); ImFontAtlas* atlas = io.Fonts; HelpMarker("Read FAQ and misc/fonts/README.txt for details on font loading."); - ImGui::PushItemWidth(120); + PushItemWidth(120); for (int i = 0; i < atlas->Fonts.Size; i++) { ImFont* font = atlas->Fonts[i]; - ImGui::PushID(font); - const bool font_details_opened = ImGui::TreeNode(font, "Font %d: \"%s\"\n%.2f px, %d glyphs, %d file(s)", i, font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount); - ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) { io.FontDefault = font; } + PushID(font); + const bool font_details_opened = TreeNode(font, "Font %d: \"%s\"\n%.2f px, %d glyphs, %d file(s)", i, font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount); + SameLine(); if (SmallButton("Set as default")) { io.FontDefault = font; } if (font_details_opened) { - ImGui::PushFont(font); - ImGui::Text("The quick brown fox jumps over the lazy dog"); - ImGui::PopFont(); - ImGui::DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); // Scale only this font - ImGui::SameLine(); HelpMarker("Note than the default embedded font is NOT meant to be scaled.\n\nFont are currently rendered into bitmaps at a given size at the time of building the atlas. You may oversample them to get some flexibility with scaling. You can also render at multiple sizes and select which one to use at runtime.\n\n(Glimmer of hope: the atlas system should hopefully be rewritten in the future to make scaling more natural and automatic.)"); - ImGui::InputFloat("Font offset", &font->DisplayOffset.y, 1, 1, "%.0f"); - ImGui::Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent); - ImGui::Text("Fallback character: '%c' (%d)", font->FallbackChar, font->FallbackChar); + PushFont(font); + Text("The quick brown fox jumps over the lazy dog"); + PopFont(); + DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); // Scale only this font + SameLine(); HelpMarker("Note than the default embedded font is NOT meant to be scaled.\n\nFont are currently rendered into bitmaps at a given size at the time of building the atlas. You may oversample them to get some flexibility with scaling. You can also render at multiple sizes and select which one to use at runtime.\n\n(Glimmer of hope: the atlas system should hopefully be rewritten in the future to make scaling more natural and automatic.)"); + InputFloat("Font offset", &font->DisplayOffset.y, 1, 1, "%.0f"); + Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent); + Text("Fallback character: '%c' (%d)", font->FallbackChar, font->FallbackChar); const float surface_sqrt = sqrtf((float)font->MetricsTotalSurface); - ImGui::Text("Texture surface: %d pixels (approx) ~ %dx%d", font->MetricsTotalSurface, (int)surface_sqrt, (int)surface_sqrt); + Text("Texture surface: %d pixels (approx) ~ %dx%d", font->MetricsTotalSurface, (int)surface_sqrt, (int)surface_sqrt); for (int config_i = 0; config_i < font->ConfigDataCount; config_i++) if (const ImFontConfig* cfg = &font->ConfigData[config_i]) - ImGui::BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d", config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH); - if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size)) + BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d", config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH); + if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size)) { // Display all glyphs of the fonts in separate pages of 256 characters for (int base = 0; base < 0x10000; base += 256) @@ -3214,12 +3214,12 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref) int count = 0; for (int n = 0; n < 256; n++) count += font->FindGlyphNoFallback((ImWchar)(base + n)) ? 1 : 0; - if (count > 0 && ImGui::TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph")) + if (count > 0 && TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph")) { const float cell_size = font->FontSize * 1; const float cell_spacing = style.ItemSpacing.y; - const ImVec2 base_pos = ImGui::GetCursorScreenPos(); - ImDrawList* draw_list = ImGui::GetWindowDrawList(); + const ImVec2 base_pos = GetCursorScreenPos(); + ImDrawList* draw_list = GetWindowDrawList(); for (int n = 0; n < 256; n++) { ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing)); @@ -3227,62 +3227,62 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref) const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n)); draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50)); if (glyph) - font->RenderChar(draw_list, cell_size, cell_p1, ImGui::GetColorU32(ImGuiCol_Text), (ImWchar)(base + n)); // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions available to generate a string. - if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2)) + font->RenderChar(draw_list, cell_size, cell_p1, GetColorU32(ImGuiCol_Text), (ImWchar)(base + n)); // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions available to generate a string. + if (glyph && IsMouseHoveringRect(cell_p1, cell_p2)) { - ImGui::BeginTooltip(); - ImGui::Text("Codepoint: U+%04X", base + n); - ImGui::Separator(); - ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX); - ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1); - ImGui::Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1); - ImGui::EndTooltip(); + BeginTooltip(); + Text("Codepoint: U+%04X", base + n); + Separator(); + Text("AdvanceX: %.1f", glyph->AdvanceX); + Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1); + Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1); + EndTooltip(); } } - ImGui::Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16)); - ImGui::TreePop(); + Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16)); + TreePop(); } } - ImGui::TreePop(); + TreePop(); } - ImGui::TreePop(); + TreePop(); } - ImGui::PopID(); + PopID(); } - if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight)) + if (TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight)) { const auto tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); const auto border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f); - ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0, 0), ImVec2(1, 1), tint_col, border_col); - ImGui::TreePop(); + Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0, 0), ImVec2(1, 1), tint_col, border_col); + TreePop(); } static float window_scale = 1.0f; - if (ImGui::DragFloat("this window scale", &window_scale, 0.005f, 0.3f, 2.0f, "%.2f")) // scale only this window - ImGui::SetWindowFontScale(window_scale); - ImGui::DragFloat("global scale", &io.FontGlobalScale, 0.005f, 0.3f, 2.0f, "%.2f"); // scale everything - ImGui::PopItemWidth(); + if (DragFloat("this window scale", &window_scale, 0.005f, 0.3f, 2.0f, "%.2f")) // scale only this window + SetWindowFontScale(window_scale); + DragFloat("global scale", &io.FontGlobalScale, 0.005f, 0.3f, 2.0f, "%.2f"); // scale everything + PopItemWidth(); - ImGui::EndTabItem(); + EndTabItem(); } - if (ImGui::BeginTabItem("Rendering")) + if (BeginTabItem("Rendering")) { - ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines); ImGui::SameLine(); HelpMarker("When disabling anti-aliasing lines, you'll probably want to disable borders in your style as well."); - ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill); - ImGui::PushItemWidth(100); - ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, "%.2f", 2.0f); + Checkbox("Anti-aliased lines", &style.AntiAliasedLines); SameLine(); HelpMarker("When disabling anti-aliasing lines, you'll probably want to disable borders in your style as well."); + Checkbox("Anti-aliased fill", &style.AntiAliasedFill); + PushItemWidth(100); + DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, "%.2f", 2.0f); if (style.CurveTessellationTol < 0.10f) style.CurveTessellationTol = 0.10f; - ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero. - ImGui::PopItemWidth(); + DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero. + PopItemWidth(); - ImGui::EndTabItem(); + EndTabItem(); } - ImGui::EndTabBar(); + EndTabBar(); } - ImGui::PopItemWidth(); + PopItemWidth(); } //----------------------------------------------------------------------------- diff --git a/imgui/imgui_draw.cpp b/imgui/imgui_draw.cpp index a3d5c2b3..0f3fbf2e 100644 --- a/imgui/imgui_draw.cpp +++ b/imgui/imgui_draw.cpp @@ -175,7 +175,7 @@ using namespace IMGUI_STB_NAMESPACE; void ImGui::StyleColorsDark(ImGuiStyle* dst) { - ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); + ImGuiStyle* style = dst ? dst : &GetStyle(); ImVec4* colors = style->Colors; colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); @@ -230,7 +230,7 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst) void ImGui::StyleColorsClassic(ImGuiStyle* dst) { - ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); + ImGuiStyle* style = dst ? dst : &GetStyle(); ImVec4* colors = style->Colors; colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); @@ -286,7 +286,7 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst) // Those light colors are better suited with a thicker font than the default one + FrameBorder void ImGui::StyleColorsLight(ImGuiStyle* dst) { - ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); + ImGuiStyle* style = dst ? dst : &GetStyle(); ImVec4* colors = style->Colors; colors[ImGuiCol_Text] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); diff --git a/imgui/imgui_widgets.cpp b/imgui/imgui_widgets.cpp index ba127d5e..a3e87f71 100644 --- a/imgui/imgui_widgets.cpp +++ b/imgui/imgui_widgets.cpp @@ -1783,7 +1783,7 @@ bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_b // Copy the value in an opaque buffer so we can compare at the end of the function if it changed at all. IM_ASSERT(data_type < ImGuiDataType_COUNT); int data_backup[2]; - const ImGuiDataTypeInfo* type_info = ImGui::DataTypeGetInfo(data_type); + const ImGuiDataTypeInfo* type_info = DataTypeGetInfo(data_type); IM_ASSERT(type_info->Size <= sizeof(data_backup)); memcpy(data_backup, data_ptr, type_info->Size); diff --git a/input/driverkeyboardinput.cpp b/input/driverkeyboardinput.cpp index 48c8c1fc..b9fed1c4 100644 --- a/input/driverkeyboardinput.cpp +++ b/input/driverkeyboardinput.cpp @@ -24,31 +24,31 @@ void driverkeyboard_input::default_bindings() { m_bindingsetups = { - { user_command::aidriverenable, {GLFW_KEY_Q | keymodifier::shift, ""} }, + { user_command::aidriverenable, {GLFW_KEY_Q | shift, ""} }, { user_command::aidriverdisable, {GLFW_KEY_Q, ""} }, // jointcontrollerset, { user_command::mastercontrollerincrease, {GLFW_KEY_KP_ADD, ""} }, - { user_command::mastercontrollerincreasefast, {GLFW_KEY_KP_ADD | keymodifier::shift, ""} }, + { user_command::mastercontrollerincreasefast, {GLFW_KEY_KP_ADD | shift, ""} }, { user_command::mastercontrollerdecrease, {GLFW_KEY_KP_SUBTRACT, ""} }, - { user_command::mastercontrollerdecreasefast, {GLFW_KEY_KP_SUBTRACT | keymodifier::shift, ""} }, + { user_command::mastercontrollerdecreasefast, {GLFW_KEY_KP_SUBTRACT | shift, ""} }, // mastercontrollerset, - { user_command::dynamicbrakecontrollerincrease, {GLFW_KEY_KP_3 | keymodifier::control, ""} }, - { user_command::dynamicbrakecontrollerdecrease, {GLFW_KEY_KP_9 | keymodifier::control, ""} }, + { user_command::dynamicbrakecontrollerincrease, {GLFW_KEY_KP_3 | control, ""} }, + { user_command::dynamicbrakecontrollerdecrease, {GLFW_KEY_KP_9 | control, ""} }, // mastercontrollerset, - { user_command::dynamicbrakecontrollerincreasefast, {GLFW_KEY_KP_3 | keymodifier::control | keymodifier::shift, ""} }, - { user_command::dynamicbrakecontrollerdecreasefast, {GLFW_KEY_KP_9 | keymodifier::control | keymodifier::shift, ""} }, + { user_command::dynamicbrakecontrollerincreasefast, {GLFW_KEY_KP_3 | control | shift, ""} }, + { user_command::dynamicbrakecontrollerdecreasefast, {GLFW_KEY_KP_9 | control | shift, ""} }, { user_command::secondcontrollerincrease, {GLFW_KEY_KP_DIVIDE, ""} }, - { user_command::secondcontrollerincreasefast, {GLFW_KEY_KP_DIVIDE | keymodifier::shift, ""} }, + { user_command::secondcontrollerincreasefast, {GLFW_KEY_KP_DIVIDE | shift, ""} }, { user_command::secondcontrollerdecrease, {GLFW_KEY_KP_MULTIPLY, ""} }, - { user_command::secondcontrollerdecreasefast, {GLFW_KEY_KP_MULTIPLY | keymodifier::shift, ""} }, + { user_command::secondcontrollerdecreasefast, {GLFW_KEY_KP_MULTIPLY | shift, ""} }, // secondcontrollerset, - { user_command::mucurrentindicatorothersourceactivate, {GLFW_KEY_Z | keymodifier::shift, ""} }, + { user_command::mucurrentindicatorothersourceactivate, {GLFW_KEY_Z | shift, ""} }, { user_command::independentbrakeincrease, {GLFW_KEY_KP_1, ""} }, - { user_command::independentbrakeincreasefast, {GLFW_KEY_KP_1 | keymodifier::shift, ""} }, + { user_command::independentbrakeincreasefast, {GLFW_KEY_KP_1 | shift, ""} }, { user_command::independentbrakedecrease, {GLFW_KEY_KP_7, ""} }, - { user_command::independentbrakedecreasefast, {GLFW_KEY_KP_7 | keymodifier::shift, ""} }, + { user_command::independentbrakedecreasefast, {GLFW_KEY_KP_7 | shift, ""} }, // independentbrakeset, { user_command::independentbrakebailoff, {GLFW_KEY_KP_4, ""} }, // universalbrakebutton1, @@ -62,19 +62,19 @@ driverkeyboard_input::default_bindings() { { user_command::trainbrakefirstservice, {GLFW_KEY_KP_8, ""} }, { user_command::trainbrakeservice, {GLFW_KEY_KP_5, ""} }, { user_command::trainbrakefullservice, {GLFW_KEY_KP_2, ""} }, - { user_command::trainbrakehandleoff, {GLFW_KEY_KP_5 | keymodifier::control, ""} }, + { user_command::trainbrakehandleoff, {GLFW_KEY_KP_5 | control, ""} }, { user_command::trainbrakeemergency, {GLFW_KEY_KP_0, ""} }, - { user_command::trainbrakebasepressureincrease, {GLFW_KEY_KP_3 | keymodifier::control, ""} }, - { user_command::trainbrakebasepressuredecrease, {GLFW_KEY_KP_9 | keymodifier::control, ""} }, - { user_command::trainbrakebasepressurereset, {GLFW_KEY_KP_6 | keymodifier::control, ""} }, - { user_command::trainbrakeoperationtoggle, {GLFW_KEY_KP_4 | keymodifier::control, ""} }, - { user_command::manualbrakeincrease, {GLFW_KEY_KP_1 | keymodifier::control, ""} }, - { user_command::manualbrakedecrease, {GLFW_KEY_KP_7 | keymodifier::control, ""} }, - { user_command::alarmchaintoggle, {GLFW_KEY_B | keymodifier::shift | keymodifier::control, ""} }, + { user_command::trainbrakebasepressureincrease, {GLFW_KEY_KP_3 | control, ""} }, + { user_command::trainbrakebasepressuredecrease, {GLFW_KEY_KP_9 | control, ""} }, + { user_command::trainbrakebasepressurereset, {GLFW_KEY_KP_6 | control, ""} }, + { user_command::trainbrakeoperationtoggle, {GLFW_KEY_KP_4 | control, ""} }, + { user_command::manualbrakeincrease, {GLFW_KEY_KP_1 | control, ""} }, + { user_command::manualbrakedecrease, {GLFW_KEY_KP_7 | control, ""} }, + { user_command::alarmchaintoggle, {GLFW_KEY_B | shift | control, ""} }, // alarmchainenable, // alarmchaindisable, { user_command::wheelspinbrakeactivate, {GLFW_KEY_KP_ENTER, ""} }, - { user_command::sandboxactivate, {GLFW_KEY_S | keymodifier::shift, ""} }, + { user_command::sandboxactivate, {GLFW_KEY_S | shift, ""} }, // autosandboxtoggle, // autosandboxactivate, // autosandboxdeactivate, @@ -84,25 +84,25 @@ driverkeyboard_input::default_bindings() { // reverserforward, // reverserneutral, // reverserbackward, - { user_command::waterpumpbreakertoggle, {GLFW_KEY_W | keymodifier::control, ""} }, + { user_command::waterpumpbreakertoggle, {GLFW_KEY_W | control, ""} }, // waterpumpbreakerclose, // waterpumpbreakeropen, { user_command::waterpumptoggle, {GLFW_KEY_W, ""} }, // waterpumpenable, // waterpumpdisable, - { user_command::waterheaterbreakertoggle, {GLFW_KEY_W | keymodifier::control | keymodifier::shift, ""} }, + { user_command::waterheaterbreakertoggle, {GLFW_KEY_W | control | shift, ""} }, // waterheaterbreakerclose, // waterheaterbreakeropen, - { user_command::waterheatertoggle, {GLFW_KEY_W | keymodifier::shift, ""} }, + { user_command::waterheatertoggle, {GLFW_KEY_W | shift, ""} }, // waterheaterenable, // waterheaterdisable, - { user_command::watercircuitslinktoggle, {GLFW_KEY_H | keymodifier::shift, ""} }, + { user_command::watercircuitslinktoggle, {GLFW_KEY_H | shift, ""} }, // watercircuitslinkenable, // watercircuitslinkdisable, { user_command::fuelpumptoggle, {GLFW_KEY_F, ""} }, // fuelpumpenable, // fuelpumpdisable, - { user_command::oilpumptoggle, {GLFW_KEY_F | keymodifier::shift, ""} }, + { user_command::oilpumptoggle, {GLFW_KEY_F | shift, ""} }, // oilpumpenable, // oilpumpdisable, { user_command::linebreakertoggle, {GLFW_KEY_M, ""} }, @@ -111,16 +111,16 @@ driverkeyboard_input::default_bindings() { { user_command::convertertoggle, {GLFW_KEY_X, ""} }, // converterenable, // converterdisable, - { user_command::convertertogglelocal, {GLFW_KEY_X | keymodifier::shift, ""} }, - { user_command::converteroverloadrelayreset, {GLFW_KEY_N | keymodifier::control, ""} }, + { user_command::convertertogglelocal, {GLFW_KEY_X | shift, ""} }, + { user_command::converteroverloadrelayreset, {GLFW_KEY_N | control, ""} }, { user_command::compressortoggle, {GLFW_KEY_C, ""} }, // compressorenable, // compressordisable, - { user_command::compressortogglelocal, {GLFW_KEY_C | keymodifier::shift, ""} }, + { user_command::compressortogglelocal, {GLFW_KEY_C | shift, ""} }, // compressorpresetactivatenext, // compressorpresetactivateprevious, // compressorpresetactivatedefault, - { user_command::motoroverloadrelaythresholdtoggle, {GLFW_KEY_F | keymodifier::control, ""} }, + { user_command::motoroverloadrelaythresholdtoggle, {GLFW_KEY_F | control, ""} }, // motoroverloadrelaythresholdsetlow, // motoroverloadrelaythresholdsethigh, { user_command::motoroverloadrelayreset, {GLFW_KEY_N, ""} }, @@ -128,33 +128,33 @@ driverkeyboard_input::default_bindings() { // universalrelayreset2, // universalrelayreset3, { user_command::notchingrelaytoggle, {GLFW_KEY_G, ""} }, - { user_command::epbrakecontroltoggle, {GLFW_KEY_Z | keymodifier::control, ""} }, + { user_command::epbrakecontroltoggle, {GLFW_KEY_Z | control, ""} }, // epbrakecontrolenable // epbrakecontroldisable - { user_command::trainbrakeoperationmodeincrease, {GLFW_KEY_KP_2 | keymodifier::control, ""} }, - { user_command::trainbrakeoperationmodedecrease, {GLFW_KEY_KP_8 | keymodifier::control, ""} }, - { user_command::brakeactingspeedincrease, {GLFW_KEY_B | keymodifier::shift, ""} }, + { user_command::trainbrakeoperationmodeincrease, {GLFW_KEY_KP_2 | control, ""} }, + { user_command::trainbrakeoperationmodedecrease, {GLFW_KEY_KP_8 | control, ""} }, + { user_command::brakeactingspeedincrease, {GLFW_KEY_B | shift, ""} }, { user_command::brakeactingspeeddecrease, {GLFW_KEY_B, ""} }, // brakeactingspeedsetcargo, // brakeactingspeedsetpassenger, // brakeactingspeedsetrapid, - { user_command::brakeloadcompensationincrease, {GLFW_KEY_H | keymodifier::shift | keymodifier::control, ""} }, - { user_command::brakeloadcompensationdecrease, {GLFW_KEY_H | keymodifier::control, ""} }, - { user_command::mubrakingindicatortoggle, {GLFW_KEY_L | keymodifier::shift, ""} }, + { user_command::brakeloadcompensationincrease, {GLFW_KEY_H | shift | control, ""} }, + { user_command::brakeloadcompensationdecrease, {GLFW_KEY_H | control, ""} }, + { user_command::mubrakingindicatortoggle, {GLFW_KEY_L | shift, ""} }, { user_command::alerteracknowledge, {GLFW_KEY_SPACE, ""} }, { user_command::hornlowactivate, {GLFW_KEY_A, ""} }, { user_command::hornhighactivate, {GLFW_KEY_S, ""} }, { user_command::whistleactivate, {GLFW_KEY_Z, ""} }, - { user_command::radiotoggle, {GLFW_KEY_R | keymodifier::control, ""} }, + { user_command::radiotoggle, {GLFW_KEY_R | control, ""} }, // radioenable // radiodisable { user_command::radiochannelincrease, {GLFW_KEY_EQUAL, ""} }, { user_command::radiochanneldecrease, {GLFW_KEY_MINUS, ""} }, // radiochannelset - { user_command::radiostopsend, {GLFW_KEY_PAUSE | keymodifier::shift | keymodifier::control, ""} }, + { user_command::radiostopsend, {GLFW_KEY_PAUSE | shift | control, ""} }, // radiostopenable // radiostopdisable - { user_command::radiostoptest, {GLFW_KEY_R | keymodifier::shift | keymodifier::control, ""} }, + { user_command::radiostoptest, {GLFW_KEY_R | shift | control, ""} }, { user_command::radiocall3send, {GLFW_KEY_BACKSPACE, ""} }, // radiovolumeincrease, // radiovolumedecrease, @@ -174,40 +174,40 @@ driverkeyboard_input::default_bindings() { { user_command::movedown, {GLFW_KEY_PAGE_DOWN, "Move down"} }, { user_command::nearestcarcouplingincrease, {GLFW_KEY_INSERT, ""} }, { user_command::nearestcarcouplingdisconnect, {GLFW_KEY_DELETE, ""} }, - { user_command::nearestcarcoupleradapterattach, {GLFW_KEY_INSERT | keymodifier::control, ""} }, - { user_command::nearestcarcoupleradapterremove, {GLFW_KEY_DELETE | keymodifier::control, ""} }, - { user_command::occupiedcarcouplingdisconnect, {GLFW_KEY_DELETE | keymodifier::shift, ""} }, + { user_command::nearestcarcoupleradapterattach, {GLFW_KEY_INSERT | control, ""} }, + { user_command::nearestcarcoupleradapterremove, {GLFW_KEY_DELETE | control, ""} }, + { user_command::occupiedcarcouplingdisconnect, {GLFW_KEY_DELETE | shift, ""} }, { user_command::doortoggleleft, {GLFW_KEY_COMMA, ""} }, { user_command::doortoggleright, {GLFW_KEY_PERIOD, ""} }, - { user_command::doorpermitleft, {GLFW_KEY_COMMA | keymodifier::shift, ""} }, - { user_command::doorpermitright, {GLFW_KEY_PERIOD | keymodifier::shift, ""} }, - { user_command::doorpermitpresetactivatenext, {GLFW_KEY_PERIOD | keymodifier::shift | keymodifier::control, ""} }, - { user_command::doorpermitpresetactivateprevious, {GLFW_KEY_COMMA | keymodifier::shift | keymodifier::control, ""} }, + { user_command::doorpermitleft, {GLFW_KEY_COMMA | shift, ""} }, + { user_command::doorpermitright, {GLFW_KEY_PERIOD | shift, ""} }, + { user_command::doorpermitpresetactivatenext, {GLFW_KEY_PERIOD | shift | control, ""} }, + { user_command::doorpermitpresetactivateprevious, {GLFW_KEY_COMMA | shift | control, ""} }, // dooropenleft, // dooropenright, - { user_command::dooropenall, {GLFW_KEY_SLASH | keymodifier::shift, ""} }, + { user_command::dooropenall, {GLFW_KEY_SLASH | shift, ""} }, // doorcloseleft, // doorcloseright, - { user_command::doorcloseall, {GLFW_KEY_SLASH | keymodifier::control, ""} }, + { user_command::doorcloseall, {GLFW_KEY_SLASH | control, ""} }, // doorsteptoggle, - { user_command::doormodetoggle, {GLFW_KEY_SLASH | keymodifier::shift | keymodifier::control, ""} }, + { user_command::doormodetoggle, {GLFW_KEY_SLASH | shift | control, ""} }, // mirrorstoggle, { user_command::departureannounce, {GLFW_KEY_SLASH, ""} }, - { user_command::doorlocktoggle, {GLFW_KEY_S | keymodifier::control, ""} }, - { user_command::pantographcompressorvalvetoggle, {GLFW_KEY_V | keymodifier::control, ""} }, + { user_command::doorlocktoggle, {GLFW_KEY_S | control, ""} }, + { user_command::pantographcompressorvalvetoggle, {GLFW_KEY_V | control, ""} }, // pantographcompressorvalveenable, // pantographcompressorvalvedisable, - { user_command::pantographcompressoractivate, {GLFW_KEY_V | keymodifier::shift, ""} }, + { user_command::pantographcompressoractivate, {GLFW_KEY_V | shift, ""} }, { user_command::pantographtogglefront, {GLFW_KEY_P, ""} }, { user_command::pantographtogglerear, {GLFW_KEY_O, ""} }, // pantographraisefront, // pantographraiserear, // pantographlowerfront, // pantographlowerrear, - { user_command::pantographlowerall, {GLFW_KEY_P | keymodifier::control, ""} }, - { user_command::pantographselectnext, {GLFW_KEY_P | keymodifier::shift, ""} }, - { user_command::pantographselectprevious, {GLFW_KEY_O | keymodifier::shift, ""} }, - { user_command::pantographtoggleselected, {GLFW_KEY_O | keymodifier::shift | keymodifier::control, ""} }, + { user_command::pantographlowerall, {GLFW_KEY_P | control, ""} }, + { user_command::pantographselectnext, {GLFW_KEY_P | shift, ""} }, + { user_command::pantographselectprevious, {GLFW_KEY_O | shift, ""} }, + { user_command::pantographtoggleselected, {GLFW_KEY_O | shift | control, ""} }, // pantographraiseselected, // pantographlowerselected, // pantographvalvesupdate, @@ -215,7 +215,7 @@ driverkeyboard_input::default_bindings() { { user_command::heatingtoggle, {GLFW_KEY_H, ""} }, // heatingenable, // heatingdisable, - { user_command::lightspresetactivatenext, {GLFW_KEY_T | keymodifier::shift, ""} }, + { user_command::lightspresetactivatenext, {GLFW_KEY_T | shift, ""} }, { user_command::lightspresetactivateprevious, {GLFW_KEY_T, ""} }, { user_command::headlighttoggleleft, {GLFW_KEY_Y, ""} }, // headlightenableleft, @@ -226,39 +226,39 @@ driverkeyboard_input::default_bindings() { { user_command::headlighttoggleupper, {GLFW_KEY_U, ""} }, // headlightenableupper, // headlightdisableupper, - { user_command::redmarkertoggleleft, {GLFW_KEY_Y | keymodifier::shift, ""} }, + { user_command::redmarkertoggleleft, {GLFW_KEY_Y | shift, ""} }, // redmarkerenableleft, // redmarkerdisableleft, - { user_command::redmarkertoggleright, {GLFW_KEY_I | keymodifier::shift, ""} }, + { user_command::redmarkertoggleright, {GLFW_KEY_I | shift, ""} }, // redmarkerenableright, // redmarkerdisableright, - { user_command::headlighttogglerearleft, {GLFW_KEY_Y | keymodifier::control, ""} }, + { user_command::headlighttogglerearleft, {GLFW_KEY_Y | control, ""} }, // headlightenablerearleft // headlightdisablerearleft - { user_command::headlighttogglerearright, {GLFW_KEY_I | keymodifier::control, ""} }, + { user_command::headlighttogglerearright, {GLFW_KEY_I | control, ""} }, // headlightenablerearright // headlightdisablerearright - { user_command::headlighttogglerearupper, {GLFW_KEY_U | keymodifier::control, ""} }, + { user_command::headlighttogglerearupper, {GLFW_KEY_U | control, ""} }, // headlightenablerearupper // headlightdisablerearupper - { user_command::redmarkertogglerearleft, {GLFW_KEY_Y | keymodifier::control | keymodifier::shift, ""} }, + { user_command::redmarkertogglerearleft, {GLFW_KEY_Y | control | shift, ""} }, // redmarkerenablerearleft // redmarkerdisablerearleft - { user_command::redmarkertogglerearright, {GLFW_KEY_I | keymodifier::control | keymodifier::shift, ""} }, + { user_command::redmarkertogglerearright, {GLFW_KEY_I | control | shift, ""} }, // redmarkerenablerearright // redmarkerdisablerearright - { user_command::redmarkerstoggle, {GLFW_KEY_E | keymodifier::shift, ""} }, + { user_command::redmarkerstoggle, {GLFW_KEY_E | shift, ""} }, { user_command::endsignalstoggle, {GLFW_KEY_E, ""} }, - { user_command::headlightsdimtoggle, {GLFW_KEY_L | keymodifier::control, ""} }, + { user_command::headlightsdimtoggle, {GLFW_KEY_L | control, ""} }, // headlightsdimenable, // headlightsdimdisable, { user_command::motorconnectorsopen, {GLFW_KEY_L, ""} }, // motorconnectorsclose, - { user_command::motordisconnect, {GLFW_KEY_E | keymodifier::control, ""} }, + { user_command::motordisconnect, {GLFW_KEY_E | control, ""} }, { user_command::interiorlighttoggle, {GLFW_KEY_APOSTROPHE, ""} }, // interiorlightenable, // interiorlightdisable, - { user_command::interiorlightdimtoggle, {GLFW_KEY_APOSTROPHE | keymodifier::control, ""} }, + { user_command::interiorlightdimtoggle, {GLFW_KEY_APOSTROPHE | control, ""} }, // interiorlightdimenable, // interiorlightdimdisable, // compartmentlightstoggle, @@ -267,10 +267,10 @@ driverkeyboard_input::default_bindings() { { user_command::instrumentlighttoggle, {GLFW_KEY_SEMICOLON, ""} }, // instrumentlightenable, // instrumentlightdisable, - { user_command::dashboardlighttoggle, {GLFW_KEY_SEMICOLON | keymodifier::shift, ""} }, + { user_command::dashboardlighttoggle, {GLFW_KEY_SEMICOLON | shift, ""} }, // dashboardlightenable // dashboardlightdisable - { user_command::timetablelighttoggle, {GLFW_KEY_APOSTROPHE | keymodifier::shift, ""} }, + { user_command::timetablelighttoggle, {GLFW_KEY_APOSTROPHE | shift, ""} }, // timetablelightenable // timetablelightdisable { user_command::generictoggle0, {GLFW_KEY_0, ""} }, @@ -289,9 +289,9 @@ driverkeyboard_input::default_bindings() { // cabactivationtoggle, // cabactivationenable, // cabactivationdisable, - { user_command::motorblowerstogglefront, {GLFW_KEY_N | keymodifier::shift, ""} }, - { user_command::motorblowerstogglerear, {GLFW_KEY_M | keymodifier::shift, ""} }, - { user_command::motorblowersdisableall, {GLFW_KEY_M | keymodifier::control, ""} }, + { user_command::motorblowerstogglefront, {GLFW_KEY_N | shift, ""} }, + { user_command::motorblowerstogglerear, {GLFW_KEY_M | shift, ""} }, + { user_command::motorblowersdisableall, {GLFW_KEY_M | control, ""} }, // coolingfanstoggle, // tempomattoggle, // springbraketoggle, @@ -317,13 +317,13 @@ driverkeyboard_input::default_bindings() { // speedcontrolbutton8, // speedcontrolbutton9, // admin_timejump, - { user_command::timejumplarge, {GLFW_KEY_F1 | keymodifier::control, "Big time jump (Debug Mode only)"} }, - { user_command::timejumpsmall, {GLFW_KEY_F1 | keymodifier::shift, "Small time jump (Debug Mode only)"} }, + { user_command::timejumplarge, {GLFW_KEY_F1 | control, "Big time jump (Debug Mode only)"} }, + { user_command::timejumpsmall, {GLFW_KEY_F1 | shift, "Small time jump (Debug Mode only)"} }, // admin_vehiclemove, - { user_command::vehiclemoveforwards, {GLFW_KEY_LEFT_BRACKET | keymodifier::control, "Move the train forwards (Debug Mode only)"} }, - { user_command::vehiclemovebackwards, {GLFW_KEY_RIGHT_BRACKET | keymodifier::control, "Move the train backwards (Debug Mode only)"} }, - { user_command::vehicleboost, {GLFW_KEY_TAB | keymodifier::control, "Boost the train (Debug Mode only)"} }, - { user_command::debugtoggle, {GLFW_KEY_F12 | keymodifier::control | keymodifier::shift, "Toggle Debug Mode"} }, + { user_command::vehiclemoveforwards, {GLFW_KEY_LEFT_BRACKET | control, "Move the train forwards (Debug Mode only)"} }, + { user_command::vehiclemovebackwards, {GLFW_KEY_RIGHT_BRACKET | control, "Move the train backwards (Debug Mode only)"} }, + { user_command::vehicleboost, {GLFW_KEY_TAB | control, "Boost the train (Debug Mode only)"} }, + { user_command::debugtoggle, {GLFW_KEY_F12 | control | shift, "Toggle Debug Mode"} }, { user_command::pausetoggle, {GLFW_KEY_ESCAPE, "Pause the game"} } }; } diff --git a/input/keyboardinput.cpp b/input/keyboardinput.cpp index 209ca76c..498f2783 100644 --- a/input/keyboardinput.cpp +++ b/input/keyboardinput.cpp @@ -197,8 +197,8 @@ keyboard_input::recall_bindings() { } else if (bindingkeyname == "//") { descriptionStarted = true; } else { - if( bindingkeyname == "shift" ) { keycode |= keymodifier::shift; } - else if( bindingkeyname == "ctrl" ) { keycode |= keymodifier::control; } + if( bindingkeyname == "shift" ) { keycode |= shift; } + else if( bindingkeyname == "ctrl" ) { keycode |= control; } else if( bindingkeyname == "none" ) { keycode = 0; } else { // regular key, convert it to glfw key code @@ -241,9 +241,9 @@ void keyboard_input::dump_bindings() const int keycode = std::get(binding.second); auto it = keytonamemap.find(keycode & 0xFFFF); if (it != keytonamemap.end()) { - if (keycode & keymodifier::control) + if (keycode & control) stream << "ctrl "; - if (keycode & keymodifier::shift) + if (keycode & shift) stream << "shift "; stream << it->second; @@ -294,8 +294,8 @@ keyboard_input::key( int const Key, int const Action ) { // include active modifiers for currently pressed key, except if the key is a modifier itself auto key = Key - | ( modifier ? 0 : input::key_shift ? keymodifier::shift : 0 ) - | ( modifier ? 0 : input::key_ctrl ? keymodifier::control : 0 ); + | ( modifier ? 0 : input::key_shift ? shift : 0 ) + | ( modifier ? 0 : input::key_ctrl ? control : 0 ); if( Action == GLFW_RELEASE ) { auto const stored = m_modsforkeys.find( Key ); @@ -448,10 +448,10 @@ keyboard_input::binding_hint( user_command const Command ) const { if( lookup == keytonamemap.end() ) { return ""; } std::string hint; - if( ( binding & keymodifier::shift ) != 0 ) { + if( ( binding & shift ) != 0 ) { hint += "SHIFT "; } - if( ( binding & keymodifier::control ) != 0 ) { + if( ( binding & control ) != 0 ) { hint += "CTRL "; } hint += lookup->second; diff --git a/input/messaging.cpp b/input/messaging.cpp index 37258451..e079f001 100644 --- a/input/messaging.cpp +++ b/input/messaging.cpp @@ -43,7 +43,7 @@ Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam) { } void -OnCommandGet(multiplayer::DaneRozkaz *pRozkaz) +OnCommandGet(DaneRozkaz *pRozkaz) { // odebranie komunikatu z serwera if (pRozkaz->iSygn == EU07_MESSAGEHEADER ) switch (pRozkaz->iComm) @@ -303,8 +303,8 @@ WyslijNamiary(TDynamicObject const *Vehicle) + Vehicle->MoverParameters->DoorLeftOpened * 16 + Vehicle->MoverParameters->DoorRightOpened * 32 #else - + ( false == Vehicle->MoverParameters->Doors.instances[side::left].is_closed ) * 16 - + ( false == Vehicle->MoverParameters->Doors.instances[side::right].is_closed ) * 32 + + ( false == Vehicle->MoverParameters->Doors.instances[left].is_closed ) * 16 + + ( false == Vehicle->MoverParameters->Doors.instances[right].is_closed ) * 32 #endif + Vehicle->MoverParameters->FuseFlag * 64 + Vehicle->MoverParameters->DepartureSignal * 128; diff --git a/input/messaging.h b/input/messaging.h index f3592b27..e2a3026f 100644 --- a/input/messaging.h +++ b/input/messaging.h @@ -38,7 +38,7 @@ struct DaneRozkaz2 { // struktura komunikacji z EU07.EXE void Navigate( std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam ); -void OnCommandGet( multiplayer::DaneRozkaz *pRozkaz ); +void OnCommandGet( DaneRozkaz *pRozkaz ); void WyslijEvent( const std::string &e, const std::string &d ); void WyslijString( const std::string &t, int n ); diff --git a/input/zmq_input.cpp b/input/zmq_input.cpp index 0e2cc1e2..58906515 100644 --- a/input/zmq_input.cpp +++ b/input/zmq_input.cpp @@ -230,7 +230,7 @@ std::unordered_map zmq_input::output_fiel { "time_millisecond_of_day", output_fields::time_millisecond_of_day } }; -zmq::message_t zmq_input::pack_field(zmq_input::output_fields f) { +zmq::message_t zmq_input::pack_field(output_fields f) { const SYSTEMTIME time = simulation::Time.data(); if (f == output_fields::time_month_of_era) diff --git a/launcher/scenery_list.cpp b/launcher/scenery_list.cpp index 79d73aaa..3d34ed7b 100644 --- a/launcher/scenery_list.cpp +++ b/launcher/scenery_list.cpp @@ -310,7 +310,7 @@ void ui::scenerylist_panel::draw_trainset(trainset_desc &trainset) selected_trainset = &trainset; } else if (ImGui::IsItemClicked(1)) { - register_popup(std::make_unique(*this, dyn_desc)); + register_popup(std::make_unique(*this, dyn_desc)); } else if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); diff --git a/model/Model3d.cpp b/model/Model3d.cpp index 4ad3c641..d4661804 100644 --- a/model/Model3d.cpp +++ b/model/Model3d.cpp @@ -1097,10 +1097,10 @@ TSubModel *TSubModel::GetFromName(std::string const &search, bool i) // AnsiString name=AnsiString(); std::string search_lc = search; if (i) - std::transform(search_lc.begin(), search_lc.end(), search_lc.begin(), ::tolower); + std::transform(search_lc.begin(), search_lc.end(), search_lc.begin(), tolower); std::string pName_lc = pName; if (i) - std::transform(pName_lc.begin(), pName_lc.end(), pName_lc.begin(), ::tolower); + std::transform(pName_lc.begin(), pName_lc.end(), pName_lc.begin(), tolower); if (pName.size() && search.size()) if (pName_lc == search_lc) return this; diff --git a/model/Model3d.h b/model/Model3d.h index 7ebb1317..60a64bd4 100644 --- a/model/Model3d.h +++ b/model/Model3d.h @@ -115,7 +115,7 @@ public: f4Specular { 0.0f,0.0f,0.0f,1.0f }, f4Emision { 1.0f,1.0f,1.0f,1.0f }; glm::vec3 DiffuseOverride { -1.f }; - normalization m_normalizenormals { normalization::none }; // indicates vectors need to be normalized due to scaling etc + normalization m_normalizenormals { none }; // indicates vectors need to be normalized due to scaling etc float diffuseMultiplier {1.0}; float fWireSize { 0.0f }; // nie używane, ale wczytywane float fSquareMaxDist { 10000.0f * 10000.0f }; diff --git a/model/vertex.h b/model/vertex.h index 4c2ff2ad..d1ab1a9c 100644 --- a/model/vertex.h +++ b/model/vertex.h @@ -58,7 +58,7 @@ struct world_vertex { void set_half( world_vertex const &Vertex1, world_vertex const &Vertex2 ) { *this = - world_vertex::lerp( + lerp( Vertex1, Vertex2, 0.5 ); } @@ -66,7 +66,7 @@ struct world_vertex { void set_from_x( world_vertex const &Vertex1, world_vertex const &Vertex2, double const X ) { *this = - world_vertex::lerp( + lerp( Vertex1, Vertex2, ( X - Vertex1.position.x ) / ( Vertex2.position.x - Vertex1.position.x ) ); } @@ -74,7 +74,7 @@ struct world_vertex { void set_from_z( world_vertex const &Vertex1, world_vertex const &Vertex2, double const Z ) { *this = - world_vertex::lerp( + lerp( Vertex1, Vertex2, ( Z - Vertex1.position.z ) / ( Vertex2.position.z - Vertex1.position.z ) ); } diff --git a/network/backend/asio.cpp b/network/backend/asio.cpp index 1ff27bb4..2ef4d3c2 100644 --- a/network/backend/asio.cpp +++ b/network/backend/asio.cpp @@ -222,7 +222,7 @@ std::shared_ptr network::tcp::asio_manager::create_server(std:: int port; stream >> port; - return std::make_shared(backbuffer, io_context, host, port); + return std::make_shared(backbuffer, io_context, host, port); } std::shared_ptr network::tcp::asio_manager::create_client(const std::string &conf) { @@ -234,7 +234,7 @@ std::shared_ptr network::tcp::asio_manager::create_client(const int port; stream >> port; - return std::make_shared(io_context, host, port); + return std::make_shared(io_context, host, port); } void network::tcp::asio_manager::update() { diff --git a/network/backend/asio.h b/network/backend/asio.h index 47e731c7..f7f250fb 100644 --- a/network/backend/asio.h +++ b/network/backend/asio.h @@ -67,7 +67,7 @@ namespace network::tcp client(asio::io_context &io_ctx, const std::string &host, uint32_t port); }; - class asio_manager : public network::backend_manager { + class asio_manager : public backend_manager { asio::io_context io_context; public: diff --git a/network/manager.h b/network/manager.h index 572a8c6b..d36c7bcb 100644 --- a/network/manager.h +++ b/network/manager.h @@ -25,7 +25,7 @@ namespace network manager(); std::optional servers; - std::shared_ptr client; + std::shared_ptr client; void create_server(const std::string &backend, const std::string &conf); void connect(const std::string &backend, const std::string &conf); diff --git a/network/message.cpp b/network/message.cpp index 87958c9e..db6d72d3 100644 --- a/network/message.cpp +++ b/network/message.cpp @@ -30,7 +30,7 @@ void network::server_hello::deserialize(std::istream &stream) scenario = sn_utils::d_str(stream); } -void ::network::request_command::serialize(std::ostream &stream) const +void network::request_command::serialize(std::ostream &stream) const { sn_utils::ls_uint32(stream, commands.size()); for (auto const &kv : commands) diff --git a/rendering/frustum.cpp b/rendering/frustum.cpp index a1fc4373..a607207f 100644 --- a/rendering/frustum.cpp +++ b/rendering/frustum.cpp @@ -169,7 +169,7 @@ cFrustum::cube_inside( float const X, float const Y, float const Z, float const return true; } -void cFrustum::normalize_plane( cFrustum::side const Side ) { +void cFrustum::normalize_plane( side const Side ) { const float magnitude = std::sqrt( diff --git a/rendering/frustum.h b/rendering/frustum.h index 4afe02f0..49734eae 100644 --- a/rendering/frustum.h +++ b/rendering/frustum.h @@ -79,7 +79,7 @@ private: // methods: void - normalize_plane( cFrustum::side const Side ); // normalizes a plane (A side) from the frustum + normalize_plane( side const Side ); // normalizes a plane (A side) from the frustum // members: float m_frustum[6][4]; // holds the A B C and D values (normal & distance) for each side of the frustum. diff --git a/rendering/geometrybank.cpp b/rendering/geometrybank.cpp index 66ac1097..47fc443f 100644 --- a/rendering/geometrybank.cpp +++ b/rendering/geometrybank.cpp @@ -251,14 +251,14 @@ void calculate_indices( index_array &Indices, vertex_array &Vertices, userdata_a // generic geometry bank class, allows storage, update and drawing of geometry chunks // creates a new geometry chunk of specified type from supplied data. returns: handle to the chunk or NULL -gfx::geometry_handle -geometry_bank::create( gfx::vertex_array &Vertices, userdata_array &Userdata, unsigned int const Type ) { +geometry_handle +geometry_bank::create( vertex_array &Vertices, userdata_array &Userdata, unsigned int const Type ) { if(Vertices.empty()) { return { 0, 0 }; } m_chunks.emplace_back( Vertices, Userdata, Type ); // NOTE: handle is effectively (index into chunk array + 1) this leaves value of 0 to serve as error/empty handle indication - const gfx::geometry_handle chunkhandle { 0, static_cast(m_chunks.size()) }; + const geometry_handle chunkhandle { 0, static_cast(m_chunks.size()) }; // template method implementation create_( chunkhandle ); // all done @@ -266,14 +266,14 @@ geometry_bank::create( gfx::vertex_array &Vertices, userdata_array &Userdata, un } // creates a new indexed geometry chunk of specified type from supplied data. returns: handle to the chunk or NULL -gfx::geometry_handle -geometry_bank::create( gfx::index_array &Indices, gfx::vertex_array &Vertices, userdata_array &Userdata, unsigned int const Type ) { +geometry_handle +geometry_bank::create( index_array &Indices, vertex_array &Vertices, userdata_array &Userdata, unsigned int const Type ) { if(Vertices.empty()) { return { 0, 0 }; } m_chunks.emplace_back( Indices, Vertices, Userdata, Type ); // NOTE: handle is effectively (index into chunk array + 1) this leaves value of 0 to serve as error/empty handle indication - const gfx::geometry_handle chunkhandle { 0, static_cast(m_chunks.size()) }; + const geometry_handle chunkhandle { 0, static_cast(m_chunks.size()) }; // template method implementation create_( chunkhandle ); // all done @@ -282,11 +282,11 @@ geometry_bank::create( gfx::index_array &Indices, gfx::vertex_array &Vertices, u // replaces data of specified chunk with the supplied vertex data, starting from specified offset bool -geometry_bank::replace( gfx::vertex_array &Vertices, userdata_array &Userdata, gfx::geometry_handle const &Geometry, std::size_t const Offset ) { +geometry_bank::replace( vertex_array &Vertices, userdata_array &Userdata, geometry_handle const &Geometry, std::size_t const Offset ) { if( ( Geometry.chunk == 0 ) || ( Geometry.chunk > m_chunks.size() ) ) { return false; } - auto &chunk = gfx::geometry_bank::chunk( Geometry ); + auto &chunk = geometry_bank::chunk( Geometry ); if( ( Offset == 0 ) && ( Vertices.size() == chunk.vertices.size() ) ) { @@ -298,8 +298,8 @@ geometry_bank::replace( gfx::vertex_array &Vertices, userdata_array &Userdata, g // ...otherwise we need to do some legwork // NOTE: if the offset is larger than existing size of the chunk, it'll bridge the gap with 'blank' vertices // TBD: we could bail out with an error instead if such request occurs - chunk.vertices.resize( Offset + Vertices.size(), gfx::basic_vertex() ); - chunk.userdata.resize( Offset + Userdata.size(), gfx::vertex_userdata() ); + chunk.vertices.resize( Offset + Vertices.size(), basic_vertex() ); + chunk.userdata.resize( Offset + Userdata.size(), vertex_userdata() ); chunk.vertices.insert( std::end( chunk.vertices ), std::begin( Vertices ), std::end( Vertices ) ); chunk.userdata.insert( std::end( chunk.userdata ), std::begin( Userdata ), std::end( Userdata ) ); } @@ -311,23 +311,23 @@ geometry_bank::replace( gfx::vertex_array &Vertices, userdata_array &Userdata, g // adds supplied vertex data at the end of specified chunk bool -geometry_bank::append( gfx::vertex_array &Vertices, userdata_array &Userdata, gfx::geometry_handle const &Geometry ) { +geometry_bank::append( vertex_array &Vertices, userdata_array &Userdata, geometry_handle const &Geometry ) { if( ( Geometry.chunk == 0 ) || ( Geometry.chunk > m_chunks.size() ) ) { return false; } - return replace( Vertices, Userdata, Geometry, gfx::geometry_bank::chunk( Geometry ).vertices.size() ); + return replace( Vertices, Userdata, Geometry, chunk( Geometry ).vertices.size() ); } // draws geometry stored in specified chunk std::size_t -geometry_bank::draw( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams ) { +geometry_bank::draw( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams ) { // template method implementation return draw_( Geometry, Units, Streams ); } // draws geometry stored in specified chunk InstanceCount times via instanced draw call std::size_t -geometry_bank::draw_instanced( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, std::size_t const InstanceCount, unsigned int const Streams ) { +geometry_bank::draw_instanced( geometry_handle const &Geometry, stream_units const &Units, std::size_t const InstanceCount, unsigned int const Streams ) { if( InstanceCount == 0 ) { return 0; } return draw_instanced_( Geometry, Units, InstanceCount, Streams ); } @@ -341,23 +341,23 @@ geometry_bank::release() { // provides direct access to indexdata of specfied chunk index_array const & -geometry_bank::indices( gfx::geometry_handle const &Geometry ) const { +geometry_bank::indices( geometry_handle const &Geometry ) const { - return geometry_bank::chunk( Geometry ).indices; + return chunk( Geometry ).indices; } // provides direct access to vertex data of specfied chunk vertex_array const & -geometry_bank::vertices( gfx::geometry_handle const &Geometry ) const { +geometry_bank::vertices( geometry_handle const &Geometry ) const { - return geometry_bank::chunk( Geometry ).vertices; + return chunk( Geometry ).vertices; } // provides direct access to vertex user data of specfied chunk userdata_array const & -geometry_bank::userdata( gfx::geometry_handle const &Geometry ) const { +geometry_bank::userdata( geometry_handle const &Geometry ) const { - return geometry_bank::chunk( Geometry ).userdata; + return chunk( Geometry ).userdata; } // geometry bank manager, holds collection of geometry banks @@ -370,7 +370,7 @@ geometrybank_manager::update() { } // creates a new geometry bank. returns: handle to the bank or NULL -gfx::geometrybank_handle +geometrybank_handle geometrybank_manager::register_bank(std::unique_ptr bank) { m_geometrybanks.emplace_back(std::move(bank), std::chrono::steady_clock::time_point() ); @@ -379,8 +379,8 @@ geometrybank_manager::register_bank(std::unique_ptr bank) { } // creates a new geometry chunk of specified type from supplied data, in specified bank. returns: handle to the chunk or NULL -gfx::geometry_handle -geometrybank_manager::create_chunk(vertex_array &Vertices, userdata_array &Userdata, gfx::geometrybank_handle const &Geometry, int const Type ) { +geometry_handle +geometrybank_manager::create_chunk(vertex_array &Vertices, userdata_array &Userdata, geometrybank_handle const &Geometry, int const Type ) { auto const newchunkhandle = bank( Geometry ).first->create( Vertices, Userdata, Type ); @@ -389,8 +389,8 @@ geometrybank_manager::create_chunk(vertex_array &Vertices, userdata_array &Userd } // creates a new indexed geometry chunk of specified type from supplied data, in specified bank. returns: handle to the chunk or NULL -gfx::geometry_handle -geometrybank_manager::create_chunk( gfx::index_array &Indices, gfx::vertex_array &Vertices, userdata_array &Userdata, gfx::geometrybank_handle const &Geometry, unsigned int const Type ) { +geometry_handle +geometrybank_manager::create_chunk( index_array &Indices, vertex_array &Vertices, userdata_array &Userdata, geometrybank_handle const &Geometry, unsigned int const Type ) { auto const newchunkhandle = bank( Geometry ).first->create( Indices, Vertices, Userdata, Type ); @@ -400,20 +400,20 @@ geometrybank_manager::create_chunk( gfx::index_array &Indices, gfx::vertex_array // replaces data of specified chunk with the supplied vertex data, starting from specified offset bool -geometrybank_manager::replace( gfx::vertex_array &Vertices, userdata_array &Userdata, gfx::geometry_handle const &Geometry, std::size_t const Offset ) { +geometrybank_manager::replace( vertex_array &Vertices, userdata_array &Userdata, geometry_handle const &Geometry, std::size_t const Offset ) { return bank( Geometry ).first->replace( Vertices, Userdata, Geometry, Offset ); } // adds supplied vertex data at the end of specified chunk bool -geometrybank_manager::append( gfx::vertex_array &Vertices, userdata_array &Userdata, gfx::geometry_handle const &Geometry ) { +geometrybank_manager::append( vertex_array &Vertices, userdata_array &Userdata, geometry_handle const &Geometry ) { return bank( Geometry ).first->append( Vertices, Userdata, Geometry ); } // draws geometry stored in specified chunk void -geometrybank_manager::draw( gfx::geometry_handle const &Geometry, unsigned int const Streams ) { +geometrybank_manager::draw( geometry_handle const &Geometry, unsigned int const Streams ) { if( Geometry == null_handle ) { return; } @@ -425,7 +425,7 @@ geometrybank_manager::draw( gfx::geometry_handle const &Geometry, unsigned int c // draws geometry stored in specified chunk InstanceCount times via instanced draw call void -geometrybank_manager::draw_instanced( gfx::geometry_handle const &Geometry, std::size_t const InstanceCount, unsigned int const Streams ) { +geometrybank_manager::draw_instanced( geometry_handle const &Geometry, std::size_t const InstanceCount, unsigned int const Streams ) { if( Geometry == null_handle ) { return; } if( InstanceCount == 0 ) { return; } @@ -437,22 +437,22 @@ geometrybank_manager::draw_instanced( gfx::geometry_handle const &Geometry, std: } // provides direct access to index data of specfied chunk -gfx::index_array const & -geometrybank_manager::indices( gfx::geometry_handle const &Geometry ) const { +index_array const & +geometrybank_manager::indices( geometry_handle const &Geometry ) const { return bank( Geometry ).first->indices( Geometry ); } // provides direct access to vertex data of specfied chunk -gfx::vertex_array const & -geometrybank_manager::vertices( gfx::geometry_handle const &Geometry ) const { +vertex_array const & +geometrybank_manager::vertices( geometry_handle const &Geometry ) const { return bank( Geometry ).first->vertices( Geometry ); } // provides direct access to vertex user data of specfied chunk -gfx::userdata_array const & -geometrybank_manager::userdata( gfx::geometry_handle const &Geometry ) const { +userdata_array const & +geometrybank_manager::userdata( geometry_handle const &Geometry ) const { return bank( Geometry ).first->userdata( Geometry ); } diff --git a/rendering/geometrybank.h b/rendering/geometrybank.h index 39735e00..64efd416 100644 --- a/rendering/geometrybank.h +++ b/rendering/geometrybank.h @@ -51,8 +51,8 @@ enum stream { texture = 0x8 }; -unsigned int const basic_streams { stream::position | stream::normal | stream::texture }; -unsigned int const color_streams { stream::position | stream::color | stream::texture }; +unsigned int const basic_streams { position | normal | texture }; +unsigned int const color_streams { position | color | texture }; struct stream_units { @@ -110,20 +110,20 @@ public: // methods: // creates a new geometry chunk of specified type from supplied data. returns: handle to the chunk or NULL - auto create( gfx::vertex_array &Vertices, gfx::userdata_array& Userdata, unsigned int const Type ) -> gfx::geometry_handle; + auto create( vertex_array &Vertices, userdata_array& Userdata, unsigned int const Type ) -> geometry_handle; // creates a new indexed geometry chunk of specified type from supplied data. returns: handle to the chunk or NULL - auto create( gfx::index_array &Indices, gfx::vertex_array &Vertices, gfx::userdata_array& Userdata, unsigned int const Type ) -> gfx::geometry_handle; + auto create( index_array &Indices, vertex_array &Vertices, userdata_array& Userdata, unsigned int const Type ) -> geometry_handle; // replaces vertex data of specified chunk with the supplied data, starting from specified offset - auto replace( gfx::vertex_array &Vertices, gfx::userdata_array& Userdata, gfx::geometry_handle const &Geometry, std::size_t const Offset = 0 ) -> bool; + auto replace( vertex_array &Vertices, userdata_array& Userdata, geometry_handle const &Geometry, std::size_t const Offset = 0 ) -> bool; // adds supplied vertex data at the end of specified chunk - auto append( gfx::vertex_array &Vertices, gfx::userdata_array& Userdata, gfx::geometry_handle const &Geometry ) -> bool; + auto append( vertex_array &Vertices, userdata_array& Userdata, geometry_handle const &Geometry ) -> bool; // draws geometry stored in specified chunk - auto draw( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams = basic_streams ) -> std::size_t; + auto draw( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams = basic_streams ) -> std::size_t; // draws geometry stored in specified chunk N times via glDrawElementsInstanced* - auto draw_instanced( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, std::size_t const InstanceCount, unsigned int const Streams = basic_streams ) -> std::size_t; + auto draw_instanced( geometry_handle const &Geometry, stream_units const &Units, std::size_t const InstanceCount, unsigned int const Streams = basic_streams ) -> std::size_t; // draws geometry stored in supplied list of chunks template - auto draw( Iterator_ First, Iterator_ Last, gfx::stream_units const &Units, unsigned int const Streams = basic_streams ) ->std::size_t { + auto draw( Iterator_ First, Iterator_ Last, stream_units const &Units, unsigned int const Streams = basic_streams ) ->std::size_t { std::size_t count { 0 }; while( First != Last ) { count += draw( *First, Units, Streams ); ++First; } @@ -131,28 +131,28 @@ public: // frees subclass-specific resources associated with the bank, typically called when the bank wasn't in use for a period of time void release(); // provides direct access to index data of specfied chunk - auto indices( gfx::geometry_handle const &Geometry ) const -> gfx::index_array const &; + auto indices( geometry_handle const &Geometry ) const -> index_array const &; // provides direct access to vertex data of specfied chunk - auto vertices( gfx::geometry_handle const &Geometry ) const -> gfx::vertex_array const &; + auto vertices( geometry_handle const &Geometry ) const -> vertex_array const &; // provides direct access to vertex user data of specfied chunk - auto userdata( gfx::geometry_handle const &Geometry ) const -> gfx::userdata_array const &; + auto userdata( geometry_handle const &Geometry ) const -> userdata_array const &; protected: // types: struct geometry_chunk { unsigned int type; // kind of geometry used by the chunk - gfx::vertex_array vertices; // geometry data - gfx::index_array indices; // index data - gfx::userdata_array userdata; + vertex_array vertices; // geometry data + index_array indices; // index data + userdata_array userdata; // NOTE: constructor doesn't copy provided geometry data, but moves it - geometry_chunk( gfx::vertex_array &Vertices, gfx::userdata_array& Userdata, unsigned int Type ) : + geometry_chunk( vertex_array &Vertices, userdata_array& Userdata, unsigned int Type ) : type( Type ) { vertices.swap( Vertices ); userdata.swap( Userdata ); } // NOTE: constructor doesn't copy provided geometry data, but moves it - geometry_chunk( gfx::index_array &Indices, gfx::vertex_array &Vertices, gfx::userdata_array& Userdata, unsigned int Type ) : + geometry_chunk( index_array &Indices, vertex_array &Vertices, userdata_array& Userdata, unsigned int Type ) : type( Type ) { vertices.swap( Vertices ); @@ -165,10 +165,10 @@ protected: // methods inline - auto chunk( gfx::geometry_handle const Geometry ) -> geometry_chunk & { + auto chunk( geometry_handle const Geometry ) -> geometry_chunk & { return m_chunks[ Geometry.chunk - 1 ]; } inline - auto chunk( gfx::geometry_handle const Geometry ) const -> geometry_chunk const & { + auto chunk( geometry_handle const Geometry ) const -> geometry_chunk const & { return m_chunks[ Geometry.chunk - 1 ]; } // members: @@ -177,13 +177,13 @@ protected: private: // methods: // create() subclass details - virtual void create_( gfx::geometry_handle const &Geometry ) = 0; + virtual void create_( geometry_handle const &Geometry ) = 0; // replace() subclass details - virtual void replace_( gfx::geometry_handle const &Geometry ) = 0; + virtual void replace_( geometry_handle const &Geometry ) = 0; // draw() subclass details - virtual auto draw_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams ) -> std::size_t = 0; + virtual auto draw_( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams ) -> std::size_t = 0; // draw_instanced() subclass details. Default implementation falls back to N regular draws. - virtual auto draw_instanced_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, std::size_t const InstanceCount, unsigned int const Streams ) -> std::size_t { + virtual auto draw_instanced_( geometry_handle const &Geometry, stream_units const &Units, std::size_t const InstanceCount, unsigned int const Streams ) -> std::size_t { std::size_t count { 0 }; for( std::size_t i = 0; i < InstanceCount; ++i ) { count += draw_( Geometry, Units, Streams ); } return count; } @@ -204,33 +204,33 @@ public: // performs a resource sweep void update(); // registers a new geometry bank. returns: handle to the bank - auto register_bank(std::unique_ptr bank) -> gfx::geometrybank_handle; + auto register_bank(std::unique_ptr bank) -> geometrybank_handle; // creates a new geometry chunk of specified type from supplied data, in specified bank. returns: handle to the chunk or NULL - auto create_chunk( gfx::vertex_array &Vertices, gfx::userdata_array &Userdata, gfx::geometrybank_handle const &Geometry, int const Type ) -> gfx::geometry_handle; + auto create_chunk( vertex_array &Vertices, userdata_array &Userdata, geometrybank_handle const &Geometry, int const Type ) -> geometry_handle; // creates a new indexed geometry chunk of specified type from supplied data, in specified bank. returns: handle to the chunk or NULL - auto create_chunk( gfx::index_array &Indices, gfx::vertex_array &Vertices, gfx::userdata_array &Userdata, gfx::geometrybank_handle const &Geometry, unsigned int const Type ) -> gfx::geometry_handle; + auto create_chunk( index_array &Indices, vertex_array &Vertices, userdata_array &Userdata, geometrybank_handle const &Geometry, unsigned int const Type ) -> geometry_handle; // replaces data of specified chunk with the supplied vertex data, starting from specified offset - auto replace( gfx::vertex_array &Vertices, gfx::userdata_array &Userdata, gfx::geometry_handle const &Geometry, std::size_t const Offset = 0 ) -> bool; + auto replace( vertex_array &Vertices, userdata_array &Userdata, geometry_handle const &Geometry, std::size_t const Offset = 0 ) -> bool; // adds supplied vertex data at the end of specified chunk - auto append( gfx::vertex_array &Vertices, gfx::userdata_array &Userdata, gfx::geometry_handle const &Geometry ) -> bool; + auto append( vertex_array &Vertices, userdata_array &Userdata, geometry_handle const &Geometry ) -> bool; // draws geometry stored in specified chunk - void draw( gfx::geometry_handle const &Geometry, unsigned int const Streams = basic_streams ); + void draw( geometry_handle const &Geometry, unsigned int const Streams = basic_streams ); // draws geometry stored in specified chunk InstanceCount times via GPU instancing. // The shader reads per-instance modelview matrices from instance_ubo[gl_InstanceID]. - void draw_instanced( gfx::geometry_handle const &Geometry, std::size_t const InstanceCount, unsigned int const Streams = basic_streams ); + void draw_instanced( geometry_handle const &Geometry, std::size_t const InstanceCount, unsigned int const Streams = basic_streams ); template void draw( Iterator_ First, Iterator_ Last, unsigned int const Streams = basic_streams ) { while( First != Last ) { draw( *First, Streams ); ++First; } } // provides direct access to index data of specfied chunk - auto indices( gfx::geometry_handle const &Geometry ) const -> gfx::index_array const &; + auto indices( geometry_handle const &Geometry ) const -> index_array const &; // provides direct access to vertex data of specfied chunk - auto vertices( gfx::geometry_handle const &Geometry ) const -> gfx::vertex_array const &; + auto vertices( geometry_handle const &Geometry ) const -> vertex_array const &; // provides direct access to vertex data of specfied chunk - auto userdata( gfx::geometry_handle const &Geometry ) const -> gfx::userdata_array const &; + auto userdata( geometry_handle const &Geometry ) const -> userdata_array const &; // sets target texture unit for the texture data stream - auto units() -> gfx::stream_units & { return m_units; } + auto units() -> stream_units & { return m_units; } // provides access to primitives count auto primitives_count() const -> std::size_t const & { return m_primitivecount; } auto primitives_count() -> std::size_t & { return m_primitivecount; } @@ -243,18 +243,18 @@ private: // members: geometrybanktimepointpair_sequence m_geometrybanks; garbage_collector m_garbagecollector { m_geometrybanks, 60, 120, "geometry buffer" }; - gfx::stream_units m_units; + stream_units m_units; // methods inline - auto valid( gfx::geometry_handle const &Geometry ) const -> bool { + auto valid( geometry_handle const &Geometry ) const -> bool { return ( ( Geometry.bank != 0 ) && ( Geometry.bank <= m_geometrybanks.size() ) ); } inline - auto bank( gfx::geometry_handle const Geometry ) -> geometrybanktimepointpair_sequence::value_type & { + auto bank( geometry_handle const Geometry ) -> geometrybanktimepointpair_sequence::value_type & { return m_geometrybanks[ Geometry.bank - 1 ]; } inline - auto bank( gfx::geometry_handle const Geometry ) const -> geometrybanktimepointpair_sequence::value_type const & { + auto bank( geometry_handle const Geometry ) const -> geometrybanktimepointpair_sequence::value_type const & { return m_geometrybanks[ Geometry.bank - 1 ]; } // members: diff --git a/rendering/lightarray.cpp b/rendering/lightarray.cpp index 9b9e0643..b29cdc8f 100644 --- a/rendering/lightarray.cpp +++ b/rendering/lightarray.cpp @@ -22,8 +22,8 @@ light_array::insert( TDynamicObject const *Owner ) { // we're only storing lights for locos, which have two sets of lights, front and rear // for a more generic role this function would have to be tweaked to add vehicle type-specific light combinations - data.emplace_back( Owner, end::front ); - data.emplace_back( Owner, end::rear ); + data.emplace_back( Owner, front ); + data.emplace_back( Owner, rear ); } void @@ -43,7 +43,7 @@ light_array::update() { for( auto &light : data ) { // update light parameters to match current data of the owner - if( light.index == end::front ) { + if( light.index == front ) { // front light set light.position = light.owner->GetPosition() + ( light.owner->VectorFront() * ( std::max( 0.0, light.owner->GetLength() * 0.5 - 2.0 ) ) );// +( light.owner->VectorUp() * 0.25 ); light.direction = glm::make_vec3( glm::value_ptr(light.owner->VectorFront()) ); // TODO: It is needed to get value_ptr and then make_vec3? @@ -63,15 +63,15 @@ light_array::update() { auto const lights { light.owner->MoverParameters->iLights[ light.index ] & light.owner->LightList( static_cast( light.index ) ) }; // ...then check their individual state light.count = 0 - + ( ( lights & light::headlight_left ) ? 1 : 0 ) - + ( ( lights & light::headlight_right ) ? 1 : 0 ) - + ( ( lights & light::headlight_upper ) ? 1 : 0 ) - + ( ( lights & light::highbeamlight_left ) ? 1: 0) - + ( ( lights & light::highbeamlight_right ) ? 1 : 0); + + ( ( lights & headlight_left ) ? 1 : 0 ) + + ( ( lights & headlight_right ) ? 1 : 0 ) + + ( ( lights & headlight_upper ) ? 1 : 0 ) + + ( ( lights & highbeamlight_left ) ? 1: 0) + + ( ( lights & highbeamlight_right ) ? 1 : 0); // set intensity if( light.count > 0 ) { - const bool isEnabled = light.index == end::front ? !light.owner->HeadlightsAoff : !light.owner->HeadlightsBoff; + const bool isEnabled = light.index == front ? !light.owner->HeadlightsAoff : !light.owner->HeadlightsBoff; light.intensity = std::max(0.0f, std::log((float)light.count + 1.0f)); if (light.owner->DimHeadlights && !light.owner->HighBeamLights && isEnabled) // tylko przyciemnione @@ -89,9 +89,9 @@ light_array::update() { // TBD, TODO: intensity can be affected further by other factors light.state = { - ( ( lights & light::headlight_left | light::highbeamlight_left ) ? 1.f : 0.f ), - ( ( lights & light::headlight_upper ) ? 1.f : 0.f ), - ( ( lights & light::headlight_right | light::highbeamlight_right) ? 1.f : 0.f ) }; + ( ( lights & headlight_left | highbeamlight_left ) ? 1.f : 0.f ), + ( ( lights & headlight_upper ) ? 1.f : 0.f ), + ( ( lights & headlight_right | highbeamlight_right) ? 1.f : 0.f ) }; light.color = { static_cast(light.owner->MoverParameters->refR) / 255.0f, diff --git a/rendering/nullrenderer.cpp b/rendering/nullrenderer.cpp index a37eddb9..6afe3639 100644 --- a/rendering/nullrenderer.cpp +++ b/rendering/nullrenderer.cpp @@ -6,4 +6,4 @@ std::unique_ptr null_renderer::create_func() return std::unique_ptr(new null_renderer()); } -bool null_renderer::renderer_register = gfx_renderer_factory::get_instance()->register_backend("null", null_renderer::create_func); +bool null_renderer::renderer_register = gfx_renderer_factory::get_instance()->register_backend("null", create_func); diff --git a/rendering/opengl33geometrybank.cpp b/rendering/opengl33geometrybank.cpp index 91c9a8dd..c4390f6c 100644 --- a/rendering/opengl33geometrybank.cpp +++ b/rendering/opengl33geometrybank.cpp @@ -18,7 +18,7 @@ namespace gfx { // create() subclass details void -opengl33_vaogeometrybank::create_( gfx::geometry_handle const &Geometry ) { +opengl33_vaogeometrybank::create_( geometry_handle const &Geometry ) { // adding a chunk means we'll be (re)building the buffer, which will fill the chunk records, amongst other things. // thus we don't need to initialize the values here m_chunkrecords.emplace_back( chunk_record() ); @@ -28,12 +28,12 @@ opengl33_vaogeometrybank::create_( gfx::geometry_handle const &Geometry ) { // replace() subclass details void -opengl33_vaogeometrybank::replace_( gfx::geometry_handle const &Geometry ) { +opengl33_vaogeometrybank::replace_( geometry_handle const &Geometry ) { auto &chunkrecord = m_chunkrecords[ Geometry.chunk - 1 ]; chunkrecord.is_good = false; // if the overall length of the chunk didn't change we can get away with reusing the old buffer... - if( geometry_bank::chunk( Geometry ).vertices.size() != chunkrecord.vertex_count ) { + if( chunk( Geometry ).vertices.size() != chunkrecord.vertex_count ) { // ...but otherwise we'll need to allocate a new one // TBD: we could keep and reuse the old buffer also if the new chunk is smaller than the old one, // but it'd require some extra tracking and work to keep all chunks up to date; also wasting vram; may be not worth it? @@ -78,7 +78,7 @@ void opengl33_vaogeometrybank::setup_buffer() // optional index buffer... if( indexcount > 0 ) { m_indexbuffer.emplace(); - m_indexbuffer->allocate( gl::buffer::ELEMENT_ARRAY_BUFFER, indexcount * sizeof( gfx::basic_index ), GL_STATIC_DRAW ); + m_indexbuffer->allocate( gl::buffer::ELEMENT_ARRAY_BUFFER, indexcount * sizeof( basic_index ), GL_STATIC_DRAW ); if( ::glGetError() == GL_OUT_OF_MEMORY ) { ErrorLog( "openGL error: out of memory; failed to create a geometry index buffer" ); throw std::bad_alloc(); @@ -92,7 +92,7 @@ void opengl33_vaogeometrybank::setup_buffer() m_vertexbuffer.emplace(); // NOTE: we're using static_draw since it's generally true for all we have implemented at the moment // TODO: allow to specify usage hint at the object creation, and pass it here - const int vertex_size = has_userdata ? sizeof( gfx::basic_vertex ) + sizeof(gfx::vertex_userdata) : sizeof(gfx::basic_vertex); + const int vertex_size = has_userdata ? sizeof( basic_vertex ) + sizeof(vertex_userdata) : sizeof(basic_vertex); m_vertexbuffer->allocate( gl::buffer::ARRAY_BUFFER, static_cast(vertexcount * vertex_size), GL_STATIC_DRAW ); if( ::glGetError() == GL_OUT_OF_MEMORY ) { ErrorLog( "openGL error: out of memory; failed to create a geometry buffer" ); @@ -123,7 +123,7 @@ void opengl33_vaogeometrybank::setup_userdata(size_t offset) { // NOTE: units and stream parameters are unused, but they're part of (legacy) interface // TBD: specialized bank/manager pair without the cruft? std::size_t -opengl33_vaogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams ) +opengl33_vaogeometrybank::draw_( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams ) { setup_buffer(); @@ -132,18 +132,18 @@ opengl33_vaogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stre if( chunkrecord.vertex_count == 0 ) return 0; - auto const &chunk = gfx::geometry_bank::chunk( Geometry ); + auto const &chunk = geometry_bank::chunk( Geometry ); if( !chunkrecord.is_good ) { m_vao->bind(); // we may potentially need to upload new buffer data before we can draw it if( chunkrecord.index_count > 0 ) { - m_indexbuffer->upload( gl::buffer::ELEMENT_ARRAY_BUFFER, chunk.indices.data(), chunkrecord.index_offset * sizeof( gfx::basic_index ), chunkrecord.index_count * sizeof( gfx::basic_index ) ); + m_indexbuffer->upload( gl::buffer::ELEMENT_ARRAY_BUFFER, chunk.indices.data(), chunkrecord.index_offset * sizeof( basic_index ), chunkrecord.index_count * sizeof( basic_index ) ); } - m_vertexbuffer->upload( gl::buffer::ARRAY_BUFFER, chunk.vertices.data(), chunkrecord.vertex_offset * sizeof( gfx::basic_vertex ), chunkrecord.vertex_count * sizeof( gfx::basic_vertex ) ); + m_vertexbuffer->upload( gl::buffer::ARRAY_BUFFER, chunk.vertices.data(), chunkrecord.vertex_offset * sizeof( basic_vertex ), chunkrecord.vertex_count * sizeof( basic_vertex ) ); if(chunkrecord.has_userdata) m_vertexbuffer->upload(gl::buffer::ARRAY_BUFFER, chunk.userdata.data(), - static_cast(m_vertex_count * sizeof(gfx::basic_vertex) + chunkrecord.vertex_offset * sizeof(gfx::vertex_userdata)), - static_cast(chunkrecord.vertex_count * sizeof(gfx::vertex_userdata))); + static_cast(m_vertex_count * sizeof(basic_vertex) + chunkrecord.vertex_offset * sizeof(vertex_userdata)), + static_cast(chunkrecord.vertex_count * sizeof(vertex_userdata))); chunkrecord.is_good = true; } // render @@ -153,14 +153,14 @@ opengl33_vaogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stre ::glDrawRangeElementsBaseVertex( chunk.type, 0, chunkrecord.vertex_count, - chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast( chunkrecord.index_offset * sizeof( gfx::basic_index ) ), + chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast( chunkrecord.index_offset * sizeof( basic_index ) ), chunkrecord.vertex_offset ); } else if (glDrawElementsBaseVertexOES) { m_vao->bind(); ::glDrawElementsBaseVertexOES( chunk.type, - chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast( chunkrecord.index_offset * sizeof( gfx::basic_index ) ), + chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast( chunkrecord.index_offset * sizeof( basic_index ) ), chunkrecord.vertex_offset ); } else { @@ -169,7 +169,7 @@ opengl33_vaogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stre ::glDrawRangeElements( chunk.type, 0, chunkrecord.vertex_count, - chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast( chunkrecord.index_offset * sizeof( gfx::basic_index ) ) ); + chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast( chunkrecord.index_offset * sizeof( basic_index ) ) ); } } else { @@ -190,24 +190,24 @@ opengl33_vaogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stre // draw_instanced() subclass details — single GL instanced draw for InstanceCount instances. // The vertex shader reads per-instance modelview from instance_ubo[gl_InstanceID]. std::size_t -opengl33_vaogeometrybank::draw_instanced_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, std::size_t const InstanceCount, unsigned int const Streams ) +opengl33_vaogeometrybank::draw_instanced_( geometry_handle const &Geometry, stream_units const &Units, std::size_t const InstanceCount, unsigned int const Streams ) { setup_buffer(); auto &chunkrecord = m_chunkrecords.at(Geometry.chunk - 1); if( chunkrecord.vertex_count == 0 ) { return 0; } - auto const &chunk = gfx::geometry_bank::chunk( Geometry ); + auto const &chunk = geometry_bank::chunk( Geometry ); if( !chunkrecord.is_good ) { m_vao->bind(); if( chunkrecord.index_count > 0 ) { - m_indexbuffer->upload( gl::buffer::ELEMENT_ARRAY_BUFFER, chunk.indices.data(), chunkrecord.index_offset * sizeof( gfx::basic_index ), chunkrecord.index_count * sizeof( gfx::basic_index ) ); + m_indexbuffer->upload( gl::buffer::ELEMENT_ARRAY_BUFFER, chunk.indices.data(), chunkrecord.index_offset * sizeof( basic_index ), chunkrecord.index_count * sizeof( basic_index ) ); } - m_vertexbuffer->upload( gl::buffer::ARRAY_BUFFER, chunk.vertices.data(), chunkrecord.vertex_offset * sizeof( gfx::basic_vertex ), chunkrecord.vertex_count * sizeof( gfx::basic_vertex ) ); + m_vertexbuffer->upload( gl::buffer::ARRAY_BUFFER, chunk.vertices.data(), chunkrecord.vertex_offset * sizeof( basic_vertex ), chunkrecord.vertex_count * sizeof( basic_vertex ) ); if( chunkrecord.has_userdata ) { m_vertexbuffer->upload( gl::buffer::ARRAY_BUFFER, chunk.userdata.data(), - static_cast(m_vertex_count * sizeof(gfx::basic_vertex) + chunkrecord.vertex_offset * sizeof(gfx::vertex_userdata)), - static_cast(chunkrecord.vertex_count * sizeof(gfx::vertex_userdata)) ); + static_cast(m_vertex_count * sizeof(basic_vertex) + chunkrecord.vertex_offset * sizeof(vertex_userdata)), + static_cast(chunkrecord.vertex_count * sizeof(vertex_userdata)) ); } chunkrecord.is_good = true; } @@ -219,7 +219,7 @@ opengl33_vaogeometrybank::draw_instanced_( gfx::geometry_handle const &Geometry, ::glDrawElementsInstancedBaseVertex( chunk.type, chunkrecord.index_count, GL_UNSIGNED_INT, - reinterpret_cast( chunkrecord.index_offset * sizeof( gfx::basic_index ) ), + reinterpret_cast( chunkrecord.index_offset * sizeof( basic_index ) ), inst_count, chunkrecord.vertex_offset ); } diff --git a/rendering/opengl33geometrybank.h b/rendering/opengl33geometrybank.h index f5cd7e37..3a1e8882 100644 --- a/rendering/opengl33geometrybank.h +++ b/rendering/opengl33geometrybank.h @@ -46,16 +46,16 @@ private: // methods: // create() subclass details void - create_( gfx::geometry_handle const &Geometry ) override; + create_( geometry_handle const &Geometry ) override; // replace() subclass details void - replace_( gfx::geometry_handle const &Geometry ) override; + replace_( geometry_handle const &Geometry ) override; // draw() subclass details auto - draw_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams ) -> std::size_t override; + draw_( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams ) -> std::size_t override; // draw_instanced() subclass details — issues glDrawElementsInstancedBaseVertex auto - draw_instanced_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, std::size_t const InstanceCount, unsigned int const Streams ) -> std::size_t override; + draw_instanced_( geometry_handle const &Geometry, stream_units const &Units, std::size_t const InstanceCount, unsigned int const Streams ) -> std::size_t override; // release() subclass details void release_() override; diff --git a/rendering/opengl33renderer.cpp b/rendering/opengl33renderer.cpp index f6cf479c..21a66fa5 100644 --- a/rendering/opengl33renderer.cpp +++ b/rendering/opengl33renderer.cpp @@ -85,7 +85,7 @@ bool opengl33_renderer::Init(GLFWwindow *Window) Global.DayLight.diffuse[1] = 242.0f / 255.0f; Global.DayLight.diffuse[2] = 231.0f / 255.0f; Global.DayLight.is_directional = true; - m_sunlight.id = opengl33_renderer::sunlight; + m_sunlight.id = sunlight; // create dynamic light pool for (int idx = 0; idx < Global.DynamicLightCount; ++idx) @@ -1254,16 +1254,16 @@ bool opengl33_renderer::Render_interior( bool const Alpha ) { glm::dvec3 const originoffset { dynamic->vPosition - m_renderpass.pass_camera.position() }; float const squaredistance{ glm::length2( glm::vec3{ originoffset } / Global.ZoomFactor ) }; dynamics.emplace_back( squaredistance, dynamic ); - dynamic = dynamic->Next( coupling::permanent ); + dynamic = dynamic->Next( permanent ); } // draw also interiors of permanently coupled vehicles in front, if there's any - dynamic = simulation::Train->Dynamic()->Prev( coupling::permanent ); + dynamic = simulation::Train->Dynamic()->Prev( permanent ); while( dynamic != nullptr ) { glm::dvec3 const originoffset { dynamic->vPosition - m_renderpass.pass_camera.position() }; float const squaredistance{ glm::length2( glm::vec3{ originoffset } / Global.ZoomFactor ) }; dynamics.emplace_back( squaredistance, dynamic ); - dynamic = dynamic->Prev( coupling::permanent ); + dynamic = dynamic->Prev( permanent ); } if( Alpha ) { std::sort( @@ -1360,11 +1360,11 @@ bool opengl33_renderer::Render_coupler_adapter( TDynamicObject *Dynamic, float c auto const position { glm::dvec3 { 0.f, Dynamic->MoverParameters->Couplers[ End ].adapter_height, - ( Dynamic->MoverParameters->Couplers[ End ].adapter_length + Dynamic->MoverParameters->Dim.L * 0.5 ) * ( End == end::front ? 1 : -1 ) } }; + ( Dynamic->MoverParameters->Couplers[ End ].adapter_length + Dynamic->MoverParameters->Dim.L * 0.5 ) * ( End == front ? 1 : -1 ) } }; auto const angle { glm::vec3{ 0, - ( End == end::front ? 0 : 180 ), + ( End == front ? 0 : 180 ), 0 } }; if( Alpha ) { @@ -3449,8 +3449,8 @@ bool opengl33_renderer::Render(TDynamicObject *Dynamic) Render( attachment, Dynamic->Material(), squaredistance ); } // optional coupling adapters - Render_coupler_adapter( Dynamic, squaredistance, end::front ); - Render_coupler_adapter( Dynamic, squaredistance, end::rear ); + Render_coupler_adapter( Dynamic, squaredistance, front ); + Render_coupler_adapter( Dynamic, squaredistance, rear ); // post-render cleanup if (Dynamic->fShade > 0.0f) @@ -3475,8 +3475,8 @@ bool opengl33_renderer::Render(TDynamicObject *Dynamic) Render( attachment, Dynamic->Material(), squaredistance ); } // optional coupling adapters - Render_coupler_adapter( Dynamic, squaredistance, end::front ); - Render_coupler_adapter( Dynamic, squaredistance, end::rear ); + Render_coupler_adapter( Dynamic, squaredistance, front ); + Render_coupler_adapter( Dynamic, squaredistance, rear ); if( Dynamic->mdLoad ) { // renderowanie nieprzezroczystego ładunku Render( Dynamic->mdLoad, Dynamic->Material(), squaredistance, { 0.f, Dynamic->LoadOffset, 0.f }, {} ); @@ -4489,8 +4489,8 @@ bool opengl33_renderer::Render_Alpha(TDynamicObject *Dynamic) Render_Alpha( attachment, Dynamic->Material(), squaredistance ); } // optional coupling adapters - Render_coupler_adapter( Dynamic, squaredistance, end::front, true ); - Render_coupler_adapter( Dynamic, squaredistance, end::rear, true ); + Render_coupler_adapter( Dynamic, squaredistance, front, true ); + Render_coupler_adapter( Dynamic, squaredistance, rear, true ); if( Dynamic->mdLoad ) { // renderowanie nieprzezroczystego ładunku Render_Alpha( Dynamic->mdLoad, Dynamic->Material(), squaredistance, { 0.f, Dynamic->LoadOffset, 0.f }, {} ); @@ -5423,7 +5423,7 @@ std::unique_ptr opengl33_renderer::create_func() return std::unique_ptr(new opengl33_renderer()); } -bool opengl33_renderer::renderer_register = gfx_renderer_factory::get_instance()->register_backend("modern", opengl33_renderer::create_func); +bool opengl33_renderer::renderer_register = gfx_renderer_factory::get_instance()->register_backend("modern", create_func); bool opengl33_renderer::opengl33_imgui_renderer::Init() { diff --git a/rendering/openglgeometrybank.cpp b/rendering/openglgeometrybank.cpp index 168b59d2..58bcc142 100644 --- a/rendering/openglgeometrybank.cpp +++ b/rendering/openglgeometrybank.cpp @@ -18,12 +18,12 @@ namespace gfx { // opengl vbo-based variant of the geometry bank GLuint opengl_vbogeometrybank::m_activevertexbuffer { 0 }; // buffer bound currently on the opengl end, if any -unsigned int opengl_vbogeometrybank::m_activestreams { gfx::stream::none }; // currently enabled data type pointers +unsigned int opengl_vbogeometrybank::m_activestreams { none }; // currently enabled data type pointers std::vector opengl_vbogeometrybank::m_activetexturearrays; // currently enabled texture coord arrays // create() subclass details void -opengl_vbogeometrybank::create_( gfx::geometry_handle const &Geometry ) { +opengl_vbogeometrybank::create_( geometry_handle const &Geometry ) { // adding a chunk means we'll be (re)building the buffer, which will fill the chunk records, amongst other things. // thus we don't need to initialize the values here m_chunkrecords.emplace_back( chunk_record() ); @@ -33,12 +33,12 @@ opengl_vbogeometrybank::create_( gfx::geometry_handle const &Geometry ) { // replace() subclass details void -opengl_vbogeometrybank::replace_( gfx::geometry_handle const &Geometry ) { +opengl_vbogeometrybank::replace_( geometry_handle const &Geometry ) { auto &chunkrecord = m_chunkrecords[ Geometry.chunk - 1 ]; chunkrecord.is_good = false; // if the overall length of the chunk didn't change we can get away with reusing the old buffer... - if( geometry_bank::chunk( Geometry ).vertices.size() != chunkrecord.vertex_count ) { + if( chunk( Geometry ).vertices.size() != chunkrecord.vertex_count ) { // ...but otherwise we'll need to allocate a new one // TBD: we could keep and reuse the old buffer also if the new chunk is smaller than the old one, // but it'd require some extra tracking and work to keep all chunks up to date; also wasting vram; may be not worth it? @@ -48,7 +48,7 @@ opengl_vbogeometrybank::replace_( gfx::geometry_handle const &Geometry ) { // draw() subclass details std::size_t -opengl_vbogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams ) { +opengl_vbogeometrybank::draw_( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams ) { setup_buffer(); @@ -59,20 +59,20 @@ opengl_vbogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream if( m_activevertexbuffer != m_vertexbuffer ) { bind_buffer(); } - auto const &chunk = gfx::geometry_bank::chunk( Geometry ); + auto const &chunk = geometry_bank::chunk( Geometry ); if( false == chunkrecord.is_good ) { // we may potentially need to upload new buffer data before we can draw it if( chunkrecord.index_count > 0 ) { ::glBufferSubData( GL_ELEMENT_ARRAY_BUFFER, - chunkrecord.index_offset * sizeof( gfx::basic_index ), - chunkrecord.index_count * sizeof( gfx::basic_index ), + chunkrecord.index_offset * sizeof( basic_index ), + chunkrecord.index_count * sizeof( basic_index ), chunk.indices.data() ); } ::glBufferSubData( GL_ARRAY_BUFFER, - chunkrecord.vertex_offset * sizeof( gfx::basic_vertex ), - chunkrecord.vertex_count * sizeof( gfx::basic_vertex ), + chunkrecord.vertex_offset * sizeof( basic_vertex ), + chunkrecord.vertex_count * sizeof( basic_vertex ), chunk.vertices.data() ); chunkrecord.is_good = true; } @@ -91,7 +91,7 @@ opengl_vbogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream ::glDrawRangeElementsBaseVertex( chunk.type, 0, chunkrecord.vertex_count, - chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast( chunkrecord.index_offset * sizeof( gfx::basic_index ) ), + chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast( chunkrecord.index_offset * sizeof( basic_index ) ), chunkrecord.vertex_offset ); } else { @@ -99,7 +99,7 @@ opengl_vbogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream ::glDrawRangeElements( chunk.type, 0, chunkrecord.vertex_count, - chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast( chunkrecord.index_offset * sizeof( gfx::basic_index ) ) ); + chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast( chunkrecord.index_offset * sizeof( basic_index ) ) ); } } else { @@ -171,7 +171,7 @@ opengl_vbogeometrybank::setup_buffer() { if( indexcount > 0 ) { ::glBufferData( GL_ELEMENT_ARRAY_BUFFER, - indexcount * sizeof( gfx::basic_index ), + indexcount * sizeof( basic_index ), nullptr, GL_STATIC_DRAW ); if( ::glGetError() == GL_OUT_OF_MEMORY ) { @@ -183,7 +183,7 @@ opengl_vbogeometrybank::setup_buffer() { } ::glBufferData( GL_ARRAY_BUFFER, - vertexcount * sizeof( gfx::basic_vertex ), + vertexcount * sizeof( basic_vertex ), nullptr, GL_STATIC_DRAW ); if( ::glGetError() == GL_OUT_OF_MEMORY ) { @@ -200,7 +200,7 @@ opengl_vbogeometrybank::bind_buffer() { ::glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_indexbuffer ); ::glBindBuffer( GL_ARRAY_BUFFER, m_vertexbuffer ); m_activevertexbuffer = m_vertexbuffer; - m_activestreams = gfx::stream::none; + m_activestreams = none; } void @@ -224,34 +224,34 @@ opengl_vbogeometrybank::delete_buffer() { } void -opengl_vbogeometrybank::bind_streams( gfx::stream_units const &Units, unsigned int const Streams, size_t offset ) { +opengl_vbogeometrybank::bind_streams( stream_units const &Units, unsigned int const Streams, size_t offset ) { - if( Streams & gfx::stream::position ) { - ::glVertexPointer( 3, GL_FLOAT, sizeof( gfx::basic_vertex ), reinterpret_cast( offsetof(gfx::basic_vertex, position) + sizeof( gfx::basic_vertex ) * offset ) ); + if( Streams & position ) { + ::glVertexPointer( 3, GL_FLOAT, sizeof( basic_vertex ), reinterpret_cast( offsetof(gfx::basic_vertex, position) + sizeof( basic_vertex ) * offset ) ); ::glEnableClientState( GL_VERTEX_ARRAY ); } else { ::glDisableClientState( GL_VERTEX_ARRAY ); } // NOTE: normal and color streams share the data, making them effectively mutually exclusive - if( Streams & gfx::stream::normal ) { - ::glNormalPointer( GL_FLOAT, sizeof( gfx::basic_vertex ), reinterpret_cast( offsetof(gfx::basic_vertex, normal) + sizeof( gfx::basic_vertex ) * offset ) ); + if( Streams & normal ) { + ::glNormalPointer( GL_FLOAT, sizeof( basic_vertex ), reinterpret_cast( offsetof(gfx::basic_vertex, normal) + sizeof( basic_vertex ) * offset ) ); ::glEnableClientState( GL_NORMAL_ARRAY ); } else { ::glDisableClientState( GL_NORMAL_ARRAY ); } - if( Streams & gfx::stream::color ) { - ::glColorPointer( 3, GL_FLOAT, sizeof( gfx::basic_vertex ), reinterpret_cast( offsetof(gfx::basic_vertex, normal) + sizeof( gfx::basic_vertex ) * offset ) ); + if( Streams & color ) { + ::glColorPointer( 3, GL_FLOAT, sizeof( basic_vertex ), reinterpret_cast( offsetof(gfx::basic_vertex, normal) + sizeof( basic_vertex ) * offset ) ); ::glEnableClientState( GL_COLOR_ARRAY ); } else { ::glDisableClientState( GL_COLOR_ARRAY ); } - if( Streams & gfx::stream::texture ) { + if( Streams & texture ) { for (const auto unit : Units.texture ) { ::glClientActiveTexture( GL_TEXTURE0 + unit ); - ::glTexCoordPointer( 2, GL_FLOAT, sizeof( gfx::basic_vertex ), reinterpret_cast( offsetof(gfx::basic_vertex, texture) + sizeof( gfx::basic_vertex ) * offset ) ); + ::glTexCoordPointer( 2, GL_FLOAT, sizeof( basic_vertex ), reinterpret_cast( offsetof(gfx::basic_vertex, texture) + sizeof( basic_vertex ) * offset ) ); ::glEnableClientState( GL_TEXTURE_COORD_ARRAY ); } m_activetexturearrays = Units.texture; @@ -278,7 +278,7 @@ opengl_vbogeometrybank::release_streams() { ::glDisableClientState( GL_TEXTURE_COORD_ARRAY ); } - m_activestreams = gfx::stream::none; + m_activestreams = none; m_activetexturearrays.clear(); } @@ -286,21 +286,21 @@ opengl_vbogeometrybank::release_streams() { // create() subclass details void -opengl_dlgeometrybank::create_( gfx::geometry_handle const &Geometry ) { +opengl_dlgeometrybank::create_( geometry_handle const &Geometry ) { m_chunkrecords.emplace_back( chunk_record() ); } // replace() subclass details void -opengl_dlgeometrybank::replace_( gfx::geometry_handle const &Geometry ) { +opengl_dlgeometrybank::replace_( geometry_handle const &Geometry ) { delete_list( Geometry ); } // draw() subclass details std::size_t -opengl_dlgeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams ) { +opengl_dlgeometrybank::draw_( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams ) { auto &chunkrecord = m_chunkrecords[ Geometry.chunk - 1 ]; if( chunkrecord.streams != Streams ) { @@ -311,7 +311,7 @@ opengl_dlgeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream_ // we don't have a list ready, so compile one chunkrecord.streams = Streams; chunkrecord.list = ::glGenLists( 1 ); - auto const &chunk = gfx::geometry_bank::chunk( Geometry ); + auto const &chunk = geometry_bank::chunk( Geometry ); ::glNewList( chunkrecord.list, GL_COMPILE ); ::glBegin( chunk.type ); @@ -319,19 +319,19 @@ opengl_dlgeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream_ // indexed geometry for( auto const &index : chunk.indices ) { auto const &vertex { chunk.vertices[ index ] }; - if( Streams & gfx::stream::normal ) { ::glNormal3fv( glm::value_ptr( vertex.normal ) ); } - else if( Streams & gfx::stream::color ) { ::glColor3fv( glm::value_ptr( vertex.normal ) ); } - if( Streams & gfx::stream::texture ) { for (const auto unit : Units.texture ) { ::glMultiTexCoord2fv( unit, glm::value_ptr( vertex.texture ) ); } } - if( Streams & gfx::stream::position ) { ::glVertex3fv( glm::value_ptr( vertex.position ) ); } + if( Streams & normal ) { ::glNormal3fv( glm::value_ptr( vertex.normal ) ); } + else if( Streams & color ) { ::glColor3fv( glm::value_ptr( vertex.normal ) ); } + if( Streams & texture ) { for (const auto unit : Units.texture ) { ::glMultiTexCoord2fv( unit, glm::value_ptr( vertex.texture ) ); } } + if( Streams & position ) { ::glVertex3fv( glm::value_ptr( vertex.position ) ); } } } else { // raw geometry for( auto const &vertex : chunk.vertices ) { - if( Streams & gfx::stream::normal ) { ::glNormal3fv( glm::value_ptr( vertex.normal ) ); } - else if( Streams & gfx::stream::color ) { ::glColor3fv( glm::value_ptr( vertex.normal ) ); } - if( Streams & gfx::stream::texture ) { for (const auto unit : Units.texture ) { ::glMultiTexCoord2fv( unit, glm::value_ptr( vertex.texture ) ); } } - if( Streams & gfx::stream::position ) { ::glVertex3fv( glm::value_ptr( vertex.position ) ); } + if( Streams & normal ) { ::glNormal3fv( glm::value_ptr( vertex.normal ) ); } + else if( Streams & color ) { ::glColor3fv( glm::value_ptr( vertex.normal ) ); } + if( Streams & texture ) { for (const auto unit : Units.texture ) { ::glMultiTexCoord2fv( unit, glm::value_ptr( vertex.texture ) ); } } + if( Streams & position ) { ::glVertex3fv( glm::value_ptr( vertex.position ) ); } } } ::glEnd(); @@ -358,19 +358,19 @@ opengl_dlgeometrybank::release_() { ::glDeleteLists( chunkrecord.list, 1 ); chunkrecord.list = 0; } - chunkrecord.streams = gfx::stream::none; + chunkrecord.streams = none; } } void -opengl_dlgeometrybank::delete_list( gfx::geometry_handle const &Geometry ) { +opengl_dlgeometrybank::delete_list( geometry_handle const &Geometry ) { // NOTE: given it's our own internal method we trust it to be called with valid parameters auto &chunkrecord = m_chunkrecords[ Geometry.chunk - 1 ]; if( chunkrecord.list != 0 ) { ::glDeleteLists( chunkrecord.list, 1 ); chunkrecord.list = 0; } - chunkrecord.streams = gfx::stream::none; + chunkrecord.streams = none; } } // namespace gfx diff --git a/rendering/openglgeometrybank.h b/rendering/openglgeometrybank.h index 1ab47445..4b7711bc 100644 --- a/rendering/openglgeometrybank.h +++ b/rendering/openglgeometrybank.h @@ -28,7 +28,7 @@ public: void reset() { m_activevertexbuffer = 0; - m_activestreams = gfx::stream::none; } + m_activestreams = none; } private: // types: @@ -45,13 +45,13 @@ private: // methods: // create() subclass details void - create_( gfx::geometry_handle const &Geometry ) override; + create_( geometry_handle const &Geometry ) override; // replace() subclass details void - replace_( gfx::geometry_handle const &Geometry ) override; + replace_( geometry_handle const &Geometry ) override; // draw() subclass details auto - draw_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams ) -> std::size_t override; + draw_( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams ) -> std::size_t override; // release() subclass details void release_() override; @@ -63,7 +63,7 @@ private: delete_buffer(); static void - bind_streams(gfx::stream_units const &Units, unsigned int const Streams , size_t offset = 0); + bind_streams(stream_units const &Units, unsigned int const Streams , size_t offset = 0); static void release_streams(); @@ -103,18 +103,18 @@ private: // methods: // create() subclass details void - create_( gfx::geometry_handle const &Geometry ) override; + create_( geometry_handle const &Geometry ) override; // replace() subclass details void - replace_( gfx::geometry_handle const &Geometry ) override; + replace_( geometry_handle const &Geometry ) override; // draw() subclass details auto - draw_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams ) -> std::size_t override; + draw_( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams ) -> std::size_t override; // release () subclass details void release_() override; void - delete_list( gfx::geometry_handle const &Geometry ); + delete_list( geometry_handle const &Geometry ); // members: chunkrecord_sequence m_chunkrecords; // helper data for all stored geometry chunks, in matching order diff --git a/rendering/openglmatrixstack.h b/rendering/openglmatrixstack.h index 9ba2fa41..a2beb590 100644 --- a/rendering/openglmatrixstack.h +++ b/rendering/openglmatrixstack.h @@ -107,17 +107,17 @@ public: void mode( GLuint const Mode ) { switch( Mode ) { - case GL_MODELVIEW: { m_mode = stack_mode::gl_modelview; break; } - case GL_PROJECTION: { m_mode = stack_mode::gl_projection; break; } - case GL_TEXTURE: { m_mode = stack_mode::gl_texture; break; } + case GL_MODELVIEW: { m_mode = gl_modelview; break; } + case GL_PROJECTION: { m_mode = gl_projection; break; } + case GL_TEXTURE: { m_mode = gl_texture; break; } default: { break; } } if( m_upload ) {::glMatrixMode( Mode ); } } glm::mat4 const & data( GLuint const Mode = -1 ) const { switch( Mode ) { - case GL_MODELVIEW: { return m_stacks[ stack_mode::gl_modelview ].data(); } - case GL_PROJECTION: { return m_stacks[ stack_mode::gl_projection ].data(); } - case GL_TEXTURE: { return m_stacks[ stack_mode::gl_texture ].data(); } + case GL_MODELVIEW: { return m_stacks[ gl_modelview ].data(); } + case GL_PROJECTION: { return m_stacks[ gl_projection ].data(); } + case GL_TEXTURE: { return m_stacks[ gl_texture ].data(); } default: { return m_stacks[ m_mode ].data(); } } } float const * data_array( GLuint const Mode = -1 ) const { @@ -207,7 +207,7 @@ public: private: // members: - stack_mode m_mode{ stack_mode::gl_projection }; + stack_mode m_mode{ gl_projection }; openglstack_array m_stacks; bool m_upload { true }; }; diff --git a/rendering/openglrenderer.cpp b/rendering/openglrenderer.cpp index 668ba201..512629fd 100644 --- a/rendering/openglrenderer.cpp +++ b/rendering/openglrenderer.cpp @@ -85,14 +85,14 @@ opengl_renderer::Init( GLFWwindow *Window ) { // setup lighting ::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr(m_baseambient) ); ::glEnable( GL_LIGHTING ); - ::glEnable( opengl_renderer::sunlight ); + ::glEnable( sunlight ); // rgb value for 5780 kelvin Global.DayLight.diffuse[ 0 ] = 255.0f / 255.0f; Global.DayLight.diffuse[ 1 ] = 242.0f / 255.0f; Global.DayLight.diffuse[ 2 ] = 231.0f / 255.0f; Global.DayLight.is_directional = true; - m_sunlight.id = opengl_renderer::sunlight; + m_sunlight.id = sunlight; // ::glLightf( opengl_renderer::sunlight, GL_SPOT_CUTOFF, 90.0f ); // create dynamic light pool @@ -767,16 +767,16 @@ bool opengl_renderer::Render_interior( bool const Alpha ) { glm::dvec3 const originoffset { dynamic->vPosition - m_renderpass.camera.position() }; float const squaredistance{ glm::length2( glm::vec3{ originoffset } / Global.ZoomFactor ) }; dynamics.emplace_back( squaredistance, dynamic ); - dynamic = dynamic->Next( coupling::permanent ); + dynamic = dynamic->Next( permanent ); } // draw also interiors of permanently coupled vehicles in front, if there's any - dynamic = simulation::Train->Dynamic()->Prev( coupling::permanent ); + dynamic = simulation::Train->Dynamic()->Prev( permanent ); while( dynamic != nullptr ) { glm::dvec3 const originoffset { dynamic->vPosition - m_renderpass.camera.position() }; float const squaredistance{ glm::length2( glm::vec3{ originoffset } / Global.ZoomFactor ) }; dynamics.emplace_back( squaredistance, dynamic ); - dynamic = dynamic->Prev( coupling::permanent ); + dynamic = dynamic->Prev( permanent ); } if( Alpha ) { std::sort( @@ -869,9 +869,9 @@ bool opengl_renderer::Render_coupler_adapter( TDynamicObject *Dynamic, float con auto const position { glm::dvec3 { 0.f, Dynamic->MoverParameters->Couplers[ End ].adapter_height, - ( Dynamic->MoverParameters->Couplers[ End ].adapter_length + Dynamic->MoverParameters->Dim.L * 0.5 ) * ( End == end::front ? 1 : -1 ) } }; + ( Dynamic->MoverParameters->Couplers[ End ].adapter_length + Dynamic->MoverParameters->Dim.L * 0.5 ) * ( End == front ? 1 : -1 ) } }; - auto const angle{ glm::vec3{ 0, ( End == end::front ? 0 : 180 ), 0 } }; + auto const angle{ glm::vec3{ 0, ( End == front ? 0 : 180 ), 0 } }; if( Alpha ) { Render_Alpha( Dynamic->m_coupleradapters[ End ], Dynamic->Material(), Squaredistance, position, angle ); @@ -1203,7 +1203,7 @@ opengl_renderer::setup_units( bool const Diffuse, bool const Shadows, bool const } else { // ...otherwise fallback on static spherical image - m_textures.bind( textureunit::helper, m_reflectiontexture ); + m_textures.bind( helper, m_reflectiontexture ); ::glEnable( GL_TEXTURE_2D ); } } @@ -2509,8 +2509,8 @@ opengl_renderer::Render( TDynamicObject *Dynamic ) { Render( attachment, Dynamic->Material(), squaredistance ); } // optional coupling adapters - Render_coupler_adapter( Dynamic, squaredistance, end::front ); - Render_coupler_adapter( Dynamic, squaredistance, end::rear ); + Render_coupler_adapter( Dynamic, squaredistance, front ); + Render_coupler_adapter( Dynamic, squaredistance, rear ); // post-render cleanup m_renderspecular = false; if( Dynamic->fShade > 0.0f ) { @@ -2536,8 +2536,8 @@ opengl_renderer::Render( TDynamicObject *Dynamic ) { Render( attachment, Dynamic->Material(), squaredistance ); } // optional coupling adapters - Render_coupler_adapter( Dynamic, squaredistance, end::front ); - Render_coupler_adapter( Dynamic, squaredistance, end::rear ); + Render_coupler_adapter( Dynamic, squaredistance, front ); + Render_coupler_adapter( Dynamic, squaredistance, rear ); if( Dynamic->mdLoad ) { // renderowanie nieprzezroczystego ładunku Render( Dynamic->mdLoad, Dynamic->Material(), squaredistance, { 0.f, Dynamic->LoadOffset, 0.f }, {} ); @@ -3713,8 +3713,8 @@ opengl_renderer::Render_Alpha( TDynamicObject *Dynamic ) { Render_Alpha( attachment, Dynamic->Material(), squaredistance ); } // optional coupling adapters - Render_coupler_adapter( Dynamic, squaredistance, end::front, true ); - Render_coupler_adapter( Dynamic, squaredistance, end::rear, true ); + Render_coupler_adapter( Dynamic, squaredistance, front, true ); + Render_coupler_adapter( Dynamic, squaredistance, rear, true ); if( Dynamic->mdLoad ) { // renderowanie nieprzezroczystego ładunku Render_Alpha( Dynamic->mdLoad, Dynamic->Material(), squaredistance, { 0.f, Dynamic->LoadOffset, 0.f }, {} ); @@ -4522,7 +4522,7 @@ std::unique_ptr opengl_renderer::create_func() return std::unique_ptr(new opengl_renderer()); } -bool opengl_renderer::renderer_register = gfx_renderer_factory::get_instance()->register_backend("legacy", opengl_renderer::create_func); +bool opengl_renderer::renderer_register = gfx_renderer_factory::get_instance()->register_backend("legacy", create_func); bool opengl_renderer::opengl_imgui_renderer::Init() { diff --git a/rendering/particles.cpp b/rendering/particles.cpp index eb02bf41..6b21f966 100644 --- a/rendering/particles.cpp +++ b/rendering/particles.cpp @@ -23,14 +23,14 @@ smoke_source::particle_emitter::deserialize( cParser &Input ) { if( Input.getToken() != "{" ) { return; } std::unordered_map const variablemap { - { "min_inclination:", inclination[ value_limit::min ] }, - { "max_inclination:", inclination[ value_limit::max ] }, - { "min_velocity:", velocity[ value_limit::min ] }, - { "max_velocity:", velocity[ value_limit::max ] }, - { "min_size:", size[ value_limit::min ] }, - { "max_size:", size[ value_limit::max ] }, - { "min_opacity:", opacity[ value_limit::min ] }, - { "max_opacity:", opacity[ value_limit::max ] } }; + { "min_inclination:", inclination[ min ] }, + { "max_inclination:", inclination[ max ] }, + { "min_velocity:", velocity[ min ] }, + { "max_velocity:", velocity[ max ] }, + { "min_size:", size[ min ] }, + { "max_size:", size[ max ] }, + { "min_opacity:", opacity[ min ] }, + { "max_opacity:", opacity[ max ] } }; std::string key; while( ( false == ( ( key = Input.getToken( true, "\n\r\t ,;[]" ) ).empty() ) ) @@ -58,20 +58,20 @@ smoke_source::particle_emitter::deserialize( cParser &Input ) { void smoke_source::particle_emitter::initialize( smoke_particle &Particle ) { - auto const polarangle { glm::radians( LocalRandom( inclination[ value_limit::min ], inclination[ value_limit::max ] ) ) }; // theta + auto const polarangle { glm::radians( LocalRandom( inclination[ min ], inclination[ max ] ) ) }; // theta auto const azimuthalangle { glm::radians( LocalRandom( -180, 180 ) ) }; // phi // convert spherical coordinates to opengl coordinates auto const launchvector { glm::vec3( std::sin( polarangle ) * std::sin( azimuthalangle ) * -1, std::cos( polarangle ), std::sin( polarangle ) * std::cos( azimuthalangle ) ) }; - auto const launchvelocity { static_cast( LocalRandom( velocity[ value_limit::min ], velocity[ value_limit::max ] ) ) }; + auto const launchvelocity { static_cast( LocalRandom( velocity[ min ], velocity[ max ] ) ) }; Particle.velocity = launchvector * launchvelocity; Particle.rotation = glm::radians( LocalRandom( 0, 360 ) ); - Particle.size = LocalRandom( size[ value_limit::min ], size[ value_limit::max ] ); - Particle.opacity = LocalRandom( opacity[ value_limit::min ], opacity[ value_limit::max ] ) / Global.SmokeFidelity; + Particle.size = LocalRandom( size[ min ], size[ max ] ); + Particle.opacity = LocalRandom( opacity[ min ], opacity[ max ] ) / Global.SmokeFidelity; Particle.age = 0; } @@ -282,8 +282,8 @@ smoke_source::update( double const Timedelta, bool const Onlydespawn ) { } // determine bounding area from calculated bounding box if( false == m_particles.empty() ) { - m_area.center = glm::mix(boundingbox[value_limit::min], boundingbox[value_limit::max], 0.5); - m_area.radius = 0.5 * ( glm::length( boundingbox[ value_limit::max ] - boundingbox[ value_limit::min ] ) ); + m_area.center = glm::mix(boundingbox[min], boundingbox[max], 0.5); + m_area.radius = 0.5 * ( glm::length( boundingbox[ max ] - boundingbox[ min ] ) ); } else { m_area.center = location(); @@ -392,8 +392,8 @@ smoke_source::update( smoke_particle &Particle, bounding_box &Boundingbox, doubl Particle.age += Timedelta; // update bounding box - Boundingbox[ value_limit::min ] = glm::min( Boundingbox[ value_limit::min ], Particle.position - glm::dvec3{ Particle.size } ); - Boundingbox[ value_limit::max ] = glm::max( Boundingbox[ value_limit::max ], Particle.position + glm::dvec3{ Particle.size } ); + Boundingbox[ min ] = glm::min( Boundingbox[ min ], Particle.position - glm::dvec3{ Particle.size } ); + Boundingbox[ max ] = glm::max( Boundingbox[ max ], Particle.position + glm::dvec3{ Particle.size } ); return true; } diff --git a/rendering/particles.h b/rendering/particles.h index 5ee44230..cef1cd31 100644 --- a/rendering/particles.h +++ b/rendering/particles.h @@ -215,8 +215,8 @@ fixedstep_modifier::update( Type_ &Variable, double const Timedelta ) con m_valuechange / *( m_valuechangemodifier ) ) }; Variable += ( valuechange * static_cast( Timedelta ) ); // clamp down to allowed value range - Variable = glm::max( Variable, m_valuelimits[ value_limit::min ] ); - Variable = glm::min( Variable, m_valuelimits[ value_limit::max ] ); + Variable = glm::max( Variable, m_valuelimits[ min ] ); + Variable = glm::min( Variable, m_valuelimits[ max ] ); } template @@ -227,8 +227,8 @@ fixedstep_modifier::deserialize( cParser &Input ) { std::unordered_map const variablemap { { "step:", m_valuechange }, - { "min:", m_valuelimits[ value_limit::min ] }, - { "max:", m_valuelimits[ value_limit::max ] } }; + { "min:", m_valuelimits[ min ] }, + { "max:", m_valuelimits[ max ] } }; std::string key; diff --git a/rendering/renderer.cpp b/rendering/renderer.cpp index 919eb4ac..86bef048 100644 --- a/rendering/renderer.cpp +++ b/rendering/renderer.cpp @@ -13,7 +13,7 @@ http://mozilla.org/MPL/2.0/. std::unique_ptr GfxRenderer; -bool gfx_renderer_factory::register_backend(const std::string &backend, gfx_renderer_factory::create_method func) +bool gfx_renderer_factory::register_backend(const std::string &backend, create_method func) { backends[backend] = func; return true; diff --git a/scene/scene.cpp b/scene/scene.cpp index 3ccbde8c..ee9abdec 100644 --- a/scene/scene.cpp +++ b/scene/scene.cpp @@ -692,7 +692,7 @@ basic_cell::launch_event( TEventLauncher *Launcher, bool local_only ) { // adjusts cell bounding area to enclose specified node void -basic_cell::enclose_area( scene::basic_node *Node ) { +basic_cell::enclose_area( basic_node *Node ) { m_area.radius = std::max( m_area.radius, diff --git a/scene/scene.h b/scene/scene.h index 9f5201f8..2a24dbe9 100644 --- a/scene/scene.h +++ b/scene/scene.h @@ -216,9 +216,9 @@ public: void launch_event(TEventLauncher *Launcher, bool local_only); void - enclose_area( scene::basic_node *Node ); + enclose_area( basic_node *Node ); // members - scene::bounding_area m_area { glm::dvec3(), static_cast( 0.5 * M_SQRT2 * EU07_CELLSIZE ) }; + bounding_area m_area { glm::dvec3(), static_cast( 0.5 * M_SQRT2 * EU07_CELLSIZE ) }; bool m_active { false }; // whether the cell holds any actual data content shapenode_sequence m_shapesopaque; // opaque pieces of geometry shapenode_sequence m_shapestranslucent; // translucent pieces of geometry @@ -350,7 +350,7 @@ public: // members // placement and visibility - scene::bounding_area m_area { glm::dvec3(), static_cast( 0.5 * M_SQRT2 * EU07_SECTIONSIZE ) }; + bounding_area m_area { glm::dvec3(), static_cast( 0.5 * M_SQRT2 * EU07_SECTIONSIZE ) }; // content cell_array m_cells; // partitioning scheme shapenode_sequence m_shapes; // large pieces of opaque geometry and (legacy) terrain diff --git a/scene/sceneeditor.cpp b/scene/sceneeditor.cpp index 4516425d..1a2ea555 100644 --- a/scene/sceneeditor.cpp +++ b/scene/sceneeditor.cpp @@ -22,7 +22,7 @@ http://mozilla.org/MPL/2.0/. namespace scene { void -basic_editor::translate( scene::basic_node *Node, glm::dvec3 const &Location, bool const Snaptoground ) { +basic_editor::translate( basic_node *Node, glm::dvec3 const &Location, bool const Snaptoground ) { auto &initiallocation { Node->location() }; @@ -49,7 +49,7 @@ basic_editor::translate( scene::basic_node *Node, glm::dvec3 const &Location, bo // translate entire group // TODO: contextual switch between group and item translation // TODO: translation of affected/relevant events - auto &nodegroup { scene::Groups.group( Node->group() ).nodes }; + auto &nodegroup { Groups.group( Node->group() ).nodes }; std::for_each( std::begin( nodegroup ), std::end( nodegroup ), [&]( auto *node ) { @@ -58,7 +58,7 @@ basic_editor::translate( scene::basic_node *Node, glm::dvec3 const &Location, bo } void -basic_editor::translate( scene::basic_node *Node, float const Offset ) { +basic_editor::translate( basic_node *Node, float const Offset ) { // NOTE: offset scaling is calculated early so the same multiplier can be applied to potential whole group auto const distance { glm::length( Node->location() - Global.pCamera.Pos ) }; @@ -71,7 +71,7 @@ basic_editor::translate( scene::basic_node *Node, float const Offset ) { // translate entire group // TODO: contextual switch between group and item translation // TODO: translation of affected/relevant events - auto &nodegroup { scene::Groups.group( Node->group() ).nodes }; + auto &nodegroup { Groups.group( Node->group() ).nodes }; std::for_each( std::begin( nodegroup ), std::end( nodegroup ), [&]( auto *node ) { @@ -80,7 +80,7 @@ basic_editor::translate( scene::basic_node *Node, float const Offset ) { } void -basic_editor::translate_node( scene::basic_node *Node, glm::dvec3 const &Location ) { +basic_editor::translate_node( basic_node *Node, glm::dvec3 const &Location ) { if( typeid( *Node ) == typeid( TAnimModel ) ) { translate_instance( static_cast( Node ), Location ); @@ -91,7 +91,7 @@ basic_editor::translate_node( scene::basic_node *Node, glm::dvec3 const &Locatio } void -basic_editor::translate_node( scene::basic_node *Node, float const Offset ) { +basic_editor::translate_node( basic_node *Node, float const Offset ) { if( typeid( *Node ) == typeid( TAnimModel ) ) { translate_instance( static_cast( Node ), Offset ); @@ -134,7 +134,7 @@ basic_editor::translate_memorycell( TMemCell *Memorycell, float const Offset ) { } void -basic_editor::rotate( scene::basic_node *Node, glm::vec3 const &Angle, float const Quantization ) { +basic_editor::rotate( basic_node *Node, glm::vec3 const &Angle, float const Quantization ) { glm::vec3 rotation{Angle.x, Angle.y, Angle.z}; @@ -160,7 +160,7 @@ basic_editor::rotate( scene::basic_node *Node, glm::vec3 const &Angle, float con // TODO: contextual switch between group and item rotation // TODO: translation of affected/relevant events auto const &rotationcenter { Node->location() }; - auto const &nodegroup { scene::Groups.group( Node->group() ).nodes }; + auto const &nodegroup { Groups.group( Node->group() ).nodes }; std::for_each( std::begin( nodegroup ), std::end( nodegroup ), [&]( auto *node ) { @@ -176,7 +176,7 @@ basic_editor::rotate( scene::basic_node *Node, glm::vec3 const &Angle, float con } void -basic_editor::rotate_node( scene::basic_node *Node, glm::vec3 const &Angle ) { +basic_editor::rotate_node( basic_node *Node, glm::vec3 const &Angle ) { if( typeid( *Node ) == typeid( TAnimModel ) ) { rotate_instance( static_cast( Node ), Angle ); diff --git a/scene/sceneeditor.h b/scene/sceneeditor.h index bcff58b6..97f0474e 100644 --- a/scene/sceneeditor.h +++ b/scene/sceneeditor.h @@ -16,10 +16,10 @@ namespace scene { // TODO: move the snapshot to history stack struct node_snapshot { - scene::basic_node *node; + basic_node *node; std::string data; - node_snapshot( scene::basic_node *Node ) : + node_snapshot( basic_node *Node ) : node( Node ) { if( Node != nullptr ) { Node->export_as_text( data ); } }; @@ -33,18 +33,18 @@ class basic_editor { public: // methods void - translate( scene::basic_node *Node, glm::dvec3 const &Location, bool const Snaptoground ); + translate( basic_node *Node, glm::dvec3 const &Location, bool const Snaptoground ); void - translate( scene::basic_node *Node, float const Offset ); + translate( basic_node *Node, float const Offset ); void - rotate( scene::basic_node *Node, glm::vec3 const &Angle, float const Quantization ); + rotate( basic_node *Node, glm::vec3 const &Angle, float const Quantization ); private: // methods void - translate_node( scene::basic_node *Node, glm::dvec3 const &Location ); + translate_node( basic_node *Node, glm::dvec3 const &Location ); void - translate_node( scene::basic_node *Node, float const Offset ); + translate_node( basic_node *Node, float const Offset ); void translate_instance( TAnimModel *Instance, glm::dvec3 const &Location ); void @@ -54,7 +54,7 @@ private: void translate_memorycell( TMemCell *Memorycell, float const Offset ); void - rotate_node( scene::basic_node *Node, glm::vec3 const &Angle ); + rotate_node( basic_node *Node, glm::vec3 const &Angle ); void rotate_instance( TAnimModel *Instance, glm::vec3 const &Angle ); }; diff --git a/scene/scenenode.cpp b/scene/scenenode.cpp index c57cefe2..7ed20c65 100644 --- a/scene/scenenode.cpp +++ b/scene/scenenode.cpp @@ -143,7 +143,7 @@ shape_node::deserialize( std::istream &Input ) { // restores content of the node from provided input stream shape_node & -shape_node::import( cParser &Input, scene::node_data const &Nodedata ) { +shape_node::import( cParser &Input, node_data const &Nodedata ) { // import common data m_name = Nodedata.name; @@ -558,7 +558,7 @@ lines_node::deserialize( std::istream &Input ) { // restores content of the node from provded input stream lines_node & -lines_node::import( cParser &Input, scene::node_data const &Nodedata ) { +lines_node::import( cParser &Input, node_data const &Nodedata ) { // import common data m_name = Nodedata.name; @@ -716,7 +716,7 @@ memory_node::deserialize( cParser &Input, node_data const &Nodedata ) { -basic_node::basic_node( scene::node_data const &Nodedata ) : +basic_node::basic_node( node_data const &Nodedata ) : m_name( Nodedata.name ) { uuid = UID::random(); diff --git a/scene/scenenode.h b/scene/scenenode.h index ca727c2c..4d4034a8 100644 --- a/scene/scenenode.h +++ b/scene/scenenode.h @@ -83,7 +83,7 @@ public: struct shapenode_data { // members: // placement and visibility - scene::bounding_area area; // bounding area, in world coordinates + bounding_area area; // bounding area, in world coordinates double rangesquared_min { 0.0 }; // visibility range, min double rangesquared_max { 0.0 }; // visibility range, max bool visible { true }; // visibility flag @@ -114,7 +114,7 @@ public: deserialize( std::istream &Input ); // restores content of the node from provided input stream shape_node & - import( cParser &Input, scene::node_data const &Nodedata ); + import( cParser &Input, node_data const &Nodedata ); // imports data from provided submodel shape_node & convert( TSubModel const *Submodel ); @@ -193,7 +193,7 @@ public: struct linesnode_data { // members: // placement and visibility - scene::bounding_area area; // bounding area, in world coordinates + bounding_area area; // bounding area, in world coordinates double rangesquared_min { 0.0 }; // visibility range, min double rangesquared_max { 0.0 }; // visibility range, max bool visible { true }; // visibility flag @@ -223,7 +223,7 @@ public: deserialize( std::istream &Input ); // restores content of the node from provided input stream lines_node & - import( cParser &Input, scene::node_data const &Nodedata ); + import( cParser &Input, node_data const &Nodedata ); // adds content of provided node to already enclosed geometry. returns: true if merge could be performed bool merge( lines_node &Lines ); @@ -325,7 +325,7 @@ class basic_node { public: // constructor - explicit basic_node( scene::node_data const &Nodedata ); + explicit basic_node( node_data const &Nodedata ); // destructor virtual ~basic_node() = default; // methods @@ -356,8 +356,8 @@ public: bool visible() const; void - group( scene::group_handle Group ); - scene::group_handle + group( group_handle Group ); + group_handle group() const; void mark_dirty() { m_dirty = true; } @@ -368,8 +368,8 @@ public: public: // members - scene::group_handle m_group { null_handle }; // group this node belongs to, if any - scene::bounding_area m_area; + group_handle m_group { null_handle }; // group this node belongs to, if any + bounding_area m_area; double m_rangesquaredmin { 0.0 }; // visibility range, min double m_rangesquaredmax { 0.0 }; // visibility range, max bool m_visible { true }; // visibility flag @@ -433,12 +433,12 @@ basic_node::visible() const { inline void -basic_node::group( scene::group_handle Group ) { +basic_node::group( group_handle Group ) { m_group = Group; } inline -scene::group_handle +group_handle basic_node::group() const { return m_group; } diff --git a/scene/scenenodegroups.cpp b/scene/scenenodegroups.cpp index 662cf672..be3560e7 100644 --- a/scene/scenenodegroups.cpp +++ b/scene/scenenodegroups.cpp @@ -21,7 +21,7 @@ namespace scene { node_groups Groups; // requests creation of a new node group. returns: handle to the group -scene::group_handle +group_handle node_groups::create() { m_activegroup.push( create_handle() ); @@ -30,7 +30,7 @@ node_groups::create() { } // indicates creation of current group ended. returns: handle to the parent group or null_handle if group stack is empty -scene::group_handle +group_handle node_groups::close() { if( false == m_activegroup.empty() ) { @@ -236,7 +236,7 @@ node_groups::handle() const { // places provided node in specified group void -node_groups::insert( scene::group_handle const Group, scene::basic_node *Node ) { +node_groups::insert( group_handle const Group, basic_node *Node ) { // TBD, TODO: automatically unregister the node from its current group? Node->group( Group ); @@ -252,7 +252,7 @@ node_groups::insert( scene::group_handle const Group, scene::basic_node *Node ) // places provided event in specified group void -node_groups::insert( scene::group_handle const Group, basic_event *Event ) { +node_groups::insert( group_handle const Group, basic_event *Event ) { // TBD, TODO: automatically unregister the event from its current group? Event->group( Group ); diff --git a/scene/scenenodegroups.h b/scene/scenenodegroups.h index 350fa3d3..062c0989 100644 --- a/scene/scenenodegroups.h +++ b/scene/scenenodegroups.h @@ -16,7 +16,7 @@ namespace scene { struct basic_group { // members - std::vector nodes; + std::vector nodes; std::vector events; }; @@ -42,13 +42,13 @@ public: handle() const; // places provided node in specified group void - insert( scene::group_handle const Group, scene::basic_node *Node ); + insert( group_handle const Group, basic_node *Node ); // places provided event in specified group void - insert( scene::group_handle const Group, basic_event *Event ); + insert( group_handle const Group, basic_event *Event ); // grants direct access to specified group - scene::basic_group & - group( scene::group_handle const Group ) { + basic_group & + group( group_handle const Group ) { return m_groupmap[ Group ]; } // sends basic content of the class in legacy (text) format to provided stream void @@ -56,7 +56,7 @@ public: private: // types - using group_map = std::unordered_map; + using group_map = std::unordered_map; // methods // removes specified group from the group list and group information from the group's nodes void @@ -68,7 +68,7 @@ private: assign_cross_switch(map::track_switch&sw, std::string &sw_name, const std::string &id, size_t idx); // members group_map m_groupmap; // map of established node groups - std::stack m_activegroup; // helper, group to be assigned to newly created nodes + std::stack m_activegroup; // helper, group to be assigned to newly created nodes }; extern node_groups Groups; diff --git a/scripting/PyIntStub.cpp b/scripting/PyIntStub.cpp index 767228e4..02ee401d 100644 --- a/scripting/PyIntStub.cpp +++ b/scripting/PyIntStub.cpp @@ -19,7 +19,7 @@ void python_taskqueue::exit() { } -bool python_taskqueue::insert(python_taskqueue::task_request const &Task) +bool python_taskqueue::insert(task_request const &Task) { return false; } diff --git a/scripting/ladderlogic.cpp b/scripting/ladderlogic.cpp index b86aba6f..2010bc49 100644 --- a/scripting/ladderlogic.cpp +++ b/scripting/ladderlogic.cpp @@ -21,14 +21,14 @@ int basic_element::blank = -1; auto basic_element::input() -> int & { - switch( (basic_element::type_e)data.index() ) { - case basic_element::type_e::variable: { + switch( (type_e)data.index() ) { + case type_e::variable: { return std::get(data).value; } - case basic_element::type_e::timer: { + case type_e::timer: { return std::get(data).value; } - case basic_element::type_e::counter: { + case type_e::counter: { return std::get(data).value; } } @@ -39,14 +39,14 @@ basic_element::input() -> int & { auto basic_element::output() const -> int { - switch( (basic_element::type_e)data.index() ) { - case basic_element::type_e::variable: { + switch( (type_e)data.index() ) { + case type_e::variable: { return std::get(data).value; } - case basic_element::type_e::timer: { + case type_e::timer: { return std::get(data).time_elapsed >= std::get(data).time_preset ? std::get(data).value : 0; } - case basic_element::type_e::counter: { + case type_e::counter: { return std::get(data).count_value >= std::get(data).count_limit ? 1 : 0; } } diff --git a/scripting/ladderlogic.h b/scripting/ladderlogic.h index 075e4b0d..b692fa07 100644 --- a/scripting/ladderlogic.h +++ b/scripting/ladderlogic.h @@ -27,7 +27,7 @@ public: }; // constructors template - basic_element( basic_element::type_e Type = basic_element::type_e::variable, Args_ ...Args ); + basic_element( type_e Type = type_e::variable, Args_ ...Args ); // methods // data access auto input() -> int &; @@ -116,7 +116,7 @@ private: auto element( element_handle const Element ) -> basic_element & { return m_elements[ Element - 1 ]; } // members - static std::map const m_operationcodemap; + static std::map const m_operationcodemap; element_sequence m_elements; // collection of elements accessed by the plc program name_sequence m_elementnames; handle_sequence m_timerhandles; // indices of timer elements, timer update optimization helper @@ -129,7 +129,7 @@ private: }; template -basic_element::basic_element( basic_element::type_e Type, Args_ ...Args ) +basic_element::basic_element( type_e Type, Args_ ...Args ) { switch( Type ) { case type_e::variable: { diff --git a/simulation/simulation.cpp b/simulation/simulation.cpp index 3d42cae9..d3b996ee 100644 --- a/simulation/simulation.cpp +++ b/simulation/simulation.cpp @@ -81,24 +81,24 @@ state_manager::init_scripting_interface() { 0, -1, "__simulation.weather", "memcell" } ); - simulation::Memory.insert( memorycell ); - simulation::Region->insert( memorycell ); + Memory.insert( memorycell ); + Region->insert( memorycell ); } { auto *memorycell = new TMemCell( { 0, -1, "__simulation.time", "memcell" } ); - simulation::Memory.insert( memorycell ); - simulation::Region->insert( memorycell ); + Memory.insert( memorycell ); + Region->insert( memorycell ); } { auto *memorycell = new TMemCell( { 0, -1, "__simulation.date", "memcell" } ); - simulation::Memory.insert( memorycell ); - simulation::Region->insert( memorycell ); + Memory.insert( memorycell ); + Region->insert( memorycell ); } } @@ -112,15 +112,15 @@ state_manager::update( double const Deltatime, int Iterationcount ) { // NOTE: we perform animations first, as they can determine factors like contact with powergrid TAnimModel::AnimUpdate( totaltime ); // wykonanie zakolejkowanych animacji - simulation::Powergrid.update( totaltime ); - simulation::Vehicles.update( Deltatime, Iterationcount ); + Powergrid.update( totaltime ); + Vehicles.update( Deltatime, Iterationcount ); } void state_manager::update_clocks() { // Ra 2014-07: przeliczenie kąta czasu (do animacji zależnych od czasu) - auto const &time = simulation::Time.data(); + auto const &time = Time.data(); Global.fTimeAngleDeg = time.wHour * 15.0 + time.wMinute * 0.25 + (time.wSecond + 0.001 * time.wMilliseconds) / 240.0; Global.fClockAngleDeg[ 0 ] = 36.0 * ( time.wSecond % 10 ); // jednostki sekund Global.fClockAngleDeg[ 1 ] = 36.0 * ( time.wSecond / 10 ); // dziesiątki sekund @@ -137,11 +137,11 @@ state_manager::update_scripting_interface() { auto *time{ Memory.find( "__simulation.time" ) }; auto *date{ Memory.find( "__simulation.date" ) }; - if( simulation::is_ready ) { + if( is_ready ) { // potentially adjust weather if( weather->Value1() != m_scriptinginterface.weather->Value1() ) { Global.Overcast = std::clamp( (float)weather->Value1(), 0.f, 2.f ); - simulation::Environment.compute_weather(); + Environment.compute_weather(); } if( weather->Value2() != m_scriptinginterface.weather->Value2() ) { Global.fFogEnd = std::clamp( (float)weather->Value2(), 10.f, 25000.f ); @@ -182,7 +182,7 @@ void state_manager::process_commands() { command_data commanddata; while( Commands.pop( commanddata, (uint32_t)command_target::simulation )) { if (commanddata.command == user_command::consistreleaser) { - TDynamicObject *found_vehicle = simulation::Vehicles.find(commanddata.payload); + TDynamicObject *found_vehicle = Vehicles.find(commanddata.payload); TDynamicObject *vehicle = found_vehicle; while (vehicle) { @@ -232,15 +232,15 @@ void state_manager::process_commands() { continue; // NOTE: because malformed scenario can have vehicle name duplicates we first try to locate vehicle in world, with name search as fallback - auto targetvehicle = std::get( simulation::Region->find_vehicle( commanddata.location, 50, false, false ) ); + auto targetvehicle = std::get( Region->find_vehicle( commanddata.location, 50, false, false ) ); if( targetvehicle == nullptr || targetvehicle->name() != commanddata.payload ) { - targetvehicle = simulation::Vehicles.find( commanddata.payload ); + targetvehicle = Vehicles.find( commanddata.payload ); } if (!targetvehicle) continue; - auto *senderlocaltrain { simulation::Trains.find_id( static_cast( commanddata.param2 ) ) }; + auto *senderlocaltrain { Trains.find_id( static_cast( commanddata.param2 ) ) }; if( senderlocaltrain ) { auto *currentvehicle { senderlocaltrain->Dynamic() }; auto const samevehicle { currentvehicle == targetvehicle }; @@ -270,14 +270,14 @@ void state_manager::process_commands() { } } - auto *train { simulation::Trains.find( targetvehicle->name() ) }; + auto *train { Trains.find( targetvehicle->name() ) }; if (train) continue; train = new TTrain(); if (train->Init(targetvehicle)) { - simulation::Trains.insert(train); + Trains.insert(train); } else { delete train; @@ -301,7 +301,7 @@ void state_manager::process_commands() { basic_event *ev = Events.FindEvent(event_name); TDynamicObject *vehicle = nullptr; if (!vehicle_name.empty()) - vehicle = simulation::Vehicles.find(vehicle_name); + vehicle = Vehicles.find(vehicle_name); if (ev) Events.AddToQuery(ev, vehicle); @@ -310,7 +310,7 @@ void state_manager::process_commands() { if (commanddata.command == user_command::setlight) { int light = std::round(commanddata.param1); float state = commanddata.param2; - TAnimModel *model = simulation::Instances.find(commanddata.payload); + TAnimModel *model = Instances.find(commanddata.payload); if (model) model->LightSet(light, state); } @@ -318,29 +318,29 @@ void state_manager::process_commands() { if (commanddata.command == user_command::setdatetime) { int yearday = std::round(commanddata.param1); int minute = std::round(commanddata.param2); - simulation::Time.set_time(yearday, minute); + Time.set_time(yearday, minute); auto const weather { Global.Weather }; - simulation::Environment.compute_season(yearday); + Environment.compute_season(yearday); if( weather != Global.Weather ) { // HACK: force re-calculation of precipitation Global.Overcast = std::clamp( Global.Overcast - 0.0001f, 0.0f, 2.0f ); } - simulation::Environment.update_moon(); + Environment.update_moon(); } if (commanddata.command == user_command::setweather) { Global.fFogEnd = commanddata.param1; Global.Overcast = commanddata.param2; - simulation::Environment.compute_weather(); + Environment.compute_weather(); } if (commanddata.command == user_command::settemperature) { Global.AirTemperature = commanddata.param1; Global.Overcast = commanddata.param2; - simulation::Environment.compute_weather(); + Environment.compute_weather(); } if (commanddata.command == user_command::insertmodel) { @@ -351,21 +351,21 @@ void state_manager::process_commands() { std::getline(ss, name, ':'); std::getline(ss, data, ':'); - TAnimModel *model = simulation::State.create_model(data, name, commanddata.location); - simulation::State.create_eventlauncher("node -1 0 launcher eventlauncher 0 0 0 0.8 none -10000.0 obstacle_collision traintriggered end", name + "_snd", commanddata.location); + TAnimModel *model = State.create_model(data, name, commanddata.location); + State.create_eventlauncher("node -1 0 launcher eventlauncher 0 0 0 0.8 none -10000.0 obstacle_collision traintriggered end", name + "_snd", commanddata.location); } if (commanddata.command == user_command::deletemodel) { - simulation::State.delete_model(simulation::Instances.find(commanddata.payload)); - simulation::State.delete_eventlauncher(simulation::Events.FindEventlauncher(commanddata.payload + "_snd")); + State.delete_model(Instances.find(commanddata.payload)); + State.delete_eventlauncher(Events.FindEventlauncher(commanddata.payload + "_snd")); } if (commanddata.command == user_command::globalradiostop) { - simulation::Region->RadioStop( commanddata.location ); + Region->RadioStop( commanddata.location ); } if (commanddata.command == user_command::resetconsist) { - TDynamicObject *found_vehicle = simulation::Vehicles.find(commanddata.payload); + TDynamicObject *found_vehicle = Vehicles.find(commanddata.payload); TDynamicObject *vehicle = found_vehicle; while (vehicle) { @@ -404,12 +404,12 @@ void state_manager::process_commands() { } if (commanddata.command == user_command::fillcompressor) { - TDynamicObject *vehicle = simulation::Vehicles.find(commanddata.payload); + TDynamicObject *vehicle = Vehicles.find(commanddata.payload); vehicle->MoverParameters->CompressedVolume = 8.0f * vehicle->MoverParameters->VeselVolume; } if (commanddata.command == user_command::dynamicmove) { - TDynamicObject *vehicle = simulation::Vehicles.find(commanddata.payload); + TDynamicObject *vehicle = Vehicles.find(commanddata.payload); if (vehicle) vehicle->move_set(commanddata.param1); } @@ -422,8 +422,8 @@ void state_manager::process_commands() { std::getline(ss, vehicle_name, '%'); std::getline(ss, track_name, '%'); - TTrack *track = simulation::Paths.find(track_name); - TDynamicObject *vehicle = simulation::Vehicles.find(vehicle_name); + TTrack *track = Paths.find(track_name); + TDynamicObject *vehicle = Vehicles.find(vehicle_name); while (vehicle) { if (vehicle->Next()) @@ -446,7 +446,7 @@ void state_manager::process_commands() { } if (commanddata.command == user_command::pullalarmchain) { - TDynamicObject *vehicle = simulation::Vehicles.find(commanddata.payload); + TDynamicObject *vehicle = Vehicles.find(commanddata.payload); if (vehicle) vehicle->MoverParameters->AlarmChainSwitch(true); } @@ -459,7 +459,7 @@ void state_manager::process_commands() { std::getline(ss, vehicle_name, '%'); std::getline(ss, command, '%'); - TDynamicObject *vehicle = simulation::Vehicles.find(vehicle_name); + TDynamicObject *vehicle = Vehicles.find(vehicle_name); glm::dvec3 location = commanddata.location; if (vehicle && vehicle->Mechanik) vehicle->Mechanik->PutCommand(command, commanddata.param1, commanddata.param2, &location); diff --git a/simulation/simulationenvironment.cpp b/simulation/simulationenvironment.cpp index 9837e0e8..c1098134 100644 --- a/simulation/simulationenvironment.cpp +++ b/simulation/simulationenvironment.cpp @@ -201,7 +201,7 @@ world_environment::update() { } m_rainsound .gain( m_rainsound.m_amplitudeoffset + m_rainsound.m_amplitudefactor * 1.f ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { m_rainsound.stop(); diff --git a/simulation/simulationstateserializer.cpp b/simulation/simulationstateserializer.cpp index 10c862cb..2078b964 100644 --- a/simulation/simulationstateserializer.cpp +++ b/simulation/simulationstateserializer.cpp @@ -44,7 +44,7 @@ state_serializer::deserialize_begin( std::string const &Scenariofile ) { SafeDelete( Region ); Region = new scene::basic_region(); - simulation::State.init_scripting_interface(); + State.init_scripting_interface(); // NOTE: for the time being import from text format is a given, since we don't have full binary serialization auto state = @@ -177,7 +177,7 @@ state_serializer::deserialize_isolated( cParser &Input, scene::scratch_data &Scr // ...followed by list of its tracks while( false == (token = Input.getToken()).empty() && token != "endisolated" ) { - auto *track { simulation::Paths.find( token ) }; + auto *track { Paths.find( token ) }; if( track != nullptr ) track->AddIsolated( groupowner ); else @@ -252,7 +252,7 @@ state_serializer::deserialize_atmo( cParser &Input, scene::scratch_data &Scratch } // overcast drives weather so do a calculation here // NOTE: ugly, clean it up when we're done with world refactoring - simulation::Environment.compute_weather(); + Environment.compute_weather(); } while( false == token.empty() && token != "endatmo" ) { @@ -342,7 +342,7 @@ state_serializer::deserialize_event( cParser &Input, scene::scratch_data &Scratc event->deserialize( Input, Scratchpad ); - if( true == simulation::Events.insert( event ) ) { + if( true == Events.insert( event ) ) { scene::Groups.insert( scene::Groups.handle(), event ); } else { @@ -356,7 +356,7 @@ void state_serializer::deserialize_lua( cParser &Input, scene::scratch_data &Scr std::string file; Input >> file; #ifdef WITH_LUA - simulation::Lua.interpret(Global.asCurrentSceneryPath + file); + Lua.interpret(Global.asCurrentSceneryPath + file); #else ErrorLog(file + ": lua scripts not supported in this build."); #endif @@ -377,11 +377,11 @@ state_serializer::deserialize_firstinit( cParser &Input, scene::scratch_data &Sc } - simulation::Paths.InitTracks(); - simulation::Traction.InitTraction(); - simulation::Events.InitEvents(); - simulation::Events.InitLaunchers(); - simulation::Memory.InitCells(); + Paths.InitTracks(); + Traction.InitTraction(); + Events.InitEvents(); + Events.InitLaunchers(); + Memory.InitCells(); if (!Scratchpad.time_initialized) init_time(); @@ -390,7 +390,7 @@ state_serializer::deserialize_firstinit( cParser &Input, scene::scratch_data &Sc } void state_serializer::init_time() { - const auto &time = simulation::Time.data(); + const auto &time = Time.data(); if( true == Global.ScenarioTimeCurrent ) { // calculate time shift required to match scenario time with local clock auto const *localtime = std::gmtime( &Global.starting_timestamp ); @@ -452,22 +452,22 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch } } - if( false == simulation::Vehicles.insert( vehicle ) ) { + if( false == Vehicles.insert( vehicle ) ) { ErrorLog( "Bad scenario: duplicate vehicle name \"" + vehicle->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); } if( vehicle->MoverParameters->CategoryFlag == 1 // trains only - && ( (vehicle->LightList(end::front) & (light::headlight_left | light::headlight_right | light::headlight_upper)) != 0 - || (vehicle->LightList(end::rear) & (light::headlight_left | light::headlight_right | light::headlight_upper)) != 0 ) ) { - simulation::Lights.insert( vehicle ); + && ( (vehicle->LightList(front) & (headlight_left | headlight_right | headlight_upper)) != 0 + || (vehicle->LightList(rear) & (headlight_left | headlight_right | headlight_upper)) != 0 ) ) { + Lights.insert( vehicle ); } } else if( nodedata.type == "track" ) { auto *path { deserialize_path( Input, Scratchpad, nodedata ) }; // duplicates of named tracks are currently experimentally allowed - if( false == simulation::Paths.insert( path ) ) { + if( false == Paths.insert( path ) ) { ErrorLog( "Bad scenario: duplicate track name \"" + path->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); /* delete path; @@ -475,7 +475,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch */ } scene::Groups.insert( scene::Groups.handle(), path ); - simulation::Region->insert_and_register( path ); + Region->insert_and_register( path ); } else if( nodedata.type == "traction" ) { @@ -483,11 +483,11 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch // traction loading is optional if( traction == nullptr ) { return; } - if( false == simulation::Traction.insert( traction ) ) { + if( false == Traction.insert( traction ) ) { ErrorLog( "Bad scenario: duplicate traction piece name \"" + traction->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); } scene::Groups.insert( scene::Groups.handle(), traction ); - simulation::Region->insert_and_register( traction ); + Region->insert_and_register( traction ); } else if( nodedata.type == "tractionpowersource" ) { @@ -495,7 +495,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch // traction loading is optional if( powersource == nullptr ) { return; } - if( false == simulation::Powergrid.insert( powersource ) ) { + if( false == Powergrid.insert( powersource ) ) { ErrorLog( "Bad scenario: duplicate power grid source name \"" + powersource->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); } /* @@ -516,14 +516,14 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch auto const cellcount = instance->TerrainCount() + 1; // zliczenie submodeli for( auto i = 1; i < cellcount; ++i ) { auto *submodel = instance->TerrainSquare( i - 1 ); - simulation::Region->insert( + Region->insert( scene::shape_node().convert( submodel ), Scratchpad, false ); // if there's more than one group of triangles in the cell they're held as children of the primary submodel submodel = submodel->ChildGet(); while( submodel != nullptr ) { - simulation::Region->insert( + Region->insert( scene::shape_node().convert( submodel ), Scratchpad, false ); @@ -553,11 +553,11 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch } } - if( false == simulation::Instances.insert( instance ) ) { + if( false == Instances.insert( instance ) ) { ErrorLog( "Bad scenario: duplicate 3d model instance name \"" + instance->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); } scene::Groups.insert( scene::Groups.handle(), instance ); - simulation::Region->insert( instance ); + Region->insert( instance ); scene::basic_node *hierarchy_node = instance; if (hierarchy_node) { scene::Hierarchy[hierarchy_node->uuid.to_string()] = hierarchy_node; @@ -579,7 +579,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch if( false == skip ) { - simulation::Region->insert( + Region->insert( scene::shape_node().import( Input, nodedata ), Scratchpad, @@ -595,7 +595,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch if( false == Scratchpad.binary.terrain ) { - simulation::Region->insert( + Region->insert( scene::lines_node().import( Input, nodedata ), Scratchpad ); @@ -608,38 +608,38 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch else if( nodedata.type == "memcell" ) { auto *memorycell { deserialize_memorycell( Input, Scratchpad, nodedata ) }; - if( false == simulation::Memory.insert( memorycell ) ) { + if( false == Memory.insert( memorycell ) ) { ErrorLog( "Bad scenario: duplicate memory cell name \"" + memorycell->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); } scene::Groups.insert( scene::Groups.handle(), memorycell ); - simulation::Region->insert( memorycell ); + Region->insert( memorycell ); } else if( nodedata.type == "eventlauncher" ) { auto *eventlauncher { deserialize_eventlauncher( Input, Scratchpad, nodedata ) }; - if( false == simulation::Events.insert( eventlauncher ) ) { + if( false == Events.insert( eventlauncher ) ) { ErrorLog( "Bad scenario: duplicate event launcher name \"" + eventlauncher->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); } // event launchers can be either global, or local with limited range of activation // each gets assigned different caretaker if( true == eventlauncher->IsGlobal() ) { - simulation::Events.queue( eventlauncher ); + Events.queue( eventlauncher ); } else { scene::Groups.insert( scene::Groups.handle(), eventlauncher ); if( false == eventlauncher->IsRadioActivated() ) { // NOTE: radio-activated launchers due to potentially large activation radius are resolved on global level rather than put in a region cell - simulation::Region->insert( eventlauncher ); + Region->insert( eventlauncher ); } } } else if( nodedata.type == "sound" ) { auto *sound { deserialize_sound( Input, Scratchpad, nodedata ) }; - if( false == simulation::Sounds.insert( sound ) ) { + if( false == Sounds.insert( sound ) ) { ErrorLog( "Bad scenario: duplicate sound node name \"" + sound->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); } - simulation::Region->insert( sound ); + Region->insert( sound ); } } @@ -740,7 +740,7 @@ state_serializer::deserialize_time( cParser &Input, scene::scratch_data &Scratch // current scenario time cParser timeparser( Input.getToken() ); timeparser.getTokens( 2, false, ":" ); - auto &time = simulation::Time.data(); + auto &time = Time.data(); timeparser >> time.wHour >> time.wMinute; @@ -875,12 +875,12 @@ state_serializer::deserialize_endtrainset( cParser &Input, scene::scratch_data & 0, nullptr ); } - if( Scratchpad.trainset.couplings.back() == coupling::faux ) { + if( Scratchpad.trainset.couplings.back() == faux ) { // jeśli ostatni pojazd ma sprzęg 0 to założymy mu końcówki blaszane (jak AI się odpali, to sobie poprawi) // place end signals only on trains without a driver, activate markers otherwise Scratchpad.trainset.vehicles.back()->RaLightsSet( -1, - Scratchpad.trainset.driver != nullptr ? light::redmarker_left | light::redmarker_right | light::rearendsignals : light::rearendsignals ); + Scratchpad.trainset.driver != nullptr ? redmarker_left | redmarker_right | rearendsignals : rearendsignals ); } // all done Scratchpad.trainset.is_open = false; @@ -1022,12 +1022,12 @@ state_serializer::deserialize_dynamic( cParser &Input, scene::scratch_data &Scra auto coupling = couplingdatawithparams != std::string::npos ? std::atoi(couplingdata.substr(0, couplingdatawithparams).c_str()) : std::atoi(couplingdata.c_str()); if( coupling < 0 ) { // sprzęg zablokowany (pojazdy nierozłączalne przy manewrach) - coupling = -coupling | coupling::permanent; + coupling = -coupling | permanent; } if( offset != -1.0 && std::abs(offset) > 0.5 ) { // maksymalna odległość między sprzęgami - do przemyślenia // likwidacja sprzęgu, jeśli odległość zbyt duża - to powinno być uwzględniane w fizyce sprzęgów... - coupling = coupling::faux; + coupling = faux; } auto const params = couplingdatawithparams != std::string::npos ? couplingdata.substr(couplingdatawithparams + 1) : ""; // load amount and type @@ -1039,7 +1039,7 @@ state_serializer::deserialize_dynamic( cParser &Input, scene::scratch_data &Scra loadtype = ""; } - auto *path = simulation::Paths.find( pathname ); + auto *path = Paths.find( pathname ); if( path == nullptr ) { ErrorLog( "Bad scenario: vehicle \"" + Nodedata.name + "\" placed on nonexistent path \"" + pathname + "\" in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); @@ -1076,8 +1076,8 @@ state_serializer::deserialize_dynamic( cParser &Input, scene::scratch_data &Scra Scratchpad.trainset.offset -= length; // automatically establish permanent connections for couplers which specify them in their definitions if( coupling != 0 - && vehicle->MoverParameters->Couplers[(offset == -1.0 ? end::front : end::rear)].AllowedFlag & coupling::permanent ) { - coupling |= coupling::permanent; + && vehicle->MoverParameters->Couplers[(offset == -1.0 ? front : rear)].AllowedFlag & permanent ) { + coupling |= permanent; } if( true == Scratchpad.trainset.is_open ) { Scratchpad.trainset.vehicles.emplace_back( vehicle ); @@ -1337,8 +1337,8 @@ TAnimModel *state_serializer::create_model(const std::string &src, const std::st cloned->mark_dirty(); cloned->location(position); - simulation::Instances.insert(cloned); - simulation::Region->insert(cloned); + Instances.insert(cloned); + Region->insert(cloned); return cloned; } @@ -1362,10 +1362,10 @@ TEventLauncher *state_serializer::create_eventlauncher(const std::string &src, c if (!launcher) return nullptr; - launcher->Event1 = simulation::Events.FindEvent( launcher->asEvent1Name ); + launcher->Event1 = Events.FindEvent( launcher->asEvent1Name ); launcher->location(position); - simulation::Events.insert(launcher); - simulation::Region->insert(launcher); + Events.insert(launcher); + Region->insert(launcher); return launcher; } diff --git a/simulation/simulationtime.cpp b/simulation/simulationtime.cpp index 2620f281..df3722f9 100644 --- a/simulation/simulationtime.cpp +++ b/simulation/simulationtime.cpp @@ -24,7 +24,7 @@ scenario_time::init(std::time_t timestamp) { const char monthdaycounts[ 2 ][ 13 ] = { { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } }; - ::memcpy( m_monthdaycounts, monthdaycounts, sizeof( monthdaycounts ) ); + memcpy( m_monthdaycounts, monthdaycounts, sizeof( monthdaycounts ) ); // potentially adjust scenario clock auto const requestedtime { clamp_circular( m_time.wHour * 60 + m_time.wMinute + Global.ScenarioTimeOffset * 60, 24 * 60 ) }; diff --git a/utilities/Logs.cpp b/utilities/Logs.cpp index bbcfd03e..c0030613 100644 --- a/utilities/Logs.cpp +++ b/utilities/Logs.cpp @@ -26,7 +26,7 @@ char endstring[10] = "\n"; std::deque log_scrollback; std::string filename_date() { - ::SYSTEMTIME st; + SYSTEMTIME st; #ifdef __unix__ timespec ts; @@ -41,7 +41,7 @@ std::string filename_date() { st.wSecond = tms->tm_sec; st.wMilliseconds = ts.tv_nsec / 1000000; #elif _WIN32 - ::GetLocalTime( &st ); + GetLocalTime( &st ); #endif std::snprintf( diff --git a/utilities/Timer.cpp b/utilities/Timer.cpp index 29d4e052..3fc68128 100644 --- a/utilities/Timer.cpp +++ b/utilities/Timer.cpp @@ -94,7 +94,7 @@ void UpdateTimers(bool pause) #if __unix__ double fTime = (double)(count / 1000000000); #elif _WIN32_WINNT >= _WIN32_WINNT_VISTA - const double fTime = ::GetTickCount64() * 0.001f; // Get current time in seconds + const double fTime = GetTickCount64() * 0.001f; // Get current time in seconds #elif _WIN32 double fTime = ::GetTickCount() * 0.001f; // Get current time in seconds #endif diff --git a/utilities/parser.cpp b/utilities/parser.cpp index a088d003..91227b37 100644 --- a/utilities/parser.cpp +++ b/utilities/parser.cpp @@ -59,7 +59,7 @@ cParser::cParser(std::string const &Stream, buffertype const Type, std::string P : allowRandomIncludes(allowRandom), LoadTraction(Loadtraction), mPath(Path) { // store to calculate sub-sequent includes from relative path - if (Type == buffertype::buffer_FILE) + if (Type == buffer_FILE) { mFile = Stream; } diff --git a/utilities/translation.cpp b/utilities/translation.cpp index 4ab188a2..5cb3cbfd 100644 --- a/utilities/translation.cpp +++ b/utilities/translation.cpp @@ -354,18 +354,18 @@ const std::string& locale::coupling_name(int c) { static std::unordered_map coupling_names = { - { coupling::faux, STRN("faux") }, - { coupling::coupler, STRN("coupler") }, - { coupling::brakehose, STRN("brake hose") }, - { coupling::control, STRN("control") }, - { coupling::highvoltage, STRN("high voltage") }, - { coupling::gangway, STRN("gangway") }, - { coupling::mainhose, STRN("main hose") }, - { coupling::heating, STRN("heating") }, - { coupling::permanent, STRN("permanent") }, - { coupling::power24v, STRN("power 24V") }, - { coupling::power110v, STRN("power 110V") }, - { coupling::power3x400v, STRN("power 3x400V") }, + { faux, STRN("faux") }, + { coupler, STRN("coupler") }, + { brakehose, STRN("brake hose") }, + { control, STRN("control") }, + { highvoltage, STRN("high voltage") }, + { gangway, STRN("gangway") }, + { mainhose, STRN("main hose") }, + { heating, STRN("heating") }, + { permanent, STRN("permanent") }, + { power24v, STRN("power 24V") }, + { power110v, STRN("power 110V") }, + { power3x400v, STRN("power 3x400V") }, }; static std::string unknown(STRN("unknown")); diff --git a/utilities/utilities.cpp b/utilities/utilities.cpp index ba2c57a6..c595e202 100644 --- a/utilities/utilities.cpp +++ b/utilities/utilities.cpp @@ -383,7 +383,7 @@ std::time_t last_modified(std::string const &Filename) { const std::string fn = Filename; struct stat filestat; - if (::stat(fn.c_str(), &filestat) == 0) + if (stat(fn.c_str(), &filestat) == 0) return filestat.st_mtime; else return 0; diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index a8901593..c10aaae4 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -774,7 +774,7 @@ void TController::TableCheck(double fDistance) { // przeliczenie odległości w tabelce, ewentualnie doskanowanie (bez analizy prędkości itp.) if( iTableDirection != iDirection ) { // jak zmiana kierunku, to skanujemy od końca składu - TableTraceRoute( fDistance, pVehicles[ end::rear ] ); + TableTraceRoute( fDistance, pVehicles[ rear ] ); TableSort(); } else if (iTableDirection) @@ -801,7 +801,7 @@ void TController::TableCheck(double fDistance) --iLast; } tLast = sSpeedTable[ i ].trTrack; - TableTraceRoute( fDistance, pVehicles[ end::rear ] ); + TableTraceRoute( fDistance, pVehicles[ rear ] ); TableSort(); // nie kontynuujemy pętli, trzeba doskanować ciąg dalszy break; @@ -838,7 +838,7 @@ void TController::TableCheck(double fDistance) sSpeedTable[iLast].Update(); // aktualizacja ostatniego // WriteLog("TableCheck: Upate last track. Dist=" + AnsiString(sSpeedTable[iLast].fDist)); if( sSpeedTable[ iLast ].fDist < fDistance ) { - TableTraceRoute( fDistance, pVehicles[ end::rear ] ); // doskanowanie dalszego odcinka + TableTraceRoute( fDistance, pVehicles[ rear ] ); // doskanowanie dalszego odcinka TableSort(); } // garbage collection @@ -1226,7 +1226,7 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub m_lastexchangestop = asNextStop; m_lastexchangedirection = pVehicle->DirectionGet(); m_lastexchangeplatforms = static_cast( std::floor( std::abs( Point.evEvent->input_value( 2 ) ) ) ) % 10; - auto const exchangetime { simulation::Station.update_load( pVehicles[ end::front ], TrainParams, m_lastexchangeplatforms ) }; + auto const exchangetime { simulation::Station.update_load( pVehicles[ front ], TrainParams, m_lastexchangeplatforms ) }; WaitingSet( exchangetime ); // announce the stop name while at it announce( announcement_t::current ); @@ -1397,7 +1397,7 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo case TCommandType::cm_SecuritySystemMagnet: { // NOTE: magnet induction calculation presumes the driver is located in the front vehicle // TBD, TODO: take into account actual position of controlled/occupied vehicle in the consist, whichever comes first - auto const magnetlocation { pVehicles[ end::front ]->MoverParameters->SecuritySystem.MagnetLocation }; + auto const magnetlocation { pVehicles[ front ]->MoverParameters->SecuritySystem.MagnetLocation }; auto const magnetrange { 1.0 }; auto const ismagnetpassed { Point.fDist < -( magnetlocation + magnetrange ) }; if( Point.fDist < -magnetlocation ) { @@ -1487,9 +1487,9 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo basic_event *foundevent = nullptr; if( Point.fDist - fMaxProximityDist > 0 ) { auto scandistance{ Point.fDist + fLength - fMaxProximityDist }; - auto *scanvehicle{ pVehicles[ end::rear ] }; + auto *scanvehicle{ pVehicles[ rear ] }; auto scandirection{ scanvehicle->DirectionGet() * scanvehicle->RaDirectionGet() }; - auto *foundtrack = BackwardTraceRoute( scandistance, scandirection, scanvehicle, foundevent, -1, end::front, false ); + auto *foundtrack = BackwardTraceRoute( scandistance, scandirection, scanvehicle, foundevent, -1, front, false ); } if( foundevent == nullptr ) { iDrivigFlags |= moveTrackEnd; // to dalsza jazda trwale ograniczona (W5, koniec toru) @@ -1824,12 +1824,12 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche, AIControllFlag( AI ), pVehicle( NewControll ) { if( pVehicle != nullptr ) { - pVehicles[ end::front ] = pVehicle->GetFirstDynamic( end::front ); // pierwszy w kierunku jazdy (Np. Pc1) - pVehicles[ end::rear ] = pVehicle->GetFirstDynamic( end::rear ); // ostatni w kierunku jazdy (końcówki) + pVehicles[ front ] = pVehicle->GetFirstDynamic( front ); // pierwszy w kierunku jazdy (Np. Pc1) + pVehicles[ rear ] = pVehicle->GetFirstDynamic( rear ); // ostatni w kierunku jazdy (końcówki) } else { - pVehicles[ end::front ] = nullptr; - pVehicles[ end::rear ] = nullptr; + pVehicles[ front ] = nullptr; + pVehicles[ rear ] = nullptr; } ControllingSet(); // utworzenie połączenia do sterowanego pojazdu if( mvOccupied != nullptr ) { @@ -2027,7 +2027,7 @@ void TController::Activation() ZeroDirection(); mvOccupied->CabOccupied = mvOccupied->CabActive; // użytkownik moze zmienić CabOccupied wychodząc mvOccupied->CabDeactivisation(); // tak jest w Train.cpp - if (TestFlag(pVehicle->MoverParameters->Couplers[iDirectionOrder < 0 ? end::rear : end::front].CouplingFlag, coupling::control)) { + if (TestFlag(pVehicle->MoverParameters->Couplers[iDirectionOrder < 0 ? rear : front].CouplingFlag, control)) { ZeroLocalBrake(); if( initialspringbrakestate ) { mvOccupied->SpringBrakeActivate( false ); @@ -2039,8 +2039,8 @@ void TController::Activation() // przejście AI na drugą stronę EN57, ET41 itp. // TODO: clean this up, there's lot of redundancy with TMoverParameters::ChangeCab() and TTrain::MoveToVehicle() { - int movedirection { ( iDirection < 0 ? end::rear : end::front ) }; - auto *targetvehicle { pVehicle->FirstFind( movedirection, coupling::control ) }; + int movedirection { ( iDirection < 0 ? rear : front ) }; + auto *targetvehicle { pVehicle->FirstFind( movedirection, control ) }; if( pVehicle != targetvehicle ) { auto *targetvehicledriver { targetvehicle->Mechanik }; // zapamiętanie tego, co ewentualnie tam siedzi, żeby w razie dwóch zamienić miejscami // move to the new vehicle @@ -2352,7 +2352,7 @@ bool TController::CheckVehicles(TOrders user) p = pVehicle->FirstFind(d); // pojazd na czele składu if (!p) p = pVehicle; - pVehicles[end::front] = p; + pVehicles[front] = p; // liczenie pojazdów w składzie i ustalenie parametrów auto dir = d = 1 - d; // a dalej będziemy zliczać od czoła do tyłu fLength = 0.0; // długość składu do badania wyjechania za ograniczenie @@ -2383,7 +2383,7 @@ bool TController::CheckVehicles(TOrders user) } } ++iVehicles; // jest jeden pojazd więcej - pVehicles[end::rear] = p; // zapamiętanie ostatniego + pVehicles[rear] = p; // zapamiętanie ostatniego fLength += p->MoverParameters->Dim.L; // dodanie długości pojazdu fMass += p->MoverParameters->TotalMass; // dodanie masy łącznie z ładunkiem fVelMax = min_speed( fVelMax, p->MoverParameters->Vmax ); // ustalenie maksymalnej prędkości dla składu @@ -2403,7 +2403,7 @@ bool TController::CheckVehicles(TOrders user) if (iDrivigFlags & movePrimary) { // jeśli jest aktywnie prowadzącym pojazd, może zrobić własny porządek auto pantmask = 1; - p = pVehicles[end::front]; + p = pVehicles[front]; // establish ownership and vehicle order while (p) { @@ -2418,13 +2418,13 @@ bool TController::CheckVehicles(TOrders user) p = p->Next(); // pojazd podłączony od tyłu (licząc od czoła) } // with the order established the virtual train manager can do their work - p = pVehicles[ end::front ]; + p = pVehicles[ front ]; ControlledEnginesCount = p->MoverParameters->Power > 1.0 ? 1 : 0; auto hasheaters { false }; while (p) { if( p != pVehicle ) { - if( false == p->is_connected( pVehicle, coupling::control ) ) { + if( false == p->is_connected( pVehicle, control ) ) { // NOTE: don't set battery in controllable vehicles, let the user/ai do it explicitly // HACK: wagony muszą mieć baterię załączoną do otwarcia drzwi... p->MoverParameters->BatterySwitch( true ); @@ -2453,8 +2453,8 @@ bool TController::CheckVehicles(TOrders user) if( user == Connect && true == main ) { // HACK: with additional vehicles in the consist ensure all linked vehicles are set to move in the same direction - if( pVehicle->Prev(coupling::control) != nullptr - || pVehicle->Next(coupling::control) != nullptr ) { + if( pVehicle->Prev(control) != nullptr + || pVehicle->Next(control) != nullptr ) { sync_consist_reversers(); } // potentially sync compartment lighting state for the newly connected vehicles @@ -2491,7 +2491,7 @@ bool TController::CheckVehicles(TOrders user) } // detect push-pull train configurations and mark them accordingly - if( pVehicles[ end::front ]->is_connected( pVehicles[ end::rear ], coupling::control ) ) { + if( pVehicles[ front ]->is_connected( pVehicles[ rear ], control ) ) { // zmiana czoła przez zmianę kabiny iDrivigFlags |= movePushPull; } @@ -2513,10 +2513,10 @@ bool TController::CheckVehicles(TOrders user) if( AIControllFlag ) { // światła manewrowe (Tb1) tylko z przodu, aby nie pozostawić odczepionego ze światłem if( mvOccupied->DirActive >= 0 ) { // jak ma kierunek do przodu - pVehicles[ end::rear ]->RaLightsSet( -1, 0 ); + pVehicles[ rear ]->RaLightsSet( -1, 0 ); } else { // jak dociska - pVehicles[ end::front ]->RaLightsSet( 0, -1 ); + pVehicles[ front ]->RaLightsSet( 0, -1 ); } } } @@ -2529,7 +2529,7 @@ bool TController::CheckVehicles(TOrders user) // TODO: replace connection test with connection check between last engine and first car, specifically auto const isheatingcouplingactive { ( ControlledEnginesCount == 1 ? - pVehicles[ end::front ]->is_connected( pVehicles[ end::rear ], coupling::heating ) : + pVehicles[ front ]->is_connected( pVehicles[ rear ], heating ) : true ) }; auto const isheatingneeded { (is_emu() || is_dmu() ? true : @@ -2557,7 +2557,7 @@ bool TController::CheckVehicles(TOrders user) void TController::Lights(int head, int rear) { // zapalenie świateł w skłądzie - pVehicles[ end::front ]->RaLightsSet(head, -1); // zapalenie przednich w pierwszym + pVehicles[ front ]->RaLightsSet(head, -1); // zapalenie przednich w pierwszym pVehicles[ end::rear ]->RaLightsSet(-1, rear); // zapalenie końcówek w ostatnim } @@ -2587,17 +2587,17 @@ TBrakeSystem TController::consist_brake_system() const { if( mvOccupied->BrakeSystem != TBrakeSystem::ElectroPneumatic ) { return mvOccupied->BrakeSystem; } auto isepcapable = true; - if( pVehicles[ end::front ] != pVehicles[ end::rear ] ) { + if( pVehicles[ front ] != pVehicles[ rear ] ) { // more detailed version, will use manual braking also for coupled sets of controlled vehicles - const auto *vehicle = pVehicles[ end::front ]; // start from first + const auto *vehicle = pVehicles[ front ]; // start from first while( true == isepcapable && vehicle != nullptr ) { // NOTE: we could simplify this by doing only check of the rear coupler, but this can be quite tricky in itself // TODO: add easier ways to access front/rear coupler taking into account vehicle's direction - isepcapable = (vehicle->MoverParameters->Couplers[end::front].Connected == nullptr || - (vehicle->MoverParameters->Couplers[end::front].CouplingFlag & coupling::control && vehicle->MoverParameters->Couplers[end::front].Connected->Power > -1)) && - (vehicle->MoverParameters->Couplers[end::rear].Connected == nullptr || - (vehicle->MoverParameters->Couplers[end::rear].CouplingFlag & coupling::control && vehicle->MoverParameters->Couplers[end::rear].Connected->Power > -1)); + isepcapable = (vehicle->MoverParameters->Couplers[front].Connected == nullptr || + (vehicle->MoverParameters->Couplers[front].CouplingFlag & control && vehicle->MoverParameters->Couplers[front].Connected->Power > -1)) && + (vehicle->MoverParameters->Couplers[rear].Connected == nullptr || + (vehicle->MoverParameters->Couplers[rear].CouplingFlag & control && vehicle->MoverParameters->Couplers[rear].Connected->Power > -1)); vehicle = vehicle->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) } } @@ -2807,10 +2807,10 @@ bool TController::PrepareEngine() cue_action( driver_hint::waitpressuretoolow ); } // enable motor blowers - if( mvOccupied->MotorBlowers[ end::front ].speed != 0 ) { + if( mvOccupied->MotorBlowers[ front ].speed != 0 ) { cue_action( driver_hint::frontmotorblowerson ); } - if( mvOccupied->MotorBlowers[ end::rear ].speed != 0 ) { + if( mvOccupied->MotorBlowers[ rear ].speed != 0 ) { cue_action( driver_hint::rearmotorblowerson ); } } @@ -2991,12 +2991,12 @@ bool TController::IncBrake() || mvOccupied->TrainType == dt_ET42 ) { // NOTE: we're doing simplified checks full of presuptions here. // they'll break if someone does strange thing like turning around the second unit - if( mvOccupied->Couplers[end::rear].CouplingFlag & coupling::permanent - && mvOccupied->Couplers[end::rear].Connected->Couplers[end::rear].Connected != nullptr ) { + if( mvOccupied->Couplers[rear].CouplingFlag & permanent + && mvOccupied->Couplers[rear].Connected->Couplers[rear].Connected != nullptr ) { standalone = false; } - if( mvOccupied->Couplers[end::front].CouplingFlag & coupling::permanent - && mvOccupied->Couplers[end::front].Connected->Couplers[end::front].Connected != nullptr ) { + if( mvOccupied->Couplers[front].CouplingFlag & permanent + && mvOccupied->Couplers[front].Connected->Couplers[front].Connected != nullptr ) { standalone = false; } } @@ -3015,18 +3015,18 @@ bool TController::IncBrake() ( ( mvOccupied->Couplers[ 0 ].CouplingFlag == 0 ) && ( mvOccupied->Couplers[ 1 ].CouplingFlag == 0 ) ); */ - if( pVehicles[ end::front ] != pVehicles[ end::rear ] ) { + if( pVehicles[ front ] != pVehicles[ rear ] ) { // more detailed version, will use manual braking also for coupled sets of controlled vehicles - const auto *vehicle = pVehicles[ end::front ]; // start from first + const auto *vehicle = pVehicles[ front ]; // start from first while( true == standalone && vehicle != nullptr ) { // NOTE: we could simplify this by doing only check of the rear coupler, but this can be quite tricky in itself // TODO: add easier ways to access front/rear coupler taking into account vehicle's direction standalone = - (vehicle->MoverParameters->Couplers[end::front].Connected == nullptr || - (vehicle->MoverParameters->Couplers[end::front].CouplingFlag & coupling::control && vehicle->MoverParameters->Couplers[end::front].Connected->Power > 1)) && - (vehicle->MoverParameters->Couplers[end::rear].Connected == nullptr || - (vehicle->MoverParameters->Couplers[end::rear].CouplingFlag & coupling::control && vehicle->MoverParameters->Couplers[end::rear].Connected->Power > 1)); + (vehicle->MoverParameters->Couplers[front].Connected == nullptr || + (vehicle->MoverParameters->Couplers[front].CouplingFlag & control && vehicle->MoverParameters->Couplers[front].Connected->Power > 1)) && + (vehicle->MoverParameters->Couplers[rear].Connected == nullptr || + (vehicle->MoverParameters->Couplers[rear].CouplingFlag & control && vehicle->MoverParameters->Couplers[rear].Connected->Power > 1)); vehicle = vehicle->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) } } @@ -4171,10 +4171,10 @@ void TController::SetTimeControllers() //6. UniversalBrakeButtons //6.1. Checking flags for Over pressure if (std::abs(BrakeCtrlPosition - gbh_FS)<0.5) { - UniversalBrakeButtons |= TUniversalBrake::ub_HighPressure | TUniversalBrake::ub_Overload; + UniversalBrakeButtons |= ub_HighPressure | ub_Overload; } else { - UniversalBrakeButtons &= ~(TUniversalBrake::ub_HighPressure | TUniversalBrake::ub_Overload); + UniversalBrakeButtons &= ~(ub_HighPressure | ub_Overload); } //6.2. Setting buttons for (int i = 0; i < 3; i++) { @@ -4265,8 +4265,8 @@ void TController::Doors( bool const Open, int const Side ) { } } // consist-wide remote signals to open doors doors - if( pVehicle->MoverParameters->Doors.open_control == control_t::conductor - || pVehicle->MoverParameters->Doors.open_control == control_t::driver + if( pVehicle->MoverParameters->Doors.open_control == conductor + || pVehicle->MoverParameters->Doors.open_control == driver // NOTE: disabled for mixed controls, leave it up to passengers to open doors by themselves /* || ( pVehicle->MoverParameters->Doors.open_control == control_t::mixed ) */ ) { if( Side & prawe ) { @@ -4305,9 +4305,9 @@ void TController::Doors( bool const Open, int const Side ) { if( true == doors_open() ) { // consist-wide remote signals to close doors - if( pVehicle->MoverParameters->Doors.close_control == control_t::conductor - || pVehicle->MoverParameters->Doors.close_control == control_t::driver - || pVehicle->MoverParameters->Doors.close_control == control_t::mixed ) { + if( pVehicle->MoverParameters->Doors.close_control == conductor + || pVehicle->MoverParameters->Doors.close_control == driver + || pVehicle->MoverParameters->Doors.close_control == mixed ) { cue_action( driver_hint::doorrightclose ); cue_action( driver_hint::doorleftclose ); } @@ -4318,19 +4318,19 @@ void TController::Doors( bool const Open, int const Side ) { } // if applicable close manually-operated doors in vehicles which may ignore remote signals { - const auto *vehicle = pVehicles[ end::front ]; // pojazd na czole składu + const auto *vehicle = pVehicles[ front ]; // pojazd na czole składu while( vehicle != nullptr ) { // zamykanie drzwi w pojazdach - flaga zezwolenia była by lepsza auto const ismanualdoor { vehicle->MoverParameters->Doors.auto_velocity == -1.f - && ( vehicle->MoverParameters->Doors.close_control == control_t::passenger - || vehicle->MoverParameters->Doors.close_control == control_t::mixed ) }; + && ( vehicle->MoverParameters->Doors.close_control == passenger + || vehicle->MoverParameters->Doors.close_control == mixed ) }; if( true == ismanualdoor && ( vehicle->LoadExchangeTime() == 0.f || vehicle->MoverParameters->Vel > EU07_AI_MOVEMENT ) ) { - vehicle->MoverParameters->OperateDoors( side::right, false, range_t::local ); - vehicle->MoverParameters->OperateDoors( side::left, false, range_t::local ); + vehicle->MoverParameters->OperateDoors( right, false, range_t::local ); + vehicle->MoverParameters->OperateDoors( left, false, range_t::local ); } vehicle = vehicle->Next(); // pojazd podłączony z tyłu (patrząc od czoła) } @@ -4345,13 +4345,13 @@ void TController::Doors( bool const Open, int const Side ) { bool TController::doors_open() const { - return IsAnyDoorOpen[side::right] || IsAnyDoorOpen[side::left]; + return IsAnyDoorOpen[right] || IsAnyDoorOpen[left]; } bool TController::doors_permit_active() const { - return IsAnyDoorPermitActive[side::right] || IsAnyDoorPermitActive[side::left]; + return IsAnyDoorPermitActive[right] || IsAnyDoorPermitActive[left]; } void @@ -4364,7 +4364,7 @@ TController::announce( announcement_t const Announcement ) { return; } - auto *vehicle { pVehicles[ end::front ] }; + auto *vehicle { pVehicles[ front ] }; while( vehicle ) { vehicle->announce( Announcement ); vehicle = vehicle->Next(); @@ -4439,14 +4439,14 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N if( true == AIControllFlag ) { // simplified door closing procedure, to sync actual door state with the door state flag // NOTE: this may result in visually ugly quick switch between closing and opening the doors, but eh - if( pVehicle->MoverParameters->Doors.close_control == control_t::driver - || pVehicle->MoverParameters->Doors.close_control == control_t::mixed ) { - pVehicle->MoverParameters->OperateDoors( side::right, false ); - pVehicle->MoverParameters->OperateDoors( side::left, false ); + if( pVehicle->MoverParameters->Doors.close_control == driver + || pVehicle->MoverParameters->Doors.close_control == mixed ) { + pVehicle->MoverParameters->OperateDoors( right, false ); + pVehicle->MoverParameters->OperateDoors( left, false ); } if( pVehicle->MoverParameters->Doors.permit_needed ) { - pVehicle->MoverParameters->PermitDoors( side::right, false ); - pVehicle->MoverParameters->PermitDoors( side::left, false ); + pVehicle->MoverParameters->PermitDoors( right, false ); + pVehicle->MoverParameters->PermitDoors( left, false ); } } iDrivigFlags &= ~moveDoorOpened; @@ -4482,7 +4482,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N NewCommand = TrainParams.Relation2; // relacja docelowa z rozkładu } // jeszcze poustawiać tekstury na wyświetlaczach - TDynamicObject *p = pVehicles[end::front]; + TDynamicObject *p = pVehicles[front]; while (p) { p->DestinationSet(NewCommand, TrainParams.TrainName); // relacja docelowa @@ -4713,13 +4713,13 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N if( NewValue1 >= 0.0 ) { // jeśli ilość wagonów inna niż wszystkie będzie odczepianie, // ale jeśli wagony są z przodu, to trzeba najpierw zmienić kierunek - if( mvOccupied->Couplers[mvOccupied->DirAbsolute > 0 ? end::rear : end::front].Connected == nullptr // z tyłu nic - && mvOccupied->Couplers[mvOccupied->DirAbsolute > 0 ? end::front : end::rear].Connected != nullptr ) { // a z przodu skład + if( mvOccupied->Couplers[mvOccupied->DirAbsolute > 0 ? rear : front].Connected == nullptr // z tyłu nic + && mvOccupied->Couplers[mvOccupied->DirAbsolute > 0 ? front : rear].Connected != nullptr ) { // a z przodu skład iDirectionOrder = -iDirection; // zmiana na ciągnięcie OrderNext( Change_direction ); // najpierw zmień kierunek (zastąpi Disconnect) OrderPush( Disconnect ); // a odczep już po zmianie kierunku } - else if( mvOccupied->Couplers[ mvOccupied->DirAbsolute > 0 ? end::rear : end::front ].Connected != nullptr ) { // z tyłu coś + else if( mvOccupied->Couplers[ mvOccupied->DirAbsolute > 0 ? rear : front ].Connected != nullptr ) { // z tyłu coś OrderNext( Disconnect ); // jak ciągnie, to tylko odczep (NewValue1) wagonów } else { @@ -4803,8 +4803,8 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N if( NewCommand == "SetLights" ) { // set consist lights pattern hints - m_lighthints[ end::front ] = static_cast( NewValue1 ); - m_lighthints[ end::rear ] = static_cast( NewValue2 ); + m_lighthints[ front ] = static_cast( NewValue1 ); + m_lighthints[ rear ] = static_cast( NewValue2 ); if( true == TestFlag( OrderCurrentGet(), Obey_train ) ) { // light hints only apply in the obey_train mode CheckVehicles(); @@ -5082,7 +5082,7 @@ void TController::OrderCheck() if( OrderCurrentGet() != Obey_train ) { // reset light hints - m_lighthints[ end::front ] = m_lighthints[ end::rear ] = -1; + m_lighthints[ front ] = m_lighthints[ rear ] = -1; } if( OrderCurrentGet() & ( Shunt | Loose_shunt | Connect | Obey_train | Bank ) ) { CheckVehicles(); // sprawdzić światła @@ -5288,7 +5288,7 @@ basic_event * TController::CheckTrackEventBackward(double fDirection, TTrack *Tr // NOTE: this method returns only one event which meets the conditions, due to limitations in the caller // TBD, TODO: clean up the caller and return all suitable events, as in theory things will go awry if the track has more than one signal auto const dir{ Vehicle->VectorFront() * (double)Vehicle->DirectionGet() }; - auto const pos{ End == end::front ? Vehicle->RearPosition() : Vehicle->HeadPosition() }; + auto const pos{ End == front ? Vehicle->RearPosition() : Vehicle->HeadPosition() }; auto const &eventsequence { ( fDirection * Eventdirection > 0 ? Track->m_events2 : Track->m_events1 ) }; for( auto const &event : eventsequence ) { if( event.second != nullptr @@ -5298,7 +5298,7 @@ basic_event * TController::CheckTrackEventBackward(double fDirection, TTrack *Tr auto const sl{ event.second->input_location() }; // położenie komórki pamięci auto const sem{ sl - pos }; // wektor do komórki pamięci od końca składu auto const isahead { dir.x * sem.x + dir.z * sem.z > 0 }; - if( End == end::front ? isahead : !isahead ) { + if( End == front ? isahead : !isahead ) { // iloczyn skalarny jest ujemny, gdy sygnał stoi z tyłu return event.second; } @@ -5427,9 +5427,9 @@ TCommandType TController::BackwardScan( double const Range ) basic_event *e = nullptr; // event potencjalnie od semafora // opcjonalnie może być skanowanie od "wskaźnika" z przodu, np. W5, Tm=Ms1, koniec toru wg // drugiej osi w kierunku ruchu - auto const *scantrack{BackwardTraceRoute(scandist, scandir, pVehicles[end::front], e)}; + auto const *scantrack{BackwardTraceRoute(scandist, scandir, pVehicles[front], e)}; auto const dir{(double)startdir * - pVehicles[end::front]->VectorFront()}; // wektor w kierunku jazdy/szukania + pVehicles[front]->VectorFront()}; // wektor w kierunku jazdy/szukania // jeśli wstecz wykryto koniec toru to raczej nic się nie da w takiej sytuacji zrobić if (e == nullptr) @@ -5451,7 +5451,7 @@ TCommandType TController::BackwardScan( double const Range ) { // najpierw sprawdzamy, czy semafor czy inny znak został przejechany auto const sl{e->input_location()}; // położenie komórki pamięci - auto const pos{pVehicles[end::rear]->RearPosition()}; // pozycja tyłu + auto const pos{pVehicles[rear]->RearPosition()}; // pozycja tyłu auto const sem{sl - pos}; // wektor do komórki pamięci od końca składu if (dir.x * sem.x + dir.z * sem.z < 0) { @@ -5635,9 +5635,9 @@ void TController::TakeControl( bool const Aidriver, bool const Forcevehiclecheck // jeśli nic nie robi OrderNext( Prepare_engine ); if( pVehicle->MoverParameters->iLights[ ( mvOccupied->CabActive < 0 ? - end::rear : - end::front ) ] - & ( light::headlight_left | light::headlight_right | light::headlight_upper ) ) // któreś ze świateł zapalone? + rear : + front ) ] + & ( headlight_left | headlight_right | headlight_upper ) ) // któreś ze świateł zapalone? { // od wersji 357 oczekujemy podania komend dla AI przez scenerię /* if( pVehicle->MoverParameters->iLights[ mvOccupied->CabActive < 0 ? end::rear : end::front ] & light::headlight_upper ) // górne światło zapalone @@ -5739,7 +5739,7 @@ void TController::sync_consist_reversers() { } } -Mtable::TTrainParameters const & +TTrainParameters const & TController::TrainTimetable() const { return TrainParams; } @@ -5948,11 +5948,11 @@ TController::determine_consist_state() { mvOccupied->PipePress < std::max(3.9, mvOccupied->BrakePressureActual.PipePressureVal) + 0.1; fAccGravity = 0.0; // przyspieszenie wynikające z pochylenia IsAnyCouplerStretched = false; - IsAnyDoorOnlyOpen[ side::right ] = IsAnyDoorOnlyOpen[ side::left ] = false; - IsAnyDoorOpen[ side::right ] = IsAnyDoorOpen[ side::left ] = false; - IsAnyDoorPermitActive[ side::right ] = IsAnyDoorPermitActive[ side::left ] = false; + IsAnyDoorOnlyOpen[ right ] = IsAnyDoorOnlyOpen[ left ] = false; + IsAnyDoorOpen[ right ] = IsAnyDoorOpen[ left ] = false; + IsAnyDoorPermitActive[ right ] = IsAnyDoorPermitActive[ left ] = false; ConsistShade = 0.0; - const auto *p { pVehicles[ end::front ] }; // pojazd na czole składu + const auto *p { pVehicles[ front ] }; // pojazd na czole składu double dy; // składowa styczna grawitacji, w przedziale <0,1> while (p) { // sprawdzenie odhamowania wszystkich połączonych pojazdów @@ -5996,24 +5996,24 @@ TController::determine_consist_state() { // check coupler state IsAnyCouplerStretched = IsAnyCouplerStretched - || vehicle->Couplers[end::front].stretch_duration > 0.0 - || vehicle->Couplers[end::rear].stretch_duration > 0.0; + || vehicle->Couplers[front].stretch_duration > 0.0 + || vehicle->Couplers[rear].stretch_duration > 0.0; // check door state { auto const switchsides{ p->DirectionGet() != (iDirection == 0 ? mvOccupied->CabOccupied : iDirection) }; - auto const &rightdoor { vehicle->Doors.instances[ ( switchsides ? side::left : side::right ) ] }; - auto const &leftdoor { vehicle->Doors.instances[ ( switchsides ? side::right : side::left ) ] }; - if( vehicle->Doors.close_control != control_t::autonomous ) { - IsAnyDoorOpen[ side::right ] |= false == rightdoor.is_closed; - IsAnyDoorOpen[ side::left ] |= false == leftdoor.is_closed; + auto const &rightdoor { vehicle->Doors.instances[ ( switchsides ? left : right ) ] }; + auto const &leftdoor { vehicle->Doors.instances[ ( switchsides ? right : left ) ] }; + if( vehicle->Doors.close_control != autonomous ) { + IsAnyDoorOpen[ right ] |= false == rightdoor.is_closed; + IsAnyDoorOpen[ left ] |= false == leftdoor.is_closed; } - if (vehicle->Doors.close_control != control_t::autonomous) { - IsAnyDoorOnlyOpen[ side::right ] |= false == rightdoor.is_door_closed; - IsAnyDoorOnlyOpen[ side::left ] |= false == leftdoor.is_door_closed; + if (vehicle->Doors.close_control != autonomous) { + IsAnyDoorOnlyOpen[ right ] |= false == rightdoor.is_door_closed; + IsAnyDoorOnlyOpen[ left ] |= false == leftdoor.is_door_closed; } if( vehicle->Doors.permit_needed ) { - IsAnyDoorPermitActive[ side::right ] |= rightdoor.open_permit; - IsAnyDoorPermitActive[ side::left ] |= leftdoor.open_permit; + IsAnyDoorPermitActive[ right ] |= rightdoor.open_permit; + IsAnyDoorPermitActive[ left ] |= leftdoor.open_permit; } } // measure lighting level @@ -6037,7 +6037,7 @@ TController::determine_consist_state() { IsAnyConverterExplicitlyEnabled = false; pVehicle->for_each( - coupling::control, + control, [this]( TDynamicObject * Vehicle ) { auto const *vehicle { Vehicle->MoverParameters }; IsAnyConverterOverloadRelayOpen |= vehicle->ConvOvldFlag; @@ -6059,7 +6059,7 @@ TController::determine_consist_state() { auto absaccs { fAccGravity }; // Ra 2014-03: jesli skład stoi, to działa na niego składowa styczna grawitacji if( mvOccupied->Vel > EU07_AI_NOMOVEMENT ) { absaccs = 0; - const auto *d = pVehicles[ end::front ]; // pojazd na czele składu + const auto *d = pVehicles[ front ]; // pojazd na czele składu while( d ) { absaccs += d->MoverParameters->TotalMass * d->MoverParameters->AccS * ( d->DirectionGet() == iDirection ? 1 : -1 ); d = d->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) @@ -6080,7 +6080,7 @@ TController::determine_consist_state() { } // second pass, for diesel engines verify the (live) engines are fully started // TODO: cache presence of diesel engines in the consist, to skip this test if there isn't any - p = pVehicles[ end::front ]; // pojazd na czole składu + p = pVehicles[ front ]; // pojazd na czole składu while( true == Ready && p != nullptr ) { @@ -6146,7 +6146,7 @@ TController::control_pantographs() { // raise/lower pantographs as needed auto const useregularpantographlayout { - pVehicle->Next(coupling::control) == nullptr // standalone + pVehicle->Next(control) == nullptr // standalone || is_emu() // special case || mvControlling->TrainType == dt_ET41 }; // special case @@ -6159,10 +6159,10 @@ TController::control_pantographs() { if( fOverhead2 > 0.0 || iOverheadDown ) { // jazda z opuszczonymi pantografami - if( mvPantographUnit->Pantographs[ end::front ].is_active ) { + if( mvPantographUnit->Pantographs[ front ].is_active ) { cue_action( driver_hint::frontpantographvalveoff ); } - if( mvPantographUnit->Pantographs[ end::rear ].is_active ) { + if( mvPantographUnit->Pantographs[ rear ].is_active ) { cue_action( driver_hint::rearpantographvalveoff ); } } @@ -6390,25 +6390,25 @@ TController::control_lights() { // jeśli jazda pociągowa if( true == TestFlag( OrderCurrentGet(), Obey_train ) ) { // head lights - if( m_lighthints[ end::front ] == -1 ) { + if( m_lighthints[ front ] == -1 ) { cue_action( driver_hint::headcodepc1 ); } - else if( m_lighthints[ end::front ] == ( light::redmarker_left | light::headlight_right | light::headlight_upper ) ) { + else if( m_lighthints[ front ] == ( redmarker_left | headlight_right | headlight_upper ) ) { cue_action( driver_hint::headcodepc2 ); } else { // custom light pattern if( AIControllFlag ) { - pVehicles[ end::front ]->RaLightsSet( m_lighthints[ end::front ], -1 ); + pVehicles[ front ]->RaLightsSet( m_lighthints[ front ], -1 ); } } // tail lights - if( m_lighthints[ end::rear ] == -1 ) { + if( m_lighthints[ rear ] == -1 ) { cue_action( driver_hint::headcodepc5 ); } else { if( AIControllFlag ) { - pVehicles[ end::rear ]->RaLightsSet( -1, m_lighthints[ end::rear ] ); + pVehicles[ rear ]->RaLightsSet( -1, m_lighthints[ rear ] ); } } } @@ -6419,8 +6419,8 @@ TController::control_lights() { } else if( is_car() ) { Lights( - light::headlight_left | light::headlight_right, - light::redmarker_left | light::redmarker_right ); + headlight_left | headlight_right, + redmarker_left | redmarker_right ); } } @@ -6535,7 +6535,7 @@ TController::scan_obstacles( double const Range ) { // HACK: vehicle order in the consist is based on intended travel direction // if our actual travel direction doesn't match that, we should be scanning from the other end of the consist // we cast to int to avoid getting confused by microstutters - const auto *frontvehicle { pVehicles[ ( static_cast( mvOccupied->V ) * iDirection >= 0 ? end::front : end::rear ) ] }; + const auto *frontvehicle { pVehicles[ ( static_cast( mvOccupied->V ) * iDirection >= 0 ? front : rear ) ] }; int routescandirection; // for moving vehicle determine heading from velocity; for standing fall back on the set direction @@ -6543,11 +6543,11 @@ TController::scan_obstacles( double const Range ) { frontvehicle->MoverParameters->V > 0.0 : pVehicle->DirectionGet() == frontvehicle->DirectionGet() ? iDirection >= 0 : iDirection <= 0 ) { // towards coupler 0 - routescandirection = end::front; + routescandirection = front; } else { // towards coupler 1 - routescandirection = end::rear; + routescandirection = rear; } /* if( pVehicle->MoverParameters->CabOccupied < 0 ) { @@ -6757,7 +6757,7 @@ TController::check_load_exchange() { if( fStopTime > 0 ) { return; } // czas postoju przed dalszą jazdą (np. na przystanku) - const auto *vehicle { pVehicles[ end::front ] }; + const auto *vehicle { pVehicles[ front ] }; while( vehicle != nullptr ) { auto const vehicleexchangetime { vehicle->LoadExchangeTime() }; DoesAnyDoorNeedOpening |= vehicleexchangetime > 0 && vehicle->LoadExchangeSpeed() == 0; @@ -6830,7 +6830,7 @@ TController::UpdateLooseShunt() { && mvOccupied->Vel < 1.0 ) { const auto *vehicle { Obstacle.vehicle }; - auto const direction { ( vehicle->Prev() != nullptr ? end::front : end::rear ) }; + auto const direction { ( vehicle->Prev() != nullptr ? front : rear ) }; while( vehicle != nullptr ) { if( vehicle->MoverParameters->BrakePress > 0.2 ) { vehicle->MoverParameters->BrakeLevelSet( 0 ); // hamulec na zero, aby nie hamował @@ -6838,7 +6838,7 @@ TController::UpdateLooseShunt() { } // NOTE: we trust the consist to be arranged in a valid chain // TBD, TODO: traversal direction validation? - vehicle = direction == end::front ? vehicle->Prev() : vehicle->Next(); + vehicle = direction == front ? vehicle->Prev() : vehicle->Next(); } } } @@ -6865,7 +6865,7 @@ TController::UpdateObeyTrain() { tsGuardSignal.owner( pVehicle ); // place virtual conductor some distance away tsGuardSignal.offset( { pVehicle->MoverParameters->Dim.W * -0.75f, 1.7f, std::min( -20.0, -0.2 * fLength ) } ); - tsGuardSignal.play( sound_flags::exclusive ); + tsGuardSignal.play( exclusive ); // NOTE: we can't rely on is_playing() check as sound playback is based on distance from local camera fActionTime = -5.0; // niech trochę potrzyma } @@ -6936,10 +6936,10 @@ TController::UpdateConnect() { // write down which vehicle should be coupled with the target consist, // so we don't lose track of it if the user does something unexpected iCouplingVehicle = { - pVehicles[ end::front ], - ( pVehicles[ end::front ]->DirectionGet() > 0 ? - end::front : - end::rear ) }; + pVehicles[ front ], + ( pVehicles[ front ]->DirectionGet() > 0 ? + front : + rear ) }; iDrivigFlags |= moveConnect; } } @@ -6949,7 +6949,7 @@ TController::UpdateConnect() { void TController::GuardOpenDoor() { if ((iDrivigFlags & moveGuardOpenDoor) != 0) { - const auto *vehicle{ pVehicles[end::front] }; + const auto *vehicle{ pVehicles[front] }; while (vehicle != nullptr && vehicle->MoverParameters->Doors.range == 0) { vehicle = vehicle->Next(); } @@ -6957,10 +6957,10 @@ TController::GuardOpenDoor() { auto const lewe = vehicle->DirectionGet() > 0 ? 1 : 2; auto const prawe = 3 - lewe; if (m_lastexchangeplatforms & lewe) { - vehicle->MoverParameters->OperateDoors(side::left, true, range_t::local); + vehicle->MoverParameters->OperateDoors(left, true, range_t::local); } if (m_lastexchangeplatforms & prawe) { - vehicle->MoverParameters->OperateDoors(side::right, true, range_t::local); + vehicle->MoverParameters->OperateDoors(right, true, range_t::local); } } else { @@ -6976,14 +6976,14 @@ TController::unit_count( int const Threshold ) const { auto unitcount { 1 }; do { auto const decoupledend{ ( vehicle->DirectionGet() > 0 ? // numer sprzęgu od strony czoła składu - end::rear : - end::front ) }; + rear : + front ) }; auto const coupling { vehicle->MoverParameters->Couplers[ decoupledend ].CouplingFlag }; - if( coupling == coupling::faux ) { + if( coupling == faux ) { break; } // jeżeli sprzęg zablokowany to liczymy człony jako jeden - if( ( coupling & coupling::permanent ) == 0 ) { + if( ( coupling & permanent ) == 0 ) { ++unitcount; } vehicle = vehicle->Next(); @@ -7025,10 +7025,10 @@ TController::UpdateDisconnect() { // szukanie pojazdu do odczepienia do { decoupledend = decoupledvehicle->DirectionGet() > 0 ? // numer sprzęgu od strony czoła składu - end::front : - end::rear; + front : + rear; // jeżeli sprzęg zablokowany to liczymy człony jako jeden - if( decoupledvehicle->MoverParameters->Couplers[ decoupledend ].CouplingFlag & coupling::permanent ) { + if( decoupledvehicle->MoverParameters->Couplers[ decoupledend ].CouplingFlag & permanent ) { ++vehiclecount; } if( decoupledvehicle != pVehicle ) { @@ -7051,7 +7051,7 @@ TController::UpdateDisconnect() { decoupledvehicle->Dettach( decoupledend ); } // tylko jeśli odepnie - if( decoupledvehicle->MoverParameters->Couplers[ decoupledend ].CouplingFlag == coupling::faux ) { + if( decoupledvehicle->MoverParameters->Couplers[ decoupledend ].CouplingFlag == faux ) { WriteLog( "Uncoupling [" + mvOccupied->Name + "]: uncoupled" ); iVehicleCount = -2; // update trainset state @@ -7062,7 +7062,7 @@ TController::UpdateDisconnect() { decoupledvehicle->remove_coupler_adapter( decoupledend ); } */ - if( pVehicles[ end::front ]->MoverParameters->Couplers[ decoupledend ].has_adapter() ) { + if( pVehicles[ front ]->MoverParameters->Couplers[ decoupledend ].has_adapter() ) { cue_action( driver_hint::couplingadapterremove, decoupledend ); } } @@ -7665,7 +7665,7 @@ TController::adjust_desired_speed_for_current_speed() { } } // HACK: limit acceleration for cargo trains, to reduce probability of breaking couplers on sudden jolts - auto MaxAcc{ 0.5 * mvOccupied->Couplers[(mvOccupied->DirAbsolute >= 0 ? end::rear : end::front)].FmaxC / fMass }; + auto MaxAcc{ 0.5 * mvOccupied->Couplers[(mvOccupied->DirAbsolute >= 0 ? rear : front)].FmaxC / fMass }; if( iVehicles - ControlledEnginesCount > 0 ) { MaxAcc *= std::clamp( vel * 0.025, 0.2, 1.0 ); } @@ -8131,10 +8131,10 @@ void TController::control_main_pipe() { // unlocking main pipe if( AccDesired > -0.03 && true == mvOccupied->LockPipe ) { - UniversalBrakeButtons |= TUniversalBrake::ub_UnlockPipe; + UniversalBrakeButtons |= ub_UnlockPipe; } else if (false == mvOccupied->LockPipe ) { - UniversalBrakeButtons &= ~TUniversalBrake::ub_UnlockPipe; + UniversalBrakeButtons &= ~ub_UnlockPipe; } // napełnianie uderzeniowe diff --git a/vehicle/Driver.h b/vehicle/Driver.h index e7c4fac0..aef23b17 100644 --- a/vehicle/Driver.h +++ b/vehicle/Driver.h @@ -527,8 +527,8 @@ private: int TableDirection() { return iTableDirection; } // Ra: stare funkcje skanujące, używane do szukania sygnalizatora z tyłu bool IsOccupiedByAnotherConsist( TTrack *Track, double const Distance ); - basic_event *CheckTrackEventBackward( double fDirection, TTrack *Track, TDynamicObject *Vehicle, int const Eventdirection = 1, end const End = end::rear ); - TTrack *BackwardTraceRoute( double &fDistance, double &fDirection, TDynamicObject *Vehicle, basic_event *&Event, int const Eventdirection = 1, end const End = end::rear, bool const Untiloccupied = true ); + basic_event *CheckTrackEventBackward( double fDirection, TTrack *Track, TDynamicObject *Vehicle, int const Eventdirection = 1, end const End = rear ); + TTrack *BackwardTraceRoute( double &fDistance, double &fDirection, TDynamicObject *Vehicle, basic_event *&Event, int const Eventdirection = 1, end const End = rear, bool const Untiloccupied = true ); void SetProximityVelocity( double dist, double vel, glm::dvec3 const *pos ); TCommandType BackwardScan( double const Range ); std::string TableText( std::size_t const Index ) const; @@ -552,7 +552,7 @@ private: // methods public: const std::string &TrainName() const; - Mtable::TTrainParameters const & TrainTimetable() const; + TTrainParameters const & TrainTimetable() const; private: std::string Relation() const; int StationIndex() const; @@ -562,7 +562,7 @@ private: // tests whether the train is delayed and sets accordingly a driving flag void UpdateDelayFlag(); // members - Mtable::TTrainParameters TrainParams; // rozkład jazdy zawsze jest, nawet jeśli pusty + TTrainParameters TrainParams; // rozkład jazdy zawsze jest, nawet jeśli pusty std::string asNextStop; // nazwa następnego punktu zatrzymania wg rozkładu // int iStationStart = 0; // numer pierwszej stacji pokazywanej na podglądzie rozkładu std::string m_lastexchangestop; // HACK: safeguard to prevent multiple load exchanges per station diff --git a/vehicle/DynObj.cpp b/vehicle/DynObj.cpp index 9623a469..3d037d7e 100644 --- a/vehicle/DynObj.cpp +++ b/vehicle/DynObj.cpp @@ -180,16 +180,16 @@ int TAnim::TypeSet(int i, TMoverParameters currentMover, int fl) iFlags = 0x055; fParamPants = new TAnimPant(); switch (currentMover.EnginePowerSource.CollectorParameters.PantographType) { - case TPantType::AKP_4E: + case AKP_4E: fParamPants->AKP_4E(); break; - case TPantType::DSAx: + case DSAx: fParamPants->DSAx(); break; - case TPantType::EC160_200: + case EC160_200: fParamPants->EC160_200(); break; - case TPantType::WBL85: + case WBL85: fParamPants->WBL85(); break; } @@ -339,11 +339,11 @@ TDynamicObject * TDynamicObject::FirstFind(int &coupler_nr, int cf) return nullptr; // Ra: zabezpieczenie przed ewentaulnymi błędami sprzęgów if ((temp->MoverParameters->Couplers[coupler_nr].CouplingFlag & cf) != cf) return temp; // nic nie ma już dalej podłączone sprzęgiem cf - if (coupler_nr == end::front) + if (coupler_nr == front) { // jeżeli szukamy od sprzęgu 0 if (temp->PrevConnected()) // jeśli mamy coś z przodu { - if (temp->PrevConnectedNo() == end::front) // jeśli pojazd od strony sprzęgu 0 jest odwrócony + if (temp->PrevConnectedNo() == front) // jeśli pojazd od strony sprzęgu 0 jest odwrócony coupler_nr = 1 - coupler_nr; // to zmieniamy kierunek sprzęgu temp = temp->PrevConnected(); // ten jest od strony 0 } @@ -354,7 +354,7 @@ TDynamicObject * TDynamicObject::FirstFind(int &coupler_nr, int cf) { if (temp->NextConnected()) { - if (temp->NextConnectedNo() == end::rear) // jeśli pojazd od strony sprzęgu 1 jest odwrócony + if (temp->NextConnectedNo() == rear) // jeśli pojazd od strony sprzęgu 1 jest odwrócony coupler_nr = 1 - coupler_nr; // to zmieniamy kierunek sprzęgu temp = temp->NextConnected(); // ten pojazd jest od strony 1 } @@ -380,13 +380,13 @@ float TDynamicObject::GetEPP() break; // Ra: zabezpieczenie przed ewentaulnymi błędami sprzęgów eq += temp->MoverParameters->PipePress * temp->MoverParameters->Dim.L; am += temp->MoverParameters->Dim.L; - if ((temp->MoverParameters->Couplers[coupler_nr].CouplingFlag & coupling::brakehose) != coupling::brakehose) + if ((temp->MoverParameters->Couplers[coupler_nr].CouplingFlag & brakehose) != brakehose) break; // nic nie ma już dalej podłączone if (coupler_nr == 0) { // jeżeli szukamy od sprzęgu 0 if (temp->PrevConnected()) // jeśli mamy coś z przodu { - if (temp->PrevConnectedNo() == end::front) // jeśli pojazd od strony sprzęgu 0 jest odwrócony + if (temp->PrevConnectedNo() == front) // jeśli pojazd od strony sprzęgu 0 jest odwrócony coupler_nr = 1 - coupler_nr; // to zmieniamy kierunek sprzęgu temp = temp->PrevConnected(); // ten jest od strony 0 } @@ -397,7 +397,7 @@ float TDynamicObject::GetEPP() { if (temp->NextConnected()) { - if (temp->NextConnectedNo() == end::rear) // jeśli pojazd od strony sprzęgu 1 jest odwrócony + if (temp->NextConnectedNo() == rear) // jeśli pojazd od strony sprzęgu 1 jest odwrócony coupler_nr = 1 - coupler_nr; // to zmieniamy kierunek sprzęgu temp = temp->NextConnected(); // ten pojazd jest od strony 1 } @@ -414,13 +414,13 @@ float TDynamicObject::GetEPP() break; // Ra: zabezpieczenie przed ewentaulnymi błędami sprzęgów eq += temp->MoverParameters->PipePress * temp->MoverParameters->Dim.L; am += temp->MoverParameters->Dim.L; - if ((temp->MoverParameters->Couplers[coupler_nr].CouplingFlag & coupling::brakehose) != coupling::brakehose) + if ((temp->MoverParameters->Couplers[coupler_nr].CouplingFlag & brakehose) != brakehose) break; // nic nie ma już dalej podłączone if (coupler_nr == 0) { // jeżeli szukamy od sprzęgu 0 if (temp->PrevConnected()) // jeśli mamy coś z przodu { - if (temp->PrevConnectedNo() == end::front) // jeśli pojazd od strony sprzęgu 0 jest odwrócony + if (temp->PrevConnectedNo() == front) // jeśli pojazd od strony sprzęgu 0 jest odwrócony coupler_nr = 1 - coupler_nr; // to zmieniamy kierunek sprzęgu temp = temp->PrevConnected(); // ten jest od strony 0 } @@ -431,7 +431,7 @@ float TDynamicObject::GetEPP() { if (temp->NextConnected()) { - if (temp->NextConnectedNo() == end::rear) // jeśli pojazd od strony sprzęgu 1 jest odwrócony + if (temp->NextConnectedNo() == rear) // jeśli pojazd od strony sprzęgu 1 jest odwrócony coupler_nr = 1 - coupler_nr; // to zmieniamy kierunek sprzęgu temp = temp->NextConnected(); // ten pojazd jest od strony 1 } @@ -516,7 +516,7 @@ void TDynamicObject::SetPneumatic(bool front, bool red) x = 3; break; // mamy prawy skos, dać prawe skosy case 3: // wszystkie cztery na prosto - if (MoverParameters->Couplers[front ? end::front : end::rear].Render) + if (MoverParameters->Couplers[front ? end::front : rear].Render) x = 1; else x = 4; @@ -563,8 +563,8 @@ void TDynamicObject::UpdateDoorTranslate(TAnim *pAnim) { auto const &door { MoverParameters->Doors.instances[ ( ( pAnim->iNumber & 1 ) == 0 ? - side::right : - side::left ) ] }; + right : + left ) ] }; pAnim->smAnimated->SetTranslate( glm::vec3{ @@ -580,8 +580,8 @@ void TDynamicObject::UpdateDoorRotate(TAnim *pAnim) { auto const &door { MoverParameters->Doors.instances[ ( ( pAnim->iNumber & 1 ) == 0 ? - side::right : - side::left ) ] }; + right : + left ) ] }; pAnim->smAnimated->SetRotate( float3(1, 0, 0), @@ -595,8 +595,8 @@ void TDynamicObject::UpdateDoorFold(TAnim *pAnim) { auto const &door { MoverParameters->Doors.instances[ ( ( pAnim->iNumber & 1 ) == 0 ? - side::right : - side::left ) ] }; + right : + left ) ] }; // skrzydło mniejsze pAnim->smAnimated->SetRotate( @@ -627,8 +627,8 @@ void TDynamicObject::UpdateDoorPlug(TAnim *pAnim) { auto const &door { MoverParameters->Doors.instances[ ( ( pAnim->iNumber & 1 ) == 0 ? - side::right : - side::left ) ] }; + right : + left ) ] }; pAnim->smAnimated->SetTranslate( glm::vec3{ @@ -666,8 +666,8 @@ void TDynamicObject::UpdatePlatformTranslate( TAnim *pAnim ) { auto const &door { MoverParameters->Doors.instances[ ( ( pAnim->iNumber & 1 ) == 0 ? - side::right : - side::left ) ] }; + right : + left ) ] }; pAnim->smAnimated->SetTranslate( glm::vec3{ @@ -683,8 +683,8 @@ void TDynamicObject::UpdatePlatformRotate( TAnim *pAnim ) { auto const &door { MoverParameters->Doors.instances[ ( ( pAnim->iNumber & 1 ) == 0 ? - side::right : - side::left ) ] }; + right : + left ) ] }; pAnim->smAnimated->SetRotate( float3( 0, 1, 0 ), @@ -698,8 +698,8 @@ void TDynamicObject::UpdateMirror( TAnim *pAnim ) { // only animate the mirror if it's located on the same end of the vehicle as the active cab auto const isactive { ( - MoverParameters->CabOccupied > 0 ? ( pAnim->iNumber >> 4 == end::front ? 1.0 : 0.0 ) : - MoverParameters->CabOccupied < 0 ? ( pAnim->iNumber >> 4 == end::rear ? 1.0 : 0.0 ) : + MoverParameters->CabOccupied > 0 ? ( pAnim->iNumber >> 4 == front ? 1.0 : 0.0 ) : + MoverParameters->CabOccupied < 0 ? ( pAnim->iNumber >> 4 == rear ? 1.0 : 0.0 ) : 0.0 ) }; if( pAnim->iNumber & 1 ) @@ -846,8 +846,8 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) // display _xon if connected with another vehicle and not the coupling owner // display _xon if not connected, but equipped with coupling adapter // display _off if not connected, not equipped with coupling adapter or if _xon model is missing - if( TestFlag( MoverParameters->Couplers[ end::front ].CouplingFlag, coupling::coupler ) ) { - if( MoverParameters->Couplers[ end::front ].Render ) { + if( TestFlag( MoverParameters->Couplers[ front ].CouplingFlag, coupler ) ) { + if( MoverParameters->Couplers[ front ].Render ) { btCoupler1.TurnOn(); } else { @@ -856,13 +856,13 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btnOn = true; } else { - if( true == MoverParameters->Couplers[ end::front ].has_adapter() ) { + if( true == MoverParameters->Couplers[ front ].has_adapter() ) { btCoupler1.TurnxOnWithOffAsFallback(); btnOn = true; } } - if( TestFlag( MoverParameters->Couplers[ end::rear ].CouplingFlag, coupling::coupler ) ) { - if( MoverParameters->Couplers[ end::rear ].Render ) { + if( TestFlag( MoverParameters->Couplers[ rear ].CouplingFlag, coupler ) ) { + if( MoverParameters->Couplers[ rear ].Render ) { btCoupler2.TurnOn(); } else { @@ -871,7 +871,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btnOn = true; } else { - if( true == MoverParameters->Couplers[ end::rear ].has_adapter() ) { + if( true == MoverParameters->Couplers[ rear ].has_adapter() ) { btCoupler2.TurnxOnWithOffAsFallback(); btnOn = true; } @@ -888,7 +888,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) SetPneumatic(true, true); // ktore z nich nalezy SetPneumatic(false, true); // wyswietlic w tej klatce - if (TestFlag(MoverParameters->Couplers[end::front].CouplingFlag, ctrain_pneumatic)) + if (TestFlag(MoverParameters->Couplers[front].CouplingFlag, ctrain_pneumatic)) { switch (cp1) { @@ -908,7 +908,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btnOn = true; } - if (TestFlag(MoverParameters->Couplers[end::rear].CouplingFlag, ctrain_pneumatic)) + if (TestFlag(MoverParameters->Couplers[rear].CouplingFlag, ctrain_pneumatic)) { switch (cp2) { @@ -929,7 +929,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } // przewody zasilajace, j.w. (yB) - if (TestFlag(MoverParameters->Couplers[end::front].CouplingFlag, ctrain_scndpneumatic)) + if (TestFlag(MoverParameters->Couplers[front].CouplingFlag, ctrain_scndpneumatic)) { switch (sp1) { @@ -949,7 +949,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btnOn = true; } - if (TestFlag(MoverParameters->Couplers[end::rear].CouplingFlag, ctrain_scndpneumatic)) + if (TestFlag(MoverParameters->Couplers[rear].CouplingFlag, ctrain_scndpneumatic)) { switch (sp2) { @@ -974,18 +974,18 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) { // przewody powietrzne j.w., ABu: decyzja czy rysowac tylko na podstawie // 'render' - if (TestFlag(MoverParameters->Couplers[end::front].CouplingFlag, ctrain_pneumatic)) + if (TestFlag(MoverParameters->Couplers[front].CouplingFlag, ctrain_pneumatic)) { - if (MoverParameters->Couplers[end::front].Render) + if (MoverParameters->Couplers[front].Render) btCPneumatic1.TurnOn(); else btCPneumatic1r.TurnOn(); btnOn = true; } - if (TestFlag(MoverParameters->Couplers[end::rear].CouplingFlag, ctrain_pneumatic)) + if (TestFlag(MoverParameters->Couplers[rear].CouplingFlag, ctrain_pneumatic)) { - if (MoverParameters->Couplers[end::rear].Render) + if (MoverParameters->Couplers[rear].Render) btCPneumatic2.TurnOn(); else btCPneumatic2r.TurnOn(); @@ -1040,13 +1040,13 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) // Winger 160204 - podnoszenie pantografow // przewody sterowania ukrotnionego - if (TestFlag(MoverParameters->Couplers[0].CouplingFlag, coupling::control)) + if (TestFlag(MoverParameters->Couplers[0].CouplingFlag, control)) { btCCtrl1.Turn( true ); btnOn = true; } // else btCCtrl1.TurnOff(); - if (TestFlag(MoverParameters->Couplers[1].CouplingFlag, coupling::control)) + if (TestFlag(MoverParameters->Couplers[1].CouplingFlag, control)) { btCCtrl2.Turn( true ); btnOn = true; @@ -1068,36 +1068,36 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) if (MoverParameters->Power24vIsAvailable || MoverParameters->Power110vIsAvailable) { // sygnaly konca pociagu if (m_endsignals1.Active()) { - if (TestFlag(MoverParameters->iLights[end::front], light::redmarker_left | light::redmarker_right ) ) { + if (TestFlag(MoverParameters->iLights[front], redmarker_left | redmarker_right ) ) { m_endsignals1.Turn( true ); btnOn = true; } } else { - if (TestFlag(MoverParameters->iLights[end::front], light::redmarker_left) && !HeadlightsAoff) + if (TestFlag(MoverParameters->iLights[front], redmarker_left) && !HeadlightsAoff) { m_endsignal13.Turn( true ); btnOn = true; } - if (TestFlag(MoverParameters->iLights[end::front], light::redmarker_right) && !HeadlightsAoff) + if (TestFlag(MoverParameters->iLights[front], redmarker_right) && !HeadlightsAoff) { m_endsignal12.Turn( true ); btnOn = true; } } if (m_endsignals2.Active()) { - if (TestFlag(MoverParameters->iLights[end::rear], light::redmarker_left | light::redmarker_right ) ) { + if (TestFlag(MoverParameters->iLights[rear], redmarker_left | redmarker_right ) ) { m_endsignals2.Turn( true ); btnOn = true; } } else { - if (TestFlag(MoverParameters->iLights[end::rear], light::redmarker_left) && !HeadlightsBoff) + if (TestFlag(MoverParameters->iLights[rear], redmarker_left) && !HeadlightsBoff) { m_endsignal23.Turn( true ); btnOn = true; } - if (TestFlag(MoverParameters->iLights[end::rear], light::redmarker_right) && !HeadlightsBoff) + if (TestFlag(MoverParameters->iLights[rear], redmarker_right) && !HeadlightsBoff) { m_endsignal22.Turn( true ); btnOn = true; @@ -1105,12 +1105,12 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } } // tablice blaszane: - if (TestFlag(MoverParameters->iLights[end::front], light::rearendsignals)) { + if (TestFlag(MoverParameters->iLights[front], rearendsignals)) { m_endtab1.Turn( true ); btnOn = true; } // else btEndSignalsTab1.TurnOff(); - if (TestFlag(MoverParameters->iLights[end::rear], light::rearendsignals)) { + if (TestFlag(MoverParameters->iLights[rear], rearendsignals)) { m_endtab2.Turn( true ); btnOn = true; } @@ -1158,7 +1158,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) // ograniczeń odległości, by były widoczne z // daleka - if (TestFlag(MoverParameters->iLights[end::front], light::headlight_left) + if (TestFlag(MoverParameters->iLights[front], headlight_left) && !HeadlightsAoff && !HighBeamLights) { if( DimHeadlights ) { @@ -1169,7 +1169,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - if (TestFlag(MoverParameters->iLights[end::front], light::headlight_upper) + if (TestFlag(MoverParameters->iLights[front], headlight_upper) && !HeadlightsAoff) { if( DimHeadlights ) { @@ -1180,7 +1180,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - if (TestFlag(MoverParameters->iLights[end::front], light::headlight_right) + if (TestFlag(MoverParameters->iLights[front], headlight_right) && !HeadlightsAoff && !HighBeamLights) { if( DimHeadlights ) { @@ -1192,7 +1192,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btnOn = true; } // else btHeadSignals13.TurnOff(); - if (TestFlag(MoverParameters->iLights[end::rear], light::headlight_left) + if (TestFlag(MoverParameters->iLights[rear], headlight_left) && !HeadlightsBoff && !HighBeamLights) { if( DimHeadlights ) { @@ -1203,7 +1203,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - if (TestFlag(MoverParameters->iLights[end::rear], light::headlight_upper) + if (TestFlag(MoverParameters->iLights[rear], headlight_upper) && !HeadlightsBoff) { if( DimHeadlights ) { @@ -1214,7 +1214,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - if (TestFlag(MoverParameters->iLights[end::rear], light::headlight_right) + if (TestFlag(MoverParameters->iLights[rear], headlight_right) && !HeadlightsBoff && !HighBeamLights) { if( DimHeadlights ) { @@ -1226,7 +1226,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btnOn = true; } // auxiliary lights - if (TestFlag(MoverParameters->iLights[end::front], light::auxiliary_left) && !HeadlightsAoff) + if (TestFlag(MoverParameters->iLights[front], auxiliary_left) && !HeadlightsAoff) { if( DimHeadlights ) { m_headsignal13.TurnxOnWithOnAsFallback(); @@ -1236,7 +1236,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - if (TestFlag(MoverParameters->iLights[end::front], light::auxiliary_right) && !HeadlightsAoff) + if (TestFlag(MoverParameters->iLights[front], auxiliary_right) && !HeadlightsAoff) { if( DimHeadlights ) { m_headsignal12.TurnxOnWithOnAsFallback(); @@ -1246,7 +1246,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - if (TestFlag(MoverParameters->iLights[end::rear], light::auxiliary_left) && !HeadlightsBoff) + if (TestFlag(MoverParameters->iLights[rear], auxiliary_left) && !HeadlightsBoff) { if( DimHeadlights ) { m_headsignal23.TurnxOnWithOnAsFallback(); @@ -1256,7 +1256,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - if (TestFlag(MoverParameters->iLights[end::rear], light::auxiliary_right) && !HeadlightsBoff) + if (TestFlag(MoverParameters->iLights[rear], auxiliary_right) && !HeadlightsBoff) { if( DimHeadlights ) { m_headsignal22.TurnxOnWithOnAsFallback(); @@ -1268,26 +1268,26 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } // logika dlugich - if (TestFlag(MoverParameters->iLights[end::front], light::headlight_left) + if (TestFlag(MoverParameters->iLights[front], headlight_left) && !HeadlightsAoff && HighBeamLights) m_highbeam13.TurnxOnWithOnAsFallback(); else m_highbeam13.TurnOff(); - if (TestFlag(MoverParameters->iLights[end::front], light::headlight_right) + if (TestFlag(MoverParameters->iLights[front], headlight_right) && !HeadlightsAoff && HighBeamLights) m_highbeam12.TurnxOnWithOnAsFallback(); else m_highbeam12.TurnOff(); // i to samo od dupy strony - if (TestFlag(MoverParameters->iLights[end::rear], light::headlight_left) + if (TestFlag(MoverParameters->iLights[rear], headlight_left) && !HeadlightsBoff && HighBeamLights) m_highbeam23.TurnxOnWithOnAsFallback(); else m_highbeam23.TurnOff(); - if (TestFlag(MoverParameters->iLights[end::rear], light::headlight_right) + if (TestFlag(MoverParameters->iLights[rear], headlight_right) && !HeadlightsBoff && HighBeamLights) m_highbeam22.TurnxOnWithOnAsFallback(); else @@ -1590,7 +1590,7 @@ int TDynamicObject::DettachStatus(int dir) // rzeczywistych od strony (dir): // 0=przód,1=tył // Ra: dziwne, że ta funkcja nie jest używana - if( MoverParameters->Couplers[ dir ].CouplingFlag == coupling::faux ) { + if( MoverParameters->Couplers[ dir ].CouplingFlag == faux ) { return 0; // jeśli nic nie podłączone, to jest OK } return MoverParameters->DettachStatus(dir); // czy jest w odpowiedniej odległości? @@ -1644,7 +1644,7 @@ TDynamicObject::couple( int const Side ) { auto *othervehicleparams{ othervehicle->MoverParameters }; auto const &othercoupler { othervehicleparams->Couplers[ neighbour.vehicle_end ] }; - if( coupler.CouplingFlag == coupling::faux ) { + if( coupler.CouplingFlag == faux ) { // najpierw hak if( ( coupler.AllowedFlag & othercoupler.AllowedFlag @@ -1661,15 +1661,15 @@ TDynamicObject::couple( int const Side ) { } } } - if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, coupling::brakehose ) ) { + if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, brakehose ) ) { // pneumatyka if( ( coupler.AllowedFlag & othercoupler.AllowedFlag - & coupling::brakehose ) == coupling::brakehose ) { + & brakehose ) == brakehose ) { if( MoverParameters->Attach( Side, neighbour.vehicle_end, othervehicleparams, - coupler.CouplingFlag | coupling::brakehose ) ) { + coupler.CouplingFlag | brakehose ) ) { SetPneumatic( Side != 0, true ); othervehicle->SetPneumatic( Side != 0, true ); // one coupling type per key press @@ -1677,15 +1677,15 @@ TDynamicObject::couple( int const Side ) { } } } - if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, coupling::mainhose ) ) { + if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, mainhose ) ) { // zasilajacy if( ( coupler.AllowedFlag & othercoupler.AllowedFlag - & coupling::mainhose ) == coupling::mainhose ) { + & mainhose ) == mainhose ) { if( MoverParameters->Attach( Side, neighbour.vehicle_end, othervehicleparams, - coupler.CouplingFlag | coupling::mainhose ) ) { + coupler.CouplingFlag | mainhose ) ) { SetPneumatic( Side != 0, false ); othervehicle->SetPneumatic( Side != 0, false ); // one coupling type per key press @@ -1693,42 +1693,42 @@ TDynamicObject::couple( int const Side ) { } } } - if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, coupling::control ) ) { + if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, control ) ) { // ukrotnionko - if( (coupler.AllowedFlag & othercoupler.AllowedFlag & coupling::control) == coupling::control + if( (coupler.AllowedFlag & othercoupler.AllowedFlag & control) == control && coupler.control_type == othercoupler.control_type ) { if( MoverParameters->Attach( Side, neighbour.vehicle_end, othervehicleparams, - coupler.CouplingFlag | coupling::control ) ) { + coupler.CouplingFlag | control ) ) { // one coupling type per key press return; } } } - if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, coupling::gangway ) ) { + if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, gangway ) ) { // mostek if( ( coupler.AllowedFlag & othercoupler.AllowedFlag - & coupling::gangway ) == coupling::gangway ) { + & gangway ) == gangway ) { if( MoverParameters->Attach( Side, neighbour.vehicle_end, othervehicleparams, - coupler.CouplingFlag | coupling::gangway ) ) { + coupler.CouplingFlag | gangway ) ) { // one coupling type per key press return; } } } - if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, coupling::heating ) ) { + if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, heating ) ) { // heating if( ( coupler.AllowedFlag & othercoupler.AllowedFlag - & coupling::heating ) == coupling::heating ) { + & heating ) == heating ) { if( MoverParameters->Attach( Side, neighbour.vehicle_end, othervehicleparams, - coupler.CouplingFlag | coupling::heating ) ) { + coupler.CouplingFlag | heating ) ) { // one coupling type per key press return; } @@ -1741,7 +1741,7 @@ int TDynamicObject::uncouple( int const Side ) { if( DettachStatus(Side) >= 0 - || true == TestFlag(MoverParameters->Couplers[Side].CouplingFlag, coupling::permanent) ) { + || true == TestFlag(MoverParameters->Couplers[Side].CouplingFlag, permanent) ) { // can't uncouple, return existing coupling state return MoverParameters->Couplers[ Side ].CouplingFlag; } @@ -1782,7 +1782,7 @@ TDynamicObject::attach_coupler_adapter( int const Side, bool const Enforce ) { coupler.adapter_length = adapterdata.position.x; coupler.adapter_height = adapterdata.position.y; // audio flag, visuals update - coupler.sounds |= sound::attachadapter; + coupler.sounds |= attachadapter; m_coupleradapters[ Side ] = TModelsManager::GetModel( adapterdata.model ); return true; @@ -1803,7 +1803,7 @@ TDynamicObject::remove_coupler_adapter( int const Side ) { coupler.adapter_length = 0.0; coupler.adapter_height = 0.0; // audio flag, visuals update - coupler.sounds |= sound::removeadapter; + coupler.sounds |= removeadapter; m_coupleradapters[ Side ] = nullptr; return true; @@ -2335,31 +2335,31 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" m_headsignal22.Init( "headsignal22", mdModel ); m_headsignal23.Init( "headsignal23", mdModel ); // informacja, czy ma poszczególne światła - iInventory[ end::front ] |= m_endsignal12.Active() ? light::redmarker_right : 0; - iInventory[ end::front ] |= m_endsignal13.Active() ? light::redmarker_left : 0; - iInventory[ end::rear ] |= m_endsignal22.Active() ? light::redmarker_right : 0; - iInventory[ end::rear ] |= m_endsignal23.Active() ? light::redmarker_left : 0; - iInventory[ end::front ] |= m_endsignals1.Active() ? light::redmarker_left | light::redmarker_right : 0; - iInventory[ end::rear ] |= m_endsignals2.Active() ? light::redmarker_left | light::redmarker_right : 0; - iInventory[ end::front ] |= m_endtab1.Active() ? light::rearendsignals : 0; // tabliczki blaszane - iInventory[ end::rear ] |= m_endtab2.Active() ? light::rearendsignals : 0; - iInventory[ end::front ] |= m_headlamp11.Active() ? light::headlight_upper : 0; - iInventory[ end::front ] |= m_headlamp12.Active() ? light::headlight_right : 0; - iInventory[ end::front ] |= m_headlamp13.Active() ? light::headlight_left : 0; + iInventory[ front ] |= m_endsignal12.Active() ? redmarker_right : 0; + iInventory[ front ] |= m_endsignal13.Active() ? redmarker_left : 0; + iInventory[ rear ] |= m_endsignal22.Active() ? redmarker_right : 0; + iInventory[ rear ] |= m_endsignal23.Active() ? redmarker_left : 0; + iInventory[ front ] |= m_endsignals1.Active() ? redmarker_left | redmarker_right : 0; + iInventory[ rear ] |= m_endsignals2.Active() ? redmarker_left | redmarker_right : 0; + iInventory[ front ] |= m_endtab1.Active() ? rearendsignals : 0; // tabliczki blaszane + iInventory[ rear ] |= m_endtab2.Active() ? rearendsignals : 0; + iInventory[ front ] |= m_headlamp11.Active() ? headlight_upper : 0; + iInventory[ front ] |= m_headlamp12.Active() ? headlight_right : 0; + iInventory[ front ] |= m_headlamp13.Active() ? headlight_left : 0; - iInventory[end::front] |= m_highbeam12.Active() ? light::highbeamlight_right : 0; - iInventory[end::front] |= m_highbeam13.Active() ? light::highbeamlight_left : 0; + iInventory[front] |= m_highbeam12.Active() ? highbeamlight_right : 0; + iInventory[front] |= m_highbeam13.Active() ? highbeamlight_left : 0; - iInventory[ end::rear ] |= m_headlamp21.Active() ? light::headlight_upper : 0; - iInventory[ end::rear ] |= m_headlamp22.Active() ? light::headlight_right : 0; - iInventory[ end::rear ] |= m_headlamp23.Active() ? light::headlight_left : 0; - iInventory[ end::front ] |= m_headsignal12.Active() ? light::auxiliary_right : 0; - iInventory[ end::front ] |= m_headsignal13.Active() ? light::auxiliary_left : 0; - iInventory[ end::rear ] |= m_headsignal22.Active() ? light::auxiliary_right : 0; - iInventory[ end::rear ] |= m_headsignal23.Active() ? light::auxiliary_left : 0; + iInventory[ rear ] |= m_headlamp21.Active() ? headlight_upper : 0; + iInventory[ rear ] |= m_headlamp22.Active() ? headlight_right : 0; + iInventory[ rear ] |= m_headlamp23.Active() ? headlight_left : 0; + iInventory[ front ] |= m_headsignal12.Active() ? auxiliary_right : 0; + iInventory[ front ] |= m_headsignal13.Active() ? auxiliary_left : 0; + iInventory[ rear ] |= m_headsignal22.Active() ? auxiliary_right : 0; + iInventory[ rear ] |= m_headsignal23.Active() ? auxiliary_left : 0; - iInventory[end::rear] |= m_highbeam22.Active() ? light::highbeamlight_right : 0; - iInventory[end::rear] |= m_highbeam23.Active() ? light::highbeamlight_left : 0; + iInventory[rear] |= m_highbeam22.Active() ? highbeamlight_right : 0; + iInventory[rear] |= m_highbeam23.Active() ? highbeamlight_left : 0; btExteriorOnly.Init("external_only", mdModel, false); @@ -2654,8 +2654,8 @@ void TDynamicObject::Move(double fDistance) } // obliczanie pozycji sprzęgów do liczenia zderzeń auto dir = 0.5 * MoverParameters->Dim.L * vFront; // wektor sprzęgu - vCoulpler[end::front] = vPosition + dir; // współrzędne sprzęgu na początku - vCoulpler[end::rear] = vPosition - dir; // współrzędne sprzęgu na końcu + vCoulpler[front] = vPosition + dir; // współrzędne sprzęgu na początku + vCoulpler[rear] = vPosition - dir; // współrzędne sprzęgu na końcu // bCameraNear= // if (bCameraNear) //jeśli istotne są szczegóły (blisko kamery) { // przeliczenie cienia @@ -2834,10 +2834,10 @@ float TDynamicObject::LoadExchangeSpeed() const { auto const lewe { DirectionGet() > 0 ? 1 : 2 }; auto const prawe { 3 - lewe }; if( m_exchange.platforms & lewe ) { - exchangespeedfactor += MoverParameters->Doors.instances[side::left].is_open ? 1.f : 0.f; + exchangespeedfactor += MoverParameters->Doors.instances[left].is_open ? 1.f : 0.f; } if( m_exchange.platforms & prawe ) { - exchangespeedfactor += MoverParameters->Doors.instances[side::right].is_open ? 1.f : 0.f; + exchangespeedfactor += MoverParameters->Doors.instances[right].is_open ? 1.f : 0.f; } return exchangespeedfactor; @@ -2860,14 +2860,14 @@ void TDynamicObject::update_exchange( double const Deltatime ) { auto const lewe { DirectionGet() > 0 ? 1 : 2 }; auto const prawe { 3 - lewe }; if( m_exchange.platforms & lewe - && false == (MoverParameters->Doors.instances[side::left].is_open || MoverParameters->Doors.instances[side::left].is_opening) ) { + && false == (MoverParameters->Doors.instances[left].is_open || MoverParameters->Doors.instances[left].is_opening) ) { // try to open left door - MoverParameters->OperateDoors( side::left, true, range_t::local ); + MoverParameters->OperateDoors( left, true, range_t::local ); } if( m_exchange.platforms & prawe - && false == (MoverParameters->Doors.instances[side::right].is_open || MoverParameters->Doors.instances[side::right].is_opening) ) { + && false == (MoverParameters->Doors.instances[right].is_open || MoverParameters->Doors.instances[right].is_opening) ) { // try to open right door - MoverParameters->OperateDoors( side::right, true, range_t::local ); + MoverParameters->OperateDoors( right, true, range_t::local ); } } @@ -2915,16 +2915,16 @@ void TDynamicObject::update_exchange( double const Deltatime ) { MoverParameters->LoadStatus = 4; // if the exchange is completed (or canceled) close the door, if applicable - if( MoverParameters->Doors.close_control == control_t::passenger - || MoverParameters->Doors.close_control == control_t::mixed ) { + if( MoverParameters->Doors.close_control == passenger + || MoverParameters->Doors.close_control == mixed ) { if( MoverParameters->Vel > 2.0 || Random() < ( // remotely controlled door are more likely to be left open - MoverParameters->Doors.close_control == control_t::passenger ? 0.75 : 0.50) ) { + MoverParameters->Doors.close_control == passenger ? 0.75 : 0.50) ) { - MoverParameters->OperateDoors( side::left, false, range_t::local ); - MoverParameters->OperateDoors( side::right, false, range_t::local ); + MoverParameters->OperateDoors( left, false, range_t::local ); + MoverParameters->OperateDoors( right, false, range_t::local ); } } // if the vehicle was emptied potentially switch load visualization model @@ -3110,19 +3110,19 @@ bool TDynamicObject::Update(double dt, double dt1) tp.QualityFlag = MyTrack->iQualityFlag; // couplers - if( MoverParameters->Couplers[0].CouplingFlag != coupling::faux - && MoverParameters->Couplers[1].CouplingFlag != coupling::faux ) { + if( MoverParameters->Couplers[0].CouplingFlag != faux + && MoverParameters->Couplers[1].CouplingFlag != faux ) { MoverParameters->InsideConsist = true; } else { MoverParameters->InsideConsist = false; } - if( TestFlag( MoverParameters->AIFlag, sound::attachcoupler ) ) { + if( TestFlag( MoverParameters->AIFlag, attachcoupler ) ) { auto *driver{ ctOwner ? ctOwner : Mechanik }; if( driver != nullptr ) { driver->CheckVehicles( Connect ); } - ClearFlag( MoverParameters->AIFlag, sound::attachcoupler ); + ClearFlag( MoverParameters->AIFlag, attachcoupler ); } // napiecie sieci trakcyjnej @@ -3143,8 +3143,8 @@ bool TDynamicObject::Update(double dt, double dt1) // jeśli jedzie if( MoverParameters->Vel > 0.5 ) { // Ra 2014-07: doraźna blokada logowania zimnych lokomotyw - zrobić to trzeba inaczej - if( MoverParameters->Pantographs[end::front].is_active - || MoverParameters->Pantographs[end::rear].is_active ) { + if( MoverParameters->Pantographs[front].is_active + || MoverParameters->Pantographs[rear].is_active ) { if( MoverParameters->Mains // Ra 15-01: logować tylko, jeśli WS załączony && MoverParameters->GetTrainsetHighVoltage() < 0.1f ) { // yB 16-03: i nie jest to asynchron zasilany z daleka // Ra 15-01: bezwzględne współrzędne pantografu nie są dostępne więc lepiej się tego nie zaloguje @@ -3267,11 +3267,11 @@ bool TDynamicObject::Update(double dt, double dt1) Mechanik->fMedAmax = amax; auto doorisopen { - false == MoverParameters->Doors.instances[side::left].is_closed - || false == MoverParameters->Doors.instances[side::right].is_closed + false == MoverParameters->Doors.instances[left].is_closed + || false == MoverParameters->Doors.instances[right].is_closed || ( MoverParameters->Doors.permit_needed - && ( MoverParameters->Doors.instances[ side::left ].open_permit - || MoverParameters->Doors.instances[ side::right ].open_permit ) ) }; + && ( MoverParameters->Doors.instances[ left ].open_permit + || MoverParameters->Doors.instances[ right ].open_permit ) ) }; doorisopen &= !(MoverParameters->ReleaseParkingBySpringBrakeWhenDoorIsOpen && MoverParameters->SpringBrake.IsActive); if (MoverParameters->Vel < 0.5 && (eimic < 0 || doorisopen || MoverParameters->Hamulec->GetEDBCP())) @@ -3741,7 +3741,7 @@ bool TDynamicObject::Update(double dt, double dt1) } else { if( pantograph->hvPowerWire != nullptr - && true == MoverParameters->Pantographs[end::front].is_active + && true == MoverParameters->Pantographs[front].is_active && pantograph->PantTraction - pantograph->PantWys < 0.01 ) { // tolerancja niedolegania ++activepantographs; } @@ -3780,7 +3780,7 @@ bool TDynamicObject::Update(double dt, double dt1) 0.95 * MoverParameters->EnginePowerSource.MaxVoltage : 0.0; } - else if( true == MoverParameters->Pantographs[end::front].is_active + else if( true == MoverParameters->Pantographs[front].is_active && PantDiff < 0.01 ) // tolerancja niedolegania { if (p->hvPowerWire) { @@ -3802,7 +3802,7 @@ bool TDynamicObject::Update(double dt, double dt1) for( auto &pantograph : m_pantographsounds ) { if( pantograph.sPantUp.offset().z > 0 ) { // limit to pantographs located in the front half of the vehicle - pantograph.sPantUp.play( sound_flags::exclusive ); + pantograph.sPantUp.play( exclusive ); } } } @@ -3823,7 +3823,7 @@ bool TDynamicObject::Update(double dt, double dt1) 0.95 * MoverParameters->EnginePowerSource.MaxVoltage : 0.0; } - else if ( true == MoverParameters->Pantographs[end::rear].is_active + else if ( true == MoverParameters->Pantographs[rear].is_active && PantDiff < 0.01 ) { if (p->hvPowerWire) { @@ -3845,7 +3845,7 @@ bool TDynamicObject::Update(double dt, double dt1) for( auto &pantograph : m_pantographsounds ) { if( pantograph.sPantUp.offset().z < 0 ) { // limit to pantographs located in the rear half of the vehicle - pantograph.sPantUp.play( sound_flags::exclusive ); + pantograph.sPantUp.play( exclusive ); } } } @@ -3922,8 +3922,8 @@ bool TDynamicObject::Update(double dt, double dt1) } } // koniec pętli po pantografach // TBD, TODO: generate sound event during mover update instead? - if( MoverParameters->Pantographs[end::front].sound_event != MoverParameters->Pantographs[ end::front ].is_active ) { - if( MoverParameters->Pantographs[ end::front ].is_active ) { + if( MoverParameters->Pantographs[front].sound_event != MoverParameters->Pantographs[ front ].is_active ) { + if( MoverParameters->Pantographs[ front ].is_active ) { // pantograph moving up // TBD: add a sound? } @@ -3932,14 +3932,14 @@ bool TDynamicObject::Update(double dt, double dt1) for( auto &pantograph : m_pantographsounds ) { if( pantograph.sPantDown.offset().z > 0 ) { // limit to pantographs located in the front half of the vehicle - pantograph.sPantDown.play( sound_flags::exclusive ); + pantograph.sPantDown.play( exclusive ); } } } - MoverParameters->Pantographs[ end::front ].sound_event = MoverParameters->Pantographs[ end::front ].is_active; + MoverParameters->Pantographs[ front ].sound_event = MoverParameters->Pantographs[ front ].is_active; } - if( MoverParameters->Pantographs[ end::rear ].sound_event != MoverParameters->Pantographs[ end::rear ].is_active ) { - if( MoverParameters->Pantographs[ end::rear ].is_active ) { + if( MoverParameters->Pantographs[ rear ].sound_event != MoverParameters->Pantographs[ rear ].is_active ) { + if( MoverParameters->Pantographs[ rear ].is_active ) { // pantograph moving up // TBD: add a sound? } @@ -3948,11 +3948,11 @@ bool TDynamicObject::Update(double dt, double dt1) for( auto &pantograph : m_pantographsounds ) { if( pantograph.sPantDown.offset().z < 0 ) { // limit to pantographs located in the front half of the vehicle - pantograph.sPantDown.play( sound_flags::exclusive ); + pantograph.sPantDown.play( exclusive ); } } } - MoverParameters->Pantographs[ end::rear ].sound_event = MoverParameters->Pantographs[ end::rear ].is_active; + MoverParameters->Pantographs[ rear ].sound_event = MoverParameters->Pantographs[ rear ].is_active; } } else if (MoverParameters->EnginePowerSource.SourceType == TPowerSource::InternalSource) @@ -4083,7 +4083,7 @@ bool TDynamicObject::Update(double dt, double dt1) { if (!sWiperFromParkPlayed) { - sWiperFromPark.play(sound_flags::exclusive); + sWiperFromPark.play(exclusive); sWiperFromParkPlayed = true; } dWiperPos[i] = std::min(1.0, dWiperPos[i] + 1.f / currentWiperParams.WiperSpeed * dt1); @@ -4093,7 +4093,7 @@ bool TDynamicObject::Update(double dt, double dt1) { if (!sWiperToParkPlayed) { - sWiperToPark.play(sound_flags::exclusive); + sWiperToPark.play(exclusive); sWiperToParkPlayed = true; } dWiperPos[i] = std::max(0.0, dWiperPos[i] - 1.f / currentWiperParams.WiperSpeed * dt1); @@ -4124,7 +4124,7 @@ bool TDynamicObject::Update(double dt, double dt1) // mirrors if( MoverParameters->Vel > MoverParameters->MirrorVelClose - || MoverParameters->CabActive == 0 && activation::mirrors + || MoverParameters->CabActive == 0 && mirrors || MoverParameters->MirrorForbidden ) { // automatically fold mirrors when above velocity threshold if( dMirrorMoveL > 0.0 ) { @@ -4141,13 +4141,13 @@ bool TDynamicObject::Update(double dt, double dt1) else { // unfold mirror on the side with open doors, if not moving too fast if( dMirrorMoveL < 1.0 - && true == MoverParameters->Doors.instances[side::left].open_permit ) { + && true == MoverParameters->Doors.instances[left].open_permit ) { dMirrorMoveL = std::min( 1.0, dMirrorMoveL + 1.0 * dt1 ); } if( dMirrorMoveR < 1.0 - && true == MoverParameters->Doors.instances[side::right].open_permit ) { + && true == MoverParameters->Doors.instances[right].open_permit ) { dMirrorMoveR = std::min( 1.0, dMirrorMoveR + 1.0 * dt1 ); @@ -4199,14 +4199,14 @@ void TDynamicObject::pants_up() { d = this; while (d) { - d->MoverParameters->OperatePantographValve(end::front, operation_t::enable, range_t::local); - d->MoverParameters->OperatePantographValve(end::rear, operation_t::enable, range_t::local); + d->MoverParameters->OperatePantographValve(front, operation_t::enable, range_t::local); + d->MoverParameters->OperatePantographValve(rear, operation_t::enable, range_t::local); d = d->Next(4); // pozostałe też } d = Prev(4); while (d) { - d->MoverParameters->OperatePantographValve(end::front, operation_t::enable, range_t::local); - d->MoverParameters->OperatePantographValve(end::rear, operation_t::enable, range_t::local); + d->MoverParameters->OperatePantographValve(front, operation_t::enable, range_t::local); + d->MoverParameters->OperatePantographValve(rear, operation_t::enable, range_t::local); d = d->Prev(4); // w drugą stronę też } } @@ -4362,7 +4362,7 @@ void TDynamicObject::RenderSounds() { frequency = sConverter.m_frequencyoffset + sConverter.m_frequencyfactor * frequency; sConverter.pitch( std::clamp( frequency, 0.75, 1.25 ) ); // arbitrary limits ) } - sConverter.play( sound_flags::exclusive | sound_flags::looping ); + sConverter.play( exclusive | looping ); } else { sConverter.stop(); @@ -4372,7 +4372,7 @@ void TDynamicObject::RenderSounds() { if (MoverParameters->BRVentilators) { - sBRVent.play(sound_flags::exclusive | sound_flags::looping); + sBRVent.play(exclusive | looping); } else { @@ -4399,16 +4399,16 @@ void TDynamicObject::RenderSounds() { } if( sCompressorIdle.empty() ) { // legacy sound path, if there's no dedicated idle sound - sCompressor.play( sound_flags::exclusive | sound_flags::looping ); + sCompressor.play( exclusive | looping ); } else { // enhanced sound path, with dedicated sound for idling compressor if( MoverParameters->CompressorGovernorLock ) { sCompressor.stop(); - sCompressorIdle.play( sound_flags::exclusive | sound_flags::looping ); + sCompressorIdle.play( exclusive | looping ); } else { - sCompressor.play( sound_flags::exclusive | sound_flags::looping ); + sCompressor.play( exclusive | looping ); sCompressorIdle.stop(); } } @@ -4421,7 +4421,7 @@ void TDynamicObject::RenderSounds() { // Winger 160404 - dzwiek malej sprezarki if( MoverParameters->PantCompFlag ) { - sSmallCompressor.play( sound_flags::exclusive | sound_flags::looping ); + sSmallCompressor.play( exclusive | looping ); } else { sSmallCompressor.stop(); @@ -4437,7 +4437,7 @@ void TDynamicObject::RenderSounds() { .pitch( true == sHeater.is_combined() ? std::abs( MoverParameters->enrot ) * 60.f * 0.01f : 1.f ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { sHeater.stop(); @@ -4446,7 +4446,7 @@ void TDynamicObject::RenderSounds() { // battery sound if( MoverParameters->Battery ) { - m_batterysound.play( sound_flags::exclusive | sound_flags::looping ); + m_batterysound.play( exclusive | looping ); } else { m_batterysound.stop(); @@ -4537,7 +4537,7 @@ void TDynamicObject::RenderSounds() { m_emergencybrake .pitch( m_emergencybrake.m_frequencyoffset + 1.0 * m_emergencybrake.m_frequencyfactor ) .gain( m_emergencybrake.m_amplitudeoffset + std::clamp( flowpressure, 0.0, 1.0 ) * m_emergencybrake.m_amplitudefactor ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else if( MoverParameters->EmergencyValveFlow < 0.015 ) { m_emergencybrakeflow = 0.0; @@ -4556,7 +4556,7 @@ void TDynamicObject::RenderSounds() { if( m_brakepressurechange > 0.05 && brakepressureratio > 0.05 ) { rsUnbrake .gain( volume ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { // don't stop the sound too abruptly @@ -4574,7 +4574,7 @@ void TDynamicObject::RenderSounds() { std::clamp( MoverParameters->BrakePress * 1.25, // arbitrary multiplier 0., 1. ) ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { sReleaser.stop(); @@ -4589,7 +4589,7 @@ void TDynamicObject::RenderSounds() { auto const velocitydifference{ GetVelocity() / MoverParameters->Vmax }; rsSlippery .gain( rsSlippery.m_amplitudeoffset + rsSlippery.m_amplitudefactor * velocitydifference ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } } else { @@ -4598,7 +4598,7 @@ void TDynamicObject::RenderSounds() { // Dzwiek piasecznicy if( MoverParameters->SandDose ) { - sSand.play( sound_flags::exclusive | sound_flags::looping ); + sSand.play( exclusive | looping ); } else { sSand.stop(); @@ -4617,7 +4617,7 @@ void TDynamicObject::RenderSounds() { rsBrake .pitch( rsBrake.m_frequencyoffset + MoverParameters->Vel * rsBrake.m_frequencyfactor ) .gain( rsBrake.m_amplitudeoffset + std::sqrt( brakeforceratio * std::lerp( 0.4, 1.0, MoverParameters->Vel / (1 + MoverParameters->Vmax) ) ) * rsBrake.m_amplitudefactor ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { rsBrake.stop(); @@ -4626,7 +4626,7 @@ void TDynamicObject::RenderSounds() { // yB: przyspieszacz (moze zadziala, ale dzwiek juz jest) if( true == bBrakeAcc ) { if( true == TestFlag( MoverParameters->Hamulec->GetSoundFlag(), sf_Acc ) ) { - sBrakeAcc.play( sound_flags::exclusive ); + sBrakeAcc.play( exclusive ); } } @@ -4641,7 +4641,7 @@ void TDynamicObject::RenderSounds() { MoverParameters->Vel * 0.01f : rsPisk.m_frequencyoffset + rsPisk.m_frequencyfactor * 1.f ) .gain( volume ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } } else { @@ -4657,25 +4657,25 @@ void TDynamicObject::RenderSounds() { if( m_springbrakesounds.state != MoverParameters->SpringBrake.Activate ) { m_springbrakesounds.state = MoverParameters->SpringBrake.Activate; if( m_springbrakesounds.state ) { - m_springbrakesounds.activate.play( sound_flags::exclusive ); + m_springbrakesounds.activate.play( exclusive ); m_springbrakesounds.release.stop(); } else { m_springbrakesounds.activate.stop(); - m_springbrakesounds.release.play( sound_flags::exclusive ); + m_springbrakesounds.release.play( exclusive ); } } // other sounds // load exchange if( MoverParameters->LoadStatus & 1 ) { - m_exchangesounds.unloading.play( sound_flags::exclusive ); + m_exchangesounds.unloading.play( exclusive ); } else { m_exchangesounds.unloading.stop(); } if( MoverParameters->LoadStatus & 2 ) { - m_exchangesounds.loading.play( sound_flags::exclusive ); + m_exchangesounds.loading.play( exclusive ); } else { m_exchangesounds.loading.stop(); @@ -4695,7 +4695,7 @@ void TDynamicObject::RenderSounds() { ) { // for the autonomous doors play the warning automatically whenever a door is closing // MC: pod warunkiem ze jest zdefiniowane w chk - doorspeaker.departure_signal.play( sound_flags::exclusive | sound_flags::looping ); + doorspeaker.departure_signal.play( exclusive | looping ); } else { doorspeaker.departure_signal.stop(); @@ -4728,7 +4728,7 @@ void TDynamicObject::RenderSounds() { } } // NBMX Obsluga drzwi, MC: zuniwersalnione - std::array const sides { side::right, side::left }; + std::array const sides { right, left }; for( auto const side : sides ) { auto const &door { MoverParameters->Doors.instances[ side ] }; @@ -4741,7 +4741,7 @@ void TDynamicObject::RenderSounds() { for( auto &doorsounds : m_doorsounds ) { if( doorsounds.placement == side ) { // determine left side doors from their offset - doorsounds.rsDoorOpen.play( sound_flags::exclusive ); + doorsounds.rsDoorOpen.play( exclusive ); doorsounds.rsDoorClose.stop(); } } @@ -4754,7 +4754,7 @@ void TDynamicObject::RenderSounds() { for( auto &doorsounds : m_doorsounds ) { if( doorsounds.placement == side ) { // determine left side doors from their offset - doorsounds.rsDoorClose.play( sound_flags::exclusive ); + doorsounds.rsDoorClose.play( exclusive ); doorsounds.rsDoorOpen.stop(); } } @@ -4764,7 +4764,7 @@ void TDynamicObject::RenderSounds() { if( door.step_unfolding ) { for( auto &doorsounds : m_doorsounds ) { if( doorsounds.placement == side ) { - doorsounds.step_open.play( sound_flags::exclusive ); + doorsounds.step_open.play( exclusive ); doorsounds.step_close.stop(); } } @@ -4774,7 +4774,7 @@ void TDynamicObject::RenderSounds() { for( auto &doorsounds : m_doorsounds ) { if( doorsounds.placement == side ) { // determine left side doors from their offset - doorsounds.step_close.play( sound_flags::exclusive ); + doorsounds.step_close.play( exclusive ); doorsounds.step_open.stop(); } } @@ -4788,10 +4788,10 @@ void TDynamicObject::RenderSounds() { // ...and play relevant sounds for( auto &door : m_doorsounds ) { if( m_doorlocks ) { - door.lock.play( sound_flags::exclusive ); + door.lock.play( exclusive ); } else { - door.unlock.play( sound_flags::exclusive ); + door.unlock.play( exclusive ); } } } @@ -4806,19 +4806,19 @@ void TDynamicObject::RenderSounds() { | MoverParameters->WarningSignal }; if( TestFlag( warningsignal, 1 ) ) { - sHorn1.play( sound_flags::exclusive | sound_flags::looping ); + sHorn1.play( exclusive | looping ); } else { sHorn1.stop(); } if( TestFlag( warningsignal, 2 ) ) { - sHorn2.play( sound_flags::exclusive | sound_flags::looping ); + sHorn2.play( exclusive | looping ); } else { sHorn2.stop(); } if( TestFlag( warningsignal, 4 ) ) { - sHorn3.play( sound_flags::exclusive | sound_flags::looping ); + sHorn3.play( exclusive | looping ); } else { sHorn3.stop(); @@ -4896,7 +4896,7 @@ void TDynamicObject::RenderSounds() { bogiesound .pitch( frequency ) // arbitrary limits to prevent the pitch going out of whack .gain( volume ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } #else m_outernoise @@ -4934,7 +4934,7 @@ void TDynamicObject::RenderSounds() { m_wheelflat .pitch( m_wheelflat.m_frequencyoffset + std::abs( MoverParameters->nrot ) * m_wheelflat.m_frequencyfactor ) .gain( m_wheelflat.m_amplitudeoffset + m_wheelflat.m_amplitudefactor * ( ( 1.0 + MoverParameters->Vel / MoverParameters->Vmax + std::clamp( MoverParameters->WheelFlat / 60.0, 0.0, 1.0 ) ) / 3.0 ) ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { m_wheelflat.stop(); @@ -4965,7 +4965,7 @@ void TDynamicObject::RenderSounds() { MoverParameters->Vel * 0.01f : rscurve.m_frequencyoffset + rscurve.m_frequencyfactor * 1.f ) .gain( 2.5 * volume ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { rscurve.stop(); @@ -4977,28 +4977,28 @@ void TDynamicObject::RenderSounds() { if( ( MoverParameters->V > 0.0 ? MoverParameters->AccSVBased > 0.1 : MoverParameters->AccSVBased < 0.1 ) && velocity > 1.0 && velocity < 15.0 ) { - m_startjolt.play( sound_flags::exclusive ); + m_startjolt.play( exclusive ); m_startjoltplayed = true; } } // McZapkie! - to wazne - SoundFlag wystawiane jest przez moje moduly gdy zachodza pewne wydarzenia komentowane dzwiekiem. // pneumatic relay - if( TestFlag( MoverParameters->SoundFlag, sound::pneumatic ) ) { + if( TestFlag( MoverParameters->SoundFlag, pneumatic ) ) { dsbPneumaticRelay .gain( - true == TestFlag( MoverParameters->SoundFlag, sound::loud ) ? + true == TestFlag( MoverParameters->SoundFlag, loud ) ? 1.0f : 0.8f ) .play(); } // door permit - if( TestFlag( MoverParameters->SoundFlag, sound::doorpermit ) ) { + if( TestFlag( MoverParameters->SoundFlag, doorpermit ) ) { // NOTE: current implementation doesn't discern between permit for left/right side, // which may be undesired in weird setups with doors only on one side // TBD, TODO: rework into dedicated sound event flag for each door location instance? for( auto &door : m_doorsounds ) { - door.permit_granted.play( sound_flags::exclusive ); + door.permit_granted.play( exclusive ); } } @@ -5008,107 +5008,107 @@ void TDynamicObject::RenderSounds() { auto &coupler { MoverParameters->Couplers[ couplerindex ] }; - if( coupler.sounds == sound::none ) { + if( coupler.sounds == none ) { ++couplerindex; continue; } - if( true == TestFlag( coupler.sounds, sound::bufferclash ) ) { + if( true == TestFlag( coupler.sounds, bufferclash ) ) { // zderzaki uderzaja o siebie - if( true == TestFlag( coupler.sounds, sound::loud ) ) { + if( true == TestFlag( coupler.sounds, loud ) ) { // loud clash if( false == couplersounds.dsbBufferClamp_loud.empty() ) { // dedicated sound for loud clash couplersounds.dsbBufferClamp_loud .gain( 1.f ) - .play( sound_flags::exclusive ); + .play( exclusive ); } else { // fallback on the standard sound couplersounds.dsbBufferClamp .gain( 1.f ) - .play( sound_flags::exclusive ); + .play( exclusive ); } } else { // basic clash couplersounds.dsbBufferClamp .gain( 1.f ) - .play( sound_flags::exclusive ); + .play( exclusive ); } } - if( true == TestFlag( coupler.sounds, sound::couplerstretch ) ) { + if( true == TestFlag( coupler.sounds, couplerstretch ) ) { // sprzegi sie rozciagaja - if( true == TestFlag( coupler.sounds, sound::loud ) ) { + if( true == TestFlag( coupler.sounds, loud ) ) { // loud stretch if( false == couplersounds.dsbCouplerStretch_loud.empty() ) { // dedicated sound for loud stretch couplersounds.dsbCouplerStretch_loud .gain( 1.f ) - .play( sound_flags::exclusive ); + .play( exclusive ); } else { // fallback on the standard sound couplersounds.dsbCouplerStretch .gain( 1.f ) - .play( sound_flags::exclusive ); + .play( exclusive ); } } else { // basic clash couplersounds.dsbCouplerStretch .gain( 1.f ) - .play( sound_flags::exclusive ); + .play( exclusive ); } } // attach/detach sounds - if( ( coupler.sounds & sound::detach ) == 0 ) { + if( ( coupler.sounds & detach ) == 0 ) { // potentially added some couplings - if( ( coupler.sounds & sound::attachcoupler ) != 0 ) { + if( ( coupler.sounds & attachcoupler ) != 0 ) { couplersounds.attach_coupler.play(); } - if( ( coupler.sounds & sound::attachbrakehose ) != 0 ) { + if( ( coupler.sounds & attachbrakehose ) != 0 ) { couplersounds.attach_brakehose.play(); } - if( ( coupler.sounds & sound::attachmainhose ) != 0 ) { + if( ( coupler.sounds & attachmainhose ) != 0 ) { couplersounds.attach_mainhose.play(); } - if( ( coupler.sounds & sound::attachcontrol ) != 0 ) { + if( ( coupler.sounds & attachcontrol ) != 0 ) { couplersounds.attach_control.play(); } - if( ( coupler.sounds & sound::attachgangway ) != 0 ) { + if( ( coupler.sounds & attachgangway ) != 0 ) { couplersounds.attach_gangway.play(); } - if( ( coupler.sounds & sound::attachheating ) != 0 ) { + if( ( coupler.sounds & attachheating ) != 0 ) { couplersounds.attach_heating.play(); } } else { // potentially removed some couplings - if( ( coupler.sounds & sound::attachcoupler ) != 0 ) { + if( ( coupler.sounds & attachcoupler ) != 0 ) { couplersounds.detach_coupler.play(); } - if( ( coupler.sounds & sound::attachbrakehose ) != 0 ) { + if( ( coupler.sounds & attachbrakehose ) != 0 ) { couplersounds.detach_brakehose.play(); } - if( ( coupler.sounds & sound::attachmainhose ) != 0 ) { + if( ( coupler.sounds & attachmainhose ) != 0 ) { couplersounds.detach_mainhose.play(); } - if( ( coupler.sounds & sound::attachcontrol ) != 0 ) { + if( ( coupler.sounds & attachcontrol ) != 0 ) { couplersounds.detach_control.play(); } - if( ( coupler.sounds & sound::attachgangway ) != 0 ) { + if( ( coupler.sounds & attachgangway ) != 0 ) { couplersounds.detach_gangway.play(); } - if( ( coupler.sounds & sound::attachheating ) != 0 ) { + if( ( coupler.sounds & attachheating ) != 0 ) { couplersounds.detach_heating.play(); } } - if( true == TestFlag( coupler.sounds, sound::attachadapter ) ) { + if( true == TestFlag( coupler.sounds, attachadapter ) ) { couplersounds.dsbAdapterAttach.play(); } - if( true == TestFlag( coupler.sounds, sound::removeadapter ) ) { + if( true == TestFlag( coupler.sounds, removeadapter ) ) { couplersounds.dsbAdapterRemove.play(); } @@ -5123,7 +5123,7 @@ void TDynamicObject::RenderSounds() { if( MoverParameters->EventFlag ) { // McZapkie: w razie wykolejenia if( true == TestFlag( MoverParameters->DamageFlag, dtrain_out ) ) { - rsDerailment.play( sound_flags::exclusive ); + rsDerailment.play( exclusive ); } MoverParameters->EventFlag = false; @@ -5816,8 +5816,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co // parzyste działają inaczej niż nieparzyste pAnimations[ i + j ].iNumber = ( ( pAnimations[ i + j ].smAnimated->offset().z > 0 ? - end::front : - end::rear ) << 4 ) + front : + rear ) << 4 ) + i; pAnimations[ i + j ].fMaxDist = 150 * 150; // drzwi to z daleka widać /* @@ -5924,7 +5924,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co else if( token == "engine:" && MoverParameters->Power > 0 ) { // plik z dzwiekiem silnika, mnozniki i ofsety amp. i czest. - m_powertrainsounds.engine.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); + m_powertrainsounds.engine.deserialize( parser, sound_type::single, range | amplitude | frequency ); m_powertrainsounds.engine.owner( this ); auto const amplitudedivisor = static_cast( MoverParameters->EngineType == TEngineType::DieselEngine ? 1 : @@ -5939,7 +5939,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co else if( token == "dieselinc:" ) { // dzwiek przy wlazeniu na obroty woodwarda - m_powertrainsounds.engine_revving.deserialize( parser, sound_type::single, sound_parameters::range ); + m_powertrainsounds.engine_revving.deserialize( parser, sound_type::single, range ); m_powertrainsounds.engine_revving.owner( this ); } @@ -5966,7 +5966,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co else if( token == "tractionmotor:" && MoverParameters->Power > 0 ) { // plik z dzwiekiem silnika, mnozniki i ofsety amp. i czest. sound_source motortemplate { sound_placement::external }; - motortemplate.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); + motortemplate.deserialize( parser, sound_type::single, range | amplitude | frequency ); auto const amplitudedivisor { static_cast( MoverParameters->nmax * 60 + MoverParameters->Power * 3 ) }; motortemplate.m_amplitudefactor /= amplitudedivisor; motortemplate.owner( this ); @@ -5994,7 +5994,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co else if( token == "tractionacmotor:" && MoverParameters->Power > 0 ) { // plik z dzwiekiem silnika, mnozniki i ofsety amp. i czest. sound_source motortemplate { sound_placement::external }; - motortemplate.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); + motortemplate.deserialize( parser, sound_type::single, range | amplitude | frequency ); motortemplate.owner( this ); auto &motors { m_powertrainsounds.acmotors }; @@ -6020,13 +6020,13 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co else if( token == "motorblower:" ) { sound_source blowertemplate { sound_placement::engine }; - blowertemplate.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); + blowertemplate.deserialize( parser, sound_type::single, range | amplitude | frequency ); blowertemplate.owner( this ); auto const amplitudedivisor { static_cast( - MoverParameters->MotorBlowers[ end::front ].speed > 0 ? MoverParameters->MotorBlowers[ end::front ].speed * MoverParameters->nmax * 60 + MoverParameters->Power * 3 : + MoverParameters->MotorBlowers[ front ].speed > 0 ? MoverParameters->MotorBlowers[ front ].speed * MoverParameters->nmax * 60 + MoverParameters->Power * 3 : blowertemplate.has_bookends() ? 1 : // NOTE: for motorblowers with fixed speed if the sound has defined bookends we skip revolutions-based part of frequency/volume adjustments - MoverParameters->MotorBlowers[ end::front ].speed * -1 ) }; + MoverParameters->MotorBlowers[ front ].speed * -1 ) }; blowertemplate.m_amplitudefactor /= amplitudedivisor; blowertemplate.m_frequencyfactor /= amplitudedivisor; @@ -6050,13 +6050,13 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co else if( token == "inverter:" ) { // plik z dzwiekiem wentylatora, mnozniki i ofsety amp. i czest. - m_powertrainsounds.inverter.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); + m_powertrainsounds.inverter.deserialize( parser, sound_type::single, range | amplitude | frequency ); m_powertrainsounds.inverter.owner( this ); } else if( token == "ventilator:" ) { // plik z dzwiekiem wentylatora, mnozniki i ofsety amp. i czest. - m_powertrainsounds.rsWentylator.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); + m_powertrainsounds.rsWentylator.deserialize( parser, sound_type::single, range | amplitude | frequency ); m_powertrainsounds.rsWentylator.owner( this ); m_powertrainsounds.rsWentylator.m_amplitudefactor /= MoverParameters->RVentnmax; @@ -6084,13 +6084,13 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co sound.m_frequencyfactor = 0.005; sound.m_frequencyoffset = 1.0; - sound.deserialize( parser, sound_type::single, sound_parameters::range ); + sound.deserialize( parser, sound_type::single, range ); sound.owner( this ); } else if( token == "brakesound:" ) { // hamowanie zwykle: - rsBrake.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency ); + rsBrake.deserialize( parser, sound_type::single, amplitude | frequency ); rsBrake.owner( this ); // NOTE: can't pre-calculate amplitude normalization based on max brake force, as this varies depending on vehicle speed rsBrake.m_frequencyfactor /= 1 + MoverParameters->Vmax; @@ -6098,7 +6098,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co else if( token == "brake:" ) { // plik z piskiem hamulca, mnozniki i ofsety amplitudy. - rsPisk.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude ); + rsPisk.deserialize( parser, sound_type::single, range | amplitude ); rsPisk.owner( this ); if( rsPisk.m_amplitudefactor > 10.f ) { @@ -6150,7 +6150,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co else if( token == "unbrake:" ) { // plik z piskiem hamulca, mnozniki i ofsety amplitudy. rsUnbrake.m_amplitudefactor = 20.0f; - rsUnbrake.deserialize( parser, sound_type::single, sound_parameters::range ); + rsUnbrake.deserialize( parser, sound_type::single, range ); rsUnbrake.owner( this ); } // spring brake sounds @@ -6165,24 +6165,24 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co else if( token == "derail:" ) { // dzwiek przy wykolejeniu - rsDerailment.deserialize( parser, sound_type::single, sound_parameters::range ); + rsDerailment.deserialize( parser, sound_type::single, range ); rsDerailment.owner( this ); } else if( token == "curve:" ) { - rscurve.deserialize( parser, sound_type::single, sound_parameters::range ); + rscurve.deserialize( parser, sound_type::single, range ); rscurve.owner( this ); } else if( token == "horn1:" ) { // pliki z trabieniem - sHorn1.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sHorn1.deserialize( parser, sound_type::multipart, range ); sHorn1.owner( this ); } else if( token == "horn2:" ) { // pliki z trabieniem wysokoton. - sHorn2.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sHorn2.deserialize( parser, sound_type::multipart, range ); sHorn2.owner( this ); // TBD, TODO: move horn selection to ai config file if( iHornWarning ) { @@ -6191,7 +6191,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co } else if( token == "horn3:" ) { - sHorn3.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sHorn3.deserialize( parser, sound_type::multipart, range ); sHorn3.owner( this ); } @@ -6217,26 +6217,26 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co else if( token == "compressor:" ) { // pliki ze sprezarka - sCompressor.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sCompressor.deserialize( parser, sound_type::multipart, range ); sCompressor.owner( this ); } else if( token == "compressoridle:" ) { // pliki ze sprezarka - sCompressorIdle.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sCompressorIdle.deserialize( parser, sound_type::multipart, range ); sCompressorIdle.owner( this ); } else if( token == "converter:" ) { // pliki z przetwornica - sConverter.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sConverter.deserialize( parser, sound_type::multipart, range ); sConverter.owner( this ); } // Dzwiek wentylatora rezystora hamowania else if (token == "brakingresistorventilator:") { - sBRVent.deserialize(parser, sound_type::multipart, sound_parameters::range); + sBRVent.deserialize(parser, sound_type::multipart, range); sBRVent.owner(this); } @@ -6254,21 +6254,21 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co else if( token == "turbo:" ) { // pliki z turbogeneratorem - m_powertrainsounds.engine_turbo.deserialize( parser, sound_type::multipart, sound_parameters::range ); + m_powertrainsounds.engine_turbo.deserialize( parser, sound_type::multipart, range ); m_powertrainsounds.engine_turbo.owner( this ); m_powertrainsounds.engine_turbo.gain( 0 ); } else if( token == "small-compressor:" ) { // pliki z przetwornica - sSmallCompressor.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sSmallCompressor.deserialize( parser, sound_type::multipart, range ); sSmallCompressor.owner( this ); } else if( token == "departuresignal:" ) { // pliki z sygnalem odjazdu sound_source soundtemplate { sound_placement::general, 25.f }; - soundtemplate.deserialize( parser, sound_type::multipart, sound_parameters::range ); + soundtemplate.deserialize( parser, sound_type::multipart, range ); soundtemplate.owner( this ); for( auto &speaker : m_doorspeakers ) { speaker.departure_signal = soundtemplate; @@ -6373,20 +6373,20 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co } else if( token == "sand:" ) { - sSand.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sSand.deserialize( parser, sound_type::multipart, range ); sSand.owner( this ); } else if( token == "releaser:" ) { // pliki z odluzniaczem - sReleaser.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sReleaser.deserialize( parser, sound_type::multipart, range ); sReleaser.owner( this ); } else if( token == "outernoise:" ) { // szum podczas jazdy: sound_source noisetemplate{ sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE }; - noisetemplate.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, MoverParameters->Vmax ); + noisetemplate.deserialize( parser, sound_type::single, amplitude | frequency, MoverParameters->Vmax ); noisetemplate.owner( this ); noisetemplate.m_amplitudefactor /= 1 + MoverParameters->Vmax; @@ -6425,7 +6425,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co else if( token == "wheelflat:" ) { // szum podczas jazdy: - m_wheelflat.deserialize( parser, sound_type::single, sound_parameters::frequency ); + m_wheelflat.deserialize( parser, sound_type::single, frequency ); m_wheelflat.owner( this ); } @@ -6518,7 +6518,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co || sides == "left" ) { // left... auto const location { glm::vec3 { MoverParameters->Dim.W * 0.5f, MoverParameters->Dim.H * 0.5f, offset } }; - door.placement = side::left; + door.placement = left; door.rsDoorClose.offset( location ); door.rsDoorOpen.offset( location ); door.lock.offset( location ); @@ -6532,7 +6532,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co || sides == "right" ) { // ...and right auto const location { glm::vec3 { MoverParameters->Dim.W * -0.5f, 2.f, offset } }; - door.placement = side::right; + door.placement = right; door.rsDoorClose.offset( location ); door.rsDoorOpen.offset( location ); door.lock.offset( location ); @@ -6620,7 +6620,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co m_powertrainsounds.engine_shutdown.owner(this); } else if( token == "engageslippery:" ) { // tarcie tarcz sprzegla: - m_powertrainsounds.rsEngageSlippery.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency ); + m_powertrainsounds.rsEngageSlippery.deserialize( parser, sound_type::single, amplitude | frequency ); m_powertrainsounds.rsEngageSlippery.owner( this ); m_powertrainsounds.rsEngageSlippery.m_frequencyfactor /= 1 + MoverParameters->nmax; @@ -6639,7 +6639,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co } else if (token == "retarder:") { - m_powertrainsounds.retarder.deserialize(parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency); + m_powertrainsounds.retarder.deserialize(parser, sound_type::single, amplitude | frequency); m_powertrainsounds.retarder.owner(this); } else if( token == "linebreakerclose:" ) { @@ -6693,7 +6693,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co } else if( token == "slipperysound:" ) { // sanie: - rsSlippery.deserialize( parser, sound_type::single, sound_parameters::amplitude ); + rsSlippery.deserialize( parser, sound_type::single, amplitude ); rsSlippery.owner( this ); rsSlippery.m_amplitudefactor /= 1 + MoverParameters->Vmax; @@ -7003,7 +7003,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co } // other sounds if( true == m_wheelflat.empty() ) { - m_wheelflat.deserialize( "lomotpodkucia 0.23 0.0", sound_type::single, sound_parameters::frequency ); + m_wheelflat.deserialize( "lomotpodkucia 0.23 0.0", sound_type::single, frequency ); m_wheelflat.owner( this ); } if( true == rscurve.empty() ) { @@ -7063,43 +7063,43 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co } // couplers auto const frontcoupleroffset { glm::vec3{ 0.f, 1.f, MoverParameters->Dim.L * 0.5f } }; - m_couplersounds[ end::front ].attach_coupler.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].attach_brakehose.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].attach_mainhose.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].attach_control.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].attach_gangway.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].attach_heating.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].detach_coupler.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].detach_brakehose.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].detach_mainhose.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].detach_control.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].detach_gangway.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].detach_heating.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].dsbCouplerStretch.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].dsbCouplerStretch_loud.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].dsbBufferClamp.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].dsbBufferClamp_loud.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].dsbAdapterAttach.offset( frontcoupleroffset ); - m_couplersounds[ end::front ].dsbAdapterRemove.offset( frontcoupleroffset ); + m_couplersounds[ front ].attach_coupler.offset( frontcoupleroffset ); + m_couplersounds[ front ].attach_brakehose.offset( frontcoupleroffset ); + m_couplersounds[ front ].attach_mainhose.offset( frontcoupleroffset ); + m_couplersounds[ front ].attach_control.offset( frontcoupleroffset ); + m_couplersounds[ front ].attach_gangway.offset( frontcoupleroffset ); + m_couplersounds[ front ].attach_heating.offset( frontcoupleroffset ); + m_couplersounds[ front ].detach_coupler.offset( frontcoupleroffset ); + m_couplersounds[ front ].detach_brakehose.offset( frontcoupleroffset ); + m_couplersounds[ front ].detach_mainhose.offset( frontcoupleroffset ); + m_couplersounds[ front ].detach_control.offset( frontcoupleroffset ); + m_couplersounds[ front ].detach_gangway.offset( frontcoupleroffset ); + m_couplersounds[ front ].detach_heating.offset( frontcoupleroffset ); + m_couplersounds[ front ].dsbCouplerStretch.offset( frontcoupleroffset ); + m_couplersounds[ front ].dsbCouplerStretch_loud.offset( frontcoupleroffset ); + m_couplersounds[ front ].dsbBufferClamp.offset( frontcoupleroffset ); + m_couplersounds[ front ].dsbBufferClamp_loud.offset( frontcoupleroffset ); + m_couplersounds[ front ].dsbAdapterAttach.offset( frontcoupleroffset ); + m_couplersounds[ front ].dsbAdapterRemove.offset( frontcoupleroffset ); auto const rearcoupleroffset { glm::vec3{ 0.f, 1.f, MoverParameters->Dim.L * -0.5f } }; - m_couplersounds[ end::rear ].attach_coupler.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].attach_brakehose.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].attach_mainhose.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].attach_control.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].attach_gangway.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].attach_heating.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].detach_coupler.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].detach_brakehose.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].detach_mainhose.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].detach_control.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].detach_gangway.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].detach_heating.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].dsbCouplerStretch.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].dsbCouplerStretch_loud.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].dsbBufferClamp.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].dsbBufferClamp_loud.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].dsbAdapterAttach.offset( rearcoupleroffset ); - m_couplersounds[ end::rear ].dsbAdapterRemove.offset( rearcoupleroffset ); + m_couplersounds[ rear ].attach_coupler.offset( rearcoupleroffset ); + m_couplersounds[ rear ].attach_brakehose.offset( rearcoupleroffset ); + m_couplersounds[ rear ].attach_mainhose.offset( rearcoupleroffset ); + m_couplersounds[ rear ].attach_control.offset( rearcoupleroffset ); + m_couplersounds[ rear ].attach_gangway.offset( rearcoupleroffset ); + m_couplersounds[ rear ].attach_heating.offset( rearcoupleroffset ); + m_couplersounds[ rear ].detach_coupler.offset( rearcoupleroffset ); + m_couplersounds[ rear ].detach_brakehose.offset( rearcoupleroffset ); + m_couplersounds[ rear ].detach_mainhose.offset( rearcoupleroffset ); + m_couplersounds[ rear ].detach_control.offset( rearcoupleroffset ); + m_couplersounds[ rear ].detach_gangway.offset( rearcoupleroffset ); + m_couplersounds[ rear ].detach_heating.offset( rearcoupleroffset ); + m_couplersounds[ rear ].dsbCouplerStretch.offset( rearcoupleroffset ); + m_couplersounds[ rear ].dsbCouplerStretch_loud.offset( rearcoupleroffset ); + m_couplersounds[ rear ].dsbBufferClamp.offset( rearcoupleroffset ); + m_couplersounds[ rear ].dsbBufferClamp_loud.offset( rearcoupleroffset ); + m_couplersounds[ rear ].dsbAdapterAttach.offset( rearcoupleroffset ); + m_couplersounds[ rear ].dsbAdapterRemove.offset( rearcoupleroffset ); } TModel3d * @@ -7232,18 +7232,18 @@ void TDynamicObject::Damage(char flag) void TDynamicObject::SetLights() { auto const isfrontcaboccupied { MoverParameters->CabOccupied * DirectionGet() >= 0 }; - int const automaticmarkers { MoverParameters->CabActive == 0 && MoverParameters->InactiveCabFlag & activation::redmarkers - ? light::redmarker_left + light::redmarker_right : 0 }; - int const front { ( isfrontcaboccupied ? end::front : end::rear ) }; + int const automaticmarkers { MoverParameters->CabActive == 0 && MoverParameters->InactiveCabFlag & redmarkers + ? redmarker_left + redmarker_right : 0 }; + int const front { ( isfrontcaboccupied ? end::front : rear ) }; int const rear { 1 - front }; auto const lightpos { MoverParameters->LightsPos - 1 }; auto const frontlights { automaticmarkers > 0 ? automaticmarkers : MoverParameters->Lights[ front ][ lightpos ] }; auto const rearlights { automaticmarkers > 0 ? automaticmarkers : MoverParameters->Lights[ rear ][ lightpos ] }; - auto *vehicle { GetFirstDynamic( MoverParameters->CabOccupied >= 0 ? end::front : end::rear, coupling::control ) }; + auto *vehicle { GetFirstDynamic( MoverParameters->CabOccupied >= 0 ? end::front : end::rear, control ) }; while( vehicle != nullptr ) { // set lights on given side if there's no coupling with another vehicle, turn them off otherwise - auto const *frontvehicle{(isfrontcaboccupied ? vehicle->Prev(coupling::coupler) : vehicle->Next(coupling::coupler))}; - auto const *rearvehicle{(isfrontcaboccupied ? vehicle->Next(coupling::coupler) : vehicle->Prev(coupling::coupler))}; + auto const *frontvehicle{(isfrontcaboccupied ? vehicle->Prev(coupler) : vehicle->Next(coupler))}; + auto const *rearvehicle{(isfrontcaboccupied ? vehicle->Next(coupler) : vehicle->Prev(coupler))}; if (MoverParameters->LightsPos == 18) { @@ -7254,7 +7254,7 @@ void TDynamicObject::SetLights() { vehicle->RaLightsSet( frontvehicle == nullptr ? frontlights : 0, rearvehicle == nullptr ? rearlights : 0 ); - vehicle = isfrontcaboccupied ? vehicle->Next(coupling::control) : vehicle->Prev(coupling::control); + vehicle = isfrontcaboccupied ? vehicle->Next(control) : vehicle->Prev(control); } }; @@ -7264,7 +7264,7 @@ void TDynamicObject::RaLightsSet(int head, int rear) // pojazdu if (!MoverParameters) return; // może tego nie być na początku - if (rear == ( light::redmarker_left | light::redmarker_right | light::rearendsignals ) ) + if (rear == ( redmarker_left | redmarker_right | rearendsignals ) ) { // jeśli koniec pociągu, to trzeba ustalić, czy // jest tam czynna lokomotywa // EN57 może nie mieć końcówek od środka członu @@ -7272,27 +7272,27 @@ void TDynamicObject::RaLightsSet(int head, int rear) if (!MoverParameters->DirActive) // jeśli nie ma ustawionego kierunku { // jeśli ma zarówno światła jak i końcówki, ustalić, czy jest w stanie aktywnym // np. lokomotywa na zimno będzie mieć końcówki a nie światła - rear = light::rearendsignals; // tablice blaszane + rear = rearendsignals; // tablice blaszane // trzeba to uzależnić od "załączenia baterii" w pojeździe } - if( rear == ( light::redmarker_left | light::redmarker_right | light::rearendsignals ) ) // jeśli nadal obydwie możliwości + if( rear == ( redmarker_left | redmarker_right | rearendsignals ) ) // jeśli nadal obydwie możliwości if( iInventory[ ( iDirection ? end::rear : - end::front ) ] & ( light::redmarker_left | light::redmarker_right ) ) { + front ) ] & ( redmarker_left | redmarker_right ) ) { // czy ma jakieś światła czerowone od danej strony - rear = light::redmarker_left | light::redmarker_right; // dwa światła czerwone + rear = redmarker_left | redmarker_right; // dwa światła czerwone } else { - rear = light::rearendsignals; // tablice blaszane + rear = rearendsignals; // tablice blaszane } } // w zależności od kierunku pojazdu w składzie if( head >= 0 ) { - auto const vehicleend { iDirection > 0 ? end::front : end::rear }; + auto const vehicleend { iDirection > 0 ? front : end::rear }; MoverParameters->iLights[ vehicleend ] = head & iInventory[vehicleend]; - bool tLeft = MoverParameters->iLights[vehicleend] & (light::auxiliary_left | light::headlight_left); // roboczo czy jakiekolwiek swiatlo z lewej jest zapalone - bool tRight = MoverParameters->iLights[vehicleend] & (light::auxiliary_right | light::headlight_right); // a tu z prawej + bool tLeft = MoverParameters->iLights[vehicleend] & (auxiliary_left | headlight_left); // roboczo czy jakiekolwiek swiatlo z lewej jest zapalone + bool tRight = MoverParameters->iLights[vehicleend] & (auxiliary_right | headlight_right); // a tu z prawej if (Controller == Humandriver) { const int ¤tDimPos = MoverParameters->modernDimmerPosition; @@ -7311,7 +7311,7 @@ void TDynamicObject::RaLightsSet(int head, int rear) DimHeadlights = false; switch (MoverParameters->CabActive) { - case end::front: + case front: HeadlightsAoff = true; break; case end::rear: @@ -7325,7 +7325,7 @@ void TDynamicObject::RaLightsSet(int head, int rear) { switch (MoverParameters->CabActive) { - case end::front: + case front: HeadlightsAoff = false; break; case end::rear: @@ -7348,14 +7348,14 @@ void TDynamicObject::RaLightsSet(int head, int rear) } if( rear >= 0 ) { - auto const vehicleend{ iDirection > 0 ? end::rear : end::front }; + auto const vehicleend{ iDirection > 0 ? end::rear : front }; MoverParameters->iLights[ vehicleend ] = rear & iInventory[vehicleend]; } }; void TDynamicObject::SetLightDimmings() { - auto const vehicleend{iDirection > 0 ? end::front : end::rear}; + auto const vehicleend{iDirection > 0 ? front : rear}; if (Controller == Humandriver) { @@ -7375,10 +7375,10 @@ void TDynamicObject::SetLightDimmings() DimHeadlights = false; switch (vehicleend) { - case end::front: + case front: HeadlightsAoff = true; break; - case end::rear: + case rear: HeadlightsBoff = true; break; default: @@ -7389,10 +7389,10 @@ void TDynamicObject::SetLightDimmings() { switch (vehicleend) { - case end::front: + case front: HeadlightsAoff = false; break; - case end::rear: + case rear: HeadlightsBoff = false; break; default: @@ -7417,24 +7417,24 @@ void TDynamicObject::SetLightDimmings() bool TDynamicObject::has_signal_pc1_on() const { - auto const vehicleend { iDirection > 0 ? end::front : end::rear }; + auto const vehicleend { iDirection > 0 ? front : rear }; auto const equippedlights { iInventory[ vehicleend ] }; - auto const pattern { equippedlights & ( light::headlight_left | light::headlight_right | light::headlight_upper ) }; - auto const patternfallback { equippedlights & ( light::auxiliary_left | light::auxiliary_right | light::headlight_upper ) }; - auto const hasauxiliarylights { ( equippedlights & ( light::auxiliary_left | light::auxiliary_right ) ) != 0 }; + auto const pattern { equippedlights & ( headlight_left | headlight_right | headlight_upper ) }; + auto const patternfallback { equippedlights & ( auxiliary_left | auxiliary_right | headlight_upper ) }; + auto const hasauxiliarylights { ( equippedlights & ( auxiliary_left | auxiliary_right ) ) != 0 }; auto const activelights { MoverParameters->iLights[ vehicleend ] }; return (pattern != 0 && activelights == pattern) || (hasauxiliarylights && activelights == patternfallback) || - (pattern == 0 && patternfallback == 0 && activelights == light::rearendsignals); // pc4 + (pattern == 0 && patternfallback == 0 && activelights == rearendsignals); // pc4 } bool TDynamicObject::has_signal_pc2_on() const { - auto const vehicleend { iDirection > 0 ? end::front : end::rear }; + auto const vehicleend { iDirection > 0 ? front : rear }; auto const equippedlights { iInventory[ vehicleend ] }; - auto const pattern { equippedlights & ( light::redmarker_left | light::headlight_right | light::headlight_upper ) }; - auto const patternfallback { equippedlights & ( light::redmarker_left | light::auxiliary_right | light::headlight_upper ) }; - auto const hasauxiliarylights { ( equippedlights & ( light::auxiliary_left | light::auxiliary_right ) ) != 0 }; + auto const pattern { equippedlights & ( redmarker_left | headlight_right | headlight_upper ) }; + auto const patternfallback { equippedlights & ( redmarker_left | auxiliary_right | headlight_upper ) }; + auto const hasauxiliarylights { ( equippedlights & ( auxiliary_left | auxiliary_right ) ) != 0 }; auto const activelights { MoverParameters->iLights[ vehicleend ] }; return activelights == pattern || (hasauxiliarylights && activelights == patternfallback); @@ -7442,10 +7442,10 @@ bool TDynamicObject::has_signal_pc2_on() const { bool TDynamicObject::has_signal_pc5_on() const { - auto const vehicleend { iDirection > 0 ? end::rear : end::front }; + auto const vehicleend { iDirection > 0 ? rear : front }; auto const equippedlights { iInventory[ vehicleend ] }; - auto const pattern { equippedlights & ( light::redmarker_left | light::redmarker_right ) }; - auto const patternfallback { equippedlights & light::rearendsignals }; + auto const pattern { equippedlights & ( redmarker_left | redmarker_right ) }; + auto const patternfallback { equippedlights & rearendsignals }; auto const activelights { MoverParameters->iLights[ vehicleend ] }; return (pattern != 0 && activelights == pattern) || (patternfallback != 0 && activelights == patternfallback); @@ -7530,7 +7530,7 @@ TDynamicObject * TDynamicObject::Neighbour(int &dir) { auto *neighbour { ( - MoverParameters->Couplers[ dir ].CouplingFlag != coupling::faux ? + MoverParameters->Couplers[ dir ].CouplingFlag != faux ? MoverParameters->Neighbours[ dir ].vehicle : nullptr ) }; // nowa wartość @@ -7543,7 +7543,7 @@ TDynamicObject::Neighbour(int &dir) { void TDynamicObject::update_neighbours() { - for( int end = end::front; end <= end::rear; ++end ) { + for( int end = front; end <= rear; ++end ) { auto &neighbour { MoverParameters->Neighbours[ end ] }; auto const &coupler { MoverParameters->Couplers[ end ] }; @@ -7591,7 +7591,7 @@ TDynamicObject::update_neighbours() { std::tuple TDynamicObject::find_vehicle( int const Direction, double const Distance ) const { - auto direction { ( Direction == end::front ? 1 : -1 ) }; + auto direction { ( Direction == front ? 1 : -1 ) }; auto const initialdirection { direction }; // zapamiętanie kierunku poszukiwań na torze początkowym, względem sprzęgów auto const *track { RaTrackGet() }; @@ -7601,7 +7601,7 @@ TDynamicObject::find_vehicle( int const Direction, double const Distance ) const } // (teraz względem toru) - auto const mycoupler { ( initialdirection < 0 ? end::rear : end::front ) }; // numer sprzęgu do podłączenia w obiekcie szukajacym + auto const mycoupler { ( initialdirection < 0 ? rear : front ) }; // numer sprzęgu do podłączenia w obiekcie szukajacym auto foundcoupler { -1 }; // numer sprzęgu w znalezionym obiekcie (znaleziony wypełni) auto distance { 0.0 }; // przeskanowana odleglość; odległość do zawalidrogi auto *foundobject { ABuFindObject( foundcoupler, distance, track, direction, mycoupler ) }; // zaczynamy szukać na tym samym torze @@ -7685,8 +7685,8 @@ TDynamicObject * TDynamicObject::FindPowered() // jeśli silnikowy będzie zapięty odwrotnie (tzn. -1), to i tak powinno jeździć dobrze // również hamowanie wykonuje się zaworem w członie, a nie w silnikowym... auto const coupling { MoverParameters->TrainType == dt_EZT || MoverParameters->TrainType == dt_DMU ? - coupling::permanent : - coupling::control }; + permanent : + control }; auto *lookup { find_vehicle( @@ -7701,7 +7701,7 @@ TDynamicObject * TDynamicObject::FindPantographCarrier() { // try first within a single unit, broaden to all vehicles under our control if first attempt fails - std::array const couplings = { coupling::permanent, coupling::control }; + std::array const couplings = { permanent, control }; for( auto const coupling : couplings ) { auto *result = @@ -7727,7 +7727,7 @@ void TDynamicObject::ParamSet(int what, int into) // dla 8 różnych if (what & 1) // na razie mamy lewe oraz prawe, czyli używamy maskę 1=lewe, // 2=prawe, 3=wszystkie - if( MoverParameters->Doors.instances[side::left].is_open ) + if( MoverParameters->Doors.instances[left].is_open ) { // są otwarte if (!into) // jeśli zamykanie { @@ -7742,7 +7742,7 @@ void TDynamicObject::ParamSet(int what, int into) } } if (what & 2) // prawe działają niezależnie od lewych - if( MoverParameters->Doors.instances[side::right].is_open ) + if( MoverParameters->Doors.instances[right].is_open ) { // są otwarte if (!into) // jeśli zamykanie { @@ -8076,7 +8076,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub oil_pump .pitch( oil_pump.m_frequencyoffset + oil_pump.m_frequencyfactor * 1.f ) .gain( oil_pump.m_amplitudeoffset + oil_pump.m_amplitudefactor * 1.f ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { oil_pump.stop(); @@ -8086,7 +8086,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub fuel_pump .pitch( fuel_pump.m_frequencyoffset + fuel_pump.m_frequencyfactor * 1.f ) .gain( fuel_pump.m_amplitudeoffset + fuel_pump.m_amplitudefactor * 1.f ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { fuel_pump.stop(); @@ -8096,7 +8096,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub water_pump .pitch( water_pump.m_frequencyoffset + water_pump.m_frequencyfactor * 1.f ) .gain( water_pump.m_amplitudeoffset + water_pump.m_amplitudefactor * 1.f ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { water_pump.stop(); @@ -8106,7 +8106,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub water_heater .pitch( water_heater.m_frequencyoffset + water_heater.m_frequencyfactor * 1.f ) .gain( water_heater.m_amplitudeoffset + water_heater.m_amplitudefactor * 1.f ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { water_heater.stop(); @@ -8122,7 +8122,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub engine_ignition .pitch( engine_ignition.m_frequencyoffset + engine_ignition.m_frequencyfactor * 1.f ) .gain( engine_ignition.m_amplitudeoffset + engine_ignition.m_amplitudefactor * 1.f ) - .play( sound_flags::exclusive ); + .play( exclusive ); // main circuit activation linebreaker_close .pitch( linebreaker_close.m_frequencyoffset + linebreaker_close.m_frequencyfactor * 1.f ) @@ -8134,7 +8134,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub engine_ignition.stop(); engine_shutdown.pitch( engine_shutdown.m_frequencyoffset + engine_shutdown.m_frequencyfactor * 1.f ) .gain( engine_shutdown.m_amplitudeoffset + engine_shutdown.m_amplitudefactor * 1.f ) - .play( sound_flags::exclusive ); + .play( exclusive ); // main circuit deactivation linebreaker_open .pitch( linebreaker_open.m_frequencyoffset + linebreaker_open.m_frequencyfactor * 1.f ) @@ -8223,7 +8223,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub engine_revving .pitch( enginerevfrequency ) .gain( enginerevvolume ) - .play( sound_flags::exclusive ); + .play( exclusive ); } else { engine_revving.stop(); @@ -8238,7 +8238,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub engine .pitch( frequency ) .gain( enginevolume ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } // enginevolume > 0.05 } else { @@ -8252,7 +8252,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub fake_engine .pitch(fake_engine.m_frequencyoffset + power * fake_engine.m_frequencyfactor) .gain(fake_engine.m_amplitudeoffset + power * fake_engine.m_amplitudefactor) - .play(sound_flags::exclusive | sound_flags::looping); + .play(exclusive | looping); } else { fake_engine.stop(); @@ -8284,7 +8284,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub .gain( volume ); if( volume > 0.05 ) { - engine_turbo.play( sound_flags::exclusive | sound_flags::looping ); + engine_turbo.play( exclusive | looping ); } else { engine_turbo.stop(); @@ -8304,7 +8304,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub rsEngageSlippery .pitch( frequency ) .gain( volume ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { rsEngageSlippery.stop(); @@ -8318,7 +8318,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub .gain(retarder.m_amplitudeoffset + Vehicle.hydro_R_Fill * retarder.m_amplitudefactor); if (retarder.gain() > 0.01 && speed > 1 && Vehicle.hydro_R_ClutchActive) { - retarder.play(sound_flags::exclusive | sound_flags::looping); + retarder.play(exclusive | looping); } else { retarder.stop(); @@ -8399,7 +8399,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub motor .pitch( frequency ) .gain( motor_volume ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } } else { @@ -8427,7 +8427,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub motor .pitch( motor.m_frequencyoffset + motor.m_frequencyfactor * Vehicle.InverterFrequency ) .gain( motor.m_amplitudeoffset + motor.m_amplitudefactor * std::sqrt( std::abs( Vehicle.eimv_pr ) ) ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } } else { @@ -8441,18 +8441,18 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub if( false == motorblowers.empty() ) { for( auto &blowersound : motorblowers ) { // match the motor blower and the sound source based on whether they're located in the front or the back of the vehicle - auto const &blower { Vehicle.MotorBlowers[ ( blowersound.offset().z > 0 ? end::front : end::rear ) ] }; + auto const &blower { Vehicle.MotorBlowers[ ( blowersound.offset().z > 0 ? front : rear ) ] }; // TODO: for the sounds with provided bookends invoke stop() when the stop is triggered and revolutions start dropping, instead of after full stop if( blower.revolutions > 1 ) { // NOTE: for motorblowers with fixed speed if the sound has defined bookends we skip revolutions-based part of frequency/volume adjustments - auto const revolutionmodifier { Vehicle.MotorBlowers[end::front].speed < 0.f && blowersound.has_bookends() ? 1.f : blower.revolutions }; + auto const revolutionmodifier { Vehicle.MotorBlowers[front].speed < 0.f && blowersound.has_bookends() ? 1.f : blower.revolutions }; blowersound .pitch( true == blowersound.is_combined() ? blower.revolutions * 0.01f : blowersound.m_frequencyoffset + blowersound.m_frequencyfactor * revolutionmodifier ) .gain( blowersound.m_amplitudeoffset + blowersound.m_amplitudefactor * revolutionmodifier ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { blowersound.stop(); @@ -8468,7 +8468,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub inverter .pitch( inverter.m_frequencyoffset + inverter.m_frequencyfactor * Vehicle.InverterFrequency ) .gain( volume ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { inverter.stop(); @@ -8480,7 +8480,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub rsWentylator .pitch( rsWentylator.m_frequencyoffset + rsWentylator.m_frequencyfactor * Vehicle.RventRot ) .gain( rsWentylator.m_amplitudeoffset + rsWentylator.m_amplitudefactor * Vehicle.RventRot ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { // ...otherwise shut down the sound @@ -8495,7 +8495,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub radiator_fan .pitch( 0.5 + radiator_fan.m_frequencyoffset + radiator_fan.m_frequencyfactor * Vehicle.dizel_heat.rpmw * 0.01 ) .gain( 0.5 + radiator_fan.m_amplitudeoffset + 0.5 * radiator_fan.m_amplitudefactor * Vehicle.dizel_heat.rpmw * 0.01 ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { // ...otherwise shut down the sound @@ -8507,7 +8507,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub radiator_fan_aux .pitch( 0.5 + radiator_fan_aux.m_frequencyoffset + radiator_fan_aux.m_frequencyfactor * Vehicle.dizel_heat.rpmw2 * 0.01 ) .gain( 0.5 + radiator_fan_aux.m_amplitudeoffset + 0.5 * radiator_fan_aux.m_amplitudefactor * Vehicle.dizel_heat.rpmw2 * 0.01 ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { // ...otherwise shut down the sound @@ -8517,9 +8517,9 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub // relay sounds auto const soundflags { Vehicle.SoundFlag }; - if( TestFlag( soundflags, sound::relay ) ) { + if( TestFlag( soundflags, relay ) ) { // przekaznik - gdy bezpiecznik, automatyczny rozruch itp - if( true == TestFlag( soundflags, sound::shuntfield ) ) { + if( true == TestFlag( soundflags, shuntfield ) ) { // shunt field motor_shuntfield .pitch( @@ -8528,15 +8528,15 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub motor_shuntfield.m_frequencyoffset + motor_shuntfield.m_frequencyfactor * 1.f ) .gain( motor_shuntfield.m_amplitudeoffset + ( - true == TestFlag( soundflags, sound::loud ) ? + true == TestFlag( soundflags, loud ) ? 1.0f : 0.8f ) * motor_shuntfield.m_amplitudefactor ) .play(); } - else if( true == TestFlag( soundflags, sound::parallel ) ) { + else if( true == TestFlag( soundflags, parallel ) ) { // parallel mode - if( TestFlag( soundflags, sound::loud ) ) { + if( TestFlag( soundflags, loud ) ) { dsbWejscie_na_bezoporow.play(); } else { @@ -8552,7 +8552,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub motor_relay.m_frequencyoffset + motor_relay.m_frequencyfactor * 1.f ) .gain( motor_relay.m_amplitudeoffset + ( - true == TestFlag( soundflags, sound::loud ) ? + true == TestFlag( soundflags, loud ) ? 1.0f : 0.8f ) * motor_relay.m_amplitudefactor ) @@ -8564,7 +8564,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub transmission .pitch( transmission.m_frequencyoffset + transmission.m_frequencyfactor * Vehicle.Vel ) .gain( transmission.m_amplitudeoffset + transmission.m_amplitudefactor * Vehicle.Vel ) - .play( sound_flags::exclusive | sound_flags::looping ); + .play( exclusive | looping ); } else { transmission.stop(); diff --git a/vehicle/DynObj.h b/vehicle/DynObj.h index f8f2ce78..77b35b81 100644 --- a/vehicle/DynObj.h +++ b/vehicle/DynObj.h @@ -217,12 +217,12 @@ public: std::string asDestination; // dokąd pojazd ma być kierowany "(stacja):(tor)" glm::dmat4 mMatrix; // macierz przekształcenia do renderowania modeli TMoverParameters *MoverParameters; // parametry fizyki ruchu oraz przeliczanie - inline TDynamicObject *NextConnected() { return MoverParameters->Neighbours[ end::rear ].vehicle; }; // pojazd podłączony od strony sprzęgu 1 (kabina -1) - inline TDynamicObject *PrevConnected() { return MoverParameters->Neighbours[ end::front ].vehicle; }; // pojazd podłączony od strony sprzęgu 0 (kabina 1) - inline TDynamicObject *NextConnected() const { return MoverParameters->Neighbours[ end::rear ].vehicle; }; // pojazd podłączony od strony sprzęgu 1 (kabina -1) - inline TDynamicObject *PrevConnected() const { return MoverParameters->Neighbours[ end::front ].vehicle; }; // pojazd podłączony od strony sprzęgu 0 (kabina 1) - inline int NextConnectedNo() const { return MoverParameters->Neighbours[ end::rear ].vehicle_end; } - inline int PrevConnectedNo() const { return MoverParameters->Neighbours[ end::front ].vehicle_end; } + inline TDynamicObject *NextConnected() { return MoverParameters->Neighbours[ rear ].vehicle; }; // pojazd podłączony od strony sprzęgu 1 (kabina -1) + inline TDynamicObject *PrevConnected() { return MoverParameters->Neighbours[ front ].vehicle; }; // pojazd podłączony od strony sprzęgu 0 (kabina 1) + inline TDynamicObject *NextConnected() const { return MoverParameters->Neighbours[ rear ].vehicle; }; // pojazd podłączony od strony sprzęgu 1 (kabina -1) + inline TDynamicObject *PrevConnected() const { return MoverParameters->Neighbours[ front ].vehicle; }; // pojazd podłączony od strony sprzęgu 0 (kabina 1) + inline int NextConnectedNo() const { return MoverParameters->Neighbours[ rear ].vehicle_end; } + inline int PrevConnectedNo() const { return MoverParameters->Neighbours[ front ].vehicle_end; } // Dev tools void Reload(); @@ -618,7 +618,7 @@ private: bool HeadlightsAoff{false}; // wygaszone swiatelki A bool HeadlightsBoff{false}; // wygaszone swiatelki B // checks whether there's unbroken connection of specified type to specified vehicle - bool is_connected( TDynamicObject const *Vehicle, coupling const Coupling = coupling::coupler ) const; + bool is_connected( TDynamicObject const *Vehicle, coupling const Coupling = coupler ) const; TDynamicObject * PrevAny() const; TDynamicObject * Prev(int C = -1) const; TDynamicObject * Next(int C = -1) const; diff --git a/vehicle/Gauge.cpp b/vehicle/Gauge.cpp index 75b62ef4..9dd97766 100644 --- a/vehicle/Gauge.cpp +++ b/vehicle/Gauge.cpp @@ -228,7 +228,7 @@ void TGauge::Load( cParser &Parser, TDynamicObject const *Owner, double const mu }; bool -TGauge::Load_mapping( cParser &Input, TGauge::scratch_data &Scratchpad ) { +TGauge::Load_mapping( cParser &Input, scratch_data &Scratchpad ) { // token can be a key or block end auto const key { Input.getToken( true, "\n\r\t ,;" ) }; @@ -316,7 +316,7 @@ TGauge::UpdateValue( float fNewDesired ) { } else { // toggle the control to continous range/exclusive sound mode from now on - m_soundtype = sound_flags::exclusive; + m_soundtype = exclusive; } // ...and if there isn't any, fall back on the basic set... auto const currentvalue = GetValue(); diff --git a/vehicle/Gauge.h b/vehicle/Gauge.h index bf0f83c3..b9baa7c2 100644 --- a/vehicle/Gauge.h +++ b/vehicle/Gauge.h @@ -78,7 +78,7 @@ private: // methods // imports member data pair from the config file bool - Load_mapping( cParser &Input, TGauge::scratch_data &Scratchpad ); + Load_mapping( cParser &Input, scratch_data &Scratchpad ); float GetScaledValue() const; void diff --git a/vehicle/Train.cpp b/vehicle/Train.cpp index c25dac2f..bddbc53b 100644 --- a/vehicle/Train.cpp +++ b/vehicle/Train.cpp @@ -720,29 +720,29 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("converter_overload", mvControlled->ConvOvldFlag); dict->insert("compress", mvControlled->CompressorFlag); dict->insert("pant_compressor", mvPantographUnit->PantCompFlag); - dict->insert("lights_front", mvOccupied->iLights[end::front]); - dict->insert("lights_rear", mvOccupied->iLights[end::rear]); + dict->insert("lights_front", mvOccupied->iLights[front]); + dict->insert("lights_rear", mvOccupied->iLights[rear]); dict->insert("off_from_dimmer", mvOccupied->dimPositions[mvOccupied->modernDimmerPosition].isOff); dict->insert("lights_compartments", mvOccupied->CompartmentLights.is_active || mvOccupied->CompartmentLights.is_disabled); if (Dynamic()->Mechanik) { auto const *controller{Dynamic()->Mechanik}; - auto const cabmodifier{cab_to_end() == end::front ? 1 : -1}; + auto const cabmodifier{cab_to_end() == front ? 1 : -1}; auto const traindirection{controller->Direction() * cabmodifier}; - auto const *frontvehicle{controller->Vehicle(traindirection >= 0 ? end::front : end::rear)}; - auto const *rearvehicle{controller->Vehicle(traindirection >= 0 ? end::rear : end::front)}; + auto const *frontvehicle{controller->Vehicle(traindirection >= 0 ? front : rear)}; + auto const *rearvehicle{controller->Vehicle(traindirection >= 0 ? rear : front)}; auto const frontvehicledirection{(frontvehicle->DirectionGet() == controller->Vehicle()->DirectionGet() ? 1 : -1)}; auto const rearvehicledirection{(rearvehicle->DirectionGet() == controller->Vehicle()->DirectionGet() ? 1 : -1)}; - auto const fronttrainlights{frontvehicle->MoverParameters->iLights[frontvehicledirection * cabmodifier >= 0 ? end::front : end::rear]}; - auto const reartrainlights{rearvehicle->MoverParameters->iLights[rearvehicledirection * cabmodifier >= 0 ? end::rear : end::front]}; + auto const fronttrainlights{frontvehicle->MoverParameters->iLights[frontvehicledirection * cabmodifier >= 0 ? front : rear]}; + auto const reartrainlights{rearvehicle->MoverParameters->iLights[rearvehicledirection * cabmodifier >= 0 ? rear : front]}; dict->insert("lights_train_front", fronttrainlights); dict->insert("lights_train_rear", reartrainlights); } else { // fallback, in the unlikely case we lose the controller - dict->insert("lights_train_front", mvOccupied->iLights[end::front]); - dict->insert("lights_train_rear", mvOccupied->iLights[end::rear]); + dict->insert("lights_train_front", mvOccupied->iLights[front]); + dict->insert("lights_train_rear", mvOccupied->iLights[rear]); } // reverser dict->insert("direction", mvOccupied->DirActive); @@ -793,8 +793,8 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("radio_volume", m_radiovolume); dict->insert("door_lock", mvOccupied->Doors.lock_enabled); dict->insert("door_step", mvOccupied->Doors.step_enabled); - dict->insert("door_permit_left", mvOccupied->Doors.instances[side::left].open_permit); - dict->insert("door_permit_right", mvOccupied->Doors.instances[side::right].open_permit); + dict->insert("door_permit_left", mvOccupied->Doors.instances[left].open_permit); + dict->insert("door_permit_right", mvOccupied->Doors.instances[right].open_permit); // movement data dict->insert("velocity", std::abs(mvOccupied->Vel)); dict->insert("tractionforce", std::abs(mvOccupied->Ft)); @@ -850,7 +850,7 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const } const bool kier = DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0; - const TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->CabOccupied < 0 ? end::rear : end::front, 4); + const TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->CabOccupied < 0 ? rear : front, 4); int in = 0; while (p && in < 8) { @@ -959,10 +959,10 @@ TTrain::state_t TTrain::get_state() const btLampkaNapNastHam.GetValue(), mvOccupied->DirActive > 0, mvOccupied->DirActive < 0, - mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? side::right : side::left].open_permit, - mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? side::right : side::left].is_open, - mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? side::left : side::right].open_permit, - mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? side::left : side::right].is_open, + mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? right : left].open_permit, + mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? right : left].is_open, + mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? left : right].open_permit, + mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? left : right].is_open, mvOccupied->Doors.step_enabled, mvOccupied->Power24vIsAvailable, 0, @@ -1059,13 +1059,13 @@ void TTrain::set_paired_open_motor_connectors_button(bool const State) { // crude implementation of the button affecting entire unit for multi-unit engines // TODO: rework it into part of standard command propagation system - if (mvControlled->Couplers[end::front].Connected != nullptr && true == TestFlag(mvControlled->Couplers[end::front].CouplingFlag, coupling::permanent)) + if (mvControlled->Couplers[front].Connected != nullptr && true == TestFlag(mvControlled->Couplers[front].CouplingFlag, permanent)) { - mvControlled->Couplers[end::front].Connected->StLinSwitchOff = State; + mvControlled->Couplers[front].Connected->StLinSwitchOff = State; } - if (mvControlled->Couplers[end::rear].Connected != nullptr && true == TestFlag(mvControlled->Couplers[end::rear].CouplingFlag, coupling::permanent)) + if (mvControlled->Couplers[rear].Connected != nullptr && true == TestFlag(mvControlled->Couplers[rear].CouplingFlag, permanent)) { - mvControlled->Couplers[end::rear].Connected->StLinSwitchOff = State; + mvControlled->Couplers[rear].Connected->StLinSwitchOff = State; } } } @@ -3133,7 +3133,7 @@ void TTrain::OnCommand_cabactivationdisable(TTrain *Train, command_data const &C } Train->mvOccupied->CabDeactivisation(); - if (Train->mvOccupied->LightsPosNo > 0 && Train->mvOccupied->InactiveCabFlag & activation::redmarkers) + if (Train->mvOccupied->LightsPosNo > 0 && Train->mvOccupied->InactiveCabFlag & redmarkers) { Train->Dynamic()->SetLights(); } @@ -3160,7 +3160,7 @@ void TTrain::OnCommand_pantographtogglefront(TTrain *Train, command_data const & if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - auto const &pantograph{Train->mvPantographUnit->Pantographs[end::front]}; + auto const &pantograph{Train->mvPantographUnit->Pantographs[front]}; auto const state{pantograph.valve.is_enabled || pantograph.is_active}; // fallback for impulse switches if (state) { @@ -3177,7 +3177,7 @@ void TTrain::OnCommand_pantographtogglefront(TTrain *Train, command_data const & if (Train->mvOccupied->PantSwitchType == "impulse") { auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(end::front, operation_t::none, ismanual ? range_t::local : range_t::consist); + Train->mvOccupied->OperatePantographValve(front, operation_t::none, ismanual ? range_t::local : range_t::consist); } } } @@ -3194,7 +3194,7 @@ void TTrain::OnCommand_pantographtogglerear(TTrain *Train, command_data const &C if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - auto const &pantograph{Train->mvPantographUnit->Pantographs[end::rear]}; + auto const &pantograph{Train->mvPantographUnit->Pantographs[rear]}; auto const state{pantograph.valve.is_enabled || pantograph.is_active}; // fallback for impulse switches if (state) { @@ -3211,7 +3211,7 @@ void TTrain::OnCommand_pantographtogglerear(TTrain *Train, command_data const &C if (Train->mvOccupied->PantSwitchType == "impulse") { auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(end::rear, operation_t::none, ismanual ? range_t::local : range_t::consist); + Train->mvOccupied->OperatePantographValve(rear, operation_t::none, ismanual ? range_t::local : range_t::consist); } } } @@ -3235,7 +3235,7 @@ void TTrain::OnCommand_pantographraisefront(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(end::front, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::enable_on : operation_t::enable, + Train->mvOccupied->OperatePantographValve(front, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::enable_on : operation_t::enable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -3264,7 +3264,7 @@ void TTrain::OnCommand_pantographraiserear(TTrain *Train, command_data const &Co // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(end::rear, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::enable_on : operation_t::enable, + Train->mvOccupied->OperatePantographValve(rear, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::enable_on : operation_t::enable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -3293,7 +3293,7 @@ void TTrain::OnCommand_pantographlowerfront(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(end::front, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::disable_on : operation_t::disable, + Train->mvOccupied->OperatePantographValve(front, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::disable_on : operation_t::disable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -3322,7 +3322,7 @@ void TTrain::OnCommand_pantographlowerrear(TTrain *Train, command_data const &Co // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(end::rear, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::disable_on : operation_t::disable, + Train->mvOccupied->OperatePantographValve(rear, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::disable_on : operation_t::disable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -3519,12 +3519,12 @@ void TTrain::update_pantograph_valves() const auto &selection{mvOccupied->PantsPreset.second[cab_to_end()]}; auto const preset{presets[selection] - '0'}; - auto const swapends{cab_to_end() != end::front}; + auto const swapends{cab_to_end() != front}; // check desired states for both pantographs; value: whether the pantograph should be raised auto const frontstate{preset & (swapends ? 2 : 1)}; auto const rearstate{preset & (swapends ? 1 : 2)}; - mvOccupied->OperatePantographValve(end::front, frontstate ? operation_t::enable : operation_t::disable); - mvOccupied->OperatePantographValve(end::rear, rearstate ? operation_t::enable : operation_t::disable); + mvOccupied->OperatePantographValve(front, frontstate ? operation_t::enable : operation_t::disable); + mvOccupied->OperatePantographValve(rear, rearstate ? operation_t::enable : operation_t::disable); } void TTrain::change_pantograph_selection(int const Change) @@ -3600,8 +3600,8 @@ void TTrain::OnCommand_pantographvalvesoff(TTrain *Train, command_data const &Co if (Command.action == GLFW_PRESS) { // implement action - Train->mvOccupied->OperatePantographValve(end::front, operation_t::disable); - Train->mvOccupied->OperatePantographValve(end::rear, operation_t::disable); + Train->mvOccupied->OperatePantographValve(front, operation_t::disable); + Train->mvOccupied->OperatePantographValve(rear, operation_t::disable); // visual feedback if (hasSeparateSwitches) Train->ggPantValvesOff.UpdateValue(1.0, Train->dsbSwitch); @@ -4530,7 +4530,7 @@ void TTrain::OnCommand_converteroverloadrelayreset(TTrain *Train, command_data c // visual feedback Train->ggConverterFuseButton.UpdateValue(1.0, Train->dsbSwitch); - Train->mvControlled->RelayReset(relay_t::primaryconverteroverload); + Train->mvControlled->RelayReset(primaryconverteroverload); } else if (Command.action == GLFW_RELEASE) { @@ -4770,7 +4770,7 @@ void TTrain::OnCommand_motorblowerstogglefront(TTrain *Train, command_data const return; } - if (false == Train->mvControlled->MotorBlowers[end::front].is_enabled) + if (false == Train->mvControlled->MotorBlowers[front].is_enabled) { // turn on OnCommand_motorblowersenablefront(Train, Command); @@ -4798,13 +4798,13 @@ void TTrain::OnCommand_motorblowersenablefront(TTrain *Train, command_data const { // visual feedback Train->ggMotorBlowersFrontButton.UpdateValue(1.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(true, end::front); + Train->mvControlled->MotorBlowersSwitch(true, front); } else if (Command.action == GLFW_RELEASE) { // visual feedback Train->ggMotorBlowersFrontButton.UpdateValue(0.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(false, end::front); + Train->mvControlled->MotorBlowersSwitch(false, front); } } else @@ -4814,8 +4814,8 @@ void TTrain::OnCommand_motorblowersenablefront(TTrain *Train, command_data const { // visual feedback Train->ggMotorBlowersFrontButton.UpdateValue(1.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(true, end::front); - Train->mvControlled->MotorBlowersSwitchOff(false, end::front); + Train->mvControlled->MotorBlowersSwitch(true, front); + Train->mvControlled->MotorBlowersSwitchOff(false, front); } } } @@ -4841,8 +4841,8 @@ void TTrain::OnCommand_motorblowersdisablefront(TTrain *Train, command_data cons { // visual feedback Train->ggMotorBlowersFrontButton.UpdateValue(0.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(false, end::front); - Train->mvControlled->MotorBlowersSwitchOff(true, end::front); + Train->mvControlled->MotorBlowersSwitch(false, front); + Train->mvControlled->MotorBlowersSwitchOff(true, front); } } } @@ -4869,7 +4869,7 @@ void TTrain::OnCommand_motorblowerstogglerear(TTrain *Train, command_data const return; } - if (false == Train->mvControlled->MotorBlowers[end::rear].is_enabled) + if (false == Train->mvControlled->MotorBlowers[rear].is_enabled) { // turn on OnCommand_motorblowersenablerear(Train, Command); @@ -4897,13 +4897,13 @@ void TTrain::OnCommand_motorblowersenablerear(TTrain *Train, command_data const { // visual feedback Train->ggMotorBlowersRearButton.UpdateValue(1.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(true, end::rear); + Train->mvControlled->MotorBlowersSwitch(true, rear); } else if (Command.action == GLFW_RELEASE) { // visual feedback Train->ggMotorBlowersRearButton.UpdateValue(0.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(false, end::rear); + Train->mvControlled->MotorBlowersSwitch(false, rear); } } else @@ -4913,8 +4913,8 @@ void TTrain::OnCommand_motorblowersenablerear(TTrain *Train, command_data const { // visual feedback Train->ggMotorBlowersRearButton.UpdateValue(1.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(true, end::rear); - Train->mvControlled->MotorBlowersSwitchOff(false, end::rear); + Train->mvControlled->MotorBlowersSwitch(true, rear); + Train->mvControlled->MotorBlowersSwitchOff(false, rear); } } } @@ -4940,8 +4940,8 @@ void TTrain::OnCommand_motorblowersdisablerear(TTrain *Train, command_data const { // visual feedback Train->ggMotorBlowersRearButton.UpdateValue(0.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(false, end::rear); - Train->mvControlled->MotorBlowersSwitchOff(true, end::rear); + Train->mvControlled->MotorBlowersSwitch(false, rear); + Train->mvControlled->MotorBlowersSwitchOff(true, rear); } } } @@ -4961,15 +4961,15 @@ void TTrain::OnCommand_motorblowersdisableall(TTrain *Train, command_data const { // visual feedback Train->ggMotorBlowersAllOffButton.UpdateValue(1.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitchOff(true, end::front); - Train->mvControlled->MotorBlowersSwitchOff(true, end::rear); + Train->mvControlled->MotorBlowersSwitchOff(true, front); + Train->mvControlled->MotorBlowersSwitchOff(true, rear); } else if (Command.action == GLFW_RELEASE) { // visual feedback Train->ggMotorBlowersAllOffButton.UpdateValue(0.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitchOff(false, end::front); - Train->mvControlled->MotorBlowersSwitchOff(false, end::rear); + Train->mvControlled->MotorBlowersSwitchOff(false, front); + Train->mvControlled->MotorBlowersSwitchOff(false, rear); } } else @@ -4981,16 +4981,16 @@ void TTrain::OnCommand_motorblowersdisableall(TTrain *Train, command_data const if (Train->ggMotorBlowersAllOffButton.GetDesiredValue() < 0.5f) { // switch is off, activate - Train->mvControlled->MotorBlowersSwitchOff(true, end::front); - Train->mvControlled->MotorBlowersSwitchOff(true, end::rear); + Train->mvControlled->MotorBlowersSwitchOff(true, front); + Train->mvControlled->MotorBlowersSwitchOff(true, rear); // visual feedback Train->ggMotorBlowersRearButton.UpdateValue(1.f, Train->dsbSwitch); } else { // deactivate - Train->mvControlled->MotorBlowersSwitchOff(false, end::front); - Train->mvControlled->MotorBlowersSwitchOff(false, end::rear); + Train->mvControlled->MotorBlowersSwitchOff(false, front); + Train->mvControlled->MotorBlowersSwitchOff(false, rear); // visual feedback Train->ggMotorBlowersRearButton.UpdateValue(0.f, Train->dsbSwitch); } @@ -5273,7 +5273,7 @@ void TTrain::OnCommand_headlighttoggleleft(TTrain *Train, command_data const &Co if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_left) == 0) + if ((Train->mvOccupied->iLights[vehicleend] & headlight_left) == 0) { // turn on OnCommand_headlightenableleft(Train, Command); @@ -5289,8 +5289,8 @@ void TTrain::OnCommand_headlighttoggleleft(TTrain *Train, command_data const &Co void TTrain::OnCommand_lightsset(TTrain *Train, command_data const &Command) { // set custom item in Lights inventory - Train->mvOccupied->Lights[end::front][17] = Command.param1; - Train->mvOccupied->Lights[end::rear][17] = Command.param2; + Train->mvOccupied->Lights[front][17] = Command.param1; + Train->mvOccupied->Lights[rear][17] = Command.param2; Train->mvOccupied->LightsPos = 18; // nasza custom pozycja Train->Dynamic()->SetLights(); } @@ -5311,14 +5311,14 @@ void TTrain::OnCommand_headlightenableleft(TTrain *Train, command_data const &Co // implementation auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_left) == 0) + if ((Train->mvOccupied->iLights[vehicleend] & headlight_left) == 0) { - Train->mvOccupied->iLights[vehicleend] ^= light::headlight_left; + Train->mvOccupied->iLights[vehicleend] ^= headlight_left; } // if the light is controlled by 3-way switch, disable marker light if (Train->ggLeftEndLightButton.SubModel == nullptr) { - Train->mvOccupied->iLights[vehicleend] &= ~light::redmarker_left; + Train->mvOccupied->iLights[vehicleend] &= ~redmarker_left; } } } @@ -5337,12 +5337,12 @@ void TTrain::OnCommand_headlightdisableleft(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down int const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_left) == 0) + if ((Train->mvOccupied->iLights[vehicleend] & headlight_left) == 0) { return; } // already disabled - Train->mvOccupied->iLights[vehicleend] ^= light::headlight_left; + Train->mvOccupied->iLights[vehicleend] ^= headlight_left; // visual feedback Train->ggLeftLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -5356,7 +5356,7 @@ void TTrain::OnCommand_headlighttoggleright(TTrain *Train, command_data const &C if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_right) == 0) + if ((Train->mvOccupied->iLights[vehicleend] & headlight_right) == 0) { // turn on OnCommand_headlightenableright(Train, Command); @@ -5385,14 +5385,14 @@ void TTrain::OnCommand_headlightenableright(TTrain *Train, command_data const &C // implementation auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_right) == 0) + if ((Train->mvOccupied->iLights[vehicleend] & headlight_right) == 0) { - Train->mvOccupied->iLights[vehicleend] ^= light::headlight_right; + Train->mvOccupied->iLights[vehicleend] ^= headlight_right; } // if the light is controlled by 3-way switch, disable marker light if (Train->ggRightEndLightButton.SubModel == nullptr) { - Train->mvOccupied->iLights[vehicleend] &= ~light::redmarker_right; + Train->mvOccupied->iLights[vehicleend] &= ~redmarker_right; } } } @@ -5411,12 +5411,12 @@ void TTrain::OnCommand_headlightdisableright(TTrain *Train, command_data const & // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_right) == 0) + if ((Train->mvOccupied->iLights[vehicleend] & headlight_right) == 0) { return; } // already disabled - Train->mvOccupied->iLights[vehicleend] ^= light::headlight_right; + Train->mvOccupied->iLights[vehicleend] ^= headlight_right; // visual feedback Train->ggRightLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -5430,7 +5430,7 @@ void TTrain::OnCommand_headlighttoggleupper(TTrain *Train, command_data const &C if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_upper) == 0) + if ((Train->mvOccupied->iLights[vehicleend] & headlight_upper) == 0) { // turn on OnCommand_headlightenableupper(Train, Command); @@ -5457,12 +5457,12 @@ void TTrain::OnCommand_headlightenableupper(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_upper) != 0) + if ((Train->mvOccupied->iLights[vehicleend] & headlight_upper) != 0) { return; } // already enabled - Train->mvOccupied->iLights[vehicleend] ^= light::headlight_upper; + Train->mvOccupied->iLights[vehicleend] ^= headlight_upper; // visual feedback Train->ggUpperLightButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -5482,12 +5482,12 @@ void TTrain::OnCommand_headlightdisableupper(TTrain *Train, command_data const & // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_upper) == 0) + if ((Train->mvOccupied->iLights[vehicleend] & headlight_upper) == 0) { return; } // already disabled - Train->mvOccupied->iLights[vehicleend] ^= light::headlight_upper; + Train->mvOccupied->iLights[vehicleend] ^= headlight_upper; // visual feedback Train->ggUpperLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -5501,7 +5501,7 @@ void TTrain::OnCommand_redmarkertoggleleft(TTrain *Train, command_data const &Co // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::redmarker_left) == 0) + if ((Train->mvOccupied->iLights[vehicleend] & redmarker_left) == 0) { // turn on OnCommand_redmarkerenableleft(Train, Command); @@ -5528,12 +5528,12 @@ void TTrain::OnCommand_redmarkerenableleft(TTrain *Train, command_data const &Co // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::redmarker_left) != 0) + if ((Train->mvOccupied->iLights[vehicleend] & redmarker_left) != 0) { return; } // already enabled - Train->mvOccupied->iLights[vehicleend] ^= light::redmarker_left; + Train->mvOccupied->iLights[vehicleend] ^= redmarker_left; // visual feedback if (Train->ggLeftEndLightButton.SubModel != nullptr) { @@ -5545,7 +5545,7 @@ void TTrain::OnCommand_redmarkerenableleft(TTrain *Train, command_data const &Co // this is crude, but for now will do Train->ggLeftLightButton.UpdateValue(-1.0, Train->dsbSwitch); // if the light is controlled by 3-way switch, disable the headlight - Train->mvOccupied->iLights[vehicleend] &= ~light::headlight_left; + Train->mvOccupied->iLights[vehicleend] &= ~headlight_left; } } } @@ -5564,12 +5564,12 @@ void TTrain::OnCommand_redmarkerdisableleft(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::redmarker_left) == 0) + if ((Train->mvOccupied->iLights[vehicleend] & redmarker_left) == 0) { return; } // already disabled - Train->mvOccupied->iLights[vehicleend] ^= light::redmarker_left; + Train->mvOccupied->iLights[vehicleend] ^= redmarker_left; // visual feedback if (Train->ggLeftEndLightButton.SubModel != nullptr) { @@ -5592,7 +5592,7 @@ void TTrain::OnCommand_redmarkertoggleright(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::redmarker_right) == 0) + if ((Train->mvOccupied->iLights[vehicleend] & redmarker_right) == 0) { // turn on OnCommand_redmarkerenableright(Train, Command); @@ -5619,12 +5619,12 @@ void TTrain::OnCommand_redmarkerenableright(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::redmarker_right) != 0) + if ((Train->mvOccupied->iLights[vehicleend] & redmarker_right) != 0) { return; } // already enabled - Train->mvOccupied->iLights[vehicleend] ^= light::redmarker_right; + Train->mvOccupied->iLights[vehicleend] ^= redmarker_right; // visual feedback if (Train->ggRightEndLightButton.SubModel != nullptr) { @@ -5636,7 +5636,7 @@ void TTrain::OnCommand_redmarkerenableright(TTrain *Train, command_data const &C // this is crude, but for now will do Train->ggRightLightButton.UpdateValue(-1.0, Train->dsbSwitch); // if the light is controlled by 3-way switch, disable the headlight - Train->mvOccupied->iLights[vehicleend] &= ~light::headlight_right; + Train->mvOccupied->iLights[vehicleend] &= ~headlight_right; } } } @@ -5655,12 +5655,12 @@ void TTrain::OnCommand_redmarkerdisableright(TTrain *Train, command_data const & // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::redmarker_right) == 0) + if ((Train->mvOccupied->iLights[vehicleend] & redmarker_right) == 0) { return; } // already disabled - Train->mvOccupied->iLights[vehicleend] ^= light::redmarker_right; + Train->mvOccupied->iLights[vehicleend] ^= redmarker_right; // visual feedback if (Train->ggRightEndLightButton.SubModel != nullptr) { @@ -5687,9 +5687,9 @@ void TTrain::OnCommand_headlighttogglerearleft(TTrain *Train, command_data const if (Command.action == GLFW_PRESS) { // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc - auto const vehicleotherend{(Train->cab_to_end() == end::front ? end::rear : end::front)}; + auto const vehicleotherend{(Train->cab_to_end() == front ? rear : front)}; // only reacting to press, so the switch doesn't flip back and forth if key is held down - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_right) == 0) + if ((Train->mvOccupied->iLights[vehicleotherend] & headlight_right) == 0) { OnCommand_headlightenablerearleft(Train, Command); } @@ -5710,12 +5710,12 @@ void TTrain::OnCommand_headlightenablerearleft(TTrain *Train, command_data const if (Command.action == GLFW_PRESS) { - auto const vehicleotherend{(Train->cab_to_end() == end::front ? end::rear : end::front)}; + auto const vehicleotherend{(Train->cab_to_end() == front ? rear : front)}; // already enabled - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_right) == 0) + if ((Train->mvOccupied->iLights[vehicleotherend] & headlight_right) == 0) { // turn on - Train->mvOccupied->iLights[vehicleotherend] ^= light::headlight_right; + Train->mvOccupied->iLights[vehicleotherend] ^= headlight_right; // visual feedback Train->ggRearLeftLightButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -5731,15 +5731,15 @@ void TTrain::OnCommand_headlightdisablerearleft(TTrain *Train, command_data cons } if (Command.action == GLFW_PRESS) { - auto const vehicleotherend{(Train->cab_to_end() == end::front ? end::rear : end::front)}; + auto const vehicleotherend{(Train->cab_to_end() == front ? rear : front)}; // already disabled - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_right) == 0) + if ((Train->mvOccupied->iLights[vehicleotherend] & headlight_right) == 0) { return; } // turn off - Train->mvOccupied->iLights[vehicleotherend] ^= light::headlight_right; + Train->mvOccupied->iLights[vehicleotherend] ^= headlight_right; // visual feedback Train->ggRearLeftLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -5750,9 +5750,9 @@ void TTrain::OnCommand_headlighttogglerearright(TTrain *Train, command_data cons if (Command.action == GLFW_PRESS) { // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc - auto const vehicleotherend{(Train->cab_to_end() == end::front ? end::rear : end::front)}; + auto const vehicleotherend{(Train->cab_to_end() == front ? rear : front)}; // only reacting to press, so the switch doesn't flip back and forth if key is held down - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_left) == 0) + if ((Train->mvOccupied->iLights[vehicleotherend] & headlight_left) == 0) { OnCommand_headlightenablerearright(Train, Command); } @@ -5774,12 +5774,12 @@ void TTrain::OnCommand_headlightenablerearright(TTrain *Train, command_data cons if (Command.action == GLFW_PRESS) { // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc - auto const vehicleotherend{(Train->cab_to_end() == end::front ? end::rear : end::front)}; + auto const vehicleotherend{(Train->cab_to_end() == front ? rear : front)}; - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_left) == 0) + if ((Train->mvOccupied->iLights[vehicleotherend] & headlight_left) == 0) { // turn on - Train->mvOccupied->iLights[vehicleotherend] ^= light::headlight_left; + Train->mvOccupied->iLights[vehicleotherend] ^= headlight_left; // visual feedback Train->ggRearRightLightButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -5797,15 +5797,15 @@ void TTrain::OnCommand_headlightdisablerearright(TTrain *Train, command_data con if (Command.action == GLFW_PRESS) { // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc - auto const vehicleotherend{(Train->cab_to_end() == end::front ? end::rear : end::front)}; + auto const vehicleotherend{(Train->cab_to_end() == front ? rear : front)}; // already disabled - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_left) == 0) + if ((Train->mvOccupied->iLights[vehicleotherend] & headlight_left) == 0) { return; } // turn off - Train->mvOccupied->iLights[vehicleotherend] ^= light::headlight_left; + Train->mvOccupied->iLights[vehicleotherend] ^= headlight_left; // visual feedback Train->ggRearRightLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -5823,8 +5823,8 @@ void TTrain::OnCommand_headlighttogglerearupper(TTrain *Train, command_data cons if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - auto const vehicleotherend{(Train->cab_to_end() == end::front ? end::rear : end::front)}; - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_upper) == 0) + auto const vehicleotherend{(Train->cab_to_end() == front ? rear : front)}; + if ((Train->mvOccupied->iLights[vehicleotherend] & headlight_upper) == 0) { OnCommand_headlightenablerearupper(Train, Command); } @@ -5847,11 +5847,11 @@ void TTrain::OnCommand_headlightenablerearupper(TTrain *Train, command_data cons if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - auto const vehicleotherend{(Train->cab_to_end() == end::front ? end::rear : end::front)}; - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_upper) == 0) + auto const vehicleotherend{(Train->cab_to_end() == front ? rear : front)}; + if ((Train->mvOccupied->iLights[vehicleotherend] & headlight_upper) == 0) { // turn on - Train->mvOccupied->iLights[vehicleotherend] ^= light::headlight_upper; + Train->mvOccupied->iLights[vehicleotherend] ^= headlight_upper; // visual feedback Train->ggRearUpperLightButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -5870,15 +5870,15 @@ void TTrain::OnCommand_headlightdisablerearupper(TTrain *Train, command_data con if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - auto const vehicleotherend{(Train->cab_to_end() == end::front ? end::rear : end::front)}; + auto const vehicleotherend{(Train->cab_to_end() == front ? rear : front)}; // already disabled? - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_upper) == 0) + if ((Train->mvOccupied->iLights[vehicleotherend] & headlight_upper) == 0) { return; } // turn off - Train->mvOccupied->iLights[vehicleotherend] ^= light::headlight_upper; + Train->mvOccupied->iLights[vehicleotherend] ^= headlight_upper; // visual feedback Train->ggRearUpperLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -5942,9 +5942,9 @@ void TTrain::OnCommand_redmarkertogglerearleft(TTrain *Train, command_data const if (Command.action == GLFW_PRESS) { // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc - auto const vehicleotherend{(Train->cab_to_end() == end::front ? end::rear : end::front)}; + auto const vehicleotherend{(Train->cab_to_end() == front ? rear : front)}; // only reacting to press, so the switch doesn't flip back and forth if key is held down - if ((Train->mvOccupied->iLights[vehicleotherend] & light::redmarker_right) == 0) + if ((Train->mvOccupied->iLights[vehicleotherend] & redmarker_right) == 0) { OnCommand_redmarkerenablerearleft(Train, Command); } @@ -5967,11 +5967,11 @@ void TTrain::OnCommand_redmarkerenablerearleft(TTrain *Train, command_data const if (Command.action == GLFW_PRESS) { // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc - auto const vehicleotherend{(Train->cab_to_end() == end::front ? end::rear : end::front)}; - if ((Train->mvOccupied->iLights[vehicleotherend] & light::redmarker_right) == 0) + auto const vehicleotherend{(Train->cab_to_end() == front ? rear : front)}; + if ((Train->mvOccupied->iLights[vehicleotherend] & redmarker_right) == 0) { // turn on - Train->mvOccupied->iLights[vehicleotherend] ^= light::redmarker_right; + Train->mvOccupied->iLights[vehicleotherend] ^= redmarker_right; // visual feedback Train->ggRearLeftEndLightButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -5990,13 +5990,13 @@ void TTrain::OnCommand_redmarkerdisablerearleft(TTrain *Train, command_data cons if (Command.action == GLFW_PRESS) { // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc - auto const vehicleotherend{(Train->cab_to_end() == end::front ? end::rear : end::front)}; - if ((Train->mvOccupied->iLights[vehicleotherend] & light::redmarker_right) == 0) + auto const vehicleotherend{(Train->cab_to_end() == front ? rear : front)}; + if ((Train->mvOccupied->iLights[vehicleotherend] & redmarker_right) == 0) { return; } // turn off - Train->mvOccupied->iLights[vehicleotherend] ^= light::redmarker_right; + Train->mvOccupied->iLights[vehicleotherend] ^= redmarker_right; // visual feedback Train->ggRearLeftEndLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -6014,9 +6014,9 @@ void TTrain::OnCommand_redmarkertogglerearright(TTrain *Train, command_data cons if (Command.action == GLFW_PRESS) { // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc - auto const vehicleotherend{(Train->cab_to_end() == end::front ? end::rear : end::front)}; + auto const vehicleotherend{(Train->cab_to_end() == front ? rear : front)}; // only reacting to press, so the switch doesn't flip back and forth if key is held down - if ((Train->mvOccupied->iLights[vehicleotherend] & light::redmarker_left) == 0) + if ((Train->mvOccupied->iLights[vehicleotherend] & redmarker_left) == 0) { OnCommand_redmarkerenablerearright(Train, Command); } @@ -6039,11 +6039,11 @@ void TTrain::OnCommand_redmarkerenablerearright(TTrain *Train, command_data cons if (Command.action == GLFW_PRESS) { // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc - auto const vehicleotherend{(Train->cab_to_end() == end::front ? end::rear : end::front)}; - if ((Train->mvOccupied->iLights[vehicleotherend] & light::redmarker_left) == 0) + auto const vehicleotherend{(Train->cab_to_end() == front ? rear : front)}; + if ((Train->mvOccupied->iLights[vehicleotherend] & redmarker_left) == 0) { // turn on - Train->mvOccupied->iLights[vehicleotherend] ^= light::redmarker_left; + Train->mvOccupied->iLights[vehicleotherend] ^= redmarker_left; // visual feedback Train->ggRearRightEndLightButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -6062,13 +6062,13 @@ void TTrain::OnCommand_redmarkerdisablerearright(TTrain *Train, command_data con if (Command.action == GLFW_PRESS) { // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc - auto const vehicleotherend{(Train->cab_to_end() == end::front ? end::rear : end::front)}; - if ((Train->mvOccupied->iLights[vehicleotherend] & light::redmarker_left) == 0) + auto const vehicleotherend{(Train->cab_to_end() == front ? rear : front)}; + if ((Train->mvOccupied->iLights[vehicleotherend] & redmarker_left) == 0) { return; } // turn off - Train->mvOccupied->iLights[vehicleotherend] ^= light::redmarker_left; + Train->mvOccupied->iLights[vehicleotherend] ^= redmarker_left; // visual feedback Train->ggRearRightEndLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -6091,7 +6091,7 @@ void TTrain::OnCommand_redmarkerstoggle(TTrain *Train, command_data const &Comma auto locationRear = vehicle->RearPosition() - glm::dvec3(Command.location); int const CouplNr{std::clamp(vehicle->DirectionGet() * (glm::dot(locationHead, locationHead) > glm::dot(locationRear, locationRear) ? 1 : -1), 0, 1)}; // z [-1,1] zrobić [0,1] - auto const lightset{light::redmarker_left | light::redmarker_right}; + auto const lightset{redmarker_left | redmarker_right}; vehicle->MoverParameters->iLights[CouplNr] = false == TestFlag(vehicle->MoverParameters->iLights[CouplNr], lightset) ? @@ -6116,7 +6116,7 @@ void TTrain::OnCommand_endsignalstoggle(TTrain *Train, command_data const &Comma std::clamp(vehicle->DirectionGet() * (glm::length2(vehicle->HeadPosition() - glm::dvec3(Command.location)) > glm::length2(vehicle->RearPosition() - glm::dvec3(Command.location)) ? 1 : -1), 0, 1)}; // z [-1,1] zrobić [0,1] - auto const lightset{light::rearendsignals}; + auto const lightset{rearendsignals}; vehicle->MoverParameters->iLights[CouplNr] = false == TestFlag(vehicle->MoverParameters->iLights[CouplNr], lightset) ? @@ -6987,7 +6987,7 @@ void TTrain::OnCommand_inverterenable(TTrain *Train, command_data const &Command // only reacting to press, so the switch doesn't flip back and forth if key is held down const bool kier = Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0; const int flag = Train->DynamicObject->MoverParameters->InverterControlCouplerFlag; - const TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, flag); + const TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? rear : front, flag); while (p) { if (p->MoverParameters->eimc[eimc_p_Pmax] > 1) @@ -7026,7 +7026,7 @@ void TTrain::OnCommand_inverterdisable(TTrain *Train, command_data const &Comman // only reacting to press, so the switch doesn't flip back and forth if key is held down const bool kier = Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0; const int flag = Train->DynamicObject->MoverParameters->InverterControlCouplerFlag; - const TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, flag); + const TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? rear : front, flag); while (p) { if (p->MoverParameters->eimc[eimc_p_Pmax] > 1) @@ -7065,7 +7065,7 @@ void TTrain::OnCommand_invertertoggle(TTrain *Train, command_data const &Command // only reacting to press, so the switch doesn't flip back and forth if key is held down const bool kier = Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0; const int flag = Train->DynamicObject->MoverParameters->InverterControlCouplerFlag; - const TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, flag); + const TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? rear : front, flag); while (p) { if (p->MoverParameters->eimc[eimc_p_Pmax] > 1) @@ -7208,7 +7208,7 @@ void TTrain::OnCommand_doorpermitleft(TTrain *Train, command_data const &Command return; } - auto const side{(Train->cab_to_end() == end::front ? side::left : side::right)}; + auto const side{(Train->cab_to_end() == front ? left : right)}; if (Command.action == GLFW_PRESS) { @@ -7258,7 +7258,7 @@ void TTrain::OnCommand_doorpermitright(TTrain *Train, command_data const &Comman return; } - auto const side{(Train->cab_to_end() == end::front ? side::right : side::left)}; + auto const side{(Train->cab_to_end() == front ? right : left)}; if (Command.action == GLFW_PRESS) { @@ -7323,7 +7323,7 @@ void TTrain::OnCommand_doorpermitpresetactivateprevious(TTrain *Train, command_d void TTrain::OnCommand_dooropenleft(TTrain *Train, command_data const &Command) { - auto const remoteopencontrol{Train->mvOccupied->Doors.open_control == control_t::driver || Train->mvOccupied->Doors.open_control == control_t::mixed}; + auto const remoteopencontrol{Train->mvOccupied->Doors.open_control == driver || Train->mvOccupied->Doors.open_control == mixed}; if (false == remoteopencontrol) { @@ -7338,7 +7338,7 @@ void TTrain::OnCommand_dooropenleft(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { - Train->mvOccupied->OperateDoors(Train->cab_to_end() == end::front ? side::left : side::right, true); + Train->mvOccupied->OperateDoors(Train->cab_to_end() == front ? left : right, true); // visual feedback if (Train->ggDoorLeftOnButton.SubModel != nullptr) { @@ -7365,7 +7365,7 @@ void TTrain::OnCommand_dooropenleft(TTrain *Train, command_data const &Command) void TTrain::OnCommand_doorcloseleft(TTrain *Train, command_data const &Command) { - auto const remoteclosecontrol{Train->mvOccupied->Doors.close_control == control_t::driver || Train->mvOccupied->Doors.close_control == control_t::mixed}; + auto const remoteclosecontrol{Train->mvOccupied->Doors.close_control == driver || Train->mvOccupied->Doors.close_control == mixed}; if (false == remoteclosecontrol) { @@ -7389,7 +7389,7 @@ void TTrain::OnCommand_doorcloseleft(TTrain *Train, command_data const &Command) else { // TODO: move door opening/closing to the update, so the switch animation doesn't hinge on door working - Train->mvOccupied->OperateDoors(Train->cab_to_end() == end::front ? side::left : side::right, false); + Train->mvOccupied->OperateDoors(Train->cab_to_end() == front ? left : right, false); } // visual feedback if (Train->ggDoorLeftOffButton.SubModel != nullptr) @@ -7411,7 +7411,7 @@ void TTrain::OnCommand_doorcloseleft(TTrain *Train, command_data const &Command) // automatic departure signal delays actual door closing until the button is released Train->mvOccupied->signal_departure(false); // now we can actually close the door - Train->mvOccupied->OperateDoors(Train->cab_to_end() == end::front ? side::left : side::right, false); + Train->mvOccupied->OperateDoors(Train->cab_to_end() == front ? left : right, false); } // visual feedback // dedicated closing buttons are presumed to be impulse switches and return automatically to neutral position @@ -7498,7 +7498,7 @@ void TTrain::OnCommand_doortoggleright(TTrain *Train, command_data const &Comman void TTrain::OnCommand_dooropenright(TTrain *Train, command_data const &Command) { - auto const remoteopencontrol{Train->mvOccupied->Doors.open_control == control_t::driver || Train->mvOccupied->Doors.open_control == control_t::mixed}; + auto const remoteopencontrol{Train->mvOccupied->Doors.open_control == driver || Train->mvOccupied->Doors.open_control == mixed}; if (false == remoteopencontrol) { @@ -7514,7 +7514,7 @@ void TTrain::OnCommand_dooropenright(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { - Train->mvOccupied->OperateDoors(Train->cab_to_end() == end::front ? side::right : side::left, true); + Train->mvOccupied->OperateDoors(Train->cab_to_end() == front ? right : left, true); // visual feedback if (Train->ggDoorRightOnButton.SubModel != nullptr) { @@ -7541,7 +7541,7 @@ void TTrain::OnCommand_dooropenright(TTrain *Train, command_data const &Command) void TTrain::OnCommand_doorcloseright(TTrain *Train, command_data const &Command) { - auto const remoteclosecontrol{Train->mvOccupied->Doors.close_control == control_t::driver || Train->mvOccupied->Doors.close_control == control_t::mixed}; + auto const remoteclosecontrol{Train->mvOccupied->Doors.close_control == driver || Train->mvOccupied->Doors.close_control == mixed}; if (false == remoteclosecontrol) { @@ -7564,7 +7564,7 @@ void TTrain::OnCommand_doorcloseright(TTrain *Train, command_data const &Command } else { - Train->mvOccupied->OperateDoors(Train->cab_to_end() == end::front ? side::right : side::left, false); + Train->mvOccupied->OperateDoors(Train->cab_to_end() == front ? right : left, false); } // visual feedback if (Train->ggDoorRightOffButton.SubModel != nullptr) @@ -7586,7 +7586,7 @@ void TTrain::OnCommand_doorcloseright(TTrain *Train, command_data const &Command // automatic departure signal delays actual door closing until the button is released Train->mvOccupied->signal_departure(false); // now we can actually close the door - Train->mvOccupied->OperateDoors(Train->cab_to_end() == end::front ? side::right : side::left, false); + Train->mvOccupied->OperateDoors(Train->cab_to_end() == front ? right : left, false); } // visual feedback // dedicated closing buttons are presumed to be impulse switches and return automatically to neutral position @@ -7598,7 +7598,7 @@ void TTrain::OnCommand_doorcloseright(TTrain *Train, command_data const &Command void TTrain::OnCommand_dooropenall(TTrain *Train, command_data const &Command) { - auto const remoteopencontrol{Train->mvOccupied->Doors.open_control == control_t::driver || Train->mvOccupied->Doors.open_control == control_t::mixed}; + auto const remoteopencontrol{Train->mvOccupied->Doors.open_control == driver || Train->mvOccupied->Doors.open_control == mixed}; if (false == remoteopencontrol) { @@ -7618,8 +7618,8 @@ void TTrain::OnCommand_dooropenall(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { - Train->mvOccupied->OperateDoors(side::right, true); - Train->mvOccupied->OperateDoors(side::left, true); + Train->mvOccupied->OperateDoors(right, true); + Train->mvOccupied->OperateDoors(left, true); // visual feedback Train->ggDoorAllOnButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -7633,7 +7633,7 @@ void TTrain::OnCommand_dooropenall(TTrain *Train, command_data const &Command) void TTrain::OnCommand_doorcloseall(TTrain *Train, command_data const &Command) { - auto const remoteclosecontrol{Train->mvOccupied->Doors.close_control == control_t::driver || Train->mvOccupied->Doors.close_control == control_t::mixed}; + auto const remoteclosecontrol{Train->mvOccupied->Doors.close_control == driver || Train->mvOccupied->Doors.close_control == mixed}; if (false == remoteclosecontrol) { @@ -7660,8 +7660,8 @@ void TTrain::OnCommand_doorcloseall(TTrain *Train, command_data const &Command) if (Train->ggDoorAllOffButton.type() != TGaugeType::push_delayed) { // delays the action until the button is released - Train->mvOccupied->OperateDoors(side::right, false); - Train->mvOccupied->OperateDoors(side::left, false); + Train->mvOccupied->OperateDoors(right, false); + Train->mvOccupied->OperateDoors(left, false); } // visual feedback Train->ggDoorLeftButton.UpdateValue(0.0, Train->dsbSwitch); @@ -7678,8 +7678,8 @@ void TTrain::OnCommand_doorcloseall(TTrain *Train, command_data const &Command) if (Train->ggDoorAllOffButton.type() == TGaugeType::push_delayed) { // now we can actually close the door - Train->mvOccupied->OperateDoors(side::right, false); - Train->mvOccupied->OperateDoors(side::left, false); + Train->mvOccupied->OperateDoors(right, false); + Train->mvOccupied->OperateDoors(left, false); } // visual feedback if (Train->ggDoorAllOffButton.SubModel) @@ -7808,7 +7808,7 @@ void TTrain::OnCommand_nearestcarcoupleradapterattach(TTrain *Train, command_dat } auto const coupler = - glm::length2(glm::vec3{vehicle->CouplerPosition(end::front)} - Command.location) < glm::length2(glm::vec3{vehicle->CouplerPosition(end::rear)} - Command.location) ? end::front : end::rear; + glm::length2(glm::vec3{vehicle->CouplerPosition(front)} - Command.location) < glm::length2(glm::vec3{vehicle->CouplerPosition(rear)} - Command.location) ? front : rear; vehicle->attach_coupler_adapter(coupler); } @@ -7827,7 +7827,7 @@ void TTrain::OnCommand_nearestcarcoupleradapterremove(TTrain *Train, command_dat } auto const coupler = - glm::length2(glm::vec3{vehicle->CouplerPosition(end::front)} - Command.location) < glm::length2(glm::vec3{vehicle->CouplerPosition(end::rear)} - Command.location) ? end::front : end::rear; + glm::length2(glm::vec3{vehicle->CouplerPosition(front)} - Command.location) < glm::length2(glm::vec3{vehicle->CouplerPosition(rear)} - Command.location) ? front : rear; vehicle->remove_coupler_adapter(coupler); } @@ -8213,7 +8213,7 @@ void TTrain::OnCommand_radiocall1send(TTrain *Train, command_data const &Command { if (Train->RadioChannel() != 10 && true == Train->mvOccupied->Radio && (Train->mvOccupied->Power24vIsAvailable || Train->mvOccupied->Power110vIsAvailable)) { - simulation::Events.queue_receivers(radio_message::call1, Train->Dynamic()->GetPosition()); + simulation::Events.queue_receivers(call1, Train->Dynamic()->GetPosition()); } // visual feedback Train->ggRadioCall1.UpdateValue(1.0); @@ -8232,7 +8232,7 @@ void TTrain::OnCommand_radiocall3send(TTrain *Train, command_data const &Command { if (Train->RadioChannel() != 10 && true == Train->mvOccupied->Radio && (Train->mvOccupied->Power24vIsAvailable || Train->mvOccupied->Power110vIsAvailable)) { - simulation::Events.queue_receivers(radio_message::call3, Train->Dynamic()->GetPosition()); + simulation::Events.queue_receivers(call3, Train->Dynamic()->GetPosition()); } // visual feedback Train->ggRadioCall3.UpdateValue(1.0); @@ -8298,11 +8298,11 @@ void TTrain::OnCommand_cabchangeforward(TTrain *Train, command_data const &Comma auto const movedirection{1}; if (false == Train->CabChange(movedirection)) { - auto const exitdirection{(movedirection > 0 ? end::front : end::rear)}; - if (TestFlag(Train->mvOccupied->Couplers[exitdirection].CouplingFlag, coupling::gangway)) + auto const exitdirection{(movedirection > 0 ? front : rear)}; + if (TestFlag(Train->mvOccupied->Couplers[exitdirection].CouplingFlag, gangway)) { // przejscie do nastepnego pojazdu - auto *targetvehicle = exitdirection == end::front ? Train->DynamicObject->PrevConnected() : Train->DynamicObject->NextConnected(); + auto *targetvehicle = exitdirection == front ? Train->DynamicObject->PrevConnected() : Train->DynamicObject->NextConnected(); targetvehicle->MoverParameters->CabOccupied = Train->mvOccupied->Neighbours[exitdirection].vehicle_end ? -1 : 1; Train->MoveToVehicle(targetvehicle); } @@ -8330,11 +8330,11 @@ void TTrain::OnCommand_cabchangebackward(TTrain *Train, command_data const &Comm if (false == Train->CabChange(movedirection)) { // current vehicle doesn't extend any farther in this direction, check if we there's one connected we can move to - auto const exitdirection{(movedirection > 0 ? end::front : end::rear)}; - if (TestFlag(Train->mvOccupied->Couplers[exitdirection].CouplingFlag, coupling::gangway)) + auto const exitdirection{(movedirection > 0 ? front : rear)}; + if (TestFlag(Train->mvOccupied->Couplers[exitdirection].CouplingFlag, gangway)) { // przejscie do nastepnego pojazdu - auto *targetvehicle = exitdirection == end::front ? Train->DynamicObject->PrevConnected() : Train->DynamicObject->NextConnected(); + auto *targetvehicle = exitdirection == front ? Train->DynamicObject->PrevConnected() : Train->DynamicObject->NextConnected(); targetvehicle->MoverParameters->CabOccupied = Train->mvOccupied->Neighbours[exitdirection].vehicle_end ? -1 : 1; Train->MoveToVehicle(targetvehicle); } @@ -8508,16 +8508,16 @@ bool TTrain::Update(double const Deltatime) // helper variables if (DynamicObject->Mechanik != nullptr) { - m_doors = DynamicObject->Mechanik->IsAnyDoorOpen[side::right] || DynamicObject->Mechanik->IsAnyDoorOpen[side::left]; - m_doorpermits = DynamicObject->Mechanik->IsAnyDoorPermitActive[side::right] || DynamicObject->Mechanik->IsAnyDoorPermitActive[side::left]; - m_doorspermitleft = mvOccupied->Doors.instances[(cab_to_end() == end::front ? side::left : side::right)].open_permit && + m_doors = DynamicObject->Mechanik->IsAnyDoorOpen[right] || DynamicObject->Mechanik->IsAnyDoorOpen[left]; + m_doorpermits = DynamicObject->Mechanik->IsAnyDoorPermitActive[right] || DynamicObject->Mechanik->IsAnyDoorPermitActive[left]; + m_doorspermitleft = mvOccupied->Doors.instances[(cab_to_end() == front ? left : right)].open_permit && (simulation::Time.data().wSecond % 2 < 1 || mvOccupied->DoorsPermitLightBlinking < 1 || - mvOccupied->DoorsPermitLightBlinking < 2 && DynamicObject->Mechanik->IsAnyDoorOpen[(cab_to_end() == end::front ? side::left : side::right)] || - (mvOccupied->DoorsPermitLightBlinking < 3 && DynamicObject->Mechanik->IsAnyDoorOnlyOpen[(cab_to_end() == end::front ? side::left : side::right)])); - m_doorspermitright = mvOccupied->Doors.instances[(cab_to_end() == end::front ? side::right : side::left)].open_permit && + mvOccupied->DoorsPermitLightBlinking < 2 && DynamicObject->Mechanik->IsAnyDoorOpen[(cab_to_end() == front ? left : right)] || + (mvOccupied->DoorsPermitLightBlinking < 3 && DynamicObject->Mechanik->IsAnyDoorOnlyOpen[(cab_to_end() == front ? left : right)])); + m_doorspermitright = mvOccupied->Doors.instances[(cab_to_end() == front ? right : left)].open_permit && (simulation::Time.data().wSecond % 2 < 1 || mvOccupied->DoorsPermitLightBlinking < 1 || - mvOccupied->DoorsPermitLightBlinking < 2 && DynamicObject->Mechanik->IsAnyDoorOpen[(cab_to_end() == end::front ? side::right : side::left)] || - (mvOccupied->DoorsPermitLightBlinking < 3 && DynamicObject->Mechanik->IsAnyDoorOnlyOpen[(cab_to_end() == end::front ? side::right : side::left)])); + mvOccupied->DoorsPermitLightBlinking < 2 && DynamicObject->Mechanik->IsAnyDoorOpen[(cab_to_end() == front ? right : left)] || + (mvOccupied->DoorsPermitLightBlinking < 3 && DynamicObject->Mechanik->IsAnyDoorOnlyOpen[(cab_to_end() == front ? right : left)])); } m_dirforward = mvControlled->DirActive > 0; m_dirneutral = mvControlled->DirActive == 0; @@ -8644,7 +8644,7 @@ bool TTrain::Update(double const Deltatime) } const bool kier = DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0; - const TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->CabOccupied < 0 ? end::rear : end::front, 4); + const TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->CabOccupied < 0 ? rear : front, 4); int in = 0; fEIMParams[0][6] = 0; iCarNo = 0; @@ -8680,10 +8680,10 @@ bool TTrain::Update(double const Deltatime) fPress[i][6] = p->MoverParameters->SpringBrake.SBP; bBrakes[i][0] = p->MoverParameters->SpringBrake.IsActive; bBrakes[i][1] = p->MoverParameters->SpringBrake.ShuttOff; - bDoors[i][1] = p->MoverParameters->Doors.instances[side::left].position > 0.f; - bDoors[i][2] = p->MoverParameters->Doors.instances[side::right].position > 0.f; - bDoors[i][3] = p->MoverParameters->Doors.instances[side::left].step_position > 0.f; - bDoors[i][4] = p->MoverParameters->Doors.instances[side::right].step_position > 0.f; + bDoors[i][1] = p->MoverParameters->Doors.instances[left].position > 0.f; + bDoors[i][2] = p->MoverParameters->Doors.instances[right].position > 0.f; + bDoors[i][3] = p->MoverParameters->Doors.instances[left].step_position > 0.f; + bDoors[i][4] = p->MoverParameters->Doors.instances[right].step_position > 0.f; bDoors[i][0] = bDoors[i][1] || bDoors[i][2]; iDoorNo[i] = p->iAnimType[ANIM_DOORS]; iUnits[i] = iUnitNo; @@ -8691,8 +8691,8 @@ bool TTrain::Update(double const Deltatime) asCarName[i] = p->name(); if (p->MoverParameters->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { - bPants[iUnitNo - 1][end::front] = bPants[iUnitNo - 1][end::front] || p->MoverParameters->Pantographs[end::front].is_active; - bPants[iUnitNo - 1][end::rear] = bPants[iUnitNo - 1][end::rear] || p->MoverParameters->Pantographs[end::rear].is_active; + bPants[iUnitNo - 1][front] = bPants[iUnitNo - 1][front] || p->MoverParameters->Pantographs[front].is_active; + bPants[iUnitNo - 1][rear] = bPants[iUnitNo - 1][rear] || p->MoverParameters->Pantographs[rear].is_active; } // TBD, TODO: clean up compressor data arrangement? if (iUnitNo <= 8) @@ -8753,9 +8753,9 @@ bool TTrain::Update(double const Deltatime) in++; iPowerNo = in; } - if ((kier ? p->Next(coupling::permanent) : p->Prev(coupling::permanent)) != (kier ? p->Next(coupling::control) : p->Prev(coupling::control))) + if ((kier ? p->Next(permanent) : p->Prev(permanent)) != (kier ? p->Next(control) : p->Prev(control))) iUnitNo++; - p = kier ? p->Next(coupling::control) : p->Prev(coupling::control); + p = kier ? p->Next(control) : p->Prev(control); iCarNo = i + 1; } else @@ -8845,10 +8845,10 @@ bool TTrain::Update(double const Deltatime) { const TDynamicObject *tmp{nullptr}; if (DynamicObject->NextConnected()) - if (TestFlag(mvControlled->Couplers[end::rear].CouplingFlag, coupling::control) && mvOccupied->CabOccupied == 1) + if (TestFlag(mvControlled->Couplers[rear].CouplingFlag, control) && mvOccupied->CabOccupied == 1) tmp = DynamicObject->NextConnected(); if (DynamicObject->PrevConnected()) - if (TestFlag(mvControlled->Couplers[end::front].CouplingFlag, coupling::control) && mvOccupied->CabOccupied == -1) + if (TestFlag(mvControlled->Couplers[front].CouplingFlag, control) && mvOccupied->CabOccupied == -1) tmp = DynamicObject->PrevConnected(); if (tmp) { @@ -9059,8 +9059,8 @@ bool TTrain::Update(double const Deltatime) btLampkaNadmSil.Turn(false == mvControlled->FuseFlagCheck() || mvControlled->ControlPressureSwitch ? false : mvControlled->BrakePress < 1.0); // relay is off and needs a reset - if ((mvControlled->CabOccupied == 1 && TestFlag(mvControlled->Couplers[end::rear].CouplingFlag, coupling::control)) || - (mvControlled->CabOccupied == -1 && TestFlag(mvControlled->Couplers[end::front].CouplingFlag, coupling::control))) + if ((mvControlled->CabOccupied == 1 && TestFlag(mvControlled->Couplers[rear].CouplingFlag, control)) || + (mvControlled->CabOccupied == -1 && TestFlag(mvControlled->Couplers[front].CouplingFlag, control))) { btLampkaUkrotnienie.Turn(true); } @@ -9166,8 +9166,8 @@ bool TTrain::Update(double const Deltatime) // NBMX wrzesien 2003 - drzwi oraz sygnał odjazdu if (DynamicObject->Mechanik != nullptr) { - btLampkaDoorLeft.Turn(DynamicObject->Mechanik->IsAnyDoorOpen[(cab_to_end() == end::front ? side::left : side::right)]); - btLampkaDoorRight.Turn(DynamicObject->Mechanik->IsAnyDoorOpen[(cab_to_end() == end::front ? side::right : side::left)]); + btLampkaDoorLeft.Turn(DynamicObject->Mechanik->IsAnyDoorOpen[(cab_to_end() == front ? left : right)]); + btLampkaDoorRight.Turn(DynamicObject->Mechanik->IsAnyDoorOpen[(cab_to_end() == front ? right : left)]); } btLampkaBlokadaDrzwi.Turn(mvOccupied->Doors.is_locked); btLampkaDoorLockOff.Turn(false == mvOccupied->Doors.lock_enabled); @@ -9198,16 +9198,16 @@ bool TTrain::Update(double const Deltatime) btLampkaSpringBrakeInactive.Turn(!mvOccupied->SpringBrake.IsActive); // light indicators // NOTE: sides are hardcoded to deal with setups where single cab is equipped with all indicators - btLampkaUpperLight.Turn((mvOccupied->iLights[end::front] & light::headlight_upper) != 0); - btLampkaLeftLight.Turn((mvOccupied->iLights[end::front] & light::headlight_left) != 0); - btLampkaRightLight.Turn((mvOccupied->iLights[end::front] & light::headlight_right) != 0); - btLampkaLeftEndLight.Turn((mvOccupied->iLights[end::front] & light::redmarker_left) != 0); - btLampkaRightEndLight.Turn((mvOccupied->iLights[end::front] & light::redmarker_right) != 0); - btLampkaRearUpperLight.Turn((mvOccupied->iLights[end::rear] & light::headlight_upper) != 0); - btLampkaRearLeftLight.Turn((mvOccupied->iLights[end::rear] & light::headlight_left) != 0); - btLampkaRearRightLight.Turn((mvOccupied->iLights[end::rear] & light::headlight_right) != 0); - btLampkaRearLeftEndLight.Turn((mvOccupied->iLights[end::rear] & light::redmarker_left) != 0); - btLampkaRearRightEndLight.Turn((mvOccupied->iLights[end::rear] & light::redmarker_right) != 0); + btLampkaUpperLight.Turn((mvOccupied->iLights[front] & headlight_upper) != 0); + btLampkaLeftLight.Turn((mvOccupied->iLights[front] & headlight_left) != 0); + btLampkaRightLight.Turn((mvOccupied->iLights[front] & headlight_right) != 0); + btLampkaLeftEndLight.Turn((mvOccupied->iLights[front] & redmarker_left) != 0); + btLampkaRightEndLight.Turn((mvOccupied->iLights[front] & redmarker_right) != 0); + btLampkaRearUpperLight.Turn((mvOccupied->iLights[rear] & headlight_upper) != 0); + btLampkaRearLeftLight.Turn((mvOccupied->iLights[rear] & headlight_left) != 0); + btLampkaRearRightLight.Turn((mvOccupied->iLights[rear] & headlight_right) != 0); + btLampkaRearLeftEndLight.Turn((mvOccupied->iLights[rear] & redmarker_left) != 0); + btLampkaRearRightEndLight.Turn((mvOccupied->iLights[rear] & redmarker_right) != 0); // others btLampkaMalfunction.Turn(mvControlled->dizel_heat.PA); // overheat indicator lamps @@ -9215,7 +9215,7 @@ bool TTrain::Update(double const Deltatime) btLampkaWaterOverheat.Turn(mvControlled->dizel_heat.water.is_hot); btLampkaWaterAuxOverheat.Turn(mvControlled->dizel_heat.water_aux.is_hot); btLampkaEngineOverheat.Turn(mvControlled->dizel_heat.engine_is_hot); - btLampkaMotorBlowers.Turn(mvControlled->MotorBlowers[end::front].is_active && mvControlled->MotorBlowers[end::rear].is_active); + btLampkaMotorBlowers.Turn(mvControlled->MotorBlowers[front].is_active && mvControlled->MotorBlowers[rear].is_active); btLampkaCoolingFans.Turn(mvControlled->RventRot > 1.0); btLampkaTempomat.Turn(mvOccupied->SpeedCtrlUnit.IsActive); btLampkaDistanceCounter.Turn(m_distancecounter >= 0.f); @@ -9305,9 +9305,9 @@ bool TTrain::Update(double const Deltatime) { // yB - wskazniki drugiego czlonu const TDynamicObject *tmp{nullptr}; //=mvControlled->mvSecond; //Ra 2014-07: trzeba to jeszcze wyjąć z kabiny... // Ra 2014-07: no nie ma potrzeby szukać tego w każdej klatce - if (TestFlag(mvControlled->Couplers[1].CouplingFlag, coupling::control) && mvOccupied->CabOccupied > 0) + if (TestFlag(mvControlled->Couplers[1].CouplingFlag, control) && mvOccupied->CabOccupied > 0) tmp = DynamicObject->NextConnected(); - if (TestFlag(mvControlled->Couplers[0].CouplingFlag, coupling::control) && mvOccupied->CabOccupied < 0) + if (TestFlag(mvControlled->Couplers[0].CouplingFlag, control) && mvOccupied->CabOccupied < 0) tmp = DynamicObject->PrevConnected(); if (tmp) @@ -9592,7 +9592,7 @@ bool TTrain::Update(double const Deltatime) InstrumentLightType == 4 ? mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable : false)}; InstrumentLightActive = InstrumentLightType == 3 ? true : // TODO: link the light state with the state of the master key - InstrumentLightType == 4 ? mvOccupied->iLights[end::front] != 0 || mvOccupied->iLights[end::rear] != 0 : + InstrumentLightType == 4 ? mvOccupied->iLights[front] != 0 || mvOccupied->iLights[rear] != 0 : InstrumentLightActive; btInstrumentLight.Turn(InstrumentLightActive && lightpower); btDashboardLight.Turn(DashboardLightActive && lightpower); @@ -9832,7 +9832,7 @@ void TTrain::update_sounds(double const Deltatime) if (m_localbrakepressurechange < -0.05f && mvOccupied->LocBrakePress > mvOccupied->BrakePress - 0.05) { rsSBHiss->gain(std::clamp(rsSBHiss->m_amplitudeoffset + rsSBHiss->m_amplitudefactor * -m_localbrakepressurechange * 0.05, 0.0, 1.5)); - rsSBHiss->play(sound_flags::exclusive | sound_flags::looping); + rsSBHiss->play(exclusive | looping); } else { @@ -9851,7 +9851,7 @@ void TTrain::update_sounds(double const Deltatime) if (m_localbrakepressurechange > 0.05f) { rsSBHissU->gain(std::clamp(rsSBHissU->m_amplitudeoffset + rsSBHissU->m_amplitudefactor * m_localbrakepressurechange * 0.05, 0.0, 1.5)); - rsSBHissU->play(sound_flags::exclusive | sound_flags::looping); + rsSBHissU->play(exclusive | looping); } else { @@ -9877,7 +9877,7 @@ void TTrain::update_sounds(double const Deltatime) if (volume * brakevolumescale > 0.05) { rsHiss->gain(volume * brakevolumescale); - rsHiss->play(sound_flags::exclusive | sound_flags::looping); + rsHiss->play(exclusive | looping); } else { @@ -9892,7 +9892,7 @@ void TTrain::update_sounds(double const Deltatime) if (volume * brakevolumescale > 0.05) { rsHissU->gain(volume * brakevolumescale); - rsHissU->play(sound_flags::exclusive | sound_flags::looping); + rsHissU->play(exclusive | looping); } else { @@ -9906,7 +9906,7 @@ void TTrain::update_sounds(double const Deltatime) if (volume * brakevolumescale > 0.05) { rsHissE->gain(volume * brakevolumescale); - rsHissE->play(sound_flags::exclusive | sound_flags::looping); + rsHissE->play(exclusive | looping); } else { @@ -9920,7 +9920,7 @@ void TTrain::update_sounds(double const Deltatime) if (volume * brakevolumescale > 0.05) { rsHissX->gain(volume * brakevolumescale); - rsHissX->play(sound_flags::exclusive | sound_flags::looping); + rsHissX->play(exclusive | looping); } else { @@ -9934,7 +9934,7 @@ void TTrain::update_sounds(double const Deltatime) if (volume * brakevolumescale > 0.05) { rsHissT->gain(volume * brakevolumescale); - rsHissT->play(sound_flags::exclusive | sound_flags::looping); + rsHissT->play(exclusive | looping); } else { @@ -9953,7 +9953,7 @@ void TTrain::update_sounds(double const Deltatime) if (volume > 0.05) { rsHiss->gain(volume); - rsHiss->play(sound_flags::exclusive | sound_flags::looping); + rsHiss->play(exclusive | looping); } else { @@ -9968,7 +9968,7 @@ void TTrain::update_sounds(double const Deltatime) if (volume > 0.01) { rsHissU->gain(volume); - rsHissU->play(sound_flags::exclusive | sound_flags::looping); + rsHissU->play(exclusive | looping); } else { @@ -9989,7 +9989,7 @@ void TTrain::update_sounds(double const Deltatime) volume = FreeFlyModeFlag ? 0.0 : rsBrake->m_amplitudeoffset + std::sqrt(brakeforceratio * std::lerp(0.4, 1.0, mvOccupied->Vel / (1 + mvOccupied->Vmax))) * rsBrake->m_amplitudefactor; rsBrake->pitch(rsBrake->m_frequencyoffset + mvOccupied->Vel * rsBrake->m_frequencyfactor); rsBrake->gain(volume); - rsBrake->play(sound_flags::exclusive | sound_flags::looping); + rsBrake->play(exclusive | looping); } else { @@ -10001,7 +10001,7 @@ void TTrain::update_sounds(double const Deltatime) // since it's typically ticking of the clock we can center it on tachometer or on middle of compartment bounding area if (rsFadeSound) { - rsFadeSound->play(sound_flags::exclusive | sound_flags::looping); + rsFadeSound->play(exclusive | looping); } if (dsbSlipAlarm) @@ -10009,7 +10009,7 @@ void TTrain::update_sounds(double const Deltatime) // alarm przy poslizgu dla 181/182 - BOMBARDIER if (mvControlled->SlippingWheels && DynamicObject->GetVelocity() > 1.0) { - dsbSlipAlarm->play(sound_flags::exclusive | sound_flags::looping); + dsbSlipAlarm->play(exclusive | looping); } else { @@ -10081,7 +10081,7 @@ void TTrain::update_sounds(double const Deltatime) m_rainsound->pitch(Global.Overcast - 1.0); } m_rainsound->gain(m_rainsound->m_amplitudeoffset + m_rainsound->m_amplitudefactor * 1.f); - m_rainsound->play(sound_flags::exclusive | sound_flags::looping); + m_rainsound->play(exclusive | looping); } else { @@ -10096,7 +10096,7 @@ void TTrain::update_sounds(double const Deltatime) auto const frequency{(true == dsbHasler->is_combined() ? fTachoVelocity * 0.01 : dsbHasler->m_frequencyoffset + dsbHasler->m_frequencyfactor)}; dsbHasler->pitch(frequency); dsbHasler->gain(dsbHasler->m_amplitudeoffset + dsbHasler->m_amplitudefactor); - dsbHasler->play(sound_flags::exclusive | sound_flags::looping); + dsbHasler->play(exclusive | looping); } else if (fTachoCount < 1.f) { @@ -10115,7 +10115,7 @@ void TTrain::update_sounds(double const Deltatime) { dsbBuzzerShp->pitch(dsbBuzzerShp->m_frequencyoffset + dsbBuzzerShp->m_frequencyfactor); dsbBuzzerShp->gain(dsbBuzzerShp->m_amplitudeoffset + dsbBuzzerShp->m_amplitudefactor); - dsbBuzzerShp->play(sound_flags::looping); + dsbBuzzerShp->play(looping); } } else @@ -10134,7 +10134,7 @@ void TTrain::update_sounds(double const Deltatime) { dsbBuzzer->pitch(dsbBuzzer->m_frequencyoffset + dsbBuzzer->m_frequencyfactor); dsbBuzzer->gain(dsbBuzzer->m_amplitudeoffset + dsbBuzzer->m_amplitudefactor); - dsbBuzzer->play(sound_flags::looping); + dsbBuzzer->play(looping); #ifdef _WIN32 Console::BitsSet(1 << 14); // ustawienie bitu 16 na PoKeys #endif @@ -10161,7 +10161,7 @@ void TTrain::update_sounds(double const Deltatime) m_distancecounter = -1.f; // turn off the meter after its task is done m_distancecounterclear->pitch(m_distancecounterclear->m_frequencyoffset + m_distancecounterclear->m_frequencyfactor); m_distancecounterclear->gain(m_distancecounterclear->m_amplitudeoffset + m_distancecounterclear->m_amplitudefactor); - m_distancecounterclear->play(sound_flags::exclusive); + m_distancecounterclear->play(exclusive); } } } @@ -10206,7 +10206,7 @@ void TTrain::update_sounds_resonancenoise(sound_source &Sound) if (volume > 0.05) { - Sound.pitch(frequency).gain(volume).play(sound_flags::exclusive | sound_flags::looping); + Sound.pitch(frequency).gain(volume).play(exclusive | looping); } else { @@ -10241,7 +10241,7 @@ void TTrain::update_sounds_runningnoise(sound_source &Sound) if (volume > 0.05) { - Sound.pitch(frequency).gain(volume).play(sound_flags::exclusive | sound_flags::looping); + Sound.pitch(frequency).gain(volume).play(exclusive | looping); } else { @@ -10272,7 +10272,7 @@ void TTrain::update_sounds_radio() { if (true == radioenabled && true == mvOccupied->RadioStopFlag) { - m_radiostop->play(sound_flags::exclusive | sound_flags::looping); + m_radiostop->play(exclusive | looping); radio_message_played |= true; } else @@ -10368,19 +10368,19 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName) {"tachoclock:", {dsbHasler, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, 0, 100.0}}, {"switch:", {dsbSwitch, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, 0, 100.0}}, {"pneumaticswitch:", {dsbPneumaticSwitch, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, 0, 100.0}}, - {"airsound:", {rsHiss, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, sound_parameters::amplitude, 100.0}}, - {"airsound2:", {rsHissU, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, sound_parameters::amplitude, 100.0}}, - {"airsound3:", {rsHissE, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, sound_parameters::amplitude, 100.0}}, - {"airsound4:", {rsHissX, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, sound_parameters::amplitude, 100.0}}, - {"airsound5:", {rsHissT, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, sound_parameters::amplitude, 100.0}}, - {"localbrakesound:", {rsSBHiss, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, sound_parameters::amplitude, 100.0}}, - {"localbrakesound2:", {rsSBHissU, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, sound_parameters::amplitude, 100.0}}, - {"brakesound:", {rsBrake, sound_placement::internal, -1, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, 100.0}}, + {"airsound:", {rsHiss, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, amplitude, 100.0}}, + {"airsound2:", {rsHissU, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, amplitude, 100.0}}, + {"airsound3:", {rsHissE, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, amplitude, 100.0}}, + {"airsound4:", {rsHissX, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, amplitude, 100.0}}, + {"airsound5:", {rsHissT, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, amplitude, 100.0}}, + {"localbrakesound:", {rsSBHiss, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, amplitude, 100.0}}, + {"localbrakesound2:", {rsSBHissU, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, amplitude, 100.0}}, + {"brakesound:", {rsBrake, sound_placement::internal, -1, sound_type::single, amplitude | frequency, 100.0}}, {"fadesound:", {rsFadeSound, sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, sound_type::single, 0, 100.0}}, - {"runningnoise:", {rsRunningNoise, sound_placement::internal, EU07_SOUND_GLOBALRANGE, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax}}, - {"resonancenoise:", {rsResonanceNoise, sound_placement::internal, EU07_SOUND_GLOBALRANGE, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax}}, - {"windsound:", {rsWindSound, sound_placement::internal, EU07_SOUND_GLOBALRANGE, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax}}, - {"huntingnoise:", {rsHuntingNoise, sound_placement::internal, EU07_SOUND_GLOBALRANGE, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax}}, + {"runningnoise:", {rsRunningNoise, sound_placement::internal, EU07_SOUND_GLOBALRANGE, sound_type::single, amplitude | frequency, mvOccupied->Vmax}}, + {"resonancenoise:", {rsResonanceNoise, sound_placement::internal, EU07_SOUND_GLOBALRANGE, sound_type::single, amplitude | frequency, mvOccupied->Vmax}}, + {"windsound:", {rsWindSound, sound_placement::internal, EU07_SOUND_GLOBALRANGE, sound_type::single, amplitude | frequency, mvOccupied->Vmax}}, + {"huntingnoise:", {rsHuntingNoise, sound_placement::internal, EU07_SOUND_GLOBALRANGE, sound_type::single, amplitude | frequency, mvOccupied->Vmax}}, {"rainsound:", {m_rainsound, sound_placement::internal, -1, sound_type::single, 0, 100.0}}, }; for (auto &soundconfig : internalsounds) @@ -10857,13 +10857,13 @@ void TTrain::DynamicSet(TDynamicObject *d) mvControlled = DynamicObject->FindPowered()->MoverParameters; mvSecond = nullptr; // gdyby się nic nie znalazło if (mvOccupied->Power > 1.0) // dwuczłonowe lub ukrotnienia, żeby nie szukać każdorazowo - if (mvOccupied->Couplers[1].Connected ? mvOccupied->Couplers[1].AllowedFlag & coupling::control : false) + if (mvOccupied->Couplers[1].Connected ? mvOccupied->Couplers[1].AllowedFlag & control : false) { // gdy jest człon od sprzęgu 1, a sprzęg łączony // warsztatowo (powiedzmy) if (mvOccupied->Couplers[1].Connected->Power > 1.0) // ten drugi ma moc mvSecond = (TMoverParameters *)mvOccupied->Couplers[1].Connected; // wskaźnik na drugiego } - else if (mvOccupied->Couplers[0].Connected ? mvOccupied->Couplers[0].AllowedFlag & coupling::control : false) + else if (mvOccupied->Couplers[0].Connected ? mvOccupied->Couplers[0].AllowedFlag & control : false) { // gdy jest człon od sprzęgu 0, a sprzęg łączony // warsztatowo (powiedzmy) if (mvOccupied->Couplers[0].Connected->Power > 1.0) // ale ten drugi ma moc @@ -11441,19 +11441,19 @@ void TTrain::set_cab_controls(int const Cab) auto const vehicleend{cab_to_end(Cab)}; - if ((mvOccupied->iLights[vehicleend] & light::headlight_left) != 0) + if ((mvOccupied->iLights[vehicleend] & headlight_left) != 0) { ggLeftLightButton.PutValue(1.f); } - if ((mvOccupied->iLights[vehicleend] & light::headlight_right) != 0) + if ((mvOccupied->iLights[vehicleend] & headlight_right) != 0) { ggRightLightButton.PutValue(1.f); } - if ((mvOccupied->iLights[vehicleend] & light::headlight_upper) != 0) + if ((mvOccupied->iLights[vehicleend] & headlight_upper) != 0) { ggUpperLightButton.PutValue(1.f); } - if ((mvOccupied->iLights[vehicleend] & light::redmarker_left) != 0) + if ((mvOccupied->iLights[vehicleend] & redmarker_left) != 0) { if (ggLeftEndLightButton.SubModel != nullptr) { @@ -11464,7 +11464,7 @@ void TTrain::set_cab_controls(int const Cab) ggLeftLightButton.PutValue(-1.f); } } - if ((mvOccupied->iLights[vehicleend] & light::redmarker_right) != 0) + if ((mvOccupied->iLights[vehicleend] & redmarker_right) != 0) { if (ggRightEndLightButton.SubModel != nullptr) { @@ -11493,16 +11493,16 @@ void TTrain::set_cab_controls(int const Cab) // doors permits if (false == ggDoorLeftPermitButton.is_push()) { - ggDoorLeftPermitButton.PutValue(mvOccupied->Doors.instances[(cab_to_end() == end::front ? side::left : side::right)].open_permit ? 1.f : 0.f); + ggDoorLeftPermitButton.PutValue(mvOccupied->Doors.instances[(cab_to_end() == front ? left : right)].open_permit ? 1.f : 0.f); } if (false == ggDoorRightPermitButton.is_push()) { - ggDoorRightPermitButton.PutValue(mvOccupied->Doors.instances[(cab_to_end() == end::front ? side::right : side::left)].open_permit ? 1.f : 0.f); + ggDoorRightPermitButton.PutValue(mvOccupied->Doors.instances[(cab_to_end() == front ? right : left)].open_permit ? 1.f : 0.f); } ggDoorPermitPresetButton.PutValue(mvOccupied->Doors.permit_preset); // door controls - ggDoorLeftButton.PutValue(mvOccupied->Doors.instances[(cab_to_end() == end::front ? side::left : side::right)].is_closed ? 0.f : 1.f); - ggDoorRightButton.PutValue(mvOccupied->Doors.instances[(cab_to_end() == end::front ? side::right : side::left)].is_closed ? 0.f : 1.f); + ggDoorLeftButton.PutValue(mvOccupied->Doors.instances[(cab_to_end() == front ? left : right)].is_closed ? 0.f : 1.f); + ggDoorRightButton.PutValue(mvOccupied->Doors.instances[(cab_to_end() == front ? right : left)].is_closed ? 0.f : 1.f); // door lock ggDoorSignallingButton.PutValue(mvOccupied->Doors.lock_enabled ? 1.f : 0.f); // door step @@ -11567,15 +11567,15 @@ void TTrain::set_cab_controls(int const Cab) // traction motor fans if (ggMotorBlowersFrontButton.type() != TGaugeType::push) { - ggMotorBlowersFrontButton.PutValue(mvControlled->MotorBlowers[end::front].is_enabled ? 1.f : 0.f); + ggMotorBlowersFrontButton.PutValue(mvControlled->MotorBlowers[front].is_enabled ? 1.f : 0.f); } if (ggMotorBlowersRearButton.type() != TGaugeType::push) { - ggMotorBlowersRearButton.PutValue(mvControlled->MotorBlowers[end::rear].is_enabled ? 1.f : 0.f); + ggMotorBlowersRearButton.PutValue(mvControlled->MotorBlowers[rear].is_enabled ? 1.f : 0.f); } if (ggMotorBlowersAllOffButton.type() != TGaugeType::push) { - ggMotorBlowersAllOffButton.PutValue(mvControlled->MotorBlowers[end::front].is_disabled || mvControlled->MotorBlowers[end::rear].is_disabled ? 1.f : 0.f); + ggMotorBlowersAllOffButton.PutValue(mvControlled->MotorBlowers[front].is_disabled || mvControlled->MotorBlowers[rear].is_disabled ? 1.f : 0.f); } // second controller if (ggScndCtrl.is_push()) @@ -11604,7 +11604,7 @@ void TTrain::set_cab_controls(int const Cab) { int itemindex = itemstart; itemstart++; - const TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->CabOccupied < 0 ? end::rear : end::front, flag); + const TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->CabOccupied < 0 ? rear : front, flag); while (p) { if (p->MoverParameters->eimc[eimc_p_Pmax] > 1) @@ -12054,10 +12054,10 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con std::unordered_map const autoboolgauges = { {"doormode_sw:", &mvOccupied->Doors.remote_only}, {"coolingfans_sw:", &mvControlled->RVentForceOn}, - {"pantfront_sw:", &mvPantographUnit->Pantographs[end::front].valve.is_enabled}, - {"pantrear_sw:", &mvPantographUnit->Pantographs[end::rear].valve.is_enabled}, - {"pantfrontoff_sw:", &mvPantographUnit->Pantographs[end::front].valve.is_disabled}, - {"pantrearoff_sw:", &mvPantographUnit->Pantographs[end::rear].valve.is_disabled}, + {"pantfront_sw:", &mvPantographUnit->Pantographs[front].valve.is_enabled}, + {"pantrear_sw:", &mvPantographUnit->Pantographs[rear].valve.is_enabled}, + {"pantfrontoff_sw:", &mvPantographUnit->Pantographs[front].valve.is_disabled}, + {"pantrearoff_sw:", &mvPantographUnit->Pantographs[rear].valve.is_disabled}, {"radio_sw:", &mvOccupied->Radio}, {"cablight_sw:", &Cabine[iCabn].bLight}, {"springbraketoggle_bt:", &mvOccupied->SpringBrake.Activate}, diff --git a/vehicle/Train.h b/vehicle/Train.h index 39c32403..2329c939 100644 --- a/vehicle/Train.h +++ b/vehicle/Train.h @@ -218,7 +218,7 @@ class TTrain { void update_sounds_radio(); inline end cab_to_end( int const End ) const { - return End == 2 ? end::rear : end::front; } + return End == 2 ? rear : front; } inline end cab_to_end() const { return cab_to_end( iCabn ); } diff --git a/vr/openvr_imp.cpp b/vr/openvr_imp.cpp index 814058d9..8425a3c4 100644 --- a/vr/openvr_imp.cpp +++ b/vr/openvr_imp.cpp @@ -26,13 +26,13 @@ vr_openvr::vr_openvr() vr::VRInput()->GetActionHandle("/actions/main/in/PrimaryAction", &primary_action); vr::VRInput()->GetActionHandle("/actions/main/in/SecondaryAction", &secondary_action); - hiddenarea_mesh[(size_t)vr_interface::eye_left] = create_hiddenarea_model(vr_interface::eye_left); - hiddenarea_mesh[(size_t)vr_interface::eye_right] = create_hiddenarea_model(vr_interface::eye_right); + hiddenarea_mesh[(size_t)eye_left] = create_hiddenarea_model(eye_left); + hiddenarea_mesh[(size_t)eye_right] = create_hiddenarea_model(eye_right); } -std::unique_ptr vr_openvr::create_hiddenarea_model(vr_interface::eye_e e) +std::unique_ptr vr_openvr::create_hiddenarea_model(eye_e e) { - vr::HiddenAreaMesh_t mesh = vr_system->GetHiddenAreaMesh((e == vr_interface::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 == vr_interface::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); @@ -351,14 +351,14 @@ bool vr_openvr::update_component(const std::string &rendermodel, vr::VRInputValu return !(component_state.uProperties & vr::VRComponentProperty_IsStatic); } -void vr_openvr::submit(vr_openvr::eye_e eye, opengl_texture* tex) +void vr_openvr::submit(eye_e eye, opengl_texture* tex) { vr::Texture_t hmd_tex = { (void*)(uint64_t)tex->id, vr::TextureType_OpenGL, vr::ColorSpace_Gamma }; - vr::VRCompositor()->Submit(eye == vr_interface::eye_left ? vr::Eye_Left : vr::Eye_Right, &hmd_tex); + vr::VRCompositor()->Submit(eye == eye_left ? vr::Eye_Left : vr::Eye_Right, &hmd_tex); } std::vector vr_openvr::get_render_models() @@ -976,4 +976,4 @@ std::unordered_map vr_openvr::m_buttonb user_command::none } }, }; -bool vr_openvr::backend_register = vr_interface_factory::get_instance()->register_backend("openvr", vr_openvr::create_func); +bool vr_openvr::backend_register = vr_interface_factory::get_instance()->register_backend("openvr", create_func); diff --git a/vr/vr_interface.cpp b/vr/vr_interface.cpp index 64452ba0..06baab3d 100644 --- a/vr/vr_interface.cpp +++ b/vr/vr_interface.cpp @@ -4,7 +4,7 @@ vr_interface::~vr_interface() {} -bool vr_interface_factory::register_backend(const std::string &backend, vr_interface_factory::create_method func) +bool vr_interface_factory::register_backend(const std::string &backend, create_method func) { backends[backend] = func; return true; diff --git a/widgets/map.cpp b/widgets/map.cpp index 826f2765..f58fa3c9 100644 --- a/widgets/map.cpp +++ b/widgets/map.cpp @@ -347,7 +347,7 @@ void ui::map_panel::render_contents() if (ImGui::IsMouseClicked(1)) { if (objects.size() > 1) - register_popup(std::make_unique(*this, std::move(objects))); + register_popup(std::make_unique(*this, std::move(objects))); else if (objects.size() == 1) handle_map_object_click(*this, objects.begin()->second); else diff --git a/widgets/map_objects.cpp b/widgets/map_objects.cpp index d67c73f5..38177012 100644 --- a/widgets/map_objects.cpp +++ b/widgets/map_objects.cpp @@ -45,7 +45,7 @@ map::sorted_object_list map::objects::find_in_range(glm::vec3 from, float distan float dist = glm::distance2(entry_location, search_point); if (dist < max_distance2) { - auto entry = std::make_shared(); + auto entry = std::make_shared(); entry->dynobj = dynobj; entry->name = dynobj->name(); items.emplace(dist, std::move(entry)); diff --git a/widgets/map_objects.h b/widgets/map_objects.h index 460eb998..4de5e301 100644 --- a/widgets/map_objects.h +++ b/widgets/map_objects.h @@ -19,8 +19,8 @@ struct map_object } }; -using object_list = std::vector>; -using sorted_object_list = std::map>; +using object_list = std::vector>; +using sorted_object_list = std::map>; // semaphore description (only for minimap purposes) struct semaphore : public map_object diff --git a/widgets/vehicleparams.cpp b/widgets/vehicleparams.cpp index aca13cf4..cb7f6caa 100644 --- a/widgets/vehicleparams.cpp +++ b/widgets/vehicleparams.cpp @@ -62,9 +62,9 @@ void ui::vehicleparams_panel::draw_mini(const TMoverParameters &mover) { ImGui::Image(reinterpret_cast(tex.get_id()), ImVec2(x, y), ImVec2(0, 1), ImVec2(1, 0)); - if (mover.Pantographs[end::rear].is_active) + if (mover.Pantographs[rear].is_active) draw_infobutton("╨╨╨", ImVec2(126, 10)); - if (mover.Pantographs[end::front].is_active) + if (mover.Pantographs[front].is_active) draw_infobutton("╨╨╨", ImVec2(290, 10)); if (mover.Battery) @@ -79,17 +79,17 @@ void ui::vehicleparams_panel::draw_mini(const TMoverParameters &mover) if (mover.WarningSignal) draw_infobutton(STR_C("horn"), ImVec2(361, 11)); - if (mover.iLights[end::front] & light::redmarker_left) + if (mover.iLights[front] & redmarker_left) draw_infobutton("o", ImVec2(490, 71), ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); - else if (mover.iLights[end::front] & light::headlight_left) + else if (mover.iLights[front] & headlight_left) draw_infobutton("O", ImVec2(490, 71), ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); - if (mover.iLights[end::front] & light::redmarker_right) + if (mover.iLights[front] & redmarker_right) draw_infobutton("o", ImVec2(443, 71), ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); - else if (mover.iLights[end::front] & light::headlight_right) + else if (mover.iLights[front] & headlight_right) draw_infobutton("O", ImVec2(443, 71), ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); - if (mover.iLights[end::front] & light::headlight_upper) + if (mover.iLights[front] & headlight_upper) draw_infobutton("O", ImVec2(467, 18), ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); } ImGui::EndChild(); @@ -147,8 +147,8 @@ void ui::vehicleparams_panel::render_contents() 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[end::rear].is_active ? (mover.PantRearVolt > 0.0 ? 'O' : 'o') : '.'), - (mover.Pantographs[end::front].is_active ? (mover.PantFrontVolt > 0.0 ? 'P' : 'p') : '.'), (mover.PantPressLockActive ? '!' : (mover.PantPressSwitchActive ? '*' : '.')), + (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' : '.')), @@ -156,9 +156,9 @@ void ui::vehicleparams_panel::render_contents() (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[end::front].power_high.voltage, mover.Couplers[end::front].power_high.current, std::string(mover.Couplers[end::front].power_high.is_local ? "" : "-").c_str(), - std::string(vehicle.DirectionGet() ? ":<<:" : ":>>:").c_str(), std::string(mover.Couplers[end::rear].power_high.is_local ? "" : "-").c_str(), - mover.Couplers[end::rear].power_high.voltage, mover.Couplers[end::rear].power_high.current); + 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(), + mover.Couplers[rear].power_high.voltage, mover.Couplers[rear].power_high.current); ImGui::TextUnformatted(buffer.data()); @@ -171,8 +171,8 @@ void ui::vehicleparams_panel::render_contents() // engine mover.EnginePower, std::abs(mover.TrainType == dt_EZT ? mover.ShowCurrent(0) : mover.Im), // revolutions - std::abs(mover.enrot) * 60, std::abs(mover.nrot) * mover.Transmision.Ratio * 60, mover.RventRot * 60, std::abs(mover.MotorBlowers[end::front].revolutions), - std::abs(mover.MotorBlowers[end::rear].revolutions), mover.dizel_heat.rpmw, mover.dizel_heat.rpmw2); + std::abs(mover.enrot) * 60, std::abs(mover.nrot) * mover.Transmision.Ratio * 60, mover.RventRot * 60, std::abs(mover.MotorBlowers[front].revolutions), + std::abs(mover.MotorBlowers[rear].revolutions), mover.dizel_heat.rpmw, mover.dizel_heat.rpmw2); ImGui::TextUnformatted(buffer.data()); diff --git a/world/EvLaunch.cpp b/world/EvLaunch.cpp index c276e520..67bd59d8 100644 --- a/world/EvLaunch.cpp +++ b/world/EvLaunch.cpp @@ -67,8 +67,8 @@ bool TEventLauncher::Load(cParser *parser) else { // this launcher may be activated by radio message std::map messages { - { "radio_call1", radio_message::call1 }, - { "radio_call3", radio_message::call3 } + { "radio_call1", call1 }, + { "radio_call3", call3 } }; const auto lookup = messages.find( token ); iKey = lookup != messages.end() ? lookup->second : diff --git a/world/Event.cpp b/world/Event.cpp index 314bab77..ac578b01 100644 --- a/world/Event.cpp +++ b/world/Event.cpp @@ -35,7 +35,7 @@ http://mozilla.org/MPL/2.0/. #include "widgets/map_objects.h" void -basic_event::event_conditions::bind( basic_event::node_sequence *Nodes ) { +basic_event::event_conditions::bind( node_sequence *Nodes ) { memcompare_cells = Nodes; } @@ -45,14 +45,14 @@ basic_event::event_conditions::init() { tracks.clear(); - if( flags & ( flags::track_busy | flags::track_free ) ) { + if( flags & ( track_busy | track_free ) ) { for( auto &target : *memcompare_cells ) { tracks.emplace_back( simulation::Paths.find( std::get( target ) ) ); if( tracks.back() == nullptr ) { // legacy compatibility behaviour, instead of disabling the event we disable the memory cell comparison test // m_ignored = true; // deaktywacja // ErrorLog( "Bad event: track \"" + std::get( target ) + "\" referenced in event \"" + asName + "\" doesn't exist" ); - flags &= ~( flags::track_busy | flags::track_free ); // zerowanie flag + flags &= ~( track_busy | track_free ); // zerowanie flag } } } @@ -76,7 +76,7 @@ basic_event::event_conditions::test() const { return false; } } - if( flags & flags::track_busy ) { + if( flags & track_busy ) { auto trackbusyresult { true }; std::string trackbusylog { "Test: Track busy - " }; for( auto *track : tracks ) { @@ -103,7 +103,7 @@ basic_event::event_conditions::test() const { return false; } } - if( flags & flags::track_free ) { + if( flags & track_free ) { auto trackfreeresult { true }; std::string trackfreelog{ "Test: Track free - " }; for( auto *track : tracks ) { @@ -123,7 +123,7 @@ basic_event::event_conditions::test() const { return false; } } - if( flags & ( flags::text | flags::value1 | flags::value2 ) ) { + if( flags & ( text | value1 | value2 ) ) { // porównanie wartości for( auto &cellwrapper : *memcompare_cells ) { const auto *cell { static_cast( std::get( cellwrapper ) ) }; @@ -147,19 +147,19 @@ basic_event::event_conditions::test() const { std::string comparisonlog = "Test: MemCompare - " + cell->name() + " - "; comparisonlog += - ( TestFlag( flags, flags::text ) ? + ( TestFlag( flags, text ) ? "[" + cell->Text() + "] " + to_string( memcompare_text_operator ) + " [" + memcompare_text + "]" : "[*]" ) + combiner; comparisonlog += - ( TestFlag( flags, flags::value1 ) ? + ( TestFlag( flags, value1 ) ? "[" + to_string( cell->Value1(), 2 ) + "] " + to_string( memcompare_value1_operator ) + " [" + to_string( memcompare_value1, 2 ) + "]" : "[*]" ) + combiner; comparisonlog += - ( TestFlag( flags, flags::value2 ) ? + ( TestFlag( flags, value2 ) ? "[" + to_string( cell->Value2(), 2 ) + "] " + to_string( memcompare_value2_operator ) + " [" + to_string( memcompare_value2, 2 ) + "]" : "[*]" ) + " - "; @@ -184,13 +184,13 @@ basic_event::event_conditions::deserialize( cParser &Input ) { std::string token; while( true == Input.getTokens() && false == (token = Input.peek()).empty() - && false == basic_event::is_keyword(token) ) { + && false == is_keyword(token) ) { if( token == "trackoccupied" ) { - flags |= flags::track_busy; + flags |= track_busy; } else if( token == "trackfree" ) { - flags |= flags::track_free; + flags |= track_free; } else if( token == "propability" || token == "probability") { //remove propability in few years after changing old scenery scripts 01.2021 flags |= flags::probability; @@ -202,19 +202,19 @@ basic_event::event_conditions::deserialize( cParser &Input ) { if( Input.peek() != "*" ) //"*" - nie brac command pod uwage { // zapamiętanie łańcucha do porównania Input >> memcompare_text; - flags |= flags::text; + flags |= text; } Input.getTokens(); if( Input.peek() != "*" ) //"*" - nie brac val1 pod uwage { Input >> memcompare_value1; - flags |= flags::value1; + flags |= value1; } Input.getTokens(); if( Input.peek() != "*" ) //"*" - nie brac val2 pod uwage { Input >> memcompare_value2; - flags |= flags::value2; + flags |= value2; } } else if( token == "memcompareex" ) { @@ -227,7 +227,7 @@ basic_event::event_conditions::deserialize( cParser &Input ) { memcompare_text_operator = comparison_operator_from_string( operatorstring ); Input.getTokens( 1, false ); // case sensitive Input >> memcompare_text; - flags |= flags::text; + flags |= text; } Input.getTokens(); if( Input.peek() != "*" ) //"*" - nie brac pod uwage @@ -237,7 +237,7 @@ basic_event::event_conditions::deserialize( cParser &Input ) { memcompare_value1_operator = comparison_operator_from_string( operatorstring ); Input.getTokens(); Input >> memcompare_value1; - flags |= flags::value1; + flags |= value1; } Input.getTokens(); if( Input.peek() != "*" ) //"*" - nie brac pod uwage @@ -247,7 +247,7 @@ basic_event::event_conditions::deserialize( cParser &Input ) { memcompare_value2_operator = comparison_operator_from_string( operatorstring ); Input.getTokens(); Input >> memcompare_value2; - flags |= flags::value2; + flags |= value2; } } } @@ -259,10 +259,10 @@ basic_event::event_conditions::export_as_text( std::ostream &Output ) const { if( flags != 0 ) { Output << "condition "; - if( ( flags & flags::track_busy ) != 0 ) { + if( ( flags & track_busy ) != 0 ) { Output << "trackoccupied "; } - if( ( flags & flags::track_free ) != 0 ) { + if( ( flags & track_free ) != 0 ) { Output << "trackfree "; } if( ( flags & flags::probability ) != 0 ) { @@ -270,13 +270,13 @@ basic_event::event_conditions::export_as_text( std::ostream &Output ) const { << "probability " << probability << ' '; } - if( ( flags & ( flags::text | flags::value1 | flags::value2 ) ) != 0 ) { + if( ( flags & ( text | value1 | value2 ) ) != 0 ) { // NOTE: export doesn't preserve original memcompare condition, these are all upgraded to memcompareex format for simplicity Output << "memcompareex " - << ( ( flags & flags::text ) == 0 ? "*" : memcompare_text + ' ' + to_string( memcompare_text_operator ) ) << ' ' - << ( ( flags & flags::value1 ) == 0 ? "*" : std::to_string( memcompare_value1 ) + ' ' + to_string( memcompare_value1_operator ) ) << ' ' - << ( ( flags & flags::value2 ) == 0 ? "*" : std::to_string( memcompare_value2 ) + ' ' + to_string( memcompare_value2_operator ) ) << ' '; + << ( ( flags & text ) == 0 ? "*" : memcompare_text + ' ' + to_string( memcompare_text_operator ) ) << ' ' + << ( ( flags & value1 ) == 0 ? "*" : std::to_string( memcompare_value1 ) + ' ' + to_string( memcompare_value1_operator ) ) << ' ' + << ( ( flags & value2 ) == 0 ? "*" : std::to_string( memcompare_value2 ) + ' ' + to_string( memcompare_value2_operator ) ) << ' '; } } } @@ -476,7 +476,7 @@ updatevalues_event::init() { std::string updatevalues_event::type() const { - return (m_input.flags & flags::mode_add) == 0 ? "updatevalues" : "addvalues"; + return (m_input.flags & mode_add) == 0 ? "updatevalues" : "addvalues"; } // deserialize() subclass details @@ -486,17 +486,17 @@ updatevalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpa Input.getTokens( 1, false ); // case sensitive Input >> m_input.data_text; if( m_input.data_text != "*" ) { //"*" - nie brac command pod uwage - m_input.flags |= flags::text; + m_input.flags |= text; } Input.getTokens(); if( Input.peek() != "*" ) { //"*" - nie brac val1 pod uwage Input >> m_input.data_value_1; - m_input.flags |= flags::value1; + m_input.flags |= value1; } Input.getTokens(); if( Input.peek() != "*" ) { //"*" - nie brac val2 pod uwage Input >> m_input.data_value_2; - m_input.flags |= flags::value2; + m_input.flags |= value2; } Input.getTokens(); // optional blocks @@ -518,10 +518,10 @@ updatevalues_event::run_() { if( false == m_conditions.test() ) { return; } - WriteLog( "Type: " + std::string( m_input.flags & flags::mode_add ? "AddValues" : "UpdateValues" ) + " & Track command - [" - + ( m_input.flags & flags::text ? m_input.data_text : "X" ) + "] [" - + ( m_input.flags & flags::value1 ? to_string( m_input.data_value_1, 2 ) : "X" ) + "] [" - + ( m_input.flags & flags::value2 ? to_string( m_input.data_value_2, 2 ) : "X" ) + "]" ); + WriteLog( "Type: " + std::string( m_input.flags & mode_add ? "AddValues" : "UpdateValues" ) + " & Track command - [" + + ( m_input.flags & text ? m_input.data_text : "X" ) + "] [" + + ( m_input.flags & value1 ? to_string( m_input.data_value_1, 2 ) : "X" ) + "] [" + + ( m_input.flags & value2 ? to_string( m_input.data_value_2, 2 ) : "X" ) + "]" ); for( auto &target : m_targets ) { auto *targetcell { static_cast( std::get( target ) ) }; if( targetcell == nullptr ) { continue; } @@ -552,9 +552,9 @@ void updatevalues_event::export_as_text_( std::ostream &Output ) const { Output - << ( ( m_input.flags & flags::text ) == 0 ? "*" : m_input.data_text ) << ' ' - << ( ( m_input.flags & flags::value1 ) == 0 ? "*" : std::to_string( m_input.data_value_1 ) ) << ' ' - << ( ( m_input.flags & flags::value2 ) == 0 ? "*" : std::to_string( m_input.data_value_2 ) ) << ' '; + << ( ( m_input.flags & text ) == 0 ? "*" : m_input.data_text ) << ' ' + << ( ( m_input.flags & value1 ) == 0 ? "*" : std::to_string( m_input.data_value_1 ) ) << ' ' + << ( ( m_input.flags & value2 ) == 0 ? "*" : std::to_string( m_input.data_value_2 ) ) << ' '; m_conditions.export_as_text( Output ); } @@ -563,7 +563,7 @@ updatevalues_event::export_as_text_( std::ostream &Output ) const { bool updatevalues_event::is_instant() const { - return (m_input.flags & flags::mode_add) != 0 && m_delay == 0.0; + return (m_input.flags & mode_add) != 0 && m_delay == 0.0; } @@ -891,7 +891,7 @@ copyvalues_event::type() const { void copyvalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { - m_input.flags = flags::text | flags::value1 | flags::value2; // normalnie trzy + m_input.flags = text | value1 | value2; // normalnie trzy std::string token; int paramidx { 0 }; @@ -907,7 +907,7 @@ copyvalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad break; } case 2: { // maska wartości - m_input.flags = stol_def( token, flags::text | flags::value1 | flags::value2 ); + m_input.flags = stol_def( token, text | value1 | value2 ); break; } default: { @@ -928,9 +928,9 @@ copyvalues_event::run_() { m_input.data_value_2 = datasource->Value2(); WriteLog( "Type: CopyValues - [" - + ( m_input.flags & flags::text ? m_input.data_text : "X" ) + "] [" - + ( m_input.flags & flags::value1 ? to_string( m_input.data_value_1, 2 ) : "X" ) + "] [" - + ( m_input.flags & flags::value2 ? to_string( m_input.data_value_2, 2 ) : "X" ) + "]" ); + + ( m_input.flags & text ? m_input.data_text : "X" ) + "] [" + + ( m_input.flags & value1 ? to_string( m_input.data_value_1, 2 ) : "X" ) + "] [" + + ( m_input.flags & value2 ? to_string( m_input.data_value_2, 2 ) : "X" ) + "]" ); // TODO: dump status of target cells after the operation for( auto &target : m_targets ) { auto *targetcell { static_cast( std::get( target ) ) }; @@ -965,7 +965,7 @@ copyvalues_event::export_as_text_( std::ostream &Output ) const { << ( datasource != nullptr ? datasource->name() : std::get( m_input.data_source ) ) - << ' ' << ( m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ) << ' '; + << ' ' << ( m_input.flags & ( text | value1 | value2 ) ) << ' '; } @@ -988,7 +988,7 @@ whois_event::type() const { void whois_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { - m_input.flags = flags::text | flags::value1 | flags::value2; // normalnie trzy + m_input.flags = text | value1 | value2; // normalnie trzy std::string token; int paramidx { 0 }; @@ -1000,7 +1000,7 @@ whois_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { Input >> token; switch( ++paramidx ) { case 1: { // maska wartości - m_input.flags = stol_def( token, flags::text | flags::value1 | flags::value2 ); + m_input.flags = stol_def( token, text | value1 | value2 ); break; } default: { @@ -1024,10 +1024,10 @@ whois_event::run_() { // +16: load type, load amount, max load amount // +8: destination, direction, engine power // +0: train name, station count, stop on next station - if( m_input.flags & flags::whois_name ) { + if( m_input.flags & whois_name ) { // +32 or +40 // next station name - if( m_input.flags & flags::mode_alt ) { + if( m_input.flags & mode_alt ) { auto const *owner { ( m_activator->Mechanik != nullptr && m_activator->Mechanik->primary() ? m_activator->Mechanik : @@ -1045,7 +1045,7 @@ whois_event::run_() { nextstop, // next station name 0, // unused isstop, // stop at next station or passthrough - m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); + m_input.flags & ( text | value1 | value2 ) ); WriteLog( "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " @@ -1059,7 +1059,7 @@ whois_event::run_() { m_activator->asName, // vehicle name 0, // unused 0, // unused - m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); + m_input.flags & ( text | value1 | value2 ) ); WriteLog( "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " @@ -1068,10 +1068,10 @@ whois_event::run_() { + "[X]" ); } } - else if( m_input.flags & flags::whois_load ) { + else if( m_input.flags & whois_load ) { // +16 or +24 // jeśli pytanie o ładunek - if( m_input.flags & flags::mode_alt ) { + if( m_input.flags & mode_alt ) { // jeśli typ pojazdu // TODO: define and recognize individual request types auto const owner { ( @@ -1091,7 +1091,7 @@ whois_event::run_() { m_activator->MoverParameters->TypeName, // typ pojazdu consistbrakelevel, collisiondistance, - m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); + m_input.flags & ( text | value1 | value2 ) ); WriteLog( "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " @@ -1105,7 +1105,7 @@ whois_event::run_() { m_activator->MoverParameters->LoadType.name, // nazwa ładunku m_activator->MoverParameters->LoadAmount, // aktualna ilość m_activator->MoverParameters->MaxLoad, // maksymalna ilość - m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); + m_input.flags & ( text | value1 | value2 ) ); WriteLog( "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " @@ -1115,12 +1115,12 @@ whois_event::run_() { } } // +8 - else if( m_input.flags & flags::mode_alt ) { // jeśli miejsce docelowe pojazdu + else if( m_input.flags & mode_alt ) { // jeśli miejsce docelowe pojazdu targetcell->UpdateValues( m_activator->asDestination, // adres docelowy m_activator->DirectionGet(), // kierunek pojazdu względem czoła składu (1=zgodny,-1=przeciwny) m_activator->MoverParameters->Power, // moc pojazdu silnikowego: 0 dla wagonu - m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); + m_input.flags & ( text | value1 | value2 ) ); WriteLog( "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " @@ -1137,7 +1137,7 @@ whois_event::run_() { m_activator->Mechanik->IsStop() ? 1 : 0, // 1, gdy ma tu zatrzymanie - m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); + m_input.flags & ( text | value1 | value2 ) ); WriteLog( "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " + "[train: " + m_activator->Mechanik->TrainName() + "], " @@ -1152,7 +1152,7 @@ whois_event::run_() { void whois_event::export_as_text_( std::ostream &Output ) const { - Output << ( m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ) << ' '; + Output << ( m_input.flags & ( text | value1 | value2 ) ) << ' '; } @@ -1208,12 +1208,12 @@ logvalues_event::export_as_text_( std::ostream &Output ) const { void multi_event::init() { - auto const conditiontchecksmemcell { ( m_conditions.flags & ( flags::text | flags::value1 | flags::value2 ) ) != 0 }; + auto const conditiontchecksmemcell { ( m_conditions.flags & ( text | value1 | value2 ) ) != 0 }; // not all multi-events have memory cell checks, for the ones which don't we can keep quiet about it init_targets( simulation::Memory, "memory cell", conditiontchecksmemcell ); if( m_ignored ) { // legacy compatibility behaviour, instead of disabling the event we disable the memory cell comparison test - m_conditions.flags &= ~( flags::text | flags::value1 | flags::value2 ); + m_conditions.flags &= ~( text | value1 | value2 ); m_ignored = false; } // conditional data @@ -1409,12 +1409,12 @@ sound_event::run_() { m_soundradiochannel ); } else { - targetsound->play( sound_flags::exclusive | sound_flags::event ); + targetsound->play( exclusive | event ); } break; } case -1: { - targetsound->play( sound_flags::exclusive | sound_flags::looping | sound_flags::event ); + targetsound->play( exclusive | looping | event ); break; } default: { diff --git a/world/Event.h b/world/Event.h index 21828339..bdcd6778 100644 --- a/world/Event.h +++ b/world/Event.h @@ -114,12 +114,12 @@ protected: comparison_operator memcompare_value2_operator { comparison_operator::equal }; // used by conditional_memcompare comparison_operator memcompare_text_operator { comparison_operator::equal }; // used by conditional_memcompare comparison_pass memcompare_pass { comparison_pass::all }; // used by conditional_memcompare - basic_event::node_sequence *memcompare_cells; // used by conditional_memcompare + node_sequence *memcompare_cells; // used by conditional_memcompare std::vector tracks; // used by conditional_track bool has_else { false }; void deserialize( cParser &Input ); - void bind( basic_event::node_sequence *Nodes ); + void bind( node_sequence *Nodes ); void init(); // verifies whether event meets execution condition(s) bool test() const; diff --git a/world/Segment.cpp b/world/Segment.cpp index a91ecea8..0750a839 100644 --- a/world/Segment.cpp +++ b/world/Segment.cpp @@ -20,12 +20,12 @@ http://mozilla.org/MPL/2.0/. void segment_data::deserialize( cParser &Input, glm::dvec3 const &Offset ) { - points[ segment_data::point::start ] = LoadPoint( Input ) + Offset; + points[ start ] = LoadPoint( Input ) + Offset; Input.getTokens(); Input >> rolls[ 0 ]; - points[ segment_data::point::control1 ] = LoadPoint( Input ); - points[ segment_data::point::control2 ] = LoadPoint( Input ); - points[ segment_data::point::end ] = LoadPoint( Input ) + Offset; + points[ control1 ] = LoadPoint( Input ); + points[ control2 ] = LoadPoint( Input ); + points[ end ] = LoadPoint( Input ) + Offset; Input.getTokens( 2 ); Input >> rolls[ 1 ] @@ -53,7 +53,7 @@ bool TSegment::Init(glm::dvec3 NewPoint1, glm::dvec3 NewPoint2, double fNewStep, */ { // prosty ze zmienną przechyłką musi być segmentowany jak krzywe dir = (NewPoint2 - NewPoint1) / 3.0; // punkty kontrolne prostego są w 1/3 długości - return TSegment::Init( + return Init( NewPoint1, NewPoint1 + dir, NewPoint2 - dir, NewPoint2, fNewStep, fNewRoll1, fNewRoll2, true); diff --git a/world/mtable.cpp b/world/mtable.cpp index cec54f87..d0db6705 100644 --- a/world/mtable.cpp +++ b/world/mtable.cpp @@ -139,7 +139,7 @@ bool TTrainParameters::UpdateMTable(double hh, double mm, std::string const &New return OK; /*czy jest nastepna stacja*/ } -bool Mtable::TTrainParameters::RewindTimeTable(std::string actualStationName) { +bool TTrainParameters::RewindTimeTable(std::string actualStationName) { if( actualStationName.compare( 0, 19, "PassengerStopPoint:" ) == 0 ) { actualStationName = ToLower( actualStationName.substr( 19 ) ); diff --git a/world/station.cpp b/world/station.cpp index 5481d6e2..06754b4b 100644 --- a/world/station.cpp +++ b/world/station.cpp @@ -22,7 +22,7 @@ basic_station Station; // exchanges load with consist attached to specified vehicle, operating on specified schedule double -basic_station::update_load( TDynamicObject *First, Mtable::TTrainParameters &Schedule, int const Platform ) { +basic_station::update_load( TDynamicObject *First, TTrainParameters &Schedule, int const Platform ) { // TODO: filter out maintenance stops when determining first and last stop auto const firststop { Schedule.StationIndex == 1 };