Changeset - r12816:33099b7286d4
[Not reviewed]
master
0 14 0
smatz - 15 years ago 2009-08-30 11:47:41
smatz@openttd.org
(svn r17316) -Codechange: use Industry::GetByTile() instead of GetIndustryByTile()
14 files changed with 52 insertions and 55 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_tilelist.cpp
Show inline comments
 
@@ -12,7 +12,7 @@
 
#include "ai_tilelist.hpp"
 
#include "ai_industry.hpp"
 
#include "../../tile_map.h"
 
#include "../../industry_map.h"
 
#include "../../industry.h"
 
#include "../../station_base.h"
 
#include "../../settings_type.h"
 

	
src/disaster_cmd.cpp
Show inline comments
 
@@ -26,7 +26,7 @@
 
#include "stdafx.h"
 
#include "landscape.h"
 

	
 
#include "industry_map.h"
 
#include "industry.h"
 
#include "station_base.h"
 
#include "command_func.h"
 
#include "news_func.h"
src/economy.cpp
Show inline comments
 
@@ -14,7 +14,7 @@
 
#include "tile_cmd.h"
 
#include "company_func.h"
 
#include "command_func.h"
 
#include "industry_map.h"
 
#include "industry.h"
 
#include "town.h"
 
#include "news_func.h"
 
#include "network/network.h"
src/effectvehicle.cpp
Show inline comments
 
@@ -11,7 +11,7 @@
 

	
 
#include "stdafx.h"
 
#include "landscape.h"
 
#include "industry_map.h"
 
#include "industry.h"
 
#include "vehicle_func.h"
 
#include "sound_func.h"
 
#include "animated_tile_func.h"
src/industry.h
Show inline comments
 
@@ -19,11 +19,9 @@
 
#include "economy_type.h"
 
#include "map_type.h"
 
#include "industry_type.h"
 
#include "industrytype.h"
 
#include "tile_type.h"
 
#include "subsidy_type.h"
 
#include "town_type.h"
 
#include "date_type.h"
 
#include "industry_map.h"
 

	
 

	
 
typedef Pool<Industry, IndustryID, 64, 64000> IndustryPool;
 
@@ -74,6 +72,17 @@ struct Industry : IndustryPool::PoolItem
 
	Industry(TileIndex tile = INVALID_TILE) : xy(tile) {}
 
	~Industry();
 

	
 
	/**
 
	 * Get the industry of the given tile
 
	 * @param t the tile to get the industry from
 
	 * @pre IsTileType(t, MP_INDUSTRY)
 
	 * @return the industry
 
	 */
 
	static FORCEINLINE Industry *GetByTile(TileIndex tile)
 
	{
 
		return Industry::Get(GetIndustryIndex(tile));
 
	}
 

	
 
	static Industry *GetRandom();
 
};
 

	
src/industry_cmd.cpp
Show inline comments
 
@@ -12,7 +12,7 @@
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "clear_map.h"
 
#include "industry_map.h"
 
#include "industry.h"
 
#include "station_base.h"
 
#include "train.h"
 
#include "landscape.h"
 
@@ -102,7 +102,7 @@ IndustryType GetIndustryType(TileIndex t
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 

	
 
	const Industry *ind = GetIndustryByTile(tile);
 
	const Industry *ind = Industry::GetByTile(tile);
 
	assert(ind != NULL);
 
	return ind->type;
 
}
 
@@ -297,7 +297,7 @@ static IndustryDrawTileProc * const _ind
 
static void DrawTile_Industry(TileInfo *ti)
 
{
 
	IndustryGfx gfx = GetIndustryGfx(ti->tile);
 
	Industry *ind = GetIndustryByTile(ti->tile);
 
	Industry *ind = Industry::GetByTile(ti->tile);
 
	const IndustryTileSpec *indts = GetIndustryTileSpec(gfx);
 
	const DrawBuildingsTileStruct *dits;
 
	SpriteID image;
 
@@ -385,7 +385,7 @@ static Foundation GetFoundation_Industry
 
	if (gfx >= NEW_INDUSTRYTILEOFFSET) {
 
		const IndustryTileSpec *indts = GetIndustryTileSpec(gfx);
 
		if (indts->grf_prop.spritegroup != NULL && HasBit(indts->callback_flags, CBM_INDT_DRAW_FOUNDATIONS)) {
 
			uint32 callback_res = GetIndustryTileCallback(CBID_INDUSTRY_DRAW_FOUNDATIONS, 0, 0, gfx, GetIndustryByTile(tile), tile);
 
			uint32 callback_res = GetIndustryTileCallback(CBID_INDUSTRY_DRAW_FOUNDATIONS, 0, 0, gfx, Industry::GetByTile(tile), tile);
 
			if (callback_res == 0) return FOUNDATION_NONE;
 
		}
 
	}
 
@@ -406,7 +406,7 @@ static void AddAcceptedCargo_Industry(Ti
 
	const uint8 *cargo_acceptance = itspec->acceptance;
 

	
 
	if (HasBit(itspec->callback_flags, CBM_INDT_ACCEPT_CARGO)) {
 
		uint16 res = GetIndustryTileCallback(CBID_INDTILE_ACCEPT_CARGO, 0, 0, gfx, GetIndustryByTile(tile), tile);
 
		uint16 res = GetIndustryTileCallback(CBID_INDTILE_ACCEPT_CARGO, 0, 0, gfx, Industry::GetByTile(tile), tile);
 
		if (res != CALLBACK_FAILED) {
 
			accepts_cargo = raw_accepts_cargo;
 
			for (uint i = 0; i < lengthof(itspec->accepts_cargo); i++) raw_accepts_cargo[i] = GetCargoTranslation(GB(res, i * 5, 5), itspec->grf_prop.grffile);
 
@@ -414,7 +414,7 @@ static void AddAcceptedCargo_Industry(Ti
 
	}
 

	
 
	if (HasBit(itspec->callback_flags, CBM_INDT_CARGO_ACCEPTANCE)) {
 
		uint16 res = GetIndustryTileCallback(CBID_INDTILE_CARGO_ACCEPTANCE, 0, 0, gfx, GetIndustryByTile(tile), tile);
 
		uint16 res = GetIndustryTileCallback(CBID_INDTILE_CARGO_ACCEPTANCE, 0, 0, gfx, Industry::GetByTile(tile), tile);
 
		if (res != CALLBACK_FAILED) {
 
			cargo_acceptance = raw_cargo_acceptance;
 
			for (uint i = 0; i < lengthof(itspec->accepts_cargo); i++) raw_cargo_acceptance[i] = GB(res, i * 4, 4);
 
@@ -429,7 +429,7 @@ static void AddAcceptedCargo_Industry(Ti
 

	
 
static void GetTileDesc_Industry(TileIndex tile, TileDesc *td)
 
{
 
	const Industry *i = GetIndustryByTile(tile);
 
	const Industry *i = Industry::GetByTile(tile);
 
	const IndustrySpec *is = GetIndustrySpec(i->type);
 

	
 
	td->owner[0] = i->owner;
 
@@ -446,7 +446,7 @@ static void GetTileDesc_Industry(TileInd
 

	
 
static CommandCost ClearTile_Industry(TileIndex tile, DoCommandFlag flags)
 
{
 
	Industry *i = GetIndustryByTile(tile);
 
	Industry *i = Industry::GetByTile(tile);
 
	const IndustrySpec *indspec = GetIndustrySpec(i->type);
 

	
 
	/* water can destroy industries
 
@@ -473,7 +473,7 @@ static CommandCost ClearTile_Industry(Ti
 

	
 
static void TransportIndustryGoods(TileIndex tile)
 
{
 
	Industry *i = GetIndustryByTile(tile);
 
	Industry *i = Industry::GetByTile(tile);
 
	const IndustrySpec *indspec = GetIndustrySpec(i->type);
 
	bool moved_cargo = false;
 

	
 
@@ -846,7 +846,7 @@ static void TileLoop_Industry(TileIndex 
 

	
 

	
 
	case GFX_TOY_FACTORY: {
 
			Industry *i = GetIndustryByTile(tile);
 
			Industry *i = Industry::GetByTile(tile);
 
			if (i->was_cargo_delivered) {
 
				i->was_cargo_delivered = false;
 
				SetIndustryAnimationLoop(tile, 0);
 
@@ -882,7 +882,7 @@ static TrackStatus GetTileTrackStatus_In
 

	
 
static void AddProducedCargo_Industry(TileIndex tile, CargoArray &produced)
 
{
 
	const Industry *i = GetIndustryByTile(tile);
 
	const Industry *i = Industry::GetByTile(tile);
 

	
 
	for (uint j = 0; j < lengthof(i->produced_cargo); j++) {
 
		CargoID cargo = i->produced_cargo[j];
 
@@ -893,7 +893,7 @@ static void AddProducedCargo_Industry(Ti
 
static void ChangeTileOwner_Industry(TileIndex tile, Owner old_owner, Owner new_owner)
 
{
 
	/* If the founder merges, the industry was created by the merged company */
 
	Industry *i = GetIndustryByTile(tile);
 
	Industry *i = Industry::GetByTile(tile);
 
	if (i->founder == old_owner) i->founder = (new_owner == INVALID_OWNER) ? OWNER_NONE : new_owner;
 
}
 

	
 
@@ -2409,7 +2409,7 @@ static CommandCost TerraformTile_Industr
 
			/* Call callback 3C 'disable autosloping for industry tiles'. */
 
			if (HasBit(itspec->callback_flags, CBM_INDT_AUTOSLOPE)) {
 
				/* If the callback fails, allow autoslope. */
 
				uint16 res = GetIndustryTileCallback(CBID_INDUSTRY_AUTOSLOPE, 0, 0, gfx, GetIndustryByTile(tile), tile);
 
				uint16 res = GetIndustryTileCallback(CBID_INDUSTRY_AUTOSLOPE, 0, 0, gfx, Industry::GetByTile(tile), tile);
 
				if ((res == 0) || (res == CALLBACK_FAILED)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 
			} else {
 
				/* allow autoslope */
src/industry_map.h
Show inline comments
 
@@ -12,7 +12,7 @@
 
#ifndef INDUSTRY_MAP_H
 
#define INDUSTRY_MAP_H
 

	
 
#include "industry.h"
 
#include "industrytype.h"
 
#include "tile_map.h"
 
#include "water_map.h"
 

	
 
@@ -70,17 +70,6 @@ static inline IndustryID GetIndustryInde
 
}
 

	
 
/**
 
 * Get the industry of the given tile
 
 * @param t the tile to get the industry from
 
 * @pre IsTileType(t, MP_INDUSTRY)
 
 * @return the industry
 
 */
 
static inline Industry *GetIndustryByTile(TileIndex t)
 
{
 
	return Industry::Get(GetIndustryIndex(t));
 
}
 

	
 
/**
 
 * Is this industry tile fully built?
 
 * @param t the tile to analyze
 
 * @pre IsTileType(t, MP_INDUSTRY)
src/newgrf_industries.cpp
Show inline comments
 
@@ -14,7 +14,7 @@
 
#include "tile_type.h"
 
#include "strings_type.h"
 
#include "company_type.h"
 
#include "industry_map.h"
 
#include "industry.h"
 
#include "newgrf.h"
 
#include "newgrf_industries.h"
 
#include "newgrf_commons.h"
 
@@ -242,7 +242,7 @@ uint32 IndustryGetVariable(const Resolve
 
		/* Get random tile bits at offset param */
 
		case 0x61:
 
			tile = GetNearbyTile(parameter, tile);
 
			return (IsTileType(tile, MP_INDUSTRY) && GetIndustryByTile(tile) == industry) ? GetIndustryRandomBits(tile) : 0;
 
			return (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) ? GetIndustryRandomBits(tile) : 0;
 

	
 
		/* Land info of nearby tiles */
 
		case 0x62: return GetNearbyIndustryTileInformation(parameter, tile, INVALID_INDUSTRY);
 
@@ -250,7 +250,7 @@ uint32 IndustryGetVariable(const Resolve
 
		/* Animation stage of nearby tiles */
 
		case 0x63:
 
			tile = GetNearbyTile(parameter, tile);
 
			if (IsTileType(tile, MP_INDUSTRY) && GetIndustryByTile(tile) == industry) {
 
			if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) {
 
				return GetIndustryAnimationState(tile);
 
			}
 
			return 0xFFFFFFFF;
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -22,7 +22,7 @@
 
#include "newgrf_industrytiles.h"
 
#include "newgrf_sound.h"
 
#include "newgrf_text.h"
 
#include "industry_map.h"
 
#include "industry.h"
 
#include "sprite.h"
 
#include "transparency.h"
 
#include "functions.h"
 
@@ -97,7 +97,7 @@ static uint32 IndustryTileGetVariable(co
 
		/* Animation stage of nearby tiles */
 
		case 0x61:
 
			tile = GetNearbyTile(parameter, tile);
 
			if (IsTileType(tile, MP_INDUSTRY) && GetIndustryByTile(tile) == inds) {
 
			if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == inds) {
 
				return GetIndustryAnimationState(tile);
 
			}
 
			return UINT_MAX;
 
@@ -122,14 +122,14 @@ static uint32 IndustryTileGetRandomBits(
 
{
 
	const TileIndex tile = object->u.industry.tile;
 
	if (tile == INVALID_TILE || !IsTileType(tile, MP_INDUSTRY)) return 0;
 
	return (object->scope == VSG_SCOPE_SELF) ? GetIndustryRandomBits(tile) : GetIndustryByTile(tile)->random;
 
	return (object->scope == VSG_SCOPE_SELF) ? GetIndustryRandomBits(tile) : Industry::GetByTile(tile)->random;
 
}
 

	
 
static uint32 IndustryTileGetTriggers(const ResolverObject *object)
 
{
 
	const TileIndex tile = object->u.industry.tile;
 
	if (tile == INVALID_TILE || !IsTileType(tile, MP_INDUSTRY)) return 0;
 
	return (object->scope == VSG_SCOPE_SELF) ? GetIndustryTriggers(tile) : GetIndustryByTile(tile)->random_triggers;
 
	return (object->scope == VSG_SCOPE_SELF) ? GetIndustryTriggers(tile) : Industry::GetByTile(tile)->random_triggers;
 
}
 

	
 
static void IndustryTileSetTriggers(const ResolverObject *object, int triggers)
 
@@ -140,7 +140,7 @@ static void IndustryTileSetTriggers(cons
 
	if (object->scope == VSG_SCOPE_SELF) {
 
		SetIndustryTriggers(tile, triggers);
 
	} else {
 
		GetIndustryByTile(tile)->random_triggers = triggers;
 
		Industry::GetByTile(tile)->random_triggers = triggers;
 
	}
 
}
 

	
 
@@ -299,7 +299,7 @@ bool PerformIndustryTileSlopeCheck(TileI
 

	
 
void AnimateNewIndustryTile(TileIndex tile)
 
{
 
	Industry *ind = GetIndustryByTile(tile);
 
	Industry *ind = Industry::GetByTile(tile);
 
	IndustryGfx gfx = GetIndustryGfx(tile);
 
	const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx);
 
	byte animation_speed = itspec->animation_speed;
 
@@ -387,7 +387,7 @@ bool StartStopIndustryTileAnimation(Tile
 

	
 
	if (!HasBit(itspec->animation_triggers, iat)) return false;
 

	
 
	Industry *ind = GetIndustryByTile(tile);
 
	Industry *ind = Industry::GetByTile(tile);
 
	ChangeIndustryTileAnimationFrame(itspec, tile, iat, random, gfx, ind);
 
	return true;
 
}
 
@@ -436,7 +436,7 @@ static void DoTriggerIndustryTile(TileIn
 

	
 
void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger)
 
{
 
	DoTriggerIndustryTile(tile, trigger, GetIndustryByTile(tile));
 
	DoTriggerIndustryTile(tile, trigger, Industry::GetByTile(tile));
 
}
 

	
 
void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
src/saveload/afterload.cpp
Show inline comments
 
@@ -22,7 +22,7 @@
 
#include "../network/network.h"
 
#include "../gfxinit.h"
 
#include "../functions.h"
 
#include "../industry_map.h"
 
#include "../industry.h"
 
#include "../town_map.h"
 
#include "../clear_map.h"
 
#include "../vehicle_func.h"
src/smallmap_gui.cpp
Show inline comments
 
@@ -11,7 +11,7 @@
 

	
 
#include "stdafx.h"
 
#include "clear_map.h"
 
#include "industry_map.h"
 
#include "industry.h"
 
#include "station_map.h"
 
#include "landscape.h"
 
#include "window_gui.h"
 
@@ -408,8 +408,8 @@ static inline uint32 GetSmallMapIndustri
 

	
 
	if (t == MP_INDUSTRY) {
 
		/* If industry is allowed to be seen, use its colour on the map */
 
		if (_legend_from_industries[_industry_to_list_pos[GetIndustryByTile(tile)->type]].show_on_map) {
 
			return GetIndustrySpec(GetIndustryByTile(tile)->type)->map_colour * 0x01010101;
 
		if (_legend_from_industries[_industry_to_list_pos[Industry::GetByTile(tile)->type]].show_on_map) {
 
			return GetIndustrySpec(Industry::GetByTile(tile)->type)->map_colour * 0x01010101;
 
		} else {
 
			/* otherwise, return the colour of the clear tiles, which will make it disappear */
 
			return ApplyMask(MKCOLOUR(0x54545454), &_smallmap_vehicles_andor[MP_CLEAR]);
 
@@ -465,7 +465,7 @@ static inline uint32 GetSmallMapVegetati
 
			return (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) < 3) ? MKCOLOUR(0x37373737) : _vegetation_clear_bits[GetClearGround(tile)];
 

	
 
		case MP_INDUSTRY:
 
			return GetIndustrySpec(GetIndustryByTile(tile)->type)->check_proc == CHECK_FOREST ? MKCOLOUR(0xD0D0D0D0) : MKCOLOUR(0xB5B5B5B5);
 
			return GetIndustrySpec(Industry::GetByTile(tile)->type)->check_proc == CHECK_FOREST ? MKCOLOUR(0xD0D0D0D0) : MKCOLOUR(0xB5B5B5B5);
 

	
 
		case MP_TREES:
 
			if (GetTreeGround(tile) == TREE_GROUND_SNOW_DESERT) {
src/station.cpp
Show inline comments
 
@@ -11,7 +11,6 @@
 

	
 
#include "stdafx.h"
 
#include "company_func.h"
 
#include "industry.h"
 
#include "newgrf_cargo.h"
 
#include "yapf/yapf.h"
 
#include "cargotype.h"
 
@@ -31,7 +30,7 @@
 
#include "core/pool_func.hpp"
 
#include "station_base.h"
 
#include "roadstop_base.h"
 
#include "industry_map.h"
 
#include "industry.h"
 

	
 
#include "table/strings.h"
 

	
 
@@ -284,7 +283,7 @@ static bool FindIndustryToDeliver(TileIn
 
	if (!IsTileType(ind_tile, MP_INDUSTRY)) return false;
 

	
 
	RectAndIndustryVector *riv = (RectAndIndustryVector *)user_data;
 
	Industry *ind = GetIndustryByTile(ind_tile);
 
	Industry *ind = Industry::GetByTile(ind_tile);
 

	
 
	/* Don't check further if this industry is already in the list */
 
	if (riv->industries_near->Contains(ind)) return false;
src/station_cmd.cpp
Show inline comments
 
@@ -21,7 +21,7 @@
 
#include "news_func.h"
 
#include "train.h"
 
#include "roadveh.h"
 
#include "industry_map.h"
 
#include "industry.h"
 
#include "newgrf_station.h"
 
#include "newgrf_commons.h"
 
#include "yapf/yapf.h"
 
@@ -143,7 +143,7 @@ static bool CMSAMine(TileIndex tile)
 
	/* No industry */
 
	if (!IsTileType(tile, MP_INDUSTRY)) return false;
 

	
 
	const Industry *ind = GetIndustryByTile(tile);
 
	const Industry *ind = Industry::GetByTile(tile);
 

	
 
	/* No extractive industry */
 
	if ((GetIndustrySpec(ind->type)->life_type & INDUSTRYLIFE_EXTRACTIVE) == 0) return false;
 
@@ -190,7 +190,7 @@ static bool CMSAForest(TileIndex tile)
 
	/* No industry */
 
	if (!IsTileType(tile, MP_INDUSTRY)) return false;
 

	
 
	const Industry *ind = GetIndustryByTile(tile);
 
	const Industry *ind = Industry::GetByTile(tile);
 

	
 
	/* No extractive industry */
 
	if ((GetIndustrySpec(ind->type)->life_type & INDUSTRYLIFE_ORGANIC) == 0) return false;
src/water_cmd.cpp
Show inline comments
 
@@ -23,7 +23,7 @@
 
#include "train.h"
 
#include "roadveh.h"
 
#include "water.h"
 
#include "industry_map.h"
 
#include "industry.h"
 
#include "cargotype.h"
 
#include "newgrf_canal.h"
 
#include "transparency.h"
0 comments (0 inline, 0 general)