Skip to content

Commit b5f04fd

Browse files
committed
TM:PE version 1.7.12:
- AI: Lane changes are reduced on congested road segments - Timed traffic lights should now correctly detect trains and trams - Bugfix: GUI: Junction restriction icons sometimes disappear - Updated Chinese (simplified) translation
1 parent c7da905 commit b5f04fd

24 files changed

+218
-154
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ 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.7.12, 09/05/2016
8+
- AI: Lane changes are reduced on congested road segments
9+
- Timed traffic lights should now correctly detect trains and trams
10+
- Bugfix: GUI: Junction restriction icons sometimes disappear
11+
- Updated Chinese (simplified) translation
12+
13+
1.7.11, 09/01/2016
14+
- Updated to game version 1.5.1-f3
15+
716
1.7.10, 08/31/2016
817
- Players can now disable spawning of pocket cars
918
- Updated Chinese (simplified) translation

TLM/TLM/Custom/AI/CustomAmbulanceAI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vecto
3737
endPosB = default(PathUnit.Position);
3838
}
3939
uint path;
40-
if (Singleton<CustomPathManager>.instance.CreatePath(vehicleType, vehicleID, out path, ref Singleton<SimulationManager>.instance.m_randomizer, Singleton<SimulationManager>.instance.m_currentBuildIndex, startPosA, startPosB, endPosA, endPosB, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, 20000f, this.IsHeavyVehicle(), this.IgnoreBlocked(vehicleID, ref vehicleData), false, false)) {
40+
if (CustomPathManager._instance.CreatePath(vehicleType, vehicleID, out path, ref Singleton<SimulationManager>.instance.m_randomizer, Singleton<SimulationManager>.instance.m_currentBuildIndex, startPosA, startPosB, endPosA, endPosB, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, 20000f, this.IsHeavyVehicle(), this.IgnoreBlocked(vehicleID, ref vehicleData), false, false)) {
4141
#if USEPATHWAITCOUNTER
4242
VehicleState state = VehicleStateManager.Instance()._GetVehicleState(vehicleID);
4343
state.PathWaitCounter = 0;

TLM/TLM/Custom/AI/CustomBusAI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vecto
4141
endPosB = default(PathUnit.Position);
4242
}
4343
uint path;
44-
if (Singleton<CustomPathManager>.instance.CreatePath(
44+
if (CustomPathManager._instance.CreatePath(
4545
#if PATHRECALC
4646
recalcRequested,
4747
#endif

TLM/TLM/Custom/AI/CustomCarAI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vecto
377377
vehicleType = ExtVehicleType.RoadVehicle;
378378
}
379379

380-
if (Singleton<CustomPathManager>.instance.CreatePath(
380+
if (CustomPathManager._instance.CreatePath(
381381
#if PATHRECALC
382382
recalcRequested,
383383
#endif

TLM/TLM/Custom/AI/CustomCargoTruckAI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vecto
9292
endPosFound = true;
9393
}
9494
if (startPosFound && endPosFound) {
95-
CustomPathManager instance = Singleton<CustomPathManager>.instance;
95+
CustomPathManager instance = CustomPathManager._instance;
9696
if (!startBothWays || num < 10f) {
9797
startPosB = default(PathUnit.Position);
9898
}

TLM/TLM/Custom/AI/CustomCitizenAI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public bool CustomStartPathFind(ushort instanceID, ref CitizenInstance citizenDa
8484
/*if (Options.disableSomething6)
8585
Log._Debug($"extVehicleType could not be determined for citizen instance {instanceID}");*/
8686
} else
87-
res = Singleton<CustomPathManager>.instance.CreatePath(false, extVehicleType, null, out path, ref Singleton<SimulationManager>.instance.m_randomizer, Singleton<SimulationManager>.instance.m_currentBuildIndex, startPosA, position2, endPosA, position2, vehiclePosition, laneType, vehicleType, 20000f, false, false, false, false, randomParking);
87+
res = CustomPathManager._instance.CreatePath(false, extVehicleType, null, out path, ref Singleton<SimulationManager>.instance.m_randomizer, Singleton<SimulationManager>.instance.m_currentBuildIndex, startPosA, position2, endPosA, position2, vehiclePosition, laneType, vehicleType, 20000f, false, false, false, false, randomParking);
8888

8989
if (res) {
9090
if (citizenData.m_path != 0u) {
@@ -228,7 +228,7 @@ public bool CustomStartPathFind2(ushort instanceID, ref CitizenInstance citizenD
228228
//Log._Debug($"CustomCitizenAI: citizen instance {instanceID}, id {citizenData.m_citizen}. vehicleType={vehicleType} laneType={laneType} extVehicleType={extVehicleType} usePublicTransport={usePublicTransport} useTaxi={useTaxi} useBike={useBike} useCar={useCar} wealthLevel={wealthLevel}");
229229
#endif
230230
// NON-STOCK CODE END //
231-
if (Singleton<CustomPathManager>.instance.CreatePath(false, (ExtVehicleType)extVehicleType, null, out path, ref Singleton<SimulationManager>.instance.m_randomizer, Singleton<SimulationManager>.instance.m_currentBuildIndex, startPosA, position2, endPosA, position2, vehiclePosition, laneType, vehicleType, 20000f, false, false, false, false, randomParking)) {
231+
if (CustomPathManager._instance.CreatePath(false, (ExtVehicleType)extVehicleType, null, out path, ref Singleton<SimulationManager>.instance.m_randomizer, Singleton<SimulationManager>.instance.m_currentBuildIndex, startPosA, position2, endPosA, position2, vehiclePosition, laneType, vehicleType, 20000f, false, false, false, false, randomParking)) {
232232
if (citizenData.m_path != 0u) {
233233
Singleton<PathManager>.instance.ReleasePath(citizenData.m_path);
234234
}

TLM/TLM/Custom/AI/CustomFireTruckAI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vecto
4444
endPosB = default(PathUnit.Position);
4545
}
4646
uint path;
47-
if (Singleton<CustomPathManager>.instance.CreatePath(
47+
if (CustomPathManager._instance.CreatePath(
4848
#if PATHRECALC
4949
recalcRequested,
5050
#endif

TLM/TLM/Custom/AI/CustomPassengerCarAI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vecto
9090
SimulationManager instance2 = Singleton<SimulationManager>.instance;
9191
uint path;
9292
PathUnit.Position def = default(PathUnit.Position);
93-
if (Singleton<CustomPathManager>.instance.CreatePath(
93+
if (CustomPathManager._instance.CreatePath(
9494
#if PATHRECALC
9595
recalcRequested
9696
#else

TLM/TLM/Custom/AI/CustomPoliceCarAI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vecto
4545
}
4646
uint path;
4747
//Log._Debug($"CustomPoliceCarAI.CustomStartPathFind: Vehicle {vehicleID}, type {vehicleType}");
48-
if (Singleton<CustomPathManager>.instance.CreatePath(
48+
if (CustomPathManager._instance.CreatePath(
4949
#if PATHRECALC
5050
recalcRequested,
5151
#endif

TLM/TLM/Custom/AI/CustomRoadAI.cs

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#define MARKCONGESTEDSEGMENTSx
1+
#define MARKCONGESTEDSEGMENTS
22
#define ABSDENSITY
33
#define RELDENSITYx
44

@@ -25,7 +25,7 @@ class CustomRoadAI : RoadBaseAI {
2525
public static uint[][] maxLaneDensities;
2626
#endif
2727

28-
public static byte[][] laneMeanSpeeds;
28+
public static ushort[][] laneMeanSpeeds; // per ten thousands
2929
#if RELDENSITY
3030
public static byte[][] laneMeanRelDensities;
3131
#endif
@@ -142,12 +142,15 @@ public void CustomSegmentSimulationStep(ushort segmentID, ref NetSegment data) {
142142
#endif
143143
currentLaneSpeeds[segmentID] = new uint[numLanes];
144144
currentLaneDensities[segmentID] = new uint[numLanes];
145-
laneMeanSpeeds[segmentID] = new byte[numLanes];
145+
laneMeanSpeeds[segmentID] = new ushort[numLanes];
146146
#if RELDENSITY
147147
laneMeanRelDensities[segmentID] = new byte[numLanes];
148148
#endif
149149
#if ABSDENSITY
150150
laneMeanAbsDensities[segmentID] = new byte[numLanes];
151+
152+
for (int i = 0; i < numLanes; ++i)
153+
laneMeanSpeeds[segmentID][i] = 5000;
151154
#endif
152155
}
153156

@@ -183,36 +186,30 @@ public void CustomSegmentSimulationStep(ushort segmentID, ref NetSegment data) {
183186
//currentMeanDensity = (byte)Math.Min(100u, (uint)((currentDensities * 100u) / Math.Max(1u, maxDens))); // 0 .. 100
184187

185188
//byte currentMeanSpeed = (byte)(InStartupPhase ? 10 : 100);
186-
byte currentMeanSpeed = 100;
189+
uint currentMeanSpeed = 10000;
187190
// we use integer division here because it's faster
188191
if (currentBuf > 0) {
189192
uint currentSpeeds = currentLaneSpeeds[segmentID][laneIndex];
190-
currentMeanSpeed = (byte)Math.Min(100u, ((currentSpeeds * 100u) / currentBuf) / ((uint)(Math.Max(SpeedLimitManager.Instance().GetLockFreeGameSpeedLimit(segmentID, laneIndex, curLaneId, data.Info.m_lanes[laneIndex]) * 8f, 1f)))); // 0 .. 100, m_speedLimit of highway is 2, actual max. vehicle speed on highway is 16, that's why we use x*8 == x<<3 (don't ask why CO uses different units for velocity)
193+
currentMeanSpeed = (uint)Math.Min(10000u, ((currentSpeeds * 10000) / currentBuf) / ((uint)(Math.Max(SpeedLimitManager.Instance().GetLockFreeGameSpeedLimit(segmentID, laneIndex, curLaneId, data.Info.m_lanes[laneIndex]) * 8f, 1f)))); // 0 .. 10000, m_speedLimit of highway is 2, actual max. vehicle speed on highway is 16, that's why we use x*8 == x<<3 (don't ask why CO uses different units for velocity)
191194
}
192195

196+
//laneMeanSpeeds[segmentID][laneIndex] = currentMeanSpeed;
197+
ushort previousMeanSpeed = laneMeanSpeeds[segmentID][laneIndex];
198+
uint speedUpdateSmoothing = currentMeanSpeed > previousMeanSpeed ? (uint)Options.someValue19 : (uint)Options.someValue17;
199+
laneMeanSpeeds[segmentID][laneIndex] = (ushort)Math.Max(0, Math.Min(((uint)previousMeanSpeed * speedUpdateSmoothing + (uint)currentMeanSpeed) / (speedUpdateSmoothing + 1), 10000));
200+
193201
#if MARKCONGESTEDSEGMENTS
194-
if (currentMeanSpeed <= 30) {
202+
if (laneMeanSpeeds[segmentID][laneIndex] <= 6000) { // <= 60 %
195203
setCongested = true;
196-
} else if (currentMeanSpeed >= 60) {
204+
} else if (currentMeanSpeed >= 7000) { // >= 70 %
197205
unsetCongested = true;
198206
}
199207
#endif
200208

201-
/*if (segmentID == 22980) {
202-
Log._Debug($"Lane {curLaneId}: currentMeanSpeed={currentMeanSpeed} currentMeanDensity={currentMeanDensity}");
203-
}*/
204-
205-
//laneMeanSpeeds[segmentID][laneIndex] = currentMeanSpeed;
206-
byte previousMeanSpeed = laneMeanSpeeds[segmentID][laneIndex];
207-
if (currentMeanSpeed > previousMeanSpeed)
208-
laneMeanSpeeds[segmentID][laneIndex] = (byte)Math.Min((int)previousMeanSpeed + 10, 100);
209-
else if (currentMeanSpeed == 0 || currentMeanSpeed < previousMeanSpeed)
210-
laneMeanSpeeds[segmentID][laneIndex] = (byte)Math.Max((int)previousMeanSpeed - 10, 0);
211-
212209
#if ABSDENSITY
213210

214211
if (maxLaneDensity > 0)
215-
laneMeanAbsDensities[segmentID][laneIndex] = (byte)((Math.Min(currentDensity * 100 / maxLaneDensity, 100) + laneMeanAbsDensities[segmentID][laneIndex] * (uint)Options.someValue9) / ((uint)Options.someValue9 + 1));
212+
laneMeanAbsDensities[segmentID][laneIndex] = (byte)Math.Min(currentDensity * 100 / maxLaneDensity, 100);
216213
else
217214
laneMeanAbsDensities[segmentID][laneIndex] /= (byte)Options.someValue8;
218215
#endif
@@ -986,7 +983,7 @@ internal static void OnBeforeLoadData() {
986983
#endif
987984
currentLaneSpeeds = new uint[NetManager.MAX_SEGMENT_COUNT][];
988985
currentLaneDensities = new uint[NetManager.MAX_SEGMENT_COUNT][];
989-
laneMeanSpeeds = new byte[NetManager.MAX_SEGMENT_COUNT][];
986+
laneMeanSpeeds = new ushort[NetManager.MAX_SEGMENT_COUNT][];
990987
#if RELDENSITY
991988
laneMeanRelDensities = new byte[NetManager.MAX_SEGMENT_COUNT][];
992989
#endif
@@ -1006,7 +1003,7 @@ internal static void resetTrafficStats() {
10061003
for (ushort i = 0; i < NetManager.MAX_SEGMENT_COUNT; ++i) {
10071004
if (currentLaneTrafficBuffer[i] != null) {
10081005
for (int k = 0; k < currentLaneTrafficBuffer[i].Length; ++k) {
1009-
laneMeanSpeeds[i][k] = 50;
1006+
laneMeanSpeeds[i][k] = 10000;
10101007
currentLaneTrafficBuffer[i][k] = 0;
10111008
#if ABSDENSITY
10121009
maxLaneDensities[i][k] = 0;

0 commit comments

Comments
 (0)