1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-29 18:32:36 +00:00

Remove preloading logic from ESM4::Cell

This logic does not belong here. If client of ESM4::Cell needs to cache load
results it can be done separately.
This commit is contained in:
elsid 2022-04-24 19:00:35 +02:00
parent 13c970b37a
commit 2c9b6fffe5
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40
2 changed files with 8 additions and 29 deletions

View File

@ -43,7 +43,14 @@ ESM4::Cell::~Cell()
{
}
void ESM4::Cell::init(ESM4::Reader& reader)
// TODO: Try loading only EDID and XCLC (along with mFormId, mFlags and mParent)
//
// But, for external cells we may be scanning the whole record since we don't know if there is
// going to be an EDID subrecord. And the vast majority of cells are these kinds.
//
// So perhaps some testing needs to be done to see if scanning and skipping takes
// longer/shorter/same as loading the subrecords.
void ESM4::Cell::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.id;
reader.adjustFormId(mFormId);
@ -64,33 +71,10 @@ void ESM4::Cell::init(ESM4::Reader& reader)
currCellGrid.grid.y = 0;
reader.setCurrCellGrid(currCellGrid); // side effect: sets mCellGridValid true
}
}
// TODO: Try loading only EDID and XCLC (along with mFormId, mFlags and mParent)
//
// But, for external cells we may be scanning the whole record since we don't know if there is
// going to be an EDID subrecord. And the vast majority of cells are these kinds.
//
// So perhaps some testing needs to be done to see if scanning and skipping takes
// longer/shorter/same as loading the subrecords.
bool ESM4::Cell::preload(ESM4::Reader& reader)
{
if (!mPreloaded)
load(reader);
mPreloaded = true;
return true;
}
void ESM4::Cell::load(ESM4::Reader& reader)
{
if (mPreloaded)
return;
// WARN: we need to call setCurrCell (and maybe setCurrCellGrid?) again before loading
// cell child groups if we are loading them after restoring the context
// (may be easier to update the context before saving?)
init(reader);
reader.setCurrCell(mFormId); // save for LAND (and other children) to access later
std::uint32_t esmVer = reader.esmVersion();
bool isFONV = esmVer == ESM::VER_132 || esmVer == ESM::VER_133 || esmVer == ESM::VER_134;

View File

@ -93,11 +93,6 @@ namespace ESM4
virtual ~Cell();
void init(ESM4::Reader& reader); // common setup for both preload() and load()
bool mPreloaded;
bool preload(ESM4::Reader& reader);
virtual void load(ESM4::Reader& reader);
//virtual void save(ESM4::Writer& writer) const;