Merge branch 'master' into jgrpp
Bump savegame for water regions for ship pathfinder Use ring_buffer for ShipPathCache
This commit is contained in:
@@ -54,5 +54,6 @@ add_files(
|
||||
train_speed_adaptation.cpp
|
||||
tunnel_sl.cpp
|
||||
vehicle_sl.cpp
|
||||
water_regions_sl.cpp
|
||||
waypoint_sl.cpp
|
||||
)
|
||||
|
||||
@@ -208,6 +208,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
||||
{ XSLFI_SAVEGAME_ID, XSCF_NULL, 1, 1, "slv_savegame_id", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_NEWGRF_LAST_SERVICE, XSCF_NULL, 1, 1, "slv_newgrf_last_service", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_CARGO_TRAVELLED, XSCF_NULL, 1, 1, "slv_cargo_travelled", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_WATER_REGIONS, XSCF_IGNORABLE_ALL, 1, 1, "slv_water_regions", nullptr, nullptr, "WRGN" },
|
||||
|
||||
{ XSLFI_TABLE_PATS, XSCF_NULL, 1, 1, "table_pats", nullptr, nullptr, nullptr },
|
||||
|
||||
|
||||
@@ -157,6 +157,7 @@ enum SlXvFeatureIndex {
|
||||
XSLFI_SAVEGAME_ID, ///< See: SLV_SAVEGAME_ID (PR #10719)
|
||||
XSLFI_NEWGRF_LAST_SERVICE, ///< See: SLV_NEWGRF_LAST_SERVICE (PR #11124)
|
||||
XSLFI_CARGO_TRAVELLED, ///< See: SLV_CARGO_TRAVELLED (PR #11283)
|
||||
XSLFI_WATER_REGIONS, ///< See: SLV_WATER_REGIONS (PR #11435)
|
||||
|
||||
XSLFI_TABLE_PATS, ///< Use upstream table format for PATS
|
||||
|
||||
|
||||
@@ -302,6 +302,7 @@ static const std::vector<ChunkHandler> &ChunkHandlers()
|
||||
extern const ChunkHandlerTable _tunnel_chunk_handlers;
|
||||
extern const ChunkHandlerTable _train_speed_adaptation_chunk_handlers;
|
||||
extern const ChunkHandlerTable _new_signal_chunk_handlers;
|
||||
extern const ChunkHandlerTable _water_region_chunk_handlers;
|
||||
extern const ChunkHandlerTable _debug_chunk_handlers;
|
||||
|
||||
/** List of all chunks in a savegame. */
|
||||
@@ -350,6 +351,7 @@ static const std::vector<ChunkHandler> &ChunkHandlers()
|
||||
_tunnel_chunk_handlers,
|
||||
_train_speed_adaptation_chunk_handlers,
|
||||
_new_signal_chunk_handlers,
|
||||
_water_region_chunk_handlers,
|
||||
_debug_chunk_handlers,
|
||||
};
|
||||
|
||||
|
||||
@@ -378,6 +378,7 @@ enum SaveLoadVersion : uint16_t {
|
||||
SLV_TIMETABLE_START_TICKS, ///< 321 PR#11468 Convert timetable start from a date to ticks.
|
||||
SLV_TIMETABLE_START_TICKS_FIX, ///< 322 PR#11557 Fix for missing convert timetable start from a date to ticks.
|
||||
SLV_TIMETABLE_TICKS_TYPE, ///< 323 PR#11435 Convert timetable current order time to ticks.
|
||||
SLV_WATER_REGIONS, ///< 324 PR#10543 Water Regions for ship pathfinder.
|
||||
|
||||
SL_MAX_VERSION, ///< Highest possible saveload version
|
||||
|
||||
|
||||
@@ -881,7 +881,7 @@ SaveLoadTable GetVehicleDescription(VehicleType vt)
|
||||
SLE_WRITEBYTE(Vehicle, type),
|
||||
SLE_VEH_INCLUDE(),
|
||||
SLE_VAR(Ship, state, SLE_UINT8),
|
||||
SLEG_CONDVARVEC(_path_td, SLE_UINT8, SLV_SHIP_PATH_CACHE, SL_MAX_VERSION),
|
||||
SLE_CONDRING(Ship, cached_path, SLE_UINT8, SLV_SHIP_PATH_CACHE, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Ship, rotation, SLE_UINT8, SLV_SHIP_ROTATION, SL_MAX_VERSION),
|
||||
SLE_CONDVAR_X(Ship, lost_count, SLE_UINT8, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_SHIP_LOST_COUNTER)),
|
||||
SLE_CONDVAR_X(Ship, critical_breakdown_count, SLE_UINT8, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_IMPROVED_BREAKDOWNS, 8)),
|
||||
@@ -1047,17 +1047,6 @@ static void Save_VEHS()
|
||||
}
|
||||
_path_layout_ctr = rv->cached_path->layout_ctr;
|
||||
}
|
||||
} else if (v->type == VEH_SHIP) {
|
||||
_path_td.clear();
|
||||
|
||||
Ship *s = Ship::From(v);
|
||||
if (s->cached_path != nullptr && !s->cached_path->empty()) {
|
||||
uint idx = s->cached_path->start;
|
||||
for (uint i = 0; i < s->cached_path->size(); i++) {
|
||||
_path_td.push_back(s->cached_path->td[idx]);
|
||||
idx = (idx + 1) & SHIP_PATH_CACHE_MASK;
|
||||
}
|
||||
}
|
||||
}
|
||||
SlSetArrayIndex(v->index);
|
||||
SlObjectSaveFiltered(v, GetVehicleDescriptionFiltered(v->type));
|
||||
@@ -1145,13 +1134,6 @@ void Load_VEHS()
|
||||
rv->cached_path->tile[i] = _path_tile[i];
|
||||
}
|
||||
rv->cached_path->layout_ctr = _path_layout_ctr;
|
||||
} else if (vtype == VEH_SHIP && !_path_td.empty() && _path_td.size() <= SHIP_PATH_CACHE_LENGTH) {
|
||||
Ship *s = Ship::From(v);
|
||||
s->cached_path.reset(new ShipPathCache());
|
||||
s->cached_path->count = (uint8_t)_path_td.size();
|
||||
for (size_t i = 0; i < _path_td.size(); i++) {
|
||||
s->cached_path->td[i] = _path_td[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
27
src/sl/water_regions_sl.cpp
Normal file
27
src/sl/water_regions_sl.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file water_regions_sl.cpp Handles saving and loading of water region data */
|
||||
#include "../stdafx.h"
|
||||
|
||||
#include "saveload.h"
|
||||
|
||||
extern SaveLoadVersion _sl_xv_upstream_version;
|
||||
|
||||
struct GetWaterRegionsLoadInfo
|
||||
{
|
||||
static SaveLoadVersion GetLoadVersion()
|
||||
{
|
||||
return _sl_xv_upstream_version != SL_MIN_VERSION ? _sl_xv_upstream_version : SLV_WATER_REGIONS;
|
||||
}
|
||||
};
|
||||
|
||||
static const ChunkHandler water_region_chunk_handlers[] = {
|
||||
MakeUpstreamChunkHandler<'WRGN', GetWaterRegionsLoadInfo>(),
|
||||
};
|
||||
|
||||
extern const ChunkHandlerTable _water_region_chunk_handlers(water_region_chunk_handlers);
|
||||
Reference in New Issue
Block a user