From aef6cd7006d1cf737b6c1ed0b66944de8b4b3caa Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Tue, 10 Mar 2020 22:44:50 +0300 Subject: [PATCH] Fix handling of empty strings in NIF string tables --- apps/openmw_test_suite/nifloader/testbulletnifloader.cpp | 2 +- components/nif/niffile.hpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp b/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp index 3044bf270..36f251246 100644 --- a/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp +++ b/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp @@ -266,7 +266,7 @@ namespace MOCK_CONST_METHOD0(numRecords, std::size_t ()); MOCK_CONST_METHOD1(getRoot, Nif::Record* (std::size_t)); MOCK_CONST_METHOD0(numRoots, std::size_t ()); - MOCK_CONST_METHOD1(getString, std::string (std::size_t)); + MOCK_CONST_METHOD1(getString, std::string (uint32_t)); MOCK_METHOD1(setUseSkinning, void (bool)); MOCK_CONST_METHOD0(getUseSkinning, bool ()); MOCK_CONST_METHOD0(getFilename, std::string ()); diff --git a/components/nif/niffile.hpp b/components/nif/niffile.hpp index e63a7ce73..4d5620a37 100644 --- a/components/nif/niffile.hpp +++ b/components/nif/niffile.hpp @@ -26,7 +26,7 @@ struct File virtual size_t numRoots() const = 0; - virtual std::string getString(size_t index) const = 0; + virtual std::string getString(uint32_t index) const = 0; virtual void setUseSkinning(bool skinning) = 0; @@ -129,8 +129,10 @@ public: size_t numRoots() const override { return roots.size(); } /// Get a given string from the file's string table - std::string getString(size_t index) const override + std::string getString(uint32_t index) const override { + if (index == std::numeric_limits::max()) + return std::string(); return strings.at(index); }