1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-29 04:20:29 +00:00

Automatically drop workaround when the format is next updated

This commit is contained in:
Evil Eye 2021-12-24 23:17:50 +01:00
parent 826553f2be
commit c1f59b1221
7 changed files with 25 additions and 19 deletions

View File

@ -2,7 +2,6 @@
#include <stdexcept> #include <stdexcept>
#include <algorithm> #include <algorithm>
#include <climits> // INT_MIN
#include <osgDB/WriteFile> #include <osgDB/WriteFile>
@ -371,7 +370,7 @@ namespace ESSImport
if (cellref.mHasACDT) if (cellref.mHasACDT)
convertACDT(cellref.mACDT, objstate.mCreatureStats); convertACDT(cellref.mACDT, objstate.mCreatureStats);
else else
objstate.mCreatureStats.mGoldPool = INT_MIN; // HACK: indicates no ACDT objstate.mCreatureStats.mMissingACDT = true;
if (cellref.mHasACSC) if (cellref.mHasACSC)
convertACSC(cellref.mACSC, objstate.mCreatureStats); convertACSC(cellref.mACSC, objstate.mCreatureStats);
convertNpcData(cellref, objstate.mNpcStats); convertNpcData(cellref, objstate.mNpcStats);
@ -414,7 +413,7 @@ namespace ESSImport
if (cellref.mHasACDT) if (cellref.mHasACDT)
convertACDT(cellref.mACDT, objstate.mCreatureStats); convertACDT(cellref.mACDT, objstate.mCreatureStats);
else else
objstate.mCreatureStats.mGoldPool = INT_MIN; // HACK: indicates no ACDT objstate.mCreatureStats.mMissingACDT = true;
if (cellref.mHasACSC) if (cellref.mHasACSC)
convertACSC(cellref.mACSC, objstate.mCreatureStats); convertACSC(cellref.mACSC, objstate.mCreatureStats);
convertCREC(crecIt->second, objstate); convertCREC(crecIt->second, objstate);

View File

@ -1,7 +1,5 @@
#include "creature.hpp" #include "creature.hpp"
#include <climits> // INT_MIN
#include <components/misc/rng.hpp> #include <components/misc/rng.hpp>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/esm/loadcrea.hpp> #include <components/esm/loadcrea.hpp>
@ -758,9 +756,7 @@ namespace MWClass
{ {
if (!ptr.getRefData().getCustomData()) if (!ptr.getRefData().getCustomData())
{ {
// FIXME: the use of mGoldPool can be replaced with another flag the next time if (creatureState.mCreatureStats.mMissingACDT)
// the save file format is changed
if (creatureState.mCreatureStats.mGoldPool == INT_MIN)
ensureCustomData(ptr); ensureCustomData(ptr);
else else
{ {

View File

@ -1,7 +1,6 @@
#include "npc.hpp" #include "npc.hpp"
#include <memory> #include <memory>
#include <climits> // INT_MIN
#include <components/misc/constants.hpp> #include <components/misc/constants.hpp>
#include <components/misc/rng.hpp> #include <components/misc/rng.hpp>
@ -1302,9 +1301,7 @@ namespace MWClass
{ {
if (!ptr.getRefData().getCustomData()) if (!ptr.getRefData().getCustomData())
{ {
// FIXME: the use of mGoldPool can be replaced with another flag the next time if (npcState.mCreatureStats.mMissingACDT)
// the save file format is changed
if (npcState.mCreatureStats.mGoldPool == INT_MIN)
ensureCustomData(ptr); ensureCustomData(ptr);
else else
// Create a CustomData, but don't fill it from ESM records (not needed) // Create a CustomData, but don't fill it from ESM records (not needed)

View File

@ -1,7 +1,6 @@
#include "creaturestats.hpp" #include "creaturestats.hpp"
#include <algorithm> #include <algorithm>
#include <climits>
#include <components/esm/creaturestats.hpp> #include <components/esm/creaturestats.hpp>
#include <components/esm/esmreader.hpp> #include <components/esm/esmreader.hpp>
@ -558,12 +557,13 @@ namespace MWMechanics
state.mHasAiSettings = true; state.mHasAiSettings = true;
for (int i=0; i<4; ++i) for (int i=0; i<4; ++i)
mAiSettings[i].writeState (state.mAiSettings[i]); mAiSettings[i].writeState (state.mAiSettings[i]);
state.mMissingACDT = false;
} }
void CreatureStats::readState (const ESM::CreatureStats& state) void CreatureStats::readState (const ESM::CreatureStats& state)
{ {
// HACK: using mGoldPool as an indicator for lack of ACDT during .ess import if (!state.mMissingACDT)
if (state.mGoldPool != INT_MIN)
{ {
for (int i=0; i<ESM::Attribute::Length; ++i) for (int i=0; i<ESM::Attribute::Length; ++i)
mAttributes[i].readState (state.mAttributes[i]); mAttributes[i].readState (state.mAttributes[i]);

View File

@ -69,8 +69,6 @@ namespace MWMechanics
MWWorld::TimeStamp mLastRestock; MWWorld::TimeStamp mLastRestock;
// The pool of merchant gold (not in inventory) // The pool of merchant gold (not in inventory)
// HACK: value of INT_MIN has a special meaning: indicates a converted .ess file
// (this is a workaround to avoid changing the save file format)
int mGoldPool; int mGoldPool;
int mActorId; int mActorId;

View File

@ -1,6 +1,9 @@
#include "creaturestats.hpp" #include "creaturestats.hpp"
#include "esmreader.hpp" #include "esmreader.hpp"
#include "esmwriter.hpp" #include "esmwriter.hpp"
#include "savedgame.hpp"
#include <limits>
void ESM::CreatureStats::load (ESMReader &esm) void ESM::CreatureStats::load (ESMReader &esm)
{ {
@ -163,6 +166,13 @@ void ESM::CreatureStats::load (ESMReader &esm)
mCorprusSpells[id] = stats; mCorprusSpells[id] = stats;
} }
if(esm.getFormat() <= 18)
mMissingACDT = mGoldPool == std::numeric_limits<int>::min();
else
{
mMissingACDT = false;
esm.getHNOT(mMissingACDT, "NOAC");
}
} }
void ESM::CreatureStats::save (ESMWriter &esm) const void ESM::CreatureStats::save (ESMWriter &esm) const
@ -173,8 +183,10 @@ void ESM::CreatureStats::save (ESMWriter &esm) const
for (int i=0; i<3; ++i) for (int i=0; i<3; ++i)
mDynamic[i].save (esm); mDynamic[i].save (esm);
if (mGoldPool) if (ESM::SavedGame::sCurrentFormat <= 18 && mMissingACDT)
esm.writeHNT ("GOLD", mGoldPool); esm.writeHNT("GOLD", std::numeric_limits<int>::min());
else if(mGoldPool)
esm.writeHNT("GOLD", mGoldPool);
if (mTradeTime.mDay != 0 || mTradeTime.mHour != 0) if (mTradeTime.mDay != 0 || mTradeTime.mHour != 0)
esm.writeHNT ("TIME", mTradeTime); esm.writeHNT ("TIME", mTradeTime);
@ -246,6 +258,8 @@ void ESM::CreatureStats::save (ESMWriter &esm) const
for (int i=0; i<4; ++i) for (int i=0; i<4; ++i)
mAiSettings[i].save(esm); mAiSettings[i].save(esm);
} }
if(ESM::SavedGame::sCurrentFormat > 18 && mMissingACDT)
esm.writeHNT("NOAC", mMissingACDT);
} }
void ESM::CreatureStats::blank() void ESM::CreatureStats::blank()
@ -274,4 +288,5 @@ void ESM::CreatureStats::blank()
mDeathAnimation = -1; mDeathAnimation = -1;
mLevel = 1; mLevel = 1;
mCorprusSpells.clear(); mCorprusSpells.clear();
mMissingACDT = false;
} }

View File

@ -85,6 +85,7 @@ namespace ESM
signed char mDeathAnimation; signed char mDeathAnimation;
ESM::TimeStamp mTimeOfDeath; ESM::TimeStamp mTimeOfDeath;
int mLevel; int mLevel;
bool mMissingACDT;
std::map<std::string, CorprusStats> mCorprusSpells; std::map<std::string, CorprusStats> mCorprusSpells;
SpellState mSpells; SpellState mSpells;