(svn r16676) -Codechange: Rename AcceptedCargo to CargoArray and its instances to more meaningful names.

pull/155/head
frosch 15 years ago
parent 415c575fe5
commit 4c3f480f92

@ -179,16 +179,16 @@
{ {
if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius <= 0) return -1; if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius <= 0) return -1;
AcceptedCargo accepts; CargoArray acceptance;
::GetAcceptanceAroundTiles(accepts, tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED); ::GetAcceptanceAroundTiles(acceptance, tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED);
return accepts[cargo_type]; return acceptance[cargo_type];
} }
/* static */ int32 AITile::GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius) /* static */ int32 AITile::GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius)
{ {
if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius <= 0) return -1; if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius <= 0) return -1;
AcceptedCargo produced; CargoArray produced;
::GetProductionAroundTiles(produced, tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED); ::GetProductionAroundTiles(produced, tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED);
return produced[cargo_type]; return produced[cargo_type];
} }

@ -92,12 +92,12 @@ AITileList_IndustryAccepting::AITileList_IndustryAccepting(IndustryID industry_i
/* Only add the tile if it accepts the cargo (sometimes just 1 tile of an /* Only add the tile if it accepts the cargo (sometimes just 1 tile of an
* industry triggers the acceptance). */ * industry triggers the acceptance). */
AcceptedCargo accepts; CargoArray acceptance;
::GetAcceptanceAroundTiles(accepts, cur_tile, 1, 1, radius); ::GetAcceptanceAroundTiles(acceptance, cur_tile, 1, 1, radius);
{ {
bool cargo_accepts = false; bool cargo_accepts = false;
for (byte j = 0; j < lengthof(i->accepts_cargo); j++) { for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
if (i->accepts_cargo[j] != CT_INVALID && accepts[i->accepts_cargo[j]] != 0) cargo_accepts = true; if (i->accepts_cargo[j] != CT_INVALID && acceptance[i->accepts_cargo[j]] != 0) cargo_accepts = true;
} }
if (!cargo_accepts) continue; if (!cargo_accepts) continue;
} }
@ -130,12 +130,12 @@ AITileList_IndustryProducing::AITileList_IndustryProducing(IndustryID industry_i
/* Only add the tile if it produces the cargo (a bug in OpenTTD makes this /* Only add the tile if it produces the cargo (a bug in OpenTTD makes this
* inconsitance). */ * inconsitance). */
AcceptedCargo produces; CargoArray produced;
::GetProductionAroundTiles(produces, cur_tile, 1, 1, radius); ::GetProductionAroundTiles(produced, cur_tile, 1, 1, radius);
{ {
bool cargo_produces = false; bool cargo_produces = false;
for (byte j = 0; j < lengthof(i->produced_cargo); j++) { for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
if (i->produced_cargo[j] != CT_INVALID && produces[i->produced_cargo[j]] != 0) cargo_produces = true; if (i->produced_cargo[j] != CT_INVALID && produced[i->produced_cargo[j]] != 0) cargo_produces = true;
} }
if (!cargo_produces) continue; if (!cargo_produces) continue;
} }

@ -55,7 +55,7 @@ enum CargoTypes {
CT_INVALID = 0xFF CT_INVALID = 0xFF
}; };
/** Array for storing amounts of accepted cargo */ /** Array for storing amounts of cargo */
typedef uint AcceptedCargo[NUM_CARGO]; typedef uint CargoArray[NUM_CARGO];
#endif /* CARGO_TYPE_H */ #endif /* CARGO_TYPE_H */

@ -847,7 +847,7 @@ struct DepotWindow : Window {
if (this->type == VEH_TRAIN) v = gdvp.wagon; if (this->type == VEH_TRAIN) v = gdvp.wagon;
if (v != NULL && mode == MODE_DRAG_VEHICLE) { if (v != NULL && mode == MODE_DRAG_VEHICLE) {
AcceptedCargo capacity, loaded; CargoArray capacity, loaded;
memset(capacity, 0, sizeof(capacity)); memset(capacity, 0, sizeof(capacity));
memset(loaded, 0, sizeof(loaded)); memset(loaded, 0, sizeof(loaded));

@ -380,18 +380,18 @@ static Foundation GetFoundation_Industry(TileIndex tile, Slope tileh)
return FlatteningFoundation(tileh); return FlatteningFoundation(tileh);
} }
static void AddAcceptedCargo_Industry(TileIndex tile, AcceptedCargo ac) static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray acceptance)
{ {
IndustryGfx gfx = GetIndustryGfx(tile); IndustryGfx gfx = GetIndustryGfx(tile);
const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx); const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx);
/* When we have to use a callback, we put our data in the next two variables */ /* When we have to use a callback, we put our data in the next two variables */
CargoID raw_accepts_cargo[lengthof(itspec->accepts_cargo)]; CargoID raw_accepts_cargo[lengthof(itspec->accepts_cargo)];
uint8 raw_acceptance[lengthof(itspec->acceptance)]; uint8 raw_cargo_acceptance[lengthof(itspec->acceptance)];
/* And then these will always point to a same sized array with the required data */ /* And then these will always point to a same sized array with the required data */
const CargoID *accepts_cargo = itspec->accepts_cargo; const CargoID *accepts_cargo = itspec->accepts_cargo;
const uint8 *acceptance = itspec->acceptance; const uint8 *cargo_acceptance = itspec->acceptance;
if (HasBit(itspec->callback_flags, CBM_INDT_ACCEPT_CARGO)) { if (HasBit(itspec->callback_flags, CBM_INDT_ACCEPT_CARGO)) {
uint16 res = GetIndustryTileCallback(CBID_INDTILE_ACCEPT_CARGO, 0, 0, gfx, GetIndustryByTile(tile), tile); uint16 res = GetIndustryTileCallback(CBID_INDTILE_ACCEPT_CARGO, 0, 0, gfx, GetIndustryByTile(tile), tile);
@ -404,14 +404,14 @@ static void AddAcceptedCargo_Industry(TileIndex tile, AcceptedCargo ac)
if (HasBit(itspec->callback_flags, CBM_INDT_CARGO_ACCEPTANCE)) { if (HasBit(itspec->callback_flags, CBM_INDT_CARGO_ACCEPTANCE)) {
uint16 res = GetIndustryTileCallback(CBID_INDTILE_CARGO_ACCEPTANCE, 0, 0, gfx, GetIndustryByTile(tile), tile); uint16 res = GetIndustryTileCallback(CBID_INDTILE_CARGO_ACCEPTANCE, 0, 0, gfx, GetIndustryByTile(tile), tile);
if (res != CALLBACK_FAILED) { if (res != CALLBACK_FAILED) {
acceptance = raw_acceptance; cargo_acceptance = raw_cargo_acceptance;
for (uint i = 0; i < lengthof(itspec->accepts_cargo); i++) raw_acceptance[i] = GB(res, i * 4, 4); for (uint i = 0; i < lengthof(itspec->accepts_cargo); i++) raw_cargo_acceptance[i] = GB(res, i * 4, 4);
} }
} }
for (byte i = 0; i < lengthof(itspec->accepts_cargo); i++) { for (byte i = 0; i < lengthof(itspec->accepts_cargo); i++) {
CargoID a = accepts_cargo[i]; CargoID a = accepts_cargo[i];
if (a != CT_INVALID) ac[a] += acceptance[i]; if (a != CT_INVALID) acceptance[a] += cargo_acceptance[i];
} }
} }
@ -868,13 +868,13 @@ static TrackStatus GetTileTrackStatus_Industry(TileIndex tile, TransportType mod
return 0; return 0;
} }
static void AddProducedCargo_Industry(TileIndex tile, AcceptedCargo ac) static void AddProducedCargo_Industry(TileIndex tile, CargoArray produced)
{ {
const Industry *i = GetIndustryByTile(tile); const Industry *i = GetIndustryByTile(tile);
for (uint j = 0; j < lengthof(i->produced_cargo); j++) { for (uint j = 0; j < lengthof(i->produced_cargo); j++) {
CargoID cargo = i->produced_cargo[j]; CargoID cargo = i->produced_cargo[j];
if (cargo != CT_INVALID) ac[cargo]++; if (cargo != CT_INVALID) produced[cargo]++;
} }
} }

@ -129,9 +129,9 @@ public:
td.grf = NULL; td.grf = NULL;
AcceptedCargo ac; CargoArray acceptance;
memset(ac, 0, sizeof(AcceptedCargo)); memset(acceptance, 0, sizeof(CargoArray));
AddAcceptedCargo(tile, ac); AddAcceptedCargo(tile, acceptance);
GetTileDesc(tile, &td); GetTileDesc(tile, &td);
uint line_nr = 0; uint line_nr = 0;
@ -230,7 +230,7 @@ public:
bool found = false; bool found = false;
for (CargoID i = 0; i < NUM_CARGO; ++i) { for (CargoID i = 0; i < NUM_CARGO; ++i) {
if (ac[i] > 0) { if (acceptance[i] > 0) {
/* Add a comma between each item. */ /* Add a comma between each item. */
if (found) { if (found) {
*strp++ = ','; *strp++ = ',';
@ -239,8 +239,8 @@ public:
found = true; found = true;
/* If the accepted value is less than 8, show it in 1/8:ths */ /* If the accepted value is less than 8, show it in 1/8:ths */
if (ac[i] < 8) { if (acceptance[i] < 8) {
SetDParam(0, ac[i]); SetDParam(0, acceptance[i]);
SetDParam(1, GetCargo(i)->name); SetDParam(1, GetCargo(i)->name);
strp = GetString(strp, STR_LAND_AREA_INFORMATION_CARGO_EIGHTS, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE])); strp = GetString(strp, STR_LAND_AREA_INFORMATION_CARGO_EIGHTS, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
} else { } else {
@ -811,7 +811,7 @@ void GuiShowTooltips(StringID str, uint paramcount, const uint64 params[], bool
} }
static int DrawStationCoverageText(const AcceptedCargo cargo, static int DrawStationCoverageText(const CargoArray cargos,
int str_x, int str_y, StationCoverageType sct, bool supplies) int str_x, int str_y, StationCoverageType sct, bool supplies)
{ {
bool first = true; bool first = true;
@ -827,7 +827,7 @@ static int DrawStationCoverageText(const AcceptedCargo cargo,
case SCT_ALL: break; case SCT_ALL: break;
default: NOT_REACHED(); default: NOT_REACHED();
} }
if (cargo[i] >= (supplies ? 1U : 8U)) { if (cargos[i] >= (supplies ? 1U : 8U)) {
if (first) { if (first) {
first = false; first = false;
} else { } else {
@ -863,14 +863,14 @@ static int DrawStationCoverageText(const AcceptedCargo cargo,
int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies) int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies)
{ {
TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y); TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y);
AcceptedCargo cargo; CargoArray cargos;
if (tile < MapSize()) { if (tile < MapSize()) {
if (supplies) { if (supplies) {
GetProductionAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad); GetProductionAroundTiles(cargos, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
} else { } else {
GetAcceptanceAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad); GetAcceptanceAroundTiles(cargos, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
} }
return DrawStationCoverageText(cargo, sx, sy, sct, supplies); return DrawStationCoverageText(cargos, sx, sy, sct, supplies);
} }
return sy; return sy;

@ -34,7 +34,7 @@ void DrawRoadVehDetails(const Vehicle *v, int left, int right, int y)
DrawString(left, right, y + y_offset, STR_VEHICLE_INFO_BUILT_VALUE); DrawString(left, right, y + y_offset, STR_VEHICLE_INFO_BUILT_VALUE);
if (RoadVehHasArticPart(v)) { if (RoadVehHasArticPart(v)) {
AcceptedCargo max_cargo; CargoArray max_cargo;
StringID subtype_text[NUM_CARGO]; StringID subtype_text[NUM_CARGO];
char capacity[512]; char capacity[512];

@ -441,10 +441,10 @@ static void ShowRejectOrAcceptNews(const Station *st, uint num_items, CargoID *c
* @param h Y extent of the area * @param h Y extent of the area
* @param rad Search radius in addition to the given area * @param rad Search radius in addition to the given area
*/ */
void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, void GetProductionAroundTiles(CargoArray produced, TileIndex tile,
int w, int h, int rad) int w, int h, int rad)
{ {
memset(produced, 0, sizeof(AcceptedCargo)); // sizeof(AcceptedCargo) != sizeof(produced) (== sizeof(uint *)) memset(produced, 0, sizeof(CargoArray)); // sizeof(CargoArray) != sizeof(produced) (== sizeof(uint *))
int x = TileX(tile); int x = TileX(tile);
int y = TileY(tile); int y = TileY(tile);
@ -478,10 +478,10 @@ void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile,
* @param h Y extent of area * @param h Y extent of area
* @param rad Search radius in addition to given area * @param rad Search radius in addition to given area
*/ */
void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, void GetAcceptanceAroundTiles(CargoArray acceptance, TileIndex tile,
int w, int h, int rad) int w, int h, int rad)
{ {
memset(accepts, 0, sizeof(AcceptedCargo)); // sizeof(AcceptedCargo) != sizeof(accepts) (== sizeof(uint *)) memset(acceptance, 0, sizeof(CargoArray)); // sizeof(CargoArray) != sizeof(acceptance) (== sizeof(uint *))
int x = TileX(tile); int x = TileX(tile);
int y = TileY(tile); int y = TileY(tile);
@ -501,7 +501,7 @@ void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile,
for (int yc = y1; yc != y2; yc++) { for (int yc = y1; yc != y2; yc++) {
for (int xc = x1; xc != x2; xc++) { for (int xc = x1; xc != x2; xc++) {
TileIndex tile = TileXY(xc, yc); TileIndex tile = TileXY(xc, yc);
AddAcceptedCargo(tile, accepts); AddAcceptedCargo(tile, acceptance);
} }
} }
} }
@ -519,22 +519,22 @@ static void UpdateStationAcceptance(Station *st, bool show_msg)
uint old_acc = GetAcceptanceMask(st); uint old_acc = GetAcceptanceMask(st);
/* And retrieve the acceptance. */ /* And retrieve the acceptance. */
AcceptedCargo accepts; CargoArray acceptance;
if (!st->rect.IsEmpty()) { if (!st->rect.IsEmpty()) {
GetAcceptanceAroundTiles( GetAcceptanceAroundTiles(
accepts, acceptance,
TileXY(st->rect.left, st->rect.top), TileXY(st->rect.left, st->rect.top),
st->rect.right - st->rect.left + 1, st->rect.right - st->rect.left + 1,
st->rect.bottom - st->rect.top + 1, st->rect.bottom - st->rect.top + 1,
st->GetCatchmentRadius() st->GetCatchmentRadius()
); );
} else { } else {
memset(accepts, 0, sizeof(accepts)); memset(acceptance, 0, sizeof(acceptance));
} }
/* Adjust in case our station only accepts fewer kinds of goods */ /* Adjust in case our station only accepts fewer kinds of goods */
for (CargoID i = 0; i < NUM_CARGO; i++) { for (CargoID i = 0; i < NUM_CARGO; i++) {
uint amt = min(accepts[i], 15); uint amt = min(acceptance[i], 15);
/* Make sure the station can accept the goods type. */ /* Make sure the station can accept the goods type. */
bool is_passengers = IsCargoInClass(i, CC_PASSENGERS); bool is_passengers = IsCargoInClass(i, CC_PASSENGERS);

@ -22,8 +22,8 @@ void FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod, StationList
void ShowStationViewWindow(StationID station); void ShowStationViewWindow(StationID station);
void UpdateAllStationVirtCoord(); void UpdateAllStationVirtCoord();
void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, int w, int h, int rad); void GetProductionAroundTiles(CargoArray produced, TileIndex tile, int w, int h, int rad);
void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad); void GetAcceptanceAroundTiles(CargoArray acceptance, TileIndex tile, int w, int h, int rad);
const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx); const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx);
void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image); void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image);

@ -70,11 +70,11 @@ typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y);
typedef CommandCost ClearTileProc(TileIndex tile, DoCommandFlag flags); typedef CommandCost ClearTileProc(TileIndex tile, DoCommandFlag flags);
/** /**
* Tile callback function signature for obtaining accepted cargo of a tile * Tile callback function signature for obtaining cargo acceptance of a tile
* @param tile Tile queried for its accepted cargo * @param tile Tile queried for its accepted cargo
* @param res Storage destination of the cargo accepted * @param acceptance Storage destination of the cargo acceptance in 1/8
*/ */
typedef void AddAcceptedCargoProc(TileIndex tile, AcceptedCargo res); typedef void AddAcceptedCargoProc(TileIndex tile, CargoArray acceptance);
/** /**
* Tile callback function signature for obtaining a tile description * Tile callback function signature for obtaining a tile description
@ -100,10 +100,10 @@ typedef TrackStatus GetTileTrackStatusProc(TileIndex tile, TransportType mode, u
/** /**
* Tile callback function signature for obtaining the produced cargo of a tile. * Tile callback function signature for obtaining the produced cargo of a tile.
* @param tile Tile being queried * @param tile Tile being queried
* @param b Destination array of produced cargo * @param produced Destination array for produced cargo
*/ */
typedef void AddProducedCargoProc(TileIndex tile, AcceptedCargo ac); typedef void AddProducedCargoProc(TileIndex tile, CargoArray produced);
typedef bool ClickTileProc(TileIndex tile); typedef bool ClickTileProc(TileIndex tile);
typedef void AnimateTileProc(TileIndex tile); typedef void AnimateTileProc(TileIndex tile);
typedef void TileLoopProc(TileIndex tile); typedef void TileLoopProc(TileIndex tile);
@ -157,18 +157,18 @@ VehicleEnterTileStatus VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner); void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner);
void GetTileDesc(TileIndex tile, TileDesc *td); void GetTileDesc(TileIndex tile, TileDesc *td);
static inline void AddAcceptedCargo(TileIndex tile, AcceptedCargo ac) static inline void AddAcceptedCargo(TileIndex tile, CargoArray acceptance)
{ {
AddAcceptedCargoProc *proc = _tile_type_procs[GetTileType(tile)]->add_accepted_cargo_proc; AddAcceptedCargoProc *proc = _tile_type_procs[GetTileType(tile)]->add_accepted_cargo_proc;
if (proc == NULL) return; if (proc == NULL) return;
proc(tile, ac); proc(tile, acceptance);
} }
static inline void AddProducedCargo(TileIndex tile, AcceptedCargo ac) static inline void AddProducedCargo(TileIndex tile, CargoArray produced)
{ {
AddProducedCargoProc *proc = _tile_type_procs[GetTileType(tile)]->add_produced_cargo_proc; AddProducedCargoProc *proc = _tile_type_procs[GetTileType(tile)]->add_produced_cargo_proc;
if (proc == NULL) return; if (proc == NULL) return;
proc(tile, ac); proc(tile, produced);
} }
static inline void AnimateTile(TileIndex tile) static inline void AnimateTile(TileIndex tile)

@ -555,7 +555,7 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlag flags)
return cost; return cost;
} }
static void AddProducedCargo_Town(TileIndex tile, AcceptedCargo ac) static void AddProducedCargo_Town(TileIndex tile, CargoArray produced)
{ {
HouseID house_id = GetHouseType(tile); HouseID house_id = GetHouseType(tile);
const HouseSpec *hs = HouseSpec::Get(house_id); const HouseSpec *hs = HouseSpec::Get(house_id);
@ -570,19 +570,19 @@ static void AddProducedCargo_Town(TileIndex tile, AcceptedCargo ac)
CargoID cargo = GetCargoTranslation(GB(callback, 8, 7), hs->grffile); CargoID cargo = GetCargoTranslation(GB(callback, 8, 7), hs->grffile);
if (cargo == CT_INVALID) continue; if (cargo == CT_INVALID) continue;
ac[cargo]++; produced[cargo]++;
} }
} else { } else {
if (hs->population > 0) { if (hs->population > 0) {
ac[CT_PASSENGERS]++; produced[CT_PASSENGERS]++;
} }
if (hs->mail_generation > 0) { if (hs->mail_generation > 0) {
ac[CT_MAIL]++; produced[CT_MAIL]++;
} }
} }
} }
static void AddAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac) static void AddAcceptedCargo_Town(TileIndex tile, CargoArray acceptance)
{ {
const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile)); const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile));
CargoID accepts[3]; CargoID accepts[3];
@ -607,13 +607,13 @@ static void AddAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
if (HasBit(hs->callback_mask, CBM_HOUSE_CARGO_ACCEPTANCE)) { if (HasBit(hs->callback_mask, CBM_HOUSE_CARGO_ACCEPTANCE)) {
uint16 callback = GetHouseCallback(CBID_HOUSE_CARGO_ACCEPTANCE, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile); uint16 callback = GetHouseCallback(CBID_HOUSE_CARGO_ACCEPTANCE, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
if (callback != CALLBACK_FAILED) { if (callback != CALLBACK_FAILED) {
if (accepts[0] != CT_INVALID) ac[accepts[0]] += GB(callback, 0, 4); if (accepts[0] != CT_INVALID) acceptance[accepts[0]] += GB(callback, 0, 4);
if (accepts[1] != CT_INVALID) ac[accepts[1]] += GB(callback, 4, 4); if (accepts[1] != CT_INVALID) acceptance[accepts[1]] += GB(callback, 4, 4);
if (_settings_game.game_creation.landscape != LT_TEMPERATE && HasBit(callback, 12)) { if (_settings_game.game_creation.landscape != LT_TEMPERATE && HasBit(callback, 12)) {
/* The 'S' bit indicates food instead of goods */ /* The 'S' bit indicates food instead of goods */
ac[CT_FOOD] += GB(callback, 8, 4); acceptance[CT_FOOD] += GB(callback, 8, 4);
} else { } else {
if (accepts[2] != CT_INVALID) ac[accepts[2]] += GB(callback, 8, 4); if (accepts[2] != CT_INVALID) acceptance[accepts[2]] += GB(callback, 8, 4);
} }
return; return;
} }
@ -621,7 +621,7 @@ static void AddAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
/* No custom acceptance, so fill in with the default values */ /* No custom acceptance, so fill in with the default values */
for (uint8 i = 0; i < lengthof(accepts); i++) { for (uint8 i = 0; i < lengthof(accepts); i++) {
if (accepts[i] != CT_INVALID) ac[accepts[i]] += hs->cargo_acceptance[i]; if (accepts[i] != CT_INVALID) acceptance[accepts[i]] += hs->cargo_acceptance[i];
} }
} }

@ -182,8 +182,8 @@ static void TrainDetailsCapacityTab(const Vehicle *v, int left, int right, int y
*/ */
int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab) int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
{ {
AcceptedCargo act_cargo; CargoArray act_cargo;
AcceptedCargo max_cargo; CargoArray max_cargo;
int num = 0; int num = 0;
if (det_tab == TDW_TAB_TOTALS) { // Total cargo tab if (det_tab == TDW_TAB_TOTALS) { // Total cargo tab
@ -272,8 +272,8 @@ void DrawTrainDetails(const Vehicle *v, int left, int right, int y, int vscroll_
if (v == NULL) return; if (v == NULL) return;
} }
} else { } else {
AcceptedCargo act_cargo; CargoArray act_cargo;
AcceptedCargo max_cargo; CargoArray max_cargo;
Money feeder_share = 0; Money feeder_share = 0;
memset(max_cargo, 0, sizeof(max_cargo)); memset(max_cargo, 0, sizeof(max_cargo));

@ -291,7 +291,7 @@ static CommandCost ClearTile_Unmovable(TileIndex tile, DoCommandFlag flags)
return CommandCost(); return CommandCost();
} }
static void AddAcceptedCargo_Unmovable(TileIndex tile, AcceptedCargo ac) static void AddAcceptedCargo_Unmovable(TileIndex tile, CargoArray acceptance)
{ {
if (!IsCompanyHQ(tile)) return; if (!IsCompanyHQ(tile)) return;
@ -303,13 +303,13 @@ static void AddAcceptedCargo_Unmovable(TileIndex tile, AcceptedCargo ac)
/* Top town building generates 10, so to make HQ interesting, the top /* Top town building generates 10, so to make HQ interesting, the top
* type makes 20. */ * type makes 20. */
ac[CT_PASSENGERS] += max(1U, level); acceptance[CT_PASSENGERS] += max(1U, level);
/* Top town building generates 4, HQ can make up to 8. The /* Top town building generates 4, HQ can make up to 8. The
* proportion passengers:mail is different because such a huge * proportion passengers:mail is different because such a huge
* commercial building generates unusually high amount of mail * commercial building generates unusually high amount of mail
* correspondence per physical visitor. */ * correspondence per physical visitor. */
ac[CT_MAIL] += max(1U, level / 2); acceptance[CT_MAIL] += max(1U, level / 2);
} }

@ -576,7 +576,7 @@ static int CDECL VehicleProfitLastYearSorter(const Vehicle * const *a, const Veh
static int CDECL VehicleCargoSorter(const Vehicle * const *a, const Vehicle * const *b) static int CDECL VehicleCargoSorter(const Vehicle * const *a, const Vehicle * const *b)
{ {
const Vehicle *v; const Vehicle *v;
AcceptedCargo diff; CargoArray diff;
memset(diff, 0, sizeof(diff)); memset(diff, 0, sizeof(diff));
/* Append the cargo of the connected weagons */ /* Append the cargo of the connected weagons */

Loading…
Cancel
Save