Skip to content

Commit

Permalink
Merge pull request #1033 from CitiesSkylinesMods/11.5-plus-cherry-picks
Browse files Browse the repository at this point in the history
Release stable 11.5.1
  • Loading branch information
krzychu124 committed Nov 19, 2020
2 parents 55ce186 + 2914bdc commit e8675d4
Show file tree
Hide file tree
Showing 39 changed files with 318 additions and 109 deletions.
2 changes: 1 addition & 1 deletion TLM/SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
// Minor Version
// Build Number
// Revision
[assembly: AssemblyVersion("11.5.0.*")]
[assembly: AssemblyVersion("11.5.1.*")]
44 changes: 44 additions & 0 deletions TLM/TLM/Manager/Impl/AdvancedParkingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2883,6 +2883,50 @@ bool citizenDebug
out parkOffset) != 0;
}

public bool VanillaFindParkingSpaceWithoutRestrictions(bool isElectric,
ushort homeId,
Vector3 refPos,
Vector3 searchDir,
ushort segment,
float width,
float length,
out Vector3 parkPos,
out Quaternion parkRot,
out float parkOffset) {
if (!CustomPassengerCarAI.FindParkingSpace(isElectric,
homeId,
refPos,
searchDir,
segment,
width,
length,
out parkPos,
out parkRot,
out parkOffset)) {
return false;
}

// in vanilla parkOffset is always >= 0 for RoadSideParkingSpace
if (Options.parkingRestrictionsEnabled && parkOffset >= 0) {
if (Singleton<NetManager>.instance.m_segments.m_buffer[segment].GetClosestLanePosition(
refPos,
NetInfo.LaneType.Parking,
VehicleInfo.VehicleType.Car,
out _,
out _,
out int laneIndex,
out _)) {
NetInfo.Direction direction
= Singleton<NetManager>.instance.m_segments.m_buffer[segment].Info.m_lanes[laneIndex].m_finalDirection;
if (!ParkingRestrictionsManager.Instance.IsParkingAllowed(segment, direction)) {
return false;
}
}
}

return true;
}

public bool GetBuildingInfoViewColor(ushort buildingId,
ref Building buildingData,
ref ExtBuilding extBuilding,
Expand Down
58 changes: 34 additions & 24 deletions TLM/TLM/Manager/Impl/ExtSegmentEndManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,10 @@ public class ExtSegmentEndManager
: AbstractCustomManager,
IExtSegmentEndManager
{
public static ExtSegmentEndManager Instance { get; }

static ExtSegmentEndManager() {
Instance = new ExtSegmentEndManager();
}

/// <summary>
/// All additional data for segment ends
/// </summary>
public ExtSegmentEnd[] ExtSegmentEnds { get; }

private ExtSegmentEndManager() {
ExtSegmentEnds = new ExtSegmentEnd[NetManager.MAX_SEGMENT_COUNT * 2];
for (uint i = 0; i < NetManager.MAX_SEGMENT_COUNT; ++i) {
Expand All @@ -31,6 +24,13 @@ public class ExtSegmentEndManager
}
}

public static ExtSegmentEndManager Instance { get; }

/// <summary>
/// All additional data for segment ends
/// </summary>
public ExtSegmentEnd[] ExtSegmentEnds { get; }

#if DEBUG
public string GenerateVehicleChainDebugInfo(ushort segmentId, bool startNode) {
int index = GetIndex(segmentId, startNode);
Expand Down Expand Up @@ -298,23 +298,33 @@ public class ExtSegmentEndManager
public void CalculateCorners(ushort segmentId, bool startNode) {
if (!Shortcuts.netService.IsSegmentValid(segmentId))
return;
ref ExtSegmentEnd segEnd = ref ExtSegmentEnds[GetIndex(segmentId, startNode)];
segmentId.ToSegment().CalculateCorner(
segmentID: segmentId,
heightOffset: true,
start: startNode,
leftSide: false,
cornerPos: out segEnd.RightCorner,
cornerDirection: out segEnd.RightCornerDir,
smooth: out _);
segmentId.ToSegment().CalculateCorner(
segmentID: segmentId,
heightOffset: true,
start: startNode,
leftSide: true,
cornerPos: out segEnd.LeftCorner,
cornerDirection: out segEnd.LeftCornerDir,
smooth: out _);
if (!segmentId.ToSegment().Info) {
Log.Warning($"segment {segmentId} has null info");
return;
}

try {
ref ExtSegmentEnd segEnd = ref ExtSegmentEnds[GetIndex(segmentId, startNode)];
segmentId.ToSegment().CalculateCorner(
segmentID: segmentId,
heightOffset: true,
start: startNode,
leftSide: false,
cornerPos: out segEnd.RightCorner,
cornerDirection: out segEnd.RightCornerDir,
smooth: out _);
segmentId.ToSegment().CalculateCorner(
segmentID: segmentId,
heightOffset: true,
start: startNode,
leftSide: true,
cornerPos: out segEnd.LeftCorner,
cornerDirection: out segEnd.LeftCornerDir,
smooth: out _);
} catch (Exception e) {
Log.Error($"failed calculating corner for segment:{segmentId}, info={segmentId.ToSegment().Info}\n"
+ e.Message);
}
}

private void CalculateIncomingOutgoing(ushort segmentId,
Expand Down
14 changes: 7 additions & 7 deletions TLM/TLM/Manager/Impl/VehicleBehaviorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,16 @@ bool citizenDebug
}

if (!searchedParkingSpace) {
bool isElectric = vehicleInfo.m_class.m_subService != ItemClass.SubService.ResidentialLow;
foundParkingSpace =
Constants.ManagerFactory.AdvancedParkingManager.FindParkingSpaceInVicinity(
Constants.ManagerFactory.AdvancedParkingManager.VanillaFindParkingSpaceWithoutRestrictions(
isElectric,
homeID,
refPos,
searchDir,
vehicleInfo,
homeID,
vehicleID,
GlobalConfig.Instance.ParkingAI.MaxBuildingToPedestrianLaneDistance,
out ExtParkingSpaceLocation parkLoc,
out ushort parkId,
pathPos.m_segment,
vehicleInfo.m_generatedInfo.m_size.x,
vehicleInfo.m_generatedInfo.m_size.z,
out parkPos,
out parkRot,
out parkOffset);
Expand Down
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/Clear-fg-disabled.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/Clear-fg-normal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/HighPriority_LHT-fg-normal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/HighPriority_RHT-fg-normal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/RoundButton-bg-active.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/RoundButton-bg-disabled.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/RoundButton-bg-hovered.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/RoundButton-bg-normal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/Roundabout_LHT-fg-disabled.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/Roundabout_LHT-fg-normal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/Roundabout_RHT-fg-disabled.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/Roundabout_RHT-fg-normal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/Stop_LHT-fg-disabled.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/Stop_LHT-fg-normal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/Stop_RHT-fg-disabled.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/Stop_RHT-fg-normal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/Yield_LHT-fg-disabled.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/Yield_LHT-fg-normal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/Yield_RHT-fg-disabled.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TLM/TLM/Resources/RoadSelectionPanel/Yield_RHT-fg-normal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions TLM/TLM/State/GlobalConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class GlobalConfig : GenericObservable<GlobalConfig> {
get => instance;
private set {
if (value != null && instance != null) {
value.Observers = instance.Observers;
value.ObserverLock = instance.ObserverLock;
value._observers = instance._observers;
value._lock = instance._lock;
}

instance = value;
Expand Down
8 changes: 6 additions & 2 deletions TLM/TLM/UI/SubTools/JunctionRestrictionsTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ public JunctionRestrictionsTool(TrafficManagerTool mainTool)
}

public override void OnSecondaryClickOverlay() {
SelectedNodeId = 0;
MainTool.RequestOnscreenDisplayUpdate();
if (SelectedNodeId != 0) {
SelectedNodeId = 0;
MainTool.RequestOnscreenDisplayUpdate();
} else {
MainTool.SetToolMode(ToolMode.None);
}
}

public override void OnActivate() {
Expand Down
32 changes: 25 additions & 7 deletions TLM/TLM/UI/SubTools/LaneConnectorTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ public LaneConnectorTool(TrafficManagerTool mainTool)
/// </summary>
/// <param name="nodeId"></param>
/// <param name="mode">determines for which side to connect lanes.</param>
/// <returns><c>false</c> if there is only one incomming/outgoing lane, <c>true</c> otherwise</returns>
/// <returns><c>true</c> if any lanes were connectde, <c>false</c> otherwise</returns>
public static bool StayInLane(ushort nodeId, StayInLaneMode mode = StayInLaneMode.None) {
Log._Debug($"Stay In Lane called node:{nodeId} mode:{mode}");
LaneConnectionManager.Instance.RemoveLaneConnectionsFromNode(nodeId);
Expand Down Expand Up @@ -629,12 +629,12 @@ public LaneConnectorTool(TrafficManagerTool mainTool)

// count relavent source(going toward the junction) lanes and
// target (going aginst the junction) lanes on each segment.
int laneCountMinorSource = minorSegmentId == 0 ? 0 : PriorityRoad.CountLanesTowardJunction(minorSegmentId, nodeId);
int laneCountMinorTarget = minorSegmentId == 0 ? 0 : PriorityRoad.CountLanesAgainstJunction(minorSegmentId, nodeId);
int laneCountMinor2Source = minorSegment2Id == 0 ? 0 : PriorityRoad.CountLanesTowardJunction(minorSegment2Id, nodeId);
int laneCountMinor2Target = minorSegment2Id == 0 ? 0 : PriorityRoad.CountLanesAgainstJunction(minorSegment2Id, nodeId);
int laneCountMainSource = PriorityRoad.CountLanesTowardJunction(mainSegmentSourceId, nodeId);
int laneCountMainTarget = PriorityRoad.CountLanesAgainstJunction(mainSegmentTargetId, nodeId);
int laneCountMinorSource = minorSegmentId == 0 ? 0 : CountLanesTowardJunction(minorSegmentId, nodeId);
int laneCountMinorTarget = minorSegmentId == 0 ? 0 : CountLanesAgainstJunction(minorSegmentId, nodeId);
int laneCountMinor2Source = minorSegment2Id == 0 ? 0 : CountLanesTowardJunction(minorSegment2Id, nodeId);
int laneCountMinor2Target = minorSegment2Id == 0 ? 0 : CountLanesAgainstJunction(minorSegment2Id, nodeId);
int laneCountMainSource = CountLanesTowardJunction(mainSegmentSourceId, nodeId);
int laneCountMainTarget = CountLanesAgainstJunction(mainSegmentTargetId, nodeId);
int totalSource = laneCountMinorSource + laneCountMainSource + laneCountMinor2Source;
int totalTarget = laneCountMinorTarget + laneCountMainTarget + laneCountMinor2Target;

Expand Down Expand Up @@ -779,6 +779,20 @@ public LaneConnectorTool(TrafficManagerTool mainTool)
return true;
}

private static int CountLanes(ushort segmentId, ushort nodeId, bool toward) {
return netService.GetSortedLanes(
segmentId,
ref segmentId.ToSegment(),
netService.IsStartNode(segmentId, nodeId) ^ (!toward),
LaneConnectionManager.LANE_TYPES,
LaneConnectionManager.VEHICLE_TYPES,
true
).Count;
}
internal static int CountLanesTowardJunction(ushort segmentId, ushort nodeId) => CountLanes(segmentId, nodeId, true);
internal static int CountLanesAgainstJunction(ushort segmentId, ushort nodeId) => CountLanes(segmentId, nodeId, false);


public override void OnPrimaryClickOverlay() {
#if DEBUG
bool logLaneConn = DebugSwitch.LaneConnections.Get();
Expand Down Expand Up @@ -952,6 +966,10 @@ public LaneConnectorTool(TrafficManagerTool mainTool)
break;
}
}

if (GetSelectionMode() == SelectionMode.None) {
MainTool.SetToolMode(ToolMode.None);
}
}

public override void OnActivate() {
Expand Down
10 changes: 7 additions & 3 deletions TLM/TLM/UI/SubTools/ManualTrafficLightsTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ public ManualTrafficLightsTool(TrafficManagerTool mainTool)
return;
}

Cleanup();
SelectedNodeId = 0;
MainTool.RequestOnscreenDisplayUpdate();
if (SelectedNodeId != 0) {
Cleanup();
SelectedNodeId = 0;
MainTool.RequestOnscreenDisplayUpdate();
} else {
MainTool.SetToolMode(ToolMode.None);
}
}

public override void OnPrimaryClickOverlay() {
Expand Down
4 changes: 4 additions & 0 deletions TLM/TLM/UI/SubTools/ParkingRestrictionsTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public ParkingRestrictionsTool(TrafficManagerTool mainTool)

public override void OnPrimaryClickOverlay() { }

public override void OnSecondaryClickOverlay() {
MainTool.SetToolMode(ToolMode.None);
}

private void RenderSegmentParkings(RenderManager.CameraInfo cameraInfo) {
bool allowed = parkingManager.IsParkingAllowed(renderInfo_.SegmentId, renderInfo_.FinalDirection);
bool pressed = Input.GetMouseButton(0);
Expand Down
8 changes: 6 additions & 2 deletions TLM/TLM/UI/SubTools/PrioritySigns/PrioritySignsTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public PrioritySignsTool(TrafficManagerTool mainTool)
if (!isRoundabout) {
record_ = PriorityRoad.FixRoad(HoveredSegmentId);
}
// TODO: benchmark why bulk setup takes a long time.
// TODO: benchmark why bulk setup takes a long time.
Log.Info("After FixRoundabout/FixRoad. Before RefreshMassEditOverlay"); // log time for benchmarking.
RefreshMassEditOverlay();
Log.Info("After RefreshMassEditOverlay."); // log time for benchmarking.
Expand Down Expand Up @@ -125,14 +125,18 @@ public PrioritySignsTool(TrafficManagerTool mainTool)
massEditMode = PrioritySignsMassEditMode.Min;
}
}

// refresh cache
if(ControlIsPressed)
RefreshMassEditOverlay();
else
RefreshCurrentPriorityNodeIds();
}

public override void OnSecondaryClickOverlay() {
MainTool.SetToolMode(ToolMode.None);
}

public override void OnToolGUI(Event e) { }

/// <summary>
Expand Down

0 comments on commit e8675d4

Please sign in to comment.