1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-04-11 19:36:43 +00:00

Merge branch 'fix_remove_deleted_dialogue_info' into 'master'

Fix handling deleted DIAL records (#7397)

Closes #7397

See merge request OpenMW/openmw!3097
This commit is contained in:
psi29a 2023-06-02 08:56:24 +00:00
commit 25bbaa2343
3 changed files with 13 additions and 12 deletions

View file

@ -73,17 +73,18 @@ namespace CSMWorld
for (const OrderedInfo& info : topicInfoOrder->second.getOrderedInfo()) for (const OrderedInfo& info : topicInfoOrder->second.getOrderedInfo())
{ {
const Record<Info>& record = infoCollection.getRecord(info.mId); const ESM::RefId id = makeCompositeInfoRefId(dialogueId, info.mId);
const Record<Info>& record = infoCollection.getRecord(id);
if (record.mState == RecordBase::State_ModifiedOnly) if (record.mState == RecordBase::State_ModifiedOnly)
{ {
erasedRecords.push_back(infoCollection.searchId(info.mId)); erasedRecords.push_back(infoCollection.searchId(id));
continue; continue;
} }
auto deletedRecord = std::make_unique<Record<Info>>(record); auto deletedRecord = std::make_unique<Record<Info>>(record);
deletedRecord->mState = RecordBase::State_Deleted; deletedRecord->mState = RecordBase::State_Deleted;
infoCollection.setRecord(infoCollection.searchId(info.mId), std::move(deletedRecord)); infoCollection.setRecord(infoCollection.searchId(id), std::move(deletedRecord));
} }
while (!erasedRecords.empty()) while (!erasedRecords.empty())
@ -91,8 +92,6 @@ namespace CSMWorld
infoCollection.removeRows(erasedRecords.back(), 1); infoCollection.removeRows(erasedRecords.back(), 1);
erasedRecords.pop_back(); erasedRecords.pop_back();
} }
infoOrders.erase(topicInfoOrder);
} }
} }
} }

View file

@ -18,16 +18,16 @@ namespace CSMWorld
{ {
namespace namespace
{ {
ESM::RefId makeCompositeRefId(const ESM::RefId& topicId, const ESM::RefId& infoId)
{
return ESM::RefId::stringRefId(topicId.getRefIdString() + '#' + infoId.getRefIdString());
}
std::string_view getInfoTopicId(const ESM::RefId& infoId) std::string_view getInfoTopicId(const ESM::RefId& infoId)
{ {
return parseInfoRefId(infoId).first; return parseInfoRefId(infoId).first;
} }
} }
ESM::RefId makeCompositeInfoRefId(const ESM::RefId& topicId, const ESM::RefId& infoId)
{
return ESM::RefId::stringRefId(topicId.getRefIdString() + '#' + infoId.getRefIdString());
}
} }
void CSMWorld::InfoCollection::load(const Info& value, bool base) void CSMWorld::InfoCollection::load(const Info& value, bool base)
@ -65,7 +65,7 @@ void CSMWorld::InfoCollection::load(
info.load(reader, isDeleted); info.load(reader, isDeleted);
const ESM::RefId id = makeCompositeRefId(dialogue.mId, info.mId); const ESM::RefId id = makeCompositeInfoRefId(dialogue.mId, info.mId);
if (isDeleted) if (isDeleted)
{ {
@ -107,7 +107,7 @@ void CSMWorld::InfoCollection::sort(const InfoOrderByTopic& infoOrders)
order.reserve(getSize()); order.reserve(getSize());
for (const auto& [topicId, infoOrder] : infoOrders) for (const auto& [topicId, infoOrder] : infoOrders)
for (const OrderedInfo& info : infoOrder.getOrderedInfo()) for (const OrderedInfo& info : infoOrder.getOrderedInfo())
order.push_back(getIndex(makeCompositeRefId(topicId, info.mId))); order.push_back(getIndex(makeCompositeInfoRefId(topicId, info.mId)));
reorderRowsImp(order); reorderRowsImp(order);
} }

View file

@ -55,6 +55,8 @@ namespace CSMWorld
bool reorderRows(int baseIndex, const std::vector<int>& newOrder) override; bool reorderRows(int baseIndex, const std::vector<int>& newOrder) override;
}; };
ESM::RefId makeCompositeInfoRefId(const ESM::RefId& topicId, const ESM::RefId& infoId);
} }
#endif #endif