Maybe load FO4 armor records

macos_ci_fix
Alexei Kotov 1 year ago
parent db6f76fea8
commit aedcc28294

@ -35,9 +35,7 @@ void ESM4::Armor::load(ESM4::Reader& reader)
{
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
std::uint32_t esmVer = reader.esmVersion();
mIsFONV = esmVer == ESM::VER_132 || esmVer == ESM::VER_133 || esmVer == ESM::VER_134;
uint16_t currentIndex = 0xFFFF;
while (reader.getSubRecordHeader())
{
const ESM4::SubRecordHeader& subHdr = reader.subRecordHeader();
@ -51,32 +49,51 @@ void ESM4::Armor::load(ESM4::Reader& reader)
break;
case ESM4::SUB_DATA:
{
// if (reader.esmVersion() == ESM::VER_094 || reader.esmVersion() == ESM::VER_170)
if (subHdr.dataSize == 8) // FO3 has 12 bytes even though VER_094
// TES5
if (subHdr.dataSize == 8)
{
reader.get(mData.value);
reader.get(mData.weight);
mIsFO3 = true;
}
else if (mIsFONV || subHdr.dataSize == 12)
// FO3, FNV, FO4
else if (subHdr.dataSize == 12)
{
reader.get(mData.value);
reader.get(mData.health);
reader.get(mData.weight);
}
// TES4
else if (subHdr.dataSize == 14)
{
reader.get(mData);
}
else
{
reader.get(mData); // TES4
mIsTES4 = true;
reader.skipSubRecordData();
}
break;
}
case ESM4::SUB_MODL: // seems only for Dawnguard/Dragonborn?
case ESM4::SUB_INDX: // FO4
{
reader.get(currentIndex);
break;
}
case ESM4::SUB_MODL:
{
// if (esmVer == ESM::VER_094 || esmVer == ESM::VER_170 || isFONV)
if (subHdr.dataSize == 4) // FO3 has zstring even though VER_094
reader.getFormId(mAddOns.emplace_back());
if (subHdr.dataSize == 4)
{
// Assuming TES5
if (currentIndex == 0xFFFF)
reader.getFormId(mAddOns.emplace_back());
// FO4
else
{
if (mAddOns.size() <= currentIndex)
mAddOns.resize(currentIndex + 1);
reader.getFormId(mAddOns[currentIndex]);
}
}
else
{
if (!reader.getZString(mModelMale))
@ -135,10 +152,21 @@ void ESM4::Armor::load(ESM4::Reader& reader)
break;
}
case ESM4::SUB_BOD2:
reader.get(mArmorFlags);
reader.get(mGeneralFlags);
mGeneralFlags &= 0x0000000f; // 0 (light), 1 (heavy) or 2 (none)
mGeneralFlags |= TYPE_TES5;
// FO4, TES5
if (subHdr.dataSize == 4 || subHdr.dataSize == 8)
{
reader.get(mArmorFlags);
if (subHdr.dataSize == 8)
{
reader.get(mGeneralFlags);
mGeneralFlags &= 0x0000000f; // 0 (light), 1 (heavy) or 2 (none)
mGeneralFlags |= TYPE_TES5;
}
}
else
{
reader.skipSubRecordData();
}
break;
case ESM4::SUB_SCRI:
reader.getFormId(mScriptId);
@ -200,7 +228,15 @@ void ESM4::Armor::load(ESM4::Reader& reader)
case ESM4::SUB_DSTA:
case ESM4::SUB_DSTD:
case ESM4::SUB_DSTF: // Destructible end
case ESM4::SUB_APPR: // FO4
case ESM4::SUB_DAMA: // FO4
case ESM4::SUB_FNAM: // FO4
case ESM4::SUB_INRD: // FO4
case ESM4::SUB_PTRN: // FO4
case ESM4::SUB_OBTE: // FO4 object template start
case ESM4::SUB_OBTF:
case ESM4::SUB_OBTS:
case ESM4::SUB_STOP: // FO4 object template end
reader.skipSubRecordData();
break;
default:

@ -152,10 +152,6 @@ namespace ESM4
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
bool mIsTES4; // TODO: check that these match the general flags
bool mIsFO3;
bool mIsFONV;
std::string mEditorId;
std::string mFullName;
std::string mModelMale;

Loading…
Cancel
Save