OpenTTD
Typedefs | Functions | Variables
afterload.cpp File Reference

Code updating data after game load. More...

#include "../stdafx.h"
#include "../void_map.h"
#include "../signs_base.h"
#include "../depot_base.h"
#include "../fios.h"
#include "../gamelog_internal.h"
#include "../network/network.h"
#include "../network/network_func.h"
#include "../gfxinit.h"
#include "../viewport_func.h"
#include "../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 "../order_backup.h"
#include "../error.h"
#include "../disaster_vehicle.h"
#include "saveload_internal.h"
#include <signal.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=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 GRFIdentifierGetOverriddenIdentifier (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.
static bool MayHaveBridgeAbove (TileIndex 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.
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 526 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, Industry::accepts_cargo, IndustrySpec::accepts_cargo, AddInflation(), CargoPacket::AfterLoad(), AfterLoadCompanyStats(), AfterLoadLinkGraphs(), AfterLoadRoadStops(), AfterLoadStoryBook(), AfterLoadVehicles(), AIR_AIRCRAFT, AircraftNextAirportPos_and_Order(), Station::airport, EconomySettings::allow_town_level_crossings, EconomySettings::allow_town_roads, SmallVector< T, S >::Append(), AT_OILRIG, CompanyProperties::avail_railtypes, Company::avail_roadtypes, StationCargoList::AvailableCount(), Subsidy::awarded, AXIS_X, AXIS_Y, AxisToDirection(), CompanyProperties::bankrupt_asked, SmallVector< T, S >::Begin(), 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<&_roadstop_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<&_cargo_payment_pool >::CanAllocateItem(), GoodsEntry::cargo, Vehicle::cargo_payment, Subsidy::cargo_type, CCF_TRACK, CeilDiv(), ChangeTileOwner(), Clamp(), SmallVector< T, S >::Clear(), 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(), 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, DAYS_TILL_ORIGINAL_BASE_YEAR, DEBUG, DeleteAnimatedTile(), Vehicle::dest_tile, DIAGDIR_END, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, DiagDirToAxis(), DiagDirToDiagTrackBits(), DiagDirToDiagTrackdir(), DiagDirToDir(), GameSettings::difficulty, Vehicle::direction, DirToDiagDir(), VehicleSettings::disable_elrails, LinkGraphSettings::distribution_armoured, LinkGraphSettings::distribution_default, LinkGraphSettings::distribution_mail, LinkGraphSettings::distribution_pax, Station::dock_tile, DoStartupNewCompany(), Subsidy::dst, Subsidy::dst_type, DT_MANUAL, VehicleSettings::dynamic_engines, GameSettings::economy, EF_ROAD_TRAM, SmallVector< T, S >::End(), 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, EconomySettings::feeder_payment_share, FindFirstCargoWithTownEffect(), SpecializedVehicle< T, Type >::First(), Vehicle::FirstShared(), FixOwnerOfRailTrack(), FixupTrainLengths(), FixVehicleInclination(), FLYING, FOR_ALL_AIRCRAFT, FOR_ALL_CARGO_PAYMENTS, FOR_ALL_DISASTERVEHICLES, FOR_ALL_ORDER_BACKUPS, FOR_ALL_VEHICLES, FOR_ALL_WAYPOINTS, PathfinderSettings::forbid_90_deg, Industry::founder, OrderList::FreeChain(), ConstructionSettings::freeform_edges, SpecializedStation< Station, false >::From(), SpecializedVehicle< Train, Type >::From(), SpecializedVehicle< RoadVehicle, Type >::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_RATING, CargoSpec::Get(), SpecializedStation< Station, false >::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<&_town_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetAircraftFlightLevelBounds(), BaseStation::GetByTile(), SpecializedStation< Station, false >::GetByTile(), SpecializedStation< Waypoint, true >::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<&_company_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_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(), GetOtherShipDepotTile(), GetOtherTunnelBridgeEnd(), GetRailType(), GetRawClearGround(), GetRoadOwner(), GetRoadTileType(), Airport::GetSpec(), GetStationGfx(), GetStationType(), GetTargetAirportIfValid(), GetTileOwner(), 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, BasePersistentStorageArray::grfid, GroundVehicle< T, Type >::gv_flags, GVF_GOINGDOWN_BIT, GVF_GOINGUP_BIT, OrthogonalTileArea::h, HasBit(), HasSignals(), HasStationRail(), HasStationTileRail(), HasTownOwnedRoad(), Town::have_ratings, Tile::height, 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_DIR, 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(), IsStationTileBlocked(), IsTileFlat(), IsTileOwner(), IsTileType(), IsTruckStop(), IsTunnelTile(), Order::IsType(), 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(), 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, GameSettings::linkgraph, Vehicle::list, Vehicle::load_unload_ticks, LoadStringWidthTable(), GameSettings::locale, 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(), ConstructionSettings::max_bridge_length, MAX_COMPANIES, ConstructionSettings::max_heightlevel, 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, 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, CompanyProperties::name, BaseStation::name, Town::name, CompanyProperties::name_1, NEW_HOUSE_OFFSET, PathfinderSettings::new_pathfinding_all, GRFConfig::next, SpecializedVehicle< T, Type >::Next(), NUM_CARGO, 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_crashes, VehicleSettings::plane_speed, PM_PAUSED_ERROR, PM_PAUSED_NORMAL, PM_UNPAUSED, PMB_PAUSED_NETWORK, CompanyProperties::president_name, CompanyProperties::president_name_1, Industry::produced_cargo, Vehicle::profit_last_year, Vehicle::profit_this_year, Industry::psa, Airport::psa, YAPFSettings::rail_use_yapf, RAILTYPE_ELECTRIC, RAILTYPE_RAIL, 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_END, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_ROAD, VehicleSettings::roadveh_acceleration_model, VehicleSettings::roadveh_slope_steepness, 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(), SetFence(), 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(), GameCreationSettings::snow_line_height, SP_END, SP_MEDIUM, Subsidy::src, Subsidy::src_type, ST_INDUSTRY, ST_TOWN, AI::StartNew(), StartupEngines(), Aircraft::state, RoadVehicle::state, GameSettings::station, EconomySettings::station_noise_level, GoodsEntry::status, 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, TFP_STUCK, OrthogonalTileArea::tile, Vehicle::tile, TILE_ADDXY, TILE_HEIGHT, TILE_SIZE, TILE_UNIT_MASK, TileHash(), TileHeight(), TileVirtXY(), TileX(), TileXY(), TileY(), TL_BETTER_ROADS, TL_RANDOM, Object::town, BaseStation::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_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_SNOW_DESERT, CompanyProperties::tree_limit, TROPICZONE_NORMAL, Station::truck_stops, Aircraft::turn_counter, Object::type, BaseVehicle::type, Industry::type, Airport::type, LocaleSettings::units_force, LocaleSettings::units_height, LocaleSettings::units_power, LocaleSettings::units_velocity, LocaleSettings::units_volume, LocaleSettings::units_weight, UpdateAircraftCache(), UpdateHousesAndTowns(), UpdateLevelCrossing(), UpdateNearestTownForRoadTiles(), UpdateOldAircraft(), Vehicle::UpdateRealOrderIndex(), UpdateStationAcceptance(), UpdateTownCargoes(), VEH_INVALID, VEH_ROAD, VEH_SHIP, VEH_TRAIN, CompanySettings::vehicle, GameSettings::vehicle, BaseConsist::vehicle_flags, Vehicle::vehstatus, VF_LOADING_FINISHED, VF_PATHFINDER_LOST, VPF_NPF, VPF_OPF, VPF_YAPF, VS_CRASHED, VS_HIDDEN, VS_STOPPED, OrthogonalTileArea::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, BaseStation::xy, Town::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 
)
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
ttile to update

Definition at line 432 of file afterload.cpp.

References CLEAR_GRASS, DIAGDIR_BEGIN, DIAGDIR_END, 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
vvehicle
dirvehicle's direction, or # INVALID_DIR if it can be ignored
Returns
inclination bits to set

Definition at line 479 of file afterload.cpp.

References DIR_NE, DIR_NW, DIR_SE, DIR_SW, GVF_GOINGDOWN_BIT, GVF_GOINGUP_BIT, 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
cthe GRF to get the 'previous' version of.
Returns
the GRF identifier or c if none could be found.

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

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

References _cur_year, Station::airport, BuildOwnerLegend(), CheckTrainsLengths(), BasePersistentStorageArray::feature, SmallFiosItem::filetype, FT_SCENARIO, GSF_FAKE_TOWNS, CompanyProperties::inaugurated_year, Object::IncTypeCount(), Industry::location, MIN_YEAR, Industry::psa, Airport::psa, RebuildSubsidisedSourceAndDestinationCache(), Station::RecomputeIndustriesNearForAll(), RecomputePrices(), ResetWindowSystem(), SetupColoursAndInitialWindow(), ShowAIDebugWindowIfAIError(), ShowNewGRFError(), OrthogonalTileArea::tile, BasePersistentStorageArray::tile, Object::type, GroupStatistics::UpdateAfterLoad(), UpdateAirportsNoise(), UpdateAllVirtCoords(), and Town::xy.

Referenced by AfterLoadGame().

static bool MayHaveBridgeAbove ( TileIndex  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 515 of file afterload.cpp.

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

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

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

Referenced by ClickChangeMaxHlCheat(), NewGRFConfirmationCallback(), NewGRFWindow::OnClick(), 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 359 of file afterload.cpp.

References _saveload_crash_with_missing_newgrfs.

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
tthe tile to change.
include_invalid_water_classAlso consider WATER_CLASS_INVALID, i.e. industry tiles on land

Definition at line 78 of file afterload.cpp.

References _m, DIAGDIR_BEGIN, DIAGDIR_END, GB(), GetTileType(), GetWaterClass(), IsCoast(), IsLock(), IsTileFlat(), MapMaxX(), MapMaxY(), MarkTileDirtyByTile(), 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().

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