From 41d6ccd3f60898e100f07e83a0ae5e739ad4e8c0 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Wed, 8 Feb 2023 14:34:10 +0300 Subject: [PATCH] Read NiDefaultAVObjectPalette --- components/nif/niffile.cpp | 1 + components/nif/node.cpp | 15 +++++++++++++++ components/nif/node.hpp | 11 +++++++++++ components/nif/record.hpp | 1 + 4 files changed, 28 insertions(+) diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 6a139d970e..fb3d92ff4f 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -174,6 +174,7 @@ namespace Nif { "NiAlphaAccumulator", &construct }, { "NiSequence", &construct }, { "NiControllerSequence", &construct }, + { "NiDefaultAVObjectPalette", &construct }, }; } diff --git a/components/nif/node.cpp b/components/nif/node.cpp index c4510658e9..f70304763f 100644 --- a/components/nif/node.cpp +++ b/components/nif/node.cpp @@ -291,4 +291,19 @@ namespace Nif else mMode = (flags >> 5) & 0x3; } + + void NiDefaultAVObjectPalette::read(NIFStream* nif) + { + mScene.read(nif); + size_t numObjects = nif->getUInt(); + for (size_t i = 0; i < numObjects; i++) + mObjects[nif->getSizedString()].read(nif); + } + + void NiDefaultAVObjectPalette::post(Reader& nif) + { + mScene.post(nif); + for (auto& object : mObjects) + object.second.post(nif); + } } diff --git a/components/nif/node.hpp b/components/nif/node.hpp index f41913cbe3..baee1fec66 100644 --- a/components/nif/node.hpp +++ b/components/nif/node.hpp @@ -1,6 +1,8 @@ #ifndef OPENMW_COMPONENTS_NIF_NODE_HPP #define OPENMW_COMPONENTS_NIF_NODE_HPP +#include + #include #include "base.hpp" @@ -273,5 +275,14 @@ namespace Nif void read(NIFStream* nif) override; }; + struct NiDefaultAVObjectPalette : Record + { + NodePtr mScene; + std::unordered_map mObjects; + + void read(NIFStream* nif) override; + void post(Reader& nif) override; + }; + } // Namespace #endif diff --git a/components/nif/record.hpp b/components/nif/record.hpp index ffa6801456..558066b8c6 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -151,6 +151,7 @@ namespace Nif RC_NiMultiTargetTransformController, RC_NiSequence, RC_NiControllerSequence, + RC_NiDefaultAVObjectPalette, }; /// Base class for all records