Empty Pathgrid record is considered as the modder's intention to delete any existing record.

pull/3097/head
cc9cii 3 years ago
parent 802a202455
commit bd3ef506cd

@ -19,7 +19,7 @@ opencs_hdrs_noqt (model/doc
opencs_units (model/world
idtable idtableproxymodel regionmap data commanddispatcher idtablebase resourcetable nestedtableproxymodel idtree infotableproxymodel landtexturetableproxymodel
actoradapter
actoradapter idcollection
)

@ -0,0 +1,43 @@
#include "idcollection.hpp"
namespace CSMWorld
{
template<>
int IdCollection<Pathgrid, IdAccessor<Pathgrid> >::load (ESM::ESMReader& reader, bool base)
{
Pathgrid record;
bool isDeleted = false;
loadRecord (record, reader, isDeleted);
std::string id = IdAccessor<Pathgrid>().getId (record);
int index = this->searchId (id);
if (record.mPoints.empty() || record.mEdges.empty())
isDeleted = true;
if (isDeleted)
{
if (index==-1)
{
// deleting a record that does not exist
// ignore it for now
/// \todo report the problem to the user
return -1;
}
if (base)
{
this->removeRows (index, 1);
return -1;
}
std::unique_ptr<Record<Pathgrid> > baseRecord(new Record<Pathgrid>(this->getRecord(index)));
baseRecord->mState = RecordBase::State_Deleted;
this->setRecord(index, std::move(baseRecord));
return index;
}
return load (record, base, index);
}
}

@ -5,6 +5,7 @@
#include "collection.hpp"
#include "land.hpp"
#include "pathgrid.hpp"
namespace CSMWorld
{
@ -153,6 +154,9 @@ namespace CSMWorld
return true;
}
template<>
int IdCollection<Pathgrid, IdAccessor<Pathgrid> >::load(ESM::ESMReader& reader, bool base);
}
#endif

@ -20,7 +20,7 @@ namespace CSMWorld
{
std::string mId;
void load (ESM::ESMReader &esm, bool &isDeleted, const IdCollection<Cell>& cells);
void load (ESM::ESMReader &esm, bool &isDeleted, const IdCollection<Cell, IdAccessor<Cell> >& cells);
void load (ESM::ESMReader &esm, bool &isDeleted);
};
}

Loading…
Cancel
Save