|
|
|
#include "activespells.hpp"
|
|
|
|
|
|
|
|
#include "esmreader.hpp"
|
|
|
|
#include "esmwriter.hpp"
|
|
|
|
|
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
void saveImpl(ESMWriter& esm, const std::vector<ActiveSpells::ActiveSpellParams>& spells, NAME tag)
|
|
|
|
{
|
|
|
|
for (const auto& params : spells)
|
|
|
|
{
|
|
|
|
esm.writeHNRefId(tag, params.mId);
|
|
|
|
|
|
|
|
esm.writeHNT("CAST", params.mCasterActorId);
|
|
|
|
esm.writeHNString("DISP", params.mDisplayName);
|
|
|
|
esm.writeHNT("TYPE", params.mType);
|
|
|
|
if (params.mItem.isSet())
|
|
|
|
esm.writeFormId(params.mItem, true, "ITEM");
|
|
|
|
if (params.mWorsenings >= 0)
|
|
|
|
{
|
|
|
|
esm.writeHNT("WORS", params.mWorsenings);
|
|
|
|
esm.writeHNT("TIME", params.mNextWorsening);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto& effect : params.mEffects)
|
|
|
|
{
|
|
|
|
esm.writeHNT("MGEF", effect.mEffectId);
|
|
|
|
if (effect.mArg != -1)
|
|
|
|
esm.writeHNT("ARG_", effect.mArg);
|
|
|
|
esm.writeHNT("MAGN", effect.mMagnitude);
|
|
|
|
esm.writeHNT("MAGN", effect.mMinMagnitude);
|
|
|
|
esm.writeHNT("MAGN", effect.mMaxMagnitude);
|
|
|
|
esm.writeHNT("DURA", effect.mDuration);
|
|
|
|
esm.writeHNT("EIND", effect.mEffectIndex);
|
|
|
|
esm.writeHNT("LEFT", effect.mTimeLeft);
|
|
|
|
esm.writeHNT("FLAG", effect.mFlags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadImpl(ESMReader& esm, std::vector<ActiveSpells::ActiveSpellParams>& spells, NAME tag)
|
|
|
|
{
|
|
|
|
const FormatVersion format = esm.getFormatVersion();
|
|
|
|
|
|
|
|
while (esm.isNextSub(tag))
|
|
|
|
{
|
|
|
|
ActiveSpells::ActiveSpellParams params;
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2 years ago
|
|
|
params.mId = esm.getRefId();
|
|
|
|
esm.getHNT(params.mCasterActorId, "CAST");
|
|
|
|
params.mDisplayName = esm.getHNString("DISP");
|
|
|
|
if (format <= MaxClearModifiersFormatVersion)
|
|
|
|
params.mType = ActiveSpells::Type_Temporary;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
esm.getHNT(params.mType, "TYPE");
|
|
|
|
if (esm.peekNextSub("ITEM"))
|
|
|
|
{
|
|
|
|
if (format <= MaxActiveSpellSlotIndexFormatVersion)
|
|
|
|
// Previous versions saved slot index in this record.
|
|
|
|
// Ignore these values as we can't use them
|
|
|
|
esm.getFormId(true, "ITEM");
|
|
|
|
else
|
|
|
|
params.mItem = esm.getFormId(true, "ITEM");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (esm.isNextSub("WORS"))
|
|
|
|
{
|
|
|
|
esm.getHT(params.mWorsenings);
|
|
|
|
esm.getHNTSized<8>(params.mNextWorsening, "TIME");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
params.mWorsenings = -1;
|
|
|
|
|
|
|
|
// spell casting timestamp, no longer used
|
|
|
|
if (esm.isNextSub("TIME"))
|
|
|
|
esm.skipHSub();
|
|
|
|
|
|
|
|
while (esm.isNextSub("MGEF"))
|
|
|
|
{
|
|
|
|
ActiveEffect effect;
|
|
|
|
esm.getHT(effect.mEffectId);
|
|
|
|
effect.mArg = -1;
|
|
|
|
esm.getHNOT(effect.mArg, "ARG_");
|
|
|
|
esm.getHNT(effect.mMagnitude, "MAGN");
|
|
|
|
if (format <= MaxClearModifiersFormatVersion)
|
|
|
|
{
|
|
|
|
effect.mMinMagnitude = effect.mMagnitude;
|
|
|
|
effect.mMaxMagnitude = effect.mMagnitude;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
esm.getHNT(effect.mMinMagnitude, "MAGN");
|
|
|
|
esm.getHNT(effect.mMaxMagnitude, "MAGN");
|
|
|
|
}
|
|
|
|
esm.getHNT(effect.mDuration, "DURA");
|
|
|
|
effect.mEffectIndex = -1;
|
|
|
|
esm.getHNOT(effect.mEffectIndex, "EIND");
|
|
|
|
if (format <= MaxOldTimeLeftFormatVersion)
|
|
|
|
effect.mTimeLeft = effect.mDuration;
|
|
|
|
else
|
|
|
|
esm.getHNT(effect.mTimeLeft, "LEFT");
|
|
|
|
if (format <= MaxClearModifiersFormatVersion)
|
|
|
|
effect.mFlags = ActiveEffect::Flag_None;
|
|
|
|
else
|
|
|
|
esm.getHNT(effect.mFlags, "FLAG");
|
|
|
|
|
|
|
|
params.mEffects.push_back(effect);
|
|
|
|
}
|
|
|
|
spells.emplace_back(params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
void ActiveSpells::save(ESMWriter& esm) const
|
|
|
|
{
|
|
|
|
saveImpl(esm, mSpells, "ID__");
|
|
|
|
saveImpl(esm, mQueue, "QID_");
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActiveSpells::load(ESMReader& esm)
|
|
|
|
{
|
|
|
|
loadImpl(esm, mSpells, "ID__");
|
|
|
|
loadImpl(esm, mQueue, "QID_");
|
|
|
|
}
|
|
|
|
}
|