From 914df4a2e6d10652dc48975ad4bbd6b6520fe227 Mon Sep 17 00:00:00 2001 From: Victor-Philipp Negoescu Date: Thu, 18 May 2017 19:07:05 +0200 Subject: [PATCH] 1.9.0: final fixes --- TLM/TLM/Custom/AI/CustomPassengerCarAI.cs | 17 +++-- TLM/TLM/Manager/RoutingManager.cs | 6 +- .../Manager/TrafficLightSimulationManager.cs | 1 + TLM/TLM/Manager/UtilityManager.cs | 67 ++++++++++++++----- TLM/TLM/Resources/lang_es.txt | 13 +++- TLM/TLM/Resources/lang_fr.txt | 13 +++- TLM/TLM/Resources/lang_it.txt | 13 +++- TLM/TLM/Resources/lang_ja.txt | 13 +++- TLM/TLM/Resources/lang_kr.txt | 11 +++ TLM/TLM/Resources/lang_nl.txt | 13 +++- TLM/TLM/Resources/lang_pl.txt | 13 +++- TLM/TLM/Resources/lang_pt.txt | 15 ++++- TLM/TLM/Resources/lang_ru.txt | 13 +++- TLM/TLM/Resources/lang_template.txt | 13 +++- TLM/TLM/Resources/lang_zh-tw.txt | 13 +++- TLM/TLM/Resources/lang_zh.txt | 13 +++- TLM/TLM/State/GlobalConfig.cs | 40 ++++++----- TLM/TLM/TrafficLight/TimedTrafficLights.cs | 16 +++++ TLM/TLM/TrafficManagerMod.cs | 6 +- TLM/TLM/UI/SubTools/LaneConnectorTool.cs | 2 - TLM/TLM/UI/SubTools/PrioritySignsTool.cs | 8 ++- TLM/TLM/UI/SubTools/TimedTrafficLightsTool.cs | 41 ++++++------ TLM/TLM/UI/UIBase.cs | 2 +- 23 files changed, 283 insertions(+), 79 deletions(-) diff --git a/TLM/TLM/Custom/AI/CustomPassengerCarAI.cs b/TLM/TLM/Custom/AI/CustomPassengerCarAI.cs index c9cf608d..e8d7b1d3 100644 --- a/TLM/TLM/Custom/AI/CustomPassengerCarAI.cs +++ b/TLM/TLM/Custom/AI/CustomPassengerCarAI.cs @@ -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; @@ -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 @@ -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}"); diff --git a/TLM/TLM/Manager/RoutingManager.cs b/TLM/TLM/Manager/RoutingManager.cs index a7589cb5..a2b19ced 100644 --- a/TLM/TLM/Manager/RoutingManager.cs +++ b/TLM/TLM/Manager/RoutingManager.cs @@ -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; }); @@ -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; }); diff --git a/TLM/TLM/Manager/TrafficLightSimulationManager.cs b/TLM/TLM/Manager/TrafficLightSimulationManager.cs index 32fb6ff7..c0b4dfe1 100644 --- a/TLM/TLM/Manager/TrafficLightSimulationManager.cs +++ b/TLM/TLM/Manager/TrafficLightSimulationManager.cs @@ -234,6 +234,7 @@ public bool LoadData(List data) { foreach (KeyValuePair 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; diff --git a/TLM/TLM/Manager/UtilityManager.cs b/TLM/TLM/Manager/UtilityManager.cs index cdc2c5c2..8ef30613 100644 --- a/TLM/TLM/Manager/UtilityManager.cs +++ b/TLM/TLM/Manager/UtilityManager.cs @@ -6,6 +6,7 @@ using TrafficManager.State; using TrafficManager.Geometry; using CSUtil.Commons; +using TrafficManager.Custom.AI; namespace TrafficManager.Manager { public class UtilityManager : AbstractCustomManager { @@ -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.instance.ForcedSimulationPaused = true; - Log._Debug($"UtilityManager.RemoveStuckEntities(): Waiting for all paths."); + Log.Info($"UtilityManager.RemoveStuckEntities(): Waiting for all paths."); Singleton.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.instance.m_instances.m_buffer[citizenInstanceId]; - if ((citizenData.m_flags & CitizenInstance.Flags.WaitingPath) != CitizenInstance.Flags.None) { + if ((Singleton.instance.m_instances.m_buffer[citizenInstanceId].m_flags & CitizenInstance.Flags.WaitingPath) != CitizenInstance.Flags.None) { CitizenAI ai = Singleton.instance.m_instances.m_buffer[citizenInstanceId].Info.m_citizenAI; - if (citizenData.m_path != 0u) { - Singleton.instance.ReleasePath(citizenData.m_path); - Singleton.instance.m_instances.m_buffer[citizenInstanceId].m_path = 0u; + if (Singleton.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.instance.ReleasePath(Singleton.instance.m_instances.m_buffer[citizenInstanceId].m_path); + Singleton.instance.m_instances.m_buffer[citizenInstanceId].m_path = 0u; +#if DEBUG + } +#endif } Singleton.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.instance.m_vehicles.m_buffer[vehicleId]; - if ((vehicleData.m_flags & Vehicle.Flags.WaitingPath) != 0) { - if (vehicleData.m_path != 0u) { - Singleton.instance.ReleasePath(vehicleData.m_path); - Singleton.instance.m_vehicles.m_buffer[vehicleId].m_path = 0u; + if ((Singleton.instance.m_vehicles.m_buffer[vehicleId].m_flags & Vehicle.Flags.WaitingPath) != 0) { + if (Singleton.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.instance.ReleasePath(Singleton.instance.m_vehicles.m_buffer[vehicleId].m_path); + Singleton.instance.m_vehicles.m_buffer[vehicleId].m_path = 0u; +#if DEBUG + } +#endif } Singleton.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.instance.m_vehicles.m_buffer[vehicleId].m_flags & Vehicle.Flags.Parking) != 0) { + ushort driverInstanceId = CustomPassengerCarAI.GetDriverInstance((ushort)vehicleId, ref Singleton.instance.m_vehicles.m_buffer[vehicleId]); + uint citizen = Singleton.instance.m_instances.m_buffer[(int)driverInstanceId].m_citizen; + if (citizen != 0u && Singleton.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.instance.m_vehicles.m_buffer[vehicleId].m_flags &= ~Vehicle.Flags.Parking; +#if DEBUG + } +#endif + } + } + } + + Log.Info($"UtilityManager.RemoveStuckEntities(): Unpausing simulation."); Singleton.instance.ForcedSimulationPaused = false; } } diff --git a/TLM/TLM/Resources/lang_es.txt b/TLM/TLM/Resources/lang_es.txt index 6d4d9728..2f7f35ca 100644 --- a/TLM/TLM/Resources/lang_es.txt +++ b/TLM/TLM/Resources/lang_es.txt @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/TLM/TLM/Resources/lang_fr.txt b/TLM/TLM/Resources/lang_fr.txt index e3f38b3e..a9484475 100644 --- a/TLM/TLM/Resources/lang_fr.txt +++ b/TLM/TLM/Resources/lang_fr.txt @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/TLM/TLM/Resources/lang_it.txt b/TLM/TLM/Resources/lang_it.txt index 0fcd6f3e..d01d58d4 100644 --- a/TLM/TLM/Resources/lang_it.txt +++ b/TLM/TLM/Resources/lang_it.txt @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/TLM/TLM/Resources/lang_ja.txt b/TLM/TLM/Resources/lang_ja.txt index b6a98b9c..7826514d 100644 --- a/TLM/TLM/Resources/lang_ja.txt +++ b/TLM/TLM/Resources/lang_ja.txt @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/TLM/TLM/Resources/lang_kr.txt b/TLM/TLM/Resources/lang_kr.txt index 7fb895fa..77cf847a 100644 --- a/TLM/TLM/Resources/lang_kr.txt +++ b/TLM/TLM/Resources/lang_kr.txt @@ -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 \ No newline at end of file diff --git a/TLM/TLM/Resources/lang_nl.txt b/TLM/TLM/Resources/lang_nl.txt index 9f066357..4469eee8 100644 --- a/TLM/TLM/Resources/lang_nl.txt +++ b/TLM/TLM/Resources/lang_nl.txt @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/TLM/TLM/Resources/lang_pl.txt b/TLM/TLM/Resources/lang_pl.txt index 66a816bd..1c78c312 100644 --- a/TLM/TLM/Resources/lang_pl.txt +++ b/TLM/TLM/Resources/lang_pl.txt @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/TLM/TLM/Resources/lang_pt.txt b/TLM/TLM/Resources/lang_pt.txt index 0412b101..1bfd165c 100644 --- a/TLM/TLM/Resources/lang_pt.txt +++ b/TLM/TLM/Resources/lang_pt.txt @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/TLM/TLM/Resources/lang_ru.txt b/TLM/TLM/Resources/lang_ru.txt index 57c0af14..61bfcefa 100644 --- a/TLM/TLM/Resources/lang_ru.txt +++ b/TLM/TLM/Resources/lang_ru.txt @@ -157,4 +157,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter Автобусы эвак Vehicle_behavior Поведение транспорта Policies_&_Restrictions Политики & Ограничения At_junctions На перекрёстках -In_case_of_emergency В случае крайней необходимости \ No newline at end of file +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 Ограничения парковки \ No newline at end of file diff --git a/TLM/TLM/Resources/lang_template.txt b/TLM/TLM/Resources/lang_template.txt index acd806d7..6fe6bd97 100644 --- a/TLM/TLM/Resources/lang_template.txt +++ b/TLM/TLM/Resources/lang_template.txt @@ -156,4 +156,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter Vehicle_behavior Policies_&_Restrictions At_junctions -In_case_of_emergency \ No newline at end of file +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 \ No newline at end of file diff --git a/TLM/TLM/Resources/lang_zh-tw.txt b/TLM/TLM/Resources/lang_zh-tw.txt index fe671978..6272b490 100644 --- a/TLM/TLM/Resources/lang_zh-tw.txt +++ b/TLM/TLM/Resources/lang_zh-tw.txt @@ -157,4 +157,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter 緊急疏散公車僅可 Vehicle_behavior 車輛行為 Policies_&_Restrictions 政策與限制 At_junctions 位在交岔路口 -In_case_of_emergency 在緊急狀況下 \ No newline at end of file +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 停車限制 \ No newline at end of file diff --git a/TLM/TLM/Resources/lang_zh.txt b/TLM/TLM/Resources/lang_zh.txt index 01ef6d8c..33d226e7 100644 --- a/TLM/TLM/Resources/lang_zh.txt +++ b/TLM/TLM/Resources/lang_zh.txt @@ -156,4 +156,15 @@ Evacuation_busses_may_only_be_used_to_reach_a_shelter 应急疏散巴士仅可 Vehicle_behavior 车辆行为 Policies_&_Restrictions 政策和限制 At_junctions 位于十字路口 -In_case_of_emergency 在紧急情况下 \ No newline at end of file +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 \ No newline at end of file diff --git a/TLM/TLM/State/GlobalConfig.cs b/TLM/TLM/State/GlobalConfig.cs index f8b6aeb0..afe90c84 100644 --- a/TLM/TLM/State/GlobalConfig.cs +++ b/TLM/TLM/State/GlobalConfig.cs @@ -17,7 +17,7 @@ namespace TrafficManager.State { public class GlobalConfig { public const string FILENAME = "TMPE_GlobalConfig.xml"; public const string BACKUP_FILENAME = FILENAME + ".bak"; - private static int LATEST_VERSION = 5; + private static int LATEST_VERSION = 6; #if DEBUG private static uint lastModificationCheckFrame = 0; #endif @@ -68,7 +68,7 @@ internal static void OnLevelUnloading() { false, // path-find debug log false, // path-find costs debug log false, // parking ai debug log (basic) - false, // -unused- + false, // do not actually repair stuck vehicles/cims, just report false, // parking ai debug log (extended) false, // geometry debug log false, // debug parking AI distance issue @@ -118,27 +118,29 @@ internal static void OnLevelUnloading() { /// /// speed-to-density balance factor, 1 = only speed is considered, 0 = both speed and density are considered /// + [Obsolete] public float SpeedToDensityBalance = 0.75f; /// /// Relative factor for lane speed cost calculation /// - public float SpeedCostFactor = 0.05f; + public float SpeedCostFactor = 0.25f; /// /// lane changing cost reduction modulo /// - public uint RandomizedLaneChangingModulo = 100; + public uint RandomizedLaneChangingModulo = 5; /// /// randomized modulo. vehicles hitting zero ignore traffic measurements /// + [Obsolete] public int RandomizedTrafficIgnoreModulo = 3; /// /// artifical lane distance for u-turns /// - public int UturnLaneDistance = 1; + public int UturnLaneDistance = 2; /// /// artifical lane distance for vehicles that change to lanes which have an incompatible lane arrow configuration @@ -148,22 +150,23 @@ internal static void OnLevelUnloading() { /// /// lane density random interval /// - public float LaneDensityRandInterval = 10f; + [Obsolete] + public float LaneDensityRandInterval = 2; /// /// lane speed random interval /// - public float LaneSpeedRandInterval = 20f; + public float LaneSpeedRandInterval = 25f; /// /// Threshold for reducing traffic buffer /// - public uint MaxTrafficBuffer = 100000; + public uint MaxTrafficBuffer = 500; /// /// Threshold for reducing path-find traffic buffer /// - public uint MaxPathFindTrafficBuffer = 100000; + public uint MaxPathFindTrafficBuffer = 5000; /// /// Threshold for restart segment direction congestion measurements @@ -249,27 +252,30 @@ internal static void OnLevelUnloading() { /// /// Minimum speed update factor /// - public float MinSpeedUpdateFactor = 0.025f; + [Obsolete] + public float MinSpeedUpdateFactor = 0.05f; /// /// Maximum speed update factor /// - public float MaxSpeedUpdateFactor = 0.25f; + [Obsolete] + public float MaxSpeedUpdateFactor = 0.1f; /// /// Maximum density accumulation after which lane densities are reset /// - public uint MaxAccumulatedLaneDensity = 100000; + [Obsolete] + public uint MaxAccumulatedLaneDensity = 1000; /// /// average speed (in %) threshold for a segment to be flagged as congested /// - public uint CongestionSpeedThreshold = 60; + public uint CongestionSpeedThreshold = 70; /// /// %/100 of time a segment must be flagged as congested to count as permanently congested /// - public uint CongestionFrequencyThreshold = 25; + public uint CongestionFrequencyThreshold = 110; /// /// lower congestion threshold (per ten-thousands) @@ -342,7 +348,8 @@ internal static void OnLevelUnloading() { /// /// Maximum allowed reported speed difference among all lanes of one segment (in 10000ths) /// - public uint MaxSpeedDifference = 950u; + [Obsolete] + public uint MaxSpeedDifference = 500u; /// /// Main menu button position @@ -368,6 +375,9 @@ private static GlobalConfig WriteDefaultConfig(GlobalConfig oldConfig, out DateT if (oldConfig != null) { conf.MainMenuButtonX = oldConfig.MainMenuButtonX; conf.MainMenuButtonY = oldConfig.MainMenuButtonY; + + conf.MainMenuX = oldConfig.MainMenuX; + conf.MainMenuY = oldConfig.MainMenuY; } modifiedTime = WriteConfig(conf); return conf; diff --git a/TLM/TLM/TrafficLight/TimedTrafficLights.cs b/TLM/TLM/TrafficLight/TimedTrafficLights.cs index 1e940bad..069758bb 100644 --- a/TLM/TLM/TrafficLight/TimedTrafficLights.cs +++ b/TLM/TLM/TrafficLight/TimedTrafficLights.cs @@ -122,11 +122,21 @@ internal void PasteSteps(TimedTrafficLights sourceTimedLight) { } Steps.Add(targetStep); } + + if (sourceTimedLight.IsStarted()) { + Start(); + } } private object rotateLock = new object(); private void Rotate(ArrowDirection dir) { + if (! IsMasterNode() || NodeGroup.Count != 1) { + return; + } + + Stop(); + try { Monitor.Enter(rotateLock); @@ -283,6 +293,12 @@ public void Start() { /*if (!housekeeping()) return;*/ + foreach (TimedTrafficLightsStep step in Steps) { + foreach (KeyValuePair e in step.CustomSegmentLights) { + e.Value.housekeeping(true, true); + } + } + CheckInvalidPedestrianLights(); CurrentStep = 0; diff --git a/TLM/TLM/TrafficManagerMod.cs b/TLM/TLM/TrafficManagerMod.cs index 50c63d4b..0dc9405f 100644 --- a/TLM/TLM/TrafficManagerMod.cs +++ b/TLM/TLM/TrafficManagerMod.cs @@ -6,13 +6,13 @@ namespace TrafficManager { public class TrafficManagerMod : IUserMod { - public static readonly string Version = "1.9.0-rc1"; + public static readonly string Version = "1.9.0"; - public static readonly uint GameVersion = 163701776u; + public static readonly uint GameVersion = 163702032u; public static readonly uint GameVersionA = 1u; public static readonly uint GameVersionB = 7u; public static readonly uint GameVersionC = 0u; - public static readonly uint GameVersionBuild = 4u; + public static readonly uint GameVersionBuild = 5u; public string Name => "Traffic Manager: President Edition [" + Version + "]"; diff --git a/TLM/TLM/UI/SubTools/LaneConnectorTool.cs b/TLM/TLM/UI/SubTools/LaneConnectorTool.cs index aec2c56d..95237928 100644 --- a/TLM/TLM/UI/SubTools/LaneConnectorTool.cs +++ b/TLM/TLM/UI/SubTools/LaneConnectorTool.cs @@ -31,7 +31,6 @@ enum StayInLaneMode { } private static readonly Color DefaultNodeMarkerColor = new Color(1f, 1f, 1f, 0.4f); - private Dictionary nodeGeometryUnsubscribers; private NodeLaneMarker selectedMarker = null; private NodeLaneMarker hoveredMarker = null; private Dictionary> currentNodeMarkers; @@ -57,7 +56,6 @@ class NodeLaneMarker { public LaneConnectorTool(TrafficManagerTool mainTool) : base(mainTool) { //Log._Debug($"TppLaneConnectorTool: Constructor called"); - nodeGeometryUnsubscribers = new Dictionary(); currentNodeMarkers = new Dictionary>(); } diff --git a/TLM/TLM/UI/SubTools/PrioritySignsTool.cs b/TLM/TLM/UI/SubTools/PrioritySignsTool.cs index 2aa9ebb9..998af6e7 100644 --- a/TLM/TLM/UI/SubTools/PrioritySignsTool.cs +++ b/TLM/TLM/UI/SubTools/PrioritySignsTool.cs @@ -77,9 +77,9 @@ private void RefreshCurrentPriorityNodeIds() { continue; } - if (! MainTool.IsNodeWithinViewDistance(nodeId)) { + /*if (! MainTool.IsNodeWithinViewDistance(nodeId)) { continue; - } + }*/ currentPriorityNodeIds.Add((ushort)nodeId); } @@ -110,6 +110,10 @@ public void ShowGUI(bool viewOnly) { ushort removedNodeId = 0; bool showRemoveButton = false; foreach (ushort nodeId in currentPriorityNodeIds) { + if (!MainTool.IsNodeWithinViewDistance(nodeId)) { + continue; + } + NodeGeometry nodeGeo = NodeGeometry.Get(nodeId); Vector3 nodePos = default(Vector3); diff --git a/TLM/TLM/UI/SubTools/TimedTrafficLightsTool.cs b/TLM/TLM/UI/SubTools/TimedTrafficLightsTool.cs index d914c569..31c25892 100644 --- a/TLM/TLM/UI/SubTools/TimedTrafficLightsTool.cs +++ b/TLM/TLM/UI/SubTools/TimedTrafficLightsTool.cs @@ -597,33 +597,32 @@ private void _guiTimedControlPanel(int num) { return; } - if (!timedLightActive) { - - GUILayout.Space(30); - - if (SelectedNodeIndexes.Count == 1 && timedNodeMain.NumSteps() > 0) { - GUILayout.BeginHorizontal(); + GUILayout.Space(30); - if (GUILayout.Button(Translation.GetString("Rotate_left"))) { - _timedViewedStep = 0; - timedNodeMain.RotateLeft(); - timedNodeMain.SetLights(); - } + if (SelectedNodeIndexes.Count == 1 && timedNodeMain.NumSteps() > 0) { + GUILayout.BeginHorizontal(); - if (GUILayout.Button(Translation.GetString("Copy"))) { - nodeIdToCopy = SelectedNodeIndexes[0]; - MainTool.SetToolMode(ToolMode.TimedLightsCopyLights); - } + if (GUILayout.Button(Translation.GetString("Rotate_left"))) { + _timedViewedStep = 0; + timedNodeMain.RotateLeft(); + timedNodeMain.SetLights(); + } - if (GUILayout.Button(Translation.GetString("Rotate_right"))) { - _timedViewedStep = 0; - timedNodeMain.RotateRight(); - timedNodeMain.SetLights(); - } + if (GUILayout.Button(Translation.GetString("Copy"))) { + nodeIdToCopy = SelectedNodeIndexes[0]; + MainTool.SetToolMode(ToolMode.TimedLightsCopyLights); + } - GUILayout.EndHorizontal(); + if (GUILayout.Button(Translation.GetString("Rotate_right"))) { + _timedViewedStep = 0; + timedNodeMain.RotateRight(); + timedNodeMain.SetLights(); } + GUILayout.EndHorizontal(); + } + + if (!timedLightActive) { GUILayout.Space(30); if (GUILayout.Button(Translation.GetString("Add_junction_to_timed_light"))) { diff --git a/TLM/TLM/UI/UIBase.cs b/TLM/TLM/UI/UIBase.cs index d16c9d88..04514224 100644 --- a/TLM/TLM/UI/UIBase.cs +++ b/TLM/TLM/UI/UIBase.cs @@ -21,6 +21,7 @@ public static TrafficManagerTool GetTrafficManagerTool(bool createIfRequired=tru Log.Info("Initializing traffic manager tool..."); tool = ToolsModifierControl.toolController.gameObject.GetComponent() ?? ToolsModifierControl.toolController.gameObject.AddComponent(); + tool.Initialize(); } return tool; @@ -139,7 +140,6 @@ public static void SetToolMode(TrafficManagerMode mode) { public static void EnableTool() { Log._Debug("LoadingExtension.EnableTool: called"); TrafficManagerTool tmTool = GetTrafficManagerTool(true); - tmTool.Initialize(); ToolsModifierControl.toolController.CurrentTool = tmTool; ToolsModifierControl.SetTool();