|
|
|
@ -443,19 +443,24 @@ namespace CSMWorld
|
|
|
|
|
void Collection<ESXRecordT, IdAccessorT>::insertRecord (const RecordBase& record, int index,
|
|
|
|
|
UniversalId::Type type)
|
|
|
|
|
{
|
|
|
|
|
if (index<0 || index>static_cast<int> (mRecords.size()))
|
|
|
|
|
int size = static_cast<int>(mRecords.size());
|
|
|
|
|
if (index < 0 || index > size)
|
|
|
|
|
throw std::runtime_error ("index out of range");
|
|
|
|
|
|
|
|
|
|
const Record<ESXRecordT>& record2 = dynamic_cast<const Record<ESXRecordT>&> (record);
|
|
|
|
|
|
|
|
|
|
mRecords.insert (mRecords.begin()+index, record2);
|
|
|
|
|
if (index == size)
|
|
|
|
|
mRecords.push_back (record2);
|
|
|
|
|
else
|
|
|
|
|
mRecords.insert (mRecords.begin()+index, record2);
|
|
|
|
|
|
|
|
|
|
if (index<static_cast<int> (mRecords.size())-1)
|
|
|
|
|
if (index < size-1)
|
|
|
|
|
{
|
|
|
|
|
for (std::map<std::string, int>::iterator iter (mIndex.begin()); iter!=mIndex.end();
|
|
|
|
|
++iter)
|
|
|
|
|
if (iter->second>=index)
|
|
|
|
|
++(iter->second);
|
|
|
|
|
for (std::map<std::string, int>::iterator iter (mIndex.begin()); iter!=mIndex.end(); ++iter)
|
|
|
|
|
{
|
|
|
|
|
if (iter->second >= index)
|
|
|
|
|
++(iter->second);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (IdAccessorT().getId (
|
|
|
|
|