1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 15:29:55 +00:00

Merge branch 'world_model_init' into 'master'

Refactor WorldModel initialization making it C++ core guidelines complaint

See merge request OpenMW/openmw!2825
This commit is contained in:
psi29a 2023-03-13 10:57:03 +00:00
commit d8d2cb980c
2 changed files with 11 additions and 14 deletions

View file

@ -153,11 +153,9 @@ void MWWorld::WorldModel::writeCell(ESM::ESMWriter& writer, CellStore& cell) con
MWWorld::WorldModel::WorldModel(const MWWorld::ESMStore& store, ESM::ReadersCache& readers)
: mStore(store)
, mReaders(readers)
, mIdCacheIndex(0)
, mPtrIndexUpdateCounter(0)
, mIdCache(std::clamp(Settings::Manager::getInt("pointers cache size", "Cells"), 40, 1000),
{ ESM::RefId::sEmpty, nullptr })
{
int cacheSize = std::clamp(Settings::Manager::getInt("pointers cache size", "Cells"), 40, 1000);
mIdCache = IdCache(cacheSize, std::pair<ESM::RefId, CellStore*>(ESM::RefId(), (CellStore*)nullptr));
}
MWWorld::CellStore* MWWorld::WorldModel::getExterior(int x, int y)

View file

@ -45,10 +45,10 @@ namespace MWWorld
mutable std::map<std::string, CellStore, Misc::StringUtils::CiComp> mInteriors;
mutable std::map<std::pair<int, int>, CellStore> mExteriors;
IdCache mIdCache;
std::size_t mIdCacheIndex;
WorldModel(const WorldModel&);
WorldModel& operator=(const WorldModel&);
std::size_t mIdCacheIndex = 0;
std::unordered_map<ESM::RefNum, Ptr> mPtrIndex;
std::size_t mPtrIndexUpdateCounter = 0;
ESM::RefNum mLastGeneratedRefnum;
const ESM::Cell* getESMCellByName(std::string_view name);
ESM::CellVariant getCellByName(std::string_view name);
@ -58,15 +58,14 @@ namespace MWWorld
void writeCell(ESM::ESMWriter& writer, CellStore& cell) const;
std::unordered_map<ESM::RefNum, Ptr> mPtrIndex;
size_t mPtrIndexUpdateCounter;
ESM::RefNum mLastGeneratedRefnum;
public:
void clear();
explicit WorldModel(const MWWorld::ESMStore& store, ESM::ReadersCache& reader);
WorldModel(const WorldModel&) = delete;
WorldModel& operator=(const WorldModel&) = delete;
void clear();
CellStore* getExterior(int x, int y);
CellStore* getInterior(std::string_view name);
CellStore* getCell(std::string_view name); // interior or named exterior