mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 12:35:46 +00:00
Delete infos of deleted dialogue when loading a content file
(cherry picked from commit e04e32bcffa3c95f7c2a007d5fcf09641fff0b03)
This commit is contained in:
parent
9a803739ff
commit
a120bb2b54
@ -1118,11 +1118,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
|
||||
{
|
||||
|
@ -187,3 +187,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…
x
Reference in New Issue
Block a user