OpenTTD Source 20241224-master-gf74b0cf984
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 "../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 "saveload_internal.h"
#include <signal.h>
#include "../safeguards.h"
#include "window_func.h"

Go to the source code of this file.

Typedefs

typedef void(CDECL * SignalHandlerPointer) (int)
 

Functions

CompanyDoStartupNewCompany (bool is_ai, CompanyID company=INVALID_COMPANY)
 Create a new company and sets all company variables default values.
 
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 317 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 566 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, _road_stop_stop_frame, _settings_client, _settings_game, _settings_newgame, _tunnel_visibility_frame, ShipVehicleInfo::acceleration, IndustrySpec::accepts_cargo, AddInflation(), CargoPacket::AfterLoad(), AfterLoadCompanyStats(), AfterLoadLabelMaps(), AfterLoadLinkGraphs(), AfterLoadRoadStops(), AfterLoadStoryBook(), AfterLoadVehiclesPhase1(), AfterLoadVehiclesPhase2(), AIR_AIRCRAFT, AircraftNextAirportPos_and_Order(), EconomySettings::allow_town_level_crossings, EconomySettings::allow_town_roads, Animated, AssignBit(), AT_OILRIG, AXIS_X, AXIS_Y, AxisToDirection(), IndustrySpec::behaviour, Object::build_date, Station::bus_stops, CalcClosestTownFromTile(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_cargo_payment_pool >::CanAllocateItem(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::CanAllocateItem(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_roadstop_pool >::CanAllocateItem(), CARGO_NO_REFIT, CeilDiv(), ChangeTileOwner(), CheckGroundVehiclesAtCorrectZ(), Clamp(), CLEAR_FIELDS, ConstructionSettings::clear_frame_burst, CLEAR_GRASS, CLEAR_SNOW, ClearBridgeMiddle(), ClosestTownFromTile(), ClrBit(), ClientSettings::company, DifficultySettings::competitors_interval, ConnectMultiheadedTrains(), GameSettings::construction, ConvertFromOldCompanyManagerFace(), ConvertOldMultiheadToNew(), CopyFromOldName(), CopyTempEngineData(), TimerGameTick::counter, Vehicle::current_order, TimerGameCalendar::date, TimerGameEconomy::date, TimerGameCalendar::date_fract, TimerGameEconomy::date_fract, Ticks::DAY_TICKS, TimerGameConst< struct Calendar >::DAYS_TILL_ORIGINAL_BASE_YEAR, TimerGameConst< struct Economy >::DAYS_TILL_ORIGINAL_BASE_YEAR, Debug, TimerGameConst< struct Calendar >::DEF_END_YEAR, DIAGDIR_END, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, DiagDirToAxis(), DiagDirToDiagTrackBits(), DiagDirToDiagTrackdir(), DiagDirToDir(), GameSettings::difficulty, Vehicle::direction, DirToDiagDir(), VehicleSettings::disable_elrails, DistanceManhattan(), LinkGraphSettings::distribution_armoured, LinkGraphSettings::distribution_default, LinkGraphSettings::distribution_mail, LinkGraphSettings::distribution_pax, DoStartupNewCompany(), DT_MANUAL, VehicleSettings::dynamic_engines, GameSettings::economy, EF_ROAD_TRAM, GameCreationSettings::ending_year, FACIL_AIRPORT, FACIL_DOCK, FACIL_TRAIN, EconomySettings::feeder_payment_share, FindFirstCargoWithTownAcceptanceEffect(), FixOwnerOfRailTrack(), FixupTrainLengths(), FixVehicleInclination(), FLYING, PathfinderSettings::forbid_90_deg, ConstructionSettings::freeform_edges, SpecializedStation< Station, false >::From(), SpecializedVehicle< T, Type >::From(), GameSettings::game_creation, GB(), GCF_COMPATIBLE, GCS_NOT_FOUND, GenerateSavegameId(), GoodsEntry::GES_RATING, SpecializedStation< Station, false >::Get(), CargoSpec::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), GetAircraftFlightLevelBounds(), BaseStation::GetByTile(), Industry::GetByTile(), GetClearDensity(), GetCompanyRailTypes(), GetCompanyRoadTypes(), GetFirstPlayableCompanyID(), OverrideManagerBase::GetGRFID(), GetHouseType(), SpecializedStation< Station, false >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), GetInclinedSlopeDirection(), GetIndustryGfx(), GetIndustrySpec(), GetIndustryType(), GetLockPart(), GetNorthernBridgeEnd(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::GetNumItems(), GetOtherShipDepotTile(), GetOtherTunnelBridgeEnd(), GetRailType(), GetRawClearGround(), GetRoadOwner(), GetRoadTileType(), GetSlopePixelZ(), GetStationGfx(), GetStationType(), GetTargetAirportIfValid(), GetTileMaxPixelZ(), GetTileMaxZ(), GetTileOwner(), GetTileSlope(), GetTileTrackStatus(), GetTileType(), GetTileZ(), GetTreeGround(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), GetWaterClass(), GetWaterTileType(), GF_REPLACE_PROTECTION, GF_REPLACE_WAGON_REMOVAL, 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(), Object::IncTypeCount(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Industry, DifficultySettings::industry_density, INDUSTRYBEH_BUILT_ONWATER, INDUSTRYBEH_PLANT_ON_BUILT, Economy::inflation_payment, Economy::inflation_prices, EconomySettings::infrastructure_maintenance, InitializeRailGUI(), InitializeWindowsAndCaches(), INVALID_COMPANY, INVALID_DIR, INVALID_OWNER, INVALID_ROADTYPE, INVALID_STRING_ID, 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(), IsValidCargoID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::IsValidID(), IsWater(), Map::Iterate(), SpecializedStation< Waypoint, true >::Iterate(), SpecializedStation< Station, false >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_cargo_payment_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_orderlist_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_order_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_depot_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_subsidy_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_order_backup_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_sign_pool >::Iterate(), SpecializedVehicle< T, Type >::Iterate(), GameCreationSettings::landscape, EconomySettings::larger_towns, GameSettings::linkgraph, LoadStringWidthTable(), GameSettings::locale, Object::location, LOCK_PART_MIDDLE, Tile::m2(), MakeCanal(), MakeClear(), MakeDefaultName(), MakeSea(), MakeShore(), ConstructionSettings::map_height_limit, ConstructionSettings::max_bridge_length, MAX_COMPANIES, MAX_INFLATION, DifficultySettings::max_loan, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::MAX_SIZE, VehicleSettings::max_train_length, ConstructionSettings::max_tunnel_length, MAX_UVALUE, Map::MaxX(), Map::MaxY(), MayAnimateTile(), MayHaveBridgeAbove(), 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, GRFConfig::next, SpecializedVehicle< T, Type >::Next(), None, DifficultySettings::number_towns, OBJECT_HQ, OBJECT_STATUE, Economy::old_max_loan_unround, Economy::old_max_loan_unround_fract, Gamelog::Oldver(), OLFB_NO_LOAD, ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, TimerGameConst< struct Calendar >::ORIGINAL_BASE_YEAR, TimerGameConst< struct Economy >::ORIGINAL_BASE_YEAR, OSL_PLATFORM_FAR_END, OUFB_TRANSFER, OUFB_UNLOAD, BaseStation::owner, OWNER_NONE, OWNER_TOWN, OWNER_WATER, GameSettings::pf, VehicleSettings::plane_crashes, VehicleSettings::plane_speed, PM_PAUSED_ERROR, PM_PAUSED_NORMAL, PM_UNPAUSED, Gamelog::PrintDebug(), RailVehicleInfo::railtype, RAILTYPE_ELECTRIC, RAILTYPE_RAIL, RATING_INITIAL, LinkGraphSettings::recalc_interval, LinkGraphSettings::recalc_time, Station::RecomputeCatchmentForAll(), BaseStation::rect, IndustryBuildData::Reset(), ResetCompanyLivery(), ResetOldNames(), ResetSignalHandlers(), Backup< T >::Restore(), PathfinderSettings::reverse_at_signals, ReverseDiagDir(), ReverseDir(), VehicleSettings::road_side, ROAD_TILE_CROSSING, ROAD_TILE_DEPOT, ROAD_TILE_NORMAL, ROAD_X, ROAD_Y, RoadVehicle::roadtype, ROADTYPE_ROAD, ROADTYPE_TRAM, VehicleSettings::roadveh_acceleration_model, VehicleSettings::roadveh_slope_steepness, 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(), TimerGameConst< struct Calendar >::SECONDS_PER_DAY, StationSettings::serve_neutral_industries, SetAircraftPosition(), SetAnimatedTileState(), SetAnimationFrame(), SetBit(), SetBridgeMiddle(), SetClearGroundDensity(), SetCrossingReservation(), TimerGameCalendar::SetDate(), TimerGameEconomy::SetDate(), SetDepotReservation(), SetDockingTile(), SetFence(), SetHouseCompleted(), SetHouseType(), SetLiftPosition(), SetNonFloodingWaterTile(), SetRailStationReservation(), SetRailStationTileFlags(), 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, 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_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_REPAIR_OBJECT_DOCKING_TILES, SLV_ROAD_TYPES, SLV_SAVEGAME_ID, SLV_SCRIPT_RANDOMIZER, 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, GameCreationSettings::starting_year, StartScripts(), StartupEngines(), RoadVehicle::state, GameSettings::station, EconomySettings::station_noise_level, BaseTimer< TTimerType >::storage, Swap(), TAE_FOOD, TAE_GOODS, TAE_MAIL, TAE_PASSENGERS, TAE_WATER, TCGM_ORIGINAL, ConstructionSettings::terraform_frame_burst, 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, BaseStation::town, Town, Object::town, CargoSpec::town_acceptance_effect, EconomySettings::town_cargogen_mode, TOWN_CUSTOM_GROWTH, 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(), VehicleSettings::train_acceleration_model, VehicleSettings::train_slope_steepness, BaseStation::train_station, 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(), UpdateHousesAndTowns(), UpdateLevelCrossing(), UpdateNearestTownForRoadTiles(), UpdateOldAircraft(), UpdateStationAcceptance(), UpdateTownMaxPass(), FreeUnitIDGenerator::UseID(), VEH_INVALID, VEH_ROAD, VEH_SHIP, VEH_TRAIN, GameSettings::vehicle, Vehicle::vehstatus, VF_LOADING_FINISHED, VF_PATHFINDER_LOST, VS_CRASHED, VS_HIDDEN, VS_STOPPED, OrthogonalTileArea::w, PathfinderSettings::wait_for_pbs_path, PathfinderSettings::wait_oneway_signal, PathfinderSettings::wait_twoway_signal, WATER_CLASS_CANAL, WATER_CLASS_INVALID, WATER_CLASS_RIVER, WATER_CLASS_SEA, WATER_TILE_CLEAR, WATER_TILE_COAST, WATER_TILE_DEPOT, WATER_TILE_LOCK, 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 517 of file afterload.cpp.

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

Referenced by AfterLoadGame().

◆ ClearAllCachedNames()

void ClearAllCachedNames ( )

Definition at line 233 of file afterload.cpp.

◆ ConvertTownOwner()

static void ConvertTownOwner ( )
static

Definition at line 157 of file afterload.cpp.

◆ DoStartupNewCompany()

Company * DoStartupNewCompany ( bool  is_ai,
CompanyID  company = INVALID_COMPANY 
)
extern

◆ FixOwnerOfRailTrack()

static void FixOwnerOfRailTrack ( Tile  t)
static

◆ FixVehicleInclination()

static uint FixVehicleInclination ( Vehicle v,
Direction  dir 
)
static

Fixes inclination of a vehicle.

Older OpenTTD versions didn't update the bits correctly.

Parameters
vvehicle
dirvehicle's direction, or # INVALID_DIR if it can be ignored
Returns
inclination bits to set

Definition at line 482 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
signumreceived signal

Definition at line 364 of file afterload.cpp.

References _gamelog, _grfconfig, _saveload_crash_with_missing_newgrfs, BSWAP32(), FormatArrayAsHex(), GCF_COMPATIBLE, GCS_NOT_FOUND, Gamelog::GetOverriddenIdentifier(), HasBit(), GRFIdentifier::md5sum, GRFConfig::next, and ResetSignalHandlers().

Referenced by SetSignalHandlers().

◆ InitializeWindowsAndCaches()

◆ 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
tThe tile to analyze
Returns
True if a bridge might have been present prior to savegame 194.

Definition at line 537 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 3393 of file afterload.cpp.

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

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

◆ ResetSignalHandlers()

static void ResetSignalHandlers ( )
static

Resets signal handlers back to original handlers.

Definition at line 338 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 353 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 328 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
tthe tile to change.
include_invalid_water_classAlso consider WATER_CLASS_INVALID, i.e. industry tiles on land

Definition at line 86 of file afterload.cpp.

References DIAGDIR_BEGIN, DIAGDIR_END, GB(), GetTileType(), GetWaterClass(), IsCoast(), IsLock(), IsTileFlat(), Tile::m2(), MarkTileDirtyByTile(), Map::MaxX(), Map::MaxY(), MP_RAILWAY, MP_TREES, MP_WATER, RAIL_GROUND_WATER, SetWaterClass(), SlErrorCorrupt(), TileAddByDiagDir(), TileX(), TileY(), TREE_GROUND_SHORE, WATER_CLASS_CANAL, WATER_CLASS_INVALID, WATER_CLASS_RIVER, and WATER_CLASS_SEA.

Referenced by AfterLoadGame().

◆ StartScripts()

◆ UpdateAllVirtCoords()

void UpdateAllVirtCoords ( )

◆ UpdateCurrencies()

static void UpdateCurrencies ( )
static

Definition at line 202 of file afterload.cpp.

◆ UpdateExclusiveRights()

static void UpdateExclusiveRights ( )
static

Definition at line 177 of file afterload.cpp.

◆ UpdateRailType()

static RailType UpdateRailType ( RailType  rt,
RailType  min 
)
inlinestatic

Definition at line 216 of file afterload.cpp.

◆ UpdateVoidTiles()

static void UpdateVoidTiles ( )
static

Definition at line 210 of file afterload.cpp.

Variable Documentation

◆ _prev_abort

SignalHandlerPointer _prev_abort = nullptr
static

Definition at line 319 of file afterload.cpp.

◆ _prev_fpe

SignalHandlerPointer _prev_fpe = nullptr
static

Definition at line 320 of file afterload.cpp.

◆ _prev_segfault

SignalHandlerPointer _prev_segfault = nullptr
static

Definition at line 318 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 346 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 193 of file afterload.cpp.