45 #include "table/strings.h" 54 void ShowIndustryViewWindow(
int industry);
57 static byte _industry_sound_ctr;
74 memset(&_industry_specs, 0,
sizeof(_industry_specs));
75 memcpy(&_industry_specs, &_origin_industry_specs,
sizeof(_origin_industry_specs));
83 memset(&_industry_tile_specs, 0,
sizeof(_industry_tile_specs));
84 memcpy(&_industry_tile_specs, &_origin_industry_tile_specs,
sizeof(_origin_industry_tile_specs));
119 return &_industry_specs[thistype];
133 return &_industry_tile_specs[gfx];
136 Industry::~Industry()
154 DeleteOilRig(tile_cur);
223 static void IndustryDrawSugarMine(
const TileInfo *ti)
237 _drawtile_proc1[d->
image_3 - 1].x, _drawtile_proc1[d->
image_3 - 1].y);
241 static void IndustryDrawToffeeQuarry(
const TileInfo *ti)
256 static void IndustryDrawBubbleGenerator(
const TileInfo *ti)
264 static void IndustryDrawToyFactory(
const TileInfo *ti)
280 static void IndustryDrawCoalPlantSparks(
const TileInfo *ti)
285 if (image != 0 && image < 7) {
295 typedef void IndustryDrawTileProc(
const TileInfo *ti);
296 static IndustryDrawTileProc *
const _industry_draw_tile_procs[5] = {
297 IndustryDrawSugarMine,
298 IndustryDrawToffeeQuarry,
299 IndustryDrawBubbleGenerator,
300 IndustryDrawToyFactory,
301 IndustryDrawCoalPlantSparks,
304 static void DrawTile_Industry(
TileInfo *ti)
341 DrawWaterClassGround(ti);
350 image = dits->building.
sprite;
353 ti->
x + dits->subtile_x,
354 ti->
y + dits->subtile_y,
365 int proc = dits->draw_proc - 1;
366 if (proc >= 0) _industry_draw_tile_procs[proc](ti);
370 static int GetSlopePixelZ_Industry(
TileIndex tile, uint x, uint y)
393 static void AddAcceptedCargo_Industry(
TileIndex tile,
CargoArray &acceptance, uint32 *always_accepted)
404 const uint8 *cargo_acceptance = itspec->
acceptance;
409 accepts_cargo = raw_accepts_cargo;
417 cargo_acceptance = raw_cargo_acceptance;
425 if (a ==
CT_INVALID || cargo_acceptance[i] == 0)
continue;
428 acceptance[a] += cargo_acceptance[i];
431 if (
HasBit(*always_accepted, a))
continue;
433 bool accepts =
false;
442 if (accepts)
continue;
445 SetBit(*always_accepted, a);
458 td->
str = STR_LAI_TOWN_INDUSTRY_DESCRIPTION_UNDER_CONSTRUCTION;
503 bool moved_cargo =
false;
520 moved_cargo |= (am != 0);
528 static void AnimateTile_Industry(
TileIndex tile)
533 AnimateNewIndustryTile(tile);
538 case GFX_SUGAR_MINE_SIEVE:
544 case 2: SndPlayTileFx(SND_2D_RIP_2, tile);
break;
545 case 6: SndPlayTileFx(SND_29_RIP, tile);
break;
559 case GFX_TOFFEE_QUARY:
564 SndPlayTileFx(SND_30_CARTOON_SOUND, tile);
577 case GFX_BUBBLE_CATCHER:
592 case GFX_POWERPLANT_SPARKS:
605 case GFX_TOY_FACTORY:
630 case GFX_PLASTIC_FOUNTAIN_ANIMATED_1:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_2:
631 case GFX_PLASTIC_FOUNTAIN_ANIMATED_3:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_4:
632 case GFX_PLASTIC_FOUNTAIN_ANIMATED_5:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_6:
633 case GFX_PLASTIC_FOUNTAIN_ANIMATED_7:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_8:
637 gfx = (gfx < 155) ? gfx + 1 : 148;
643 case GFX_OILWELL_ANIMATED_1:
644 case GFX_OILWELL_ANIMATED_2:
645 case GFX_OILWELL_ANIMATED_3:
651 if (m == 4 && (m = 0, ++gfx) == GFX_OILWELL_ANIMATED_3 + 1 && (gfx = GFX_OILWELL_ANIMATED_1, b)) {
663 case GFX_COAL_MINE_TOWER_ANIMATED:
664 case GFX_COPPER_MINE_TOWER_ANIMATED:
665 case GFX_GOLD_MINE_TOWER_ANIMATED: {
668 if ((state -= 0x400) < 0)
return;
671 if (state < 0x20 || state >= 0x180) {
677 if (state & 7)
return;
679 if (state & 3)
return;
682 if (m > 0xC2) m = 0xC0;
685 }
else if (state >= 0x200 && state < 0x3A0) {
686 int i = (state < 0x220 || state >= 0x380) ? 7 : 3;
687 if (state & i)
return;
690 if (m < 0x80) m = 0x82;
699 static void CreateChimneySmoke(
TileIndex tile)
708 static void MakeIndustryTileBigger(
TileIndex tile)
733 case GFX_POWERPLANT_CHIMNEY:
734 CreateChimneySmoke(tile);
752 case GFX_TOY_FACTORY:
753 case GFX_BUBBLE_CATCHER:
754 case GFX_TOFFEE_QUARY:
759 case GFX_PLASTIC_FOUNTAIN_ANIMATED_1:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_2:
760 case GFX_PLASTIC_FOUNTAIN_ANIMATED_3:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_4:
761 case GFX_PLASTIC_FOUNTAIN_ANIMATED_5:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_6:
762 case GFX_PLASTIC_FOUNTAIN_ANIMATED_7:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_8:
768 static void TileLoopIndustry_BubbleGenerator(
TileIndex tile)
770 static const int8 _bubble_spawn_location[3][4] = {
778 int dir = Random() & 3;
783 _bubble_spawn_location[2][dir],
790 static void TileLoop_Industry(
TileIndex tile)
803 MakeIndustryTileBigger(tile);
807 if (_game_mode == GM_EDITOR)
return;
821 if (StartStopIndustryTileAnimation(tile,
IAT_TILELOOP))
return;
833 case GFX_COAL_MINE_TOWER_NOT_ANIMATED:
834 case GFX_COPPER_MINE_TOWER_NOT_ANIMATED:
835 case GFX_GOLD_MINE_TOWER_NOT_ANIMATED:
838 case GFX_COAL_MINE_TOWER_NOT_ANIMATED: gfx = GFX_COAL_MINE_TOWER_ANIMATED;
break;
839 case GFX_COPPER_MINE_TOWER_NOT_ANIMATED: gfx = GFX_COPPER_MINE_TOWER_ANIMATED;
break;
840 case GFX_GOLD_MINE_TOWER_NOT_ANIMATED: gfx = GFX_GOLD_MINE_TOWER_ANIMATED;
break;
848 case GFX_OILWELL_NOT_ANIMATED:
856 case GFX_COAL_MINE_TOWER_ANIMATED:
857 case GFX_COPPER_MINE_TOWER_ANIMATED:
858 case GFX_GOLD_MINE_TOWER_ANIMATED:
861 case GFX_COAL_MINE_TOWER_ANIMATED: gfx = GFX_COAL_MINE_TOWER_NOT_ANIMATED;
break;
862 case GFX_COPPER_MINE_TOWER_ANIMATED: gfx = GFX_COPPER_MINE_TOWER_NOT_ANIMATED;
break;
863 case GFX_GOLD_MINE_TOWER_ANIMATED: gfx = GFX_GOLD_MINE_TOWER_NOT_ANIMATED;
break;
872 case GFX_POWERPLANT_SPARKS:
879 case GFX_COPPER_MINE_CHIMNEY:
884 case GFX_TOY_FACTORY: {
894 case GFX_BUBBLE_GENERATOR:
895 TileLoopIndustry_BubbleGenerator(tile);
898 case GFX_TOFFEE_QUARY:
902 case GFX_SUGAR_MINE_SIEVE:
908 static bool ClickTile_Industry(
TileIndex tile)
950 static const byte _plantfarmfield_type[] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6};
964 default:
return false;
985 if (or_ == 1 &&
Chance16(1, 7)) or_ = 2;
994 static void PlantFarmField(
TileIndex tile, IndustryID industry)
1001 uint32 r = (Random() & 0x303) + 0x404;
1003 uint size_x =
GB(r, 0, 8);
1004 uint size_y =
GB(r, 8, 8);
1009 if (ta.
w == 0 || ta.
h == 0)
return;
1017 if (count * 2 < ta.
w * ta.
h)
return;
1022 uint field_type =
GB(r, 8, 8) * 9 >> 8;
1028 MakeField(cur_tile, field_type, industry);
1036 type = _plantfarmfield_type[Random() & 0xF];
1045 void PlantRandomFarmField(
const Industry *i)
1047 int x = i->
location.
w / 2 + Random() % 31 - 16;
1048 int y = i->
location.
h / 2 + Random() % 31 - 16;
1068 _industry_sound_ctr = 1;
1069 _industry_sound_tile = tile;
1099 static void ProduceIndustryGoods(
Industry *i)
1104 if ((i->
counter & 0x3F) == 0) {
1137 if (plant) PlantRandomFarmField(i);
1160 void OnTick_Industry()
1162 if (_industry_sound_ctr != 0) {
1163 _industry_sound_ctr++;
1165 if (_industry_sound_ctr == 75) {
1167 }
else if (_industry_sound_ctr == 160) {
1168 _industry_sound_ctr = 0;
1173 if (_game_mode == GM_EDITOR)
return;
1176 FOR_ALL_INDUSTRIES(i) {
1177 ProduceIndustryGoods(i);
1213 if (_game_mode == GM_EDITOR)
return CommandCost();
1219 extern bool _ignore_restrictions;
1228 if (_game_mode == GM_EDITOR && _ignore_restrictions)
return CommandCost();
1339 FOR_ALL_INDUSTRIES(i) {
1340 if (i->
type == (byte)type && i->
town == *t) {
1349 bool IsSlopeRefused(
Slope current,
Slope refused)
1380 bool refused_slope =
false;
1381 bool custom_shape =
false;
1398 if (ret.
Failed())
return ret;
1409 custom_shape =
true;
1411 if (ret.
Failed())
return ret;
1428 if (ret.
Failed())
return ret;
1433 if (ret.
Failed())
return ret;
1436 }
while ((++it)->ti.x != -0x80);
1438 if (custom_shape_check != NULL) *custom_shape_check = custom_shape;
1459 return_cmd_error(STR_ERROR_CAN_ONLY_BE_BUILT_IN_TOWNS_WITH_POPULATION_OF_1200);
1469 static bool CheckCanTerraformSurroundingTiles(
TileIndex tile, uint height,
int internal)
1481 if (
internal != 0 &&
Delta(curh, height) > 1)
return false;
1486 if (
internal == 0 && curh != height) {
1487 if (
TileX(tile_walk) == 0 ||
TileY(tile_walk) == 0 || !CheckCanTerraformSurroundingTiles(tile_walk +
TileDiffXY(-1, -1), height,
internal + 1)) {
1502 const int MKEND = -0x80;
1508 if (it->gfx == 0xFF)
continue;
1509 if (it->ti.
x > max_x) max_x = it->ti.
x;
1510 if (it->ti.
y > max_y) max_y = it->ti.
y;
1511 }
while ((++it)->ti.
x != MKEND);
1534 if (!CheckCanTerraformSurroundingTiles(tile_walk, h, 0)) {
1556 curh += (curh > h) ? -1 : 1;
1578 static const int dmax = 14;
1580 const int tx =
TileX(tile);
1581 const int ty =
TileY(tile);
1586 if (i == i2)
continue;
1599 FOR_ALL_INDUSTRIES(i) {
1668 uint16 r = Random();
1671 i->
random = initial_random_bits;
1779 }
while ((++it)->ti.
x != -0x80);
1782 for (uint j = 0; j != 50; j++) PlantRandomFarmField(i);
1807 assert(itspec_index < indspec->num_table);
1809 bool custom_shape_check =
false;
1815 _cleared_object_areas = object_areas;
1816 if (ret.
Failed())
return ret;
1823 if (ret.
Failed())
return ret;
1831 if (ret.
Failed())
return ret;
1835 if (ret.
Failed())
return ret;
1839 if (ret.
Failed())
return ret;
1866 IndustryType it =
GB(p1, 0, 8);
1886 uint16 random_initial_bits =
GB(p2, 0, 16);
1887 uint32 random_var8f = randomizer.
Next();
1901 for (
int i = 0; i < 5000; i++) {
1909 for (
int j = 0; j < num_layouts; j++) {
1910 layout = (layout + 1) % num_layouts;
1920 int layout =
GB(p1, 8, 8);
1921 if (layout >= num_layouts)
return CMD_ERROR;
1924 for (
int i = 0; i < num_layouts; i++) {
1925 layout = (layout + 1) % num_layouts;
1931 if (ret.
Failed())
return ret;
1934 if ((flags &
DC_EXEC) && ind != NULL && _game_mode != GM_EDITOR) {
1953 uint32 seed = Random();
1954 uint32 seed2 = Random();
1956 CommandCost ret =
CreateNewIndustryHelper(tile, type,
DC_EXEC, indspec,
RandomRange(indspec->
num_table), seed,
GB(seed2, 0, 16),
OWNER_NONE, creation_type, &i);
1957 assert(i != NULL || ret.
Failed());
1974 *force_at_least_one =
false;
2019 static const uint16 numof_industry_table[] = {
2043 uint tries = try_hard ? 10000u : 2000u;
2044 for (; tries > 0; tries--) {
2046 if (ind != NULL)
return ind;
2081 this->probability = 0;
2082 this->min_number = 0;
2083 this->target_count = 0;
2085 this->wait_count = 0;
2094 this->builddata[it].Reset();
2101 static const int NEWINDS_PER_MONTH = 0x38000 / (10 * 12);
2122 uint32 total_prob = 0;
2123 uint num_forced = 0;
2127 total_prob += industry_probs[it];
2128 if (force_at_least_one[it]) num_forced++;
2132 if (total_prob == 0 || total_amount < num_forced) {
2134 total_amount = num_forced;
2141 if (force_at_least_one[it]) {
2142 assert(total_amount > 0);
2149 for (uint i = 0; i < total_amount; i++) {
2151 IndustryType it = 0;
2152 while (r >= industry_probs[it]) {
2153 r -= industry_probs[it];
2155 assert(it < NUM_INDUSTRYTYPES);
2157 assert(industry_probs[it] > 0);
2160 _industry_builder.
Reset();
2211 bool changed = min_number != this->min_number || probability != this->probability;
2212 this->min_number = min_number;
2213 this->probability = probability;
2220 bool changed =
false;
2221 uint num_planned = 0;
2223 changed |= this->builddata[it].GetIndustryTypeData(it);
2224 num_planned += this->builddata[it].target_count;
2226 uint total_amount = this->wanted_inds >> 16;
2227 changed |= num_planned != total_amount;
2228 if (!changed)
return;
2231 uint force_build = 0;
2232 uint32 total_prob = 0;
2240 if (total_prob == 0)
return;
2243 total_amount = (total_amount <= force_build) ? 0 : total_amount - force_build;
2246 while (total_amount > 0) {
2248 IndustryType it = 0;
2249 while (r >= this->builddata[it].probability) {
2250 r -= this->builddata[it].probability;
2252 assert(it < NUM_INDUSTRYTYPES);
2254 assert(this->builddata[it].probability > 0);
2255 this->builddata[it].target_count++;
2265 this->SetupTargetCount();
2269 uint32 total_prob = 0;
2273 missing += difference;
2274 if (this->builddata[it].wait_count > 0)
continue;
2275 if (difference > 0) {
2278 if (forced_build == NUM_INDUSTRYTYPES ||
2283 total_prob += difference;
2288 if (
EconomyIsInRecession() || (forced_build == NUM_INDUSTRYTYPES && (missing <= 0 || total_prob == 0))) count = 0;
2294 if (forced_build != NUM_INDUSTRYTYPES) {
2301 if (this->builddata[it].wait_count > 0)
continue;
2303 if (difference <= 0)
continue;
2304 if (count == 1)
break;
2305 if (r < (uint)difference)
break;
2314 this->builddata[it].wait_count = this->builddata[it].max_wait + 1;
2315 this->builddata[it].max_wait =
min(1000, this->builddata[it].max_wait + 2);
2318 this->builddata[it].max_wait =
max(this->builddata[it].max_wait / 2, 1);
2324 if (this->builddata[it].wait_count > 0) this->builddata[it].wait_count--;
2394 if (stations.
Length() == 0)
return 0;
2403 bool c_accepts =
false;
2404 bool c_produces =
false;
2406 for (
const Vehicle *u = v; u != NULL; u = u->
Next()) {
2414 if (!c_accepts && !c_produces)
continue;
2421 FOR_VEHICLE_ORDERS(v, o) {
2455 default: NOT_REACHED();
2460 AddIndustryNewsItem(
2461 percent >= 0 ? STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_SMOOTH : STR_NEWS_INDUSTRY_PRODUCTION_DECREASE_SMOOTH,
2467 static const uint PERCENT_TRANSPORTED_60 = 153;
2468 static const uint PERCENT_TRANSPORTED_80 = 204;
2478 bool closeit =
false;
2480 bool standard =
false;
2481 bool suppress_message =
false;
2482 bool recalculate_multipliers =
false;
2490 if (callback_enabled) {
2493 suppress_message =
HasBit(res, 7);
2496 res =
GB(res, 0, 4);
2498 default: NOT_REACHED();
2500 case 0x1: div = 1;
break;
2501 case 0x2: mul = 1;
break;
2502 case 0x3: closeit =
true;
break;
2503 case 0x4: standard =
true;
break;
2504 case 0x5:
case 0x6:
case 0x7:
2505 case 0x8: div = res - 0x3;
break;
2506 case 0x9:
case 0xA:
case 0xB:
2507 case 0xC: mul = res - 0x7;
break;
2510 increment = res == 0x0D ? -1 : 1;
2514 recalculate_multipliers =
true;
2519 if (monthly != smooth_economy)
return;
2527 if (smooth_economy) {
2531 uint32 r = Random();
2532 int old_prod, new_prod, percent;
2540 if (only_decrease) {
2551 new_prod += mult * (
max(((
RandomRange(50) + 10) * old_prod) >> 8, 1U));
2555 new_prod =
Clamp(new_prod, 1, 255);
2558 new_prod =
Clamp(new_prod, 0, 16);
2562 if (new_prod == old_prod && old_prod > 1) {
2567 percent = (old_prod == 0) ? 100 : (new_prod * 100 / old_prod - 100);
2571 if (new_prod > 1) closeit =
false;
2573 if (
abs(percent) >= 10) {
2578 if (only_decrease ||
Chance16(1, 3)) {
2598 recalculate_multipliers =
true;
2603 while (div-- != 0 && !closeit) {
2608 recalculate_multipliers =
true;
2614 if (increment != 0) {
2619 recalculate_multipliers =
true;
2634 if (!suppress_message && str != STR_NULL) {
2646 default: NOT_REACHED();
2650 if (str > STR_LAST_STRINGID) {
2654 }
else if (closeit) {
2665 AddIndustryNewsItem(str, nt, i->
index);
2689 if (change_loop == 0) {
2701 for (uint16 j = 0; j < change_loop; j++) {
2719 void IndustryMonthlyLoop()
2726 FOR_ALL_INDUSTRIES(i) {
2743 void InitializeIndustries()
2746 _industry_sound_tile = 0;
2748 _industry_builder.
Reset();
2758 bool force_at_least_one;
2760 if (chance == 0 || !force_at_least_one)
continue;
2764 ShowErrorMessage(STR_ERROR_NO_SUITABLE_PLACES_FOR_INDUSTRIES, STR_ERROR_NO_SUITABLE_PLACES_FOR_INDUSTRIES_EXPLANATION,
WL_WARNING);
2767 if (count >= 3)
break;
2799 PR_BUILD_INDUSTRY_RAW : PR_BUILD_INDUSTRY] * this->cost_multiplier) >> 8;
2810 return (_price[PR_CLEAR_INDUSTRY] * this->removal_cost_multiplier) >> 8;
2855 GetSlopePixelZ_Industry,
2857 AddAcceptedCargo_Industry,
2858 GetTileDesc_Industry,
2859 GetTileTrackStatus_Industry,
2861 AnimateTile_Industry,
2863 ChangeTileOwner_Industry,
2866 GetFoundation_Industry,
2867 TerraformTile_Industry,
static void ResetIndustryCounts()
Resets industry counts.
customize the cargoes the industry produces
Functions related to OTTD's strings.
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
static void SetIndustryGfx(TileIndex t, IndustryGfx gfx)
Set the industry graphics ID for the given industry tile.
don't allow building on structures
initialise production level on construction
Functions/types related to NewGRF debugging.
the north corner of the tile is raised
do not change town rating
static CommandCost CheckNewIndustry_Lumbermill(TileIndex tile)
Check the conditions of CHECK_LUMBERMILL (Industry should be in the rain forest). ...
#define RandomTile()
Get a valid random tile.
void ClampToMap()
Clamp the tile area to map borders.
byte image_2
image offset 2
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
uint8 acceptance[3]
Level of acceptance per cargo type.
Trigger whenever the construction state changes.
bool enabled
entity still available (by default true).newgrf can disable it, though
void SetupTargetCount()
Decide how many industries of each type are needed.
static TropicZone GetTropicZone(TileIndex tile)
Get the tropic zone.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
static void SetAnimationFrame(TileIndex t, byte frame)
Set a new animation frame.
Tile information, used while rendering the tile.
south and east corner are raised
static const int INDUSTRY_CUT_TREE_TICKS
cycle duration for lumber mill's extra action
uint8 raw_industry_construction
type of (raw) industry construction (none, "normal", prospecting)
static CommandCost CheckNewIndustry_Farm(TileIndex tile)
Check the conditions of CHECK_FARM (Industry should be below snow-line in arctic).
Trigger when cargo is distributed.
the west corner of the tile is raised
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
void TileLoop_Water(TileIndex tile)
Let a water tile floods its diagonal adjoining tiles called from tunnelbridge_cmd, and by TileLoop_Industry() and TileLoop_Track()
byte landscape
the landscape we're currently in
static bool Chance16I(const uint a, const uint b, const uint32 r)
Checks if a given randomize-number is below a given probability.
void AddAnimatedTile(TileIndex tile)
Add the given tile to the animated tile table (if it does not exist on that table yet)...
byte land_generator
the landscape generator
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 ...
Money GetRemovalCost() const
Get the cost for removing this industry Take note that the cost will always be zero for non-grf indus...
EconomySettings economy
settings to change the economy
byte image_3
image offset 3
byte image_1
image offset 1
uint16 counter
used for animation and/or production (if available cargo)
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
below this level, the industry is set to be closing
void DeleteIndustryNews(IndustryID iid)
Remove news regarding given industry.
int32 TileIndexDiff
An offset value between to tiles.
static Titem * Get(size_t index)
Returns Titem with given index.
static void ReportNewsProductionChangeIndustry(Industry *ind, CargoID type, int percent)
Report news that industry production has changed significantly.
Trigger in the periodic tile loop.
Functions related to dates.
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
const char * grf
newGRF used for the tile contents
OwnerByte founder
Founder of the industry.
static bool IsSuitableForFarmField(TileIndex tile, bool allow_fields)
Check whether the tile can be replaced by a farm field.
static CommandCost CheckNewIndustry_BubbleGen(TileIndex tile)
Check the conditions of CHECK_BUBBLEGEN (Industry should be in low land).
uint16 last_month_production[2]
total units produced per cargo in the last full month
uint16 this_month_transported[2]
stats of this month's transport per cargo
uint32 prospecting_chance
Chance prospecting succeeds.
static byte GetAnimationFrame(TileIndex t)
Get the current animation frame.
from the Fund/build using prospecting
Industries at sea should be positioned near edge of the map.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
static const IndustryGfx INVALID_INDUSTRYTILE
one above amount is considered invalid
Number of industry density settings.
CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit)
Translate a GRF-local cargo slot/bitnum into a CargoID.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
Customize the input cargo types of a newly build industry.
Slope tileh
Slope of the tile.
uint32 GetIndustryProbabilityCallback(IndustryType type, IndustryAvailabilityCallType creation_type, uint32 default_prob)
Check with callback CBID_INDUSTRY_PROBABILITY whether the industry can be built.
static IndustryGfx GetIndustryGfx(TileIndex t)
Get the industry graphics ID for the given industry tile.
byte selected_layout
Which tile layout was used when creating the industry.
static uint ScaleByMapSize(uint n)
Scales the given value by the map size, where the given value is for a 256 by 256 map...
CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint layout, uint32 seed, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type)
Check that the industry callback allows creation of the industry.
uint8 construction_type
Way the industry was constructed (.
from the Fund/build window
default level set when the industry is created
Other industry production changes.
IndustryLifeType life_type
This is also known as Industry production flag, in newgrf specs.
periodically plants fields around itself (temp and arctic farms)
Called monthly on production changes, so it can be adjusted more frequently.
do not increase production (oil wells) in the temperate climate
Functions related to vehicles.
uint16 callback_mask
Bitmask of industry callbacks that have to be called.
CargoID accepts_cargo[3]
Cargo accepted by this tile.
static uint TileX(TileIndex tile)
Get the X component of a tile.
CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type)
Check the slope of a tile of a new industry.
static CommandCost CheckNewIndustry_Water(TileIndex tile)
Check the conditions of CHECK_WATER (Industry should be in the desert).
static int GetSlopeMaxZ(Slope s)
Returns the height of the highest corner of a slope relative to TileZ (= minimal height) ...
byte animation_substate
Sub state to time the change of the graphics/behaviour.
signal set to actually close the industry
Defines the internal data of a functional industry.
during random map creation
Tile description for the 'land area information' tool.
DifficultySettings difficulty
settings related to the difficulty
static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company=MAX_COMPANIES)
Broadcast a new event to all active AIs.
bool ambient
Play ambient, industry and town sounds.
Tindex index
Index of this pool item.
the east corner of the tile is raised
void IndustryProductionCallback(Industry *ind, int reason)
Get the industry production callback and apply it to the industry.
Northeast, upper right on your monitor.
A special vehicle is one of the following:
static bool IsSteepSlope(Slope s)
Checks if a slope is steep.
static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, const IndustryTileTable *it, byte layout, Town *t, Owner founder, uint16 initial_random_bits)
Put an industry on the map.
static byte GetIndustryAnimationLoop(TileIndex tile)
Get the animation loop number.
check industry construction on given area
Simple vector template class.
Map accessors for tree tiles.
Functions related to world/map generation.
byte was_cargo_delivered
flag that indicate this has been the closest industry chosen for cargo delivery by a station...
const IndustryTileTable *const * table
List of the tiles composing the industry.
static void ResetIndustryConstructionStage(TileIndex tile)
Reset the construction stage counter of the industry, as well as the completion bit.
uint16 random
Random value used for randomisation of all kinds of things.
south and west corner are raised
Common return value for all commands.
static Industry * GetRandom()
Return a random valid industry.
static CommandCost CheckNewIndustry_Plantation(TileIndex tile)
Check the conditions of CHECK_PLANTATION (Industry should NOT be in the desert).
static const int INDUSTRY_COMPLETED
final stage of industry construction.
static T max(const T a, const T b)
Returns the maximum of two values.
static void InvalidateAllFrom(SourceType src_type, SourceID src)
Invalidates (sets source_id to INVALID_SOURCE) all cargo packets from given source.
static bool IsClearGround(TileIndex t, ClearGround ct)
Set the type of clear tile.
uint8 status
Status; 0: no looping, 1: looping, 0xFF: no animation.
is always built near towns (toy shop)
EffectVehicle * CreateEffectVehicleAbove(int x, int y, int z, EffectVehicleType type)
Create an effect vehicle above a particular location.
the industry is running at full speed
uint32 population
Current population of people.
Year _cur_year
Current year, starting at 0.
uint16 incoming_cargo_waiting[3]
incoming cargo waiting to be processed
uint16 w
The width of the area.
bool IsTileFlat(TileIndex tile, int *h)
Check if a given tile is flat.
static IndustryID GetIndustryIndexOfField(TileIndex t)
Get the industry (farm) that made the field.
static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, DoCommandFlag flags, const IndustrySpec *indspec, uint itspec_index, uint32 random_var8f, uint16 random_initial_bits, Owner founder, IndustryAvailabilityCallType creation_type, Industry **ip)
Helper function for Build/Fund an industry.
void DeleteSubsidyWith(SourceType type, SourceID index)
Delete the subsidies associated with a given cargo source type and id.
Tables with default industry layouts and behaviours.
static const uint TILE_SIZE
Tile size in world coordinates.
StringID production_down_text
Message appearing when the industry's production is decreasing.
uint32 industry_daily_increment
The value which will increment industry_daily_change_counter. Computed value. NOSAVE.
byte random_colour
randomized colour of the industry, for display purpose
Industry directory; Window numbers:
static uint32 RandomRange(uint32 limit)
Pick a random number between 0 and limit - 1, inclusive.
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
Owner owner[4]
Name of the owner(s)
StringID name
Displayed name of the industry.
IndustryBuildData _industry_builder
In-game manager of industries.
bool IndustryTemporarilyRefusesCargo(Industry *ind, CargoID cargo_type)
Check whether an industry temporarily refuses to accept a certain cargo.
can only be built in towns (arctic/tropic banks, water tower)
north and east corner are raised
static uint ClampU(const uint a, const uint min, const uint max)
Clamp an unsigned integer between an interval.
Do not force one instance of this type to appear on map generation.
not really a tile, but rather a very special check
static bool IsIndustryCompleted(TileIndex t)
Is this industry tile fully built?
static uint GetTreeGrowth(TileIndex t)
Returns the tree growth status.
Class to backup a specific variable and restore it later.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Date construction_date
Date of the construction of the industry.
Functions related to (drawing on) viewports.
void ResetIndustries()
This function initialize the spec arrays of both industry and industry tiles.
Bubble of bubble generator (industry).
The object is owned by a superuser / goal script.
static IndustryGfx GetTranslatedIndustryTileID(IndustryGfx gfx)
Do industry gfx ID translation for NewGRFs.
Data for managing the number and type of industries in the game.
int16 y
The y value of the coordinate.
decides allowance of autosloping
Slope GetTileSlope(TileIndex tile, int *h)
Return the slope of a given tile inside the map.
static const size_t MAX_SIZE
Make template parameter accessible from outside.
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
Slope slopes_refused
slope pattern on which this tile cannot be built
static bool IsBridgeAbove(TileIndex t)
checks if a bridge is set above the ground of this tile
const uint8 * random_sounds
array of random sounds.
uint8 industry_platform
the amount of flat land around an industry
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=NULL, uint textref_stack_size=0, const uint32 *textref_stack=NULL)
Display an error message in a window.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold...
static Slope ComplementSlope(Slope s)
Return the complement of a slope.
void IndustryDailyLoop()
Daily handler for the industry changes Taking the original map size of 256*256, the number of random ...
Some methods of Pool are placed here in order to reduce compilation time and binary size...
uint x
X position of the tile in unit coordinates.
static uint32 GetRegister(uint i)
Gets the value of a so-called newgrf "register".
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Foundation
Enumeration for Foundations.
Types related to cheating.
TileIndex xy
town center tile
Customize the output cargo types of a newly build industry.
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a give tiletype.
static void MakeField(TileIndex t, uint field_type, IndustryID industry)
Make a (farm) field tile.
can only be built after 1960 (oil rigs)
TileIndex tile
Tile index.
Functions related to errors.
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
bool IsRawIndustry() const
Is an industry with the spec a raw industry?
uint Length() const
Get the number of items in the list.
void Add(TileIndex to_add)
Add a single tile to a tile area; enlarge if needed.
during random map generation
PersistentStorage * psa
Persistent storage for NewGRF industries.
The tile is leveled up to a flat slope.
static size_t GetPoolSize()
Returns first unused index.
SoundSettings sound
sound effect settings
uint16 produced_cargo_waiting[2]
amount of cargo produced per cargo
bool Contains(const T &item) const
Tests whether a item is present in the vector.
Like power plants and banks.
static void ChangeIndustryProduction(Industry *i, bool monthly)
Change industry production or do closure.
controls random production change
either by user or random creation process
WaterClass
classes of water (for WATER_TILE_CLEAR water tile type).
static void SetupFarmFieldFence(TileIndex tile, int size, byte type, DiagDirection side)
Build farm field fence.
void TryBuildNewIndustry()
Try to create a random industry, during gameplay.
bool IsProcessingIndustry() const
Is an industry with the spec a processing industry?
static byte GetIndustryConstructionStage(TileIndex tile)
Returns the industry construction stage of the specified tile.
uint DistanceMax(TileIndex t0, TileIndex t1)
Gets the biggest distance component (x or y) between the two given tiles.
Year last_prod_year
last year of production
bool multiple_industry_per_town
allow many industries of the same type per town
bool IsType(OrderType type) const
Check whether this order is of the given type.
decides if default foundations need to be drawn
const StationList * GetStations()
Run a tile loop to find stations around a tile, on demand.
bool ConvertBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
Converts a callback result into a boolean.
static void SetIndustryConstructionCounter(TileIndex tile, byte value)
Sets this industry tile's construction counter value.
Called to determine if industry can alter the ground below industry tile.
DoCommandFlag
List of flags for a command.
Called to determine the type (if any) of foundation to draw for industry tile.
ClientSettings _settings_client
The current settings for this game.
bool Succeeded() const
Did this command succeed?
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
void DeleteAnimatedTile(TileIndex tile)
Removes the given tile from the animated tile table.
#define TILE_AREA_LOOP(var, ta)
A loop which iterates over the tiles of a TileArea.
Definition of base types and functions in a cross-platform compatible way.
static void SetIndustryAnimationLoop(TileIndex tile, byte count)
Set the animation loop number.
static void AdvertiseIndustryOpening(const Industry *ind)
Advertise about a new industry opening.
uint16 this_month_production[2]
stats of this month's production per cargo
bool UsesSmoothEconomy() const
Determines whether this industrytype uses smooth economy or whether it uses standard/newgrf productio...
CommandCost CheckNewIndustryProc(TileIndex tile)
Industrytype check function signature.
#define TILE_ADDXY(tile, x, y)
Adds a given offset to a tile.
void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger)
Trigger a random trigger for a single industry tile.
A number of safeguards to prevent using unsafe methods.
bool value
tells if the bool cheat is active or not
int16 x
The x value of the coordinate.
bool CircularTileSearch(TileIndex *tile, uint size, TestTileOnSearchProc proc, void *user_data)
Function performing a search around a center tile and going outward, thus in circle.
IndustryType GetIndustryType(TileIndex tile)
Retrieve the type for this industry.
IndustryType type
type of industry.
static PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
static const IndustryGfx NEW_INDUSTRYTILEOFFSET
original number of tiles
StringID new_industry_text
Message appearing when the industry is built.
uint y
Y position of the tile in unit coordinates.
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
#define MKEND()
Macro for end of list marker in arrays of LegendAndColour.
End marker of the industry check procedures.
CargoID accepts_cargo[3]
3 input cargo slots
StringID MapGRFStringID(uint32 grfid, StringID str)
Used when setting an object's property to map to the GRF's strings while taking in consideration the ...
static CommandCost CheckNewIndustry_OilRig(TileIndex tile)
Check the conditions of CHECK_OIL_RIG (Industries at sea should be positioned near edge of the map)...
byte anim_production
Animation frame to start when goods are produced.
decides amount of cargo acceptance
CargoLabel label
Unique label of the cargo type.
TileArea location
Location of the industry.
static int WhoCanServiceIndustry(Industry *ind)
Compute who can service the industry.
CargoID cargo_type
type of cargo this vehicle is carrying
const T & GetOriginalValue() const
Returns the backupped value.
Represents the covered area of e.g.
static const IndustryGfx NUM_INDUSTRYTILES
total number of industry tiles, new and old
bool IsFrontEngine() const
Check if the vehicle is a front engine.
don't allow building on water
Defines the data structure for constructing industry.
TerraGenesis Perlin landscape generator.
This structure is the same for both Industries and Houses.
static uint16 GetIndustryTypeCount(IndustryType type)
Get the count of industries for this type.
The tile has no ownership.
GRFFileProps grf_prop
properties related to the grf file
CargoID produced_cargo[2]
2 production cargo slots
Industry should be positioned near edge of the map.
void CheckIndustries()
Verify whether the generated industries are complete, and warn the user if not.
customize the cargoes the industry requires
Money GetConstructionCost() const
Get the cost for constructing this industry.
Base class for all effect vehicles.
const IndustryTileSpec * GetIndustryTileSpec(IndustryGfx gfx)
Accessor for array _industry_tile_specs.
void SetSeed(uint32 seed)
(Re)set the state of the random number generator.
static const DrawBuildingsTileStruct _industry_draw_tile_data[NEW_INDUSTRYTILEOFFSET *4]
Structure for industry tiles drawing.
static const uint8 ANIM_STATUS_NO_ANIMATION
There is no animation.
IndustryAvailabilityCallType
From where has callback CBID_INDUSTRY_PROBABILITY been called.
static void PlaceInitialIndustry(IndustryType type, bool try_hard)
Try to build a industry on the map.
Industry view; Window numbers:
DiagDirection
Enumeration for diagonal directions.
static CommandCost CheckIfFarEnoughFromConflictingIndustry(TileIndex tile, int type)
Check that the new industry is far enough from conflicting industries.
#define lengthof(x)
Return the length of an fixed size array.
IndustryBehaviour behaviour
How this industry will behave, and how others entities can use it.
byte prod_level
general production level
byte appear_ingame[NUM_LANDSCAPE]
Probability of appearance in game.
GRFFileProps grf_prop
properties related to the grf file
static bool IsWaterTile(TileIndex t)
Is it a water tile with plain water?
static T min(const T a, const T b)
Returns the minimum of two values.
#define MAX_UVALUE(type)
The largest value that can be entered in a variable.
static Foundation FlatteningFoundation(Slope s)
Returns the foundation needed to flatten a slope.
static bool EconomyIsInRecession()
Is the economy in recession?
cuts trees and produce first output cargo from them (lumber mill)
Data for managing the number of industries of a single industry type.
bool GetIndustryTypeData(IndustryType it)
Set the probability and min_number fields for the industry type it for a running game.
Functions related to autoslope.
Functions related to sound.
The game does not build industries.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
static bool AutoslopeEnabled()
Tests if autoslope is enabled for _current_company.
uint DistanceFromEdge(TileIndex tile)
Param the minimum distance to an edge.
NewGRF handling of industry tiles.
bool Failed() const
Did this command fail?
const struct SpriteGroup * spritegroup[Tcnt]
pointer to the different sprites of the entity
static bool Chance16R(const uint a, const uint b, uint32 &r)
Flips a coin with a given probability and saves the randomize-number in a variable.
Called to determine the colour of an industry.
byte last_month_pct_transported[2]
percentage transported per cargo in the last full month
CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Build/Fund an industry.
void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w, int h, int dz, int z, bool transparent, int bb_offset_x, int bb_offset_y, int bb_offset_z, const SubSprite *sub)
Draw a (transparent) sprite at given coordinates with a given bounding box.
uint16 last_month_transported[2]
total units transported per cargo in the last full month
Transfer all cargo onto the platform.
static uint GetNumberOfIndustries()
Get wanted number of industries on the map.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
controls monthly random production change
static void IncIndustryTypeCount(IndustryType type)
Increment the count of industries for this type.
Base class for all pools.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void Reset()
Reset the entry.
OrderUnloadFlags GetUnloadType() const
How must the consist be unloaded?
TileIndex TileAddWrap(TileIndex tile, int addx, int addy)
This function checks if we add addx/addy to tile, if we do wrap around the edges. ...
Called to determine which cargoes an industry should accept.
static bool Chance16(const uint a, const uint b)
Flips a coin with given probability.
uint8 callback_mask
Bitmask of industry tile callbacks that have to be called.
bool IsTileForestIndustry(TileIndex tile)
Check whether the tile is a forest.
TileIndex tile
The base tile of the area.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset)
Mark a tile given by its index dirty for repaint.
uint16 _tick_counter
Ever incrementing (and sometimes wrapping) tick counter for setting off various events.
uint64 dparam[2]
Parameters of the str string.
static uint ScaleByMapSize1D(uint n)
Scales the given value by the maps circumference, where the given value is for a 256 by 256 map...
EffectVehicle * CreateEffectVehicle(int x, int y, int z, EffectVehicleType type)
Create an effect vehicle at a particular location.
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
static uint16 GetIndustryGamePlayProbability(IndustryType it, byte *min_number)
Compute the probability for constructing a new industry during game play.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
static Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
static TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between to tiles from a TileIndexDiffC struct.
byte num_table
Number of elements in the table.
execute the given command
static bool CleaningPool()
Returns current state of pool cleaning - yes or no.
static void PostDestructor(size_t index)
Invalidating some stuff after removing item from the pool.
void GenerateIndustries()
This function will create random industries during game creation.
static const DrawIndustryCoordinates _coal_plant_sparks[]
Movement of the sparks , only used for Power Station.
void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
Trigger a random trigger for all industry tiles.
GRFConfig * GetGRFConfig(uint32 grfid, uint32 mask)
Retrieve a NewGRF from the current config by its grfid.
static uint MapSize()
Get the size of the map.
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
Class for storing amounts of cargo.
bool _generating_world
Whether we are generating the map or not.
byte oil_refinery_limit
distance oil refineries allowed from map edge
DestinationID GetDestination() const
Gets the destination of this order.
during creation of random ingame industry
is built on water (oil rig)
byte minimal_cargo
minimum amount of cargo transported to the stations.
Invisible tiles at the SW and SE border.
byte appear_creation[NUM_LANDSCAPE]
Probability of appearance during map creation.
Production changes of industry serviced by local company.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
CompanyByte _current_company
Company currently doing an action.
Set of callback functions for performing tile operations of a given tile type.
uint32 TileIndex
The index/ID of a Tile.
Map accessors for 'clear' tiles.
AnimationInfo animation
Information about the animation (is it looping, how many loops etc)
Cargo support for NewGRFs.
void ReleaseDisastersTargetingIndustry(IndustryID i)
Marks all disasters targeting this industry in such a way they won't call Industry::Get(v->dest_tile)...
static size_t GetNumItems()
Returns number of valid items in the pool.
static Industry * CreateNewIndustry(TileIndex tile, IndustryType type, IndustryAvailabilityCallType creation_type)
Create a new industry of random layout.
A town owns the tile, or a town is expanding.
Vehicle * Next() const
Get the next vehicle of this vehicle.
void RecomputeProductionMultipliers()
Recompute production_rate for current prod_level.
static TreeGround GetTreeGround(TileIndex t)
Returns the groundtype for tree tiles.
north and west corner are raised
static const IndustryType NUM_INDUSTRYTYPES
total number of industry types, new and old; limited to 240 because we need some special ids like INV...
Source/destination is an industry.
static IndustryID GetIndustryIndex(TileIndex t)
Get the industry ID of the given tile.
StringID closure_text
Message appearing when the industry closes.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Cheat magic_bulldozer
dynamite industries, objects
static void SetIndustryCompleted(TileIndex tile)
Set if the industry that owns the tile as under construction or not.
OwnerByte owner
Which company owns the vehicle?
byte anim_next
Next frame in an animation.
static PaletteID SpriteLayoutPaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOUR to a palette entry of a sprite layou...
static T abs(const T a)
Returns the absolute value of (scalar) variable.
The tile has no foundation, the slope remains unchanged.
TransportType
Available types of transport.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
int x
coordinate x of the first image offset
static bool IsOilRig(TileIndex t)
Is tile t part of an oilrig?
Slope
Enumeration for the slope-type.
uint32 Next()
Generate the next pseudo random number.
Called to query the cargo acceptance of the industry tile.
TownCache cache
Container for all cacheable data.
static Industry * PlaceIndustry(IndustryType type, IndustryAvailabilityCallType creation_type, bool try_hard)
Try to place the industry in the game.
static uint MapMaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
static void DecIndustryTypeCount(IndustryType type)
Decrement the count of industries for this type.
call production callback when cargo arrives at the industry
uint32 industry_daily_change_counter
Bits 31-16 are number of industry to be performed, 15-0 are fractional collected daily.
static const IndustryType NEW_INDUSTRYOFFSET
original number of industry types
static CommandCost CheckNewIndustry_OilRefinery(TileIndex tile)
Check the conditions of CHECK_REFINERY (Industry should be positioned near edge of the map)...
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() ...
This is used to gather some data about animation drawing in the industry code Image_1-2-3 are in fact...
static uint GetCurrentTotalNumberOfIndustries()
Get total number of industries existing in the game.
Functions related to OTTD's landscape.
static void RecomputeIndustriesNearForAll()
Recomputes Station::industries_near for all stations.
byte production_rate[2]
production rate for each cargo
Base functions for all Games.
static uint32 GetScaledIndustryGenerationProbability(IndustryType it, bool *force_at_least_one)
Compute the appearance probability for an industry during map creation.
Functions related to commands.
IndustryBehaviour
Various industry behaviours mostly to represent original TTD specialities.
uint32 probability
Relative probability of building this industry.
static void SetIndustryIndexOfField(TileIndex t, IndustryID i)
Set the industry (farm) that made the field.
static uint16 counts[NUM_INDUSTRYTYPES]
Number of industries per type ingame.
void DrawGroundSprite(SpriteID image, PaletteID pal, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
Draws a ground sprite for the current tile.
IndustryType conflicting[3]
Industries this industry cannot be close to.
byte GetSnowLine()
Get the current snow line, either variable or static.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
static CommandCost FindTownForIndustry(TileIndex tile, int type, Town **t)
Find a town for the industry, while checking for multiple industries in the same town.
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
static CommandCost CheckNewIndustry_Forest(TileIndex tile)
Check the conditions of CHECK_FOREST (Industry should be build above snow-line in arctic climate)...
uint32 wanted_inds
Number of wanted industries (bits 31-16), and a fraction (bits 15-0).
Fields are planted around when built (all farms)
Smoke of power plant (industry).
Allow closing down the last instance of this type.
ConstructionSettings construction
construction of things in-game
CargoID accepts_cargo[3]
3 accepted cargoes.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
const char * GetName() const
Get the name of this grf.
void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool transparent, const SubSprite *sub, bool scale)
Add a child sprite to a parent sprite.
static CommandCost CheckIfIndustryIsAllowed(TileIndex tile, int type, const Town *t)
Is the industry allowed to be built at this place for the town?
void ResetOverride()
Resets the override, which is used while initializing game.
const struct GRFFile * grffile
grf file that introduced this entity
uint8 number_of_sounds
Number of sounds available in the sounds array.
void MonthlyLoop()
Monthly update of industry build data.
StringID str
Description of the tile.
byte min_number
Smallest number of industries that should exist (either 0 or 1).
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
static bool HasTileWaterClass(TileIndex t)
Checks whether the tile has an waterclass associated.
StringID production_up_text
Message appearing when the industry's production is increasing.
static bool SearchLumberMillTrees(TileIndex tile, void *user_data)
Search callback function for ChopLumberMillTrees.
void Restore()
Restore the variable.
Base functions for all AIs.
#define FOR_ALL_VEHICLES(var)
Iterate over all vehicles.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
static void SetClearCounter(TileIndex t, uint c)
Sets the counter used to advance to the next clear density/field type.
byte check_proc
Index to a procedure to check for conflicting circumstances.
static void SetFence(TileIndex t, DiagDirection side, uint h)
Sets the type of fence (and whether there is one) for the given border.
bool TileBelongsToIndustry(TileIndex tile) const
Check if a given tile belongs to this industry.
GameCreationSettings game_creation
settings used during the creation of a game (map)
A tile without any structures, i.e. grass, rocks, farm fields etc.
byte CargoID
Cargo slots to indicate a cargo type within a game.
Defines the data structure of each individual tile of an industry.
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
static bool IsInvisibilitySet(TransparencyOption to)
Check if the invisibility option bit is set and if we aren't in the game menu (there's never transpar...
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
Very few industries at game start.
uint16 target_count
Desired number of industries of this type.
Owner
Enum for all companies/owners.
Window functions not directly related to making/drawing windows.
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
static void CanCargoServiceIndustry(CargoID cargo, Industry *ind, bool *c_accepts, bool *c_produces)
Can given cargo type be accepted or produced by the industry?
bool smooth_economy
smooth economy
Functions related to water (management)
Force unloading all cargo onto the platform, possibly not getting paid.
Structure to encapsulate the pseudo random number generators.
town rating does not disallow you from building
byte industry_density
The industry density.
static bool IsTileOnWater(TileIndex t)
Tests if the tile was built on water.
Production changes of industry serviced by competitor(s)
can only be built in towns larger than 1200 inhabitants (temperate bank)
static void ChopLumberMillTrees(Industry *i)
Perform a circular search around the Lumber Mill in order to find trees to cut.
static CheckNewIndustryProc *const _check_new_industry_procs[CHECK_END]
Check functions for different types of industry.
SpriteID sprite
The 'real' sprite.
OwnerByte owner
owner of the industry. Which SHOULD always be (imho) OWNER_NONE
Called to determine industry special effects.
static void SetDParamX(uint64 *s, uint n, uint64 v)
Set a string parameter v at index n in a given array s.
Functions related to news.
The tile of the industry has been triggered during the tileloop.
Structure contains cached list of stations nearby.
void FindStationsAroundTiles(const TileArea &location, StationList *stations)
Find all stations around a rectangular producer (industry, house, headquarter, ...)
Base classes/functions for stations.
call production callback every 256 ticks
Called when industry is built to set initial production level.
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
static Station * Get(size_t index)
Gets station with given index.
Date _date
Current date in days (day counter)
static T Delta(const T a, const T b)
Returns the (absolute) difference between two (scalar) variables.
uint16 h
The height of the area.
static void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx, uint8 random, WaterClass wc)
Make the given tile an industry tile.
static const int INDUSTRY_PRODUCE_TICKS
cycle duration for industry production
can only be built before 1950 (oil wells)
the south corner of the tile is raised
static const IndustryGfx INDUSTRYTILE_NOANIM
flag to mark industry tiles as having no animation
The tile/execution is done by "water".
static bool TransportIndustryGoods(TileIndex tile)
Move produced cargo from industry to nearby stations.
void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index)
Delete inspect window for a given feature and index.
static void UpdateIndustryStatistics(Industry *i)
Monthly update of industry statistics.
VehicleTypeByte type
Type of vehicle.
SoundFx
Sound effects from baseset.
Class for backupping variables and making sure they are restored later.
Functions related to effect vehicles.
static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, uint itspec_index, int type, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type, bool *custom_shape_check=NULL)
Are the tiles of the industry free?
static bool IsTransparencySet(TransparencyOption to)
Check if the transparency option bit is set and if we aren't in the game menu (there's never transpar...
#define TILE_MASK(x)
'Wraps' the given tile to it is within the map.
Functions related to subsidies.
Used for industry tiles on land (also for oilrig if newgrf says so).
static bool CheckIndustryCloseDownProtection(IndustryType type)
Protects an industry from closure if the appropriate flags and conditions are met INDUSTRYBEH_CANCLOS...
static void SetIndustryConstructionStage(TileIndex tile, byte value)
Sets the industry construction stage of the specified tile.
Called on production changes, so it can be adjusted.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static byte GetIndustryConstructionCounter(TileIndex tile)
Returns this industry tile's construction counter value.
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
byte HighestSnowLine()
Get the highest possible snow line height, either variable or static.
The industry has been triggered via its tick.
static CommandCost CheckNewIndustry_NULL(TileIndex tile)
Check the conditions of CHECK_NOTHING (Always succeeds).
bool anim_state
When true, the tile has to be drawn using the animation state instead of the construction state...
give a custom colour to newly build industries
Cheats _cheats
All the cheats.
uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile)
Perform an industry callback.
static int GetTileMaxPixelZ(TileIndex tile)
Get top height of the tile.
void Reset()
Completely reset the industry build data.
decides slope suitability
Information about the behaviour of the default industry tiles.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
PaletteID pal
The palette (use PAL_NONE) if not needed)