summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-06-27 17:05:20 +0000
committersmatz <smatz@openttd.org>2009-06-27 17:05:20 +0000
commit50b5678e267d371c9c69195966b60ce903bfbe46 (patch)
tree5f5b144a504cc9537b7073a88d66a38159b32393 /src
parent996e5eea471f740428f2878884363521200d6ca1 (diff)
downloadopenttd-50b5678e267d371c9c69195966b60ce903bfbe46.tar.xz
(svn r16673) -Codechange: rename GetProducedCargo() to AddProducedCargo() and change its behaviour accordingly
Diffstat (limited to 'src')
-rw-r--r--src/clear_cmd.cpp2
-rw-r--r--src/dummy_land.cpp2
-rw-r--r--src/industry_cmd.cpp10
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/road_cmd.cpp2
-rw-r--r--src/station_cmd.cpp16
-rw-r--r--src/tile_cmd.h11
-rw-r--r--src/town_cmd.cpp10
-rw-r--r--src/tree_cmd.cpp2
-rw-r--r--src/tunnelbridge_cmd.cpp2
-rw-r--r--src/unmovable_cmd.cpp2
-rw-r--r--src/water_cmd.cpp2
12 files changed, 30 insertions, 33 deletions
diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp
index 0fc082eeb..f018f4252 100644
--- a/src/clear_cmd.cpp
+++ b/src/clear_cmd.cpp
@@ -354,7 +354,7 @@ extern const TileTypeProcs _tile_type_clear_procs = {
NULL, ///< animate_tile_proc
TileLoop_Clear, ///< tile_loop_clear
ChangeTileOwner_Clear, ///< change_tile_owner_clear
- NULL, ///< get_produced_cargo_proc
+ NULL, ///< add_produced_cargo_proc
NULL, ///< vehicle_enter_tile_proc
GetFoundation_Clear, ///< get_foundation_proc
TerraformTile_Clear, ///< terraform_tile_proc
diff --git a/src/dummy_land.cpp b/src/dummy_land.cpp
index 8bc5e888e..70bc9e999 100644
--- a/src/dummy_land.cpp
+++ b/src/dummy_land.cpp
@@ -70,7 +70,7 @@ extern const TileTypeProcs _tile_type_dummy_procs = {
NULL, // animate_tile_proc
TileLoop_Dummy, // tile_loop_clear
ChangeTileOwner_Dummy, // change_tile_owner_clear
- NULL, // get_produced_cargo_proc
+ NULL, // add_produced_cargo_proc
NULL, // vehicle_enter_tile_proc
GetFoundation_Dummy, // get_foundation_proc
TerraformTile_Dummy, // terraform_tile_proc
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 629123686..384ef4bd0 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -868,12 +868,14 @@ static TrackStatus GetTileTrackStatus_Industry(TileIndex tile, TransportType mod
return 0;
}
-static void GetProducedCargo_Industry(TileIndex tile, CargoID *b)
+static void AddProducedCargo_Industry(TileIndex tile, AcceptedCargo ac)
{
const Industry *i = GetIndustryByTile(tile);
- b[0] = i->produced_cargo[0];
- b[1] = i->produced_cargo[1];
+ for (uint j = 0; j < lengthof(i->produced_cargo); j++) {
+ CargoID cargo = i->produced_cargo[j];
+ if (cargo != CT_INVALID) ac[cargo]++;
+ }
}
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
TileLoop_Industry, // tile_loop_proc
ChangeTileOwner_Industry, // change_tile_owner_proc
- GetProducedCargo_Industry, // get_produced_cargo_proc
+ AddProducedCargo_Industry, // add_produced_cargo_proc
NULL, // vehicle_enter_tile_proc
GetFoundation_Industry, // get_foundation_proc
TerraformTile_Industry, // terraform_tile_proc
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 16e29a3d2..b3cd88546 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -2618,7 +2618,7 @@ extern const TileTypeProcs _tile_type_rail_procs = {
NULL, // animate_tile_proc
TileLoop_Track, // tile_loop_clear
ChangeTileOwner_Track, // change_tile_owner_clear
- NULL, // get_produced_cargo_proc
+ NULL, // add_produced_cargo_proc
VehicleEnter_Track, // vehicle_enter_tile_proc
GetFoundation_Track, // get_foundation_proc
TerraformTile_Track, // terraform_tile_proc
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 98781c36a..ef9206fde 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -1634,7 +1634,7 @@ extern const TileTypeProcs _tile_type_road_procs = {
NULL, // animate_tile_proc
TileLoop_Road, // tile_loop_clear
ChangeTileOwner_Road, // change_tile_owner_clear
- NULL, // get_produced_cargo_proc
+ NULL, // add_produced_cargo_proc
VehicleEnter_Road, // vehicle_enter_tile_proc
GetFoundation_Road, // get_foundation_proc
TerraformTile_Road, // terraform_tile_proc
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 080ded56b..033eb3f45 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -465,19 +465,7 @@ void GetProductionAroundTiles(AcceptedCargo produced, 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)) {
- 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]]++;
- }
- }
- }
+ AddProducedCargo(tile, produced);
}
}
}
@@ -3156,7 +3144,7 @@ extern const TileTypeProcs _tile_type_station_procs = {
AnimateTile_Station, // animate_tile_proc
TileLoop_Station, // tile_loop_clear
ChangeTileOwner_Station, // change_tile_owner_clear
- NULL, // get_produced_cargo_proc
+ NULL, // add_produced_cargo_proc
VehicleEnter_Station, // vehicle_enter_tile_proc
GetFoundation_Station, // get_foundation_proc
TerraformTile_Station, // terraform_tile_proc
diff --git a/src/tile_cmd.h b/src/tile_cmd.h
index a1cd92fda..6d8cb1a40 100644
--- a/src/tile_cmd.h
+++ b/src/tile_cmd.h
@@ -103,7 +103,7 @@ typedef TrackStatus GetTileTrackStatusProc(TileIndex tile, TransportType mode, u
* @param tile Tile being queried
* @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 void AnimateTileProc(TileIndex tile);
typedef void TileLoopProc(TileIndex tile);
@@ -144,7 +144,7 @@ struct TileTypeProcs {
AnimateTileProc *animate_tile_proc;
TileLoopProc *tile_loop_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
GetFoundationProc *get_foundation_proc;
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);
}
+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)
{
AnimateTileProc *proc = _tile_type_procs[GetTileType(tile)]->animate_tile_proc;
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index dabf20ca3..c51f5df38 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -555,7 +555,7 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlag flags)
return cost;
}
-static void GetProducedCargo_Town(TileIndex tile, CargoID *b)
+static void AddProducedCargo_Town(TileIndex tile, AcceptedCargo ac)
{
HouseID house_id = GetHouseType(tile);
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);
if (cargo == CT_INVALID) continue;
- *(b++) = cargo;
+ ac[cargo]++;
}
} else {
if (hs->population > 0) {
- *(b++) = CT_PASSENGERS;
+ ac[CT_PASSENGERS]++;
}
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
TileLoop_Town, // tile_loop_clear
ChangeTileOwner_Town, // change_tile_owner_clear
- GetProducedCargo_Town, // get_produced_cargo_proc
+ AddProducedCargo_Town, // add_produced_cargo_proc
NULL, // vehicle_enter_tile_proc
GetFoundation_Town, // get_foundation_proc
TerraformTile_Town, // terraform_tile_proc
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp
index 2801383a3..653ba8bd5 100644
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -764,7 +764,7 @@ extern const TileTypeProcs _tile_type_trees_procs = {
NULL, // animate_tile_proc
TileLoop_Trees, // tile_loop_clear
ChangeTileOwner_Trees, // change_tile_owner_clear
- NULL, // get_produced_cargo_proc
+ NULL, // add_produced_cargo_proc
NULL, // vehicle_enter_tile_proc
GetFoundation_Trees, // get_foundation_proc
TerraformTile_Trees, // terraform_tile_proc
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 91132c4b1..0c0f1ca0c 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -1535,7 +1535,7 @@ extern const TileTypeProcs _tile_type_tunnelbridge_procs = {
NULL, // animate_tile_proc
TileLoop_TunnelBridge, // tile_loop_clear
ChangeTileOwner_TunnelBridge, // change_tile_owner_clear
- NULL, // get_produced_cargo_proc
+ NULL, // add_produced_cargo_proc
VehicleEnter_TunnelBridge, // vehicle_enter_tile_proc
GetFoundation_TunnelBridge, // get_foundation_proc
TerraformTile_TunnelBridge, // terraform_tile_proc
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index c223263b7..3ddf393f3 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -503,7 +503,7 @@ extern const TileTypeProcs _tile_type_unmovable_procs = {
NULL, // animate_tile_proc
TileLoop_Unmovable, // tile_loop_clear
ChangeTileOwner_Unmovable, // change_tile_owner_clear
- NULL, // get_produced_cargo_proc
+ NULL, // add_produced_cargo_proc
NULL, // vehicle_enter_tile_proc
GetFoundation_Unmovable, // get_foundation_proc
TerraformTile_Unmovable, // terraform_tile_proc
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index e82a0b3b6..a692e53a6 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -1157,7 +1157,7 @@ extern const TileTypeProcs _tile_type_water_procs = {
NULL, // animate_tile_proc
TileLoop_Water, // tile_loop_clear
ChangeTileOwner_Water, // change_tile_owner_clear
- NULL, // get_produced_cargo_proc
+ NULL, // add_produced_cargo_proc
VehicleEnter_Water, // vehicle_enter_tile_proc
GetFoundation_Water, // get_foundation_proc
TerraformTile_Water, // terraform_tile_proc