Skip to content

Commit

Permalink
TMPE version 1.8.10:
Browse files Browse the repository at this point in the history
- Improved path-finding performance (a bit)
- Added a check for invalid road thumbnails in the "custom default speed limits" dialog
  • Loading branch information
VictorPhilipp committed Dec 31, 2016
1 parent 7fd4bb6 commit eedec28
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 12 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ A work-in-progress modification for **Cities: Skylines** to add additional traff
User manual: http://www.viathinksoft.de/tmpe

# Changelog
1.8.10, 12/31/2016
- Improved path-finding performance (a bit)
- Added a check for invalid road thumbnails in the "custom default speed limits" dialog

1.8.9, 12/29/2016
- It is now possible to set speed limits for metro tracks
- Custom default speed limits may now be defined for train and metro tracks
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 @@ -2912,7 +2912,7 @@ private void ProcessItemPedBicycle(BufferItem item, ushort targetNodeId, ushort
return;

// check if pedestrian light won't change to green
CustomSegmentLights lights = customTrafficLightsManager.GetSegmentLights(nextSegmentId, nextIsStartNode);
CustomSegmentLights lights = customTrafficLightsManager.GetSegmentLights(nextSegmentId, nextIsStartNode, false);
if (lights != null) {
if (lights.InvalidPedestrianLight) {
return;
Expand Down
2 changes: 2 additions & 0 deletions TLM/TLM/Manager/CustomSegmentLightsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ public CustomSegmentLights GetSegmentLights(ushort segmentId, bool startNode, bo

public CustomSegmentLights GetSegmentLights(ushort nodeId, ushort segmentId) {
SegmentEndGeometry endGeometry = SegmentGeometry.Get(segmentId).GetEnd(nodeId);
if (endGeometry == null)
return null;
return GetSegmentLights(segmentId, endGeometry.StartNode, false);
}

Expand Down
8 changes: 4 additions & 4 deletions TLM/TLM/Manager/SpeedLimitManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,14 @@ public override void OnBeforeLoadData() {

List<NetInfo> mainNetInfos = new List<NetInfo>();

Log._Debug($"SpeedLimitManager.OnBeforeLoadData: {numLoaded} NetInfos loaded.");
Log.Info($"SpeedLimitManager.OnBeforeLoadData: {numLoaded} NetInfos loaded.");
for (uint i = 0; i < numLoaded; ++i) {
NetInfo info = PrefabCollection<NetInfo>.GetLoaded(i);
//Log._Debug($"Iterating over: {info.name}, {info.m_netAI == null}");
if (/*info.m_placementStyle == ItemClass.Placement.Manual && */info.m_netAI != null && (info.m_netAI is RoadBaseAI || info.m_netAI is MetroTrackAI || info.m_netAI is TrainTrackBaseAI) && (info.m_dlcRequired == 0 || (uint)(info.m_dlcRequired & dlcMask) != 0u)) {
string infoName = info.name;
if (!vanillaLaneSpeedLimitsByNetInfoName.ContainsKey(infoName)) {
Log._Debug($"Loaded road NetInfo: {infoName}");
Log.Info($"Loaded road NetInfo: {infoName}");
NetInfoByName[infoName] = info;
mainNetInfos.Add(info);

Expand Down Expand Up @@ -588,8 +588,8 @@ public override void OnBeforeLoadData() {
for (int y = 0; y < mainNetInfos.Count; ++y) {
NetInfo parentInfo = mainNetInfos[y];

if (!infoName.Equals(parentInfo.name) && infoName.StartsWith(parentInfo.name)) {
Log._Debug($"Identified child NetInfo {infoName} of parent {parentInfo.name}");
if (info.m_placementStyle == ItemClass.Placement.Procedural && !infoName.Equals(parentInfo.name) && infoName.StartsWith(parentInfo.name)) {
Log.Info($"Identified child NetInfo {infoName} of parent {parentInfo.name}");
if (!childNetInfoNamesByCustomizableNetInfoName.ContainsKey(parentInfo.name)) {
childNetInfoNamesByCustomizableNetInfoName[parentInfo.name] = new List<string>();
}
Expand Down
Binary file added TLM/TLM/Resources/noimage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion TLM/TLM/State/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public static bool MenuRebuildRequired {
internal set {
if (value) {
if (LoadingExtension.BaseUI != null) {
LoadingExtension.BaseUI.Close();
LoadingExtension.BaseUI.RebuildMenu();
}
}
Expand Down
3 changes: 3 additions & 0 deletions TLM/TLM/TLM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@
<ItemGroup>
<EmbeddedResource Include="Resources\lang_it.txt" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\noimage.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>mkdir "D:\Games\Steam\steamapps\workshop\content\255710\583429740"
Expand Down
2 changes: 1 addition & 1 deletion TLM/TLM/TrafficManagerMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace TrafficManager {
public class TrafficManagerMod : IUserMod {

public static readonly string Version = "1.8.9";
public static readonly string Version = "1.8.10";

public static readonly uint GameVersion = 159638032u;
public static readonly uint GameVersionA = 1u;
Expand Down
24 changes: 19 additions & 5 deletions TLM/TLM/UI/SubTools/SpeedLimitsTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,26 @@ private void _guiDefaultsWindow(int num) {
}

private void UpdateRoadTex(NetInfo info) {
SpriteInfo spriteInfo = info.m_Atlas[info.m_Thumbnail];
if (info != null) {
if (info.m_Atlas != null && info.m_Atlas.material != null && info.m_Atlas.material.mainTexture != null && info.m_Atlas.material.mainTexture is Texture2D) {
Texture2D mainTex = (Texture2D)info.m_Atlas.material.mainTexture;
SpriteInfo spriteInfo = info.m_Atlas[info.m_Thumbnail];

if (spriteInfo != null && spriteInfo.texture != null && spriteInfo.texture.width > 0 && spriteInfo.texture.height > 0) {
try {
roadTex = new Texture2D((int)spriteInfo.texture.width, (int)spriteInfo.texture.height, TextureFormat.ARGB32, false);
roadTex.SetPixels(0, 0, roadTex.width, roadTex.height, mainTex.GetPixels((int)(spriteInfo.region.x * mainTex.width), (int)(spriteInfo.region.y * mainTex.height), (int)(spriteInfo.region.width * mainTex.width), (int)(spriteInfo.region.height * mainTex.height)));
roadTex.Apply();
return;
} catch (Exception e) {
Log.Warning($"Could not get texture from NetInfo {info.name}: {e.ToString()}");
}
}
}
}

roadTex = new Texture2D((int)spriteInfo.texture.width, (int)spriteInfo.texture.height, TextureFormat.ARGB32, false);
Texture2D mainTex = (Texture2D)info.m_Atlas.material.mainTexture;
roadTex.SetPixels(0, 0, roadTex.width, roadTex.height, mainTex.GetPixels((int)(spriteInfo.region.x * mainTex.width), (int)(spriteInfo.region.y * mainTex.height), (int)(spriteInfo.region.width * mainTex.width), (int)(spriteInfo.region.height * mainTex.height)));
roadTex.Apply();
// fallback to "noimage" texture
roadTex = TrafficLightToolTextureResources.NoImageTexture2D;
}

private void _guiSpeedLimitsWindow(int num) {
Expand Down
4 changes: 4 additions & 0 deletions TLM/TLM/UI/TrafficLightToolTextureResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ public class TrafficLightToolTextureResources
public static readonly Texture2D PedestrianCrossingAllowedTexture2D;
public static readonly Texture2D PedestrianCrossingForbiddenTexture2D;
public static readonly Texture2D MainMenuButtonTexture2D;
public static readonly Texture2D NoImageTexture2D;

static TrafficLightToolTextureResources()
{
// missing image
NoImageTexture2D = LoadDllResource("noimage.png", 64, 64);

// main menu icon
MainMenuButtonTexture2D = LoadDllResource("MenuButton.png", 300, 50);
MainMenuButtonTexture2D.name = "TMPE_MainMenuButtonIcon";
Expand Down
1 change: 1 addition & 0 deletions TLM/TLM/UI/UIBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void ToggleMainMenu() {
}

internal void RebuildMenu() {
Close();
if (menu != null) {
UnityEngine.Object.Destroy(menu);
}
Expand Down

0 comments on commit eedec28

Please sign in to comment.