OpenTTD Source 20261129-master-g72a8bdc861
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 "../network/network.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 "../station_func.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_base.h"
#include "../tree_map.h"
#include "../company_func.h"
#include "../company_manager_face.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 "../subsidy_base.h"
#include "../subsidy_func.h"
#include "../newgrf.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 "../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_error.hpp"
#include "saveload_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(* SignalHandlerPointer) (int)

Functions

Company * DoStartupNewCompany (bool is_ai, CompanyID company=CompanyID::Invalid())
 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 ()
 Since savegame version 4.1, exclusive transport rights are stored at towns.
static void UpdateCurrencies ()
 Since savegame version 4.2 the currencies are arranged differently.
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 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 GroundVehicleFlags 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 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(* SignalHandlerPointer) (int)

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

References _animated_tiles, _current_company, _gamelog, _grfconfig, _industry_builder, _network_dedicated, _network_server, _networking, _new_competitor_timeout, _old_engine_renew_saveload_pool, _old_order_saveload_pool, _old_vds, _pause_mode, _random, _road_stop_stop_frame, _saved_scrollpos_x, _saved_scrollpos_y, _saved_scrollpos_zoom, _settings_client, _settings_game, _settings_newgame, _tunnel_visibility_frame, IndustrySpec::accepts_cargo, ActiveClients, OrthogonalTileArea::Add(), AddInflation(), AdjacentStations, CargoPacket::AfterLoad(), AfterLoadCompanyStats(), AfterLoadLabelMaps(), AfterLoadLinkGraphs(), AfterLoadRoadStops(), AfterLoadStoryBook(), AfterLoadVehiclesPhase1(), AfterLoadVehiclesPhase2(), AIR_AIRCRAFT, AircraftNextAirportPos_and_Order(), AircraftSpeedHolding, Airport, AirportAnimationFrames, AirportNoise, AIStartDate, All, AllGood, Animated, AnimatedTileStateInMap, Arctic, AssignBit(), AT_OILRIG, AutoreplaceWhenOldTreeLimit, Available, GoodsEntry::AvailableCount(), AxisToDirection(), AxisToRoadBits(), AxisToTrack(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::base(), IndustrySpec::behaviour, BetterRoads, BigDates, BridgeWormhole, Object::build_date, BuiltOnWater, Buoy, BuoysAt0_0, Bus, Station::bus_stops, CalcClosestTownFromTile(), CalendarSubDateFract, Canal, CARGO_NO_REFIT, Vehicle::cargo_payment, Cargodist, CargoPaymentOverflow, CargoPayments, CeilDiv(), ChangeTileOwner(), CheckGroundVehiclesAtCorrectZ(), Cities, Clamp(), ClampTo(), Clear, ClearBridgeMiddle(), ClosestTownFromTile(), ClrBit(), Coast, Combo, CompanyInauguratedPeriodV2, CompanyServiceIntervals, Compatible, ConnectMultiheadedTrains(), ConsistentPartialZ, ConvertFromOldCompanyManagerFace(), ConvertOldMultiheadToNew(), CopyFromOldName(), CopyTempEngineData(), TimerGameTick::counter, CountPaidForCargo, Crashed, Critical, Crossing, CumulatedInflation, Vehicle::current_order, CustomGrowth, CustomSeaLevel, 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, Default, Depot, DepotUnbunching, DepotWaterOwners, DiagDirToAxis(), DiagDirToDiagTrack(), DiagDirToDiagTrackdir(), DiagDirToDir(), Vehicle::direction, DirToDiagDir(), DisableElrailSetting, DisableTownLevelCrossing, DisallowRoadReconstruction, DistanceManhattan(), DistantStationJoining, Dock, DoStartupNewCompany(), DriveBackwards, EconomyDate, EconomyModeTimekeepingUnits, Electric, Elrail, EndingYear, EndOfLineOnly, EngineRenew, Error, ExclusivePreview, ExtendIndustryCargoSlots, ExtendRailtypes, FaceStyles, FarEnd, Fields, FifoLoading, FindCompanyManagerFaceLabel(), FindFirstCargoWithTownAcceptanceEffect(), FixCompanyCargoTypes, FixOrderBackup, FixOwnerOfRailTrack(), FixStationPickupAccounting, FixTreeGround, FixupTrainLengths(), FixVehicleInclination(), Train::flags, FLYING, Food, FoundTown, FractionProfitRunningTicks, FreeformEdges, SpecializedStation< Station, false >::From(), SpecializedVehicle< RoadVehicle, Type >::From(), SpecializedVehicle< Train, Type >::From(), FundedOnly, Gamelog, GB(), GenerateSavegameId(), CargoSpec::Get(), SpecializedStation< Station, false >::Get(), GetAircraftFlightLevelBounds(), BaseStation::GetByTile(), Industry::GetByTile(), GetClearDensity(), GetClearGround(), GetCompanyRailTypes(), GetCompanyRoadTypes(), GetCustomStationSpecIndex(), 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_COAL_MINE_TOWER_ANIMATED, GFX_COPPER_MINE_TOWER_ANIMATED, GFX_GOLD_MINE_TOWER_ANIMATED, GFX_OILRIG_1, GFX_OILWELL_ANIMATED_1, GFX_OILWELL_ANIMATED_2, GFX_OILWELL_ANIMATED_3, GFX_POWERPLANT_SPARKS, GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET, GfxLoadSprites(), GoalProgressPlaneAcceleration, GoingDown, GoingUp, Goods, Grass, GroupNumbers, GroupReplaceWagonRemoval, GSIndustryControl, GroundVehicle< T, Type >::gv_flags, OrthogonalTileArea::h, HasBit(), HasSignals(), HasStationRail(), HasStationTileRail(), HasTownOwnedRoad(), Hidden, House, ImprovedOrders, ImproveMultistop, IncreaseHouseLimit, IncreaseStationTypeFieldSize, Industry, IndustryManagement, IndustryPlatform, IndustryTileWaterClass, InfrastructureMaintenanceCosts, InitializeSignalGui(), InitializeWindowsAndCaches(), Invalid, INVALID_OWNER, INVALID_ROADTYPE, INVALID_TILE, 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(), IsRailWaypointTile(), 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, LargerTownCargoStatistics, LargerTownIterator, GoodsEntry::last_speed, LastLoadingTick, LastVehicleType, LeaveRoadStopSeparately, LinkFarmFieldToIndustry, LinkgraphSeconds, Liveries, LoadingFinished, LoadStringWidthTable(), Object::location, Lock, Lower, Tile::m2(), Mail, MakeCanal(), MakeClear(), MakeDefaultName(), MakeRailNormal(), MakeSea(), MakeShore(), Manual, MAX_INFLATION, Pool< CargoPayment, CargoPaymentID, 512 >::MAX_SIZE, Pool< Vehicle, VehicleID, 512 >::MAX_SIZE, MaxBridgeMapHeight, MaximumDepotPenalty, MaxLengthAndReverseSignals, MaxLoanForCompany, Map::MaxX(), Map::MaxY(), MayAnimateTile(), MayHaveBridgeAbove(), Middle, TimerGameConst< struct Economy >::MIN_DATE, MIN_SNOWLINE_HEIGHT, MinVersion, MonthlyBankruptcyCheck, MoreAirportBlocks, MoreCargoPackets, MoreCompanies, MoreEngineTypes, MoreHouseAnimationFrames, MoveBuoysToWaypoints(), MoveSemaphoreBits, MoveWaypointsToBaseStations(), MultipleRoadStops, MultipleRoadTypes, MultipleSignalTypes, MultitileDocks, MultiTileWaypoints, MultitrackLevelCrossings, N, NE, Net, NEW_HOUSE_OFFSET, NewGRFAirportSmoke, NewGRFDepotBuildDate, NewGRFHouses, NewGRFIndustryRandomTriggers, NewGRFLastService, NewGRFPalette, NewGRFPersistentStorage, NewGRFSuppliedStationName, SpecializedVehicle< T, Type >::Next(), NoLoad, None, NonfloodingWaterTiles, NonStop, Normal, NotFound, NW, Object, OBJECT_HQ, OBJECT_STATUE, ObjectTypeToPool, Oilrig, OrderMaxSpeed, Original, TimerGameConst< struct Calendar >::ORIGINAL_BASE_YEAR, TimerGameConst< struct Economy >::ORIGINAL_BASE_YEAR, OtherAxis(), BaseStation::owner, OWNER_NONE, OWNER_TOWN, OWNER_WATER, Passengers, PathfinderLost, PauseModes, PersistentStoragePool, PlaneSpeedFactor, PlantOnBuild, PlatformStopLocation, Rail, RailTrackTypeUnification, RAILTYPE_ELECTRIC, RAILTYPE_RAIL, Railway, Random, RandomiseCompanyManagerFace(), GoodsEntry::Rating, RATING_INITIAL, Station::RecomputeCatchmentForAll(), ReducePlaneCrashes, RefitOrders, RemoveOldPbs, RemoveSubsidyStationBinding, ReorderUnmovableRemoveReserved, RepairObjectDockingTiles, ReplaceCustomNameArray, ReplaceProtection, ReplaceWagonRemoval, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), ResetCompanyLivery(), ResetOldNames(), ResetSignalHandlers(), ReverseDiagDir(), ReverseDir(), Right, River, Road, RoadIsTram, RoadLayoutPerTown, ROADTRAMTYPES_ALL, RoadVehicle::roadtype, ROADTYPE_ROAD, ROADTYPE_TRAM, RoadTypes, RocksStayUnderSnow, RVC_DRIVE_THROUGH_STOP_FRAME, RvRealisticAcceleration, RVS_DRIVE_SIDE, RVS_ENTERED_STOP, RVS_IN_DT_ROAD_STOP, RVS_IN_ROAD_STOP, RVSB_IN_DEPOT, RVSB_IN_ROAD_STOP, RVSB_WORMHOLE, SavegameId, SB(), ScriptRandomizer, ScriptSaveInstances, ScriptTownGrowth, SE, Sea, TimerGameConst< struct Calendar >::SECONDS_PER_DAY, Semaphore, SeparateLocaleUnits, SeparateOrderTravelWaitTime, SeparateRoadOwners, ServeNeutralIndustries, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SetAircraftPosition(), SetAnimatedTileState(), SetAnimationFrame(), SetBit(), SetBridgeMiddle(), SetClearGroundDensity(), SetCompanyManagerFaceStyle(), SetCrossingReservation(), TimerGameCalendar::SetDate(), TimerGameEconomy::SetDate(), SetDepotReservation(), SetDockingTile(), SetFence(), SetHouseCompleted(), SetHouseType(), SetLiftPosition(), SetNonFloodingWaterTile(), SetRailStationReservation(), SetRailType(), SetRoadOwner(), SetRoadTypes(), SetSaveLoadError(), SetSignalHandlers(), SetSignalStates(), SetSignalVariant(), SetStationGfx(), SetTileOwner(), SetTileType(), CompanyProperties::settings, SetTownIndex(), SetTrackReservation(), SetTropicZone(), SetTunnelBridgeReservation(), SetWaterClass(), SetWaterClassDependingOnSurroundings(), SetWaterTileType(), Ship, ShipAcceleration, ShipsStopInLocks, Shore, ShowErrorMessage(), SimplifyPathfinderSettings, SimplifyPlayerFace, Sl, SlError(), SlErrorCorrupt(), SnowOrDesert, SPECSTR_PRESIDENT_NAME, SPECSTR_TOWNNAME_START, SplitHQ, SplitLoadWaitCounters, SplitStationTypeFromGfxid, BaseStation::spread, StartScripts(), StartupEngines(), RoadVehicle::state, Station, StationsUnderBridges, StatueOwner, GoodsEntry::status, StoreAirportSize, StoreIndustryCargo, StoreWaypointIdInMap, SW, TerraformLimits, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TFP_NONE, TFP_STUCK, Tile, OrthogonalTileArea::tile, Vehicle::tile, TILE_HEIGHT, TILE_SIZE, TILE_UNIT_MASK, TileAddXY(), TileDiffXY(), TileHash(), TileHeight(), TileVirtXY(), TileX(), TileXY(), TileY(), 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, TownAcceptance, TownCargogen, TownGrowthInGameTicks, TownLayout, TownTolerancePauseMode, Train::track, TrackdirBitsToTrackBits(), TrackStatus::trackdirs, TrackRealAndAutoOrders, Train, BaseStation::train_station, TrainSlopeSteepness, Tram, Transfer, Trees, TreesWaterClass, TrimIndustryAcceptedProduced(), Tropic, Truck, Station::truck_stops, TunnelBridge, BaseVehicle::type, Object::type, UnifyAnimationFrame, UnifyAnimationState, UnifyRvTravelTime, UnifyWaterClass, UnifyWaypointAndStation, UniqueDepotNames, GroupStatistics::UpdateAfterLoad(), UpdateAircraftCache(), UpdateCompanyLiveries(), UpdateCurrencies(), UpdateExclusiveRights(), UpdateGroupChildren(), UpdateHousesAndTowns(), UpdateLevelCrossing(), UpdateNearestTownForRoadTiles(), UpdateOldAircraft(), UpdateStationAcceptance(), UpdateTownMaxPass(), UpdateVoidTiles(), Upper, FreeUnitIDGenerator::UseID(), VehicleCentreAndZPos, VehicleCurrencyStationChanges, VehicleEconomyAge, Vehicle::vehstatus, VelocityNautical, VeryLowTownIndustryNumber, VirtualFeederSharePayment, Void, OrthogonalTileArea::w, Water, WaterClass, WaterTileType, WaypointMoreLikeStation, Wormhole, X, XYNSToDiagDir(), Y, YapfNotifyTrackLayoutChange(), Yapp, 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 508 of file afterload.cpp.

References GetSlopePixelZ(), and TileVirtXY().

Referenced by AfterLoadGame().

◆ ClearAllCachedNames()

void ClearAllCachedNames ( )

Definition at line 226 of file afterload.cpp.

◆ ConvertTownOwner()

void ConvertTownOwner ( )
static

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

References BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::base(), End, GetCrossingRoadBits(), GetRoadOwner(), GetTileOwner(), GetTileTrackStatus(), Grass, HasBit(), Invalid, IsLevelCrossingTile(), IsPlainRailTile(), Tile::m3(), Tile::m5(), Tile::m6(), Tile::m7(), MakeClear(), Normal, Vehicle::owner, Rail, ReverseDiagDir(), Road, SB(), SetRoadOwner(), SetTileOwner(), SetTileType(), TileOffsByDiagDir(), to_underlying(), and Tram.

Referenced by AfterLoadGame().

◆ FixVehicleInclination()

GroundVehicleFlags 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 # Direction::Invalid if it can be ignored
Returns
inclination bits to set

Definition at line 473 of file afterload.cpp.

References GetSlopePixelZ(), GoingDown, GoingUp, Invalid, NE, NW, SE, SW, TILE_SIZE, TILE_UNIT_MASK, Vehicle::x_pos, and Vehicle::y_pos.

Referenced by AfterLoadGame().

◆ HandleSavegameLoadCrash()

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

References _gamelog, _grfconfig, _saveload_crash_with_missing_newgrfs, Compatible, FormatArrayAsHex(), GRFIdentifier::md5sum, NotFound, 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 242 of file afterload.cpp.

References _file_to_saveload, Airports, BuildOwnerLegend(), CheckTrainsLengths(), FakeTowns, Object::IncTypeCount(), Industries, SpecializedStation< Station, false >::Iterate(), TimerGameConst< struct Economy >::MIN_YEAR, RebuildSubsidisedSourceAndDestinationCache(), RecomputePrices(), ResetWindowSystem(), Scenario, 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 528 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 3470 of file afterload.cpp.

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

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

◆ ResetSignalHandlers()

void ResetSignalHandlers ( )
static

Resets signal handlers back to original handlers.

Definition at line 331 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 346 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 321 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 87 of file afterload.cpp.

References Canal, End, GB(), GetRailGroundType(), 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 537 of file afterload.cpp.

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

Referenced by AfterLoadGame().

◆ UpdateAllVirtCoords()

void UpdateAllVirtCoords ( )

◆ UpdateCurrencies()

void UpdateCurrencies ( )
static

Since savegame version 4.2 the currencies are arranged differently.

Definition at line 186 of file afterload.cpp.

References _settings_game, ATS, BEF, CHF, CZK, DEM, DKK, ESP, EUR, FIM, FRF, GBP, GRD, HUF, ISK, ITL, JPY, NLG, NOK, PLN, RON, RUR, SIT, to_underlying(), and USD.

Referenced by AfterLoadGame().

◆ UpdateExclusiveRights()

void UpdateExclusiveRights ( )
static

Since savegame version 4.1, exclusive transport rights are stored at towns.

Definition at line 178 of file afterload.cpp.

Referenced by AfterLoadGame().

◆ UpdateRailType()

RailType UpdateRailType ( RailType rt,
RailType min )
inlinestatic

Definition at line 209 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 203 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 312 of file afterload.cpp.

◆ _prev_fpe

SignalHandlerPointer _prev_fpe = nullptr
static

Definition at line 313 of file afterload.cpp.

◆ _prev_segfault

SignalHandlerPointer _prev_segfault = nullptr
static

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

Referenced by HandleSavegameLoadCrash(), and SaveloadCrashWithMissingNewGRFs().