OpenTTD

Tasklist

FS#5978 - Autoreplace window isn't updated after group hierarchy changes

Attached to Project: OpenTTD
Opened by Juanjo (juanjo) - Friday, 11 April 2014, 20:53 GMT
Last edited by andythenorth (andythenorth) - Friday, 25 August 2017, 15:46 GMT
Type Bug
Category Core
Status With patch
Assigned To No-one
Operating System All
Severity Low
Priority High
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

The autoreplace window lists are not updated after making a group hierarchy change.

Group 1: Has no maglevs.
Group 2: Has maglevs.

Open autoreplace window for G1. It doesn't list maglevs.
Add G2 as a subgroup of G1. Autoreplace window for G1 should list maglevs, but it doesn't.

Showing diesel engines and then going back to maglev ones makes window up-to-date.

Maybe group hierarchy code should call InvalidateAutoreplaceWindow somewhere.
This task depends upon

Comment by Juanjo (juanjo) - Friday, 11 April 2014, 20:54 GMT
Title should be "Autoreplace window isn't *updated* after group hierarchy changes."
Comment by Alex6 (alex6) - Thursday, 23 October 2014, 16:57 GMT
I was not able to reproduce the problem following the steps.
Do you have a savegame ?
Comment by Juanjo (juanjo) - Thursday, 23 October 2014, 17:58 GMT
Here is a savegame (r27037) and some images.
It happens if you open a replacement window for vehicles of GROUP 1.
Comment by 3298 (3298) - Friday, 25 August 2017, 15:40 GMT
It was indeed a simple fix, a call to GroupStatistics::UpdateAutoreplace was missing. While I was testing I also found two other equally small issues between autoreplace and groups: the group window doesn't refresh when starting or stopping a replacement (i.e. the autoreplace icon didn't (dis-)appear when it should, but after another redraw trigger like selecting a group it did), and in addition the color of the autoreplace icon in the group window doesn't accurately reflect the status of autoreplace when the only remaining vehicles to replace are in subgroups (it is drawn like when the autoreplace has finished, even though that is not yet true).
The attached patch fixes all three issues. The first two hunks refresh the group window when starting/stopping autoreplace; the third hunk fixes the issue with incorrect display of autoreplace's "finished" status; and the fourth hunk is the fix for the original issue, refreshing the autoreplace window on group hierarchy changes.
I aggregated them into a single patch because they are closely related, tiny, and easy to separate if needed.

Loading...