1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-10 15:39:02 +00:00
OpenMW/apps/opencs/model/tools/mandatoryid.cpp
elsid 069d4255b9
Make ESM::RefId to be fixed size cheap to copy
Use std::variant. Store refId strings in unordered_set and use pointer to an
item there. Inserts to unordered_set do not invalidate pointers to values so the
pointer is always valid. Elements are not removed. Assume there is finite number
of string refIds.
2023-03-19 17:20:43 +01:00

30 lines
860 B
C++

#include "mandatoryid.hpp"
#include <memory>
#include "../world/collectionbase.hpp"
#include "../world/record.hpp"
#include <apps/opencs/model/doc/messages.hpp>
#include <apps/opencs/model/world/universalid.hpp>
CSMTools::MandatoryIdStage::MandatoryIdStage(const CSMWorld::CollectionBase& idCollection,
const CSMWorld::UniversalId& collectionId, const std::vector<ESM::RefId>& ids)
: mIdCollection(idCollection)
, mCollectionId(collectionId)
, mIds(ids)
{
}
int CSMTools::MandatoryIdStage::setup()
{
return static_cast<int>(mIds.size());
}
void CSMTools::MandatoryIdStage::perform(int stage, CSMDoc::Messages& messages)
{
if (mIdCollection.searchId(mIds.at(stage)) == -1 || mIdCollection.getRecord(mIds.at(stage)).isDeleted())
messages.add(mCollectionId, "Missing mandatory record: " + mIds.at(stage).toDebugString());
}