Skip to content

Commit fb35622

Browse files
committed
TMPE 1.9.2
1 parent 89bf334 commit fb35622

37 files changed

+459
-255
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@ A work-in-progress modification for **Cities: Skylines** to add additional traff
44
User manual: http://www.viathinksoft.de/tmpe
55

66
# Changelog
7-
1.9.0, 04/09/2017
7+
1.9.2, 05/20/2017
8+
- UI: Main menu & UI tools performance improved
9+
- Bugfix: Traffic lights can be removed from junctions that are controlled by a timed traffic light program
10+
11+
1.9.1, 05/19/2017
12+
- Updated French, Dutch and Korean translation
13+
- Bugfix: Using the vanilla traffic light toggling feature crashes the game if TMPE's main menu has not been opened at least once
14+
- Bugfix: AI: More car traffic and less public transportation present than in vanilla
15+
16+
1.9.0, 05/18/2017
817
- Updated for game version 1.7.0-f5
918
- New feature: Parking restrictions
1019
- New feature: Speed limits can be set up for individual lanes with the Control key
@@ -19,9 +28,10 @@ User manual: http://www.viathinksoft.de/tmpe
1928
- Path-finding cost multiplicator for vehicle restrictions is now configurable in TMPE_GlobalConfig.xml
2029
- UI: More compact, movable main menu UI
2130
- Added support for custom languages
31+
- Added Korean translation (thanks to @Toothless FLY [ROK]LSh.st for translating)
2232
- Updated translations: German, Polish, Russian, Portuguese, Traditional Chinese
2333
- Major code refactorings
24-
- AI: Tuned parameters
34+
- AI: Tuned path-finding parameters
2535
- New option: Main button position can be locked
2636
- New option: Main menu position can be locked
2737
- New option: Added language selection in options dialog

TLM/TLM/Custom/PathFinding/CustomPathFind.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ private bool ProcessItemCosts(bool debug, bool allowAdvancedAI, bool obeyStockLa
15961596
Randomizer randomizer = new Randomizer(this._pathFindIndex << 16 | (uint)item.m_position.m_segment);
15971597
prevCost *= (float)(randomizer.Int32(900, 1000 + (int)(prevSegment.m_trafficDensity * 10)) + this._pathRandomizer.Int32(20u)) * 0.001f;
15981598
} else {
1599-
prevCost *= (1f - _conf.SpeedCostFactor) + _conf.SpeedCostFactor * (1f - prevSpeed);
1599+
prevCost *= 1f + _conf.SpeedCostFactor * (1f - prevSpeed);
16001600
}
16011601
}
16021602

TLM/TLM/Geometry/SegmentEndGeometry.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ internal void Recalculate(GeometryCalculationMode calcMode) {
337337
IncomingOneWay = true;
338338
}
339339
OnlyHighways = true;
340+
#if DEBUGGEO
341+
if (GlobalConfig.Instance.DebugSwitches[5])
342+
Log._Debug($"Checking if segment {SegmentId} is connected to highways only at node {NodeId()}. OnlyHighways={OnlyHighways}");
343+
#endif
340344

341345
//ItemClass connectionClass = netManager.m_segments.m_buffer[SegmentId].Info.GetConnectionClass();
342346

@@ -362,8 +366,13 @@ internal void Recalculate(GeometryCalculationMode calcMode) {
362366
bool otherIsOneWay;
363367
bool otherIsOutgoingOneWay;
364368
SegmentGeometry.calculateOneWayAtNode(otherSegmentId, nodeId, out otherIsOneWay, out otherIsOutgoingOneWay);
369+
bool otherIsHighway = SegmentGeometry.calculateIsHighway(otherSegmentId);
365370

366-
if (!(SegmentGeometry.calculateIsHighway(otherSegmentId) && otherIsOneWay))
371+
#if DEBUGGEO
372+
if (GlobalConfig.Instance.DebugSwitches[5])
373+
Log._Debug($"Segment {SegmentId} is connected to segment {otherSegmentId} at node {NodeId()}. otherIsOneWay={otherIsOneWay} otherIsOutgoingOneWay={otherIsOutgoingOneWay} otherIsHighway={otherIsHighway}");
374+
#endif
375+
if (! otherIsHighway || ! otherIsOneWay)
367376
OnlyHighways = false;
368377

369378
if (IsRightSegment(SegmentId, otherSegmentId, nodeId)) {
@@ -404,8 +413,13 @@ internal void Recalculate(GeometryCalculationMode calcMode) {
404413
NumIncomingSegments = (byte)(NumIncomingLeftSegments + NumIncomingStraightSegments + NumIncomingRightSegments);
405414
NumOutgoingSegments = (byte)(NumOutgoingLeftSegments + NumOutgoingStraightSegments + NumOutgoingRightSegments);
406415

407-
if (!hasOtherSegments)
416+
if (!hasOtherSegments) {
417+
#if DEBUGGEO
418+
if (GlobalConfig.Instance.DebugSwitches[5])
419+
Log._Debug($"Segment {SegmentId} is not connected to any other segments at node {NodeId()}.");
420+
#endif
408421
OnlyHighways = false;
422+
}
409423

410424
// propagate information to other segments
411425
if (calcMode == GeometryCalculationMode.Init || (calcMode == GeometryCalculationMode.Propagate && nodeIdBeforeRecalc != nodeId)) {

TLM/TLM/Geometry/SegmentGeometry.cs

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,7 @@ public ArrowDirection GetDirection(ushort otherSegmentId, bool startNode) {
10361036
/// </summary>
10371037
/// <param name="startNode"></param>
10381038
/// <returns></returns>
1039+
[Obsolete]
10391040
public bool AreHighwayRulesEnabled(bool startNode) {
10401041
if (!Options.highwayRules)
10411042
return false;
@@ -1086,9 +1087,14 @@ internal static bool calculateIsOutgoingOneWay(ushort segmentId, ushort nodeId)
10861087
var laneId = instance.m_segments.m_buffer[segmentId].m_lanes;
10871088
var laneIndex = 0;
10881089
while (laneIndex < info.m_lanes.Length && laneId != 0u) {
1089-
if (info.m_lanes[laneIndex].m_laneType != NetInfo.LaneType.Pedestrian &&
1090-
((info.m_lanes[laneIndex].m_finalDirection & dir) != NetInfo.Direction.None)) {
1091-
return false;
1090+
bool validLane = (info.m_lanes[laneIndex].m_laneType & (NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle)) != NetInfo.LaneType.None &&
1091+
(info.m_lanes[laneIndex].m_vehicleType & (VehicleInfo.VehicleType.Car | VehicleInfo.VehicleType.Train | VehicleInfo.VehicleType.Tram | VehicleInfo.VehicleType.Metro | VehicleInfo.VehicleType.Monorail)) != VehicleInfo.VehicleType.None;
1092+
// TODO the lane types and vehicle types should be specified to make it clear which lanes we need to check
1093+
1094+
if (validLane) {
1095+
if ((info.m_lanes[laneIndex].m_finalDirection & dir) != NetInfo.Direction.None) {
1096+
return false;
1097+
}
10921098
}
10931099

10941100
laneId = instance.m_lanes.m_buffer[laneId].m_nextLane;
@@ -1116,18 +1122,22 @@ private static bool calculateIsOneWay(ushort segmentId) {
11161122
var laneId = instance.m_segments.m_buffer[segmentId].m_lanes;
11171123
var laneIndex = 0;
11181124
while (laneIndex < info.m_lanes.Length && laneId != 0u) {
1119-
if (info.m_lanes[laneIndex].m_laneType != NetInfo.LaneType.Pedestrian &&
1120-
(info.m_lanes[laneIndex].m_direction & NetInfo.Direction.Forward) != NetInfo.Direction.None) {
1121-
hasForward = true;
1122-
}
1125+
bool validLane = (info.m_lanes[laneIndex].m_laneType & (NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle)) != NetInfo.LaneType.None &&
1126+
(info.m_lanes[laneIndex].m_vehicleType & (VehicleInfo.VehicleType.Car | VehicleInfo.VehicleType.Train | VehicleInfo.VehicleType.Tram | VehicleInfo.VehicleType.Metro | VehicleInfo.VehicleType.Monorail)) != VehicleInfo.VehicleType.None;
1127+
// TODO the lane types and vehicle types should be specified to make it clear which lanes we need to check
11231128

1124-
if (info.m_lanes[laneIndex].m_laneType != NetInfo.LaneType.Pedestrian &&
1125-
(info.m_lanes[laneIndex].m_direction & NetInfo.Direction.Backward) != NetInfo.Direction.None) {
1126-
hasBackward = true;
1127-
}
1129+
if (validLane) {
1130+
if ((info.m_lanes[laneIndex].m_direction & NetInfo.Direction.Forward) != NetInfo.Direction.None) {
1131+
hasForward = true;
1132+
}
1133+
1134+
if ((info.m_lanes[laneIndex].m_direction & NetInfo.Direction.Backward) != NetInfo.Direction.None) {
1135+
hasBackward = true;
1136+
}
11281137

1129-
if (hasForward && hasBackward) {
1130-
return false;
1138+
if (hasForward && hasBackward) {
1139+
return false;
1140+
}
11311141
}
11321142

11331143
laneId = instance.m_lanes.m_buffer[(int)((UIntPtr)laneId)].m_nextLane;
@@ -1192,19 +1202,22 @@ internal static void calculateOneWayAtNode(ushort segmentId, ushort nodeId, out
11921202
var laneId = instance.m_segments.m_buffer[segmentId].m_lanes;
11931203
var laneIndex = 0;
11941204
while (laneIndex < info.m_lanes.Length && laneId != 0u) {
1195-
if (info.m_lanes[laneIndex].m_laneType != NetInfo.LaneType.Pedestrian &&
1196-
(info.m_lanes[laneIndex].m_finalDirection & dir2) != NetInfo.Direction.None) {
1197-
isOutgoingOneWay = false;
1198-
}
1205+
bool validLane = (info.m_lanes[laneIndex].m_laneType & (NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle)) != NetInfo.LaneType.None &&
1206+
(info.m_lanes[laneIndex].m_vehicleType & (VehicleInfo.VehicleType.Car | VehicleInfo.VehicleType.Train | VehicleInfo.VehicleType.Tram | VehicleInfo.VehicleType.Metro | VehicleInfo.VehicleType.Monorail)) != VehicleInfo.VehicleType.None;
1207+
// TODO the lane types and vehicle types should be specified to make it clear which lanes we need to check
11991208

1200-
if (info.m_lanes[laneIndex].m_laneType != NetInfo.LaneType.Pedestrian &&
1201-
(info.m_lanes[laneIndex].m_direction & NetInfo.Direction.Forward) != NetInfo.Direction.None) {
1202-
hasForward = true;
1203-
}
1209+
if (validLane) {
1210+
if ((info.m_lanes[laneIndex].m_finalDirection & dir2) != NetInfo.Direction.None) {
1211+
isOutgoingOneWay = false;
1212+
}
12041213

1205-
if (info.m_lanes[laneIndex].m_laneType != NetInfo.LaneType.Pedestrian &&
1206-
(info.m_lanes[laneIndex].m_direction & NetInfo.Direction.Backward) != NetInfo.Direction.None) {
1207-
hasBackward = true;
1214+
if ((info.m_lanes[laneIndex].m_direction & NetInfo.Direction.Forward) != NetInfo.Direction.None) {
1215+
hasForward = true;
1216+
}
1217+
1218+
if ((info.m_lanes[laneIndex].m_direction & NetInfo.Direction.Backward) != NetInfo.Direction.None) {
1219+
hasBackward = true;
1220+
}
12081221
}
12091222

12101223
laneId = instance.m_lanes.m_buffer[laneId].m_nextLane;

TLM/TLM/Manager/LaneConnectionManager.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,29 @@ public bool HasConnections(uint sourceLaneId, bool startNode) {
7171
return ret;
7272
}
7373

74+
/// <summary>
75+
/// Determines if there exist custom lane connections at the specified node
76+
/// </summary>
77+
/// <param name="nodeId"></param>
78+
public bool HasNodeConnections(ushort nodeId) {
79+
#if DEBUGCONN
80+
Log._Debug($"LaneConnectionManager.RemoveLaneConnectionsFromNode({nodeId}) called.");
81+
#endif
82+
83+
bool ret = false;
84+
Services.NetService.IterateNodeSegments(nodeId, delegate (ushort segmentId, ref NetSegment segment) {
85+
Services.NetService.IterateSegmentLanes(segmentId, delegate (uint laneId, ref NetLane lane, NetInfo.Lane laneInfo, ushort segId, ref NetSegment seg, byte laneIndex) {
86+
if (HasConnections(laneId, seg.m_startNode == nodeId)) {
87+
ret = true;
88+
return false;
89+
}
90+
return true;
91+
});
92+
return !ret;
93+
});
94+
return ret;
95+
}
96+
7497
public bool HasUturnConnections(ushort segmentId, bool startNode) {
7598
NetManager netManager = Singleton<NetManager>.instance;
7699
int nodeArrayIndex = startNode ? 0 : 1;

TLM/TLM/Manager/TrafficLightManager.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public bool SetTrafficLight(ushort nodeId, bool flag) {
3434

3535
public bool SetTrafficLight(ushort nodeId, bool flag, out UnableReason reason) {
3636
if (! IsTrafficLightToggleable(nodeId, out reason)) {
37-
return false;
37+
if (reason != UnableReason.HasTimedLight || !flag) {
38+
return false;
39+
}
3840
}
3941

4042
Constants.ServiceFactory.NetService.ProcessNode(nodeId, delegate (ushort nId, ref NetNode node) {
@@ -85,7 +87,7 @@ public bool IsTrafficLightToggleable(ushort nodeId, out UnableReason reason) {
8587
return false;
8688
}
8789

88-
if (TrafficLightSimulationManager.Instance.HasActiveTimedSimulation(nodeId)) {
90+
if (TrafficLightSimulationManager.Instance.HasTimedSimulation(nodeId)) {
8991
reason = UnableReason.HasTimedLight;
9092
return false;
9193
}

TLM/TLM/Manager/TrafficMeasurementManager.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace TrafficManager.Manager {
1313
public class TrafficMeasurementManager : AbstractCustomManager {
14+
public const VehicleInfo.VehicleType VEHICLE_TYPES = VehicleInfo.VehicleType.Car;
1415
public const NetInfo.LaneType LANE_TYPES = NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle;
1516

1617
public static readonly TrafficMeasurementManager Instance = new TrafficMeasurementManager();
@@ -210,6 +211,8 @@ public void SimulationStep(ushort segmentId, ref NetSegment segmentData) {
210211
ushort maxBuffer = 0;
211212
for (uint li = 0; li < numLanes; ++li) {
212213
NetInfo.Lane laneInfo = segmentInfo.m_lanes[li];
214+
if ((laneInfo.m_vehicleType & VEHICLE_TYPES) == VehicleInfo.VehicleType.None)
215+
continue;
213216
if ((laneInfo.m_laneType & LANE_TYPES) == NetInfo.LaneType.None)
214217
continue;
215218

TLM/TLM/Manager/TrafficPriorityManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ private bool HasVehiclePriority(bool debug, ushort transitNodeId, ushort targetV
496496
#endif
497497

498498
if (targetEnd.NodeId != incomingEnd.NodeId) {
499-
Log.Error($"HasVehiclePriority: Incompatible SegmentEnds!");
499+
Log._Debug($"HasVehiclePriority: Incompatible SegmentEnds: targetEnd.NodeId={targetEnd.NodeId}, incomingEnd.NodeId={incomingEnd.NodeId}");
500500
return true;
501501
}
502502

TLM/TLM/Resources/lang.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,5 @@ Lock_main_menu_button_position Lock main menu button position
168168
Lock_main_menu_position Lock main menu position
169169
Recalculating_lane_routing Recalculating lane routing
170170
Please_wait Please wait
171-
Parking_restrictions Parking restrictions
171+
Parking_restrictions Parking restrictions
172+
Simulation Simulation

TLM/TLM/Resources/lang_de.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,5 @@ Lock_main_menu_button_position Position der Hauptmenü-Schaltfläche sperren
167167
Lock_main_menu_position Position des Hauptmenüs sperren
168168
Recalculating_lane_routing Berechne Routenführung neu
169169
Please_wait Bitte warten
170-
Parking_restrictions Parkverbote
170+
Parking_restrictions Parkverbote
171+
Simulation Simulation

0 commit comments

Comments
 (0)