Codechange: Use std::array and std::unique_ptr for PersistentStorageArrays.

This (mostly) avoids the need for manual memory management and copying.
This commit is contained in:
Peter Nelson
2023-09-08 20:34:20 +01:00
committed by PeterN
parent c3918838f6
commit 9040d7813d
3 changed files with 11 additions and 29 deletions

View File

@@ -246,7 +246,7 @@ struct INDYChunkHandler : ChunkHandler {
/* Store the old persistent storage. The GRFID will be added later. */
assert(PersistentStorage::CanAllocateItem());
i->psa = new PersistentStorage(0, 0, 0);
memcpy(i->psa->storage, _old_ind_persistent_storage.storage, sizeof(_old_ind_persistent_storage.storage));
std::copy(std::begin(_old_ind_persistent_storage.storage), std::end(_old_ind_persistent_storage.storage), std::begin(i->psa->storage));
}
if (IsSavegameVersionBefore(SLV_INDUSTRY_CARGO_REORGANISE)) LoadMoveAcceptsProduced(i);
Industry::IncIndustryTypeCount(i->type);