mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-27 03:40:24 +00:00
Add option to disable debug log for unsupported nif files
It becomes quite extensive and not very useful when loading oblivion content files.
This commit is contained in:
parent
ac5f22445e
commit
2c43a8558a
6 changed files with 35 additions and 6 deletions
|
@ -98,7 +98,7 @@ void readVFS(std::unique_ptr<VFS::Archive>&& anArchive, const std::filesystem::p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parseOptions(int argc, char** argv, std::vector<Files::MaybeQuotedPath>& files)
|
bool parseOptions(int argc, char** argv, std::vector<Files::MaybeQuotedPath>& files, bool& writeDebugLog)
|
||||||
{
|
{
|
||||||
bpo::options_description desc(R"(Ensure that OpenMW can use the provided NIF and BSA files
|
bpo::options_description desc(R"(Ensure that OpenMW can use the provided NIF and BSA files
|
||||||
|
|
||||||
|
@ -109,6 +109,7 @@ Usages:
|
||||||
Allowed options)");
|
Allowed options)");
|
||||||
auto addOption = desc.add_options();
|
auto addOption = desc.add_options();
|
||||||
addOption("help,h", "print help message.");
|
addOption("help,h", "print help message.");
|
||||||
|
addOption("write-debug-log,v", "write debug log for unsupported nif files");
|
||||||
addOption("input-file", bpo::value<Files::MaybeQuotedPathContainer>(), "input file");
|
addOption("input-file", bpo::value<Files::MaybeQuotedPathContainer>(), "input file");
|
||||||
|
|
||||||
// Default option if none provided
|
// Default option if none provided
|
||||||
|
@ -126,6 +127,7 @@ Allowed options)");
|
||||||
std::cout << desc << std::endl;
|
std::cout << desc << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
writeDebugLog = variables.count("write-debug-log") > 0;
|
||||||
if (variables.count("input-file"))
|
if (variables.count("input-file"))
|
||||||
{
|
{
|
||||||
files = variables["input-file"].as<Files::MaybeQuotedPathContainer>();
|
files = variables["input-file"].as<Files::MaybeQuotedPathContainer>();
|
||||||
|
@ -146,10 +148,13 @@ Allowed options)");
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
std::vector<Files::MaybeQuotedPath> files;
|
std::vector<Files::MaybeQuotedPath> files;
|
||||||
if (!parseOptions(argc, argv, files))
|
bool writeDebugLog = false;
|
||||||
|
if (!parseOptions(argc, argv, files, writeDebugLog))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
Nif::Reader::setLoadUnsupportedFiles(true);
|
Nif::Reader::setLoadUnsupportedFiles(true);
|
||||||
|
Nif::Reader::setWriteNifDebugLog(writeDebugLog);
|
||||||
|
|
||||||
// std::cout << "Reading Files" << std::endl;
|
// std::cout << "Reading Files" << std::endl;
|
||||||
for (const auto& path : files)
|
for (const auto& path : files)
|
||||||
{
|
{
|
||||||
|
|
|
@ -600,6 +600,7 @@ namespace MWRender
|
||||||
NifOsg::Loader::setHiddenNodeMask(Mask_UpdateVisitor);
|
NifOsg::Loader::setHiddenNodeMask(Mask_UpdateVisitor);
|
||||||
NifOsg::Loader::setIntersectionDisabledNodeMask(Mask_Effect);
|
NifOsg::Loader::setIntersectionDisabledNodeMask(Mask_Effect);
|
||||||
Nif::Reader::setLoadUnsupportedFiles(Settings::Manager::getBool("load unsupported nif files", "Models"));
|
Nif::Reader::setLoadUnsupportedFiles(Settings::Manager::getBool("load unsupported nif files", "Models"));
|
||||||
|
Nif::Reader::setWriteNifDebugLog(Settings::Manager::getBool("write nif debug log", "Models"));
|
||||||
|
|
||||||
mStateUpdater->setFogEnd(mViewDistance);
|
mStateUpdater->setFogEnd(mViewDistance);
|
||||||
|
|
||||||
|
|
|
@ -220,13 +220,14 @@ namespace Nif
|
||||||
NIFFile::VER_MW,
|
NIFFile::VER_MW,
|
||||||
};
|
};
|
||||||
const bool supportedVersion = std::find(supportedVers.begin(), supportedVers.end(), ver) != supportedVers.end();
|
const bool supportedVersion = std::find(supportedVers.begin(), supportedVers.end(), ver) != supportedVers.end();
|
||||||
|
const bool writeDebugLog = sWriteNifDebugLog;
|
||||||
if (!supportedVersion)
|
if (!supportedVersion)
|
||||||
{
|
{
|
||||||
if (sLoadUnsupportedFiles)
|
if (!sLoadUnsupportedFiles)
|
||||||
|
throw Nif::Exception("Unsupported NIF version: " + printVersion(ver), filename);
|
||||||
|
if (writeDebugLog)
|
||||||
Log(Debug::Warning) << " NIFFile Warning: Unsupported NIF version: " << printVersion(ver)
|
Log(Debug::Warning) << " NIFFile Warning: Unsupported NIF version: " << printVersion(ver)
|
||||||
<< ". Proceed with caution! File: " << filename;
|
<< ". Proceed with caution! File: " << filename;
|
||||||
else
|
|
||||||
throw Nif::Exception("Unsupported NIF version: " + printVersion(ver), filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NIF data endianness
|
// NIF data endianness
|
||||||
|
@ -322,7 +323,7 @@ namespace Nif
|
||||||
|
|
||||||
r = entry->second();
|
r = entry->second();
|
||||||
|
|
||||||
if (!supportedVersion)
|
if (!supportedVersion && writeDebugLog)
|
||||||
Log(Debug::Verbose) << "NIF Debug: Reading record of type " << rec << ", index " << i << " ("
|
Log(Debug::Verbose) << "NIF Debug: Reading record of type " << rec << ", index " << i << " ("
|
||||||
<< filename << ")";
|
<< filename << ")";
|
||||||
|
|
||||||
|
@ -364,12 +365,18 @@ namespace Nif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::atomic_bool Reader::sLoadUnsupportedFiles = false;
|
std::atomic_bool Reader::sLoadUnsupportedFiles = false;
|
||||||
|
std::atomic_bool Reader::sWriteNifDebugLog = false;
|
||||||
|
|
||||||
void Reader::setLoadUnsupportedFiles(bool load)
|
void Reader::setLoadUnsupportedFiles(bool load)
|
||||||
{
|
{
|
||||||
sLoadUnsupportedFiles = load;
|
sLoadUnsupportedFiles = load;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Reader::setWriteNifDebugLog(bool value)
|
||||||
|
{
|
||||||
|
sWriteNifDebugLog = value;
|
||||||
|
}
|
||||||
|
|
||||||
std::string Reader::getString(std::uint32_t index) const
|
std::string Reader::getString(std::uint32_t index) const
|
||||||
{
|
{
|
||||||
if (index == std::numeric_limits<std::uint32_t>::max())
|
if (index == std::numeric_limits<std::uint32_t>::max())
|
||||||
|
|
|
@ -110,6 +110,7 @@ namespace Nif
|
||||||
bool& mUseSkinning;
|
bool& mUseSkinning;
|
||||||
|
|
||||||
static std::atomic_bool sLoadUnsupportedFiles;
|
static std::atomic_bool sLoadUnsupportedFiles;
|
||||||
|
static std::atomic_bool sWriteNifDebugLog;
|
||||||
|
|
||||||
/// Get the file's version in a human readable form
|
/// Get the file's version in a human readable form
|
||||||
///\returns A string containing a human readable NIF version number
|
///\returns A string containing a human readable NIF version number
|
||||||
|
@ -145,6 +146,8 @@ namespace Nif
|
||||||
unsigned int getBethVersion() const { return bethVer; }
|
unsigned int getBethVersion() const { return bethVer; }
|
||||||
|
|
||||||
static void setLoadUnsupportedFiles(bool load);
|
static void setLoadUnsupportedFiles(bool load);
|
||||||
|
|
||||||
|
static void setWriteNifDebugLog(bool load);
|
||||||
};
|
};
|
||||||
using NIFFilePtr = std::shared_ptr<const Nif::NIFFile>;
|
using NIFFilePtr = std::shared_ptr<const Nif::NIFFile>;
|
||||||
|
|
||||||
|
|
|
@ -263,3 +263,13 @@ weatherblizzard
|
||||||
Path to the file used for the blizzard clouds weather effect in Morrowind.
|
Path to the file used for the blizzard clouds weather effect in Morrowind.
|
||||||
OpenMW doesn't use this file, instead it renders a similar looking particle
|
OpenMW doesn't use this file, instead it renders a similar looking particle
|
||||||
effect. Changing this won't have any effect.
|
effect. Changing this won't have any effect.
|
||||||
|
|
||||||
|
write nif debug log
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
:Type: boolean
|
||||||
|
:Range: True/False
|
||||||
|
:Default: True
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
|
@ -1116,6 +1116,9 @@ weathersnow = meshes/snow.nif
|
||||||
# Blizzard weather effect
|
# Blizzard weather effect
|
||||||
weatherblizzard = meshes/blizzard.nif
|
weatherblizzard = meshes/blizzard.nif
|
||||||
|
|
||||||
|
# Enable to write logs when loading unsupported nif file
|
||||||
|
write nif debug log = true
|
||||||
|
|
||||||
[Groundcover]
|
[Groundcover]
|
||||||
|
|
||||||
# enable separate groundcover handling
|
# enable separate groundcover handling
|
||||||
|
|
Loading…
Reference in a new issue