mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-28 22:09:42 +00:00
Update record pointer loading
This commit is contained in:
parent
6872c7144e
commit
878d4ddaa7
1 changed files with 8 additions and 6 deletions
|
@ -1,9 +1,10 @@
|
|||
#ifndef OPENMW_COMPONENTS_NIF_RECORDPTR_HPP
|
||||
#define OPENMW_COMPONENTS_NIF_RECORDPTR_HPP
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "niffile.hpp"
|
||||
#include "nifstream.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
|
@ -39,7 +40,7 @@ namespace Nif
|
|||
assert(index == -2);
|
||||
|
||||
// Store the index for later
|
||||
index = nif->getInt();
|
||||
index = nif->get<int32_t>();
|
||||
assert(index >= -1);
|
||||
}
|
||||
|
||||
|
@ -90,12 +91,13 @@ namespace Nif
|
|||
template <class T>
|
||||
void readRecordList(NIFStream* nif, RecordListT<T>& list)
|
||||
{
|
||||
const int length = nif->getInt();
|
||||
const std::uint32_t length = nif->get<std::uint32_t>();
|
||||
|
||||
if (length < 0)
|
||||
throw std::runtime_error("Negative NIF record list length: " + std::to_string(length));
|
||||
// No reasonable list can hit this generous limit
|
||||
if (length >= (1 << 24))
|
||||
throw std::runtime_error("Record list too long: " + std::to_string(length));
|
||||
|
||||
list.resize(static_cast<std::size_t>(length));
|
||||
list.resize(length);
|
||||
|
||||
for (auto& value : list)
|
||||
value.read(nif);
|
||||
|
|
Loading…
Reference in a new issue