Handle enchantment autocalc flag as a flag (bug #5363)

pull/578/head
Capostrophic 5 years ago
parent f27e299025
commit ad333e88fe

@ -1,6 +1,7 @@
0.47.0 0.47.0
------ ------
Bug #5363: Enchantment autocalc not always 0/1
0.46.0 0.46.0
------ ------

@ -4,6 +4,7 @@
#include <components/esm/loadcell.hpp> #include <components/esm/loadcell.hpp>
#include <components/esm/loadcont.hpp> #include <components/esm/loadcont.hpp>
#include <components/esm/loadcrea.hpp> #include <components/esm/loadcrea.hpp>
#include <components/esm/loadench.hpp>
#include <components/esm/loadlevlist.hpp> #include <components/esm/loadlevlist.hpp>
#include <components/esm/loadligh.hpp> #include <components/esm/loadligh.hpp>
#include <components/esm/loadmgef.hpp> #include <components/esm/loadmgef.hpp>
@ -726,6 +727,16 @@ std::string creatureFlags(int flags)
return properties; return properties;
} }
std::string enchantmentFlags(int flags)
{
std::string properties;
if (flags == 0) properties += "[None] ";
if (flags & ESM::Enchantment::Autocalc) properties += "Autocalc ";
if (flags & (0xFFFFFFFF ^ ESM::Enchantment::Autocalc)) properties += "Invalid ";
properties += Misc::StringUtils::format("(0x%08X)", flags);
return properties;
}
std::string landFlags(int flags) std::string landFlags(int flags)
{ {
std::string properties; std::string properties;

@ -49,6 +49,7 @@ std::string bodyPartFlags(int flags);
std::string cellFlags(int flags); std::string cellFlags(int flags);
std::string containerFlags(int flags); std::string containerFlags(int flags);
std::string creatureFlags(int flags); std::string creatureFlags(int flags);
std::string enchantmentFlags(int flags);
std::string landFlags(int flags); std::string landFlags(int flags);
std::string creatureListFlags(int flags); std::string creatureListFlags(int flags);
std::string itemListFlags(int flags); std::string itemListFlags(int flags);

@ -714,7 +714,7 @@ void Record<ESM::Enchantment>::print()
<< " (" << mData.mData.mType << ")" << std::endl; << " (" << mData.mData.mType << ")" << std::endl;
std::cout << " Cost: " << mData.mData.mCost << std::endl; std::cout << " Cost: " << mData.mData.mCost << std::endl;
std::cout << " Charge: " << mData.mData.mCharge << std::endl; std::cout << " Charge: " << mData.mData.mCharge << std::endl;
std::cout << " AutoCalc: " << mData.mData.mAutocalc << std::endl; std::cout << " Flags: " << enchantmentFlags(mData.mData.mFlags) << std::endl;
printEffectList(mData.mEffects); printEffectList(mData.mEffects);
std::cout << " Deleted: " << mIsDeleted << std::endl; std::cout << " Deleted: " << mIsDeleted << std::endl;
} }

@ -373,7 +373,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::Pat
mEnchantments.addColumn (new EnchantmentTypeColumn<ESM::Enchantment>); mEnchantments.addColumn (new EnchantmentTypeColumn<ESM::Enchantment>);
mEnchantments.addColumn (new CostColumn<ESM::Enchantment>); mEnchantments.addColumn (new CostColumn<ESM::Enchantment>);
mEnchantments.addColumn (new ChargesColumn2<ESM::Enchantment>); mEnchantments.addColumn (new ChargesColumn2<ESM::Enchantment>);
mEnchantments.addColumn (new AutoCalcColumn<ESM::Enchantment>); mEnchantments.addColumn (new FlagColumn<ESM::Enchantment> (Columns::ColumnId_AutoCalc, ESM::Enchantment::Autocalc));
// Enchantment effects // Enchantment effects
mEnchantments.addColumn (new NestedParentColumn<ESM::Enchantment> (Columns::ColumnId_EffectList)); mEnchantments.addColumn (new NestedParentColumn<ESM::Enchantment> (Columns::ColumnId_EffectList));
index = mEnchantments.getColumns()-1; index = mEnchantments.getColumns()-1;

@ -63,7 +63,7 @@ namespace MWMechanics
const MWWorld::Ptr& player = getPlayer(); const MWWorld::Ptr& player = getPlayer();
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player); MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
ESM::Enchantment enchantment; ESM::Enchantment enchantment;
enchantment.mData.mAutocalc = 0; enchantment.mData.mFlags = 0;
enchantment.mData.mType = mCastStyle; enchantment.mData.mType = mCastStyle;
enchantment.mData.mCost = getBaseCastCost(); enchantment.mData.mCost = getBaseCastCost();
@ -219,7 +219,7 @@ namespace MWMechanics
if (iter->mEffects.mList.size() != toFind.mEffects.mList.size()) if (iter->mEffects.mList.size() != toFind.mEffects.mList.size())
continue; continue;
if (iter->mData.mAutocalc != toFind.mData.mAutocalc if (iter->mData.mFlags != toFind.mData.mFlags
|| iter->mData.mType != toFind.mData.mType || iter->mData.mType != toFind.mData.mType
|| iter->mData.mCost != toFind.mData.mCost || iter->mData.mCost != toFind.mData.mCost
|| iter->mData.mCharge != toFind.mData.mCharge) || iter->mData.mCharge != toFind.mData.mCharge)

@ -66,7 +66,7 @@ namespace ESM
mData.mType = 0; mData.mType = 0;
mData.mCost = 0; mData.mCost = 0;
mData.mCharge = 0; mData.mCharge = 0;
mData.mAutocalc = 0; mData.mFlags = 0;
mEffects.mList.clear(); mEffects.mList.clear();
} }

@ -29,13 +29,17 @@ struct Enchantment
ConstantEffect = 3 ConstantEffect = 3
}; };
enum Flags
{
Autocalc = 0x01
};
struct ENDTstruct struct ENDTstruct
{ {
int mType; int mType;
int mCost; int mCost;
int mCharge; int mCharge;
int mAutocalc; // Guessing this is 1 if we are supposed to auto int mFlags;
// calculate
}; };
std::string mId; std::string mId;

Loading…
Cancel
Save