#include "refcollection.hpp" #include #include "ref.hpp" #include "cell.hpp" #include "universalid.hpp" #include "record.hpp" void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base) { Record cell = mCells.getRecord (cellIndex); Cell& cell2 = base ? cell.mBase : cell.mModified; CellRef ref; while (cell2.getNextRef (reader, ref)) { /// \todo handle deleted and moved references ref.load (reader, cell2, getNewId()); Record record2; record2.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly; (base ? record2.mBase : record2.mModified) = ref; appendRecord (record2); } mCells.setRecord (cellIndex, cell); } std::string CSMWorld::RefCollection::getNewId() { std::ostringstream stream; stream << "ref#" << mNextId++; return stream.str(); } void CSMWorld::RefCollection::cloneRecord(const std::string& origin, const std::string& destination, const CSMWorld::UniversalId::Type type, const CSMWorld::UniversalId::ArgumentType argumentType) { Record clone(getRecord(origin)); clone.mState = CSMWorld::RecordBase::State_ModifiedOnly; clone.get().mId = destination; insertRecord(clone, getAppendIndex(destination, type), type); }