Skip to content

Commit

Permalink
1.9.0: final fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorPhilipp committed May 18, 2017
1 parent 3bac079 commit 914df4a
Show file tree
Hide file tree
Showing 23 changed files with 283 additions and 79 deletions.
17 changes: 11 additions & 6 deletions TLM/TLM/Custom/AI/CustomPassengerCarAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,13 @@ public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vecto
driverExtInstance.Reset();

// pocket car fallback
vehicleData.m_flags |= Vehicle.Flags.Parking;
return true;
//vehicleData.m_flags |= Vehicle.Flags.Parking;
return false;
} else {
#if DEBUG
if (GlobalConfig.Instance.DebugSwitches[4])
Log._Debug($"Increased number of parking attempts for vehicle {vehicleID}: {driverExtInstance.FailedParkingAttempts}/{GlobalConfig.Instance.MaxParkingAttempts}");
#endif
}
} else {
driverExtInstance.PathMode = ExtPathMode.CalculatingCarPathToKnownParkPos;
Expand Down Expand Up @@ -448,9 +453,9 @@ public bool CustomParkVehicle(ushort vehicleID, ref Vehicle vehicleData, PathUni
}

if (! foundParkingSpace) {
foundParkingSpace = prohibitPocketCars ?
CustomFindParkingSpace(this.m_info, homeID, refPos, searchDir, pathPos.m_segment, out parkPos, out parkRot, out parkOffset) :
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);
foundParkingSpace = /*prohibitPocketCars ?*/
CustomFindParkingSpace(this.m_info, homeID, refPos, searchDir, pathPos.m_segment, out parkPos, out parkRot, out parkOffset) /*:
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)*/;
}

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

if (GlobalConfig.Instance.DebugSwitches[6] && sqrDist >= 16000) {
Log._Debug($"CustomPassengerCarAI.CustomParkVehicle: FORCED PAUSE. Distance very large! Vehicle {vehicleID}. dist={sqrDist}");
Expand Down
6 changes: 4 additions & 2 deletions TLM/TLM/Manager/RoutingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,8 @@ public int CalcInnerLaneSimilarIndex(ushort segmentId, int laneIndex) {
int ret = -1;
Constants.ServiceFactory.NetService.ProcessSegment(segmentId, delegate (ushort segId, ref NetSegment segment) {
NetInfo.Lane laneInfo = segment.Info.m_lanes[laneIndex];
ret = (byte)(laneInfo.m_finalDirection & NetInfo.Direction.Forward) != 0 ? laneInfo.m_similarLaneIndex : laneInfo.m_similarLaneCount - laneInfo.m_similarLaneIndex - 1;
// note: m_direction is correct here
ret = (byte)(laneInfo.m_direction & NetInfo.Direction.Forward) != 0 ? laneInfo.m_similarLaneIndex : laneInfo.m_similarLaneCount - laneInfo.m_similarLaneIndex - 1;
return true;
});

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

Expand Down
1 change: 1 addition & 0 deletions TLM/TLM/Manager/TrafficLightSimulationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ public bool LoadData(List<Configuration.TimedTrafficLights> data) {
foreach (KeyValuePair<ushort, Configuration.CustomSegmentLights> e in cnfTimedStep.segmentLights) {
if (!Services.NetService.IsSegmentValid(e.Key))
continue;
e.Value.nodeId = cnfTimedLights.nodeId;

Log._Debug($"Loading timed step {j}, segment {e.Key} at node {cnfTimedLights.nodeId}");
CustomSegmentLights lights = null;
Expand Down
67 changes: 51 additions & 16 deletions TLM/TLM/Manager/UtilityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using TrafficManager.State;
using TrafficManager.Geometry;
using CSUtil.Commons;
using TrafficManager.Custom.AI;

namespace TrafficManager.Manager {
public class UtilityManager : AbstractCustomManager {
Expand Down Expand Up @@ -94,43 +95,77 @@ private void PrintAllDebugInfo() {
}

private void ResetStuckEntities() {
Log._Debug($"UtilityManager.RemoveStuckEntities() called.");
Log.Info($"UtilityManager.RemoveStuckEntities() called.");

Log._Debug($"UtilityManager.RemoveStuckEntities(): Pausing simulation.");
Log.Info($"UtilityManager.RemoveStuckEntities(): Pausing simulation.");
Singleton<SimulationManager>.instance.ForcedSimulationPaused = true;

Log._Debug($"UtilityManager.RemoveStuckEntities(): Waiting for all paths.");
Log.Info($"UtilityManager.RemoveStuckEntities(): Waiting for all paths.");
Singleton<PathManager>.instance.WaitForAllPaths();

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

if (citizenData.m_path != 0u) {
Singleton<PathManager>.instance.ReleasePath(citizenData.m_path);
Singleton<CitizenManager>.instance.m_instances.m_buffer[citizenInstanceId].m_path = 0u;
if (Singleton<CitizenManager>.instance.m_instances.m_buffer[citizenInstanceId].m_path != 0u) {
#if DEBUG
if (GlobalConfig.Instance.DebugSwitches[3]) {
Log._Debug($"Would reset citizen instance {citizenInstanceId} (waiting for path)");
} else {
#endif
Singleton<PathManager>.instance.ReleasePath(Singleton<CitizenManager>.instance.m_instances.m_buffer[citizenInstanceId].m_path);
Singleton<CitizenManager>.instance.m_instances.m_buffer[citizenInstanceId].m_path = 0u;
#if DEBUG
}
#endif
}
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);
}
}

Log._Debug($"UtilityManager.RemoveStuckEntities(): Resetting vehicles that are waiting for a path.");
Log.Info($"UtilityManager.RemoveStuckEntities(): Resetting vehicles that are waiting for a path.");
for (uint vehicleId = 1; vehicleId < VehicleManager.MAX_VEHICLE_COUNT; ++vehicleId) {
//Log._Debug($"UtilityManager.RemoveStuckEntities(): Processing vehicle {vehicleId}.");
Vehicle vehicleData = Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId];
if ((vehicleData.m_flags & Vehicle.Flags.WaitingPath) != 0) {
if (vehicleData.m_path != 0u) {
Singleton<PathManager>.instance.ReleasePath(vehicleData.m_path);
Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_path = 0u;
if ((Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_flags & Vehicle.Flags.WaitingPath) != 0) {
if (Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_path != 0u) {
#if DEBUG
if (GlobalConfig.Instance.DebugSwitches[3]) {
Log._Debug($"Would reset vehicle {vehicleId} (waiting for path)");
} else {
#endif
Singleton<PathManager>.instance.ReleasePath(Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_path);
Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_path = 0u;
#if DEBUG
}
#endif
}
Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_flags &= ~Vehicle.Flags.WaitingPath;
}
}

Log._Debug($"UtilityManager.RemoveStuckEntities(): Unpausing simulation.");
Log.Info($"UtilityManager.RemoveStuckEntities(): Resetting vehicles that are parking and where no parked vehicle is assigned to the driver.");
for (uint vehicleId = 1; vehicleId < VehicleManager.MAX_VEHICLE_COUNT; ++vehicleId) {
//Log._Debug($"UtilityManager.RemoveStuckEntities(): Processing vehicle {vehicleId}.");
if ((Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_flags & Vehicle.Flags.Parking) != 0) {
ushort driverInstanceId = CustomPassengerCarAI.GetDriverInstance((ushort)vehicleId, ref Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId]);
uint citizen = Singleton<CitizenManager>.instance.m_instances.m_buffer[(int)driverInstanceId].m_citizen;
if (citizen != 0u && Singleton<CitizenManager>.instance.m_citizens.m_buffer[(int)((UIntPtr)citizen)].m_parkedVehicle == 0) {
#if DEBUG
if (GlobalConfig.Instance.DebugSwitches[3]) {
Log._Debug($"Would reset vehicle {vehicleId} (parking without parked vehicle)");
} else {
#endif
Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId].m_flags &= ~Vehicle.Flags.Parking;
#if DEBUG
}
#endif
}
}
}

Log.Info($"UtilityManager.RemoveStuckEntities(): Unpausing simulation.");
Singleton<SimulationManager>.instance.ForcedSimulationPaused = false;
}
}
Expand Down
13 changes: 12 additions & 1 deletion TLM/TLM/Resources/lang_es.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter Evacuation busses may only
Vehicle_behavior Vehicle behavior
Policies_&_Restrictions Policies & Restrictions
At_junctions At junctions
In_case_of_emergency In case of emergency
In_case_of_emergency In case of emergency
Show_lane-wise_speed_limits Show lane-wise speed limits
Language Language
Game_language Game language
requires_game_restart requires game restart
Customizations_come_into_effect_instantaneously Customizations come into effect instantaneously
Options Options
Lock_main_menu_button_position Lock main menu button position
Lock_main_menu_position Lock main menu position
Recalculating_lane_routing Recalculating lane routing
Please_wait Please wait
Parking_restrictions Parking restrictions
13 changes: 12 additions & 1 deletion TLM/TLM/Resources/lang_fr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter Les bus d'évacuation peuv
Vehicle_behavior Comportement des véhicules
Policies_&_Restrictions Restrictions et politiques
At_junctions Aux jonctions
In_case_of_emergency En cas d'urgence
In_case_of_emergency En cas d'urgence
Show_lane-wise_speed_limits Show lane-wise speed limits
Language Language
Game_language Game language
requires_game_restart requires game restart
Customizations_come_into_effect_instantaneously Customizations come into effect instantaneously
Options Options
Lock_main_menu_button_position Lock main menu button position
Lock_main_menu_position Lock main menu position
Recalculating_lane_routing Recalculating lane routing
Please_wait Please wait
Parking_restrictions Parking restrictions
13 changes: 12 additions & 1 deletion TLM/TLM/Resources/lang_it.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter I bus di evacuazione posso
Vehicle_behavior Comportamente del veicolo
Policies_&_Restrictions Policies & Restrizioni
At_junctions Agli incroci
In_case_of_emergency In caso di emergenza
In_case_of_emergency In caso di emergenza
Show_lane-wise_speed_limits Show lane-wise speed limits
Language Language
Game_language Game language
requires_game_restart requires game restart
Customizations_come_into_effect_instantaneously Customizations come into effect instantaneously
Options Options
Lock_main_menu_button_position Lock main menu button position
Lock_main_menu_position Lock main menu position
Recalculating_lane_routing Recalculating lane routing
Please_wait Please wait
Parking_restrictions Parking restrictions
13 changes: 12 additions & 1 deletion TLM/TLM/Resources/lang_ja.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter Evacuation busses may only
Vehicle_behavior Vehicle behavior
Policies_&_Restrictions Policies & Restrictions
At_junctions At junctions
In_case_of_emergency In case of emergency
In_case_of_emergency In case of emergency
Show_lane-wise_speed_limits Show lane-wise speed limits
Language Language
Game_language Game language
requires_game_restart requires game restart
Customizations_come_into_effect_instantaneously Customizations come into effect instantaneously
Options Options
Lock_main_menu_button_position Lock main menu button position
Lock_main_menu_position Lock main menu position
Recalculating_lane_routing Recalculating lane routing
Please_wait Please wait
Parking_restrictions Parking restrictions
11 changes: 11 additions & 0 deletions TLM/TLM/Resources/lang_kr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,14 @@ Vehicle_behavior 차량 제한
Policies_&_Restrictions 정책 및 제한
At_junctions 교차로 설정
In_case_of_emergency 긴급 상황 설정
Show_lane-wise_speed_limits Show lane-wise speed limits
Language Language
Game_language Game language
requires_game_restart requires game restart
Customizations_come_into_effect_instantaneously Customizations come into effect instantaneously
Options Options
Lock_main_menu_button_position Lock main menu button position
Lock_main_menu_position Lock main menu position
Recalculating_lane_routing Recalculating lane routing
Please_wait Please wait
Parking_restrictions Parking restrictions
13 changes: 12 additions & 1 deletion TLM/TLM/Resources/lang_nl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter Evacuatiebussen mogen enke
Vehicle_behavior Vortuiggedrag
Policies_&_Restrictions Beleidsregels & beperkingen
At_junctions Bij splitsingen
In_case_of_emergency In geval van nood
In_case_of_emergency In geval van nood
Show_lane-wise_speed_limits Show lane-wise speed limits
Language Language
Game_language Game language
requires_game_restart requires game restart
Customizations_come_into_effect_instantaneously Customizations come into effect instantaneously
Options Options
Lock_main_menu_button_position Lock main menu button position
Lock_main_menu_position Lock main menu position
Recalculating_lane_routing Recalculating lane routing
Please_wait Please wait
Parking_restrictions Parking restrictions
13 changes: 12 additions & 1 deletion TLM/TLM/Resources/lang_pl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter Autobusy ewakuacyjne mogą
Vehicle_behavior Zachowanie pojazdu
Policies_&_Restrictions Zasady i Ograniczenia
At_junctions Na strzyżowaniach
In_case_of_emergency W sytuacjach nadzwyczajnych
In_case_of_emergency W sytuacjach nadzwyczajnych
Show_lane-wise_speed_limits Pokaz limity prêdkoœci dla pasów
Language Jêzyk
Game_language Jêzyk gry
requires_game_restart wymagane ponowne uruchomienie gry
Customizations_come_into_effect_instantaneously Modyfikacje ustawieñ maj¹ natychmiastowy efekt
Options Opcje
Lock_main_menu_button_position Zablokuj pozycjê przycisku menu g³ównego
Lock_main_menu_position Zablokuj pozycjê menu g³ównego
Recalculating_lane_routing Ponowne obliczanie tras
Please_wait Proszê czekaæ
Parking_restrictions Ograniczenia parkingowe
15 changes: 14 additions & 1 deletion TLM/TLM/Resources/lang_pt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,17 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter Os ônibus de evacuação
Vehicle_behavior Comportamento do veículo
Policies_&_Restrictions Políticas e Restrições
At_junctions Nas junções
In_case_of_emergency Em caso de emergência
In_case_of_emergency Em caso de emergência
Show_lane-wise_speed_limits Mostrar limites de velocidade por faixa.
Language Linguagem
Game_language Linguagem do Jogo
requires_game_restart Requer reinicialização do jogo
Customizations_come_into_effect_instantaneously Personalizações entram em vigor instantaneamente
Options Opções
Lock_main_menu_button_position Travar posição do botão de menu principal
Lock_main_menu_position Travar posição do menu principal
Recalculating_lane_routing Recalculando o roteamento de faixa
Please_wait Por favor, aguarde
Parking_restrictions Restrições de estacionamento
Please_wait Please wait
Parking_restrictions Parking restrictions
13 changes: 12 additions & 1 deletion TLM/TLM/Resources/lang_ru.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter Автобусы эвак
Vehicle_behavior Поведение транспорта
Policies_&_Restrictions Политики & Ограничения
At_junctions На перекрёстках
In_case_of_emergency В случае крайней необходимости
In_case_of_emergency В случае крайней необходимости
Show_lane-wise_speed_limits Показ ограничения скорости по полосам
Language Локализация
Game_language Язык игры
requires_game_restart требуется перезапуск игры
Customizations_come_into_effect_instantaneously Настройки применяются сразу
Options Свойства
Lock_main_menu_button_position Блокировка позиции кнопки главного меню
Lock_main_menu_position Блокировка позиции главного меню
Recalculating_lane_routing Обновление маршрута
Please_wait Подождите пожалуйста
Parking_restrictions Ограничения парковки
13 changes: 12 additions & 1 deletion TLM/TLM/Resources/lang_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter
Vehicle_behavior
Policies_&_Restrictions
At_junctions
In_case_of_emergency
In_case_of_emergency
Show_lane-wise_speed_limits
Language
Game_language
requires_game_restart
Customizations_come_into_effect_instantaneously
Options
Lock_main_menu_button_position
Lock_main_menu_position
Recalculating_lane_routing
Please_wait
Parking_restrictions
13 changes: 12 additions & 1 deletion TLM/TLM/Resources/lang_zh-tw.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter 緊急疏散公車僅可
Vehicle_behavior 車輛行為
Policies_&_Restrictions 政策與限制
At_junctions 位在交岔路口
In_case_of_emergency 在緊急狀況下
In_case_of_emergency 在緊急狀況下
Show_lane-wise_speed_limits 顯示車道速限
Language 語言
Game_language 遊戲顯示語言
requires_game_restart 需要重新啟動遊戲
Customizations_come_into_effect_instantaneously 自訂值即時生效
Options 選項
Lock_main_menu_button_position 鎖定主選單的選項位置
Lock_main_menu_position 鎖定主選單的位置
Recalculating_lane_routing 重新規劃行駛路線
Please_wait 請稍候
Parking_restrictions 停車限制
13 changes: 12 additions & 1 deletion TLM/TLM/Resources/lang_zh.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter 应急疏散巴士仅可
Vehicle_behavior 车辆行为
Policies_&_Restrictions 政策和限制
At_junctions 位于十字路口
In_case_of_emergency 在紧急情况下
In_case_of_emergency 在紧急情况下
Show_lane-wise_speed_limits Show lane-wise speed limits
Language Language
Game_language Game language
requires_game_restart requires game restart
Customizations_come_into_effect_instantaneously Customizations come into effect instantaneously
Options Options
Lock_main_menu_button_position Lock main menu button position
Lock_main_menu_position Lock main menu position
Recalculating_lane_routing Recalculating lane routing
Please_wait Please wait
Parking_restrictions Parking restrictions
Loading

0 comments on commit 914df4a

Please sign in to comment.