mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
handle deleted dialogue records
This commit is contained in:
parent
dc12648a3e
commit
3b85d97087
2 changed files with 43 additions and 2 deletions
|
@ -493,7 +493,18 @@ void CSMWorld::Data::loadFile (const boost::filesystem::path& path, bool base)
|
|||
}
|
||||
else if (record.mType==ESM::Dialogue::Deleted)
|
||||
{
|
||||
/// \todo handle deleted records
|
||||
if (mJournals.tryDelete (id))
|
||||
{
|
||||
/// \todo handle info records
|
||||
}
|
||||
else if (mTopics.tryDelete (id))
|
||||
{
|
||||
/// \todo handle info records
|
||||
}
|
||||
else
|
||||
{
|
||||
/// \todo report deletion of non-existing record
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace CSMWorld
|
||||
{
|
||||
|
||||
/// \brief Single type collection of top level records
|
||||
template<typename ESXRecordT, typename IdAccessorT = IdAccessor<ESXRecordT> >
|
||||
class IdCollection : public Collection<ESXRecordT, IdAccessorT>
|
||||
|
@ -17,6 +16,11 @@ namespace CSMWorld
|
|||
void load (ESM::ESMReader& reader, bool base);
|
||||
|
||||
void load (const ESXRecordT& record, bool base);
|
||||
|
||||
bool tryDelete (const std::string& id);
|
||||
///< Try deleting \a id. If the id does not exist or can't be deleted the call is ignored.
|
||||
///
|
||||
/// \return Has the ID been deleted?
|
||||
};
|
||||
|
||||
template<typename ESXRecordT, typename IdAccessorT>
|
||||
|
@ -86,6 +90,32 @@ namespace CSMWorld
|
|||
this->setRecord (index, record2);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename ESXRecordT, typename IdAccessorT>
|
||||
bool IdCollection<ESXRecordT, IdAccessorT>::tryDelete (const std::string& id)
|
||||
{
|
||||
int index = this->searchId (id);
|
||||
|
||||
if (index==-1)
|
||||
return false;
|
||||
|
||||
Record<ESXRecordT> record = Collection<ESXRecordT, IdAccessorT>::getRecord (index);
|
||||
|
||||
if (record.isDeleted())
|
||||
return false;
|
||||
|
||||
if (record.mState==RecordBase::State_ModifiedOnly)
|
||||
{
|
||||
Collection<ESXRecordT, IdAccessorT>::removeRows (index, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
record.mState = RecordBase::State_Deleted;
|
||||
setRecord (index, record);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue