mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-07 06:39:08 +00:00
(svn r19573) -Fix (r19541): Special cargos did not appear at the refit list.
This commit is contained in:
parent
dfa9e9d9d3
commit
869fac9964
@ -854,7 +854,7 @@ struct BuildVehicleWindow : Window {
|
|||||||
|
|
||||||
/* Collect available cargo types for filtering. */
|
/* Collect available cargo types for filtering. */
|
||||||
const CargoSpec *cs;
|
const CargoSpec *cs;
|
||||||
FOR_ALL_SORTED_CARGOSPECS(cs) {
|
FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
|
||||||
this->cargo_filter[filter_items] = cs->Index();
|
this->cargo_filter[filter_items] = cs->Index();
|
||||||
this->cargo_filter_texts[filter_items] = cs->name;
|
this->cargo_filter_texts[filter_items] = cs->name;
|
||||||
filter_items++;
|
filter_items++;
|
||||||
|
@ -116,7 +116,9 @@ SpriteID CargoSpec::GetCargoIcon() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CargoSpec *_sorted_cargo_specs[NUM_CARGO]; ///< Cargo specifications sorted alphabetically by name.
|
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. */
|
/** Sort cargo specifications by their name. */
|
||||||
static int CDECL CargoSpecNameSorter(const CargoSpec * const *a, const CargoSpec * const *b)
|
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) {
|
if (res == 0) {
|
||||||
res = ((*b)->classes & CC_MAIL) - ((*a)->classes & CC_MAIL);
|
res = ((*b)->classes & CC_MAIL) - ((*a)->classes & CC_MAIL);
|
||||||
if (res == 0) {
|
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()
|
void InitializeSortedCargoSpecs()
|
||||||
{
|
{
|
||||||
_sorted_cargo_specs_size = 0;
|
_sorted_cargo_specs_size = 0;
|
||||||
CargoSpec *cargo;
|
const CargoSpec *cargo;
|
||||||
/* Add each cargo spec to the list. */
|
/* Add each cargo spec to the list. */
|
||||||
FOR_ALL_CARGOSPECS(cargo) {
|
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[_sorted_cargo_specs_size] = cargo;
|
||||||
_sorted_cargo_specs_size++;
|
_sorted_cargo_specs_size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sort cargo specifications by cargo class and name. */
|
/* Sort cargo specifications by cargo class and name. */
|
||||||
QSortT(_sorted_cargo_specs, _sorted_cargo_specs_size, &CargoSpecClassSorter);
|
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++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,6 +134,7 @@ CargoID GetCargoIDByBitnum(uint8 bitnum);
|
|||||||
void InitializeSortedCargoSpecs();
|
void InitializeSortedCargoSpecs();
|
||||||
extern const CargoSpec *_sorted_cargo_specs[NUM_CARGO];
|
extern const CargoSpec *_sorted_cargo_specs[NUM_CARGO];
|
||||||
extern uint8 _sorted_cargo_specs_size;
|
extern uint8 _sorted_cargo_specs_size;
|
||||||
|
extern uint8 _sorted_standard_cargo_specs_size;
|
||||||
|
|
||||||
/** Does cargo \a c have cargo class \a cc?
|
/** Does cargo \a c have cargo class \a cc?
|
||||||
* @param c Cargo type.
|
* @param c Cargo type.
|
||||||
@ -151,4 +152,6 @@ static inline bool IsCargoInClass(CargoID c, CargoClass cc)
|
|||||||
|
|
||||||
#define FOR_ALL_SORTED_CARGOSPECS(var) for (uint8 index = 0; var = _sorted_cargo_specs[index], index < _sorted_cargo_specs_size; index++)
|
#define FOR_ALL_SORTED_CARGOSPECS(var) for (uint8 index = 0; var = _sorted_cargo_specs[index], index < _sorted_cargo_specs_size; index++)
|
||||||
|
|
||||||
|
#define FOR_ALL_SORTED_STANDARD_CARGOSPECS(var) for (uint8 index = 0; var = _sorted_cargo_specs[index], index < _sorted_standard_cargo_specs_size; index++)
|
||||||
|
|
||||||
#endif /* CARGOTYPE_H */
|
#endif /* CARGOTYPE_H */
|
||||||
|
@ -851,7 +851,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
|
|||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
const CargoSpec *cs;
|
const CargoSpec *cs;
|
||||||
FOR_ALL_SORTED_CARGOSPECS(cs) {
|
FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
|
||||||
if (HasBit(_legend_excluded_cargo, cs->Index())) SetBit(this->excluded_data, i);
|
if (HasBit(_legend_excluded_cargo, cs->Index())) SetBit(this->excluded_data, i);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -859,7 +859,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
|
|||||||
|
|
||||||
void UpdateLoweredWidgets()
|
void UpdateLoweredWidgets()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _sorted_cargo_specs_size; i++) {
|
for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
|
||||||
this->SetWidgetLoweredState(CPW_CARGO_FIRST + i, !HasBit(this->excluded_data, i));
|
this->SetWidgetLoweredState(CPW_CARGO_FIRST + i, !HasBit(this->excluded_data, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -924,7 +924,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
|
|||||||
/* Add all cargos to the excluded lists. */
|
/* Add all cargos to the excluded lists. */
|
||||||
int i = 0;
|
int i = 0;
|
||||||
const CargoSpec *cs;
|
const CargoSpec *cs;
|
||||||
FOR_ALL_SORTED_CARGOSPECS(cs) {
|
FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
|
||||||
SetBit(_legend_excluded_cargo, cs->Index());
|
SetBit(_legend_excluded_cargo, cs->Index());
|
||||||
SetBit(this->excluded_data, i);
|
SetBit(this->excluded_data, i);
|
||||||
i++;
|
i++;
|
||||||
@ -962,7 +962,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
|
|||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
const CargoSpec *cs;
|
const CargoSpec *cs;
|
||||||
FOR_ALL_SORTED_CARGOSPECS(cs) {
|
FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
|
||||||
this->colours[i] = cs->legend_colour;
|
this->colours[i] = cs->legend_colour;
|
||||||
for (uint j = 0; j != 20; j++) {
|
for (uint j = 0; j != 20; j++) {
|
||||||
this->cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 4 + 4, cs->Index());
|
this->cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 4 + 4, cs->Index());
|
||||||
@ -978,14 +978,14 @@ static NWidgetBase *MakeCargoButtons(int *biggest_index)
|
|||||||
{
|
{
|
||||||
NWidgetVertical *ver = new NWidgetVertical;
|
NWidgetVertical *ver = new NWidgetVertical;
|
||||||
|
|
||||||
for (int i = 0; i < _sorted_cargo_specs_size; i++) {
|
for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
|
||||||
NWidgetBackground *leaf = new NWidgetBackground(WWT_PANEL, COLOUR_ORANGE, CPW_CARGO_FIRST + i, NULL);
|
NWidgetBackground *leaf = new NWidgetBackground(WWT_PANEL, COLOUR_ORANGE, CPW_CARGO_FIRST + i, NULL);
|
||||||
leaf->tool_tip = STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO;
|
leaf->tool_tip = STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO;
|
||||||
leaf->SetFill(1, 0);
|
leaf->SetFill(1, 0);
|
||||||
leaf->SetLowered(true);
|
leaf->SetLowered(true);
|
||||||
ver->Add(leaf);
|
ver->Add(leaf);
|
||||||
}
|
}
|
||||||
*biggest_index = CPW_CARGO_FIRST + _sorted_cargo_specs_size - 1;
|
*biggest_index = CPW_CARGO_FIRST + _sorted_standard_cargo_specs_size - 1;
|
||||||
return ver;
|
return ver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1128,7 +1128,7 @@ struct StationViewWindow : public Window {
|
|||||||
y += FONT_HEIGHT_NORMAL;
|
y += FONT_HEIGHT_NORMAL;
|
||||||
|
|
||||||
const CargoSpec *cs;
|
const CargoSpec *cs;
|
||||||
FOR_ALL_SORTED_CARGOSPECS(cs) {
|
FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
|
||||||
const GoodsEntry *ge = &st->goods[cs->Index()];
|
const GoodsEntry *ge = &st->goods[cs->Index()];
|
||||||
if (!HasBit(ge->acceptance_pickup, GoodsEntry::PICKUP)) continue;
|
if (!HasBit(ge->acceptance_pickup, GoodsEntry::PICKUP)) continue;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user