diff options
author | terkhen <terkhen@openttd.org> | 2010-04-07 14:17:29 +0000 |
---|---|---|
committer | terkhen <terkhen@openttd.org> | 2010-04-07 14:17:29 +0000 |
commit | 869fac9964de697eeb41761c3e047eea858023f5 (patch) | |
tree | e723ca4637829cfd9c715da8e987a08b827beb4e /src/cargotype.cpp | |
parent | dfa9e9d9d3f49abc6d4957677db65c141adc92e8 (diff) | |
download | openttd-869fac9964de697eeb41761c3e047eea858023f5.tar.xz |
(svn r19573) -Fix (r19541): Special cargos did not appear at the refit list.
Diffstat (limited to 'src/cargotype.cpp')
-rw-r--r-- | src/cargotype.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/cargotype.cpp b/src/cargotype.cpp index 01b5f425f..ecad2308e 100644 --- a/src/cargotype.cpp +++ b/src/cargotype.cpp @@ -116,7 +116,9 @@ SpriteID CargoSpec::GetCargoIcon() const } const CargoSpec *_sorted_cargo_specs[NUM_CARGO]; ///< Cargo specifications sorted alphabetically by name. -uint8 _sorted_cargo_specs_size; ///< Number of cargo specifications stored at the _sorted_cargo_specs array. +uint8 _sorted_cargo_specs_size; ///< Number of cargo specifications stored at the _sorted_cargo_specs array (including special cargos). +uint8 _sorted_standard_cargo_specs_size; ///< Number of standard cargo specifications stored at the _sorted_cargo_specs array. + /** Sort cargo specifications by their name. */ static int CDECL CargoSpecNameSorter(const CargoSpec * const *a, const CargoSpec * const *b) @@ -140,7 +142,10 @@ static int CDECL CargoSpecClassSorter(const CargoSpec * const *a, const CargoSpe if (res == 0) { res = ((*b)->classes & CC_MAIL) - ((*a)->classes & CC_MAIL); if (res == 0) { - return CargoSpecNameSorter(a, b); + res = ((*a)->classes & CC_SPECIAL) - ((*b)->classes & CC_SPECIAL); + if (res == 0) { + return CargoSpecNameSorter(a, b); + } } } @@ -151,15 +156,20 @@ static int CDECL CargoSpecClassSorter(const CargoSpec * const *a, const CargoSpe void InitializeSortedCargoSpecs() { _sorted_cargo_specs_size = 0; - CargoSpec *cargo; + const CargoSpec *cargo; /* Add each cargo spec to the list. */ FOR_ALL_CARGOSPECS(cargo) { - if ((cargo->classes & CC_SPECIAL) != 0) continue; // Exclude fake cargo types. _sorted_cargo_specs[_sorted_cargo_specs_size] = cargo; _sorted_cargo_specs_size++; } /* Sort cargo specifications by cargo class and name. */ QSortT(_sorted_cargo_specs, _sorted_cargo_specs_size, &CargoSpecClassSorter); + + _sorted_standard_cargo_specs_size = 0; + FOR_ALL_SORTED_CARGOSPECS(cargo) { + if (cargo->classes & CC_SPECIAL) break; + _sorted_standard_cargo_specs_size++; + } } |