OpenTTD
|
Chunks and fix-ups for TTO/TTD/TTDP savegames. More...
#include "../stdafx.h"
#include "../town.h"
#include "../industry.h"
#include "../company_func.h"
#include "../aircraft.h"
#include "../roadveh.h"
#include "../ship.h"
#include "../train.h"
#include "../signs_base.h"
#include "../station_base.h"
#include "../subsidy_base.h"
#include "../debug.h"
#include "../depot_base.h"
#include "../date_func.h"
#include "../vehicle_func.h"
#include "../effectvehicle_base.h"
#include "../engine_func.h"
#include "../company_base.h"
#include "../disaster_vehicle.h"
#include "saveload_internal.h"
#include "oldloader.h"
#include "table/strings.h"
#include "../table/engines.h"
#include "../table/townname.h"
#include "../safeguards.h"
Go to the source code of this file.
Macros | |
#define | FIXNUM(x, y, z) (((((x) << 16) / (y)) + 1) << z) |
Functions | |
void | FixOldMapArray () |
static void | FixTTDMapArray () |
static void | FixTTDDepots () |
static uint32 | RemapOldTownName (uint32 townnameparts, byte old_town_name_type) |
static void | FixOldTowns () |
void | FixOldVehicles () |
Convert the old style vehicles into something that resembles the old new style savegames. | |
static bool | FixTTOMapArray () |
static bool | FixTTOEngines () |
static void | FixTTOCompanies () |
static byte | RemapTTOColour (byte tto) |
static uint | RemapTownIndex (uint x) |
static uint | RemapOrderIndex (uint x) |
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 | LoadOldGood (LoadgameState *ls, int num) |
static bool | LoadOldStation (LoadgameState *ls, int num) |
static bool | LoadOldIndustry (LoadgameState *ls, int num) |
static bool | LoadOldCompanyYearly (LoadgameState *ls, int num) |
static bool | LoadOldCompanyEconomy (LoadgameState *ls, int num) |
static bool | LoadOldCompany (LoadgameState *ls, int num) |
static bool | LoadOldVehicleUnion (LoadgameState *ls, int num) |
bool | LoadOldVehicle (LoadgameState *ls, int num) |
Load the vehicles of an old style savegame. | |
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) |
bool | LoadTTDMain (LoadgameState *ls) |
bool | LoadTTOMain (LoadgameState *ls) |
Variables | |
static bool | _read_ttdpatch_flags |
Have we (tried to) read TTDPatch extra flags? | |
static uint16 | _old_extra_chunk_nums |
Number of extra TTDPatch chunks. | |
static byte | _old_vehicle_multiplier |
TTDPatch vehicle multiplier. | |
static uint8 * | _old_map3 |
static StringID * | _old_vehicle_names |
static Engine * | _old_engines |
TileIndex * | _animated_tile_list |
The table/list with animated tiles. | |
uint | _animated_tile_count |
The number of animated tiles in the current state. | |
char * | _old_name_array |
Location to load the old names to. | |
static uint32 | _old_town_index |
static uint16 | _old_string_id |
static uint16 | _old_string_id_2 |
static const OldChunks | town_chunk [] |
static uint16 | _old_order |
static const OldChunks | order_chunk [] |
static const OldChunks | depot_chunk [] |
static StationID | _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 CompanyID | _current_company_id |
static int32 | _old_yearly |
static const OldChunks | _company_yearly_chunk [] |
static const OldChunks | _company_economy_chunk [] |
static const OldChunks | _company_chunk [] |
static uint32 | _old_order_ptr |
static uint16 | _old_next_ptr |
static VehicleID | _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_effect_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 [] |
TileIndex | _cur_tileloop_tile |
uint16 | _disaster_delay |
Delay counter for considering the next disaster. | |
byte | _trees_tick_ctr |
Determines when to consider building more trees. | |
byte | _age_cargo_skip_counter |
Skip aging of cargo? Used before savegame version 162. | |
uint8 | _old_diff_level |
uint8 | _old_units |
static const OldChunks | main_chunk [] |
Chunks and fix-ups for TTO/TTD/TTDP savegames.
TTO loader code is based on SVXConverter by Roman Vetter.
Definition in file oldloader_sl.cpp.
void FixOldVehicles | ( | ) |
Convert the old style vehicles into something that resembles the old new style savegames.
Then AfterLoadGame can handle the rest of the conversion.
Definition at line 174 of file oldloader_sl.cpp.
References _m, ClrBit(), CopyFromOldName(), Vehicle::current_order, FOR_ALL_VEHICLES, SpecializedVehicle< RoadVehicle, Type >::From(), 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< Tpool >::index, IsCompanyBuildableVehicleType(), Vehicle::IsPrimaryVehicle(), IsTileType(), Order::IsType(), Tile::m5, Order::MakeDummy(), MP_STATION, BaseConsist::name, Vehicle::next, RVS_IN_DT_ROAD_STOP, RVSB_IN_DEPOT, RVSB_WORMHOLE, SetBit(), Vehicle::spritenum, RoadVehicle::state, Vehicle::subtype, Vehicle::tile, BaseVehicle::type, VEH_EFFECT, VEH_ROAD, and VEH_SHIP.
|
static |
Workaround for SVXConverter bug, depots 252-255 could be invalid
Definition at line 110 of file oldloader_sl.cpp.
References GetDepotIndex(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, and IsDepotTile().
|
static |
TTD->TTO remapping of engines; 255 means there is no equivalent. SVXConverter uses (almost) the same table.
TTO->TTD remapping of engines. SVXConverter uses the same table.
Definition at line 355 of file oldloader_sl.cpp.
References _date, EngineInfo::climates, Engine::company_avail, ConvertYMDToDate(), DAYS_TILL_ORIGINAL_BASE_YEAR, Engine::duration_phase_1, Engine::duration_phase_2, Engine::duration_phase_3, ENGINE_AVAILABLE, Vehicle::engine_type, Engine::flags, FOR_ALL_VEHICLES, HasBit(), Engine::intro_date, INVALID_COMPANY, lengthof, min(), Engine::name, Engine::preview_asked, Engine::preview_company, Engine::preview_wait, Engine::reliability, Engine::reliability_final, Engine::reliability_max, Engine::reliability_spd_dec, Engine::reliability_start, StartupOneEngine(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
bool LoadOldVehicle | ( | LoadgameState * | ls, |
int | num | ||
) |
Load the vehicles of an old style savegame.
So we can set the proper next pointer while loading.
ls | State (buffer) of the currently loaded game. |
num | The number of vehicles to load. |
Definition at line 1233 of file oldloader_sl.cpp.
References _old_vehicle_multiplier, VehicleCargoList::Append(), Order::AssignOrder(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_cargopacket_pool >::CanAllocateItem(), Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, Vehicle::cur_image, Vehicle::current_order, DEBUG, SpecializedVehicle< Train, Type >::From(), SpecializedStation< Station, false >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_order_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsInsideMM(), lengthof, LoadChunk(), max(), Vehicle::next, Vehicle::old, Vehicle::orders, ReadByte(), Vehicle::refit_cap, RemapOldStringID(), SGT_TTO, SlErrorCorrupt(), Vehicle::spritenum, BaseVehicle::type, UnpackOldOrder(), VEH_ROAD, VEH_SHIP, VEH_TRAIN, and BaseStation::xy.
|
inlinestatic |
Lossy remapping of TTO colours to TTD colours. SVXConverter uses the same conversion.
Definition at line 468 of file oldloader_sl.cpp.
References lengthof.
uint _animated_tile_count |
The number of animated tiles in the current state.
Definition at line 22 of file animated_tile.cpp.
Referenced by AddAnimatedTile(), AfterLoadGame(), AnimateAnimatedTiles(), DeleteAnimatedTile(), InitializeAnimatedTiles(), Load_ANIT(), and Save_ANIT().
TileIndex* _animated_tile_list |
The table/list with animated tiles.
Definition at line 20 of file animated_tile.cpp.
Referenced by AddAnimatedTile(), AfterLoadGame(), AnimateAnimatedTiles(), DeleteAnimatedTile(), InitializeAnimatedTiles(), Load_ANIT(), and Save_ANIT().
|
static |
Definition at line 892 of file oldloader_sl.cpp.
|
static |
Definition at line 870 of file oldloader_sl.cpp.
uint16 _disaster_delay |
Delay counter for considering the next disaster.
Definition at line 56 of file disaster_vehicle.cpp.
char* _old_name_array |
Location to load the old names to.
Definition at line 51 of file strings_sl.cpp.
Referenced by CopyFromOldName(), InitializeOldNames(), Load_NAME(), and ResetOldNames().
byte _trees_tick_ctr |
Determines when to consider building more trees.
Definition at line 53 of file tree_cmd.cpp.
|
static |
Definition at line 664 of file oldloader_sl.cpp.
|
static |
Definition at line 1395 of file oldloader_sl.cpp.
|
static |
Definition at line 1448 of file oldloader_sl.cpp.
|
static |
Definition at line 692 of file oldloader_sl.cpp.
|
static |
Definition at line 617 of file oldloader_sl.cpp.
|
static |
Definition at line 1365 of file oldloader_sl.cpp.
|
static |
|
static |
|
static |
Definition at line 1092 of file oldloader_sl.cpp.
|
static |
Definition at line 1083 of file oldloader_sl.cpp.
|
static |
Definition at line 1101 of file oldloader_sl.cpp.
|
static |
Definition at line 1050 of file oldloader_sl.cpp.
|
static |
Definition at line 1064 of file oldloader_sl.cpp.