|
|
|
@ -166,16 +166,17 @@ namespace MWWorld
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
|
const T *insert(const T &x) {
|
|
|
|
|
std::ostringstream id;
|
|
|
|
|
id << "$dynamic" << mDynamicCount++;
|
|
|
|
|
|
|
|
|
|
Store<T> &store = const_cast<Store<T> &>(get<T>());
|
|
|
|
|
if (store.search(x.mId) != 0) {
|
|
|
|
|
if (store.search(id.str()) != 0) {
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
T record = x;
|
|
|
|
|
|
|
|
|
|
std::ostringstream id;
|
|
|
|
|
id << "$dynamic" << mDynamicCount++;
|
|
|
|
|
record.mId = id.str();
|
|
|
|
|
|
|
|
|
|
T *ptr = store.insert(record);
|
|
|
|
@ -189,10 +190,13 @@ namespace MWWorld
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
|
const T *insertStatic(const T &x) {
|
|
|
|
|
std::ostringstream id;
|
|
|
|
|
id << "$dynamic" << mDynamicCount++;
|
|
|
|
|
|
|
|
|
|
Store<T> &store = const_cast<Store<T> &>(get<T>());
|
|
|
|
|
if (store.search(x.mId) != 0) {
|
|
|
|
|
if (store.search(id.str()) != 0) {
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
T record = x;
|
|
|
|
@ -225,17 +229,18 @@ namespace MWWorld
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
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")) {
|
|
|
|
|
return mNpcs.insert(npc);
|
|
|
|
|
} else if (mNpcs.search(npc.mId) != 0) {
|
|
|
|
|
} else if (mNpcs.search(id.str()) != 0) {
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
ESM::NPC record = npc;
|
|
|
|
|
|
|
|
|
|
std::ostringstream id;
|
|
|
|
|
id << "$dynamic" << mDynamicCount++;
|
|
|
|
|
record.mId = id.str();
|
|
|
|
|
|
|
|
|
|
ESM::NPC *ptr = mNpcs.insert(record);
|
|
|
|
|