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
Fix #10511: Delay 'go to nearest depot' orders #11548
Fix #10511: Delay 'go to nearest depot' orders #11548
Conversation
This comment has been minimized.
This comment has been minimized.
b0ac816
to
c46407b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Squash required, but final diff looks good to me.
c46407b
to
a6597af
Compare
Seems default penalty is actually too small
This comment has been minimized.
This comment has been minimized.
a6597af
to
ed89a52
Compare
ed89a52
to
dcf026b
Compare
dcf026b
to
1678a5e
Compare
A better savegame with 74 vehicles going to nearest depot. |
1678a5e
to
c55bbb0
Compare
@SamuXarick This looks fine to me, but can you test your demo savegame and verify it still works, and I haven't given you some wrong code? 😉 |
If there's some other functionality I'm not aware that could skew this check, then I must be aware. |
c55bbb0
to
75d9d91
Compare
src/order_cmd.cpp
Outdated
AircraftNextAirportPos_and_Order(a); | ||
/* If the vehicle can't find its destination, delay its next search. | ||
* In case many vehicles are in this state, use the vehicle index to spread out pathfinder calls. */ | ||
if (v->dest_tile != 0 || TimerGameCalendar::date_fract == (v->index % Ticks::DAY_TICKS)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (v->dest_tile != 0 || TimerGameCalendar::date_fract == (v->index % Ticks::DAY_TICKS)) { | |
if (v->dest_tile == 0 && TimerGameCalendar::date_fract != (v->index % Ticks::DAY_TICKS)) break; |
should work too without needing to touch indentation.
(Maybe return false
instead of break, but I didn't analyse all the function)
Delay the nearest depot order search for a day if the vehicle can't find its destination, which happens when it has already attempted to do so and failed to find a valid destination.
75d9d91
to
a1efb1f
Compare
What happens to the road vehicle in this state? Does it just carry on driving randomly? |
Yes for at most a day, it's usually a user error if the vehicle can't determine what is the nearest depot, and the change is just so it has less impact on gameloop. |
Motivation / Problem
#10511
A lone Road Vehicle with a "go to nearest depot" order on a large road network and no depot nearby causes constant calls to the pathfinder every tick, hindering game performance.
This is happening in
ProcessOrders
and not inIndividualRoadVehicleController
as it's been in the previous reported cases with similar symptoms. I think that the ideal solution here would be to call the pathfinder upon reaching the end of a segment, as that would in theory limit the number of calls significantly. But in this case, it really wants to know what's the destination of the order before handling it over to theIndividualRoadVehicleController
.I don't know how to do that, so I thought of a different approach.
Description
Delay the nearest depot order search for a day if the destination has been set to zero, which happens when it has already attempted to do so and failed to find a valid destination.
Closes #10511.
Limitations
It may break other "legitimate" uses for
v->dest_tile == 0
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.