mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Improve null root handling
This commit is contained in:
parent
b10a817f7e
commit
19f0b80983
3 changed files with 12 additions and 8 deletions
|
@ -322,7 +322,7 @@ void NIFFile::parse(Files::IStreamPtr stream)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
roots[i] = nullptr;
|
roots[i] = nullptr;
|
||||||
warn("Null Root found");
|
warn("Root " + std::to_string(i + 1) + " does not point to a record: index " + std::to_string(idx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,12 +121,14 @@ osg::ref_ptr<Resource::BulletShape> BulletNifLoader::load(const Nif::File& nif)
|
||||||
mAvoidStaticMesh.reset();
|
mAvoidStaticMesh.reset();
|
||||||
|
|
||||||
const size_t numRoots = nif.numRoots();
|
const size_t numRoots = nif.numRoots();
|
||||||
std::vector<Nif::Node*> roots;
|
std::vector<const Nif::Node*> roots;
|
||||||
for (size_t i = 0; i < numRoots; ++i)
|
for (size_t i = 0; i < numRoots; ++i)
|
||||||
{
|
{
|
||||||
Nif::Record* r = nif.getRoot(i);
|
const Nif::Record* r = nif.getRoot(i);
|
||||||
assert(r != nullptr);
|
if (!r)
|
||||||
if (Nif::Node* node = dynamic_cast<Nif::Node*>(r))
|
continue;
|
||||||
|
const Nif::Node* node = dynamic_cast<const Nif::Node*>(r);
|
||||||
|
if (node)
|
||||||
roots.emplace_back(node);
|
roots.emplace_back(node);
|
||||||
}
|
}
|
||||||
const std::string filename = nif.getFilename();
|
const std::string filename = nif.getFilename();
|
||||||
|
|
|
@ -254,8 +254,7 @@ namespace NifOsg
|
||||||
for (size_t i = 0; i < numRoots; ++i)
|
for (size_t i = 0; i < numRoots; ++i)
|
||||||
{
|
{
|
||||||
const Nif::Record *r = nif->getRoot(i);
|
const Nif::Record *r = nif->getRoot(i);
|
||||||
assert(r != nullptr);
|
if (r && r->recType == Nif::RC_NiSequenceStreamHelper)
|
||||||
if (r->recType == Nif::RC_NiSequenceStreamHelper)
|
|
||||||
{
|
{
|
||||||
seq = static_cast<const Nif::NiSequenceStreamHelper*>(r);
|
seq = static_cast<const Nif::NiSequenceStreamHelper*>(r);
|
||||||
break;
|
break;
|
||||||
|
@ -312,7 +311,10 @@ namespace NifOsg
|
||||||
for (size_t i = 0; i < numRoots; ++i)
|
for (size_t i = 0; i < numRoots; ++i)
|
||||||
{
|
{
|
||||||
const Nif::Record* r = nif->getRoot(i);
|
const Nif::Record* r = nif->getRoot(i);
|
||||||
if (const Nif::Node* nifNode = dynamic_cast<const Nif::Node*>(r))
|
if (!r)
|
||||||
|
continue;
|
||||||
|
const Nif::Node* nifNode = dynamic_cast<const Nif::Node*>(r);
|
||||||
|
if (nifNode)
|
||||||
roots.emplace_back(nifNode);
|
roots.emplace_back(nifNode);
|
||||||
}
|
}
|
||||||
if (roots.empty())
|
if (roots.empty())
|
||||||
|
|
Loading…
Reference in a new issue