diff --git a/apps/esmtool/tes4.cpp b/apps/esmtool/tes4.cpp index 815eb6dd34..2959b8145a 100644 --- a/apps/esmtool/tes4.cpp +++ b/apps/esmtool/tes4.cpp @@ -62,6 +62,24 @@ namespace EsmTool template constexpr bool hasFlags = HasFlags::value; + template > + struct HasEditorId : std::false_type {}; + + template + struct HasEditorId> : std::true_type {}; + + template + constexpr bool hasEditorId = HasEditorId::value; + + template > + struct HasModel : std::false_type {}; + + template + struct HasModel> : std::true_type {}; + + template + constexpr bool hasModel = HasModel::value; + template void readTypedRecord(const Params& params, ESM4::Reader& reader) { @@ -75,9 +93,13 @@ namespace EsmTool std::cout << "\n Record: " << ESM::NAME(reader.hdr().record.typeId).toStringView(); if constexpr (hasFormId) - std::cout << ' ' << value.mFormId; + std::cout << "\n FormId: " << value.mFormId; if constexpr (hasFlags) std::cout << "\n Record flags: " << recordFlags(value.mFlags); + if constexpr (hasEditorId) + std::cout << "\n EditorId: " << value.mEditorId; + if constexpr (hasModel) + std::cout << "\n Model: " << value.mModel; std::cout << '\n'; } diff --git a/components/esm4/reader.cpp b/components/esm4/reader.cpp index 450b86de0d..cc13f5db97 100644 --- a/components/esm4/reader.cpp +++ b/components/esm4/reader.cpp @@ -652,7 +652,12 @@ bool Reader::getStringImpl(std::string& str, std::size_t size, stream.read(input.data(), size); if (stream.gcount() == static_cast(size)) { - encoder->getUtf8(input, ToUTF8::BufferAllocationPolicy::FitToRequiredSize, str); + const std::string_view result = encoder->getUtf8(input, ToUTF8::BufferAllocationPolicy::FitToRequiredSize, str); + if (str.empty() && !result.empty()) + { + str = std::move(input); + str.resize(result.size()); + } return true; } }