mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Saveload: Use table format for pending speed restrictions chunk
This commit is contained in:
parent
da53196399
commit
1dd8890a8f
@ -140,7 +140,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
||||
{ XSLFI_STATE_CHECKSUM, XSCF_NULL, 1, 1, "state_checksum", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_DEBUG, XSCF_IGNORABLE_ALL, 2, 2, "debug", nullptr, nullptr, "DBGD" },
|
||||
{ XSLFI_FLOW_STAT_FLAGS, XSCF_NULL, 1, 1, "flow_stat_flags", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_SPEED_RESTRICTION, XSCF_NULL, 1, 1, "speed_restriction", nullptr, nullptr, "VESR" },
|
||||
{ XSLFI_SPEED_RESTRICTION, XSCF_NULL, 2, 2, "speed_restriction", nullptr, nullptr, "VESR" },
|
||||
{ XSLFI_STATION_GOODS_EXTRA, XSCF_NULL, 1, 1, "station_goods_extra", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_DOCKING_CACHE_VER, XSCF_IGNORABLE_ALL, 3, 3, "docking_cache_ver", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_EXTRA_CHEATS, XSCF_NULL, 2, 2, "extra_cheats", nullptr, nullptr, nullptr },
|
||||
|
@ -1459,13 +1459,13 @@ void Load_VEOX()
|
||||
}
|
||||
}
|
||||
|
||||
const SaveLoadTable GetVehicleSpeedRestrictionDescription()
|
||||
const NamedSaveLoadTable GetVehicleSpeedRestrictionDescription()
|
||||
{
|
||||
static const SaveLoad _vehicle_speed_restriction_desc[] = {
|
||||
SLE_VAR(PendingSpeedRestrictionChange, distance, SLE_UINT16),
|
||||
SLE_VAR(PendingSpeedRestrictionChange, new_speed, SLE_UINT16),
|
||||
SLE_VAR(PendingSpeedRestrictionChange, prev_speed, SLE_UINT16),
|
||||
SLE_VAR(PendingSpeedRestrictionChange, flags, SLE_UINT16),
|
||||
static const NamedSaveLoad _vehicle_speed_restriction_desc[] = {
|
||||
NSL("distance", SLE_VAR(PendingSpeedRestrictionChange, distance, SLE_UINT16)),
|
||||
NSL("new_speed", SLE_VAR(PendingSpeedRestrictionChange, new_speed, SLE_UINT16)),
|
||||
NSL("prev_speed", SLE_VAR(PendingSpeedRestrictionChange, prev_speed, SLE_UINT16)),
|
||||
NSL("flags", SLE_VAR(PendingSpeedRestrictionChange, flags, SLE_UINT16)),
|
||||
};
|
||||
|
||||
return _vehicle_speed_restriction_desc;
|
||||
@ -1473,20 +1473,24 @@ const SaveLoadTable GetVehicleSpeedRestrictionDescription()
|
||||
|
||||
void Save_VESR()
|
||||
{
|
||||
SaveLoadTableData slt = SlTableHeader(GetVehicleSpeedRestrictionDescription());
|
||||
|
||||
for (auto &it : _pending_speed_restriction_change_map) {
|
||||
SlSetArrayIndex(it.first);
|
||||
PendingSpeedRestrictionChange *ptr = &(it.second);
|
||||
SlObject(ptr, GetVehicleSpeedRestrictionDescription());
|
||||
SlObjectSaveFiltered(ptr, slt);
|
||||
}
|
||||
}
|
||||
|
||||
void Load_VESR()
|
||||
{
|
||||
SaveLoadTableData slt = SlTableHeaderOrRiff(GetVehicleSpeedRestrictionDescription());
|
||||
|
||||
int index;
|
||||
while ((index = SlIterateArray()) != -1) {
|
||||
auto iter = _pending_speed_restriction_change_map.insert({ static_cast<VehicleID>(index), {} });
|
||||
PendingSpeedRestrictionChange *ptr = &(iter->second);
|
||||
SlObject(ptr, GetVehicleSpeedRestrictionDescription());
|
||||
SlObjectLoadFiltered(ptr, slt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1806,7 +1810,7 @@ void Load_VUBS()
|
||||
static const ChunkHandler veh_chunk_handlers[] = {
|
||||
{ 'VEHS', Save_VEHS, Load_VEHS, Ptrs_VEHS, nullptr, CH_SPARSE_TABLE },
|
||||
{ 'VEOX', nullptr, Load_VEOX, nullptr, nullptr, CH_READONLY },
|
||||
{ 'VESR', Save_VESR, Load_VESR, nullptr, nullptr, CH_SPARSE_ARRAY },
|
||||
{ 'VESR', Save_VESR, Load_VESR, nullptr, nullptr, CH_SPARSE_TABLE },
|
||||
{ 'VENC', Save_VENC, Load_VENC, nullptr, nullptr, CH_RIFF, Special_VENC },
|
||||
{ 'VLKA', nullptr, Load_VLKA, nullptr, nullptr, CH_READONLY },
|
||||
{ 'VUBS', nullptr, Load_VUBS, nullptr, nullptr, CH_READONLY },
|
||||
|
Loading…
Reference in New Issue
Block a user