mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 17:46:48 +01:00
refactor(physics): the ends and the sides of a vehicle as scoped enums
end and side were unscoped enums: front, rear, left and right sat in the
global namespace (the test PCH had to leave mover.h out for it), and an end
went into any int, a side into an end, without a word from the compiler. They
become enum class VehicleEnd and VehicleSide (physics/vehicletypes.h); the
names follow the rule for types, and leave "end" and "side" to the many
locals of that name. The numbers stay: front 0, rear 1, right 0, left 1.
- ByEnd<T> / BySide<T>: two values indexed by the enum, and by a number
where a loop or a format counts them. The arrays of the ends and the sides
are these now: Couplers, Neighbours, Pantographs, MotorBlowers, Lights,
iLights, Doors.instances, pVehicles, IsAnyDoor*, m_lighthints, vCoulpler,
m_couplersounds, m_mirrormotion, iInventory, and the voltages of the
couplers
- VehicleEnds / VehicleSides to go through them, Opposite() in place of
1 - end, NumberOf() where a number is needed
- the couplers and the collisions take the ends they work on as VehicleEnd:
CouplerForce, CouplerVelocityDifference, CollisionDetect, crush_hit,
CompatibleCoupling and the rest of their family, DirF, DirPatch, and of
the vehicle couple, uncouple, the adapters, off_track_gap, has_signal_on;
Attach, Dettach and DettachStatus have overloads by the ends
- neighbour_data::FacingEnd() and TCoupling::ConnectedEnd() give the end of
the other vehicle as VehicleEnd; the fields stay numbers, as they hold -1
and 2 for "none" in places
The walks along the consist (FirstFind, Neighbour, the AI's coupling and
uncoupling) still carry the ends as numbers; where one of them meets a typed
end, NumberOf() and EndOf() say so, and keep the number as it was.
Kept as it was, and worth a look: TDynamicObject::SetLights() switches the
headlights A/B off by CabActive with the cases end::front and end::rear, that
is CabActive 0 and 1, while CabActive is 1 or -1 for the cabs; the cases are
NumberOf(VehicleEnd::front / rear) now, the same numbers.
No change in behaviour: 1144/1144 tests, golden traces exact against staging
62f7a29b. betterRenderer/, not built, has had only end:: and side:: renamed.
This commit is contained in:
+36
-36
@@ -126,8 +126,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( MoverParameters->Couplers[ end::front ].CouplingFlag.HasAll(Coupling::coupler) ) {
|
||||
if( MoverParameters->Couplers[ end::front ].Render ) {
|
||||
if( MoverParameters->Couplers[ VehicleEnd::front ].CouplingFlag.HasAll(Coupling::coupler) ) {
|
||||
if( MoverParameters->Couplers[ VehicleEnd::front ].Render ) {
|
||||
btCoupler1.TurnOn();
|
||||
}
|
||||
else {
|
||||
@@ -136,13 +136,13 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
btnOn = true;
|
||||
}
|
||||
else {
|
||||
if( true == MoverParameters->Couplers[ end::front ].has_adapter() ) {
|
||||
if( true == MoverParameters->Couplers[ VehicleEnd::front ].has_adapter() ) {
|
||||
btCoupler1.TurnxOnWithOffAsFallback();
|
||||
btnOn = true;
|
||||
}
|
||||
}
|
||||
if( MoverParameters->Couplers[ end::rear ].CouplingFlag.HasAll(Coupling::coupler) ) {
|
||||
if( MoverParameters->Couplers[ end::rear ].Render ) {
|
||||
if( MoverParameters->Couplers[ VehicleEnd::rear ].CouplingFlag.HasAll(Coupling::coupler) ) {
|
||||
if( MoverParameters->Couplers[ VehicleEnd::rear ].Render ) {
|
||||
btCoupler2.TurnOn();
|
||||
}
|
||||
else {
|
||||
@@ -151,7 +151,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
btnOn = true;
|
||||
}
|
||||
else {
|
||||
if( true == MoverParameters->Couplers[ end::rear ].has_adapter() ) {
|
||||
if( true == MoverParameters->Couplers[ VehicleEnd::rear ].has_adapter() ) {
|
||||
btCoupler2.TurnxOnWithOffAsFallback();
|
||||
btnOn = true;
|
||||
}
|
||||
@@ -168,7 +168,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
SetPneumatic(true, true); // ktore z nich nalezy
|
||||
SetPneumatic(false, true); // wyswietlic w tej klatce
|
||||
|
||||
if (MoverParameters->Couplers[end::front].CouplingFlag.HasAll(Coupling::brakeHose))
|
||||
if (MoverParameters->Couplers[VehicleEnd::front].CouplingFlag.HasAll(Coupling::brakeHose))
|
||||
{
|
||||
switch (cp1)
|
||||
{
|
||||
@@ -188,7 +188,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
btnOn = true;
|
||||
}
|
||||
|
||||
if (MoverParameters->Couplers[end::rear].CouplingFlag.HasAll(Coupling::brakeHose))
|
||||
if (MoverParameters->Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::brakeHose))
|
||||
{
|
||||
switch (cp2)
|
||||
{
|
||||
@@ -209,7 +209,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
}
|
||||
|
||||
// przewody zasilajace, j.w. (yB)
|
||||
if (MoverParameters->Couplers[end::front].CouplingFlag.HasAll(Coupling::mainHose))
|
||||
if (MoverParameters->Couplers[VehicleEnd::front].CouplingFlag.HasAll(Coupling::mainHose))
|
||||
{
|
||||
switch (sp1)
|
||||
{
|
||||
@@ -229,7 +229,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
btnOn = true;
|
||||
}
|
||||
|
||||
if (MoverParameters->Couplers[end::rear].CouplingFlag.HasAll(Coupling::mainHose))
|
||||
if (MoverParameters->Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::mainHose))
|
||||
{
|
||||
switch (sp2)
|
||||
{
|
||||
@@ -254,18 +254,18 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
{
|
||||
// przewody powietrzne j.w., ABu: decyzja czy rysowac tylko na podstawie
|
||||
// 'render'
|
||||
if (MoverParameters->Couplers[end::front].CouplingFlag.HasAll(Coupling::brakeHose))
|
||||
if (MoverParameters->Couplers[VehicleEnd::front].CouplingFlag.HasAll(Coupling::brakeHose))
|
||||
{
|
||||
if (MoverParameters->Couplers[end::front].Render)
|
||||
if (MoverParameters->Couplers[VehicleEnd::front].Render)
|
||||
btCPneumatic1.TurnOn();
|
||||
else
|
||||
btCPneumatic1r.TurnOn();
|
||||
btnOn = true;
|
||||
}
|
||||
|
||||
if (MoverParameters->Couplers[end::rear].CouplingFlag.HasAll(Coupling::brakeHose))
|
||||
if (MoverParameters->Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::brakeHose))
|
||||
{
|
||||
if (MoverParameters->Couplers[end::rear].Render)
|
||||
if (MoverParameters->Couplers[VehicleEnd::rear].Render)
|
||||
btCPneumatic2.TurnOn();
|
||||
else
|
||||
btCPneumatic2r.TurnOn();
|
||||
@@ -348,36 +348,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[VehicleEnd::front], light::redmarker_left | light::redmarker_right ) ) {
|
||||
m_endsignals1.Turn( true );
|
||||
btnOn = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (TestFlag(MoverParameters->iLights[end::front], light::redmarker_left) && !HeadlightsAoff)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::redmarker_left) && !HeadlightsAoff)
|
||||
{
|
||||
m_endsignal13.Turn( true );
|
||||
btnOn = true;
|
||||
}
|
||||
if (TestFlag(MoverParameters->iLights[end::front], light::redmarker_right) && !HeadlightsAoff)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::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[VehicleEnd::rear], light::redmarker_left | light::redmarker_right ) ) {
|
||||
m_endsignals2.Turn( true );
|
||||
btnOn = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (TestFlag(MoverParameters->iLights[end::rear], light::redmarker_left) && !HeadlightsBoff)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::redmarker_left) && !HeadlightsBoff)
|
||||
{
|
||||
m_endsignal23.Turn( true );
|
||||
btnOn = true;
|
||||
}
|
||||
if (TestFlag(MoverParameters->iLights[end::rear], light::redmarker_right) && !HeadlightsBoff)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::redmarker_right) && !HeadlightsBoff)
|
||||
{
|
||||
m_endsignal22.Turn( true );
|
||||
btnOn = true;
|
||||
@@ -385,12 +385,12 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
}
|
||||
}
|
||||
// tablice blaszane:
|
||||
if (TestFlag(MoverParameters->iLights[end::front], light::rearendsignals)) {
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::rearendsignals)) {
|
||||
m_endtab1.Turn( true );
|
||||
btnOn = true;
|
||||
}
|
||||
// else btEndSignalsTab1.TurnOff();
|
||||
if (TestFlag(MoverParameters->iLights[end::rear], light::rearendsignals)) {
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::rearendsignals)) {
|
||||
m_endtab2.Turn( true );
|
||||
btnOn = true;
|
||||
}
|
||||
@@ -438,7 +438,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[VehicleEnd::front], light::headlight_left)
|
||||
&& !HeadlightsAoff && !HighBeamLights)
|
||||
{
|
||||
if( DimHeadlights ) {
|
||||
@@ -449,7 +449,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
}
|
||||
btnOn = true;
|
||||
}
|
||||
if (TestFlag(MoverParameters->iLights[end::front], light::headlight_upper)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::headlight_upper)
|
||||
&& !HeadlightsAoff)
|
||||
{
|
||||
if( DimHeadlights ) {
|
||||
@@ -460,7 +460,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
}
|
||||
btnOn = true;
|
||||
}
|
||||
if (TestFlag(MoverParameters->iLights[end::front], light::headlight_right)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::headlight_right)
|
||||
&& !HeadlightsAoff && !HighBeamLights)
|
||||
{
|
||||
if( DimHeadlights ) {
|
||||
@@ -472,7 +472,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
btnOn = true;
|
||||
}
|
||||
// else btHeadSignals13.TurnOff();
|
||||
if (TestFlag(MoverParameters->iLights[end::rear], light::headlight_left)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::headlight_left)
|
||||
&& !HeadlightsBoff && !HighBeamLights)
|
||||
{
|
||||
if( DimHeadlights ) {
|
||||
@@ -483,7 +483,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
}
|
||||
btnOn = true;
|
||||
}
|
||||
if (TestFlag(MoverParameters->iLights[end::rear], light::headlight_upper)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::headlight_upper)
|
||||
&& !HeadlightsBoff)
|
||||
{
|
||||
if( DimHeadlights ) {
|
||||
@@ -494,7 +494,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
}
|
||||
btnOn = true;
|
||||
}
|
||||
if (TestFlag(MoverParameters->iLights[end::rear], light::headlight_right)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::headlight_right)
|
||||
&& !HeadlightsBoff && !HighBeamLights)
|
||||
{
|
||||
if( DimHeadlights ) {
|
||||
@@ -506,7 +506,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
btnOn = true;
|
||||
}
|
||||
// auxiliary lights
|
||||
if (TestFlag(MoverParameters->iLights[end::front], light::auxiliary_left) && !HeadlightsAoff)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::auxiliary_left) && !HeadlightsAoff)
|
||||
{
|
||||
if( DimHeadlights ) {
|
||||
m_headsignal13.TurnxOnWithOnAsFallback();
|
||||
@@ -516,7 +516,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
}
|
||||
btnOn = true;
|
||||
}
|
||||
if (TestFlag(MoverParameters->iLights[end::front], light::auxiliary_right) && !HeadlightsAoff)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::auxiliary_right) && !HeadlightsAoff)
|
||||
{
|
||||
if( DimHeadlights ) {
|
||||
m_headsignal12.TurnxOnWithOnAsFallback();
|
||||
@@ -526,7 +526,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
}
|
||||
btnOn = true;
|
||||
}
|
||||
if (TestFlag(MoverParameters->iLights[end::rear], light::auxiliary_left) && !HeadlightsBoff)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::auxiliary_left) && !HeadlightsBoff)
|
||||
{
|
||||
if( DimHeadlights ) {
|
||||
m_headsignal23.TurnxOnWithOnAsFallback();
|
||||
@@ -536,7 +536,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
}
|
||||
btnOn = true;
|
||||
}
|
||||
if (TestFlag(MoverParameters->iLights[end::rear], light::auxiliary_right) && !HeadlightsBoff)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::auxiliary_right) && !HeadlightsBoff)
|
||||
{
|
||||
if( DimHeadlights ) {
|
||||
m_headsignal22.TurnxOnWithOnAsFallback();
|
||||
@@ -548,26 +548,26 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
}
|
||||
|
||||
// logika dlugich
|
||||
if (TestFlag(MoverParameters->iLights[end::front], light::headlight_left)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::headlight_left)
|
||||
&& !HeadlightsAoff && HighBeamLights)
|
||||
m_highbeam13.TurnxOnWithOnAsFallback();
|
||||
else
|
||||
m_highbeam13.TurnOff();
|
||||
|
||||
if (TestFlag(MoverParameters->iLights[end::front], light::headlight_right)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::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[VehicleEnd::rear], light::headlight_left)
|
||||
&& !HeadlightsBoff && HighBeamLights)
|
||||
m_highbeam23.TurnxOnWithOnAsFallback();
|
||||
else
|
||||
m_highbeam23.TurnOff();
|
||||
|
||||
if (TestFlag(MoverParameters->iLights[end::rear], light::headlight_right)
|
||||
if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::headlight_right)
|
||||
&& !HeadlightsBoff && HighBeamLights)
|
||||
m_highbeam22.TurnxOnWithOnAsFallback();
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user