OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
10 #include "../stdafx.h"
11 #include "../void_map.h"
12 #include "../signs_base.h"
13 #include "../depot_base.h"
15 #include "../gamelog_internal.h"
16 #include "../network/network.h"
17 #include "../network/network_func.h"
18 #include "../gfxinit.h"
19 #include "../viewport_func.h"
20 #include "../viewport_kdtree.h"
21 #include "../industry.h"
22 #include "../clear_map.h"
23 #include "../vehicle_func.h"
24 #include "../string_func.h"
25 #include "../roadveh.h"
26 #include "../roadveh_cmd.h"
28 #include "../station_base.h"
29 #include "../waypoint_base.h"
30 #include "../roadstop_base.h"
31 #include "../tunnelbridge_map.h"
32 #include "../pathfinder/yapf/yapf_cache.h"
33 #include "../elrail_func.h"
34 #include "../signs_func.h"
35 #include "../aircraft.h"
36 #include "../object_map.h"
37 #include "../object_base.h"
38 #include "../tree_map.h"
39 #include "../company_func.h"
40 #include "../road_cmd.h"
41 #include "../ai/ai.hpp"
42 #include "../script/script_gui.h"
43 #include "../game/game.hpp"
45 #include "../economy_base.h"
46 #include "../animated_tile_func.h"
47 #include "../subsidy_base.h"
48 #include "../subsidy_func.h"
49 #include "../newgrf.h"
50 #include "../newgrf_station.h"
51 #include "../engine_func.h"
52 #include "../rail_gui.h"
53 #include "../core/backup_type.hpp"
54 #include "../smallmap_gui.h"
55 #include "../news_func.h"
56 #include "../order_backup.h"
58 #include "../disaster_vehicle.h"
61 #include "../timer/timer.h"
62 #include "../timer/timer_game_calendar.h"
63 #include "../timer/timer_game_economy.h"
64 #include "../timer/timer_game_tick.h"
70 #include "../safeguards.h"
89 if (include_invalid_water_class) {
106 bool has_water =
false;
107 bool has_canal =
false;
108 bool has_river =
false;
117 }
else if (!
IsLock(neighbour)) {
141 if (!has_water && !has_canal && !has_river && include_invalid_water_class) {
146 if (has_river && !has_canal) {
148 }
else if (has_canal || !has_water) {
155 static void ConvertTownOwner()
175 static void UpdateExclusiveRights()
191 static const uint8_t convert_currency[] = {
200 static void UpdateCurrencies()
208 static void UpdateVoidTiles()
216 return rt >= min ? (
RailType)(rt + 1): rt;
227 UpdateAllTextEffectVirtCoords();
228 RebuildViewportKdtree();
231 void ClearAllCachedNames()
233 ClearAllStationCachedNames();
235 ClearAllIndustryCachedNames();
254 ClearAllCachedNames();
256 ResetViewportAfterLoadGame();
274 if (i->psa !=
nullptr) {
275 i->psa->feature = GSF_INDUSTRIES;
276 i->psa->tile = i->location.tile;
280 if (s->airport.psa !=
nullptr) {
281 s->airport.psa->feature = GSF_AIRPORTS;
282 s->airport.psa->tile = s->airport.tile;
286 for (
auto &it : t->psa_list) {
292 if (rv->IsFrontEngine()) {
315 typedef void (CDECL *SignalHandlerPointer)(int);
316 static SignalHandlerPointer _prev_segfault =
nullptr;
317 static SignalHandlerPointer _prev_abort =
nullptr;
318 static SignalHandlerPointer _prev_fpe =
nullptr;
338 signal(SIGSEGV, _prev_segfault);
339 signal(SIGABRT, _prev_abort);
340 signal(SIGFPE, _prev_fpe);
367 message.reserve(1024);
368 message +=
"Loading your savegame caused OpenTTD to crash.\n";
376 "This is most likely caused by a missing NewGRF or a NewGRF that\n"
377 "has been loaded as replacement for a missing NewGRF. OpenTTD\n"
378 "cannot easily determine whether a replacement NewGRF is of a newer\n"
379 "or older version.\n"
380 "It will load a NewGRF with the same GRF ID as the missing NewGRF.\n"
381 "This means that if the author makes incompatible NewGRFs with the\n"
382 "same GRF ID, OpenTTD cannot magically do the right thing. In most\n"
383 "cases, OpenTTD will load the savegame and not crash, but this is an\n"
385 "Please load the savegame with the appropriate NewGRFs installed.\n"
386 "The missing/compatible NewGRFs are:\n";
391 fmt::format_to(std::back_inserter(message),
"NewGRF {:08X} (checksum {}) not found.\n Loaded NewGRF \"{}\" (checksum {}) with same GRF ID instead.\n",
395 fmt::format_to(std::back_inserter(message),
"NewGRF {:08X} ({}) not found; checksum {}.\n",
401 "This is probably caused by a corruption in the savegame.\n"
402 "Please file a bug report and attach this savegame.\n";
407 SignalHandlerPointer call =
nullptr;
409 case SIGSEGV: call = _prev_segfault;
break;
410 case SIGABRT: call = _prev_abort;
break;
411 case SIGFPE: call = _prev_fpe;
break;
412 default: NOT_REACHED();
414 if (call !=
nullptr) call(signum);
463 t.
m3() = (hasroad ? bits : 0);
483 int entry_x = v->
x_pos;
484 int entry_y = v->
y_pos;
491 default: NOT_REACHED();
501 if (middle_z == entry_z)
return 0;
518 if (v->IsGroundVehicle()) {
570 if (_cur_tileloop_tile == 0) _cur_tileloop_tile = 1;
578 RebuildStationKdtree();
581 RebuildViewportKdtree();
588 Debug(net, 0,
"The loading savegame was paused due to an error state");
589 Debug(net, 0,
" This savegame cannot be used for multiplayer");
612 st->train_station.w = st->train_station.h = 0;
616 if (t.m5() > 7)
continue;
621 assert(dx >= 0 && dy >= 0);
632 t.height() =
GB(t.type(), 0, 4);
633 SB(t.type(), 0, 2,
GB(t.m6(), 0, 2));
636 SB(t.type(), 2, 2,
GB(t.m6(), 6, 2));
639 SB(t.type(), 2, 2, 0);
668 if (!c->name.empty()) c->name_1 = STR_SV_UNNAMED;
670 if (!c->president_name.empty()) c->president_name_1 = SPECSTR_PRESIDENT_NAME;
676 if (!st->name.empty()) st->string_id = STR_SV_STNAME_FALLBACK;
691 if (st->airport.tile == 0) st->airport.tile =
INVALID_TILE;
692 if (st->train_station.tile == 0) st->train_station.tile =
INVALID_TILE;
825 if (st->airport.tile !=
INVALID_TILE && st->airport.type == 15) {
850 cp->front->cargo_payment = cp;
851 cp->current_station = cp->front->last_station_visited;
872 st = STATION_AIRPORT;
880 }
else if (gfx == 75) {
886 }
else if (gfx == 82) {
890 st = STATION_AIRPORT;
903 SB(t.m6(), 3, 3, st);
928 bst->
rect.BeforeAddTile(t, StationRect::ADD_FORCE);
957 case STATION_OILRIG: {
997 t.m4() |= (t.m2() << 4);
1025 c->engine_renew_list =
nullptr;
1026 c->settings.engine_renew =
false;
1027 c->settings.engine_renew_months = 6;
1028 c->settings.engine_renew_money = 100000;
1050 uint tmp =
GB(t.m4(), 0, 4);
1051 SB(t.m4(), 0, 4,
GB(t.m2(), 0, 4));
1052 SB(t.m2(), 0, 4, tmp);
1053 }
else if (
HasBit(t.m5(), 2)) {
1063 Swap(t.m3(), t.m4());
1077 SB(t.m5(), 6, 2,
GB(t.m5(), 4, 2));
1081 SB(t.m4(), 0, 4,
GB(t.m5(), 0, 4));
1082 SB(t.m4(), 4, 4, 0);
1083 SB(t.m6(), 2, 4, 0);
1086 SB(t.m4(), 5, 2,
GB(t.m5(), 2, 2));
1090 SB(t.m7(), 6, 2, 1);
1101 SB(t.m7(), 6, 2, 1);
1117 if (fix_roadtypes)
SB(t.m7(), 6, 2, (
RoadTypes)
GB(t.m7(), 5, 3));
1118 SB(t.m7(), 5, 1,
GB(t.m3(), 7, 1));
1122 SB(t.m7(), 0, 4,
GB(t.m3(), 0, 4));
1123 SB(t.m6(), 3, 3,
GB(t.m3(), 4, 3));
1124 SB(t.m3(), 0, 4,
GB(t.m4(), 4, 4));
1125 SB(t.m3(), 4, 4,
GB(t.m5(), 0, 4));
1126 SB(t.m5(), 0, 4,
GB(t.m4(), 0, 4));
1130 SB(t.m7(), 0, 5,
GB(t.m4(), 0, 5));
1131 SB(t.m6(), 3, 3,
GB(t.m3(), 4, 3));
1132 SB(t.m3(), 4, 4,
GB(t.m5(), 0, 4));
1133 SB(t.m5(), 0, 1,
GB(t.m4(), 6, 1));
1134 SB(t.m5(), 5, 1,
GB(t.m4(), 5, 1));
1150 if (fix_roadtypes)
SB(t.m7(), 6, 2, (
RoadTypes)
GB(t.m3(), 0, 3));
1152 SB(t.m3(), 4, 4, t.m1());
1159 if (fix_roadtypes)
SB(t.m7(), 6, 2, (
RoadTypes)
GB(t.m3(), 0, 3));
1162 SB(t.m7(), 0, 5, o);
1165 SB(t.m6(), 2, 4,
GB(t.m2(), 4, 4));
1166 SB(t.m7(), 5, 1,
GB(t.m4(), 7, 1));
1232 SB(t.m6(), 2, 4, 0);
1237 if (
GB(t.m5(), 3, 2) == 0) {
1254 uint north_south =
GB(t.m5(), 5, 1);
1258 t.m5() = 1 << 7 | type << 2 | dir;
1264 if (!v->IsGroundVehicle())
continue;
1271 case DIAGDIR_NE:
if ((v->x_pos & 0xF) != 0)
continue;
break;
1274 case DIAGDIR_NW:
if ((v->y_pos & 0xF) != 0)
continue;
break;
1278 v->UpdatePosition();
1293 bool has_road =
false;
1314 SB(t.m7(), 6, 2, 0);
1361 if (v->IsFrontEngine() || v->IsFreeWagon()) v->ConsistChanged(
CCF_TRACK);
1401 SB(t.m4(), 4, 4, 0);
1418 rv->vehstatus &= ~0x40;
1439 AfterLoadStations();
1476 for (j = 0; j != 50; j++) PlantRandomFarmField(i);
1507 SB(t.m5(), 3, 2,
GB(t.m3(), 6, 2));
1508 SB(t.m3(), 6, 2, 0);
1542 case GFX_POWERPLANT_SPARKS:
1543 t.m3() =
GB(t.m1(), 2, 5);
1546 case GFX_OILWELL_ANIMATED_1:
1547 case GFX_OILWELL_ANIMATED_2:
1548 case GFX_OILWELL_ANIMATED_3:
1549 t.m3() =
GB(t.m1(), 0, 2);
1552 case GFX_COAL_MINE_TOWER_ANIMATED:
1553 case GFX_COPPER_MINE_TOWER_ANIMATED:
1554 case GFX_GOLD_MINE_TOWER_ANIMATED:
1572 ClrBit(v->vehicle_flags, 2);
1589 v->cur_speed *= 128;
1591 v->acceleration = avi->acceleration;
1612 t->larger_town =
true;
1622 v->current_order.IsType(OT_LOADING)) {
1623 Station::Get(v->last_station_visited)->loading_vehicles.push_back(v);
1634 for (
auto iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); ) {
1637 iter = st->loading_vehicles.erase(iter);
1663 SB(t.m2(), 4, 4, 0);
1665 SB(t.m2(), 4, 3,
GB(t.m2(), 0, 3));
1673 if (rv->state == 250 || rv->state == 251) {
1725 for (uint j = 0; j < std::size(i->produced); j++) {
1726 i->produced[j].cargo = indsp->produced_cargo[j];
1728 for (uint j = 0; j < std::size(i->accepted); j++) {
1761 if (v->orders !=
nullptr && v->orders->GetFirstOrder() !=
nullptr && v->orders->GetFirstOrder()->IsType(OT_NOTHING)) {
1762 v->orders->FreeChain();
1763 v->orders =
nullptr;
1766 v->current_order.ConvertFromOldSavegame();
1767 if (v->type ==
VEH_ROAD && v->IsPrimaryVehicle() && v->FirstShared() == v) {
1789 if (!order->IsType(OT_GOTO_DEPOT))
continue;
1794 if (!v->current_order.IsType(OT_GOTO_DEPOT))
continue;
1795 v->current_order.SetDepotActionType((
OrderDepotActionFlags)(v->current_order.GetDepotActionType() >> 1));
1805 case STATION_OILRIG:
1809 SB(t.m3(), 0, 2, 0);
1820 SB(t.m3(), 0, 2, 0);
1889 for (RoadTramType rtt : _roadtramtypes) {
1906 v->profit_this_year <<= 8;
1907 v->profit_last_year <<= 8;
1908 v->running_ticks = 0;
1916 SB(t.m6(), 2, 6,
GB(t.m6(), 3, 5));
1917 SB(t.m3(), 5, 1, 0);
1998 if (t->First() == t) t->ReserveTrackUnderConsist();
2014 st->indtype = IT_INVALID;
2021 if (!a->IsNormalAircraft()) {
2022 a->engine_type = a->First()->engine_type;
2028 if (c->bankrupt_asked == 0xFF) c->bankrupt_asked =
MAX_UVALUE(CompanyMask);
2032 if (e->company_avail == 0xFF) e->company_avail =
MAX_UVALUE(CompanyMask);
2036 if (t->have_ratings == 0xFF) t->have_ratings =
MAX_UVALUE(CompanyMask);
2048 t.m3() =
GB(t.m5(), 0, 5);
2060 t.m3() = type ==
OBJECT_HQ ?
GB(t.m3(), 1, 1) |
GB(t.m3(), 0, 1) << 4 : 0;
2077 uint offset = t.m3();
2080 t.m3() =
GB(t.m6(), 2, 4);
2081 SB(t.m6(), 2, 4, 0);
2091 SlError(STR_ERROR_TOO_MANY_OBJECTS);
2104 Tile northern_tile = t -
TileXY(
GB(offset, 0, 4),
GB(offset, 4, 4));
2106 t.m2() = northern_tile.
m2();
2134 case 5: layout = 1;
break;
2135 case 0: layout = 2;
break;
2137 t->layout =
static_cast<TownLayout>(layout - 1);
2167 if (v->subtype == 2 && v->state != 0) {
2182 for (
Vehicle *v : st->loading_vehicles) {
2204 remove = *tile == *j;
2219 wp->train_station.tile = wp->xy;
2220 wp->train_station.w = 1;
2221 wp->train_station.h = 1;
2224 wp->train_station.w = 0;
2225 wp->train_station.h = 0;
2233 if (s->remaining < 12) {
2235 s->remaining = 12 - s->remaining;
2262 s->remaining = 24 - s->remaining;
2270 if (ss !=
nullptr && sd !=
nullptr && ss->
owner == sd->
owner &&
2275 s->awarded = ss->
owner;
2313 Debug(sl, 0,
"Removing invalid depot {} at {}, {}", d->index,
TileX(d->xy),
TileY(d->xy));
2318 tile.
m2() = d->index;
2327 if (t->force_proceed !=
TFP_NONE) {
2346 uint density =
GB(t.m2(), 6, 2);
2347 uint ground =
GB(t.m2(), 4, 2);
2348 t.m2() = ground << 6 | density << 4;
2356 a->turn_counter = a->current_order.IsType(OT_LOADING) ? 0 : a->load_unload_ticks;
2360 t->wait_counter = t->current_order.IsType(OT_LOADING) ? 0 : t->load_unload_ticks;
2366 struct AirportTileConversion {
2370 static const AirportTileConversion atcs[] = {
2385 for (
const auto &atc : atcs) {
2386 if (old_gfx < atc.old_start) {
2390 if (old_gfx < atc.old_start + atc.num_frames) {
2395 offset += atc.num_frames - 1;
2404 st->airport.w = st->airport.GetSpec()->size_x;
2405 st->airport.h = st->airport.GetSpec()->size_y;
2435 if (!v->IsNormalAircraft())
continue;
2437 if (st ==
nullptr && v->state !=
FLYING) {
2456 uint per_proc = t.m7();
2457 t.m7() =
GB(t.m6(), 2, 6) | (
GB(t.m3(), 5, 1) << 6);
2458 SB(t.m3(), 5, 1, 0);
2459 SB(t.m6(), 2, 6, std::min(per_proc, 63U));
2486 o->colour = (owner ==
OWNER_NONE) ?
static_cast<Colours
>(
GB(Random(), 0, 4)) :
Company::Get(owner)->livery->colour1;
2503 if (!wp->name.empty()) wp->town_cn = UINT16_MAX;
2520 if (!v->IsGroundVehicle())
continue;
2530 if (
GetSlopePixelZ(v->x_pos, v->y_pos,
true) != v->z_pos)
continue;
2565 default: NOT_REACHED();
2573 default: NOT_REACHED();
2583 bool loading = rv->current_order.IsType(OT_LOADING) || rv->current_order.IsType(OT_LEAVESTATION);
2588 SB(rv->state,
RVS_ENTERED_STOP, 1, loading || rv->frame > RVC_DRIVE_THROUGH_STOP_FRAME);
2596 if (!
HasBit(t->flags, 5))
continue;
2620 if (v->IsGroundVehicle() &&
TileVirtXY(v->x_pos, v->y_pos) == v->tile) {
2713 if (!v->IsPrimaryVehicle())
continue;
2716 if (v->cur_implicit_order_index >= v->GetNumOrders()) v->cur_implicit_order_index = 0;
2718 v->cur_real_order_index = v->cur_implicit_order_index;
2719 v->UpdateRealOrderIndex();
2750 assert(ind->psa !=
nullptr);
2753 bool is_empty =
true;
2754 for (uint i = 0; i <
sizeof(ind->psa->storage); i++) {
2755 if (ind->psa->GetValue(i) != 0) {
2762 ind->psa->grfid = _industry_mngr.
GetGRFID(ind->type);
2773 assert(st->airport.psa !=
nullptr);
2776 bool is_empty =
true;
2777 for (uint i = 0; i <
sizeof(st->airport.psa->storage); i++) {
2778 if (st->airport.psa->GetValue(i) != 0) {
2785 st->airport.psa->grfid = _airport_mngr.
GetGRFID(st->airport.type);
2787 delete st->airport.psa;
2788 st->airport.psa =
nullptr;
2805 uint fence =
GB(t.m4(), 5, 3);
2809 fence =
GB(t.m4(), 2, 3);
2813 SB(t.m4(), 2, 3, 0);
2814 SB(t.m4(), 5, 3, 0);
2839 _saved_scrollpos_zoom =
static_cast<ZoomLevel>(_saved_scrollpos_zoom + ZOOM_BASE_SHIFT);
2840 _saved_scrollpos_x *= ZOOM_BASE;
2841 _saved_scrollpos_y *= ZOOM_BASE;
2871 c->months_of_bankruptcy = 3 * c->months_of_bankruptcy;
2888 v->acceleration = avi->acceleration;
2903 extern uint8_t _old_units;
2939 std::vector<uint> skip_frames;
2941 if (!v->IsFrontEngine())
continue;
2942 skip_frames.clear();
2944 uint prev_tile_skip = 0;
2947 if (u->tile != prev_tile) {
2948 prev_tile_skip = cur_skip;
2949 prev_tile = u->tile;
2951 cur_skip = prev_tile_skip;
2954 uint &this_skip = skip_frames.emplace_back(prev_tile_skip);
2960 if (u->frame <= (roadside ? 9 : 5)) this_skip = cur_skip;
2965 if (u->frame <= (roadside ? 5 : 9)) this_skip = cur_skip;
2970 if (u->frame <= (roadside ? 4 : 2)) this_skip = cur_skip;
2977 while (cur_skip > skip_frames[0]) {
2980 for (uint sf : skip_frames) {
2981 if (sf >= cur_skip) IndividualRoadVehicleController(u, prev);
2993 order->SetTravelTimetabled(order->GetTravelTime() > 0);
2994 order->SetWaitTimetabled(order->GetWaitTime() > 0);
2997 orderlist->RecalculateTimetableDuration();
3008 #ifndef DEBUG_DUMP_COMMANDS
3023 t->growth_rate = TownTicksToGameTicks(t->growth_rate & ~0x8000);
3035 for (
auto &a : i->accepted) {
3037 a.last_accepted = i->GetAccepted(0).last_accepted;
3039 a.last_accepted = 0;
3052 int x = s->x_pos & 0xF;
3053 int y = s->y_pos & 0xF;
3054 if (x == 8 && y == 8)
continue;
3059 switch (shipdiagdir) {
3060 default: NOT_REACHED();
3070 if ((shipdiagdir == slopediagdir) == second_half) {
3094 st->industry->neutral_station = st;
3127 if (st->ship_station.tile !=
INVALID_TILE) UpdateStationDockingTiles(st);
3151 uint16_t wagon_removal = 0;
3153 if (c->settings.renew_keep_length)
SetBit(wagon_removal, c->index);
3156 if (g->flags != 0) {
3168 v->last_loading_tick = std::max(
TimerGameTick::counter,
static_cast<uint64_t
>(v->current_order_time)) - v->current_order_time;
3181 if (rv->IsArticulatedPart())
continue;
3184 if (rv->cur_speed > 0)
continue;
3196 if (closestDepot.found &&
DistanceManhattan(rv->tile, closestDepot.location) < 512u) {
3199 u->tile = closestDepot.location;
3208 u->UpdatePosition();
3210 RoadVehLeaveDepot(rv,
false);
3218 SB(t.m2(), 0, 4, 0);
3254 v->date_of_last_service_newgrf = v->date_of_last_service.base();
3261 if (s->acceleration == 0) s->acceleration = ShipVehInfo(s->engine_type)->
acceleration;
3267 c->max_loan = COMPANY_MAX_LOAN_DEFAULT;
3272 ScriptObject::InitializeRandomizers();
3290 g->number = c->freegroups.
UseID(g->index);
3292 c->freegroups.
UseID(g->number);
3296 AfterLoadLabelMaps();
3349 AfterLoadStations();
void LoadStringWidthTable(bool monospace)
Initialize _stringwidth_table cache.
Buses, trucks and trams belong to this class.
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
debug_inline bool IsFrontEngine() const
Check if the vehicle is a front engine.
@ MP_HOUSE
A house by a town.
bool IsTileFlat(TileIndex tile, int *h)
Check if a given tile is flat.
uint8_t misc_flags
Miscellaneous flags.
void BuildOwnerLegend()
Completes the array for the owned property legend.
@ DIAGDIR_NE
Northeast, upper right on your monitor.
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-...
Direction ReverseDir(Direction d)
Return the reverse of a direction.
bool AfterLoadGame()
Perform a (large) amount of savegame conversion magic in order to load older savegames and to fill th...
uint32_t GetGRFID(uint16_t entity_id) const
Gives the GRFID of the file the entity belongs to.
uint8_t road_side
the side of the road vehicles drive on
void AircraftNextAirportPos_and_Order(Aircraft *v)
set the right pos when heading to other airports after takeoff
bool IsClearGround(Tile t, ClearGround ct)
Set the type of clear tile.
@ OUFB_UNLOAD
Force unloading all cargo onto the platform, possibly not getting paid.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
@ SIG_SEMAPHORE
Old-fashioned semaphore signal.
void SetSaveLoadError(StringID str)
Set the error message from outside of the actual loading/saving of the game (AfterLoadGame and friend...
debug_inline uint8_t & m5()
General purpose.
@ FT_SCENARIO
old or new scenario
bool IsType(OrderType type) const
Check whether this order is of the given type.
static Titem * Get(size_t index)
Returns Titem with given index.
void SettingsDisableElrail(int32_t new_value)
_settings_game.disable_elrail callback
static TickCounter counter
Monotonic counter, in ticks, since start of game.
void SetRoadTypes(Tile t, RoadType road_rt, RoadType tram_rt)
Set the present road types of a tile.
StationSettings station
settings related to station management
static const uint MIN_SNOWLINE_HEIGHT
Minimum snowline height.
uint8_t larger_towns
the number of cities to build. These start off larger and grow twice as fast
void SetRailStationTileFlags(TileIndex tile, const StationSpec *statspec)
Set rail station tile flags for the given tile.
@ SLV_GROUP_REPLACE_WAGON_REMOVAL
291 PR#7441 Per-group wagon removal flag.
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
@ FACIL_TRAIN
Station with train station.
debug_inline uint8_t & m3()
General purpose.
static constexpr TimerGame< struct Calendar >::Date DAYS_TILL_ORIGINAL_BASE_YEAR
The date of the first day of the original base year.
static const CargoID CARGO_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-renew).
RoadBits
Enumeration for the road parts on a tile.
static void CDECL HandleSavegameLoadCrash(int signum)
Signal handler used to give a user a more useful report for crashes during the savegame loading proce...
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
uint8_t GetLockPart(Tile t)
Get the part of a lock.
@ SLV_GROUP_NUMBERS
336 PR#12297 Add per-company group numbers.
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track)
Use this function to notify YAPF that track layout (or signal configuration) has change.
@ ROADTYPE_ROAD
Basic road type.
const TileTypeProcs *const _tile_type_procs[16]
Tile callback functions for each type of tile.
@ GLC_COMPATIBLE
Compatible (eg. the same ID, but different checksum) GRF found in at least one case.
bool IsTunnelTile(Tile t)
Is this a tunnel (entrance)?
TownLayout town_layout
select town layout,
constexpr void Swap(T &a, T &b)
Type safe swap operation.
bool forbid_90_deg
forbid trains to make 90 deg turns
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
@ TRACK_BIT_X
X-axis track.
TreeGround GetTreeGround(Tile t)
Returns the groundtype for tree tiles.
@ ROAD_Y
Full road along the y-axis (north-west + south-east)
static void InitializeWindowsAndCaches()
Initialization of the windows and several kinds of caches.
uint8_t max_train_length
maximum length for trains
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
static DateFract date_fract
Fractional part of the day.
@ SLV_11
11.0 2033 11.1 2041
@ ROAD_TILE_CROSSING
Level crossing.
WaterClass GetWaterClass(Tile t)
Get the water class at a tile.
Class to backup a specific variable and restore it later.
void AfterLoadRoadStops()
(Re)building of road stop caches after loading a savegame.
@ FACIL_DOCK
Station with a dock.
@ RAILTYPE_RAIL
Standard non-electric rails.
static debug_inline uint MaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
@ PM_PAUSED_ERROR
A game paused because a (critical) error.
@ SIGTYPE_COMBO
presignal inter-block
@ RAILTYPE_ELECTRIC
Electric rails.
T * Next() const
Get next vehicle in the chain.
@ OUFB_TRANSFER
Transfer all cargo onto the platform.
Town * town
The town this station is associated with.
@ WC_COMPANY_COLOUR
Company colour selection; Window numbers:
Gamelog _gamelog
Gamelog instance.
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
Slope GetTileSlope(TileIndex tile)
Return the slope of a given tile inside the map.
static void FixOwnerOfRailTrack(Tile t)
Tries to change owner of this rail tile to a valid owner.
static debug_inline bool IsPlainRail(Tile t)
Returns whether this is plain rails, with or without signals.
@ INVALID_COMPANY
An invalid company.
@ INVALID_OWNER
An invalid owner.
uint8_t snow_line_height
the configured snow line height (deduced from "snow_coverage")
uint64_t inflation_payment
Cumulated inflation of cargo payment since game start; 16 bit fractional part.
uint16_t tree_frame_burst
how many trees may, over a short period, be planted?
uint8_t units_velocity_nautical
unit system for velocity of ships and aircraft
bool _network_server
network-server is active
TileArea location
Location of the object.
void SetTunnelBridgeReservation(Tile t, bool b)
Set the reservation state of the rail tunnel/bridge.
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.
@ SIG_ELECTRIC
Light signal.
Owner
Enum for all companies/owners.
RailType
Enumeration for all possible railtypes.
VehicleDefaultSettings _old_vds
Used for loading default vehicles settings from old savegames.
Tindex index
Index of this pool item.
@ RVSB_IN_ROAD_STOP
The vehicle is in a road stop.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
@ VEH_TRAIN
Train vehicle type.
DistributionType distribution_mail
distribution type for mail
TileIndex TileAddXY(TileIndex tile, int x, int y)
Adds a given offset to a tile.
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
IndustryGfx GetIndustryGfx(Tile t)
Get the industry graphics ID for the given industry tile.
@ SLV_ECONOMY_DATE
326 PR#10700 Split calendar and economy timers and dates.
DifficultySettings difficulty
settings related to the difficulty
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
uint8_t plane_crashes
number of plane crashes, 0 = none, 1 = reduced, 2 = normal
bool IsOilRig(Tile t)
Is tile t part of an oilrig?
@ SLV_198
198 PR#6763 Switch town growth rate and counter to actual game ticks
@ SLV_184
184 25508 Unit localisation split
Representation of a waypoint.
uint TileHash(uint x, uint y)
Calculate a hash value from a tile position.
@ SLV_ROAD_TYPES
214 PR#6811 NewGRF road types.
static const ObjectType OBJECT_STATUE
Statue in towns.
@ VF_LOADING_FINISHED
Vehicle has finished loading.
TimekeepingUnits timekeeping_units
time units to use for the game economy, either calendar or wallclock
@ VEH_ROAD
Road vehicle type.
static const uint TILE_SIZE
Tile size in world coordinates.
DiagDirection
Enumeration for diagonal directions.
@ GCS_NOT_FOUND
GRF file was not found in the local cache.
Wrapper class to abstract away the way the tiles are stored.
void UpdateOldAircraft()
need to be called to load aircraft from old version
bool IsLevelCrossingTile(Tile t)
Return whether a tile is a level crossing tile.
void ClearBridgeMiddle(Tile t)
Removes bridges from the given, that is bridges along the X and Y axis.
bool HasTownOwnedRoad(Tile t)
Checks if given tile has town owned road.
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
static DateFract date_fract
Fractional part of the day.
static Station * Get(size_t index)
Gets station with given index.
bool IsLevelCrossing(Tile t)
Return whether a tile is a level crossing.
ClientSettings _settings_client
The current settings for this game.
Specification of a cargo type.
@ MP_INDUSTRY
Part of an industry.
@ SLV_192
192 26700 FS#6066 Fix saving of order backups
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
void Add(TileIndex to_add)
Add a single tile to a tile area; enlarge if needed.
uint8_t wait_for_pbs_path
how long to wait for a path reservation.
Direction AxisToDirection(Axis a)
Converts an Axis to a Direction.
uint8_t number_towns
the amount of towns
RoadType roadtype
NOSAVE: Roadtype of this vehicle.
uint8_t status
Status of this cargo, see GoodsEntryStatus.
@ SLV_SERVE_NEUTRAL_INDUSTRIES
210 PR#7234 Company stations can serve industries with attached neutral stations.
std::vector< TileIndex > _animated_tiles
The table/list with animated tiles.
uint16_t max_tunnel_length
maximum length of tunnels
Defines the internal data of a functional industry.
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
@ SLV_LAST_LOADING_TICK
301 PR#9693 Store tick of last loading for vehicles.
Owner owner
Which company owns the vehicle?
static void SetSignalHandlers()
Replaces signal handlers of SIGSEGV and SIGABRT and stores pointers to original handlers in memory.
void StartupEngines()
Start/initialise all our engines.
uint16_t max_bridge_length
maximum length of bridges
static constexpr TimerGame< struct Calendar >::Year DEF_END_YEAR
The default scoring end year.
@ INVALID_DIR
Flag for an invalid direction.
int GetSlopePixelZ(int x, int y, bool ground_vehicle)
Return world Z coordinate of a given point of a tile.
uint8_t landscape
the landscape we're currently in
Owner owner
The owner of this station.
@ AIR_AIRCRAFT
an airplane
@ MP_ROAD
A tile with road (or tram tracks)
static const uint16_t TOWN_GROWTH_RATE_NONE
Special value for Town::growth_rate to disable town growth.
@ TCGM_ORIGINAL
Original algorithm (quadratic cargo by population)
debug_inline uint8_t & m7()
Primarily used for newgrf support.
static bool _saveload_crash_with_missing_newgrfs
Was the saveload crash because of missing NewGRFs?
Station * GetTargetAirportIfValid(const Aircraft *v)
Returns aircraft's target station if v->target_airport is a valid station with airport.
void SetSignalStates(Tile tile, uint state)
Set the states of the signals (Along/AgainstTrackDir)
uint16_t h
The height of the area.
bool IsLock(Tile t)
Is there a lock on a given water tile?
static void IncTypeCount(ObjectType type)
Increment the count of objects for this type.
@ TAE_MAIL
Cargo behaves mail-like.
void ShowNewGRFError()
Show the first NewGRF error we can find.
RoadBits GetCrossingRoadBits(Tile tile)
Get the road bits of a level crossing.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
StationType
Station types.
@ GCF_COMPATIBLE
GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches)
uint8_t units_velocity
unit system for velocity of trains and road vehicles
void MakeSea(Tile t)
Make a sea tile.
@ SLV_16
16.0 2817 16.1 3155
int32_t x_pos
x coordinate.
@ SLV_SHIPS_STOP_IN_LOCKS
206 PR#7150 Ship/lock movement changes.
GameCreationSettings game_creation
settings used during the creation of a game (map)
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
static void StartNew(CompanyID company)
Start a new AI company.
@ TRANSPORT_ROAD
Transport by road vehicle.
uint16_t recalc_interval
time (in days) between subsequent checks for link graphs to be calculated.
CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32_t face)
Converts an old company manager's face format to the new company manager's face format.
bool IsCoast(Tile t)
Is it a coast tile?
void SetCrossingReservation(Tile t, bool b)
Set the reservation state of the rail crossing.
TileIndex GetOtherShipDepotTile(Tile t)
Get the other tile of the ship depot.
TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir.
@ RATING_INITIAL
initial rating
Aircraft, helicopters, rotors and their shadows belong to this class.
@ GVF_GOINGDOWN_BIT
Vehicle is currently going downhill. (Cached track information for acceleration)
static debug_inline TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
void MakeClear(Tile t, ClearGround g, uint density)
Make a clear tile.
@ TRACK_BIT_NONE
No track.
@ INDUSTRYBEH_PLANT_ON_BUILT
Fields are planted around when built (all farms)
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner)
Change the owner of a tile.
@ RVS_DRIVE_SIDE
Only used when retrieving move data.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
static constexpr size_t MAX_SIZE
Make template parameter accessible from outside.
UnitID UseID(UnitID index)
Use a unit number.
bool IsDock(Tile t)
Is tile t a dock tile?
uint8_t train_acceleration_model
realistic acceleration for trains
bool IsTruckStop(Tile t)
Is the station at t a truck stop?
void SetBridgeMiddle(Tile t, Axis a)
Set that there is a bridge over the given axis.
@ ROAD_TILE_NORMAL
Normal road.
@ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
The vehicle will not stop at any stations it passes except the destination.
TransportType
Available types of transport.
Basic data to distinguish a GRF.
AbstractFileType abstract_ftype
Abstract type of file (scenario, heightmap, etc).
PathfinderSettings pf
settings for all pathfinders
@ SLV_VELOCITY_NAUTICAL
305 PR#10594 Separation of land and nautical velocity (knots!)
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
void UpdateAllTownVirtCoords()
Update the virtual coords needed to draw the town sign for all towns.
@ VS_HIDDEN
Vehicle is not visible.
@ COMPANY_FIRST
First company, same as owner.
static debug_inline bool IsRailDepot(Tile t)
Is this rail tile a rail depot?
@ SLV_188
188 26169 v1.4 FS#5831 Unify RV travel time
bool station_noise_level
build new airports when the town noise level is still within accepted limits
@ SLV_REPAIR_OBJECT_DOCKING_TILES
299 PR#9594 v12.0 Fixing issue with docking tiles overlapping objects.
static const uint TILE_UNIT_MASK
For masking in/out the inner-tile world coordinate units.
@ VEH_INVALID
Non-existing type of vehicle.
bool serve_neutral_industries
company stations can serve industries with attached neutral stations
Struct about subsidies, offered and awarded.
StationGfx GetStationGfx(Tile t)
Get the station graphics of this tile.
bool IsBayRoadStopTile(Tile t)
Is tile t a bay (non-drive through) road stop station?
GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig)
Check if all GRFs in the GRF config from a savegame can be loaded.
debug_inline uint16_t & m2()
Primarily used for indices to towns, industries and stations.
bool IsBridge(Tile t)
Checks if this is a bridge, instead of a tunnel.
static uint32_t BSWAP32(uint32_t x)
Perform a 32 bits endianness bitswap on x.
bool IsWater(Tile t)
Is it a plain water tile?
TimeoutTimer< TimerGameTick > _new_competitor_timeout({ TimerGameTick::Priority::COMPETITOR_TIMEOUT, 0 }, []() { if(_game_mode==GM_MENU||!AI::CanStartNew()) return;if(_networking &&Company::GetNumItems() >=_settings_client.network.max_companies) return;uint8_t n=0;for(const Company *c :Company::Iterate()) { if(c->is_ai) n++;} if(n >=_settings_game.difficulty.max_no_competitors) return;Command< CMD_COMPANY_CTRL >::Post(CCA_NEW_AI, INVALID_COMPANY, CRR_NONE, INVALID_CLIENT_ID);})
Start a new competitor company if possible.
Information about GRF, used in the game and (part of it) in savegames.
void SetStationGfx(Tile t, StationGfx gfx)
Set the station graphics of this tile.
uint8_t StationGfx
Copy from station_map.h.
TileArea train_station
Tile area the train 'station' part covers.
@ OWNER_NONE
The tile has no ownership.
uint16_t ObjectType
Types of objects.
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
@ WATER_TILE_CLEAR
Plain water.
std::string FormatArrayAsHex(std::span< const uint8_t > data)
Format a byte array into a continuous hex string.
@ GSF_FAKE_TOWNS
Fake town GrfSpecFeature for NewGRF debugging (parent scope)
TrackBits
Allow incrementing of Track variables.
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
@ SLV_CONSISTENT_PARTIAL_Z
306 PR#10570 Conversion from an inconsistent partial Z calculation for slopes, to one that is (more) ...
static void RecomputeCatchmentForAll()
Recomputes catchment of all stations.
uint16_t competitors_interval
the interval (in minutes) between adding competitors
@ GVF_GOINGUP_BIT
Vehicle is currently going uphill. (Cached track information for acceleration)
RoadTypes
The different roadtypes we support, but then a bitmask of them.
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
static const HouseID NEW_HOUSE_OFFSET
Offset for new houses.
@ SLV_EXTEND_INDUSTRY_CARGO_SLOTS
202 PR#6867 Increase industry cargo slots to 16 in, 16 out
TileIndex tile
Current tile index.
static const uint TOWN_GROWTH_DESERT
The town needs the cargo for growth when on desert (any amount)
@ DIAGDIR_BEGIN
Used for iterations.
@ MP_OBJECT
Contains objects such as transmitters and owned land.
uint8_t map_height_limit
the maximum allowed heightlevel
@ VS_CRASHED
Vehicle is crashed.
uint16_t clear_frame_burst
how many tiles may, over a short period, be cleared?
MD5Hash md5sum
MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF)
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
@ WATER_CLASS_INVALID
Used for industry tiles on land (also for oilrig if newgrf says so).
void UpdateAirportsNoise()
Recalculate the noise generated by the airports of each town.
Helper class to perform the cargo payment.
DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
void SetFence(Tile t, DiagDirection side, uint h)
Sets the type of fence (and whether there is one) for the given border.
void MakeVoid(Tile t)
Make a nice void tile ;)
ClearGround GetRawClearGround(Tile t)
Get the type of clear tile but never return CLEAR_SNOW.
void AfterLoadStoryBook()
Called after load to trash broken pages.
Order current_order
The current order (+ status, like: loading)
std::string CopyFromOldName(StringID id)
Copy and convert old custom names to UTF-8.
@ INDUSTRYBEH_BUILT_ONWATER
is built on water (oil rig)
@ VEH_SHIP
Ship vehicle type.
const uint8_t _tunnel_visibility_frame[DIAGDIR_END]
Frame when a vehicle should be hidden in a tunnel with a certain direction.
bool IsShipDepotTile(Tile t)
Is it a ship depot tile?
Direction DiagDirToDir(DiagDirection dir)
Convert a DiagDirection to a Direction.
TileIndex GetNorthernBridgeEnd(TileIndex t)
Finds the northern end of a bridge starting at a middle tile.
An object, such as transmitter, on the map.
Airport airport
Tile area the airport covers.
@ TL_RANDOM
Random town layout.
PauseMode _pause_mode
The current pause mode.
bool HasStationTileRail(Tile t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
void TrimIndustryAcceptedProduced(Industry *ind)
Remove unused industry accepted/produced slots – entries after the last slot with valid cargo.
@ SLV_GS_INDUSTRY_CONTROL
287 PR#7912 and PR#8115 GS industry control.
@ LOCK_PART_MIDDLE
Middle part of a lock.
bool SaveloadCrashWithMissingNewGRFs()
Did loading the savegame cause a crash? If so, were NewGRFs missing?
TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ RVS_ENTERED_STOP
Only set when a vehicle has entered the stop.
@ SLV_MULTITILE_DOCKS
216 PR#7380 Multiple docks per station.
void GetAircraftFlightLevelBounds(const Vehicle *v, int *min, int *max)
Get the 'flight level' bounds, in pixels from 'z_pos' 0 for a particular vehicle for normal flight si...
CompanySettings settings
settings specific for each company
bool IsBuoyTile(Tile t)
Is tile t a buoy tile?
bool IsBridgeTile(Tile t)
checks if there is a bridge on this tile
RoadType
The different roadtypes we support.
void SetAircraftPosition(Aircraft *v, int x, int y, int z)
Set aircraft position.
EconomySettings economy
settings to change the economy
@ VS_STOPPED
Vehicle is stopped by the player.
ObjectType type
Type of the object.
@ SLV_VEHICLE_ECONOMY_AGE
334 PR#12141 v14.0 Add vehicle age in economy year, for profit stats minimum age
@ SLV_182
182 25115 FS#5492, r25259, r25296 Goal status
@ SLV_EXTEND_RAILTYPES
200 PR#6805 Extend railtypes to 64, adding uint16_t to map array.
void ClearAllTownCachedNames()
Clear the cached_name of all towns.
bool IsSavegameVersionBeforeOrAt(SaveLoadVersion major)
Checks whether the savegame is below or at major.
TimerGameCalendar::Year starting_year
starting date
static bool IsValidAiID(size_t index)
Is this company a valid company, controlled by the computer (a NoAI program)?
'Train' is either a loco or a wagon.
bool freeform_edges
allow terraforming the tiles at the map edges
uint8_t wait_oneway_signal
waitingtime in days before a oneway signal
void MoveWaypointsToBaseStations()
Perform all steps to upgrade from the old waypoints to the new version that uses station.
DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
void CopyTempEngineData()
Copy data from temporary engine array into the real engine pool.
void SetWaterClass(Tile t, WaterClass wc)
Set the water class at a tile.
TimerGameCalendar::Year ending_year
scoring end date
void GRFRemove(uint32_t grfid)
Logs removal of a GRF.
static debug_inline RoadTileType GetRoadTileType(Tile t)
Get the type of the road tile.
void SetTrackReservation(Tile t, TrackBits b)
Sets the reserved track bits of the tile.
bool _networking
are we in networking mode?
uint8_t units_volume
unit system for volume
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
@ RVS_IN_ROAD_STOP
The vehicle is in a road stop.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
void UpdateAllSignVirtCoords()
Update the coordinates of all signs.
void MakeCanal(Tile t, Owner o, uint8_t random_bits)
Make a canal tile.
@ INVALID_ROADTYPE
flag for invalid roadtype
static void SetDate(Date date, DateFract fract)
Set the date.
debug_inline uint8_t & m6()
General purpose.
Default settings for vehicles.
HouseID GetHouseType(Tile t)
Get the type of this house, which is an index into the house spec array.
bool IsDepotTile(Tile tile)
Is the given tile a tile with a depot on it?
LinkGraphSettings linkgraph
settings for link graph calculations
uint AvailableCount() const
Returns sum of cargo still available for loading at the sation.
@ SLV_ECONOMY_MODE_TIMEKEEPING_UNITS
327 PR#11341 Mode to display economy measurements in wallclock units.
@ TAE_PASSENGERS
Cargo behaves passenger-like.
@ SLV_4
4.0 1 4.1 122 0.3.3, 0.3.4 4.2 1222 0.3.5 4.3 1417 4.4 1426
void MoveBuoysToWaypoints()
Perform all steps to upgrade from the old station buoys to the new version that uses waypoints.
static Station * From(BaseStation *st)
Converts a BaseStation to SpecializedStation with type checking.
void SetRailStationReservation(Tile t, bool b)
Set the reservation state of the rail station.
bool _network_dedicated
are we a dedicated server?
TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
void PrintDebug(int level)
Prints gamelog to debug output.
void FixupTrainLengths()
Fixup old train spacing.
void SetTileOwner(Tile tile, Owner owner)
Sets the owner of a tile.
RoadStop * truck_stops
All the truck stops.
Defines the data structure for constructing industry.
static void StartScripts()
Start the scripts.
static void AfterLoad()
Savegame conversion for cargopackets.
void UpdateNearestTownForRoadTiles(bool invalidate)
Updates cached nearest town for all road tiles.
uint8_t units_power
unit system for power
static const int GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET
The offset for the drive through parts.
static const uint8_t TOWN_HOUSE_COMPLETED
Simple value that indicates the house has reached the final stage of construction.
const CargoSpec * FindFirstCargoWithTownAcceptanceEffect(TownAcceptanceEffect effect)
Determines the first cargo with a certain town effect.
StationType GetStationType(Tile t)
Get the station type of this tile.
uint8_t units_weight
unit system for weight
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
@ Town
Source/destination is a town.
uint8_t plane_speed
divisor for speed of aircraft
Disasters, like submarines, skyrangers and their shadows, belong to this class.
TownCargoGenMode town_cargogen_mode
algorithm for generating cargo from houses,
static debug_inline bool IsPlainRailTile(Tile t)
Checks whether the tile is a rail tile or rail tile with signals.
static bool MayHaveBridgeAbove(Tile t)
Checks for the possibility that a bridge may be on this tile These are in fact all the tile types on ...
@ RAIL_GROUND_WATER
Grass with a fence and shore or water on the free halftile.
@ TRACK_BIT_WORMHOLE
Bitflag for a wormhole (used for tunnels)
Direction direction
facing
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
@ SLV_INCREASE_STATION_TYPE_FIELD_SIZE
337 PR#12572 Increase size of StationType field in map array
uint8_t industry_density
The industry density.
@ MP_TREES
Tile got trees.
static constexpr TimerGameTick::Ticks TOWN_GROWTH_TICKS
Cycle duration for towns trying to grow (this originates from the size of the town array in TTD).
void UpdateAircraftCache(Aircraft *v, bool update_range=false)
Update cached values of an aircraft.
uint8_t roadveh_acceleration_model
realistic acceleration for road vehicles
static debug_inline uint SizeX()
Get the size of the map along the X.
constexpr T AssignBit(T &x, const uint8_t y, bool value)
Assigns a bit in a variable.
static const uint TOWN_GROWTH_WINTER
The town only needs this cargo in the winter (any amount)
@ DT_MANUAL
Manual distribution. No link graph calculations are run.
bool infrastructure_maintenance
enable monthly maintenance fee for owner infrastructure
void Reset()
Completely reset the industry build data.
bool allow_town_level_crossings
towns are allowed to build level crossings
void MakeDefaultName(T *obj)
Set the default name for a depot/waypoint.
All ships have this type.
void AfterLoadVehicles(bool part_of_load)
Called after load to update coordinates.
Stores station stats for a single cargo.
CompanyID _current_company
Company currently doing an action.
void TestMode()
Finds last stored game mode or landscape.
TreeGround
Enumeration for ground types of tiles with trees.
bool dynamic_engines
enable dynamic allocation of engine data
void ShowScriptDebugWindowIfScriptError()
Open the AI debug window if one of the AI scripts has crashed.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
A timeout timer will fire once after the interval.
static uint MaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
bool IsBuoy(Tile t)
Is tile t a buoy tile?
static Year year
Current year, starting at 0.
void ConnectMultiheadedTrains()
Link front and rear multiheaded engines to each other This is done when loading a savegame.
@ OSL_PLATFORM_FAR_END
Stop at the far end of the platform.
@ WATER_CLASS_CANAL
Canal.
void SetHouseCompleted(Tile t, bool status)
Mark this house as been completed.
@ PMB_PAUSED_NETWORK
Pause mode bits when paused for network reasons.
@ MP_VOID
Invisible tiles at the SW and SE border.
void RebuildSubsidisedSourceAndDestinationCache()
Perform a full rebuild of the subsidies cache.
static size_t GetNumItems()
Returns number of valid items in the pool.
RailTypes GetCompanyRailTypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
@ TL_BETTER_ROADS
Extended original algorithm (min. 2 distance between roads)
static debug_inline bool IsRailDepotTile(Tile t)
Is this tile rail tile and a rail depot?
uint64_t inflation_prices
Cumulated inflation of prices since game start; 16 bit fractional part.
void Restore()
Restore the variable.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
Axis
Allow incrementing of DiagDirDiff variables.
@ TRANSPORT_RAIL
Transport by train.
void SetDepotReservation(Tile t, bool b)
Set the reservation state of the depot.
void MakeShore(Tile t)
Helper function to make a coast tile.
void DeleteInvalidEngineNews()
Remove engine announcements for invalid engines.
void AfterLoadLinkGraphs()
Spawn the threads for running link graph calculations.
@ ROAD_TILE_DEPOT
Depot (one entrance)
TileIndex tile
The base tile of the area.
const GRFIdentifier * GetOverriddenIdentifier(const GRFConfig *c)
Try to find the overridden GRF identifier of the given GRF.
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
@ SLV_SHIP_ACCELERATION
329 PR#10734 Start using Vehicle's acceleration field for ships too.
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
bool HasStationRail(Tile t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
@ OWNER_WATER
The tile/execution is done by "water".
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
void UpdateAllVirtCoords()
Update the viewport coordinates of all signs.
void GenerateSavegameId()
Generate an unique savegame ID.
struct GRFConfig * next
NOSAVE: Next item in the linked list.
CargoPayment * cargo_payment
The cargo payment we're currently in.
uint8_t acceleration
Acceleration (1 unit = 1/3.2 mph per tick = 0.5 km-ish/h per tick)
bool HasSignals(Tile t)
Checks if a rail tile has signals.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
void SetDockingTile(Tile t, bool b)
Set the docking tile state of a tile.
void SetRailType(Tile t, RailType r)
Sets the rail type of the given tile.
uint16_t old_max_loan_unround_fract
Old: Fraction of the unrounded max loan.
@ SLV_TOWN_CARGOGEN
208 PR#6965 New algorithms for town building cargo generation.
@ SLV_2
2.0 0.3.0 2.1 0.3.1, 0.3.2
@ MP_STATION
A tile of a station.
Owner GetRoadOwner(Tile t, RoadTramType rtt)
Get the owner of a specific road type.
@ WC_COMPANY_INFRASTRUCTURE
Company infrastructure overview; Window numbers:
uint32_t max_loan
the maximum initial loan
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
void SetTileType(Tile tile, TileType type)
Set the type of a tile.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
bool IsHouseCompleted(Tile t)
Get the completion of this house.
TransportType GetTunnelBridgeTransportType(Tile t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
bool disable_elrails
when true, the elrails are disabled
static constexpr TimerGame< struct Economy >::Year MIN_YEAR
The absolute minimum year in OTTD.
CompanyID GetFirstPlayableCompanyID()
Get the index of the first available company.
#define MAX_UVALUE(type)
The largest value that can be entered in a variable.
void Oldver()
Logs loading from savegame without gamelog.
@ DIAGDIR_END
Used for iterations.
@ TRACK_UPPER
Track in the upper corner of the tile (north)
Direction
Defines the 8 directions on the map.
Money old_max_loan_unround
Old: Unrounded max loan.
void RecomputePrices()
Computes all prices, payments and maximum loan.
RailType railtype
Railtype, mangled if elrail is disabled.
uint8_t town_name
the town name generator used for town names
@ TRACK_BIT_Y
Y-axis track.
bool reverse_at_signals
whether to reverse at signals at all
void GfxLoadSprites()
Initialise and load all the sprites.
Base class for all station-ish types.
@ SLV_183
183 25363 Cargodist
@ SLV_AI_START_DATE
309 PR#10653 Removal of individual AI start dates and added a generic one.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
void SetRoadOwner(Tile t, RoadTramType rtt, Owner o)
Set the owner of a specific road type.
@ TRACK_LOWER
Track in the lower corner of the tile (south)
static Pool::IterateWrapper< RoadVehicle > Iterate(size_t from=0)
Returns an iterable ensemble of all valid vehicles of type T.
void SetTownIndex(Tile t, TownID index)
Set the town index for a road or house tile.
TileIndex GetOtherTunnelBridgeEnd(Tile t)
Determines type of the wormhole and returns its other end.
int32_t y_pos
y coordinate.
Structure to return information about the closest depot location, and whether it could be found.
void UpdateLevelCrossing(TileIndex tile, bool sound=true, bool force_bar=false)
Update a level crossing to barred or open (crossing may include multiple adjacent tiles).
void SetClearGroundDensity(Tile t, ClearGround type, uint density)
Sets ground type and density in one go, also sets the counter to 0.
uint16_t w
The width of the area.
void UpdateHousesAndTowns()
Check and update town and house values.
uint8_t wait_twoway_signal
waitingtime in days before a twoway signal
GRFConfig * _grfconfig
First item in list of current GRF set up.
void SetLiftPosition(Tile t, uint8_t pos)
Set the position of the lift on this animated house.
static void SetDate(Date date, DateFract fract)
Set the date.
void TestRevision()
Finds out if current revision is different than last revision stored in the savegame.
void GRFCompatible(const GRFIdentifier *newg)
Logs loading compatible GRF (the same ID, but different MD5 hash)
IndustryBehaviour behaviour
How this industry will behave, and how others entities can use it.
bool IsStationTileBlocked(Tile t)
Is tile t a blocked tile?
static uint FixVehicleInclination(Vehicle *v, Direction dir)
Fixes inclination of a vehicle.
@ RVSB_WORMHOLE
The vehicle is in a tunnel and/or bridge.
@ SLV_ENDING_YEAR
218 PR#7747 v1.10 Configurable ending year.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
static debug_inline TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
@ VF_PATHFINDER_LOST
Vehicle's pathfinder is lost.
int GetTileMaxPixelZ(TileIndex tile)
Get top height of the tile.
@ GF_REPLACE_PROTECTION
If set to true, the global autoreplace has no effect on the group.
static debug_inline uint TileHeight(Tile tile)
Returns the height of a tile.
static Station * GetIfValid(size_t index)
Returns station if the index is a valid index for this station type.
LocaleSettings locale
settings related to used currency/unit system in the current game
const uint8_t _road_stop_stop_frame[]
Table of road stop stop frames, when to stop at a road stop.
static constexpr TimerGame< struct Calendar >::Year ORIGINAL_BASE_YEAR
The minimum starting year/base year of the original TTD.
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_BASE.
void UpdateCompanyLiveries(Company *c)
Update liveries for a company.
@ TAE_WATER
Cargo behaves water-like.
uint8_t currency
currency we currently use
@ SLV_LINKGRAPH_SECONDS
308 PR#10610 Store linkgraph update intervals in seconds instead of days.
void SlError(StringID string, const std::string &extra_msg)
Error handler.
@ TFP_NONE
Normal operation.
@ SLV_NEWGRF_LAST_SERVICE
317 PR#11124 Added stable date_of_last_service to avoid NewGRF trouble.
void CheckTrainsLengths()
Checks if lengths of all rail vehicles are valid.
static constexpr int SECONDS_PER_DAY
approximate seconds per day, not for precise calculations
uint16_t recalc_time
time (in days) for recalculating each link graph component.
bool IsStationRoadStop(Tile t)
Is the station at t a road station?
static debug_inline TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
bool IsValidCargoID(CargoID t)
Test whether cargo type is not INVALID_CARGO.
void InitializeRailGUI()
Resets the rail GUI - sets default railtype to build and resets the signal GUI.
@ SLV_MULTITRACK_LEVEL_CROSSINGS
302 PR#9931 v13.0 Multi-track level crossings.
IndustryType GetIndustryType(Tile tile)
Retrieve the type for this industry.
@ SLV_17
17.0 3212 17.1 3218
std::array< CargoID, INDUSTRY_NUM_INPUTS > accepts_cargo
16 accepted cargoes.
IndustryBuildData _industry_builder
In-game manager of industries.
RoadStop * bus_stops
All the road stops.
@ RVS_IN_DT_ROAD_STOP
The vehicle is in a drive-through road stop.
void ResetWindowSystem()
Reset the windowing system, by means of shutting it down followed by re-initialization.
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
@ EF_ROAD_TRAM
Road vehicle is a tram/light rail vehicle.
void GRFAddList(const GRFConfig *newg)
Logs adding of list of GRFs.
@ TREE_GROUND_SNOW_DESERT
a desert or snow tile, depend on landscape
@ TFP_STUCK
Proceed till next signal, but ignore being stuck till then. This includes force leaving depots.
static Date date
Current date in days (day counter).
CompanySettings company
default values for per-company settings
ConstructionSettings construction
construction of things in-game
@ CCF_TRACK
Valid changes while vehicle is driving, and possibly changing tracks.
VehicleSettings vehicle
options for vehicles
@ SLV_SAVEGAME_ID
313 PR#10719 Add an unique ID to every savegame (used to deduplicate surveys).
void UpdateTownMaxPass(Town *t)
Update the maximum amount of montly passengers and mail for a town, based on its population.
bool IsAirportTile(Tile t)
Is this tile a station tile and an airport tile?
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
TimerGameCalendar::Date build_date
Date of construction.
void SetWaterClassDependingOnSurroundings(Tile t, bool include_invalid_water_class)
Makes a tile canal or water depending on the surroundings.
Data for backing up an order of a vehicle so it can be restored after a vehicle is rebuilt in the sam...
bool IsAnyRoadStop(Tile t)
Is the station at t a road station?
static constexpr TimerGameTick::Ticks DAY_TICKS
1 day is 74 ticks; TimerGameCalendar::date_fract used to be uint16_t and incremented by 885.
@ MAX_COMPANIES
Maximum number of companies.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
uint16_t terraform_frame_burst
how many tile heights may, over a short period, be terraformed?
WaterTileType GetWaterTileType(Tile t)
Get the water tile type at a tile.
@ SLV_TREES_WATER_CLASS
213 PR#7405 WaterClass update for tree tiles.
DistributionType distribution_armoured
distribution type for armoured cargo class
A Stop for a Road Vehicle.
VehicleType type
Type of vehicle.
@ TROPICZONE_NORMAL
Normal tropiczone.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
@ SLV_SCRIPT_RANDOMIZER
333 PR#12063 v14.0-RC1 Save script randomizers.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
void SetAnimationFrame(Tile t, uint8_t frame)
Set a new animation frame.
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
@ GLC_ALL_GOOD
All GRF needed by game are present.
@ WATER_TILE_LOCK
Water lock.
@ PM_UNPAUSED
A normal unpaused game.
@ SLV_190
190 26547 Separate order travel and wait times
Information about a aircraft vehicle.
WaterClass
classes of water (for WATER_TILE_CLEAR water tile type).
static const ObjectType OBJECT_HQ
HeadQuarter of a player.
void ResetOldNames()
Free the memory of the old names array.
@ RVSB_IN_DEPOT
The vehicle is in a depot.
uint8_t roadveh_slope_steepness
Steepness of hills for road vehicles when using realistic acceleration.
static void CheckGroundVehiclesAtCorrectZ()
Check whether the ground vehicles are at the correct Z-coordinate.
uint8_t type
Type of this airport,.
OrderDepotActionFlags
Actions that can be performed when the vehicle enters the depot.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
bool IsTileOwner(Tile tile, Owner owner)
Checks if a tile belongs to the given owner.
static const uint64_t MAX_INFLATION
Maximum inflation (including fractional part) without causing overflows in int64_t price computations...
@ INVALID_TRACK
Flag for an invalid track.
Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
void UpdateAllStationVirtCoords()
Update the virtual coords needed to draw the station sign for all stations.
bool AddInflation(bool check_year)
Add monthly inflation.
@ WATER_CLASS_RIVER
River.
@ PM_PAUSED_NORMAL
A game normally paused.
@ TOWN_CUSTOM_GROWTH
Growth rate is controlled by GS.
static void ResetSignalHandlers()
Resets signal handlers back to original handlers.
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
@ SLV_COMPANY_INAUGURATED_PERIOD
339 PR#12798 Companies show the period inaugurated in wallclock mode.
bool allow_town_roads
towns are allowed to build roads (always allowed when generating world / in SE)
TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
void ConvertOldMultiheadToNew()
Converts all trains to the new subtype format introduced in savegame 16.2 It also links multiheaded e...
@ GLC_NOT_FOUND
At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE)
uint8_t units_height
unit system for height
DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
bool IsShipDepot(Tile t)
Is it a water tile with a ship depot on it?
void SetTropicZone(Tile tile, TropicZone type)
Set the tropic zone.
Town * town
Town the object is built in.
@ SLV_DEPOT_UNBUNCHING
331 PR#11945 Allow unbunching shared order vehicles at a depot.
@ GES_RATING
This indicates whether a cargo has a rating at the station.
@ TAE_GOODS
Cargo behaves goods/candy-like.
@ SLV_MAX_LOAN_FOR_COMPANY
330 PR#11224 Separate max loan for each company.
GRFListCompatibility
Status of post-gameload GRF compatibility check.
static debug_inline bool IsRoadDepot(Tile t)
Return whether a tile is a road depot.
@ ROAD_X
Full road along the x-axis (south-west + north-east)
TileArea ship_station
Tile area the ship 'station' part covers.
static void StartNew()
Start up a new GameScript.
uint GetClearDensity(Tile t)
Get the density of a non-field clear tile.
DistributionType distribution_pax
distribution type for passengers
@ Industry
Source/destination is an industry.
@ FLYING
Vehicle is flying in the air.
uint8_t train_slope_steepness
Steepness of hills for trains when using realistic acceleration.
bool IsDriveThroughStopTile(Tile t)
Is tile t a drive through road stop station or waypoint?
uint8_t last_speed
Maximum speed (up to 255) of the last vehicle that tried to load this cargo.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
@ AT_OILRIG
Oilrig airport.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
void ResetCompanyLivery(Company *c)
Reset the livery schemes to the company's primary colour.
DiagDirection XYNSToDiagDir(Axis xy, uint ns)
Convert an axis and a flag for north/south into a DiagDirection.
static uint SizeY()
Get the size of the map along the Y.
ZoomLevel
All zoom levels we know.
@ WL_CRITICAL
Critical errors, the MessageBox is shown in all cases.
void AfterLoadCompanyStats()
Rebuilding of company statistics after loading a savegame.
uint8_t units_force
unit system for force
static void UpdateAfterLoad()
Update all caches after loading a game, changing NewGRF, etc.
@ GF_REPLACE_WAGON_REMOVAL
If set, autoreplace will perform wagon removal on vehicles in this group.
void SetupColoursAndInitialWindow()
Initialise the default colours (remaps and the likes), and load the main windows.
@ TAE_FOOD
Cargo behaves food/fizzy-drinks-like.
@ OLFB_NO_LOAD
Do not load anything.
DistributionType distribution_default
distribution type for all other goods
void UpdateStationAcceptance(Station *st, bool show_msg)
Update the acceptance for a station.
bool modified_catchment
different-size catchment areas
DiagDirection GetTunnelBridgeDirection(Tile t)
Get the direction pointing to the other end.
uint8_t feeder_payment_share
percentage of leg payment to virtually pay in feeder systems
static Year year
Current year, starting at 0.
@ FACIL_AIRPORT
Station with an airport.
static Date date
Current date in days (day counter).
Company * DoStartupNewCompany(bool is_ai, CompanyID company=INVALID_COMPANY)
Create a new company and sets all company variables default values.
TownAcceptanceEffect town_acceptance_effect
The effect that delivering this cargo type has on towns. Also affects destination of subsidies.
@ SLV_186
186 25833 Objects storage
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.