Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 3-more-accurate-lan…
Browse files Browse the repository at this point in the history
…e-routing-arcs
  • Loading branch information
krzychu124 committed May 31, 2019
2 parents 58f1173 + 14687d6 commit c923e5d
Show file tree
Hide file tree
Showing 37 changed files with 957 additions and 362 deletions.
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: Bug Report
about: Help us understand what we need to fix.
labels: bug, triage
---

<!-- Want to see an example bug report before you submit one? See: https://bit.ly/tmpe-etbr -->

### Description


### Reproduction Steps
Add more steps as nessecary.
1.
2.
3.

### Mod List
Please list the mods enabled when you noticed the bug.
- TM:PE xx.xx
-
-

### Output Log
<!-- Don't know how to share your log file? See: https://bit.ly/2I3YVFL -->


### Savegame (Optional)
<!-- Don't know how to share savegames? See: https://bit.ly/2FXog0z -->


### Screenshots (Optional)
<!-- Don't know how to share screenshots? See: https://bit.ly/2Kc8owO -->


### Additional Info
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature Request
about: Make suggestions on how TM:PE could improve.
labels: feature, triage
---

<!-- Want to see an example feature request before you submit one? See: https://bit.ly/tmpe-etfr -->

### Description


### Sources / Links (Optional)
<!-- Example: For turn on red, a link to a "turn on red rule" in a drivers handbook. -->


### Screenshots (Optional)
<!-- Don't know how to share screenshots? See: https://bit.ly/2Kc8owO -->


### Additional Info
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/translation-update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Translation Update
about: Help us make TM:PE available for everyone, no matter what language.
labels: localisation, triage
---

<!-- Want to see an example translation update before you submit one? See: https://bit.ly/tmpe-ettu -->

### Language to be Updated


### Localization File
If you're familiar with github, go ahead and send us a Pull Request instead of submitting this issue.
If you're not, click below then drag-and-drop your translation file to upload it here. Alternatively, you can paste the URL to the file below.
<!-- Don't understand how to get one of these? See: https://bit.ly/tmpe-localisation -->


### Additional Info
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# Cities: Skylines - Traffic Manager: *President Edition* [![Discord](https://img.shields.io/discord/545065285862948894.svg)](https://discord.gg/faKUnST)

# Changelog
10.20, 21/05/2019
- Updated for game version 1.12.0-f5
- Updated Korean translation (thanks Twotoolus-FLY-LShst) (#294)
- Updated French translation (thanks PierreTSE) (#311)

10.19, 20/04/2019
- Bugfix: Mod options overlapping issue (#250, #266).
- Added: Japanese language (thanks mashitaro) (#258).
- Update: Chinese language (thanks Emphasia) (#285, #286).
- Update: "Vanilla Trees Remover" as incompatible mod (it breaks mod options screen) (#271, #290).
- Update: Moved "Delete" step button on timed traffic lights (#283, #285).
- Update: Mod incompatibility checker can now be disabled, or skip disabled mods (#264, #284, #286).

10.18, 29/03/2019
- Bugfix: Parking AI: Cars do not spawn at outside connections (#245)
- Bugfix: Trams perform turns on red (#248)
Expand Down
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Traffic Manager: *President Edition* [![Discord](https://img.shields.io/discord/545065285862948894.svg)](https://discord.gg/faKUnST) [![Build status](https://ci.appveyor.com/api/projects/status/dehkvuxk8b3h66e7/branch/master?svg=true)](https://ci.appveyor.com/project/krzychu124/cities-skylines-traffic-manager-president-edition/branch/master)
# Traffic Manager: *President Edition* [![Steam](https://img.shields.io/endpoint.svg?url=https://shieldsio-steam-workshop.jross.me/583429740)](https://steamcommunity.com/sharedfiles/filedetails/?id=583429740) [![Discord](https://img.shields.io/discord/545065285862948894.svg?logo=discord&logoColor=F5F5F5)](https://discord.gg/faKUnST) [![Build status](https://ci.appveyor.com/api/projects/status/dehkvuxk8b3h66e7/branch/master?svg=true)](https://ci.appveyor.com/project/krzychu124/cities-skylines-traffic-manager-president-edition/branch/master)

A mod for **Cities: Skylines** that gives you more control over road and rail traffic in your city.

[Steam Workshop](https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252)[Installation](https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/wiki/Installation)[User Guide](http://www.viathinksoft.de/tmpe/wiki)[Issue Tracker](https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/issues)[Report a Bug](https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/wiki/Report-a-Bug)
[Steam Workshop](https://steamcommunity.com/sharedfiles/filedetails/?id=583429740)[Discord Guild](https://discord.gg/faKUnST)[Installation](https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/wiki/Installation)[User Guide](http://www.viathinksoft.de/tmpe/wiki)[Issue Tracker](https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/issues)[Report a Bug](https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/wiki/Report-a-Bug)

# Features

Expand All @@ -22,10 +22,10 @@ A mod for **Cities: Skylines** that gives you more control over road and rail tr
* Clear traffic, stuck cims, etc.

# Changelog
### [10.18](https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/compare/10.17...10.18), 29/03/2019
- Bugfix: Parking AI: Cars do not spawn at outside connections (#245)
- Bugfix: Trams perform turns on red (#248)
- Update: Service Radius Adjuster mod by Egi removed from incompatible mods list (#255)
### [10.20](https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/compare/10.19...10.20), 21/05/2019
- Updated for game version 1.12.0-f5
- Updated Korean translation (thanks Twotoolus-FLY-LShst) (#294)
- Updated French translation (thanks PierreTSE) (#311)

See [Full Changelog](https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/blob/master/CHANGELOG.md) for details of earlier releases.

Expand All @@ -37,8 +37,22 @@ Contact us:

* [Issue tracker](https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/issues)
* [Discord (chat)](https://discord.gg/faKUnST)
* [Steam Workshop](https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252)
* [Steam Workshop (Stable)](https://steamcommunity.com/sharedfiles/filedetails/?id=583429740)
* [Steam Workshop (Labs)](https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252)

# License

[MIT License](https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/blob/master/LICENSE) (open source)

# Notice

The TM:PE team is happy to support you if you have any issues with the mod under the following conditions:
- You are using the latest version of the STABLE and/or LABS mod.
- You are using a properly purchased version of Cities: Skylines.

We will not provide support if:
- You are using a pirated version of Cities: Skylines.
- You are using an older version of the mod.
- You are using an older version of Cities: Skylines.

TM:PE is only tested on and updated for the latest version of Cities: Skylines.
115 changes: 115 additions & 0 deletions TLM/TLM/Custom/AI/CustomPostVanAI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using ColossalFramework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TrafficManager.Custom.PathFinding;
using TrafficManager.Traffic;
using TrafficManager.Traffic.Data;
using UnityEngine;
using static TrafficManager.Custom.PathFinding.CustomPathManager;

namespace TrafficManager.Custom.AI {
public class CustomPostVanAI : CarAI {
public bool CustomStartPathFind(ushort vehicleID, ref Vehicle vehicleData, Vector3 startPos, Vector3 endPos, bool startBothWays, bool endBothWays, bool undergroundTarget) {
if (vehicleData.m_transferType == (byte)TransferManager.TransferReason.Mail) {
return base.StartPathFind(vehicleID, ref vehicleData, startPos, endPos, startBothWays, endBothWays, undergroundTarget);
}

if ((vehicleData.m_flags & (Vehicle.Flags.TransferToSource | Vehicle.Flags.GoingBack)) != 0) {
return base.StartPathFind(vehicleID, ref vehicleData, startPos, endPos, startBothWays, endBothWays, undergroundTarget);
}

bool allowUnderground = (vehicleData.m_flags & (Vehicle.Flags.Underground | Vehicle.Flags.Transition)) != (Vehicle.Flags)0;
PathUnit.Position startPosA = default(PathUnit.Position);
PathUnit.Position startPosB = default(PathUnit.Position);
float startDistSqrA = default(float);
float startDistSqrB = default(float);

// try to find road start position
bool startPosFound = CustomPathManager.FindPathPosition(startPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, VehicleInfo.VehicleType.Car, allowUnderground, false, 32f, out startPosA, out startPosB, out startDistSqrA, out startDistSqrB);

// try to find other start position (plane, train, ship)
PathUnit.Position altStartPosA = default(PathUnit.Position);
PathUnit.Position altStartPosB = default(PathUnit.Position);
float altStartDistSqrA = default(float);
float altStartDistSqrB = default(float);
if (PathManager.FindPathPosition(startPos, ItemClass.Service.PublicTransport, NetInfo.LaneType.Vehicle, VehicleInfo.VehicleType.Train | VehicleInfo.VehicleType.Ship | VehicleInfo.VehicleType.Plane, allowUnderground, false, 32f, out altStartPosA, out altStartPosB, out altStartDistSqrA, out altStartDistSqrB)) {
if (!startPosFound || (altStartDistSqrA < startDistSqrA && (Mathf.Abs(startPos.x) > 4800f || Mathf.Abs(startPos.z) > 4800f))) {
startPosA = altStartPosA;
startPosB = altStartPosB;
startDistSqrA = altStartDistSqrA;
startDistSqrB = altStartDistSqrB;
}
startPosFound = true;
}

PathUnit.Position endPosA = default(PathUnit.Position);
PathUnit.Position endPosB = default(PathUnit.Position);
float endDistSqrA = default(float);
float endDistSqrB = default(float);

// try to find road end position
bool endPosFound = PathManager.FindPathPosition(endPos, ItemClass.Service.Road, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, VehicleInfo.VehicleType.Car, undergroundTarget, false, 32f, out endPosA, out endPosB, out endDistSqrA, out endDistSqrB);

// try to find other end position (plane, train, ship)
PathUnit.Position altEndPosA = default(PathUnit.Position);
PathUnit.Position altEndPosB = default(PathUnit.Position);
float altEndDistSqrA = default(float);
float altEndDistSqrB = default(float);
if (PathManager.FindPathPosition(endPos, ItemClass.Service.PublicTransport, NetInfo.LaneType.Vehicle, VehicleInfo.VehicleType.Train | VehicleInfo.VehicleType.Ship | VehicleInfo.VehicleType.Plane, undergroundTarget, false, 32f, out altEndPosA, out altEndPosB, out altEndDistSqrA, out altEndDistSqrB)) {
if (!endPosFound || (altEndDistSqrA < endDistSqrA && (Mathf.Abs(endPos.x) > 4800f || Mathf.Abs(endPos.z) > 4800f))) {
endPosA = altEndPosA;
endPosB = altEndPosB;
endDistSqrA = altEndDistSqrA;
endDistSqrB = altEndDistSqrB;
}
endPosFound = true;
}

if (startPosFound && endPosFound) {
CustomPathManager pathManager = CustomPathManager._instance;
if (!startBothWays || startDistSqrA < 10f) {
startPosB = default(PathUnit.Position);
}
if (!endBothWays || endDistSqrA < 10f) {
endPosB = default(PathUnit.Position);
}
uint path;

PathCreationArgs args;
args.extPathType = ExtCitizenInstance.ExtPathType.None;
args.extVehicleType = ExtVehicleType.Service;
args.vehicleId = vehicleID;
args.spawned = (vehicleData.m_flags & Vehicle.Flags.Spawned) != 0;
args.buildIndex = Singleton<SimulationManager>.instance.m_currentBuildIndex;
args.startPosA = startPosA;
args.startPosB = startPosB;
args.endPosA = endPosA;
args.endPosB = endPosB;
args.vehiclePosition = default(PathUnit.Position);
args.laneTypes = NetInfo.LaneType.Vehicle | NetInfo.LaneType.CargoVehicle;
args.vehicleTypes = VehicleInfo.VehicleType.Car | VehicleInfo.VehicleType.Train | VehicleInfo.VehicleType.Ship | VehicleInfo.VehicleType.Plane;
args.maxLength = 20000f;
args.isHeavyVehicle = this.IsHeavyVehicle();
args.hasCombustionEngine = this.CombustionEngine();
args.ignoreBlocked = this.IgnoreBlocked(vehicleID, ref vehicleData);
args.ignoreFlooded = false;
args.ignoreCosts = false;
args.randomParking = false;
args.stablePath = false;
args.skipQueue = (vehicleData.m_flags & Vehicle.Flags.Spawned) != 0;

if (pathManager.CreatePath(out path, ref Singleton<SimulationManager>.instance.m_randomizer, args)) {
if (vehicleData.m_path != 0) {
pathManager.ReleasePath(vehicleData.m_path);
}
vehicleData.m_path = path;
vehicleData.m_flags |= Vehicle.Flags.WaitingPath;
return true;
}
}
return false;
}
}
}
7 changes: 6 additions & 1 deletion TLM/TLM/Custom/PathFinding/CustomPathFind2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,12 @@ private void PathFindImplementation(uint unit, ref PathUnit data) {
}

#if DEBUG
if (m_debug) {
bool detourMissing = (m_vehicleTypes & (VehicleInfo.VehicleType.Car | VehicleInfo.VehicleType.Train | VehicleInfo.VehicleType.Tram | VehicleInfo.VehicleType.Monorail | VehicleInfo.VehicleType.Metro)) != VehicleInfo.VehicleType.None && !m_queueItem.queued;
if (detourMissing) {
Log.Warning($"Path-finding for unhandled vehicle requested!");
}

if (m_debug || detourMissing) {
Debug(unit, $"PathFindImplementation: Preparing calculation:\n" +
$"\tbufferItemStartA: segment={bufferItemStartA.m_position.m_segment} lane={bufferItemStartA.m_position.m_lane} off={bufferItemStartA.m_position.m_offset} laneId={bufferItemStartA.m_laneID}\n" +
$"\tbufferItemStartB: segment={bufferItemStartB.m_position.m_segment} lane={bufferItemStartB.m_position.m_lane} off={bufferItemStartB.m_position.m_offset} laneId={bufferItemStartB.m_laneID}\n" +
Expand Down
22 changes: 22 additions & 0 deletions TLM/TLM/LoadingExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2266,6 +2266,28 @@ public void initDetours() {
detourFailed = true;
}

Log.Info("Redirection PostVanAI::StartPathFind calls");
try {
Detours.Add(new Detour(typeof(PostVanAI).GetMethod("StartPathFind",
BindingFlags.NonPublic | BindingFlags.Instance,
null,
new[]
{
typeof (ushort),
typeof (Vehicle).MakeByRefType(),
typeof (Vector3),
typeof (Vector3),
typeof (bool),
typeof (bool),
typeof (bool)
},
null),
typeof(CustomPostVanAI).GetMethod("CustomStartPathFind")));
} catch (Exception) {
Log.Error("Could not redirect PostVanAI::StartPathFind");
detourFailed = true;
}

Log.Info("Redirection RoadBaseAI::SetTrafficLightState calls");
try {
Detours.Add(new Detour(typeof(RoadBaseAI).GetMethod("SetTrafficLightState",
Expand Down
4 changes: 2 additions & 2 deletions TLM/TLM/Manager/Impl/OptionsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public bool LoadData(byte[] data) {
}

if (data.Length >= 28) {
Options.setRealisticSpeeds(data[27] == (byte)1);
Options.setIndividualDrivingStyle(data[27] == (byte)1);
}

if (data.Length >= 29) {
Expand Down Expand Up @@ -221,7 +221,7 @@ public byte[] SaveData(ref bool success) {
(byte)(Options.junctionRestrictionsEnabled ? 1 : 0),
(byte)(Options.prohibitPocketCars ? 1 : 0),
(byte)(Options.preferOuterLane ? 1 : 0),
(byte)(Options.realisticSpeeds ? 1 : 0),
(byte)(Options.individualDrivingStyle ? 1 : 0),
(byte)(Options.evacBussesMayIgnoreRules ? 1 : 0),
(byte)(Options.instantEffects ? 1 : 0),
(byte)(Options.parkingRestrictionsEnabled ? 1 : 0),
Expand Down
Loading

0 comments on commit c923e5d

Please sign in to comment.