#include "stdafx.h"
#include "openttd.h"
#include "station_map.h"
#include "town.h"
#include "industry.h"
#include "station.h"
#include "player_func.h"
#include "player_base.h"
#include "engine.h"
#include "aircraft.h"
#include "roadveh.h"
#include "ship.h"
#include "train.h"
#include "signs.h"
#include "debug.h"
#include "depot.h"
#include "newgrf_config.h"
#include "ai/ai.h"
#include "ai/default/default.h"
#include "zoom_func.h"
#include "functions.h"
#include "date_func.h"
#include "vehicle_func.h"
#include "variables.h"
#include "table/strings.h"
Go to the source code of this file.
Data Structures | |
struct | LoadgameState |
struct | OldChunks |
Defines | |
#define | OCL_SVAR(type, base, offset) { type, 1, NULL, (uint)cpp_offsetof(base, offset), NULL } |
#define | OCL_VAR(type, amount, pointer) { type, amount, pointer, 0, NULL } |
#define | OCL_END() { OC_END, 0, NULL, 0, NULL } |
#define | OCL_NULL(amount) { OC_NULL, amount, NULL, 0, NULL } |
#define | OCL_CHUNK(amount, proc) { OC_CHUNK, amount, NULL, 0, proc } |
#define | OCL_ASSERT(size) { OC_ASSERT, 1, NULL, size, NULL } |
#define | REMAP_TOWN_IDX(x) ((x) - (0x0459154 - 0x0458EF0)) / 94 |
#define | REMAP_ORDER_IDX(x) ((x) - (0x045AB08 - 0x0458EF0)) / 2 |
Typedefs | |
typedef bool | OldChunkProc (LoadgameState *ls, int num) |
Enumerations | |
enum | { HEADER_SIZE = 49, BUFFER_SIZE = 4096, OLD_MAP_SIZE = 256 * 256 } |
enum | OldChunkType { OC_SIMPLE = 0, OC_NULL = 1, OC_CHUNK = 2, OC_ASSERT = 3, OC_VAR_I8 = 1 << 8, OC_VAR_U8 = 2 << 8, OC_VAR_I16 = 3 << 8, OC_VAR_U16 = 4 << 8, OC_VAR_I32 = 5 << 8, OC_VAR_U32 = 6 << 8, OC_VAR_I64 = 7 << 8, OC_FILE_I8 = 1 << 16, OC_FILE_U8 = 2 << 16, OC_FILE_I16 = 3 << 16, OC_FILE_U16 = 4 << 16, OC_FILE_I32 = 5 << 16, OC_FILE_U32 = 6 << 16, OC_INT8 = OC_VAR_I8 | OC_FILE_I8, OC_UINT8 = OC_VAR_U8 | OC_FILE_U8, OC_INT16 = OC_VAR_I16 | OC_FILE_I16, OC_UINT16 = OC_VAR_U16 | OC_FILE_U16, OC_INT32 = OC_VAR_I32 | OC_FILE_I32, OC_UINT32 = OC_VAR_U32 | OC_FILE_U32, OC_TILE = OC_VAR_U32 | OC_FILE_U16, OC_END = 0 } |
Functions | |
DECLARE_ENUM_AS_BIT_SET (OldChunkType) | |
assert_compile (sizeof(TileIndex)==4) | |
static OldChunkType | GetOldChunkType (OldChunkType type) |
static OldChunkType | GetOldChunkVarType (OldChunkType type) |
static OldChunkType | GetOldChunkFileType (OldChunkType type) |
static byte | CalcOldVarLen (OldChunkType type) |
static byte | ReadByteFromFile (LoadgameState *ls) |
Reads a byte from a file (do not call yourself, use ReadByte()). | |
static byte | ReadByte (LoadgameState *ls) |
Reads a byte from the buffer and decompress if needed. | |
static uint16 | ReadUint16 (LoadgameState *ls) |
static uint32 | ReadUint32 (LoadgameState *ls) |
static bool | LoadChunk (LoadgameState *ls, void *base, const OldChunks *chunks) |
Loads a chunk from the old savegame. | |
static void | InitLoading (LoadgameState *ls) |
Initialize some data before reading. | |
uint32 | GetOldTownName (uint32 townnameparts, byte old_town_name_type) |
static void | FixOldTowns () |
static void | FixOldStations () |
static void | FixOldVehicles () |
static void | ReadTTDPatchFlags () |
static bool | LoadOldTown (LoadgameState *ls, int num) |
static bool | LoadOldOrder (LoadgameState *ls, int num) |
static bool | LoadOldAnimTileList (LoadgameState *ls, int num) |
static bool | LoadOldDepot (LoadgameState *ls, int num) |
static bool | LoadOldPrice (LoadgameState *ls, int num) |
static bool | LoadOldCargoPaymentRate (LoadgameState *ls, int num) |
static bool | LoadOldGood (LoadgameState *ls, int num) |
static bool | LoadOldStation (LoadgameState *ls, int num) |
static bool | LoadOldIndustry (LoadgameState *ls, int num) |
static bool | OldPlayerYearly (LoadgameState *ls, int num) |
static bool | OldPlayerEconomy (LoadgameState *ls, int num) |
static bool | OldLoadAIBuildRec (LoadgameState *ls, int num) |
static bool | OldPlayerAI (LoadgameState *ls, int num) |
static bool | LoadOldPlayer (LoadgameState *ls, int num) |
static bool | LoadOldVehicleUnion (LoadgameState *ls, int num) |
bool | LoadOldVehicle (LoadgameState *ls, int num) |
static bool | LoadOldSign (LoadgameState *ls, int num) |
static bool | LoadOldEngine (LoadgameState *ls, int num) |
static bool | LoadOldEngineName (LoadgameState *ls, int num) |
static bool | LoadOldSubsidy (LoadgameState *ls, int num) |
static bool | LoadOldGameDifficulty (LoadgameState *ls, int num) |
static bool | LoadOldMapPart1 (LoadgameState *ls, int num) |
static bool | LoadOldMapPart2 (LoadgameState *ls, int num) |
static bool | LoadTTDPatchExtraChunks (LoadgameState *ls, int num) |
static bool | LoadOldMain (LoadgameState *ls) |
bool | LoadOldSaveGame (const char *file) |
void | GetOldSaveGameName (char *title, const char *path, const char *file) |
Variables | |
static uint32 | _bump_assert_value |
static bool | _read_ttdpatch_flags |
static StringID * | _old_vehicle_names = NULL |
TileIndex * | _animated_tile_list |
The table/list with animated tiles. | |
uint | _animated_tile_count |
The number of animated tiles in the current state. | |
char | _name_array [512][32] |
static byte | _old_vehicle_multiplier |
static uint8 | _old_map3 [OLD_MAP_SIZE *2] |
static bool | _new_ttdpatch_format |
static uint32 | _old_town_index |
static uint16 | _old_string_id |
static uint16 | _old_string_id_2 |
static uint16 | _old_extra_chunk_nums |
static const OldChunks | town_chunk [] |
static uint16 | _old_order |
static const OldChunks | order_chunk [] |
static const OldChunks | depot_chunk [] |
static int32 | _old_price |
static uint16 | _old_price_frac |
static const OldChunks | price_chunk [] |
static const OldChunks | cargo_payment_rate_chunk [] |
static uint8 | _old_platforms |
static uint | _current_station_id |
static uint16 | _waiting_acceptance |
static uint8 | _cargo_source |
static uint8 | _cargo_days |
static const OldChunks | goods_chunk [] |
static const OldChunks | station_chunk [] |
static const OldChunks | industry_chunk [] |
static PlayerID | _current_player_id |
static int32 | _old_yearly |
static const OldChunks | player_yearly_chunk [] |
static const OldChunks | player_economy_chunk [] |
static const OldChunks | player_ai_build_rec_chunk [] |
static const OldChunks | player_ai_chunk [] |
uint8 | ai_tick |
static const OldChunks | player_chunk [] |
static uint32 | _old_order_ptr |
static uint16 | _old_next_ptr |
static uint32 | _current_vehicle_id |
static const OldChunks | vehicle_train_chunk [] |
static const OldChunks | vehicle_road_chunk [] |
static const OldChunks | vehicle_ship_chunk [] |
static const OldChunks | vehicle_air_chunk [] |
static const OldChunks | vehicle_special_chunk [] |
static const OldChunks | vehicle_disaster_chunk [] |
static const OldChunks | vehicle_empty_chunk [] |
static uint16 | _cargo_count |
static const OldChunks | vehicle_chunk [] |
static const OldChunks | sign_chunk [] |
static const OldChunks | engine_chunk [] |
static const OldChunks | subsidy_chunk [] |
static const OldChunks | game_difficulty_chunk [] |
static uint32 | _old_cur_town_ctr |
static const OldChunks | main_chunk [] |
Definition in file oldloader.cpp.
enum OldChunkType |
Definition at line 56 of file oldloader.cpp.
static void InitLoading | ( | LoadgameState * | ls | ) | [static] |
static bool LoadChunk | ( | LoadgameState * | ls, | |
void * | base, | |||
const OldChunks * | chunks | |||
) | [static] |
Loads a chunk from the old savegame.
Definition at line 200 of file oldloader.cpp.
References GB(), OC_END, and ReadByte().
static byte ReadByte | ( | LoadgameState * | ls | ) | [static] |
Reads a byte from the buffer and decompress if needed.
Definition at line 154 of file oldloader.cpp.
References ReadByteFromFile().
Referenced by BmpRead1(), BmpRead24(), BmpRead4(), BmpRead4Rle(), BmpRead8(), BmpRead8Rle(), and LoadChunk().
static byte ReadByteFromFile | ( | LoadgameState * | ls | ) | [static] |
Reads a byte from a file (do not call yourself, use ReadByte()).
Definition at line 128 of file oldloader.cpp.
Referenced by ReadByte().
uint _animated_tile_count |
const OldChunks cargo_payment_rate_chunk[] [static] |
Initial value:
{ OCL_VAR ( OC_INT32, 1, &_old_price ), OCL_VAR ( OC_UINT16, 1, &_old_price_frac ), OCL_NULL( 2 ), }
Definition at line 586 of file oldloader.cpp.
const OldChunks depot_chunk[] [static] |
Initial value:
{ OCL_SVAR( OC_TILE, Depot, xy ), OCL_VAR ( OC_UINT32, 1, &_old_town_index ), }
Definition at line 549 of file oldloader.cpp.
const OldChunks engine_chunk[] [static] |
Initial value:
{ OCL_SVAR( OC_UINT16, Engine, player_avail ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U32, Engine, intro_date ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U32, Engine, age ), OCL_SVAR( OC_UINT16, Engine, reliability ), OCL_SVAR( OC_UINT16, Engine, reliability_spd_dec ), OCL_SVAR( OC_UINT16, Engine, reliability_start ), OCL_SVAR( OC_UINT16, Engine, reliability_max ), OCL_SVAR( OC_UINT16, Engine, reliability_final ), OCL_SVAR( OC_UINT16, Engine, duration_phase_1 ), OCL_SVAR( OC_UINT16, Engine, duration_phase_2 ), OCL_SVAR( OC_UINT16, Engine, duration_phase_3 ), OCL_SVAR( OC_UINT8, Engine, lifelength ), OCL_SVAR( OC_UINT8, Engine, flags ), OCL_SVAR( OC_UINT8, Engine, preview_player_rank ), OCL_SVAR( OC_UINT8, Engine, preview_wait ), OCL_NULL( 2 ), }
Definition at line 1312 of file oldloader.cpp.
const OldChunks game_difficulty_chunk[] [static] |
Initial value:
{ OCL_SVAR( OC_UINT16, GameDifficulty, max_no_competitors ), OCL_SVAR( OC_UINT16, GameDifficulty, competitor_start_time ), OCL_SVAR( OC_UINT16, GameDifficulty, number_towns ), OCL_SVAR( OC_UINT16, GameDifficulty, number_industries ), OCL_SVAR( OC_UINT16, GameDifficulty, max_loan ), OCL_SVAR( OC_UINT16, GameDifficulty, initial_interest ), OCL_SVAR( OC_UINT16, GameDifficulty, vehicle_costs ), OCL_SVAR( OC_UINT16, GameDifficulty, competitor_speed ), OCL_SVAR( OC_UINT16, GameDifficulty, competitor_intelligence ), OCL_SVAR( OC_UINT16, GameDifficulty, vehicle_breakdowns ), OCL_SVAR( OC_UINT16, GameDifficulty, subsidy_multiplier ), OCL_SVAR( OC_UINT16, GameDifficulty, construction_cost ), OCL_SVAR( OC_UINT16, GameDifficulty, terrain_type ), OCL_SVAR( OC_UINT16, GameDifficulty, quantity_sea_lakes ), OCL_SVAR( OC_UINT16, GameDifficulty, economy ), OCL_SVAR( OC_UINT16, GameDifficulty, line_reverse_mode ), OCL_SVAR( OC_UINT16, GameDifficulty, disasters ), }
Definition at line 1367 of file oldloader.cpp.
const OldChunks goods_chunk[] [static] |
Initial value:
{ OCL_VAR ( OC_UINT16, 1, &_waiting_acceptance ), OCL_SVAR( OC_UINT8, GoodsEntry, days_since_pickup ), OCL_SVAR( OC_UINT8, GoodsEntry, rating ), OCL_VAR ( OC_UINT8, 1, &_cargo_source ), OCL_VAR ( OC_UINT8, 1, &_cargo_days ), OCL_SVAR( OC_UINT8, GoodsEntry, last_speed ), OCL_SVAR( OC_UINT8, GoodsEntry, last_age ), }
Definition at line 610 of file oldloader.cpp.
const OldChunks order_chunk[] [static] |
Initial value:
{ OCL_VAR ( OC_UINT16, 1, &_old_order ), }
Definition at line 506 of file oldloader.cpp.
const OldChunks player_ai_build_rec_chunk[] [static] |
Initial value:
{ OCL_SVAR( OC_TILE, AiBuildRec, spec_tile ), OCL_SVAR( OC_TILE, AiBuildRec, use_tile ), OCL_SVAR( OC_UINT8, AiBuildRec, rand_rng ), OCL_SVAR( OC_UINT8, AiBuildRec, cur_building_rule ), OCL_SVAR( OC_UINT8, AiBuildRec, unk6 ), OCL_SVAR( OC_UINT8, AiBuildRec, unk7 ), OCL_SVAR( OC_UINT8, AiBuildRec, buildcmd_a ), OCL_SVAR( OC_UINT8, AiBuildRec, buildcmd_b ), OCL_SVAR( OC_UINT8, AiBuildRec, direction ), OCL_SVAR( OC_UINT8, AiBuildRec, cargo ), OCL_NULL( 8 ), }
Definition at line 813 of file oldloader.cpp.
const OldChunks player_economy_chunk[] [static] |
Initial value:
{ OCL_SVAR( OC_FILE_I32 | OC_VAR_I64, PlayerEconomyEntry, income ), OCL_SVAR( OC_FILE_I32 | OC_VAR_I64, PlayerEconomyEntry, expenses ), OCL_SVAR( OC_INT32, PlayerEconomyEntry, delivered_cargo ), OCL_SVAR( OC_INT32, PlayerEconomyEntry, performance_history ), OCL_SVAR( OC_FILE_I32 | OC_VAR_I64, PlayerEconomyEntry, company_value ), }
Definition at line 782 of file oldloader.cpp.
const OldChunks player_yearly_chunk[] [static] |
Initial value:
{ OCL_VAR( OC_INT32, 1, &_old_yearly ), }
Definition at line 763 of file oldloader.cpp.
const OldChunks price_chunk[] [static] |
Initial value:
{ OCL_VAR ( OC_INT32, 1, &_old_price ), OCL_VAR ( OC_UINT16, 1, &_old_price_frac ), }
Definition at line 568 of file oldloader.cpp.
const OldChunks sign_chunk[] [static] |
Initial value:
{ OCL_VAR ( OC_UINT16, 1, &_old_string_id ), OCL_SVAR( OC_FILE_U16 | OC_VAR_I32, Sign, x ), OCL_SVAR( OC_FILE_U16 | OC_VAR_I32, Sign, y ), OCL_SVAR( OC_FILE_U16 | OC_VAR_I8, Sign, z ), OCL_NULL( 6 ), }
Definition at line 1290 of file oldloader.cpp.
const OldChunks subsidy_chunk[] [static] |
Initial value:
{ OCL_SVAR( OC_UINT8, Subsidy, cargo_type ), OCL_SVAR( OC_UINT8, Subsidy, age ), OCL_SVAR( OC_FILE_U8 | OC_VAR_U16, Subsidy, from ), OCL_SVAR( OC_FILE_U8 | OC_VAR_U16, Subsidy, to ), }
Definition at line 1353 of file oldloader.cpp.
const OldChunks vehicle_air_chunk[] [static] |
Initial value:
{ OCL_SVAR( OC_UINT8, VehicleAir, pos ), OCL_SVAR( OC_FILE_U8 | OC_VAR_U16, VehicleAir, targetairport ), OCL_SVAR( OC_UINT16, VehicleAir, crashed_counter ), OCL_SVAR( OC_UINT8, VehicleAir, state ), OCL_NULL( 5 ), }
Definition at line 1083 of file oldloader.cpp.
const OldChunks vehicle_disaster_chunk[] [static] |
Initial value:
{ OCL_SVAR( OC_UINT16, VehicleDisaster, image_override ), OCL_SVAR( OC_UINT16, VehicleDisaster, big_ufo_destroyer_target ), OCL_NULL( 6 ), }
Definition at line 1103 of file oldloader.cpp.
const OldChunks vehicle_empty_chunk[] [static] |
const OldChunks vehicle_road_chunk[] [static] |
Initial value:
{ OCL_SVAR( OC_UINT8, VehicleRoad, state ), OCL_SVAR( OC_UINT8, VehicleRoad, frame ), OCL_SVAR( OC_UINT16, VehicleRoad, blocked_ctr ), OCL_SVAR( OC_UINT8, VehicleRoad, overtaking ), OCL_SVAR( OC_UINT8, VehicleRoad, overtaking_ctr ), OCL_SVAR( OC_UINT16, VehicleRoad, crashed_ctr ), OCL_SVAR( OC_UINT8, VehicleRoad, reverse_ctr ), OCL_NULL( 1 ), }
Definition at line 1061 of file oldloader.cpp.
const OldChunks vehicle_ship_chunk[] [static] |
Initial value:
{ OCL_SVAR( OC_UINT8, VehicleShip, state ), OCL_NULL( 9 ), }
Definition at line 1075 of file oldloader.cpp.
const OldChunks vehicle_special_chunk[] [static] |
Initial value:
{ OCL_SVAR( OC_UINT16, VehicleSpecial, animation_state ), OCL_SVAR( OC_UINT8, VehicleSpecial, animation_substate ), OCL_NULL( 7 ), }
Definition at line 1094 of file oldloader.cpp.
const OldChunks vehicle_train_chunk[] [static] |
Initial value:
{ OCL_SVAR( OC_UINT8, VehicleRail, track ), OCL_SVAR( OC_UINT8, VehicleRail, force_proceed ), OCL_SVAR( OC_UINT16, VehicleRail, crash_anim_pos ), OCL_SVAR( OC_UINT8, VehicleRail, railtype ), OCL_NULL( 5 ), }
Definition at line 1050 of file oldloader.cpp.