1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-28 17:41:34 +00:00

Merge branch 'ESSImportRegression' into 'master'

Import ESS kill count / selected spell as RefIDs, handle old INFO records

Closes #8559

See merge request OpenMW/openmw!4712
This commit is contained in:
Alexei Kotov 2025-06-12 23:28:15 +03:00
commit 019af35278
7 changed files with 32 additions and 18 deletions

View file

@ -252,7 +252,7 @@ namespace ESSImport
for (size_t i = 0; i < invState.mItems.size(); ++i) for (size_t i = 0; i < invState.mItems.size(); ++i)
{ {
// FIXME: in case of conflict (multiple items with this refID) use the already equipped one? // FIXME: in case of conflict (multiple items with this refID) use the already equipped one?
if (invState.mItems[i].mRef.mRefID == ESM::RefId::stringRefId(refr.mActorData.mSelectedEnchantItem)) if (invState.mItems[i].mRef.mRefID == refr.mActorData.mSelectedEnchantItem)
invState.mSelectedEnchantItem = i; invState.mSelectedEnchantItem = i;
} }
} }
@ -260,12 +260,12 @@ namespace ESSImport
void write(ESM::ESMWriter& esm) override void write(ESM::ESMWriter& esm) override
{ {
esm.startRecord(ESM::REC_ASPL); esm.startRecord(ESM::REC_ASPL);
esm.writeHNString("ID__", mSelectedSpell); esm.writeHNRefId("ID__", mSelectedSpell);
esm.endRecord(ESM::REC_ASPL); esm.endRecord(ESM::REC_ASPL);
} }
private: private:
std::string mSelectedSpell; ESM::RefId mSelectedSpell;
}; };
class ConvertPCDT : public Converter class ConvertPCDT : public Converter
@ -374,16 +374,16 @@ namespace ESSImport
void write(ESM::ESMWriter& esm) override void write(ESM::ESMWriter& esm) override
{ {
esm.startRecord(ESM::REC_DCOU); esm.startRecord(ESM::REC_DCOU);
for (auto it = mKillCounter.begin(); it != mKillCounter.end(); ++it) for (const auto& [id, count] : mKillCounter)
{ {
esm.writeHNString("ID__", it->first); esm.writeHNRefId("ID__", id);
esm.writeHNT("COUN", it->second); esm.writeHNT("COUN", count);
} }
esm.endRecord(ESM::REC_DCOU); esm.endRecord(ESM::REC_DCOU);
} }
private: private:
std::map<std::string, int> mKillCounter; std::map<ESM::RefId, int> mKillCounter;
}; };
class ConvertFACT : public Converter class ConvertFACT : public Converter

View file

@ -75,8 +75,8 @@ namespace ESSImport
// to change them ingame // to change them ingame
int mCombatStats[3][2]; int mCombatStats[3][2];
std::string mSelectedSpell; ESM::RefId mSelectedSpell;
std::string mSelectedEnchantItem; ESM::RefId mSelectedEnchantItem;
SCRI mSCRI; SCRI mSCRI;

View file

@ -107,12 +107,12 @@ namespace ESSImport
if (esm.isNextSub("WNAM")) if (esm.isNextSub("WNAM"))
{ {
std::string id = esm.getHString(); ESM::RefId spellRefId = esm.getRefId();
if (esm.isNextSub("XNAM")) if (esm.isNextSub("XNAM"))
mActorData.mSelectedEnchantItem = esm.getHString(); mActorData.mSelectedEnchantItem = esm.getRefId();
else else
mActorData.mSelectedSpell = std::move(id); mActorData.mSelectedSpell = std::move(spellRefId);
if (esm.isNextSub("YNAM")) if (esm.isNextSub("YNAM"))
esm.skipHSub(); // 4 byte, 0 esm.skipHSub(); // 4 byte, 0

View file

@ -7,7 +7,19 @@ namespace ESSImport
void INFO::load(ESM::ESMReader& esm) void INFO::load(ESM::ESMReader& esm)
{ {
mInfo = esm.getHNString("INAM"); if (esm.peekNextSub("XNAM"))
{
// TODO: Support older saves by turning XNAM into a RefId.
// XNAM is probably the number of the topic response within the topic record's linked list.
// Resolving this value will likely require loading Morrowind.esm.
esm.getSubName();
esm.skipHSub();
mInfo = ESM::RefId();
}
else
mInfo = esm.getHNRefId("INAM");
mActorRefId = esm.getHNString("ACDT"); mActorRefId = esm.getHNString("ACDT");
} }

View file

@ -3,6 +3,8 @@
#include <string> #include <string>
#include <components/esm/refid.hpp>
namespace ESM namespace ESM
{ {
class ESMReader; class ESMReader;
@ -13,7 +15,7 @@ namespace ESSImport
struct INFO struct INFO
{ {
std::string mInfo; ESM::RefId mInfo;
std::string mActorRefId; std::string mActorRefId;
void load(ESM::ESMReader& esm); void load(ESM::ESMReader& esm);

View file

@ -9,7 +9,7 @@ namespace ESSImport
{ {
while (esm.isNextSub("KNAM")) while (esm.isNextSub("KNAM"))
{ {
std::string refId = esm.getHString(); ESM::RefId refId = esm.getRefId();
int32_t count; int32_t count;
esm.getHNT(count, "CNAM"); esm.getHNT(count, "CNAM");
mKillCounter[refId] = count; mKillCounter[refId] = count;

View file

@ -3,7 +3,8 @@
#include <cstdint> #include <cstdint>
#include <map> #include <map>
#include <string>
#include <components/esm/refid.hpp>
namespace ESM namespace ESM
{ {
@ -18,8 +19,7 @@ namespace ESSImport
{ {
void load(ESM::ESMReader& esm); void load(ESM::ESMReader& esm);
/// RefId, kill count std::map<ESM::RefId, int32_t> mKillCounter;
std::map<std::string, int32_t> mKillCounter;
int32_t mWerewolfKills; int32_t mWerewolfKills;
}; };