mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-27 18:41:37 +00:00
Import ESS kill count / selected spell as RefIDs, handle old INFO records
This commit is contained in:
parent
b988190fba
commit
f085717aef
7 changed files with 32 additions and 18 deletions
|
@ -252,7 +252,7 @@ namespace ESSImport
|
|||
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?
|
||||
if (invState.mItems[i].mRef.mRefID == ESM::RefId::stringRefId(refr.mActorData.mSelectedEnchantItem))
|
||||
if (invState.mItems[i].mRef.mRefID == refr.mActorData.mSelectedEnchantItem)
|
||||
invState.mSelectedEnchantItem = i;
|
||||
}
|
||||
}
|
||||
|
@ -260,12 +260,12 @@ namespace ESSImport
|
|||
void write(ESM::ESMWriter& esm) override
|
||||
{
|
||||
esm.startRecord(ESM::REC_ASPL);
|
||||
esm.writeHNString("ID__", mSelectedSpell);
|
||||
esm.writeHNRefId("ID__", mSelectedSpell);
|
||||
esm.endRecord(ESM::REC_ASPL);
|
||||
}
|
||||
|
||||
private:
|
||||
std::string mSelectedSpell;
|
||||
ESM::RefId mSelectedSpell;
|
||||
};
|
||||
|
||||
class ConvertPCDT : public Converter
|
||||
|
@ -374,16 +374,16 @@ namespace ESSImport
|
|||
void write(ESM::ESMWriter& esm) override
|
||||
{
|
||||
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.writeHNT("COUN", it->second);
|
||||
esm.writeHNRefId("ID__", id);
|
||||
esm.writeHNT("COUN", count);
|
||||
}
|
||||
esm.endRecord(ESM::REC_DCOU);
|
||||
}
|
||||
|
||||
private:
|
||||
std::map<std::string, int> mKillCounter;
|
||||
std::map<ESM::RefId, int> mKillCounter;
|
||||
};
|
||||
|
||||
class ConvertFACT : public Converter
|
||||
|
|
|
@ -75,8 +75,8 @@ namespace ESSImport
|
|||
// to change them ingame
|
||||
int mCombatStats[3][2];
|
||||
|
||||
std::string mSelectedSpell;
|
||||
std::string mSelectedEnchantItem;
|
||||
ESM::RefId mSelectedSpell;
|
||||
ESM::RefId mSelectedEnchantItem;
|
||||
|
||||
SCRI mSCRI;
|
||||
|
||||
|
|
|
@ -107,12 +107,12 @@ namespace ESSImport
|
|||
|
||||
if (esm.isNextSub("WNAM"))
|
||||
{
|
||||
std::string id = esm.getHString();
|
||||
ESM::RefId spellRefId = esm.getRefId();
|
||||
|
||||
if (esm.isNextSub("XNAM"))
|
||||
mActorData.mSelectedEnchantItem = esm.getHString();
|
||||
mActorData.mSelectedEnchantItem = esm.getRefId();
|
||||
else
|
||||
mActorData.mSelectedSpell = std::move(id);
|
||||
mActorData.mSelectedSpell = std::move(spellRefId);
|
||||
|
||||
if (esm.isNextSub("YNAM"))
|
||||
esm.skipHSub(); // 4 byte, 0
|
||||
|
|
|
@ -7,7 +7,19 @@ namespace ESSImport
|
|||
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESMReader;
|
||||
|
@ -13,7 +15,7 @@ namespace ESSImport
|
|||
|
||||
struct INFO
|
||||
{
|
||||
std::string mInfo;
|
||||
ESM::RefId mInfo;
|
||||
std::string mActorRefId;
|
||||
|
||||
void load(ESM::ESMReader& esm);
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace ESSImport
|
|||
{
|
||||
while (esm.isNextSub("KNAM"))
|
||||
{
|
||||
std::string refId = esm.getHString();
|
||||
ESM::RefId refId = esm.getRefId();
|
||||
int32_t count;
|
||||
esm.getHNT(count, "CNAM");
|
||||
mKillCounter[refId] = count;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
@ -18,8 +19,7 @@ namespace ESSImport
|
|||
{
|
||||
void load(ESM::ESMReader& esm);
|
||||
|
||||
/// RefId, kill count
|
||||
std::map<std::string, int32_t> mKillCounter;
|
||||
std::map<ESM::RefId, int32_t> mKillCounter;
|
||||
|
||||
int32_t mWerewolfKills;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue