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 "../gfxinit.h"`
`#include "../viewport_func.h"`
`#include "../industry.h"`
`#include "../clear_map.h"`
`#include "../vehicle_func.h"`
`#include "../string_func.h"`
`#include "../date_func.h"`
`#include "../roadveh.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 "../ai/ai_gui.hpp"`
`#include "../town.h"`
`#include "../economy_base.h"`
`#include "../animated_tile_func.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 "../error.h"`
`#include "saveload_internal.h"`
`#include <signal.h>`

Go to the source code of this file.

## Typedefs
typedef void(CDECL * | SignalHandlerPointer )(int)
## Functions
Company * | DoStartupNewCompany (bool is_ai, CompanyID company=INVALID_COMPANY)
| Create a new company and sets all company variables default values.
void | SetWaterClassDependingOnSurroundings (TileIndex 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.
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.
static const GRFIdentifier * | GetOverriddenIdentifier (const GRFConfig *c)
| Try to find the overridden GRF identifier of the given GRF.
bool | SaveloadCrashWithMissingNewGRFs ()
| Did loading the savegame cause a crash? If so, were NewGRFs missing?
static void | FixOwnerOfRailTrack (TileIndex 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.
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 byte | convert_currency []
static SignalHandlerPointer | _prev_segfault = NULL
static SignalHandlerPointer | _prev_abort = NULL
static SignalHandlerPointer | _prev_fpe = NULL
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.

## Function Documentation

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.

Definition at line 480 of file afterload.cpp.

References _animated_tile_count, _animated_tile_list, _cur_year, _current_company, _date, _date_fract, _grfconfig, _industry_builder, _m, _me, _network_dedicated, _network_server, _networking, _old_vds, _pause_mode, _road_stop_stop_frame, _settings_client, _settings_game, _tile_type_procs, _tunnel_visibility_frame, Vehicle::acceleration, GoodsEntry::acceptance_pickup, IndustrySpec::accepts_cargo, Industry::accepts_cargo, AddInflation(), CargoPacket::AfterLoad(), AfterLoadCompanyStats(), AfterLoadLinkGraphs(), AfterLoadRoadStops(), AfterLoadVehicles(), AIR_AIRCRAFT, AircraftNextAirportPos_and_Order(), Station::airport, EconomySettings::allow_town_roads, CompanyProperties::avail_railtypes, Company::avail_roadtypes, Subsidy::awarded, AXIS_X, AxisToDirection(), CompanyProperties::bankrupt_asked, IndustrySpec::behaviour, Depot::build_date, Object::build_date, BaseStation::build_date, Vehicle::build_year, Station::bus_stops, GroundVehicleCache::cached_total_length, 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(), GoodsEntry::cargo, Vehicle::cargo_payment, Subsidy::cargo_type, CeilDiv(), ChangeTileOwner(), Clamp(), CLEAR_FIELDS, ConstructionSettings::clear_frame_burst, CLEAR_GRASS, CompanyProperties::clear_limit, CLEAR_SNOW, ClearBridgeMiddle(), ClosestTownFromTile(), ClrBit(), Object::colour, ClientSettings::company, Engine::company_avail, COMPANY_FIRST, ConnectMultiheadedTrains(), Train::ConsistChanged(), GameSettings::construction, ConvertFromOldCompanyManagerFace(), Order::ConvertFromOldSavegame(), ConvertOldMultiheadToNew(), CopyFromOldName(), CopyTempEngineData(), CargoList< Tinst, Tcont >::Count(), CT_NO_REFIT, BaseConsist::cur_implicit_order_index, BaseConsist::cur_real_order_index, Vehicle::cur_speed, Vehicle::current_order, CargoPayment::current_station, Vehicle::date_of_last_service, DAY_TICKS, DEBUG, DeleteAnimatedTile(), Vehicle::dest_tile, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, DiagDirToAxis(), DiagDirToDiagTrackBits(), DiagDirToDiagTrackdir(), DiagDirToDir(), GameSettings::difficulty, Vehicle::direction, DirToDiagDir(), VehicleSettings::disable_elrails, Station::dock_tile, DoStartupNewCompany(), Subsidy::dst, Subsidy::dst_type, VehicleSettings::dynamic_engines, GameSettings::economy, EF_ROAD_TRAM, CompanySettings::engine_renew, Company::engine_renew_list, CompanySettings::engine_renew_money, CompanySettings::engine_renew_months, Vehicle::engine_type, CompanyProperties::face, FACIL_AIRPORT, FACIL_DOCK, FACIL_TRAIN, BaseStation::facilities, FindFirstCargoWithTownEffect(), SpecializedVehicle< T, Type >::First(), Vehicle::FirstShared(), FixOwnerOfRailTrack(), FixupTrainLengths(), FixVehicleInclination(), FLYING, FOR_ALL_AIRCRAFT, FOR_ALL_CARGO_PAYMENTS, FOR_ALL_DISASTERVEHICLES, FOR_ALL_VEHICLES, FOR_ALL_WAYPOINTS, PathfinderSettings::forbid_90_deg, Industry::founder, OrderList::FreeChain(), ConstructionSettings::freeform_edges, SpecializedVehicle< RoadVehicle, Type >::From(), SpecializedVehicle< Train, Type >::From(), SpecializedStation< Station, false >::From(), CargoPayment::front, GameSettings::game_creation, GamelogGRFAddList(), GamelogGRFCompatible(), GamelogGRFRemove(), GamelogOldver(), GamelogPrintDebug(), GamelogTestMode(), GamelogTestRevision(), GB(), GroundVehicle< T, Type >::gcache, GCF_COMPATIBLE, GCS_NOT_FOUND, GoodsEntry::GES_PICKUP, CargoSpec::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), SpecializedStation< Station, false >::Get(), GetAircraftFlyingAltitude(), SpecializedStation< Waypoint, true >::GetByTile(), SpecializedStation< Station, false >::GetByTile(), BaseStation::GetByTile(), GetClearDensity(), GetCompanyRailtypes(), GetCompanyRoadtypes(), Order::GetDestination(), OrderList::GetFirstOrder(), OverrideManagerBase::GetGRFID(), GetHouseType(), SpecializedStation< Station, false >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), GetIndustryGfx(), GetIndustrySpec(), GetIndustryType(), GetNorthernBridgeEnd(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetNumItems(), Vehicle::GetNumOrders(), GetObjectType(), GetOtherShipDepotTile(), GetOtherTunnelBridgeEnd(), GetRailType(), GetRawClearGround(), GetRoadOwner(), GetRoadTileType(), Airport::GetSpec(), GetStationGfx(), GetStationType(), GetTargetAirportIfValid(), GetTileOwner(), GetTileSlope(), GetTileTrackStatus(), GetTileType(), GetTownIndex(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), Order::GetUnloadType(), PersistentStorageArray< TYPE, SIZE >::GetValue(), GetWaterClass(), GetWaterTileType(), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET, GfxLoadSprites(), GLC_ALL_GOOD, GLC_COMPATIBLE, GLC_NOT_FOUND, Town::goal, Station::goods, PersistentStorage::grfid, GroundVehicle< T, Type >::gv_flags, GVF_GOINGDOWN_BIT, GVF_GOINGUP_BIT, TileArea::h, HasBit(), HasSignals(), HasStationRail(), HasTownOwnedRoad(), Town::have_ratings, CompanyProperties::inaugurated_year, Object::IncTypeCount(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Station::indtype, DifficultySettings::industry_density, INDUSTRYBEH_BUILT_ONWATER, INDUSTRYBEH_PLANT_ON_BUILT, Economy::inflation_payment, Economy::inflation_prices, EconomySettings::infrastructure_maintenance, InitializeRailGUI(), InitializeWindowsAndCaches(), Engine::intro_date, INVALID_COMPANY, INVALID_OWNER, INVALID_STRING_ID, INVALID_TILE, INVALID_TRACK, CompanyProperties::is_ai, IsAirportTile(), IsBridge(), IsBridgeTile(), IsBuoy(), IsBuoyTile(), IsClearGround(), IsDock(), IsDriveThroughStopTile(), SpecializedStation< Station, false >::IsExpected(), GroundVehicle< T, Type >::IsFreeWagon(), Vehicle::IsFrontEngine(), IsGoodGRFConfigList(), Vehicle::IsGroundVehicle(), IsHouseCompleted(), IsInsideMM(), IsLevelCrossing(), IsLevelCrossingTile(), IsLock(), Aircraft::IsNormalAircraft(), IsOilRig(), IsPlainRail(), IsPlainRailTile(), Vehicle::IsPrimaryVehicle(), IsRailDepot(), IsRailDepotTile(), IsRoadDepot(), IsRoadStop(), IsSavegameVersionBefore(), IsShipDepot(), IsShipDepotTile(), IsStandardRoadStopTile(), IsStatueTile(), IsTileOwner(), IsTileType(), IsTruckStop(), IsTunnelTile(), Order::IsType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_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<&_company_pool >::IsValidID(), IsWater(), GameCreationSettings::landscape, Town::larger_town, EconomySettings::larger_towns, Industry::last_prod_year, GoodsEntry::last_speed, Vehicle::last_station_visited, Town::layout, lengthof, Vehicle::list, Vehicle::load_unload_ticks, LoadStringWidthTable(), Object::location, CompanyProperties::location_of_HQ, Tile::m1, Tile::m2, Tile::m3, Tile::m4, Tile::m5, TileExtended::m7, MakeCanal(), MakeClear(), MakeDefaultName(), MakeRoadNormal(), MakeSea(), MakeShore(), MapMaxX(), MapMaxY(), MapSize(), MAX_COMPANIES, MAX_INFLATION, DifficultySettings::max_loan, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::MAX_SIZE, VehicleSettings::max_train_length, MayHaveBridgeAbove(), min(), MIN_SNOWLINE_HEIGHT, StationSettings::modified_catchment, CompanyProperties::months_of_bankruptcy, MoveBuoysToWaypoints(), MoveWaypointsToBaseStations(), MP_CLEAR, MP_HOUSE, MP_INDUSTRY, MP_OBJECT, MP_RAILWAY, MP_ROAD, MP_STATION, MP_TREES, MP_TUNNELBRIDGE, MP_VOID, MP_WATER, BaseStation::name, CompanyProperties::name, CompanyProperties::name_1, PathfinderSettings::new_pathfinding_all, GRFConfig::next, DifficultySettings::number_towns, OBJECT_HQ, OBJECT_STATUE, Economy::old_max_loan_unround, Economy::old_max_loan_unround_fract, OLFB_NO_LOAD, ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, Vehicle::orders, ORIGINAL_BASE_YEAR, OSL_PLATFORM_FAR_END, OUFB_TRANSFER, OUFB_UNLOAD, BaseStation::owner, OWNER_NONE, OWNER_TOWN, OWNER_WATER, PathfinderSettings::pathfinder_for_roadvehs, PathfinderSettings::pathfinder_for_ships, PathfinderSettings::pathfinder_for_trains, GameSettings::pf, VehicleSettings::plane_speed, PM_PAUSED_ERROR, PM_PAUSED_NORMAL, PM_UNPAUSED, CompanyProperties::president_name, CompanyProperties::president_name_1, Industry::produced_cargo, Vehicle::profit_last_year, Vehicle::profit_this_year, Airport::psa, Industry::psa, YAPFSettings::rail_use_yapf, RAILTYPE_ELECTRIC, RATING_INITIAL, Town::ratings, BaseStation::rect, Subsidy::remaining, CompanySettings::renew_keep_length, Train::ReserveTrackUnderConsist(), 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, YAPFSettings::road_use_yapf, ROAD_X, ROAD_Y, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_ROAD, VehicleSettings::roadveh_acceleration_model, Vehicle::running_ticks, 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(), GameSettings::script, SetAircraftPosition(), SetAnimationFrame(), SetBit(), SetBridgeMiddle(), SetClearGroundDensity(), SetCrossingReservation(), SetDate(), SetDepotReservation(), SetFenceNE(), SetFenceNW(), SetHouseCompleted(), SetLiftPosition(), Order::SetLoadType(), Order::SetNonStopType(), SetRailStationReservation(), SetRailType(), Order::SetRefit(), SetRoadOwner(), SetRoadTypes(), SetSaveLoadError(), SetSignalHandlers(), SetSignalStates(), SetStationGfx(), Order::SetStopLocation(), SetTileOwner(), Company::settings, ScriptSettings::settings_profile, SettingsDisableElrail(), SetTownIndex(), SetTrackReservation(), SetTropicZone(), SetTunnelBridgeReservation(), Order::SetUnloadType(), SetWaterClass(), SetWaterClassDependingOnSurroundings(), CompanyProperties::share_owners, YAPFSettings::ship_use_yapf, ShowErrorMessage(), SIG_ELECTRIC, SIG_SEMAPHORE, SIGTYPE_COMBO, AirportSpec::size_x, AirportSpec::size_y, SlError(), SlErrorCorrupt(), SLOPE_FLAT, GameCreationSettings::snow_line_height, SP_END, SP_MEDIUM, Subsidy::src, Subsidy::src_type, AI::StartNew(), StartupEngines(), Aircraft::state, RoadVehicle::state, GameSettings::station, PersistentStorageArray< TYPE, SIZE >::storage, BaseStation::string_id, Vehicle::subtype, Swap(), TE_FOOD, TE_GOODS, TE_MAIL, TE_PASSENGERS, TE_WATER, ConstructionSettings::terraform_frame_burst, CompanyProperties::terraform_limit, TFP_NONE, Vehicle::tile, TileArea::tile, TILE_ADDXY, TILE_HEIGHT, TILE_SIZE, TILE_UNIT_MASK, TileHash(), TileHeight(), TileVirtXY(), TileX(), TileXY(), TileY(), TL_RANDOM, BaseStation::town, Object::town, Waypoint::town_cn, Depot::town_cn, CargoSpec::town_effect, TOWN_GROWTH_DESERT, TOWN_GROWTH_WINTER, TOWN_HOUSE_COMPLETED, EconomySettings::town_layout, GameCreationSettings::town_name, TRACK_BIT_NONE, TRACK_BIT_X, TRACK_BIT_Y, TRACK_LOWER, TRACK_UPPER, TRACK_X, TrackStatusToTrackBits(), VehicleSettings::train_acceleration_model, BaseStation::train_station, TRANSPORT_RAIL, TRANSPORT_ROAD, ConstructionSettings::tree_frame_burst, TREE_GROUND_SNOW_DESERT, CompanyProperties::tree_limit, TROPICZONE_NORMAL, Station::truck_stops, Aircraft::turn_counter, Industry::type, BaseVehicle::type, Airport::type, UpdateAircraftCache(), UpdateHousesAndTowns(), UpdateLevelCrossing(), UpdateNearestTownForRoadTiles(), UpdateOldAircraft(), Vehicle::UpdateRealOrderIndex(), UpdateStationAcceptance(), UpdateTownCargoes(), VEH_ROAD, VEH_SHIP, VEH_TRAIN, CompanySettings::vehicle, GameSettings::vehicle, BaseConsist::vehicle_flags, Vehicle::vehstatus, VF_LOADING_FINISHED, VF_PATHFINDER_LOST, VPF_NPF, VS_CRASHED, VS_STOPPED, TileArea::w, Train::wait_counter, 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_LOCK, WL_CRITICAL, Vehicle::x_pos, Town::xy, BaseStation::xy, XYNSToDiagDir(), Vehicle::y_pos, PathfinderSettings::yapf, YapfNotifyTrackLayoutChange(), and Vehicle::z_pos.

Referenced by DoLoad(), and SaveOrLoad().

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

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 527 of file company_cmd.cpp.

References _company_colours, _cur_year, _network_server, _networking, CompanyProperties::avail_railtypes, Company::avail_roadtypes, AI::BroadcastNewEvent(), BuildOwnerLegend(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::CanAllocateItem(), CompanyProperties::colour, CompanyProperties::current_loan, CompanyProperties::face, GenerateCompanyColour(), GeneratePresidentName(), GetCompanyRailtypes(), GetCompanyRoadtypes(), CompanyProperties::inaugurated_year, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Economy::inflation_prices, INVALID_COMPANY, InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), CompanyProperties::money, Game::NewEvent(), RandomCompanyManagerFaceBits(), ResetCompanyLivery(), SetDefaultCompanySettings(), SetWindowClassesDirty(), SetWindowDirty(), CompanyProperties::share_owners, AI::StartNew(), WC_CLIENT_LIST, WC_CLIENT_LIST_POPUP, WC_GRAPH_LEGEND, WC_LINKGRAPH_LEGEND, and WC_SMALLMAP.

Referenced by AfterLoadGame(), and CmdCompanyCtrl().

static void FixOwnerOfRailTrack | ( | TileIndex | 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 398 of file afterload.cpp.

References CLEAR_GRASS, DIAGDIR_BEGIN, GetCrossingRoadBits(), GetRoadOwner(), GetRoadTypes(), GetTileOwner(), GetTileTrackStatus(), GetTownIndex(), IsLevelCrossingTile(), IsPlainRailTile(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), MakeClear(), MakeRoadNormal(), Vehicle::owner, ReverseDiagDir(), ROADTYPE_ROAD, ROADTYPE_TRAM, SetTileOwner(), TileOffsByDiagDir(), and TRANSPORT_RAIL.

Referenced by AfterLoadGame().

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

References DIR_NE, DIR_NW, DIR_SE, DIR_SW, INVALID_DIR, TILE_SIZE, TILE_UNIT_MASK, Vehicle::x_pos, and Vehicle::y_pos.

Referenced by AfterLoadGame().

static const GRFIdentifier* GetOverriddenIdentifier | ( | const GRFConfig * | c | ) | `[static]`

Try to find the overridden GRF identifier of the given GRF.

Parameters:

  | c | the GRF to get the 'previous' version of.

Returns:
  the GRF identifier or c if none could be found.

Definition at line 304 of file afterload.cpp.

References _gamelog_action, _gamelog_actions, LoggedAction::at, LoggedAction::change, LoggedAction::changes, GLAT_LOAD, GLCT_GRFCOMPAT, LoggedChange::grfcompat, GRFIdentifier::grfid, and GRFConfig::ident.

Referenced by 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 336 of file afterload.cpp.

References _grfconfig, BSWAP32(), GCF_COMPATIBLE, GCS_NOT_FOUND, GetOverriddenIdentifier(), HasBit(), lastof, GRFIdentifier::md5sum, md5sumToString(), GRFConfig::next, ResetSignalHandlers(), and seprintf().

Referenced by SetSignalHandlers().

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

References _cur_year, BuildOwnerLegend(), CheckTrainsLengths(), SmallFiosItem::filetype, FT_SCENARIO, CompanyProperties::inaugurated_year, MIN_YEAR, RebuildSubsidisedSourceAndDestinationCache(), Station::RecomputeIndustriesNearForAll(), RecomputePrices(), ResetWindowSystem(), SetupColoursAndInitialWindow(), ShowAIDebugWindowIfAIError(), ShowNewGRFError(), GroupStatistics::UpdateAfterLoad(), UpdateAirportsNoise(), and UpdateAllVirtCoords().

Referenced by AfterLoadGame().

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

References AfterLoadCompanyStats(), AfterLoadVehicles(), CheckTrainsLengths(), COMPANY_FIRST, DeleteInvalidEngineNews(), GfxLoadSprites(), InvalidateWindowClassesData(), InvalidateWindowData(), LoadStringWidthTable(), MarkWholeScreenDirty(), RecomputePrices(), StartupEngines(), GroupStatistics::UpdateAfterLoad(), UpdateHousesAndTowns(), WC_COMPANY_COLOUR, and WC_COMPANY_INFRASTRUCTURE.

Referenced by NewGRFConfirmationCallback(), and EngineOverrideManager::ResetToCurrentNewGRFConfig().

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

Referenced by HandleCrash().

void SetWaterClassDependingOnSurroundings | ( | TileIndex | 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 WATER_CLASS_INVALID, i.e. industry tiles on land

Definition at line 73 of file afterload.cpp.

References _m, DIAGDIR_BEGIN, GB(), GetTileSlope(), GetTileType(), GetWaterClass(), IsCoast(), IsLock(), MapMaxX(), MapMaxY(), MarkTileDirtyByTile(), MP_RAILWAY, MP_TREES, MP_WATER, SetWaterClass(), SlErrorCorrupt(), SLOPE_FLAT, TileAddByDiagDir(), TileX(), TileY(), WATER_CLASS_CANAL, WATER_CLASS_INVALID, WATER_CLASS_RIVER, and WATER_CLASS_SEA.

Referenced by AfterLoadGame().

## Variable Documentation

const byte 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 182 of file afterload.cpp.