Skip to content

Commit 914df4a

Browse files
committed
1.9.0: final fixes
1 parent 3bac079 commit 914df4a

23 files changed

+283
-79
lines changed

TLM/TLM/Custom/AI/CustomPassengerCarAI.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,13 @@ public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vecto
165165
driverExtInstance.Reset();
166166

167167
// pocket car fallback
168-
vehicleData.m_flags |= Vehicle.Flags.Parking;
169-
return true;
168+
//vehicleData.m_flags |= Vehicle.Flags.Parking;
169+
return false;
170+
} else {
171+
#if DEBUG
172+
if (GlobalConfig.Instance.DebugSwitches[4])
173+
Log._Debug($"Increased number of parking attempts for vehicle {vehicleID}: {driverExtInstance.FailedParkingAttempts}/{GlobalConfig.Instance.MaxParkingAttempts}");
174+
#endif
170175
}
171176
} else {
172177
driverExtInstance.PathMode = ExtPathMode.CalculatingCarPathToKnownParkPos;
@@ -448,9 +453,9 @@ public bool CustomParkVehicle(ushort vehicleID, ref Vehicle vehicleData, PathUni
448453
}
449454

450455
if (! foundParkingSpace) {
451-
foundParkingSpace = prohibitPocketCars ?
452-
CustomFindParkingSpace(this.m_info, homeID, refPos, searchDir, pathPos.m_segment, out parkPos, out parkRot, out parkOffset) :
453-
FindParkingSpace(homeID, refPos, searchDir, pathPos.m_segment, this.m_info.m_generatedInfo.m_size.x, this.m_info.m_generatedInfo.m_size.z, out parkPos, out parkRot, out parkOffset);
456+
foundParkingSpace = /*prohibitPocketCars ?*/
457+
CustomFindParkingSpace(this.m_info, homeID, refPos, searchDir, pathPos.m_segment, out parkPos, out parkRot, out parkOffset) /*:
458+
FindParkingSpace(homeID, refPos, searchDir, pathPos.m_segment, this.m_info.m_generatedInfo.m_size.x, this.m_info.m_generatedInfo.m_size.z, out parkPos, out parkRot, out parkOffset)*/;
454459
}
455460

456461
// NON-STOCK CODE END
@@ -460,7 +465,7 @@ public bool CustomParkVehicle(ushort vehicleID, ref Vehicle vehicleData, PathUni
460465
#if DEBUG
461466
float sqrDist = (refPos - parkPos).sqrMagnitude;
462467
if (GlobalConfig.Instance.DebugSwitches[4])
463-
Log._Debug($"Vehicle {vehicleID} succeeded in parking! CurrentPathMode={driverExtInstance.PathMode} sqrDist={sqrDist}");
468+
Log._Debug($"Vehicle {vehicleID} succeeded in parking! CurrentPathMode={driverExtInstance?.PathMode} sqrDist={sqrDist}");
464469

465470
if (GlobalConfig.Instance.DebugSwitches[6] && sqrDist >= 16000) {
466471
Log._Debug($"CustomPassengerCarAI.CustomParkVehicle: FORCED PAUSE. Distance very large! Vehicle {vehicleID}. dist={sqrDist}");

TLM/TLM/Manager/RoutingManager.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,8 @@ public int CalcInnerLaneSimilarIndex(ushort segmentId, int laneIndex) {
11441144
int ret = -1;
11451145
Constants.ServiceFactory.NetService.ProcessSegment(segmentId, delegate (ushort segId, ref NetSegment segment) {
11461146
NetInfo.Lane laneInfo = segment.Info.m_lanes[laneIndex];
1147-
ret = (byte)(laneInfo.m_finalDirection & NetInfo.Direction.Forward) != 0 ? laneInfo.m_similarLaneIndex : laneInfo.m_similarLaneCount - laneInfo.m_similarLaneIndex - 1;
1147+
// note: m_direction is correct here
1148+
ret = (byte)(laneInfo.m_direction & NetInfo.Direction.Forward) != 0 ? laneInfo.m_similarLaneIndex : laneInfo.m_similarLaneCount - laneInfo.m_similarLaneIndex - 1;
11481149
return true;
11491150
});
11501151

@@ -1155,7 +1156,8 @@ public int CalcOuterLaneSimilarIndex(ushort segmentId, int laneIndex) {
11551156
int ret = -1;
11561157
Constants.ServiceFactory.NetService.ProcessSegment(segmentId, delegate (ushort segId, ref NetSegment segment) {
11571158
NetInfo.Lane laneInfo = segment.Info.m_lanes[laneIndex];
1158-
ret = (byte)(laneInfo.m_finalDirection & NetInfo.Direction.Forward) != 0 ? laneInfo.m_similarLaneCount - laneInfo.m_similarLaneIndex - 1 : laneInfo.m_similarLaneIndex;
1159+
// note: m_direction is correct here
1160+
ret = (byte)(laneInfo.m_direction & NetInfo.Direction.Forward) != 0 ? laneInfo.m_similarLaneCount - laneInfo.m_similarLaneIndex - 1 : laneInfo.m_similarLaneIndex;
11591161
return true;
11601162
});
11611163

TLM/TLM/Manager/TrafficLightSimulationManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ public bool LoadData(List<Configuration.TimedTrafficLights> data) {
234234
foreach (KeyValuePair<ushort, Configuration.CustomSegmentLights> e in cnfTimedStep.segmentLights) {
235235
if (!Services.NetService.IsSegmentValid(e.Key))
236236
continue;
237+
e.Value.nodeId = cnfTimedLights.nodeId;
237238

238239
Log._Debug($"Loading timed step {j}, segment {e.Key} at node {cnfTimedLights.nodeId}");
239240
CustomSegmentLights lights = null;

TLM/TLM/Manager/UtilityManager.cs

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using TrafficManager.State;
77
using TrafficManager.Geometry;
88
using CSUtil.Commons;
9+
using TrafficManager.Custom.AI;
910

1011
namespace TrafficManager.Manager {
1112
public class UtilityManager : AbstractCustomManager {
@@ -94,43 +95,77 @@ private void PrintAllDebugInfo() {
9495
}
9596

9697
private void ResetStuckEntities() {
97-
Log._Debug($"UtilityManager.RemoveStuckEntities() called.");
98+
Log.Info($"UtilityManager.RemoveStuckEntities() called.");
9899

99-
Log._Debug($"UtilityManager.RemoveStuckEntities(): Pausing simulation.");
100+
Log.Info($"UtilityManager.RemoveStuckEntities(): Pausing simulation.");
100101
Singleton<SimulationManager>.instance.ForcedSimulationPaused = true;
101102

102-
Log._Debug($"UtilityManager.RemoveStuckEntities(): Waiting for all paths.");
103+
Log.Info($"UtilityManager.RemoveStuckEntities(): Waiting for all paths.");
103104
Singleton<PathManager>.instance.WaitForAllPaths();
104105

105-
Log._Debug($"UtilityManager.RemoveStuckEntities(): Resetting citizen instances that are waiting for a path.");
106+
Log.Info($"UtilityManager.RemoveStuckEntities(): Resetting citizen instances that are waiting for a path.");
106107
for (uint citizenInstanceId = 1; citizenInstanceId < CitizenManager.MAX_INSTANCE_COUNT; ++citizenInstanceId) {
107108
//Log._Debug($"UtilityManager.RemoveStuckEntities(): Processing instance {citizenInstanceId}.");
108-
CitizenInstance citizenData = Singleton<CitizenManager>.instance.m_instances.m_buffer[citizenInstanceId];
109-
if ((citizenData.m_flags & CitizenInstance.Flags.WaitingPath) != CitizenInstance.Flags.None) {
109+
if ((Singleton<CitizenManager>.instance.m_instances.m_buffer[citizenInstanceId].m_flags & CitizenInstance.Flags.WaitingPath) != CitizenInstance.Flags.None) {
110110
CitizenAI ai = Singleton<CitizenManager>.instance.m_instances.m_buffer[citizenInstanceId].Info.m_citizenAI;
111111

112-
if (citizenData.m_path != 0u) {
113-
Singleton<PathManager>.instance.ReleasePath(citizenData.m_path);
114-
Singleton<CitizenManager>.instance.m_instances.m_buffer[citizenInstanceId].m_path = 0u;
112+
if (Singleton<CitizenManager>.instance.m_instances.m_buffer[citizenInstanceId].m_path != 0u) {
113+
#if DEBUG
114+
if (GlobalConfig.Instance.DebugSwitches[3]) {
115+
Log._Debug($"Would reset citizen instance {citizenInstanceId} (waiting for path)");
116+
} else {
117+
#endif
118+
Singleton<PathManager>.instance.ReleasePath(Singleton<CitizenManager>.instance.m_instances.m_buffer[citizenInstanceId].m_path);
119+
Singleton<CitizenManager>.instance.m_instances.m_buffer[citizenInstanceId].m_path = 0u;
120+
#if DEBUG
121+
}
122+
#endif
115123
}
116124
Singleton<CitizenManager>.instance.m_instances.m_buffer[citizenInstanceId].m_flags &= ~(CitizenInstance.Flags.WaitingTransport | CitizenInstance.Flags.EnteringVehicle | CitizenInstance.Flags.BoredOfWaiting | CitizenInstance.Flags.WaitingTaxi | CitizenInstance.Flags.WaitingPath);
117125
}
118126
}
119127

120-
Log._Debug($"UtilityManager.RemoveStuckEntities(): Resetting vehicles that are waiting for a path.");
128+
Log.Info($"UtilityManager.RemoveStuckEntities(): Resetting vehicles that are waiting for a path.");
121129
for (uint vehicleId = 1; vehicleId < VehicleManager.MAX_VEHICLE_COUNT; ++vehicleId) {
122130
//Log._Debug($"UtilityManager.RemoveStuckEntities(): Processing vehicle {vehicleId}.");
123-
Vehicle vehicleData = Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId];
124-
if ((vehicleData.m_flags & Vehicle.Flags.WaitingPath) != 0) {
125-
if (vehicleData.m_path != 0u) {
126-
Singleton<PathManager>.instance.ReleasePath(vehicleData.m_path);
127-
Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_path = 0u;
131+
if ((Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_flags & Vehicle.Flags.WaitingPath) != 0) {
132+
if (Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_path != 0u) {
133+
#if DEBUG
134+
if (GlobalConfig.Instance.DebugSwitches[3]) {
135+
Log._Debug($"Would reset vehicle {vehicleId} (waiting for path)");
136+
} else {
137+
#endif
138+
Singleton<PathManager>.instance.ReleasePath(Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_path);
139+
Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_path = 0u;
140+
#if DEBUG
141+
}
142+
#endif
128143
}
129144
Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_flags &= ~Vehicle.Flags.WaitingPath;
130145
}
131146
}
132147

133-
Log._Debug($"UtilityManager.RemoveStuckEntities(): Unpausing simulation.");
148+
Log.Info($"UtilityManager.RemoveStuckEntities(): Resetting vehicles that are parking and where no parked vehicle is assigned to the driver.");
149+
for (uint vehicleId = 1; vehicleId < VehicleManager.MAX_VEHICLE_COUNT; ++vehicleId) {
150+
//Log._Debug($"UtilityManager.RemoveStuckEntities(): Processing vehicle {vehicleId}.");
151+
if ((Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_flags & Vehicle.Flags.Parking) != 0) {
152+
ushort driverInstanceId = CustomPassengerCarAI.GetDriverInstance((ushort)vehicleId, ref Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId]);
153+
uint citizen = Singleton<CitizenManager>.instance.m_instances.m_buffer[(int)driverInstanceId].m_citizen;
154+
if (citizen != 0u && Singleton<CitizenManager>.instance.m_citizens.m_buffer[(int)((UIntPtr)citizen)].m_parkedVehicle == 0) {
155+
#if DEBUG
156+
if (GlobalConfig.Instance.DebugSwitches[3]) {
157+
Log._Debug($"Would reset vehicle {vehicleId} (parking without parked vehicle)");
158+
} else {
159+
#endif
160+
Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_flags &= ~Vehicle.Flags.Parking;
161+
#if DEBUG
162+
}
163+
#endif
164+
}
165+
}
166+
}
167+
168+
Log.Info($"UtilityManager.RemoveStuckEntities(): Unpausing simulation.");
134169
Singleton<SimulationManager>.instance.ForcedSimulationPaused = false;
135170
}
136171
}

TLM/TLM/Resources/lang_es.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter Evacuation busses may only
156156
Vehicle_behavior Vehicle behavior
157157
Policies_&_Restrictions Policies & Restrictions
158158
At_junctions At junctions
159-
In_case_of_emergency In case of emergency
159+
In_case_of_emergency In case of emergency
160+
Show_lane-wise_speed_limits Show lane-wise speed limits
161+
Language Language
162+
Game_language Game language
163+
requires_game_restart requires game restart
164+
Customizations_come_into_effect_instantaneously Customizations come into effect instantaneously
165+
Options Options
166+
Lock_main_menu_button_position Lock main menu button position
167+
Lock_main_menu_position Lock main menu position
168+
Recalculating_lane_routing Recalculating lane routing
169+
Please_wait Please wait
170+
Parking_restrictions Parking restrictions

TLM/TLM/Resources/lang_fr.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter Les bus d'évacuation peuv
156156
Vehicle_behavior Comportement des véhicules
157157
Policies_&_Restrictions Restrictions et politiques
158158
At_junctions Aux jonctions
159-
In_case_of_emergency En cas d'urgence
159+
In_case_of_emergency En cas d'urgence
160+
Show_lane-wise_speed_limits Show lane-wise speed limits
161+
Language Language
162+
Game_language Game language
163+
requires_game_restart requires game restart
164+
Customizations_come_into_effect_instantaneously Customizations come into effect instantaneously
165+
Options Options
166+
Lock_main_menu_button_position Lock main menu button position
167+
Lock_main_menu_position Lock main menu position
168+
Recalculating_lane_routing Recalculating lane routing
169+
Please_wait Please wait
170+
Parking_restrictions Parking restrictions

TLM/TLM/Resources/lang_it.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter I bus di evacuazione posso
156156
Vehicle_behavior Comportamente del veicolo
157157
Policies_&_Restrictions Policies & Restrizioni
158158
At_junctions Agli incroci
159-
In_case_of_emergency In caso di emergenza
159+
In_case_of_emergency In caso di emergenza
160+
Show_lane-wise_speed_limits Show lane-wise speed limits
161+
Language Language
162+
Game_language Game language
163+
requires_game_restart requires game restart
164+
Customizations_come_into_effect_instantaneously Customizations come into effect instantaneously
165+
Options Options
166+
Lock_main_menu_button_position Lock main menu button position
167+
Lock_main_menu_position Lock main menu position
168+
Recalculating_lane_routing Recalculating lane routing
169+
Please_wait Please wait
170+
Parking_restrictions Parking restrictions

TLM/TLM/Resources/lang_ja.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter Evacuation busses may only
157157
Vehicle_behavior Vehicle behavior
158158
Policies_&_Restrictions Policies & Restrictions
159159
At_junctions At junctions
160-
In_case_of_emergency In case of emergency
160+
In_case_of_emergency In case of emergency
161+
Show_lane-wise_speed_limits Show lane-wise speed limits
162+
Language Language
163+
Game_language Game language
164+
requires_game_restart requires game restart
165+
Customizations_come_into_effect_instantaneously Customizations come into effect instantaneously
166+
Options Options
167+
Lock_main_menu_button_position Lock main menu button position
168+
Lock_main_menu_position Lock main menu position
169+
Recalculating_lane_routing Recalculating lane routing
170+
Please_wait Please wait
171+
Parking_restrictions Parking restrictions

TLM/TLM/Resources/lang_kr.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,14 @@ Vehicle_behavior 차량 제한
158158
Policies_&_Restrictions 정책 및 제한
159159
At_junctions 교차로 설정
160160
In_case_of_emergency 긴급 상황 설정
161+
Show_lane-wise_speed_limits Show lane-wise speed limits
162+
Language Language
163+
Game_language Game language
164+
requires_game_restart requires game restart
165+
Customizations_come_into_effect_instantaneously Customizations come into effect instantaneously
166+
Options Options
167+
Lock_main_menu_button_position Lock main menu button position
168+
Lock_main_menu_position Lock main menu position
169+
Recalculating_lane_routing Recalculating lane routing
170+
Please_wait Please wait
171+
Parking_restrictions Parking restrictions

TLM/TLM/Resources/lang_nl.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter Evacuatiebussen mogen enke
157157
Vehicle_behavior Vortuiggedrag
158158
Policies_&_Restrictions Beleidsregels & beperkingen
159159
At_junctions Bij splitsingen
160-
In_case_of_emergency In geval van nood
160+
In_case_of_emergency In geval van nood
161+
Show_lane-wise_speed_limits Show lane-wise speed limits
162+
Language Language
163+
Game_language Game language
164+
requires_game_restart requires game restart
165+
Customizations_come_into_effect_instantaneously Customizations come into effect instantaneously
166+
Options Options
167+
Lock_main_menu_button_position Lock main menu button position
168+
Lock_main_menu_position Lock main menu position
169+
Recalculating_lane_routing Recalculating lane routing
170+
Please_wait Please wait
171+
Parking_restrictions Parking restrictions

0 commit comments

Comments
 (0)