mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 22:36:43 +00:00
Fix a bug in ESMStore code that checks for duplicate record insertions
This commit is contained in:
parent
3ad28ec5aa
commit
07d9845aa0
1 changed files with 15 additions and 10 deletions
|
@ -166,16 +166,17 @@ namespace MWWorld
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
const T *insert(const T &x) {
|
const T *insert(const T &x) {
|
||||||
|
std::ostringstream id;
|
||||||
|
id << "$dynamic" << mDynamicCount++;
|
||||||
|
|
||||||
Store<T> &store = const_cast<Store<T> &>(get<T>());
|
Store<T> &store = const_cast<Store<T> &>(get<T>());
|
||||||
if (store.search(x.mId) != 0) {
|
if (store.search(id.str()) != 0) {
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
msg << "Try to override existing record '" << x.mId << "'";
|
msg << "Try to override existing record '" << id.str() << "'";
|
||||||
throw std::runtime_error(msg.str());
|
throw std::runtime_error(msg.str());
|
||||||
}
|
}
|
||||||
T record = x;
|
T record = x;
|
||||||
|
|
||||||
std::ostringstream id;
|
|
||||||
id << "$dynamic" << mDynamicCount++;
|
|
||||||
record.mId = id.str();
|
record.mId = id.str();
|
||||||
|
|
||||||
T *ptr = store.insert(record);
|
T *ptr = store.insert(record);
|
||||||
|
@ -189,10 +190,13 @@ namespace MWWorld
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
const T *insertStatic(const T &x) {
|
const T *insertStatic(const T &x) {
|
||||||
|
std::ostringstream id;
|
||||||
|
id << "$dynamic" << mDynamicCount++;
|
||||||
|
|
||||||
Store<T> &store = const_cast<Store<T> &>(get<T>());
|
Store<T> &store = const_cast<Store<T> &>(get<T>());
|
||||||
if (store.search(x.mId) != 0) {
|
if (store.search(id.str()) != 0) {
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
msg << "Try to override existing record '" << x.mId << "'";
|
msg << "Try to override existing record '" << id.str() << "'";
|
||||||
throw std::runtime_error(msg.str());
|
throw std::runtime_error(msg.str());
|
||||||
}
|
}
|
||||||
T record = x;
|
T record = x;
|
||||||
|
@ -225,17 +229,18 @@ namespace MWWorld
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline const ESM::NPC *ESMStore::insert<ESM::NPC>(const ESM::NPC &npc) {
|
inline const ESM::NPC *ESMStore::insert<ESM::NPC>(const ESM::NPC &npc) {
|
||||||
|
std::ostringstream id;
|
||||||
|
id << "$dynamic" << mDynamicCount++;
|
||||||
|
|
||||||
if (Misc::StringUtils::ciEqual(npc.mId, "player")) {
|
if (Misc::StringUtils::ciEqual(npc.mId, "player")) {
|
||||||
return mNpcs.insert(npc);
|
return mNpcs.insert(npc);
|
||||||
} else if (mNpcs.search(npc.mId) != 0) {
|
} else if (mNpcs.search(id.str()) != 0) {
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
msg << "Try to override existing record '" << npc.mId << "'";
|
msg << "Try to override existing record '" << id.str() << "'";
|
||||||
throw std::runtime_error(msg.str());
|
throw std::runtime_error(msg.str());
|
||||||
}
|
}
|
||||||
ESM::NPC record = npc;
|
ESM::NPC record = npc;
|
||||||
|
|
||||||
std::ostringstream id;
|
|
||||||
id << "$dynamic" << mDynamicCount++;
|
|
||||||
record.mId = id.str();
|
record.mId = id.str();
|
||||||
|
|
||||||
ESM::NPC *ptr = mNpcs.insert(record);
|
ESM::NPC *ptr = mNpcs.insert(record);
|
||||||
|
|
Loading…
Reference in a new issue