Load more ESM4 records

depth-refraction
Petr Mikheev 2 years ago
parent a90815e8ed
commit ff774d6406

@ -1,5 +1,7 @@
#include "classes.hpp"
#include <components/esm/records.hpp>
#include "activator.hpp"
#include "apparatus.hpp"
#include "armor.hpp"
@ -49,7 +51,18 @@ namespace MWClass
Static::registerSelf();
BodyPart::registerSelf();
ESM4Static::registerSelf();
ESM4Static<ESM4::Activator>::registerSelf();
ESM4Static<ESM4::Potion>::registerSelf();
ESM4Static<ESM4::Ammunition>::registerSelf();
ESM4Static<ESM4::Armor>::registerSelf();
ESM4Static<ESM4::Book>::registerSelf();
ESM4Static<ESM4::Clothing>::registerSelf();
ESM4Static<ESM4::Container>::registerSelf();
ESM4Static<ESM4::Door>::registerSelf();
ESM4Static<ESM4::Ingredient>::registerSelf();
ESM4Static<ESM4::MiscItem>::registerSelf();
ESM4Static<ESM4::Static>::registerSelf();
ESM4Static<ESM4::Weapon>::registerSelf();
ESM4Light::registerSelf();
}
}

@ -65,13 +65,8 @@ namespace MWClass
return MWWorld::Ptr(cell.insert(ref), &cell);
}
ESM4Static::ESM4Static()
: MWWorld::RegisteredClass<ESM4Static>(ESM4::Static::sRecordId)
{
}
void ESM4Static ::insertObjectRendering(
const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
void ESM4StaticImpl::insertObjectRendering(
const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface)
{
if (!model.empty())
{
@ -80,37 +75,9 @@ namespace MWClass
}
}
void ESM4Static::insertObject(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
MWPhysics::PhysicsSystem& physics) const
{
insertObjectPhysics(ptr, model, rotation, physics);
}
void ESM4Static::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
MWPhysics::PhysicsSystem& physics) const
void ESM4StaticImpl::insertObjectPhysics(
const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics)
{
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_World);
}
std::string ESM4Static::getModel(const MWWorld::ConstPtr& ptr) const
{
return getClassModel<ESM4::Static>(ptr);
}
std::string_view ESM4Static ::getName(const MWWorld::ConstPtr& ptr) const
{
return {};
}
bool ESM4Static::hasToolTip(const MWWorld::ConstPtr& ptr) const
{
return false;
}
MWWorld::Ptr ESM4Static::copyToCellImpl(const MWWorld::ConstPtr& ptr, MWWorld::CellStore& cell) const
{
const MWWorld::LiveCellRef<ESM4::Static>* ref = ptr.get<ESM4::Static>();
return MWWorld::Ptr(cell.insert(ref), &cell);
}
}

@ -1,8 +1,11 @@
#ifndef GAME_MWCLASS_STATIC_H
#define GAME_MWCLASS_STATIC_H
#include "../mwworld/cellstore.hpp"
#include "../mwworld/registeredclass.hpp"
#include "classmodel.hpp"
namespace MWClass
{
class Static : public MWWorld::RegisteredClass<Static>
@ -32,31 +35,56 @@ namespace MWClass
std::string getModel(const MWWorld::ConstPtr& ptr) const override;
};
class ESM4Static : public MWWorld::RegisteredClass<ESM4Static>
namespace ESM4StaticImpl
{
void insertObjectRendering(
const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface);
void insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
MWPhysics::PhysicsSystem& physics);
}
// Templated because it is used as a dummy MWClass implementation for several ESM4 recors
template <typename Record>
class ESM4Static : public MWWorld::RegisteredClass<ESM4Static<Record>>
{
friend MWWorld::RegisteredClass<ESM4Static>;
ESM4Static();
ESM4Static()
: MWWorld::RegisteredClass<ESM4Static>(Record::sRecordId)
{
}
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr& ptr, MWWorld::CellStore& cell) const override;
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr& ptr, MWWorld::CellStore& cell) const override
{
const MWWorld::LiveCellRef<Record>* ref = ptr.get<Record>();
return MWWorld::Ptr(cell.insert(ref), &cell);
}
public:
void insertObjectRendering(const MWWorld::Ptr& ptr, const std::string& model,
MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering
MWRender::RenderingInterface& renderingInterface) const override
{
ESM4StaticImpl::insertObjectRendering(ptr, model, renderingInterface);
}
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
MWPhysics::PhysicsSystem& physics) const override;
MWPhysics::PhysicsSystem& physics) const override
{
insertObjectPhysics(ptr, model, rotation, physics);
}
void insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
MWPhysics::PhysicsSystem& physics) const override;
MWPhysics::PhysicsSystem& physics) const override
{
ESM4StaticImpl::insertObjectPhysics(ptr, model, rotation, physics);
}
std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
std::string_view getName(const MWWorld::ConstPtr& ptr) const override { return ""; }
///< \return name or ID; can return an empty string.
bool hasToolTip(const MWWorld::ConstPtr& ptr) const override;
bool hasToolTip(const MWWorld::ConstPtr& ptr) const override { return false; }
///< @return true if this object has a tooltip when focused (default implementation: true)
std::string getModel(const MWWorld::ConstPtr& ptr) const override;
std::string getModel(const MWWorld::ConstPtr& ptr) const override { return getClassModel<Record>(ptr); }
};
}

@ -7,6 +7,7 @@
#include <components/debug/debuglog.hpp>
#include <components/esm/format.hpp>
#include <components/esm/records.hpp>
#include <components/esm3/cellref.hpp>
#include <components/esm3/cellstate.hpp>
#include <components/esm3/containerstate.hpp>

@ -60,6 +60,17 @@ namespace ESM4
struct Reference;
struct Static;
struct Light;
struct Activator;
struct Potion;
struct Ammunition;
struct Armor;
struct Book;
struct Clothing;
struct Container;
struct Door;
struct Ingredient;
struct MiscItem;
struct Weapon;
}
namespace MWWorld
@ -74,7 +85,10 @@ namespace MWWorld
CellRefList<ESM::Lockpick>, CellRefList<ESM::Miscellaneous>, CellRefList<ESM::NPC>, CellRefList<ESM::Probe>,
CellRefList<ESM::Repair>, CellRefList<ESM::Static>, CellRefList<ESM::Weapon>, CellRefList<ESM::BodyPart>,
CellRefList<ESM4::Static>, CellRefList<ESM4::Light>>;
CellRefList<ESM4::Static>, CellRefList<ESM4::Light>, CellRefList<ESM4::Activator>, CellRefList<ESM4::Potion>,
CellRefList<ESM4::Ammunition>, CellRefList<ESM4::Armor>, CellRefList<ESM4::Book>, CellRefList<ESM4::Clothing>,
CellRefList<ESM4::Container>, CellRefList<ESM4::Door>, CellRefList<ESM4::Ingredient>,
CellRefList<ESM4::MiscItem>, CellRefList<ESM4::Weapon>>;
/// \brief Mutable state of a cell
class CellStore

@ -14,10 +14,6 @@
#include <components/misc/algorithm.hpp>
#include <components/esm4/common.hpp>
#include <components/esm4/loadcell.hpp>
#include <components/esm4/loadligh.hpp>
#include <components/esm4/loadrefr.hpp>
#include <components/esm4/loadstat.hpp>
#include <components/esm4/reader.hpp>
#include <components/esm4/readerutils.hpp>
#include <components/esmloader/load.hpp>
@ -281,6 +277,16 @@ namespace MWWorld
case ESM::REC_BODY:
case ESM::REC_STAT4:
case ESM::REC_LIGH4:
case ESM::REC_ACTI4:
case ESM::REC_ALCH4:
case ESM::REC_AMMO4:
case ESM::REC_ARMO4:
case ESM::REC_BOOK4:
case ESM::REC_CONT4:
case ESM::REC_DOOR4:
case ESM::REC_INGR4:
case ESM::REC_MISC4:
case ESM::REC_WEAP4:
return true;
break;
}

@ -31,6 +31,17 @@ namespace ESM4
struct Cell;
struct Light;
struct Reference;
struct Activator;
struct Potion;
struct Ammunition;
struct Armor;
struct Book;
struct Clothing;
struct Container;
struct Door;
struct Ingredient;
struct MiscItem;
struct Weapon;
}
namespace ESM
@ -106,7 +117,10 @@ namespace MWWorld
// Special entry which is hardcoded and not loaded from an ESM
Store<ESM::Attribute>,
Store<ESM4::Static>, Store<ESM4::Cell>, Store<ESM4::Light>, Store<ESM4::Reference>>;
Store<ESM4::Static>, Store<ESM4::Cell>, Store<ESM4::Light>, Store<ESM4::Reference>, Store<ESM4::Activator>,
Store<ESM4::Potion>, Store<ESM4::Ammunition>, Store<ESM4::Armor>, Store<ESM4::Book>, Store<ESM4::Clothing>,
Store<ESM4::Container>, Store<ESM4::Door>, Store<ESM4::Ingredient>, Store<ESM4::MiscItem>,
Store<ESM4::Weapon>>;
private:
template <typename T>

@ -8,10 +8,6 @@
#include <components/esm/records.hpp>
#include <components/esm3/esmreader.hpp>
#include <components/esm3/esmwriter.hpp>
#include <components/esm4/loadcell.hpp>
#include <components/esm4/loadligh.hpp>
#include <components/esm4/loadrefr.hpp>
#include <components/esm4/loadstat.hpp>
#include <components/loadinglistener/loadinglistener.hpp>
#include <components/misc/rng.hpp>
@ -1266,7 +1262,18 @@ template class MWWorld::TypedDynamicStore<ESM::StartScript>;
template class MWWorld::TypedDynamicStore<ESM::Static>;
template class MWWorld::TypedDynamicStore<ESM::Weapon>;
template class MWWorld::TypedDynamicStore<ESM4::Activator>;
template class MWWorld::TypedDynamicStore<ESM4::Potion>;
template class MWWorld::TypedDynamicStore<ESM4::Ammunition>;
template class MWWorld::TypedDynamicStore<ESM4::Armor>;
template class MWWorld::TypedDynamicStore<ESM4::Book>;
template class MWWorld::TypedDynamicStore<ESM4::Clothing>;
template class MWWorld::TypedDynamicStore<ESM4::Container>;
template class MWWorld::TypedDynamicStore<ESM4::Door>;
template class MWWorld::TypedDynamicStore<ESM4::Ingredient>;
template class MWWorld::TypedDynamicStore<ESM4::MiscItem>;
template class MWWorld::TypedDynamicStore<ESM4::Static>;
template class MWWorld::TypedDynamicStore<ESM4::Light>;
template class MWWorld::TypedDynamicStore<ESM4::Reference>;
template class MWWorld::TypedDynamicStore<ESM4::Cell>;
template class MWWorld::TypedDynamicStore<ESM4::Weapon>;

@ -42,6 +42,23 @@
#include "components/esm3/loadsscr.hpp"
#include "components/esm3/loadstat.hpp"
#include "components/esm3/loadweap.hpp"
#include <components/esm4/loadacti.hpp>
#include <components/esm4/loadalch.hpp>
#include <components/esm4/loadammo.hpp>
#include <components/esm4/loadarmo.hpp>
#include <components/esm4/loadbook.hpp>
#include <components/esm4/loadcell.hpp>
#include <components/esm4/loadclot.hpp>
#include <components/esm4/loadcont.hpp>
#include <components/esm4/loaddoor.hpp>
#include <components/esm4/loadingr.hpp>
#include <components/esm4/loadligh.hpp>
#include <components/esm4/loadmisc.hpp>
#include <components/esm4/loadrefr.hpp>
#include <components/esm4/loadstat.hpp>
#include <components/esm4/loadweap.hpp>
#include "defs.hpp"
// Special records which are not loaded from ESM

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

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

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

@ -30,6 +30,9 @@
#include <cstdint>
#include <string>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "effect.hpp" // FormId, ScriptEffect
namespace ESM4
@ -55,7 +58,7 @@ namespace ESM4
};
#pragma pack(pop)
FormId mFormId; // from the header
ESM::RefId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -79,6 +82,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_ALCH4;
};
}

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

@ -31,6 +31,9 @@
#include <string>
#include <vector>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "formid.hpp"
namespace ESM4
@ -54,7 +57,7 @@ namespace ESM4
float mConsumedPercentage{ 0.f };
};
FormId mFormId; // from the header
ESM::RefId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -84,6 +87,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_AMMO4;
};
}

@ -34,8 +34,7 @@
void ESM4::Armor::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getRefIdFromHeader();
mFlags = reader.hdr().record.flags;
std::uint32_t esmVer = reader.esmVersion();
mIsFONV = esmVer == ESM::VER_132 || esmVer == ESM::VER_133 || esmVer == ESM::VER_134;

@ -31,6 +31,9 @@
#include <string>
#include <vector>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "formid.hpp"
namespace ESM4
@ -148,7 +151,7 @@ namespace ESM4
};
#pragma pack(pop)
FormId mFormId; // from the header
ESM::RefId 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
@ -187,6 +190,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_ARMO4;
};
}

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

@ -30,6 +30,9 @@
#include <cstdint>
#include <string>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "formid.hpp"
namespace ESM4
@ -81,7 +84,7 @@ namespace ESM4
float weight;
};
FormId mFormId; // from the header
ESM::RefId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -105,6 +108,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_BOOK4;
};
}

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

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

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

@ -31,6 +31,9 @@
#include <string>
#include <vector>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "formid.hpp"
#include "inventory.hpp" // InventoryItem
@ -41,7 +44,7 @@ namespace ESM4
struct Container
{
FormId mFormId; // from the header
ESM::RefId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -62,6 +65,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_CONT4;
};
}

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

@ -30,6 +30,9 @@
#include <cstdint>
#include <string>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "formid.hpp"
namespace ESM4
@ -47,7 +50,7 @@ namespace ESM4
Flag_MinimalUse = 0x08
};
FormId mFormId; // from the header
ESM::RefId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -67,6 +70,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_DOOR4;
};
}

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

@ -30,6 +30,9 @@
#include <cstdint>
#include <vector>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "effect.hpp"
namespace ESM4
@ -53,7 +56,7 @@ namespace ESM4
};
#pragma pack(pop)
FormId mFormId; // from the header
ESM::RefId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -74,6 +77,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_INGR4;
};
}

@ -33,9 +33,7 @@
void ESM4::Light::load(ESM4::Reader& reader)
{
FormId formId = reader.hdr().record.getFormId();
reader.adjustFormId(formId);
mId = ESM::RefId::formIdRefId(formId);
mId = reader.getRefIdFromHeader();
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;

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

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

@ -34,9 +34,7 @@
void ESM4::Static::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = ESM::RefId::formIdRefId(mFormId);
mId = reader.getRefIdFromHeader();
mFlags = reader.hdr().record.flags;
while (reader.getSubRecordHeader())

@ -33,8 +33,7 @@
void ESM4::Weapon::load(ESM4::Reader& reader)
{
mFormId = reader.hdr().record.getFormId();
reader.adjustFormId(mFormId);
mId = reader.getRefIdFromHeader();
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,6 +30,9 @@
#include <cstdint>
#include <string>
#include <components/esm/defs.hpp>
#include <components/esm/refid.hpp>
#include "formid.hpp"
namespace ESM4
@ -72,7 +75,7 @@ namespace ESM4
}
};
FormId mFormId; // from the header
ESM::RefId mId; // from the header
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
std::string mEditorId;
@ -97,6 +100,7 @@ namespace ESM4
// void save(ESM4::Writer& writer) const;
// void blank();
static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_WEAP4;
};
}

@ -603,7 +603,7 @@ namespace ESM4
// FIXME: Apparently ModIndex '00' in an ESP means the object is defined in one of its masters.
// This means we may need to search multiple times to get the correct id.
// (see https://www.uesp.net/wiki/Tes4Mod:Formid#ModIndex_Zero)
void Reader::adjustFormId(FormId& id)
void Reader::adjustFormId(FormId& id) const
{
if (id.hasContentFile() && id.mContentFile < static_cast<int>(mCtx.parentFileIndices.size()))
id.mContentFile = mCtx.parentFileIndices[id.mContentFile];
@ -611,7 +611,7 @@ namespace ESM4
id.mContentFile = mCtx.modIndex;
}
void Reader::adjustFormId(FormId32& id)
void Reader::adjustFormId(FormId32& id) const
{
FormId formId = FormId::fromUint32(id);
adjustFormId(formId);
@ -629,6 +629,13 @@ namespace ESM4
return true;
}
ESM::FormIdRefId Reader::getRefIdFromHeader() const
{
FormId formId = hdr().record.getFormId();
adjustFormId(formId);
return ESM::FormIdRefId(formId);
}
void Reader::adjustGRUPFormId()
{
adjustFormId(mCtx.recordHeader.group.label.value);

@ -33,6 +33,7 @@
#include "common.hpp"
#include "loadtes4.hpp"
#include <components/esm/formidrefid.hpp>
#include <components/files/istreamptr.hpp>
#include <components/vfs/manager.hpp>
@ -333,12 +334,13 @@ namespace ESM4
}
// ModIndex adjusted formId according to master file dependencies
void adjustFormId(FormId& id);
void adjustFormId(FormId& id) const;
// Temporary. Doesn't support mod index > 255
void adjustFormId(FormId32& id);
void adjustFormId(FormId32& id) const;
bool getFormId(FormId& id);
ESM::FormIdRefId getRefIdFromHeader() const;
void adjustGRUPFormId();

Loading…
Cancel
Save