mirror of https://github.com/OpenTTD/OpenTTD
(svn r16673) -Codechange: rename GetProducedCargo() to AddProducedCargo() and change its behaviour accordingly
parent
996e5eea47
commit
50b5678e26
|
@ -354,7 +354,7 @@ extern const TileTypeProcs _tile_type_clear_procs = {
|
||||||
NULL, ///< animate_tile_proc
|
NULL, ///< animate_tile_proc
|
||||||
TileLoop_Clear, ///< tile_loop_clear
|
TileLoop_Clear, ///< tile_loop_clear
|
||||||
ChangeTileOwner_Clear, ///< change_tile_owner_clear
|
ChangeTileOwner_Clear, ///< change_tile_owner_clear
|
||||||
NULL, ///< get_produced_cargo_proc
|
NULL, ///< add_produced_cargo_proc
|
||||||
NULL, ///< vehicle_enter_tile_proc
|
NULL, ///< vehicle_enter_tile_proc
|
||||||
GetFoundation_Clear, ///< get_foundation_proc
|
GetFoundation_Clear, ///< get_foundation_proc
|
||||||
TerraformTile_Clear, ///< terraform_tile_proc
|
TerraformTile_Clear, ///< terraform_tile_proc
|
||||||
|
|
|
@ -70,7 +70,7 @@ extern const TileTypeProcs _tile_type_dummy_procs = {
|
||||||
NULL, // animate_tile_proc
|
NULL, // animate_tile_proc
|
||||||
TileLoop_Dummy, // tile_loop_clear
|
TileLoop_Dummy, // tile_loop_clear
|
||||||
ChangeTileOwner_Dummy, // change_tile_owner_clear
|
ChangeTileOwner_Dummy, // change_tile_owner_clear
|
||||||
NULL, // get_produced_cargo_proc
|
NULL, // add_produced_cargo_proc
|
||||||
NULL, // vehicle_enter_tile_proc
|
NULL, // vehicle_enter_tile_proc
|
||||||
GetFoundation_Dummy, // get_foundation_proc
|
GetFoundation_Dummy, // get_foundation_proc
|
||||||
TerraformTile_Dummy, // terraform_tile_proc
|
TerraformTile_Dummy, // terraform_tile_proc
|
||||||
|
|
|
@ -868,12 +868,14 @@ static TrackStatus GetTileTrackStatus_Industry(TileIndex tile, TransportType mod
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GetProducedCargo_Industry(TileIndex tile, CargoID *b)
|
static void AddProducedCargo_Industry(TileIndex tile, AcceptedCargo ac)
|
||||||
{
|
{
|
||||||
const Industry *i = GetIndustryByTile(tile);
|
const Industry *i = GetIndustryByTile(tile);
|
||||||
|
|
||||||
b[0] = i->produced_cargo[0];
|
for (uint j = 0; j < lengthof(i->produced_cargo); j++) {
|
||||||
b[1] = i->produced_cargo[1];
|
CargoID cargo = i->produced_cargo[j];
|
||||||
|
if (cargo != CT_INVALID) ac[cargo]++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ChangeTileOwner_Industry(TileIndex tile, Owner old_owner, Owner new_owner)
|
static void ChangeTileOwner_Industry(TileIndex tile, Owner old_owner, Owner new_owner)
|
||||||
|
@ -2417,7 +2419,7 @@ extern const TileTypeProcs _tile_type_industry_procs = {
|
||||||
AnimateTile_Industry, // animate_tile_proc
|
AnimateTile_Industry, // animate_tile_proc
|
||||||
TileLoop_Industry, // tile_loop_proc
|
TileLoop_Industry, // tile_loop_proc
|
||||||
ChangeTileOwner_Industry, // change_tile_owner_proc
|
ChangeTileOwner_Industry, // change_tile_owner_proc
|
||||||
GetProducedCargo_Industry, // get_produced_cargo_proc
|
AddProducedCargo_Industry, // add_produced_cargo_proc
|
||||||
NULL, // vehicle_enter_tile_proc
|
NULL, // vehicle_enter_tile_proc
|
||||||
GetFoundation_Industry, // get_foundation_proc
|
GetFoundation_Industry, // get_foundation_proc
|
||||||
TerraformTile_Industry, // terraform_tile_proc
|
TerraformTile_Industry, // terraform_tile_proc
|
||||||
|
|
|
@ -2618,7 +2618,7 @@ extern const TileTypeProcs _tile_type_rail_procs = {
|
||||||
NULL, // animate_tile_proc
|
NULL, // animate_tile_proc
|
||||||
TileLoop_Track, // tile_loop_clear
|
TileLoop_Track, // tile_loop_clear
|
||||||
ChangeTileOwner_Track, // change_tile_owner_clear
|
ChangeTileOwner_Track, // change_tile_owner_clear
|
||||||
NULL, // get_produced_cargo_proc
|
NULL, // add_produced_cargo_proc
|
||||||
VehicleEnter_Track, // vehicle_enter_tile_proc
|
VehicleEnter_Track, // vehicle_enter_tile_proc
|
||||||
GetFoundation_Track, // get_foundation_proc
|
GetFoundation_Track, // get_foundation_proc
|
||||||
TerraformTile_Track, // terraform_tile_proc
|
TerraformTile_Track, // terraform_tile_proc
|
||||||
|
|
|
@ -1634,7 +1634,7 @@ extern const TileTypeProcs _tile_type_road_procs = {
|
||||||
NULL, // animate_tile_proc
|
NULL, // animate_tile_proc
|
||||||
TileLoop_Road, // tile_loop_clear
|
TileLoop_Road, // tile_loop_clear
|
||||||
ChangeTileOwner_Road, // change_tile_owner_clear
|
ChangeTileOwner_Road, // change_tile_owner_clear
|
||||||
NULL, // get_produced_cargo_proc
|
NULL, // add_produced_cargo_proc
|
||||||
VehicleEnter_Road, // vehicle_enter_tile_proc
|
VehicleEnter_Road, // vehicle_enter_tile_proc
|
||||||
GetFoundation_Road, // get_foundation_proc
|
GetFoundation_Road, // get_foundation_proc
|
||||||
TerraformTile_Road, // terraform_tile_proc
|
TerraformTile_Road, // terraform_tile_proc
|
||||||
|
|
|
@ -465,19 +465,7 @@ void GetProductionAroundTiles(AcceptedCargo produced, 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);
|
||||||
|
AddProducedCargo(tile, produced);
|
||||||
if (!IsTileType(tile, MP_STATION)) {
|
|
||||||
GetProducedCargoProc *gpc = _tile_type_procs[GetTileType(tile)]->get_produced_cargo_proc;
|
|
||||||
if (gpc != NULL) {
|
|
||||||
CargoID cargos[256]; // Required for CBID_HOUSE_PRODUCE_CARGO.
|
|
||||||
memset(cargos, CT_INVALID, sizeof(cargos));
|
|
||||||
|
|
||||||
gpc(tile, cargos);
|
|
||||||
for (uint i = 0; i < lengthof(cargos); ++i) {
|
|
||||||
if (cargos[i] != CT_INVALID) produced[cargos[i]]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3156,7 +3144,7 @@ extern const TileTypeProcs _tile_type_station_procs = {
|
||||||
AnimateTile_Station, // animate_tile_proc
|
AnimateTile_Station, // animate_tile_proc
|
||||||
TileLoop_Station, // tile_loop_clear
|
TileLoop_Station, // tile_loop_clear
|
||||||
ChangeTileOwner_Station, // change_tile_owner_clear
|
ChangeTileOwner_Station, // change_tile_owner_clear
|
||||||
NULL, // get_produced_cargo_proc
|
NULL, // add_produced_cargo_proc
|
||||||
VehicleEnter_Station, // vehicle_enter_tile_proc
|
VehicleEnter_Station, // vehicle_enter_tile_proc
|
||||||
GetFoundation_Station, // get_foundation_proc
|
GetFoundation_Station, // get_foundation_proc
|
||||||
TerraformTile_Station, // terraform_tile_proc
|
TerraformTile_Station, // terraform_tile_proc
|
||||||
|
|
|
@ -103,7 +103,7 @@ typedef TrackStatus GetTileTrackStatusProc(TileIndex tile, TransportType mode, u
|
||||||
* @param tile Tile being queried
|
* @param tile Tile being queried
|
||||||
* @param b Destination array of produced cargo
|
* @param b Destination array of produced cargo
|
||||||
*/
|
*/
|
||||||
typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
|
typedef void AddProducedCargoProc(TileIndex tile, AcceptedCargo ac);
|
||||||
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);
|
||||||
|
@ -144,7 +144,7 @@ struct TileTypeProcs {
|
||||||
AnimateTileProc *animate_tile_proc;
|
AnimateTileProc *animate_tile_proc;
|
||||||
TileLoopProc *tile_loop_proc;
|
TileLoopProc *tile_loop_proc;
|
||||||
ChangeTileOwnerProc *change_tile_owner_proc;
|
ChangeTileOwnerProc *change_tile_owner_proc;
|
||||||
GetProducedCargoProc *get_produced_cargo_proc; ///< Return produced cargo of the tile
|
AddProducedCargoProc *add_produced_cargo_proc; ///< Adds produced cargo of the tile to cargo array supplied as parameter
|
||||||
VehicleEnterTileProc *vehicle_enter_tile_proc; ///< Called when a vehicle enters a tile
|
VehicleEnterTileProc *vehicle_enter_tile_proc; ///< Called when a vehicle enters a tile
|
||||||
GetFoundationProc *get_foundation_proc;
|
GetFoundationProc *get_foundation_proc;
|
||||||
TerraformTileProc *terraform_tile_proc; ///< Called when a terraforming operation is about to take place
|
TerraformTileProc *terraform_tile_proc; ///< Called when a terraforming operation is about to take place
|
||||||
|
@ -164,6 +164,13 @@ static inline void AddAcceptedCargo(TileIndex tile, AcceptedCargo ac)
|
||||||
proc(tile, ac);
|
proc(tile, ac);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void AddProducedCargo(TileIndex tile, AcceptedCargo ac)
|
||||||
|
{
|
||||||
|
AddProducedCargoProc *proc = _tile_type_procs[GetTileType(tile)]->add_produced_cargo_proc;
|
||||||
|
if (proc == NULL) return;
|
||||||
|
proc(tile, ac);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void AnimateTile(TileIndex tile)
|
static inline void AnimateTile(TileIndex tile)
|
||||||
{
|
{
|
||||||
AnimateTileProc *proc = _tile_type_procs[GetTileType(tile)]->animate_tile_proc;
|
AnimateTileProc *proc = _tile_type_procs[GetTileType(tile)]->animate_tile_proc;
|
||||||
|
|
|
@ -555,7 +555,7 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlag flags)
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GetProducedCargo_Town(TileIndex tile, CargoID *b)
|
static void AddProducedCargo_Town(TileIndex tile, AcceptedCargo ac)
|
||||||
{
|
{
|
||||||
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,14 +570,14 @@ static void GetProducedCargo_Town(TileIndex tile, CargoID *b)
|
||||||
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;
|
||||||
*(b++) = cargo;
|
ac[cargo]++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (hs->population > 0) {
|
if (hs->population > 0) {
|
||||||
*(b++) = CT_PASSENGERS;
|
ac[CT_PASSENGERS]++;
|
||||||
}
|
}
|
||||||
if (hs->mail_generation > 0) {
|
if (hs->mail_generation > 0) {
|
||||||
*(b++) = CT_MAIL;
|
ac[CT_MAIL]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2903,7 +2903,7 @@ extern const TileTypeProcs _tile_type_town_procs = {
|
||||||
AnimateTile_Town, // animate_tile_proc
|
AnimateTile_Town, // animate_tile_proc
|
||||||
TileLoop_Town, // tile_loop_clear
|
TileLoop_Town, // tile_loop_clear
|
||||||
ChangeTileOwner_Town, // change_tile_owner_clear
|
ChangeTileOwner_Town, // change_tile_owner_clear
|
||||||
GetProducedCargo_Town, // get_produced_cargo_proc
|
AddProducedCargo_Town, // add_produced_cargo_proc
|
||||||
NULL, // vehicle_enter_tile_proc
|
NULL, // vehicle_enter_tile_proc
|
||||||
GetFoundation_Town, // get_foundation_proc
|
GetFoundation_Town, // get_foundation_proc
|
||||||
TerraformTile_Town, // terraform_tile_proc
|
TerraformTile_Town, // terraform_tile_proc
|
||||||
|
|
|
@ -764,7 +764,7 @@ extern const TileTypeProcs _tile_type_trees_procs = {
|
||||||
NULL, // animate_tile_proc
|
NULL, // animate_tile_proc
|
||||||
TileLoop_Trees, // tile_loop_clear
|
TileLoop_Trees, // tile_loop_clear
|
||||||
ChangeTileOwner_Trees, // change_tile_owner_clear
|
ChangeTileOwner_Trees, // change_tile_owner_clear
|
||||||
NULL, // get_produced_cargo_proc
|
NULL, // add_produced_cargo_proc
|
||||||
NULL, // vehicle_enter_tile_proc
|
NULL, // vehicle_enter_tile_proc
|
||||||
GetFoundation_Trees, // get_foundation_proc
|
GetFoundation_Trees, // get_foundation_proc
|
||||||
TerraformTile_Trees, // terraform_tile_proc
|
TerraformTile_Trees, // terraform_tile_proc
|
||||||
|
|
|
@ -1535,7 +1535,7 @@ extern const TileTypeProcs _tile_type_tunnelbridge_procs = {
|
||||||
NULL, // animate_tile_proc
|
NULL, // animate_tile_proc
|
||||||
TileLoop_TunnelBridge, // tile_loop_clear
|
TileLoop_TunnelBridge, // tile_loop_clear
|
||||||
ChangeTileOwner_TunnelBridge, // change_tile_owner_clear
|
ChangeTileOwner_TunnelBridge, // change_tile_owner_clear
|
||||||
NULL, // get_produced_cargo_proc
|
NULL, // add_produced_cargo_proc
|
||||||
VehicleEnter_TunnelBridge, // vehicle_enter_tile_proc
|
VehicleEnter_TunnelBridge, // vehicle_enter_tile_proc
|
||||||
GetFoundation_TunnelBridge, // get_foundation_proc
|
GetFoundation_TunnelBridge, // get_foundation_proc
|
||||||
TerraformTile_TunnelBridge, // terraform_tile_proc
|
TerraformTile_TunnelBridge, // terraform_tile_proc
|
||||||
|
|
|
@ -503,7 +503,7 @@ extern const TileTypeProcs _tile_type_unmovable_procs = {
|
||||||
NULL, // animate_tile_proc
|
NULL, // animate_tile_proc
|
||||||
TileLoop_Unmovable, // tile_loop_clear
|
TileLoop_Unmovable, // tile_loop_clear
|
||||||
ChangeTileOwner_Unmovable, // change_tile_owner_clear
|
ChangeTileOwner_Unmovable, // change_tile_owner_clear
|
||||||
NULL, // get_produced_cargo_proc
|
NULL, // add_produced_cargo_proc
|
||||||
NULL, // vehicle_enter_tile_proc
|
NULL, // vehicle_enter_tile_proc
|
||||||
GetFoundation_Unmovable, // get_foundation_proc
|
GetFoundation_Unmovable, // get_foundation_proc
|
||||||
TerraformTile_Unmovable, // terraform_tile_proc
|
TerraformTile_Unmovable, // terraform_tile_proc
|
||||||
|
|
|
@ -1157,7 +1157,7 @@ extern const TileTypeProcs _tile_type_water_procs = {
|
||||||
NULL, // animate_tile_proc
|
NULL, // animate_tile_proc
|
||||||
TileLoop_Water, // tile_loop_clear
|
TileLoop_Water, // tile_loop_clear
|
||||||
ChangeTileOwner_Water, // change_tile_owner_clear
|
ChangeTileOwner_Water, // change_tile_owner_clear
|
||||||
NULL, // get_produced_cargo_proc
|
NULL, // add_produced_cargo_proc
|
||||||
VehicleEnter_Water, // vehicle_enter_tile_proc
|
VehicleEnter_Water, // vehicle_enter_tile_proc
|
||||||
GetFoundation_Water, // get_foundation_proc
|
GetFoundation_Water, // get_foundation_proc
|
||||||
TerraformTile_Water, // terraform_tile_proc
|
TerraformTile_Water, // terraform_tile_proc
|
||||||
|
|
Loading…
Reference in New Issue