12 #include "../stdafx.h" 14 #include "../industry.h" 15 #include "../company_func.h" 16 #include "../aircraft.h" 17 #include "../roadveh.h" 20 #include "../signs_base.h" 21 #include "../station_base.h" 22 #include "../subsidy_base.h" 24 #include "../depot_base.h" 25 #include "../date_func.h" 26 #include "../vehicle_func.h" 27 #include "../effectvehicle_base.h" 28 #include "../engine_func.h" 29 #include "../company_base.h" 30 #include "../disaster_vehicle.h" 31 #include "../core/smallvec_type.hpp" 36 #include "table/strings.h" 37 #include "../table/engines.h" 38 #include "../table/townname.h" 40 #include "../safeguards.h" 46 static uint8 *_old_map3;
57 static void FixTTDMapArray()
60 for (
TileIndex t = 0; t < OLD_MAP_SIZE; t++) {
61 _m[t].
m3 = _old_map3[t * 2];
62 _m[t].
m4 = _old_map3[t * 2 + 1];
65 for (
TileIndex t = 0; t < OLD_MAP_SIZE; t++) {
71 case 0x53:
case 0x54:
_m[t].
m5 += 170 - 0x53;
break;
72 case 0x57:
case 0x58:
_m[t].
m5 += 168 - 0x57;
break;
73 case 0x55:
case 0x56:
_m[t].
m5 += 170 - 0x55;
break;
74 case 0x59:
case 0x5A:
_m[t].
m5 += 168 - 0x59;
break;
81 if (
GB(
_m[t].m5, 6, 2) == 1) {
94 if (
GB(
_m[t].m3, 0, 2) == 3) {
115 FOR_ALL_DEPOTS_FROM(d, 252) {
123 #define FIXNUM(x, y, z) (((((x) << 16) / (y)) + 1) << z) 125 static uint32 RemapOldTownName(uint32 townnameparts, byte old_town_name_type)
127 switch (old_town_name_type) {
130 return townnameparts;
135 return FIXNUM(townnameparts - 86,
lengthof(_name_french_real), 0);
138 DEBUG(misc, 0,
"German Townnames are buggy (%d)", townnameparts);
139 return townnameparts;
143 return FIXNUM(townnameparts,
lengthof(_name_spanish_real), 0);
149 return FIXNUM(townnameparts,
lengthof(_name_silly_1), 0) | FIXNUM(
GB(townnameparts, 16, 8),
lengthof(_name_silly_2), 16);
156 static void FixOldTowns()
161 FOR_ALL_TOWNS(town) {
162 if (
IsInsideMM(town->townnametype, 0x20C1, 0x20C3)) {
169 static StringID *_old_vehicle_names;
181 if ((
size_t)v->
next == 0xFFFF) {
227 static bool FixTTOMapArray()
229 for (
TileIndex t = 0; t < OLD_MAP_SIZE; t++) {
245 switch (
GB(
_m[t].m5, 6, 2)) {
250 SB(
_m[t].m2, 6, 2,
GB(
_m[t].m5, 3, 2));
264 switch (
GB(
_m[t].m5, 4, 4)) {
266 if (
_m[t].m2 == 4)
_m[t].
m2 = 5;
281 if (
_m[t].m2 >= 5)
_m[t].
m2++;
290 _m[t].
m3 = (
_m[t].
m5 >= 0x08 &&
_m[t].
m5 <= 0x0F) ? 1 : 0;
291 if (
_m[t].m5 >= 8)
_m[t].
m5 -= 8;
292 if (
_m[t].m5 >= 0x42)
_m[t].
m5++;
309 case 0x25:
case 0x27:
310 case 0x28:
case 0x29:
case 0x2A:
case 0x2B:
314 if (
_m[t].m5 >= 0x2C)
_m[t].
m5 += 3;
322 _m[t].
m5 = m5 & 0xE1;
323 if (
GB(m5, 1, 2) == 1)
_m[t].m5 |= 0x02;
324 if (
GB(m5, 1, 2) == 3)
_m[t].m2 |= 0xA0;
326 _m[t].
m3 = (
GB(m5, 1, 2) == 3) ? 1 : 0;
329 if (
GB(m5, 3, 2) == 3)
_m[t].
m3 |= 1;
330 if (
GB(m5, 3, 2) == 1)
_m[t].
m5 |= 0x08;
355 static Engine *_old_engines;
360 static const EngineID ttd_to_tto[] = {
361 0, 255, 255, 255, 255, 255, 255, 255, 5, 7, 8, 9, 10, 11, 12, 13,
362 255, 255, 255, 255, 255, 255, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
363 25, 26, 27, 29, 28, 30, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
364 255, 255, 255, 255, 255, 255, 255, 31, 255, 32, 33, 34, 35, 36, 37, 38,
365 39, 40, 41, 42, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
366 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
367 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
368 255, 255, 255, 255, 44, 45, 46, 255, 255, 255, 255, 47, 48, 255, 49, 50,
369 255, 255, 255, 255, 51, 52, 255, 53, 54, 255, 55, 56, 255, 57, 59, 255,
370 58, 60, 255, 61, 62, 255, 63, 64, 255, 65, 66, 255, 255, 255, 255, 255,
371 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
372 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
373 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 67, 68, 69, 70,
374 71, 255, 255, 76, 77, 255, 255, 78, 79, 80, 81, 82, 83, 84, 85, 86,
375 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 255,
376 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 102, 255, 255
380 static const EngineID tto_to_ttd[] = {
381 0, 0, 8, 8, 8, 8, 8, 9, 10, 11, 12, 13, 14, 15, 15, 22,
382 23, 24, 25, 26, 27, 29, 28, 30, 31, 32, 33, 34, 35, 36, 37, 55,
383 57, 59, 58, 60, 61, 62, 63, 64, 65, 66, 67, 116, 116, 117, 118, 123,
384 124, 126, 127, 132, 133, 135, 136, 138, 139, 141, 142, 144, 145, 147, 148, 150,
385 151, 153, 154, 204, 205, 206, 207, 208, 211, 212, 211, 212, 211, 212, 215, 216,
386 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232,
387 233, 234, 235, 236, 237, 238, 253
398 for (uint i = 0; i <
lengthof(_orig_rail_vehicle_info); i++, j++)
new (GetTempDataEngine(j))
Engine(
VEH_TRAIN, i);
399 for (uint i = 0; i <
lengthof(_orig_road_vehicle_info); i++, j++)
new (GetTempDataEngine(j))
Engine(
VEH_ROAD, i);
400 for (uint i = 0; i <
lengthof(_orig_ship_vehicle_info); i++, j++)
new (GetTempDataEngine(j))
Engine(
VEH_SHIP, i);
405 for (
EngineID i = 0; i < 256; i++) {
406 int oi = ttd_to_tto[i];
407 Engine *e = GetTempDataEngine(i);
424 Engine *oe = &_old_engines[oi];
442 for (uint j = 0; j <
lengthof(tto_to_ttd); j++) {
443 if (tto_to_ttd[j] == i && _old_engines[j].company_avail != 0) {
462 static void FixTTOCompanies()
465 FOR_ALL_COMPANIES(c) {
473 static const byte tto_colour_remap[] = {
474 COLOUR_DARK_BLUE, COLOUR_GREY, COLOUR_YELLOW, COLOUR_RED,
475 COLOUR_PURPLE, COLOUR_DARK_GREEN, COLOUR_ORANGE, COLOUR_PALE_GREEN,
476 COLOUR_BLUE, COLOUR_GREEN, COLOUR_CREAM, COLOUR_BROWN,
477 COLOUR_WHITE, COLOUR_LIGHT_BLUE, COLOUR_MAUVE, COLOUR_PINK
480 if ((
size_t)tto >=
lengthof(tto_colour_remap))
return COLOUR_GREY;
482 return tto_colour_remap[tto];
485 static inline uint RemapTownIndex(uint x)
490 static inline uint RemapOrderIndex(uint x)
498 static uint32 _old_town_index;
499 static uint16 _old_string_id;
500 static uint16 _old_string_id_2;
502 static void ReadTTDPatchFlags()
512 _bump_assert_value = 0;
531 for (uint i = 0; i < 17; i++) {
541 for (uint i = 0; i < 17; i++) _old_map3[i] = 0;
542 for (uint i = 0x1FE00; i < 0x20000; i++) _old_map3[i] = 0;
544 if (_savegame_type ==
SGT_TTDP2)
DEBUG(oldloader, 2,
"Found TTDPatch game");
550 OCL_SVAR( OC_TILE,
Town, xy ),
552 OCL_SVAR( OC_UINT16,
Town, townnametype ),
553 OCL_SVAR( OC_UINT32,
Town, townnameparts ),
554 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Town, grow_counter ),
558 OCL_SVAR( OC_FILE_U16 | OC_VAR_U8,
Town, flags ),
561 OCL_SVAR( OC_INT16,
Town, ratings[0] ),
562 OCL_SVAR( OC_INT16,
Town, ratings[1] ),
563 OCL_SVAR( OC_INT16,
Town, ratings[2] ),
564 OCL_SVAR( OC_INT16,
Town, ratings[3] ),
565 OCL_SVAR( OC_INT16,
Town, ratings[4] ),
566 OCL_SVAR( OC_INT16,
Town, ratings[5] ),
567 OCL_SVAR( OC_INT16,
Town, ratings[6] ),
568 OCL_SVAR( OC_INT16,
Town, ratings[7] ),
570 OCL_SVAR( OC_FILE_U32 | OC_VAR_U16,
Town, have_ratings ),
571 OCL_SVAR( OC_FILE_U32 | OC_VAR_U16,
Town, statues ),
573 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Town, time_until_rebuild ),
574 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Town, growth_rate ),
576 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[CT_PASSENGERS].new_max ),
577 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[CT_MAIL].new_max ),
578 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[CT_PASSENGERS].new_act ),
579 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[CT_MAIL].new_act ),
580 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[CT_PASSENGERS].old_max ),
581 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[CT_MAIL].old_max ),
582 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[CT_PASSENGERS].old_act ),
583 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Town, supplied[CT_MAIL].old_act ),
592 OCL_SVAR( OC_UINT8,
Town, road_build_months ),
593 OCL_SVAR( OC_UINT8,
Town, fund_buildings_months ),
603 if (!
LoadChunk(ls, t, town_chunk))
return false;
608 t->townnametype = t->townnametype == 0x10B6 ? 0x20C1 : t->townnametype + 0x2A00;
617 static uint16 _old_order;
619 OCL_VAR ( OC_UINT16, 1, &_old_order ),
625 if (!
LoadChunk(ls,
nullptr, order_chunk))
return false;
630 if (o->
IsType(OT_NOTHING)) {
636 if (prev !=
nullptr) prev->
next = o;
646 OCL_VAR ( OC_TILE, 256, anim_list ),
650 if (!
LoadChunk(ls,
nullptr, anim_chunk))
return false;
653 for (
int i = 0; i < 256; i++) {
654 if (anim_list[i] == 0)
break;
662 OCL_SVAR( OC_TILE,
Depot, xy ),
663 OCL_VAR ( OC_UINT32, 1, &_old_town_index ),
670 if (!
LoadChunk(ls, d, depot_chunk))
return false;
684 static StationID _current_station_id;
685 static uint16 _waiting_acceptance;
686 static uint8 _cargo_source;
687 static uint8 _cargo_days;
690 OCL_VAR ( OC_UINT16, 1, &_waiting_acceptance ),
691 OCL_SVAR( OC_UINT8,
GoodsEntry, time_since_pickup ),
693 OCL_VAR ( OC_UINT8, 1, &_cargo_source ),
694 OCL_VAR ( OC_UINT8, 1, &_cargo_days ),
709 if (!
LoadChunk(ls, ge, goods_chunk))
return false;
714 ge->
cargo.
Append(
new CargoPacket(
GB(_waiting_acceptance, 0, 12), _cargo_days, (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source, 0, 0),
721 static const OldChunks station_chunk[] = {
722 OCL_SVAR( OC_TILE,
Station, xy ),
723 OCL_VAR ( OC_UINT32, 1, &_old_town_index ),
726 OCL_SVAR( OC_TILE,
Station, train_station.tile ),
727 OCL_SVAR( OC_TILE,
Station, airport.tile ),
729 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Station, train_station.w ),
734 OCL_VAR ( OC_UINT16, 1, &_old_string_id ),
738 OCL_SVAR( OC_FILE_U16 | OC_VAR_U8,
Station, had_vehicle_of_type ),
740 OCL_CHUNK( 12, LoadOldGood ),
742 OCL_SVAR( OC_UINT8,
Station, time_since_load ),
743 OCL_SVAR( OC_UINT8,
Station, time_since_unload ),
744 OCL_SVAR( OC_UINT8,
Station, delete_ctr ),
745 OCL_SVAR( OC_UINT8,
Station, owner ),
746 OCL_SVAR( OC_UINT8,
Station, facilities ),
748 OCL_SVAR(
OC_TTO | OC_FILE_U16 | OC_VAR_U64,
Station, airport.flags ),
751 OCL_SVAR(
OC_TTD | OC_FILE_U16 | OC_VAR_U64,
Station, airport.flags ),
761 _current_station_id = num;
763 if (!
LoadChunk(ls, st, station_chunk))
return false;
770 st->
string_id = STR_SV_STNAME + (_old_string_id - 0x180F);
792 static const OldChunks industry_chunk[] = {
793 OCL_SVAR( OC_TILE,
Industry, location.tile ),
794 OCL_VAR ( OC_UINT32, 1, &_old_town_index ),
795 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Industry, location.w ),
796 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Industry, location.h ),
799 OCL_SVAR(
OC_TTD | OC_UINT16,
Industry, produced_cargo_waiting[0] ),
800 OCL_SVAR(
OC_TTD | OC_UINT16,
Industry, produced_cargo_waiting[1] ),
801 OCL_SVAR(
OC_TTO | OC_FILE_U8 | OC_VAR_U16,
Industry, produced_cargo_waiting[0] ),
802 OCL_SVAR(
OC_TTO | OC_FILE_U8 | OC_VAR_U16,
Industry, produced_cargo_waiting[1] ),
804 OCL_SVAR( OC_UINT8,
Industry, production_rate[0] ),
805 OCL_SVAR( OC_UINT8,
Industry, production_rate[1] ),
809 OCL_SVAR( OC_UINT8,
Industry, prod_level ),
811 OCL_SVAR( OC_UINT16,
Industry, this_month_production[0] ),
812 OCL_SVAR( OC_UINT16,
Industry, this_month_production[1] ),
813 OCL_SVAR( OC_UINT16,
Industry, this_month_transported[0] ),
814 OCL_SVAR( OC_UINT16,
Industry, this_month_transported[1] ),
816 OCL_SVAR( OC_UINT8,
Industry, last_month_pct_transported[0] ),
817 OCL_SVAR( OC_UINT8,
Industry, last_month_pct_transported[1] ),
819 OCL_SVAR( OC_UINT16,
Industry, last_month_production[0] ),
820 OCL_SVAR( OC_UINT16,
Industry, last_month_production[1] ),
821 OCL_SVAR( OC_UINT16,
Industry, last_month_transported[0] ),
822 OCL_SVAR( OC_UINT16,
Industry, last_month_transported[1] ),
824 OCL_SVAR( OC_UINT8,
Industry, type ),
826 OCL_SVAR( OC_UINT8,
Industry, owner ),
827 OCL_SVAR( OC_UINT8,
Industry, random_colour ),
828 OCL_SVAR(
OC_TTD | OC_FILE_U8 | OC_VAR_I32,
Industry, last_prod_year ),
840 if (!
LoadChunk(ls, i, industry_chunk))
return false;
847 if (i->
type == 0x0A) i->
type = 0x12;
865 static int32 _old_yearly;
867 static const OldChunks _company_yearly_chunk[] = {
868 OCL_VAR( OC_INT32, 1, &_old_yearly ),
876 for (uint i = 0; i < 13; i++) {
880 if (!
LoadChunk(ls,
nullptr, _company_yearly_chunk))
return false;
889 static const OldChunks _company_economy_chunk[] = {
899 static bool LoadOldCompanyEconomy(
LoadgameState *ls,
int num)
909 for (uint i = 0; i < 24; i++) {
919 static const OldChunks _company_chunk[] = {
920 OCL_VAR ( OC_UINT16, 1, &_old_string_id ),
921 OCL_SVAR( OC_UINT32,
Company, name_2 ),
922 OCL_SVAR( OC_UINT32,
Company, face ),
923 OCL_VAR ( OC_UINT16, 1, &_old_string_id_2 ),
924 OCL_SVAR( OC_UINT32,
Company, president_name_2 ),
926 OCL_SVAR( OC_FILE_I32 | OC_VAR_I64,
Company, money ),
927 OCL_SVAR( OC_FILE_I32 | OC_VAR_I64,
Company, current_loan ),
929 OCL_SVAR( OC_UINT8,
Company, colour ),
930 OCL_SVAR( OC_UINT8,
Company, money_fraction ),
931 OCL_SVAR( OC_UINT8,
Company, months_of_bankruptcy ),
932 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Company, bankrupt_asked ),
933 OCL_SVAR( OC_FILE_U32 | OC_VAR_I64,
Company, bankrupt_value ),
934 OCL_SVAR( OC_UINT16,
Company, bankrupt_timeout ),
939 OCL_CHUNK( 3, LoadOldCompanyYearly ),
940 OCL_CHUNK( 1, LoadOldCompanyEconomy ),
942 OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,
Company, inaugurated_year),
943 OCL_SVAR( OC_TILE,
Company, last_build_coordinate ),
944 OCL_SVAR( OC_UINT8,
Company, num_valid_stat_ent ),
948 OCL_SVAR( OC_UINT8,
Company, block_preview ),
951 OCL_SVAR( OC_TILE,
Company, location_of_HQ ),
968 if (!
LoadChunk(ls, c, _company_chunk))
return false;
970 if (_old_string_id == 0) {
983 if (_old_string_id == 0 || _old_string_id == 0x4C00) {
984 _old_string_id = STR_SV_UNNAMED;
985 }
else if (
GB(_old_string_id, 8, 8) == 0x52) {
986 _old_string_id += 0x2A00;
990 c->
name_1 = _old_string_id;
993 switch (_old_string_id_2) {
994 case 0x4CDA: _old_string_id_2 = SPECSTR_PRESIDENT_NAME;
break;
995 case 0x0006: _old_string_id_2 = STR_SV_EMPTY;
break;
996 default: _old_string_id_2 = _old_string_id_2 + 0x2A00;
break;
1002 if (num != 0) c->
is_ai =
true;
1010 c->
name_1 = STR_SV_UNNAMED;
1032 static uint32 _old_order_ptr;
1033 static uint16 _old_next_ptr;
1036 static const OldChunks vehicle_train_chunk[] = {
1037 OCL_SVAR( OC_UINT8,
Train, track ),
1038 OCL_SVAR( OC_UINT8,
Train, force_proceed ),
1039 OCL_SVAR( OC_UINT16,
Train, crash_anim_pos ),
1040 OCL_SVAR( OC_UINT8,
Train, railtype ),
1047 static const OldChunks vehicle_road_chunk[] = {
1052 OCL_SVAR( OC_UINT8,
RoadVehicle, overtaking_ctr ),
1061 static const OldChunks vehicle_ship_chunk[] = {
1062 OCL_SVAR( OC_UINT8,
Ship, state ),
1069 static const OldChunks vehicle_air_chunk[] = {
1070 OCL_SVAR( OC_UINT8,
Aircraft, pos ),
1071 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Aircraft, targetairport ),
1072 OCL_SVAR( OC_UINT16,
Aircraft, crashed_counter ),
1073 OCL_SVAR( OC_UINT8,
Aircraft, state ),
1080 static const OldChunks vehicle_effect_chunk[] = {
1089 static const OldChunks vehicle_disaster_chunk[] = {
1098 static const OldChunks vehicle_empty_chunk[] = {
1107 uint temp = ls->total_read;
1111 res =
LoadChunk(ls,
nullptr, vehicle_empty_chunk);
1125 if (ls->total_read - temp != 10) {
1126 DEBUG(oldloader, 0,
"Assert failed in VehicleUnion: invalid chunk size");
1133 static uint16 _cargo_count;
1135 static const OldChunks vehicle_chunk[] = {
1136 OCL_SVAR( OC_UINT8,
Vehicle, subtype ),
1141 OCL_VAR ( OC_UINT32, 1, &_old_order_ptr ),
1142 OCL_VAR ( OC_UINT16, 1, &_old_order ),
1145 OCL_SVAR( OC_UINT8,
Vehicle, cur_implicit_order_index ),
1146 OCL_SVAR( OC_TILE,
Vehicle, dest_tile ),
1147 OCL_SVAR( OC_UINT16,
Vehicle, load_unload_ticks ),
1148 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Vehicle, date_of_last_service ),
1149 OCL_SVAR( OC_UINT16,
Vehicle, service_interval ),
1150 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Vehicle, last_station_visited ),
1155 OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,
Vehicle, x_pos ),
1156 OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,
Vehicle, y_pos ),
1157 OCL_SVAR( OC_FILE_U8 | OC_VAR_I32,
Vehicle, z_pos ),
1158 OCL_SVAR( OC_UINT8,
Vehicle, direction ),
1163 OCL_SVAR( OC_UINT8,
Vehicle, owner ),
1164 OCL_SVAR( OC_TILE,
Vehicle, tile ),
1165 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Vehicle, sprite_seq.seq[0].sprite ),
1169 OCL_SVAR( OC_FILE_U16 | OC_VAR_U8,
Vehicle, vehstatus ),
1171 OCL_SVAR(
OC_TTO | OC_FILE_U8 | OC_VAR_U16,
Vehicle, cur_speed ),
1172 OCL_SVAR( OC_UINT8,
Vehicle, subspeed ),
1173 OCL_SVAR( OC_UINT8,
Vehicle, acceleration ),
1174 OCL_SVAR( OC_UINT8,
Vehicle, progress ),
1176 OCL_SVAR( OC_UINT8,
Vehicle, cargo_type ),
1178 OCL_SVAR(
OC_TTO | OC_FILE_U8 | OC_VAR_U16,
Vehicle, cargo_cap ),
1179 OCL_VAR (
OC_TTD | OC_UINT16, 1, &_cargo_count ),
1180 OCL_VAR (
OC_TTO | OC_FILE_U8 | OC_VAR_U16, 1, &_cargo_count ),
1181 OCL_VAR ( OC_UINT8, 1, &_cargo_source ),
1182 OCL_VAR ( OC_UINT8, 1, &_cargo_days ),
1186 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Vehicle, age ),
1187 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Vehicle, max_age ),
1188 OCL_SVAR( OC_FILE_U8 | OC_VAR_I32,
Vehicle, build_year ),
1189 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Vehicle, unitnumber ),
1192 OCL_SVAR(
OC_TTO | OC_FILE_U8 | OC_VAR_U16,
Vehicle, engine_type ),
1194 OCL_SVAR( OC_UINT8,
Vehicle, spritenum ),
1195 OCL_SVAR( OC_UINT8,
Vehicle, day_counter ),
1197 OCL_SVAR( OC_UINT8,
Vehicle, breakdowns_since_last_service ),
1198 OCL_SVAR( OC_UINT8,
Vehicle, breakdown_ctr ),
1199 OCL_SVAR( OC_UINT8,
Vehicle, breakdown_delay ),
1200 OCL_SVAR( OC_UINT8,
Vehicle, breakdown_chance ),
1204 OCL_SVAR( OC_UINT16,
Vehicle, reliability ),
1205 OCL_SVAR( OC_UINT16,
Vehicle, reliability_spd_dec ),
1207 OCL_SVAR( OC_FILE_I32 | OC_VAR_I64,
Vehicle, profit_this_year ),
1208 OCL_SVAR( OC_FILE_I32 | OC_VAR_I64,
Vehicle, profit_last_year ),
1210 OCL_VAR ( OC_UINT16, 1, &_old_next_ptr ),
1212 OCL_SVAR( OC_FILE_U32 | OC_VAR_I64,
Vehicle, value ),
1214 OCL_VAR ( OC_UINT16, 1, &_old_string_id ),
1216 OCL_CHUNK( 1, LoadOldVehicleUnion ),
1233 ReadTTDPatchFlags();
1236 _current_vehicle_id = num * _old_vehicle_multiplier + i;
1243 default:
return false;
1244 case 0x00 : v =
nullptr;
break;
1246 case 0x20 : v =
new (_current_vehicle_id)
Train();
break;
1247 case 0x21 : v =
new (_current_vehicle_id)
RoadVehicle();
break;
1248 case 0x22 : v =
new (_current_vehicle_id)
Ship();
break;
1249 case 0x23 : v =
new (_current_vehicle_id)
Aircraft();
break;
1250 case 0x24 : v =
new (_current_vehicle_id)
EffectVehicle();
break;
1254 if (!
LoadChunk(ls, v, vehicle_chunk))
return false;
1255 if (v ==
nullptr)
continue;
1273 static const byte spriteset_rail[] = {
1274 0, 2, 4, 4, 8, 10, 12, 14, 16, 18, 20, 22, 40, 42, 44, 46,
1275 48, 52, 54, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 120, 122,
1276 124, 126, 128, 130, 132, 134, 136, 138, 140
1308 switch (_old_string_id) {
1310 case 0x0006: _old_string_id = STR_SV_EMPTY;
break;
1311 case 0x8495: _old_string_id = STR_SV_TRAIN_NAME;
break;
1312 case 0x8842: _old_string_id = STR_SV_ROAD_VEHICLE_NAME;
break;
1313 case 0x8C3B: _old_string_id = STR_SV_SHIP_NAME;
break;
1314 case 0x9047: _old_string_id = STR_SV_AIRCRAFT_NAME;
break;
1315 default: _old_string_id += 0x2A00;
break;
1318 _old_vehicle_names[_current_vehicle_id] = _old_string_id;
1323 case 0x00 : v =
nullptr;
break;
1324 case 0x10 : v =
new (_current_vehicle_id)
Train();
break;
1325 case 0x11 : v =
new (_current_vehicle_id)
RoadVehicle();
break;
1326 case 0x12 : v =
new (_current_vehicle_id)
Ship();
break;
1327 case 0x13 : v =
new (_current_vehicle_id)
Aircraft();
break;
1328 case 0x14 : v =
new (_current_vehicle_id)
EffectVehicle();
break;
1332 if (!
LoadChunk(ls, v, vehicle_chunk))
return false;
1333 if (v ==
nullptr)
continue;
1335 _old_vehicle_names[_current_vehicle_id] =
RemapOldStringID(_old_string_id);
1338 if (v->
index != _current_vehicle_id) {
1339 DEBUG(oldloader, 0,
"Loading failed - vehicle-array is invalid");
1344 if (_old_order_ptr != 0 && _old_order_ptr != 0xFFFFFFFF) {
1346 uint old_id = RemapOrderIndex(_old_order_ptr);
1354 StationID source = (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
1364 OCL_VAR ( OC_UINT16, 1, &_old_string_id ),
1365 OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,
Sign, x ),
1366 OCL_SVAR( OC_FILE_U16 | OC_VAR_I32,
Sign, y ),
1367 OCL_SVAR( OC_FILE_U16 | OC_VAR_I8,
Sign, z ),
1377 if (!
LoadChunk(ls, si, sign_chunk))
return false;
1379 if (_old_string_id != 0) {
1381 if (_old_string_id != 0x140A) si->name =
CopyFromOldName(_old_string_id + 0x2A00);
1393 static const OldChunks engine_chunk[] = {
1394 OCL_SVAR( OC_UINT16,
Engine, company_avail ),
1395 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Engine, intro_date ),
1396 OCL_SVAR( OC_FILE_U16 | OC_VAR_U32,
Engine, age ),
1397 OCL_SVAR( OC_UINT16,
Engine, reliability ),
1398 OCL_SVAR( OC_UINT16,
Engine, reliability_spd_dec ),
1399 OCL_SVAR( OC_UINT16,
Engine, reliability_start ),
1400 OCL_SVAR( OC_UINT16,
Engine, reliability_max ),
1401 OCL_SVAR( OC_UINT16,
Engine, reliability_final ),
1402 OCL_SVAR( OC_UINT16,
Engine, duration_phase_1 ),
1403 OCL_SVAR( OC_UINT16,
Engine, duration_phase_2 ),
1404 OCL_SVAR( OC_UINT16,
Engine, duration_phase_3 ),
1407 OCL_SVAR( OC_UINT8,
Engine, flags ),
1409 OCL_SVAR( OC_UINT8,
Engine, preview_wait ),
1424 Engine *e = GetTempDataEngine(num);
1429 static const OldChunks subsidy_chunk[] = {
1430 OCL_SVAR( OC_UINT8,
Subsidy, cargo_type ),
1431 OCL_SVAR( OC_UINT8,
Subsidy, remaining ),
1432 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Subsidy, src ),
1433 OCL_SVAR( OC_FILE_U8 | OC_VAR_U16,
Subsidy, dst ),
1441 bool ret =
LoadChunk(ls, s, subsidy_chunk);
1446 static const OldChunks game_difficulty_chunk[] = {
1467 static bool LoadOldGameDifficulty(
LoadgameState *ls,
int num)
1482 for (uint i = 0; i < OLD_MAP_SIZE; i++) {
1485 for (uint i = 0; i < OLD_MAP_SIZE; i++) {
1490 for (uint i = 0; i < OLD_MAP_SIZE; i++) {
1492 _old_map3[i * 2 + 1] =
ReadByte(ls);
1494 for (uint i = 0; i < OLD_MAP_SIZE / 4; i++) {
1496 _me[i * 4 + 0].
m6 =
GB(b, 0, 2);
1497 _me[i * 4 + 1].
m6 =
GB(b, 2, 2);
1498 _me[i * 4 + 2].
m6 =
GB(b, 4, 2);
1499 _me[i * 4 + 3].
m6 =
GB(b, 6, 2);
1510 for (i = 0; i < OLD_MAP_SIZE; i++) {
1513 for (i = 0; i < OLD_MAP_SIZE; i++) {
1520 static bool LoadTTDPatchExtraChunks(
LoadgameState *ls,
int num)
1522 ReadTTDPatchFlags();
1527 uint16
id = ReadUint16(ls);
1528 uint32 len = ReadUint32(ls);
1536 ReadUint32(ls);
ReadByte(ls); len -= 5;
1540 uint32 grfid = ReadUint32(ls);
1560 DEBUG(oldloader, 3,
"Game saved with TTDPatch version %d.%d.%d r%d",
1561 GB(
_ttdp_version, 24, 8),
GB(
_ttdp_version, 20, 4),
GB(
_ttdp_version, 16, 4),
GB(
_ttdp_version, 0, 16));
1567 DEBUG(oldloader, 4,
"Skipping unknown extra chunk %X",
id);
1580 extern uint8 _old_diff_level;
1581 extern uint8 _old_units;
1585 OCL_VAR ( OC_FILE_U16 | OC_VAR_U32, 1, &
_date ),
1590 OCL_ASSERT(
OC_TTD, 0x264 ),
1591 OCL_ASSERT(
OC_TTO, 0x264 ),
1593 OCL_CCHUNK(
OC_TTD, 70, LoadOldTown ),
1594 OCL_CCHUNK(
OC_TTO, 80, LoadOldTown ),
1596 OCL_ASSERT(
OC_TTD, 0x1C18 ),
1597 OCL_ASSERT(
OC_TTO, 0x1AC4 ),
1599 OCL_CCHUNK(
OC_TTD, 5000, LoadOldOrder ),
1600 OCL_CCHUNK(
OC_TTO, 3000, LoadOldOrder ),
1602 OCL_ASSERT(
OC_TTD, 0x4328 ),
1603 OCL_ASSERT(
OC_TTO, 0x3234 ),
1605 OCL_CHUNK( 1, LoadOldAnimTileList ),
1608 OCL_ASSERT(
OC_TTO, 0x3438 ),
1610 OCL_CCHUNK(
OC_TTD, 255, LoadOldDepot ),
1611 OCL_CCHUNK(
OC_TTO, 252, LoadOldDepot ),
1613 OCL_ASSERT(
OC_TTD, 0x4B26 ),
1614 OCL_ASSERT(
OC_TTO, 0x3A20 ),
1622 OCL_VAR ( OC_TILE, 1, &_cur_tileloop_tile ),
1624 OCL_ASSERT(
OC_TTO, 0x3A2E ),
1626 OCL_CNULL(
OC_TTO, 48 * 6 ),
1627 OCL_CNULL(
OC_TTD, 49 * 6 ),
1629 OCL_ASSERT(
OC_TTO, 0x3B4E ),
1631 OCL_CNULL(
OC_TTO, 11 * 8 ),
1632 OCL_CNULL(
OC_TTD, 12 * 8 ),
1634 OCL_ASSERT(
OC_TTD, 0x4CBA ),
1635 OCL_ASSERT(
OC_TTO, 0x3BA6 ),
1637 OCL_CHUNK( 1, LoadOldMapPart1 ),
1639 OCL_ASSERT(
OC_TTD, 0x48CBA ),
1640 OCL_ASSERT(
OC_TTO, 0x23BA6 ),
1642 OCL_CCHUNK(
OC_TTD, 250, LoadOldStation ),
1643 OCL_CCHUNK(
OC_TTO, 200, LoadOldStation ),
1645 OCL_ASSERT(
OC_TTO, 0x29E16 ),
1647 OCL_CCHUNK(
OC_TTD, 90, LoadOldIndustry ),
1648 OCL_CCHUNK(
OC_TTO, 100, LoadOldIndustry ),
1650 OCL_ASSERT(
OC_TTO, 0x2ADB6 ),
1652 OCL_CHUNK( 8, LoadOldCompany ),
1654 OCL_ASSERT(
OC_TTD, 0x547F2 ),
1655 OCL_ASSERT(
OC_TTO, 0x2C746 ),
1660 OCL_ASSERT(
OC_TTD, 0x6F0F2 ),
1661 OCL_ASSERT(
OC_TTO, 0x45746 ),
1666 OCL_ASSERT(
OC_TTO, 0x46A06 ),
1670 OCL_CHUNK( 40, LoadOldSign ),
1672 OCL_ASSERT(
OC_TTO, 0x48C36 ),
1674 OCL_CCHUNK(
OC_TTD, 256, LoadOldEngine ),
1675 OCL_CCHUNK(
OC_TTO, 103, LoadOldEngine ),
1677 OCL_ASSERT(
OC_TTO, 0x496AC ),
1681 OCL_CHUNK( 8, LoadOldSubsidy ),
1683 OCL_ASSERT(
OC_TTO, 0x496CE ),
1689 OCL_VAR ( OC_FILE_I16 | OC_VAR_I32, 1, &_saved_scrollpos_x ),
1690 OCL_VAR ( OC_FILE_I16 | OC_VAR_I32, 1, &_saved_scrollpos_y ),
1691 OCL_VAR ( OC_FILE_U16 | OC_VAR_U8, 1, &_saved_scrollpos_zoom ),
1695 OCL_VAR ( OC_INT16, 1, &_economy.
fluct ),
1699 OCL_ASSERT(
OC_TTO, 0x496E4 ),
1701 OCL_CNULL(
OC_TTD, 144 ),
1703 OCL_CCHUNK(
OC_TTD, 256, LoadOldEngineName ),
1705 OCL_CNULL(
OC_TTD, 144 ),
1710 OCL_VAR ( OC_UINT8, 1, &_old_units ),
1723 OCL_CHUNK( 1, LoadOldGameDifficulty ),
1725 OCL_ASSERT(
OC_TTD, 0x77130 ),
1727 OCL_VAR ( OC_UINT8, 1, &_old_diff_level ),
1738 OCL_ASSERT(
OC_TTD, 0x77179 ),
1739 OCL_ASSERT(
OC_TTO, 0x4971D ),
1741 OCL_CHUNK( 1, LoadOldMapPart2 ),
1743 OCL_ASSERT(
OC_TTD, 0x97179 ),
1744 OCL_ASSERT(
OC_TTO, 0x6971D ),
1747 OCL_CHUNK(1, LoadTTDPatchExtraChunks),
1754 DEBUG(oldloader, 3,
"Reading main chunk...");
1759 std::array<byte, OLD_MAP_SIZE * 2> map3;
1760 _old_map3 = map3.data();
1761 _old_vehicle_names =
nullptr;
1763 if (!
LoadChunk(ls,
nullptr, main_chunk)) {
1764 DEBUG(oldloader, 0,
"Loading failed");
1765 free(_old_vehicle_names);
1769 free(_old_vehicle_names);
1773 DEBUG(oldloader, 3,
"Done, converting game data...");
1788 DEBUG(oldloader, 3,
"Finished converting game data");
1789 DEBUG(oldloader, 1,
"TTD(Patch) savegame successfully converted");
1791 free(_old_vehicle_names);
1798 DEBUG(oldloader, 3,
"Reading main chunk...");
1802 std::array<byte, 103 * sizeof(Engine)> engines;
1803 _old_engines = (
Engine *)engines.data();
1804 std::array<StringID, 800> vehnames;
1805 _old_vehicle_names = vehnames.data();
1808 if (!
LoadChunk(ls,
nullptr, main_chunk)) {
1809 DEBUG(oldloader, 0,
"Loading failed");
1812 DEBUG(oldloader, 3,
"Done, converting game data...");
1820 DEBUG(oldloader, 0,
"Conversion failed");
1837 DEBUG(oldloader, 3,
"Finished converting game data");
1838 DEBUG(oldloader, 1,
"TTO savegame successfully converted");
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
Owner
Enum for all companies/owners.
VehicleSettings vehicle
options for vehicles
byte infl_amount_pr
inflation rate for payment rates
uint16 reliability_start
Initial reliability of the engine.
uint16 reliability
Current reliability of the engine.
byte type
Type of this airport,.
VehicleCargoList cargo
The cargo this vehicle is carrying.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
byte infl_amount
inflation amount
Money old_max_loan_unround
Old: Unrounded max loan.
static void SetTileOwner(TileIndex tile, Owner owner)
Sets the owner of a tile.
void Append(CargoPacket *cp, MoveToAction action=MTA_KEEP)
Appends the given cargo packet.
GRFConfig * _grfconfig
First item in list of current GRF set up.
byte landscape
the landscape we're currently in
#define DAYS_TILL_ORIGINAL_BASE_YEAR
The offset in days from the '_date == 0' till 'ConvertYMDToDate(ORIGINAL_BASE_YEAR, 0, 1)'.
void NORETURN SlErrorCorrupt(const char *msg)
Error handler for corrupt savegames.
union Vehicle::@49 orders
The orders currently assigned to the vehicle.
static Titem * Get(size_t index)
Returns Titem with given index.
void ClearGRFConfigList(GRFConfig **config)
Clear a GRF Config list, freeing all nodes.
TileType
The different types of tiles.
-//- TTO (default is neither of these)
void FixOldVehicles()
Convert the old style vehicles into something that resembles the old new style savegames.
Year inaugurated_year
Year of starting the company.
The vehicle is in a drive-through road stop.
uint16 m2
Primarily used for indices to towns, industries and stations.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
A tile with road (or tram tracks)
Maximal number of cargo types in a game.
Date intro_date
Date of introduction of the engine.
byte spritenum
currently displayed sprite index 0xfd == custom sprite, 0xfe == custom second head sprite 0xff == res...
Tile * _m
Tiles of the map.
byte interest_rate
Interest.
void StartupOneEngine(Engine *e, Date aging_date)
Start/initialise one engine.
chunk is valid ONLY for TTD savegames
char * CopyFromOldName(StringID id)
Copy and convert old custom names to UTF-8.
Aircraft, helicopters, rotors and their shadows belong to this class.
Defines the internal data of a functional industry.
DifficultySettings difficulty
settings related to the difficulty
Stores station stats for a single cargo.
Tindex index
Index of this pool item.
A special vehicle is one of the following:
byte _age_cargo_skip_counter
Skip aging of cargo? Used before savegame version 162.
Cargo behaves water-like.
char * _old_name_array
Location to load the old names to.
Contains objects such as transmitters and owned land.
GRFIdentifier ident
grfid and md5sum to uniquely identify newgrfs
StationCargoList cargo
The cargo packets of cargo waiting in this station.
static T max(const T a, const T b)
Returns the maximum of two values.
Town * town
The town this station is associated with.
uint32 max_loan
the maximum initial loan
byte flags
Flags of the engine.
static RoadVehicle * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
GoodsEntry goods[NUM_CARGO]
Goods at this station.
byte random_colour
randomized colour of the industry, for display purpose
VehicleSpriteSeq sprite_seq
Vehicle appearance.
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.
uint16 duration_phase_2
Second reliability phase in months, keeping reliability_max.
static 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.
byte m1
Primarily used for ownership information.
Order * next
Pointer to next order. If nullptr, end of list.
uint _cur_company_tick_index
used to generate a name for one company that doesn't have a name yet per tick
Money expenses
The amount of expenses.
byte subtype
subtype (Filled with values from AircraftSubType/DisasterSubType/EffectVehicleType/GroundVehicleSubty...
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
Buses, trucks and trams belong to this class.
uint16 cargo_cap
total capacity
static bool _read_ttdpatch_flags
Have we (tried to) read TTDPatch extra flags?
The tile has no ownership.
uint16 reliability_spd_dec
Speed of reliability decay between services (per day).
TileIndex xy
town center tile
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
This indicates whether a cargo has a rating at the station.
DateFract _date_fract
Fractional part of the day.
Information about GRF, used in the game and (part of it) in savegames.
byte ReadByte(LoadgameState *ls)
Reads a byte from the buffer and decompress if needed.
Order UnpackOldOrder(uint16 packed)
Unpacks a order from savegames made with TTD(Patch)
void MakeDummy()
Makes this order a Dummy order.
byte road_side
the side of the road vehicles drive on
Year last_prod_year
last year of production
uint32 VehicleID
The type all our vehicle IDs have.
bool IsType(OrderType type) const
Check whether this order is of the given type.
The vehicle is in a tunnel and/or bridge.
Money current_loan
Amount of money borrowed from the bank.
uint16 duration_phase_3
Third reliability phase on months, decaying to reliability_final.
byte status
Status of this cargo, see GoodsEntryStatus.
byte snow_line_height
the configured snow line height
Container for cargo from the same location and time.
uint16 duration_phase_1
First reliability phase in months, increasing reliability from reliability_start to reliability_max...
Data structure to convert between Date and triplet (year, month, and day).
static Town * GetRandom()
Return a random valid town.
IndustryType type
type of industry.
TileExtended * _me
Extended Tiles of the map.
TTDP savegame in new format (data at SE border)
TileArea location
Location of the industry.
The vehicle is in a depot.
CargoID cargo_type
type of cargo this vehicle is carrying
CompanyMask company_avail
Bit for each company whether the engine is available for that company.
uint16 reliability_max
Maximal reliability of the engine.
SavegameType _savegame_type
type of savegame we are loading
Order * old
Only used during conversion of old save games.
Money CalculateCompanyValue(const Company *c, bool including_loan=true)
Calculate the value of the company.
TileIndex tile
Current tile index.
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
Money money
Money owned by the company.
bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks)
Loads a chunk from the old savegame.
byte _trees_tick_ctr
Determines when to consider building more trees.
static void FixTTDDepots()
void AppendStaticGRFConfigs(GRFConfig **dst)
Appends the static GRFs to a list of GRFs.
bool LoadOldVehicle(LoadgameState *ls, int num)
Load the vehicles of an old style savegame.
uint64 flags
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
#define lengthof(x)
Return the length of an fixed size array.
uint16 reliability_final
Final reliability of the engine.
Declarations of strctures and function used in loader of old savegames.
static T min(const T a, const T b)
Returns the minimum of two values.
char * name
Custom name of engine.
uint16 refit_cap
Capacity left over from before last refit.
uint32 _ttdp_version
version of TTDP savegame (if applicable)
static const Year ORIGINAL_BASE_YEAR
The minimum starting year/base year of the original TTD.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
CargoID cargo_type
Cargo type involved in this subsidy, CT_INVALID for invalid subsidy.
CompanyManagerFace face
Face description of the president.
All ships have this type.
static DepotID GetDepotIndex(TileIndex t)
Get the index of which depot is attached to the tile.
static byte RemapTTOColour(byte tto)
static void IncIndustryTypeCount(IndustryType type)
Increment the count of industries for this type.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el)
Appends an element to a list of GRFs.
#define DEBUG(name, level,...)
Output a line of debugging information.
Struct about subsidies, offered and awarded.
'Train' is either a loco or a wagon.
StringID RemapOldStringID(StringID s)
Remap a string ID from the old format to the new format.
TileIndex tile
The base tile of the area.
uint16 _tick_counter
Ever incrementing (and sometimes wrapping) tick counter for setting off various events.
char * name
Name of vehicle.
CompanyID preview_company
Company which is currently being offered a preview INVALID_COMPANY means no company.
Effect vehicle type (smoke, explosions, sparks, bubbles)
byte preview_wait
Daily countdown timer for timeout of offering the engine to the preview_company company.
The tile/execution is done by "water".
RailType
Enumeration for all possible railtypes.
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
TTDP savegame ( -//- ) (data at NW border)
Tunnel entry/exit and bridge heads.
Invisible tiles at the SW and SE border.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
uint16 EngineID
Unique identification number of an engine.
std::vector< TileIndex > _animated_tiles
The table/list with animated tiles.
uint32 TileIndex
The index/ID of a Tile.
Randomizer _random
Random used in the game state calculations.
static const uint64 MAX_INFLATION
Maximum inflation (including fractional part) without causing overflows in int64 price computations...
StringID name_1
Name of the company if the user did not change it.
byte colour
Company colour.
CompanyMask preview_asked
Bit for each company which has already been offered a preview.
StringID president_name_1
Name of the president if the user did not change it.
byte 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 _disaster_delay
Delay counter for considering the next disaster.
TileIndex xy
Base tile of the station.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
VehicleType type
Type of vehicle.
Vehicle * next
pointer to the next vehicle in the chain
static void SetTileType(TileIndex tile, TileType type)
Set the type of a tile.
uint _next_competitor_start
the number of ticks before the next AI is started
static uint16 _old_extra_chunk_nums
Number of extra TTDPatch chunks.
int16 fluct
Economy fluctuation status.
uint64 inflation_payment
Cumulated inflation of cargo paypent since game start; 16 bit fractional part.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() ...
static bool FixTTOEngines()
void AssignOrder(const Order &other)
Assign data to an order (from another order) This function makes sure that the index is maintained co...
LocaleSettings locale
settings related to used currency/unit system in the current game
byte town_name
the town name generator used for town names
static byte _old_vehicle_multiplier
TTDPatch vehicle multiplier.
Colours _company_colours[MAX_COMPANIES]
NOSAVE: can be determined from company structs.
Cargo behaves food/fizzy-drinks-like.
Settings related to the difficulty of the game.
int32 Date
The type to store our dates in.
Money yearly_expenses[3][EXPENSES_END]
Expenses of the company for the last three years, in every ExpensesType category. ...
uint32 grfid
GRF ID (defined by Action 0x08)
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Airport airport
Tile area the airport covers.
Statistics about the economy.
EngineID engine_type
The type of engine used for this vehicle.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
#define FOR_ALL_VEHICLES(var)
Iterate over all vehicles.
GameCreationSettings game_creation
settings used during the creation of a game (map)
A tile without any structures, i.e. grass, rocks, farm fields etc.
Money income
The amount of income.
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
This vehicle is available to everyone.
static uint32 BSWAP32(uint32 x)
Perform a 32 bits endianness bitswap on x.
static bool IsDepotTile(TileIndex tile)
Is the given tile a tile with a depot on it?
byte type
The type (bits 4..7), bridges (2..3), rainforest/desert (0..1)
Money company_value
The value of the company.
uint32 state[2]
The state of the randomizer.
SpriteID sprite
The 'real' sprite.
CompanyEconomyEntry cur_economy
Economic data of the company of this quarter.
byte climates
Climates supported by the engine.
static Station * Get(size_t index)
Gets station with given index.
Date _date
Current date in days (day counter)
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
StringID string_id
Default name (town area) of station.
Declaration of functions used in more save/load files.
static bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
void Append(CargoPacket *cp, StationID next)
Appends the given cargo packet to the range of packets with the same next station.
Set when the station accepts the cargo currently for final deliveries.
Order current_order
The current order (+ status, like: loading)
Dereference the pointer once before writing to it, so we do not have to use big static arrays...
static void MemSetT(T *ptr, byte value, size_t num=1)
Type-safe version of memset().
byte currency
currency we currently use