CitiesSkylinesMods / TMPE

Cities: Skylines Traffic Manager: President Edition
https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252
MIT License
576 stars 85 forks source link

Merge close-proximity level crossings. #11

Open originalfoo opened 5 years ago

originalfoo commented 5 years ago

See: https://github.com/VictorPhilipp/Cities-Skylines-Traffic-Manager-President-Edition/issues/218

krzychu124 commented 5 years ago

Just to clarify, I have to block vehicles from entering level crossing if there is no space on the next segment to leave train tracks, am I right? If yes I think that would be nice to hide that sign in junction restriction since I should ignore all user setting in this special case?

originalfoo commented 5 years ago

There should be special default case for level crossings:

On level crossings vehicles must not enter if road blocked, even if Vehicles may enter blocked junctions setting (Policies & Restrictions tab) is enabled

However, user should still be able to manually override it for individual junctions via junction restrictions.

The reason for allowing manual override is to cope with multi-track stations which, if built close to perpendicular road, might have two or more tracks crossing the road. The result is that the road in middle is a very short segment, and the effect of preventing access if blocked is that traffic jams will quickly occur. So the user, in rare cases, needs ability to allow traffic to enter when blocked, but will have to deal with the consequences.

originalfoo commented 5 years ago

BTW, in cases where multiple rails cross a road in short space, I had this idea which was to essentially merge the level crossings in to a single "big" level crossing:

https://github.com/VictorPhilipp/Cities-Skylines-Traffic-Manager-President-Edition/issues/130

While quite an involved bit of coding (I assume?) it would be great for users of multi track stations. Currently those stations need placing away from any perpendicular roads so that tracks can be merged in to a single track for crossing the road, which is a PITA especially in mountainous maps.

krzychu124 commented 5 years ago

I have hard time to reproduce this issue if crossing single train track segment (not multitrack yet). I can see in code that even if vehicle has reckless driver flag(vanilla Emergency2 - ambulances, police, firetruck on emergency) it must check for space available at the next segment 😕

Moreover it doesn't matter now if you enabled entering at blocked junction on level crossing - reckless drivers will ignore that setting and they'll still check for available space (it's bug, because every other vehicle type are following these user setting)

krzychu124 commented 5 years ago

Screenshots to visualize this

originalfoo commented 5 years ago

Hrm, interesting.

I wonder if the Simulation accuracy setting (general tab in mod options) affects it? From vague memory, it controls how accurate the simulation is at junctions, amongst other things.

When I encountered the issue it could possibly have been ambulances getting stuck between two level crossings (issue with enter blocked junctions bug you mentioned?) and somehow blocking one of the crossings (which caused my rail network to traffic jam).

In the referenced issue though, https://github.com/VictorPhilipp/Cities-Skylines-Traffic-Manager-President-Edition/issues/218, @Krutonium screengrabs show that the trains were stopping even though there were no vehicles on the tracks...?

krzychu124 commented 5 years ago

I forgot to mention that current tests are made without Timed traffic light set at level crossing.

With regards to https://github.com/VictorPhilipp/Cities-Skylines-Traffic-Manager-President-Edition/issues/218 it looks like it is, but currently train will stop only when vehicle is blocking train tracks.

I've been watching this for a while and one thing I can see is when two vehicles are trying to fit in one available space at lane while segment behind junction has less lanes than in front of the junction (lanes merging problem - occurs with other junction types too).

I will change Simulation accuracy to check if it'll change something

originalfoo commented 5 years ago

Wait, I think I know what happened!

There's actually 2 separate bugs in https://github.com/VictorPhilipp/Cities-Skylines-Traffic-Manager-President-Edition/issues/218

Just checking something, brb..

originalfoo commented 5 years ago

So, while the original bug was fixed by preventing reckless/emergency from entering blocked level crossings, that in turn created the bug I saw = vehicles can get stuck between two blocked crossings if they are close enough together. And it just so happened that when I spotted it, an ambulance was the culprit, but it could have been any vehicle type.

Make sense?

A vehicle got stuck between two level crossings, blocking the crossing behind it. And that was caused because the manually set "allow enter blocked junction" on my crossings were no longer working for emergency/reckless vehicles.

So to fix both issues:

  1. Level crossings should prevent road vehicles entering if they are blocked - by default
    • This is how mod currently works
  2. But if a user manually sets "allow enter blocked", that should be respected
    • This is the change that needs making to allow users to overcome fringe cases where there are two or more level crossings in close proximity
krzychu124 commented 5 years ago

Thank you for quick and such complex response 😃

I've just came up with an idea. Maybe we should give user ability to connect two or more level crossings nodes to make those act like one (to close all in group if one is closing). I think it would solve problem with stucking vehicles in between crossings

In addition to this feature would be cool to hide barriers at all crossings in between first and last selected node (It will involve some digging in code how level crossing are made)

What do you think?

originalfoo commented 5 years ago

Maybe we should give user ability to connect two or more level crossings nodes to make those act like one

Yesssss!!!!! This would be my dream solution!

I had asked LinuxFan similar, but he didn't want to do it: https://github.com/VictorPhilipp/Cities-Skylines-Traffic-Manager-President-Edition/issues/130

It can be automated too, because you can detect when a single road segment has level crossing at both ends. And with no middle barriers, the traffic in the middle can escape the 'wide crossing'. Would be perfect!!!

krzychu124 commented 5 years ago

What a nightmare 🤣 🤣 🤣

krzychu124 commented 5 years ago

I won't halt currently collected bug fixes and improvements to wait for finishing development of this feature. I will check if there is something less involving to fix to add to upcoming patch.

originalfoo commented 5 years ago

I think there was also another bug with level crossing lights: https://github.com/VictorPhilipp/Cities-Skylines-Traffic-Manager-President-Edition/issues/176

So probably worth having a specific milestone for level crossing improvements.

krzychu124 commented 5 years ago

Nice suggestion, so I will create a new milestone, maybe more general - railroad related improvements.

Krutonium commented 5 years ago

Should I close #218 ?

krzychu124 commented 5 years ago

Yup, it looks like that bug was fixed

krzychu124 commented 5 years ago

zrzut ekranu 107

krzychu124 commented 5 years ago

Both trains m_flags2 has state Yielding... Good question is who has priority now??

originalfoo commented 5 years ago

Hmm, pseudo-random choice?

BTW, this lane flag might be useful: https://cslmodding.info/asset/network/#lane-flag-joinedjunction

On a road you could check that as a quick way of filtering out ineligible segments? There are other flags (see rest of that page linked above) that indicate presence of level crossing and a bunch of other useful stuff.

There's also situation where there might be multiple close-proximity level crossings along a train track, in which case would it make sense to merge those too?

krzychu124 commented 5 years ago

Good idea with those joined junctions, I thought about that issue when I've read descriptions of flags.

With regards to yield state I will try to find why the train is getting this yield state when there are no blocked lane segments in front of him...

krzychu124 commented 5 years ago

Ok, there must be bug in Vehicle Behavior class because when I've added Timed Traffic lights trains doesn't stop on green light and everything is working properly, besides those traffic lights stop trains now...

originalfoo commented 5 years ago

hey, I just realised, both trains have right of way if the barriers are down - it's not like they can change tracks at the level crossing junction, the tracks are still separate