12#include "../industry.h"
13#include "../company_func.h"
14#include "../aircraft.h"
15#include "../roadveh.h"
18#include "../signs_base.h"
19#include "../station_base.h"
20#include "../subsidy_base.h"
22#include "../depot_base.h"
23#include "../timer/timer_game_calendar.h"
24#include "../timer/timer_game_calendar.h"
25#include "../vehicle_func.h"
26#include "../effectvehicle_base.h"
27#include "../engine_func.h"
28#include "../company_base.h"
29#include "../disaster_vehicle.h"
30#include "../timer/timer.h"
31#include "../timer/timer_game_tick.h"
32#include "../timer/timer_game_calendar.h"
36#include "table/strings.h"
37#include "../table/engines.h"
38#include "../table/townname.h"
40#include "../safeguards.h"
52static void FixTTDMapArray()
54 for (
auto tile :
Map::Iterate()) {
60 case 0x53:
case 0x54: tile.m5() += 170 - 0x53;
break;
61 case 0x57:
case 0x58: tile.m5() += 168 - 0x57;
break;
62 case 0x55:
case 0x56: tile.m5() += 170 - 0x55;
break;
63 case 0x59:
case 0x5A: tile.m5() += 168 - 0x59;
break;
70 if (
GB(tile.m5(), 6, 2) == 1) {
73 tile.m4() = (tile.m4() >> 1) & 7;
83 if (
GB(tile.m3(), 0, 2) == 3) {
111#define FIXNUM(x, y, z) (((((x) << 16) / (y)) + 1) << z)
113static uint32_t RemapOldTownName(uint32_t townnameparts, uint8_t old_town_name_type)
115 switch (old_town_name_type) {
118 return townnameparts;
123 return FIXNUM(townnameparts - 86,
lengthof(_name_french_real), 0);
126 Debug(misc, 0,
"German Townnames are buggy ({})", townnameparts);
127 return townnameparts;
131 return FIXNUM(townnameparts,
lengthof(_name_spanish_real), 0);
137 return FIXNUM(townnameparts,
lengthof(_name_silly_1), 0) | FIXNUM(
GB(townnameparts, 16, 8),
lengthof(_name_silly_2), 16);
144static void FixOldTowns()
147 for (
Town *town :
Town::Iterate()) {
148 if (
IsInsideMM(town->townnametype, 0x20C1, 0x20C3)) {
163 if ((
size_t)v->next == 0xFFFF) {
170 switch (v->spritenum) {
172 case 0xff: v->spritenum = 0xfe;
break;
173 default: v->spritenum >>= 1;
break;
177 if (v->type ==
VEH_EFFECT) v->subtype = v->subtype >> 1;
202 (v->IsPrimaryVehicle() && v->current_order.IsType(OT_NOTHING))) {
203 v->current_order.MakeDummy();
210static bool FixTTOMapArray()
212 for (
auto tile :
Map::Iterate()) {
228 switch (
GB(tile.m5(), 6, 2)) {
232 tile.m4() = (~tile.m5() & 1) << 2;
233 SB(tile.m2(), 6, 2,
GB(tile.m5(), 3, 2));
235 tile.m5() =
HasBit(tile.m5(), 5) ? 2 : 1;
247 switch (
GB(tile.m5(), 4, 4)) {
249 if (tile.m2() == 4) tile.m2() = 5;
252 tile.m3() = tile.m1();
262 tile.m3() = tile.m2() & 0xC0;
264 if (tile.m2() >= 5) tile.m2()++;
268 tile.m3() =
GB(tile.m5(), 3, 3);
273 tile.m3() = (tile.m5() >= 0x08 && tile.m5() <= 0x0F) ? 1 : 0;
274 if (tile.m5() >= 8) tile.m5() -= 8;
275 if (tile.m5() >= 0x42) tile.m5()++;
279 tile.m3() = tile.m2() = 0;
283 tile.m2() = tile.m3() = tile.m5() = 0;
292 case 0x25:
case 0x27:
293 case 0x28:
case 0x29:
case 0x2A:
case 0x2B:
297 if (tile.m5() >= 0x2C) tile.m5() += 3;
303 if (
HasBit(tile.m5(), 7)) {
304 uint8_t m5 = tile.m5();
305 tile.m5() = m5 & 0xE1;
306 if (
GB(m5, 1, 2) == 1) tile.m5() |= 0x02;
307 if (
GB(m5, 1, 2) == 3) tile.m2() |= 0xA0;
309 tile.m3() = (
GB(m5, 1, 2) == 3) ? 1 : 0;
311 tile.m3() =
HasBit(m5, 2) ? 0x10 : 0;
312 if (
GB(m5, 3, 2) == 3) tile.m3() |= 1;
313 if (
GB(m5, 3, 2) == 1) tile.m5() |= 0x08;
317 tile.m3() =
HasBit(tile.m5(), 3);
318 tile.m5() &=
HasBit(tile.m5(), 3) ? 0x03 : 0x07 ;
338static Engine *_old_engines;
342 using OldEngineID = uint8_t;
344 static const OldEngineID ttd_to_tto[] = {
345 0, 255, 255, 255, 255, 255, 255, 255, 5, 7, 8, 9, 10, 11, 12, 13,
346 255, 255, 255, 255, 255, 255, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
347 25, 26, 27, 29, 28, 30, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
348 255, 255, 255, 255, 255, 255, 255, 31, 255, 32, 33, 34, 35, 36, 37, 38,
349 39, 40, 41, 42, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
350 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
351 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
352 255, 255, 255, 255, 44, 45, 46, 255, 255, 255, 255, 47, 48, 255, 49, 50,
353 255, 255, 255, 255, 51, 52, 255, 53, 54, 255, 55, 56, 255, 57, 59, 255,
354 58, 60, 255, 61, 62, 255, 63, 64, 255, 65, 66, 255, 255, 255, 255, 255,
355 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
356 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
357 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 67, 68, 69, 70,
358 71, 255, 255, 76, 77, 255, 255, 78, 79, 80, 81, 82, 83, 84, 85, 86,
359 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 255,
360 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 102, 255, 255
364 static const OldEngineID tto_to_ttd[] = {
365 0, 0, 8, 8, 8, 8, 8, 9, 10, 11, 12, 13, 14, 15, 15, 22,
366 23, 24, 25, 26, 27, 29, 28, 30, 31, 32, 33, 34, 35, 36, 37, 55,
367 57, 59, 58, 60, 61, 62, 63, 64, 65, 66, 67, 116, 116, 117, 118, 123,
368 124, 126, 127, 132, 133, 135, 136, 138, 139, 141, 142, 144, 145, 147, 148, 150,
369 151, 153, 154, 204, 205, 206, 207, 208, 211, 212, 211, 212, 211, 212, 215, 216,
370 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232,
371 233, 234, 235, 236, 237, 238, 253
375 if (v->engine_type >=
lengthof(tto_to_ttd))
return false;
376 v->engine_type =
static_cast<EngineID>(tto_to_ttd[v->engine_type.base()]);
382 for (uint16_t i = 0; i <
lengthof(_orig_rail_vehicle_info); ++i, ++j)
new (GetTempDataEngine(j))
Engine(
VEH_TRAIN, i);
383 for (uint16_t i = 0; i <
lengthof(_orig_road_vehicle_info); ++i, ++j)
new (GetTempDataEngine(j))
Engine(
VEH_ROAD, i);
384 for (uint16_t i = 0; i <
lengthof(_orig_ship_vehicle_info); ++i, ++j)
new (GetTempDataEngine(j))
Engine(
VEH_SHIP, i);
391 for (
EngineID i = EngineID::Begin(); i < 256; ++i) {
392 OldEngineID oi = ttd_to_tto[i.base()];
393 Engine *e = GetTempDataEngine(i);
411 Engine *oe = &_old_engines[oi];
429 for (uint j = 0; j <
lengthof(tto_to_ttd); j++) {
430 if (tto_to_ttd[j] == i && _old_engines[j].company_avail.Any()) {
437 e->info.
climates = LandscapeType::Temperate;
443 e->
name = std::string{};
449static void FixTTOCompanies()
459 static const Colours tto_colour_remap[] = {
460 COLOUR_DARK_BLUE, COLOUR_GREY, COLOUR_YELLOW, COLOUR_RED,
461 COLOUR_PURPLE, COLOUR_DARK_GREEN, COLOUR_ORANGE, COLOUR_PALE_GREEN,
462 COLOUR_BLUE, COLOUR_GREEN, COLOUR_CREAM, COLOUR_BROWN,
463 COLOUR_WHITE, COLOUR_LIGHT_BLUE, COLOUR_MAUVE, COLOUR_PINK
466 if (
static_cast<size_t>(tto) >= std::size(tto_colour_remap))
return COLOUR_GREY;
468 return tto_colour_remap[tto];
471static inline uint RemapTownIndex(uint x)
476static inline uint RemapOrderIndex(uint x)
485static uint32_t _old_town_index;
486static uint16_t _old_string_id;
487static uint16_t _old_string_id_2;
519 _bump_assert_value = 0;
522 ls.vehicle_names.resize(800);
550 if (ttdp2_header_first.m3() ==
'T' && ttdp2_header_first.m4() ==
'T' &&
551 ttdp2_header_second.m3() ==
'D' && ttdp2_header_second.m4() ==
'p') {
559 for (
TileIndex i{}; i < 9; i++) ClearOldMap3(i);
568 OCL_SVAR( OC_TILE,
Town, xy ),
570 OCL_SVAR( OC_UINT16,
Town, townnametype ),
571 OCL_SVAR( OC_UINT32,
Town, townnameparts ),
572 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Town, grow_counter ),
576 OCL_SVAR( OC_FILE_U16 | OC_VAR_U8,
Town, flags ),
579 OCL_SVAR( OC_INT16,
Town, ratings[0] ),
580 OCL_SVAR( OC_INT16,
Town, ratings[1] ),
581 OCL_SVAR( OC_INT16,
Town, ratings[2] ),
582 OCL_SVAR( OC_INT16,
Town, ratings[3] ),
583 OCL_SVAR( OC_INT16,
Town, ratings[4] ),
584 OCL_SVAR( OC_INT16,
Town, ratings[5] ),
585 OCL_SVAR( OC_INT16,
Town, ratings[6] ),
586 OCL_SVAR( OC_INT16,
Town, ratings[7] ),
588 OCL_SVAR( OC_FILE_U32 | OC_VAR_U16,
Town, have_ratings ),
589 OCL_SVAR( OC_FILE_U32 | OC_VAR_U16,
Town, statues ),
591 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Town, time_until_rebuild ),
592 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Town, growth_rate ),
595 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[0].new_max ),
596 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[2].new_max ),
597 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[0].new_act ),
598 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[2].new_act ),
599 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[0].old_max ),
600 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[2].old_max ),
601 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[0].old_act ),
602 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[2].old_act ),
611 OCL_SVAR( OC_UINT8,
Town, road_build_months ),
612 OCL_SVAR( OC_UINT8,
Town, fund_buildings_months ),
622 if (!
LoadChunk(ls, t, town_chunk))
return false;
627 t->townnametype = t->townnametype == 0x10B6 ? 0x20C1 : t->townnametype + 0x2A00;
636static uint16_t _old_order;
638 OCL_VAR ( OC_UINT16, 1, &_old_order ),
644 if (!
LoadChunk(ls,
nullptr, order_chunk))
return false;
649 if (o->
IsType(OT_NOTHING)) {
655 if (prev !=
nullptr) prev->
next = o;
665 OCL_VAR ( OC_TILE, 256, anim_list ),
669 if (!
LoadChunk(ls,
nullptr, anim_chunk))
return false;
672 for (
int i = 0; i < 256; i++) {
673 if (anim_list[i] == 0)
break;
681 OCL_SVAR( OC_TILE,
Depot, xy ),
682 OCL_VAR ( OC_UINT32, 1, &_old_town_index ),
689 if (!
LoadChunk(ls, d, depot_chunk))
return false;
692 d->town = RemapTown(d->xy);
701static uint16_t _waiting_acceptance;
702static uint8_t _cargo_source;
703static uint8_t _cargo_periods;
706 OCL_VAR ( OC_UINT16, 1, &_waiting_acceptance ),
707 OCL_SVAR( OC_UINT8,
GoodsEntry, time_since_pickup ),
709 OCL_VAR ( OC_UINT8, 1, &_cargo_source ),
710 OCL_VAR ( OC_UINT8, 1, &_cargo_periods ),
725 if (!
LoadChunk(ls, ge, goods_chunk))
return false;
737static const OldChunks station_chunk[] = {
738 OCL_SVAR( OC_TILE,
Station, xy ),
739 OCL_VAR ( OC_UINT32, 1, &_old_town_index ),
742 OCL_SVAR( OC_TILE,
Station, train_station.tile ),
743 OCL_SVAR( OC_TILE,
Station, airport.tile ),
745 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Station, train_station.w ),
750 OCL_VAR ( OC_UINT16, 1, &_old_string_id ),
754 OCL_SVAR( OC_FILE_U16 | OC_VAR_U8,
Station, had_vehicle_of_type ),
756 OCL_CHUNK( 12, LoadOldGood ),
758 OCL_SVAR( OC_UINT8,
Station, time_since_load ),
759 OCL_SVAR( OC_UINT8,
Station, time_since_unload ),
760 OCL_SVAR( OC_UINT8,
Station, delete_ctr ),
761 OCL_SVAR( OC_UINT8,
Station, owner ),
762 OCL_SVAR( OC_UINT8,
Station, facilities ),
764 OCL_SVAR(
OC_TTO | OC_FILE_U16 | OC_VAR_U64,
Station, airport.blocks ),
767 OCL_SVAR(
OC_TTD | OC_FILE_U16 | OC_VAR_U64,
Station, airport.blocks ),
777 _current_station_id = st->
index;
779 if (!
LoadChunk(ls, st, station_chunk))
return false;
782 st->
town = RemapTown(st->
xy);
786 st->
string_id = STR_SV_STNAME + (_old_string_id - 0x180F);
809static std::array<Industry::AcceptedCargo, INDUSTRY_ORIGINAL_NUM_INPUTS> _old_accepted{};
810static std::array<Industry::ProducedCargo, INDUSTRY_ORIGINAL_NUM_OUTPUTS> _old_produced{};
812static const OldChunks industry_chunk[] = {
813 OCL_SVAR( OC_TILE,
Industry, location.tile ),
814 OCL_VAR ( OC_UINT32, 1, &_old_town_index ),
815 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Industry, location.w ),
816 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Industry, location.h ),
819 OCL_VAR(
OC_TTD | OC_UINT16, 1, &_old_produced[0].waiting ),
820 OCL_VAR(
OC_TTD | OC_UINT16, 1, &_old_produced[1].waiting ),
821 OCL_VAR(
OC_TTO | OC_FILE_U8 | OC_VAR_U16, 1, &_old_produced[0].waiting ),
822 OCL_VAR(
OC_TTO | OC_FILE_U8 | OC_VAR_U16, 1, &_old_produced[1].waiting ),
824 OCL_VAR( OC_UINT8, 1, &_old_produced[0].rate ),
825 OCL_VAR( OC_UINT8, 1, &_old_produced[1].rate ),
829 OCL_SVAR( OC_UINT8,
Industry, prod_level ),
831 OCL_VAR( OC_UINT16, 1, &_old_produced[0].history[THIS_MONTH].production ),
832 OCL_VAR( OC_UINT16, 1, &_old_produced[1].history[THIS_MONTH].production ),
833 OCL_VAR( OC_UINT16, 1, &_old_produced[0].history[THIS_MONTH].transported ),
834 OCL_VAR( OC_UINT16, 1, &_old_produced[1].history[THIS_MONTH].transported ),
838 OCL_VAR( OC_UINT16, 1, &_old_produced[0].history[LAST_MONTH].production ),
839 OCL_VAR( OC_UINT16, 1, &_old_produced[1].history[LAST_MONTH].production ),
840 OCL_VAR( OC_UINT16, 1, &_old_produced[0].history[LAST_MONTH].transported ),
841 OCL_VAR( OC_UINT16, 1, &_old_produced[1].history[LAST_MONTH].transported ),
843 OCL_SVAR( OC_UINT8,
Industry, type ),
845 OCL_SVAR( OC_UINT8,
Industry, owner ),
846 OCL_SVAR( OC_UINT8,
Industry, random_colour ),
847 OCL_SVAR(
OC_TTD | OC_FILE_U8 | OC_VAR_I32,
Industry, last_prod_year ),
859 if (!
LoadChunk(ls, i, industry_chunk))
return false;
863 std::copy(std::begin(_old_accepted), std::end(_old_accepted), std::back_inserter(i->
accepted));
864 std::copy(std::begin(_old_produced), std::end(_old_produced), std::back_inserter(i->
produced));
870 if (i->
type == 0x0A) i->
type = 0x12;
887static int32_t _old_yearly;
889static const OldChunks _company_yearly_chunk[] = {
890 OCL_VAR( OC_INT32, 1, &_old_yearly ),
898 for (uint i = 0; i < 13; i++) {
902 if (!
LoadChunk(ls,
nullptr, _company_yearly_chunk))
return false;
911static const OldChunks _company_economy_chunk[] = {
931 for (uint i = 0; i < 24; i++) {
941static const OldChunks _company_chunk[] = {
942 OCL_VAR ( OC_UINT16, 1, &_old_string_id ),
943 OCL_SVAR( OC_UINT32,
Company, name_2 ),
944 OCL_SVAR( OC_UINT32,
Company, face ),
945 OCL_VAR ( OC_UINT16, 1, &_old_string_id_2 ),
946 OCL_SVAR( OC_UINT32,
Company, president_name_2 ),
948 OCL_SVAR( OC_FILE_I32 | OC_VAR_I64,
Company, money ),
949 OCL_SVAR( OC_FILE_I32 | OC_VAR_I64,
Company, current_loan ),
951 OCL_SVAR( OC_UINT8,
Company, colour ),
952 OCL_SVAR( OC_UINT8,
Company, money_fraction ),
953 OCL_SVAR( OC_UINT8,
Company, months_of_bankruptcy ),
954 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Company, bankrupt_asked ),
955 OCL_SVAR( OC_FILE_U32 | OC_VAR_I64,
Company, bankrupt_value ),
956 OCL_SVAR( OC_UINT16,
Company, bankrupt_timeout ),
961 OCL_CHUNK( 3, LoadOldCompanyYearly ),
962 OCL_CHUNK( 1, LoadOldCompanyEconomy ),
964 OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,
Company, inaugurated_year),
965 OCL_SVAR( OC_TILE,
Company, last_build_coordinate ),
966 OCL_SVAR( OC_UINT8,
Company, num_valid_stat_ent ),
970 OCL_SVAR( OC_UINT8,
Company, block_preview ),
973 OCL_SVAR( OC_TILE,
Company, location_of_HQ ),
988 if (!
LoadChunk(ls, c, _company_chunk))
return false;
990 if (_old_string_id == 0) {
1003 if (_old_string_id == 0 || _old_string_id == 0x4C00) {
1004 _old_string_id = STR_SV_UNNAMED;
1005 }
else if (
GB(_old_string_id, 8, 8) == 0x52) {
1006 _old_string_id += 0x2A00;
1010 c->
name_1 = _old_string_id;
1013 switch (_old_string_id_2) {
1015 case 0x0006: _old_string_id_2 = STR_SV_EMPTY;
break;
1016 default: _old_string_id_2 = _old_string_id_2 + 0x2A00;
break;
1022 if (num != 0) c->
is_ai =
true;
1029 if (c->
name_1 == STR_NULL) {
1030 c->
name_1 = STR_SV_UNNAMED;
1052static uint32_t _old_order_ptr;
1053static uint16_t _old_next_ptr;
1054static typename VehicleID::BaseType _current_vehicle_id;
1056static const OldChunks vehicle_train_chunk[] = {
1057 OCL_SVAR( OC_UINT8,
Train, track ),
1058 OCL_SVAR( OC_UINT8,
Train, force_proceed ),
1059 OCL_SVAR( OC_UINT16,
Train, crash_anim_pos ),
1060 OCL_SVAR( OC_UINT8,
Train, railtype ),
1067static const OldChunks vehicle_road_chunk[] = {
1072 OCL_SVAR( OC_UINT8,
RoadVehicle, overtaking_ctr ),
1081static const OldChunks vehicle_ship_chunk[] = {
1082 OCL_SVAR( OC_UINT8,
Ship, state ),
1089static const OldChunks vehicle_air_chunk[] = {
1090 OCL_SVAR( OC_UINT8,
Aircraft, pos ),
1091 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Aircraft, targetairport ),
1092 OCL_SVAR( OC_UINT16,
Aircraft, crashed_counter ),
1093 OCL_SVAR( OC_UINT8,
Aircraft, state ),
1100static const OldChunks vehicle_effect_chunk[] = {
1109static const OldChunks vehicle_disaster_chunk[] = {
1118static const OldChunks vehicle_empty_chunk[] = {
1127 uint temp = ls.total_read;
1131 res =
LoadChunk(ls,
nullptr, vehicle_empty_chunk);
1145 if (ls.total_read - temp != 10) {
1146 Debug(oldloader, 0,
"Assert failed in VehicleUnion: invalid chunk size");
1153static uint16_t _cargo_count;
1155static const OldChunks vehicle_chunk[] = {
1156 OCL_SVAR( OC_UINT8,
Vehicle, subtype ),
1161 OCL_VAR ( OC_UINT32, 1, &_old_order_ptr ),
1162 OCL_VAR ( OC_UINT16, 1, &_old_order ),
1165 OCL_SVAR( OC_UINT8,
Vehicle, cur_implicit_order_index ),
1166 OCL_SVAR( OC_TILE,
Vehicle, dest_tile ),
1167 OCL_SVAR( OC_UINT16,
Vehicle, load_unload_ticks ),
1168 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Vehicle, date_of_last_service ),
1169 OCL_SVAR( OC_UINT16,
Vehicle, service_interval ),
1170 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Vehicle, last_station_visited ),
1175 OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,
Vehicle, x_pos ),
1176 OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,
Vehicle, y_pos ),
1177 OCL_SVAR( OC_FILE_U8 | OC_VAR_I32,
Vehicle, z_pos ),
1178 OCL_SVAR( OC_UINT8,
Vehicle, direction ),
1183 OCL_SVAR( OC_UINT8,
Vehicle, owner ),
1184 OCL_SVAR( OC_TILE,
Vehicle, tile ),
1185 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Vehicle, sprite_cache.sprite_seq.seq[0].sprite ),
1189 OCL_SVAR( OC_FILE_U16 | OC_VAR_U8,
Vehicle, vehstatus ),
1191 OCL_SVAR(
OC_TTO | OC_FILE_U8 | OC_VAR_U16,
Vehicle, cur_speed ),
1192 OCL_SVAR( OC_UINT8,
Vehicle, subspeed ),
1193 OCL_SVAR( OC_UINT8,
Vehicle, acceleration ),
1194 OCL_SVAR( OC_UINT8,
Vehicle, progress ),
1196 OCL_SVAR( OC_UINT8,
Vehicle, cargo_type ),
1198 OCL_SVAR(
OC_TTO | OC_FILE_U8 | OC_VAR_U16,
Vehicle, cargo_cap ),
1199 OCL_VAR (
OC_TTD | OC_UINT16, 1, &_cargo_count ),
1200 OCL_VAR (
OC_TTO | OC_FILE_U8 | OC_VAR_U16, 1, &_cargo_count ),
1201 OCL_VAR ( OC_UINT8, 1, &_cargo_source ),
1202 OCL_VAR ( OC_UINT8, 1, &_cargo_periods ),
1206 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Vehicle, age ),
1207 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Vehicle, max_age ),
1208 OCL_SVAR( OC_FILE_U8 | OC_VAR_I32,
Vehicle, build_year ),
1209 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Vehicle, unitnumber ),
1212 OCL_SVAR(
OC_TTO | OC_FILE_U8 | OC_VAR_U16,
Vehicle, engine_type ),
1214 OCL_SVAR( OC_UINT8,
Vehicle, spritenum ),
1215 OCL_SVAR( OC_UINT8,
Vehicle, day_counter ),
1217 OCL_SVAR( OC_UINT8,
Vehicle, breakdowns_since_last_service ),
1218 OCL_SVAR( OC_UINT8,
Vehicle, breakdown_ctr ),
1219 OCL_SVAR( OC_UINT8,
Vehicle, breakdown_delay ),
1220 OCL_SVAR( OC_UINT8,
Vehicle, breakdown_chance ),
1224 OCL_SVAR( OC_UINT16,
Vehicle, reliability ),
1225 OCL_SVAR( OC_UINT16,
Vehicle, reliability_spd_dec ),
1227 OCL_SVAR( OC_FILE_I32 | OC_VAR_I64,
Vehicle, profit_this_year ),
1228 OCL_SVAR( OC_FILE_I32 | OC_VAR_I64,
Vehicle, profit_last_year ),
1230 OCL_VAR ( OC_UINT16, 1, &_old_next_ptr ),
1232 OCL_SVAR( OC_FILE_U32 | OC_VAR_I64,
Vehicle, value ),
1234 OCL_VAR ( OC_UINT16, 1, &_old_string_id ),
1236 OCL_CHUNK( 1, LoadOldVehicleUnion ),
1253 ReadTTDPatchFlags(ls);
1263 default:
return false;
1264 case 0x00 : v =
nullptr;
break;
1266 case 0x20 : v =
new (
VehicleID(_current_vehicle_id))
Train();
break;
1268 case 0x22 : v =
new (
VehicleID(_current_vehicle_id))
Ship();
break;
1274 if (!
LoadChunk(ls, v, vehicle_chunk))
return false;
1275 if (v ==
nullptr)
continue;
1293 static const uint8_t spriteset_rail[] = {
1294 0, 2, 4, 4, 8, 10, 12, 14, 16, 18, 20, 22, 40, 42, 44, 46,
1295 48, 52, 54, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 120, 122,
1296 124, 126, 128, 130, 132, 134, 136, 138, 140
1328 switch (_old_string_id) {
1330 case 0x0006: _old_string_id = STR_SV_EMPTY;
break;
1331 case 0x8495: _old_string_id = STR_SV_TRAIN_NAME;
break;
1332 case 0x8842: _old_string_id = STR_SV_ROAD_VEHICLE_NAME;
break;
1333 case 0x8C3B: _old_string_id = STR_SV_SHIP_NAME;
break;
1334 case 0x9047: _old_string_id = STR_SV_AIRCRAFT_NAME;
break;
1335 default: _old_string_id += 0x2A00;
break;
1338 ls.vehicle_names[_current_vehicle_id] = _old_string_id;
1343 case 0x00 : v =
nullptr;
break;
1344 case 0x10 : v =
new (
VehicleID(_current_vehicle_id))
Train();
break;
1346 case 0x12 : v =
new (
VehicleID(_current_vehicle_id))
Ship();
break;
1352 if (!
LoadChunk(ls, v, vehicle_chunk))
return false;
1353 if (v ==
nullptr)
continue;
1358 if (v->
index != _current_vehicle_id) {
1359 Debug(oldloader, 0,
"Loading failed - vehicle-array is invalid");
1364 if (_old_order_ptr != 0 && _old_order_ptr != 0xFFFFFFFF) {
1366 uint old_id = RemapOrderIndex(_old_order_ptr);
1378 StationID source = (_cargo_source == 0xFF) ? StationID::Invalid() :
StationID{_cargo_source};
1401 for (
auto &c : str) c =
ReadByte(ls);
1407 OCL_VAR ( OC_UINT16, 1, &_old_string_id ),
1408 OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,
Sign, x ),
1409 OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,
Sign, y ),
1410 OCL_SVAR( OC_FILE_U16 | OC_VAR_I8,
Sign, z ),
1420 if (!
LoadChunk(ls, si, sign_chunk))
return false;
1422 if (_old_string_id != 0) {
1424 if (_old_string_id != 0x140A) si->name =
CopyFromOldName(_old_string_id + 0x2A00);
1436static const OldChunks engine_chunk[] = {
1437 OCL_SVAR( OC_UINT16,
Engine, company_avail ),
1438 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Engine, intro_date ),
1439 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Engine, age ),
1440 OCL_SVAR( OC_UINT16,
Engine, reliability ),
1441 OCL_SVAR( OC_UINT16,
Engine, reliability_spd_dec ),
1442 OCL_SVAR( OC_UINT16,
Engine, reliability_start ),
1443 OCL_SVAR( OC_UINT16,
Engine, reliability_max ),
1444 OCL_SVAR( OC_UINT16,
Engine, reliability_final ),
1445 OCL_SVAR( OC_UINT16,
Engine, duration_phase_1 ),
1446 OCL_SVAR( OC_UINT16,
Engine, duration_phase_2 ),
1447 OCL_SVAR( OC_UINT16,
Engine, duration_phase_3 ),
1450 OCL_SVAR( OC_UINT8,
Engine, flags ),
1452 OCL_SVAR( OC_UINT8,
Engine, preview_wait ),
1472static const OldChunks subsidy_chunk[] = {
1473 OCL_SVAR( OC_UINT8,
Subsidy, cargo_type ),
1474 OCL_SVAR( OC_UINT8,
Subsidy, remaining ),
1475 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Subsidy, src ),
1476 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Subsidy, dst ),
1484 bool ret =
LoadChunk(ls, s, subsidy_chunk);
1489static const OldChunks game_difficulty_chunk[] = {
1524 for (
auto t :
Map::Iterate()) {
1527 for (
auto t :
Map::Iterate()) {
1533 for (
auto t :
Map::Iterate()) {
1538 for (
auto it = range.begin(); it != range.end(); ) {
1540 for (
int i = 0; i < 8; i += 2, ++it) (*it).m6() =
GB(b, i, 2);
1549 for (
auto t :
Map::Iterate()) {
1552 for (
auto t :
Map::Iterate()) {
1561 ReadTTDPatchFlags(ls);
1566 uint16_t
id = ReadUint16(ls);
1567 uint32_t len = ReadUint32(ls);
1575 ReadUint32(ls);
ReadByte(ls); len -= 5;
1579 uint32_t grfid = ReadUint32(ls);
1582 auto c = std::make_unique<GRFConfig>(
"TTDP game, no information");
1583 c->ident.grfid = grfid;
1585 Debug(oldloader, 3,
"TTDPatch game using GRF file with GRFID {:08X}", std::byteswap(c->ident.grfid));
1599 Debug(oldloader, 3,
"Game saved with TTDPatch version {}.{}.{} r{}",
1600 GB(
_ttdp_version, 24, 8),
GB(
_ttdp_version, 20, 4),
GB(
_ttdp_version, 16, 4),
GB(
_ttdp_version, 0, 16));
1606 Debug(oldloader, 4,
"Skipping unknown extra chunk {}",
id);
1619extern uint8_t _old_diff_level;
1620extern uint8_t _old_units;
1629 OCL_ASSERT(
OC_TTD, 0x264 ),
1630 OCL_ASSERT(
OC_TTO, 0x264 ),
1632 OCL_CCHUNK(
OC_TTD, 70, LoadOldTown ),
1633 OCL_CCHUNK(
OC_TTO, 80, LoadOldTown ),
1635 OCL_ASSERT(
OC_TTD, 0x1C18 ),
1636 OCL_ASSERT(
OC_TTO, 0x1AC4 ),
1638 OCL_CCHUNK(
OC_TTD, 5000, LoadOldOrder ),
1639 OCL_CCHUNK(
OC_TTO, 3000, LoadOldOrder ),
1641 OCL_ASSERT(
OC_TTD, 0x4328 ),
1642 OCL_ASSERT(
OC_TTO, 0x3234 ),
1644 OCL_CHUNK( 1, LoadOldAnimTileList ),
1647 OCL_ASSERT(
OC_TTO, 0x3438 ),
1649 OCL_CCHUNK(
OC_TTD, 255, LoadOldDepot ),
1650 OCL_CCHUNK(
OC_TTO, 252, LoadOldDepot ),
1652 OCL_ASSERT(
OC_TTD, 0x4B26 ),
1653 OCL_ASSERT(
OC_TTO, 0x3A20 ),
1661 OCL_VAR ( OC_TILE, 1, &_cur_tileloop_tile ),
1663 OCL_ASSERT(
OC_TTO, 0x3A2E ),
1665 OCL_CNULL(
OC_TTO, 48 * 6 ),
1666 OCL_CNULL(
OC_TTD, 49 * 6 ),
1668 OCL_ASSERT(
OC_TTO, 0x3B4E ),
1670 OCL_CNULL(
OC_TTO, 11 * 8 ),
1671 OCL_CNULL(
OC_TTD, 12 * 8 ),
1673 OCL_ASSERT(
OC_TTD, 0x4CBA ),
1674 OCL_ASSERT(
OC_TTO, 0x3BA6 ),
1676 OCL_CHUNK( 1, LoadOldMapPart1 ),
1678 OCL_ASSERT(
OC_TTD, 0x48CBA ),
1679 OCL_ASSERT(
OC_TTO, 0x23BA6 ),
1681 OCL_CCHUNK(
OC_TTD, 250, LoadOldStation ),
1682 OCL_CCHUNK(
OC_TTO, 200, LoadOldStation ),
1684 OCL_ASSERT(
OC_TTO, 0x29E16 ),
1686 OCL_CCHUNK(
OC_TTD, 90, LoadOldIndustry ),
1687 OCL_CCHUNK(
OC_TTO, 100, LoadOldIndustry ),
1689 OCL_ASSERT(
OC_TTO, 0x2ADB6 ),
1691 OCL_CHUNK( 8, LoadOldCompany ),
1693 OCL_ASSERT(
OC_TTD, 0x547F2 ),
1694 OCL_ASSERT(
OC_TTO, 0x2C746 ),
1699 OCL_ASSERT(
OC_TTD, 0x6F0F2 ),
1700 OCL_ASSERT(
OC_TTO, 0x45746 ),
1705 OCL_ASSERT(
OC_TTO, 0x46A06 ),
1709 OCL_CHUNK( 40, LoadOldSign ),
1711 OCL_ASSERT(
OC_TTO, 0x48C36 ),
1713 OCL_CCHUNK(
OC_TTD, 256, LoadOldEngine ),
1714 OCL_CCHUNK(
OC_TTO, 103, LoadOldEngine ),
1716 OCL_ASSERT(
OC_TTO, 0x496AC ),
1720 OCL_CHUNK( 8, LoadOldSubsidy ),
1722 OCL_ASSERT(
OC_TTO, 0x496CE ),
1728 OCL_VAR ( OC_FILE_I16 | OC_VAR_I32, 1, &_saved_scrollpos_x ),
1729 OCL_VAR ( OC_FILE_I16 | OC_VAR_I32, 1, &_saved_scrollpos_y ),
1730 OCL_VAR ( OC_FILE_U16 | OC_VAR_U8, 1, &_saved_scrollpos_zoom ),
1734 OCL_VAR ( OC_INT16, 1, &_economy.
fluct ),
1738 OCL_ASSERT(
OC_TTO, 0x496E4 ),
1740 OCL_CNULL(
OC_TTD, 144 ),
1742 OCL_CCHUNK(
OC_TTD, 256, LoadOldEngineName ),
1744 OCL_CNULL(
OC_TTD, 144 ),
1749 OCL_VAR ( OC_UINT8, 1, &_old_units ),
1762 OCL_CHUNK( 1, LoadOldGameDifficulty ),
1764 OCL_ASSERT(
OC_TTD, 0x77130 ),
1766 OCL_VAR ( OC_UINT8, 1, &_old_diff_level ),
1777 OCL_ASSERT(
OC_TTD, 0x77179 ),
1778 OCL_ASSERT(
OC_TTO, 0x4971D ),
1780 OCL_CHUNK( 1, LoadOldMapPart2 ),
1782 OCL_ASSERT(
OC_TTD, 0x97179 ),
1783 OCL_ASSERT(
OC_TTO, 0x6971D ),
1786 OCL_CHUNK(1, LoadTTDPatchExtraChunks),
1793 Debug(oldloader, 3,
"Reading main chunk...");
1798 if (!
LoadChunk(ls,
nullptr, main_chunk)) {
1799 Debug(oldloader, 0,
"Loading failed");
1803 Debug(oldloader, 3,
"Done, converting game data...");
1818 Debug(oldloader, 3,
"Finished converting game data");
1819 Debug(oldloader, 1,
"TTD(Patch) savegame successfully converted");
1826 Debug(oldloader, 3,
"Reading main chunk...");
1830 std::array<uint8_t, 103 *
sizeof(
Engine)> engines;
1831 _old_engines = (
Engine *)engines.data();
1834 if (!
LoadChunk(ls,
nullptr, main_chunk)) {
1835 Debug(oldloader, 0,
"Loading failed");
1838 Debug(oldloader, 3,
"Done, converting game data...");
1846 Debug(oldloader, 0,
"Conversion failed");
1863 Debug(oldloader, 3,
"Finished converting game data");
1864 Debug(oldloader, 1,
"TTO savegame successfully converted");
AirportBlock
Movement Blocks on Airports blocks (eg_airport_flags).
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
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.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
debug_inline 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 ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
bool IsValidCargoType(CargoType t)
Test whether cargo type is not INVALID_CARGO.
static const CargoType NUM_CARGO
Maximum number of cargo types in a game.
@ TAE_FOOD
Cargo behaves food/fizzy-drinks-like.
@ TAE_WATER
Cargo behaves water-like.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr Timpl & Set()
Set all bits.
void Append(CargoPacket *cp, StationID next)
Appends the given cargo packet to the range of packets with the same next station.
Wrapper class to abstract away the way the tiles are stored.
debug_inline uint8_t & m4()
General purpose.
debug_inline uint8_t & m3()
General purpose.
debug_inline uint8_t & m5()
General purpose.
A timeout timer will fire once after the interval.
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
static Date date
Current date in days (day counter).
static DateFract date_fract
Fractional part of the day.
static constexpr TimerGame< struct Economy >::Year ORIGINAL_BASE_YEAR
The minimum starting year/base year of the original TTD.
static constexpr TimerGame< struct Calendar >::Date DAYS_TILL_ORIGINAL_BASE_YEAR
The date of the first day of the original base year.
static Date date
Current date in days (day counter).
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
static TickCounter counter
Monotonic counter, in ticks, since start of game.
void Append(CargoPacket *cp, MoveToAction action=MTA_KEEP)
Appends the given cargo packet.
Money CalculateCompanyValue(const Company *c, bool including_loan=true)
Calculate the value of the company.
uint _cur_company_tick_index
used to generate a name for one company that doesn't have a name yet per tick
TimeoutTimer< TimerGameTick > _new_competitor_timeout({ TimerGameTick::Priority::COMPETITOR_TIMEOUT, 0 }, []() { if(_game_mode==GM_MENU||!AI::CanStartNew()) return;if(_networking &&Company::GetNumItems() >=_settings_client.network.max_companies) return;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< CMD_COMPANY_CTRL >::Post(CCA_NEW_AI, CompanyID::Invalid(), CRR_NONE, INVALID_CLIENT_ID);})
Start a new competitor company if possible.
ReferenceThroughBaseContainer< std::array< Colours, MAX_COMPANIES > > _company_colours
NOSAVE: can be determined from company structs.
static constexpr Owner OWNER_NONE
The tile has no ownership.
static constexpr Owner OWNER_WATER
The tile/execution is done by "water".
#define Debug(category, level, format_string,...)
Output a line of debugging information.
DepotID GetDepotIndex(Tile t)
Get the index of which depot is attached to the tile.
bool IsDepotTile(Tile tile)
Is the given tile a tile with a depot on it?
PoolID< uint16_t, struct DepotIDTag, 64000, 0xFFFF > DepotID
Type for the unique identifier of depots.
static const uint64_t MAX_INFLATION
Maximum inflation (including fractional part) without causing overflows in int64_t price computations...
void StartupOneEngine(Engine *e, const TimerGameCalendar::YearMonthDay &aging_ymd, uint32_t seed)
Start/initialise one engine.
void CalcEngineReliability(Engine *e, bool new_month)
Update Engine::reliability and (if needed) update the engine GUIs.
@ Available
This vehicle is available to everyone.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
uint32_t _ttdp_version
version of TTDP savegame (if applicable)
SavegameType _savegame_type
type of savegame we are loading
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
@ Random
Randomise borders.
static debug_inline TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
constexpr bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
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 T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
GRFConfigList _grfconfig
First item in list of current GRF set up.
void AppendStaticGRFConfigs(GRFConfigList &dst)
Appends the static GRFs to a list of GRFs.
void AppendToGRFConfigList(GRFConfigList &dst, std::unique_ptr< GRFConfig > &&el)
Appends an element to a list of GRFs.
void ClearGRFConfigList(GRFConfigList &config)
Clear a GRF Config list, freeing all nodes.
@ Invalid
GRF is unusable with this version of OpenTTD.
bool LoadChunk(LoadgameState &ls, void *base, const OldChunks *chunks)
Loads a chunk from the old savegame.
uint8_t ReadByte(LoadgameState &ls)
Reads a byte from the buffer and decompress if needed.
Declarations of structures and functions used in loader of old savegames.
@ OC_TTO
-//- TTO (default is neither of these)
@ OC_TTD
chunk is valid ONLY for TTD savegames
std::unique_ptr< std::string[]> _old_name_array
Location to load the old names to.
bool LoadOldCustomString(LoadgameState &ls, int index)
Read a single string from the savegame.
void FixOldVehicles(LoadgameState &ls)
Convert the old style vehicles into something that resembles the old new style savegames.
bool LoadOldVehicle(LoadgameState &ls, int num)
Load the vehicles of an old style savegame.
static void FixTTDDepots()
uint16_t _disaster_delay
Delay counter for considering the next disaster.
static bool _read_ttdpatch_flags
Have we (tried to) read TTDPatch extra flags?
static Colours RemapTTOColour(Colours tto)
static uint16_t _old_extra_chunk_nums
Number of extra TTDPatch chunks.
static bool FixTTOEngines()
uint8_t _age_cargo_skip_counter
Skip aging of cargo? Used before savegame version 162.
uint8_t _trees_tick_ctr
Determines when to consider building more trees.
std::vector< TileIndex > _animated_tiles
The table/list with animated tiles.
Order UnpackOldOrder(uint16_t packed)
Unpacks a order from savegames made with TTD(Patch)
RailType
Enumeration for all possible railtypes.
Randomizer _random
Random used in the game state calculations.
@ RVS_IN_DT_ROAD_STOP
The vehicle is in a drive-through road stop.
@ RVSB_IN_DEPOT
The vehicle is in a depot.
@ RVSB_WORMHOLE
The vehicle is in a tunnel and/or bridge.
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
@ SGT_TTDP2
TTDP savegame in new format (data at SE border)
@ SGT_TTDP1
TTDP savegame ( -//- ) (data at NW border)
Declaration of functions used in more save/load files.
StringID RemapOldStringID(StringID s)
Remap a string ID from the old format to the new format.
std::string CopyFromOldName(StringID id)
Copy and convert old custom names to UTF-8.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
PoolID< uint16_t, struct SignIDTag, 64000, 0xFFFF > SignID
The type of the IDs of signs.
#define lengthof(array)
Return the length of an fixed size array.
static constexpr StringID SPECSTR_PRESIDENT_NAME
Special string for the president's name.
static constexpr StringID SPECSTR_TOWNNAME_START
Special strings for town names.
Aircraft, helicopters, rotors and their shadows belong to this class.
AirportBlocks blocks
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
uint8_t type
Type of this airport,.
StringID string_id
Default name (town area) of station.
TileIndex xy
Base tile of the station.
Town * town
The town this station is associated with.
VehicleType type
Type of vehicle.
Container for cargo from the same location and time.
Statistics about the economy.
Money income
The amount of income.
Money expenses
The amount of expenses.
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
StringID name_1
Name of the company if the user did not change it.
Money current_loan
Amount of money borrowed from the bank.
TimerGameEconomy::Year inaugurated_year
Economy year of starting the company.
CompanyEconomyEntry cur_economy
Economic data of the company of this quarter.
Colours colour
Company colour.
std::array< CompanyEconomyEntry, MAX_HISTORY_QUARTERS > old_economy
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
CompanyManagerFace face
Face description of the president.
std::array< Expenses, 3 > yearly_expenses
Expenses of the company for the last three years.
StringID president_name_1
Name of the president if the user did not change it.
Money money
Money owned by the company.
Settings related to the difficulty of the game.
uint32_t max_loan
the maximum initial loan
uint8_t town_council_tolerance
minimum required town ratings to be allowed to demolish stuff
Disasters, like submarines, skyrangers and their shadows, belong to this class.
uint16_t state
Action stage of the disaster vehicle.
uint64_t inflation_payment
Cumulated inflation of cargo payment since game start; 16 bit fractional part.
uint8_t infl_amount
inflation amount
Money old_max_loan_unround
Old: Unrounded max loan.
int16_t fluct
Economy fluctuation status.
uint8_t infl_amount_pr
inflation rate for payment rates
uint8_t interest_rate
Interest.
A special vehicle is one of the following:
LandscapeTypes climates
Climates supported by the engine.
uint16_t reliability_spd_dec
Speed of reliability decay between services (per day).
uint16_t reliability_start
Initial reliability of the engine.
TimerGameCalendar::Date intro_date
Date of introduction of the engine.
EngineFlags flags
Flags of the engine.
CompanyMask company_avail
Bit for each company whether the engine is available for that company.
uint16_t reliability_max
Maximal reliability of the engine.
uint16_t reliability_final
Final reliability of the engine.
CompanyID preview_company
Company which is currently being offered a preview CompanyID::Invalid() means no company.
uint16_t duration_phase_3
Third reliability phase in months, decaying to reliability_final.
uint16_t duration_phase_2
Second reliability phase in months, keeping reliability_max.
uint8_t preview_wait
Daily countdown timer for timeout of offering the engine to the preview_company company.
uint16_t reliability
Current reliability of the engine.
CompanyMask preview_asked
Bit for each company which has already been offered a preview.
int32_t age
Age of the engine in months.
std::string name
Custom name of engine.
uint16_t duration_phase_1
First reliability phase in months, increasing reliability from reliability_start to reliability_max.
LandscapeType landscape
the landscape we're currently in
uint8_t snow_line_height
the configured snow line height (deduced from "snow_coverage")
uint8_t town_name
the town name generator used for town names
LocaleSettings locale
settings related to used currency/unit system in the current game
DifficultySettings difficulty
settings related to the difficulty
GameCreationSettings game_creation
settings used during the creation of a game (map)
VehicleSettings vehicle
options for vehicles
StationCargoList cargo
The cargo packets of cargo waiting in this station.
Stores station stats for a single cargo.
uint8_t status
Status of this cargo, see GoodsEntryStatus.
@ GES_ACCEPTANCE
Set when the station accepts the cargo currently for final deliveries.
@ GES_RATING
This indicates whether a cargo has a rating at the station.
GoodsEntryData & GetOrCreateData()
Get optional cargo packet/flow data.
Defines the internal data of a functional industry.
IndustryType type
type of industry.
Colours random_colour
randomized colour of the industry, for display purpose
TimerGameEconomy::Year last_prod_year
last economy year of production
ProducedCargoes produced
produced cargo slots
AcceptedCargoes accepted
accepted cargo slots
static std::array< std::vector< IndustryID >, NUM_INDUSTRYTYPES > industries
List of industries of each type.
TileArea location
Location of the industry.
uint8_t vehicle_multiplier
TTDPatch vehicle multiplier.
uint8_t currency
currency we currently use
Size related data of the map.
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
static uint MaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
static void Allocate(uint size_x, uint size_y)
(Re)allocates a map with the given dimension
static debug_inline uint Size()
Get the size of the map.
VehicleSpriteSeq sprite_seq
Vehicle appearance.
DestinationID GetDestination() const
Gets the destination of this order.
bool IsType(OrderType type) const
Check whether this order is of the given type.
Order * next
Pointer to next order. If nullptr, end of list.
void AssignOrder(const Order &other)
Assign data to an order (from another order) This function makes sure that the index is maintained co...
TileIndex tile
The base tile of the area.
SpriteID sprite
The 'real' sprite.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static Titem * Get(auto index)
Returns Titem with given index.
Tindex index
Index of this pool item.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
static Titem * GetIfValid(auto index)
Returns Titem with given index.
uint32_t state[2]
The state of the randomizer.
Buses, trucks and trams belong to this class.
All ships have this type.
static Station * Get(auto index)
Gets station with given index.
static T * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
std::array< GoodsEntry, NUM_CARGO > goods
Goods at this station.
Airport airport
Tile area the airport covers.
Templated helper to make a type-safe 'typedef' representing a single POD value.
Struct about subsidies, offered and awarded.
CargoType cargo_type
Cargo type involved in this subsidy, INVALID_CARGO for invalid subsidy.
TileIndex xy
town center tile
'Train' is either a loco or a wagon.
uint8_t road_side
the side of the road vehicles drive on
VehicleCargoList cargo
The cargo this vehicle is carrying.
uint16_t cargo_cap
total capacity
CargoType cargo_type
type of cargo this vehicle is carrying
Order current_order
The current order (+ status, like: loading)
Order * old_orders
Only used during conversion of old save games.
uint16_t refit_cap
Capacity left over from before last refit.
uint8_t spritenum
currently displayed sprite index 0xfd == custom sprite, 0xfe == custom second head sprite 0xff == res...
Vehicle * next
pointer to the next vehicle in the chain
MutableSpriteCache sprite_cache
Cache of sprites and values related to recalculating them, see MutableSpriteCache.
TileIndex tile
Current tile index.
PoolID< uint16_t, struct SubsidyIDTag, 256, 0xFFFF > SubsidyID
ID of a subsidy.
void SetTileType(Tile tile, TileType type)
Set the type of a tile.
void SetTileOwner(Tile tile, Owner owner)
Sets the owner of a tile.
static debug_inline TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
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.
TileType
The different types of tiles.
@ MP_TREES
Tile got trees.
@ MP_ROAD
A tile with road (or tram tracks)
@ MP_STATION
A tile of a station.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
@ MP_HOUSE
A house by a town.
@ MP_INDUSTRY
Part of an industry.
@ MP_VOID
Invisible tiles at the SW and SE border.
@ MP_OBJECT
Contains objects such as transmitters and owned land.
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
PoolID< uint32_t, struct VehicleIDTag, 0xFF000, 0xFFFFF > VehicleID
The type all our vehicle IDs have.
@ VEH_ROAD
Road vehicle type.
@ VEH_DISASTER
Disaster vehicle type.
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ VEH_SHIP
Ship vehicle type.
@ VEH_EFFECT
Effect vehicle type (smoke, explosions, sparks, bubbles)
@ VEH_TRAIN
Train vehicle type.
void MakeSea(Tile t)
Make a sea tile.