74#include "table/strings.h"
96 if (include_invalid_water_class) {
113 bool has_water =
false;
114 bool has_canal =
false;
115 bool has_river =
false;
124 }
else if (!
IsLock(neighbour)) {
148 if (!has_water && !has_canal && !has_river && include_invalid_water_class) {
153 if (has_river && !has_canal) {
155 }
else if (has_canal || !has_water) {
162static void ConvertTownOwner()
185 t->exclusivity = CompanyID::Invalid();
192 constexpr Currency convert_currency[] = {
215 return rt >= min ? (
RailType)(rt + 1): rt;
226 UpdateAllTextEffectVirtCoords();
227 RebuildViewportKdtree();
230void ClearAllCachedNames()
232 ClearAllStationCachedNames();
234 ClearAllIndustryCachedNames();
253 ClearAllCachedNames();
255 ResetViewportAfterLoadGame();
273 if (i->psa !=
nullptr) {
275 i->psa->tile = i->location.tile;
279 if (s->airport.psa !=
nullptr) {
281 s->airport.psa->tile = s->airport.tile;
285 for (
auto &it : t->psa_list) {
291 if (rv->IsFrontEngine()) {
314typedef void (CDECL *SignalHandlerPointer)(int);
315static SignalHandlerPointer _prev_segfault =
nullptr;
316static SignalHandlerPointer _prev_abort =
nullptr;
317static SignalHandlerPointer _prev_fpe =
nullptr;
337 signal(SIGSEGV, _prev_segfault);
338 signal(SIGABRT, _prev_abort);
339 signal(SIGFPE, _prev_fpe);
366 message.reserve(1024);
367 message +=
"Loading your savegame caused OpenTTD to crash.\n";
373 "This is most likely caused by a missing NewGRF or a NewGRF that\n"
374 "has been loaded as replacement for a missing NewGRF. OpenTTD\n"
375 "cannot easily determine whether a replacement NewGRF is of a newer\n"
376 "or older version.\n"
377 "It will load a NewGRF with the same GRF ID as the missing NewGRF.\n"
378 "This means that if the author makes incompatible NewGRFs with the\n"
379 "same GRF ID, OpenTTD cannot magically do the right thing. In most\n"
380 "cases, OpenTTD will load the savegame and not crash, but this is an\n"
382 "Please load the savegame with the appropriate NewGRFs installed.\n"
383 "The missing/compatible NewGRFs are:\n";
388 format_append(message,
"NewGRF {:08X} (checksum {}) not found.\n Loaded NewGRF \"{}\" (checksum {}) with same GRF ID instead.\n",
392 format_append(message,
"NewGRF {:08X} ({}) not found; checksum {}.\n",
398 "This is probably caused by a corruption in the savegame.\n"
399 "Please file a bug report and attach this savegame.\n";
404 SignalHandlerPointer call =
nullptr;
406 case SIGSEGV: call = _prev_segfault;
break;
407 case SIGABRT: call = _prev_abort;
break;
408 case SIGFPE: call = _prev_fpe;
break;
409 default: NOT_REACHED();
411 if (call !=
nullptr) call(signum);
460 t.
m3() = (hasroad ? bits.
base() : 0);
480 int entry_x = v->
x_pos;
481 int entry_y = v->
y_pos;
488 default: NOT_REACHED();
498 if (middle_z == entry_z)
return {};
515 if (v->IsGroundVehicle()) {
567 if (_cur_tileloop_tile == 0) _cur_tileloop_tile =
TileIndex{1};
575 RebuildStationKdtree();
578 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;
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;
845 cp->front->cargo_payment = cp;
846 cp->current_station = cp->front->last_station_visited;
853 static constexpr uint8_t WBL_COAST_FLAG = 0;
858 switch (
GB(t.m5(), 4, 4)) {
896 }
else if (gfx == 75) {
902 }
else if (gfx == 82) {
944 bst->
rect.BeforeAddTile(t, StationRect::ADD_FORCE);
1013 t.m4() |= (t.m2() << 4);
1042 c->engine_renew_list =
nullptr;
1043 c->settings.engine_renew =
false;
1044 c->settings.engine_renew_months = 6;
1045 c->settings.engine_renew_money = 100000;
1067 uint tmp =
GB(t.m4(), 0, 4);
1068 SB(t.m4(), 0, 4,
GB(t.m2(), 0, 4));
1069 SB(t.m2(), 0, 4, tmp);
1070 }
else if (
HasBit(t.m5(), 2)) {
1080 std::swap(t.m3(), t.m4());
1094 SB(t.m5(), 6, 2,
GB(t.m5(), 4, 2));
1098 SB(t.m4(), 0, 4,
GB(t.m5(), 0, 4));
1099 SB(t.m4(), 4, 4, 0);
1100 SB(t.m6(), 2, 4, 0);
1103 SB(t.m4(), 5, 2,
GB(t.m5(), 2, 2));
1107 SB(t.m7(), 6, 2, 1);
1118 SB(t.m7(), 6, 2, 1);
1134 if (fix_roadtypes)
SB(t.m7(), 6, 2,
GB(t.m7(), 5, 3));
1135 SB(t.m7(), 5, 1,
GB(t.m3(), 7, 1));
1139 SB(t.m7(), 0, 4,
GB(t.m3(), 0, 4));
1140 SB(t.m6(), 3, 3,
GB(t.m3(), 4, 3));
1141 SB(t.m3(), 0, 4,
GB(t.m4(), 4, 4));
1142 SB(t.m3(), 4, 4,
GB(t.m5(), 0, 4));
1143 SB(t.m5(), 0, 4,
GB(t.m4(), 0, 4));
1147 SB(t.m7(), 0, 5,
GB(t.m4(), 0, 5));
1148 SB(t.m6(), 3, 3,
GB(t.m3(), 4, 3));
1149 SB(t.m3(), 4, 4,
GB(t.m5(), 0, 4));
1150 SB(t.m5(), 0, 1,
GB(t.m4(), 6, 1));
1151 SB(t.m5(), 5, 1,
GB(t.m4(), 5, 1));
1167 if (fix_roadtypes)
SB(t.m7(), 6, 2,
GB(t.m3(), 0, 3));
1169 SB(t.m3(), 4, 4, t.m1());
1176 if (fix_roadtypes)
SB(t.m7(), 6, 2,
GB(t.m3(), 0, 3));
1179 SB(t.m7(), 0, 5, o.base());
1182 SB(t.m6(), 2, 4,
GB(t.m2(), 4, 4));
1183 SB(t.m7(), 5, 1,
GB(t.m4(), 7, 1));
1231 Axis axis =
static_cast<Axis>(
GB(t.m5(), 0, 1));
1246 t.m2() = town.base();
1249 SB(t.m6(), 2, 4, 0);
1254 if (
GB(t.m5(), 3, 2) == 0) {
1270 Axis axis =
static_cast<Axis>(
GB(t.m5(), 0, 1));
1271 uint north_south =
GB(t.m5(), 5, 1);
1281 if (!v->IsGroundVehicle())
continue;
1295 v->UpdatePosition();
1310 bool has_road =
false;
1331 SB(t.m7(), 6, 2, 0);
1341 RailTypes rts = RailVehInfo(v->engine_type)->railtypes;
1413 SB(t.m4(), 4, 4, 0);
1430 static constexpr VehStates OLD_VS_WAIT_FOR_SLOT{0x40};
1432 rv->vehstatus.Reset(OLD_VS_WAIT_FOR_SLOT);
1453 AfterLoadStations();
1490 for (j = 0; j != 50; j++) PlantRandomFarmField(i);
1498 for (
Order &order : orderlist->GetOrders()) {
1512 UpdateDisableElrailSettingState(
_settings_game.vehicle.disable_elrails,
false);
1523 SB(t.m5(), 3, 2,
GB(t.m3(), 6, 2));
1524 SB(t.m3(), 6, 2, 0);
1579 case GFX_POWERPLANT_SPARKS:
1580 t.m3() =
GB(t.m1(), 2, 5);
1583 case GFX_OILWELL_ANIMATED_1:
1584 case GFX_OILWELL_ANIMATED_2:
1585 case GFX_OILWELL_ANIMATED_3:
1586 t.m3() =
GB(t.m1(), 0, 2);
1589 case GFX_COAL_MINE_TOWER_ANIMATED:
1590 case GFX_COPPER_MINE_TOWER_ANIMATED:
1591 case GFX_GOLD_MINE_TOWER_ANIMATED:
1626 v->cur_speed *= 128;
1628 v->acceleration = avi->acceleration;
1647 if (style.has_value()) {
1670 t->larger_town =
true;
1679 !v->vehstatus.Any({VehState::Stopped, VehState::Crashed}) &&
1680 v->current_order.IsType(OT_LOADING)) {
1681 Station::Get(v->last_station_visited)->loading_vehicles.push_back(v);
1692 for (
auto iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); ) {
1695 iter = st->loading_vehicles.erase(iter);
1721 SB(t.m2(), 4, 4, 0);
1723 SB(t.m2(), 4, 3,
GB(t.m2(), 0, 3));
1731 if (rv->state == 250 || rv->state == 251) {
1783 for (uint j = 0; j < std::size(i->produced); j++) {
1784 i->produced[j].cargo = indsp->produced_cargo[j];
1786 for (uint j = 0; j < std::size(i->accepted); j++) {
1817 for (
Order &o : orderlist->GetOrders()) {
1818 o.ConvertFromOldSavegame();
1823 if (v->orders !=
nullptr && v->GetFirstOrder() !=
nullptr && v->GetFirstOrder()->IsType(OT_NOTHING)) {
1824 v->orders->FreeChain();
1825 v->orders =
nullptr;
1828 v->current_order.ConvertFromOldSavegame();
1829 if (v->type ==
VehicleType::Road && v->IsPrimaryVehicle() && v->FirstShared() == v) {
1836 for (
Order &order : orderlist->GetOrders()) {
1853 for (
Order &order : orderlist->GetOrders()) {
1854 if (!order.IsType(OT_GOTO_DEPOT))
continue;
1855 order.SetDepotActionType(
static_cast<OrderDepotActionFlags>(order.GetDepotActionType().base() >> 1));
1860 if (!v->current_order.IsType(OT_GOTO_DEPOT))
continue;
1861 v->current_order.SetDepotActionType(
static_cast<OrderDepotActionFlags>(v->current_order.GetDepotActionType().base() >> 1));
1875 SB(t.m3(), 0, 2, 0);
1886 SB(t.m3(), 0, 2, 0);
1913 Owner o = (Owner)t.m4();
1971 v->profit_this_year <<= 8;
1972 v->profit_last_year <<= 8;
1973 v->running_ticks = 0;
1981 SB(t.m6(), 2, 6,
GB(t.m6(), 3, 5));
1982 SB(t.m3(), 5, 1, 0);
2063 if (t->First() == t) t->ReserveTrackUnderConsist();
2079 st->indtype = IT_INVALID;
2086 if (!a->IsNormalAircraft()) {
2087 a->engine_type = a->First()->engine_type;
2093 if (c->bankrupt_asked.base() == 0xFF) c->bankrupt_asked.Set();
2097 if (e->company_avail.base() == 0xFF) e->company_avail.Set();
2101 if (t->have_ratings.base() == 0xFF) t->have_ratings.Set();
2113 t.m3() =
GB(t.m5(), 0, 5);
2125 t.m3() = type ==
OBJECT_HQ ?
GB(t.m3(), 1, 1) |
GB(t.m3(), 0, 1) << 4 : 0;
2142 uint offset = t.m3();
2145 t.m3() =
GB(t.m6(), 2, 4);
2146 SB(t.m6(), 2, 4, 0);
2156 SlError(STR_ERROR_TOO_MANY_OBJECTS);
2165 t.m2() = o->index.base();
2168 Tile northern_tile = t -
TileXY(
GB(offset, 0, 4),
GB(offset, 4, 4));
2170 t.m2() = northern_tile.
m2();
2179 if (old_town_layout == 0) {
2199 case 5: layout = 1;
break;
2200 case 0: layout = 2;
break;
2202 t->layout =
static_cast<TownLayout>(layout - 1);
2218 for (
Order &o : orderlist->GetOrders()) {
2241 if (v->subtype == 2 && v->state != 0) {
2256 for (
Vehicle *v : st->loading_vehicles) {
2278 remove = *tile == *j;
2317 wp->train_station.tile = wp->xy;
2318 wp->train_station.w = 1;
2319 wp->train_station.h = 1;
2322 wp->train_station.w = 0;
2323 wp->train_station.h = 0;
2331 if (s->remaining < 12) {
2333 s->remaining = 12 - s->remaining;
2334 s->awarded = CompanyID::Invalid();
2360 s->remaining = 24 - s->remaining;
2368 if (ss !=
nullptr && sd !=
nullptr && ss->
owner == sd->
owner &&
2371 s->src.SetIndex(ss->
town->index);
2372 s->dst.SetIndex(sd->
town->index);
2373 s->awarded = ss->
owner;
2394 uint64_t aimed_inflation = (_economy.old_max_loan_unround << 16 | _economy.old_max_loan_unround_fract) /
_settings_game.difficulty.max_loan;
2400 while (_economy.inflation_prices < aimed_inflation) {
2411 Debug(sl, 0,
"Removing invalid depot {} at {}, {}", d->index,
TileX(d->xy),
TileY(d->xy));
2416 tile.
m2() = d->index.base();
2425 if (t->force_proceed !=
TFP_NONE) {
2444 uint density =
GB(t.m2(), 6, 2);
2445 uint ground =
GB(t.m2(), 4, 2);
2446 t.m2() = ground << 6 | density << 4;
2454 a->turn_counter = a->current_order.IsType(OT_LOADING) ? 0 : a->load_unload_ticks;
2458 t->wait_counter = t->current_order.IsType(OT_LOADING) ? 0 : t->load_unload_ticks;
2464 struct AirportTileConversion {
2468 static const AirportTileConversion atcs[] = {
2483 for (
const auto &atc : atcs) {
2484 if (old_gfx < atc.old_start) {
2488 if (old_gfx < atc.old_start + atc.num_frames) {
2493 offset += atc.num_frames - 1;
2502 if (st->airport.tile !=
INVALID_TILE && st->airport.type == 15) {
2511 st->airport.w = st->airport.GetSpec()->size_x;
2512 st->airport.h = st->airport.GetSpec()->size_y;
2548 if (!v->IsNormalAircraft())
continue;
2550 if (st ==
nullptr && v->state !=
FLYING) {
2569 uint per_proc = t.m7();
2570 t.m7() =
GB(t.m6(), 2, 6) | (
GB(t.m3(), 5, 1) << 6);
2571 SB(t.m3(), 5, 1, 0);
2572 SB(t.m6(), 2, 6, std::min(per_proc, 63U));
2616 if (!wp->name.empty()) wp->town_cn = UINT16_MAX;
2633 if (!v->IsGroundVehicle())
continue;
2643 if (
GetSlopePixelZ(v->x_pos, v->y_pos,
true) != v->z_pos)
continue;
2678 default: NOT_REACHED();
2686 default: NOT_REACHED();
2696 bool loading = rv->current_order.IsType(OT_LOADING) || rv->current_order.IsType(OT_LEAVESTATION);
2717 c->terraform_limit =
_settings_game.construction.terraform_frame_burst << 16;
2718 c->clear_limit =
_settings_game.construction.clear_frame_burst << 16;
2733 if (v->IsGroundVehicle() &&
TileVirtXY(v->x_pos, v->y_pos) == v->tile) {
2824 if (!v->IsPrimaryVehicle())
continue;
2827 if (v->cur_implicit_order_index >= v->GetNumOrders()) v->cur_implicit_order_index = 0;
2829 v->cur_real_order_index = v->cur_implicit_order_index;
2830 v->UpdateRealOrderIndex();
2861 assert(ind->psa !=
nullptr);
2864 bool is_empty =
true;
2865 for (uint i = 0; i <
sizeof(ind->psa->storage); i++) {
2866 if (ind->psa->GetValue(i) != 0) {
2873 ind->psa->grfid = _industry_mngr.GetGRFID(ind->type);
2884 assert(st->airport.psa !=
nullptr);
2887 bool is_empty =
true;
2888 for (uint i = 0; i <
sizeof(st->airport.psa->storage); i++) {
2889 if (st->airport.psa->GetValue(i) != 0) {
2896 st->airport.psa->grfid = _airport_mngr.GetGRFID(st->airport.type);
2898 delete st->airport.psa;
2899 st->airport.psa =
nullptr;
2916 uint fence =
GB(t.m4(), 5, 3);
2920 fence =
GB(t.m4(), 2, 3);
2924 SB(t.m4(), 2, 3, 0);
2925 SB(t.m4(), 5, 3, 0);
2934 if (!t->IsPrimaryVehicle())
continue;
3002 c->months_of_bankruptcy = 3 * c->months_of_bankruptcy;
3011 v->acceleration = avi->acceleration;
3026 extern uint8_t _old_units;
3070 std::vector<uint> skip_frames;
3072 if (!v->IsFrontEngine())
continue;
3073 skip_frames.clear();
3075 uint prev_tile_skip = 0;
3078 if (u->tile != prev_tile) {
3079 prev_tile_skip = cur_skip;
3080 prev_tile = u->tile;
3082 cur_skip = prev_tile_skip;
3085 uint &this_skip = skip_frames.emplace_back(prev_tile_skip);
3091 if (u->frame <= (roadside ? 9 : 5)) this_skip = cur_skip;
3096 if (u->frame <= (roadside ? 5 : 9)) this_skip = cur_skip;
3101 if (u->frame <= (roadside ? 4 : 2)) this_skip = cur_skip;
3108 while (cur_skip > skip_frames[0]) {
3111 for (uint sf : skip_frames) {
3112 if (sf >= cur_skip) IndividualRoadVehicleController(u, prev);
3124 for (
Order &order : orderlist->GetOrders()) {
3125 order.SetTravelTimetabled(order.GetTravelTime() > 0);
3126 order.SetWaitTimetabled(order.GetWaitTime() > 0);
3128 orderlist->RecalculateTimetableDuration();
3139#ifndef DEBUG_DUMP_COMMANDS
3154 t->growth_rate = TownTicksToGameTicks(t->growth_rate & ~0x8000);
3166 for (
auto &a : i->accepted) {
3168 a.last_accepted = i->GetAccepted(0).last_accepted;
3183 int x = s->x_pos & 0xF;
3184 int y = s->y_pos & 0xF;
3185 if (x == 8 && y == 8)
continue;
3190 switch (shipdiagdir) {
3191 default: NOT_REACHED();
3201 if ((shipdiagdir == slopediagdir) == second_half) {
3225 st->industry->neutral_station = st;
3258 if (st->ship_station.tile !=
INVALID_TILE) UpdateStationDockingTiles(st);
3275 if (c->settings.renew_keep_length) wagon_removal.
Set(c->index);
3278 if (g->flags.Any()) {
3289 v->last_loading_tick = std::max(
TimerGameTick::counter,
static_cast<uint64_t
>(v->current_order_time)) - v->current_order_time;
3302 if (rv->IsArticulatedPart())
continue;
3305 if (rv->cur_speed > 0)
continue;
3317 if (closest_depot.found &&
DistanceManhattan(rv->tile, closest_depot.location) < 512u) {
3320 u->tile = closest_depot.location;
3329 u->UpdatePosition();
3331 RoadVehLeaveDepot(rv,
false);
3339 SB(t.m2(), 0, 4, 0);
3382 if (s->acceleration == 0) s->acceleration = ShipVehInfo(s->engine_type)->acceleration;
3388 c->max_loan = COMPANY_MAX_LOAN_DEFAULT;
3393 ScriptObject::InitializeRandomizers();
3398 c->inaugurated_year_calendar =
_settings_game.game_creation.starting_year;
3432 g->number = c->freegroups.
UseID(g->index.base());
3434 c->freegroups.
UseID(g->number);
3493 AfterLoadStations();
3501 for (CompanyID i = CompanyID::Begin(); i < MAX_COMPANIES; ++i)
InvalidateWindowData(WindowClass::CompanyLivery, i);
3505 InvalidateAllPickerWindows();
static void SetSignalHandlers()
Replaces signal handlers of SIGSEGV and SIGABRT and stores pointers to original handlers in memory.
static void UpdateExclusiveRights()
Since savegame version 4.1, exclusive transport rights are stored at towns.
Company * DoStartupNewCompany(bool is_ai, CompanyID company=CompanyID::Invalid())
Create a new company and sets all company variables default values.
static void InitializeWindowsAndCaches()
Initialization of the windows and several kinds of caches.
static void CheckGroundVehiclesAtCorrectZ()
Check whether the ground vehicles are at the correct Z-coordinate.
static bool _saveload_crash_with_missing_newgrfs
Was the saveload crash because of missing NewGRFs?
static void HandleSavegameLoadCrash(int signum)
Signal handler used to give a user a more useful report for crashes during the savegame loading proce...
static void FixOwnerOfRailTrack(Tile t)
Tries to change owner of this rail tile to a valid owner.
static void UpdateVoidTiles()
Up to revision 1413 the invisible tiles at the southern border have not been TileType::Void,...
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 ...
static void UpdateCurrencies()
Since savegame version 4.2 the currencies are arranged differently.
void SetWaterClassDependingOnSurroundings(Tile t, bool include_invalid_water_class)
Makes a tile canal or water depending on the surroundings.
static GroundVehicleFlags FixVehicleInclination(Vehicle *v, Direction dir)
Fixes inclination of a vehicle.
static void StartScripts()
Start the scripts.
bool SaveloadCrashWithMissingNewGRFs()
Did loading the savegame cause a crash?
void UpdateAllVirtCoords()
Update the viewport coordinates of all signs.
void ClearOldOrders()
Clear all old orders.
bool AfterLoadGame()
Perform a (large) amount of savegame conversion magic in order to load older savegames and to fill th...
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
static void ResetSignalHandlers()
Resets signal handlers back to original handlers.
Base functions for all AIs.
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...
void AircraftNextAirportPos_and_Order(Aircraft *v)
Set the right pos when heading to other airports after takeoff.
Station * GetTargetAirportIfValid(const Aircraft *v)
Returns aircraft's target station if v->target_airport is a valid station with airport.
void SetAircraftPosition(Aircraft *v, int x, int y, int z)
Set aircraft position.
@ AIR_AIRCRAFT
an airplane
void UpdateAircraftCache(Aircraft *v, bool update_range=false)
Update cached values of an aircraft.
@ FLYING
Vehicle is flying in the air.
@ AT_OILRIG
Oilrig airport.
std::vector< TileIndex > _animated_tiles
The table/list with animated tiles.
Maps accessors for animated tiles.
@ Animated
Tile is animated.
@ None
Tile is not animated.
void SetAnimatedTileState(Tile t, AnimatedTileState state)
Set the animated state of a tile.
Class for backupping variables and making sure they are restored later.
VehicleFlag
Bit numbers in Vehicle::vehicle_flags.
@ PathfinderLost
Vehicle's pathfinder is lost.
@ LoadingFinished
Vehicle has finished loading.
constexpr T AssignBit(T &x, const uint8_t y, bool value)
Assigns a bit in a variable.
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.
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr enable_if_t< is_integral_v< T >, T > byteswap(T x) noexcept
Custom implementation of std::byteswap; remove once we build with C++23.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
TileIndex GetNorthernBridgeEnd(TileIndex t)
Finds the northern end of a bridge starting at a middle tile.
void SetBridgeMiddle(Tile t, Axis a)
Set that there is a bridge over the given axis.
bool IsBridgeTile(Tile t)
checks if there is a bridge on this tile
void ClearBridgeMiddle(Tile t)
Removes bridges from the given, that is bridges along the X and Y axis.
bool IsBridge(Tile t)
Checks if this is a bridge, instead of a tunnel.
void AfterLoadCompanyStats()
Rebuilding of company statistics after loading a savegame.
bool IsValidCargoType(CargoType cargo)
Test whether cargo type is not INVALID_CARGO.
static constexpr CargoType CARGO_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-renew).
@ Food
Cargo behaves food/fizzy-drinks-like.
@ Water
Cargo behaves water-like.
@ Mail
Cargo behaves mail-like.
@ Passengers
Cargo behaves passenger-like.
@ Goods
Cargo behaves goods/candy-like.
static void StartNew(CompanyID company)
Start a new AI company.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr Tstorage base() const noexcept
Retrieve the raw value behind this bit set.
constexpr Timpl & Reset()
Reset all bits.
constexpr Timpl & Set()
Set all bits.
Iterate a range of enum values.
UnitID UseID(UnitID index)
Use a unit number.
static void StartNew()
Start up a new GameScript.
static constexpr TimerGameTick::Ticks DAY_TICKS
1 day is 74 ticks; TimerGameCalendar::date_fract used to be uint16_t and incremented by 885.
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).
Wrapper class to abstract away the way the tiles are stored.
uint8_t & m5()
General purpose.
uint8_t & m6()
General purpose.
uint8_t & m7()
Primarily used for newgrf support.
uint8_t & m3()
General purpose.
uint16_t & m2()
Primarily used for indices to towns, industries and stations.
A timeout timer will fire once after the interval.
static void SetDate(Date date, DateFract fract)
Set the date.
static Date date
Current date in days (day counter).
static Year year
Current year, starting at 0.
static DateFract date_fract
Fractional part of the day.
static constexpr TimerGame< struct Economy >::Date MIN_DATE
static constexpr TimerGame< struct Calendar >::Year DEF_END_YEAR
static constexpr TimerGame< struct Economy >::Year MIN_YEAR
static constexpr int SECONDS_PER_DAY
static constexpr TimerGame< struct Calendar >::Year ORIGINAL_BASE_YEAR
static constexpr TimerGame< struct Calendar >::Date DAYS_TILL_ORIGINAL_BASE_YEAR
static Date date
Current date in days (day counter).
static Year year
Current year, starting at 0.
static DateFract date_fract
Fractional part of the day.
static void SetDate(Date date, DateFract fract)
Set the date.
static TickCounter counter
Monotonic counter, in ticks, since start of game.
StrongType::Typedef< int32_t, DateTag< struct Economy >, StrongType::Compare, StrongType::Integer > Date
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.
@ Grass
Plain grass with dirt transition (0-3).
void MakeClear(Tile t, ClearGround g, uint density)
Make a clear tile.
ClearGround GetClearGround(Tile t)
Get the type of clear tile.
void SetClearGroundDensity(Tile t, ClearGround type, uint density)
Sets ground type and density in one go, also sets the counter to 0.
uint GetClearDensity(Tile t)
Get the density of a non-field clear tile.
void RandomiseCompanyManagerFace(CompanyManagerFace &cmf, Randomizer &randomizer)
Completely randomise a company manager face, including style.
TimeoutTimer< TimerGameTick > _new_competitor_timeout({ TimerGameTick::Priority::CompetitorTimeout, 0 }, []() { if(_game_mode==GameMode::Menu||!AI::CanStartNew()) return;if(_networking &&Company::GetNumItems() >=_settings_client.network.max_companies) return;if(_settings_game.difficulty.competitors_interval==0) 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< Commands::CompanyControl >::Post(CompanyCtrlAction::NewAI, CompanyID::Invalid(), CompanyRemoveReason::None, ClientID::Invalid);})
Start a new competitor company if possible.
void ResetCompanyLivery(Company *c)
Reset the livery schemes to the company's primary colour.
void UpdateCompanyLiveries(Company *c)
Update liveries for a company.
void SetCompanyManagerFaceStyle(CompanyManagerFace &cmf, uint style)
Set a company face style.
CompanyID GetFirstPlayableCompanyID()
Get the index of the first available company.
std::optional< uint > FindCompanyManagerFaceLabel(std::string_view label)
Find a company manager face style by label.
CompanyID _current_company
Company currently doing an action.
Functions related to companies.
CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32_t face)
Converts an old company manager's face format to the new company manager's face format.
static constexpr Owner OWNER_TOWN
A town owns the tile, or a town is expanding.
static constexpr Owner OWNER_NONE
The tile has no ownership.
static constexpr Owner INVALID_OWNER
An invalid owner.
static constexpr Owner OWNER_WATER
The tile/execution is done by "water".
Currency
This enum gives the currencies a unique id which must be maintained for savegame compatibility and in...
#define Debug(category, level, format_string,...)
Output a line of debugging information.
Base for all depots (except hangars).
bool IsDepotTile(Tile tile)
Is the given tile a tile with a depot on it?
Direction DiagDirToDir(DiagDirection dir)
Convert a DiagDirection to a Direction.
DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Direction ReverseDir(Direction d)
Return the reverse of a direction.
Direction AxisToDirection(Axis a)
Converts an Axis to a Direction.
Axis OtherAxis(Axis a)
Select the other axis as provided.
Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
DiagDirection XYNSToDiagDir(Axis xy, uint ns)
Convert an axis and a flag for north/south into a DiagDirection.
DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
EnumIndexArray< T, DiagDirection, DiagDirection::End > DiagDirectionIndexArray
Array with DiagDirection as index.
Direction
Defines the 8 directions on the map.
@ Invalid
Flag for an invalid direction.
Axis
Enumeration for the two axis X and Y.
DiagDirection
Enumeration for diagonal directions.
@ End
Used for iterations.
@ NE
Northeast, upper right on your monitor.
void RecomputePrices()
Computes all prices, payments and maximum loan.
bool AddInflation(bool check_year)
Add monthly inflation.
Base classes related to the economy.
static const uint64_t MAX_INFLATION
Maximum inflation (including fractional part) without causing overflows in int64_t price computations...
Header file for electrified rail specific functions.
void StartupEngines()
Start/initialise all our engines.
Functions related to engines.
void CopyTempEngineData()
Copy data from temporary engine array into the real engine pool.
EnumBitSet< EngineFlag, uint8_t > EngineFlags
Bitset of EngineFlag elements.
@ RoadIsTram
Road vehicle is a tram/light rail vehicle.
EngineFlag
Engine.flags is a bitmask, with the following values.
@ Available
This vehicle is available to everyone.
@ ExclusivePreview
This vehicle is in the exclusive preview stage, either being used or being offered to a company.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23).
Functions related to errors.
@ Critical
Critical errors, the MessageBox is shown in all cases.
void ShowErrorMessage(EncodedString &&summary_msg, int x, int y, CommandCost &cc)
Display an error message in a window.
@ Scenario
old or new scenario
Declarations for savegames operations.
Base functions for all Games.
Gamelog _gamelog
Gamelog instance.
Declaration shared among gamelog.cpp and saveload/gamelog_sl.cpp.
void LoadStringWidthTable(FontSizes fontsizes)
Initialize _stringwidth_table cache for the specified font sizes.
PauseModes _pause_mode
The current pause mode.
void GfxLoadSprites()
Initialise and load all the sprites.
Functions related to the graphics initialization.
@ Tile
Destination is a tile.
void UpdateGroupChildren()
Update children list for each group.
@ ReplaceProtection
If set, the global autoreplace has no effect on the group.
@ ReplaceWagonRemoval
If set, autoreplace will perform wagon removal on vehicles in this group.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
@ BuildingIsProtected
towns and AI will not remove this house, while human players will be able to
static const HouseID NEW_HOUSE_OFFSET
Offset for new houses.
static const uint8_t TOWN_HOUSE_COMPLETED
Simple value that indicates the house has reached the final stage of construction.
IndustryBuildData _industry_builder
In-game manager of industries.
void TrimIndustryAcceptedProduced(Industry *ind)
Remove unused industry accepted/produced slots – entries after the last slot with valid cargo.
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
IndustryType GetIndustryType(Tile tile)
Retrieve the type for this industry.
IndustryGfx GetIndustryGfx(Tile t)
Get the industry graphics ID for the given industry tile.
@ PlantOnBuild
Fields are planted around when built (all farms).
@ BuiltOnWater
is built on water (oil rig)
void AfterLoadLabelMaps()
Perform rail type and road type conversion if necessary.
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner)
Change the owner of a tile.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, RoadTramType sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
int GetSlopePixelZ(int x, int y, bool ground_vehicle)
Return world Z coordinate of a given point of a tile.
@ Arctic
Landscape with snow levels.
@ Tropic
Landscape with distinct rainforests and deserts,.
void AfterLoadLinkGraphs()
Spawn the threads for running link graph calculations.
@ Manual
Manual distribution. No link graph calculations are run.
void SetupColoursAndInitialWindow()
Initialise the default colours (remaps and the likes), and load the main windows.
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
TileIndex TileAddXY(TileIndex tile, int x, int y)
Adds a given offset to a tile.
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
static uint TileX(TileIndex tile)
Get the X component of a tile.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
constexpr bool IsInsideMM(const size_t x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
constexpr To ClampTo(From value)
Clamp the given value down to lie within the requested type.
void GenerateSavegameId()
Generate an unique savegame ID.
ZoomLevel _saved_scrollpos_zoom
bool _networking
are we in networking mode?
bool _network_dedicated
are we a dedicated server?
bool _network_server
network-server is active
Basic functions/variables used all over the place.
Network functions used by other parts of OpenTTD.
Base for the NewGRF implementation.
@ FakeTowns
Fake town GrfSpecFeature for NewGRF debugging (parent scope).
@ Airports
Airports feature.
@ Industries
Industries feature.
void ShowNewGRFError()
Show the first NewGRF error we can find.
uint8_t StationGfx
Copy from station_map.h.
GRFConfigList _grfconfig
First item in list of current GRF set up.
GRFListCompatibility IsGoodGRFConfigList(GRFConfigList &grfconfig)
Check if all GRFs in the GRF config from a savegame can be loaded.
GRFListCompatibility
Status of post-gameload GRF compatibility check.
@ NotFound
At least one GRF couldn't be found (higher priority than GRFListCompatibility::Compatible).
@ AllGood
All GRF needed by game are present.
@ Compatible
Compatible (eg. the same ID, but different checksum) GRF found in at least one case.
@ NotFound
GRF file was not found in the local cache.
@ Compatible
GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches).
Header file for NewGRF stations.
Functions related to news.
void DeleteInvalidEngineNews()
Remove engine announcements for invalid engines.
Map accessors for object tiles.
uint16_t ObjectType
Types of objects.
static const ObjectType OBJECT_STATUE
Statue in towns.
static const ObjectType OBJECT_HQ
HeadQuarter of a player.
@ Error
A game paused because a (critical) error.
@ ActiveClients
A game paused for 'min_active_clients'.
@ Normal
A game normally paused.
@ Join
A game paused for 'pause_on_join'.
EnumBitSet< PauseMode, uint8_t > PauseModes
Bitset of PauseMode elements.
Functions related to order backups.
OrderUnloadType
Unloading order types.
@ Transfer
Transfer all cargo onto the platform.
@ FarEnd
Stop at the far end of the platform.
@ NonStop
The vehicle will not stop at any stations it passes except the destination, aka non-stop.
EnumBitSet< OrderDepotActionFlag, uint8_t > OrderDepotActionFlags
Bitset of OrderDepotActionFlag elements.
@ NoLoad
Do not load anything.
RailTypes GetCompanyRailTypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
void InitializeSignalGui()
Resets the signal GUI.
static bool IsPlainRail(Tile t)
Returns whether this is plain rails, with or without signals.
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
static bool IsRailDepot(Tile t)
Is this rail tile a rail depot?
RailGroundType GetRailGroundType(Tile t)
Get the ground type for rail tiles.
static bool IsPlainRailTile(Tile t)
Checks whether the tile is a rail tile or rail tile with signals.
void MakeRailNormal(Tile t, Owner o, TrackBits b, RailType r)
Make the given tile a normal rail.
void SetTrackReservation(Tile t, TrackBits b)
Sets the reserved track bits of the tile.
@ HalfTileWater
Grass with a fence and shore or water on the free halftile.
void SetDepotReservation(Tile t, bool b)
Set the reservation state of the depot.
bool HasSignals(Tile t)
Checks if a rail tile has signals.
void SetSignalVariant(Tile t, Track track, SignalVariant v)
Set the signal variant for a track on a tile.
static bool IsRailDepotTile(Tile t)
Is this tile rail tile and a rail depot?
void SetSignalStates(Tile tile, uint state)
Set the states of the signals (Along/AgainstTrackDir).
void SetRailType(Tile t, RailType r)
Sets the rail type of the given tile.
EnumBitSet< RailType, uint64_t > RailTypes
Bitset of RailType elements.
RailType
Enumeration for all possible railtypes.
@ RAILTYPE_ELECTRIC
Electric rails.
@ RAILTYPE_RAIL
Standard non-electric rails.
Randomizer _random
Random used in the game state calculations.
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
void UpdateNearestTownForRoadTiles(bool invalidate)
Updates cached nearest town for all road tiles.
RoadBits AxisToRoadBits(Axis a)
Create the road-part which belongs to the given Axis.
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 SetRoadOwner(Tile t, RoadTramType rtt, Owner o)
Set the owner of a specific road type.
static RoadTileType GetRoadTileType(Tile t)
Get the type of the road tile.
bool HasTownOwnedRoad(Tile t)
Checks if given tile has town owned road.
bool IsLevelCrossingTile(Tile t)
Return whether a tile is a level crossing tile.
void SetRoadTypes(Tile t, RoadType road_rt, RoadType tram_rt)
Set the present road types of a tile.
static bool IsRoadDepot(Tile t)
Return whether a tile is a road depot.
@ Depot
Depot (one entrance).
@ Crossing
Level crossing.
RoadBits GetCrossingRoadBits(Tile tile)
Get the road bits of a level crossing.
Owner GetRoadOwner(Tile t, RoadTramType rtt)
Get the owner of a specific road type.
void SetCrossingReservation(Tile t, bool b)
Set the reservation state of the rail crossing.
bool IsLevelCrossing(Tile t)
Return whether a tile is a level crossing.
EnumBitSet< RoadBit, uint8_t > RoadBits
Bitset of RoadBit elements.
static constexpr RoadTramTypes ROADTRAMTYPES_ALL
All possible RoadTramTypes.
RoadType
The different roadtypes we support.
@ INVALID_ROADTYPE
flag for invalid roadtype
@ ROADTYPE_ROAD
Basic road type.
RoadTramType
The different types of road type.
Base class for roadstops.
@ RVS_ENTERED_STOP
Only set when a vehicle has entered the stop.
@ RVSB_IN_ROAD_STOP
The vehicle is in a road stop.
@ RVS_IN_DT_ROAD_STOP
The vehicle is in a drive-through road stop.
@ RVS_IN_ROAD_STOP
The vehicle is in a road stop.
@ RVSB_IN_DEPOT
The vehicle is in a depot.
@ RVSB_WORMHOLE
The vehicle is in a tunnel and/or bridge.
@ RVS_DRIVE_SIDE
Only used when retrieving move data.
static const uint RVC_DRIVE_THROUGH_STOP_FRAME
Stop frame for a vehicle in a drive-through stop.
Command definitions related to road vehicles.
const uint8_t _road_stop_stop_frame[]
Table of road stop stop frames, when to stop at a road stop.
A number of safeguards to prevent using unsafe methods.
void SlError(StringID string, const std::string &extra_msg)
Error handler.
void SetSaveLoadError(StringID str)
Set the error message from outside of the actual loading/saving of the game (AfterLoadGame and friend...
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
@ LastLoadingTick
Saveload version: 301, GitHub pull request: 9693 Store tick of last loading for vehicles.
@ LargerTownCargoStatistics
Saveload version: 9.0, SVN revision: 1909 Increase size of passenger/mail production of this and pre...
@ BigDates
Saveload version: 31, SVN revision: 5999 Change date from 1920 - 2090 to 0 - 5 000 000.
@ IncreaseHouseLimit
Saveload version: 348, GitHub pull request: 12288 Increase house limit to 4096.
@ CustomSeaLevel
Saveload version: 149, SVN revision: 20832 Setting to influence the sea level (amount of water).
@ StoreIndustryCargo
Saveload version: 78, SVN revision: 11176 Store an industry's cargo, so it can be customised upon bu...
@ MoreEngineTypes
Saveload version: 95, SVN revision: 12924 Allow more than the original 255 engine types.
@ TrainSlopeSteepness
Saveload version: 133, SVN revision: 18674 Setting to increase steepness of slopes for trains under ...
@ FractionProfitRunningTicks
Saveload version: 88, SVN revision: 12134 Store vehicle profits as a (fixed point) fraction,...
@ UnifyWaypointAndStation
Saveload version: 123, SVN revision: 16909 Unify stations and waypoints.
@ InfrastructureMaintenanceCosts
Saveload version: 166, SVN revision: 23415 Infrastructure can now cost some periodic fee.
@ VehicleEconomyAge
Saveload version: 334, GitHub pull request: 12141, release: 14.0 Add vehicle age in economy year,...
@ GroupReplaceWagonRemoval
Saveload version: 291, GitHub pull request: 7441 Per-group wagon removal flag.
@ PauseModes
Saveload version: 119, SVN revision: 16242 Use bitmask of reason to pause, so manual/auto pausing do...
@ ImproveMultistop
Saveload version: 25, SVN revision: 4259 Improve the behaviour of RVs going to road stops.
@ MonthlyBankruptcyCheck
Saveload version: 177, SVN revision: 24619 Check for bankruptcy on a monthly cycle.
@ CompanyInauguratedPeriodV2
Saveload version: 349, GitHub pull request: 13448 Fix savegame storage for company inaugurated year ...
@ GoalProgressPlaneAcceleration
Saveload version: 182, SVN revision: 25115, r25259, r25296 Goal status and plane acceleration fixes.
@ CountPaidForCargo
Saveload version: 45, SVN revision: 8501 Count the amount of cargo that was paid for.
@ EndingYear
Saveload version: 218, GitHub pull request: 7747, release: 1.10 Configurable ending year.
@ FifoLoading
Saveload version: 57, SVN revision: 9691 First-in-first-out loading of vehicles.
@ LargerTownIterator
Saveload version: 11.0, SVN revision: 2033 Increase size of the town iterator.
@ FreeformEdges
Saveload version: 111, SVN revision: 15190 Allow terraforming along the edge of the map.
@ UnifyAnimationState
Saveload version: 43, SVN revision: 7642 Put all animation state information in same map bits.
@ MoveSemaphoreBits
Saveload version: 15.0, SVN revision: 2499 Move rail signal bit for semaphores.
@ ReplaceCustomNameArray
Saveload version: 84, SVN revision: 11822 Replace single fixed size array of custom names,...
@ IncreaseStationTypeFieldSize
Saveload version: 337, GitHub pull request: 12572 Increase size of StationType field in map array.
@ WaterClass
Saveload version: 86, SVN revision: 12042 Store the type of water (sea/ocean, canal,...
@ LastVehicleType
Saveload version: 26, SVN revision: 4466 Store the last vehicle type at stations instead of the vehi...
@ RoadLayoutPerTown
Saveload version: 113, SVN revision: 15340 Allow for different road layouts for each of the towns.
@ SplitStationTypeFromGfxid
Saveload version: 72, SVN revision: 10601 Splits the encoding of station type from the graphics iden...
@ NewGRFSuppliedStationName
Saveload version: 103, SVN revision: 14598 NewGRF industry supplying default names for nearby statio...
@ MaxLengthAndReverseSignals
Saveload version: 159, SVN revision: 21962 Settings for reversing at signals, and maximum train,...
@ ObjectTypeToPool
Saveload version: 186, SVN revision: 25833 Move object type from map to pool object.
@ MultipleSignalTypes
Saveload version: 64, SVN revision: 10006 Multiple different signal types on the same (diagonal) til...
@ SimplifyPlayerFace
Saveload version: 49, SVN revision: 8969 Simplify the storage of player face information.
@ VehicleCurrencyStationChanges
Saveload version: 2.0, release: 0.3.0 Adding vehicle state, larger currency size for statistics,...
@ TownTolerancePauseMode
Saveload version: 4.0, SVN revision: 1 Town council tolerance and pause mode.
@ RoadTypes
Saveload version: 214, GitHub pull request: 6811 NewGRF road types.
@ AircraftSpeedHolding
Saveload version: 50, SVN revision: 8973 Aircraft speed in km-ish/h and reduced speed in holding pat...
@ MaxLoanForCompany
Saveload version: 330, GitHub pull request: 11224 Separate max loan for each company.
@ TrackRealAndAutoOrders
Saveload version: 158, SVN revision: 21933 Track which real and auto order is the current order.
@ VehicleCentreAndZPos
Saveload version: 164, SVN revision: 23290 Vehicle centres are not fixed at 4/8 of the vehicle; chan...
@ VirtualFeederSharePayment
Saveload version: 134, SVN revision: 18703 Pay a part of the virtual profit during a transfer to the...
@ SimplifyPathfinderSettings
Saveload version: 87, SVN revision: 12129 Make it easier to select the pathfinder to use.
@ EconomyModeTimekeepingUnits
Saveload version: 327, GitHub pull request: 11341 Mode to display economy measurements in wallclock ...
@ DriveBackwards
Saveload version: 365, GitHub pull request: 15379 Trains can drive backwards.
@ MultipleRoadTypes
Saveload version: 61, SVN revision: 9892 Multiple road types for the same tile.
@ MultitileDocks
Saveload version: 216, GitHub pull request: 7380 Multiple docks per station.
@ RailTrackTypeUnification
Saveload version: 48, SVN revision: 8935 Put all the rail track type information in same map bits.
@ AnimatedTileStateInMap
Saveload version: 347, GitHub pull request: 13082 Animated tile state saved for improved performance...
@ NewGRFIndustryRandomTriggers
Saveload version: 82, SVN revision: 11410 NewGRF random triggers for industries.
@ NewGRFLastService
Saveload version: 317, GitHub pull request: 11124 Added stable date_of_last_service to avoid NewGRF ...
@ LinkgraphSeconds
Saveload version: 308, GitHub pull request: 10610 Store linkgraph update intervals in seconds instea...
@ DisableTownLevelCrossing
Saveload version: 143, SVN revision: 20048 Setting to be able to disable building rail/road crossing...
@ ShipAcceleration
Saveload version: 329, GitHub pull request: 10734 Start using Vehicle's acceleration field for ships...
@ MaximumDepotPenalty
Saveload version: 131, SVN revision: 18481 Add configurable maximum pathfinder penalty for finding a...
@ NewGRFPersistentStorage
Saveload version: 76, SVN revision: 11139 Persistently store some state of NewGRF objects/entities.
@ TownAcceptance
Saveload version: 127, SVN revision: 17439 Store mask of cargos accepted by town houses and head qua...
@ MoreCargoPackets
Saveload version: 69, SVN revision: 10319 Allow more than ~65k cargo packets.
@ FixTreeGround
Saveload version: 81, SVN revision: 11244 Various fixes to improve the visuals of the ground under t...
@ SeparateOrderTravelWaitTime
Saveload version: 190, SVN revision: 26547 Separate order travel and wait times.
@ AirportAnimationFrames
Saveload version: 137, SVN revision: 18912 Use animation frames instead of many airport tile ids for...
@ IndustryManagement
Saveload version: 152, SVN revision: 21171 Manage the amount of industries that ought to be spawned ...
@ NewGRFHouses
Saveload version: 53, SVN revision: 9316 NewGRF controlled houses.
@ FoundTown
Saveload version: 128, SVN revision: 18281 Founding of new towns.
@ NonfloodingWaterTiles
Saveload version: 345, GitHub pull request: 13013 Store water tile non-flooding state.
@ RefitOrders
Saveload version: 36, SVN revision: 6624 Vehicles can be refitted as part of an order.
@ ExtendIndustryCargoSlots
Saveload version: 202, GitHub pull request: 6867 Increase industry cargo slots to 16 in,...
@ RemoveSubsidyStationBinding
Saveload version: 125, SVN revision: 17113 Awarded subsidies are not bound to stations,...
@ ImprovedOrders
Saveload version: 93, SVN revision: 12648 Orders support all full load/non stop types at the same ti...
@ DisableElrailSetting
Saveload version: 38, SVN revision: 7195 Add setting to disable electrified rails.
@ AIStartDate
Saveload version: 309, GitHub pull request: 10653 Removal of individual AI start dates and added a g...
@ StoreAirportSize
Saveload version: 140, SVN revision: 19382 Store the size of the airport in the station.
@ StoreWaypointIdInMap
Saveload version: 17.0, SVN revision: 3212 Store the ID of waypoints in m2 of the map.
@ BuoysAt0_0
Saveload version: 364, GitHub pull request: 14983 Allow to build buoys at (0x0).
@ PlatformStopLocation
Saveload version: 117, SVN revision: 16037 Set the platform stop location via train orders.
@ SeparateRoadOwners
Saveload version: 114, SVN revision: 15601 Separate owners for road bits, tram bits and the road sto...
@ MoreCompanies
Saveload version: 104, SVN revision: 14735 Increase maximum number of companies to 15.
@ NewGRFPalette
Saveload version: 101, SVN revision: 14233 Store palette used by each of the NewGRFs.
@ MultipleRoadStops
Saveload version: 6.0, SVN revision: 1721 Multi tile road stops, and some map size related fixes.
@ SavegameId
Saveload version: 313, GitHub pull request: 10719 Add an unique ID to every savegame (used to dedupl...
@ UnifyAnimationFrame
Saveload version: 147, SVN revision: 20621 Unify location of animation frame.
@ AutoreplaceWhenOldTreeLimit
Saveload version: 175, SVN revision: 24136 Autoreplace vehicle only when they are old,...
@ CargoPayments
Saveload version: 121, SVN revision: 16694 Perform payment of cargo after unloading.
@ MultitrackLevelCrossings
Saveload version: 302, GitHub pull request: 9931, release: 13.0 Multi-track level crossings.
@ PlaneSpeedFactor
Saveload version: 90, SVN revision: 12293 Setting to increase aircraft speed to be on par with the o...
@ StationsUnderBridges
Saveload version: 359, GitHub pull request: 14477 Allow stations under bridges.
@ CumulatedInflation
Saveload version: 126, SVN revision: 17433 Store cumulated inflation, and recalculate prices/payment...
@ TownCargogen
Saveload version: 208, GitHub pull request: 6965 New algorithms for town building cargo generation.
@ DisallowRoadReconstruction
Saveload version: 160, SVN revision: 21974, release: 1.1.x Setting to disallow road reconstruction.
@ Cargodist
Saveload version: 183, SVN revision: 25363 Cargodist.
@ Elrail
Saveload version: 24, SVN revision: 4150 Electrified railways.
@ CompanyServiceIntervals
Saveload version: 120, SVN revision: 16439 Make service intervals configurable per company.
@ MoreAirportBlocks
Saveload version: 46, SVN revision: 8705 Increase number of blocks an airport can have.
@ ReducePlaneCrashes
Saveload version: 138, SVN revision: 18942, release: 1.0.x Setting to reduce/disable crashing of pla...
@ RocksStayUnderSnow
Saveload version: 135, SVN revision: 18719 Rocks stay under snow, i.e. they return when the snow goe...
@ MinVersion
First savegame version.
@ EconomyDate
Saveload version: 326, GitHub pull request: 10700 Split calendar and economy timers and dates.
@ OrderMaxSpeed
Saveload version: 172, SVN revision: 23947 Set maximum speed for orders.
@ MoreHouseAnimationFrames
Saveload version: 91, SVN revision: 12347 Increase number of animation frames for NewGRF houses.
@ WaypointMoreLikeStation
Saveload version: 122, SVN revision: 16855 Make waypoint data look more like stations.
@ ExtendRailtypes
Saveload version: 200, GitHub pull request: 6805 Extend railtypes to 64, adding uint16_t to map arra...
@ VeryLowTownIndustryNumber
Saveload version: 58, SVN revision: 9762 Difficulty settings for very low number of industries and t...
@ ProtectPlacedHouses
Saveload version: 351, GitHub pull request: 13270 Houses individually placed by players can be prote...
@ SplitLoadWaitCounters
Saveload version: 136, SVN revision: 18764 Split counters for (un)loading and signal waiting/turning...
@ LeaveRoadStopSeparately
Saveload version: 153, SVN revision: 21263 Fix issue where multiple vehicles could leave a road stop...
@ StatueOwner
Saveload version: 52, SVN revision: 9066 Store the owner of the statue, so the town can be informed ...
@ SplitHQ
Saveload version: 112, SVN revision: 15290 Split the behaviour of headquarters from the other unmova...
@ UniqueDepotNames
Saveload version: 141, SVN revision: 19799 Give depots unique names.
@ DepotWaterOwners
Saveload version: 83, SVN revision: 11589 Store the owner of the water under depots,...
@ EngineRenew
Saveload version: 16.0, SVN revision: 2817 Automatic replacing/renewing of vehicles.
@ TownGrowthInGameTicks
Saveload version: 198, GitHub pull request: 6763 Switch town growth rate and counter to actual game ...
@ DepotUnbunching
Saveload version: 331, GitHub pull request: 11945 Allow unbunching shared order vehicles at a depot.
@ ShipsStopInLocks
Saveload version: 206, GitHub pull request: 7150 Ship/lock movement changes.
@ IndustryTileWaterClass
Saveload version: 99, SVN revision: 13838 Add water classes to industry tiles.
@ ScriptRandomizer
Saveload version: 333, GitHub pull request: 12063, release: 14.0-RC1 Save script randomizers.
@ RepairObjectDockingTiles
Saveload version: 299, GitHub pull request: 9594, release: 12.0 Fixing issue with docking tiles over...
@ RemoveOldPbs
Saveload version: 21, SVN revision: 3472, release: 0.4.x Remove old implementation of path based sig...
@ NewGRFDepotBuildDate
Saveload version: 142, SVN revision: 20003 Depot build date for NewGRFs.
@ NewGRFAirportSmoke
Saveload version: 145, SVN revision: 20376 NewGRF support for airport and configurable amount of smo...
@ FixStationPickupAccounting
Saveload version: 74, SVN revision: 11030 Accounting of which cargos a station would pick up was don...
@ DistantStationJoining
Saveload version: 106, SVN revision: 14919 Distant joining of stations.
@ VelocityNautical
Saveload version: 305, GitHub pull request: 10594 Separation of land and nautical velocity (knots!...
@ CalendarSubDateFract
Saveload version: 328, GitHub pull request: 11428 Add sub_date_fract to measure calendar days.
@ Liveries
Saveload version: 34, SVN revision: 6455 Liveries and two company colours (2cc).
@ GroupNumbers
Saveload version: 336, GitHub pull request: 12297 Add per-company group numbers.
@ RvRealisticAcceleration
Saveload version: 139, SVN revision: 19346 Realistic acceleration of road vehicles.
@ ServeNeutralIndustries
Saveload version: 210, GitHub pull request: 7234 Company stations can serve industries with attached...
@ ReorderUnmovableRemoveReserved
Saveload version: 144, SVN revision: 20334 Reorder map bits of unmovable tiles and remove unused res...
@ Yapp
Saveload version: 100, SVN revision: 13952 New version of path based signals.
@ MultiTileWaypoints
Saveload version: 124, SVN revision: 16993 Waypoints can be bigger than a single tile.
@ FaceStyles
Saveload version: 355, GitHub pull request: 14319 Addition of face styles, replacing gender and ethn...
@ TerraformLimits
Saveload version: 156, SVN revision: 21728 Introduce limits for terraforming and clearing times.
@ SeparateLocaleUnits
Saveload version: 184, SVN revision: 25508 Unit localisation split.
@ TreesWaterClass
Saveload version: 213, GitHub pull request: 7405 WaterClass update for tree tiles.
@ AdjacentStations
Saveload version: 62, SVN revision: 9905 Allow building multiple stations directly next to eachother...
@ UnifyRvTravelTime
Saveload version: 188, SVN revision: 26169, release: 1.4 Unify RV travel time.
@ MaxBridgeMapHeight
Saveload version: 194, SVN revision: 26881, release: 1.5 Setting for maximum bridge and map height.
@ ScriptSaveInstances
Saveload version: 352, GitHub pull request: 13556 Scripts are allowed to save instances.
@ IndustryPlatform
Saveload version: 148, SVN revision: 20659 Setting to make a flat area around (new) industries.
@ ScriptTownGrowth
Saveload version: 165, SVN revision: 23304 Storage of cargo statistics for use by game scripts.
@ FixCompanyCargoTypes
Saveload version: 94, SVN revision: 12816 The company's cargo types should have increased in since w...
@ Gamelog
Saveload version: 98, SVN revision: 13375 Logging of important actions/situations in the save.
@ PersistentStoragePool
Saveload version: 161, SVN revision: 22567 Store persistent storage in a pool.
@ TownLayout
Saveload version: 59, SVN revision: 9779 More layout options for towns.
@ UnifyWaterClass
Saveload version: 146, SVN revision: 20446 Unify location for storing water class in the map.
@ Cities
Saveload version: 56, SVN revision: 9667 Cities that start bigger and grow faster.
@ AirportNoise
Saveload version: 96, SVN revision: 13226 Introduce noise for airports, to allow more than two airpo...
@ CargoPaymentOverflow
Saveload version: 70, SVN revision: 10541 Fix overflow of cargo payment rates, plus preparation for ...
@ WaterTileType
Saveload version: 342, GitHub pull request: 13030 Simplify water tile type.
@ FixOrderBackup
Saveload version: 192, SVN revision: 26700 Fix saving of order backups.
@ BridgeWormhole
Saveload version: 42, SVN revision: 7573 Bridges become wormholes, so more things can be built under...
@ GSIndustryControl
Saveload version: 287, GitHub pull request: 7912 and 8115 GS industry control.
@ LinkFarmFieldToIndustry
Saveload version: 32, SVN revision: 6001 Link farm fields to the industry, so it gets removed when t...
@ ConsistentPartialZ
Saveload version: 306, GitHub pull request: 10570 Conversion from an inconsistent partial Z calculat...
bool IsSavegameVersionBeforeOrAt(SaveLoadVersion major)
Checks whether the savegame is below or at major.
Declaration of functions used in more save/load files.
void AfterLoadVehiclesPhase1(bool part_of_load)
Called after load for phase 1 of vehicle initialisation.
void ResetOldNames()
Free the memory of the old names array.
void FixupTrainLengths()
Fixup old train spacing.
void MoveBuoysToWaypoints()
Perform all steps to upgrade from the old station buoys to the new version that uses waypoints.
void UpdateOldAircraft()
need to be called to load aircraft from old version
void ConvertOldMultiheadToNew()
Converts all trains to the new subtype format introduced in savegame 16.2 It also links multiheaded e...
void ConnectMultiheadedTrains()
Link front and rear multiheaded engines to each other This is done when loading a savegame.
void AfterLoadRoadStops()
(Re)building of road stop caches after loading a savegame.
void MoveWaypointsToBaseStations()
Perform all steps to upgrade from the old waypoints to the new version that uses station.
void AfterLoadVehiclesPhase2(bool part_of_load)
Called after load for phase 2 of vehicle initialisation.
void UpdateHousesAndTowns()
Check and update town and house values.
std::string CopyFromOldName(StringID id)
Copy and convert old custom names to UTF-8.
void AfterLoadStoryBook()
Called after load to trash broken pages.
void ShowScriptDebugWindowIfScriptError()
Open the AI debug window if one of the AI scripts has crashed.
Window for configuring the scripts.
VehicleDefaultSettings _old_vds
Used for loading default vehicles settings from old savegames.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
ClientSettings _settings_client
The current settings for this game.
IndustryDensity
Available industry map generation densities.
@ FundedOnly
The game does not build industries.
@ EndOfLineOnly
Trains can only flip when the track ends.
@ All
Trains can flip anywhere.
@ Right
Drive on the right side.
@ Combo
presignal inter-block.
@ Semaphore
Old-fashioned semaphore signal.
void UpdateAllSignVirtCoords()
Update the coordinates of all signs.
Functions related to signs.
DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
void BuildOwnerLegend()
Completes the array for the owned property legend.
@ Industry
Source/destination is an industry.
@ Town
Source/destination is a town.
Base classes/functions for stations.
void UpdateAllStationVirtCoords()
Update the virtual coords needed to draw the station sign for all stations.
void UpdateAirportsNoise()
Recalculate the noise generated by the airports of each town.
void UpdateStationAcceptance(Station *st, bool show_msg)
Update the acceptance for a station.
StationType GetStationType(Tile t)
Get the station type of this tile.
StationGfx GetStationGfx(Tile t)
Get the station graphics of this tile.
void SetStationGfx(Tile t, StationGfx gfx)
Set the station graphics of this tile.
bool IsAirportTile(Tile t)
Is this tile a station tile and an airport tile?
bool IsBayRoadStopTile(Tile t)
Is tile t a bay (non-drive through) road stop station?
bool IsRailWaypointTile(Tile t)
Is this tile a station tile and a rail waypoint?
bool IsBuoy(Tile t)
Is tile t a buoy tile?
bool IsDriveThroughStopTile(Tile t)
Is tile t a drive through road stop station or waypoint?
bool HasStationTileRail(Tile t)
Has this station tile a rail?
uint GetCustomStationSpecIndex(Tile t)
Get the custom station spec for this tile.
void SetRailStationReservation(Tile t, bool b)
Set the reservation state of the rail station.
bool IsAnyRoadStop(Tile t)
Is the station at t a road station?
bool IsStationTileBlocked(Tile t)
Is tile t a blocked tile?
bool IsTruckStop(Tile t)
Is the station at t a truck stop?
bool IsStationRoadStop(Tile t)
Is the station at t a road station?
bool HasStationRail(Tile t)
Has this station tile a rail?
static const int GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET
The offset for the drive through parts.
bool IsOilRig(Tile t)
Is tile t part of an oilrig?
bool IsBuoyTile(Tile t)
Is tile t a buoy tile?
bool IsDock(Tile t)
Is tile t a dock tile?
@ Dock
Station with a dock.
@ Train
Station with train station.
@ Airport
Station with an airport.
StationType
Station types.
@ Rail
Railways/train station.
@ Bus
Road stop for busses.
@ Truck
Road stop for trucks.
@ Buoy
Waypoint for ships.
@ Oilrig
Heliport on an oil rig.
@ Airport
Airports and heliports, excluding the ones on oil rigs.
Definition of base types and functions in a cross-platform compatible way.
std::string FormatArrayAsHex(std::span< const uint8_t > data)
Format a byte array into a continuous hex string.
Functions related to low-level strings.
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
Functions related to OTTD's strings.
static constexpr StringID SPECSTR_PRESIDENT_NAME
Special string for the president's name.
static constexpr StringID SPECSTR_TOWNNAME_START
Special strings for town names.
Information about a aircraft vehicle.
Aircraft, helicopters, rotors and their shadows belong to this class.
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
Base class for all station-ish types.
TileArea train_station
Tile area the train 'station' part covers.
Owner owner
The owner of this station.
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
Town * town
The town this station is associated with.
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
VehicleType type
Type of vehicle.
static void AfterLoad()
Savegame conversion for cargopackets.
Helper class to perform the cargo payment.
Specification of a cargo type.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo type.
TownAcceptanceEffect town_acceptance_effect
The effect that delivering this cargo type has on towns. Also affects destination of subsidies.
Structure to return information about the closest depot location, and whether it could be found.
CompanySettings settings
settings specific for each company
static bool IsValidAiID(auto index)
Is this company a valid company, controlled by the computer (a NoAI program)?
Disasters, like submarines, skyrangers and their shadows, belong to this class.
Basic data to distinguish a GRF.
MD5Hash md5sum
MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF).
Stores station stats for a single cargo.
uint8_t last_speed
Maximum speed (up to 255) of the last vehicle that tried to load this cargo.
States status
Status of this cargo, see State.
@ Rating
This indicates whether a cargo has a rating at the station.
uint AvailableCount() const
Returns sum of cargo still available for loading at the station.
GroundVehicleFlags gv_flags
static void UpdateAfterLoad()
Update all caches after loading a game, changing NewGRF, etc.
static HouseSpec * Get(size_t house_id)
Get the spec for a house ID.
HouseExtraFlags extra_flags
some more flags
Defines the data structure for constructing industry.
std::array< CargoType, INDUSTRY_NUM_INPUTS > accepts_cargo
16 accepted cargoes.
IndustryBehaviours behaviour
How this industry will behave, and how others entities can use it.
Defines the internal data of a functional industry.
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
static uint SizeX()
Get the size of the map along the X.
static uint SizeY()
Get the size of the map along the Y.
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
static uint MaxY()
Gets the maximum Y coordinate within the map, including TileType::Void.
static uint MaxX()
Gets the maximum X coordinate within the map, including TileType::Void.
An object, such as transmitter, on the map.
ObjectType type
Type of the object.
Town * town
Town the object is built in.
static void IncTypeCount(ObjectType type)
Increment the count of objects for this type.
TimerGameCalendar::Date build_date
Date of construction.
TileArea location
Location of the object.
Data for backing up an order of a vehicle so it can be restored after a vehicle is rebuilt in the sam...
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
If you change this, keep in mind that it is also saved in 2 other places:
bool IsType(OrderType type) const
Check whether this order is of the given type.
uint16_t w
The width of the area.
TileIndex tile
The base tile of the area.
uint16_t h
The height of the area.
static Pool::IterateWrapper< Town > Iterate(size_t from=0)
static T * Create(Targs &&... args)
static Town * Get(auto index)
static size_t GetNumItems()
static bool CanAllocateItem(size_t n=1)
static bool IsValidID(auto index)
static Company * GetIfValid(auto index)
static constexpr size_t MAX_SIZE
A Stop for a Road Vehicle.
Buses, trucks and trams belong to this class.
RoadType roadtype
NOSAVE: Roadtype of this vehicle.
All ships have this type.
static bool IsExpected(const BaseStation *st)
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
static Station * Get(auto index)
static Station * GetIfValid(auto index)
static Station * From(BaseStation *st)
T * Next() const
Get next vehicle in the chain.
static Train * From(Vehicle *v)
RoadStop * bus_stops
All the road stops.
static void RecomputeCatchmentForAll()
Recomputes catchment of all stations.
RoadStop * truck_stops
All the truck stops.
Struct about subsidies, offered and awarded.
TrackdirBits trackdirs
Trackdirs present on the tile.
'Train' is either a loco or a wagon.
TrackBits track
On which track the train currently is.
VehicleRailFlags flags
Which flags has this train currently set.
Default settings for vehicles.
CargoPayment * cargo_payment
The cargo payment we're currently in.
Direction direction
facing
VehStates vehstatus
Status.
Order current_order
The current order (+ status, like: loading).
int32_t y_pos
y coordinate.
int32_t x_pos
x coordinate.
TileIndex tile
Current tile index.
Owner owner
Which company owns the vehicle?
Representation of a waypoint.
void RebuildSubsidisedSourceAndDestinationCache()
Perform a full rebuild of the subsidies cache.
Functions related to subsidies.
bool MayAnimateTile(TileIndex tile)
Test if a tile may be animated.
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.
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
uint TileHash(uint x, uint y)
Calculate a hash value from a tile position.
static uint TileHeight(Tile tile)
Returns the height of a tile.
bool IsTileOwner(Tile tile, Owner owner)
Checks if a tile belongs to the given owner.
void SetTileType(Tile tile, TileType type)
Set the type of a tile.
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
void SetTileOwner(Tile tile, Owner owner)
Sets the owner of a tile.
int GetTileMaxPixelZ(TileIndex tile)
Get top height of the tile.
void SetAnimationFrame(Tile t, uint8_t frame)
Set a new animation frame.
Slope GetTileSlope(TileIndex tile)
Return the slope of a given tile inside the map.
void SetTropicZone(Tile tile, TropicZone type)
Set the tropic zone.
static TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
static constexpr uint TILE_UNIT_MASK
For masking in/out the inner-tile world coordinate units.
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.
@ Normal
Normal tropiczone.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
static constexpr uint TILE_SIZE
Tile size in world coordinates.
static constexpr uint MIN_SNOWLINE_HEIGHT
Minimum snowline height.
static constexpr uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in ZOOM_BASE.
@ TunnelBridge
Tunnel entry/exit and bridge heads.
@ Station
A tile of a station or airport.
@ Object
Contains objects such as transmitters and owned land.
@ Industry
Part of an industry.
@ Railway
A tile with railway.
@ Void
Invisible tiles at the SW and SE border.
@ Trees
Tile with one or more trees.
@ House
A house by a town.
@ Road
A tile with road and/or tram tracks.
@ Clear
A tile without any structures, i.e. grass, rocks, farm fields etc.
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.
static const uint TOWN_GROWTH_WINTER
The town only needs this cargo in the winter (any amount).
const CargoSpec * FindFirstCargoWithTownAcceptanceEffect(TownAcceptanceEffect effect)
Determines the first cargo with a certain town effect.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
static const uint TOWN_GROWTH_DESERT
The town needs the cargo for growth when on desert (any amount).
void UpdateTownMaxPass(Town *t)
Update the maximum amount of monthly passengers and mail for a town, based on its population.
void ClearAllTownCachedNames()
Clear the cached_name of all towns.
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
@ CustomGrowth
Growth rate is controlled by GS.
static const uint16_t TOWN_GROWTH_RATE_NONE
Special value for Town::growth_rate to disable town growth.
void MakeDefaultName(T *obj)
Set the default name for a depot/waypoint.
void UpdateAllTownVirtCoords()
Update the virtual coords needed to draw the town sign for all towns.
HouseID GetHouseType(Tile t)
Get the type of this house, which is an index into the house spec array.
void SetHouseType(Tile t, HouseID house_id)
Set the house type.
void SetLiftPosition(Tile t, uint8_t pos)
Set the position of the lift on this animated house.
void SetHouseCompleted(Tile t, bool status)
Mark this house as been completed.
void SetHouseProtected(Tile t, bool house_protected)
Set a house as protected from removal by towns.
void SetTownIndex(Tile t, TownID index)
Set the town index for a road or house tile.
bool IsHouseCompleted(Tile t)
Get the completion of this house.
static constexpr int RATING_INITIAL
initial rating
@ Original
Original algorithm (quadratic cargo by population).
@ Random
Random town layout.
@ BetterRoads
Extended original algorithm (min. 2 distance between roads).
Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
Track AxisToTrack(Axis a)
Convert an Axis to the corresponding Track Axis::X -> Track::X Axis::Y -> Track::Y Uses the fact that...
Track DiagDirToDiagTrack(DiagDirection diagdir)
Maps a DiagDirection to the associated diagonal Track.
TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
Discards all directional information from a TrackdirBits value.
EnumBitSet< Track, uint8_t > TrackBits
Bitset of Track elements.
@ X
Track along the x-axis (north-east to south-west).
@ Upper
Track in the upper corner of the tile (north).
@ Invalid
Flag for an invalid track.
@ Y
Track along the y-axis (north-west to south-east).
@ Depot
Special flag indicating a vehicle is inside a depot.
@ Lower
Track in the lower corner of the tile (south).
@ Wormhole
Special flag indicating vehicle is inside a bridge or tunnel.
Base for the train class.
void CheckTrainsLengths()
Checks if lengths of all rail vehicles are valid.
VehicleRailFlag
Rail vehicle flags.
@ TFP_NONE
Normal operation.
@ TFP_STUCK
Proceed till next signal, but ignore being stuck till then. This includes force leaving depots.
TransportType
Available types of transport.
@ Rail
Transport by train.
@ Road
Transport by road vehicle.
Map accessors for tree tiles.
TreeGround GetTreeGround(Tile t)
Returns the groundtype for tree tiles.
TreeGround
Enumeration for ground types of tiles with trees.
@ SnowOrDesert
Snow or desert, depending on landscape.
bool IsTunnelTile(Tile t)
Is this a tunnel (entrance)?
const DiagDirectionIndexArray< uint8_t > _tunnel_visibility_frame
Frame when a vehicle should be hidden in a tunnel with a certain direction.
Functions that have tunnels and bridges in common.
DiagDirection GetTunnelBridgeDirection(Tile t)
Get the direction pointing to the other end.
TransportType GetTunnelBridgeTransportType(Tile t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
TileIndex GetOtherTunnelBridgeEnd(Tile t)
Determines type of the wormhole and returns its other end.
void SetTunnelBridgeReservation(Tile t, bool b)
Set the reservation state of the rail tunnel/bridge.
@ Crashed
Vehicle is crashed.
@ Hidden
Vehicle is not visible.
EnumBitSet< VehState, uint8_t > VehStates
Bitset of VehState elements.
Functions related to vehicles.
@ Invalid
Non-existing type of vehicle.
@ Train
Train vehicle type.
@ Original
Original acceleration model.
EnumBitSet< GroundVehicleFlag, uint16_t > GroundVehicleFlags
Bitset of GroundVehicleFlag elements.
@ GoingUp
Vehicle is currently going uphill. (Cached track information for acceleration).
@ GoingDown
Vehicle is currently going downhill. (Cached track information for acceleration).
Functions related to (drawing on) viewports.
Declarations for accessing the k-d tree of viewports.
Map accessors for void tiles.
void MakeVoid(Tile t)
Make a nice void tile ;).
Functions related to water management.
void MakeShore(Tile t)
Helper function to make a coast tile.
void SetWaterClass(Tile t, WaterClass wc)
Set the water class at a tile.
bool IsShipDepot(Tile t)
Is it a water tile with a ship depot on it?
WaterClass
classes of water (for WaterTileType::Clear water tile type).
@ Invalid
Used for industry tiles on land (also for oilrig if newgrf says so).
bool IsShipDepotTile(Tile t)
Is it a ship depot tile?
bool IsCoast(Tile t)
Is it a coast tile?
WaterTileType GetWaterTileType(Tile t)
Get the water tile type of a tile.
void SetNonFloodingWaterTile(Tile t, bool b)
Set the non-flooding water tile state of a tile.
void SetWaterTileType(Tile t, WaterTileType type)
Set the water tile type of a tile.
WaterClass GetWaterClass(Tile t)
Get the water class at a tile.
void MakeCanal(Tile t, Owner o, uint8_t random_bits)
Make a canal tile.
TileIndex GetOtherShipDepotTile(Tile t)
Get the other tile of the ship depot.
void SetDockingTile(Tile t, bool b)
Set the docking tile state of a tile.
@ Middle
Middle part of a lock.
bool IsWater(Tile t)
Is it a plain water tile?
bool IsLock(Tile t)
Is there a lock on a given water tile?
void MakeSea(Tile t)
Make a sea tile.
LockPart GetLockPart(Tile t)
Get the part of a lock.
void ResetWindowSystem()
Reset the windowing system, by means of shutting it down followed by re-initialization.
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 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...
Window functions not directly related to making/drawing windows.
Entry point for OpenTTD to YAPF's cache.
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track)
Use this function to notify YAPF that track layout (or signal configuration) has change.