From 2c9b6fffe51791ccece206f81c3a44973afab17c Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 24 Apr 2022 19:00:35 +0200 Subject: [PATCH] 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. --- components/esm4/loadcell.cpp | 32 ++++++++------------------------ components/esm4/loadcell.hpp | 5 ----- 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/components/esm4/loadcell.cpp b/components/esm4/loadcell.cpp index 0b90a7cdbf..97b3603204 100644 --- a/components/esm4/loadcell.cpp +++ b/components/esm4/loadcell.cpp @@ -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; diff --git a/components/esm4/loadcell.hpp b/components/esm4/loadcell.hpp index c2274fcbe9..3dff4fdf0a 100644 --- a/components/esm4/loadcell.hpp +++ b/components/esm4/loadcell.hpp @@ -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;