GithubHelp home page GithubHelp logo

vectorial1024 / publictransportunstucker Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 3.61 MB

Unstucks public transport by fixing known causes of stucking.

Home Page: https://steamcommunity.com/sharedfiles/filedetails/?id=2774427140

C# 100.00%
mod cities-skylines steam-workshop

publictransportunstucker's Introduction

Public Transport Unstucker

Unstucks public transport by fixing known causes of stucking.

Alternatively:

Buses are stuck? metros are stuck? Public transport is stuck? Buses and metros arrive at their stations but never depart? Unbunching is disabled but they are still stuck? Look no further! Public Transport Unstucker (PTU) is here to help.

Mod Status

  • No known incomaptibility problems (yet; TODO does EBS work with this?)

Because this mod is very small and simple, I am open-sourcing this to everyone out there.

Types of Transportation Covered

These transportation types are currently covered by this mod:

  • Buses; as a result of game mechanics, the following transportation types are also covered:
    • Evacuation buses
    • Tourism buses
    • Intercity buses
  • Trolleybuses
  • Metros
  • Trains
  • Planes
  • Blimps
  • Helicopers
  • Ships
  • Ferries

Other types are not yet covered, but perhaps they are also affected by this bug. I am not sure.

Motivation and Technical Information

It actually started when I was developing my other mod Express Bus Services. When testing that mod, I noticed that sometimes buses will fail to depart, yet the logic was correct on my side. Using ModTools, I discovered this phenomenon/bug which I dubbed the "Citizen Runaway Problem" ("CRP").

The main idea of CRP is very simple. It is known that buses etc cannot depart before everyone has entered the vehicle and despawned, this makes sense. However, randomly, there will be passengers who declare that they have entered the vehicle but actually did not (fun fact: they will begin to slide through the terrain to their destination so they usually cannot be seen). This results in the vehicles waiting basically forever for those rogue passengers to return, making them stuck.

I do not understand why this happens, nor do I have the time to find out, but I do know how to "fix" this problem: whenever this problem appears, disappear the problem. Simple.

When supported public transport vehicles are checking whether everyone is on board, I add an extra check to detect rogue passengers, and if there are such passengers, I force-despawn them. This sends them back to the "background" and the "all aboard" check passes.

Special Note: if for some reason the passenger in question is too far away from the transport vehicle, then the passenger is also considered as a rogue passenger. The rogue distance is different for each type of public transport covered, but the range is set so that they do not block vanilla behavior using vanilla numbers.

For example, currently trains have a rogue range of 160 units (16 tiles), which is the max length of a vanilla train platform. If the passenger is somehow beyond 160-units far, then it is marked as rogue and forced to despawn into the vehicle.

publictransportunstucker's People

Contributors

vectorial1024 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

publictransportunstucker's Issues

What is the Citizen Runaway Problem?

Normal Situation/Intended Behavior

When a public transport vehicle (eg bus, metro, ...) are about to depart, it checks a few things. One of the things to check is whether all passengers have entered the vehicle.

What is the problem?

Sometimes, there are some passengers who declared that they have entered the vehicle, but actually did not. They would add themselves to the passenger list of the vehicles, but physically begin to move away from the vehicle themselves. It is as if they are "running away", so to speak.

The all-aboard check is actually checking whether the passengers are physically close to the vehicle, so that the vehicle may reset the passengers' state and despawn them.

So, public transport vehicles spend a lot of time waiting for those runaway passengers, and appear as if they are "stuck at boarding".

The solution

Simple. When we detect that this is happening, we force-despawn the problematic passengers, so that the check passes.

Code-inspect and extend to other types of public transport

Steam user raised a very good point about whether it is applicable on eg blimps.

I did not test this against blimps, but supposedly every kinds of transport in CSL are using similar code, so it makes sense to use code-inspect to "prove" whether we should extend to other types of transport, and to "prove" without testing that it will just work the same way.

Plane-related stucking

Report from Steam user:

Necko 26 Aug @ 6:12pm
Can you make update for planes too?

Lots of citizens are stuck there making my Citizen Instances increse a lot and that plane itself are stuck there for 10minutes or more (keep in mind my simulation speed is so slow, 500k population)
https://prnt.sc/kA2-lhawtCno

Also planes are sometimes confused after take-off, not sure does that have anything to do with slow boarding (That green dot at end edge of map is plane outside connection for that plane):

https://prnt.sc/wFQxSpMkDFrE


Right now I am not sure what is going on, but can investigate when have free time. If I have more info on this, I can then decide whether this is in scope of this mod.

Consider allowing/forcing cims to despawn when too far away

Currently receiving reports about custom long train stations being too slow to board because cims need to walk all the way to the end of the platform to get into their train car.

We can think about this for now, until I have time to look deeper.

Tram-related stucking

Initial hypothesis: this is totally unrelated to the Citizen Runaway Problem.

Situation:

It seems that trams can randomly enter the "confused" state and "fold onto themselves", causing them to get stuck and blocking the other trams nearby.

I have observed similar situation before when one time I was adjusting train tracks, and at a certain angle, the train could not snap to the new tracks, The train started "folding onto itself", and was promptly despawned. Interesting that the trams could not do this...

Citizen Runaway check results in "too early" runaway-fix

This results in hilarious situation where eg correctly-boarding passengers for the metro is wrongly detected as "runaway" and gets cancelled too early. They aren't even rogues!

Maybe we did not clean up/init the data tables correctly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.