mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 07:45:39 +00:00
Revamp NIF debug logging
Disabled by default Extend it to supported files Log more version info Reduce noise
This commit is contained in:
parent
3bf5b150c5
commit
99024d3826
3 changed files with 24 additions and 17 deletions
|
@ -512,6 +512,10 @@ namespace Nif
|
|||
|
||||
void Reader::parse(Files::IStreamPtr&& stream)
|
||||
{
|
||||
const bool writeDebug = sWriteNifDebugLog;
|
||||
if (writeDebug)
|
||||
Log(Debug::Verbose) << "NIF Debug: Reading file: '" << mFilename << "'";
|
||||
|
||||
const std::array<std::uint64_t, 2> fileHash = Files::getHash(mFilename, *stream);
|
||||
mHash.append(reinterpret_cast<const char*>(fileHash.data()), fileHash.size() * sizeof(std::uint64_t));
|
||||
|
||||
|
@ -538,15 +542,9 @@ namespace Nif
|
|||
};
|
||||
const bool supportedVersion
|
||||
= std::find(supportedVers.begin(), supportedVers.end(), mVersion) != supportedVers.end();
|
||||
const bool writeDebugLog = sWriteNifDebugLog;
|
||||
if (!supportedVersion)
|
||||
{
|
||||
if (!sLoadUnsupportedFiles)
|
||||
throw Nif::Exception("Unsupported NIF version: " + versionToString(mVersion), mFilename);
|
||||
if (writeDebugLog)
|
||||
Log(Debug::Warning) << " NIFFile Warning: Unsupported NIF version: " << versionToString(mVersion)
|
||||
<< ". Proceed with caution! File: " << mFilename;
|
||||
}
|
||||
|
||||
if (!supportedVersion && !sLoadUnsupportedFiles)
|
||||
throw Nif::Exception("Unsupported NIF version: " + versionToString(mVersion), mFilename);
|
||||
|
||||
const bool hasEndianness = mVersion >= NIFStream::generateVersion(20, 0, 0, 4);
|
||||
const bool hasUserVersion = mVersion >= NIFStream::generateVersion(10, 0, 1, 8);
|
||||
|
@ -603,6 +601,17 @@ namespace Nif
|
|||
}
|
||||
}
|
||||
|
||||
if (writeDebug)
|
||||
{
|
||||
std::stringstream versionInfo;
|
||||
versionInfo << "NIF Debug: Version: " << versionToString(mVersion);
|
||||
if (mUserVersion)
|
||||
versionInfo << "\nUser version: " << mUserVersion;
|
||||
if (mBethVersion)
|
||||
versionInfo << "\nBSStream version: " << mBethVersion;
|
||||
Log(Debug::Verbose) << versionInfo.str();
|
||||
}
|
||||
|
||||
if (hasRecTypeListings)
|
||||
{
|
||||
// TODO: 20.3.1.2 uses DJB hashes instead of strings
|
||||
|
@ -658,9 +667,8 @@ namespace Nif
|
|||
|
||||
r = entry->second();
|
||||
|
||||
if (!supportedVersion && writeDebugLog)
|
||||
Log(Debug::Verbose) << "NIF Debug: Reading record of type " << rec << ", index " << i << " ("
|
||||
<< mFilename << ")";
|
||||
if (writeDebug)
|
||||
Log(Debug::Verbose) << "NIF Debug: Reading record of type " << rec << ", index " << i;
|
||||
|
||||
assert(r != nullptr);
|
||||
assert(r->recType != RC_MISSING);
|
||||
|
|
|
@ -269,7 +269,6 @@ write nif debug log
|
|||
|
||||
:Type: boolean
|
||||
:Range: True/False
|
||||
:Default: True
|
||||
:Default: False
|
||||
|
||||
If enabled, log the loading process of unsupported NIF files.
|
||||
:ref:`load unsupported nif files` setting must be enabled for this setting to have any effect.
|
||||
If enabled, log the loading process of NIF files.
|
||||
|
|
|
@ -1136,8 +1136,8 @@ weathersnow = meshes/snow.nif
|
|||
# Blizzard weather effect
|
||||
weatherblizzard = meshes/blizzard.nif
|
||||
|
||||
# Enable to write logs when loading unsupported nif file
|
||||
write nif debug log = true
|
||||
# Enable to write logs when loading NIF files
|
||||
write nif debug log = false
|
||||
|
||||
[Groundcover]
|
||||
|
||||
|
|
Loading…
Reference in a new issue