mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r16659) -Codechange: rename GetAcceptedCargo() to AddAcceptedCargo() and change its behaviour accordingly
-Codechange: remove dummy GetAcceptedCargo_*() handlers
This commit is contained in:
parent
103bff508b
commit
c30a87758f
@ -118,11 +118,6 @@ static Foundation GetFoundation_Clear(TileIndex tile, Slope tileh)
|
||||
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_clear_procs = {
|
||||
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
|
||||
|
@ -33,11 +33,6 @@ static CommandCost ClearTile_Dummy(TileIndex tile, DoCommandFlag flags)
|
||||
}
|
||||
|
||||
|
||||
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_dummy_procs = {
|
||||
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
|
||||
|
@ -354,7 +354,7 @@ static Foundation GetFoundation_Industry(TileIndex tile, Slope tileh)
|
||||
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(TileIndex tile, AcceptedCargo ac)
|
||||
|
||||
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_industry_procs = {
|
||||
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
|
||||
|
@ -500,12 +500,6 @@ void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner)
|
||||
_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);
|
||||
|
@ -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;
|
||||
|
@ -2074,11 +2074,6 @@ static Foundation GetFoundation_Track(TileIndex tile, Slope tileh)
|
||||
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_rail_procs = {
|
||||
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
|
||||
|
@ -1287,11 +1287,6 @@ static Foundation GetFoundation_Road(TileIndex tile, Slope tileh)
|
||||
}
|
||||
}
|
||||
|
||||
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_road_procs = {
|
||||
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
|
||||
|
@ -524,13 +524,7 @@ void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile,
|
||||
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(TileIndex tile, Slope tileh)
|
||||
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_station_procs = {
|
||||
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
|
||||
|
@ -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(TileIndex tile, DoCommandFlag flags);
|
||||
* @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_type_procs[16];
|
||||
|
||||
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 */
|
||||
|
@ -569,7 +569,7 @@ static void GetProducedCargo_Town(TileIndex tile, CargoID *b)
|
||||
}
|
||||
}
|
||||
|
||||
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(TileIndex tile, AcceptedCargo ac)
|
||||
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(TileIndex tile, AcceptedCargo ac)
|
||||
|
||||
/* 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_town_procs = {
|
||||
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
|
||||
|
@ -544,11 +544,6 @@ static CommandCost ClearTile_Trees(TileIndex tile, DoCommandFlag flags)
|
||||
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_trees_procs = {
|
||||
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
|
||||
|
@ -1247,12 +1247,6 @@ static Foundation GetFoundation_TunnelBridge(TileIndex tile, Slope tileh)
|
||||
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_tunnelbridge_procs = {
|
||||
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
|
||||
|
@ -291,7 +291,7 @@ static CommandCost ClearTile_Unmovable(TileIndex tile, DoCommandFlag flags)
|
||||
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(TileIndex tile, AcceptedCargo ac)
|
||||
|
||||
/* 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_unmovable_procs = {
|
||||
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
|
||||
|
@ -682,11 +682,6 @@ static Foundation GetFoundation_Water(TileIndex tile, Slope tileh)
|
||||
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_water_procs = {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user