mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-15 22:21:00 +00:00
Merge branch 'charming_stats' into 'master'
Third time's the charm Closes #6611 See merge request OpenMW/openmw!1657
This commit is contained in:
commit
be761b5c07
@ -21,13 +21,13 @@ namespace MWMechanics
|
||||
void Stat<T>::writeState (ESM::StatState<T>& state) const
|
||||
{
|
||||
state.mBase = mBase;
|
||||
state.mMod = mModifier + mBase;
|
||||
state.mMod = mModifier;
|
||||
}
|
||||
template<typename T>
|
||||
void Stat<T>::readState (const ESM::StatState<T>& state)
|
||||
{
|
||||
mBase = state.mBase;
|
||||
mModifier = state.mMod - mBase;
|
||||
mModifier = state.mMod;
|
||||
}
|
||||
|
||||
|
||||
|
@ -185,6 +185,11 @@ namespace
|
||||
else if constexpr (std::is_same_v<T, ESM::NPC>)
|
||||
MWWorld::convertMagicEffects(state.mCreatureStats, state.mInventory, &state.mNpcStats);
|
||||
}
|
||||
else if(state.mVersion < 20)
|
||||
{
|
||||
if constexpr (std::is_same_v<T, ESM::Creature> || std::is_same_v<T, ESM::NPC>)
|
||||
MWWorld::convertStats(state.mCreatureStats);
|
||||
}
|
||||
|
||||
if (state.mRef.mRefNum.hasContentFile())
|
||||
{
|
||||
|
@ -201,14 +201,23 @@ namespace MWWorld
|
||||
{
|
||||
auto& dynamic = creatureStats.mDynamic[i];
|
||||
dynamic.mCurrent -= dynamic.mMod - dynamic.mBase;
|
||||
dynamic.mMod = dynamic.mBase;
|
||||
dynamic.mMod = 0.f;
|
||||
}
|
||||
for(std::size_t i = 0; i < 4; ++i)
|
||||
creatureStats.mAiSettings[i].mMod = creatureStats.mAiSettings[i].mBase;
|
||||
creatureStats.mAiSettings[i].mMod = 0.f;
|
||||
if(npcStats)
|
||||
{
|
||||
for(std::size_t i = 0; i < ESM::Skill::Length; ++i)
|
||||
npcStats->mSkills[i].mMod = 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
// Versions 17-19 wrote different modifiers to the savegame depending on whether the save had upgraded from a pre-17 version or not
|
||||
void convertStats(ESM::CreatureStats& creatureStats)
|
||||
{
|
||||
for(std::size_t i = 0; i < 3; ++i)
|
||||
creatureStats.mDynamic[i].mMod = 0.f;
|
||||
for(std::size_t i = 0; i < 4; ++i)
|
||||
creatureStats.mAiSettings[i].mMod = 0.f;
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ namespace MWWorld
|
||||
{
|
||||
void convertMagicEffects(ESM::CreatureStats& creatureStats, ESM::InventoryState& inventory,
|
||||
ESM::NpcStats* npcStats = nullptr);
|
||||
|
||||
void convertStats(ESM::CreatureStats& creatureStats);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -383,6 +383,8 @@ namespace MWWorld
|
||||
}
|
||||
if (reader.getFormat() < 17)
|
||||
convertMagicEffects(player.mObject.mCreatureStats, player.mObject.mInventory, &player.mObject.mNpcStats);
|
||||
else if(reader.getFormat() < 20)
|
||||
convertStats(player.mObject.mCreatureStats);
|
||||
|
||||
if (!player.mObject.mEnabled)
|
||||
{
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "esmwriter.hpp"
|
||||
|
||||
unsigned int ESM::SavedGame::sRecordId = ESM::REC_SAVE;
|
||||
int ESM::SavedGame::sCurrentFormat = 19;
|
||||
int ESM::SavedGame::sCurrentFormat = 20;
|
||||
|
||||
void ESM::SavedGame::load (ESMReader &esm)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user