mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-22 18:49:40 +00:00
0833396cdf
* Codechange: rename SLV_115 to SLV_CUSTOM_TOWN_NUMBER * Codechange: rename SLV_116 to SLV_GAMELOG_EMERGENCY * Codechange: rename SLV_117 to SLV_PLATFORM_STOP_LOCATION * Codechange: rename SLV_118 to SLV_DIGIT_GROUP_SEPARATOR * Codechange: rename SLV_119 to SLV_PAUSE_MODES * Codechange: rename SLV_120 to SLV_COMPANY_SERVICE_INTERVALS * Codechange: rename SLV_121 to SLV_CARGO_PAYMENTS * Codechange: rename SLV_122 to SLV_WAYPOINT_MORE_LIKE_STATION * Codechange: rename SLV_123 to SLV_UNIFY_WAYPOINT_AND_STATION * Codechange: rename SLV_124 to SLV_MULTI_TILE_WAYPOINTS * Codechange: rename SLV_125 to SLV_REMOVE_SUBSIDY_STATION_BINDING * Codechange: rename SLV_126 to SLV_CUMULATED_INFLATION * Codechange: rename SLV_127 to SLV_TOWN_ACCEPTANCE * Codechange: rename SLV_128 to SLV_FOUND_TOWN * Codechange: rename SLV_129 to SLV_TIMETABLE_START * Codechange: rename SLV_130 to SLV_ROAD_STOP_OCCUPANCY_PENALTY * Codechange: rename SLV_131 to SLV_MAXIMUM_DEPOT_PENALTY * Codechange: rename SLV_132 to SLV_DISALLOW_TREE_BUILDING * Codechange: rename SLV_133 to SLV_TRAIN_SLOPE_STEEPNESS * Codechange: rename SLV_134 to SLV_VIRTUAL_FEEDER_SHARE_PAYMENT * Codechange: rename SLV_135 to SLV_ROCKS_STAY_UNDER_SNOW * Codechange: rename SLV_136 to SLV_SPLIT_LOAD_WAIT_COUNTERS * Codechange: rename SLV_137 to SLV_AIRPORT_ANIMATION_FRAMES * Codechange: rename SLV_138 to SLV_REDUCE_PLANE_CRASHES * Codechange: rename SLV_139 to SLV_RV_REALISTIC_ACCELERATION * Codechange: rename SLV_140 to SLV_STORE_AIRPORT_SIZE * Codechange: rename SLV_141 to SLV_UNIQUE_DEPOT_NAMES * Codechange: rename SLV_142 to SLV_NEWGRF_DEPOT_BUILD_DATE * Codechange: rename SLV_143 to SLV_DISABLE_TOWN_LEVEL_CROSSING * Codechange: rename SLV_144 to SLV_REORDER_UNMOVABLE_REMOVE_RESERVED
75 lines
2.7 KiB
C++
75 lines
2.7 KiB
C++
/*
|
|
* This file is part of OpenTTD.
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
|
|
*/
|
|
|
|
/** @file depot_sl.cpp Code handling saving and loading of depots. */
|
|
|
|
#include "../stdafx.h"
|
|
|
|
#include "saveload.h"
|
|
#include "compat/depot_sl_compat.h"
|
|
|
|
#include "../depot_base.h"
|
|
#include "../town.h"
|
|
|
|
#include "../safeguards.h"
|
|
|
|
static TownID _town_index;
|
|
|
|
static const SaveLoad _depot_desc[] = {
|
|
SLE_CONDVAR(Depot, xy, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_MULTIPLE_ROAD_STOPS),
|
|
SLE_CONDVAR(Depot, xy, SLE_UINT32, SLV_MULTIPLE_ROAD_STOPS, SL_MAX_VERSION),
|
|
SLEG_CONDVAR("town_index", _town_index, SLE_UINT16, SL_MIN_VERSION, SLV_UNIQUE_DEPOT_NAMES),
|
|
SLE_CONDREF(Depot, town, REF_TOWN, SLV_UNIQUE_DEPOT_NAMES, SL_MAX_VERSION),
|
|
SLE_CONDVAR(Depot, town_cn, SLE_UINT16, SLV_UNIQUE_DEPOT_NAMES, SL_MAX_VERSION),
|
|
SLE_CONDSSTR(Depot, name, SLE_STR, SLV_UNIQUE_DEPOT_NAMES, SL_MAX_VERSION),
|
|
SLE_CONDVAR(Depot, build_date, SLE_INT32, SLV_NEWGRF_DEPOT_BUILD_DATE, SL_MAX_VERSION),
|
|
};
|
|
|
|
struct DEPTChunkHandler : ChunkHandler {
|
|
DEPTChunkHandler() : ChunkHandler('DEPT', CH_TABLE) {}
|
|
|
|
void Save() const override
|
|
{
|
|
SlTableHeader(_depot_desc);
|
|
|
|
for (Depot *depot : Depot::Iterate()) {
|
|
SlSetArrayIndex(depot->index);
|
|
SlObject(depot, _depot_desc);
|
|
}
|
|
}
|
|
|
|
void Load() const override
|
|
{
|
|
const std::vector<SaveLoad> slt = SlCompatTableHeader(_depot_desc, _depot_sl_compat);
|
|
|
|
int index;
|
|
|
|
while ((index = SlIterateArray()) != -1) {
|
|
Depot *depot = Depot::CreateAtIndex(DepotID(index));
|
|
SlObject(depot, slt);
|
|
|
|
/* Set the town 'pointer' so we can restore it later. */
|
|
if (IsSavegameVersionBefore(SLV_UNIQUE_DEPOT_NAMES)) depot->town = reinterpret_cast<Town *>(static_cast<size_t>(_town_index.base()));
|
|
}
|
|
}
|
|
|
|
void FixPointers() const override
|
|
{
|
|
for (Depot *depot : Depot::Iterate()) {
|
|
SlObject(depot, _depot_desc);
|
|
if (IsSavegameVersionBefore(SLV_UNIQUE_DEPOT_NAMES)) depot->town = Town::Get((size_t)depot->town);
|
|
}
|
|
}
|
|
};
|
|
|
|
static const DEPTChunkHandler DEPT;
|
|
static const ChunkHandlerRef depot_chunk_handlers[] = {
|
|
DEPT,
|
|
};
|
|
|
|
extern const ChunkHandlerTable _depot_chunk_handlers(depot_chunk_handlers);
|