afterload.cpp File Reference

Code updating data after game load. More...

#include "../stdafx.h"
#include "../void_map.h"
#include "../signs_base.h"
#include "../window_func.h"
#include "../fios.h"
#include "../train.h"
#include "../roadveh.h"
#include "../string_func.h"
#include "../gamelog.h"
#include "../network/network.h"
#include "../gfxinit.h"
#include "../functions.h"
#include "../industry_map.h"
#include "../town_map.h"
#include "../clear_map.h"
#include "../vehicle_func.h"
#include "../newgrf_station.h"
#include "../yapf/yapf.hpp"
#include "../elrail_func.h"
#include "../signs_func.h"
#include "../aircraft.h"
#include "../unmovable_map.h"
#include "../tree_map.h"
#include "../company_func.h"
#include "../road_cmd.h"
#include "../ai/ai.hpp"
#include "../animated_tile_func.h"
#include "../economy_base.h"
#include "table/strings.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)
 Create a new company and sets all company variables default values.
void InitializeRailGUI ()
 Resets the rail GUI - sets default railtype to build and resets the signal GUI.
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)
static bool 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 void FixOwnerOfRailTrack (TileIndex t)
 Tries to change owner of this rail tile to a valid owner.
bool AfterLoadGame ()
void ReloadNewGRFData ()
 Reload all NewGRF files during a running game.

Variables

StringID _switch_mode_errorstr
static const byte convert_currency []
static SignalHandlerPointer _prev_segfault = NULL
static SignalHandlerPointer _prev_abort = NULL
static SignalHandlerPointer _prev_fpe = NULL


Detailed Description

Code updating data after game load.

Definition in file afterload.cpp.


Function Documentation

Company* DoStartupNewCompany ( bool  is_ai  ) 

Create a new company and sets all company variables default values.

Parameters:
is_ai is a ai company?
Returns:
the company struct

Definition at line 425 of file company_cmd.cpp.

References _company_colours, _cur_year, GetCompanyRailtypes(), GetCompanyRoadtypes(), INVALID_OWNER, InvalidateWindow(), MAX_COMPANIES, RandomCompanyManagerFaceBits(), and ResetCompanyLivery().

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

References CLEAR_GRASS, DIAGDIR_BEGIN, DIAGDIR_END, GetTileOwner(), GetTileTrackStatus(), GetTownIndex(), IsPlainRailTile(), MakeClear(), ReverseDiagDir(), ROADTYPE_ROAD, ROADTYPE_TRAM, SetTileOwner(), TileOffsByDiagDir(), and TRANSPORT_RAIL.

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

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

Referenced by SetSignalHandlers().

static bool 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.

Returns:
true if everything went according to plan, otherwise false.

Definition at line 205 of file afterload.cpp.

References _cur_year, CheckTrainsLengths(), FT_SCENARIO, ResetWindowSystem(), SetCachedEngineCounts(), UpdateAirportsNoise(), UpdateAllSignVirtCoords(), UpdateAllStationVirtCoord(), UpdateAllTownVirtCoords(), and UpdateAllWaypointSigns().

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

References AfterLoadVehicles(), AfterLoadWaypoints(), CheckTrainsLengths(), COMPANY_FIRST, InvalidateWindowData(), LoadStringWidthTable(), MarkWholeScreenDirty(), MAX_COMPANIES, SetCachedEngineCounts(), and UpdateHousesAndTowns().

Referenced by ChangeDynamicEngines(), ClickChangeClimateCheat(), NewGRFConfirmationCallback(), and NewGRFWindow::OnClick().

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.
o the owner of the new tile.
include_invalid_water_class Also consider WATER_CLASS_INVALID, i.e. industry tiles on land

Definition at line 55 of file afterload.cpp.

References DIAGDIR_BEGIN, DIAGDIR_END, GetTileSlope(), GetTileType(), GetTreeGround(), MapMaxX(), MapMaxY(), MarkTileDirtyByTile(), MP_RAILWAY, MP_TREES, MP_WATER, RAIL_GROUND_WATER, SLOPE_FLAT, TileAddByDiagDir(), TileX(), TileY(), TREE_GROUND_SHORE, and WATER_CLASS_INVALID.


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


Generated on Wed Jul 15 20:36:10 2009 for OpenTTD by  doxygen 1.5.6