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

Added aditional checks for books. Activator check.

This commit is contained in:
Marek Kochanowicz 2013-12-20 22:31:17 +01:00
parent 8085fcc792
commit f69465d7e0
4 changed files with 74 additions and 6 deletions

View file

@ -4,26 +4,27 @@
#include <map>
#include <cassert>
#include <components/esm/loadbook.hpp>
#include "../world/record.hpp"
#include "../world/universalid.hpp"
CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable) :
mReferencables(referenceable),
mBooksSize(0)
mBooksSize(0),
mActivatorsSize(0)
{
setSizeVariables();
}
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 - minus prev sizes as stage.
//Checks for books, than, when stage is above mBooksSize goes to other checks, with (stage - PrevSum) as stage.
bool CheckPerformed = false;
int PrevSum(0);
if (stage <= mBooksSize)
{
bookCheck(stage, mReferencables.getBooks(), messages);
{
bookCheck(stage, mReferencables.getBooks(), messages);
CheckPerformed = true;
}
@ -31,6 +32,21 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str
{
return;
}
PrevSum += mBooksSize;
if ((stage - PrevSum) <= mActivatorsSize)
{
activatorCheck(stage - PrevSum, mReferencables.getActivator(), messages);
CheckPerformed = true;
}
if (CheckPerformed)
{
return;
}
PrevSum += mActivatorsSize;
}
int CSMTools::ReferenceableCheckStage::setup()
@ -55,9 +71,53 @@ void CSMTools::ReferenceableCheckStage::bookCheck(int stage, const CSMWorld::Ref
{
messages.push_back(id.toString() + "|" + Book.mId + " has an empty name");
}
//Checking for weight
if (Book.mData.mWeight < 0)
{
messages.push_back(id.toString() + "|" + Book.mId + " has a negative weight");
}
//Checking for value
if (Book.mData.mValue < 0)
{
messages.push_back(id.toString() + "|" + Book.mId + " has a negative value");
}
//checking for model
if (Book.mModel.empty())
{
messages.push_back(id.toString() + "|" + Book.mId + " has no model");
}
//checking for icon
if (Book.mIcon.empty())
{
messages.push_back(id.toString() + "|" + Book.mId + " has no icon");
}
}
void CSMTools::ReferenceableCheckStage::activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, std::vector< std::string >& messages)
{
const CSMWorld::RecordBase& baserecord = records.getRecord(stage);
if (baserecord.isDeleted())
{
return;
}
const ESM::Activator& Activator = (static_cast<const CSMWorld::Record<ESM::Activator>& >(baserecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Activator, Activator.mId);
//Checking for model, IIRC all activators should have a model
if (Activator.mModel.empty())
{
messages.push_back(id.toString() + "|" + Activator.mId + " has no model");
}
}
void CSMTools::ReferenceableCheckStage::setSizeVariables()
{
mBooksSize = mReferencables.getBooks().getSize();
mActivatorsSize = mReferencables.getActivator().getSize();
}

View file

@ -17,10 +17,12 @@ namespace CSMTools
private:
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 setSizeVariables();
const CSMWorld::RefIdData mReferencables;
int mBooksSize;
int mActivatorsSize;
};
}
#endif // REFERENCEABLECHECKSTAGE_H

View file

@ -236,3 +236,8 @@ const CSMWorld::RefIdDataContainer< ESM::Book >& CSMWorld::RefIdData::getBooks()
{
return mBooks;
}
const CSMWorld::RefIdDataContainer< ESM::Activator >& CSMWorld::RefIdData::getActivator() const
{
return mActivators;
}

View file

@ -222,6 +222,7 @@ namespace CSMWorld
//RECORD CONTAINERS ACCESS METHODS
const RefIdDataContainer<ESM::Book>& getBooks() const;
const RefIdDataContainer<ESM::Activator>& getActivator() const;
};
}