# industry_cmd.cpp File Reference

Handling of industry tiles. More...

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "clear_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"`
`#include "newgrf_cargo.h"`
`#include "newgrf_commons.h"`
`#include "newgrf_industries.h"`
`#include "newgrf_industrytiles.h"`
`#include "autoslope.h"`
`#include "transparency.h"`
`#include "water.h"`
`#include "strings_func.h"`
`#include "functions.h"`
`#include "window_func.h"`
`#include "date_func.h"`
`#include "vehicle_func.h"`
`#include "sound_func.h"`
`#include "animated_tile_func.h"`
`#include "effectvehicle_func.h"`
`#include "ai/ai.hpp"`
`#include "core/pool_func.hpp"`
`#include "subsidy_func.h"`
`#include "table/strings.h"`
`#include "table/industry_land.h"`
`#include "table/build_industry.h"`

Go to the source code of this file.

## Data Structures
struct | ProbabilityHelper
| Simple helper that will collect data for the generation of industries. More...
## Typedefs
typedef void | IndustryDrawTileProc (const TileInfo *ti)
typedef bool | CheckNewIndustryProc (TileIndex tile)
## Enumerations
enum | ProductionLevels { PRODLEVEL_CLOSURE = 0x00, PRODLEVEL_MINIMUM = 0x04, PRODLEVEL_DEFAULT = 0x10, PRODLEVEL_MAXIMUM = 0x80 }
| Production level maximum, minimum and default values. More...
enum | { NB_NUMOFINDUSTRY = 11, NB_DIFFICULTY_LEVEL = 5 }
enum | { PERCENT_TRANSPORTED_60 = 153, PERCENT_TRANSPORTED_80 = 204 }
## Functions
void | ShowIndustryViewWindow (int industry)
void | BuildOilRig (TileIndex tile)
void | ResetIndustries ()
| This function initialize the spec arrays of both industry and industry tiles.
void | ResetIndustryCreationProbility (IndustryType type)
IndustryType | GetIndustryType (TileIndex tile)
| Retrieve the type for this industry.
const IndustrySpec * | GetIndustrySpec (IndustryType thistype)
| Accessor for array _industry_specs.
const IndustryTileSpec * | GetIndustryTileSpec (IndustryGfx gfx)
| Accessor for array _industry_tile_specs.
static void | IndustryDrawSugarMine (const TileInfo *ti)
static void | IndustryDrawToffeeQuarry (const TileInfo *ti)
static void | IndustryDrawBubbleGenerator (const TileInfo *ti)
static void | IndustryDrawToyFactory (const TileInfo *ti)
static void | IndustryDrawCoalPlantSparks (const TileInfo *ti)
static void | DrawTile_Industry (TileInfo *ti)
static uint | GetSlopeZ_Industry (TileIndex tile, uint x, uint y)
static Foundation | GetFoundation_Industry (TileIndex tile, Slope tileh)
static void | AddAcceptedCargo_Industry (TileIndex tile, CargoArray &acceptance, uint32 *always_accepted)
static void | GetTileDesc_Industry (TileIndex tile, TileDesc *td)
static CommandCost | ClearTile_Industry (TileIndex tile, DoCommandFlag flags)
static void | TransportIndustryGoods (TileIndex tile)
static void | AnimateTile_Industry (TileIndex tile)
static void | CreateChimneySmoke (TileIndex tile)
static void | MakeIndustryTileBigger (TileIndex tile)
static void | TileLoopIndustry_BubbleGenerator (TileIndex tile)
static void | TileLoop_Industry (TileIndex tile)
static bool | ClickTile_Industry (TileIndex tile)
static TrackStatus | GetTileTrackStatus_Industry (TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
static void | ChangeTileOwner_Industry (TileIndex tile, Owner old_owner, Owner new_owner)
static bool | IsBadFarmFieldTile (TileIndex tile)
static bool | IsBadFarmFieldTile2 (TileIndex tile)
static void | SetupFarmFieldFence (TileIndex tile, int size, byte type, Axis direction)
static void | PlantFarmField (TileIndex tile, IndustryID industry)
void | PlantRandomFarmField (const Industry *i)
static bool | SearchLumberMillTrees (TileIndex tile, void *user_data)
| Search callback function for ChopLumberMillTrees.
static void | ChopLumberMillTrees (Industry *i)
| Perform a circular search around the Lumber Mill in order to find trees to cut.
static void | ProduceIndustryGoods (Industry *i)
void | OnTick_Industry ()
static bool | CheckNewIndustry_NULL (TileIndex tile)
static bool | CheckNewIndustry_Forest (TileIndex tile)
static bool | CheckNewIndustry_OilRefinery (TileIndex tile)
static bool | CheckNewIndustry_OilRig (TileIndex tile)
static bool | CheckNewIndustry_Farm (TileIndex tile)
static bool | CheckNewIndustry_Plantation (TileIndex tile)
static bool | CheckNewIndustry_Water (TileIndex tile)
static bool | CheckNewIndustry_Lumbermill (TileIndex tile)
static bool | CheckNewIndustry_BubbleGen (TileIndex tile)
static const Town * | CheckMultipleIndustryInTown (TileIndex tile, int type)
bool | IsSlopeRefused (Slope current, Slope refused)
static bool | CheckIfIndustryTilesAreFree (TileIndex tile, const IndustryTileTable *it, uint itspec_index, int type, bool *custom_shape_check=NULL)
static bool | CheckIfIndustryIsAllowed (TileIndex tile, int type, const Town *t)
static bool | CheckCanTerraformSurroundingTiles (TileIndex tile, uint height, int internal)
static bool | CheckIfCanLevelIndustryPlatform (TileIndex tile, DoCommandFlag flags, const IndustryTileTable *it, int type)
| This function tries to flatten out the land below an industry, without damaging the surroundings too much.
static bool | CheckIfFarEnoughFromIndustry (TileIndex tile, int type)
static void | DoCreateNewIndustry (Industry *i, TileIndex tile, int type, const IndustryTileTable *it, byte layout, const Town *t, Owner owner, Owner founder)
static Industry * | CreateNewIndustryHelper (TileIndex tile, IndustryType type, DoCommandFlag flags, const IndustrySpec *indspec, uint itspec_index, uint32 seed, Owner founder)
| Helper function for Build/Fund an industry.
CommandCost | CmdBuildIndustry (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build/Fund an industry.
static Industry * | CreateNewIndustry (TileIndex tile, IndustryType type)
static void | PlaceInitialIndustry (IndustryType type, int amount)
| This function is the one who really do the creation work of random industries during game creation.
void | GenerateIndustries ()
| This function will create ramdon industries during game creation.
static void | UpdateIndustryStatistics (Industry *i)
static void | MaybeNewIndustry ()
| Try to create a random industry, during gameplay.
static bool | CheckIndustryCloseDownProtection (IndustryType type)
| Protects an industry from closure if the appropriate flags and conditions are met INDUSTRYBEH_CANCLOSE_LASTINSTANCE must be set (which, by default, it is not) and the count of industries of this type must one (or lower) in order to be protected against closure.
static void | CanCargoServiceIndustry (CargoID cargo, Industry *ind, bool *c_accepts, bool *c_produces)
| Can given cargo type be accepted or produced by the industry?
static int | WhoCanServiceIndustry (Industry *ind)
| Compute who can service the industry.
static void | ReportNewsProductionChangeIndustry (Industry *ind, CargoID type, int percent)
| Report news that industry production has changed significantly.
static void | ChangeIndustryProduction (Industry *i, bool monthly)
| Change industry production or do closure.
void | IndustryDailyLoop ()
| Daily handler for the industry changes Taking the original map size of 256*256, the number of random changes was always of just one unit.
void | IndustryMonthlyLoop ()
void | InitializeIndustries ()
static CommandCost | TerraformTile_Industry (TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
## Variables
IndustryPool | _industry_pool ("Industry")
static byte | _industry_sound_ctr
static TileIndex | _industry_sound_tile
uint16 | _industry_counts [NUM_INDUSTRYTYPES]
| Number of industries per type ingame.
IndustrySpec | _industry_specs [NUM_INDUSTRYTYPES]
IndustryTileSpec | _industry_tile_specs [NUM_INDUSTRYTILES]
static IndustryDrawTileProc *const | _industry_draw_tile_procs [5]
static const byte | _plantfarmfield_type [] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6}
bool | _ignore_restrictions
static CheckNewIndustryProc *const | _check_new_industry_procs [CHECK_END]
static const byte | _numof_industry_table [NB_DIFFICULTY_LEVEL][NB_NUMOFINDUSTRY]
const TileTypeProcs | _tile_type_industry_procs

## Detailed Description

Handling of industry tiles.

Definition in file industry_cmd.cpp.

## Enumeration Type Documentation

enum ProductionLevels

Production level maximum, minimum and default values.

It is not a value been really used in order to change, but rather an indicator of how the industry is behaving.

Enumerator:

  PRODLEVEL_CLOSURE | signal set to actually close the industry
  PRODLEVEL_MINIMUM | below this level, the industry is set to be closing
  PRODLEVEL_DEFAULT | default level set when the industry is created
  PRODLEVEL_MAXIMUM | the industry is running at full speed

Definition at line 1521 of file industry_cmd.cpp.

## Function Documentation

static void CanCargoServiceIndustry | ( | CargoID | cargo,
|  | Industry * | ind,
|  | bool * | c_accepts,
|  | bool * | c_produces |
| ) |  |  | `[static]`

Can given cargo type be accepted or produced by the industry?

Parameters:

  | cargo,: | Cargo type
  | ind,: | Industry
  | *c_accepts,: | Pointer to boolean for acceptance of cargo
  | *c_produces,: | Pointer to boolean for production of cargo

Returns:
  : `*c_accepts` is set when industry accepts the cargo type, `*c_produces` is set when the industry produces the cargo type

Definition at line 2004 of file industry_cmd.cpp.

References Industry::accepts_cargo, IndustrySpec::callback_mask, CBID_INDUSTRY_REFUSE_CARGO, CBM_IND_REFUSE_CARGO, CT_INVALID, GetIndustrySpec(), IndustrySpec::grf_prop, GRFFileProps::grffile, HasBit(), lengthof, Industry::location, Industry::produced_cargo, TileArea::tile, and Industry::type.

Referenced by WhoCanServiceIndustry().

static void ChangeIndustryProduction | ( | Industry * | i,
|  | bool | monthly |
| ) |  |  | `[static]`

Change industry production or do closure.

Parameters:

  | i | Industry for which changes are performed
  | monthly | true if it's the monthly call, false if it's the random call

< reinitialize production_rate to match prod_level

Definition at line 2134 of file industry_cmd.cpp.

References _cur_year, _settings_game, abs(), AddNewsItem(), IndustrySpec::behaviour, CALLBACK_FAILED, IndustrySpec::callback_mask, CBID_INDUSTRY_MONTHLYPROD_CHANGE, CBID_INDUSTRY_PRODUCTION_CHANGE, CBM_IND_MONTHLYPROD_CHANGE, CBM_IND_PRODUCTION_256_TICKS, CBM_IND_PRODUCTION_CARGO_ARRIVAL, CBM_IND_PRODUCTION_CHANGE, Chance16(), Chance16I(), CheckIndustryCloseDownProtection(), Clamp(), ClampU(), IndustrySpec::closure_text, CT_INVALID, GameSettings::economy, GameSettings::game_creation, GB(), GetIndustrySpec(), GetRegister(), IndustrySpec::grf_prop, GRFFileProps::grffile, GRFFile::grfid, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INDUSTRYBEH_DONT_INCR_PROD, INDUSTRYLIFE_BLACK_HOLE, INDUSTRYLIFE_EXTRACTIVE, INDUSTRYLIFE_ORGANIC, INDUSTRYLIFE_PROCESSING, GameCreationSettings::landscape, Industry::last_month_pct_transported, Industry::last_prod_year, lengthof, IndustrySpec::life_type, Industry::location, MapGRFStringID(), max(), min(), IndustrySpec::name, NR_INDUSTRY, NR_TILE, NS_INDUSTRY_CLOSE, NS_INDUSTRY_COMPANY, NS_INDUSTRY_NOBODY, NS_INDUSTRY_OTHER, Industry::prod_level, PRODLEVEL_CLOSURE, PRODLEVEL_DEFAULT, PRODLEVEL_MAXIMUM, PRODLEVEL_MINIMUM, Industry::produced_cargo, IndustrySpec::production_down_text, IndustrySpec::production_rate, Industry::production_rate, IndustrySpec::production_up_text, ReportNewsProductionChangeIndustry(), SetDParam(), EconomySettings::smooth_economy, TileArea::tile, TileDiffXY(), Industry::town, Industry::type, and WhoCanServiceIndustry().

Referenced by IndustryDailyLoop().

static bool CheckIndustryCloseDownProtection | ( | IndustryType | type | ) | `[static]`

Protects an industry from closure if the appropriate flags and conditions are met INDUSTRYBEH_CANCLOSE_LASTINSTANCE must be set (which, by default, it is not) and the count of industries of this type must one (or lower) in order to be protected against closure.

Parameters:

  | type | IndustryType been queried

Returns:
  true if protection is on, false otherwise (except for oil wells)

Definition at line 1986 of file industry_cmd.cpp.

References _settings_game, IndustrySpec::behaviour, GameSettings::game_creation, GetIndustrySpec(), GetIndustryTypeCount(), INDUSTRYBEH_CANCLOSE_LASTINSTANCE, INDUSTRYBEH_DONT_INCR_PROD, and GameCreationSettings::landscape.

Referenced by ChangeIndustryProduction().

static void ChopLumberMillTrees | ( | Industry * | i | ) | `[static]`

Perform a circular search around the Lumber Mill in order to find trees to cut.

Parameters:

  | i | industry

< Can't proceed if not completed

< 40x40 tiles to search

< Found a tree, add according value to waiting cargo

Definition at line 1073 of file industry_cmd.cpp.

References CircularTileSearch(), IsIndustryCompleted(), Industry::location, min(), Industry::produced_cargo_waiting, SearchLumberMillTrees(), and TileArea::tile.

CommandCost CmdBuildIndustry | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build/Fund an industry.

Parameters:

  | tile | tile where industry is built
  | flags | of operations to conduct
  | p1 | various bitstuffed elements p1 = (bit 0 - 7) - industry type see build_industry.h and see industry.h p1 = (bit 8 - 15) - first layout to try
  | p2 | seed to use for variable 8F
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1706 of file industry_cmd.cpp.

References _settings_game, CMD_ERROR, GameSettings::construction, CreateNewIndustryHelper(), IndustrySpec::enabled, GB(), IndustrySpec::GetConstructionCost(), GetIndustrySpec(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, IndustrySpec::IsRawIndustry(), IndustrySpec::name, IndustrySpec::new_industry_text, NS_INDUSTRY_OPEN, NUM_INDUSTRYTYPES, IndustrySpec::num_table, OWNER_TOWN, IndustrySpec::prospecting_chance, RandomTile, ConstructionSettings::raw_industry_construction, SetDParam(), IndustrySpec::table, and Industry::town.

static Industry* CreateNewIndustryHelper | ( | TileIndex | tile,
|  | IndustryType | type,
|  | DoCommandFlag | flags,
|  | const IndustrySpec * | indspec,
|  | uint | itspec_index,
|  | uint32 | seed,
|  | Owner | founder |
| ) |  |  | `[static]`

Helper function for Build/Fund an industry.

Parameters:

  | tile | tile where industry is built
  | type | of industry to build
  | flags | of operations to conduct
  | indspec | pointer to industry specifications
  | itspec_index | the index of the itsepc to build/fund
  | seed | random seed (possibly) used by industries
  | founder | Founder of the industry

Returns:
  the pointer of the newly created industry, or NULL if it failed

Definition at line 1659 of file industry_cmd.cpp.

References _settings_game, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::CanAllocateItem(), CBM_IND_LOCATION, IndustrySpec::check_proc, CheckIfCanLevelIndustryPlatform(), DC_NO_WATER, GameSettings::game_creation, GetIndustrySpec(), HasBit(), GameCreationSettings::land_generator, LG_TERRAGENESIS, OWNER_NONE, and IndustrySpec::table.

Referenced by CmdBuildIndustry().

void GenerateIndustries | ( |  | ) |

This function will create ramdon industries during game creation.

It will scale the amount of industries by map size as well as difficulty level

Definition at line 1834 of file industry_cmd.cpp.

References _settings_game, IndustrySpec::appear_creation, IndustrySpec::check_proc, GameSettings::difficulty, IndustrySpec::enabled, GameSettings::game_creation, GetIndustrySpec(), GWP_INDUSTRY, IACT_MAPGENERATION, GameCreationSettings::landscape, NUM_INDUSTRYTYPES, IndustrySpec::num_table, DifficultySettings::number_industries, PlaceInitialIndustry(), ScaleByMapSize(), ScaleByMapSize1D(), and SetGeneratingWorldProgress().

Referenced by _GenerateWorld(), and BuildIndustryWindow::OnClick().

const IndustrySpec* GetIndustrySpec | ( | IndustryType | thistype | ) |

Accessor for array _industry_specs.

Array of industries data.

This will ensure at once : proper access and not allowing modifications of it.

Parameters:

  | thistype | of industry (which is the index in _industry_specs)

Precondition:
  thistype < NUM_INDUSTRYTYPES

Returns:
  a pointer to the corresponding industry spec

Definition at line 119 of file industry_cmd.cpp.

References NUM_INDUSTRYTYPES.

Referenced by BuildIndustriesLegend(), AIIndustryType::BuildIndustry(), AIIndustryType::CanBuildIndustry(), CanCargoServiceIndustry(), AIIndustryType::CanProspectIndustry(), ChangeIndustryProduction(), CheckIndustryCloseDownProtection(), CmdBuildIndustry(), CMSAForest(), CMSAMine(), CreateNewIndustryHelper(), DeliverGoodsToIndustry(), Disaster_CoalMine_Init(), Disaster_Helicopter_Init(), DisasterTick_Aircraft(), BuildIndustryWindow::DrawWidget(), FindNearIndustryName(), GenerateIndustries(), AIIndustryType::GetAcceptedCargo(), AIIndustryType::GetConstructionCost(), GetCountAndDistanceOfClosestInstance(), GetIndustryIDAtOffset(), IndustryDirectoryWindow::GetIndustryString(), AIIndustryType::GetName(), AIIndustryType::GetProducedCargo(), GetSmallMapIndustriesPixels(), GetSmallMapVegetationPixels(), AIIndustryType::HasDock(), AIIndustry::HasDock(), AIIndustryType::HasHeliport(), AIIndustry::HasHeliport(), IndustryGetVariable(), IndustryProductionCallback(), AIIndustryType::IsBuiltOnWater(), AIIndustry::IsBuiltOnWater(), AIIndustryType::IsRawIndustry(), AIIndustryType::IsValidIndustryType(), MaybeNewIndustry(), BuildIndustryWindow::OnClick(), BuildIndustryWindow::OnInvalidateData(), BuildIndustryWindow::OnPlaceObject(), BuildIndustryWindow::OnTick(), PlaceInitialIndustry(), AIIndustryType::ProductionCanIncrease(), BuildIndustryWindow::SetStringParameters(), TriggerIndustryProduction(), and BuildIndustryWindow::UpdateWidgetSize().

const IndustryTileSpec* GetIndustryTileSpec | ( | IndustryGfx | gfx | ) |

Accessor for array _industry_tile_specs.

Array of industry tiles data.

This will ensure at once : proper access and not allowing modifications of it.

Parameters:

  | gfx | of industrytile (which is the index in _industry_tile_specs)

Precondition:
  gfx < INVALID_INDUSTRYTILE

Returns:
  a pointer to the corresponding industrytile spec

Definition at line 133 of file industry_cmd.cpp.

References INVALID_INDUSTRYTILE.

Referenced by GetIndustryIDAtOffset().

IndustryType GetIndustryType | ( | TileIndex | tile | ) |

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.

Parameters:

  | tile | that is queried

Precondition:
  IsTileType(tile, MP_INDUSTRY)

Returns:
  general type for this industry, as defined in industry.h

Definition at line 102 of file industry_cmd.cpp.

References Industry::GetByTile(), IsTileType(), MP_INDUSTRY, and Industry::type.

Referenced by FindNearIndustryName().

void IndustryDailyLoop | ( |  | ) |

Daily handler for the industry changes Taking the original map size of 256*256, the number of random changes was always of just one unit.

But it cannot be the same on smaller or bigger maps. That number has to be scaled up or down. For small maps, it implies that less than one change per month is required, while on bigger maps, it would be way more. The daily loop handles those changes.

Definition at line 2336 of file industry_cmd.cpp.

References Chance16(), ChangeIndustryProduction(), Industry::GetRandom(), InvalidateWindowData(), MaybeNewIndustry(), and OWNER_NONE.

Referenced by OnNewDay().

static void PlaceInitialIndustry | ( | IndustryType | type,
|  | int | amount |
| ) |  |  | `[static]`

This function is the one who really do the creation work of random industries during game creation.

Parameters:

  | type | IndustryType of the desired industry
  | amount | of industries that need to be built

Definition at line 1803 of file industry_cmd.cpp.

References _settings_game, GameSettings::difficulty, GetIndustrySpec(), GWP_INDUSTRY, IncreaseGeneratingWorldProgress(), DifficultySettings::number_industries, OWNER_NONE, RandomTile, ScaleByMapSize(), and ScaleByMapSize1D().

Referenced by GenerateIndustries().

static void ReportNewsProductionChangeIndustry | ( | Industry * | ind,
|  | CargoID | type,
|  | int | percent |
| ) |  |  | `[static]`

Report news that industry production has changed significantly.

Parameters:

  | ind,: | Industry with changed production
  | type,: | Cargo type that has changed
  | percent,: | Percentage of change (>0 means increase, <0 means decrease)

Definition at line 2105 of file industry_cmd.cpp.

References abs(), CargoSpec::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, NS_INDUSTRY_COMPANY, NS_INDUSTRY_NOBODY, NS_INDUSTRY_OTHER, SetDParam(), and WhoCanServiceIndustry().

Referenced by ChangeIndustryProduction().

void ResetIndustries | ( |  | ) |

This function initialize the spec arrays of both industry and industry tiles.

It adjusts the enabling of the industry too, based on climate availability. This will allow for clearer testings

Definition at line 69 of file industry_cmd.cpp.

References _settings_game, IndustrySpec::enabled, GameSettings::game_creation, HasBit(), GameCreationSettings::landscape, and NEW_INDUSTRYOFFSET.

Referenced by ResetNewGRFData().

static bool SearchLumberMillTrees | ( | TileIndex | tile,
|  | void * | user_data |
| ) |  |  | `[static]`

Search callback function for ChopLumberMillTrees.

Parameters:

  | tile | to test
  | user_data | that is passed by the caller. In this case, nothing

Returns:
  the result of the test

< 3 and up means all fully grown trees

Definition at line 1050 of file industry_cmd.cpp.

References CMD_LANDSCAPE_CLEAR, DoCommand(), GetTreeGrowth(), IsTileType(), MP_TREES, and OWNER_NONE.

Referenced by ChopLumberMillTrees().

static int WhoCanServiceIndustry | ( | Industry * | ind | ) | `[static]`

Compute who can service the industry.

Here, 'can service' means that he/she has trains and stations close enough to the industry with the right cargo type and the right orders (ie has the technical means).

Parameters:

  | ind,: | Industry being investigated.

Returns:
  : 0 if nobody can service the industry, 2 if the local company can service the industry, and 1 otherwise (only competitors can service the industry)

Definition at line 2046 of file industry_cmd.cpp.

References CanCargoServiceIndustry(), SmallVector< T, S >::Contains(), FindStationsAroundTiles(), SpecializedVehicle< Train, VEH_TRAIN >::From(), SpecializedStation< Station, false >::Get(), Train::IsFrontEngine(), SmallVector< T, S >::Length(), Industry::location, OUFB_TRANSFER, OUFB_UNLOAD, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by ChangeIndustryProduction(), and ReportNewsProductionChangeIndustry().

## Variable Documentation

CheckNewIndustryProc* const _check_new_industry_procs[CHECK_END]`[static]`

Initial value:

     {
      CheckNewIndustry_NULL,
      CheckNewIndustry_Forest,
      CheckNewIndustry_OilRefinery,
      CheckNewIndustry_Farm,
      CheckNewIndustry_Plantation,
      CheckNewIndustry_Water,
      CheckNewIndustry_Lumbermill,
      CheckNewIndustry_BubbleGen,
      CheckNewIndustry_OilRig
    }

Definition at line 1237 of file industry_cmd.cpp.

IndustryDrawTileProc* const _industry_draw_tile_procs[5]`[static]`

Initial value:

     {
      IndustryDrawSugarMine,
      IndustryDrawToffeeQuarry,
      IndustryDrawBubbleGenerator,
      IndustryDrawToyFactory,
      IndustryDrawCoalPlantSparks,
    }

Definition at line 300 of file industry_cmd.cpp.

const byte _numof_industry_table[NB_DIFFICULTY_LEVEL][NB_NUMOFINDUSTRY]`[static]`

Initial value:

     {

      {0, 0, 0, 0, 0, 0, 0, 0,  0,  0,  0},
      {0, 1, 1, 1, 1, 1, 1, 1,  1,  1,  1},
      {0, 1, 1, 1, 2, 2, 3, 3,  4,  4,  5},
      {0, 1, 2, 3, 4, 5, 6, 7,  8,  9, 10},
      {0, 2, 3, 4, 6, 7, 8, 9, 10, 10, 10},
    }

Definition at line 1790 of file industry_cmd.cpp.

const TileTypeProcs _tile_type_industry_procs

Initial value:

     {
      DrawTile_Industry,
      GetSlopeZ_Industry,
      ClearTile_Industry,
      AddAcceptedCargo_Industry,
      GetTileDesc_Industry,
      GetTileTrackStatus_Industry,
      ClickTile_Industry,
      AnimateTile_Industry,
      TileLoop_Industry,
      ChangeTileOwner_Industry,
      NULL,
      NULL,
      GetFoundation_Industry,
      TerraformTile_Industry,
    }