diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -118,11 +118,6 @@ static Foundation GetFoundation_Clear(Ti return FOUNDATION_NONE; } -static void GetAcceptedCargo_Clear(TileIndex tile, AcceptedCargo ac) -{ - /* unused */ -} - static void AnimateTile_Clear(TileIndex tile) { /* unused */ @@ -363,7 +358,7 @@ extern const TileTypeProcs _tile_type_cl DrawTile_Clear, ///< draw_tile_proc GetSlopeZ_Clear, ///< get_slope_z_proc ClearTile_Clear, ///< clear_tile_proc - GetAcceptedCargo_Clear, ///< get_accepted_cargo_proc + NULL, ///< get_accepted_cargo_proc GetTileDesc_Clear, ///< get_tile_desc_proc GetTileTrackStatus_Clear, ///< get_tile_track_status_proc ClickTile_Clear, ///< click_tile_proc diff --git a/src/dummy_land.cpp b/src/dummy_land.cpp --- a/src/dummy_land.cpp +++ b/src/dummy_land.cpp @@ -33,11 +33,6 @@ static CommandCost ClearTile_Dummy(TileI } -static void GetAcceptedCargo_Dummy(TileIndex tile, AcceptedCargo ac) -{ - /* not used */ -} - static void GetTileDesc_Dummy(TileIndex tile, TileDesc *td) { td->str = STR_EMPTY; @@ -79,7 +74,7 @@ extern const TileTypeProcs _tile_type_du DrawTile_Dummy, // draw_tile_proc GetSlopeZ_Dummy, // get_slope_z_proc ClearTile_Dummy, // clear_tile_proc - GetAcceptedCargo_Dummy, // get_accepted_cargo_proc + NULL, // get_accepted_cargo_proc GetTileDesc_Dummy, // get_tile_desc_proc GetTileTrackStatus_Dummy, // get_tile_track_status_proc ClickTile_Dummy, // click_tile_proc diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -354,7 +354,7 @@ static Foundation GetFoundation_Industry return FlatteningFoundation(tileh); } -static void GetAcceptedCargo_Industry(TileIndex tile, AcceptedCargo ac) +static void AddAcceptedCargo_Industry(TileIndex tile, AcceptedCargo ac) { IndustryGfx gfx = GetIndustryGfx(tile); const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx); @@ -385,8 +385,7 @@ static void GetAcceptedCargo_Industry(Ti for (byte i = 0; i < lengthof(itspec->accepts_cargo); i++) { CargoID a = accepts_cargo[i]; - /* Only set the value once. */ - if (a != CT_INVALID && ac[a] == 0) ac[a] = acceptance[i]; + if (a != CT_INVALID) ac[a] += acceptance[i]; } } @@ -2385,7 +2384,7 @@ extern const TileTypeProcs _tile_type_in DrawTile_Industry, // draw_tile_proc GetSlopeZ_Industry, // get_slope_z_proc ClearTile_Industry, // clear_tile_proc - GetAcceptedCargo_Industry, // get_accepted_cargo_proc + AddAcceptedCargo_Industry, // add_accepted_cargo_proc GetTileDesc_Industry, // get_tile_desc_proc GetTileTrackStatus_Industry, // get_tile_track_status_proc ClickTile_Industry, // click_tile_proc diff --git a/src/landscape.cpp b/src/landscape.cpp --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -500,12 +500,6 @@ void ChangeTileOwner(TileIndex tile, Own _tile_type_procs[GetTileType(tile)]->change_tile_owner_proc(tile, old_owner, new_owner); } -void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac) -{ - memset(ac, 0, sizeof(AcceptedCargo)); - _tile_type_procs[GetTileType(tile)]->get_accepted_cargo_proc(tile, ac); -} - void AnimateTile(TileIndex tile) { _tile_type_procs[GetTileType(tile)]->animate_tile_proc(tile); diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -108,7 +108,6 @@ public: /* Because build_date is not set yet in every TileDesc, we make sure it is empty */ TileDesc td; - AcceptedCargo ac; td.build_date = INVALID_DATE; @@ -130,7 +129,9 @@ public: td.grf = NULL; - GetAcceptedCargo(tile, ac); + AcceptedCargo ac; + memset(ac, 0, sizeof(AcceptedCargo)); + AddAcceptedCargo(tile, ac); GetTileDesc(tile, &td); uint line_nr = 0; diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -2074,11 +2074,6 @@ static Foundation GetFoundation_Track(Ti return IsPlainRail(tile) ? GetRailFoundation(tileh, GetTrackBits(tile)) : FlatteningFoundation(tileh); } -static void GetAcceptedCargo_Track(TileIndex tile, AcceptedCargo ac) -{ - /* not used */ -} - static void AnimateTile_Track(TileIndex tile) { /* not used */ @@ -2620,7 +2615,7 @@ extern const TileTypeProcs _tile_type_ra DrawTile_Track, // draw_tile_proc GetSlopeZ_Track, // get_slope_z_proc ClearTile_Track, // clear_tile_proc - GetAcceptedCargo_Track, // get_accepted_cargo_proc + NULL, // get_accepted_cargo_proc GetTileDesc_Track, // get_tile_desc_proc GetTileTrackStatus_Track, // get_tile_track_status_proc ClickTile_Track, // click_tile_proc diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1287,11 +1287,6 @@ static Foundation GetFoundation_Road(Til } } -static void GetAcceptedCargo_Road(TileIndex tile, AcceptedCargo ac) -{ - /* not used */ -} - static void AnimateTile_Road(TileIndex tile) { if (IsLevelCrossing(tile)) MarkTileDirtyByTile(tile); @@ -1637,7 +1632,7 @@ extern const TileTypeProcs _tile_type_ro DrawTile_Road, // draw_tile_proc GetSlopeZ_Road, // get_slope_z_proc ClearTile_Road, // clear_tile_proc - GetAcceptedCargo_Road, // get_accepted_cargo_proc + NULL, // get_accepted_cargo_proc GetTileDesc_Road, // get_tile_desc_proc GetTileTrackStatus_Road, // get_tile_track_status_proc ClickTile_Road, // click_tile_proc diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -524,13 +524,7 @@ void GetAcceptanceAroundTiles(AcceptedCa for (int yc = y1; yc != y2; yc++) { for (int xc = x1; xc != x2; xc++) { TileIndex tile = TileXY(xc, yc); - - if (!IsTileType(tile, MP_STATION)) { - AcceptedCargo ac; - - GetAcceptedCargo(tile, ac); - for (uint i = 0; i < lengthof(ac); ++i) accepts[i] += ac[i]; - } + AddAcceptedCargo(tile, accepts); } } } @@ -2348,11 +2342,6 @@ static Foundation GetFoundation_Station( return FlatteningFoundation(tileh); } -static void GetAcceptedCargo_Station(TileIndex tile, AcceptedCargo ac) -{ - /* not used */ -} - static void GetTileDesc_Station(TileIndex tile, TileDesc *td) { td->owner[0] = GetTileOwner(tile); @@ -3163,7 +3152,7 @@ extern const TileTypeProcs _tile_type_st DrawTile_Station, // draw_tile_proc GetSlopeZ_Station, // get_slope_z_proc ClearTile_Station, // clear_tile_proc - GetAcceptedCargo_Station, // get_accepted_cargo_proc + NULL, // get_accepted_cargo_proc GetTileDesc_Station, // get_tile_desc_proc GetTileTrackStatus_Station, // get_tile_track_status_proc ClickTile_Station, // click_tile_proc diff --git a/src/tile_cmd.h b/src/tile_cmd.h --- a/src/tile_cmd.h +++ b/src/tile_cmd.h @@ -16,6 +16,7 @@ #include "direction_type.h" #include "track_type.h" #include "transport_type.h" +#include "tile_map.h" /** The returned bits of VehicleEnterTile. */ enum VehicleEnterTileStatus { @@ -73,7 +74,7 @@ typedef CommandCost ClearTileProc(TileIn * @param tile Tile queried for its accepted cargo * @param res Storage destination of the cargo accepted */ -typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res); +typedef void AddAcceptedCargoProc(TileIndex tile, AcceptedCargo res); /** * Tile callback function signature for obtaining a tile description @@ -136,7 +137,7 @@ struct TileTypeProcs { DrawTileProc *draw_tile_proc; ///< Called to render the tile and its contents to the screen GetSlopeZProc *get_slope_z_proc; ClearTileProc *clear_tile_proc; - GetAcceptedCargoProc *get_accepted_cargo_proc; ///< Return accepted cargo of the tile + AddAcceptedCargoProc *add_accepted_cargo_proc; ///< Adds accepted cargo of the tile to cargo array supplied as parameter GetTileDescProc *get_tile_desc_proc; ///< Get a description of a tile (for the 'land area information' tool) GetTileTrackStatusProc *get_tile_track_status_proc; ///< Get available tracks and status of a tile ClickTileProc *click_tile_proc; ///< Called when tile is clicked @@ -153,10 +154,16 @@ extern const TileTypeProcs * const _tile TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side = INVALID_DIAGDIR); VehicleEnterTileStatus VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y); -void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac); void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner); void AnimateTile(TileIndex tile); bool ClickTile(TileIndex tile); void GetTileDesc(TileIndex tile, TileDesc *td); +static inline void AddAcceptedCargo(TileIndex tile, AcceptedCargo ac) +{ + AddAcceptedCargoProc *proc = _tile_type_procs[GetTileType(tile)]->add_accepted_cargo_proc; + if (proc == NULL) return; + proc(tile, ac); +} + #endif /* TILE_CMD_H */ diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -569,7 +569,7 @@ static void GetProducedCargo_Town(TileIn } } -static void GetAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac) +static void AddAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac) { const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile)); CargoID accepts[3]; @@ -594,13 +594,13 @@ static void GetAcceptedCargo_Town(TileIn if (HasBit(hs->callback_mask, CBM_HOUSE_CARGO_ACCEPTANCE)) { uint16 callback = GetHouseCallback(CBID_HOUSE_CARGO_ACCEPTANCE, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile); if (callback != CALLBACK_FAILED) { - if (accepts[0] != CT_INVALID) ac[accepts[0]] = GB(callback, 0, 4); - if (accepts[1] != CT_INVALID) ac[accepts[1]] = GB(callback, 4, 4); + if (accepts[0] != CT_INVALID) ac[accepts[0]] += GB(callback, 0, 4); + if (accepts[1] != CT_INVALID) ac[accepts[1]] += GB(callback, 4, 4); if (_settings_game.game_creation.landscape != LT_TEMPERATE && HasBit(callback, 12)) { /* The 'S' bit indicates food instead of goods */ - ac[CT_FOOD] = GB(callback, 8, 4); + ac[CT_FOOD] += GB(callback, 8, 4); } else { - if (accepts[2] != CT_INVALID) ac[accepts[2]] = GB(callback, 8, 4); + if (accepts[2] != CT_INVALID) ac[accepts[2]] += GB(callback, 8, 4); } return; } @@ -608,7 +608,7 @@ static void GetAcceptedCargo_Town(TileIn /* No custom acceptance, so fill in with the default values */ 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) ac[accepts[i]] += hs->cargo_acceptance[i]; } } @@ -2883,7 +2883,7 @@ extern const TileTypeProcs _tile_type_to DrawTile_Town, // draw_tile_proc GetSlopeZ_Town, // get_slope_z_proc ClearTile_Town, // clear_tile_proc - GetAcceptedCargo_Town, // get_accepted_cargo_proc + AddAcceptedCargo_Town, // add_accepted_cargo_proc GetTileDesc_Town, // get_tile_desc_proc GetTileTrackStatus_Town, // get_tile_track_status_proc ClickTile_Town, // click_tile_proc diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -544,11 +544,6 @@ static CommandCost ClearTile_Trees(TileI return CommandCost(EXPENSES_CONSTRUCTION, num * _price.remove_trees); } -static void GetAcceptedCargo_Trees(TileIndex tile, AcceptedCargo ac) -{ - /* not used */ -} - static void GetTileDesc_Trees(TileIndex tile, TileDesc *td) { TreeType tt = GetTreeType(tile); @@ -773,7 +768,7 @@ extern const TileTypeProcs _tile_type_tr DrawTile_Trees, // draw_tile_proc GetSlopeZ_Trees, // get_slope_z_proc ClearTile_Trees, // clear_tile_proc - GetAcceptedCargo_Trees, // get_accepted_cargo_proc + NULL, // get_accepted_cargo_proc GetTileDesc_Trees, // get_tile_desc_proc GetTileTrackStatus_Trees, // get_tile_track_status_proc ClickTile_Trees, // click_tile_proc diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -1247,12 +1247,6 @@ static Foundation GetFoundation_TunnelBr return IsTunnel(tile) ? FOUNDATION_NONE : GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(tile))); } - -static void GetAcceptedCargo_TunnelBridge(TileIndex tile, AcceptedCargo ac) -{ - /* not used */ -} - static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc *td) { TransportType tt = GetTunnelBridgeTransportType(tile); @@ -1546,7 +1540,7 @@ extern const TileTypeProcs _tile_type_tu DrawTile_TunnelBridge, // draw_tile_proc GetSlopeZ_TunnelBridge, // get_slope_z_proc ClearTile_TunnelBridge, // clear_tile_proc - GetAcceptedCargo_TunnelBridge, // get_accepted_cargo_proc + NULL, // get_accepted_cargo_proc GetTileDesc_TunnelBridge, // get_tile_desc_proc GetTileTrackStatus_TunnelBridge, // get_tile_track_status_proc ClickTile_TunnelBridge, // click_tile_proc diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp --- a/src/unmovable_cmd.cpp +++ b/src/unmovable_cmd.cpp @@ -291,7 +291,7 @@ static CommandCost ClearTile_Unmovable(T return CommandCost(); } -static void GetAcceptedCargo_Unmovable(TileIndex tile, AcceptedCargo ac) +static void AddAcceptedCargo_Unmovable(TileIndex tile, AcceptedCargo ac) { if (!IsCompanyHQ(tile)) return; @@ -303,13 +303,13 @@ static void GetAcceptedCargo_Unmovable(T /* Top town building generates 10, so to make HQ interesting, the top * type makes 20. */ - ac[CT_PASSENGERS] = max(1U, level); + ac[CT_PASSENGERS] += max(1U, level); /* Top town building generates 4, HQ can make up to 8. The * proportion passengers:mail is different because such a huge * commercial building generates unusually high amount of mail * correspondence per physical visitor. */ - ac[CT_MAIL] = max(1U, level / 2); + ac[CT_MAIL] += max(1U, level / 2); } @@ -501,7 +501,7 @@ extern const TileTypeProcs _tile_type_un DrawTile_Unmovable, // draw_tile_proc GetSlopeZ_Unmovable, // get_slope_z_proc ClearTile_Unmovable, // clear_tile_proc - GetAcceptedCargo_Unmovable, // get_accepted_cargo_proc + AddAcceptedCargo_Unmovable, // add_accepted_cargo_proc GetTileDesc_Unmovable, // get_tile_desc_proc GetTileTrackStatus_Unmovable, // get_tile_track_status_proc ClickTile_Unmovable, // click_tile_proc diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -682,11 +682,6 @@ static Foundation GetFoundation_Water(Ti return FOUNDATION_NONE; } -static void GetAcceptedCargo_Water(TileIndex tile, AcceptedCargo ac) -{ - /* not used */ -} - static void GetTileDesc_Water(TileIndex tile, TileDesc *td) { switch (GetWaterTileType(tile)) { @@ -1160,7 +1155,7 @@ extern const TileTypeProcs _tile_type_wa DrawTile_Water, // draw_tile_proc GetSlopeZ_Water, // get_slope_z_proc ClearTile_Water, // clear_tile_proc - GetAcceptedCargo_Water, // get_accepted_cargo_proc + NULL, // get_accepted_cargo_proc GetTileDesc_Water, // get_tile_desc_proc GetTileTrackStatus_Water, // get_tile_track_status_proc ClickTile_Water, // click_tile_proc