From 117697ea227933cf8c3a6c4b784bc8d659991559 Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov Date: Sat, 14 Nov 2020 01:12:32 +0300 Subject: [PATCH] Fix NiStringPalette loading --- components/nif/data.cpp | 16 ++-------------- components/nif/data.hpp | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/components/nif/data.cpp b/components/nif/data.cpp index 1eb5c40fe..235825e4a 100644 --- a/components/nif/data.cpp +++ b/components/nif/data.cpp @@ -460,21 +460,9 @@ void NiPalette::read(NIFStream *nif) void NiStringPalette::read(NIFStream *nif) { - unsigned int size = nif->getUInt(); - if (!size) - return; - std::vector source; - nif->getChars(source, size); - if (nif->getUInt() != size) + palette = nif->getString(); + if (nif->getUInt() != palette.size()) nif->file->warn("Failed size check in NiStringPalette"); - if (source[source.size()-1] != '\0') - source.emplace_back('\0'); - const char* buffer = source.data(); - while (static_cast(buffer - source.data()) < source.size()) - { - palette.emplace_back(buffer); - buffer += palette.back().size() + 1; - } } void NiBoolData::read(NIFStream *nif) diff --git a/components/nif/data.hpp b/components/nif/data.hpp index 4d13afb9d..35f329573 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -262,7 +262,7 @@ public: struct NiStringPalette : public Record { - std::vector palette; + std::string palette; void read(NIFStream *nif) override; };