Index: src/lang/english.txt =================================================================== --- src/lang/english.txt (revision 8591) +++ src/lang/english.txt (working copy) @@ -384,7 +384,8 @@ STR_SORT_BY_VALUE :Value STR_SORT_BY_FACILITY :Station type STR_SORT_BY_WAITING :Waiting cargo value -STR_SORT_BY_RATING_MAX :Cargo rating +STR_SORT_BY_RATING_MAX :Cargo rating (max) +STR_SORT_BY_RATING_MIN :Cargo rating (min) STR_ENGINE_SORT_ENGINE_ID :EngineID (classic sort) STR_ENGINE_SORT_COST :Cost STR_ENGINE_SORT_POWER :Power Index: src/station_gui.cpp =================================================================== --- src/station_gui.cpp (revision 8591) +++ src/station_gui.cpp (working copy) @@ -45,6 +45,7 @@ static StationSortListingTypeFunction StationTypeSorter; static StationSortListingTypeFunction StationWaitingSorter; static StationSortListingTypeFunction StationRatingMaxSorter; +static StationSortListingTypeFunction StationRatingMinSorter; /** Draw small boxes of cargo amount and ratings data at the given * coordinates. If amount exceeds 576 units, it is shown 'full', same @@ -87,6 +88,7 @@ STR_SORT_BY_FACILITY, STR_SORT_BY_WAITING, STR_SORT_BY_RATING_MAX, + STR_SORT_BY_RATING_MIN, INVALID_STRING_ID }; @@ -152,6 +154,23 @@ return (_internal_sort_order & 1) ? maxr2 - maxr1 : maxr1 - maxr2; } +static int CDECL StationRatingMinSorter(const void *a, const void *b) +{ + const Station* st1 = *(const Station**)a; + const Station* st2 = *(const Station**)b; + byte minr1 = 255; + byte minr2 = 255; + int j; + + for (j = 0; j < NUM_CARGO; j++) { + //using same criteria used to display ratings in DrawStationViewWindow + if (st1->goods[j].enroute_from != INVALID_STATION) minr1 = min(minr1, st1->goods[j].rating); + if (st2->goods[j].enroute_from != INVALID_STATION) minr2 = min(minr2, st2->goods[j].rating); + } + + return (_internal_sort_order & 1) ? minr2 - minr1 : minr1 - minr2; +} + typedef enum StationListFlags { SL_ORDER = 0x01, SL_RESORT = 0x02, @@ -248,7 +267,8 @@ &StationNameSorter, &StationTypeSorter, &StationWaitingSorter, - &StationRatingMaxSorter + &StationRatingMaxSorter, + &StationRatingMinSorter, }; if (!(sl->flags & SL_RESORT)) return;