diff --git a/apps/openmw/mwclass/classes.cpp b/apps/openmw/mwclass/classes.cpp index a60bdc57af..5b53da317e 100644 --- a/apps/openmw/mwclass/classes.cpp +++ b/apps/openmw/mwclass/classes.cpp @@ -61,9 +61,11 @@ namespace MWClass ESM4Named::registerSelf(); ESM4Named::registerSelf(); ESM4Named::registerSelf(); + ESM4Named::registerSelf(); ESM4Named::registerSelf(); ESM4Named::registerSelf(); ESM4Static::registerSelf(); + ESM4Tree::registerSelf(); ESM4Named::registerSelf(); ESM4Light::registerSelf(); } diff --git a/apps/openmw/mwclass/esm4base.hpp b/apps/openmw/mwclass/esm4base.hpp index 6a28faf2f3..abd4989a68 100644 --- a/apps/openmw/mwclass/esm4base.hpp +++ b/apps/openmw/mwclass/esm4base.hpp @@ -2,6 +2,7 @@ #define GAME_MWCLASS_ESM4BASE_H #include +#include #include #include "../mwgui/tooltips.hpp" @@ -88,6 +89,15 @@ namespace MWClass } }; + class ESM4Tree final : public MWWorld::RegisteredClass> + { + friend MWWorld::RegisteredClass>; + ESM4Tree() + : MWWorld::RegisteredClass>(ESM4::Tree::sRecordId) + { + } + }; + // For records with `mFullName` that should be shown as a tooltip. // All objects with a tooltip can be activated (activation can be handled in Lua). template diff --git a/apps/openmw/mwlua/cellbindings.cpp b/apps/openmw/mwlua/cellbindings.cpp index 83102df61f..a8e448aa6c 100644 --- a/apps/openmw/mwlua/cellbindings.cpp +++ b/apps/openmw/mwlua/cellbindings.cpp @@ -188,6 +188,9 @@ namespace MWLua case ESM::REC_DOOR4: cell.mStore->template forEachType(visitor); break; + case ESM::REC_FURN4: + cell.mStore->template forEachType(visitor); + break; case ESM::REC_INGR4: cell.mStore->template forEachType(visitor); break; @@ -203,6 +206,9 @@ namespace MWLua case ESM::REC_STAT4: cell.mStore->template forEachType(visitor); break; + case ESM::REC_TREE4: + cell.mStore->template forEachType(visitor); + break; case ESM::REC_WEAP4: cell.mStore->template forEachType(visitor); break; diff --git a/apps/openmw/mwlua/types/types.cpp b/apps/openmw/mwlua/types/types.cpp index 5b1d6c5278..8af374af2e 100644 --- a/apps/openmw/mwlua/types/types.cpp +++ b/apps/openmw/mwlua/types/types.cpp @@ -40,11 +40,13 @@ namespace MWLua constexpr std::string_view ESM4Clothing = "ESM4Clothing"; constexpr std::string_view ESM4Container = "ESM4Container"; constexpr std::string_view ESM4Door = "ESM4Door"; + constexpr std::string_view ESM4Furniture = "ESM4Furniture"; constexpr std::string_view ESM4Ingredient = "ESM4Ingredient"; constexpr std::string_view ESM4Light = "ESM4Light"; constexpr std::string_view ESM4MiscItem = "ESM4Miscellaneous"; constexpr std::string_view ESM4Potion = "ESM4Potion"; constexpr std::string_view ESM4Static = "ESM4Static"; + constexpr std::string_view ESM4Tree = "ESM4Tree"; constexpr std::string_view ESM4Weapon = "ESM4Weapon"; } @@ -79,11 +81,13 @@ namespace MWLua { ESM::REC_CLOT4, ObjectTypeName::ESM4Clothing }, { ESM::REC_CONT4, ObjectTypeName::ESM4Container }, { ESM::REC_DOOR4, ObjectTypeName::ESM4Door }, + { ESM::REC_FURN4, ObjectTypeName::ESM4Furniture }, { ESM::REC_INGR4, ObjectTypeName::ESM4Ingredient }, { ESM::REC_LIGH4, ObjectTypeName::ESM4Light }, { ESM::REC_MISC4, ObjectTypeName::ESM4MiscItem }, { ESM::REC_ALCH4, ObjectTypeName::ESM4Potion }, { ESM::REC_STAT4, ObjectTypeName::ESM4Static }, + { ESM::REC_TREE4, ObjectTypeName::ESM4Tree }, { ESM::REC_WEAP4, ObjectTypeName::ESM4Weapon }, }; } @@ -210,11 +214,13 @@ namespace MWLua addType(ObjectTypeName::ESM4Clothing, { ESM::REC_CLOT4 }); addType(ObjectTypeName::ESM4Container, { ESM::REC_CONT4 }); addESM4DoorBindings(addType(ObjectTypeName::ESM4Door, { ESM::REC_DOOR4 }), context); + addType(ObjectTypeName::ESM4Furniture, { ESM::REC_FURN4 }); addType(ObjectTypeName::ESM4Ingredient, { ESM::REC_INGR4 }); addType(ObjectTypeName::ESM4Light, { ESM::REC_LIGH4 }); addType(ObjectTypeName::ESM4MiscItem, { ESM::REC_MISC4 }); addType(ObjectTypeName::ESM4Potion, { ESM::REC_ALCH4 }); addType(ObjectTypeName::ESM4Static, { ESM::REC_STAT4 }); + addType(ObjectTypeName::ESM4Tree, { ESM::REC_TREE4 }); addType(ObjectTypeName::ESM4Weapon, { ESM::REC_WEAP4 }); sol::table typeToPackage = getTypeToPackageTable(context.mLua->sol()); diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index f0690e13a1..c8187328b5 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -68,8 +68,10 @@ namespace ESM4 struct Clothing; struct Container; struct Door; + struct Furniture; struct Ingredient; struct MiscItem; + struct Tree; struct Weapon; } @@ -87,8 +89,8 @@ namespace MWWorld CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, - CellRefList, CellRefList, CellRefList, - CellRefList, CellRefList>; + CellRefList, CellRefList, CellRefList, CellRefList, + CellRefList, CellRefList, CellRefList>; /// \brief Mutable state of a cell class CellStore diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index 598ec70a5c..97e28ece33 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -286,8 +286,10 @@ namespace MWWorld case ESM::REC_BOOK4: case ESM::REC_CONT4: case ESM::REC_DOOR4: + case ESM::REC_FURN4: case ESM::REC_INGR4: case ESM::REC_MISC4: + case ESM::REC_TREE4: case ESM::REC_WEAP4: return true; break; diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index 1818a3bc02..535f5fb430 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -39,8 +39,10 @@ namespace ESM4 struct Clothing; struct Container; struct Door; + struct Furniture; struct Ingredient; struct MiscItem; + struct Tree; struct Weapon; struct World; struct Land; @@ -122,7 +124,7 @@ namespace MWWorld Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, - Store, Store, Store>; + Store, Store, Store, Store, Store>; private: template diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index d9520dc3b3..639c710119 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -1298,9 +1298,11 @@ template class MWWorld::TypedDynamicStore; template class MWWorld::TypedDynamicStore; template class MWWorld::TypedDynamicStore; template class MWWorld::TypedDynamicStore; +template class MWWorld::TypedDynamicStore; template class MWWorld::TypedDynamicStore; template class MWWorld::TypedDynamicStore; template class MWWorld::TypedDynamicStore; +template class MWWorld::TypedDynamicStore; template class MWWorld::TypedDynamicStore; template class MWWorld::TypedDynamicStore; template class MWWorld::TypedDynamicStore; diff --git a/components/esm/records.hpp b/components/esm/records.hpp index 1ef0c72c8f..fe5e6176f8 100644 --- a/components/esm/records.hpp +++ b/components/esm/records.hpp @@ -52,11 +52,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include "defs.hpp" diff --git a/components/esm4/loadfurn.cpp b/components/esm4/loadfurn.cpp index 5e0ad81c0d..fe3269ab32 100644 --- a/components/esm4/loadfurn.cpp +++ b/components/esm4/loadfurn.cpp @@ -33,8 +33,7 @@ void ESM4::Furniture::load(ESM4::Reader& reader) { - mFormId = reader.hdr().record.getFormId(); - reader.adjustFormId(mFormId); + mId = reader.getRefIdFromHeader(); mFlags = reader.hdr().record.flags; while (reader.getSubRecordHeader()) diff --git a/components/esm4/loadfurn.hpp b/components/esm4/loadfurn.hpp index 8fc8e47d1c..3bc88da4a5 100644 --- a/components/esm4/loadfurn.hpp +++ b/components/esm4/loadfurn.hpp @@ -30,6 +30,9 @@ #include #include +#include +#include + #include "formid.hpp" namespace ESM4 @@ -39,7 +42,7 @@ namespace ESM4 struct Furniture { - 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; @@ -55,6 +58,7 @@ namespace ESM4 // void save(ESM4::Writer& writer) const; // void blank(); + static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_FURN4; }; } diff --git a/components/esm4/loadtree.cpp b/components/esm4/loadtree.cpp index fa8dfbca49..efed827341 100644 --- a/components/esm4/loadtree.cpp +++ b/components/esm4/loadtree.cpp @@ -33,8 +33,7 @@ void ESM4::Tree::load(ESM4::Reader& reader) { - mFormId = reader.hdr().record.getFormId(); - reader.adjustFormId(mFormId); + mId = reader.getRefIdFromHeader(); mFlags = reader.hdr().record.flags; while (reader.getSubRecordHeader()) diff --git a/components/esm4/loadtree.hpp b/components/esm4/loadtree.hpp index cc4f88fad6..22921096f3 100644 --- a/components/esm4/loadtree.hpp +++ b/components/esm4/loadtree.hpp @@ -30,7 +30,8 @@ #include #include -#include "formid.hpp" +#include +#include namespace ESM4 { @@ -39,7 +40,7 @@ namespace ESM4 struct Tree { - 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; @@ -53,6 +54,7 @@ namespace ESM4 // void save(ESM4::Writer& writer) const; // void blank(); + static constexpr ESM::RecNameInts sRecordId = ESM::RecNameInts::REC_TREE4; }; }