1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-01 05:15:36 +00:00

Added armor check

This commit is contained in:
Marek Kochanowicz 2013-12-22 14:22:03 +01:00
parent 955fe3e8cf
commit 97fc8acbdb
4 changed files with 89 additions and 9 deletions

View file

@ -13,7 +13,8 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefId
mBooksSize(0),
mActivatorsSize(0),
mPotionsSize(0),
mApparatiSize(0)
mApparatiSize(0),
mArmorsSzie(0)
{
setSizeVariables();
}
@ -24,6 +25,7 @@ void CSMTools::ReferenceableCheckStage::setSizeVariables()
mActivatorsSize = mReferencables.getActivators().getSize();
mPotionsSize = mReferencables.getPotions().getSize();
mApparatiSize = mReferencables.getApparati().getSize();
mArmorsSzie = mReferencables.getArmors().getSize();
}
void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages)
@ -52,14 +54,22 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str
}
stage -= mPotionsSize;
if (stage < mApparatiSize)
{
apparatusCheck(stage, mReferencables.getApparati(), messages);
return;
apparatusCheck(stage, mReferencables.getApparati(), messages);
return;
}
stage -= mApparatiSize;
if (stage < mArmorsSzie)
{
armorCheck(stage, mReferencables.getArmors(), messages);
return;
}
stage -= mApparatiSize;
stage -= mArmorsSzie;
}
int CSMTools::ReferenceableCheckStage::setup()
@ -108,11 +118,11 @@ void CSMTools::ReferenceableCheckStage::bookCheck(int stage, const CSMWorld::Ref
{
messages.push_back(id.toString() + "|" + Book.mId + " has no icon");
}
//checking for enchantment points
if (Book.mData.mEnchant < 0)
{
messages.push_back(id.toString() + "|" + Book.mId + " has negative enchantment");
messages.push_back(id.toString() + "|" + Book.mId + " has negative enchantment");
}
}
@ -176,6 +186,7 @@ void CSMTools::ReferenceableCheckStage::potionCheck(int stage, const CSMWorld::R
{
messages.push_back(id.toString() + "|" + Potion.mId + " has no icon");
}
//IIRC potion can have empty effects list just fine.
}
@ -221,10 +232,71 @@ void CSMTools::ReferenceableCheckStage::apparatusCheck(int stage, const CSMWorld
{
messages.push_back(id.toString() + "|" + Apparatus.mId + " has no icon");
}
//checking for quality, 0 → apparatus is basicly useless, any negative → apparatus is harmfull instead of helpfull
if (Apparatus.mData.mQuality <= 0)
{
messages.push_back(id.toString() + "|" + Apparatus.mId + " has non-positive quality");
messages.push_back(id.toString() + "|" + Apparatus.mId + " has non-positive quality");
}
}
void CSMTools::ReferenceableCheckStage::armorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Armor >& records, std::vector< std::string >& messages)
{
const CSMWorld::RecordBase& baserecord = records.getRecord(stage);
if (baserecord.isDeleted())
{
return;
}
const ESM::Armor& Armor = (static_cast<const CSMWorld::Record<ESM::Armor>& >(baserecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Armor, Armor.mId);
//Checking for name
if (Armor.mName.empty())
{
messages.push_back(id.toString() + "|" + Armor.mId + " has an empty name");
}
//Checking for weight
if (Armor.mData.mWeight < 0)
{
messages.push_back(id.toString() + "|" + Armor.mId + " has negative weight");
}
//Checking for value
if (Armor.mData.mValue < 0)
{
messages.push_back(id.toString() + "|" + Armor.mId + " has negative value");
}
//checking for model
if (Armor.mModel.empty())
{
messages.push_back(id.toString() + "|" + Armor.mId + " has no model");
}
//checking for icon
if (Armor.mIcon.empty())
{
messages.push_back(id.toString() + "|" + Armor.mId + " has no icon");
}
//checking for enchantment points
if (Armor.mData.mEnchant < 0)
{
messages.push_back(id.toString() + "|" + Armor.mId + " has negative enchantment");
}
//checking for armor class, armor should have poistive armor class, but 0 is considered legal
if (Armor.mData.mArmor < 0)
{
messages.push_back(id.toString() + "|" + Armor.mId + " has negative armor class");
}
//checking for health. Only positive numbers are allowed, and 0 is illegal
if (Armor.mData.mHealth <= 0)
{
messages.push_back(id.toString() + "|" + Armor.mId + " has non positive health");
}
}

View file

@ -21,6 +21,7 @@ namespace CSMTools
void activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, std::vector< std::string >& messages);
void potionCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Potion>& records, std::vector<std::string>& messages);
void apparatusCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Apparatus>& records, std::vector<std::string>& messages);
void armorCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Armor>& records, std::vector<std::string>& messages);
void setSizeVariables();
@ -31,6 +32,7 @@ namespace CSMTools
int mActivatorsSize;
int mPotionsSize;
int mApparatiSize;
int mArmorsSzie;
};
}
#endif // REFERENCEABLECHECKSTAGE_H

View file

@ -251,3 +251,8 @@ const CSMWorld::RefIdDataContainer< ESM::Apparatus >& CSMWorld::RefIdData::getAp
{
return mApparati;
}
const CSMWorld::RefIdDataContainer< ESM::Armor >& CSMWorld::RefIdData::getArmors() const
{
return mArmors;
}

View file

@ -225,6 +225,7 @@ namespace CSMWorld
const RefIdDataContainer<ESM::Activator>& getActivators() const;
const RefIdDataContainer<ESM::Potion>& getPotions() const;
const RefIdDataContainer<ESM::Apparatus>& getApparati() const;
const RefIdDataContainer<ESM::Armor>& getArmors() const;
};
}