Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add news notifications for significantly delayed trains #7954

Closed
wants to merge 1 commit into from

Conversation

joestringer
Copy link
Contributor

Occasionally in single-player games, I get deeply engrossed in new construction projects only to find out hours later that I've inadvertently constructed the perfect deadlock; or I throw several new trains on a line which is nearing capacity and fail to realize that the newly introduced congestion is crowding out my profitable shared city stations.

Locating the source of these congestion points is quite easy. First, you wait until the end of the next full year.. then you observe the flood of notifications about unprofitable trains. Then you fix it. Easy, right?

But wait, if we can notify about unprofitable trains, and you can certainly notify about those ships with pathfinding issues... why can't the game tell you when your trains are deadlocking? Challenge accepted! Let me just put together a menu item...

delay-option

Bit of digging around and hacking on the code...

delay-train

et, voila! Stop a random train on one of your congested routes, and a short while later you'll see this message pop up. I recall the particular congestion point that caused me to write this patch, but what I didn't expect is that the first time I loaded up my game with this, it pointed out yet another highly congested track down at the bottom of my network! I hadn't looked down there for years!

I had to run a few variations on this patch to tweak the threshold, I found that path delay * 2 * DAY_TICKS was a reliable point where you don't receive false alerts, but it will still reliably detect deadlocks and highly congested paths. Moderate congestion does not trigger the alerts.

Let me know what you think!

Support detecting when trains are being significantly delayed, for
instance due to deadlock or high congestion, and send a notification to
the player. The delay is chosen to be not too sensitive that it will
trigger false alarms, but will reliably detect certain deadlock or
severe traffic.
@nielsmh
Copy link
Contributor

nielsmh commented Jan 22, 2020

I'm not sure I like the approach here, hooking into the train pathfinding and only the waiting at signal part. It's too specific to trains, doesn't handle livelocks, and doesn't handle things that are just running intensely slow but still move.

@joestringer
Copy link
Contributor Author

@nielsmh Thanks for reviewing the approach.

hooking into the train pathfinding and only the waiting at signal part. It's too specific to trains...

How about if it was hooked into RunVehicleDayProc() instead? There could be a once-a-day check per vehicle for whether it is making progress, and trigger the news item from there.

...doesn't handle livelocks...

This seems like a much more involved problem to solve. I'm not even sure I've hit this myself. Can you provide an example of such cases where you'd want to be notified?

...and doesn't handle things that are just running intensely slow but still move.

Hmm, yeah this might be useful to know about. I'm thinking heavy trains taking a long time to ascend a hill. Not sure how you could generically detect this though, it seems like you'd want to signal it based on the functions that apply the speed limits, which are all vehicle-specific AFAICT.

@nielsmh
Copy link
Contributor

nielsmh commented Jan 25, 2020

I wonder if it would be possible to use the timetable information already being gathered, and compare the current travel time to the next destination with the expected. This could both work with explicit timetables (travel time set by player) and implicit timetables (just the last measured time).
If a vehicle has spent much longer than the expected travel time and still hasn't arrived, then warn.

@joestringer
Copy link
Contributor Author

There are many caveats to different approaches to solving this problem, depending on your play style. I agree that this current approach won't always work, and another approach may be more broadly applicable. I don't expect to rework this PR to achieve such any time soon, so I'll close this out.

Thanks for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants