Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master to testing #1088

Merged
merged 46 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c489626
Add Schinese icon
TianQiBuTian Aug 30, 2020
57b3a44
- no need to allocate a new List each time if we can work with locks …
DaEgi01 May 25, 2020
d0633b4
fixed stay-in-lane for MOM tracks.
kianzarrin Jun 2, 2020
c052823
Updated icons for RoadSelectionPanel to optimized 8bit as the previou…
chameleon-tbn Jul 30, 2020
eb34bdd
Bugfix floating vehicles if ParkingAI disabled
krzychu124 Aug 14, 2020
37c5d02
Apply Shift+Click speed limit to entire roundabout (#920)
krzychu124 Nov 14, 2020
2278e4c
Right-click close main menu if no tool selected, right-click exit too…
krzychu124 Nov 14, 2020
2914bdc
Version bump
krzychu124 Nov 14, 2020
e8675d4
Merge pull request #1033 from CitiesSkylinesMods/11.5-plus-cherry-picks
krzychu124 Nov 19, 2020
5875d42
Fix - RMB lane connector - to select node
krzychu124 Nov 20, 2020
b684109
Merge branch 'master' into schinese-icon
TianQiBuTian Nov 21, 2020
a3cd8fa
Merge pull request #1037 from CitiesSkylinesMods/fix/rmb-lane-connect…
krzychu124 Nov 21, 2020
24f741c
Fixed SA1410 warnings by replacing the delegates with lambdas.
DaEgi01 Apr 7, 2021
f064a2c
Fixed "SA1137 Elements should have the same indentation" warnings.
DaEgi01 Apr 7, 2021
4e85745
Fixed "SA1137 Elements should have the same indentation" warning.
DaEgi01 Apr 7, 2021
514a644
Fixed all instances of delegate instance allocation (HAA0603) where i…
DaEgi01 Apr 8, 2021
ebe29ea
cleaning up life cycle code (#1068)
kianzarrin Apr 8, 2021
1bcbc71
Merge branch 'master' into Warning_SA1410
DaEgi01 Apr 8, 2021
d461fa2
Merge branch 'master' into Warning_SA1137
DaEgi01 Apr 8, 2021
515b40e
Merge branch 'master' into Warning_HAA0603_GUILayoutWindow
DaEgi01 Apr 8, 2021
1678f64
Merge pull request #1069 from CitiesSkylinesMods/Warning_SA1410
DaEgi01 Apr 8, 2021
8fee629
Merge branch 'master' into Warning_SA1137
DaEgi01 Apr 8, 2021
fd8f2d6
Merge pull request #1070 from CitiesSkylinesMods/Warning_SA1137
DaEgi01 Apr 8, 2021
2670f8c
Merge branch 'master' into Warning_HAA0603_GUILayoutWindow
DaEgi01 Apr 8, 2021
89898f2
Merge pull request #1071 from CitiesSkylinesMods/Warning_HAA0603_GUIL…
DaEgi01 Apr 8, 2021
6180d23
Merge tag '11.5.1-hotfix1' into release_merge_ours
DaEgi01 Apr 8, 2021
cf220a9
Merge pull request #1073 from CitiesSkylinesMods/release_merge_ours
DaEgi01 Apr 9, 2021
443acad
Main Camera cache reinitialization to prevent use of inactive camera
krzychu124 Apr 11, 2021
2c541a3
Hide overlays if no longer necessary
krzychu124 Apr 11, 2021
a8bc6e2
Merge pull request #1080 from CitiesSkylinesMods/1065-overlay-rendere…
krzychu124 Apr 11, 2021
a908bec
Merge branch 'master' into 1078-camera-cache-fix
krzychu124 Apr 11, 2021
319e882
Merge pull request #1079 from CitiesSkylinesMods/1078-camera-cache-fix
krzychu124 Apr 11, 2021
57c0e92
730 cleanup loading custom path manager (#1072)
kianzarrin Apr 12, 2021
f4d55ae
harmon patcher continues on error (#1076)
kianzarrin Apr 12, 2021
6b0b6cc
lifecycle class (#1077)
kianzarrin Apr 12, 2021
92d6a6a
Merge branch 'master' into schinese-icon
DaEgi01 Apr 12, 2021
01ac7bf
fixed merge bug.
DaEgi01 Apr 12, 2021
290e8ae
Converted .ruleset to .editorconfig
DaEgi01 Apr 12, 2021
ea0f419
Merge pull request #1082 from CitiesSkylinesMods/ruleset_to_editorconfig
DaEgi01 Apr 13, 2021
f961808
Merge branch 'master' into schinese-icon
DaEgi01 Apr 13, 2021
70767bf
Removed warnings
DaEgi01 Apr 13, 2021
738e9f2
Merge pull request #1081 from CitiesSkylinesMods/schinese-icon
DaEgi01 Apr 13, 2021
4cc466b
Merge branch 'master' into doc_warning_removal
DaEgi01 Apr 13, 2021
baad59a
Merge pull request #1083 from CitiesSkylinesMods/doc_warning_removal
DaEgi01 Apr 13, 2021
cac1b15
Merge branch 'testing' of https://github.com/krzychu124/Cities-Skylin…
krzychu124 Apr 13, 2021
a226e16
Removed invalid references (RedirectionFramework deleted after migrat…
krzychu124 Apr 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions TLM/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,47 @@ max_line_length=100
insert_final_newline=true
trim_trailing_whitespace=true
indent_style=space
dotnet_diagnostic.RAS0001.severity = error
dotnet_diagnostic.SA1000.severity = none
dotnet_diagnostic.SA1005.severity = none
dotnet_diagnostic.SA1027.severity = none
dotnet_diagnostic.SA1028.severity = none
dotnet_diagnostic.SA1100.severity = none
dotnet_diagnostic.SA1101.severity = none
dotnet_diagnostic.SA1107.severity = none
dotnet_diagnostic.SA1115.severity = none
dotnet_diagnostic.SA1116.severity = none
dotnet_diagnostic.SA1118.severity = none
dotnet_diagnostic.SA1200.severity = none
dotnet_diagnostic.SA1208.severity = none
dotnet_diagnostic.SA1210.severity = none
dotnet_diagnostic.SA1211.severity = none
dotnet_diagnostic.SA1216.severity = none
dotnet_diagnostic.SA1217.severity = none
dotnet_diagnostic.SA1308.severity = suggestion
dotnet_diagnostic.SA1309.severity = silent
dotnet_diagnostic.SA1310.severity = none
dotnet_diagnostic.SA1500.severity = none
dotnet_diagnostic.SA1503.severity = suggestion
dotnet_diagnostic.SA1505.severity = silent
dotnet_diagnostic.SA1512.severity = none
dotnet_diagnostic.SA1513.severity = none
dotnet_diagnostic.SA1515.severity = none
dotnet_diagnostic.SA1516.severity = silent
dotnet_diagnostic.SA1600.severity = none
dotnet_diagnostic.SA1602.severity = none
dotnet_diagnostic.SA1611.severity = none
dotnet_diagnostic.SA1615.severity = none
dotnet_diagnostic.SA1623.severity = none
dotnet_diagnostic.SA1629.severity = none
dotnet_diagnostic.SA1633.severity = none
dotnet_diagnostic.SA1634.severity = none
dotnet_diagnostic.SA1635.severity = none
dotnet_diagnostic.SA1636.severity = none
dotnet_diagnostic.SA1637.severity = none
dotnet_diagnostic.SA1638.severity = none
dotnet_diagnostic.SA1640.severity = none
dotnet_diagnostic.SA1652.severity = none

[*]
charset=utf-8
Expand Down
2 changes: 1 addition & 1 deletion TLM/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion TLM/CSUtil.CameraControl
2 changes: 1 addition & 1 deletion TLM/CSUtil.Commons/CSUtil.Commons.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\TMPE.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion TLM/OptionsFramework
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.3.*")]
[assembly: AssemblyVersion("11.5.4.*")]
2 changes: 1 addition & 1 deletion TLM/TLM/Custom/PathFinding/CustomPathFind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace TrafficManager.Custom.PathFinding {
#endif

/// <summary>
/// This replaces game PathFind class if PF_DIJKSTRA is defined
/// This replaces game PathFind class
/// This is ALL targets except Benchmark
/// </summary>
public class CustomPathFind : PathFind {
Expand Down
149 changes: 107 additions & 42 deletions TLM/TLM/Custom/PathFinding/CustomPathManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ namespace TrafficManager.Custom.PathFinding {
using System;
using API.Traffic.Enums;
using TrafficManager.API.Traffic.Data;
#if !PF_DIJKSTRA
using CustomPathFind = CustomPathFind_Old;
#endif
using TrafficManager.Manager.Impl;
using TrafficManager.State;
using UnityEngine;
using ColossalFramework.UI;

public class CustomPathManager : PathManager {
/// <summary>
Expand All @@ -24,20 +25,58 @@ public class CustomPathManager : PathManager {

public static CustomPathManager _instance;

private PathManager stockPathManager_;

private static FastList<ISimulationManager> GetSimulationManagers() =>
typeof(SimulationManager)
.GetField("m_managers", BindingFlags.Static | BindingFlags.NonPublic)
?.GetValue(null)
as FastList<ISimulationManager>
?? throw new Exception("could not get SimulationManager.m_managers");

private static FieldInfo PathManagerInstance =>
typeof(Singleton<PathManager>)
.GetField(
"sInstance",
BindingFlags.Static | BindingFlags.NonPublic) ??
throw new Exception("pathManagerInstance is null");

#if QUEUEDSTATS
public static uint TotalQueuedPathFinds {
get; private set;
}
public static uint TotalQueuedPathFinds { get; private set; }
#endif

public static bool InitDone {
get; private set;
public static void OnLevelLoaded() {
try {
Log.Info("CustomPathManager.OnLevelLoaded() called.");
PathManager.instance.gameObject.AddComponent<CustomPathManager>();
} catch (Exception ex) {
string error =
"Traffic Manager: President Edition failed to load. You can continue " +
"playing but it's NOT recommended. Traffic Manager will not work as expected.";
Log.Error(error);
Log.Error($"Path manager replacement error: {ex}");
UIView.library.ShowModal<ExceptionPanel>("ExceptionPanel")
.SetMessage("TM:PE failed to load", error, true);
}
}

// On waking up, replace the stock pathfinders with the custom one
[UsedImplicitly]
public new virtual void Awake() {
protected override void Awake() {
// On waking up, replace the stock pathfinders with the custom one
// but retain the original version for future replace
// also suppress call to base class.
_instance = this;
stockPathManager_ = PathManager.instance
?? throw new Exception("stockPathManager is null");
Log._Debug($"Got stock PathManager instance {stockPathManager_?.GetName()}");
PathManagerInstance.SetValue(null, this);
Log._Debug("Should be custom: " + PathManager.instance.GetType());

UpdateWithPathManagerValues(stockPathManager_);

var simManagers = GetSimulationManagers();
simManagers.Remove(stockPathManager_);
simManagers.Add(this);
}

public void UpdateWithPathManagerValues(PathManager stockPathManager) {
Expand All @@ -51,8 +90,6 @@ public void UpdateWithPathManagerValues(PathManager stockPathManager) {
m_pathUnits = stockPathManager.m_pathUnits;
m_bufferLock = stockPathManager.m_bufferLock;

Log._Debug("Waking up CustomPathManager.");

QueueItems = new PathUnitQueueItem[MAX_PATHUNIT_COUNT];

PathFind[] stockPathFinds = GetComponents<PathFind>();
Expand All @@ -61,26 +98,18 @@ public void UpdateWithPathManagerValues(PathManager stockPathManager) {

Log._Debug("Creating " + numCustomPathFinds + " custom PathFind objects.");
_replacementPathFinds = new CustomPathFind[numCustomPathFinds];
FieldInfo f_pathfinds = typeof(PathManager).GetField(
"m_pathfinds",
BindingFlags.NonPublic | BindingFlags.Instance)
?? throw new Exception("f_pathFinds is null");

lock(m_bufferLock) {
lock (m_bufferLock) {

for (int i = 0; i < numCustomPathFinds; i++) {
_replacementPathFinds[i] = gameObject.AddComponent<CustomPathFind>();
#if !PF_DIJKSTRA
_replacementPathFinds[i].pfId = i;
if (i == 0) {
_replacementPathFinds[i].IsMasterPathFind = true;
}
#endif
}

Log._Debug("Setting _replacementPathFinds");
FieldInfo fieldInfo = typeof(PathManager).GetField(
"m_pathfinds",
BindingFlags.NonPublic | BindingFlags.Instance);

Log._Debug("Setting m_pathfinds to custom collection");
fieldInfo?.SetValue(this, _replacementPathFinds);
f_pathfinds?.SetValue(this, _replacementPathFinds);

for (int i = 0; i < numOfStockPathFinds; i++) {
Log._Debug($"PF {i}: {stockPathFinds[i].m_queuedPathFindCount} queued path-finds");
Expand All @@ -90,8 +119,39 @@ public void UpdateWithPathManagerValues(PathManager stockPathManager) {
Destroy(stockPathFinds[i]);
}
}
}

public void UpdateOldPathManagerValues(PathManager stockPathManager) {
stockPathManager.m_drawCallData = m_drawCallData;
stockPathManager.m_pathUnitCount = m_pathUnitCount;
stockPathManager.m_renderPathGizmo = m_renderPathGizmo;

int n = _replacementPathFinds.Length;

Log._Debug("Creating " + n + " stock PathFind objects.");
PathFind[] stockPathFinds = new PathFind[n];

InitDone = true;
FieldInfo f_pathfinds = typeof(PathManager).GetField(
"m_pathfinds",
BindingFlags.NonPublic | BindingFlags.Instance)
?? throw new Exception("f_pathFinds is null");

// both stcok and custom PathMangers use the same lock object
lock (m_bufferLock) {
for (int i = 0; i < n; i++) {
Log._Debug($"PF {i}: {_replacementPathFinds[i].m_queuedPathFindCount} queued path-finds");

// would cause deadlock since we have a lock on m_bufferLock
// customPathFinds[i].WaitForAllPaths();
Destroy(_replacementPathFinds[i]);
}

for (int i = 0; i < n; i++) {
stockPathFinds[i] = gameObject.AddComponent<PathFind>();
}

f_pathfinds?.SetValue(stockPathManager, stockPathFinds);
}
}

/// <summary>
Expand All @@ -110,7 +170,7 @@ internal void CustomReleasePath(uint unit) {
if (m_pathUnits.m_buffer[unit].m_simulationFlags == 0) {
return;
}
lock(m_bufferLock) {
lock (m_bufferLock) {

int numIters = 0;
while (unit != 0u) {
Expand Down Expand Up @@ -147,7 +207,7 @@ public bool CustomCreatePath(out uint unit,
ref Randomizer randomizer,
PathCreationArgs args) {
uint pathUnitId;
lock(m_bufferLock) {
lock (m_bufferLock) {

int numIters = 0;
while (true) {
Expand Down Expand Up @@ -249,18 +309,12 @@ public bool CustomCreatePath(out uint unit,
pathFind = pathFindCandidate;
}

#if PF_DIJKSTRA
if (pathFind != null && pathFind.CalculatePath(unit, args.skipQueue)) {
return true;
}
#else
if (pathFind != null && pathFind.ExtCalculatePath(unit, args.skipQueue)) {
return true;
}
#endif

// NON-STOCK CODE START
lock(m_bufferLock) {
lock (m_bufferLock) {

QueueItems[pathUnitId].queued = false;
// NON-STOCK CODE END
Expand Down Expand Up @@ -379,15 +433,26 @@ private static ExtVehicleType ConvertToExtVehicleType(VehicleInfo.VehicleType ve
return extVehicleType;
}

private void StopPathFinds() {
foreach (CustomPathFind pathFind in _replacementPathFinds) {
Destroy(pathFind);
}
public void OnLevelUnloading() {
Log.Info("CustomPathManager.OnLevelUnloading()");
DestroyImmediate(this);
}

protected virtual void OnDestroy() {
Log._Debug("CustomPathManager: OnDestroy");
StopPathFinds();
WaitForAllPaths();

PathManagerInstance.SetValue(null, stockPathManager_);
Log._Debug("Should be stock: " + PathManager.instance.GetType());

UpdateOldPathManagerValues(stockPathManager_);
var simManagers = GetSimulationManagers();

simManagers.Remove(this);

simManagers.Add(stockPathManager_);

_instance = null;
}
}
}
}
14 changes: 14 additions & 0 deletions TLM/TLM/Lifecycle/LoadingExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace TrafficManager.Lifecycle {
using ColossalFramework;
using CSUtil.Commons;
using ICities;
using JetBrains.Annotations;
using System.Collections.Generic;
using System.Reflection;

[UsedImplicitly]
public class LoadingExtension : LoadingExtensionBase {
public override void OnLevelLoaded(LoadMode mode) => TMPELifecycle.Instance.Load();
public override void OnLevelUnloading() => TMPELifecycle.Instance.Unload();
}
}
Loading