mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-20 14:23:53 +00:00
Delete infos of deleted dialogue when loading a content file
This commit is contained in:
parent
a4d3e59e5c
commit
e04e32bcff
3 changed files with 40 additions and 2 deletions
|
@ -998,11 +998,11 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Messages& messages)
|
|||
|
||||
if (mJournals.tryDelete (record.mId))
|
||||
{
|
||||
/// \todo handle info records
|
||||
mJournalInfos.removeDialogueInfos(record.mId);
|
||||
}
|
||||
else if (mTopics.tryDelete (record.mId))
|
||||
{
|
||||
/// \todo handle info records
|
||||
mTopicInfos.removeDialogueInfos(record.mId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -188,3 +188,39 @@ CSMWorld::InfoCollection::Range CSMWorld::InfoCollection::getTopicRange (const s
|
|||
|
||||
return Range (begin, end);
|
||||
}
|
||||
|
||||
void CSMWorld::InfoCollection::removeDialogueInfos(const std::string& dialogueId)
|
||||
{
|
||||
std::string id = Misc::StringUtils::lowerCase(dialogueId);
|
||||
std::vector<int> erasedRecords;
|
||||
|
||||
std::map<std::string, int>::const_iterator current = getIdMap().lower_bound(id);
|
||||
std::map<std::string, int>::const_iterator end = getIdMap().end();
|
||||
for (; current != end; ++current)
|
||||
{
|
||||
Record<Info> record = getRecord(current->second);
|
||||
|
||||
if (Misc::StringUtils::ciEqual(dialogueId, record.get().mTopicId))
|
||||
{
|
||||
if (record.mState == RecordBase::State_ModifiedOnly)
|
||||
{
|
||||
erasedRecords.push_back(current->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
record.mState = RecordBase::State_Deleted;
|
||||
setRecord(current->second, record);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (!erasedRecords.empty())
|
||||
{
|
||||
removeRows(erasedRecords.back(), 1);
|
||||
erasedRecords.pop_back();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,8 @@ namespace CSMWorld
|
|||
Range getTopicRange (const std::string& topic) const;
|
||||
///< Return iterators that point to the beginning and past the end of the range for
|
||||
/// the given topic.
|
||||
|
||||
void removeDialogueInfos(const std::string& dialogueId);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue