OpenTTD Source
1.11.0-beta2
|
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 "../date_func.h"
26 #include "../roadveh.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 "../ai/ai_gui.hpp"
44 #include "../economy_base.h"
45 #include "../animated_tile_func.h"
46 #include "../subsidy_base.h"
47 #include "../subsidy_func.h"
48 #include "../newgrf.h"
49 #include "../engine_func.h"
50 #include "../rail_gui.h"
51 #include "../core/backup_type.hpp"
52 #include "../smallmap_gui.h"
53 #include "../news_func.h"
54 #include "../order_backup.h"
56 #include "../disaster_vehicle.h"
65 #include "../safeguards.h"
84 if (include_invalid_water_class) {
101 bool has_water =
false;
102 bool has_canal =
false;
103 bool has_river =
false;
112 }
else if (!
IsLock(neighbour)) {
136 if (!has_water && !has_canal && !has_river && include_invalid_water_class) {
141 if (has_river && !has_canal) {
143 }
else if (has_canal || !has_water) {
150 static void ConvertTownOwner()
170 static void UpdateExclusiveRights()
186 static const byte convert_currency[] = {
195 static void UpdateCurrencies()
203 static void UpdateVoidTiles()
211 return rt >= min ? (
RailType)(rt + 1): rt;
222 RebuildViewportKdtree();
225 void ClearAllCachedNames()
227 ClearAllStationCachedNames();
228 ClearAllTownCachedNames();
229 ClearAllIndustryCachedNames();
248 ClearAllCachedNames();
250 ResetViewportAfterLoadGame();
268 if (i->psa !=
nullptr) {
269 i->psa->feature = GSF_INDUSTRIES;
270 i->psa->tile = i->location.tile;
274 if (s->airport.psa !=
nullptr) {
275 s->airport.psa->feature = GSF_AIRPORTS;
276 s->airport.psa->tile = s->airport.tile;
280 for (std::list<PersistentStorage *>::iterator it = t->psa_list.begin(); it != t->psa_list.end(); ++it) {
286 if (rv->IsFrontEngine()) {
310 typedef void (CDECL *SignalHandlerPointer)(int);
311 static SignalHandlerPointer _prev_segfault =
nullptr;
312 static SignalHandlerPointer _prev_abort =
nullptr;
313 static SignalHandlerPointer _prev_fpe =
nullptr;
333 signal(SIGSEGV, _prev_segfault);
334 signal(SIGABRT, _prev_abort);
335 signal(SIGFPE, _prev_fpe);
381 p +=
seprintf(p,
lastof(buffer),
"Loading your savegame caused OpenTTD to crash.\n");
389 "This is most likely caused by a missing NewGRF or a NewGRF that\n"
390 "has been loaded as replacement for a missing NewGRF. OpenTTD\n"
391 "cannot easily determine whether a replacement NewGRF is of a newer\n"
392 "or older version.\n"
393 "It will load a NewGRF with the same GRF ID as the missing NewGRF.\n"
394 "This means that if the author makes incompatible NewGRFs with the\n"
395 "same GRF ID OpenTTD cannot magically do the right thing. In most\n"
396 "cases OpenTTD will load the savegame and not crash, but this is an\n"
398 "Please load the savegame with the appropriate NewGRFs installed.\n"
399 "The missing/compatible NewGRFs are:\n");
406 p +=
seprintf(p,
lastof(buffer),
"NewGRF %08X (checksum %s) not found.\n Loaded NewGRF \"%s\" with same GRF ID instead.\n",
BSWAP32(c->ident.grfid), buf, c->filename);
411 p +=
seprintf(p,
lastof(buffer),
"NewGRF %08X (%s) not found; checksum %s.\n",
BSWAP32(c->ident.grfid), c->filename, buf);
416 "This is probably caused by a corruption in the savegame.\n"
417 "Please file a bug report and attach this savegame.\n");
422 SignalHandlerPointer call =
nullptr;
424 case SIGSEGV: call = _prev_segfault;
break;
425 case SIGABRT: call = _prev_abort;
break;
426 case SIGFPE: call = _prev_fpe;
break;
427 default: NOT_REACHED();
429 if (call !=
nullptr) call(signum);
478 _m[t].
m3 = (hasroad ? bits : 0);
480 SB(
_me[t].m6, 2, 4, 0);
498 int entry_x = v->
x_pos;
499 int entry_y = v->
y_pos;
506 default: NOT_REACHED();
508 byte entry_z = GetSlopePixelZ(entry_x, entry_y);
513 byte middle_z = GetSlopePixelZ(middle_x, middle_y);
516 if (middle_z == entry_z)
return 0;
550 if (_cur_tileloop_tile == 0) _cur_tileloop_tile = 1;
558 RebuildStationKdtree();
561 RebuildViewportKdtree();
568 DEBUG(net, 0,
"The loading savegame was paused due to an error state.");
569 DEBUG(net, 0,
" The savegame cannot be used for multiplayer!");
592 st->train_station.w = st->train_station.h = 0;
594 for (
TileIndex t = 0; t < map_size; t++) {
596 if (
_m[t].m5 > 7)
continue;
601 assert(dx >= 0 && dy >= 0);
611 for (
TileIndex t = 0; t < map_size; t++) {
613 SB(
_m[t].type, 0, 2,
GB(
_me[t].m6, 0, 2));
614 SB(
_me[t].m6, 0, 2, 0);
616 SB(
_m[t].type, 2, 2,
GB(
_me[t].m6, 6, 2));
617 SB(
_me[t].m6, 6, 2, 0);
619 SB(
_m[t].type, 2, 2, 0);
638 for (
TileIndex t = 0; t < map_size; t++) {
648 if (!c->name.empty()) c->name_1 = STR_SV_UNNAMED;
650 if (!c->president_name.empty()) c->president_name_1 = SPECSTR_PRESIDENT_NAME;
656 if (!st->name.empty()) st->string_id = STR_SV_STNAME_FALLBACK;
671 if (st->airport.tile == 0) st->airport.tile =
INVALID_TILE;
672 if (st->train_station.tile == 0) st->train_station.tile =
INVALID_TILE;
789 if (st->airport.tile !=
INVALID_TILE && st->airport.type == 15) {
801 if (c->is_ai && c->ai_instance ==
nullptr)
AI::StartNew(c->index);
831 cp->front->cargo_payment = cp;
832 cp->current_station = cp->front->last_station_visited;
853 st = STATION_AIRPORT;
861 }
else if (gfx == 75) {
867 }
else if (gfx == 82) {
871 st = STATION_AIRPORT;
884 SB(
_me[t].m6, 3, 3, st);
891 for (
TileIndex t = 0; t < map_size; t++) {
900 bst->
rect.BeforeAddTile(t, StationRect::ADD_FORCE);
929 case STATION_OILRIG: {
965 for (
TileIndex t = 0; t < map_size; t++) {
1001 c->engine_renew_list =
nullptr;
1002 c->settings.engine_renew =
false;
1003 c->settings.engine_renew_months = 6;
1004 c->settings.engine_renew_money = 100000;
1020 for (
TileIndex t = 0; t < map_size; t++) {
1026 uint tmp =
GB(
_m[t].m4, 0, 4);
1027 SB(
_m[t].m4, 0, 4,
GB(
_m[t].m2, 0, 4));
1028 SB(
_m[t].m2, 0, 4, tmp);
1050 for (
TileIndex t = 0; t < map_size; t++) {
1053 SB(
_m[t].m5, 6, 2,
GB(
_m[t].m5, 4, 2));
1057 SB(
_m[t].m4, 0, 4,
GB(
_m[t].m5, 0, 4));
1058 SB(
_m[t].m4, 4, 4, 0);
1059 SB(
_me[t].m6, 2, 4, 0);
1062 SB(
_m[t].m4, 5, 2,
GB(
_m[t].m5, 2, 2));
1066 SB(
_me[t].m7, 6, 2, 1);
1077 SB(
_me[t].m7, 6, 2, 1);
1090 for (
TileIndex t = 0; t < map_size; t++) {
1094 SB(
_me[t].m7, 5, 1,
GB(
_m[t].m3, 7, 1));
1098 SB(
_me[t].m7, 0, 4,
GB(
_m[t].m3, 0, 4));
1099 SB(
_me[t].m6, 3, 3,
GB(
_m[t].m3, 4, 3));
1100 SB(
_m[t].m3, 0, 4,
GB(
_m[t].m4, 4, 4));
1101 SB(
_m[t].m3, 4, 4,
GB(
_m[t].m5, 0, 4));
1102 SB(
_m[t].m5, 0, 4,
GB(
_m[t].m4, 0, 4));
1106 SB(
_me[t].m7, 0, 5,
GB(
_m[t].m4, 0, 5));
1107 SB(
_me[t].m6, 3, 3,
GB(
_m[t].m3, 4, 3));
1108 SB(
_m[t].m3, 4, 4,
GB(
_m[t].m5, 0, 4));
1109 SB(
_m[t].m5, 0, 1,
GB(
_m[t].m4, 6, 1));
1110 SB(
_m[t].m5, 5, 1,
GB(
_m[t].m4, 5, 1));
1128 SB(
_m[t].m3, 4, 4,
_m[t].m1);
1138 SB(
_me[t].m7, 0, 5, o);
1141 SB(
_me[t].m6, 2, 4,
GB(
_m[t].m2, 4, 4));
1142 SB(
_me[t].m7, 5, 1,
GB(
_m[t].m4, 7, 1));
1155 for (
TileIndex t = 0; t < map_size; t++) {
1186 for (
TileIndex t = 0; t < map_size; t++) {
1208 SB(
_me[t].m6, 2, 4, 0);
1213 if (
GB(
_m[t].m5, 3, 2) == 0) {
1230 uint north_south =
GB(
_m[t].m5, 5, 1);
1234 _m[t].
m5 = 1 << 7 | type << 2 | dir;
1240 if (!v->IsGroundVehicle())
continue;
1247 case DIAGDIR_NE:
if ((v->x_pos & 0xF) != 0)
continue;
break;
1250 case DIAGDIR_NW:
if ((v->y_pos & 0xF) != 0)
continue;
break;
1252 }
else if (v->z_pos > GetSlopePixelZ(v->x_pos, v->y_pos)) {
1254 v->UpdatePosition();
1268 for (
TileIndex t = 0; t < map_size; t++) {
1269 bool has_road =
false;
1290 SB(
_me[t].m7, 6, 2, 0);
1300 RailType rt = RailVehInfo(v->engine_type)->railtype;
1307 for (
TileIndex t = 0; t < map_size; t++) {
1337 if (v->IsFrontEngine() || v->IsFreeWagon()) v->ConsistChanged(
CCF_TRACK);
1359 for (
TileIndex t = 0; t < map_size; t++) {
1377 SB(
_m[t].m4, 4, 4, 0);
1394 rv->vehstatus &= ~0x40;
1439 for (
TileIndex t = 0; t < map_size; t++) {
1450 for (j = 0; j != 50; j++) PlantRandomFarmField(i);
1476 for (
TileIndex t = 0; t < map_size; t++) {
1481 SB(
_m[t].m5, 3, 2,
GB(
_m[t].m3, 6, 2));
1482 SB(
_m[t].m3, 6, 2, 0);
1513 for (
TileIndex t = 0; t < map_size; t++) {
1516 case GFX_POWERPLANT_SPARKS:
1520 case GFX_OILWELL_ANIMATED_1:
1521 case GFX_OILWELL_ANIMATED_2:
1522 case GFX_OILWELL_ANIMATED_3:
1526 case GFX_COAL_MINE_TOWER_ANIMATED:
1527 case GFX_COPPER_MINE_TOWER_ANIMATED:
1528 case GFX_GOLD_MINE_TOWER_ANIMATED:
1546 ClrBit(v->vehicle_flags, 2);
1563 v->cur_speed *= 128;
1565 v->acceleration = avi->acceleration;
1573 for (
TileIndex t = 0; t < map_size; t++) {
1586 t->larger_town =
true;
1596 v->current_order.IsType(OT_LOADING)) {
1597 Station::Get(v->last_station_visited)->loading_vehicles.push_back(v);
1608 std::list<Vehicle *>::iterator iter;
1609 for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end();) {
1631 for (
TileIndex t = 0; t < map_size; t++) {
1635 SB(
_m[t].m2, 4, 4, 0);
1637 SB(
_m[t].m2, 4, 3,
GB(
_m[t].m2, 0, 3));
1645 if (rv->state == 250 || rv->state == 251) {
1659 for (
TileIndex t = 0; t < map_size; t++) {
1676 for (
TileIndex t = 0; t < map_size; t++) {
1686 st->goods[c].last_speed = 0;
1696 for (j = 0; j <
lengthof(i->produced_cargo); j++) {
1697 i->produced_cargo[j] = indsp->produced_cargo[j];
1699 for (j = 0; j <
lengthof(i->accepts_cargo); j++) {
1710 for (
TileIndex t = 0; t < map_size; t++) {
1724 if (v->orders.list !=
nullptr && v->orders.list->GetFirstOrder() !=
nullptr && v->orders.list->GetFirstOrder()->IsType(OT_NOTHING)) {
1725 v->orders.list->FreeChain();
1726 v->orders.list =
nullptr;
1729 v->current_order.ConvertFromOldSavegame();
1730 if (v->type ==
VEH_ROAD && v->IsPrimaryVehicle() && v->FirstShared() == v) {
1759 for (uint i = 0; i < 4; i++) {
1769 for (
TileIndex t = 0; t < map_size; t++) {
1773 case STATION_OILRIG:
1777 SB(
_m[t].m3, 0, 2, 0);
1788 SB(
_m[t].m3, 0, 2, 0);
1803 for (
TileIndex t = 0; t < map_size; t++) {
1825 for (
TileIndex t = 0; t < map_size; t++) {
1834 for (
TileIndex t = 0; t < map_size; t++) {
1857 FOR_ALL_ROADTRAMTYPES(rtt) {
1893 v->profit_this_year <<= 8;
1894 v->profit_last_year <<= 8;
1895 v->running_ticks = 0;
1901 for (
TileIndex t = 0; t < map_size; t++) {
1904 SB(
_m[t].m3, 5, 1, 0);
1922 for (
TileIndex t = 0; t < map_size; t++) {
1946 for (
TileIndex t = 0; t < map_size; t++) {
1985 if (t->First() == t) t->ReserveTrackUnderConsist();
1990 for (
TileIndex t = 0; t < map_size; t++) {
2008 st->indtype = IT_INVALID;
2015 if (!a->IsNormalAircraft()) {
2016 a->engine_type = a->First()->engine_type;
2022 if (c->bankrupt_asked == 0xFF) c->bankrupt_asked = 0xFFFF;
2026 if (e->company_avail == 0xFF) e->company_avail = 0xFFFF;
2030 if (t->have_ratings == 0xFF) t->have_ratings = 0xFFFF;
2036 for (
TileIndex t = 0; t < map_size; t++) {
2048 for (
TileIndex t = 0; t < map_size; t++) {
2064 for (
TileIndex t = 0; t < map_size; t++) {
2071 uint offset =
_m[t].
m3;
2075 SB(
_me[t].m6, 2, 4, 0);
2085 SlError(STR_ERROR_TOO_MANY_OBJECTS);
2128 case 5: layout = 1;
break;
2129 case 0: layout = 2;
break;
2131 t->layout =
static_cast<TownLayout>(layout - 1);
2161 if (v->subtype == 2 && v->current_order.GetDestination() != 0) {
2176 std::list<Vehicle *>::iterator iter;
2177 for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); ++iter) {
2200 remove = *tile == *j;
2215 wp->train_station.tile = wp->xy;
2216 wp->train_station.w = 1;
2217 wp->train_station.h = 1;
2220 wp->train_station.w = 0;
2221 wp->train_station.h = 0;
2229 if (s->remaining < 12) {
2231 s->remaining = 12 - s->remaining;
2238 s->src_type = s->dst_type =
ST_TOWN;
2258 s->remaining = 24 - s->remaining;
2266 if (ss !=
nullptr && sd !=
nullptr && ss->
owner == sd->
owner &&
2268 s->src_type = s->dst_type =
ST_TOWN;
2271 s->awarded = ss->
owner;
2308 DEBUG(sl, 0,
"Removing invalid depot %d at %d, %d", d->index,
TileX(d->xy),
TileY(d->xy));
2313 _m[d->xy].
m2 = d->index;
2322 if (t->force_proceed !=
TFP_NONE) {
2331 for (
TileIndex t = 0; t < map_size; t++) {
2341 uint density =
GB(
_m[t].m2, 6, 2);
2342 uint ground =
GB(
_m[t].m2, 4, 2);
2343 uint counter =
GB(
_m[t].m2, 0, 4);
2344 _m[t].
m2 = ground << 6 | density << 4 | counter;
2352 a->turn_counter = a->current_order.IsType(OT_LOADING) ? 0 : a->load_unload_ticks;
2356 t->wait_counter = t->current_order.IsType(OT_LOADING) ? 0 : t->load_unload_ticks;
2362 struct AirportTileConversion {
2366 static const AirportTileConversion atc[] = {
2377 for (
TileIndex t = 0; t < map_size; t++) {
2381 for (uint i = 0; i <
lengthof(atc); i++) {
2382 if (old_gfx < atc[i].old_start) {
2386 if (old_gfx < atc[i].old_start + atc[i].num_frames) {
2391 offset += atc[i].num_frames - 1;
2400 st->airport.w = st->airport.GetSpec()->size_x;
2401 st->airport.h = st->airport.GetSpec()->size_y;
2407 for (
TileIndex t = 0; t < map_size; t++) {
2431 if (!v->IsNormalAircraft())
continue;
2433 if (st ==
nullptr && v->state !=
FLYING) {
2448 for (
TileIndex t = 0; t < map_size; t++) {
2452 uint per_proc =
_me[t].
m7;
2454 SB(
_m[t].m3, 5, 1, 0);
2455 SB(
_me[t].m6, 2, 6, std::min(per_proc, 63U));
2460 uint rand =
_me[t].
m7;
2487 for (
TileIndex t = 0; t < map_size; t++) {
2499 if (!wp->name.empty()) wp->town_cn = UINT16_MAX;
2516 if (!v->IsGroundVehicle())
continue;
2526 if (GetSlopePixelZ(v->x_pos, v->y_pos) != v->z_pos)
continue;
2561 default: NOT_REACHED();
2569 default: NOT_REACHED();
2579 bool loading = rv->current_order.IsType(OT_LOADING) || rv->current_order.IsType(OT_LEAVESTATION);
2584 SB(rv->state,
RVS_ENTERED_STOP, 1, loading || rv->frame > RVC_DRIVE_THROUGH_STOP_FRAME);
2592 if (!
HasBit(t->flags, 5))
continue;
2672 v->z_pos = GetSlopePixelZ(v->x_pos, v->y_pos);
2686 assert(v->tile !=
TileVirtXY(v->x_pos, v->y_pos) || v->z_pos == GetSlopePixelZ(v->x_pos, v->y_pos));
2691 if (!v->IsPrimaryVehicle())
continue;
2694 if (v->cur_implicit_order_index >= v->GetNumOrders()) v->cur_implicit_order_index = 0;
2696 v->cur_real_order_index = v->cur_implicit_order_index;
2697 v->UpdateRealOrderIndex();
2728 assert(ind->psa !=
nullptr);
2731 bool is_empty =
true;
2732 for (uint i = 0; i <
sizeof(ind->psa->storage); i++) {
2733 if (ind->psa->GetValue(i) != 0) {
2740 ind->psa->grfid = _industry_mngr.
GetGRFID(ind->type);
2751 assert(st->airport.psa !=
nullptr);
2754 bool is_empty =
true;
2755 for (uint i = 0; i <
sizeof(st->airport.psa->storage); i++) {
2756 if (st->airport.psa->GetValue(i) != 0) {
2763 st->airport.psa->grfid = _airport_mngr.
GetGRFID(st->airport.type);
2765 delete st->airport.psa;
2766 st->airport.psa =
nullptr;
2780 for (
TileIndex t = 0; t < map_size; t++) {
2783 uint fence =
GB(
_m[t].m4, 5, 3);
2787 fence =
GB(
_m[t].m4, 2, 3);
2791 SB(
_m[t].m4, 2, 3, 0);
2792 SB(
_m[t].m4, 5, 3, 0);
2817 _saved_scrollpos_zoom =
static_cast<ZoomLevel>(_saved_scrollpos_zoom + ZOOM_LVL_SHIFT);
2818 _saved_scrollpos_x *= ZOOM_LVL_BASE;
2819 _saved_scrollpos_y *= ZOOM_LVL_BASE;
2829 for (
TileIndex t = 0; t < map_size; t++) {
2849 c->months_of_bankruptcy = 3 * c->months_of_bankruptcy;
2854 extern uint8 _old_diff_level;
2864 v->acceleration = avi->acceleration;
2870 for (
TileIndex t = 0; t < map_size; t++) {
2879 extern uint8 _old_units;
2890 for (
TileIndex t = 0; t < map_size; t++) {
2906 std::vector<uint> skip_frames;
2908 if (!v->IsFrontEngine())
continue;
2909 skip_frames.clear();
2911 uint prev_tile_skip = 0;
2914 if (u->tile != prev_tile) {
2915 prev_tile_skip = cur_skip;
2916 prev_tile = u->tile;
2918 cur_skip = prev_tile_skip;
2921 uint &this_skip = skip_frames.emplace_back(prev_tile_skip);
2927 if (u->frame <= (roadside ? 9 : 5)) this_skip = cur_skip;
2932 if (u->frame <= (roadside ? 5 : 9)) this_skip = cur_skip;
2937 if (u->frame <= (roadside ? 4 : 2)) this_skip = cur_skip;
2944 while (cur_skip > skip_frames[0]) {
2947 for (uint sf : skip_frames) {
2949 if (sf >= cur_skip) IndividualRoadVehicleController(u, prev);
2961 order->SetTravelTimetabled(order->GetTravelTime() > 0);
2962 order->SetWaitTimetabled(order->GetWaitTime() > 0);
2965 orderlist->RecalculateTimetableDuration();
2976 #ifndef DEBUG_DUMP_COMMANDS
2991 t->growth_rate = TownTicksToGameTicks(t->growth_rate & ~0x8000);
2994 t->grow_counter = TownTicksToGameTicks(t->grow_counter) + t->index %
TOWN_GROWTH_TICKS;
3001 for (
size_t ci = 2; ci <
lengthof(i->produced_cargo); ci++) {
3003 i->produced_cargo_waiting[ci] = 0;
3004 i->production_rate[ci] = 0;
3005 i->last_month_production[ci] = 0;
3006 i->last_month_transported[ci] = 0;
3007 i->last_month_pct_transported[ci] = 0;
3008 i->this_month_production[ci] = 0;
3009 i->this_month_transported[ci] = 0;
3011 for (
size_t ci = 3; ci <
lengthof(i->accepts_cargo); ci++) {
3013 i->incoming_cargo_waiting[ci] = 0;
3017 for (
size_t ci = 0; ci <
lengthof(i->accepts_cargo); ci++) {
3019 i->last_cargo_accepted_at[ci] = i->last_cargo_accepted_at[0];
3021 i->last_cargo_accepted_at[ci] = 0;
3034 int x = s->x_pos & 0xF;
3035 int y = s->y_pos & 0xF;
3036 if (x == 8 && y == 8)
continue;
3041 switch (shipdiagdir) {
3042 default: NOT_REACHED();
3052 if ((shipdiagdir == slopediagdir) == second_half) {
3076 st->industry->neutral_station = st;
3086 for (
TileIndex t = 0; t < map_size; t++) {
3093 for (
TileIndex t = 0; t < map_size; t++) {
3111 if (st->ship_station.tile !=
INVALID_TILE) UpdateStationDockingTiles(st);
3115 for (
TileIndex t = 0; t < map_size; t++) {
3140 AfterLoadLabelMaps();
3174 AfterLoadStations();
void LoadStringWidthTable(bool monospace)
Initialize _stringwidth_table cache.
Buses, trucks and trams belong to this class.
@ TE_WATER
Cargo behaves water-like.
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
@ MP_HOUSE
A house by a town.
bool IsTileFlat(TileIndex tile, int *h)
Check if a given tile is flat.
static bool IsTunnelTile(TileIndex t)
Is this a tunnel (entrance)?
@ TRACK_BIT_WORMHOLE
Bitflag for a wormhole (used for tunnels)
static bool HasTownOwnedRoad(TileIndex t)
Checks if given tile has town owned road.
void BuildOwnerLegend()
Completes the array for the owned property legend.
@ SLV_186
186 25833 Objects storage
uint32 TileIndex
The index/ID of a Tile.
uint64 inflation_prices
Cumulated inflation of prices since game start; 16 bit fractional part.
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-...
bool AfterLoadGame()
Perform a (large) amount of savegame conversion magic in order to load older savegames and to fill th...
@ TRACK_BIT_NONE
No track.
byte wait_for_pbs_path
how long to wait for a path reservation.
void AircraftNextAirportPos_and_Order(Aircraft *v)
set the right pos when heading to other airports after takeoff
static Direction AxisToDirection(Axis a)
Converts an Axis to a Direction.
@ OUFB_UNLOAD
Force unloading all cargo onto the platform, possibly not getting paid.
byte StationGfx
Copy from station_map.h.
void SetSaveLoadError(StringID str)
Set the error message from outside of the actual loading/saving of the game (AfterLoadGame and friend...
uint8 roadveh_slope_steepness
Steepness of hills for road vehicles when using realistic acceleration.
@ FT_SCENARIO
old or new scenario
uint8 pathfinder_for_roadvehs
the pathfinder to use for roadvehicles
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.
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Direction
Defines the 8 directions on the map.
StationSettings station
settings related to station management
static const uint MIN_SNOWLINE_HEIGHT
Minimum snowline height.
static TileIndex GetOtherShipDepotTile(TileIndex t)
Get the other tile of the ship depot.
static bool IsRoadStop(TileIndex t)
Is the station at t a road station?
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
@ SLV_TREES_WATER_CLASS
213 PR#7405 WaterClass update for tree tiles.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
uint64 inflation_payment
Cumulated inflation of cargo paypent since game start; 16 bit fractional part.
uint8 train_acceleration_model
realistic acceleration for trains
static void CDECL HandleSavegameLoadCrash(int signum)
Signal handler used to give a user a more useful report for crashes during the savegame loading proce...
static IndustryGfx GetIndustryGfx(TileIndex t)
Get the industry graphics ID for the given industry tile.
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track)
Use this function to notify YAPF that track layout (or signal configuration) has change.
const TileTypeProcs *const _tile_type_procs[16]
Tile callback functions for each type of tile.
@ SLV_ROAD_TYPES
214 PR#6811 NewGRF road types.
@ GLC_COMPATIBLE
Compatible (eg. the same ID, but different checksum) GRF found in at least one case.
TownLayout town_layout
select town layout,
bool forbid_90_deg
forbid trains to make 90 deg turns
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
@ SP_END
End of setting profiles.
uint8 max_heightlevel
maximum allowed heightlevel
static void InitializeWindowsAndCaches()
Initialization of the windows and several kinds of caches.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
uint8 settings_profile
difficulty profile to set initial settings of scripts, esp. random AIs
@ ROAD_TILE_CROSSING
Level crossing.
byte landscape
the landscape we're currently in
Class to backup a specific variable and restore it later.
void AfterLoadRoadStops()
(Re)building of road stop caches after loading a savegame.
static void SetTileType(TileIndex tile, TileType type)
Set the type of a tile.
Year _cur_year
Current year, starting at 0.
T * Next() const
Get next vehicle in the chain.
@ TRANSPORT_RAIL
Transport by train.
void SetWaterClassDependingOnSurroundings(TileIndex t, bool include_invalid_water_class)
Makes a tile canal or water depending on the surroundings.
@ 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:
TownEffect town_effect
The effect that delivering this cargo type has on towns. Also affects destination of subsidies.
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
static bool IsHouseCompleted(TileIndex t)
Get the completion of this house.
static void SetTrackReservation(TileIndex t, TrackBits b)
Sets the reserved track bits of the tile.
DateFract _date_fract
Fractional part of the day.
static bool IsAirportTile(TileIndex t)
Is this tile a station tile and an airport tile?
@ INVALID_ROADTYPE
flag for invalid roadtype
bool _network_server
network-server is active
TileArea location
Location of the object.
uint32 max_loan
the maximum initial loan
@ TRACK_LOWER
Track in the lower corner of the tile (south)
@ SLV_198
198 PR#6763 Switch town growth rate and counter to actual game ticks
static Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
static void MakeSea(TileIndex t)
Make a sea tile.
IndustryType GetIndustryType(TileIndex tile)
Retrieve the type for this industry.
@ TE_FOOD
Cargo behaves food/fizzy-drinks-like.
static void SetRailStationReservation(TileIndex t, bool b)
Set the reservation state of the rail station.
uint _gamelog_actions
number of actions
@ TL_RANDOM
Random town layout.
@ DIAGDIR_END
Used for iterations.
static void MakeClear(TileIndex t, ClearGround g, uint density)
Make a clear tile.
@ VPF_YAPF
Yet Another PathFinder.
static const int TOWN_GROWTH_TICKS
cycle duration for towns trying to grow. (this originates from the size of the town array in TTD
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.
DistributionType distribution_mail
distribution type for mail
uint8 larger_towns
the number of cities to build. These start off larger and grow twice as fast
void SetDate(Date date, DateFract fract)
Set the date.
@ DT_MANUAL
Manual distribution. No link graph calculations are run.
DifficultySettings difficulty
settings related to the difficulty
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
TileExtended * _me
Extended Tiles of the map.
void ShowAIDebugWindowIfAIError()
Open the AI debug window if one of the AI scripts has crashed.
byte units_volume
unit system for volume
@ SLV_SHIPS_STOP_IN_LOCKS
206 PR#7150 Ship/lock movement changes.
static bool IsClearGround(TileIndex t, ClearGround ct)
Set the type of clear tile.
static Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
@ ROAD_X
Full road along the x-axis (south-west + north-east)
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
Representation of a waypoint.
uint16 m2
Primarily used for indices to towns, industries and stations.
static bool IsStandardRoadStopTile(TileIndex t)
Is tile t a standard (non-drive through) road stop station?
static void SetStationGfx(TileIndex t, StationGfx gfx)
Set the station graphics of this tile.
WaterClass
classes of water (for WATER_TILE_CLEAR water tile type).
static void SetCrossingReservation(TileIndex t, bool b)
Set the reservation state of the rail crossing.
static void SetRoadOwner(TileIndex t, RoadTramType rtt, Owner o)
Set the owner of a specific road type.
static const ObjectType OBJECT_STATUE
Statue in towns.
static bool IsDriveThroughStopTile(TileIndex t)
Is tile t a drive through road stop station?
@ VF_LOADING_FINISHED
Vehicle has finished loading.
byte town_name
the town name generator used for town names
static const uint TILE_SIZE
Tile size in world coordinates.
@ GCS_NOT_FOUND
GRF file was not found in the local cache.
void UpdateOldAircraft()
need to be called to load aircraft from old version
ZoomLevel
All zoom levels we know.
static Station * Get(size_t index)
Gets station with given index.
GRFIdentifier ident
grfid and md5sum to uniquely identify newgrfs
uint8 feeder_payment_share
percentage of leg payment to virtually pay in feeder systems
ClientSettings _settings_client
The current settings for this game.
static bool HasSignals(TileIndex t)
Checks if a rail tile has signals.
@ TCGM_ORIGINAL
Original algorithm (quadratic cargo by population)
Specification of a cargo type.
static bool IsCoast(TileIndex t)
Is it a coast tile?
GamelogActionType at
Type of action.
@ MP_INDUSTRY
Part of an industry.
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
static const Year ORIGINAL_BASE_YEAR
The minimum starting year/base year of the original TTD.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
@ PMB_PAUSED_NETWORK
Pause mode bits when paused for network reasons.
void Add(TileIndex to_add)
Add a single tile to a tile area; enlarge if needed.
@ SLV_SERVE_NEUTRAL_INDUSTRIES
210 PR#7234 Company stations can serve industries with attached neutral stations.
static RoadBits GetCrossingRoadBits(TileIndex tile)
Get the road bits of a level crossing.
static bool MayHaveBridgeAbove(TileIndex t)
Checks for the possibility that a bridge may be on this tile These are in fact all the tile types on ...
RoadType roadtype
Roadtype of this vehicle.
byte road_side
the side of the road vehicles drive on
static void SetRoadTypes(TileIndex t, RoadType road_rt, RoadType tram_rt)
Set the present road types of a tile.
@ WATER_CLASS_RIVER
River.
std::vector< TileIndex > _animated_tiles
The table/list with animated tiles.
TransportType
Available types of transport.
@ VEH_ROAD
Road vehicle type.
Defines the internal data of a functional industry.
const CargoSpec * FindFirstCargoWithTownEffect(TownEffect effect)
Determines the first cargo with a certain town effect.
@ ROADTYPE_ROAD
Basic road type.
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.
Owner
Enum for all companies/owners.
Owner owner
The owner of this station.
uint8 md5sum[16]
MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF)
byte m1
Primarily used for ownership information.
static bool IsTruckStop(TileIndex t)
Is the station at t a truck stop?
@ AIR_AIRCRAFT
an airplane
@ MP_ROAD
A tile with road (or tram tracks)
static bool IsRailDepot(TileIndex t)
Is this rail tile a rail depot?
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.
static void SetFence(TileIndex t, DiagDirection side, uint h)
Sets the type of fence (and whether there is one) for the given border.
static bool IsLevelCrossing(TileIndex t)
Return whether a tile is a level crossing.
static void IncTypeCount(ObjectType type)
Increment the count of objects for this type.
uint32 grfid
GRF ID (defined by Action 0x08)
void ShowNewGRFError()
Show the first NewGRF error we can find.
@ GCF_COMPATIBLE
GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches)
@ ST_TOWN
Source/destination is a town.
static uint TileX(TileIndex tile)
Get the X component of a tile.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
static byte GetLockPart(TileIndex t)
Get the part of a lock.
static bool IsDepotTile(TileIndex tile)
Is the given tile a tile with a depot on it?
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.
@ RAILTYPE_ELECTRIC
Electric rails.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
void GamelogGRFRemove(uint32 grfid)
Logs removal of a GRF.
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
@ SP_MEDIUM
Medium difficulty.
@ RATING_INITIAL
initial rating
static bool IsSavegameVersionUntil(SaveLoadVersion major)
Checks whether the savegame is below or at major.
Aircraft, helicopters, rotors and their shadows belong to this class.
@ PM_UNPAUSED
A normal unpaused game.
@ GVF_GOINGDOWN_BIT
Vehicle is currently going downhill. (Cached track information for acceleration)
@ TE_MAIL
Cargo behaves mail-like.
static uint MapSizeX()
Get the size of the map along the X.
@ INDUSTRYBEH_PLANT_ON_BUILT
Fields are planted around when built (all farms)
byte wait_oneway_signal
waitingtime in days before a oneway signal
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.
static HouseID GetHouseType(TileIndex t)
Get the type of this house, which is an index into the house spec array.
@ SIG_ELECTRIC
Light signal.
bool rail_use_yapf
use YAPF for rail
@ TE_PASSENGERS
Cargo behaves passenger-like.
StationType
Station types.
@ TRANSPORT_ROAD
Transport by road vehicle.
RoadBits
Enumeration for the road parts on a tile.
@ COMPANY_FIRST
First company, same as owner.
@ SLV_EXTEND_INDUSTRY_CARGO_SLOTS
202 PR#6867 Increase industry cargo slots to 16 in, 16 out
bool ship_use_yapf
use YAPF for ships
@ ROAD_TILE_NORMAL
Normal road.
@ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
The vehicle will not stop at any stations it passes except the destination.
Basic data to distinguish a GRF.
uint8 plane_crashes
number of plane crashes, 0 = none, 1 = reduced, 2 = normal
AbstractFileType abstract_ftype
Abstract type of file (scenario, heightmap, etc).
@ WATER_CLASS_INVALID
Used for industry tiles on land (also for oilrig if newgrf says so).
PathfinderSettings pf
settings for all pathfinders
void UpdateAllTownVirtCoords()
Update the virtual coords needed to draw the town sign for all towns.
uint16 terraform_frame_burst
how many tile heights may, over a short period, be terraformed?
@ VS_HIDDEN
Vehicle is not visible.
static ClearGround GetRawClearGround(TileIndex t)
Get the type of clear tile but never return CLEAR_SNOW.
byte wait_twoway_signal
waitingtime in days before a twoway signal
bool station_noise_level
build new airports when the town noise level is still within accepted limits
static const uint TILE_UNIT_MASK
For masking in/out the inner-tile world coordinate units.
static DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
bool serve_neutral_industries
company stations can serve industries with attached neutral stations
Struct about subsidies, offered and awarded.
const byte _tunnel_visibility_frame[DIAGDIR_END]
Frame when a vehicle should be hidden in a tunnel with a certain direction.
static uint MapSize()
Get the size of the map.
static uint GetClearDensity(TileIndex t)
Get the density of a non-field clear tile.
@ TL_BETTER_ROADS
Extended original algorithm (min. 2 distance between roads)
GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig)
Check if all GRFs in the GRF config from a savegame can be loaded.
uint32 changes
Number of changes in this action.
RailType
Enumeration for all possible railtypes.
static bool IsBridgeTile(TileIndex t)
checks if there is a bridge on this tile
const byte _road_stop_stop_frame[]
Table of road stop stop frames, when to stop at a road stop.
Date _date
Current date in days (day counter)
static bool HasStationRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
static void SetTropicZone(TileIndex tile, TropicZone type)
Set the tropic zone.
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
Information about GRF, used in the game and (part of it) in savegames.
uint8 train_slope_steepness
Steepness of hills for trains when using realistic acceleration.
TileArea train_station
Tile area the train 'station' part covers.
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
@ WATER_TILE_CLEAR
Plain water.
@ GSF_FAKE_TOWNS
Fake town GrfSpecFeature for NewGRF debugging (parent scope)
static const size_t MAX_SIZE
Make template parameter accessible from outside.
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
static void RecomputeCatchmentForAll()
Recomputes catchment of all stations.
static const Year MIN_YEAR
The absolute minimum & maximum years in OTTD.
static DiagDirection XYNSToDiagDir(Axis xy, uint ns)
Convert an axis and a flag for north/south into a DiagDirection.
@ GVF_GOINGUP_BIT
Vehicle is currently going uphill. (Cached track information for acceleration)
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
static const HouseID NEW_HOUSE_OFFSET
Offset for new houses.
@ SLV_MULTITILE_DOCKS
216 PR#7380 Multiple docks per station.
TileIndex tile
Current tile index.
static void SetBridgeMiddle(TileIndex t, Axis a)
Set that there is a bridge over the given axis.
static const GRFIdentifier * GetOverriddenIdentifier(const GRFConfig *c)
Try to find the overridden GRF identifier of the given GRF.
ScriptSettings script
settings for scripts
uint16 tree_frame_burst
how many trees may, over a short period, be planted?
#define DEBUG(name, level,...)
Output a line of debugging information.
static const uint TOWN_GROWTH_DESERT
The town needs the cargo for growth when on desert (any amount)
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
@ SLV_11
11.0 2033 11.1 2041
uint16 ObjectType
Types of objects.
@ MP_OBJECT
Contains objects such as transmitters and owned land.
@ VS_CRASHED
Vehicle is crashed.
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
static bool IsBuoy(TileIndex t)
Is tile t a buoy tile?
CargoID accepts_cargo[INDUSTRY_NUM_INPUTS]
16 accepted cargoes.
@ INVALID_OWNER
An invalid owner.
uint16 w
The width of the area.
void UpdateAirportsNoise()
Recalculate the noise generated by the airports of each town.
Helper class to perform the cargo payment.
static StationType GetStationType(TileIndex t)
Get the station type of this tile.
static void StartNew(CompanyID company, bool rerandomise_ai=true)
Start a new AI company.
bool SettingsDisableElrail(int32 p1)
_settings_game.disable_elrail callback
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.
@ TRACK_UPPER
Track in the upper corner of the tile (north)
@ INDUSTRYBEH_BUILT_ONWATER
is built on water (oil rig)
void AfterLoadCompanyStats()
Rebuilding of company statistics after loading a savegame.
static void MakeVoid(TileIndex t)
Make a nice void tile ;)
@ SIGTYPE_COMBO
presignal inter-block
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.
@ ST_INDUSTRY
Source/destination is an industry.
static bool IsShipDepot(TileIndex t)
Is it a water tile with a ship depot on it?
PauseMode _pause_mode
The current pause mode.
RoadTypes
The different roadtypes we support, but then a bitmask of them.
bool IsFrontEngine() const
Check if the vehicle is a front engine.
@ LOCK_PART_MIDDLE
Middle part of a lock.
static void SetSignalStates(TileIndex tile, uint state)
Set the states of the signals (Along/AgainstTrackDir)
bool SaveloadCrashWithMissingNewGRFs()
Did loading the savegame cause a crash? If so, were NewGRFs missing?
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.
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 SetAircraftPosition(Aircraft *v, int x, int y, int z)
Set aircraft position.
@ SLV_TOWN_CARGOGEN
208 PR#6965 New algorithms for town building cargo generation.
EconomySettings economy
settings to change the economy
@ VS_STOPPED
Vehicle is stopped by the player.
ObjectType type
Type of the object.
@ MAX_COMPANIES
Maximum number of companies.
@ TRACK_BIT_X
X-axis track.
static RoadTileType GetRoadTileType(TileIndex t)
Get the type of the road tile.
static bool HasStationTileRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
byte snow_line_height
the configured snow line height
static bool IsRailDepotTile(TileIndex t)
Is this tile rail tile and a rail depot?
static void SetDockingTile(TileIndex t, bool b)
Set the docking tile state of a tile.
'Train' is either a loco or a wagon.
@ VEH_INVALID
Non-existing type of vehicle.
static Direction DiagDirToDir(DiagDirection dir)
Convert a DiagDirection to a Direction.
bool freeform_edges
allow terraforming the tiles at the map edges
void MoveWaypointsToBaseStations()
Perform all steps to upgrade from the old waypoints to the new version that uses station.
Slope GetTileSlope(TileIndex tile, int *h)
Return the slope of a given tile inside the map.
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
static TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
static void SetLiftPosition(TileIndex t, byte pos)
Set the position of the lift on this animated house.
void CopyTempEngineData()
Copy data from temporary engine array into the real engine pool.
static bool IsBridge(TileIndex t)
Checks if this is a bridge, instead of a tunnel.
@ SLV_183
183 25363 Cargodist
static bool IsTileOwner(TileIndex tile, Owner owner)
Checks if a tile belongs to the given owner.
byte industry_density
The industry density.
static bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor=0)
Checks whether the savegame is below major.
bool _networking
are we in networking mode?
static uint TileHash(uint x, uint y)
Calculate a hash value from a tile position.
@ 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 UpdateLevelCrossing(TileIndex tile, bool sound=true)
Sets correct crossing state.
Default settings for vehicles.
void GamelogTestRevision()
Finds out if current revision is different than last revision stored in the savegame.
static bool IsRoadDepot(TileIndex t)
Return whether a tile is a road depot.
LinkGraphSettings linkgraph
settings for link graph calculations
DiagDirection
Enumeration for diagonal directions.
byte units_weight
unit system for weight
static uint MapSizeY()
Get the size of the map along the Y.
@ FACIL_DOCK
Station with a dock.
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.
bool _network_dedicated
are we a dedicated server?
@ SLV_182
182 25115 FS#5492, r25259, r25296 Goal status
@ WATER_CLASS_CANAL
Canal.
@ SLV_17
17.0 3212 17.1 3218
LoggedChange * change
First logged change in this action.
RoadType
The different roadtypes we support.
void FixupTrainLengths()
Fixup old train spacing.
RoadStop * truck_stops
All the truck stops.
Defines the data structure for constructing industry.
static uint32 BSWAP32(uint32 x)
Perform a 32 bits endianness bitswap on x.
static void AfterLoad()
Savegame conversion for cargopackets.
void UpdateNearestTownForRoadTiles(bool invalidate)
Updates cached nearest town for all road tiles.
static const int GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET
The offset for the drive through parts.
LoggedAction * _gamelog_action
first logged action
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
Year ending_year
scoring end date
@ SLV_2
2.0 0.3.0 2.1 0.3.1, 0.3.2
static void SetDepotReservation(TileIndex t, bool b)
Set the reservation state of the depot.
TownCargoGenMode town_cargogen_mode
algorithm for generating cargo from houses,
static DiagDirection GetTunnelBridgeDirection(TileIndex t)
Get the direction pointing to the other end.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
@ RAIL_GROUND_WATER
Grass with a fence and shore or water on the free halftile.
Direction direction
facing
byte units_force
unit system for force
uint16 h
The height of the area.
@ MP_TREES
Tile got trees.
void UpdateAircraftCache(Aircraft *v, bool update_range=false)
Update cached values of an aircraft.
void NORETURN SlError(StringID string, const char *extra_msg)
Error handler.
uint8 pathfinder_for_trains
the pathfinder to use for trains
@ RAILTYPE_RAIL
Standard non-electric rails.
@ TE_GOODS
Cargo behaves goods/candy-like.
uint16 max_bridge_length
maximum length of bridges
bool road_use_yapf
use YAPF for road
static const uint TOWN_GROWTH_WINTER
The town only needs this cargo in the winter (any amount)
bool infrastructure_maintenance
enable monthly maintenance fee for owner infrastructure
static Direction ReverseDir(Direction d)
Return the reverse of a direction.
void Reset()
Completely reset the industry build data.
bool IsStationTileBlocked(TileIndex tile)
Check whether a rail station tile is NOT traversable.
bool allow_town_level_crossings
towns are allowed to build level crossings
void MakeDefaultName(T *obj)
Set the default name for a depot/waypoint.
static bool IsBuoyTile(TileIndex t)
Is tile t a buoy tile?
All ships have this type.
void AfterLoadVehicles(bool part_of_load)
Called after load to update coordinates.
CompanyID _current_company
Company currently doing an action.
TreeGround
Enumeration for ground types of tiles with trees.
@ SLV_16
16.0 2817 16.1 3155
bool dynamic_engines
enable dynamic allocation of engine data
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void GamelogPrintDebug(int level)
Prints gamelog to debug output.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
void ConnectMultiheadedTrains()
Link front and rear multiheaded engines to each other This is done when loading a savegame.
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
@ OSL_PLATFORM_FAR_END
Stop at the far end of the platform.
static uint MapMaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
byte currency
currency we currently use
@ MP_VOID
Invisible tiles at the SW and SE border.
@ SLV_GS_INDUSTRY_CONTROL
287 PR#7912 and PR#8115 GS industry control.
void RebuildSubsidisedSourceAndDestinationCache()
Perform a full rebuild of the subsidies cache.
static size_t GetNumItems()
Returns number of valid items in the pool.
static const uint64 MAX_INFLATION
Maximum inflation (including fractional part) without causing overflows in int64 price computations.
static bool IsPlainRail(TileIndex t)
Returns whether this is plain rails, with or without signals.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static void ClearBridgeMiddle(TileIndex t)
Removes bridges from the given, that is bridges along the X and Y axis.
void Restore()
Restore the variable.
@ FACIL_TRAIN
Station with train station.
@ GLCT_GRFCOMPAT
Loading compatible GRF.
static WaterTileType GetWaterTileType(TileIndex t)
Get the water tile type at a tile.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
void GamelogGRFCompatible(const GRFIdentifier *newg)
Logs loading compatible GRF (the same ID, but different MD5 hash)
static StationGfx GetStationGfx(TileIndex t)
Get the station graphics of this tile.
byte units_power
unit system for power
uint8 roadveh_acceleration_model
realistic acceleration for road vehicles
void NORETURN SlErrorCorrupt(const char *msg)
Error handler for corrupt savegames.
void DeleteInvalidEngineNews()
Remove engine announcements for invalid engines.
void AfterLoadLinkGraphs()
Spawn the threads for running link graph calculations.
@ ROAD_TILE_DEPOT
Depot (one entrance)
static void SetHouseCompleted(TileIndex t, bool status)
Mark this house as been completed.
TileIndex tile
The base tile of the area.
byte units_height
unit system for height
uint8 pathfinder_for_ships
the pathfinder to use for ships
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...
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
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.
struct GRFConfig * next
NOSAVE: Next item in the linked list.
static void SetTunnelBridgeReservation(TileIndex t, bool b)
Set the reservation state of the rail tunnel/bridge.
CargoPayment * cargo_payment
The cargo payment we're currently in.
static void SetTownIndex(TileIndex t, TownID index)
Set the town index for a road or house tile.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
@ OWNER_NONE
The tile has no ownership.
@ PM_PAUSED_NORMAL
A game normally paused.
static void MakeShore(TileIndex t)
Helper function to make a coast tile.
RailTypes GetCompanyRailtypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
@ MP_STATION
A tile of a station.
@ WC_COMPANY_INFRASTRUCTURE
Company infrastructure overview; Window numbers:
@ NUM_CARGO
Maximal number of cargo types in a game.
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
@ ROAD_Y
Full road along the y-axis (north-west + south-east)
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
bool disable_elrails
when true, the elrails are disabled
static bool IsLock(TileIndex t)
Is there a lock on a given water tile?
@ SLV_184
184 25508 Unit localisation split
@ DIAGDIR_BEGIN
Used for iterations.
void GamelogGRFAddList(const GRFConfig *newg)
Logs adding of list of GRFs.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Money old_max_loan_unround
Old: Unrounded max loan.
void RecomputePrices()
Computes all prices, payments and maximum loan.
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.
static void FixOwnerOfRailTrack(TileIndex t)
Tries to change owner of this rail tile to a valid owner.
GRFIdentifier grfcompat
ID and new md5sum of changed GRF.
@ SLV_ENDING_YEAR
218 PR#7747 v1.10 Configurable ending year.
uint16 clear_frame_burst
how many tiles may, over a short period, be cleared?
static Pool::IterateWrapper< RoadVehicle > Iterate(size_t from=0)
Returns an iterable ensemble of all valid vehicles of type T.
static bool IsLevelCrossingTile(TileIndex t)
Return whether a tile is a level crossing tile.
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
static TreeGround GetTreeGround(TileIndex t)
Returns the groundtype for tree tiles.
#define TILE_ADDXY(tile, x, y)
Adds a given offset to a tile.
static const Year DEF_END_YEAR
The default scoring end year.
void UpdateHousesAndTowns()
Check and update town and house values.
@ SLV_188
188 26169 v1.4 FS#5831 Unify RV travel time
TrackBits
Bitfield corresponding to Track.
GRFConfig * _grfconfig
First item in list of current GRF set up.
IndustryBehaviour behaviour
How this industry will behave, and how others entities can use it.
static void MakeCanal(TileIndex t, Owner o, uint8 random_bits)
Make a canal tile.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
static uint FixVehicleInclination(Vehicle *v, Direction dir)
Fixes inclination of a vehicle.
#define lengthof(x)
Return the length of an fixed size array.
@ RVSB_WORMHOLE
The vehicle is in a tunnel and/or bridge.
static TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
static bool IsDock(TileIndex t)
Is tile t a dock tile?
YAPFSettings yapf
pathfinder settings for the yet another pathfinder
@ VF_PATHFINDER_LOST
Vehicle's pathfinder is lost.
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
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
byte type
Type of this airport,.
static bool IsOilRig(TileIndex t)
Is tile t part of an oilrig?
byte CargoID
Cargo slots to indicate a cargo type within a game.
static bool IsPlainRailTile(TileIndex t)
Checks whether the tile is a rail tile or rail tile with signals.
byte m7
Primarily used for newgrf support.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
void CheckTrainsLengths()
Checks if lengths of all rail vehicles are valid.
Axis
Allow incrementing of DiagDirDiff variables.
@ INVALID_COMPANY
An invalid company.
void GamelogOldver()
Logs loading from savegame without gamelog.
uint8 plane_speed
divisor for speed of aircraft
void GamelogTestMode()
Finds last stored game mode or landscape.
uint8 max_train_length
maximum length for trains
static Owner GetRoadOwner(TileIndex t, RoadTramType rtt)
Get the owner of a specific road type.
void InitializeRailGUI()
Resets the rail GUI - sets default railtype to build and resets the signal GUI.
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
uint32 GetGRFID(uint16 entity_id) const
Gives the GRFID of the file the entity belongs to.
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.
static void SetTileOwner(TileIndex tile, Owner owner)
Sets the owner of a tile.
@ EF_ROAD_TRAM
Road vehicle is a tram/light rail vehicle.
@ TREE_GROUND_SNOW_DESERT
a desert or snow tile, depend on landscape
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
@ TRACK_BIT_Y
Y-axis track.
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_192
192 26700 FS#6066 Fix saving of order backups
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
Data for backing up an order of a vehicle so it can be restored after a vehicle is rebuilt in the sam...
@ TFP_NONE
Normal operation.
char * md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
Convert the md5sum to a hexadecimal string representation.
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
@ TFP_STUCK
Proceed till next signal, but ignore being stuck till then. This includes force leaving depots.
@ VEH_TRAIN
Train vehicle type.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
byte units_velocity
unit system for velocity
DistributionType distribution_armoured
distribution type for armoured cargo class
A Stop for a Road Vehicle.
VehicleType type
Type of vehicle.
static void SetWaterClass(TileIndex t, WaterClass wc)
Set the water class at a tile.
@ TROPICZONE_NORMAL
Normal tropiczone.
@ FACIL_AIRPORT
Station with an airport.
static bool IsWater(TileIndex t)
Is it a plain water tile?
@ GLC_ALL_GOOD
All GRF needed by game are present.
CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32 face)
Converts an old company manager's face format to the new company manager's face format.
@ WATER_TILE_LOCK
Water lock.
static void Swap(T &a, T &b)
Type safe swap operation.
@ INVALID_DIR
Flag for an invalid direction.
Contains information about one logged change.
Information about a aircraft vehicle.
uint16 old_max_loan_unround_fract
Old: Fraction of the unrounded max loan.
@ CT_INVALID
Invalid cargo type.
static const ObjectType OBJECT_HQ
HeadQuarter of a player.
@ 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
static void SetAnimationFrame(TileIndex t, byte frame)
Set a new animation frame.
void ResetOldNames()
Free the memory of the old names array.
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
@ DIAGDIR_NE
Northeast, upper right on your monitor.
static const byte TOWN_HOUSE_COMPLETED
Simple value that indicates the house has reached the final stage of construction.
@ VEH_SHIP
Ship vehicle type.
static bool IsShipDepotTile(TileIndex t)
Is it a ship depot tile?
@ PM_PAUSED_ERROR
A game paused because a (critical) error.
uint16 max_tunnel_length
maximum length of tunnels
@ RVSB_IN_DEPOT
The vehicle is in a depot.
byte number_towns
the amount of towns
@ CT_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
byte height
The height of the northern corner.
void UpdateAllStationVirtCoords()
Update the virtual coords needed to draw the station sign for all stations.
@ OWNER_WATER
The tile/execution is done by "water".
bool AddInflation(bool check_year)
Add monthly inflation.
@ 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.
#define lastof(x)
Get the last element of an fixed size array.
bool allow_town_roads
towns are allowed to build roads (always allowed when generating world / in SE)
Date build_date
Date of construction.
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)
CompanySettings settings
settings specific for each company
Town * town
Town the object is built in.
@ GES_RATING
This indicates whether a cargo has a rating at the station.
static void SetRailType(TileIndex t, RailType r)
Sets the rail type of the given tile.
GRFListCompatibility
Status of post-gameload GRF compatibility check.
static const int DAY_TICKS
1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885.
Tile * _m
Tiles of the map.
static const uint16 TOWN_GROWTH_RATE_NONE
Special value for Town::growth_rate to disable town growth.
TileArea ship_station
Tile area the ship 'station' part covers.
@ SIG_SEMAPHORE
Old-fashioned semaphore signal.
DistributionType distribution_pax
distribution type for passengers
@ FLYING
Vehicle is flying in the air.
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
Contains information about one logged action that caused at least one logged change.
@ 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.
@ WL_CRITICAL
Critical errors, the MessageBox is shown in all cases.
@ SLV_190
190 26547 Separate order travel and wait times
static void UpdateAfterLoad()
Update all caches after loading a game, changing NewGRF, etc.
#define DAYS_TILL_ORIGINAL_BASE_YEAR
The offset in days from the '_date == 0' till 'ConvertYMDToDate(ORIGINAL_BASE_YEAR,...
static DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
void SetupColoursAndInitialWindow()
Initialise the default colours (remaps and the likes), and load the main windows.
@ 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
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
static void SetClearGroundDensity(TileIndex t, ClearGround type, uint density)
Sets ground type and density in one go, also sets the counter to 0.
@ SLV_EXTEND_RAILTYPES
200 PR#6805 Extend railtypes to 64, adding uint16 to map array.
Company * DoStartupNewCompany(bool is_ai, CompanyID company=INVALID_COMPANY)
Create a new company and sets all company variables default values.
@ INVALID_TRACK
Flag for an invalid track.