Change: simplified water region evaluation, removed savegame data (#11750)

This commit is contained in:
Kuhnovic
2024-01-21 21:56:50 +01:00
committed by GitHub
parent 1985e7415b
commit b38d3c2208
12 changed files with 29 additions and 88 deletions

View File

@@ -61,7 +61,6 @@
#include "../timer/timer.h"
#include "../timer/timer_game_calendar.h"
#include "../timer/timer_game_tick.h"
#include "../pathfinder/water_regions.h"
#include "saveload_internal.h"
@@ -3297,8 +3296,6 @@ bool AfterLoadGame()
}
}
if (IsSavegameVersionBefore(SLV_WATER_REGIONS)) InitializeWaterRegions();
return true;
}

View File

@@ -367,6 +367,8 @@ enum SaveLoadVersion : uint16_t {
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.
SLV_WATER_REGION_EVAL_SIMPLIFIED, ///< 325 PR#11750 Simplified Water Region evaluation.
SL_MAX_VERSION, ///< Highest possible saveload version
};

View File

@@ -10,45 +10,23 @@
#include "../stdafx.h"
#include "saveload.h"
#include "pathfinder/water_regions.h"
#include "../safeguards.h"
static const SaveLoad _water_region_desc[] = {
SLE_VAR(WaterRegionSaveLoadInfo, initialized, SLE_BOOL),
};
extern void SlSkipArray();
struct WRGNChunkHandler : ChunkHandler {
WRGNChunkHandler() : ChunkHandler('WRGN', CH_TABLE) {}
void Save() const override
{
SlTableHeader(_water_region_desc);
int index = 0;
for (WaterRegionSaveLoadInfo &region : GetWaterRegionSaveLoadInfo()) {
SlSetArrayIndex(index++);
SlObject(&region, _water_region_desc);
}
}
/* Water Region savegame data is no longer used, but still needed for old savegames to load without errors. */
struct WaterRegionChunkHandler : ChunkHandler {
WaterRegionChunkHandler() : ChunkHandler('WRGN', CH_READONLY)
{}
void Load() const override
{
const std::vector<SaveLoad> slt = SlTableHeader(_water_region_desc);
int index;
std::vector<WaterRegionSaveLoadInfo> loaded_info;
while ((index = SlIterateArray()) != -1) {
WaterRegionSaveLoadInfo region_info;
SlObject(&region_info, slt);
loaded_info.push_back(std::move(region_info));
}
LoadWaterRegions(loaded_info);
}
SlTableHeader({});
SlSkipArray();
};
};
static const WRGNChunkHandler WRGN;
static const WaterRegionChunkHandler WRGN;
static const ChunkHandlerRef water_region_chunk_handlers[] = { WRGN };
extern const ChunkHandlerTable _water_region_chunk_handlers(water_region_chunk_handlers);