mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-07 05:15:34 +00:00
Merge branch 'save_safeguard' into 'master'
Add a safeguard to do not use uninitialized value See merge request OpenMW/openmw!3349
This commit is contained in:
commit
e5d5cbcdd1
1 changed files with 15 additions and 7 deletions
|
@ -355,18 +355,26 @@ namespace MWWorld
|
||||||
template <class T, class Id>
|
template <class T, class Id>
|
||||||
RecordId TypedDynamicStore<T, Id>::read(ESM::ESMReader& reader, bool overrideOnly)
|
RecordId TypedDynamicStore<T, Id>::read(ESM::ESMReader& reader, bool overrideOnly)
|
||||||
{
|
{
|
||||||
T record;
|
|
||||||
bool isDeleted = false;
|
|
||||||
if constexpr (!ESM::isESM4Rec(T::sRecordId))
|
if constexpr (!ESM::isESM4Rec(T::sRecordId))
|
||||||
{
|
{
|
||||||
|
T record;
|
||||||
|
bool isDeleted = false;
|
||||||
record.load(reader, isDeleted);
|
record.load(reader, isDeleted);
|
||||||
}
|
|
||||||
insert(record, overrideOnly);
|
|
||||||
|
|
||||||
if constexpr (std::is_same_v<Id, ESM::RefId>)
|
insert(record, overrideOnly);
|
||||||
return RecordId(record.mId, isDeleted);
|
|
||||||
|
if constexpr (std::is_same_v<Id, ESM::RefId>)
|
||||||
|
return RecordId(record.mId, isDeleted);
|
||||||
|
else
|
||||||
|
return RecordId();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return RecordId();
|
{
|
||||||
|
std::stringstream msg;
|
||||||
|
msg << "Can not load record of type ESM::REC_" << getRecNameString(T::sRecordId).toStringView()
|
||||||
|
<< ": ESM::ESMReader can load only ESM3 records.";
|
||||||
|
throw std::runtime_error(msg.str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LandTexture
|
// LandTexture
|
||||||
|
|
Loading…
Reference in a new issue