mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 15:29:55 +00:00
Avoid gaps between local indexes in RefIdData after removal of records (Fix #2545)
This commit is contained in:
parent
9767910f06
commit
d27b92e9f1
1 changed files with 14 additions and 1 deletions
|
@ -176,7 +176,6 @@ void CSMWorld::RefIdData::erase (const LocalIndex& index, int count)
|
||||||
{
|
{
|
||||||
std::map<UniversalId::Type, RefIdDataContainerBase *>::iterator iter =
|
std::map<UniversalId::Type, RefIdDataContainerBase *>::iterator iter =
|
||||||
mRecordContainers.find (index.second);
|
mRecordContainers.find (index.second);
|
||||||
|
|
||||||
if (iter==mRecordContainers.end())
|
if (iter==mRecordContainers.end())
|
||||||
throw std::logic_error ("invalid local index type");
|
throw std::logic_error ("invalid local index type");
|
||||||
|
|
||||||
|
@ -189,6 +188,20 @@ void CSMWorld::RefIdData::erase (const LocalIndex& index, int count)
|
||||||
mIndex.erase (result);
|
mIndex.erase (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Adjust the local indexes to avoid gaps between them after removal of records
|
||||||
|
int recordIndex = index.first + count;
|
||||||
|
int recordCount = iter->second->getSize();
|
||||||
|
while (recordIndex < recordCount)
|
||||||
|
{
|
||||||
|
std::map<std::string, LocalIndex>::iterator recordIndexFound =
|
||||||
|
mIndex.find(Misc::StringUtils::lowerCase(iter->second->getId(recordIndex)));
|
||||||
|
if (recordIndexFound != mIndex.end())
|
||||||
|
{
|
||||||
|
recordIndexFound->second.first -= count;
|
||||||
|
}
|
||||||
|
++recordIndex;
|
||||||
|
}
|
||||||
|
|
||||||
iter->second->erase (index.first, count);
|
iter->second->erase (index.first, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue