mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 17:49:41 +00:00
Print a NIF file's version information when an error occurs
This commit is contained in:
parent
9ebf3f2f10
commit
5abed1c32a
2 changed files with 24 additions and 4 deletions
|
@ -109,6 +109,23 @@ static std::map<std::string,RecordFactoryEntry> makeFactory()
|
||||||
///Make the factory map used for parsing the file
|
///Make the factory map used for parsing the file
|
||||||
static const std::map<std::string,RecordFactoryEntry> factories = makeFactory();
|
static const std::map<std::string,RecordFactoryEntry> factories = makeFactory();
|
||||||
|
|
||||||
|
/// Get the file's version in a human readable form
|
||||||
|
std::string NIFFile::printVersion(unsigned int version)
|
||||||
|
{
|
||||||
|
union ver_quad
|
||||||
|
{
|
||||||
|
uint32_t full;
|
||||||
|
uint8_t quad[4];
|
||||||
|
} version_out;
|
||||||
|
|
||||||
|
version_out.full = version;
|
||||||
|
|
||||||
|
return Ogre::StringConverter::toString(version_out.quad[3])
|
||||||
|
+"." + Ogre::StringConverter::toString(version_out.quad[2])
|
||||||
|
+"." + Ogre::StringConverter::toString(version_out.quad[1])
|
||||||
|
+"." + Ogre::StringConverter::toString(version_out.quad[0]);
|
||||||
|
}
|
||||||
|
|
||||||
void NIFFile::parse()
|
void NIFFile::parse()
|
||||||
{
|
{
|
||||||
NIFStream nif (this, Ogre::ResourceGroupManager::getSingleton().openResource(filename));
|
NIFStream nif (this, Ogre::ResourceGroupManager::getSingleton().openResource(filename));
|
||||||
|
@ -119,10 +136,9 @@ void NIFFile::parse()
|
||||||
fail("Invalid NIF header");
|
fail("Invalid NIF header");
|
||||||
|
|
||||||
// Get BCD version
|
// Get BCD version
|
||||||
ver = nif.getInt();
|
ver = nif.getUInt();
|
||||||
if(ver != VER_MW)
|
if(ver != VER_MW)
|
||||||
fail("Unsupported NIF version");
|
fail("Unsupported NIF version: " + printVersion(ver));
|
||||||
|
|
||||||
// Number of records
|
// Number of records
|
||||||
size_t recNum = nif.getInt();
|
size_t recNum = nif.getInt();
|
||||||
records.resize(recNum);
|
records.resize(recNum);
|
||||||
|
|
|
@ -19,7 +19,7 @@ class NIFFile
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Nif file version
|
/// Nif file version
|
||||||
int ver;
|
unsigned int ver;
|
||||||
|
|
||||||
/// File name, used for error messages and opening the file
|
/// File name, used for error messages and opening the file
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
@ -33,6 +33,10 @@ class NIFFile
|
||||||
/// Parse the file
|
/// Parse the file
|
||||||
void parse();
|
void parse();
|
||||||
|
|
||||||
|
/// Get the file's version in a human readable form
|
||||||
|
///\returns A string containing a human readable NIF version number
|
||||||
|
std::string printVersion(unsigned int version);
|
||||||
|
|
||||||
///Private Copy Constructor
|
///Private Copy Constructor
|
||||||
NIFFile (NIFFile const &);
|
NIFFile (NIFFile const &);
|
||||||
///\overload
|
///\overload
|
||||||
|
|
Loading…
Reference in a new issue