Changeset - r14160:24d7cfd54d1c
[Not reviewed]
master
0 9 0
rubidium - 14 years ago 2010-01-04 18:30:10
rubidium@openttd.org
(svn r18718) -Codechange: make a wrapper macro for looping TileAreas
9 files changed with 23 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_industry.cpp
Show inline comments
 
@@ -162,7 +162,7 @@
 
	if (!HasHeliport(industry_id)) return INVALID_TILE;
 

	
 
	const Industry *ind = ::Industry::Get(industry_id);
 
	TILE_LOOP(tile_cur, ind->location.w, ind->location.h, ind->location.tile) {
 
	TILE_AREA_LOOP(tile_cur, ind->location) {
 
		if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
 
			return tile_cur;
 
		}
 
@@ -184,7 +184,7 @@
 
	if (!HasDock(industry_id)) return INVALID_TILE;
 

	
 
	const Industry *ind = ::Industry::Get(industry_id);
 
	TILE_LOOP(tile_cur, ind->location.w, ind->location.h, ind->location.tile) {
 
	TILE_AREA_LOOP(tile_cur, ind->location) {
 
		if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
 
			return tile_cur;
 
		}
src/ai/api/ai_tilelist.cpp
Show inline comments
 
@@ -86,7 +86,7 @@ AITileList_IndustryAccepting::AITileList
 

	
 
	if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED;
 

	
 
	TILE_LOOP(cur_tile, i->location.w + radius * 2, i->location.h+ radius * 2, i->location.tile - ::TileDiffXY(radius, radius)) {
 
	TILE_LOOP(cur_tile, i->location.w + radius * 2, i->location.h + radius * 2, i->location.tile - ::TileDiffXY(radius, radius)) {
 
		if (!::IsValidTile(cur_tile)) continue;
 
		/* Exclude all tiles that belong to this industry */
 
		if (::IsTileType(cur_tile, MP_INDUSTRY) && ::GetIndustryIndex(cur_tile) == industry_id) continue;
 
@@ -123,7 +123,7 @@ AITileList_IndustryProducing::AITileList
 

	
 
	if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED;
 

	
 
	TILE_LOOP(cur_tile, i->location.w + radius * 2, i->location.h+ radius * 2, i->location.tile - ::TileDiffXY(radius, radius)) {
 
	TILE_LOOP(cur_tile, i->location.w + radius * 2, i->location.h + radius * 2, i->location.tile - ::TileDiffXY(radius, radius)) {
 
		if (!::IsValidTile(cur_tile)) continue;
 
		/* Exclude all tiles that belong to this industry */
 
		if (::IsTileType(cur_tile, MP_INDUSTRY) && ::GetIndustryIndex(cur_tile) == industry_id) continue;
src/industry_cmd.cpp
Show inline comments
 
@@ -144,7 +144,7 @@ Industry::~Industry()
 
	 * This means that we do not have to clear tiles either. */
 
	if (this->location.w == 0) return;
 

	
 
	TILE_LOOP(tile_cur, this->location.w, this->location.h, this->location.tile) {
 
	TILE_AREA_LOOP(tile_cur, this->location) {
 
		if (IsTileType(tile_cur, MP_INDUSTRY)) {
 
			if (GetIndustryIndex(tile_cur) == this->index) {
 
				/* MakeWaterKeepingClass() can also handle 'land' */
src/map_func.h
Show inline comments
 
@@ -348,6 +348,16 @@ uint DistanceFromEdge(TileIndex); ///< s
 
		for (uint cur_w = (w); cur_w > 0; --cur_w, var++)
 

	
 
/**
 
 * A loop which iterates over the tiles of a TileArea
 
 *
 
 * This macro starts 2 nested loops which iterates over a square of tiles.
 
 *
 
 * @param var The name of the variable which contains the current tile
 
 * @param ta  The tile area to search over
 
 */
 
#define TILE_AREA_LOOP(var, ta) TILE_LOOP(var, ta.w, ta.h, ta.tile)
 

	
 
/**
 
 * Convert a DiagDirection to a TileIndexDiff
 
 *
 
 * @param dir The DiagDirection
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -396,7 +396,7 @@ bool StartStopIndustryTileAnimation(cons
 
{
 
	bool ret = true;
 
	uint32 random = Random();
 
	TILE_LOOP(tile, ind->location.w, ind->location.h, ind->location.tile) {
 
	TILE_AREA_LOOP(tile, ind->location) {
 
		if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == ind->index) {
 
			if (StartStopIndustryTileAnimation(tile, iat, random)) {
 
				SB(random, 0, 16, Random());
 
@@ -441,7 +441,7 @@ void TriggerIndustryTile(TileIndex tile,
 

	
 
void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
 
{
 
	TILE_LOOP(tile, ind->location.w, ind->location.h, ind->location.tile) {
 
	TILE_AREA_LOOP(tile, ind->location) {
 
		if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == ind->index) {
 
			DoTriggerIndustryTile(tile, trigger, ind);
 
		}
src/newgrf_station.cpp
Show inline comments
 
@@ -837,7 +837,7 @@ void DeallocateSpecFromStation(BaseStati
 

	
 
	ETileArea area = ETileArea(st, INVALID_TILE, TA_WHOLE);
 
	/* Check all tiles over the station to check if the specindex is still in use */
 
	TILE_LOOP(tile, area.w, area.h, area.tile) {
 
	TILE_AREA_LOOP(tile, area) {
 
		if (st->TileBelongsToRailStation(tile) && GetCustomStationSpecIndex(tile) == specindex) {
 
			return;
 
		}
 
@@ -1076,7 +1076,7 @@ void StationAnimationTrigger(const BaseS
 
	ETileArea area = ETileArea(st, tile, tas[trigger]);
 

	
 
	/* Check all tiles over the station to check if the specindex is still in use */
 
	TILE_LOOP(tile, area.w, area.h, area.tile) {
 
	TILE_AREA_LOOP(tile, area) {
 
		if (st->TileBelongsToRailStation(tile)) {
 
			const StationSpec *ss = GetStationSpec(tile);
 
			if (ss != NULL && HasBit(ss->anim_triggers, trigger)) {
src/station_cmd.cpp
Show inline comments
 
@@ -1223,7 +1223,7 @@ CommandCost RemoveFromRailBaseStation(Ti
 
	CommandCost total_cost(EXPENSES_CONSTRUCTION);
 

	
 
	/* Do the action for every tile into the area */
 
	TILE_LOOP(tile, ta.w, ta.h, ta.tile) {
 
	TILE_AREA_LOOP(tile, ta) {
 
		/* Make sure the specified tile is a rail station */
 
		if (!HasStationTileRail(tile)) continue;
 

	
 
@@ -1388,7 +1388,7 @@ CommandCost RemoveRailStation(T *st, DoC
 

	
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	/* clear all areas of the station */
 
	TILE_LOOP(tile, ta.w, ta.h, ta.tile) {
 
	TILE_AREA_LOOP(tile, ta) {
 
		/* for nonuniform stations, only remove tiles that are actually train station tiles */
 
		if (!st->TileBelongsToRailStation(tile)) continue;
 

	
src/station_gui.cpp
Show inline comments
 
@@ -1211,7 +1211,7 @@ static const T *FindStationsNearby(TileA
 
	_deleted_stations_nearby.Clear();
 

	
 
	/* Check the inside, to return, if we sit on another station */
 
	TILE_LOOP(t, ta.w, ta.h, ta.tile) {
 
	TILE_AREA_LOOP(t, ta) {
 
		if (t < MapSize() && IsTileType(t, MP_STATION) && T::IsValidID(GetStationIndex(t))) return T::GetByTile(t);
 
	}
 

	
src/water_cmd.cpp
Show inline comments
 
@@ -761,7 +761,7 @@ static void FloodVehicles(TileIndex tile
 
	if (!_settings_game.station.nonuniform_stations && IsTileType(tile, MP_STATION) && GetStationType(tile) == STATION_RAIL) {
 
		const Station *st = Station::GetByTile(tile);
 

	
 
		TILE_LOOP(t, st->train_station.w, st->train_station.h, st->train_station.tile) {
 
		TILE_AREA_LOOP(t, st->train_station) {
 
			if (st->TileBelongsToRailStation(t)) {
 
				FindVehicleOnPos(tile, &z, &FloodVehicleProc);
 
			}
0 comments (0 inline, 0 general)