Skip to content

Commit

Permalink
1.10.9: New path-finding implementation works
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorPhilipp committed Jul 13, 2018
1 parent a940c0a commit 91dca4e
Show file tree
Hide file tree
Showing 7 changed files with 766 additions and 122 deletions.
844 changes: 738 additions & 106 deletions TLM/TLM/Custom/PathFinding/CustomPathFind2.cs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions TLM/TLM/State/ConfigData/Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace TrafficManager.State.ConfigData {
#if DEBUG
public class Debug {
public bool[] Switches = {
false, // 0: path-find debug log
false, // 1: path-find costs debug log
false, // 0: -
false, // 1: -
false, // 2: parking ai debug log (basic)
false, // 3: do not actually repair stuck vehicles/cims, just report
false, // 4: parking ai debug log (extended)
Expand All @@ -19,7 +19,7 @@ public class Debug {
false, // 8: debug routing
false, // 9: debug vehicle to segment end linking
false, // 10: prevent routing recalculation on global configuration reload
false, // 11: disable custom routing
false, // 11: -
false, // 12: pedestrian path-find debug log
false, // 13: priority rules debug
false, // 14: disable GUI overlay of citizens having a valid path
Expand Down
4 changes: 2 additions & 2 deletions TLM/TLM/State/ConfigData/PathFinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public class PathFinding {
/// <summary>
/// Minimum penalty for entering public transport vehicles
/// </summary>
public float PublicTransportTransitionMinPenalty = 250f;
public float PublicTransportTransitionMinPenalty = 0f;

/// <summary>
/// Maximum penalty for entering public transport vehicles
/// </summary>
public float PublicTransportTransitionMaxPenalty = 500f;
public float PublicTransportTransitionMaxPenalty = 100f;
}
}
2 changes: 1 addition & 1 deletion TLM/TLM/State/GlobalConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace TrafficManager.State {
public class GlobalConfig : GenericObservable<GlobalConfig> {
public const string FILENAME = "TMPE_GlobalConfig.xml";
public const string BACKUP_FILENAME = FILENAME + ".bak";
private static int LATEST_VERSION = 14;
private static int LATEST_VERSION = 15;
#if DEBUG
private static uint lastModificationCheckFrame = 0;
#endif
Expand Down
8 changes: 4 additions & 4 deletions TLM/TLM/TLM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;QUEUEDSTATS</DefineConstants>
<DefineConstants>DEBUG;PF2;QUEUEDSTATS;PARKINGAI;SPEEDLIMITS;ROUTING;JUNCTIONRESTRICTIONS;VEHICLERESTRICTIONS;ADVANCEDAI;CUSTOMTRAFFICLIGHTS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>0</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -27,15 +27,15 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>QUEUEDSTATS</DefineConstants>
<DefineConstants>PF2;QUEUEDSTATS;PARKINGAI;SPEEDLIMITS;ROUTING;JUNCTIONRESTRICTIONS;VEHICLERESTRICTIONS;ADVANCEDAI;CUSTOMTRAFFICLIGHTS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'FullDebug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\DebugGeometry\</OutputPath>
<DefineConstants>DEBUG;QUEUEDSTATS;DEBUGGEO;DEBUGVSTATE;DEBUGNEWPF;DEBUGCOSTS;DEBUGCONN2;DEBUGTTL;DEBUGHWJUNCTIONROUTING;DEBUGROUTING;DEBUGHK</DefineConstants>
<DefineConstants>DEBUG;PF2;QUEUEDSTATS;DEBUGGEO;DEBUGVSTATE;DEBUGNEWPF;DEBUGCOSTS;DEBUGCONN2;DEBUGTTL;DEBUGHWJUNCTIONROUTING;DEBUGROUTING;DEBUGHK;PARKINGAI;SPEEDLIMITS;ROUTING;JUNCTIONRESTRICTIONS;VEHICLERESTRICTIONS;ADVANCEDAI;CUSTOMTRAFFICLIGHTS</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<WarningLevel>0</WarningLevel>
<DebugType>full</DebugType>
Expand All @@ -57,7 +57,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'PF2_Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\PF2_Debug\</OutputPath>
<DefineConstants>DEBUG;QUEUEDSTATS;DEBUGGEO;DEBUGVSTATE;DEBUGNEWPF;DEBUGCOSTS;DEBUGCONN2;DEBUGTTL;DEBUGHWJUNCTIONROUTING;DEBUGROUTING;DEBUGHK;PF2;PARKINGAI;SPEEDLIMITS</DefineConstants>
<DefineConstants>DEBUG;QUEUEDSTATS;DEBUGGEO;DEBUGVSTATE;DEBUGNEWPF;DEBUGCOSTS;DEBUGCONN2;DEBUGTTL;DEBUGHWJUNCTIONROUTING;DEBUGROUTING;DEBUGHK;PF2;PARKINGAI;SPEEDLIMITS;ROUTING;JUNCTIONRESTRICTIONS;VEHICLERESTRICTIONS;ADVANCEDAI;CUSTOMTRAFFICLIGHTS</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<WarningLevel>0</WarningLevel>
<DebugType>full</DebugType>
Expand Down
18 changes: 15 additions & 3 deletions TLM/TLM/Traffic/Data/SegmentEndFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,34 @@ public struct SegmentEndFlags {
public TernaryBool pedestrianCrossingAllowed;

private bool defaultEnterWhenBlockedAllowed;
private bool defaultUturnAllowed;
//private bool defaultPedestrianCrossingAllowed;

public void UpdateDefaults(SegmentEndGeometry segmentEndGeometry) {
NodeGeometry nodeGeo = NodeGeometry.Get(segmentEndGeometry.NodeId());

bool newDefaultEnterWhenBlockedAllowed = false;
NetNode.Flags _nodeFlags = NetNode.Flags.None;
bool newDefaultUturnAllowed = false;
//NetNode.Flags _nodeFlags = NetNode.Flags.None;
Constants.ServiceFactory.NetService.ProcessNode(segmentEndGeometry.NodeId(), delegate (ushort nodeId, ref NetNode node) {
_nodeFlags = node.m_flags;
//_nodeFlags = node.m_flags;
int numOutgoing = 0;
int numIncoming = 0;
node.CountLanes(nodeId, 0, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, VehicleInfo.VehicleType.Car, true, ref numOutgoing, ref numIncoming);
newDefaultEnterWhenBlockedAllowed = numOutgoing == 1 || numIncoming == 1;

if (Options.allowUTurns) {
newDefaultUturnAllowed =
(node.m_flags & (NetNode.Flags.Junction | NetNode.Flags.Transition | NetNode.Flags.Bend | NetNode.Flags.End | NetNode.Flags.OneWayOut)) != NetNode.Flags.None &&
node.Info?.m_class?.m_service != ItemClass.Service.Beautification
;
} else {
newDefaultUturnAllowed = (node.m_flags & (NetNode.Flags.End | NetNode.Flags.OneWayOut)) != NetNode.Flags.None;
}
return true;
});
defaultEnterWhenBlockedAllowed = newDefaultEnterWhenBlockedAllowed;
defaultUturnAllowed = newDefaultUturnAllowed;
//Log._Debug($"SegmentEndFlags.UpdateDefaults: this={this} _nodeFlags={_nodeFlags} defaultEnterWhenBlockedAllowed={defaultEnterWhenBlockedAllowed}");
}

Expand All @@ -45,7 +57,7 @@ public bool IsUturnAllowed() {
}

public bool GetDefaultUturnAllowed() {
return Options.allowUTurns;
return defaultUturnAllowed;
}

public bool IsLaneChangingAllowedWhenGoingStraight() {
Expand Down
6 changes: 3 additions & 3 deletions TLM/TLM/TrafficManagerMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
namespace TrafficManager {
public class TrafficManagerMod : IUserMod {

public static readonly string Version = "1.10.9-alpha1";
public static readonly string Version = "1.10.9";

public static readonly uint GameVersion = 176284432u;
public static readonly uint GameVersion = 176415504u;
public static readonly uint GameVersionA = 1u;
public static readonly uint GameVersionB = 10u;
public static readonly uint GameVersionC = 0u;
public static readonly uint GameVersionC = 1u;
public static readonly uint GameVersionBuild = 3u;

public string Name => "Traffic Manager: President Edition [" + Version + "]";
Expand Down

0 comments on commit 91dca4e

Please sign in to comment.