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

@ -127,7 +127,7 @@ namespace MWLua
const std::vector<std::string>& contentList = MWBase::Environment::get().getWorld()->getContentFiles(); const std::vector<std::string>& contentList = MWBase::Environment::get().getWorld()->getContentFiles();
for (size_t i = 0; i < contentList.size(); ++i) for (size_t i = 0; i < contentList.size(); ++i)
if (Misc::StringUtils::ciEqual(contentList[i], contentFile)) 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)); throw std::runtime_error("Content file not found: " + std::string(contentFile));
}; };
addTimeBindings(api, context, false); addTimeBindings(api, context, false);

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

@ -21,7 +21,7 @@ namespace MWWorld
if (!value.mEditorId.empty()) if (!value.mEditorId.empty())
return value.mEditorId; return value.mEditorId;
return value.mId.serializeText(); return ESM::RefId(value.mId).serializeText();
} }
std::string getCellDescription(const ESM4::Cell& cell, const ESM4::World* world) 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) // The NPC that owns this object (and will get angry if you steal it)
ESM::RefId getOwner() const ESM::RefId getOwner() const
{ {
struct Visitor return std::visit([](auto&& ref) -> ESM::RefId { return ref.mOwner; }, mCellRef.mVariant);
{
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);
} }
void setOwner(const ESM::RefId& owner); void setOwner(const ESM::RefId& owner);

@ -172,7 +172,7 @@ namespace MWWorld
if (!mShared.empty()) if (!mShared.empty())
return mShared[Misc::Rng::rollDice(mShared.size(), prng)]; 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::vector<const T*> results;
std::copy_if(mShared.begin(), mShared.end(), std::back_inserter(results), std::copy_if(mShared.begin(), mShared.end(), std::back_inserter(results),

@ -711,7 +711,7 @@ namespace MWWorld
if (!activeOnly) if (!activeOnly)
{ {
ret = mWorldModel.getPtr(name); ret = mWorldModel.getPtrByRefId(name);
if (!ret.isEmpty()) if (!ret.isEmpty())
return ret; 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) for (const auto& [cachedId, cellStore] : mIdCache)
{ {

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

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

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

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

@ -15,15 +15,15 @@ namespace ESM
uint32_t mIndex = 0; uint32_t mIndex = 0;
int32_t mContentFile = -1; int32_t mContentFile = -1;
bool hasContentFile() const { return mContentFile >= 0; } constexpr bool hasContentFile() const { return mContentFile >= 0; }
bool isSet() const { return mIndex != 0 || mContentFile != -1; } constexpr bool isSet() const { return mIndex != 0 || mContentFile != -1; }
// Zero is used in ESM4 as a null reference // 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; std::string toString() const;
FormId32 toUint32() 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) 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); uint64_t v = deserializeHexIntegral<uint64_t>(formIdRefIdPrefix.size(), value);
uint32_t index = static_cast<uint32_t>(v) & 0xffffff; uint32_t index = static_cast<uint32_t>(v) & 0xffffff;
int contentFile = static_cast<int>(v >> 24); int contentFile = static_cast<int>(v >> 24);
return ESM::RefId::formIdRefId({ index, contentFile }); return ESM::FormId{ index, contentFile };
} }
if (value.starts_with(generatedRefIdPrefix)) if (value.starts_with(generatedRefIdPrefix))

@ -61,7 +61,7 @@ namespace ESM
static RefId stringRefId(std::string_view value); static RefId stringRefId(std::string_view value);
// Constructs RefId from FormId storing the value in-place. // 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 // Constructs RefId from uint64 storing the value in-place. Should be used for generated records where id is a
// global counter. // 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 constexpr RefId(GeneratedRefId value) noexcept
: mValue(value) : mValue(value)
{ {

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

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

@ -29,7 +29,7 @@
#include <cstdint> #include <cstdint>
#include "formid.hpp" #include <components/esm/formid.hpp>
namespace ESM4 namespace ESM4
{ {
@ -42,7 +42,7 @@ namespace ESM4
struct ScriptEffect 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. std::int32_t school; // Magic school. See Magic schools for more information.
EFI_Label visualEffect; // Visual effect name or 0x00000000 if None EFI_Label visualEffect; // Visual effect name or 0x00000000 if None
std::uint8_t flags; // 0x01 = Hostile 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 <cstdint>
#include "formid.hpp" #include <components/esm/formid.hpp>
namespace ESM4 namespace ESM4
{ {
@ -39,14 +39,14 @@ namespace ESM4
{ {
std::int16_t level; std::int16_t level;
std::uint16_t unknown; // sometimes missing std::uint16_t unknown; // sometimes missing
FormId32 item; ESM::FormId32 item;
std::int16_t count; std::int16_t count;
std::uint16_t unknown2; // sometimes missing std::uint16_t unknown2; // sometimes missing
}; };
struct InventoryItem // NPC_, CREA, CONT struct InventoryItem // NPC_, CREA, CONT
{ {
FormId32 item; ESM::FormId32 item;
std::uint32_t count; std::uint32_t count;
}; };
#pragma pack(pop) #pragma pack(pop)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -33,7 +33,7 @@
void ESM4::Armor::load(ESM4::Reader& reader) void ESM4::Armor::load(ESM4::Reader& reader)
{ {
mId = reader.getRefIdFromHeader(); mId = reader.getFormIdFromHeader();
mFlags = reader.hdr().record.flags; mFlags = reader.hdr().record.flags;
std::uint32_t esmVer = reader.esmVersion(); std::uint32_t esmVer = reader.esmVersion();
mIsFONV = esmVer == ESM::VER_132 || esmVer == ESM::VER_133 || esmVer == ESM::VER_134; 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 (esmVer == ESM::VER_094 || esmVer == ESM::VER_170 || isFONV)
if (subHdr.dataSize == 4) // FO3 has zstring even though VER_094 if (subHdr.dataSize == 4) // FO3 has zstring even though VER_094
{ reader.getFormId(mAddOns.emplace_back());
FormId formId;
reader.getFormId(formId);
mAddOns.push_back(formId);
}
else else
{ {
if (!reader.getZString(mModelMale)) if (!reader.getZString(mModelMale))

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

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

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

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

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

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

@ -31,7 +31,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "formid.hpp" #include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4 namespace ESM4
{ {
@ -68,14 +69,14 @@ namespace ESM4
std::uint8_t explExplosionChance; // % std::uint8_t explExplosionChance; // %
std::uint16_t explDebrisCount; std::uint16_t explDebrisCount;
FormId32 explDebris; ESM::FormId32 explDebris;
FormId32 explExplosion; ESM::FormId32 explExplosion;
float trackingMaxAngle; float trackingMaxAngle;
float explDebrisScale; float explDebrisScale;
std::int32_t sevDebrisCount; std::int32_t sevDebrisCount;
FormId32 sevDebris; ESM::FormId32 sevDebris;
FormId32 sevExplosion; ESM::FormId32 sevExplosion;
float sevDebrisScale; float sevDebrisScale;
// Struct - Gore Effects Positioning // Struct - Gore Effects Positioning
@ -86,8 +87,8 @@ namespace ESM4
float rotY; float rotY;
float rotZ; float rotZ;
FormId32 sevImpactDataSet; ESM::FormId32 sevImpactDataSet;
FormId32 explImpactDataSet; ESM::FormId32 explImpactDataSet;
uint8_t sevDecalCount; uint8_t sevDecalCount;
uint8_t explDecalCount; uint8_t explDecalCount;
uint16_t Unknown; uint16_t Unknown;
@ -108,7 +109,7 @@ namespace ESM4
void clear(); 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::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId; std::string mEditorId;
@ -121,6 +122,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const; // void save(ESM4::Writer& writer) const;
// void blank(); // 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. // longer/shorter/same as loading the subrecords.
void ESM4::Cell::load(ESM4::Reader& reader) void ESM4::Cell::load(ESM4::Reader& reader)
{ {
mFormId = reader.hdr().record.getFormId(); ESM::FormId formId = reader.getFormIdFromHeader();
reader.adjustFormId(mFormId); mId = formId;
mId = ESM::RefId::formIdRefId(mFormId);
mFlags = reader.hdr().record.flags; mFlags = reader.hdr().record.flags;
mParent = ESM::RefId::formIdRefId(reader.currWorld()); mParent = reader.currWorld();
mWaterHeight = sInvalidWaterLevel; mWaterHeight = sInvalidWaterLevel;
reader.clearCellGrid(); // clear until XCLC FIXME: somehow do this automatically? 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 // WARN: we need to call setCurrCell (and maybe setCurrCellGrid?) again before loading
// cell child groups if we are loading them after restoring the context // cell child groups if we are loading them after restoring the context
// (may be easier to update the context before saving?) // (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(); std::uint32_t esmVer = reader.esmVersion();
bool isFONV = esmVer == ESM::VER_132 || esmVer == ESM::VER_133 || esmVer == ESM::VER_134; bool isFONV = esmVer == ESM::VER_132 || esmVer == ESM::VER_133 || esmVer == ESM::VER_134;
bool isSkyrim = (esmVer == ESM::VER_170 || esmVer == ESM::VER_094); 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 case ESM4::SUB_XCLR: // for exterior cells
{ {
mRegions.resize(subHdr.dataSize / sizeof(FormId32)); mRegions.resize(subHdr.dataSize / sizeof(ESM::FormId32));
for (std::vector<FormId>::iterator it = mRegions.begin(); it != mRegions.end(); ++it) for (std::vector<ESM::FormId>::iterator it = mRegions.begin(); it != mRegions.end(); ++it)
{ {
reader.getFormId(*it); reader.getFormId(*it);
#if 0 #if 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -10,7 +10,7 @@ namespace ESM4
{ {
namespace 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()) if (editorId.empty())
{ {
@ -53,8 +53,7 @@ namespace ESM4
void GameSetting::load(Reader& reader) void GameSetting::load(Reader& reader)
{ {
mFormId = reader.hdr().record.getFormId(); mId = reader.getFormIdFromHeader();
reader.adjustFormId(mFormId);
mFlags = reader.hdr().record.flags; mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader()) while (reader.getSubRecordHeader())
@ -66,11 +65,11 @@ namespace ESM4
reader.getZString(mEditorId); reader.getZString(mEditorId);
break; break;
case ESM4::SUB_DATA: case ESM4::SUB_DATA:
mData = readData(mFormId, mEditorId, reader); mData = readData(mId, mEditorId, reader);
break; break;
default: default:
throw std::runtime_error( 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 <string>
#include <variant> #include <variant>
#include "formid.hpp" #include <components/esm/defs.hpp>
#include <components/esm/formid.hpp>
namespace ESM4 namespace ESM4
{ {
@ -15,12 +16,13 @@ namespace ESM4
{ {
using Data = std::variant<std::monostate, bool, float, std::int32_t, std::string>; 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::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId; std::string mEditorId;
Data mData; Data mData;
void load(Reader& reader); void load(Reader& reader);
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_GMST4;
}; };
} }

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

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

@ -30,6 +30,9 @@
#include <cstdint> #include <cstdint>
#include <vector> #include <vector>
#include <components/esm/formid.hpp>
#include <components/esm4/reader.hpp>
namespace ESM4 namespace ESM4
{ {
// http://www.uesp.net/wiki/Tes4Mod:Mod_File_Format#Hierarchical_Top_Groups // http://www.uesp.net/wiki/Tes4Mod:Mod_File_Format#Hierarchical_Top_Groups
@ -76,14 +79,14 @@ namespace ESM4
// //
struct WorldGroup struct WorldGroup
{ {
FormId mWorld; // WRLD record for this group ESM::FormId mWorld; // WRLD record for this group
// occurs only after World Child (type 1) // occurs only after World Child (type 1)
// since GRUP label may not be reliable, need to keep the formid of the current WRLD in // since GRUP label may not be reliable, need to keep the formid of the current WRLD in
// the reader's context // 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 // 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 // NOTE: There may be many CELL records in one subblock
struct CellGroup 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) 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 // 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 // cache (modindex adjusted) formId's of children
// FIXME: also need file index + file context of all those that has type 8 GRUP // FIXME: also need file index + file context of all those that has type 8 GRUP
GroupTypeHeader mHdrPersist; GroupTypeHeader mHdrPersist;
std::vector<FormId> mPersistent; // REFR, ACHR, ACRE std::vector<ESM::FormId> mPersistent; // REFR, ACHR, ACRE
std::vector<FormId> mdelPersistent; std::vector<ESM::FormId> mdelPersistent;
// FIXME: also need file index + file context of all those that has type 10 GRUP // FIXME: also need file index + file context of all those that has type 10 GRUP
GroupTypeHeader mHdrVisDist; GroupTypeHeader mHdrVisDist;
std::vector<FormId> mVisibleDist; // REFR, ACHR, ACRE std::vector<ESM::FormId> mVisibleDist; // REFR, ACHR, ACRE
std::vector<FormId> mdelVisibleDist; std::vector<ESM::FormId> mdelVisibleDist;
// FIXME: also need file index + file context of all those that has type 9 GRUP // FIXME: also need file index + file context of all those that has type 9 GRUP
GroupTypeHeader mHdrTemp; GroupTypeHeader mHdrTemp;
FormId mLand; // if present, assume only one LAND per exterior CELL ESM::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 ESM::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<ESM::FormId> mTemporary; // REFR, ACHR, ACRE
std::vector<FormId> mdelTemporary; std::vector<ESM::FormId> mdelTemporary;
// need to keep modindex and context for lazy loading (of all the files that contribute // need to keep modindex and context for lazy loading (of all the files that contribute
// to this group) // to this group)

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

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

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

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

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

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

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

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

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

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

@ -29,16 +29,17 @@
#include <cstring> #include <cstring>
#include <stdexcept> #include <stdexcept>
#include <components/esm/refid.hpp>
#include "reader.hpp" #include "reader.hpp"
//#include "writer.hpp" //#include "writer.hpp"
void ESM4::DialogInfo::load(ESM4::Reader& reader) void ESM4::DialogInfo::load(ESM4::Reader& reader)
{ {
mFormId = reader.hdr().record.getFormId(); mId = reader.getFormIdFromHeader();
reader.adjustFormId(mFormId);
mFlags = reader.hdr().record.flags; 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; static ScriptLocalVariableData localVar;
bool ignore = false; bool ignore = false;

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save