diff --git a/apps/openmw/mwlua/types/npc.cpp b/apps/openmw/mwlua/types/npc.cpp index 3aa84257bd..1905ac7c03 100644 --- a/apps/openmw/mwlua/types/npc.cpp +++ b/apps/openmw/mwlua/types/npc.cpp @@ -91,10 +91,10 @@ namespace npc.mNpdt.mDisposition = rec["baseDisposition"].get(); if (rec["baseGold"] != sol::nil) - npc.mNpdt.mGold = static_cast(rec["baseGold"]); + npc.mNpdt.mGold = rec["baseGold"].get(); if (rec["bloodType"] != sol::nil) - npc.mBloodType = static_cast(rec["bloodType"]); + npc.mBloodType = rec["bloodType"].get(); // Services offered if (rec["servicesOffered"] != sol::nil) diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index 80bcdb056a..0e64e6e627 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -269,13 +269,29 @@ namespace MWWorld list.push_back((*it)->mId); } } + template + inline bool shouldInsert(const IdType& id, const StaticMap& map) + { + auto it = map.find(id); + return it != map.end(); + } + + template + inline bool shouldInsert(const ESM::RefId& id, const StaticMap& map) + { + if (!id.template is()) + { + auto it = map.find(id); + return it != map.end(); + } + return true; + } template T* TypedDynamicStore::insert(const T& item, bool overrideOnly) { if (overrideOnly) { - auto it = mStatic.find(item.mId); - if (it == mStatic.end()) + if (!shouldInsert(item.mId, mStatic)) return nullptr; } std::pair result = mDynamic.insert_or_assign(item.mId, item);