Changeset - r12248:7acc3688a3f0
[Not reviewed]
master
0 12 0
smatz - 15 years ago 2009-06-27 17:05:20
smatz@openttd.org
(svn r16673) -Codechange: rename GetProducedCargo() to AddProducedCargo() and change its behaviour accordingly
12 files changed with 30 insertions and 33 deletions:
0 comments (0 inline, 0 general)
src/clear_cmd.cpp
Show inline comments
 
@@ -354,7 +354,7 @@ extern const TileTypeProcs _tile_type_cl
 
	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
src/dummy_land.cpp
Show inline comments
 
@@ -70,7 +70,7 @@ extern const TileTypeProcs _tile_type_du
 
	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
src/industry_cmd.cpp
Show inline comments
 
@@ -868,12 +868,14 @@ static TrackStatus GetTileTrackStatus_In
 
	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_in
 
	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
src/rail_cmd.cpp
Show inline comments
 
@@ -2618,7 +2618,7 @@ extern const TileTypeProcs _tile_type_ra
 
	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
src/road_cmd.cpp
Show inline comments
 
@@ -1634,7 +1634,7 @@ extern const TileTypeProcs _tile_type_ro
 
	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
src/station_cmd.cpp
Show inline comments
 
@@ -465,19 +465,7 @@ void GetProductionAroundTiles(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)) {
 
				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_st
 
	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
src/tile_cmd.h
Show inline comments
 
@@ -103,7 +103,7 @@ typedef TrackStatus GetTileTrackStatusPr
 
 * @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(Tile
 
	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;
src/town_cmd.cpp
Show inline comments
 
@@ -555,7 +555,7 @@ static CommandCost ClearTile_Town(TileIn
 
	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(TileIn
 
			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_to
 
	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
src/tree_cmd.cpp
Show inline comments
 
@@ -764,7 +764,7 @@ extern const TileTypeProcs _tile_type_tr
 
	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
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -1535,7 +1535,7 @@ extern const TileTypeProcs _tile_type_tu
 
	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
src/unmovable_cmd.cpp
Show inline comments
 
@@ -503,7 +503,7 @@ extern const TileTypeProcs _tile_type_un
 
	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
src/water_cmd.cpp
Show inline comments
 
@@ -1157,7 +1157,7 @@ extern const TileTypeProcs _tile_type_wa
 
	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
0 comments (0 inline, 0 general)