Skip to content

Commit

Permalink
TMPE 1.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorPhilipp committed May 20, 2017
1 parent 89bf334 commit fb35622
Show file tree
Hide file tree
Showing 37 changed files with 459 additions and 255 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ A work-in-progress modification for **Cities: Skylines** to add additional traff
User manual: http://www.viathinksoft.de/tmpe

# Changelog
1.9.0, 04/09/2017
1.9.2, 05/20/2017
- UI: Main menu & UI tools performance improved
- Bugfix: Traffic lights can be removed from junctions that are controlled by a timed traffic light program

1.9.1, 05/19/2017
- Updated French, Dutch and Korean translation
- Bugfix: Using the vanilla traffic light toggling feature crashes the game if TMPE's main menu has not been opened at least once
- Bugfix: AI: More car traffic and less public transportation present than in vanilla

1.9.0, 05/18/2017
- Updated for game version 1.7.0-f5
- New feature: Parking restrictions
- New feature: Speed limits can be set up for individual lanes with the Control key
Expand All @@ -19,9 +28,10 @@ User manual: http://www.viathinksoft.de/tmpe
- Path-finding cost multiplicator for vehicle restrictions is now configurable in TMPE_GlobalConfig.xml
- UI: More compact, movable main menu UI
- Added support for custom languages
- Added Korean translation (thanks to @Toothless FLY [ROK]LSh.st for translating)
- Updated translations: German, Polish, Russian, Portuguese, Traditional Chinese
- Major code refactorings
- AI: Tuned parameters
- AI: Tuned path-finding parameters
- New option: Main button position can be locked
- New option: Main menu position can be locked
- New option: Added language selection in options dialog
Expand Down
2 changes: 1 addition & 1 deletion TLM/TLM/Custom/PathFinding/CustomPathFind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ private bool ProcessItemCosts(bool debug, bool allowAdvancedAI, bool obeyStockLa
Randomizer randomizer = new Randomizer(this._pathFindIndex << 16 | (uint)item.m_position.m_segment);
prevCost *= (float)(randomizer.Int32(900, 1000 + (int)(prevSegment.m_trafficDensity * 10)) + this._pathRandomizer.Int32(20u)) * 0.001f;
} else {
prevCost *= (1f - _conf.SpeedCostFactor) + _conf.SpeedCostFactor * (1f - prevSpeed);
prevCost *= 1f + _conf.SpeedCostFactor * (1f - prevSpeed);
}
}

Expand Down
18 changes: 16 additions & 2 deletions TLM/TLM/Geometry/SegmentEndGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ internal void Recalculate(GeometryCalculationMode calcMode) {
IncomingOneWay = true;
}
OnlyHighways = true;
#if DEBUGGEO
if (GlobalConfig.Instance.DebugSwitches[5])
Log._Debug($"Checking if segment {SegmentId} is connected to highways only at node {NodeId()}. OnlyHighways={OnlyHighways}");
#endif

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

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

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

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

if (!hasOtherSegments)
if (!hasOtherSegments) {
#if DEBUGGEO
if (GlobalConfig.Instance.DebugSwitches[5])
Log._Debug($"Segment {SegmentId} is not connected to any other segments at node {NodeId()}.");
#endif
OnlyHighways = false;
}

// propagate information to other segments
if (calcMode == GeometryCalculationMode.Init || (calcMode == GeometryCalculationMode.Propagate && nodeIdBeforeRecalc != nodeId)) {
Expand Down
61 changes: 37 additions & 24 deletions TLM/TLM/Geometry/SegmentGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,7 @@ public ArrowDirection GetDirection(ushort otherSegmentId, bool startNode) {
/// </summary>
/// <param name="startNode"></param>
/// <returns></returns>
[Obsolete]
public bool AreHighwayRulesEnabled(bool startNode) {
if (!Options.highwayRules)
return false;
Expand Down Expand Up @@ -1086,9 +1087,14 @@ internal static bool calculateIsOutgoingOneWay(ushort segmentId, ushort nodeId)
var laneId = instance.m_segments.m_buffer[segmentId].m_lanes;
var laneIndex = 0;
while (laneIndex < info.m_lanes.Length && laneId != 0u) {
if (info.m_lanes[laneIndex].m_laneType != NetInfo.LaneType.Pedestrian &&
((info.m_lanes[laneIndex].m_finalDirection & dir) != NetInfo.Direction.None)) {
return false;
bool validLane = (info.m_lanes[laneIndex].m_laneType & (NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle)) != NetInfo.LaneType.None &&
(info.m_lanes[laneIndex].m_vehicleType & (VehicleInfo.VehicleType.Car | VehicleInfo.VehicleType.Train | VehicleInfo.VehicleType.Tram | VehicleInfo.VehicleType.Metro | VehicleInfo.VehicleType.Monorail)) != VehicleInfo.VehicleType.None;
// TODO the lane types and vehicle types should be specified to make it clear which lanes we need to check

if (validLane) {
if ((info.m_lanes[laneIndex].m_finalDirection & dir) != NetInfo.Direction.None) {
return false;
}
}

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

if (info.m_lanes[laneIndex].m_laneType != NetInfo.LaneType.Pedestrian &&
(info.m_lanes[laneIndex].m_direction & NetInfo.Direction.Backward) != NetInfo.Direction.None) {
hasBackward = true;
}
if (validLane) {
if ((info.m_lanes[laneIndex].m_direction & NetInfo.Direction.Forward) != NetInfo.Direction.None) {
hasForward = true;
}

if ((info.m_lanes[laneIndex].m_direction & NetInfo.Direction.Backward) != NetInfo.Direction.None) {
hasBackward = true;
}

if (hasForward && hasBackward) {
return false;
if (hasForward && hasBackward) {
return false;
}
}

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

if (info.m_lanes[laneIndex].m_laneType != NetInfo.LaneType.Pedestrian &&
(info.m_lanes[laneIndex].m_direction & NetInfo.Direction.Forward) != NetInfo.Direction.None) {
hasForward = true;
}
if (validLane) {
if ((info.m_lanes[laneIndex].m_finalDirection & dir2) != NetInfo.Direction.None) {
isOutgoingOneWay = false;
}

if (info.m_lanes[laneIndex].m_laneType != NetInfo.LaneType.Pedestrian &&
(info.m_lanes[laneIndex].m_direction & NetInfo.Direction.Backward) != NetInfo.Direction.None) {
hasBackward = true;
if ((info.m_lanes[laneIndex].m_direction & NetInfo.Direction.Forward) != NetInfo.Direction.None) {
hasForward = true;
}

if ((info.m_lanes[laneIndex].m_direction & NetInfo.Direction.Backward) != NetInfo.Direction.None) {
hasBackward = true;
}
}

laneId = instance.m_lanes.m_buffer[laneId].m_nextLane;
Expand Down
23 changes: 23 additions & 0 deletions TLM/TLM/Manager/LaneConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,29 @@ public bool HasConnections(uint sourceLaneId, bool startNode) {
return ret;
}

/// <summary>
/// Determines if there exist custom lane connections at the specified node
/// </summary>
/// <param name="nodeId"></param>
public bool HasNodeConnections(ushort nodeId) {
#if DEBUGCONN
Log._Debug($"LaneConnectionManager.RemoveLaneConnectionsFromNode({nodeId}) called.");
#endif

bool ret = false;
Services.NetService.IterateNodeSegments(nodeId, delegate (ushort segmentId, ref NetSegment segment) {
Services.NetService.IterateSegmentLanes(segmentId, delegate (uint laneId, ref NetLane lane, NetInfo.Lane laneInfo, ushort segId, ref NetSegment seg, byte laneIndex) {
if (HasConnections(laneId, seg.m_startNode == nodeId)) {
ret = true;
return false;
}
return true;
});
return !ret;
});
return ret;
}

public bool HasUturnConnections(ushort segmentId, bool startNode) {
NetManager netManager = Singleton<NetManager>.instance;
int nodeArrayIndex = startNode ? 0 : 1;
Expand Down
6 changes: 4 additions & 2 deletions TLM/TLM/Manager/TrafficLightManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public bool SetTrafficLight(ushort nodeId, bool flag) {

public bool SetTrafficLight(ushort nodeId, bool flag, out UnableReason reason) {
if (! IsTrafficLightToggleable(nodeId, out reason)) {
return false;
if (reason != UnableReason.HasTimedLight || !flag) {
return false;
}
}

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

if (TrafficLightSimulationManager.Instance.HasActiveTimedSimulation(nodeId)) {
if (TrafficLightSimulationManager.Instance.HasTimedSimulation(nodeId)) {
reason = UnableReason.HasTimedLight;
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions TLM/TLM/Manager/TrafficMeasurementManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace TrafficManager.Manager {
public class TrafficMeasurementManager : AbstractCustomManager {
public const VehicleInfo.VehicleType VEHICLE_TYPES = VehicleInfo.VehicleType.Car;
public const NetInfo.LaneType LANE_TYPES = NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle;

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

Expand Down
2 changes: 1 addition & 1 deletion TLM/TLM/Manager/TrafficPriorityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ private bool HasVehiclePriority(bool debug, ushort transitNodeId, ushort targetV
#endif

if (targetEnd.NodeId != incomingEnd.NodeId) {
Log.Error($"HasVehiclePriority: Incompatible SegmentEnds!");
Log._Debug($"HasVehiclePriority: Incompatible SegmentEnds: targetEnd.NodeId={targetEnd.NodeId}, incomingEnd.NodeId={incomingEnd.NodeId}");
return true;
}

Expand Down
3 changes: 2 additions & 1 deletion TLM/TLM/Resources/lang.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,5 @@ 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
Parking_restrictions Parking restrictions
Simulation Simulation
3 changes: 2 additions & 1 deletion TLM/TLM/Resources/lang_de.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,5 @@ Lock_main_menu_button_position Position der Hauptmenü-Schaltfläche sperren
Lock_main_menu_position Position des Hauptmenüs sperren
Recalculating_lane_routing Berechne Routenführung neu
Please_wait Bitte warten
Parking_restrictions Parkverbote
Parking_restrictions Parkverbote
Simulation Simulation
3 changes: 2 additions & 1 deletion TLM/TLM/Resources/lang_es.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,5 @@ 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
Parking_restrictions Parking restrictions
Simulation Simulation
3 changes: 2 additions & 1 deletion TLM/TLM/Resources/lang_fr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,5 @@ 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
Parking_restrictions Parking restrictions
Simulation Simulation
3 changes: 2 additions & 1 deletion TLM/TLM/Resources/lang_it.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,5 @@ 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
Parking_restrictions Parking restrictions
Simulation Simulation
3 changes: 2 additions & 1 deletion TLM/TLM/Resources/lang_ja.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,5 @@ 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
Parking_restrictions Parking restrictions
Simulation Simulation
27 changes: 14 additions & 13 deletions TLM/TLM/Resources/lang_kr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Busses_may_ignore_lane_arrows 버스가 도로 화살표를 무시 할 수 있
Reckless_driving 난폭 운전 (베타 기능)
TMPE_Title 트래픽 매니저 : 대통령 에디션
Settings_are_defined_for_each_savegame_separately 설정은 각 저장된 게임마다 별개로 작동합니다.
Simulation_accuracy 시뮬레이션 정확도 (효과가 올라갈수록 성능은 감소합니다)
Simulation_accuracy 시뮬레이션 정확도 (높을수록 더 많은 연산을 요구합니다)
Enable_highway_specific_lane_merging/splitting_rules 고속도로 특정도로 병합/분할 기능 활성화
Drivers_want_to_change_lanes_(only_applied_if_Advanced_AI_is_enabled): 운전자가 차선을 변경합니다 (발전된 차량 AI를 사용 중일 때만 적용됩니다)
Maintenance 유지보수 (추가정보)
Expand All @@ -70,7 +70,7 @@ Sometimes 가끔
Rarely 드물게
Very_rarely 매우 드물게
Only_if_necessary 필요한 경우에만
Nodes_and_segments 도로와 세그먼트(구간)
Nodes_and_segments 도로와 세그먼트(노드)
Lanes 차선
Path_Of_Evil_(10_%) 악마의 도로 (10 %)
Rush_Hour_(5_%) 출퇴근정도의 혼잡 (5 %)
Expand Down Expand Up @@ -158,14 +158,15 @@ 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
Show_lane-wise_speed_limits 차선 속도제한 보기
Language 언어
Game_language 게임 언어
requires_game_restart 게임 재시작후 적용됩니다
Customizations_come_into_effect_instantaneously 커스텀 기능이 즉시 적용됩니다
Options 설정
Lock_main_menu_button_position TMPE 모드버튼 위치 잠금
Lock_main_menu_position TMPE 모드매뉴 위치 잠금
Recalculating_lane_routing 차선 경로 재 계산하기
Please_wait 잠시만 기다려주십시오
Parking_restrictions 주차 제한
Simulation 시뮬레이션
22 changes: 11 additions & 11 deletions TLM/TLM/Resources/lang_nl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ Vehicle_behavior Vortuiggedrag
Policies_&_Restrictions Beleidsregels & beperkingen
At_junctions Bij splitsingen
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
Show_lane-wise_speed_limits Toon rijstrookspecifieke snelheidslimieten
Language Taal
Game_language Taal van spel
requires_game_restart Vereist spelherstart
Customizations_come_into_effect_instantaneously Aanpassingen zijn onmiddelijk van toepassing
Options Instellingen
Lock_main_menu_button_position Vergendel positie van hoofdmenuknop
Lock_main_menu_position Vergrendel positie van hoofdmenu
Recalculating_lane_routing Rijstrookroutering wordt herberekend
Please_wait Even geduld graag
Parking_restrictions Parkeerbeperkingen
3 changes: 2 additions & 1 deletion TLM/TLM/Resources/lang_pl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,5 @@ 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
Parking_restrictions Ograniczenia parkingowe
Simulation Simulation
3 changes: 2 additions & 1 deletion TLM/TLM/Resources/lang_pt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,5 @@ 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
Parking_restrictions Parking restrictions
Simulation Simulation
Loading

0 comments on commit fb35622

Please sign in to comment.