diff --git a/apps/essimporter/converter.cpp b/apps/essimporter/converter.cpp index 874b936baf..6e79e27f18 100644 --- a/apps/essimporter/converter.cpp +++ b/apps/essimporter/converter.cpp @@ -2,7 +2,6 @@ #include #include -#include // INT_MIN #include @@ -371,7 +370,7 @@ namespace ESSImport if (cellref.mHasACDT) convertACDT(cellref.mACDT, objstate.mCreatureStats); else - objstate.mCreatureStats.mGoldPool = INT_MIN; // HACK: indicates no ACDT + objstate.mCreatureStats.mMissingACDT = true; if (cellref.mHasACSC) convertACSC(cellref.mACSC, objstate.mCreatureStats); convertNpcData(cellref, objstate.mNpcStats); @@ -414,7 +413,7 @@ namespace ESSImport if (cellref.mHasACDT) convertACDT(cellref.mACDT, objstate.mCreatureStats); else - objstate.mCreatureStats.mGoldPool = INT_MIN; // HACK: indicates no ACDT + objstate.mCreatureStats.mMissingACDT = true; if (cellref.mHasACSC) convertACSC(cellref.mACSC, objstate.mCreatureStats); convertCREC(crecIt->second, objstate); diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 0b3ffa924f..03b7cfb069 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -1,7 +1,5 @@ #include "creature.hpp" -#include // INT_MIN - #include #include #include @@ -758,9 +756,7 @@ namespace MWClass { if (!ptr.getRefData().getCustomData()) { - // FIXME: the use of mGoldPool can be replaced with another flag the next time - // the save file format is changed - if (creatureState.mCreatureStats.mGoldPool == INT_MIN) + if (creatureState.mCreatureStats.mMissingACDT) ensureCustomData(ptr); else { diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 5d50ba558f..c46e3c0534 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -1,7 +1,6 @@ #include "npc.hpp" #include -#include // INT_MIN #include #include @@ -1302,9 +1301,7 @@ namespace MWClass { if (!ptr.getRefData().getCustomData()) { - // FIXME: the use of mGoldPool can be replaced with another flag the next time - // the save file format is changed - if (npcState.mCreatureStats.mGoldPool == INT_MIN) + if (npcState.mCreatureStats.mMissingACDT) ensureCustomData(ptr); else // Create a CustomData, but don't fill it from ESM records (not needed) diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index d832c47c87..c99f87e833 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -1,7 +1,6 @@ #include "creaturestats.hpp" #include -#include #include #include @@ -558,12 +557,13 @@ namespace MWMechanics state.mHasAiSettings = true; for (int i=0; i<4; ++i) mAiSettings[i].writeState (state.mAiSettings[i]); + + state.mMissingACDT = false; } void CreatureStats::readState (const ESM::CreatureStats& state) { - // HACK: using mGoldPool as an indicator for lack of ACDT during .ess import - if (state.mGoldPool != INT_MIN) + if (!state.mMissingACDT) { for (int i=0; i void ESM::CreatureStats::load (ESMReader &esm) { @@ -163,6 +166,13 @@ void ESM::CreatureStats::load (ESMReader &esm) mCorprusSpells[id] = stats; } + if(esm.getFormat() <= 18) + mMissingACDT = mGoldPool == std::numeric_limits::min(); + else + { + mMissingACDT = false; + esm.getHNOT(mMissingACDT, "NOAC"); + } } 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) mDynamic[i].save (esm); - if (mGoldPool) - esm.writeHNT ("GOLD", mGoldPool); + if (ESM::SavedGame::sCurrentFormat <= 18 && mMissingACDT) + esm.writeHNT("GOLD", std::numeric_limits::min()); + else if(mGoldPool) + esm.writeHNT("GOLD", mGoldPool); if (mTradeTime.mDay != 0 || mTradeTime.mHour != 0) esm.writeHNT ("TIME", mTradeTime); @@ -246,6 +258,8 @@ void ESM::CreatureStats::save (ESMWriter &esm) const for (int i=0; i<4; ++i) mAiSettings[i].save(esm); } + if(ESM::SavedGame::sCurrentFormat > 18 && mMissingACDT) + esm.writeHNT("NOAC", mMissingACDT); } void ESM::CreatureStats::blank() @@ -274,4 +288,5 @@ void ESM::CreatureStats::blank() mDeathAnimation = -1; mLevel = 1; mCorprusSpells.clear(); + mMissingACDT = false; } diff --git a/components/esm/creaturestats.hpp b/components/esm/creaturestats.hpp index 651b126d0e..7b261e3dd3 100644 --- a/components/esm/creaturestats.hpp +++ b/components/esm/creaturestats.hpp @@ -85,6 +85,7 @@ namespace ESM signed char mDeathAnimation; ESM::TimeStamp mTimeOfDeath; int mLevel; + bool mMissingACDT; std::map mCorprusSpells; SpellState mSpells;