28 #include "strings_internal.h"
51 #include "table/strings.h"
60 void ShowIndustryViewWindow(
int industry);
63 static uint8_t _industry_sound_ctr;
82 auto industry_insert = std::copy(std::begin(_origin_industry_specs), std::end(_origin_industry_specs), std::begin(_industry_specs));
83 std::fill(industry_insert, std::end(_industry_specs),
IndustrySpec{});
86 for (
auto it = std::begin(_industry_specs); it != industry_insert; ++it) {
90 auto industry_tile_insert = std::copy(std::begin(_origin_industry_tile_specs), std::end(_origin_industry_tile_specs), std::begin(_industry_tile_specs));
91 std::fill(industry_tile_insert, std::end(_industry_tile_specs),
IndustryTileSpec{});
111 assert(ind !=
nullptr);
126 return &_industry_specs[thistype];
140 return &_industry_tile_specs[gfx];
143 Industry::~Industry()
163 DeleteOilRig(tile_cur);
167 if (has_neutral_station) {
169 for (
TileIndex tile_cur : this->location) {
202 st->RemoveIndustryToDeliver(
this);
242 static void IndustryDrawSugarMine(
const TileInfo *ti)
256 _drawtile_proc1[d->
image_3 - 1].x, _drawtile_proc1[d->
image_3 - 1].y);
260 static void IndustryDrawToffeeQuarry(
const TileInfo *ti)
275 static void IndustryDrawBubbleGenerator(
const TileInfo *ti)
283 static void IndustryDrawToyFactory(
const TileInfo *ti)
299 static void IndustryDrawCoalPlantSparks(
const TileInfo *ti)
304 if (image != 0 && image < 7) {
314 typedef void IndustryDrawTileProc(
const TileInfo *ti);
315 static IndustryDrawTileProc *
const _industry_draw_tile_procs[5] = {
316 IndustryDrawSugarMine,
317 IndustryDrawToffeeQuarry,
318 IndustryDrawBubbleGenerator,
319 IndustryDrawToyFactory,
320 IndustryDrawCoalPlantSparks,
323 static void DrawTile_Industry(
TileInfo *ti)
335 if (indts->
grf_prop.
spritegroup[0] !=
nullptr && DrawNewIndustryTile(ti, ind, gfx, indts)) {
360 DrawWaterClassGround(ti);
369 image = dits->building.
sprite;
372 ti->
x + dits->subtile_x,
373 ti->
y + dits->subtile_y,
384 int proc = dits->draw_proc - 1;
385 if (proc >= 0) _industry_draw_tile_procs[proc](ti);
389 static int GetSlopePixelZ_Industry(
TileIndex tile, uint, uint,
bool)
412 static void AddAcceptedCargo_Industry(
TileIndex tile,
CargoArray &acceptance, CargoTypes &always_accepted)
424 for (
const auto &a : ind->
accepted) {
425 auto pos = std::find(std::begin(accepts_cargo), std::end(accepts_cargo), a.cargo);
426 if (pos == std::end(accepts_cargo)) {
428 pos = std::find(std::begin(accepts_cargo), std::end(accepts_cargo), INVALID_CARGO);
429 if (pos == std::end(accepts_cargo))
continue;
432 cargo_acceptance[std::distance(std::begin(accepts_cargo), pos)] += 8;
440 accepts_cargo.fill(INVALID_CARGO);
449 cargo_acceptance.fill(0);
454 for (uint8_t i = 0; i < std::size(itspec->
accepts_cargo); i++) {
459 acceptance[a] += cargo_acceptance[i];
462 if (
HasBit(always_accepted, a))
continue;
468 SetBit(always_accepted, a);
481 td->
str = STR_LAI_TOWN_INDUSTRY_DESCRIPTION_UNDER_CONSTRUCTION;
526 bool moved_cargo =
false;
529 uint cw = ClampTo<uint8_t>(p.waiting);
536 p.history[THIS_MONTH].production += cw;
539 p.history[THIS_MONTH].transported += am;
541 moved_cargo |= (am != 0);
548 static void AnimateSugarSieve(
TileIndex tile)
568 static void AnimateToffeeQuarry(
TileIndex tile)
585 static void AnimateBubbleCatcher(
TileIndex tile)
598 static void AnimatePowerPlantSparks(
TileIndex tile)
610 static void AnimateToyFactory(
TileIndex tile)
634 static void AnimatePlasticFountain(
TileIndex tile, IndustryGfx gfx)
636 gfx = (gfx < GFX_PLASTIC_FOUNTAIN_ANIMATED_8) ? gfx + 1 : GFX_PLASTIC_FOUNTAIN_ANIMATED_1;
641 static void AnimateOilWell(
TileIndex tile, IndustryGfx gfx)
645 if (m == 4 && (m = 0, ++gfx) == GFX_OILWELL_ANIMATED_3 + 1 && (gfx = GFX_OILWELL_ANIMATED_1, b)) {
656 static void AnimateMineTower(
TileIndex tile)
660 if ((state -= 0x400) < 0)
return;
663 if (state < 0x20 || state >= 0x180) {
669 if (state & 7)
return;
671 if (state & 3)
return;
674 if (m > 0xC2) m = 0xC0;
677 }
else if (state >= 0x200 && state < 0x3A0) {
678 int i = (state < 0x220 || state >= 0x380) ? 7 : 3;
679 if (state & i)
return;
682 if (m < 0x80) m = 0x82;
688 static void AnimateTile_Industry(
TileIndex tile)
693 AnimateNewIndustryTile(tile);
698 case GFX_SUGAR_MINE_SIEVE:
702 case GFX_TOFFEE_QUARY:
706 case GFX_BUBBLE_CATCHER:
710 case GFX_POWERPLANT_SPARKS:
714 case GFX_TOY_FACTORY:
718 case GFX_PLASTIC_FOUNTAIN_ANIMATED_1:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_2:
719 case GFX_PLASTIC_FOUNTAIN_ANIMATED_3:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_4:
720 case GFX_PLASTIC_FOUNTAIN_ANIMATED_5:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_6:
721 case GFX_PLASTIC_FOUNTAIN_ANIMATED_7:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_8:
725 case GFX_OILWELL_ANIMATED_1:
726 case GFX_OILWELL_ANIMATED_2:
727 case GFX_OILWELL_ANIMATED_3:
731 case GFX_COAL_MINE_TOWER_ANIMATED:
732 case GFX_COPPER_MINE_TOWER_ANIMATED:
733 case GFX_GOLD_MINE_TOWER_ANIMATED:
734 AnimateMineTower(tile);
739 static void CreateChimneySmoke(
TileIndex tile)
748 static void MakeIndustryTileBigger(
TileIndex tile)
773 case GFX_POWERPLANT_CHIMNEY:
774 CreateChimneySmoke(tile);
792 case GFX_TOY_FACTORY:
793 case GFX_BUBBLE_CATCHER:
794 case GFX_TOFFEE_QUARY:
799 case GFX_PLASTIC_FOUNTAIN_ANIMATED_1:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_2:
800 case GFX_PLASTIC_FOUNTAIN_ANIMATED_3:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_4:
801 case GFX_PLASTIC_FOUNTAIN_ANIMATED_5:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_6:
802 case GFX_PLASTIC_FOUNTAIN_ANIMATED_7:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_8:
808 static void TileLoopIndustry_BubbleGenerator(
TileIndex tile)
810 static const int8_t _bubble_spawn_location[3][4] = {
818 int dir = Random() & 3;
823 _bubble_spawn_location[2][dir],
830 static void TileLoop_Industry(
TileIndex tile)
843 MakeIndustryTileBigger(tile);
847 if (_game_mode == GM_EDITOR)
return;
861 if (StartStopIndustryTileAnimation(tile,
IAT_TILELOOP))
return;
873 case GFX_COAL_MINE_TOWER_NOT_ANIMATED:
874 case GFX_COPPER_MINE_TOWER_NOT_ANIMATED:
875 case GFX_GOLD_MINE_TOWER_NOT_ANIMATED:
878 case GFX_COAL_MINE_TOWER_NOT_ANIMATED: gfx = GFX_COAL_MINE_TOWER_ANIMATED;
break;
879 case GFX_COPPER_MINE_TOWER_NOT_ANIMATED: gfx = GFX_COPPER_MINE_TOWER_ANIMATED;
break;
880 case GFX_GOLD_MINE_TOWER_NOT_ANIMATED: gfx = GFX_GOLD_MINE_TOWER_ANIMATED;
break;
888 case GFX_OILWELL_NOT_ANIMATED:
896 case GFX_COAL_MINE_TOWER_ANIMATED:
897 case GFX_COPPER_MINE_TOWER_ANIMATED:
898 case GFX_GOLD_MINE_TOWER_ANIMATED:
901 case GFX_COAL_MINE_TOWER_ANIMATED: gfx = GFX_COAL_MINE_TOWER_NOT_ANIMATED;
break;
902 case GFX_COPPER_MINE_TOWER_ANIMATED: gfx = GFX_COPPER_MINE_TOWER_NOT_ANIMATED;
break;
903 case GFX_GOLD_MINE_TOWER_ANIMATED: gfx = GFX_GOLD_MINE_TOWER_NOT_ANIMATED;
break;
913 case GFX_POWERPLANT_SPARKS:
920 case GFX_COPPER_MINE_CHIMNEY:
925 case GFX_TOY_FACTORY: {
935 case GFX_BUBBLE_GENERATOR:
936 TileLoopIndustry_BubbleGenerator(tile);
939 case GFX_TOFFEE_QUARY:
943 case GFX_SUGAR_MINE_SIEVE:
949 static bool ClickTile_Industry(
TileIndex tile)
986 return std::any_of(std::begin(ind->
produced), std::end(ind->
produced), [](
const auto &p) { return IsValidCargoID(p.cargo) && CargoSpec::Get(p.cargo)->label == CT_WOOD; });
989 static const uint8_t _plantfarmfield_type[] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6};
1003 default:
return false;
1023 TileIndex neighbour = tile + neighbour_diff;
1028 if (or_ == 1 &&
Chance16(1, 7)) or_ = 2;
1038 static void PlantFarmField(
TileIndex tile, IndustryID industry)
1045 uint32_t r = (Random() & 0x303) + 0x404;
1047 uint size_x =
GB(r, 0, 8);
1048 uint size_y =
GB(r, 8, 8);
1053 if (ta.w == 0 || ta.h == 0)
return;
1061 if (count * 2 < ta.w * ta.h)
return;
1065 uint counter =
GB(r, 5, 3);
1066 uint field_type =
GB(r, 8, 8) * 9 >> 8;
1072 MakeField(cur_tile, field_type, industry);
1080 type = _plantfarmfield_type[Random() & 0xF];
1089 void PlantRandomFarmField(
const Industry *i)
1091 int x = i->
location.
w / 2 + Random() % 31 - 16;
1092 int y = i->
location.
h / 2 + Random() % 31 - 16;
1111 _industry_sound_ctr = 1;
1112 _industry_sound_tile = tile;
1130 auto itp = std::begin(i->
produced);
1156 uint16_t amount = p.rate;
1159 p.waiting = ClampTo<uint16_t>(p.waiting + amount);
1163 static void ProduceIndustryGoods(
Industry *i)
1168 if ((i->
counter & 0x3F) == 0) {
1171 if (std::any_of(std::begin(i->
produced), std::end(i->
produced), [](
const auto &p) { return p.history[LAST_MONTH].production > 0; })) {
1213 if (plant) PlantRandomFarmField(i);
1236 void OnTick_Industry()
1238 if (_industry_sound_ctr != 0) {
1239 _industry_sound_ctr++;
1241 if (_industry_sound_ctr == 75) {
1243 }
else if (_industry_sound_ctr == 160) {
1244 _industry_sound_ctr = 0;
1249 if (_game_mode == GM_EDITOR)
return;
1252 ProduceIndustryGoods(i);
1289 uint maxdist_x = maxdist;
1290 uint maxdist_y = maxdist;
1310 if (_game_mode == GM_EDITOR)
return CommandCost();
1317 extern bool _ignore_restrictions;
1326 if (_game_mode == GM_EDITOR && _ignore_restrictions)
return CommandCost();
1438 if (i->
type == (uint8_t)type && i->
town == *t) {
1447 bool IsSlopeRefused(
Slope current,
Slope refused)
1490 if (ret.
Failed())
return ret;
1509 if (ret.
Failed())
return ret;
1513 if (ret.
Failed())
return ret;
1535 bool refused_slope =
false;
1536 bool custom_shape =
false;
1547 custom_shape =
true;
1549 if (ret.
Failed())
return ret;
1557 if (custom_shape_check !=
nullptr) *custom_shape_check = custom_shape;
1578 return_cmd_error(STR_ERROR_CAN_ONLY_BE_BUILT_IN_TOWNS_WITH_POPULATION_OF_1200);
1588 static bool CheckCanTerraformSurroundingTiles(
TileIndex tile, uint height,
int internal)
1600 if (
internal != 0 &&
Delta(curh, height) > 1)
return false;
1605 if (
internal == 0 && curh != height) {
1606 if (
TileX(tile_walk) == 0 ||
TileY(tile_walk) == 0 || !CheckCanTerraformSurroundingTiles(tile_walk +
TileDiffXY(-1, -1), height,
internal + 1)) {
1627 if (it.ti.x > max_x) max_x = it.ti.x;
1628 if (it.ti.y > max_y) max_y = it.ti.y;
1654 if (!CheckCanTerraformSurroundingTiles(tile_walk, h, 0)) {
1676 curh += (curh > h) ? -1 : 1;
1697 static const int dmax = 14;
1704 if (i == i2)
continue;
1766 if (!IsTileType(tile, MP_INDUSTRY) || GetIndustryIndex(tile) != ind->index) return false;
1767 ind->stations_near.insert(st);
1768 st->AddIndustryToDeliver(ind, tile);
1792 for (
size_t index = 0; index < std::size(indspec->produced_cargo); ++index) {
1796 p.
cargo = indspec->produced_cargo[index];
1797 p.
rate = indspec->production_rate[index];
1800 for (
size_t index = 0; index < std::size(indspec->
accepts_cargo); ++index) {
1810 p.rate = ClampTo<uint8_t>((
RandomRange(256) + 128) * p.rate >> 8);
1817 uint16_t r = Random();
1820 i->
random = initial_random_bits;
1858 p.history[LAST_MONTH].production = p.waiting * 8;
1881 for (uint j = 0; j < maxcargoes; j++) {
1895 a.
cargo = INVALID_CARGO;
1904 if (std::any_of(std::begin(i->
accepted), std::begin(i->
accepted) + j, [&cargo](
const auto &a) { return a.cargo == cargo; })) {
1919 for (uint j = 0; j < maxcargoes; j++) {
1931 p.
cargo = INVALID_CARGO;
1935 if (std::find(std::begin(indspec->produced_cargo), std::end(indspec->produced_cargo), cargo) == std::end(indspec->produced_cargo)) {
1940 if (std::any_of(std::begin(i->
produced), std::begin(i->
produced) + j, [&cargo](
const auto &p) { return p.cargo == cargo; })) {
1977 for (uint j = 0; j != 50; j++) PlantRandomFarmField(i);
2003 assert(layout_index < indspec->layouts.size());
2010 if (ret.
Failed())
return ret;
2014 if (ret.
Failed())
return ret;
2015 assert(t !=
nullptr);
2018 if (ret.
Failed())
return ret;
2021 std::vector<ClearedObjectArea> object_areas(_cleared_object_areas);
2023 _cleared_object_areas = object_areas;
2024 if (ret.
Failed())
return ret;
2032 if (ret.
Failed())
return ret;
2035 bool custom_shape_check =
false;
2036 ret =
CheckIfIndustryTileSlopes(tile, layout, layout_index, type, random_initial_bits, founder, creation_type, &custom_shape_check);
2037 if (ret.
Failed())
return ret;
2049 DoCreateNewIndustry(*ip, tile, type, layout, layout_index, t, founder, random_initial_bits);
2086 uint16_t random_initial_bits =
GB(seed, 0, 16);
2087 uint32_t random_var8f = randomizer.
Next();
2088 size_t num_layouts = indspec->
layouts.size();
2099 if (prospect_success) {
2103 for (
int i = 0; i < 5000; i++) {
2109 size_t layout =
RandomRange((uint32_t)num_layouts);
2111 for (
size_t j = 0; j < num_layouts; j++) {
2112 layout = (layout + 1) % num_layouts;
2121 if (prospect_success) {
2129 size_t layout = first_layout;
2130 if (layout >= num_layouts)
return CMD_ERROR;
2133 for (
size_t i = 0; i < num_layouts; i++) {
2134 layout = (layout + 1) % num_layouts;
2140 if (ret.
Failed())
return ret;
2143 if ((flags &
DC_EXEC) && ind !=
nullptr && _game_mode != GM_EDITOR) {
2190 }
else if (prod_level < ind->prod_level) {
2193 if (prod_level != ind->
prod_level && !custom_news.empty()) str = STR_NEWS_CUSTOM_ITEM;
2200 if (show_news && str != STR_NULL) {
2206 default: NOT_REACHED();
2210 if (str == STR_NEWS_CUSTOM_ITEM) {
2212 }
else if (str > STR_LAST_STRINGID) {
2219 AddIndustryNewsItem(str, nt, ind->
index);
2273 if (!text.empty()) ind->
text = text;
2291 uint32_t seed = Random();
2292 uint32_t seed2 = Random();
2295 [[maybe_unused]]
CommandCost ret =
CreateNewIndustryHelper(tile, type,
DC_EXEC, indspec, layout_index, seed,
GB(seed2, 0, 16),
OWNER_NONE, creation_type, &i);
2296 assert(i !=
nullptr || ret.
Failed());
2313 *force_at_least_one =
false;
2359 static const uint16_t numof_industry_table[] = {
2387 uint tries = try_hard ? 10000u : 2000u;
2388 for (; tries > 0; tries--) {
2390 if (ind !=
nullptr)
return ind;
2445 static const int NEWINDS_PER_MONTH = 0x38000 / (10 * 12);
2466 uint32_t total_prob = 0;
2467 uint num_forced = 0;
2471 total_prob += industry_probs[it];
2472 if (force_at_least_one[it]) num_forced++;
2476 if (total_prob == 0 || total_amount < num_forced) {
2478 total_amount = num_forced;
2485 if (force_at_least_one[it]) {
2486 assert(total_amount > 0);
2493 for (uint i = 0; i < total_amount; i++) {
2495 IndustryType it = 0;
2496 while (r >= industry_probs[it]) {
2497 r -= industry_probs[it];
2501 assert(industry_probs[it] > 0);
2518 std::rotate(std::rbegin(p.history), std::rbegin(p.history) + 1, std::rend(p.history));
2519 p.history[THIS_MONTH].production = 0;
2520 p.history[THIS_MONTH].transported = 0;
2536 p.rate = ClampTo<uint8_t>(
CeilDiv(indspec->production_rate[&p - this->produced.data()] * this->prod_level,
PRODLEVEL_DEFAULT));
2540 void Industry::FillCachedName()
const
2542 auto tmp_params = MakeParameters(this->
index);
2546 void ClearAllIndustryCachedNames()
2571 bool changed =
false;
2572 uint num_planned = 0;
2578 changed |= num_planned != total_amount;
2579 if (!changed)
return;
2582 uint force_build = 0;
2583 uint32_t total_prob = 0;
2591 if (total_prob == 0)
return;
2594 total_amount = (total_amount <= force_build) ? 0 : total_amount - force_build;
2597 while (total_amount > 0) {
2599 IndustryType it = 0;
2600 while (r >= this->
builddata[it].probability) {
2605 assert(this->
builddata[it].probability > 0);
2620 uint32_t total_prob = 0;
2624 missing += difference;
2625 if (this->
builddata[it].wait_count > 0)
continue;
2626 if (difference > 0) {
2634 total_prob += difference;
2652 if (this->
builddata[it].wait_count > 0)
continue;
2654 if (difference <= 0)
continue;
2655 if (count == 1)
break;
2656 if (r < (uint)difference)
break;
2664 if (ind ==
nullptr) {
2739 bool c_accepts =
false;
2740 bool c_produces =
false;
2742 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
2750 if (!c_accepts && !c_produces)
continue;
2757 if (o->IsType(OT_GOTO_STATION) && !(o->GetUnloadType() &
OUFB_TRANSFER)) {
2760 assert(st !=
nullptr);
2763 if ((o->GetUnloadType() &
OUFB_UNLOAD) && !c_accepts)
break;
2790 default: NOT_REACHED();
2795 AddIndustryNewsItem(
2796 percent >= 0 ? STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_SMOOTH : STR_NEWS_INDUSTRY_PRODUCTION_DECREASE_SMOOTH,
2802 static const uint PERCENT_TRANSPORTED_60 = 153;
2803 static const uint PERCENT_TRANSPORTED_80 = 204;
2813 bool closeit =
false;
2815 bool standard =
false;
2816 bool suppress_message =
false;
2817 bool recalculate_multipliers =
false;
2822 int8_t increment = 0;
2825 if (callback_enabled) {
2828 suppress_message =
HasBit(res, 7);
2831 res =
GB(res, 0, 4);
2833 default: NOT_REACHED();
2835 case 0x1: div = 1;
break;
2836 case 0x2: mul = 1;
break;
2837 case 0x3: closeit =
true;
break;
2838 case 0x4: standard =
true;
break;
2839 case 0x5:
case 0x6:
case 0x7:
2840 case 0x8: div = res - 0x3;
break;
2841 case 0x9:
case 0xA:
case 0xB:
2842 case 0xC: mul = res - 0x7;
break;
2845 increment = res == 0x0D ? -1 : 1;
2849 recalculate_multipliers =
true;
2854 if (monthly == original_economy)
return;
2863 if (original_economy) {
2864 if (only_decrease ||
Chance16(1, 3)) {
2876 uint32_t r = Random();
2877 int old_prod, new_prod, percent;
2879 int mult = (p.history[LAST_MONTH].PctTransported() > PERCENT_TRANSPORTED_60) ? 1 : -1;
2881 new_prod = old_prod = p.rate;
2885 if (only_decrease) {
2889 }
else if (
Chance16I(1, ((p.history[LAST_MONTH].PctTransported() > PERCENT_TRANSPORTED_80) ? 6 : 3), r)) {
2896 new_prod += mult * (std::max(((
RandomRange(50) + 10) * old_prod) >> 8, 1U));
2900 new_prod =
Clamp(new_prod, 1, 255);
2902 new_prod =
Clamp(new_prod, 0, 16);
2910 if (new_prod == old_prod && old_prod > 1) {
2915 percent = (old_prod == 0) ? 100 : (new_prod * 100 / old_prod - 100);
2919 if (new_prod > 1) closeit =
false;
2921 if (
abs(percent) >= 10) {
2946 recalculate_multipliers =
true;
2951 while (div-- != 0 && !closeit) {
2957 recalculate_multipliers =
true;
2963 if (increment != 0) {
2968 recalculate_multipliers =
true;
2983 if (!suppress_message && str != STR_NULL) {
2995 default: NOT_REACHED();
2999 if (str > STR_LAST_STRINGID) {
3003 }
else if (closeit) {
3014 AddIndustryNewsItem(str, nt, i->
index);
3038 if (change_loop == 0) {
3050 for (uint16_t j = 0; j < change_loop; j++) {
3062 cur_company.Restore();
3084 cur_company.Restore();
3091 void InitializeIndustries()
3094 _industry_sound_tile = 0;
3106 bool force_at_least_one;
3108 if (chance == 0 || !force_at_least_one)
continue;
3112 ShowErrorMessage(STR_ERROR_NO_SUITABLE_PLACES_FOR_INDUSTRIES, STR_ERROR_NO_SUITABLE_PLACES_FOR_INDUSTRIES_EXPLANATION,
WL_WARNING);
3115 if (count >= 3)
break;
3147 PR_BUILD_INDUSTRY_RAW : PR_BUILD_INDUSTRY] * this->cost_multiplier) >> 8;
3203 GetSlopePixelZ_Industry,
3205 AddAcceptedCargo_Industry,
3206 GetTileDesc_Industry,
3207 GetTileTrackStatus_Industry,
3209 AnimateTile_Industry,
3211 ChangeTileOwner_Industry,
3214 GetFoundation_Industry,
3215 TerraformTile_Industry,
3221 return std::tie(lhs.distance, lhs.industry->
index) < std::tie(rhs.distance, rhs.industry->
index);
3230 auto ita = std::find_if(std::rbegin(ind->
accepted), std::rend(ind->
accepted), [](
const auto &a) { return IsValidCargoID(a.cargo); });
3234 auto itp = std::find_if(std::rbegin(ind->
produced), std::rend(ind->
produced), [](
const auto &p) { return IsValidCargoID(p.cargo); });
Base functions for all AIs.
void DeleteAnimatedTile(TileIndex tile)
Removes the given tile from the animated tile table.
void AddAnimatedTile(TileIndex tile, bool mark_dirty)
Add the given tile to the animated tile table (if it does not exist yet).
Functions related to autoslope.
bool AutoslopeEnabled()
Tests if autoslope is enabled for _current_company.
Class for backupping variables and making sure they are restored later.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
bool IsBridgeAbove(Tile t)
checks if a bridge is set above the ground of this tile
Tables with default industry layouts and behaviours.
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
bool IsValidCargoID(CargoID t)
Test whether cargo type is not INVALID_CARGO.
static constexpr CargoLabel CT_PASSENGERS
Available types of cargo Labels may be re-used between different climates.
@ Industry
Source/destination is an industry.
Cheats _cheats
All the cheats.
Types related to cheating.
static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company=MAX_COMPANIES)
Broadcast a new event to all active AIs.
Common return value for all commands.
bool Succeeded() const
Did this command succeed?
bool Failed() const
Did this command fail?
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
An interval timer will fire every interval, and will continue to fire until it is deleted.
void ResetOverride()
Resets the override, which is used while initializing game.
static constexpr TimerGameTick::Ticks INDUSTRY_CUT_TREE_TICKS
Cycle duration for lumber mill's extra action.
static constexpr TimerGameTick::Ticks INDUSTRY_PRODUCE_TICKS
Cycle duration for industry production.
Wrapper class to abstract away the way the tiles are stored.
static Date date
Current date in days (day counter).
static Year year
Current year, starting at 0.
static Year year
Current year, starting at 0.
static TickCounter counter
Monotonic counter, in ticks, since start of game.
Map accessors for 'clear' tiles.
bool IsClearGround(Tile t, ClearGround ct)
Set the type of clear tile.
void SetFence(Tile t, DiagDirection side, uint h)
Sets the type of fence (and whether there is one) for the given border.
IndustryID GetIndustryIndexOfField(Tile t)
Get the industry (farm) that made the field.
void SetIndustryIndexOfField(Tile t, IndustryID i)
Set the industry (farm) that made the field.
void MakeField(Tile t, uint field_type, IndustryID industry)
Make a (farm) field tile.
void SetClearCounter(Tile t, uint c)
Sets the counter used to advance to the next clear density/field type.
uint GetFence(Tile t, DiagDirection side)
Is there a fence at the given border?
Functions related to commands.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
DoCommandFlag
List of flags for a command.
@ DC_NO_TEST_TOWN_RATING
town rating does not disallow you from building
@ DC_AUTO
don't allow building on structures
@ DC_NO_WATER
don't allow building on water
@ DC_NO_MODIFY_TOWN_RATING
do not change town rating
@ DC_EXEC
execute the given command
Definition of stuff that is very close to a company, like the company struct itself.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
CompanyID _current_company
Company currently doing an action.
bool IsLocalCompany()
Is the current company the local company?
Owner
Enum for all companies/owners.
@ INVALID_OWNER
An invalid owner.
@ OWNER_DEITY
The object is owned by a superuser / goal script.
@ OWNER_NONE
The tile has no ownership.
@ OWNER_WATER
The tile/execution is done by "water".
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Axis OtherAxis(Axis a)
Select the other axis as provided.
Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
DiagDirection
Enumeration for diagonal directions.
@ DIAGDIR_NE
Northeast, upper right on your monitor.
void ReleaseDisastersTargetingIndustry(IndustryID i)
Marks all disasters targeting this industry in such a way they won't call Industry::Get(v->dest_tile)...
static uint ScaleByInverseCargoScale(uint num, bool town)
Scale a number by the inverse of the cargo scale setting, e.g.
bool EconomyIsInRecession()
Is the economy in recession?
uint ScaleByCargoScale(uint num, bool town)
Scale a number by the cargo scale setting.
@ EXPENSES_CONSTRUCTION
Construction costs.
@ EXPENSES_OTHER
Other expenses.
EffectVehicle * CreateEffectVehicleAbove(int x, int y, int z, EffectVehicleType type)
Create an effect vehicle above a particular location.
EffectVehicle * CreateEffectVehicle(int x, int y, int z, EffectVehicleType type)
Create an effect vehicle at a particular location.
Base class for all effect vehicles.
Functions related to effect vehicles.
@ EV_BUBBLE
Bubble of bubble generator (industry).
@ EV_CHIMNEY_SMOKE
Smoke of power plant (industry).
@ EV_COPPER_MINE_SMOKE
Smoke at copper mine.
Functions related to errors.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
@ WL_WARNING
Other information.
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
Base functions for all Games.
bool _generating_world
Whether we are generating the map or not.
Functions related to world/map generation.
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
@ GWP_INDUSTRY
Generate industries.
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
@ LG_TERRAGENESIS
TerraGenesis Perlin landscape generator.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
uint8_t GetSnowLine()
Get the current snow line, either variable or static.
uint8_t HighestSnowLine()
Get the highest possible snow line height, either variable or static.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
IndustryControlFlags
Flags to control/override the behaviour of an industry.
@ INDCTL_EXTERNAL_PROD_LEVEL
Indicates that the production level of the industry is externally controlled.
@ INDCTL_NONE
No flags in effect.
@ INDCTL_NO_CLOSURE
Industry can not close regardless of production level or time since last delivery.
@ INDCTL_NO_PRODUCTION_DECREASE
When industry production change is evaluated, rolls to decrease are ignored.
@ INDCTL_MASK
Mask of all flags set.
@ INDCTL_NO_PRODUCTION_INCREASE
When industry production change is evaluated, rolls to increase are ignored.
static constexpr uint8_t PRODLEVEL_MAXIMUM
the industry is running at full speed
static constexpr uint8_t PRODLEVEL_DEFAULT
default level set when the industry is created
static const TimerGameEconomy::Year PROCESSING_INDUSTRY_ABANDONMENT_YEARS
If a processing industry doesn't produce for this many consecutive economy years, it may close.
static constexpr uint8_t PRODLEVEL_MINIMUM
below this level, the industry is set to be closing
static constexpr uint8_t PRODLEVEL_CLOSURE
signal set to actually close the industry
static CommandCost CheckIfIndustryIsAllowed(TileIndex tile, int type, const Town *t)
Is the industry allowed to be built at this place for the town?
CommandCost CmdIndustrySetText(DoCommandFlag flags, IndustryID ind_id, const std::string &text)
Change additional industry text.
static uint16_t GetIndustryGamePlayProbability(IndustryType it, uint8_t *min_number)
Compute the probability for constructing a new industry during game play.
static void ReportNewsProductionChangeIndustry(Industry *ind, CargoID type, int percent)
Report news that industry production has changed significantly.
static CommandCost CheckNewIndustry_Water(TileIndex tile)
Check the conditions of CHECK_WATER (Industry should be in the desert).
static uint32_t GetScaledIndustryGenerationProbability(IndustryType it, bool *force_at_least_one)
Compute the appearance probability for an industry during map creation.
static CheckNewIndustryProc *const _check_new_industry_procs[CHECK_END]
Check functions for different types of industry.
static CommandCost CheckIfFarEnoughFromConflictingIndustry(TileIndex tile, int type)
Check that the new industry is far enough from conflicting industries.
static bool TransportIndustryGoods(TileIndex tile)
Move produced cargo from industry to nearby stations.
static uint GetCurrentTotalNumberOfIndustries()
Get total number of industries existing in the game.
static CommandCost CheckNewIndustry_OilRefinery(TileIndex tile)
Check the conditions of CHECK_REFINERY (Industry should be positioned near edge of the map).
static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileLayout &layout, IndustryType type)
Are the tiles of the industry free?
static void PlaceInitialIndustry(IndustryType type, bool try_hard)
Try to build a industry on the map.
static CommandCost CheckNewIndustry_BubbleGen(TileIndex tile)
Check the conditions of CHECK_BUBBLEGEN (Industry should be in low land).
static CommandCost CheckNewIndustry_Farm(TileIndex tile)
Check the conditions of CHECK_FARM (Industry should be below snow-line in arctic).
const IndustryTileSpec * GetIndustryTileSpec(IndustryGfx gfx)
Accessor for array _industry_tile_specs.
static void AdvertiseIndustryOpening(const Industry *ind)
Advertise about a new industry opening.
static void ChopLumberMillTrees(Industry *i)
Perform a circular search around the Lumber Mill in order to find trees to cut.
static bool CheckScaledDistanceFromEdge(TileIndex tile, uint maxdist)
Check if a tile is within a distance from map edges, scaled by map dimensions independently.
static bool SearchLumberMillTrees(TileIndex tile, void *)
Search callback function for ChopLumberMillTrees.
CommandCost CmdIndustrySetExclusivity(DoCommandFlag flags, IndustryID ind_id, Owner company_id, bool consumer)
Change exclusive consumer or supplier for the industry.
static Industry * PlaceIndustry(IndustryType type, IndustryAvailabilityCallType creation_type, bool try_hard)
Try to place the industry in the game.
static CommandCost CheckIfIndustryTileSlopes(TileIndex tile, const IndustryTileLayout &layout, size_t layout_index, int type, uint16_t initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type, bool *custom_shape_check=nullptr)
Check slope requirements for industry tiles.
bool IsTileForestIndustry(TileIndex tile)
Check whether the tile is a forest.
void GenerateIndustries()
This function will create random industries during game creation.
static void ProduceIndustryGoodsHelper(Industry *i, bool scale)
Helper for ProduceIndustryGoods that scales and produces cargos.
static Industry * CreateNewIndustry(TileIndex tile, IndustryType type, IndustryAvailabilityCallType creation_type)
Create a new industry of random layout.
IndustryBuildData _industry_builder
In-game manager of industries.
CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType it, uint32_t first_layout, bool fund, uint32_t seed)
Build/Fund an industry.
static CommandCost CheckNewIndustry_Plantation(TileIndex tile)
Check the conditions of CHECK_PLANTATION (Industry should NOT be in the desert).
static void CanCargoServiceIndustry(CargoID cargo, Industry *ind, bool *c_accepts, bool *c_produces)
Can given cargo type be accepted or produced by the industry?
void CheckIndustries()
Verify whether the generated industries are complete, and warn the user if not.
static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlag flags, const IndustryTileLayout &layout)
This function tries to flatten out the land below an industry, without damaging the surroundings too ...
static void PopulateStationsNearby(Industry *ind)
Populate an industry's list of nearby stations, and if it accepts any cargo, also add the industry to...
static CommandCost CheckNewIndustry_Forest(TileIndex tile)
Check the conditions of CHECK_FOREST (Industry should be build above snow-line in arctic climate).
static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, const IndustryTileLayout &layout, size_t layout_index, Town *t, Owner founder, uint16_t initial_random_bits)
Put an industry on the map.
CommandCost CmdIndustrySetProduction(DoCommandFlag flags, IndustryID ind_id, uint8_t prod_level, bool show_news, const std::string &custom_news)
Set industry production.
CommandCost CheckNewIndustryProc(TileIndex tile)
Industrytype check function signature.
static int WhoCanServiceIndustry(Industry *ind)
Compute who can service the industry.
void ResetIndustries()
This function initialize the spec arrays of both industry and industry tiles.
static bool IsSuitableForFarmField(TileIndex tile, bool allow_fields)
Check whether the tile can be replaced by a farm field.
static CommandCost CheckNewIndustry_OilRig(TileIndex tile)
Check the conditions of CHECK_OIL_RIG (Industries at sea should be positioned near edge of the map).
void TrimIndustryAcceptedProduced(Industry *ind)
Remove unused industry accepted/produced slots – entries after the last slot with valid cargo.
static uint GetNumberOfIndustries()
Get wanted number of industries on the map.
static bool CheckIndustryCloseDownProtection(IndustryType type)
Protects an industry from closure if the appropriate flags and conditions are met INDUSTRYBEH_CANCLOS...
static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, DoCommandFlag flags, const IndustrySpec *indspec, size_t layout_index, uint32_t random_var8f, uint16_t random_initial_bits, Owner founder, IndustryAvailabilityCallType creation_type, Industry **ip)
Helper function for Build/Fund an industry.
static IntervalTimer< TimerGameEconomy > _economy_industries_daily({TimerGameEconomy::DAY, TimerGameEconomy::Priority::INDUSTRY}, [](auto) { _economy.industry_daily_change_counter+=_economy.industry_daily_increment;uint16_t change_loop=_economy.industry_daily_change_counter >> 16;_economy.industry_daily_change_counter &=0xFFFF;if(change_loop==0) { return;} Backup< CompanyID > cur_company(_current_company, OWNER_NONE);uint perc=3;if((_industry_builder.wanted_inds >> 16) > GetCurrentTotalNumberOfIndustries()) { perc=std::min(9u, perc+(_industry_builder.wanted_inds >> 16) - GetCurrentTotalNumberOfIndustries());} for(uint16_t j=0;j< change_loop;j++) { if(Chance16(perc, 100)) { _industry_builder.TryBuildNewIndustry();} else { Industry *i=Industry::GetRandom();if(i !=nullptr) { ChangeIndustryProduction(i, false);SetWindowDirty(WC_INDUSTRY_VIEW, i->index);} } } cur_company.Restore();InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, IDIWD_PRODUCTION_CHANGE);})
Every economy day handler for the industry changes Taking the original map size of 256*256,...
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
static void SetupFarmFieldFence(TileIndex tile, int size, uint8_t type, DiagDirection side)
Build farm field fence.
CommandCost CmdIndustrySetFlags(DoCommandFlag flags, IndustryID ind_id, IndustryControlFlags ctlflags)
Set industry control flags.
IndustryType GetIndustryType(Tile tile)
Retrieve the type for this industry.
static void UpdateIndustryStatistics(Industry *i)
Monthly update of industry statistics.
static CommandCost CheckNewIndustry_NULL(TileIndex)
Check the conditions of CHECK_NOTHING (Always succeeds).
static void ChangeIndustryProduction(Industry *i, bool monthly)
Change industry production or do closure.
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 CommandCost CheckNewIndustry_Lumbermill(TileIndex tile)
Check the conditions of CHECK_LUMBERMILL (Industry should be in the rain forest).
Command definitions related to industries.
Information about the behaviour of the default industry tiles.
static const DrawIndustryCoordinates _coal_plant_sparks[]
Movement of the sparks , only used for Power Station.
static const DrawBuildingsTileStruct _industry_draw_tile_data[NEW_INDUSTRYTILEOFFSET *4]
Structure for industry tiles drawing.
void SetIndustryCompleted(Tile tile)
Set if the industry that owns the tile as under construction or not.
@ GFX_WATERTILE_SPECIALCHECK
not really a tile, but rather a very special check
void SetIndustryGfx(Tile t, IndustryGfx gfx)
Set the industry graphics ID for the given industry tile.
void ResetIndustryConstructionStage(Tile tile)
Reset the construction stage counter of the industry, as well as the completion bit.
void SetIndustryConstructionCounter(Tile tile, uint8_t value)
Sets this industry tile's construction counter value.
IndustryGfx GetIndustryGfx(Tile t)
Get the industry graphics ID for the given industry tile.
bool IsIndustryCompleted(Tile t)
Is this industry tile fully built?
IndustryID GetIndustryIndex(Tile t)
Get the industry ID of the given tile.
uint8_t GetIndustryConstructionCounter(Tile tile)
Returns this industry tile's construction counter value.
void MakeIndustry(Tile t, IndustryID index, IndustryGfx gfx, uint8_t random, WaterClass wc)
Make the given tile an industry tile.
void SetIndustryAnimationLoop(Tile tile, uint8_t count)
Set the animation loop number.
void SetIndustryConstructionStage(Tile tile, uint8_t value)
Sets the industry construction stage of the specified tile.
uint8_t GetIndustryAnimationLoop(Tile tile)
Get the animation loop number.
uint8_t GetIndustryConstructionStage(Tile tile)
Returns the industry construction stage of the specified tile.
static const IndustryGfx NEW_INDUSTRYTILEOFFSET
original number of tiles
static const IndustryGfx INDUSTRYTILE_NOANIM
flag to mark industry tiles as having no animation
static const int INDUSTRY_ORIGINAL_NUM_INPUTS
Original number of accepted cargo types.
static const int INDUSTRY_NUM_OUTPUTS
Number of cargo types an industry can produce.
static const int INDUSTRY_NUM_INPUTS
Number of cargo types an industry can accept.
static const IndustryType NUM_INDUSTRYTYPES
total number of industry types, new and old; limited to 240 because we need some special ids like INV...
static const IndustryGfx INVALID_INDUSTRYTILE
one above amount is considered invalid
static const IndustryGfx NUM_INDUSTRYTILES
total number of industry tiles, new and old
static const int INDUSTRY_COMPLETED
final stage of industry construction.
@ INDUSTRYLIFE_EXTRACTIVE
Like mines.
@ INDUSTRYLIFE_BLACK_HOLE
Like power plants and banks.
@ INDUSTRYLIFE_PROCESSING
Like factories.
@ INDUSTRYLIFE_ORGANIC
Like forests.
@ ICT_MAP_GENERATION
during random map creation
@ ICT_NORMAL_GAMEPLAY
either by user or random creation process
@ ICT_SCENARIO_EDITOR
while editing a scenario
@ CHECK_REFINERY
Industry should be positioned near edge of the map.
@ CHECK_END
End marker of the industry check procedures.
@ CHECK_OIL_RIG
Industries at sea should be positioned near edge of the map.
IndustryGfx GetTranslatedIndustryTileID(IndustryGfx gfx)
Do industry gfx ID translation for NewGRFs.
std::vector< IndustryTileLayoutTile > IndustryTileLayout
A complete tile layout for an industry is a list of tiles.
IndustryBehaviour
Various industry behaviours mostly to represent original TTD specialities.
@ INDUSTRYBEH_DONT_INCR_PROD
do not increase production (oil wells) in the temperate climate
@ INDUSTRYBEH_PLANT_ON_BUILT
Fields are planted around when built (all farms)
@ INDUSTRYBEH_CARGOTYPES_UNLIMITED
Allow produced/accepted cargoes callbacks to supply more than 2 and 3 types.
@ INDUSTRYBEH_NO_PAX_PROD_CLAMP
Do not clamp production of passengers. (smooth economy only)
@ INDUSTRYBEH_AFTER_1960
can only be built after 1960 (oil rigs)
@ INDUSTRYBEH_CUT_TREES
cuts trees and produce first output cargo from them (lumber mill)
@ INDUSTRYBEH_BUILT_ONWATER
is built on water (oil rig)
@ INDUSTRYBEH_PLANT_FIELDS
periodically plants fields around itself (temp and arctic farms)
@ INDUSTRYBEH_CANCLOSE_LASTINSTANCE
Allow closing down the last instance of this type.
@ INDUSTRYBEH_ONLY_NEARTOWN
is always built near towns (toy shop)
@ INDUSTRYBEH_TOWN1200_MORE
can only be built in towns larger than 1200 inhabitants (temperate bank)
@ INDUSTRYBEH_ONLY_INTOWN
can only be built in towns (arctic/tropic banks, water tower)
@ INDUSTRYBEH_BEFORE_1950
can only be built before 1950 (oil wells)
@ INDUSTRYBEH_NOBUILT_MAPCREATION
Do not force one instance of this type to appear on map generation.
@ INDTILE_SPECIAL_ACCEPTS_ALL_CARGO
Tile always accepts all cargoes the associated industry accepts.
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
Functions related to OTTD's landscape.
Command definitions related to landscape (slopes etc.).
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.
uint DistanceMax(TileIndex t0, TileIndex t1)
Gets the biggest distance component (x or y) between the two given tiles.
uint DistanceFromEdgeDir(TileIndex tile, DiagDirection dir)
Gets the distance to the edge of the map in given direction.
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.
TileIndex TileAddXY(TileIndex tile, int x, int y)
Adds a given offset to a tile.
TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between two tiles from a TileIndexDiffC struct.
TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
TileIndexDiff TileOffsByAxis(Axis axis)
Convert an Axis to a TileIndexDiff.
#define RandomTile()
Get a valid random tile.
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
int32_t TileIndexDiff
An offset value between two tiles.
constexpr T abs(const T a)
Returns the absolute value of (scalar) variable.
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
constexpr T Delta(const T a, const T b)
Returns the (absolute) difference between two (scalar) variables.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
constexpr uint ClampU(const uint a, const uint min, const uint max)
Clamp an unsigned integer between an interval.
StringID MapGRFStringID(uint32_t grfid, StringID str)
Used when setting an object's property to map to the GRF's strings while taking in consideration the ...
@ IAT_TILELOOP
Trigger in the periodic tile loop.
@ IAT_CONSTRUCTION_STATE_CHANGE
Trigger whenever the construction state changes.
@ IAT_INDUSTRY_DISTRIBUTES_CARGO
Trigger when cargo is distributed.
@ IAT_INDUSTRY_TICK
Trigger every tick.
static const uint8_t ANIM_STATUS_NO_ANIMATION
There is no animation.
@ CBM_INDT_ACCEPT_CARGO
decides accepted types
@ CBM_INDT_AUTOSLOPE
decides allowance of autosloping
@ CBM_INDT_CARGO_ACCEPTANCE
decides amount of cargo acceptance
@ CBM_INDT_SHAPE_CHECK
decides slope suitability
@ CBM_INDT_DRAW_FOUNDATIONS
decides if default foundations need to be drawn
@ CBM_IND_PROD_CHANGE_BUILD
initialise production level on construction
@ CBM_IND_PRODUCTION_CHANGE
controls random production change
@ CBM_IND_LOCATION
check industry construction on given area
@ CBM_IND_DECIDE_COLOUR
give a custom colour to newly build industries
@ CBM_IND_SPECIAL_EFFECT
control special effects
@ CBM_IND_INPUT_CARGO_TYPES
customize the cargoes the industry requires
@ CBM_IND_MONTHLYPROD_CHANGE
controls monthly random production change
@ CBM_IND_PRODUCTION_CARGO_ARRIVAL
call production callback when cargo arrives at the industry
@ CBM_IND_OUTPUT_CARGO_TYPES
customize the cargoes the industry produces
@ CBM_IND_PRODUCTION_256_TICKS
call production callback every 256 ticks
@ CBID_INDUSTRY_OUTPUT_CARGO_TYPES
Customize the output cargo types of a newly build industry.
@ CBID_INDUSTRY_SPECIAL_EFFECT
Called to determine industry special effects.
@ CBID_INDTILE_AUTOSLOPE
Called to determine if industry can alter the ground below industry tile.
@ CBID_INDUSTRY_DECIDE_COLOUR
Called to determine the colour of an industry.
@ CBID_INDTILE_DRAW_FOUNDATIONS
Called to determine the type (if any) of foundation to draw for industry tile.
@ CBID_INDUSTRY_PRODUCTION_CHANGE
Called on production changes, so it can be adjusted.
@ CBID_INDUSTRY_MONTHLYPROD_CHANGE
Called monthly on production changes, so it can be adjusted more frequently.
@ CBID_INDUSTRY_PROD_CHANGE_BUILD
Called when industry is built to set initial production level.
@ CBID_INDTILE_CARGO_ACCEPTANCE
Called to query the cargo acceptance of the industry tile.
@ CBID_INDTILE_ACCEPT_CARGO
Called to determine which cargoes an industry should accept.
@ CBID_INDUSTRY_INPUT_CARGO_TYPES
Customize the input cargo types of a newly build industry.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
CargoID GetCargoTranslation(uint8_t cargo, const GRFFile *grffile, bool usebit)
Translate a GRF-local cargo slot/bitnum into a CargoID.
Cargo support for NewGRFs.
void ErrorUnknownCallbackResult(uint32_t grfid, uint16_t cbid, uint16_t cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
bool ConvertBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
GRFConfig * GetGRFConfig(uint32_t grfid, uint32_t mask)
Retrieve a NewGRF from the current config by its grfid.
Functions/types related to NewGRF debugging.
void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index)
Delete inspect window for a given feature and index.
CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, size_t layout, uint32_t seed, uint16_t initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type)
Check that the industry callback allows creation of the industry.
bool IndustryTemporarilyRefusesCargo(Industry *ind, CargoID cargo_type)
Check whether an industry temporarily refuses to accept a certain cargo.
void IndustryProductionCallback(Industry *ind, int reason)
Get the industry production callback and apply it to the industry.
uint32_t GetIndustryProbabilityCallback(IndustryType type, IndustryAvailabilityCallType creation_type, uint32_t default_prob)
Check with callback CBID_INDUSTRY_PROBABILITY whether the industry can be built.
uint16_t GetIndustryCallback(CallbackID callback, uint32_t param1, uint32_t param2, Industry *industry, IndustryType type, TileIndex tile)
Perform an industry callback.
IndustryAvailabilityCallType
From where has callback CBID_INDUSTRY_PROBABILITY been called.
@ IACT_USERCREATION
from the Fund/build window
@ IACT_RANDOMCREATION
during creation of random ingame industry
@ IACT_MAPGENERATION
during random map generation
@ IACT_PROSPECTCREATION
from the Fund/build using prospecting
void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
Trigger a random trigger for all industry tiles.
CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, size_t layout_index, uint16_t initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type)
Check the slope of a tile of a new industry.
void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger)
Trigger a random trigger for a single industry tile.
NewGRF handling of industry tiles.
@ INDTILE_TRIGGER_TILE_LOOP
The tile of the industry has been triggered during the tileloop.
@ INDUSTRY_TRIGGER_INDUSTRY_TICK
The industry has been triggered via its tick.
uint32_t GetRegister(uint i)
Gets the value of a so-called newgrf "register".
Functions related to news.
void DeleteIndustryNews(IndustryID iid)
Remove news regarding given industry.
@ NT_INDUSTRY_NOBODY
Other industry production changes.
@ NT_INDUSTRY_COMPANY
Production changes of industry serviced by local company.
@ NT_INDUSTRY_OPEN
Opening of industries.
@ NT_INDUSTRY_CLOSE
Closing of industries.
@ NT_INDUSTRY_OTHER
Production changes of industry serviced by competitor(s)
@ OUFB_TRANSFER
Transfer all cargo onto the platform.
@ OUFB_UNLOAD
Force unloading all cargo onto the platform, possibly not getting paid.
Some methods of Pool are placed here in order to reduce compilation time and binary size.
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
uint32_t RandomRange(uint32_t limit, const std::source_location location=std::source_location::current())
Pick a random number between 0 and limit - 1, inclusive.
bool Chance16I(const uint32_t a, const uint32_t b, const uint32_t r)
Checks if a given randomize-number is below a given probability.
bool Chance16(const uint32_t a, const uint32_t b, const std::source_location location=std::source_location::current())
Flips a coin with given probability.
bool Chance16R(const uint32_t a, const uint32_t b, uint32_t &r, const std::source_location location=std::source_location::current())
Flips a coin with a given probability and saves the randomize-number in a variable.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
ClientSettings _settings_client
The current settings for this game.
@ ID_CUSTOM
Custom number of industries.
@ ID_VERY_LOW
Very few industries at game start.
@ ID_END
Number of industry density settings.
@ ID_FUND_ONLY
The game does not build industries.
static constexpr int GetSlopeMaxZ(Slope s)
Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
static constexpr bool IsSteepSlope(Slope s)
Checks if a slope is steep.
Foundation FlatteningFoundation(Slope s)
Returns the foundation needed to flatten a slope.
Slope ComplementSlope(Slope s)
Return the complement of a slope.
Slope
Enumeration for the slope-type.
@ SLOPE_W
the west corner of the tile is raised
@ SLOPE_E
the east corner of the tile is raised
@ SLOPE_S
the south corner of the tile is raised
@ SLOPE_N
the north corner of the tile is raised
@ SLOPE_SW
south and west corner are raised
@ SLOPE_NE
north and east corner are raised
@ SLOPE_SE
south and east corner are raised
@ SLOPE_NW
north and west corner are raised
Foundation
Enumeration for Foundations.
@ FOUNDATION_LEVELED
The tile is leveled up to a flat slope.
@ FOUNDATION_NONE
The tile has no foundation, the slope remains unchanged.
Functions related to sound.
SoundFx
Sound effects from baseset.
@ SND_30_TOFFEE_QUARRY
48 == 0x30 Industry animation: toffee quarry: drill
@ SND_2E_BUBBLE_GENERATOR
46 == 0x2E Industry animation: bubble generator (1): generate bubble
@ SND_2D_SUGAR_MINE_1
45 == 0x2D Industry animation: sugar mine (1): shaking sieve
@ SND_2B_TOY_FACTORY_2
43 == 0x2B Industry animation: toy factory (2): stamp product
@ SND_38_LUMBER_MILL_1
56 == 0x38 Industry animation: lumber mill (1): chainsaw
@ SND_29_SUGAR_MINE_2
41 == 0x29 Industry animation: sugar mine (2): shaking sieve
@ SND_2C_TOY_FACTORY_1
44 == 0x2C Industry animation: toy factory (1): conveyor belt
@ SND_37_LUMBER_MILL_2
55 == 0x37 Industry animation: lumber mill (2): falling tree
@ SND_0C_POWER_STATION
10 == 0x0A Industry animation: power station: spark
@ SND_0B_MINE
9 == 0x09 Industry animation: coal/copper/gold mine: headgear
@ SND_36_LUMBER_MILL_3
54 == 0x36 Industry animation: lumber mill (3): crashing tree
@ SND_2A_TOY_FACTORY_3
42 == 0x2A Industry animation: toy factory (3): eject product
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...
PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
Base classes/functions for stations.
void ForAllStationsAroundTiles(const TileArea &ta, Func func)
Call a function on all stations that have any part of the requested area within their catchment.
void ClearDockingTilesCheckingNeighbours(TileIndex tile)
Clear docking tile status from tiles around a removed dock, if the tile has no neighbours which would...
bool IsOilRig(Tile t)
Is tile t part of an oilrig?
Definition of base types and functions in a cross-platform compatible way.
#define MAX_UVALUE(type)
The largest value that can be entered in a variable.
#define lengthof(array)
Return the length of an fixed size array.
Functions related to low-level strings.
void GetStringWithArgs(StringBuilder &builder, StringID string, StringParameters &args, uint case_index, bool game_script)
Get a parsed string with most special stringcodes replaced by the string parameters.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
uint8_t status
Status; 0: no looping, 1: looping, 0xFF: no animation.
Class to backup a specific variable and restore it later.
const T & GetOriginalValue() const
Returns the backupped value.
void Restore()
Restore the variable.
VehicleType type
Type of vehicle.
Class for storing amounts of cargo.
static void InvalidateAllFrom(SourceType src_type, SourceID src)
Invalidates (sets source_id to INVALID_SOURCE) all cargo packets from given source.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
bool value
tells if the bool cheat is active or not
Cheat magic_bulldozer
dynamite industries, objects
SoundSettings sound
sound effect settings
uint8_t raw_industry_construction
type of (raw) industry construction (none, "normal", prospecting)
uint8_t industry_platform
the amount of flat land around an industry
uint8_t industry_density
The industry density.
This structure is the same for both Industries and Houses.
This is used to gather some data about animation drawing in the industry code Image_1-2-3 are in fact...
uint8_t image_1
image offset 1
uint8_t image_3
image offset 3
uint8_t image_2
image offset 2
int x
coordinate x of the first image offset
EconomyType type
economy type (original/smooth/frozen)
bool multiple_industry_per_town
allow many industries of the same type per town
uint32_t industry_daily_change_counter
Bits 31-16 are number of industry to be performed, 15-0 are fractional collected daily.
uint32_t industry_daily_increment
The value which will increment industry_daily_change_counter. Computed value. NOSAVE.
A special vehicle is one of the following:
uint8_t animation_substate
Sub state to time the change of the graphics/behaviour.
const char * GetName() const
Get the name of this grf.
const struct GRFFile * grffile
grf file that introduced this entity
std::array< const struct SpriteGroup *, Tcnt > spritegroup
pointers to the different sprites of the entity
uint16_t custom_industry_number
manually entered number of industries
uint8_t oil_refinery_limit
distance oil refineries allowed from map edge
uint8_t land_generator
the landscape generator
uint8_t landscape
the landscape we're currently in
EconomySettings economy
settings to change the economy
ConstructionSettings construction
construction of things in-game
DifficultySettings difficulty
settings related to the difficulty
GameCreationSettings game_creation
settings used during the creation of a game (map)
StationSettings station
settings related to station management
Data for managing the number and type of industries in the game.
void Reset()
Completely reset the industry build data.
void EconomyMonthlyLoop()
Monthly update of industry build data.
uint32_t wanted_inds
Number of wanted industries (bits 31-16), and a fraction (bits 15-0).
void SetupTargetCount()
Decide how many industries of each type are needed.
void TryBuildNewIndustry()
Try to create a random industry, during gameplay.
IndustryTypeBuildData builddata[NUM_INDUSTRYTYPES]
Industry build data for every industry type.
Defines the data structure for constructing industry.
bool IsProcessingIndustry() const
Is an industry with the spec a processing industry?
std::vector< uint8_t > random_sounds
Random sounds;.
uint16_t callback_mask
Bitmask of industry callbacks that have to be called.
Money GetRemovalCost() const
Get the cost for removing this industry Take note that the cost will always be zero for non-grf indus...
uint8_t appear_creation[NUM_LANDSCAPE]
Probability of appearance during map creation.
std::array< CargoID, INDUSTRY_NUM_INPUTS > accepts_cargo
16 accepted cargoes.
bool UsesOriginalEconomy() const
Determines whether this industrytype uses standard/newgrf production changes.
uint8_t minimal_cargo
minimum amount of cargo transported to the stations.
uint32_t removal_cost_multiplier
Base removal cost multiplier.
uint32_t prospecting_chance
Chance prospecting succeeds.
StringID production_up_text
Message appearing when the industry's production is increasing.
StringID name
Displayed name of the industry.
IndustryBehaviour behaviour
How this industry will behave, and how others entities can use it.
bool IsRawIndustry() const
Is an industry with the spec a raw industry?
IndustryType conflicting[3]
Industries this industry cannot be close to.
uint8_t appear_ingame[NUM_LANDSCAPE]
Probability of appearance in game.
GRFFileProps grf_prop
properties related to the grf file
StringID production_down_text
Message appearing when the industry's production is decreasing.
IndustryLifeType life_type
This is also known as Industry production flag, in newgrf specs.
StringID closure_text
Message appearing when the industry closes.
StringID new_industry_text
Message appearing when the industry is built.
std::vector< IndustryTileLayout > layouts
List of possible tile layouts for the industry.
bool enabled
entity still available (by default true).newgrf can disable it, though
Money GetConstructionCost() const
Get the cost for constructing this industry.
uint8_t check_proc
Index to a procedure to check for conflicting circumstances.
Definition of one tile in an industry tile layout.
Defines the data structure of each individual tile of an industry.
uint8_t anim_next
Next frame in an animation.
IndustryTileSpecialFlags special_flags
Bitmask of extra flags used by the tile.
std::array< CargoID, INDUSTRY_NUM_INPUTS > accepts_cargo
Cargo accepted by this tile.
GRFFileProps grf_prop
properties related to the grf file
Slope slopes_refused
slope pattern on which this tile cannot be built
AnimationInfo animation
Information about the animation (is it looping, how many loops etc)
std::array< int8_t, INDUSTRY_NUM_INPUTS > acceptance
Level of acceptance per cargo type (signed, may be negative!)
uint8_t callback_mask
Bitmask of industry tile callbacks that have to be called.
bool anim_state
When true, the tile has to be drawn using the animation state instead of the construction state.
uint8_t anim_production
Animation frame to start when goods are produced.
Data for managing the number of industries of a single industry type.
uint32_t probability
Relative probability of building this industry.
uint16_t target_count
Desired number of industries of this type.
uint8_t min_number
Smallest number of industries that should exist (either 0 or 1).
void Reset()
Reset the entry.
bool GetIndustryTypeData(IndustryType it)
Set the probability and min_number fields for the industry type it for a running game.
uint16_t wait_count
Number of turns to wait before trying to build again.
uint16_t max_wait
Starting number of turns to wait (copied to wait_count).
std::array< ProducedHistory, 25 > history
History of cargo produced and transported for this month and 24 previous months.
uint8_t rate
Production rate.
Defines the internal data of a functional industry.
static Industry * GetRandom()
Return a random valid industry.
IndustryType type
type of industry.
Owner exclusive_supplier
Which company has exclusive rights to deliver cargo (INVALID_OWNER = anyone)
TimerGameCalendar::Date construction_date
Date of the construction of the industry.
IndustryControlFlags ctlflags
flags overriding standard behaviours
bool IsCargoAccepted() const
Test if this industry accepts any cargo.
PersistentStorage * psa
Persistent storage for NewGRF industries.
uint8_t prod_level
general production level
Colours random_colour
randomized colour of the industry, for display purpose
void RecomputeProductionMultipliers()
Recompute #production_rate for current prod_level.
uint8_t construction_type
Way the industry was constructed (.
std::string cached_name
NOSAVE: Cache of the resolved name of the industry.
TimerGameEconomy::Year last_prod_year
last economy year of production
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
ProducedCargoes produced
produced cargo slots
uint16_t random
Random value used for randomisation of all kinds of things.
static void PostDestructor(size_t index)
Invalidating some stuff after removing item from the pool.
Owner founder
Founder of the industry.
uint8_t selected_layout
Which tile layout was used when creating the industry.
AcceptedCargoes accepted
accepted cargo slots
static uint16_t GetIndustryTypeCount(IndustryType type)
Get the count of industries for this type.
std::string text
General text with additional information.
static void ResetIndustryCounts()
Resets industry counts.
Owner owner
owner of the industry. Which SHOULD always be (imho) OWNER_NONE
static void IncIndustryTypeCount(IndustryType type)
Increment the count of industries for this type.
TileArea location
Location of the industry.
Station * neutral_station
Associated neutral station.
static uint16_t counts[NUM_INDUSTRYTYPES]
Number of industries per type ingame.
StationList stations_near
NOSAVE: List of nearby stations.
bool IsCargoProduced() const
Test if this industry produces any cargo.
Owner exclusive_consumer
Which company has exclusive rights to take cargo (INVALID_OWNER = anyone)
const ProducedCargo & GetProduced(size_t slot) const
Safely get a produced cargo slot, or an empty data if the slot does not exist.
uint16_t counter
used for animation and/or production (if available cargo)
uint8_t was_cargo_delivered
flag that indicate this has been the closest industry chosen for cargo delivery by a station....
static void DecIndustryTypeCount(IndustryType type)
Decrement the count of industries for this type.
bool TileBelongsToIndustry(TileIndex tile) const
Check if a given tile belongs to this industry.
static TileIndex WrapToMap(TileIndex tile)
'Wraps' the given "tile" so it is within the map.
static uint ScaleBySize(uint n)
Scales the given value by the map size, where the given value is for a 256 by 256 map.
static uint SizeY()
Get the size of the map along the Y.
static debug_inline uint SizeX()
Get the size of the map along the X.
static uint ScaleBySize1D(uint n)
Scales the given value by the maps circumference, where the given value is for a 256 by 256 map.
static uint MaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
static debug_inline uint Size()
Get the size of the map.
static debug_inline uint MaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
Represents the covered area of e.g.
uint16_t w
The width of the area.
void Add(TileIndex to_add)
Add a single tile to a tile area; enlarge if needed.
TileIndex tile
The base tile of the area.
uint16_t h
The height of the area.
OrthogonalTileArea & Expand(int rad)
Expand a tile area by rad tiles in each direction, keeping within map bounds.
SpriteID sprite
The 'real' sprite.
PaletteID pal
The palette (use PAL_NONE) if not needed)
static size_t GetPoolSize()
Returns first unused index.
Tindex index
Index of this pool item.
static Titem * Get(size_t index)
Returns Titem with given index.
static size_t GetNumItems()
Returns number of valid items in the pool.
static bool CleaningPool()
Returns current state of pool cleaning - yes or no.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Base class for all pools.
static constexpr size_t MAX_SIZE
Make template parameter accessible from outside.
Structure to encapsulate the pseudo random number generators.
void SetSeed(uint32_t seed)
(Re)set the state of the random number generator.
uint32_t Next()
Generate the next pseudo random number.
bool ambient
Play ambient, industry and town sounds.
static Station * Get(size_t index)
Gets station with given index.
T * Next() const
Get next vehicle in the chain.
bool serve_neutral_industries
company stations can serve industries with attached neutral stations
IndustryList industries_near
Cached list of industries near the station that can accept cargo,.
Tile description for the 'land area information' tool.
StringID str
Description of the tile.
uint64_t dparam
Parameter of the str string.
const char * grf
newGRF used for the tile contents
Owner owner[4]
Name of the owner(s)
Tile information, used while rendering the tile.
int x
X position of the tile in unit coordinates.
Slope tileh
Slope of the tile.
TileIndex tile
Tile index.
int y
Y position of the tile in unit coordinates.
Set of callback functions for performing tile operations of a given tile type.
uint32_t population
Current population of people.
TileIndex xy
town center tile
TownCache cache
Container for all cacheable data.
debug_inline bool IsFrontEngine() const
Check if the vehicle is a front engine.
CargoID cargo_type
type of cargo this vehicle is carrying
IterateWrapper Orders() const
Returns an iterable ensemble of orders of a vehicle.
Owner owner
Which company owns the vehicle?
void DeleteSubsidyWith(SourceType type, SourceID index)
Delete the subsidies associated with a given cargo source type and id.
Functions related to subsidies.
bool IsTileFlat(TileIndex tile, int *h)
Check if a given tile is flat.
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
int GetTileMaxPixelZ(TileIndex tile)
Get top height of the tile.
static debug_inline TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
uint8_t GetAnimationFrame(Tile t)
Get the current animation frame.
bool IsValidTile(Tile tile)
Checks if a tile is valid.
TropicZone GetTropicZone(Tile tile)
Get the tropic zone.
void SetAnimationFrame(Tile t, uint8_t frame)
Set a new animation frame.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Slope GetTileSlope(TileIndex tile)
Return the slope of a given tile inside the map.
static debug_inline uint TileHeight(Tile tile)
Returns the height of a tile.
@ TROPICZONE_RAINFOREST
Rainforest tile.
@ TROPICZONE_DESERT
Tile is desert.
static const uint TILE_SIZE
Tile size in world coordinates.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
@ MP_TREES
Tile got trees.
@ MP_STATION
A tile of a station.
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
@ MP_HOUSE
A house by a town.
@ MP_INDUSTRY
Part of an industry.
@ MP_VOID
Invisible tiles at the SW and SE border.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Definition of Interval and OneShot timers.
Definition of the game-calendar-timer.
Definition of the game-economy-timer.
Definition of the tick-based game-timer.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
@ TO_INDUSTRIES
industries
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...
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...
TransportType
Available types of transport.
Map accessors for tree tiles.
TreeGrowthStage GetTreeGrowth(Tile t)
Returns the tree growth stage.
TreeGround GetTreeGround(Tile t)
Returns the groundtype for tree tiles.
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
Functions related to vehicles.
@ VEH_ROAD
Road vehicle type.
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ VEH_SHIP
Ship vehicle type.
@ VEH_TRAIN
Train vehicle type.
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.
void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool transparent, const SubSprite *sub, bool scale, bool relative)
Add a child sprite to a parent sprite.
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.
Functions related to (drawing on) viewports.
Functions related to water (management)
void TileLoop_Water(TileIndex tile)
Let a water tile floods its diagonal adjoining tiles called from tunnelbridge_cmd,...
bool IsTileOnWater(Tile t)
Tests if the tile was built on water.
WaterClass
classes of water (for WATER_TILE_CLEAR water tile type).
@ WATER_CLASS_INVALID
Used for industry tiles on land (also for oilrig if newgrf says so).
bool HasTileWaterClass(Tile t)
Checks whether the tile has an waterclass associated.
WaterClass GetWaterClass(Tile t)
Get the water class at a tile.
bool IsWaterTile(Tile t)
Is it a water tile with plain water?
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
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-...
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Window functions not directly related to making/drawing windows.
@ WC_INDUSTRY_DIRECTORY
Industry directory; Window numbers:
@ WC_INDUSTRY_VIEW
Industry view; Window numbers:
@ WC_BUILD_INDUSTRY
Build industry; Window numbers: