mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-22 02:09:49 +00:00
implemented reference record deleting
This commit is contained in:
parent
d8440e1fdc
commit
e0b6bf6aeb
3 changed files with 34 additions and 6 deletions
|
@ -539,7 +539,7 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Stage::Messages& messages)
|
||||||
{
|
{
|
||||||
mCells.load (*mReader, mBase);
|
mCells.load (*mReader, mBase);
|
||||||
std::string cellId = Misc::StringUtils::lowerCase (mCells.getId (mCells.getSize()-1));
|
std::string cellId = Misc::StringUtils::lowerCase (mCells.getId (mCells.getSize()-1));
|
||||||
mRefs.load (*mReader, mCells.getSize()-1, mBase, mRefLoadCache[cellId]);
|
mRefs.load (*mReader, mCells.getSize()-1, mBase, mRefLoadCache[cellId], messages);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "record.hpp"
|
#include "record.hpp"
|
||||||
|
|
||||||
void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base,
|
void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base,
|
||||||
std::map<ESM::CellRef::RefNum, std::string>& cache)
|
std::map<ESM::CellRef::RefNum, std::string>& cache, CSMDoc::Stage::Messages& messages)
|
||||||
{
|
{
|
||||||
Record<Cell> cell = mCells.getRecord (cellIndex);
|
Record<Cell> cell = mCells.getRecord (cellIndex);
|
||||||
|
|
||||||
|
@ -27,14 +27,39 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
|
||||||
|
|
||||||
/// \todo handle moved references
|
/// \todo handle moved references
|
||||||
|
|
||||||
|
std::map<ESM::CellRef::RefNum, std::string>::iterator iter = cache.find (ref.mRefNum);
|
||||||
|
|
||||||
if (deleted)
|
if (deleted)
|
||||||
{
|
{
|
||||||
/// \todo handle deleted references
|
if (iter==cache.end())
|
||||||
|
{
|
||||||
|
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Cell,
|
||||||
|
mCells.getId (cellIndex));
|
||||||
|
|
||||||
|
messages.push_back (std::make_pair (id,
|
||||||
|
"Attempt to delete a non-existing reference"));
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int index = getIndex (iter->second);
|
||||||
|
|
||||||
|
Record<CellRef> record = getRecord (index);
|
||||||
|
|
||||||
|
if (record.mState==RecordBase::State_BaseOnly)
|
||||||
|
{
|
||||||
|
removeRows (index, 1);
|
||||||
|
cache.erase (iter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
record.mState = RecordBase::State_Deleted;
|
||||||
|
setRecord (index, record);
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<ESM::CellRef::RefNum, std::string>::iterator iter = cache.find (ref.mRefNum);
|
|
||||||
|
|
||||||
if (iter==cache.end())
|
if (iter==cache.end())
|
||||||
{
|
{
|
||||||
// new reference
|
// new reference
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#include "../doc/stage.hpp"
|
||||||
|
|
||||||
#include "collection.hpp"
|
#include "collection.hpp"
|
||||||
#include "ref.hpp"
|
#include "ref.hpp"
|
||||||
#include "record.hpp"
|
#include "record.hpp"
|
||||||
|
@ -25,7 +27,8 @@ namespace CSMWorld
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void load (ESM::ESMReader& reader, int cellIndex, bool base,
|
void load (ESM::ESMReader& reader, int cellIndex, bool base,
|
||||||
std::map<ESM::CellRef::RefNum, std::string>& cache);
|
std::map<ESM::CellRef::RefNum, std::string>& cache,
|
||||||
|
CSMDoc::Stage::Messages& messages);
|
||||||
///< Load a sequence of references.
|
///< Load a sequence of references.
|
||||||
|
|
||||||
std::string getNewId();
|
std::string getNewId();
|
||||||
|
|
Loading…
Reference in a new issue