mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-28 04:41:34 +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)
|
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
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue