Skip to content

Commit 35e1992

Browse files
committed
TMPE version 1.8.12:
- Updated for game version 1.6.2-f1 - Bugfix: After leaving the "Manual traffic lights" mode traffic light simulation is not cleaned up correctly (thanks to @ diezelunderwood for reporting this issue) - Bugfix: Insufficient access rights to log file causes the mod to crash
1 parent 42b9d00 commit 35e1992

File tree

6 files changed

+59
-9
lines changed

6 files changed

+59
-9
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ A work-in-progress modification for **Cities: Skylines** to add additional traff
44
User manual: http://www.viathinksoft.de/tmpe
55

66
# Changelog
7+
1.8.12, 01/02/2017
8+
- Updated for game version 1.6.2-f1
9+
- Bugfix: After leaving the "Manual traffic lights" mode traffic light simulation is not cleaned up correctly (thanks to @ diezelunderwood for reporting this issue)
10+
- Bugfix: Insufficient access rights to log file causes the mod to crash
11+
712
1.8.11, 01/02/2017
813
- Bugfix: Speed limits for elevated/underground road segments are sometimes not correctly loaded (thanks to @Pirazel and @[P.A.N] Uf0 for reporting this issue)
914

TLM/TLM/Log.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,24 @@ private enum LogLevel {
2222
private static string logFilename = Path.Combine(Application.dataPath, "TMPE.log");
2323
private static Stopwatch sw = Stopwatch.StartNew();
2424
private static bool logToConsole = false;
25+
private static bool logFileAccessible = true;
2526

2627

2728
static Log() {
28-
File.Delete(logFilename);
29+
try {
30+
if (File.Exists(logFilename))
31+
File.Delete(logFilename);
32+
} catch (Exception) {
33+
logFileAccessible = false;
34+
}
2935
}
3036

3137
[Conditional("DEBUG")]
3238
public static void _Debug(string s) {
39+
if (!logFileAccessible) {
40+
return;
41+
}
42+
3343
try {
3444
Monitor.Enter(logLock);
3545
if (logToConsole)
@@ -43,6 +53,10 @@ public static void _Debug(string s) {
4353
}
4454

4555
public static void Info(string s) {
56+
if (!logFileAccessible) {
57+
return;
58+
}
59+
4660
try {
4761
#if DEBUG
4862
if (logToConsole)
@@ -58,6 +72,10 @@ public static void Info(string s) {
5872
}
5973

6074
public static void Error(string s) {
75+
if (!logFileAccessible) {
76+
return;
77+
}
78+
6179
try {
6280
#if DEBUG
6381
if (logToConsole)
@@ -73,6 +91,10 @@ public static void Error(string s) {
7391
}
7492

7593
public static void Warning(string s) {
94+
if (!logFileAccessible) {
95+
return;
96+
}
97+
7698
try {
7799
#if DEBUG
78100
if (logToConsole)
@@ -88,6 +110,10 @@ public static void Warning(string s) {
88110
}
89111

90112
private static void LogToFile(string log, LogLevel level) {
113+
if (! logFileAccessible) {
114+
return;
115+
}
116+
91117
try {
92118
using (StreamWriter w = File.AppendText(logFilename)) {
93119
w.WriteLine($"[{level.ToString()}] @ {sw.ElapsedTicks} {log}");
@@ -96,7 +122,9 @@ private static void LogToFile(string log, LogLevel level) {
96122
w.WriteLine();
97123
}
98124
}
99-
} catch (Exception) { }
125+
} catch (Exception) {
126+
logFileAccessible = false;
127+
}
100128
}
101129
}
102130

TLM/TLM/TrafficLight/TrafficLightSimulation.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ public void SetupManualTrafficLight() {
4343
manualTrafficLights = true;
4444
}
4545

46-
public void DestroyManualTrafficLight() {
46+
internal void DestroyManualTrafficLight() {
4747
if (IsTimedLight())
4848
return;
49+
if (!IsManualLight())
50+
return;
4951
manualTrafficLights = false;
52+
53+
TrafficPriorityManager.Instance.RemovePrioritySegments(NodeId);
5054
}
5155

5256
public void SetupTimedTrafficLight(List<ushort> nodeGroup) {
@@ -56,14 +60,18 @@ public void SetupTimedTrafficLight(List<ushort> nodeGroup) {
5660
TimedLight = new TimedTrafficLights(NodeId, nodeGroup);
5761
}
5862

59-
public void DestroyTimedTrafficLight() {
63+
internal void DestroyTimedTrafficLight() {
64+
if (!IsTimedLight())
65+
return;
6066
var timedLight = TimedLight;
6167
TimedLight = null;
6268

6369
if (timedLight != null) {
6470
timedLight.Destroy();
6571
}
6672

73+
TrafficPriorityManager.Instance.RemovePrioritySegments(NodeId);
74+
6775
/*if (!IsManualLight() && timedLight != null)
6876
timedLight.Destroy();*/
6977
}

TLM/TLM/TrafficManagerMod.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
namespace TrafficManager {
66
public class TrafficManagerMod : IUserMod {
77

8-
public static readonly string Version = "1.8.11";
8+
public static readonly string Version = "1.8.12";
99

10-
public static readonly uint GameVersion = 159638032u;
10+
public static readonly uint GameVersion = 159768848u;
1111
public static readonly uint GameVersionA = 1u;
1212
public static readonly uint GameVersionB = 6u;
13-
public static readonly uint GameVersionC = 1u;
14-
public static readonly uint GameVersionBuild = 2u;
13+
public static readonly uint GameVersionC = 2u;
14+
public static readonly uint GameVersionBuild = 1u;
1515

1616
public string Name => "Traffic Manager: President Edition";
1717

TLM/TLM/UI/SubTools/ManualTrafficLightsTool.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,6 @@ public override void Cleanup() {
693693

694694
if (nodeSimulation == null || !nodeSimulation.IsManualLight()) return;
695695

696-
nodeSimulation.DestroyManualTrafficLight();
697696
tlsMan.RemoveNodeFromSimulation(SelectedNodeId, true, false);
698697
}
699698
}

TLM/TLM/UI/TrafficManagerTool.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,18 @@ public static void SetToolMode(ToolMode mode) {
127127

128128
bool toolModeChanged = (mode != _toolMode);
129129
var oldToolMode = _toolMode;
130+
var oldSubTool = subTools[(int)oldToolMode];
130131
_toolMode = mode;
131132
activeSubTool = subTools[(int)_toolMode];
133+
134+
if (oldSubTool != null) {
135+
if ((oldToolMode == ToolMode.TimedLightsSelectNode || oldToolMode == ToolMode.TimedLightsShowLights || oldToolMode == ToolMode.TimedLightsAddNode || oldToolMode == ToolMode.TimedLightsRemoveNode)) { // TODO refactor to SubToolMode
136+
if (mode != ToolMode.TimedLightsSelectNode && mode != ToolMode.TimedLightsShowLights && mode != ToolMode.TimedLightsAddNode && mode != ToolMode.TimedLightsRemoveNode)
137+
oldSubTool.Cleanup();
138+
} else
139+
oldSubTool.Cleanup();
140+
}
141+
132142
if (toolModeChanged && activeSubTool != null) {
133143
if ((oldToolMode == ToolMode.TimedLightsSelectNode || oldToolMode == ToolMode.TimedLightsShowLights || oldToolMode == ToolMode.TimedLightsAddNode || oldToolMode == ToolMode.TimedLightsRemoveNode)) { // TODO refactor to SubToolMode
134144
if (mode != ToolMode.TimedLightsSelectNode && mode != ToolMode.TimedLightsShowLights && mode != ToolMode.TimedLightsAddNode && mode != ToolMode.TimedLightsRemoveNode)

0 commit comments

Comments
 (0)