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
 
@@ -3,25 +3,25 @@
 
/*
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file ai_tilelist.cpp Implementation of AITileList and friends. */
 

	
 
#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"
 

	
 
void AITileList::FixRectangleSpan(TileIndex &t1, TileIndex &t2)
 
{
 
	uint x1 = ::TileX(t1);
 
	uint x2 = ::TileX(t2);
 

	
 
	uint y1 = ::TileY(t1);
 
	uint y2 = ::TileY(t2);
 

	
 
	if (x1 >= x2) ::Swap(x1, x2);
src/disaster_cmd.cpp
Show inline comments
 
@@ -17,25 +17,25 @@
 
 *     that handles the vehicle's ticks.
 
 * <li>Run the disaster vehicles each tick until their target has been reached,
 
 *     this happens in the DisasterTick_XXX() functions. In here, a vehicle's
 
 *     state is kept by v->current_order.dest variable. Each achieved sub-target
 
 *     will increase this value, and the last one will remove the disaster itself
 
 * </ol>
 
 */
 

	
 

	
 
#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"
 
#include "town.h"
 
#include "company_func.h"
 
#include "variables.h"
 
#include "strings_func.h"
 
#include "date_func.h"
 
#include "functions.h"
 
#include "vehicle_func.h"
 
#include "sound_func.h"
 
#include "effectvehicle_func.h"
src/economy.cpp
Show inline comments
 
@@ -5,25 +5,25 @@
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file economy.cpp Handling of the economy. */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#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"
 
#include "network/network_func.h"
 
#include "vehicle_gui.h"
 
#include "ai/ai.hpp"
 
#include "aircraft.h"
 
#include "train.h"
 
#include "newgrf_engine.h"
 
#include "newgrf_sound.h"
 
#include "newgrf_industries.h"
 
#include "newgrf_industrytiles.h"
src/effectvehicle.cpp
Show inline comments
 
@@ -2,25 +2,25 @@
 

	
 
/*
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file effectvehicle.cpp Implementation of everything generic to vehicles. */
 

	
 
#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"
 
#include "effectvehicle_base.h"
 
#include "effectvehicle_func.h"
 

	
 
#include "table/sprites.h"
 

	
 
static void ChimneySmokeInit(EffectVehicle *v)
 
{
 
	uint32 r = Random();
 
	v->cur_image = SPR_CHIMNEY_SMOKE_0 + GB(r, 0, 3);
src/industry.h
Show inline comments
 
@@ -10,29 +10,27 @@
 
/** @file industry.h Base of all industries. */
 

	
 
#ifndef INDUSTRY_H
 
#define INDUSTRY_H
 

	
 
#include "core/pool_type.hpp"
 
#include "core/random_func.hpp"
 
#include "newgrf_storage.h"
 
#include "cargo_type.h"
 
#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;
 
extern IndustryPool _industry_pool;
 

	
 
/**
 
 * Defines the internal data of a functionnal industry
 
 */
 
struct Industry : IndustryPool::PoolItem<&_industry_pool> {
 
	typedef PersistentStorageArray<uint32, 16> PersistentStorage;
 

	
 
	TileIndex xy;                       ///< coordinates of the primary tile the industry is built one
 
@@ -65,24 +63,35 @@ struct Industry : IndustryPool::PoolItem
 
	uint8 construction_type;            ///< Way the industry was constructed (@see IndustryConstructionType)
 
	Date last_cargo_accepted_at;        ///< Last day cargo was accepted by this industry
 
	byte selected_layout;               ///< Which tile layout was used when creating the industry
 

	
 
	byte random_triggers;               ///< Triggers for the random
 
	uint16 random;                      ///< Random value used for randomisation of all kinds of things
 

	
 
	PersistentStorage psa;              ///< Persistent storage for NewGRF industries.
 

	
 
	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();
 
};
 

	
 
void PlantRandomFarmField(const Industry *i);
 

	
 
void ReleaseDisastersTargetingIndustry(IndustryID);
 

	
 
/* smallmap_gui.cpp */
 
void BuildIndustriesLegend();
 
/* industry_cmd.cpp */
 
void SetIndustryDailyChanges();
 

	
src/industry_cmd.cpp
Show inline comments
 
@@ -3,25 +3,25 @@
 
/*
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file industry_cmd.cpp Handling of industry tiles. */
 

	
 
#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"
 
#include "viewport_func.h"
 
#include "command_func.h"
 
#include "town.h"
 
#include "news_func.h"
 
#include "variables.h"
 
#include "cheat_type.h"
 
#include "genworld.h"
 
#include "tree_map.h"
 
#include "newgrf.h"
 
@@ -93,25 +93,25 @@ void ResetIndustryCreationProbility(Indu
 
/**
 
 * Retrieve the type for this industry.  Although it is accessed by a tile,
 
 * it will return the general type of industry, and not the sprite index
 
 * as would do GetIndustryGfx.
 
 * @param tile that is queried
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 * @return general type for this industry, as defined in industry.h
 
 **/
 
IndustryType GetIndustryType(TileIndex tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 

	
 
	const Industry *ind = GetIndustryByTile(tile);
 
	const Industry *ind = Industry::GetByTile(tile);
 
	assert(ind != NULL);
 
	return ind->type;
 
}
 

	
 
/**
 
 * Accessor for array _industry_specs.
 
 * This will ensure at once : proper access and
 
 * not allowing modifications of it.
 
 * @param thistype of industry (which is the index in _industry_specs)
 
 * @pre thistype < NUM_INDUSTRYTYPES
 
 * @return a pointer to the corresponding industry spec
 
 **/
 
@@ -288,25 +288,25 @@ static void IndustryDrawCoalPlantSparks(
 
typedef void IndustryDrawTileProc(const TileInfo *ti);
 
static IndustryDrawTileProc * const _industry_draw_tile_procs[5] = {
 
	IndustryDrawSugarMine,
 
	IndustryDrawToffeeQuarry,
 
	IndustryDrawBubbleGenerator,
 
	IndustryDrawToyFactory,
 
	IndustryDrawCoalPlantSparks,
 
};
 

	
 
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;
 
	SpriteID pal;
 

	
 
	/* Retrieve pointer to the draw industry tile struct */
 
	if (gfx >= NEW_INDUSTRYTILEOFFSET) {
 
		/* Draw the tile using the specialized method of newgrf industrytile.
 
		 * DrawNewIndustry will return false if ever the resolver could not
 
		 * find any sprite to display.  So in this case, we will jump on the
 
		 * substitute gfx instead. */
 
		if (indts->grf_prop.spritegroup != NULL && DrawNewIndustryTile(ti, ind, gfx, indts)) {
 
@@ -376,86 +376,86 @@ static uint GetSlopeZ_Industry(TileIndex
 

	
 
static Foundation GetFoundation_Industry(TileIndex tile, Slope tileh)
 
{
 
	IndustryGfx gfx = GetIndustryGfx(tile);
 

	
 
	/* For NewGRF industry tiles we might not be drawing a foundation. We need to
 
	 * account for this, as other structures should
 
	 * draw the wall of the foundation in this case.
 
	 */
 
	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;
 
		}
 
	}
 
	return FlatteningFoundation(tileh);
 
}
 

	
 
static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance)
 
{
 
	IndustryGfx gfx = GetIndustryGfx(tile);
 
	const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx);
 

	
 
	/* When we have to use a callback, we put our data in the next two variables */
 
	CargoID raw_accepts_cargo[lengthof(itspec->accepts_cargo)];
 
	uint8 raw_cargo_acceptance[lengthof(itspec->acceptance)];
 

	
 
	/* And then these will always point to a same sized array with the required data */
 
	const CargoID *accepts_cargo = itspec->accepts_cargo;
 
	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);
 
		}
 
	}
 

	
 
	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);
 
		}
 
	}
 

	
 
	for (byte i = 0; i < lengthof(itspec->accepts_cargo); i++) {
 
		CargoID a = accepts_cargo[i];
 
		if (a != CT_INVALID) acceptance[a] += cargo_acceptance[i];
 
	}
 
}
 

	
 
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;
 
	td->str = is->name;
 
	if (!IsIndustryCompleted(tile)) {
 
		SetDParamX(td->dparam, 0, td->str);
 
		td->str = STR_LAI_TOWN_INDUSTRY_DESCRIPTION_UNDER_CONSTRUCTION;
 
	}
 

	
 
	if (is->grf_prop.grffile != NULL) {
 
		td->grf = GetGRFConfig(is->grf_prop.grffile->grfid)->name;
 
	}
 
}
 

	
 
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
 
	 * in editor you can bulldoze industries
 
	 * with magic_bulldozer cheat you can destroy industries
 
	 * (area around OILRIG is water, so water shouldn't flood it
 
	 */
 
	if ((_current_company != OWNER_WATER && _game_mode != GM_EDITOR &&
 
			!_cheats.magic_bulldozer.value) ||
 
			((flags & DC_AUTO) != 0) ||
 
			(_current_company == OWNER_WATER &&
 
				((indspec->behaviour & INDUSTRYBEH_BUILT_ONWATER) ||
 
@@ -464,25 +464,25 @@ static CommandCost ClearTile_Industry(Ti
 
		return_cmd_error(flags & DC_AUTO ? STR_ERROR_UNMOVABLE_OBJECT_IN_THE_WAY : INVALID_STRING_ID);
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		AI::BroadcastNewEvent(new AIEventIndustryClose(i->index));
 
		delete i;
 
	}
 
	return CommandCost(EXPENSES_CONSTRUCTION, indspec->GetRemovalCost());
 
}
 

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

	
 
	for (uint j = 0; j < lengthof(i->produced_cargo_waiting); j++) {
 
		uint cw = min(i->produced_cargo_waiting[j], 255);
 
		if (cw > indspec->minimal_cargo && i->produced_cargo[j] != CT_INVALID) {
 
			i->produced_cargo_waiting[j] -= cw;
 

	
 
			/* fluctuating economy? */
 
			if (_economy.fluct <= 0) cw = (cw + 1) / 2;
 

	
 
			i->this_month_production[j] += cw;
 
@@ -837,25 +837,25 @@ static void TileLoop_Industry(TileIndex 
 
		if (Chance16(1, 3)) {
 
			SndPlayTileFx(SND_0C_ELECTRIC_SPARK, tile);
 
			AddAnimatedTile(tile);
 
		}
 
		break;
 

	
 
	case GFX_COPPER_MINE_CHIMNEY:
 
		CreateEffectVehicleAbove(TileX(tile) * TILE_SIZE + 6, TileY(tile) * TILE_SIZE + 6, 43, EV_SMOKE);
 
		break;
 

	
 

	
 
	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);
 
				AddAnimatedTile(tile);
 
			}
 
		}
 
		break;
 

	
 
	case GFX_BUBBLE_GENERATOR:
 
		TileLoopIndustry_BubbleGenerator(tile);
 
		break;
 

	
 
@@ -873,36 +873,36 @@ static bool ClickTile_Industry(TileIndex
 
{
 
	ShowIndustryViewWindow(GetIndustryIndex(tile));
 
	return true;
 
}
 

	
 
static TrackStatus GetTileTrackStatus_Industry(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 
{
 
	return 0;
 
}
 

	
 
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];
 
		if (cargo != CT_INVALID) produced[cargo]++;
 
	}
 
}
 

	
 
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;
 
}
 

	
 
static const byte _plantfarmfield_type[] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6};
 

	
 
static bool IsBadFarmFieldTile(TileIndex tile)
 
{
 
	switch (GetTileType(tile)) {
 
		case MP_CLEAR: return IsClearGround(tile, CLEAR_FIELDS) || IsClearGround(tile, CLEAR_SNOW) || IsClearGround(tile, CLEAR_DESERT);
 
		case MP_TREES: return (GetTreeGround(tile) == TREE_GROUND_SHORE);
 
		default:       return true;
 
	}
 
@@ -2400,25 +2400,25 @@ static CommandCost TerraformTile_Industr
 
		 *  - Allow autoslope by default.
 
		 *  - Disallow autoslope if callback succeeds and returns non-zero.
 
		 */
 
		Slope tileh_old = GetTileSlope(tile, NULL);
 
		/* TileMaxZ must not be changed. Slopes must not be steep. */
 
		if (!IsSteepSlope(tileh_old) && !IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new))) {
 
			const IndustryGfx gfx = GetIndustryGfx(tile);
 
			const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx);
 

	
 
			/* 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 */
 
				return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 
			}
 
		}
 
	}
 
	return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
}
 

	
 
extern const TileTypeProcs _tile_type_industry_procs = {
 
	DrawTile_Industry,           // draw_tile_proc
src/industry_map.h
Show inline comments
 
@@ -3,25 +3,25 @@
 
/*
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file industry_map.h Accessors for industries */
 

	
 
#ifndef INDUSTRY_MAP_H
 
#define INDUSTRY_MAP_H
 

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

	
 

	
 
/**
 
 * The following enums are indices used to know what to draw for this industry tile.
 
 * They all are pointing toward array _industry_draw_tile_data, in table/industry_land.h
 
 * How to calculate the correct position ? GFXid << 2 | IndustryStage (0 to 3)
 
 */
 
enum {
 
	GFX_COAL_MINE_TOWER_NOT_ANIMATED   =   0,
 
	GFX_COAL_MINE_TOWER_ANIMATED       =   1,
 
@@ -61,35 +61,24 @@ enum {
 
 * Get the industry ID of the given tile
 
 * @param t the tile to get the industry ID from
 
 * @pre IsTileType(t, MP_INDUSTRY)
 
 * @return the industry ID
 
 */
 
static inline IndustryID GetIndustryIndex(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_INDUSTRY));
 
	return _m[t].m2;
 
}
 

	
 
/**
 
 * 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)
 
 * @return true if and only if the industry tile is fully built
 
 */
 
static inline bool IsIndustryCompleted(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_INDUSTRY));
 
	return HasBit(_m[t].m1, 7);
 
}
 

	
 
IndustryType GetIndustryType(TileIndex tile);
src/newgrf_industries.cpp
Show inline comments
 
@@ -5,25 +5,25 @@
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file newgrf_industries.cpp Handling of NewGRF industries. */
 

	
 
#include "stdafx.h"
 
#include "debug.h"
 
#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"
 
#include "newgrf_text.h"
 
#include "newgrf_town.h"
 
#include "window_func.h"
 
#include "town.h"
 
#include "company_base.h"
 
#include "command_func.h"
 
#include "gui.h"
 
#include "strings_func.h"
 

	
 
@@ -233,33 +233,33 @@ uint32 IndustryGetVariable(const Resolve
 

	
 
			return industry->founder | (is_ai ? 0x10000 : 0) | (colours << 24);
 
		}
 

	
 
		case 0x46: return industry->construction_date; // Date when built - long format - (in days)
 

	
 
		/* Get industry ID at offset param */
 
		case 0x60: return GetIndustryIDAtOffset(GetNearbyTile(parameter, industry->xy), industry);
 

	
 
		/* 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);
 

	
 
		/* 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;
 

	
 
		/* Distance of nearest industry of given type */
 
		case 0x64: return GetClosestIndustry(tile, MapNewGRFIndustryType(parameter, indspec->grf_prop.grffile->grfid), industry);
 
		/* Get town zone and Manhattan distance of closest town */
 
		case 0x65: return GetTownRadiusGroup(industry->town, tile) << 16 | min(DistanceManhattan(tile, industry->town->xy), 0xFFFF);
 
		/* Get square of Euclidian distance of closes town */
 
		case 0x66: return GetTownRadiusGroup(industry->town, tile) << 16 | min(DistanceSquare(tile, industry->town->xy), 0xFFFF);
 

	
 
		/* Count of industry, distance of closest instance
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -13,25 +13,25 @@
 
#include "openttd.h"
 
#include "variables.h"
 
#include "debug.h"
 
#include "viewport_func.h"
 
#include "landscape.h"
 
#include "newgrf.h"
 
#include "core/random_func.hpp"
 
#include "newgrf_commons.h"
 
#include "newgrf_industries.h"
 
#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"
 
#include "town.h"
 
#include "command_func.h"
 
#include "animated_tile_func.h"
 
#include "water.h"
 

	
 
#include "table/strings.h"
 

	
 
/**
 
 * Based on newhouses equivalent, but adapted for newindustries
 
@@ -88,68 +88,68 @@ static uint32 IndustryTileGetVariable(co
 
		/* Relative position */
 
		case 0x43: return GetRelativePosition(tile, inds->xy);
 

	
 
		/* Animation frame. Like house variable 46 but can contain anything 0..FF. */
 
		case 0x44: return (IsTileType(tile, MP_INDUSTRY)) ? GetIndustryAnimationState(tile) : 0;
 

	
 
		/* Land info of nearby tiles */
 
		case 0x60: return GetNearbyIndustryTileInformation(parameter, tile, inds == NULL ? (IndustryID)INVALID_INDUSTRY : inds->index);
 

	
 
		/* 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;
 

	
 
		/* Get industry tile ID at offset */
 
		case 0x62: return GetIndustryIDAtOffset(GetNearbyTile(parameter, tile), inds);
 
	}
 

	
 
	DEBUG(grf, 1, "Unhandled industry tile property 0x%X", variable);
 

	
 
	*available = false;
 
	return UINT_MAX;
 
}
 

	
 
static const SpriteGroup *IndustryTileResolveReal(const ResolverObject *object, const RealSpriteGroup *group)
 
{
 
	/* IndustryTile do not have 'real' groups.  Or do they?? */
 
	return NULL;
 
}
 

	
 
static uint32 IndustryTileGetRandomBits(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) ? 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)
 
{
 
	const TileIndex tile = object->u.industry.tile;
 
	if (tile == INVALID_TILE || !IsTileType(tile, MP_INDUSTRY)) return;
 

	
 
	if (object->scope == VSG_SCOPE_SELF) {
 
		SetIndustryTriggers(tile, triggers);
 
	} else {
 
		GetIndustryByTile(tile)->random_triggers = triggers;
 
		Industry::GetByTile(tile)->random_triggers = triggers;
 
	}
 
}
 

	
 
static void NewIndustryTileResolver(ResolverObject *res, IndustryGfx gfx, TileIndex tile, Industry *indus)
 
{
 
	res->GetRandomBits = IndustryTileGetRandomBits;
 
	res->GetTriggers   = IndustryTileGetTriggers;
 
	res->SetTriggers   = IndustryTileSetTriggers;
 
	res->GetVariable   = IndustryTileGetVariable;
 
	res->ResolveReal   = IndustryTileResolveReal;
 

	
 
	res->psa             = &indus->psa;
 
@@ -290,25 +290,25 @@ bool PerformIndustryTileSlopeCheck(TileI
 
	SwitchToNormalRefStack();
 

	
 
	switch (callback_res) {
 
		case 0x401: _error_message = STR_ERROR_SITE_UNSUITABLE;                 return false;
 
		case 0x402: _error_message = STR_ERROR_CAN_ONLY_BE_BUILT_IN_RAINFOREST; return false;
 
		case 0x403: _error_message = STR_ERROR_CAN_ONLY_BE_BUILT_IN_DESERT;     return false;
 
		default: _error_message = GetGRFStringID(its->grf_prop.grffile->grfid, 0xD000 + callback_res); return false;
 
	}
 
}
 

	
 
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;
 

	
 
	if (HasBit(itspec->callback_flags, CBM_INDT_ANIM_SPEED)) {
 
		uint16 callback_res = GetIndustryTileCallback(CBID_INDTILE_ANIMATION_SPEED, 0, 0, gfx, ind, tile);
 
		if (callback_res != CALLBACK_FAILED) animation_speed = Clamp(callback_res & 0xFF, 0, 16);
 
	}
 

	
 
	/* An animation speed of 2 means the animation frame changes 4 ticks, and
 
	 * increasing this value by one doubles the wait. 0 is the minimum value
 
	 * allowed for animation_speed, which corresponds to 30ms, and 16 is the
 
@@ -378,25 +378,25 @@ static void ChangeIndustryTileAnimationF
 
	/* If the lower 7 bits of the upper byte of the callback
 
	 * result are not empty, it is a sound effect. */
 
	if (GB(callback_res, 8, 7) != 0) PlayTileSound(itspec->grf_prop.grffile, GB(callback_res, 8, 7), tile);
 
}
 

	
 
bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32 random)
 
{
 
	IndustryGfx gfx = GetIndustryGfx(tile);
 
	const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx);
 

	
 
	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;
 
}
 

	
 
bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigger iat)
 
{
 
	bool ret = true;
 
	uint32 random = Random();
 
	TILE_LOOP(tile, ind->width, ind->height, ind->xy) {
 
		if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == ind->index) {
 
			if (StartStopIndustryTileAnimation(tile, iat, random)) {
 
				SB(random, 0, 16, Random());
 
@@ -427,23 +427,23 @@ static void DoTriggerIndustryTile(TileIn
 
	if (group == NULL) return;
 

	
 
	byte new_random_bits = Random();
 
	byte random_bits = GetIndustryRandomBits(tile);
 
	random_bits &= ~object.reseed;
 
	random_bits |= new_random_bits & object.reseed;
 
	SetIndustryRandomBits(tile, random_bits);
 
	MarkTileDirtyByTile(tile);
 
}
 

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

	
 
void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
 
{
 
	TILE_LOOP(tile, ind->width, ind->height, ind->xy) {
 
		if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == ind->index) {
 
			DoTriggerIndustryTile(tile, trigger, ind);
 
		}
 
	}
 
}
src/saveload/afterload.cpp
Show inline comments
 
@@ -13,25 +13,25 @@
 
#include "../void_map.h"
 
#include "../signs_base.h"
 
#include "../roadstop_base.h"
 
#include "../window_func.h"
 
#include "../fios.h"
 
#include "../train.h"
 
#include "../string_func.h"
 
#include "../gamelog.h"
 
#include "../gamelog_internal.h"
 
#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"
 
#include "../newgrf_station.h"
 
#include "../yapf/yapf.hpp"
 
#include "../elrail_func.h"
 
#include "../signs_func.h"
 
#include "../aircraft.h"
 
#include "../unmovable_map.h"
 
#include "../tree_map.h"
 
#include "../company_func.h"
 
#include "../road_cmd.h"
src/smallmap_gui.cpp
Show inline comments
 
@@ -2,25 +2,25 @@
 

	
 
/*
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file smallmap_gui.cpp GUI that shows a small map of the world with metadata like owner or height. */
 

	
 
#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"
 
#include "tree_map.h"
 
#include "viewport_func.h"
 
#include "gfx_func.h"
 
#include "town.h"
 
#include "blitter/factory.hpp"
 
#include "tunnelbridge_map.h"
 
#include "strings_func.h"
 
#include "zoom_func.h"
 
#include "core/endian_func.hpp"
 
@@ -399,26 +399,26 @@ static inline uint32 GetSmallMapVehicles
 
/**
 
 * Return the colour a tile would be displayed with in the small map in mode "Industries".
 
 *
 
 * @param tile The tile of which we would like to get the colour.
 
 * @return The colour of tile in the small map in mode "Industries"
 
 */
 
static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile)
 
{
 
	TileType t = GetEffectiveTileType(tile);
 

	
 
	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]);
 
		}
 
	}
 

	
 
	return ApplyMask(MKCOLOUR(0x54545454), &_smallmap_vehicles_andor[t]);
 
}
 

	
 
/**
 
 * Return the colour a tile would be displayed with in the small map in mode "Routes".
 
 *
 
@@ -456,25 +456,25 @@ static const uint32 _vegetation_clear_bi
 
	MKCOLOUR(0x54545454), ///< unused
 
};
 

	
 
static inline uint32 GetSmallMapVegetationPixels(TileIndex tile)
 
{
 
	TileType t = GetEffectiveTileType(tile);
 

	
 
	switch (t) {
 
		case MP_CLEAR:
 
			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) {
 
				return (_settings_game.game_creation.landscape == LT_ARCTIC) ? MKCOLOUR(0x98575798) : MKCOLOUR(0xC25757C2);
 
			}
 
			return MKCOLOUR(0x54575754);
 

	
 
		default:
 
			return ApplyMask(MKCOLOUR(0x54545454), &_smallmap_vehicles_andor[t]);
 
	}
 
}
 

	
src/station.cpp
Show inline comments
 
@@ -2,45 +2,44 @@
 

	
 
/*
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file station.cpp Implementation of the station base class. */
 

	
 
#include "stdafx.h"
 
#include "company_func.h"
 
#include "industry.h"
 
#include "newgrf_cargo.h"
 
#include "yapf/yapf.h"
 
#include "cargotype.h"
 
#include "roadveh.h"
 
#include "window_type.h"
 
#include "station_gui.h"
 
#include "zoom_func.h"
 
#include "functions.h"
 
#include "window_func.h"
 
#include "date_func.h"
 
#include "command_func.h"
 
#include "news_func.h"
 
#include "aircraft.h"
 
#include "vehicle_gui.h"
 
#include "settings_type.h"
 
#include "subsidy_func.h"
 
#include "core/pool_func.hpp"
 
#include "station_base.h"
 
#include "roadstop_base.h"
 
#include "industry_map.h"
 
#include "industry.h"
 

	
 
#include "table/strings.h"
 

	
 
StationPool _station_pool("Station");
 
INSTANTIATE_POOL_METHODS(Station)
 

	
 
BaseStation::~BaseStation()
 
{
 
	free(this->name);
 
	free(this->speclist);
 
}
 

	
 
@@ -275,25 +274,25 @@ struct RectAndIndustryVector {
 
 * Tests whether tile is an industry and possibly adds
 
 * the industry to station's industries_near list.
 
 * @param ind_tile tile to check
 
 * @param user_data pointer to RectAndIndustryVector
 
 * @return always false, we want to search all tiles
 
 */
 
static bool FindIndustryToDeliver(TileIndex ind_tile, void *user_data)
 
{
 
	/* Only process industry tiles */
 
	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;
 

	
 
	/* Only process tiles in the station acceptance rectangle */
 
	int x = TileX(ind_tile);
 
	int y = TileY(ind_tile);
 
	if (x < riv->rect.left || x > riv->rect.right || y < riv->rect.top || y > riv->rect.bottom) return false;
 

	
 
	/* Include only industries that can accept cargo */
 
	uint cargo_index;
 
	for (cargo_index = 0; cargo_index < lengthof(ind->accepts_cargo); cargo_index++) {
src/station_cmd.cpp
Show inline comments
 
@@ -12,25 +12,25 @@
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "aircraft.h"
 
#include "bridge_map.h"
 
#include "cmd_helper.h"
 
#include "landscape.h"
 
#include "viewport_func.h"
 
#include "command_func.h"
 
#include "town.h"
 
#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"
 
#include "road_internal.h" /* For drawing catenary/checking road removal */
 
#include "variables.h"
 
#include "autoslope.h"
 
#include "water.h"
 
#include "station_gui.h"
 
#include "strings_func.h"
 
#include "functions.h"
 
#include "window_func.h"
 
#include "date_func.h"
 
@@ -134,25 +134,25 @@ static int CountMapSquareAround(TileInde
 
}
 

	
 
/**
 
 * Check whether the tile is a mine.
 
 * @param tile the tile to investigate.
 
 * @return true if and only if the tile is a mine
 
 */
 
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;
 

	
 
	for (uint i = 0; i < lengthof(ind->produced_cargo); i++) {
 
		/* The industry extracts something non-liquid, i.e. no oil or plastic, so it is a mine.
 
		 * Also the production of passengers and mail is ignored. */
 
		if (ind->produced_cargo[i] != CT_INVALID &&
 
				(CargoSpec::Get(ind->produced_cargo[i])->classes & (CC_LIQUID | CC_PASSENGERS | CC_MAIL)) == 0) {
 
			return true;
 
		}
 
	}
 
@@ -181,25 +181,25 @@ static bool CMSATree(TileIndex tile)
 
}
 

	
 
/**
 
 * Check whether the tile is a forest.
 
 * @param tile the tile to investigate.
 
 * @return true if and only if the tile is a mine
 
 */
 
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;
 

	
 
	for (uint i = 0; i < lengthof(ind->produced_cargo); i++) {
 
		/* The industry produces wood. */
 
		if (ind->produced_cargo[i] != CT_INVALID && CargoSpec::Get(ind->produced_cargo[i])->label == 'WOOD') return true;
 
	}
 

	
 
	return false;
 
}
 

	
src/water_cmd.cpp
Show inline comments
 
@@ -14,25 +14,25 @@
 
#include "cmd_helper.h"
 
#include "landscape.h"
 
#include "viewport_func.h"
 
#include "command_func.h"
 
#include "town.h"
 
#include "news_func.h"
 
#include "depot_base.h"
 
#include "depot_func.h"
 
#include "vehicle_gui.h"
 
#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"
 
#include "strings_func.h"
 
#include "functions.h"
 
#include "window_func.h"
 
#include "vehicle_func.h"
 
#include "sound_func.h"
 
#include "company_func.h"
 
#include "clear_map.h"
 
#include "tree_map.h"
 
#include "aircraft.h"
0 comments (0 inline, 0 general)