12 #include "../stdafx.h" 13 #include "../void_map.h" 14 #include "../signs_base.h" 15 #include "../depot_base.h" 17 #include "../gamelog_internal.h" 18 #include "../network/network.h" 19 #include "../network/network_func.h" 20 #include "../gfxinit.h" 21 #include "../viewport_func.h" 22 #include "../industry.h" 23 #include "../clear_map.h" 24 #include "../vehicle_func.h" 25 #include "../string_func.h" 26 #include "../date_func.h" 27 #include "../roadveh.h" 29 #include "../station_base.h" 30 #include "../waypoint_base.h" 31 #include "../roadstop_base.h" 32 #include "../tunnelbridge_map.h" 33 #include "../pathfinder/yapf/yapf_cache.h" 34 #include "../elrail_func.h" 35 #include "../signs_func.h" 36 #include "../aircraft.h" 37 #include "../object_map.h" 38 #include "../object_base.h" 39 #include "../tree_map.h" 40 #include "../company_func.h" 41 #include "../road_cmd.h" 42 #include "../ai/ai.hpp" 43 #include "../ai/ai_gui.hpp" 45 #include "../economy_base.h" 46 #include "../animated_tile_func.h" 47 #include "../subsidy_base.h" 48 #include "../subsidy_func.h" 49 #include "../newgrf.h" 50 #include "../engine_func.h" 51 #include "../rail_gui.h" 52 #include "../core/backup_type.hpp" 53 #include "../smallmap_gui.h" 54 #include "../news_func.h" 55 #include "../order_backup.h" 57 #include "../disaster_vehicle.h" 64 #include "../safeguards.h" 83 if (include_invalid_water_class) {
100 bool has_water =
false;
101 bool has_canal =
false;
102 bool has_river =
false;
111 }
else if (!
IsLock(neighbour)) {
135 if (!has_water && !has_canal && !has_river && include_invalid_water_class) {
140 if (has_river && !has_canal) {
142 }
else if (has_canal || !has_water) {
149 static void ConvertTownOwner()
169 static void UpdateExclusiveRights()
187 static const byte convert_currency[] = {
196 static void UpdateCurrencies()
204 static void UpdateVoidTiles()
214 return rt >= min ? (
RailType)(rt + 1): rt;
244 ResetViewportAfterLoadGame();
247 FOR_ALL_COMPANIES(c) {
264 FOR_ALL_INDUSTRIES(i) {
265 if (i->
psa != NULL) {
271 FOR_ALL_STATIONS(s) {
279 for (std::list<PersistentStorage *>::iterator it = t->psa_list.begin(); it != t->psa_list.end(); ++it) {
305 typedef void (CDECL *SignalHandlerPointer)(int);
306 static SignalHandlerPointer _prev_segfault = NULL;
307 static SignalHandlerPointer _prev_abort = NULL;
308 static SignalHandlerPointer _prev_fpe = NULL;
328 signal(SIGSEGV, _prev_segfault);
329 signal(SIGABRT, _prev_abort);
330 signal(SIGFPE, _prev_fpe);
376 p +=
seprintf(p,
lastof(buffer),
"Loading your savegame caused OpenTTD to crash.\n");
384 "This is most likely caused by a missing NewGRF or a NewGRF that\n" 385 "has been loaded as replacement for a missing NewGRF. OpenTTD\n" 386 "cannot easily determine whether a replacement NewGRF is of a newer\n" 387 "or older version.\n" 388 "It will load a NewGRF with the same GRF ID as the missing NewGRF.\n" 389 "This means that if the author makes incompatible NewGRFs with the\n" 390 "same GRF ID OpenTTD cannot magically do the right thing. In most\n" 391 "cases OpenTTD will load the savegame and not crash, but this is an\n" 393 "Please load the savegame with the appropriate NewGRFs installed.\n" 394 "The missing/compatible NewGRFs are:\n");
401 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);
406 p +=
seprintf(p,
lastof(buffer),
"NewGRF %08X (%s) not found; checksum %s.\n",
BSWAP32(c->ident.grfid), c->filename, buf);
411 "This is probably caused by a corruption in the savegame.\n" 412 "Please file a bug report and attach this savegame.\n");
417 SignalHandlerPointer call = NULL;
419 case SIGSEGV: call = _prev_segfault;
break;
420 case SIGABRT: call = _prev_abort;
break;
421 case SIGFPE: call = _prev_fpe;
break;
422 default: NOT_REACHED();
424 if (call != NULL) call(signum);
482 int entry_x = v->
x_pos;
483 int entry_y = v->
y_pos;
490 default: NOT_REACHED();
492 byte entry_z = GetSlopePixelZ(entry_x, entry_y);
497 byte middle_z = GetSlopePixelZ(middle_x, middle_y);
500 if (middle_z == entry_z)
return 0;
534 if (_cur_tileloop_tile == 0) _cur_tileloop_tile = 1;
546 DEBUG(net, 0,
"The loading savegame was paused due to an error state.");
547 DEBUG(net, 0,
" The savegame cannot be used for multiplayer!");
570 FOR_ALL_STATIONS(st) {
573 for (
TileIndex t = 0; t < map_size; t++) {
575 if (
_m[t].m5 > 7)
continue;
580 assert(dx >= 0 && dy >= 0);
590 for (
TileIndex t = 0; t < map_size; t++) {
592 SB(
_m[t].type, 0, 2,
GB(
_me[t].m6, 0, 2));
593 SB(
_me[t].m6, 0, 2, 0);
595 SB(
_m[t].type, 2, 2,
GB(
_me[t].m6, 6, 2));
596 SB(
_me[t].m6, 6, 2, 0);
598 SB(
_m[t].type, 2, 2, 0);
617 for (
TileIndex t = 0; t < map_size; t++) {
626 FOR_ALL_COMPANIES(c) {
628 if (c->
name != NULL) c->
name_1 = STR_SV_UNNAMED;
634 FOR_ALL_STATIONS(st) {
637 if (st->
name != NULL) st->
string_id = STR_SV_STNAME_FALLBACK;
653 FOR_ALL_STATIONS(st) {
661 FOR_ALL_COMPANIES(c) {
770 FOR_ALL_STATIONS(st) {
783 FOR_ALL_COMPANIES(c) {
837 st = STATION_AIRPORT;
845 }
else if (gfx == 75) {
851 }
else if (gfx == 82) {
855 st = STATION_AIRPORT;
868 SB(
_me[t].m6, 3, 3, st);
875 for (
TileIndex t = 0; t < map_size; t++) {
881 bst->
rect.BeforeAddTile(t, StationRect::ADD_FORCE);
910 case STATION_OILRIG: {
946 for (
TileIndex t = 0; t < map_size; t++) {
976 FOR_ALL_TOWNS(t) UpdateTownMaxPass(t);
983 FOR_ALL_COMPANIES(c) {
1003 for (
TileIndex t = 0; t < map_size; t++) {
1009 uint tmp =
GB(
_m[t].m4, 0, 4);
1010 SB(
_m[t].m4, 0, 4,
GB(
_m[t].m2, 0, 4));
1011 SB(
_m[t].m2, 0, 4, tmp);
1033 for (
TileIndex t = 0; t < map_size; t++) {
1036 SB(
_m[t].m5, 6, 2,
GB(
_m[t].m5, 4, 2));
1040 SB(
_m[t].m4, 0, 4,
GB(
_m[t].m5, 0, 4));
1041 SB(
_m[t].m4, 4, 4, 0);
1042 SB(
_me[t].m6, 2, 4, 0);
1045 SB(
_m[t].m4, 5, 2,
GB(
_m[t].m5, 2, 2));
1073 for (
TileIndex t = 0; t < map_size; t++) {
1077 SB(
_me[t].m7, 5, 1,
GB(
_m[t].m3, 7, 1));
1081 SB(
_me[t].m7, 0, 4,
GB(
_m[t].m3, 0, 4));
1082 SB(
_me[t].m6, 3, 3,
GB(
_m[t].m3, 4, 3));
1083 SB(
_m[t].m3, 0, 4,
GB(
_m[t].m4, 4, 4));
1084 SB(
_m[t].m3, 4, 4,
GB(
_m[t].m5, 0, 4));
1085 SB(
_m[t].m5, 0, 4,
GB(
_m[t].m4, 0, 4));
1089 SB(
_me[t].m7, 0, 5,
GB(
_m[t].m4, 0, 5));
1090 SB(
_me[t].m6, 3, 3,
GB(
_m[t].m3, 4, 3));
1091 SB(
_m[t].m3, 4, 4,
GB(
_m[t].m5, 0, 4));
1092 SB(
_m[t].m5, 0, 1,
GB(
_m[t].m4, 6, 1));
1093 SB(
_m[t].m5, 5, 1,
GB(
_m[t].m4, 5, 1));
1111 SB(
_m[t].m3, 4, 4,
_m[t].m1);
1121 SB(
_me[t].m7, 0, 5, o);
1124 SB(
_me[t].m6, 2, 4,
GB(
_m[t].m2, 4, 4));
1125 SB(
_me[t].m7, 5, 1,
GB(
_m[t].m4, 7, 1));
1139 for (
TileIndex t = 0; t < map_size; t++) {
1165 if (
GB(
_m[t].m5, 3, 2) == 0) {
1182 uint north_south =
GB(
_m[t].m5, 5, 1);
1186 _m[t].
m5 = 1 << 7 | type << 2 | dir;
1230 for (
TileIndex t = 0; t < map_size; t++) {
1283 for (
TileIndex t = 0; t < map_size; t++) {
1301 SB(
_m[t].m4, 4, 4, 0);
1318 FOR_ALL_ROADVEHICLES(rv) {
1325 FOR_ALL_STATIONS(st) {
1338 FOR_ALL_COMPANIES(c) {
1375 for (
TileIndex t = 0; t < map_size; t++) {
1382 FOR_ALL_INDUSTRIES(i) {
1386 for (j = 0; j != 50; j++) PlantRandomFarmField(i);
1396 FOR_ALL_ORDERS(order) {
1415 for (
TileIndex t = 0; t < map_size; t++) {
1420 SB(
_m[t].m5, 3, 2,
GB(
_m[t].m3, 6, 2));
1421 SB(
_m[t].m3, 6, 2, 0);
1452 for (
TileIndex t = 0; t < map_size; t++) {
1455 case GFX_POWERPLANT_SPARKS:
1459 case GFX_OILWELL_ANIMATED_1:
1460 case GFX_OILWELL_ANIMATED_2:
1461 case GFX_OILWELL_ANIMATED_3:
1465 case GFX_COAL_MINE_TOWER_ANIMATED:
1466 case GFX_COPPER_MINE_TOWER_ANIMATED:
1467 case GFX_GOLD_MINE_TOWER_ANIMATED:
1515 for (
TileIndex t = 0; t < map_size; t++) {
1553 FOR_ALL_STATIONS(st) {
1554 std::list<Vehicle *>::iterator iter;
1555 for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end();) {
1577 for (
TileIndex t = 0; t < map_size; t++) {
1581 SB(
_m[t].m2, 4, 4, 0);
1583 SB(
_m[t].m2, 4, 3,
GB(
_m[t].m2, 0, 3));
1591 FOR_ALL_ROADVEHICLES(rv) {
1607 for (
TileIndex t = 0; t < map_size; t++) {
1624 for (
TileIndex t = 0; t < map_size; t++) {
1633 FOR_ALL_STATIONS(st) {
1644 FOR_ALL_INDUSTRIES(i) {
1660 for (
TileIndex t = 0; t < map_size; t++) {
1689 FOR_ALL_ORDERS(order) {
1712 FOR_ALL_COMPANIES(c) {
1713 for (uint i = 0; i < 4; i++) {
1723 for (
TileIndex t = 0; t < map_size; t++) {
1727 case STATION_OILRIG:
1731 SB(
_m[t].m3, 0, 2, 0);
1742 SB(
_m[t].m3, 0, 2, 0);
1757 for (
TileIndex t = 0; t < map_size; t++) {
1779 for (
TileIndex t = 0; t < map_size; t++) {
1788 for (
TileIndex t = 0; t < map_size; t++) {
1856 for (
TileIndex t = 0; t < map_size; t++) {
1859 SB(
_m[t].m3, 5, 1, 0);
1868 FOR_ALL_ROADVEHICLES(v) {
1877 for (
TileIndex t = 0; t < map_size; t++) {
1901 for (
TileIndex t = 0; t < map_size; t++) {
1946 for (
TileIndex t = 0; t < map_size; t++) {
1965 FOR_ALL_STATIONS(st) {
1981 FOR_ALL_COMPANIES(c) {
1986 FOR_ALL_ENGINES(e) {
1998 for (
TileIndex t = 0; t < map_size; t++) {
2010 for (
TileIndex t = 0; t < map_size; t++) {
2026 for (
TileIndex t = 0; t < map_size; t++) {
2033 uint offset =
_m[t].
m3;
2037 SB(
_me[t].m6, 2, 4, 0);
2047 SlError(STR_ERROR_TOO_MANY_OBJECTS);
2091 case 5: layout = 1;
break;
2092 case 0: layout = 2;
break;
2103 FOR_ALL_STATIONS(st) {
2119 FOR_ALL_COMPANIES(c) {
2143 FOR_ALL_STATIONS(st) {
2144 std::list<Vehicle *>::iterator iter;
2145 for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); ++iter) {
2168 for (uint j = 0; !
remove && j < i; j++) {
2169 remove = _animated_tile_list[i] == _animated_tile_list[j];
2199 FOR_ALL_SUBSIDIES(s) {
2237 if (ss != NULL && sd != NULL && ss->
owner == sd->
owner &&
2287 if (t->force_proceed !=
TFP_NONE) {
2296 for (
TileIndex t = 0; t < map_size; t++) {
2306 uint density =
GB(
_m[t].m2, 6, 2);
2307 uint ground =
GB(
_m[t].m2, 4, 2);
2308 uint counter =
GB(
_m[t].m2, 0, 4);
2309 _m[t].
m2 = ground << 6 | density << 4 | counter;
2329 struct AirportTileConversion {
2333 static const AirportTileConversion atc[] = {
2344 for (
TileIndex t = 0; t < map_size; t++) {
2348 for (uint i = 0; i <
lengthof(atc); i++) {
2349 if (old_gfx < atc[i].old_start) {
2353 if (old_gfx < atc[i].old_start + atc[i].num_frames) {
2358 offset += atc[i].num_frames - 1;
2366 FOR_ALL_STATIONS(st) {
2375 for (
TileIndex t = 0; t < map_size; t++) {
2384 FOR_ALL_DEPOTS(d) d->
town_cn = UINT16_MAX;
2419 for (
TileIndex t = 0; t < map_size; t++) {
2423 uint per_proc =
_me[t].
m7;
2425 SB(
_m[t].m3, 5, 1, 0);
2426 SB(
_me[t].m6, 2, 6,
min(per_proc, 63));
2431 uint rand =
_me[t].
m7;
2452 FOR_ALL_OBJECTS(o) {
2459 for (
TileIndex t = 0; t < map_size; t++) {
2514 hidden = frame >= _tunnel_visibility_frame[dir];
2517 hidden = frame <
TILE_SIZE - _tunnel_visibility_frame[dir];
2535 default: NOT_REACHED();
2543 default: NOT_REACHED();
2551 FOR_ALL_ROADVEHICLES(rv) {
2568 if (!
HasBit(t->flags, 5))
continue;
2576 FOR_ALL_COMPANIES(c) {
2707 FOR_ALL_INDUSTRIES(ind) {
2708 assert(ind->
psa != NULL);
2711 bool is_empty =
true;
2712 for (uint i = 0; i <
sizeof(ind->
psa->
storage); i++) {
2730 FOR_ALL_STATIONS(st) {
2735 bool is_empty =
true;
2761 for (
TileIndex t = 0; t < map_size; t++) {
2764 uint fence =
GB(
_m[t].m4, 5, 3);
2768 fence =
GB(
_m[t].m4, 2, 3);
2772 SB(
_m[t].m4, 2, 3, 0);
2773 SB(
_m[t].m4, 5, 3, 0);
2800 _saved_scrollpos_zoom = _saved_scrollpos_zoom + ZOOM_LVL_SHIFT;
2801 _saved_scrollpos_x *= ZOOM_LVL_BASE;
2802 _saved_scrollpos_y *= ZOOM_LVL_BASE;
2812 for (
TileIndex t = 0; t < map_size; t++) {
2818 FOR_ALL_TOWNS(town) {
2825 for (
TileIndex t = 0; t < map_size; t++) {
2845 FOR_ALL_COMPANIES(c) {
2851 extern uint8 _old_diff_level;
2868 for (
TileIndex t = 0; t < map_size; t++) {
2877 extern uint8 _old_units;
2888 for (
TileIndex t = 0; t < map_size; t++) {
2906 FOR_ALL_ROADVEHICLES(v) {
2908 skip_frames.
Clear();
2910 uint prev_tile_skip = 0;
2913 if (u->tile != prev_tile) {
2914 prev_tile_skip = cur_skip;
2915 prev_tile = u->tile;
2917 cur_skip = prev_tile_skip;
2920 uint *this_skip = skip_frames.
Append();
2921 *this_skip = 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 *it = skip_frames.
Begin(); it != skip_frames.
End(); ++it, prev = u, u = u->
Next()) {
2949 if (*it >= cur_skip) IndividualRoadVehicleController(u, prev);
2963 #ifndef DEBUG_DUMP_COMMANDS 2982 AfterLoadLabelMaps();
3016 AfterLoadStations();
bool disable_elrails
when true, the elrails are disabled
Flag for an invalid direction.
TileIndex tile
NOSAVE: Used to identify in the owner of the array in debug output.
void SetupColoursAndInitialWindow()
Initialise the default colours (remaps and the likes), and load the main windows. ...
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
static const uint TOWN_GROWTH_WINTER
The town only needs this cargo in the winter (any amount)
static void UpdateAfterLoad()
Update all caches after loading a game, changing NewGRF etc.
VehicleSettings vehicle
options for vehicles
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner)
Change the owner of a tile.
static void Swap(T &a, T &b)
Type safe swap operation.
byte type
Type of this airport,.
Vehicle is stopped by the player.
Source/destination is a town.
uint8 max_heightlevel
maximum allowed heightlevel
static void ResetSignalHandlers()
Resets signal handlers back to original handlers.
static void ClearBridgeMiddle(TileIndex t)
Removes bridges from the given, that is bridges along the X and Y axis.
static uint MapSizeX()
Get the size of the map along the X.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static void StartNew(CompanyID company, bool rerandomise_ai=true)
Start a new AI company.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
void UpdateNearestTownForRoadTiles(bool invalidate)
Updates cached nearest town for all road tiles.
bool _networking
are we in networking mode?
Default settings for vehicles.
void CopyTempEngineData()
Copy data from temporary engine array into the real engine pool.
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
void UpdateOldAircraft()
need to be called to load aircraft from old version
uint16 town_cn
The N-1th waypoint for this town (consecutive number)
static void SetAnimationFrame(TileIndex t, byte frame)
Set a new animation frame.
void UpdateTownCargoes(Town *t)
Update cargo acceptance for the complete town.
static void SetTunnelBridgeReservation(TileIndex t, bool b)
Set the reservation state of the rail tunnel/bridge.
const AirportSpec * GetSpec() const
Get the AirportSpec that from the airport type of this airport.
Money old_max_loan_unround
Old: Unrounded max loan.
static void SetTileOwner(TileIndex tile, Owner owner)
Sets the owner of a tile.
static const byte TOWN_HOUSE_COMPLETED
Simple value that indicates the house has reached the final stage of construction.
char * name
Name of the company if the user changed it.
static void FixOwnerOfRailTrack(TileIndex t)
Tries to change owner of this rail tile to a valid owner.
static void MakeVoid(TileIndex t)
Make a nice void tile ;)
GRFConfig * _grfconfig
First item in list of current GRF set up.
static DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
byte landscape
the landscape we're currently in
IndustryBuildData _industry_builder
In-game manager of industries.
DirectionByte direction
facing
byte size_y
size of airport in y direction
RailType
Enumeration for all possible railtypes.
Non-existing type of vehicle.
void BuildOwnerLegend()
Completes the array for the owned property legend.
static void CDECL HandleSavegameLoadCrash(int signum)
Signal handler used to give a user a more useful report for crashes during the savegame loading proce...
SourceID src
Index of source. Either TownID or IndustryID.
static bool IsAirportTile(TileIndex t)
Is this tile a station tile and an airport tile?
All GRF needed by game are present.
EconomySettings economy
settings to change the economy
Vehicle has finished loading.
void AfterLoadCompanyStats()
Rebuilding of company statistics after loading a savegame.
#define DAYS_TILL_ORIGINAL_BASE_YEAR
The offset in days from the '_date == 0' till 'ConvertYMDToDate(ORIGINAL_BASE_YEAR, 0, 1)'.
Compatible (eg. the same ID, but different checksum) GRF found in at least one case.
static bool IsWater(TileIndex t)
Is it a plain water tile?
void NORETURN SlErrorCorrupt(const char *msg)
Error handler for corrupt savegames.
static Titem * Get(size_t index)
Returns Titem with given index.
static bool IsBridgeTile(TileIndex t)
checks if there is a bridge on this tile
static bool IsInsideMM(const T x, const uint min, const uint max)
Checks if a value is in an interval.
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
Town * town
Town the object is built in.
OwnerByte founder
Founder of the industry.
byte units_weight
unit system for weight
CompanyByte exclusivity
which company has exclusivity
void SetWaterClassDependingOnSurroundings(TileIndex t, bool include_invalid_water_class)
Makes a tile canal or water depending on the surroundings.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
The vehicle is in a drive-through road stop.
Year inaugurated_year
Year of starting the company.
byte m7
Primarily used for newgrf support.
void CheckTrainsLengths()
Checks if lengths of all rail vehicles are valid.
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.
uint16 old_max_loan_unround_fract
Old: Fraction of the unrounded max loan.
static void MakeShore(TileIndex t)
Helper function to make a coast tile.
EngineRenewList engine_renew_list
Engine renewals of this company.
uint16 cur_speed
current speed
A tile with road (or tram tracks)
bool road_use_yapf
use YAPF for road
void ReserveTrackUnderConsist() const
Tries to reserve track under whole train consist.
uint32 GetGRFID(uint16 entity_id) const
Gives the GRFID of the file the entity belongs to.
static const ObjectType OBJECT_STATUE
Statue in towns.
static IndustryGfx GetIndustryGfx(TileIndex t)
Get the industry graphics ID for the given industry tile.
Date intro_date
Date of introduction of the engine.
Full road along the x-axis (south-west + north-east)
uint64 inflation_prices
Cumulated inflation of prices since game start; 16 bit fractional part.
SourceID dst
Index of destination. Either TownID or IndustryID.
Tile * _m
Tiles of the map.
The Original PathFinder (only for ships)
void NORETURN SlError(StringID string, const char *extra_msg)
Error handler.
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
Specification of a cargo type.
static TileIndex GetOtherShipDepotTile(TileIndex t)
Get the other tile of the ship depot.
TileIndex dock_tile
The location of the dock.
OrderList * list
Pointer to the order list for this vehicle.
TileIndex dest_tile
Heading for this tile.
CompanyMask bankrupt_asked
which companies were asked about buying it?
uint16 wait_counter
Ticks waiting in front of a signal, ticks being stuck or a counter for forced proceeding through sign...
static bool IsRoadStop(TileIndex t)
Is the station at t a road station?
DistributionTypeByte distribution_mail
distribution type for mail
char * CopyFromOldName(StringID id)
Copy and convert old custom names to UTF-8.
static TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir. ...
Aircraft, helicopters, rotors and their shadows belong to this class.
char * md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
Convert the md5sum to a hexadecimal string representation.
Manual distribution. No link graph calculations are run.
Date build_date
Date of construction.
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
uint32 changes
Number of changes in this action.
static uint TileX(TileIndex tile)
Get the X component of a tile.
void AfterLoadStoryBook()
Called after load to trash broken pages.
PathfinderSettings pf
settings for all pathfinders
TileArea train_station
Tile area the train 'station' part covers.
Only used when retrieving move data.
static TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
byte colour
Colour of the object, for display purpose.
GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig)
Check if all GRFs in the GRF config from a savegame can be loaded.
void UpdateAllTownVirtCoords()
Update the virtual coords needed to draw the town sign for all towns.
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
static void AfterLoad()
Savegame conversion for cargopackets.
void Clear()
Remove all items from the list.
void SetRefit(CargoID cargo)
Make this depot/station order also a refit order.
TownLayoutByte town_layout
select town layout,
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
byte units_velocity
unit system for velocity
Defines the internal data of a functional industry.
const T * Begin() const
Get the pointer to the first item (const)
DifficultySettings difficulty
settings related to the difficulty
Tindex index
Index of this pool item.
Vehicle is flying in the air.
byte months_of_bankruptcy
Number of months that the company is unable to pay its debts.
Northeast, upper right on your monitor.
char * president_name
Name of the president if the user changed it.
static const int DAY_TICKS
1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885.
SourceTypeByte src_type
Source of subsidised path (ST_INDUSTRY or ST_TOWN)
T * First() const
Get the first vehicle in the chain.
bool forbid_90_deg
forbid trains to make 90 deg turns
Cargo behaves water-like.
Representation of a waypoint.
StationID last_station_visited
The last station we stopped at.
static void SetRailStationReservation(TileIndex t, bool b)
Set the reservation state of the rail station.
#define lastof(x)
Get the last element of an fixed size array.
byte feature
NOSAVE: Used to identify in the owner of the array in debug output.
Simple vector template class.
const byte _tunnel_visibility_frame[DIAGDIR_END]
Frame when a vehicle should be hidden in a tunnel with a certain direction.
void GamelogPrintDebug(int level)
Prints gamelog to debug output.
void SetUnloadType(OrderUnloadFlags unload_type)
Set how the consist must be unloaded.
A game paused because a (critical) error.
uint16 tree_frame_burst
how many trees may, over a short period, be planted?
GRF file was not found in the local cache.
Cargo behaves goods/candy-like.
void AircraftNextAirportPos_and_Order(Aircraft *v)
set the right pos when heading to other airports after takeoff
void GamelogOldver()
Logs loading from savegame without gamelog.
Contains objects such as transmitters and owned land.
RoadTypes GetCompanyRoadtypes(CompanyID company)
Get the road types the given company can build.
static uint FixVehicleInclination(Vehicle *v, Direction dir)
Fixes inclination of a vehicle.
Standard non-electric rails.
static void InitializeWindowsAndCaches()
Initialization of the windows and several kinds of caches.
void ShowAIDebugWindowIfAIError()
Open the AI debug window if one of the AI scripts has crashed.
static bool IsStandardRoadStopTile(TileIndex t)
Is tile t a standard (non-drive through) road stop station?
GRFIdentifier ident
grfid and md5sum to uniquely identify newgrfs
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...
static bool IsLevelCrossing(TileIndex t)
Return whether a tile is a level crossing.
static void SetWaterClass(TileIndex t, WaterClass wc)
Set the water class at a tile.
RoadType
The different roadtypes we support.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
byte units_force
unit system for force
static bool IsDriveThroughStopTile(TileIndex t)
Is tile t a drive through road stop station?
bool allow_town_roads
towns are allowed to build roads (always allowed when generating world / in SE)
Town * town
The town this station is associated with.
GRFIdentifier grfcompat
ID and new md5sum of changed GRF.
byte units_height
unit system for height
static bool IsClearGround(TileIndex t, ClearGround ct)
Set the type of clear tile.
uint32 max_loan
the maximum initial loan
Year _cur_year
Current year, starting at 0.
uint16 w
The width of the area.
bool infrastructure_maintenance
enable monthly maintenance fee for owner infrastructure
Basic data to distinguish a GRF.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
bool IsTileFlat(TileIndex tile, int *h)
Check if a given tile is flat.
uint _gamelog_actions
number of actions
CompanySettings settings
settings specific for each company
const T * End() const
Get the pointer behind the last valid item (const)
bool AfterLoadGame()
Perform a (large) amount of savegame conversion magic in order to load older savegames and to fill th...
bool IsNormalAircraft() const
Check if the aircraft type is a normal flying device; eg not a rotor or a shadow. ...
static StationType GetStationType(TileIndex t)
Get the station type of this tile.
StationSettings station
settings related to station management
GoodsEntry goods[NUM_CARGO]
Goods at this station.
static const uint TILE_SIZE
Tile size in world coordinates.
struct GRFConfig * next
NOSAVE: Next item in the linked list.
Direction
Defines the 8 directions on the map.
void UpdateStationAcceptance(Station *st, bool show_msg)
Update the acceptance for a station.
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.
TileIndex GetNorthernBridgeEnd(TileIndex t)
Finds the northern end of a bridge starting at a middle tile.
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track)
Use this function to notify YAPF that track layout (or signal configuration) has change.
static Station * From(BaseStation *st)
Converts a BaseStation to SpecializedStation with type checking.
#define FOR_ALL_CARGO_PAYMENTS(var)
Iterate over all cargo payments.
Money profit_last_year
Profit last year << 8, low 8 bits are fract.
byte m1
Primarily used for ownership information.
static bool IsLock(TileIndex t)
Is there a lock on a given water tile?
T * Append(uint to_add=1)
Append an item and return it.
bool _network_dedicated
are we a dedicated server?
Date build_date
Date of construction.
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
Class to backup a specific variable and restore it later.
TileIndex * _animated_tile_list
The table/list with animated tiles.
static bool HasStationRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint...
uint32 goal[NUM_TE]
Amount of cargo required for the town to grow.
bool freeform_edges
allow terraforming the tiles at the map edges
static bool IsHouseCompleted(TileIndex t)
Get the completion of this house.
Stop at the far end of the platform.
static const size_t MAX_SIZE
Make template parameter accessible from outside.
byte subtype
subtype (Filled with values from #EffectVehicles/#TrainSubTypes/#AircraftSubTypes) ...
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...
bool reverse_at_signals
whether to reverse at signals at all
TrackBits
Bitfield corresponding to Track.
Buses, trucks and trams belong to this class.
Fake town GrfSpecFeature for NewGRF debugging (parent scope)
uint _animated_tile_count
The number of animated tiles in the current state.
Critical errors, the MessageBox is shown in all cases.
static bool IsTileOwner(TileIndex tile, Owner owner)
Checks if a tile belongs to the given owner.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=NULL, uint textref_stack_size=0, const uint32 *textref_stack=NULL)
Display an error message in a window.
void UpdateAirportsNoise()
Recalculate the noise generated by the airports of each town.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold...
static void SetCrossingReservation(TileIndex t, bool b)
Set the reservation state of the rail crossing.
void SetDate(Date date, DateFract fract)
Set the date.
static void MakeSea(TileIndex t)
Make a sea tile.
byte acceleration
used by train & aircraft
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
TileIndex xy
town center tile
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
static bool IsBuoy(TileIndex t)
Is tile t a buoy tile?
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a give tiletype.
void MakeDefaultName(T *obj)
Set the default name for a depot/waypoint.
TYPE GetValue(uint pos) const
Gets the value from a given position.
static bool _saveload_crash_with_missing_newgrfs
Was the saveload crash because of missing NewGRFs?
The vehicle is in a road stop.
uint32 terraform_limit
Amount of tileheights we can (still) terraform (times 65536).
void SetNonStopType(OrderNonStopFlags non_stop_type)
Set whether we must stop at stations or not.
static bool IsCoast(TileIndex t)
Is it a coast tile?
RoadStop * truck_stops
All the truck stops.
Contains information about one logged action that caused at least one logged change.
This indicates whether a cargo has a rating at the station.
void ConvertOldMultiheadToNew()
Converts all trains to the new subtype format introduced in savegame 16.2 It also links multiheaded e...
PersistentStorage * psa
Persistent storage for NewGRF industries.
DateFract _date_fract
Fractional part of the day.
static Owner GetRoadOwner(TileIndex t, RoadType rt)
Get the owner of a specific road type.
#define FOR_ALL_ORDER_BACKUPS(var)
Iterator over all order backups.
void UpdateAircraftCache(Aircraft *v, bool update_range=false)
Update cached values of an aircraft.
CompanySettings company
default values for per-company settings
Information about GRF, used in the game and (part of it) in savegames.
Vehicle * front
The front vehicle to do the payment of.
void ConsistChanged(ConsistChangeFlags allowed_changes)
Recalculates the cached stuff of a train.
YAPFSettings yapf
pathfinder settings for the yet another pathfinder
static void SetStationGfx(TileIndex t, StationGfx gfx)
Set the station graphics of this tile.
static void SetRoadOwner(TileIndex t, RoadType rt, Owner o)
Set the owner of a specific road type.
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
int16 ratings[MAX_COMPANIES]
ratings of each company for this town
VehicleDefaultSettings vehicle
default settings for vehicles
byte road_side
the side of the road vehicles drive on
WaterClass
classes of water (for WATER_TILE_CLEAR water tile type).
static bool IsTruckStop(TileIndex t)
Is the station at t a truck stop?
void MoveBuoysToWaypoints()
Perform all steps to upgrade from the old station buoys to the new version that uses waypoints...
static bool HasTownOwnedRoad(TileIndex t)
Checks if given tile has town owned road.
byte units_volume
unit system for volume
Year last_prod_year
last year of production
static TownID GetTownIndex(TileIndex t)
Get the index of which town this house/street is attached to.
bool IsType(OrderType type) const
Check whether this order is of the given type.
The vehicle is in a tunnel and/or bridge.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
void UpdateAllVirtCoords()
Update the viewport coordinates of all signs.
T * Next() const
Get next vehicle in the chain.
ClientSettings _settings_client
The current settings for this game.
byte status
Status of this cargo, see GoodsEntryStatus.
byte snow_line_height
the configured snow line height
static bool HasStationTileRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint...
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
void DeleteAnimatedTile(TileIndex tile)
Removes the given tile from the animated tile table.
TileIndex location_of_HQ
Northern tile of HQ; INVALID_TILE when there is none.
void LoadStringWidthTable(bool monospace)
Initialize _stringwidth_table cache.
uint32 grfid
GRFID associated to this persistent storage. A value of zero means "default".
static const int GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET
The offset for the drive through parts.
#define TILE_ADDXY(tile, x, y)
Adds a given offset to a tile.
Track in the lower corner of the tile (south)
IndustryType GetIndustryType(TileIndex tile)
Retrieve the type for this industry.
IndustryType type
type of industry.
uint32 clear_limit
Amount of tiles we can (still) clear (times 65536).
TileExtended * _me
Extended Tiles of the map.
First company, same as owner.
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
bool dynamic_engines
enable dynamic allocation of engine data
CargoID accepts_cargo[3]
3 input cargo slots
Station * GetTargetAirportIfValid(const Aircraft *v)
Returns aircraft's target station if v->target_airport is a valid station with airport.
static void SetClearGroundDensity(TileIndex t, ClearGround type, uint density)
Sets ground type and density in one go, also sets the counter to 0.
void FreeChain(bool keep_orderlist=false)
Free a complete order chain.
void UpdateRealOrderIndex()
Skip implicit orders until cur_real_order_index is a non-implicit order.
An object, such as transmitter, on the map.
TileArea location
Location of the industry.
TYPE storage[SIZE]
Memory to for the storage array.
The vehicle is in a depot.
uint32 engine_renew_money
minimum amount of money before autorenew is used
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
CompanyMask company_avail
Bit for each company whether the engine is available for that company.
static bool IsBuoyTile(TileIndex t)
Is tile t a buoy tile?
uint16 load_unload_ticks
Ticks to wait before starting next cycle.
const CargoSpec * FindFirstCargoWithTownEffect(TownEffect effect)
Determines the first cargo with a certain town effect.
void GamelogGRFAddList(const GRFConfig *newg)
Logs adding of list of GRFs.
CompanyByte awarded
Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone.
static void SetSignalStates(TileIndex tile, uint state)
Set the states of the signals (Along/AgainstTrackDir)
Company colour selection; Window numbers:
uint16 max_bridge_length
maximum length of bridges
bool IsFrontEngine() const
Check if the vehicle is a front engine.
static WaterTileType GetWaterTileType(TileIndex t)
Get the water tile type at a tile.
Order * GetFirstOrder() const
Get the first order of the order chain.
TileIndex tile
Current tile index.
Defines the data structure for constructing industry.
CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32 face)
Converts an old company manager's face format to the new company manager's face format.
Grass with a fence and shore or water on the free halftile.
void SetSaveLoadError(StringID str)
Set the error message from outside of the actual loading/saving of the game (AfterLoadGame and friend...
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
The tile has no ownership.
static void SetHouseCompleted(TileIndex t, bool status)
Mark this house as been completed.
PersistentStorage * psa
Persistent storage for NewGRF airports.
CargoID produced_cargo[2]
2 production cargo slots
static Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
const byte _road_stop_stop_frame[]
Table of road stop stop frames, when to stop at a road stop.
DistributionTypeByte distribution_pax
distribution type for passengers
void UpdateAllSignVirtCoords()
Update the coordinates of all signs.
void GamelogGRFCompatible(const GRFIdentifier *newg)
Logs loading compatible GRF (the same ID, but different MD5 hash)
void AfterLoadLinkGraphs()
Spawn the threads for running link graph calculations.
StationFacilityByte facilities
The facilities that this station has.
uint16 clear_frame_burst
how many tiles may, over a short period, be cleared?
bool renew_keep_length
sell some wagons if after autoreplace the train is longer than before
DiagDirection
Enumeration for diagonal directions.
static bool IsSavegameVersionBefore(uint16 major, byte minor=0)
Checks whether the savegame is below major.
#define lengthof(x)
Return the length of an fixed size array.
byte last_speed
Maximum speed (up to 255) of the last vehicle that tried to load this cargo.
PauseModeByte _pause_mode
The current pause mode.
Company * DoStartupNewCompany(bool is_ai, CompanyID company=INVALID_COMPANY)
Create a new company and sets all company variables default values.
IndustryBehaviour behaviour
How this industry will behave, and how others entities can use it.
static uint TileHash(uint x, uint y)
Calculate a hash value from a tile position.
void UpdateHousesAndTowns()
Check and update town and house values.
static T min(const T a, const T b)
Returns the minimum of two values.
void GamelogTestRevision()
Finds out if current revision is different than last revision stored in the savegame.
static bool IsShipDepotTile(TileIndex t)
Is it a ship depot tile?
Helper class to perform the cargo payment.
uint16 ObjectType
Types of objects.
uint8 plane_speed
divisor for speed of aircraft
static void SetBridgeMiddle(TileIndex t, Axis a)
Set that there is a bridge over the given axis.
static const Year ORIGINAL_BASE_YEAR
The minimum starting year/base year of the original TTD.
static DiagDirection GetTunnelBridgeDirection(TileIndex t)
Get the direction pointing to the other end.
static bool IsPlainRailTile(TileIndex t)
Checks whether the tile is a rail tile or rail tile with signals.
byte number_towns
the amount of towns
Vehicle is currently going uphill. (Cached track information for acceleration)
a desert or snow tile, depend on landscape
Vehicle's pathfinder is lost.
RailTypes GetCompanyRailtypes(CompanyID company)
Get the rail types the given company can build.
CargoID cargo_type
Cargo type involved in this subsidy, CT_INVALID for invalid subsidy.
static StationGfx GetStationGfx(TileIndex t)
Get the station graphics of this tile.
void UpdateLevelCrossing(TileIndex tile, bool sound=true)
Sets correct crossing state.
CompanyManagerFace face
Face description of the president.
uint8 plane_crashes
number of plane crashes, 0 = none, 1 = reduced, 2 = normal
Maximum number of companies.
RoadTypes
The different roadtypes we support, but then a bitmask of them.
RoadStop * bus_stops
All the road stops.
Year build_year
Year the vehicle has been built.
uint32 tree_limit
Amount of trees we can (still) plant (times 65536).
Transfer all cargo onto the platform.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
byte state
State of the airport.
int16 engine_renew_months
months before/after the maximum vehicle age a vehicle should be renewed
byte turn_counter
Ticks between each turn to prevent > 45 degree turns.
bool engine_renew
is autorenew enabled
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static bool HasSignals(TileIndex t)
Checks if a rail tile has signals.
OrderUnloadFlags GetUnloadType() const
How must the consist be unloaded?
ScriptSettings script
settings for scripts
void MoveWaypointsToBaseStations()
Perform all steps to upgrade from the old waypoints to the new version that uses station.
void SetLoadType(OrderLoadFlags load_type)
Set how the consist must be loaded.
#define DEBUG(name, level,...)
Output a line of debugging information.
Struct about subsidies, offered and awarded.
'Train' is either a loco or a wagon.
LoggedAction * _gamelog_action
first logged action
Maximal number of cargo types in a game.
byte units_power
unit system for power
static RoadBits GetCrossingRoadBits(TileIndex tile)
Get the road bits of a level crossing.
TileIndex tile
The base tile of the area.
static uint GetClearDensity(TileIndex t)
Get the density of a non-field clear tile.
OwnerByte owner
The owner of this station.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset)
Mark a tile given by its index dirty for repaint.
void StartupEngines()
Start/initialise all our engines.
void ResetOldNames()
Free the memory of the old names array.
uint8 train_slope_steepness
Steepness of hills for trains when using realistic acceleration.
void ShowNewGRFError()
Show the first NewGRF error we can find.
void UpdateAllStationVirtCoords()
Update the virtual coords needed to draw the station sign for all stations.
static Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
Cargo behaves passenger-like.
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
Bitflag for a wormhole (used for tunnels)
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
byte StationGfx
Copy from station_map.h.
Company infrastructure overview; Window numbers:
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
static const uint TOWN_GROWTH_DESERT
The town needs the cargo for growth when on desert (any amount)
static const uint MIN_SNOWLINE_HEIGHT
Minimum snowline height.
void ConnectMultiheadedTrains()
Link front and rear multiheaded engines to each other This is done when loading a savegame...
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
Vehicle is currently going downhill. (Cached track information for acceleration)
static uint MapSize()
Get the size of the map.
TownEffect town_effect
The effect that delivering this cargo type has on towns. Also affects destination of subsidies...
StationType
Station types.
GamelogActionType at
Type of action.
void SetAircraftPosition(Aircraft *v, int x, int y, int z)
Set aircraft position.
Flag for an invalid track.
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
static RoadTileType GetRoadTileType(TileIndex t)
Get the type of the road tile.
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
static bool IsRailDepot(TileIndex t)
Is this rail tile a rail depot?
bool IsStationTileBlocked(TileIndex tile)
Check whether a rail station tile is NOT traversable.
Tunnel entry/exit and bridge heads.
DestinationID GetDestination() const
Gets the destination of this order.
is built on water (oil rig)
static bool IsRailDepotTile(TileIndex t)
Is this tile rail tile and a rail depot?
Invisible tiles at the SW and SE border.
bool station_noise_level
build new airports when the town noise level is still within accepted limits
static DiagDirection XYNSToDiagDir(Axis xy, uint ns)
Convert an axis and a flag for north/south into a DiagDirection.
void RecomputePrices()
Computes all prices, payments and maximum loan.
static void SetLiftPosition(TileIndex t, byte pos)
Set the position of the lift on this animated house.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
CompanyByte _current_company
Company currently doing an action.
static bool IsShipDepot(TileIndex t)
Is it a water tile with a ship depot on it?
uint32 TileIndex
The index/ID of a Tile.
void FixupTrainLengths()
Fixup old train spacing.
GRFListCompatibility
Status of post-gameload GRF compatibility check.
OwnerByte share_owners[4]
Owners of the 4 shares of the company. INVALID_OWNER if nobody has bought them yet.
static size_t GetNumItems()
Returns number of valid items in the pool.
SourceTypeByte dst_type
Destination of subsidised path (ST_INDUSTRY or ST_TOWN)
A town owns the tile, or a town is expanding.
static const uint64 MAX_INFLATION
Maximum inflation (including fractional part) without causing overflows in int64 price computations...
Date date_of_last_service
Last date the vehicle had a service at a depot.
static void IncTypeCount(ObjectType type)
Increment the count of objects for this type.
RailTypes avail_railtypes
Rail types available to the company.
StringID name_1
Name of the company if the user did not change it.
bool ship_use_yapf
use YAPF for ships
Information about a aircraft vehicle.
bool modified_catchment
different-size catchment areas
At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE)
CargoPayment * cargo_payment
The cargo payment we're currently in.
LoggedChange * change
First logged change in this action.
static HouseID GetHouseType(TileIndex t)
Get the type of this house, which is an index into the house spec array.
static bool IsLevelCrossingTile(TileIndex t)
Return whether a tile is a level crossing tile.
Source/destination is an industry.
StringID president_name_1
Name of the president if the user did not change it.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Only set when a vehicle has entered the stop.
static Direction AxisToDirection(Axis a)
Converts an Axis to a Direction.
void AfterLoadRoadStops()
(Re)building of road stop caches after loading a savegame.
static void MakeClear(TileIndex t, ClearGround g, uint density)
Make a clear tile.
OwnerByte owner
Which company owns the vehicle?
Contains information about one logged change.
uint8 pathfinder_for_trains
the pathfinder to use for trains
uint16 terraform_frame_burst
how many tile heights may, over a short period, be terraformed?
Old-fashioned semaphore signal.
byte size_x
size of airport in x direction
byte height
The height of the northern corner.
RoadTypes avail_roadtypes
Road types available to this company.
TileIndex xy
Base tile of the station.
TileArea location
Location of the object.
void RebuildSubsidisedSourceAndDestinationCache()
Perform a full rebuild of the subsidies cache.
TransportType
Available types of transport.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
uint16 cached_total_length
Length of the whole vehicle (valid only for the first engine).
byte wait_twoway_signal
waitingtime in days before a twoway signal
static ClearGround GetRawClearGround(TileIndex t)
Get the type of clear tile but never return CLEAR_SNOW.
static bool IsOilRig(TileIndex t)
Is tile t part of an oilrig?
ObjectType type
Type of the object.
void AfterLoadVehicles(bool part_of_load)
Called after load to update coordinates.
const TileTypeProcs *const _tile_type_procs[16]
Tile callback functions for each type of tile.
VehicleDefaultSettings _old_vds
Used for loading default vehicles settings from old savegames.
uint8 larger_towns
the number of cities to build. These start off larger and grow twice as fast
static const HouseID NEW_HOUSE_OFFSET
Offset for new houses.
static uint MapMaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
static void MakeCanal(TileIndex t, Owner o, uint8 random_bits)
Make a canal tile.
uint64 inflation_payment
Cumulated inflation of cargo paypent since game start; 16 bit fractional part.
Station with train station.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() ...
Transport by road vehicle.
The vehicle will not stop at any stations it passes except the destination.
static const uint TILE_UNIT_MASK
For masking in/out the inner-tile world coordinate units.
LocaleSettings locale
settings related to used currency/unit system in the current game
static void RecomputeIndustriesNearForAll()
Recomputes Station::industries_near for all stations.
The vehicle is in a road stop.
byte town_name
the town name generator used for town names
Extended original algorithm (min. 2 distance between roads)
bool larger_town
if this is a larger town and should grow more quickly
char * name
Custom town name. If NULL, the town was not renamed and uses the generated name.
bool _network_server
network-server is active
A Stop for a Road Vehicle.
void GamelogGRFRemove(uint32 grfid)
Logs removal of a GRF.
void InitializeRailGUI()
Resets the rail GUI - sets default railtype to build and resets the signal GUI.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
#define FOR_ALL_AIRCRAFT(var)
Macro for iterating over all aircrafts.
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
AbstractFileType abstract_ftype
Abstract type of file (scenario, heightmap, etc).
Proceed till next signal, but ignore being stuck till then. This includes force leaving depots...
uint8 train_acceleration_model
realistic acceleration for trains
Fields are planted around when built (all farms)
Cargo behaves food/fizzy-drinks-like.
TownLayoutByte layout
town specific road layout
static void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, TownID town, Owner road, Owner tram)
Make a normal road tile.
ConstructionSettings construction
construction of things in-game
CargoID accepts_cargo[3]
3 accepted cargoes.
static const Year MIN_YEAR
The absolute minimum & maximum years in OTTD.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
VehicleOrderID GetNumOrders() const
Get the number of orders this vehicle has.
#define FOR_ALL_DISASTERVEHICLES(var)
Iterate over disaster vehicles.
static RoadTypes GetRoadTypes(TileIndex t)
Get the present road types of a tile.
uint32 grfid
GRF ID (defined by Action 0x08)
bool IsFreeWagon() const
Check if the vehicle is a free wagon (got no engine in front of it).
static bool IsTunnelTile(TileIndex t)
Is this a tunnel (entrance)?
Airport airport
Tile area the airport covers.
uint8 roadveh_acceleration_model
realistic acceleration for road vehicles
byte running_ticks
Number of ticks this vehicle was not stopped this day.
EngineID engine_type
The type of engine used for this vehicle.
uint8 settings_profile
difficulty profile to set initial settings of scripts, esp. random AIs
uint16 vehicle_flags
Used for gradual loading and other miscellaneous things (.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
void Restore()
Restore the variable.
#define FOR_ALL_VEHICLES(var)
Iterate over all vehicles.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
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 ...
bool AddInflation(bool check_year)
Add monthly inflation.
static void SetFence(TileIndex t, DiagDirection side, uint h)
Sets the type of fence (and whether there is one) for the given border.
GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches) ...
GameCreationSettings game_creation
settings used during the creation of a game (map)
static bool IsPlainRail(TileIndex t)
Returns whether this is plain rails, with or without signals.
uint AvailableCount() const
Returns sum of cargo still available for loading at the sation.
A tile without any structures, i.e. grass, rocks, farm fields etc.
void GamelogTestMode()
Finds last stored game mode or landscape.
Full road along the y-axis (north-west + south-east)
byte CargoID
Cargo slots to indicate a cargo type within a game.
IndustryType indtype
Industry type to get the name from.
uint8 roadveh_slope_steepness
Steepness of hills for road vehicles when using realistic acceleration.
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
TreeGround
Enumeration for ground types of tiles with trees.
Pause mode bits when paused for network reasons.
Road vehicle is a tram/light rail vehicle.
byte wait_for_pbs_path
how long to wait for a path reservation.
static uint32 BSWAP32(uint32 x)
Perform a 32 bits endianness bitswap on x.
Owner
Enum for all companies/owners.
void ResetWindowSystem()
Reset the windowing system, by means of shutting it down followed by re-initialization.
byte remaining
Remaining months when this subsidy is valid.
bool SaveloadCrashWithMissingNewGRFs()
Did loading the savegame cause a crash? If so, were NewGRFs missing?
uint8 md5sum[16]
MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF) ...
void DeleteInvalidEngineNews()
Remove engine announcements for invalid engines.
Force unloading all cargo onto the platform, possibly not getting paid.
void ConvertFromOldSavegame()
Converts this order from an old savegame's version; it moves all bits to the new location.
byte industry_density
The industry density.
uint8 pathfinder_for_ships
the pathfinder to use for ships
bool rail_use_yapf
use YAPF for rail
union Vehicle::@46 orders
The orders currently assigned to the vehicle.
static void SetTrackReservation(TileIndex t, TrackBits b)
Sets the reserved track bits of the tile.
static void SetRoadTypes(TileIndex t, RoadTypes rt)
Set the present road types of a tile.
Money profit_this_year
Profit this year << 8, low 8 bits are fract.
bool new_pathfinding_all
use the newest pathfinding algorithm for all
Data for backing up an order of a vehicle so it can be restored after a vehicle is rebuilt in the sam...
static void SetTownIndex(TileIndex t, TownID index)
Set the town index for a road or house tile.
static bool IsDock(TileIndex t)
Is tile t a dock tile?
static Station * Get(size_t index)
Gets station with given index.
Date _date
Current date in days (day counter)
void ResetCompanyLivery(Company *c)
Reset the livery schemes to the company's primary colour.
uint16 h
The height of the area.
static Direction ReverseDir(Direction d)
Return the reverse of a direction.
byte wait_oneway_signal
waitingtime in days before a oneway signal
VehicleOrderID cur_implicit_order_index
The index to the current implicit order.
StationID current_station
The current station.
DistributionTypeByte distribution_default
distribution type for all other goods
Track in the upper corner of the tile (north)
bool allow_town_level_crossings
towns are allowed to build level crossings
StringID string_id
Default name (town area) of station.
Declaration of functions used in more save/load files.
The tile/execution is done by "water".
uint8 feeder_payment_share
percentage of leg payment to virtually pay in feeder systems
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
VehicleTypeByte type
Type of vehicle.
Valid changes while vehicle is driving, and possibly changing tracks.
DistributionTypeByte distribution_armoured
distribution type for armoured cargo class
void SetStopLocation(OrderStopLocation stop_location)
Set where we must stop at the platform.
Base class for all station-ish types.
Axis
Allow incrementing of DiagDirDiff variables.
static const GRFIdentifier * GetOverriddenIdentifier(const GRFConfig *c)
Try to find the overridden GRF identifier of the given GRF.
static bool IsRoadDepot(TileIndex t)
Return whether a tile is a road depot.
static const ObjectType OBJECT_HQ
HeadQuarter of a player.
LinkGraphSettings linkgraph
settings for link graph calculations
Used for industry tiles on land (also for oilrig if newgrf says so).
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
Order current_order
The current order (+ status, like: loading)
static bool IsBridge(TileIndex t)
Checks if this is a bridge, instead of a tunnel.
static Direction DiagDirToDir(DiagDirection dir)
Convert a DiagDirection to a Direction.
#define FOR_ALL_WAYPOINTS(var)
Iterate over all waypoints.
Date build_date
Date of construction.
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-...
static void SetTropicZone(TileIndex tile, TropicZone type)
Set the tropic zone.
GroundVehicleCache gcache
Cache of often calculated values.
CompanyMask have_ratings
which companies have a rating
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
uint16 town_cn
The N-1th depot for this town (consecutive number)
static void SetSignalHandlers()
Replaces signal handlers of SIGSEGV and SIGABRT and stores pointers to original handlers in memory...
static void SetRailType(TileIndex t, RailType r)
Sets the rail type of the given tile.
void GfxLoadSprites()
Initialise and load all the sprites.
uint16 max_tunnel_length
maximum length of tunnels
void Reset()
Completely reset the industry build data.
uint8 pathfinder_for_roadvehs
the pathfinder to use for roadvehicles
byte currency
currency we currently use
bool SettingsDisableElrail(int32 p1)
_settings_game.disable_elrail callback
uint8 max_train_length
maximum length for trains
static void SetDepotReservation(TileIndex t, bool b)
Set the reservation state of the depot.
static Station * GetIfValid(size_t index)
Returns station if the index is a valid index for this station type.