1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-13 20:39:40 +00:00

Added enchantmnet check for books.

This commit is contained in:
Marek Kochanowicz 2013-12-21 12:07:40 +01:00
parent ee5dfd1cc8
commit a27441720e
4 changed files with 85 additions and 13 deletions

View file

@ -12,11 +12,20 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefId
mReferencables(referenceable), mReferencables(referenceable),
mBooksSize(0), mBooksSize(0),
mActivatorsSize(0), mActivatorsSize(0),
mPotionsSize(0) mPotionsSize(0),
mApparatiSize(0)
{ {
setSizeVariables(); setSizeVariables();
} }
void CSMTools::ReferenceableCheckStage::setSizeVariables()
{
mBooksSize = mReferencables.getBooks().getSize();
mActivatorsSize = mReferencables.getActivators().getSize();
mPotionsSize = mReferencables.getPotions().getSize();
mApparatiSize = mReferencables.getApparati().getSize();
}
void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages) void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages)
{ {
//Checks for books, than, when stage is above mBooksSize goes to other checks, with (stage - PrevSum) as stage. //Checks for books, than, when stage is above mBooksSize goes to other checks, with (stage - PrevSum) as stage.
@ -24,6 +33,7 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str
if (stage <= mBooksSize) if (stage <= mBooksSize)
{ {
bookCheck(stage, mReferencables.getBooks(), messages); bookCheck(stage, mReferencables.getBooks(), messages);
std::cout<<"Book checking \n";
return; return;
} }
@ -39,11 +49,19 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str
if (stage <= mPotionsSize) if (stage <= mPotionsSize)
{ {
potionsCheck(stage, mReferencables.getPotions(), messages); potionCheck(stage, mReferencables.getPotions(), messages);
return; return;
} }
stage -= mPotionsSize; stage -= mPotionsSize;
if (stage <= mApparatiSize)
{
apparatusCheck(stage, mReferencables.getApparati(), messages);
return;
}
stage -= mApparatiSize;
} }
int CSMTools::ReferenceableCheckStage::setup() int CSMTools::ReferenceableCheckStage::setup()
@ -72,13 +90,13 @@ void CSMTools::ReferenceableCheckStage::bookCheck(int stage, const CSMWorld::Ref
//Checking for weight //Checking for weight
if (Book.mData.mWeight < 0) if (Book.mData.mWeight < 0)
{ {
messages.push_back(id.toString() + "|" + Book.mId + " has a negative weight"); messages.push_back(id.toString() + "|" + Book.mId + " has negative weight");
} }
//Checking for value //Checking for value
if (Book.mData.mValue < 0) if (Book.mData.mValue < 0)
{ {
messages.push_back(id.toString() + "|" + Book.mId + " has a negative value"); messages.push_back(id.toString() + "|" + Book.mId + " has negative value");
} }
//checking for model //checking for model
@ -92,6 +110,12 @@ void CSMTools::ReferenceableCheckStage::bookCheck(int stage, const CSMWorld::Ref
{ {
messages.push_back(id.toString() + "|" + Book.mId + " has no icon"); 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");
}
} }
void CSMTools::ReferenceableCheckStage::activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, std::vector< std::string >& messages) void CSMTools::ReferenceableCheckStage::activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, std::vector< std::string >& messages)
@ -113,7 +137,7 @@ void CSMTools::ReferenceableCheckStage::activatorCheck(int stage, const CSMWorld
} }
} }
void CSMTools::ReferenceableCheckStage::potionsCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Potion >& records, std::vector< std::string >& messages) void CSMTools::ReferenceableCheckStage::potionCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Potion >& records, std::vector< std::string >& messages)
{ {
const CSMWorld::RecordBase& baserecord = records.getRecord(stage); const CSMWorld::RecordBase& baserecord = records.getRecord(stage);
@ -134,13 +158,13 @@ void CSMTools::ReferenceableCheckStage::potionsCheck(int stage, const CSMWorld::
//Checking for weight //Checking for weight
if (Potion.mData.mWeight < 0) if (Potion.mData.mWeight < 0)
{ {
messages.push_back(id.toString() + "|" + Potion.mId + " has a negative weight"); messages.push_back(id.toString() + "|" + Potion.mId + " has negative weight");
} }
//Checking for value //Checking for value
if (Potion.mData.mValue < 0) if (Potion.mData.mValue < 0)
{ {
messages.push_back(id.toString() + "|" + Potion.mId + " has a negative value"); messages.push_back(id.toString() + "|" + Potion.mId + " has negative value");
} }
//checking for model //checking for model
@ -157,9 +181,46 @@ void CSMTools::ReferenceableCheckStage::potionsCheck(int stage, const CSMWorld::
//IIRC potion can have empty effects list just fine. //IIRC potion can have empty effects list just fine.
} }
void CSMTools::ReferenceableCheckStage::setSizeVariables()
void CSMTools::ReferenceableCheckStage::apparatusCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Apparatus >& records, std::vector< std::string >& messages)
{ {
mBooksSize = mReferencables.getBooks().getSize(); const CSMWorld::RecordBase& baserecord = records.getRecord(stage);
mActivatorsSize = mReferencables.getActivators().getSize();
mPotionsSize = mReferencables.getPotions().getSize(); if (baserecord.isDeleted())
} {
return;
}
const ESM::Apparatus& Apparatus = (static_cast<const CSMWorld::Record<ESM::Apparatus>& >(baserecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Apparatus, Apparatus.mId);
//Checking for name
if (Apparatus.mName.empty())
{
messages.push_back(id.toString() + "|" + Apparatus.mId + " has an empty name");
}
//Checking for weight
if (Apparatus.mData.mWeight < 0)
{
messages.push_back(id.toString() + "|" + Apparatus.mId + " has negative weight");
}
//Checking for value
if (Apparatus.mData.mValue < 0)
{
messages.push_back(id.toString() + "|" + Apparatus.mId + " has negative value");
}
//checking for model
if (Apparatus.mModel.empty())
{
messages.push_back(id.toString() + "|" + Apparatus.mId + " has no model");
}
//checking for icon
if (Apparatus.mIcon.empty())
{
messages.push_back(id.toString() + "|" + Apparatus.mId + " has no icon");
}
}

View file

@ -16,16 +16,21 @@ namespace CSMTools
virtual int setup(); virtual int setup();
private: private:
//CONCRETE CHECKS
void bookCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Book >& records, std::vector< std::string >& messages); void bookCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Book >& records, std::vector< std::string >& messages);
void activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, std::vector< std::string >& messages); void activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, std::vector< std::string >& messages);
void potionsCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Potion>& 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 setSizeVariables(); void setSizeVariables();
const CSMWorld::RefIdData mReferencables; const CSMWorld::RefIdData mReferencables;
//SIZES OF CONCRETE TYPES
int mBooksSize; int mBooksSize;
int mActivatorsSize; int mActivatorsSize;
int mPotionsSize; int mPotionsSize;
int mApparatiSize;
}; };
} }
#endif // REFERENCEABLECHECKSTAGE_H #endif // REFERENCEABLECHECKSTAGE_H

View file

@ -246,3 +246,8 @@ const CSMWorld::RefIdDataContainer< ESM::Potion >& CSMWorld::RefIdData::getPotio
{ {
return mPotions; return mPotions;
} }
const CSMWorld::RefIdDataContainer< ESM::Apparatus >& CSMWorld::RefIdData::getApparati() const
{
return mApparati;
}

View file

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