diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index c3d5dd839b..49b28d7f14 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -210,21 +210,28 @@ namespace MWWorld template RecordId TypedDynamicStore::load(ESM::ESMReader& esm) { - T record; - bool isDeleted = false; if constexpr (!ESM::isESM4Rec(T::sRecordId)) { + T record; + bool isDeleted = false; record.load(esm, isDeleted); - } - std::pair inserted = mStatic.insert_or_assign(record.mId, record); - if (inserted.second) - mShared.push_back(&inserted.first->second); + std::pair inserted = mStatic.insert_or_assign(record.mId, record); + if (inserted.second) + mShared.push_back(&inserted.first->second); - if constexpr (std::is_same_v) - return RecordId(record.mId, isDeleted); + if constexpr (std::is_same_v) + return RecordId(record.mId, isDeleted); + else + return RecordId(); + } else - return RecordId(); + { + std::stringstream msg; + msg << "Can not load record of type ESM::REC_" << getRecNameString(T::sRecordId).toStringView() + << ": ESM::ESMReader can load only ESM3 records."; + throw std::runtime_error(msg.str()); + } } template