From 9a6c2fd2ccab30ee6e9b14643562cd4e7de5233f Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Mon, 30 Oct 2023 23:23:39 +0300 Subject: [PATCH 1/2] Fill out ESM4::ItemMod --- components/esm4/loadimod.cpp | 38 ++++++++++++++++++++++++++++++++++-- components/esm4/loadimod.hpp | 19 ++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/components/esm4/loadimod.cpp b/components/esm4/loadimod.cpp index 7382946e2c..0359f6d23b 100644 --- a/components/esm4/loadimod.cpp +++ b/components/esm4/loadimod.cpp @@ -46,16 +46,50 @@ void ESM4::ItemMod::load(ESM4::Reader& reader) case ESM4::SUB_EDID: reader.getZString(mEditorId); break; - case ESM4::SUB_OBND: case ESM4::SUB_FULL: + reader.getLocalizedString(mFullName); + break; case ESM4::SUB_MODL: + reader.getZString(mModel); + break; + case ESM4::SUB_MODB: + reader.get(mBoundRadius); + break; + case ESM4::SUB_DESC: + reader.getLocalizedString(mText); + break; case ESM4::SUB_ICON: + reader.getZString(mIcon); + break; case ESM4::SUB_MICO: + reader.getZString(mMiniIcon); + break; case ESM4::SUB_SCRI: - case ESM4::SUB_DESC: + reader.getFormId(mScriptId); + break; case ESM4::SUB_YNAM: + reader.getFormId(mPickUpSound); + break; case ESM4::SUB_ZNAM: + reader.getFormId(mDropSound); + break; case ESM4::SUB_DATA: + reader.get(mData.mValue); + reader.get(mData.mWeight); + break; + case ESM4::SUB_OBND: + case ESM4::SUB_MODT: // Model data + case ESM4::SUB_MODS: + case ESM4::SUB_MODD: // Model data end + case ESM4::SUB_DAMC: // Destructible + case ESM4::SUB_DEST: + case ESM4::SUB_DMDC: + case ESM4::SUB_DMDL: + case ESM4::SUB_DMDT: + case ESM4::SUB_DMDS: + case ESM4::SUB_DSTA: + case ESM4::SUB_DSTD: + case ESM4::SUB_DSTF: // Destructible end reader.skipSubRecordData(); break; default: diff --git a/components/esm4/loadimod.hpp b/components/esm4/loadimod.hpp index f1faed978c..1f6250ae72 100644 --- a/components/esm4/loadimod.hpp +++ b/components/esm4/loadimod.hpp @@ -42,10 +42,29 @@ namespace ESM4 struct ItemMod { + struct Data + { + std::uint32_t mValue{ 0 }; + float mWeight{ 0.f }; + }; + ESM::FormId mId; // from the header std::uint32_t mFlags; // from the header, see enum type RecordFlag for details std::string mEditorId; + std::string mFullName; + std::string mModel; + std::string mText; + std::string mIcon; + std::string mMiniIcon; + + ESM::FormId mScriptId; + ESM::FormId mPickUpSound; + ESM::FormId mDropSound; + + float mBoundRadius; + + Data mData; void load(ESM4::Reader& reader); // void save(ESM4::Writer& writer) const; From 03c38182290843af1ce78380bd5d1f2798440d75 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Mon, 30 Oct 2023 23:33:11 +0300 Subject: [PATCH 2/2] Place ESM4::ItemMod into the scene --- apps/openmw/mwclass/classes.cpp | 2 ++ apps/openmw/mwlua/cellbindings.cpp | 4 ++++ apps/openmw/mwlua/types/types.cpp | 3 +++ apps/openmw/mwworld/cellstore.cpp | 1 + apps/openmw/mwworld/cellstore.hpp | 3 ++- apps/openmw/mwworld/esmstore.hpp | 5 +++-- apps/openmw/mwworld/store.cpp | 1 + components/esm/records.hpp | 1 + files/lua_api/openmw/types.lua | 3 +++ 9 files changed, 20 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwclass/classes.cpp b/apps/openmw/mwclass/classes.cpp index 5017b1b272..f96c73e529 100644 --- a/apps/openmw/mwclass/classes.cpp +++ b/apps/openmw/mwclass/classes.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -84,6 +85,7 @@ namespace MWClass ESM4Named::registerSelf(); ESM4Named::registerSelf(); ESM4Named::registerSelf(); + ESM4Named::registerSelf(); ESM4Light::registerSelf(); ESM4Named::registerSelf(); ESM4Named::registerSelf(); diff --git a/apps/openmw/mwlua/cellbindings.cpp b/apps/openmw/mwlua/cellbindings.cpp index 7c3b31c7b6..e43354bfaf 100644 --- a/apps/openmw/mwlua/cellbindings.cpp +++ b/apps/openmw/mwlua/cellbindings.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -232,6 +233,9 @@ namespace MWLua case ESM::REC_FURN4: cell.mStore->template forEachType(visitor); break; + case ESM::REC_IMOD4: + cell.mStore->template forEachType(visitor); + break; case ESM::REC_INGR4: cell.mStore->template forEachType(visitor); break; diff --git a/apps/openmw/mwlua/types/types.cpp b/apps/openmw/mwlua/types/types.cpp index bd8b592f7a..694b63ddf2 100644 --- a/apps/openmw/mwlua/types/types.cpp +++ b/apps/openmw/mwlua/types/types.cpp @@ -45,6 +45,7 @@ namespace MWLua constexpr std::string_view ESM4Flora = "ESM4Flora"; constexpr std::string_view ESM4Furniture = "ESM4Furniture"; constexpr std::string_view ESM4Ingredient = "ESM4Ingredient"; + constexpr std::string_view ESM4ItemMod = "ESM4ItemMod"; constexpr std::string_view ESM4Light = "ESM4Light"; constexpr std::string_view ESM4MiscItem = "ESM4Miscellaneous"; constexpr std::string_view ESM4MovableStatic = "ESM4MovableStatic"; @@ -90,6 +91,7 @@ namespace MWLua { ESM::REC_FLOR4, ObjectTypeName::ESM4Flora }, { ESM::REC_FURN4, ObjectTypeName::ESM4Furniture }, { ESM::REC_INGR4, ObjectTypeName::ESM4Ingredient }, + { ESM::REC_IMOD4, ObjectTypeName::ESM4ItemMod }, { ESM::REC_LIGH4, ObjectTypeName::ESM4Light }, { ESM::REC_MISC4, ObjectTypeName::ESM4MiscItem }, { ESM::REC_MSTT4, ObjectTypeName::ESM4MovableStatic }, @@ -230,6 +232,7 @@ namespace MWLua addType(ObjectTypeName::ESM4Flora, { ESM::REC_FLOR4 }); addType(ObjectTypeName::ESM4Furniture, { ESM::REC_FURN4 }); addType(ObjectTypeName::ESM4Ingredient, { ESM::REC_INGR4 }); + addType(ObjectTypeName::ESM4ItemMod, { ESM::REC_IMOD4 }); addType(ObjectTypeName::ESM4Light, { ESM::REC_LIGH4 }); addType(ObjectTypeName::ESM4MiscItem, { ESM::REC_MISC4 }); addType(ObjectTypeName::ESM4MovableStatic, { ESM::REC_MSTT4 }); diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index ff79940540..6ee638f233 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index debd80a97b..c80cf56d6a 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -72,6 +72,7 @@ namespace ESM4 struct Furniture; struct Flora; struct Ingredient; + struct ItemMod; struct MiscItem; struct MovableStatic; struct Terminal; @@ -96,7 +97,7 @@ namespace MWWorld CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, - CellRefList, CellRefList, CellRefList, + CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList>; diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index ceba4a26ef..16062c97db 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -91,6 +91,7 @@ namespace ESM4 struct Hair; struct HeadPart; struct Ingredient; + struct ItemMod; struct Land; struct LandTexture; struct LevelledCreature; @@ -140,8 +141,8 @@ namespace MWWorld Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, - Store, Store, Store, Store, Store, - Store, Store, Store, + Store, Store, Store, Store, Store, + Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store>; diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index e42675c66e..ac3ee72a94 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -1362,6 +1362,7 @@ 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 4473e0290f..ded4b92a92 100644 --- a/components/esm/records.hpp +++ b/components/esm/records.hpp @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include diff --git a/files/lua_api/openmw/types.lua b/files/lua_api/openmw/types.lua index 69ce5fbaf2..56cfd538f2 100644 --- a/files/lua_api/openmw/types.lua +++ b/files/lua_api/openmw/types.lua @@ -1875,6 +1875,9 @@ --- Functions for @{#ESM4Ingredient} objects -- @field [parent=#types] #ESM4Ingredient ESM4Ingredient +--- Functions for @{#ESM4ItemMod} objects +-- @field [parent=#types] #ESM4ItemMod ESM4ItemMod + --- Functions for @{#ESM4Light} objects -- @field [parent=#types] #ESM4Light ESM4Light