From b8edd9bac33ad0f0c8f0701ebc8b020e5368ab51 Mon Sep 17 00:00:00 2001 From: Arthur Moore Date: Fri, 12 Dec 2014 01:48:57 -0500 Subject: [PATCH] Get a nif file's version string regardless of its length. --- components/nif/niffile.cpp | 4 ++-- components/nif/nifstream.cpp | 4 ++++ components/nif/nifstream.hpp | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index c689e27b3a..9a544f3c4e 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -131,9 +131,9 @@ void NIFFile::parse() NIFStream nif (this, Ogre::ResourceGroupManager::getSingleton().openResource(filename)); // Check the header string - std::string head = nif.getString(40); + std::string head = nif.getVersionString(); if(head.compare(0, 22, "NetImmerse File Format") != 0) - fail("Invalid NIF header"); + fail("Invalid NIF header: " + head); // Get BCD version ver = nif.getUInt(); diff --git a/components/nif/nifstream.cpp b/components/nif/nifstream.cpp index 878b6b75f7..e5699db7b9 100644 --- a/components/nif/nifstream.cpp +++ b/components/nif/nifstream.cpp @@ -101,6 +101,10 @@ std::string NIFStream::getString() size_t size = read_le32(); return getString(size); } +std::string NIFStream::getVersionString() +{ + return inp->getLine(); +} void NIFStream::getShorts(std::vector &vec, size_t size) { diff --git a/components/nif/nifstream.hpp b/components/nif/nifstream.hpp index 3d6a1319a8..cc14971fd5 100644 --- a/components/nif/nifstream.hpp +++ b/components/nif/nifstream.hpp @@ -81,6 +81,8 @@ public: std::string getString(size_t length); ///Read in a string of the length specified in the file std::string getString(); + ///This is special since the version string doesn't start with a number, and ends with "\n" + std::string getVersionString(); void getShorts(std::vector &vec, size_t size); void getFloats(std::vector &vec, size_t size);