Skip to content

Commit bf17ddd

Browse files
authored
Merge pull request #580 from krzychu124/pr-disambiguate-lhd
Disambiguate `LeftHandDrive` to `TrafficDrivesOnLeft`
2 parents b3e5de6 + 27a958a commit bf17ddd

File tree

13 files changed

+61
-53
lines changed

13 files changed

+61
-53
lines changed

TLM/TLM/Manager/Impl/JunctionRestrictionsManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,11 @@ public bool IsTurnOnRedAllowedConfigurable(bool near,
401401
ref NetNode node) {
402402
ITurnOnRedManager turnOnRedMan = Constants.ManagerFactory.TurnOnRedManager;
403403
int index = turnOnRedMan.GetIndex(segmentId, startNode);
404-
bool lhd = Services.SimulationService.LeftHandDrive;
404+
bool lht = Services.SimulationService.TrafficDrivesOnLeft;
405405
bool ret =
406406
(node.m_flags & NetNode.Flags.TrafficLights) != NetNode.Flags.None &&
407-
(((lhd == near) && turnOnRedMan.TurnOnRedSegments[index].leftSegmentId != 0) ||
408-
((!lhd == near) && turnOnRedMan.TurnOnRedSegments[index].rightSegmentId != 0));
407+
(((lht == near) && turnOnRedMan.TurnOnRedSegments[index].leftSegmentId != 0) ||
408+
((!lht == near) && turnOnRedMan.TurnOnRedSegments[index].rightSegmentId != 0));
409409
#if DEBUG
410410
if (DebugSwitch.JunctionRestrictions.Get()) {
411411
Log._Debug(

TLM/TLM/Manager/Impl/LaneArrowManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,10 @@ public static void SeparateSegmentLanes(ushort segmentId, ushort nodeId, out Set
327327
}
328328

329329
int l = 0, f = 0, r = 0;
330-
bool lhd = LaneArrowManager.Instance.Services.SimulationService.LeftHandDrive;
330+
bool lht = LaneArrowManager.Instance.Services.SimulationService.TrafficDrivesOnLeft;
331331
if (numdirs == 2) {
332-
if (!lhd) {
333-
//if right hand drive then favour the more difficult left turns.
332+
if (!lht) {
333+
//if traffic drives on right, then favour the more difficult left turns.
334334
if (leftLanesCount == 0) {
335335
DistributeLanes2(srcLaneCount, forwardLanesCount, rightLanesCount, out f, out r);
336336
} else if (rightLanesCount == 0) {
@@ -340,7 +340,7 @@ public static void SeparateSegmentLanes(ushort segmentId, ushort nodeId, out Set
340340
DistributeLanes2(srcLaneCount, leftLanesCount, rightLanesCount, out l, out r);
341341
}
342342
} else {
343-
//if left hand drive then favour the more difficult right turns.
343+
//if traffic drives on left, then favour the more difficult right turns.
344344
if (leftLanesCount == 0) {
345345
DistributeLanes2(srcLaneCount, rightLanesCount, forwardLanesCount, out r, out f);
346346
} else if (rightLanesCount == 0) {
@@ -352,7 +352,7 @@ public static void SeparateSegmentLanes(ushort segmentId, ushort nodeId, out Set
352352
}
353353
} else {
354354
Debug.Assert(numdirs == 3 && srcLaneCount >= 3);
355-
if (!lhd) {
355+
if (!lht) {
356356
DistributeLanes3(srcLaneCount, leftLanesCount, forwardLanesCount, rightLanesCount, out l, out f, out r);
357357
} else {
358358
DistributeLanes3(srcLaneCount, rightLanesCount, forwardLanesCount, leftLanesCount, out r, out f, out l);

TLM/TLM/Manager/Impl/LaneConnectionManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ private void RecalculateLaneArrows(uint laneId, ushort nodeId, bool startNode) {
654654
// check if arrow has already been set for this direction
655655
switch (dir) {
656656
case ArrowDirection.Turn: {
657-
if (Constants.ServiceFactory.SimulationService.LeftHandDrive) {
657+
if (Constants.ServiceFactory.SimulationService.TrafficDrivesOnLeft) {
658658
if ((arrows & LaneArrows.Right) != LaneArrows.None) {
659659
return true;
660660
}
@@ -740,7 +740,7 @@ private void RecalculateLaneArrows(uint laneId, ushort nodeId, bool startNode) {
740740

741741
switch (dir) {
742742
case ArrowDirection.Turn: {
743-
if (Constants.ServiceFactory.SimulationService.LeftHandDrive) {
743+
if (Constants.ServiceFactory.SimulationService.TrafficDrivesOnLeft) {
744744
arrows |= LaneArrows.Right;
745745
} else {
746746
arrows |= LaneArrows.Left;

TLM/TLM/Manager/Impl/RoutingManager.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace TrafficManager.Manager.Impl {
1+
namespace TrafficManager.Manager.Impl {
22
using System;
33
using System.Collections.Generic;
44
using System.Linq;
@@ -419,7 +419,7 @@ protected void RecalculateLaneEndRoutingData(ushort segmentId,
419419
return true;
420420
});
421421

422-
bool leftHandDrive = Constants.ServiceFactory.SimulationService.LeftHandDrive;
422+
bool lht = Constants.ServiceFactory.SimulationService.TrafficDrivesOnLeft;
423423

424424
IExtSegmentEndManager segEndMan = Constants.ManagerFactory.ExtSegmentEndManager;
425425
ExtSegment prevSeg = Constants.ManagerFactory.ExtSegmentManager.ExtSegments[segmentId];
@@ -549,7 +549,7 @@ protected void RecalculateLaneEndRoutingData(ushort segmentId,
549549
Log._DebugFormat(
550550
"RoutingManager.RecalculateLaneEndRoutingData({0}, {1}, {2}, {3}): " +
551551
"prevSegIsInverted={4} leftHandDrive={5}",
552-
segmentId, laneIndex, laneId, startNode, prevSegIsInverted, leftHandDrive);
552+
segmentId, laneIndex, laneId, startNode, prevSegIsInverted, lht);
553553
Log._DebugFormat(
554554
"RoutingManager.RecalculateLaneEndRoutingData({0}, {1}, {2}, {3}): " +
555555
"prevSimilarLaneCount={4} prevInnerSimilarLaneIndex={5} prevOuterSimilarLaneIndex={6} " +
@@ -870,8 +870,8 @@ protected void RecalculateLaneEndRoutingData(ushort segmentId,
870870
(nextIncomingDir == ArrowDirection.Turn
871871
&& (!nextIsRealJunction
872872
|| nextIsEndOrOneWayOut
873-
|| ((leftHandDrive && hasRightArrow)
874-
|| (!leftHandDrive && hasLeftArrow))))) // valid turning lane
873+
|| ((lht && hasRightArrow)
874+
|| (!lht && hasLeftArrow))))) // valid turning lane
875875
{
876876
if (extendedLogRouting) {
877877
Log._DebugFormat(
@@ -1920,7 +1920,7 @@ bool laneChangesAllowed
19201920
Constants.ServiceFactory.NetService.ProcessSegment(
19211921
nextSegmentId,
19221922
(ushort nextSegId, ref NetSegment segment) => {
1923-
nextSegmentId = Constants.ServiceFactory.SimulationService.LeftHandDrive
1923+
nextSegmentId = Constants.ServiceFactory.SimulationService.TrafficDrivesOnLeft
19241924
? segment.GetLeftSegment(nextNodeId)
19251925
: segment.GetRightSegment(nextNodeId);
19261926
return true;

TLM/TLM/Manager/Impl/TrafficPriorityManager.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -900,15 +900,15 @@ private bool HasVehiclePriority(bool logPriority,
900900
vehicleId, incomingVehicleId, targetToDir, incomingFromDir, incomingToRelDir);
901901
}
902902

903-
if (Services.SimulationService.LeftHandDrive) {
904-
// mirror situation for left-hand traffic systems
903+
if (Services.SimulationService.TrafficDrivesOnLeft) {
904+
// mirror situation if traffic drives on left
905905
targetToDir = ArrowDirectionUtil.InvertLeftRight(targetToDir);
906906
incomingFromDir = ArrowDirectionUtil.InvertLeftRight(incomingFromDir);
907907
incomingToRelDir = ArrowDirectionUtil.InvertLeftRight(incomingToRelDir);
908908

909909
if (logPriority) {
910910
Log._DebugFormat(
911-
" TrafficPriorityManager.HasVehiclePriority({0}, {1}): LHD! targetToDir: {2}, " +
911+
" TrafficPriorityManager.HasVehiclePriority({0}, {1}): LHT! targetToDir: {2}, " +
912912
"incomingFromDir: {3}, incomingToRelDir: {4}",
913913
vehicleId, incomingVehicleId, targetToDir, incomingFromDir, incomingToRelDir);
914914
}
@@ -1366,7 +1366,7 @@ public bool IsLaneOrderConflictFree(bool logPriority,
13661366
NetSegment.Flags.Invert) == NetSegment.Flags.None)
13671367
? dir
13681368
: NetInfo.InvertDirection(dir);
1369-
NetInfo.Direction dir3 = Services.SimulationService.LeftHandDrive
1369+
NetInfo.Direction dir3 = Services.SimulationService.TrafficDrivesOnLeft
13701370
? NetInfo.InvertDirection(dir2)
13711371
: dir2;
13721372

TLM/TLM/Manager/Impl/TurnOnRedManager.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected void UpdateSegmentEnd(ref ExtSegment seg, ref ExtSegmentEnd end) {
129129
return;
130130
}
131131

132-
bool lhd = Services.SimulationService.LeftHandDrive;
132+
bool lht = Services.SimulationService.TrafficDrivesOnLeft;
133133

134134
// check node
135135
// note that we must not check for the `TrafficLights` flag here because the flag might not be loaded yet
@@ -219,32 +219,32 @@ protected void UpdateSegmentEnd(ref ExtSegment seg, ref ExtSegmentEnd end) {
219219
}
220220

221221
if (seg.oneWay) {
222-
if ((lhd && rightSegmentId != 0) || (!lhd && leftSegmentId != 0)) {
222+
if ((lht && rightSegmentId != 0) || (!lht && leftSegmentId != 0)) {
223223
// special case: one-way to one-way in non-preferred direction
224224
if (logTurnOnRed) {
225225
Log._Debug(
226226
$"TurnOnRedManager.UpdateSegmentEnd({end.segmentId}, {end.startNode}): " +
227227
"source is incoming one-way. checking for one-way in non-preferred direction");
228228
}
229229

230-
ushort targetSegmentId = lhd ? rightSegmentId : leftSegmentId;
230+
ushort targetSegmentId = lht ? rightSegmentId : leftSegmentId;
231231

232232
if (!segmentManager.ExtSegments[targetSegmentId].oneWay) {
233233
// disallow turn in non-preferred direction
234234
if (logTurnOnRed) {
235235
Log._Debug(
236236
$"TurnOnRedManager.UpdateSegmentEnd({end.segmentId}, {end.startNode}): " +
237-
$"turn in non-preferred direction {(lhd ? "right" : "left")} disallowed");
237+
$"turn in non-preferred direction {(lht ? "right" : "left")} disallowed");
238238
}
239239

240-
if (lhd) {
240+
if (lht) {
241241
rightSegmentId = 0;
242242
} else {
243243
leftSegmentId = 0;
244244
}
245245
}
246246
}
247-
} else if (lhd) {
247+
} else if (lht) {
248248
// default case (LHD): turn in preferred direction
249249
rightSegmentId = 0;
250250
} else {

TLM/TLM/Manager/Impl/VehicleBehaviorManager.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace TrafficManager.Manager.Impl {
1+
namespace TrafficManager.Manager.Impl {
22
using System;
33
using API.Manager;
44
using API.Traffic.Data;
@@ -1393,19 +1393,19 @@ protected VehicleJunctionTransitState MayChangeSegment(
13931393
IJunctionRestrictionsManager junctionRestrictionsManager
13941394
= Constants.ManagerFactory.JunctionRestrictionsManager;
13951395
ITurnOnRedManager turnOnRedMan = Constants.ManagerFactory.TurnOnRedManager;
1396-
bool lhd = Constants.ServiceFactory.SimulationService.LeftHandDrive;
1396+
bool lht = Constants.ServiceFactory.SimulationService.TrafficDrivesOnLeft;
13971397
int torIndex = turnOnRedMan.GetIndex(prevPos.m_segment, isTargetStartNode);
13981398

13991399
if ((turnOnRedMan.TurnOnRedSegments[torIndex].leftSegmentId ==
14001400
position.m_segment
14011401
&& junctionRestrictionsManager.IsTurnOnRedAllowed(
1402-
lhd,
1402+
lht,
14031403
prevPos.m_segment,
14041404
isTargetStartNode))
14051405
|| (turnOnRedMan.TurnOnRedSegments[torIndex].rightSegmentId ==
14061406
position.m_segment
14071407
&& junctionRestrictionsManager.IsTurnOnRedAllowed(
1408-
!lhd,
1408+
!lht,
14091409
prevPos.m_segment,
14101410
isTargetStartNode)))
14111411
{

TLM/TLM/TrafficLight/Impl/CustomSegmentLight.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// #define DEBUGVISUALS
1+
// #define DEBUGVISUALS
22

33
namespace TrafficManager.TrafficLight.Impl {
44
using System;
@@ -262,7 +262,7 @@ public RoadBaseAI.TrafficLightState GetLightState(ArrowDirection dir) {
262262
}
263263

264264
case ArrowDirection.Turn: {
265-
return Constants.ServiceFactory.SimulationService.LeftHandDrive
265+
return Constants.ServiceFactory.SimulationService.TrafficDrivesOnLeft
266266
? LightRight
267267
: LightLeft;
268268
}

TLM/TLM/TrafficLight/Impl/CustomSegmentLights.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// #define DEBUGGET
1+
// #define DEBUGGET
22

33
namespace TrafficManager.TrafficLight.Impl {
44
using System;
@@ -493,7 +493,7 @@ public void CalculateAutoPedestrianLightState(ref NetNode node, bool propagate=t
493493
});
494494

495495
var autoPedestrianLightState = RoadBaseAI.TrafficLightState.Green;
496-
bool lhd = Constants.ServiceFactory.SimulationService.LeftHandDrive;
496+
bool lht = Constants.ServiceFactory.SimulationService.TrafficDrivesOnLeft;
497497

498498
if (!(segEnd.incoming && seg.oneWay)) {
499499
for (int i = 0; i < 8; ++i) {
@@ -561,10 +561,10 @@ public void CalculateAutoPedestrianLightState(ref NetNode node, bool propagate=t
561561
autoPedestrianLightState = RoadBaseAI.TrafficLightState.Red;
562562
break;
563563
}
564-
} else if (((dir == ArrowDirection.Left && lhd)
565-
|| (dir == ArrowDirection.Right && !lhd))
566-
&& ((lhd && !otherLights.IsAllRightRed())
567-
|| (!lhd && !otherLights.IsAllLeftRed())))
564+
} else if (((dir == ArrowDirection.Left && lht)
565+
|| (dir == ArrowDirection.Right && !lht))
566+
&& ((lht && !otherLights.IsAllRightRed())
567+
|| (!lht && !otherLights.IsAllLeftRed())))
568568
{
569569
Log._DebugIf(
570570
logTrafficLights,

TLM/TLM/TrafficLight/Impl/TimedTrafficLightsStep.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ IDictionary<ushort, uint> movingVehiclesMetric
925925
switch (dir) {
926926
case ArrowDirection.Turn: {
927927
addToFlow =
928-
Constants.ServiceFactory.SimulationService.LeftHandDrive
928+
Constants.ServiceFactory.SimulationService.TrafficDrivesOnLeft
929929
? segLight.IsRightGreen()
930930
: segLight.IsLeftGreen();
931931
break;

0 commit comments

Comments
 (0)