1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-10 21:40:15 +00:00

Fixed charges checking

This commit is contained in:
Kamil Bar 2015-02-13 12:13:40 +01:00
parent e1314d6211
commit 52a064afc3
2 changed files with 28 additions and 13 deletions

View File

@ -10,6 +10,7 @@ CSMTools::ReferenceCheckStage::ReferenceCheckStage(
: :
mReferences(references), mReferences(references),
mReferencables(referencables), mReferencables(referencables),
mDataSet(referencables.getDataSet()),
mCells(cells), mCells(cells),
mFactions(factions) mFactions(factions)
{ {
@ -26,12 +27,33 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages &message
const CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Reference, cellRef.mId); const CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Reference, cellRef.mId);
// Check for empty reference id // Check for empty reference id
if (cellRef.mRefID.empty()) if (cellRef.mRefID.empty()) {
messages.push_back(std::make_pair(id, " is an empty reference")); messages.push_back(std::make_pair(id, " is an empty reference"));
} else {
// Check for non existing referenced object // Check for non existing referenced object
if (mReferencables.searchId(cellRef.mRefID) == -1) if (mReferencables.searchId(cellRef.mRefID) == -1) {
messages.push_back(std::make_pair(id, " is referencing non existing object " + cellRef.mRefID)); messages.push_back(std::make_pair(id, " is referencing non existing object " + cellRef.mRefID));
} else {
// Check if reference charge isn't negative if it's proper type
CSMWorld::RefIdData::LocalIndex localIndex = mDataSet.searchId(cellRef.mRefID);
if (localIndex.second == CSMWorld::UniversalId::Type_Armor ||
localIndex.second == CSMWorld::UniversalId::Type_Weapon) {
if (cellRef.mChargeFloat < 0) {
std::string str = " has negative durability ";
str += boost::lexical_cast<std::string>(cellRef.mChargeFloat);
messages.push_back(std::make_pair(id, id.getId() + str));
}
} else if (localIndex.second == CSMWorld::UniversalId::Type_Lockpick ||
localIndex.second == CSMWorld::UniversalId::Type_Probe ||
localIndex.second == CSMWorld::UniversalId::Type_Repair) {
if (cellRef.mChargeInt < -1) {
std::string str = " has invalid charges ";
str += boost::lexical_cast<std::string>(cellRef.mChargeFloat);
messages.push_back(std::make_pair(id, id.getId() + str));
}
}
}
}
// Check if referenced object is in valid cell // Check if referenced object is in valid cell
if (mCells.searchId(cellRef.mCell) == -1) if (mCells.searchId(cellRef.mCell) == -1)
@ -72,14 +94,6 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages &message
messages.push_back(std::make_pair(id, id.getId() + str)); messages.push_back(std::make_pair(id, id.getId() + str));
} }
// Check if charge isn't negative
if (cellRef.mChargeFloat < 0)
{
std::string str = " has negative charges ";
str += boost::lexical_cast<std::string>(cellRef.mChargeFloat);
messages.push_back(std::make_pair(id, id.getId() + str));
}
// Check if enchantement points aren't negative or are at full (-1) // Check if enchantement points aren't negative or are at full (-1)
if (cellRef.mEnchantmentCharge < 0 && cellRef.mEnchantmentCharge != -1) if (cellRef.mEnchantmentCharge < 0 && cellRef.mEnchantmentCharge != -1)
{ {

View File

@ -20,6 +20,7 @@ namespace CSMTools
private: private:
const CSMWorld::RefCollection& mReferences; const CSMWorld::RefCollection& mReferences;
const CSMWorld::RefIdCollection& mReferencables; const CSMWorld::RefIdCollection& mReferencables;
const CSMWorld::RefIdData& mDataSet;
const CSMWorld::IdCollection<CSMWorld::Cell>& mCells; const CSMWorld::IdCollection<CSMWorld::Cell>& mCells;
const CSMWorld::IdCollection<ESM::Faction>& mFactions; const CSMWorld::IdCollection<ESM::Faction>& mFactions;
}; };