Refactor components/esm4

macos_ci_fix
Petr Mikheev 1 year ago
parent e6cffa5494
commit 5d54ca6fdb

@ -9,6 +9,7 @@
#include <components/debug/writeflags.hpp>
#include <components/esm/esmcommon.hpp>
#include <components/esm/refid.hpp>
#include <components/esm/typetraits.hpp>
#include <components/esm4/reader.hpp>
#include <components/esm4/readerutils.hpp>
@ -145,19 +146,15 @@ namespace EsmTool
return;
std::cout << "\n Record: " << ESM::NAME(reader.hdr().record.typeId).toStringView();
if constexpr (ESM4::hasFormId<T>)
std::cout << "\n FormId: 0x" << ESM4::formIdToString(value.mFormId);
if constexpr (ESM::hasId<T>)
{
if constexpr (std::is_same_v<decltype(value.mId), ESM4::FormId>)
std::cout << "\n FormId: 0x" << ESM4::formIdToString(value.mId);
if constexpr (std::is_same_v<decltype(value.mId), ESM::FormId>)
std::cout << "\n " << ESM::RefId(value.mId);
else
std::cout << "\n Id: " << value.mId;
}
if constexpr (ESM4::hasFlags<T>)
std::cout << "\n Record flags: " << recordFlags(value.mFlags);
if constexpr (ESM4::hasParentFormId<T>)
std::cout << "\n ParentFormId: 0x" << ESM4::formIdToString(value.mParentFormId);
if constexpr (ESM4::hasParent<T>)
std::cout << "\n Parent: " << value.mParent;
if constexpr (ESM4::hasEditorId<T>)

@ -127,7 +127,7 @@ namespace MWLua
const std::vector<std::string>& contentList = MWBase::Environment::get().getWorld()->getContentFiles();
for (size_t i = 0; i < contentList.size(); ++i)
if (Misc::StringUtils::ciEqual(contentList[i], contentFile))
return ESM::RefId(ESM::FormIdRefId(ESM::FormId{ index, int(i) })).serializeText();
return ESM::RefId(ESM::FormId{ index, int(i) }).serializeText();
throw std::runtime_error("Content file not found: " + std::string(contentFile));
};
addTimeBindings(api, context, false);

@ -100,10 +100,11 @@ namespace MWLua
addRecordFunctionBinding<ESM4::Door>(door, context, "ESM4Door");
sol::usertype<ESM4::Door> record = context.mLua->sol().new_usertype<ESM4::Door>("ESM4_Door");
record[sol::meta_function::to_string]
= [](const ESM4::Door& rec) -> std::string { return "ESM4_Door[" + rec.mId.toDebugString() + "]"; };
record["id"]
= sol::readonly_property([](const ESM4::Door& rec) -> std::string { return rec.mId.serializeText(); });
record[sol::meta_function::to_string] = [](const ESM4::Door& rec) -> std::string {
return "ESM4_Door[" + ESM::RefId(rec.mId).toDebugString() + "]";
};
record["id"] = sol::readonly_property(
[](const ESM4::Door& rec) -> std::string { return ESM::RefId(rec.mId).serializeText(); });
record["name"] = sol::readonly_property([](const ESM4::Door& rec) -> std::string { return rec.mFullName; });
record["model"] = sol::readonly_property([vfs](const ESM4::Door& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);

@ -21,7 +21,7 @@ namespace MWWorld
if (!value.mEditorId.empty())
return value.mEditorId;
return value.mId.serializeText();
return ESM::RefId(value.mId).serializeText();
}
std::string getCellDescription(const ESM4::Cell& cell, const ESM4::World* world)

@ -125,13 +125,7 @@ namespace MWWorld
// The NPC that owns this object (and will get angry if you steal it)
ESM::RefId getOwner() const
{
struct Visitor
{
ESM::RefId operator()(const ESM::CellRef& ref) { return ref.mOwner; }
ESM::RefId operator()(const ESM4::Reference& ref) { return ESM::RefId::formIdRefId(ref.mOwner); }
ESM::RefId operator()(const ESM4::ActorCharacter& ref) { return ESM::RefId::formIdRefId(ref.mOwner); }
};
return std::visit(Visitor(), mCellRef.mVariant);
return std::visit([](auto&& ref) -> ESM::RefId { return ref.mOwner; }, mCellRef.mVariant);
}
void setOwner(const ESM::RefId& owner);

@ -172,7 +172,7 @@ namespace MWWorld
if (!mShared.empty())
return mShared[Misc::Rng::rollDice(mShared.size(), prng)];
}
else
else if constexpr (!std::is_same_v<decltype(T::mId), ESM::FormId>)
{
std::vector<const T*> results;
std::copy_if(mShared.begin(), mShared.end(), std::back_inserter(results),

@ -711,7 +711,7 @@ namespace MWWorld
if (!activeOnly)
{
ret = mWorldModel.getPtr(name);
ret = mWorldModel.getPtrByRefId(name);
if (!ret.isEmpty())
return ret;
}

@ -342,7 +342,7 @@ namespace MWWorld
}
}
MWWorld::Ptr MWWorld::WorldModel::getPtr(const ESM::RefId& name)
MWWorld::Ptr MWWorld::WorldModel::getPtrByRefId(const ESM::RefId& name)
{
for (const auto& [cachedId, cellStore] : mIdCache)
{

@ -65,7 +65,7 @@ namespace MWWorld
CellStore& getCell(std::string_view name, bool forceLoad = true) const;
Ptr getPtr(const ESM::RefId& name);
Ptr getPtrByRefId(const ESM::RefId& name);
Ptr getPtr(ESM::RefNum refNum) const { return mPtrRegistry.getOrEmpty(refNum); }

@ -208,11 +208,12 @@ namespace ESM
EXPECT_EQ(map.count(RefId::stringRefId("A")), 1);
}
TEST(ESMRefIdTest, stringRefIdIsNotEqualToFormId)
TEST(ESMRefIdTest, emptyRefId)
{
const RefId stringRefId = RefId::stringRefId("\0");
const RefId formIdRefId = RefId::formIdRefId({ .mIndex = 0, .mContentFile = 0 });
EXPECT_NE(stringRefId, formIdRefId);
EXPECT_EQ(RefId(), EmptyRefId());
EXPECT_EQ(RefId(), RefId::stringRefId("\0"));
EXPECT_EQ(RefId(), RefId::formIdRefId({ .mIndex = 0, .mContentFile = 0 }));
EXPECT_EQ(RefId(), RefId::formIdRefId({ .mIndex = 0, .mContentFile = -1 }));
}
TEST(ESMRefIdTest, indexRefIdHashDiffersForDistinctValues)
@ -337,7 +338,6 @@ namespace ESM
{ RefId::stringRefId("foo"), "foo" },
{ RefId::stringRefId("BAR"), "bar" },
{ RefId::stringRefId(std::string({ 'a', 0, -1, '\n', '\t' })), { 'a', 0, -1, '\n', '\t' } },
{ RefId::formIdRefId({ .mIndex = 0, .mContentFile = 0 }), "FormId:0x0" },
{ RefId::formIdRefId({ .mIndex = 1, .mContentFile = 0 }), "FormId:0x1" },
{ RefId::formIdRefId({ .mIndex = 0x1f, .mContentFile = 0 }), "FormId:0x1f" },
{ RefId::formIdRefId({ .mIndex = 0x1f, .mContentFile = 2 }), "FormId:0x200001f" },

@ -2,7 +2,6 @@
#include <components/esm4/common.hpp>
#include <components/esm4/dialogue.hpp>
#include <components/esm4/effect.hpp>
#include <components/esm4/formid.hpp>
#include <components/esm4/inventory.hpp>
#include <components/esm4/lighting.hpp>
#include <components/esm4/loadachr.hpp>

@ -155,7 +155,6 @@ add_component_dir (esm4
common
dialogue
effect
formid
grid
grouptype
inventory

@ -15,15 +15,15 @@ namespace ESM
uint32_t mIndex = 0;
int32_t mContentFile = -1;
bool hasContentFile() const { return mContentFile >= 0; }
bool isSet() const { return mIndex != 0 || mContentFile != -1; }
constexpr bool hasContentFile() const { return mContentFile >= 0; }
constexpr bool isSet() const { return mIndex != 0 || mContentFile != -1; }
// Zero is used in ESM4 as a null reference
bool isZeroOrUnset() const { return mIndex == 0 && (mContentFile == 0 || mContentFile == -1); }
constexpr bool isZeroOrUnset() const { return mIndex == 0 && (mContentFile == 0 || mContentFile == -1); }
std::string toString() const;
FormId32 toUint32() const;
static FormId fromUint32(FormId32 v) { return { v & 0xffffff, static_cast<int32_t>(v >> 24) }; }
static constexpr FormId fromUint32(FormId32 v) { return { v & 0xffffff, static_cast<int32_t>(v >> 24) }; }
};
inline constexpr bool operator==(const FormId& left, const FormId& right)

@ -227,7 +227,7 @@ namespace ESM
uint64_t v = deserializeHexIntegral<uint64_t>(formIdRefIdPrefix.size(), value);
uint32_t index = static_cast<uint32_t>(v) & 0xffffff;
int contentFile = static_cast<int>(v >> 24);
return ESM::RefId::formIdRefId({ index, contentFile });
return ESM::FormId{ index, contentFile };
}
if (value.starts_with(generatedRefIdPrefix))

@ -61,7 +61,7 @@ namespace ESM
static RefId stringRefId(std::string_view value);
// Constructs RefId from FormId storing the value in-place.
static RefId formIdRefId(FormId value) { return RefId(FormIdRefId(value)); }
static RefId formIdRefId(FormId value) { return RefId(value); }
// Constructs RefId from uint64 storing the value in-place. Should be used for generated records where id is a
// global counter.
@ -90,6 +90,14 @@ namespace ESM
{
}
constexpr RefId(FormId value)
{
if (value.isZeroOrUnset())
mValue = EmptyRefId();
else
mValue = FormIdRefId(value);
}
constexpr RefId(GeneratedRefId value) noexcept
: mValue(value)
{

@ -29,7 +29,7 @@
#include <cstdint>
#include "formid.hpp"
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -109,7 +109,7 @@ namespace ESM4
struct ActorFaction
{
FormId32 faction;
ESM::FormId32 faction;
std::int8_t rank;
std::uint8_t unknown1;
std::uint8_t unknown2;

@ -29,8 +29,8 @@
#include <variant>
#include "formid.hpp"
#include "grid.hpp"
#include <components/esm/formid.hpp>
namespace ESM4
{

@ -29,7 +29,7 @@
#include <cstdint>
#include "formid.hpp"
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -42,7 +42,7 @@ namespace ESM4
struct ScriptEffect
{
FormId32 formId; // Script effect (Magic effect must be SEFF)
ESM::FormId32 formId; // Script effect (Magic effect must be SEFF)
std::int32_t school; // Magic school. See Magic schools for more information.
EFI_Label visualEffect; // Visual effect name or 0x00000000 if None
std::uint8_t flags; // 0x01 = Hostile

@ -1,41 +0,0 @@
/*
Copyright (C) 2016, 2020-2021 cc9cii
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
cc9cii cc9c@iinet.net.au
*/
#include "formid.hpp"
#include <stdexcept>
#include <string>
namespace ESM4
{
std::string formIdToString(const FormId& formId)
{
std::string str;
char buf[8 + 1];
int res = snprintf(buf, 8 + 1, "%08X", formId.toUint32());
if (res > 0 && res < 8 + 1)
str.assign(buf);
else
throw std::runtime_error("Possible buffer overflow while converting formId");
return str;
}
}

@ -1,37 +0,0 @@
/*
Copyright (C) 2016 cc9cii
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
cc9cii cc9c@iinet.net.au
*/
#ifndef ESM4_FORMID_H
#define ESM4_FORMID_H
#include <string>
#include <components/esm/formid.hpp>
namespace ESM4
{
using FormId = ESM::FormId;
using FormId32 = uint32_t;
std::string formIdToString(const FormId& formId);
}
#endif // ESM4_FORMID_H

@ -29,7 +29,7 @@
#include <cstdint>
#include "formid.hpp"
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -39,14 +39,14 @@ namespace ESM4
{
std::int16_t level;
std::uint16_t unknown; // sometimes missing
FormId32 item;
ESM::FormId32 item;
std::int16_t count;
std::uint16_t unknown2; // sometimes missing
};
struct InventoryItem // NPC_, CREA, CONT
{
FormId32 item;
ESM::FormId32 item;
std::uint32_t count;
};
#pragma pack(pop)

@ -33,10 +33,9 @@
void ESM4::ActorCharacter::load(ESM4::Reader& reader)
{
mId = reader.hdr().record.getFormId();
reader.adjustFormId(mId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
mParent = ESM::RefId::formIdRefId(reader.currCell());
mParent = reader.currCell();
while (reader.getSubRecordHeader())
{
@ -50,12 +49,8 @@ void ESM4::ActorCharacter::load(ESM4::Reader& reader)
reader.getZString(mFullName);
break;
case ESM4::SUB_NAME:
{
FormId baseId;
reader.getFormId(baseId);
mBaseObj = ESM::RefId::formIdRefId(baseId);
reader.getFormId(mBaseObj);
break;
}
case ESM4::SUB_DATA:
reader.get(mPos);
break;

@ -32,7 +32,7 @@
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "reference.hpp" // FormId, Placement, EnableParent
#include "reference.hpp" // Placement, EnableParent
namespace ESM4
{
@ -48,7 +48,7 @@ namespace ESM4
std::string mEditorId;
std::string mFullName;
ESM::RefId mBaseObj;
ESM::FormId mBaseObj;
ESM::Position mPos;
float mScale = 1.0f;

@ -33,7 +33,7 @@
void ESM4::Activator::load(ESM4::Reader& reader)
{
mId = reader.getRefIdFromHeader();
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -31,9 +31,7 @@
#include <string>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "formid.hpp"
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -42,21 +40,21 @@ namespace ESM4
struct Activator
{
ESM::RefId mId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
std::string mFullName;
std::string mModel;
FormId mScriptId;
FormId mLoopingSound; // SOUN
FormId mActivationSound; // SOUN
ESM::FormId mScriptId;
ESM::FormId mLoopingSound; // SOUN
ESM::FormId mActivationSound; // SOUN
float mBoundRadius;
FormId mRadioTemplate; // SOUN
FormId mRadioStation; // TACT
ESM::FormId mRadioTemplate; // SOUN
ESM::FormId mRadioStation; // TACT
std::string mActivationPrompt;

@ -34,7 +34,7 @@
void ESM4::Potion::load(ESM4::Reader& reader)
{
mId = reader.getRefIdFromHeader();
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -31,7 +31,7 @@
#include <string>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include <components/esm/formid.hpp>
#include "effect.hpp" // FormId, ScriptEffect
@ -52,13 +52,13 @@ namespace ESM4
{
std::int32_t value;
std::uint32_t flags;
FormId32 withdrawl;
ESM::FormId32 withdrawl;
float chanceAddition;
FormId32 sound;
ESM::FormId32 sound;
};
#pragma pack(pop)
ESM::RefId mId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -67,10 +67,10 @@ namespace ESM4
std::string mIcon; // inventory
std::string mMiniIcon; // inventory
FormId mPickUpSound;
FormId mDropSound;
ESM::FormId mPickUpSound;
ESM::FormId mDropSound;
FormId mScriptId;
ESM::FormId mScriptId;
ScriptEffect mEffect;
float mBoundRadius;

@ -29,15 +29,12 @@
#include <cstring>
#include <stdexcept>
//#include "formid.hpp" // FIXME:
#include "reader.hpp"
//#include "writer.hpp"
void ESM4::MediaLocationController::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())
@ -52,53 +49,23 @@ void ESM4::MediaLocationController::load(ESM4::Reader& reader)
reader.getZString(mFullName);
break;
case ESM4::SUB_GNAM:
{
FormId id;
reader.getFormId(id);
mBattleSets.push_back(id);
reader.getFormId(mBattleSets.emplace_back());
break;
}
case ESM4::SUB_LNAM:
{
FormId id;
reader.getFormId(id);
mLocationSets.push_back(id);
reader.getFormId(mLocationSets.emplace_back());
break;
}
case ESM4::SUB_YNAM:
{
FormId id;
reader.getFormId(id);
mEnemySets.push_back(id);
reader.getFormId(mEnemySets.emplace_back());
break;
}
case ESM4::SUB_HNAM:
{
FormId id;
reader.getFormId(id);
mNeutralSets.push_back(id);
reader.getFormId(mNeutralSets.emplace_back());
break;
}
case ESM4::SUB_XNAM:
{
FormId id;
reader.getFormId(id);
mFriendSets.push_back(id);
reader.getFormId(mFriendSets.emplace_back());
break;
}
case ESM4::SUB_ZNAM:
{
FormId id;
reader.getFormId(id);
mAllySets.push_back(id);
reader.getFormId(mAllySets.emplace_back());
break;
}
case ESM4::SUB_RNAM:
reader.getFormId(mConditionalFaction);
break;

@ -31,7 +31,8 @@
#include <string>
#include <vector>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -52,22 +53,22 @@ namespace ESM4
struct MediaLocationController
{
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
std::string mFullName;
std::vector<FormId> mBattleSets;
std::vector<FormId> mLocationSets;
std::vector<FormId> mEnemySets;
std::vector<FormId> mNeutralSets;
std::vector<FormId> mFriendSets;
std::vector<FormId> mAllySets;
std::vector<ESM::FormId> mBattleSets;
std::vector<ESM::FormId> mLocationSets;
std::vector<ESM::FormId> mEnemySets;
std::vector<ESM::FormId> mNeutralSets;
std::vector<ESM::FormId> mFriendSets;
std::vector<ESM::FormId> mAllySets;
MLC_Flags mMediaFlags;
FormId mConditionalFaction;
ESM::FormId mConditionalFaction;
float mLocationDelay;
float mRetriggerDelay;
@ -79,6 +80,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_ALOC4;
};
}

@ -33,7 +33,7 @@
void ESM4::Ammunition::load(ESM4::Reader& reader)
{
mId = reader.getRefIdFromHeader();
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())
@ -128,12 +128,8 @@ void ESM4::Ammunition::load(ESM4::Reader& reader)
reader.getLocalizedString(mAbbrev);
break;
case ESM4::SUB_RCIL:
{
FormId effect;
reader.getFormId(effect);
mAmmoEffects.push_back(effect);
reader.getFormId(mAmmoEffects.emplace_back());
break;
}
case ESM4::SUB_SCRI:
reader.getFormId(mScript);
break;

@ -32,9 +32,7 @@
#include <vector>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "formid.hpp"
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -52,12 +50,12 @@ namespace ESM4
float mDamage{ 0.f };
std::uint8_t mClipRounds{ 0u };
std::uint32_t mProjPerShot{ 0u };
FormId mProjectile;
FormId mConsumedAmmo;
ESM::FormId mProjectile;
ESM::FormId mConsumedAmmo;
float mConsumedPercentage{ 0.f };
};
ESM::RefId mId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -69,17 +67,17 @@ namespace ESM4
std::string mIcon; // inventory
std::string mMiniIcon; // inventory
FormId mPickUpSound;
FormId mDropSound;
ESM::FormId mPickUpSound;
ESM::FormId mDropSound;
float mBoundRadius;
std::uint16_t mEnchantmentPoints;
FormId mEnchantment;
ESM::FormId mEnchantment;
std::vector<FormId> mAmmoEffects;
std::vector<ESM::FormId> mAmmoEffects;
FormId mScript;
ESM::FormId mScript;
Data mData;

@ -33,8 +33,7 @@
void ESM4::AnimObject::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -30,7 +30,8 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -39,7 +40,7 @@ namespace ESM4
struct AnimObject
{
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -47,13 +48,14 @@ namespace ESM4
float mBoundRadius;
FormId mIdleAnim; // only in TES4
ESM::FormId mIdleAnim; // only in TES4
std::string mUnloadEvent; // only in TES5
void load(ESM4::Reader& reader);
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_ANIO4;
};
}

@ -33,8 +33,7 @@
void ESM4::Apparatus::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -30,7 +30,8 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -47,7 +48,7 @@ namespace ESM4
float quality;
};
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -58,7 +59,7 @@ namespace ESM4
float mBoundRadius;
FormId mScriptId;
ESM::FormId mScriptId;
Data mData;
@ -66,6 +67,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_APPA4;
};
}

@ -33,8 +33,7 @@
void ESM4::ArmorAddon::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
std::uint32_t esmVer = reader.esmVersion();
@ -71,11 +70,7 @@ void ESM4::ArmorAddon::load(ESM4::Reader& reader)
break;
case ESM4::SUB_MODL:
if ((esmVer == ESM::VER_094 || esmVer == ESM::VER_170) && subHdr.dataSize == 4) // TES5
{
FormId formId;
reader.getFormId(formId);
mRaces.push_back(formId);
}
reader.getFormId(mRaces.emplace_back());
else
reader.skipSubRecordData(); // FIXME: this should be mModelMale for FO3/FONV

@ -31,8 +31,10 @@
#include <string>
#include <vector>
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
#include "actor.hpp" // BodyTemplate
#include "formid.hpp"
namespace ESM4
{
@ -41,7 +43,7 @@ namespace ESM4
struct ArmorAddon
{
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -49,11 +51,11 @@ namespace ESM4
std::string mModelMale;
std::string mModelFemale;
FormId mTextureMale;
FormId mTextureFemale;
ESM::FormId mTextureMale;
ESM::FormId mTextureFemale;
FormId mRacePrimary;
std::vector<FormId> mRaces; // TES5 only
ESM::FormId mRacePrimary;
std::vector<ESM::FormId> mRaces; // TES5 only
BodyTemplate mBodyTemplate; // TES5
@ -61,6 +63,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_ARMA4;
};
}

@ -33,7 +33,7 @@
void ESM4::Armor::load(ESM4::Reader& reader)
{
mId = reader.getRefIdFromHeader();
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;
@ -76,12 +76,7 @@ void ESM4::Armor::load(ESM4::Reader& reader)
{
// if (esmVer == ESM::VER_094 || esmVer == ESM::VER_170 || isFONV)
if (subHdr.dataSize == 4) // FO3 has zstring even though VER_094
{
FormId formId;
reader.getFormId(formId);
mAddOns.push_back(formId);
}
reader.getFormId(mAddOns.emplace_back());
else
{
if (!reader.getZString(mModelMale))

@ -32,9 +32,7 @@
#include <vector>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "formid.hpp"
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -151,7 +149,7 @@ namespace ESM4
};
#pragma pack(pop)
ESM::RefId mId; // from the header
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
@ -170,8 +168,8 @@ namespace ESM4
std::string mIconFemale;
std::string mMiniIconFemale;
FormId mPickUpSound;
FormId mDropSound;
ESM::FormId mPickUpSound;
ESM::FormId mDropSound;
std::string mModel; // FIXME: for OpenCS
@ -179,11 +177,11 @@ namespace ESM4
std::uint32_t mArmorFlags;
std::uint32_t mGeneralFlags;
FormId mScriptId;
ESM::FormId mScriptId;
std::uint16_t mEnchantmentPoints;
FormId mEnchantment;
ESM::FormId mEnchantment;
std::vector<FormId> mAddOns; // TES5 ARMA
std::vector<ESM::FormId> mAddOns; // TES5 ARMA
Data mData;
void load(ESM4::Reader& reader);

@ -33,8 +33,7 @@
void ESM4::AcousticSpace::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())
@ -49,12 +48,8 @@ void ESM4::AcousticSpace::load(ESM4::Reader& reader)
reader.get(mEnvironmentType);
break;
case ESM4::SUB_SNAM:
{
FormId id;
reader.getFormId(id);
mAmbientLoopSounds.push_back(id);
reader.getFormId(mAmbientLoopSounds.emplace_back());
break;
}
case ESM4::SUB_RDAT:
reader.getFormId(mSoundRegion);
break;

@ -31,7 +31,8 @@
#include <string>
#include <vector>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -40,7 +41,7 @@ namespace ESM4
struct AcousticSpace
{
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -48,8 +49,8 @@ namespace ESM4
std::uint32_t mEnvironmentType;
// 0 Dawn (5:00 start), 1 Afternoon (8:00), 2 Dusk (18:00), 3 Night (20:00)
std::vector<FormId> mAmbientLoopSounds;
FormId mSoundRegion;
std::vector<ESM::FormId> mAmbientLoopSounds;
ESM::FormId mSoundRegion;
std::uint32_t mIsInterior; // if true only use mAmbientLoopSounds[0]
@ -57,6 +58,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_ASPC4;
};
}

@ -33,7 +33,7 @@
void ESM4::Book::load(ESM4::Reader& reader)
{
mId = reader.getRefIdFromHeader();
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
// std::uint32_t esmVer = reader.esmVersion(); // currently unused

@ -31,9 +31,7 @@
#include <string>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "formid.hpp"
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -84,7 +82,7 @@ namespace ESM4
float weight;
};
ESM::RefId mId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -94,15 +92,15 @@ namespace ESM4
float mBoundRadius;
std::string mText;
FormId mScriptId;
ESM::FormId mScriptId;
std::string mIcon;
std::uint16_t mEnchantmentPoints;
FormId mEnchantment;
ESM::FormId mEnchantment;
Data mData;
FormId mPickUpSound;
FormId mDropSound;
ESM::FormId mPickUpSound;
ESM::FormId mDropSound;
void load(ESM4::Reader& reader);
// void save(ESM4::Writer& writer) const;

@ -45,8 +45,7 @@ void ESM4::BodyPartData::BodyPart::clear()
void ESM4::BodyPartData::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
BodyPart bodyPart;

@ -31,7 +31,8 @@
#include <string>
#include <vector>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -68,14 +69,14 @@ namespace ESM4
std::uint8_t explExplosionChance; // %
std::uint16_t explDebrisCount;
FormId32 explDebris;
FormId32 explExplosion;
ESM::FormId32 explDebris;
ESM::FormId32 explExplosion;
float trackingMaxAngle;
float explDebrisScale;
std::int32_t sevDebrisCount;
FormId32 sevDebris;
FormId32 sevExplosion;
ESM::FormId32 sevDebris;
ESM::FormId32 sevExplosion;
float sevDebrisScale;
// Struct - Gore Effects Positioning
@ -86,8 +87,8 @@ namespace ESM4
float rotY;
float rotZ;
FormId32 sevImpactDataSet;
FormId32 explImpactDataSet;
ESM::FormId32 sevImpactDataSet;
ESM::FormId32 explImpactDataSet;
uint8_t sevDecalCount;
uint8_t explDecalCount;
uint16_t Unknown;
@ -108,7 +109,7 @@ namespace ESM4
void clear();
};
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -121,6 +122,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_BPTD4;
};
}

@ -47,11 +47,10 @@ float ESM4::Cell::sInvalidWaterLevel = -200000.f;
// longer/shorter/same as loading the subrecords.
void ESM4::Cell::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = ESM::RefId::formIdRefId(mFormId);
ESM::FormId formId = reader.getFormIdFromHeader();
mId = formId;
mFlags = reader.hdr().record.flags;
mParent = ESM::RefId::formIdRefId(reader.currWorld());
mParent = reader.currWorld();
mWaterHeight = sInvalidWaterLevel;
reader.clearCellGrid(); // clear until XCLC FIXME: somehow do this automatically?
@ -70,7 +69,7 @@ void ESM4::Cell::load(ESM4::Reader& reader)
// WARN: we need to call setCurrCell (and maybe setCurrCellGrid?) again before loading
// cell child groups if we are loading them after restoring the context
// (may be easier to update the context before saving?)
reader.setCurrCell(mFormId); // save for LAND (and other children) to access later
reader.setCurrCell(formId); // save for LAND (and other children) to access later
std::uint32_t esmVer = reader.esmVersion();
bool isFONV = esmVer == ESM::VER_132 || esmVer == ESM::VER_133 || esmVer == ESM::VER_134;
bool isSkyrim = (esmVer == ESM::VER_170 || esmVer == ESM::VER_094);
@ -155,8 +154,8 @@ void ESM4::Cell::load(ESM4::Reader& reader)
}
case ESM4::SUB_XCLR: // for exterior cells
{
mRegions.resize(subHdr.dataSize / sizeof(FormId32));
for (std::vector<FormId>::iterator it = mRegions.begin(); it != mRegions.end(); ++it)
mRegions.resize(subHdr.dataSize / sizeof(ESM::FormId32));
for (std::vector<ESM::FormId>::iterator it = mRegions.begin(); it != mRegions.end(); ++it)
{
reader.getFormId(*it);
#if 0

@ -31,14 +31,13 @@
#include <string>
#include <vector>
#include "formid.hpp"
#include "lighting.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include <components/esm/util.hpp>
#include <components/esm4/reader.hpp>
#include "lighting.hpp"
namespace ESM4
{
class Reader;
@ -63,8 +62,7 @@ namespace ESM4
// The cells need to be organised under world spaces.
struct Cell
{
FormId mFormId; // from the header
ESM::RefId mId;
ESM::RefId mId; // from the header
std::uint32_t mFlags = 0; // from the header, see enum type RecordFlag for details
ESM::RefId mParent; // world formId (for grouping cells), from the loading sequence
@ -76,20 +74,20 @@ namespace ESM4
std::int32_t mX = 0;
std::int32_t mY = 0;
FormId mOwner;
FormId mGlobal;
FormId mClimate;
FormId mWater;
ESM::FormId mOwner;
ESM::FormId mGlobal;
ESM::FormId mClimate;
ESM::FormId mWater;
float mWaterHeight = sInvalidWaterLevel;
std::vector<FormId> mRegions;
std::vector<ESM::FormId> mRegions;
Lighting mLighting;
FormId mLightingTemplate; // FO3/FONV
ESM::FormId mLightingTemplate; // FO3/FONV
std::uint32_t mLightingTemplateFlags = 0; // FO3/FONV
FormId mMusic; // FO3/FONV
FormId mAcousticSpace; // FO3/FONV
ESM::FormId mMusic; // FO3/FONV
ESM::FormId mAcousticSpace; // FO3/FONV
// TES4: 0 = default, 1 = public, 2 = dungeon
// FO3/FONV have more types (not sure how they are used, however)
std::uint8_t mMusicType = 0;

@ -33,8 +33,7 @@
void ESM4::Class::load(ESM4::Reader& reader)
{
// mFormId = reader.adjustFormId(reader.hdr().record.id); // FIXME: use master adjusted?
mFormId = reader.hdr().record.getFormId();
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -30,7 +30,8 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -44,7 +45,7 @@ namespace ESM4
std::uint32_t attr;
};
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -57,6 +58,7 @@ namespace ESM4
// void save(ESM4::Writer& reader) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::REC_CLAS4;
};
}

@ -33,8 +33,7 @@
void ESM4::Colour::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -30,7 +30,8 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -48,7 +49,7 @@ namespace ESM4
struct Colour
{
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -61,6 +62,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::REC_CLFM4;
};
}

@ -33,7 +33,7 @@
void ESM4::Clothing::load(ESM4::Reader& reader)
{
mId = reader.getRefIdFromHeader();
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -31,9 +31,7 @@
#include <string>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "formid.hpp"
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -50,7 +48,7 @@ namespace ESM4
};
#pragma pack(pop)
ESM::RefId mId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -67,9 +65,9 @@ namespace ESM4
float mBoundRadius;
std::uint32_t mClothingFlags; // see Armor::ArmorFlags for the values
FormId mScriptId;
ESM::FormId mScriptId;
std::uint16_t mEnchantmentPoints;
FormId mEnchantment;
ESM::FormId mEnchantment;
Data mData;

@ -33,7 +33,7 @@
void ESM4::Container::load(ESM4::Reader& reader)
{
mId = reader.getRefIdFromHeader();
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -32,9 +32,8 @@
#include <vector>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include <components/esm/formid.hpp>
#include "formid.hpp"
#include "inventory.hpp" // InventoryItem
namespace ESM4
@ -44,7 +43,7 @@ namespace ESM4
struct Container
{
ESM::RefId mId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -55,9 +54,9 @@ namespace ESM4
unsigned char mDataFlags;
float mWeight;
FormId mOpenSound;
FormId mCloseSound;
FormId mScriptId; // TES4 only
ESM::FormId mOpenSound;
ESM::FormId mCloseSound;
ESM::FormId mScriptId; // TES4 only
std::vector<InventoryItem> mInventory;

@ -37,7 +37,7 @@
void ESM4::Creature::load(ESM4::Reader& reader)
{
mId = reader.getRefIdFromHeader();
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())
@ -63,19 +63,11 @@ void ESM4::Creature::load(ESM4::Reader& reader)
break;
}
case ESM4::SUB_SPLO:
{
FormId id;
reader.getFormId(id);
mSpell.push_back(id);
reader.getFormId(mSpell.emplace_back());
break;
}
case ESM4::SUB_PKID:
{
FormId id;
reader.getFormId(id);
mAIPackages.push_back(id);
reader.getFormId(mAIPackages.emplace_back());
break;
}
case ESM4::SUB_SNAM:
reader.get(mFaction);
reader.adjustFormId(mFaction.faction);
@ -163,12 +155,8 @@ void ESM4::Creature::load(ESM4::Reader& reader)
reader.getFormId(mBaseTemplate);
break; // FO3
case ESM4::SUB_PNAM: // FO3/FONV/TES5
{
FormId bodyPart;
reader.getFormId(bodyPart);
mBodyParts.push_back(bodyPart);
reader.getFormId(mBodyParts.emplace_back());
break;
}
case ESM4::SUB_MODT:
case ESM4::SUB_RNAM:
case ESM4::SUB_CSDT:

@ -32,7 +32,7 @@
#include <vector>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include <components/esm/formid.hpp>
#include "actor.hpp"
#include "inventory.hpp"
@ -106,25 +106,25 @@ namespace ESM4
};
#pragma pack(pop)
ESM::RefId mId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
std::string mFullName;
std::string mModel;
FormId mDeathItem;
std::vector<FormId> mSpell;
FormId mScriptId;
ESM::FormId mDeathItem;
std::vector<ESM::FormId> mSpell;
ESM::FormId mScriptId;
AIData mAIData;
std::vector<FormId> mAIPackages;
std::vector<ESM::FormId> mAIPackages;
ActorBaseConfig mBaseConfig;
ActorFaction mFaction;
Data mData;
FormId mCombatStyle;
FormId mSoundBase;
FormId mSound;
ESM::FormId mCombatStyle;
ESM::FormId mSoundBase;
ESM::FormId mSound;
std::uint8_t mSoundChance;
float mBaseScale;
float mTurningSpeed;
@ -138,8 +138,8 @@ namespace ESM4
std::vector<InventoryItem> mInventory;
FormId mBaseTemplate; // FO3/FONV
std::vector<FormId> mBodyParts; // FO3/FONV
ESM::FormId mBaseTemplate; // FO3/FONV
std::vector<ESM::FormId> mBodyParts; // FO3/FONV
void load(ESM4::Reader& reader);
// void save(ESM4::Writer& writer) const;

@ -34,8 +34,7 @@
void ESM4::Dialogue::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())
@ -50,19 +49,11 @@ void ESM4::Dialogue::load(ESM4::Reader& reader)
reader.getZString(mTopicName);
break;
case ESM4::SUB_QSTI:
{
FormId questId;
reader.getFormId(questId);
mQuests.push_back(questId);
reader.getFormId(mQuests.emplace_back());
break;
}
case ESM4::SUB_QSTR: // Seems never used in TES4
{
FormId questRem;
reader.getFormId(questRem);
mQuestsRemoved.push_back(questRem);
reader.getFormId(mQuestsRemoved.emplace_back());
break;
}
case ESM4::SUB_DATA:
{
if (subHdr.dataSize == 4) // TES5

@ -31,7 +31,8 @@
#include <string>
#include <vector>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -40,12 +41,12 @@ namespace ESM4
struct Dialogue
{
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
std::vector<FormId> mQuests;
std::vector<FormId> mQuestsRemoved; // FONV only?
std::vector<ESM::FormId> mQuests;
std::vector<ESM::FormId> mQuestsRemoved; // FONV only?
std::string mTopicName;
std::string mTextDumb; // FIXME: temp name
@ -60,6 +61,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_DIAL4;
};
}

@ -36,8 +36,7 @@
void ESM4::DefaultObj::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -32,7 +32,8 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -41,46 +42,46 @@ namespace ESM4
struct Defaults
{
FormId stimpack;
FormId superStimpack;
FormId radX;
FormId radAway;
FormId morphine;
FormId perkParalysis;
FormId playerFaction;
FormId mysteriousStrangerNPC;
FormId mysteriousStrangerFaction;
FormId defaultMusic;
FormId battleMusic;
FormId deathMusic;
FormId successMusic;
FormId levelUpMusic;
FormId playerVoiceMale;
FormId playerVoiceMaleChild;
FormId playerVoiceFemale;
FormId playerVoiceFemaleChild;
FormId eatPackageDefaultFood;
FormId everyActorAbility;
FormId drugWearsOffImageSpace;
ESM::FormId stimpack;
ESM::FormId superStimpack;
ESM::FormId radX;
ESM::FormId radAway;
ESM::FormId morphine;
ESM::FormId perkParalysis;
ESM::FormId playerFaction;
ESM::FormId mysteriousStrangerNPC;
ESM::FormId mysteriousStrangerFaction;
ESM::FormId defaultMusic;
ESM::FormId battleMusic;
ESM::FormId deathMusic;
ESM::FormId successMusic;
ESM::FormId levelUpMusic;
ESM::FormId playerVoiceMale;
ESM::FormId playerVoiceMaleChild;
ESM::FormId playerVoiceFemale;
ESM::FormId playerVoiceFemaleChild;
ESM::FormId eatPackageDefaultFood;
ESM::FormId everyActorAbility;
ESM::FormId drugWearsOffImageSpace;
// below FONV only
FormId doctorsBag;
FormId missFortuneNPC;
FormId missFortuneFaction;
FormId meltdownExplosion;
FormId unarmedForwardPA;
FormId unarmedBackwardPA;
FormId unarmedLeftPA;
FormId unarmedRightPA;
FormId unarmedCrouchPA;
FormId unarmedCounterPA;
FormId spotterEffect;
FormId itemDetectedEfect;
FormId cateyeMobileEffectNYI;
ESM::FormId doctorsBag;
ESM::FormId missFortuneNPC;
ESM::FormId missFortuneFaction;
ESM::FormId meltdownExplosion;
ESM::FormId unarmedForwardPA;
ESM::FormId unarmedBackwardPA;
ESM::FormId unarmedLeftPA;
ESM::FormId unarmedRightPA;
ESM::FormId unarmedCrouchPA;
ESM::FormId unarmedCounterPA;
ESM::FormId spotterEffect;
ESM::FormId itemDetectedEfect;
ESM::FormId cateyeMobileEffectNYI;
};
struct DefaultObj
{
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -91,6 +92,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_DOBJ4;
};
}

@ -33,7 +33,7 @@
void ESM4::Door::load(ESM4::Reader& reader)
{
mId = reader.getRefIdFromHeader();
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -31,9 +31,7 @@
#include <string>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "formid.hpp"
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -50,7 +48,7 @@ namespace ESM4
Flag_MinimalUse = 0x08
};
ESM::RefId mId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -60,11 +58,11 @@ namespace ESM4
float mBoundRadius;
std::uint8_t mDoorFlags;
FormId mScriptId;
FormId mOpenSound; // SNDR for TES5, SOUN for others
FormId mCloseSound; // SNDR for TES5, SOUN for others
FormId mLoopSound;
FormId mRandomTeleport;
ESM::FormId mScriptId;
ESM::FormId mOpenSound; // SNDR for TES5, SOUN for others
ESM::FormId mCloseSound; // SNDR for TES5, SOUN for others
ESM::FormId mLoopSound;
ESM::FormId mRandomTeleport;
void load(ESM4::Reader& reader);
// void save(ESM4::Writer& writer) const;

@ -33,8 +33,7 @@
void ESM4::Eyes::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -30,7 +30,8 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -46,7 +47,7 @@ namespace ESM4
};
#pragma pack(pop)
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -59,6 +60,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_EYES4;
};
}

@ -33,8 +33,7 @@
void ESM4::Flora::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -30,7 +30,8 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -57,7 +58,7 @@ namespace ESM4
};
#pragma pack(pop)
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -66,15 +67,16 @@ namespace ESM4
float mBoundRadius;
FormId mScriptId;
FormId mIngredient;
FormId mSound;
ESM::FormId mScriptId;
ESM::FormId mIngredient;
ESM::FormId mSound;
Production mPercentHarvest;
void load(ESM4::Reader& reader);
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_FLOR4;
};
}

@ -33,8 +33,7 @@
void ESM4::FormIdList::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())
@ -46,12 +45,8 @@ void ESM4::FormIdList::load(ESM4::Reader& reader)
reader.getZString(mEditorId);
break;
case ESM4::SUB_LNAM:
{
FormId formId;
reader.getFormId(formId);
mObjects.push_back(formId);
reader.getFormId(mObjects.emplace_back());
break;
}
default:
throw std::runtime_error("ESM4::FLST::load - Unknown subrecord " + ESM::printName(subHdr.typeId));
}

@ -31,7 +31,8 @@
#include <string>
#include <vector>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -40,17 +41,18 @@ namespace ESM4
struct FormIdList
{
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
std::vector<FormId> mObjects;
std::vector<ESM::FormId> mObjects;
void load(ESM4::Reader& reader);
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_FLST4;
};
}

@ -33,7 +33,7 @@
void ESM4::Furniture::load(ESM4::Reader& reader)
{
mId = reader.getRefIdFromHeader();
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -31,9 +31,7 @@
#include <string>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "formid.hpp"
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -42,7 +40,7 @@ namespace ESM4
struct Furniture
{
ESM::RefId mId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -51,7 +49,7 @@ namespace ESM4
float mBoundRadius;
FormId mScriptId;
ESM::FormId mScriptId;
std::uint32_t mActiveMarkerFlags;
void load(ESM4::Reader& reader);

@ -33,8 +33,7 @@
void ESM4::GlobalVariable::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -30,7 +30,8 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -39,7 +40,7 @@ namespace ESM4
struct GlobalVariable
{
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -51,6 +52,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_GLOB4;
};
}

@ -10,7 +10,7 @@ namespace ESM4
{
namespace
{
GameSetting::Data readData(FormId formId, std::string_view editorId, Reader& reader)
GameSetting::Data readData(ESM::FormId formId, std::string_view editorId, Reader& reader)
{
if (editorId.empty())
{
@ -53,8 +53,7 @@ namespace ESM4
void GameSetting::load(Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())
@ -66,11 +65,11 @@ namespace ESM4
reader.getZString(mEditorId);
break;
case ESM4::SUB_DATA:
mData = readData(mFormId, mEditorId, reader);
mData = readData(mId, mEditorId, reader);
break;
default:
throw std::runtime_error(
"Unknown ESM4 GMST (" + mFormId.toString() + ") subrecord " + ESM::printName(subHdr.typeId));
"Unknown ESM4 GMST (" + mId.toString() + ") subrecord " + ESM::printName(subHdr.typeId));
}
}
}

@ -5,7 +5,8 @@
#include <string>
#include <variant>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -15,12 +16,13 @@ namespace ESM4
{
using Data = std::variant<std::monostate, bool, float, std::int32_t, std::string>;
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
Data mData;
void load(Reader& reader);
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_GMST4;
};
}

@ -33,8 +33,7 @@
void ESM4::Grass::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -30,7 +30,8 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -75,7 +76,7 @@ namespace ESM4
};
#pragma pack(pop)
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -89,6 +90,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_GRAS4;
};
}

@ -30,6 +30,9 @@
#include <cstdint>
#include <vector>
#include <components/esm/formid.hpp>
#include <components/esm4/reader.hpp>
namespace ESM4
{
// http://www.uesp.net/wiki/Tes4Mod:Mod_File_Format#Hierarchical_Top_Groups
@ -76,14 +79,14 @@ namespace ESM4
//
struct WorldGroup
{
FormId mWorld; // WRLD record for this group
ESM::FormId mWorld; // WRLD record for this group
// occurs only after World Child (type 1)
// since GRUP label may not be reliable, need to keep the formid of the current WRLD in
// the reader's context
FormId mRoad;
ESM::FormId mRoad;
std::vector<FormId> mCells; // FIXME should this be CellGroup* instead?
std::vector<ESM::FormId> mCells; // FIXME should this be CellGroup* instead?
};
// http://www.uesp.net/wiki/Tes4Mod:Mod_File_Format/CELL
@ -99,7 +102,7 @@ namespace ESM4
// NOTE: There may be many CELL records in one subblock
struct CellGroup
{
FormId mCell; // CELL record for this cell group
ESM::FormId mCell; // CELL record for this cell group
int mCellModIndex; // from which file to get the CELL record (e.g. may have been updated)
// For retrieving parent group size (for lazy loading or skipping) and sub-block number / grid
@ -129,20 +132,20 @@ namespace ESM4
// cache (modindex adjusted) formId's of children
// FIXME: also need file index + file context of all those that has type 8 GRUP
GroupTypeHeader mHdrPersist;
std::vector<FormId> mPersistent; // REFR, ACHR, ACRE
std::vector<FormId> mdelPersistent;
std::vector<ESM::FormId> mPersistent; // REFR, ACHR, ACRE
std::vector<ESM::FormId> mdelPersistent;
// FIXME: also need file index + file context of all those that has type 10 GRUP
GroupTypeHeader mHdrVisDist;
std::vector<FormId> mVisibleDist; // REFR, ACHR, ACRE
std::vector<FormId> mdelVisibleDist;
std::vector<ESM::FormId> mVisibleDist; // REFR, ACHR, ACRE
std::vector<ESM::FormId> mdelVisibleDist;
// FIXME: also need file index + file context of all those that has type 9 GRUP
GroupTypeHeader mHdrTemp;
FormId mLand; // if present, assume only one LAND per exterior CELL
FormId mPgrd; // if present, seems to be the first record after LAND in Temp Cell Child GRUP
std::vector<FormId> mTemporary; // REFR, ACHR, ACRE
std::vector<FormId> mdelTemporary;
ESM::FormId mLand; // if present, assume only one LAND per exterior CELL
ESM::FormId mPgrd; // if present, seems to be the first record after LAND in Temp Cell Child GRUP
std::vector<ESM::FormId> mTemporary; // REFR, ACHR, ACRE
std::vector<ESM::FormId> mdelTemporary;
// need to keep modindex and context for lazy loading (of all the files that contribute
// to this group)

@ -33,8 +33,7 @@
void ESM4::Hair::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -30,7 +30,8 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -46,7 +47,7 @@ namespace ESM4
};
#pragma pack(pop)
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -62,6 +63,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_HAIR4;
};
}

@ -35,8 +35,7 @@
void ESM4::HeadPart::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
std::optional<std::uint32_t> type;

@ -31,7 +31,8 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -40,7 +41,7 @@ namespace ESM4
struct HeadPart
{
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -49,15 +50,16 @@ namespace ESM4
std::uint8_t mData;
FormId mAdditionalPart;
ESM::FormId mAdditionalPart;
std::array<std::string, 3> mTriFile;
FormId mBaseTexture;
ESM::FormId mBaseTexture;
void load(ESM4::Reader& reader);
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_HDPT4;
};
}

@ -33,8 +33,7 @@
void ESM4::IdleAnimation::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -30,7 +30,8 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -39,7 +40,7 @@ namespace ESM4
struct IdleAnimation
{
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -47,8 +48,8 @@ namespace ESM4
std::string mEvent;
std::string mModel;
FormId mParent; // IDLE or AACT
FormId mPrevious;
ESM::FormId mParent; // IDLE or AACT
ESM::FormId mPrevious;
float mBoundRadius;
@ -56,6 +57,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_IDLE4;
};
}

@ -33,8 +33,7 @@
void ESM4::IdleMarker::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
std::uint32_t esmVer = reader.esmVersion();
@ -72,7 +71,7 @@ void ESM4::IdleMarker::load(ESM4::Reader& reader)
}
mIdleAnim.resize(mIdleCount);
for (FormId& value : mIdleAnim)
for (ESM::FormId& value : mIdleAnim)
reader.getFormId(value);
break;
}

@ -31,7 +31,8 @@
#include <string>
#include <vector>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -40,7 +41,7 @@ namespace ESM4
struct IdleMarker
{
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -49,12 +50,13 @@ namespace ESM4
std::uint8_t mIdleFlags;
std::uint8_t mIdleCount;
float mIdleTimer;
std::vector<FormId> mIdleAnim;
std::vector<ESM::FormId> mIdleAnim;
void load(ESM4::Reader& reader);
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_IDLM4;
};
}

@ -35,8 +35,7 @@
void ESM4::ItemMod::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -32,7 +32,8 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -41,7 +42,7 @@ namespace ESM4
struct ItemMod
{
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -50,6 +51,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_IMOD4;
};
}

@ -29,16 +29,17 @@
#include <cstring>
#include <stdexcept>
#include <components/esm/refid.hpp>
#include "reader.hpp"
//#include "writer.hpp"
void ESM4::DialogInfo::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
mEditorId = formIdToString(mFormId); // FIXME: quick workaround to use existing code
mEditorId = ESM::RefId(mId).serializeText(); // FIXME: quick workaround to use existing code
static ScriptLocalVariableData localVar;
bool ignore = false;

@ -30,8 +30,9 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include "script.hpp" // TargetCondition
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -54,13 +55,13 @@ namespace ESM4
struct DialogInfo
{
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId; // FIXME: no such record for INFO, but keep here to avoid extra work for now
FormId mQuest;
FormId mSound; // unused?
ESM::FormId mQuest;
ESM::FormId mSound; // unused?
TargetResponseData mResponseData;
std::string mResponse;
@ -72,7 +73,7 @@ namespace ESM4
std::uint16_t mInfoFlags; // see above enum
TargetCondition mTargetCondition;
FormId mParam3; // TES5 only
ESM::FormId mParam3; // TES5 only
ScriptDefinition mScript; // FIXME: ignoring the second one after the NEXT sub-record
@ -80,6 +81,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_INFO4;
};
}

@ -34,7 +34,7 @@
void ESM4::Ingredient::load(ESM4::Reader& reader)
{
mId = reader.getRefIdFromHeader();
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -31,7 +31,7 @@
#include <vector>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include <components/esm/formid.hpp>
#include "effect.hpp"
@ -56,7 +56,7 @@ namespace ESM4
};
#pragma pack(pop)
ESM::RefId mId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -67,7 +67,7 @@ namespace ESM4
float mBoundRadius;
std::vector<std::string> mScriptEffect; // FIXME: prob. should be in a struct
FormId mScriptId;
ESM::FormId mScriptId;
ScriptEffect mEffect;
ENIT mEnchantment;

@ -33,8 +33,7 @@
void ESM4::Key::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -30,7 +30,8 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -47,7 +48,7 @@ namespace ESM4
};
#pragma pack(pop)
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -56,11 +57,11 @@ namespace ESM4
std::string mIcon; // inventory
std::string mMiniIcon; // inventory
FormId mPickUpSound;
FormId mDropSound;
ESM::FormId mPickUpSound;
ESM::FormId mDropSound;
float mBoundRadius;
FormId mScriptId;
ESM::FormId mScriptId;
Data mData;
@ -68,6 +69,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_KEYM4;
};
}

@ -51,12 +51,10 @@
//
void ESM4::Land::load(ESM4::Reader& reader)
{
ESM::FormId formId = reader.hdr().record.getFormId();
reader.adjustFormId(formId);
mId = ESM::RefId::formIdRefId(formId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
mDataTypes = 0;
mCell = ESM::RefId::formIdRefId(reader.currCell());
mCell = reader.currCell();
TxtLayer layer;
std::int8_t currentAddQuad = -1; // for VTXT following ATXT
@ -181,19 +179,15 @@ void ESM4::Land::load(ESM4::Reader& reader)
}
case ESM4::SUB_VTEX: // only in Oblivion?
{
int count = (int)reader.subRecordHeader().dataSize / sizeof(FormId32);
if ((reader.subRecordHeader().dataSize % sizeof(FormId32)) != 0)
int count = (int)reader.subRecordHeader().dataSize / sizeof(ESM::FormId32);
if ((reader.subRecordHeader().dataSize % sizeof(ESM::FormId32)) != 0)
throw std::runtime_error("ESM4::LAND VTEX data size error");
if (count)
{
mIds.resize(count);
for (std::vector<FormId>::iterator it = mIds.begin(); it != mIds.end(); ++it)
{
reader.getFormId(*it);
// FIXME: debug only
// std::cout << "VTEX: " << std::hex << *it << std::endl;
}
for (ESM::FormId& id : mIds)
reader.getFormId(id);
}
break;
}

@ -30,10 +30,8 @@
#include <cstdint>
#include <vector>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -76,7 +74,7 @@ namespace ESM4
struct BTXT
{
FormId32 formId;
ESM::FormId32 formId;
std::uint8_t quadrant; // 0 = bottom left, 1 = bottom right, 2 = top left, 3 = top right
std::uint8_t unknown1;
std::uint16_t unknown2;
@ -84,7 +82,7 @@ namespace ESM4
struct ATXT
{
FormId32 formId;
ESM::FormId32 formId;
std::uint8_t quadrant; // 0 = bottom left, 1 = bottom right, 2 = top left, 3 = top right
std::uint8_t unknown;
std::uint16_t layerIndex; // texture layer, 0..7
@ -111,7 +109,7 @@ namespace ESM4
std::vector<TxtLayer> layers;
};
ESM::RefId mId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::uint32_t mLandFlags; // from DATA subrecord
@ -125,8 +123,8 @@ namespace ESM4
unsigned char mVertColr[VERTS_PER_SIDE * VERTS_PER_SIDE * 3]; // from VCLR subrecord
VHGT mHeightMap;
Texture mTextures[4]; // 0 = bottom left, 1 = bottom right, 2 = top left, 3 = top right
std::vector<FormId> mIds; // land texture (LTEX) formids
ESM::RefId mCell;
std::vector<ESM::FormId> mIds; // land texture (LTEX) formids
ESM::FormId mCell;
void load(Reader& reader);
Land() = default;
// void save(Writer& writer) const;

@ -36,8 +36,7 @@
void ESM4::LightingTemplate::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -32,8 +32,9 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include "lighting.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -42,7 +43,7 @@ namespace ESM4
struct LightingTemplate
{
FormId mFormId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -53,6 +54,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_LGTM4;
};
}

@ -33,7 +33,7 @@
void ESM4::Light::load(ESM4::Reader& reader)
{
mId = reader.getRefIdFromHeader();
mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags;
std::uint32_t esmVer = reader.esmVersion();
bool isFONV = esmVer == ESM::VER_132 || esmVer == ESM::VER_133 || esmVer == ESM::VER_134;

@ -30,10 +30,8 @@
#include <cstdint>
#include <string>
#include "formid.hpp"
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include <components/esm/formid.hpp>
namespace ESM4
{
@ -84,7 +82,7 @@ namespace ESM4
float weight;
};
ESM::RefId mId; // from the header
ESM::FormId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -94,8 +92,8 @@ namespace ESM4
float mBoundRadius;
FormId mScriptId;
FormId mSound;
ESM::FormId mScriptId;
ESM::FormId mSound;
float mFade;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save