OpenTTD Source 20260208-master-g43af8e94d0
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

CompanyDoStartupNewCompany (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 ()
 Up to revision 1413 the invisible tiles at the southern border have not been TileType::Void, even though they should have.
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?
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 314 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 561 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, IndustrySpec::accepts_cargo, ActiveClients, AddInflation(), CargoPacket::AfterLoad(), AfterLoadCompanyStats(), AfterLoadLabelMaps(), AfterLoadLinkGraphs(), AfterLoadRoadStops(), AfterLoadStoryBook(), AfterLoadVehiclesPhase1(), AfterLoadVehiclesPhase2(), AIR_AIRCRAFT, AircraftNextAirportPos_and_Order(), Airport, Animated, Arctic, AssignBit(), AT_OILRIG, Available, GoodsEntry::AvailableCount(), AXIS_X, AXIS_Y, AxisToDirection(), IndustrySpec::behaviour, Object::build_date, BuildingIsProtected, BuiltOnWater, Buoy, Bus, Station::bus_stops, CalcClosestTownFromTile(), Canal, CARGO_NO_REFIT, Vehicle::cargo_payment, CeilDiv(), ChangeTileOwner(), CheckGroundVehiclesAtCorrectZ(), Clamp(), ClampTo(), Clear, ClearBridgeMiddle(), ClearOldOrders(), ClosestTownFromTile(), ClrBit(), Coast, Compatible, ConnectMultiheadedTrains(), 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 Calendar >::DAYS_TILL_ORIGINAL_BASE_YEAR, TimerGameConst< struct Economy >::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(), DIR_N, Vehicle::direction, DirToDiagDir(), DistanceManhattan(), Dock, DoStartupNewCompany(), DT_MANUAL, Error, ExclusivePreview, HouseSpec::extra_flags, FarEnd, Fields, FindCompanyManagerFaceLabel(), FindFirstCargoWithTownAcceptanceEffect(), FixOwnerOfRailTrack(), FixupTrainLengths(), FixVehicleInclination(), FLYING, SpecializedStation< Station, false >::From(), SpecializedVehicle< RoadVehicle, Type >::From(), SpecializedVehicle< Train, Type >::From(), FundedOnly, GB(), GCS_NOT_FOUND, GenerateSavegameId(), CargoSpec::Get(), HouseSpec::Get(), SpecializedStation< Station, false >::Get(), GetAircraftFlightLevelBounds(), BaseStation::GetByTile(), Industry::GetByTile(), GetClearDensity(), GetClearGround(), GetCompanyRailTypes(), GetCompanyRoadTypes(), GetEncodedString(), GetFirstPlayableCompanyID(), GetHouseType(), SpecializedStation< Station, false >::GetIfValid(), GetInclinedSlopeDirection(), GetIndustryGfx(), GetIndustrySpec(), GetIndustryType(), GetLockPart(), GetNorthernBridgeEnd(), 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, Grass, GroundVehicle< T, Type >::gv_flags, GVF_GOINGDOWN_BIT, GVF_GOINGUP_BIT, OrthogonalTileArea::h, HasBit(), HasSignals(), HasStationRail(), HasStationTileRail(), HasTownOwnedRoad(), Hidden, House, Object::IncTypeCount(), Industry, 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(), IsWater(), Map::Iterate(), SpecializedStation< Station, false >::Iterate(), SpecializedStation< Waypoint, true >::Iterate(), Join, GoodsEntry::last_speed, LoadingFinished, LoadStringWidthTable(), Object::location, Lock, Tile::m2(), MakeCanal(), MakeClear(), MakeDefaultName(), MakeSea(), MakeShore(), MAX_INFLATION, Pool< CargoPayment, CargoPaymentID, 512 >::MAX_SIZE, Pool< Vehicle, VehicleID, 512 >::MAX_SIZE, Map::MaxX(), Map::MaxY(), MayAnimateTile(), MayHaveBridgeAbove(), Middle, TimerGameConst< struct Economy >::MIN_DATE, MIN_SNOWLINE_HEIGHT, MoveBuoysToWaypoints(), MoveWaypointsToBaseStations(), NEW_HOUSE_OFFSET, SpecializedVehicle< T, Type >::Next(), NoIntermediate, NoLoad, None, Normal, Object, OBJECT_HQ, OBJECT_STATUE, Oilrig, TimerGameConst< struct Calendar >::ORIGINAL_BASE_YEAR, TimerGameConst< struct Economy >::ORIGINAL_BASE_YEAR, BaseStation::owner, OWNER_NONE, OWNER_TOWN, OWNER_WATER, PathfinderLost, PlantOnBuild, Rail, RAILTYPE_ELECTRIC, RAILTYPE_RAIL, Railway, RandomiseCompanyManagerFace(), GoodsEntry::Rating, RATING_INITIAL, Station::RecomputeCatchmentForAll(), BaseStation::rect, ReplaceProtection, ReplaceWagonRemoval, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), ResetCompanyLivery(), ResetOldNames(), ResetSignalHandlers(), Backup< T >::Restore(), ReverseDiagDir(), ReverseDir(), River, Road, ROAD_X, ROAD_Y, RoadIsTram, RoadVehicle::roadtype, ROADTYPE_ROAD, ROADTYPE_TRAM, 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, 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(), Shore, 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_BUOYS_AT_0_0, SLV_CALENDAR_SUB_DATE_FRACT, 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, SnowOrDesert, SPECSTR_PRESIDENT_NAME, SPECSTR_TOWNNAME_START, StartScripts(), StartupEngines(), RoadVehicle::state, Station, GoodsEntry::status, TAE_FOOD, TAE_GOODS, TAE_MAIL, TAE_PASSENGERS, TAE_WATER, TCGM_ORIGINAL, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TFP_NONE, TFP_STUCK, OrthogonalTileArea::tile, Vehicle::tile, TILE_HEIGHT, TILE_SIZE, TILE_UNIT_MASK, TileAddXY(), TileDiffXY(), TileHash(), TileHeight(), TileVirtXY(), TileX(), TileXY(), TileY(), TL_BETTER_ROADS, TL_RANDOM, to_underlying(), Town, BaseStation::town, Object::town, CargoSpec::town_acceptance_effect, TOWN_GROWTH_DESERT, TOWN_GROWTH_RATE_NONE, Ticks::TOWN_GROWTH_TICKS, TOWN_GROWTH_WINTER, TOWN_HOUSE_COMPLETED, TRACK_BIT_NONE, TRACK_BIT_WORMHOLE, TRACK_BIT_X, TRACK_BIT_Y, TRACK_LOWER, TRACK_UPPER, TrackStatusToTrackBits(), Train, BaseStation::train_station, Transfer, TRANSPORT_RAIL, TRANSPORT_ROAD, Trees, TrimIndustryAcceptedProduced(), Tropic, TROPICZONE_NORMAL, Truck, Station::truck_stops, TunnelBridge, BaseVehicle::type, Object::type, GroupStatistics::UpdateAfterLoad(), UpdateAircraftCache(), UpdateCompanyLiveries(), UpdateGroupChildren(), UpdateHousesAndTowns(), UpdateLevelCrossing(), UpdateNearestTownForRoadTiles(), UpdateOldAircraft(), UpdateStationAcceptance(), UpdateTownMaxPass(), UpdateVoidTiles(), FreeUnitIDGenerator::UseID(), VEH_INVALID, VEH_ROAD, VEH_SHIP, VEH_TRAIN, Vehicle::vehstatus, Void, OrthogonalTileArea::w, Water, WL_CRITICAL, XYNSToDiagDir(), YapfNotifyTrackLayoutChange(), TimerGameCalendar::year, and TimerGameEconomy::year.

Referenced by DoLoad(), and SaveOrLoad().

◆ CheckGroundVehiclesAtCorrectZ()

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 512 of file afterload.cpp.

References GetSlopePixelZ(), and TileVirtXY().

Referenced by AfterLoadGame().

◆ ClearAllCachedNames()

void ClearAllCachedNames ( )

Definition at line 230 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()

void ConvertTownOwner ( )
static

Definition at line 162 of file afterload.cpp.

◆ DoStartupNewCompany()

◆ FixOwnerOfRailTrack()

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
ttile to update

Definition at line 419 of file afterload.cpp.

References DIAGDIR_BEGIN, DIAGDIR_END, GetCrossingRoadBits(), GetRoadOwner(), GetTileOwner(), GetTileTrackStatus(), Grass, HasBit(), IsLevelCrossingTile(), IsPlainRailTile(), Tile::m3(), Tile::m5(), Tile::m6(), Tile::m7(), MakeClear(), Normal, Vehicle::owner, ReverseDiagDir(), Road, RTT_ROAD, RTT_TRAM, SB(), SetRoadOwner(), SetTileOwner(), SetTileType(), TileOffsByDiagDir(), to_underlying(), and TRANSPORT_RAIL.

Referenced by AfterLoadGame().

◆ FixVehicleInclination()

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 477 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()

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 361 of file afterload.cpp.

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

Referenced by SetSignalHandlers().

◆ InitializeWindowsAndCaches()

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 246 of file afterload.cpp.

References _file_to_saveload, BuildOwnerLegend(), CheckTrainsLengths(), FT_SCENARIO, GSF_FAKE_TOWNS, Object::IncTypeCount(), SpecializedStation< Station, false >::Iterate(), TimerGameConst< struct Economy >::MIN_YEAR, RebuildSubsidisedSourceAndDestinationCache(), RecomputePrices(), ResetWindowSystem(), SetupColoursAndInitialWindow(), ShowNewGRFError(), GroupStatistics::UpdateAfterLoad(), UpdateAirportsNoise(), UpdateAllVirtCoords(), and TimerGameEconomy::year.

Referenced by AfterLoadGame().

◆ MayHaveBridgeAbove()

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 532 of file afterload.cpp.

References Clear, IsTileType(), Object, Railway, Road, TunnelBridge, and 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 3453 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()

void ResetSignalHandlers ( )
static

Resets signal handlers back to original handlers.

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

References _saveload_crash_with_missing_newgrfs.

Referenced by HandleCrash(), and HandleCrash().

◆ SetSignalHandlers()

void SetSignalHandlers ( )
static

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

Definition at line 325 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 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(), Railway, River, Sea, SetWaterClass(), Shore, SlErrorCorrupt(), TileAddByDiagDir(), TileX(), TileY(), Trees, and Water.

Referenced by AfterLoadGame().

◆ StartScripts()

void StartScripts ( )
static

Start the scripts.

Definition at line 541 of file afterload.cpp.

References Company::IsValidAiID(), ShowScriptDebugWindowIfScriptError(), AI::StartNew(), and Game::StartNew().

Referenced by AfterLoadGame().

◆ UpdateAllVirtCoords()

void UpdateAllVirtCoords ( )

◆ UpdateCurrencies()

void UpdateCurrencies ( )
static

Definition at line 198 of file afterload.cpp.

◆ UpdateExclusiveRights()

void UpdateExclusiveRights ( )
static

Definition at line 182 of file afterload.cpp.

◆ UpdateRailType()

RailType UpdateRailType ( RailType rt,
RailType min )
inlinestatic

Definition at line 213 of file afterload.cpp.

◆ UpdateVoidTiles()

void UpdateVoidTiles ( )
static

Up to revision 1413 the invisible tiles at the southern border have not been TileType::Void, even though they should have.

This is fixed by this function.

Definition at line 207 of file afterload.cpp.

References MakeVoid(), Map::MaxX(), Map::MaxY(), Map::SizeX(), Map::SizeY(), and TileXY().

Referenced by AfterLoadGame().

Variable Documentation

◆ _prev_abort

SignalHandlerPointer _prev_abort = nullptr
static

Definition at line 316 of file afterload.cpp.

◆ _prev_fpe

SignalHandlerPointer _prev_fpe = nullptr
static

Definition at line 317 of file afterload.cpp.

◆ _prev_segfault

SignalHandlerPointer _prev_segfault = nullptr
static

Definition at line 315 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 343 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.