OpenTTD Source: src/saveload/afterload.cpp File Reference

OpenTTD Source 15.0-RC2

Typedefs | Functions | Variables
afterload.cpp File Reference

Code updating data after game load. More...

`#include "../stdafx.h"`
`#include "../void_map.h"`
`#include "../signs_base.h"`
`#include "../depot_base.h"`
`#include "../fios.h"`
`#include "../gamelog_internal.h"`
`#include "../network/network.h"`
`#include "../network/network_func.h"`
`#include "../gfxinit.h"`
`#include "../viewport_func.h"`
`#include "../viewport_kdtree.h"`
`#include "../industry.h"`
`#include "../clear_map.h"`
`#include "../vehicle_func.h"`
`#include "../string_func.h"`
`#include "../strings_func.h"`
`#include "../window_func.h"`
`#include "../roadveh.h"`
`#include "../roadveh_cmd.h"`
`#include "../train.h"`
`#include "../station_base.h"`
`#include "../waypoint_base.h"`
`#include "../roadstop_base.h"`
`#include "../tunnelbridge_map.h"`
`#include "../pathfinder/yapf/yapf_cache.h"`
`#include "../elrail_func.h"`
`#include "../signs_func.h"`
`#include "../aircraft.h"`
`#include "../object_map.h"`
`#include "../object_base.h"`
`#include "../tree_map.h"`
`#include "../company_func.h"`
`#include "../road_cmd.h"`
`#include "../ai/ai.hpp"`
`#include "../script/script_gui.h"`
`#include "../game/game.hpp"`
`#include "../town.h"`
`#include "../economy_base.h"`
`#include "../animated_tile_map.h"`
`#include "../animated_tile_func.h"`
`#include "../subsidy_base.h"`
`#include "../subsidy_func.h"`
`#include "../newgrf.h"`
`#include "../newgrf_station.h"`
`#include "../engine_func.h"`
`#include "../rail_gui.h"`
`#include "../core/backup_type.hpp"`
`#include "../smallmap_gui.h"`
`#include "../news_func.h"`
`#include "../order_backup.h"`
`#include "../error.h"`
`#include "../disaster_vehicle.h"`
`#include "../ship.h"`
`#include "../water.h"`
`#include "../timer/timer.h"`
`#include "../timer/timer_game_calendar.h"`
`#include "../timer/timer_game_economy.h"`
`#include "../timer/timer_game_tick.h"`
`#include "../picker_func.h"`
`#include "saveload_internal.h"`
`#include <signal.h>`
`#include "table/strings.h"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Typedefs
typedef void(CDECL * | SignalHandlerPointer) (int)

## Functions
Company * | DoStartupNewCompany (bool is_ai, CompanyID company=CompanyID::Invalid())
| Create a new company and sets all company variables default values.
void | ClearOldOrders ()
| Clear all old orders.
void | SetWaterClassDependingOnSurroundings (Tile t, bool include_invalid_water_class)
| Makes a tile canal or water depending on the surroundings.
static void | ConvertTownOwner ()
static void | UpdateExclusiveRights ()
static void | UpdateCurrencies ()
static void | UpdateVoidTiles ()
static RailType | UpdateRailType (RailType rt, RailType min)
void | UpdateAllVirtCoords ()
| Update the viewport coordinates of all signs.
void | ClearAllCachedNames ()
static void | InitializeWindowsAndCaches ()
| Initialization of the windows and several kinds of caches.
static void CDECL | HandleSavegameLoadCrash (int signum)
| Signal handler used to give a user a more useful report for crashes during the savegame loading process; especially when there's problems with the NewGRFs that are required by the savegame.
static void | SetSignalHandlers ()
| Replaces signal handlers of SIGSEGV and SIGABRT and stores pointers to original handlers in memory.
static void | ResetSignalHandlers ()
| Resets signal handlers back to original handlers.
bool | SaveloadCrashWithMissingNewGRFs ()
| Did loading the savegame cause a crash? If so, were NewGRFs missing?
static void | FixOwnerOfRailTrack (Tile t)
| Tries to change owner of this rail tile to a valid owner.
static uint | FixVehicleInclination (Vehicle *v, Direction dir)
| Fixes inclination of a vehicle.
static void | CheckGroundVehiclesAtCorrectZ ()
| Check whether the ground vehicles are at the correct Z-coordinate.
static bool | MayHaveBridgeAbove (Tile t)
| Checks for the possibility that a bridge may be on this tile These are in fact all the tile types on which a bridge can be found.
static void | StartScripts ()
| Start the scripts.
bool | AfterLoadGame ()
| Perform a (large) amount of savegame conversion magic in order to load older savegames and to fill the caches for various purposes.
void | ReloadNewGRFData ()
| Reload all NewGRF files during a running game.

## Variables
static const uint8_t | convert_currency []
static SignalHandlerPointer | _prev_segfault = nullptr
static SignalHandlerPointer | _prev_abort = nullptr
static SignalHandlerPointer | _prev_fpe = nullptr
static bool | _saveload_crash_with_missing_newgrfs = false
| Was the saveload crash because of missing NewGRFs?

## Detailed Description

Code updating data after game load.

Definition in file afterload.cpp.

## Typedef Documentation

## ◆ SignalHandlerPointer

typedef void(CDECL * SignalHandlerPointer) (int)

Definition at line 313 of file afterload.cpp.

## Function Documentation

## ◆ AfterLoadGame()

bool AfterLoadGame | ( |  | ) |

Perform a (large) amount of savegame conversion magic in order to load older savegames and to fill the caches for various purposes.

Returns
  True iff conversion went without a problem.

< Flag for coast.

Definition at line 560 of file afterload.cpp.

References _animated_tiles, _current_company, _gamelog, _grfconfig, _industry_builder, _network_dedicated, _network_server, _networking, _new_competitor_timeout, _old_vds, _pause_mode, _random, _road_stop_stop_frame, _settings_client, _settings_game, _settings_newgame, _tunnel_visibility_frame, ShipVehicleInfo::acceleration, IndustrySpec::accepts_cargo, ActiveClients, AddInflation(), CargoPacket::AfterLoad(), AfterLoadCompanyStats(), AfterLoadLabelMaps(), AfterLoadLinkGraphs(), AfterLoadRoadStops(), AfterLoadStoryBook(), AfterLoadVehiclesPhase1(), AfterLoadVehiclesPhase2(), AIR_AIRCRAFT, AircraftNextAirportPos_and_Order(), Airport, EconomySettings::allow_town_level_crossings, EconomySettings::allow_town_roads, Animated, AssignBit(), AT_OILRIG, Available, AXIS_X, AXIS_Y, AxisToDirection(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::base(), IndustrySpec::behaviour, Object::build_date, BuildingIsProtected, BuiltOnWater, Station::bus_stops, CalcClosestTownFromTile(), Canal, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_object_pool >::CanAllocateItem(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_cargo_payment_pool >::CanAllocateItem(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_roadstop_pool >::CanAllocateItem(), CARGO_NO_REFIT, CeilDiv(), ChangeTileOwner(), CheckGroundVehiclesAtCorrectZ(), Clamp(), Clear, CLEAR_FIELDS, ConstructionSettings::clear_frame_burst, CLEAR_GRASS, CLEAR_SNOW, ClearBridgeMiddle(), ClearOldOrders(), ClosestTownFromTile(), ClrBit(), Coast, ClientSettings::company, Compatible, DifficultySettings::competitors_interval, ConnectMultiheadedTrains(), GameSettings::construction, ConvertFromOldCompanyManagerFace(), ConvertOldMultiheadToNew(), CopyFromOldName(), CopyTempEngineData(), TimerGameTick::counter, Crashed, Crossing, Vehicle::current_order, CustomGrowth, TimerGameCalendar::date, TimerGameEconomy::date, TimerGameCalendar::date_fract, TimerGameEconomy::date_fract, Ticks::DAY_TICKS, TimerGameConst< struct Economy >::DAYS_TILL_ORIGINAL_BASE_YEAR, TimerGameConst< struct Calendar >::DAYS_TILL_ORIGINAL_BASE_YEAR, Debug, TimerGameConst< struct Calendar >::DEF_END_YEAR, Depot, DIAGDIR_END, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, DiagDirToAxis(), DiagDirToDiagTrackBits(), DiagDirToDiagTrackdir(), DiagDirToDir(), GameSettings::difficulty, DIR_N, Vehicle::direction, DirToDiagDir(), VehicleSettings::disable_elrails, DistanceManhattan(), LinkGraphSettings::distribution_armoured, LinkGraphSettings::distribution_default, LinkGraphSettings::distribution_mail, LinkGraphSettings::distribution_pax, Dock, DoStartupNewCompany(), DT_MANUAL, VehicleSettings::dynamic_engines, GameSettings::economy, GameCreationSettings::ending_year, Error, ExclusivePreview, HouseSpec::extra_flags, FarEnd, EconomySettings::feeder_payment_share, FindCompanyManagerFaceLabel(), FindFirstCargoWithTownAcceptanceEffect(), FixOwnerOfRailTrack(), FixupTrainLengths(), FixVehicleInclination(), FLYING, PathfinderSettings::forbid_90_deg, ConstructionSettings::freeform_edges, SpecializedStation< Station, false >::From(), SpecializedVehicle< T, Type >::From(), GameSettings::game_creation, GB(), GCS_NOT_FOUND, GenerateSavegameId(), SpecializedStation< Station, false >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_town_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_object_pool >::Get(), HouseSpec::Get(), CargoSpec::Get(), GetAircraftFlightLevelBounds(), BaseStation::GetByTile(), Industry::GetByTile(), GetClearDensity(), GetClearGround(), GetCompanyRailTypes(), GetCompanyRoadTypes(), GetEncodedString(), GetFirstPlayableCompanyID(), OverrideManagerBase::GetGRFID(), GetHouseType(), SpecializedStation< Station, false >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_vehicle_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::GetIfValid(), GetInclinedSlopeDirection(), GetIndustryGfx(), GetIndustrySpec(), GetIndustryType(), GetLockPart(), GetNorthernBridgeEnd(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_object_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_town_pool >::GetNumItems(), GetOtherShipDepotTile(), GetOtherTunnelBridgeEnd(), GetRailType(), GetRoadOwner(), GetRoadTileType(), GetSlopePixelZ(), GetStationGfx(), GetStationType(), GetTargetAirportIfValid(), GetTileMaxPixelZ(), GetTileMaxZ(), GetTileOwner(), GetTileSlope(), GetTileTrackStatus(), GetTileType(), GetTileZ(), GetTreeGround(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), GetWaterClass(), GetWaterTileType(), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET, GfxLoadSprites(), GLC_ALL_GOOD, GLC_COMPATIBLE, GLC_NOT_FOUND, Gamelog::GRFAddList(), Gamelog::GRFCompatible(), Gamelog::GRFRemove(), GroundVehicle< T, Type >::gv_flags, GVF_GOINGDOWN_BIT, GVF_GOINGUP_BIT, OrthogonalTileArea::h, HasBit(), HasSignals(), HasStationRail(), HasStationTileRail(), HasTownOwnedRoad(), Hidden, Object::IncTypeCount(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Industry, DifficultySettings::industry_density, Economy::inflation_payment, Economy::inflation_prices, EconomySettings::infrastructure_maintenance, InitializeRailGUI(), InitializeWindowsAndCaches(), Invalid, INVALID_DIR, INVALID_OWNER, INVALID_ROADTYPE, INVALID_TILE, INVALID_TRACK, IsAirportTile(), IsAnyRoadStop(), IsBayRoadStopTile(), IsBridge(), IsBridgeTile(), IsBuoy(), IsBuoyTile(), IsClearGround(), IsDepotTile(), IsDock(), IsDriveThroughStopTile(), SpecializedStation< Station, false >::IsExpected(), IsGoodGRFConfigList(), IsHouseCompleted(), IsInsideMM(), IsLevelCrossing(), IsLevelCrossingTile(), IsLock(), IsOilRig(), IsPlainRail(), IsPlainRailTile(), IsRailDepot(), IsRailDepotTile(), IsRoadDepot(), IsSavegameVersionBefore(), IsSavegameVersionBeforeOrAt(), IsShipDepot(), IsShipDepotTile(), IsStationRoadStop(), IsStationTileBlocked(), IsTileFlat(), IsTileOwner(), IsTileType(), IsTruckStop(), IsTunnelTile(), Order::IsType(), IsValidCargoType(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_town_pool >::IsValidID(), IsWater(), Map::Iterate(), SpecializedStation< Station, false >::Iterate(), SpecializedStation< Waypoint, true >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_vehicle_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_cargo_payment_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_group_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_town_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_depot_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_subsidy_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_orderlist_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_order_backup_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_sign_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_object_pool >::Iterate(), SpecializedVehicle< T, Type >::Iterate(), Join, GameCreationSettings::landscape, EconomySettings::larger_towns, GameSettings::linkgraph, LoadingFinished, LoadStringWidthTable(), GameSettings::locale, Object::location, Lock, Tile::m2(), MakeCanal(), MakeClear(), MakeDefaultName(), MakeSea(), MakeShore(), ConstructionSettings::map_height_limit, ConstructionSettings::max_bridge_length, MAX_INFLATION, DifficultySettings::max_loan, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::MAX_SIZE, VehicleSettings::max_train_length, ConstructionSettings::max_tunnel_length, Map::MaxX(), Map::MaxY(), MayAnimateTile(), MayHaveBridgeAbove(), Middle, TimerGameConst< struct Economy >::MIN_DATE, MIN_SNOWLINE_HEIGHT, EngineInfo::misc_flags, StationSettings::modified_catchment, MoveBuoysToWaypoints(), MoveWaypointsToBaseStations(), MP_CLEAR, MP_HOUSE, MP_INDUSTRY, MP_OBJECT, MP_RAILWAY, MP_ROAD, MP_STATION, MP_TREES, MP_TUNNELBRIDGE, MP_VOID, MP_WATER, NEW_HOUSE_OFFSET, SpecializedVehicle< T, Type >::Next(), NoIntermediate, NoLoad, None, Normal, DifficultySettings::number_towns, OBJECT_HQ, OBJECT_STATUE, Economy::old_max_loan_unround, Economy::old_max_loan_unround_fract, Gamelog::Oldver(), TimerGameConst< struct Economy >::ORIGINAL_BASE_YEAR, TimerGameConst< struct Calendar >::ORIGINAL_BASE_YEAR, BaseStation::owner, OWNER_NONE, OWNER_TOWN, OWNER_WATER, PathfinderLost, GameSettings::pf, VehicleSettings::plane_crashes, VehicleSettings::plane_speed, PlantOnBuild, Gamelog::PrintDebug(), RAILTYPE_ELECTRIC, RAILTYPE_RAIL, RailVehicleInfo::railtypes, Random, RandomiseCompanyManagerFace(), GoodsEntry::Rating, RATING_INITIAL, LinkGraphSettings::recalc_interval, LinkGraphSettings::recalc_time, Station::RecomputeCatchmentForAll(), BaseStation::rect, ReplaceProtection, ReplaceWagonRemoval, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), IndustryBuildData::Reset(), ResetCompanyLivery(), ResetOldNames(), ResetSignalHandlers(), Backup< T >::Restore(), PathfinderSettings::reverse_at_signals, ReverseDiagDir(), ReverseDir(), River, VehicleSettings::road_side, ROAD_X, ROAD_Y, RoadIsTram, RoadVehicle::roadtype, ROADTYPE_ROAD, ROADTYPE_TRAM, VehicleSettings::roadveh_acceleration_model, VehicleSettings::roadveh_slope_steepness, RTT_ROAD, RTT_TRAM, RVS_DRIVE_SIDE, RVS_ENTERED_STOP, RVS_IN_DT_ROAD_STOP, RVS_IN_ROAD_STOP, RVSB_IN_DEPOT, RVSB_IN_ROAD_STOP, RVSB_WORMHOLE, SB(), Sea, TimerGameConst< struct Calendar >::SECONDS_PER_DAY, StationSettings::serve_neutral_industries, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SetAircraftPosition(), SetAnimatedTileState(), SetAnimationFrame(), SetBit(), SetBridgeMiddle(), SetClearGroundDensity(), SetCompanyManagerFaceStyle(), SetCrossingReservation(), TimerGameCalendar::SetDate(), TimerGameEconomy::SetDate(), SetDepotReservation(), SetDockingTile(), SetFence(), SetHouseCompleted(), SetHouseProtected(), SetHouseType(), SetLiftPosition(), SetNonFloodingWaterTile(), SetRailStationReservation(), SetRailType(), SetRoadOwner(), SetRoadTypes(), SetSaveLoadError(), SetSignalHandlers(), SetSignalStates(), SetStationGfx(), SetTileOwner(), SetTileType(), CompanyProperties::settings, SetTownIndex(), SetTrackReservation(), SetTropicZone(), SetTunnelBridgeReservation(), SetWaterClass(), SetWaterClassDependingOnSurroundings(), SetWaterTileType(), ShowErrorMessage(), SIG_ELECTRIC, SIG_SEMAPHORE, SIGTYPE_COMBO, SlError(), SlErrorCorrupt(), SLV_1, SLV_100, SLV_101, SLV_103, SLV_104, SLV_106, SLV_11, SLV_111, SLV_112, SLV_113, SLV_114, SLV_117, SLV_119, SLV_120, SLV_121, SLV_122, SLV_123, SLV_124, SLV_125, SLV_126, SLV_127, SLV_128, SLV_131, SLV_133, SLV_134, SLV_135, SLV_136, SLV_137, SLV_138, SLV_139, SLV_140, SLV_141, SLV_142, SLV_143, SLV_144, SLV_145, SLV_146, SLV_147, SLV_148, SLV_149, SLV_15, SLV_152, SLV_153, SLV_156, SLV_158, SLV_159, SLV_16, SLV_160, SLV_161, SLV_164, SLV_165, SLV_166, SLV_17, SLV_172, SLV_175, SLV_177, SLV_182, SLV_183, SLV_184, SLV_186, SLV_188, SLV_190, SLV_192, SLV_194, SLV_198, SLV_2, SLV_21, SLV_24, SLV_25, SLV_26, SLV_31, SLV_32, SLV_34, SLV_36, SLV_38, SLV_4, SLV_42, SLV_43, SLV_45, SLV_46, SLV_48, SLV_49, SLV_50, SLV_52, SLV_53, SLV_56, SLV_57, SLV_58, SLV_59, SLV_6, SLV_61, SLV_62, SLV_64, SLV_69, SLV_70, SLV_72, SLV_74, SLV_76, SLV_78, SLV_81, SLV_82, SLV_83, SLV_84, SLV_86, SLV_87, SLV_88, SLV_9, SLV_90, SLV_91, SLV_93, SLV_94, SLV_95, SLV_96, SLV_98, SLV_99, SLV_AI_START_DATE, SLV_ANIMATED_TILE_STATE_IN_MAP, SLV_COMPANY_INAUGURATED_PERIOD_V2, SLV_CONSISTENT_PARTIAL_Z, SLV_DEPOT_UNBUNCHING, SLV_ECONOMY_DATE, SLV_ECONOMY_MODE_TIMEKEEPING_UNITS, SLV_ENDING_YEAR, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_EXTEND_RAILTYPES, SLV_FACE_STYLES, SLV_GROUP_NUMBERS, SLV_GROUP_REPLACE_WAGON_REMOVAL, SLV_GS_INDUSTRY_CONTROL, SLV_INCREASE_HOUSE_LIMIT, SLV_INCREASE_STATION_TYPE_FIELD_SIZE, SLV_LAST_LOADING_TICK, SLV_LINKGRAPH_SECONDS, SLV_MAX_LOAN_FOR_COMPANY, SLV_MULTITILE_DOCKS, SLV_MULTITRACK_LEVEL_CROSSINGS, SLV_NEWGRF_LAST_SERVICE, SLV_NONFLOODING_WATER_TILES, SLV_PROTECT_PLACED_HOUSES, SLV_REPAIR_OBJECT_DOCKING_TILES, SLV_ROAD_TYPES, SLV_SAVEGAME_ID, SLV_SCRIPT_RANDOMIZER, SLV_SCRIPT_SAVE_INSTANCES, SLV_SERVE_NEUTRAL_INDUSTRIES, SLV_SHIP_ACCELERATION, SLV_SHIPS_STOP_IN_LOCKS, SLV_TOWN_CARGOGEN, SLV_TREES_WATER_CLASS, SLV_VEHICLE_ECONOMY_AGE, SLV_VELOCITY_NAUTICAL, SLV_WATER_TILE_TYPE, GameCreationSettings::snow_line_height, SPECSTR_PRESIDENT_NAME, SPECSTR_TOWNNAME_START, GameCreationSettings::starting_year, StartScripts(), StartupEngines(), RoadVehicle::state, GameSettings::station, EconomySettings::station_noise_level, Stopped, BaseTimer< TTimerType >::storage, TAE_FOOD, TAE_GOODS, TAE_MAIL, TAE_PASSENGERS, TAE_WATER, TCGM_ORIGINAL, ConstructionSettings::terraform_frame_burst, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Gamelog::TestMode(), Gamelog::TestRevision(), TFP_NONE, TFP_STUCK, OrthogonalTileArea::tile, Vehicle::tile, TILE_HEIGHT, TILE_SIZE, TILE_UNIT_MASK, TileAddXY(), TileDiffXY(), TileHash(), TileHeight(), TileVirtXY(), TileX(), TileXY(), TileY(), EconomySettings::timekeeping_units, TL_BETTER_ROADS, TL_RANDOM, to_underlying(), BaseStation::town, Object::town, Town, CargoSpec::town_acceptance_effect, EconomySettings::town_cargogen_mode, TOWN_GROWTH_DESERT, TOWN_GROWTH_RATE_NONE, Ticks::TOWN_GROWTH_TICKS, TOWN_GROWTH_WINTER, TOWN_HOUSE_COMPLETED, EconomySettings::town_layout, GameCreationSettings::town_name, TRACK_BIT_NONE, TRACK_BIT_WORMHOLE, TRACK_BIT_X, TRACK_BIT_Y, TRACK_LOWER, TRACK_UPPER, TrackStatusToTrackBits(), Train, VehicleSettings::train_acceleration_model, VehicleSettings::train_slope_steepness, BaseStation::train_station, Transfer, TRANSPORT_RAIL, TRANSPORT_ROAD, ConstructionSettings::tree_frame_burst, TREE_GROUND_SHORE, TREE_GROUND_SNOW_DESERT, TrimIndustryAcceptedProduced(), TROPICZONE_NORMAL, Station::truck_stops, Object::type, BaseVehicle::type, LocaleSettings::units_force, LocaleSettings::units_height, LocaleSettings::units_power, LocaleSettings::units_velocity, LocaleSettings::units_velocity_nautical, LocaleSettings::units_volume, LocaleSettings::units_weight, GroupStatistics::UpdateAfterLoad(), UpdateAircraftCache(), UpdateCompanyLiveries(), UpdateGroupChildren(), UpdateHousesAndTowns(), UpdateLevelCrossing(), UpdateNearestTownForRoadTiles(), UpdateOldAircraft(), UpdateStationAcceptance(), UpdateTownMaxPass(), FreeUnitIDGenerator::UseID(), VEH_INVALID, VEH_ROAD, VEH_SHIP, VEH_TRAIN, GameSettings::vehicle, Vehicle::vehstatus, OrthogonalTileArea::w, PathfinderSettings::wait_for_pbs_path, PathfinderSettings::wait_oneway_signal, PathfinderSettings::wait_twoway_signal, WL_CRITICAL, XYNSToDiagDir(), YapfNotifyTrackLayoutChange(), TimerGameCalendar::year, and TimerGameEconomy::year.

Referenced by DoLoad(), and SaveOrLoad().

## ◆ CheckGroundVehiclesAtCorrectZ()

static void CheckGroundVehiclesAtCorrectZ | ( |  | ) |
| static

Check whether the ground vehicles are at the correct Z-coordinate.

When they are not, this will cause all kinds of problems later on as the vehicle might not get onto bridges and so on.

Definition at line 511 of file afterload.cpp.

References GetSlopePixelZ(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_vehicle_pool >::Iterate(), and TileVirtXY().

Referenced by AfterLoadGame().

## ◆ ClearAllCachedNames()

void ClearAllCachedNames | ( |  | ) |

Definition at line 229 of file afterload.cpp.

## ◆ ClearOldOrders()

void ClearOldOrders | ( |  | ) |
| extern

Clear all old orders.

Definition at line 114 of file order_sl.cpp.

References _old_order_saveload_pool.

Referenced by AfterLoadGame().

## ◆ ConvertTownOwner()

static void ConvertTownOwner | ( |  | ) |
| static

Definition at line 162 of file afterload.cpp.

## ◆ DoStartupNewCompany()

Company * DoStartupNewCompany | ( | bool | is_ai,
|  | CompanyID | company = `CompanyID::Invalid()`
| ) |  |
| extern

Create a new company and sets all company variables default values.

Parameters

  is_ai | is an AI company?
  company | CompanyID to use for the new company

Returns
  the company struct

Definition at line 598 of file company_cmd.cpp.

References _company_colours, _company_manager_face, _network_server, _networking, _random, Company::avail_railtypes, Company::avail_roadtypes, AI::BroadcastNewEvent(), BuildOwnerLegend(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::CanAllocateItem(), ClearEnginesHiddenFlagOfCompany(), CompanyProperties::colour, CompanyProperties::current_loan, CompanyProperties::face, GenerateCompanyColour(), GeneratePresidentName(), GetCompanyRailTypes(), GetCompanyRoadTypes(), CompanyProperties::inaugurated_year, CompanyProperties::inaugurated_year_calendar, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Economy::inflation_prices, INITIAL_LOAN, InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), LOAN_INTERVAL, Economy::max_loan, CompanyProperties::money, Game::NewEvent(), ParseCompanyManagerFaceCode(), RandomiseCompanyManagerFace(), ResetCompanyLivery(), SetDefaultCompanySettings(), SetWindowDirty(), AI::StartNew(), WC_CLIENT_LIST, WC_GRAPH_LEGEND, WC_LINKGRAPH_LEGEND, WC_SMALLMAP, TimerGameCalendar::year, and TimerGameEconomy::year.

Referenced by AfterLoadGame(), and CmdCompanyCtrl().

## ◆ FixOwnerOfRailTrack()

static void FixOwnerOfRailTrack | ( | Tile | t | ) |
| static

Tries to change owner of this rail tile to a valid owner.

In very old versions it could happen that a rail track had an invalid owner. When conversion isn't possible, track is removed.

Parameters

  t | tile to update

Definition at line 418 of file afterload.cpp.

References CLEAR_GRASS, DIAGDIR_BEGIN, DIAGDIR_END, GetCrossingRoadBits(), GetRoadOwner(), GetTileOwner(), GetTileTrackStatus(), HasBit(), IsLevelCrossingTile(), IsPlainRailTile(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), SpecializedVehicle< T, Type >::Iterate(), Tile::m3(), Tile::m5(), Tile::m6(), Tile::m7(), MakeClear(), MP_ROAD, Normal, Vehicle::owner, ReverseDiagDir(), RTT_ROAD, RTT_TRAM, SB(), SetRoadOwner(), SetTileOwner(), SetTileType(), TileOffsByDiagDir(), to_underlying(), and TRANSPORT_RAIL.

Referenced by AfterLoadGame().

## ◆ FixVehicleInclination()

static uint FixVehicleInclination | ( | Vehicle * | v,
|  | Direction | dir
| ) |  |
| static

Fixes inclination of a vehicle.

Older OpenTTD versions didn't update the bits correctly.

Parameters

  v | vehicle
  dir | vehicle's direction, or # INVALID_DIR if it can be ignored

Returns
  inclination bits to set

Definition at line 476 of file afterload.cpp.

References DIR_NE, DIR_NW, DIR_SE, DIR_SW, GetSlopePixelZ(), GVF_GOINGDOWN_BIT, GVF_GOINGUP_BIT, INVALID_DIR, TILE_SIZE, TILE_UNIT_MASK, Vehicle::x_pos, and Vehicle::y_pos.

Referenced by AfterLoadGame().

## ◆ HandleSavegameLoadCrash()

static void CDECL HandleSavegameLoadCrash | ( | int | signum | ) |
| static

Signal handler used to give a user a more useful report for crashes during the savegame loading process; especially when there's problems with the NewGRFs that are required by the savegame.

Parameters

  signum | received signal

Definition at line 360 of file afterload.cpp.

References _gamelog, _grfconfig, _saveload_crash_with_missing_newgrfs, Compatible, FormatArrayAsHex(), GCS_NOT_FOUND, Gamelog::GetOverriddenIdentifier(), GRFIdentifier::md5sum, and ResetSignalHandlers().

Referenced by SetSignalHandlers().

## ◆ InitializeWindowsAndCaches()

static void InitializeWindowsAndCaches | ( |  | ) |
| static

Initialization of the windows and several kinds of caches.

This is not done directly in AfterLoadGame because these functions require that all saveload conversions have been done. As people tend to add savegame conversion stuff after the initialization of the windows and caches quite some bugs had been made. Moving this out of there is both cleaner and less bug-prone.

Definition at line 245 of file afterload.cpp.

References _file_to_saveload, FiosType::abstract, BuildOwnerLegend(), CheckTrainsLengths(), FT_SCENARIO, FileToSaveLoad::ftype, GSF_FAKE_TOWNS, Object::IncTypeCount(), SpecializedStation< Station, false >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_object_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_town_pool >::Iterate(), SpecializedVehicle< T, Type >::Iterate(), TimerGameConst< struct Economy >::MIN_YEAR, RebuildSubsidisedSourceAndDestinationCache(), RecomputePrices(), ResetWindowSystem(), SetupColoursAndInitialWindow(), ShowNewGRFError(), GroupStatistics::UpdateAfterLoad(), UpdateAirportsNoise(), UpdateAllVirtCoords(), and TimerGameEconomy::year.

Referenced by AfterLoadGame().

## ◆ MayHaveBridgeAbove()

static bool MayHaveBridgeAbove | ( | Tile | t | ) |
| inlinestatic

Checks for the possibility that a bridge may be on this tile These are in fact all the tile types on which a bridge can be found.

Parameters

  t | The tile to analyze

Returns
  True if a bridge might have been present prior to savegame 194.

Definition at line 531 of file afterload.cpp.

References IsTileType(), MP_CLEAR, MP_OBJECT, MP_RAILWAY, MP_ROAD, MP_TUNNELBRIDGE, and MP_WATER.

Referenced by AfterLoadGame().

## ◆ ReloadNewGRFData()

void ReloadNewGRFData | ( |  | ) |

Reload all NewGRF files during a running game.

This is a cut-down version of AfterLoadGame(). XXX - We need to reset the vehicle position hash because with a non-empty hash AfterLoadVehicles() will loop infinitely. We need AfterLoadVehicles() to recalculate vehicle data as some NewGRF vehicle sets could have been removed or added and changed statistics

Definition at line 3442 of file afterload.cpp.

References AfterLoadCompanyStats(), AfterLoadLabelMaps(), AfterLoadVehiclesPhase1(), AfterLoadVehiclesPhase2(), CheckTrainsLengths(), DeleteInvalidEngineNews(), GfxLoadSprites(), InvalidateWindowClassesData(), InvalidateWindowData(), LoadStringWidthTable(), MarkWholeScreenDirty(), RecomputePrices(), StartupEngines(), GroupStatistics::UpdateAfterLoad(), UpdateHousesAndTowns(), WC_BUILD_TOOLBAR, WC_COMPANY_COLOUR, and WC_COMPANY_INFRASTRUCTURE.

Referenced by ClickChangeMaxHlCheat(), NewGRFWindow::Close(), NewGRFConfirmationCallback(), and EngineOverrideManager::ResetToCurrentNewGRFConfig().

## ◆ ResetSignalHandlers()

static void ResetSignalHandlers | ( |  | ) |
| static

Resets signal handlers back to original handlers.

Definition at line 334 of file afterload.cpp.

Referenced by AfterLoadGame(), and HandleSavegameLoadCrash().

## ◆ SaveloadCrashWithMissingNewGRFs()

bool SaveloadCrashWithMissingNewGRFs | ( |  | ) |

Did loading the savegame cause a crash? If so, were NewGRFs missing?

Returns
  when the saveload crashed due to missing NewGRFs.

Definition at line 349 of file afterload.cpp.

References _saveload_crash_with_missing_newgrfs.

Referenced by HandleCrash(), and HandleCrash().

## ◆ SetSignalHandlers()

static void SetSignalHandlers | ( |  | ) |
| static

Replaces signal handlers of SIGSEGV and SIGABRT and stores pointers to original handlers in memory.

Definition at line 324 of file afterload.cpp.

References HandleSavegameLoadCrash().

Referenced by AfterLoadGame().

## ◆ SetWaterClassDependingOnSurroundings()

void SetWaterClassDependingOnSurroundings | ( | Tile | t,
|  | bool | include_invalid_water_class
| ) |  |

Makes a tile canal or water depending on the surroundings.

Must only be used for converting old savegames. Use WaterClass now.

This as for example docks and shipdepots do not store whether the tile used to be canal or 'normal' water.

Parameters

  t | the tile to change.
  include_invalid_water_class | Also consider WaterClass::Invalid, i.e. industry tiles on land

Definition at line 91 of file afterload.cpp.

References Canal, DIAGDIR_BEGIN, DIAGDIR_END, GB(), GetTileType(), GetWaterClass(), HalfTileWater, Invalid, IsCoast(), IsLock(), IsTileFlat(), Tile::m2(), MarkTileDirtyByTile(), Map::MaxX(), Map::MaxY(), MP_RAILWAY, MP_TREES, MP_WATER, River, Sea, SetWaterClass(), SlErrorCorrupt(), TileAddByDiagDir(), TileX(), TileY(), and TREE_GROUND_SHORE.

Referenced by AfterLoadGame().

## ◆ StartScripts()

static void StartScripts | ( |  | ) |
| static

Start the scripts.

Definition at line 540 of file afterload.cpp.

References Company::IsValidAiID(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Iterate(), ShowScriptDebugWindowIfScriptError(), Game::StartNew(), and AI::StartNew().

Referenced by AfterLoadGame().

## ◆ UpdateAllVirtCoords()

void UpdateAllVirtCoords | ( |  | ) |

Update the viewport coordinates of all signs.

Definition at line 220 of file afterload.cpp.

References UpdateAllSignVirtCoords(), UpdateAllStationVirtCoords(), and UpdateAllTownVirtCoords().

Referenced by AdjustGUIZoom(), InitializeWindowsAndCaches(), GameOptionsWindow::OnClick(), GameOptionsWindow::OnDropdownSelect(), and MainWindow::OnHotkey().

## ◆ UpdateCurrencies()

static void UpdateCurrencies | ( |  | ) |
| static

Definition at line 198 of file afterload.cpp.

## ◆ UpdateExclusiveRights()

static void UpdateExclusiveRights | ( |  | ) |
| static

Definition at line 182 of file afterload.cpp.

## ◆ UpdateRailType()

static RailType UpdateRailType | ( | RailType | rt,
|  | RailType | min
| ) |  |
| inlinestatic

Definition at line 212 of file afterload.cpp.

## ◆ UpdateVoidTiles()

static void UpdateVoidTiles | ( |  | ) |
| static

Definition at line 206 of file afterload.cpp.

## Variable Documentation

## ◆ _prev_abort

SignalHandlerPointer _prev_abort = nullptr
| static

Definition at line 315 of file afterload.cpp.

## ◆ _prev_fpe

SignalHandlerPointer _prev_fpe = nullptr
| static

Definition at line 316 of file afterload.cpp.

## ◆ _prev_segfault

SignalHandlerPointer _prev_segfault = nullptr
| static

Definition at line 314 of file afterload.cpp.

## ◆ _saveload_crash_with_missing_newgrfs

bool _saveload_crash_with_missing_newgrfs = false
| static

Was the saveload crash because of missing NewGRFs?

Definition at line 342 of file afterload.cpp.

Referenced by HandleSavegameLoadCrash(), and SaveloadCrashWithMissingNewGRFs().

## ◆ convert_currency

const uint8_t convert_currency[]
| static

Initial value:
= {
0, 1, 12, 8, 3,
10, 14, 19, 4, 5,
9, 11, 13, 6, 17,
16, 22, 21, 7, 15,
18, 2, 20,
}

Definition at line 189 of file afterload.cpp.