From 64a9f742da453b04824ce0b9af96919e11b7b9d6 Mon Sep 17 00:00:00 2001 From: "florent.teppe" Date: Tue, 3 Jan 2023 23:28:31 +0100 Subject: [PATCH] Improves check: throws an error that says which RecName is used twice. --- apps/openmw/mwworld/esmstore.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index d69d4e8804..29d014afd1 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -196,6 +196,28 @@ namespace MWWorld { }; + struct RecNameIntChar + { + char name[6]; + RecNameIntChar(ESM::RecNameInts recName) + { + unsigned int FourCC = recName & ~ESM::sEsm4RecnameFlag; // Removes the flag + name[0] = FourCC & 0xFF; + name[1] = (FourCC >> 8) & 0xFF; + name[2] = (FourCC >> 16) & 0xFF; + name[3] = (FourCC >> 24) & 0xFF; + if (ESM::isESM4Rec(recName)) + { + name[4] = '4'; + name[5] = '\0'; + } + else + { + name[4] = '\0'; + } + } + }; + template static bool typedReadRecordESM4(ESM4::Reader& reader, Store& store) { @@ -239,7 +261,11 @@ namespace MWWorld { const unsigned int recordIdCount = std::apply([](auto&&... x) { return (hasSameRecordId(x, T::sRecordId) + ...); }, stores); - assert(recordIdCount == 1); + if (recordIdCount != 1) + { + throw std::runtime_error( + "The same RecNameInt is used twice ESM::REC_" + std::string(RecNameIntChar(T::sRecordId).name)); + } } }