diff --git a/apps/niftest/niftest.cpp b/apps/niftest/niftest.cpp index 75cf5772d9..9f3f8066c6 100644 --- a/apps/niftest/niftest.cpp +++ b/apps/niftest/niftest.cpp @@ -98,7 +98,7 @@ void readVFS(std::unique_ptr&& anArchive, const std::filesystem::p } } -bool parseOptions(int argc, char** argv, std::vector& files) +bool parseOptions(int argc, char** argv, std::vector& files, bool& writeDebugLog) { bpo::options_description desc(R"(Ensure that OpenMW can use the provided NIF and BSA files @@ -109,6 +109,7 @@ Usages: Allowed options)"); auto addOption = desc.add_options(); addOption("help,h", "print help message."); + addOption("write-debug-log,v", "write debug log for unsupported nif files"); addOption("input-file", bpo::value(), "input file"); // Default option if none provided @@ -126,6 +127,7 @@ Allowed options)"); std::cout << desc << std::endl; return false; } + writeDebugLog = variables.count("write-debug-log") > 0; if (variables.count("input-file")) { files = variables["input-file"].as(); @@ -146,10 +148,13 @@ Allowed options)"); int main(int argc, char** argv) { std::vector files; - if (!parseOptions(argc, argv, files)) + bool writeDebugLog = false; + if (!parseOptions(argc, argv, files, writeDebugLog)) return 1; Nif::Reader::setLoadUnsupportedFiles(true); + Nif::Reader::setWriteNifDebugLog(writeDebugLog); + // std::cout << "Reading Files" << std::endl; for (const auto& path : files) { diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 130ad577ce..f226b089f4 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -600,6 +600,7 @@ namespace MWRender NifOsg::Loader::setHiddenNodeMask(Mask_UpdateVisitor); NifOsg::Loader::setIntersectionDisabledNodeMask(Mask_Effect); 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); diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index fb3d92ff4f..2da28bb5d9 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -220,13 +220,14 @@ namespace Nif NIFFile::VER_MW, }; const bool supportedVersion = std::find(supportedVers.begin(), supportedVers.end(), ver) != supportedVers.end(); + const bool writeDebugLog = sWriteNifDebugLog; 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) << ". Proceed with caution! File: " << filename; - else - throw Nif::Exception("Unsupported NIF version: " + printVersion(ver), filename); } // NIF data endianness @@ -322,7 +323,7 @@ namespace Nif r = entry->second(); - if (!supportedVersion) + if (!supportedVersion && writeDebugLog) Log(Debug::Verbose) << "NIF Debug: Reading record of type " << rec << ", index " << i << " (" << filename << ")"; @@ -364,12 +365,18 @@ namespace Nif } std::atomic_bool Reader::sLoadUnsupportedFiles = false; + std::atomic_bool Reader::sWriteNifDebugLog = false; void Reader::setLoadUnsupportedFiles(bool load) { sLoadUnsupportedFiles = load; } + void Reader::setWriteNifDebugLog(bool value) + { + sWriteNifDebugLog = value; + } + std::string Reader::getString(std::uint32_t index) const { if (index == std::numeric_limits::max()) diff --git a/components/nif/niffile.hpp b/components/nif/niffile.hpp index 5f5f112eaf..f2adb698d0 100644 --- a/components/nif/niffile.hpp +++ b/components/nif/niffile.hpp @@ -110,6 +110,7 @@ namespace Nif bool& mUseSkinning; static std::atomic_bool sLoadUnsupportedFiles; + static std::atomic_bool sWriteNifDebugLog; /// Get the file's version in a human readable form ///\returns A string containing a human readable NIF version number @@ -145,6 +146,8 @@ namespace Nif unsigned int getBethVersion() const { return bethVer; } static void setLoadUnsupportedFiles(bool load); + + static void setWriteNifDebugLog(bool load); }; using NIFFilePtr = std::shared_ptr; diff --git a/docs/source/reference/modding/settings/models.rst b/docs/source/reference/modding/settings/models.rst index b870268567..998be9e6ea 100644 --- a/docs/source/reference/modding/settings/models.rst +++ b/docs/source/reference/modding/settings/models.rst @@ -263,3 +263,13 @@ weatherblizzard 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 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. diff --git a/files/settings-default.cfg b/files/settings-default.cfg index e052aefcf2..fe93e019bf 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -1116,6 +1116,9 @@ 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 + [Groundcover] # enable separate groundcover handling