1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 23:53:52 +00:00

Revert old fix.

This commit is contained in:
cc9cii 2014-09-27 23:39:22 +10:00
parent a2d043f43a
commit d790b8edfa

View file

@ -7,7 +7,6 @@
#include <cctype> #include <cctype>
#include <stdexcept> #include <stdexcept>
#include <functional> #include <functional>
#include <iostream>
#include <QVariant> #include <QVariant>
@ -432,27 +431,18 @@ namespace CSMWorld
const Record<ESXRecordT>& record2 = dynamic_cast<const Record<ESXRecordT>&> (record); const Record<ESXRecordT>& record2 = dynamic_cast<const Record<ESXRecordT>&> (record);
std::pair<std::map<std::string, int>::iterator, bool> insertResult = mRecords.insert (mRecords.begin()+index, record2);
mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (IdAccessorT().getId (record2.get())),
index));
if(!insertResult.second) // duplicate index found, replace the current record
{
std::cerr << "Duplicate record found, using new: " + IdAccessorT().getId(record2.get()) << std::endl;
replace(insertResult.first->second, record2);
return;
}
// else update the index except for the record to be inserted
if (index<static_cast<int> (mRecords.size())-1) if (index<static_cast<int> (mRecords.size())-1)
{ {
std::string id = IdAccessorT().getId(record2.get()); for (std::map<std::string, int>::iterator iter (mIndex.begin()); iter!=mIndex.end();
for (std::map<std::string, int>::iterator iter (mIndex.begin()); iter!=mIndex.end(); ++iter) ++iter)
if (iter->second > index || (iter->second == index && iter->first != id)) if (iter->second>=index)
++(iter->second); ++(iter->second);
} }
mRecords.insert (mRecords.begin()+index, record2); mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (IdAccessorT().getId (
record2.get())), index));
} }
template<typename ESXRecordT, typename IdAccessorT> template<typename ESXRecordT, typename IdAccessorT>