diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index 60179f01b5..bf8d656ecd 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -166,6 +166,10 @@ namespace MWWorld { msg << T::getRecordType(); } + else + { + msg << "ESM::REC_" << getRecNameString(T::sRecordId).toStringView(); + } msg << " '" << id << "' not found"; throw std::runtime_error(msg.str()); } @@ -1164,6 +1168,20 @@ namespace MWWorld return mKeywordSearch; } + + ESM::FixedString<6> getRecNameString(ESM::RecNameInts recName) + { + ESM::FixedString<6> name; + name.assign(""); + ESM::NAME fourCCName(recName & ~ESM::sEsm4RecnameFlag); + for (int i = 0; i < 4; i++) + name.mData[i] = fourCCName.mData[i]; + if (ESM::isESM4Rec(recName)) + { + name.mData[4] = '4'; + } + return name; + } } template class MWWorld::TypedDynamicStore; diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index a6f869e362..6acfb6d41e 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -517,6 +517,8 @@ namespace MWWorld const MWDialogue::KeywordSearch& getDialogIdKeywordSearch() const; }; + ESM::FixedString<6> getRecNameString(ESM::RecNameInts recName); + } // end namespace #endif diff --git a/apps/openmw_test_suite/mwworld/test_store.cpp b/apps/openmw_test_suite/mwworld/test_store.cpp index 19363064f0..e8c4dbc8a7 100644 --- a/apps/openmw_test_suite/mwworld/test_store.cpp +++ b/apps/openmw_test_suite/mwworld/test_store.cpp @@ -315,11 +315,8 @@ static void testRecNameIntCount(const MWWorld::Store& store, const MWWorld::E { const unsigned int recordIdCount = std::apply([](auto&&... x) { return (hasSameRecordId(x, T::sRecordId) + ...); }, stores); - std::string RecordIdName(ESM::NAME(T::sRecordId & ~ESM::sEsm4RecnameFlag).toStringView()); - if (ESM::isESM4Rec(T::sRecordId)) - RecordIdName += '4'; - - ASSERT_EQ(recordIdCount, 1) << "The same RecNameInt is used twice ESM::REC_" << RecordIdName; + ASSERT_EQ(recordIdCount, 1) << "The same RecNameInt is used twice ESM::REC_" + << MWWorld::getRecNameString(T::sRecordId).toStringView(); } }