Changeset - r6639:fa7f2f2338ea
[Not reviewed]
master
0 3 0
belugas - 17 years ago 2007-05-18 17:55:07
belugas@openttd.org
(svn r9870) -Codechange: Silence two compiler warnings and give proper type to the "type" member of industry struct
3 files changed with 6 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/economy.cpp
Show inline comments
 
@@ -1187,32 +1187,33 @@ int32 GetTransportedGoodsIncome(uint num
 
static void DeliverGoodsToIndustry(TileIndex xy, CargoID cargo_type, int num_pieces)
 
{
 
	Industry *best = NULL;
 
	Industry *ind;
 
	const IndustrySpec *indspec;
 
	uint best_dist;
 
	uint accepted_cargo_index;
 
	uint accepted_cargo_index = 0;  ///< unlikely value, just for warning removing
 

	
 
	/* Check if there's an industry close to the station that accepts the cargo
 
	 * XXX - Think of something better to
 
	 *       1) Only deliver to industries which are withing the catchment radius
 
	 *       2) Distribute between industries if more then one is present */
 
	best_dist = (_patches.station_spread + 8) * 2;
 
	FOR_ALL_INDUSTRIES(ind) {
 
		indspec = GetIndustrySpec(ind->type);
 
		uint i;
 

	
 
		if (indspec->produced_cargo[0] == CT_INVALID) continue;
 

	
 
		uint i;
 
		for (i = 0; i < lengthof(indspec->accepts_cargo); i++) {
 
			if (cargo_type == indspec->accepts_cargo[i] &&
 
					(indspec->input_cargo_multiplier[i][0] != 0 || indspec->input_cargo_multiplier[i][1] != 0)) {
 
				break;
 
			}
 
		}
 

	
 
		/* Check if matching cargo has been found */
 
		if (i == lengthof(indspec->accepts_cargo)) continue;
 

	
 
		uint dist = DistanceManhattan(ind->xy, xy);
 

	
 
		if (dist < best_dist) {
 
			best = ind;
src/industry.h
Show inline comments
 
@@ -74,13 +74,13 @@ struct Industry {
 
	uint16 last_mo_transported[2];  ///< stats of last month transport per cargo
 
	byte pct_transported[2];        ///< percentage transported per cargo
 
	uint16 total_production[2];     ///< total units produced per cargo
 
	uint16 total_transported[2];    ///< total units transported per cargo
 
	uint16 counter;                 ///< used for animation and/or production (if available cargo)
 

	
 
	byte type;                      ///< type of industry. see IT_COAL_MINE and others
 
	IndustryType type;              ///< type of industry. see IT_COAL_MINE and others
 
	OwnerByte owner;                ///< owner of the industry.  Which SHOULD always be (imho) OWNER_NONE
 
	byte random_color;              ///< randomized colour of the industry, for display purpose
 
	Year last_prod_year;            ///< last year of production
 
	byte was_cargo_delivered;       ///< flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry
 

	
 
	IndustryID index;               ///< index of the industry in the pool of industries
src/industry_cmd.cpp
Show inline comments
 
@@ -60,14 +60,14 @@ DEFINE_OLD_POOL(Industry, Industry, Indu
 
 * @return general type for this industry, as defined in industry.h
 
 **/
 
IndustryType GetIndustryType(TileIndex tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 

	
 
	const Industry *ind = GetIndustry(GetIndustryIndex(tile));
 
	return IsValidIndustry(ind) ? ind->type : IT_INVALID;
 
	const Industry *ind = GetIndustryByTile(tile);
 
	return IsValidIndustry(ind) ? ind->type : (IndustryType)IT_INVALID;
 
}
 

	
 
/**
 
 * Accessor for array _industry_specs.
 
 * This will ensure at once : proper access and
 
 * not allowing modifications of it.
0 comments (0 inline, 0 general)