mirror of
https://github.com/OpenMW/openmw.git
synced 2025-05-09 22:41:25 +00:00
Delete infos of deleted dialogue when loading a content file
(cherry picked from commit e04e32bcff
)
This commit is contained in:
parent
9a803739ff
commit
a120bb2b54
3 changed files with 40 additions and 2 deletions
|
@ -1118,11 +1118,11 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Messages& messages)
|
||||||
|
|
||||||
if (mJournals.tryDelete (record.mId))
|
if (mJournals.tryDelete (record.mId))
|
||||||
{
|
{
|
||||||
/// \todo handle info records
|
mJournalInfos.removeDialogueInfos(record.mId);
|
||||||
}
|
}
|
||||||
else if (mTopics.tryDelete (record.mId))
|
else if (mTopics.tryDelete (record.mId))
|
||||||
{
|
{
|
||||||
/// \todo handle info records
|
mTopicInfos.removeDialogueInfos(record.mId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -187,3 +187,39 @@ CSMWorld::InfoCollection::Range CSMWorld::InfoCollection::getTopicRange (const s
|
||||||
|
|
||||||
return Range (begin, end);
|
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;
|
Range getTopicRange (const std::string& topic) const;
|
||||||
///< Return iterators that point to the beginning and past the end of the range for
|
///< Return iterators that point to the beginning and past the end of the range for
|
||||||
/// the given topic.
|
/// the given topic.
|
||||||
|
|
||||||
|
void removeDialogueInfos(const std::string& dialogueId);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue