1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 10:23:52 +00:00

reformatted

This commit is contained in:
Marek Kochanowicz 2013-12-30 13:23:16 +01:00
parent c89608f390
commit 3758fe3834
4 changed files with 157 additions and 154 deletions

View file

@ -16,7 +16,7 @@ namespace CSMTools
virtual int setup();
private:
//CONCRETE CHECKS
//CONCRETE CHECKS
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 potionCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Potion>& records, std::vector<std::string>& messages);
@ -26,18 +26,18 @@ namespace CSMTools
void containerCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Container>& records, std::vector<std::string>& messages);
void creatureCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Creature>& records, std::vector<std::string>& messages);
void doorCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Door>& records, std::vector<std::string>& messages);
void ingredientCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Ingredient>& records, std::vector<std::string>& messages);
void creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::CreatureLevList>& records, std::vector<std::string>& messages);
void itemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::ItemLevList>& records, std::vector<std::string>& messages);
void lightCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Light>& records, std::vector<std::string>& messages);
void lockpickCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Lockpick>& records, std::vector<std::string>& messages);
void miscCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Miscellaneous>& records, std::vector<std::string>& messages);
void npcCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::NPC>& records, std::vector<std::string>& messages);
void ingredientCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Ingredient>& records, std::vector<std::string>& messages);
void creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::CreatureLevList>& records, std::vector<std::string>& messages);
void itemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::ItemLevList>& records, std::vector<std::string>& messages);
void lightCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Light>& records, std::vector<std::string>& messages);
void lockpickCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Lockpick>& records, std::vector<std::string>& messages);
void miscCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Miscellaneous>& records, std::vector<std::string>& messages);
void npcCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::NPC>& records, std::vector<std::string>& messages);
const CSMWorld::RefIdData& mReferencables;
const CSMWorld::IdCollection<ESM::Race>& mRaces;
const CSMWorld::IdCollection<ESM::Class>& mClasses;
const CSMWorld::IdCollection<ESM::Faction>& mFactions;
const CSMWorld::IdCollection<ESM::Race>& mRaces;
const CSMWorld::IdCollection<ESM::Class>& mClasses;
const CSMWorld::IdCollection<ESM::Faction>& mFactions;
};
}
#endif // REFERENCEABLECHECKSTAGE_H

View file

@ -21,7 +21,7 @@
#include "spellcheck.hpp"
#include "referenceablecheck.hpp"
CSMDoc::Operation *CSMTools::Tools::get (int type)
CSMDoc::Operation* CSMTools::Tools::get(int type)
{
switch (type)
{
@ -31,60 +31,60 @@ CSMDoc::Operation *CSMTools::Tools::get (int type)
return 0;
}
const CSMDoc::Operation *CSMTools::Tools::get (int type) const
const CSMDoc::Operation* CSMTools::Tools::get(int type) const
{
return const_cast<Tools *> (this)->get (type);
return const_cast<Tools*>(this)->get(type);
}
CSMDoc::Operation *CSMTools::Tools::getVerifier()
CSMDoc::Operation* CSMTools::Tools::getVerifier()
{
if (!mVerifier)
{
mVerifier = new CSMDoc::Operation (CSMDoc::State_Verifying, false);
mVerifier = new CSMDoc::Operation(CSMDoc::State_Verifying, false);
connect (mVerifier, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int)));
connect (mVerifier, SIGNAL (done (int)), this, SIGNAL (done (int)));
connect (mVerifier, SIGNAL (reportMessage (const QString&, int)),
this, SLOT (verifierMessage (const QString&, int)));
connect(mVerifier, SIGNAL(progress(int, int, int)), this, SIGNAL(progress(int, int, int)));
connect(mVerifier, SIGNAL(done(int)), this, SIGNAL(done(int)));
connect(mVerifier, SIGNAL(reportMessage(const QString&, int)),
this, SLOT(verifierMessage(const QString&, int)));
std::vector<std::string> mandatoryIds; // I want C++11, damn it!
mandatoryIds.push_back ("Day");
mandatoryIds.push_back ("DaysPassed");
mandatoryIds.push_back ("GameHour");
mandatoryIds.push_back ("Month");
mandatoryIds.push_back ("PCRace");
mandatoryIds.push_back ("PCVampire");
mandatoryIds.push_back ("PCWerewolf");
mandatoryIds.push_back ("PCYear");
mandatoryIds.push_back("Day");
mandatoryIds.push_back("DaysPassed");
mandatoryIds.push_back("GameHour");
mandatoryIds.push_back("Month");
mandatoryIds.push_back("PCRace");
mandatoryIds.push_back("PCVampire");
mandatoryIds.push_back("PCWerewolf");
mandatoryIds.push_back("PCYear");
mVerifier->appendStage (new MandatoryIdStage (mData.getGlobals(),
CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Globals), mandatoryIds));
mVerifier->appendStage(new MandatoryIdStage(mData.getGlobals(),
CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Globals), mandatoryIds));
mVerifier->appendStage (new SkillCheckStage (mData.getSkills()));
mVerifier->appendStage(new SkillCheckStage(mData.getSkills()));
mVerifier->appendStage (new ClassCheckStage (mData.getClasses()));
mVerifier->appendStage(new ClassCheckStage(mData.getClasses()));
mVerifier->appendStage (new FactionCheckStage (mData.getFactions()));
mVerifier->appendStage(new FactionCheckStage(mData.getFactions()));
mVerifier->appendStage (new RaceCheckStage (mData.getRaces()));
mVerifier->appendStage(new RaceCheckStage(mData.getRaces()));
mVerifier->appendStage (new SoundCheckStage (mData.getSounds()));
mVerifier->appendStage(new SoundCheckStage(mData.getSounds()));
mVerifier->appendStage (new RegionCheckStage (mData.getRegions()));
mVerifier->appendStage(new RegionCheckStage(mData.getRegions()));
mVerifier->appendStage (new BirthsignCheckStage (mData.getBirthsigns()));
mVerifier->appendStage(new BirthsignCheckStage(mData.getBirthsigns()));
mVerifier->appendStage (new SpellCheckStage (mData.getSpells()));
mVerifier->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses(), mData.getFactions()));
mVerifier->appendStage(new SpellCheckStage(mData.getSpells()));
mVerifier->appendStage(new ReferenceableCheckStage(mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses(), mData.getFactions()));
}
return mVerifier;
}
CSMTools::Tools::Tools (CSMWorld::Data& data) : mData (data), mVerifier (0), mNextReportNumber (0)
CSMTools::Tools::Tools(CSMWorld::Data& data) : mData(data), mVerifier(0), mNextReportNumber(0)
{
for (std::map<int, ReportModel *>::iterator iter (mReports.begin()); iter!=mReports.end(); ++iter)
for (std::map<int, ReportModel*>::iterator iter(mReports.begin()); iter != mReports.end(); ++iter)
delete iter->second;
}
@ -95,17 +95,17 @@ CSMTools::Tools::~Tools()
CSMWorld::UniversalId CSMTools::Tools::runVerifier()
{
mReports.insert (std::make_pair (mNextReportNumber++, new ReportModel));
mActiveReports[CSMDoc::State_Verifying] = mNextReportNumber-1;
mReports.insert(std::make_pair(mNextReportNumber++, new ReportModel));
mActiveReports[CSMDoc::State_Verifying] = mNextReportNumber - 1;
getVerifier()->start();
return CSMWorld::UniversalId (CSMWorld::UniversalId::Type_VerificationResults, mNextReportNumber-1);
return CSMWorld::UniversalId(CSMWorld::UniversalId::Type_VerificationResults, mNextReportNumber - 1);
}
void CSMTools::Tools::abortOperation (int type)
void CSMTools::Tools::abortOperation(int type)
{
if (CSMDoc::Operation *operation = get (type))
if (CSMDoc::Operation* operation = get(type))
operation->abort();
}
@ -113,32 +113,32 @@ int CSMTools::Tools::getRunningOperations() const
{
static const int sOperations[] =
{
CSMDoc::State_Verifying,
CSMDoc::State_Verifying,
-1
};
int result = 0;
for (int i=0; sOperations[i]!=-1; ++i)
if (const CSMDoc::Operation *operation = get (sOperations[i]))
for (int i = 0; sOperations[i] != -1; ++i)
if (const CSMDoc::Operation* operation = get(sOperations[i]))
if (operation->isRunning())
result |= sOperations[i];
return result;
}
CSMTools::ReportModel *CSMTools::Tools::getReport (const CSMWorld::UniversalId& id)
CSMTools::ReportModel* CSMTools::Tools::getReport(const CSMWorld::UniversalId& id)
{
if (id.getType()!=CSMWorld::UniversalId::Type_VerificationResults)
throw std::logic_error ("invalid request for report model: " + id.toString());
if (id.getType() != CSMWorld::UniversalId::Type_VerificationResults)
throw std::logic_error("invalid request for report model: " + id.toString());
return mReports.at (id.getIndex());
return mReports.at(id.getIndex());
}
void CSMTools::Tools::verifierMessage (const QString& message, int type)
void CSMTools::Tools::verifierMessage(const QString& message, int type)
{
std::map<int, int>::iterator iter = mActiveReports.find (type);
std::map<int, int>::iterator iter = mActiveReports.find(type);
if (iter!=mActiveReports.end())
mReports[iter->second]->add (message.toStdString());
if (iter != mActiveReports.end())
mReports[iter->second]->add(message.toStdString());
}

View file

@ -25,9 +25,9 @@ namespace CSMWorld
public:
RefIdColumn (int columnId, Display displayType,
int flag = Flag_Table | Flag_Dialogue, bool editable = true,
bool userEditable = true);
RefIdColumn(int columnId, Display displayType,
int flag = Flag_Table | Flag_Dialogue, bool editable = true,
bool userEditable = true);
virtual bool isEditable() const;
@ -40,11 +40,11 @@ namespace CSMWorld
RefIdData mData;
std::deque<RefIdColumn> mColumns;
std::map<UniversalId::Type, RefIdAdapter *> mAdapters;
std::map<UniversalId::Type, RefIdAdapter*> mAdapters;
private:
const RefIdAdapter& findAdaptor (UniversalId::Type) const;
const RefIdAdapter& findAdaptor(UniversalId::Type) const;
///< Throws an exception if no adaptor for \a Type can be found.
public:
@ -55,60 +55,60 @@ namespace CSMWorld
virtual int getSize() const;
virtual std::string getId (int index) const;
virtual std::string getId(int index) const;
virtual int getIndex (const std::string& id) const;
virtual int getIndex(const std::string& id) const;
virtual int getColumns() const;
virtual const ColumnBase& getColumn (int column) const;
virtual const ColumnBase& getColumn(int column) const;
virtual QVariant getData (int index, int column) const;
virtual QVariant getData(int index, int column) const;
virtual void setData (int index, int column, const QVariant& data);
virtual void setData(int index, int column, const QVariant& data);
virtual void removeRows (int index, int count);
virtual void removeRows(int index, int count);
virtual void appendBlankRecord (const std::string& id, UniversalId::Type type);
virtual void appendBlankRecord(const std::string& id, UniversalId::Type type);
///< \param type Will be ignored, unless the collection supports multiple record types
virtual int searchId (const std::string& id) const;
virtual int searchId(const std::string& id) const;
////< Search record with \a id.
/// \return index of record (if found) or -1 (not found)
virtual void replace (int index, const RecordBase& record);
virtual void replace(int index, const RecordBase& record);
///< If the record type does not match, an exception is thrown.
///
/// \attention \a record must not change the ID.
virtual void appendRecord (const RecordBase& record, UniversalId::Type type);
virtual void appendRecord(const RecordBase& record, UniversalId::Type type);
///< If the record type does not match, an exception is thrown.
///
///< \param type Will be ignored, unless the collection supports multiple record types
virtual const RecordBase& getRecord (const std::string& id) const;
virtual const RecordBase& getRecord(const std::string& id) const;
virtual const RecordBase& getRecord (int index) const;
virtual const RecordBase& getRecord(int index) const;
void load (ESM::ESMReader& reader, bool base, UniversalId::Type type);
void load(ESM::ESMReader& reader, bool base, UniversalId::Type type);
virtual int getAppendIndex (const std::string& id, UniversalId::Type type) const;
virtual int getAppendIndex(const std::string& id, UniversalId::Type type) const;
///< \param type Will be ignored, unless the collection supports multiple record types
virtual std::vector<std::string> getIds (bool listDeleted) const;
virtual std::vector<std::string> getIds(bool listDeleted) const;
///< Return a sorted collection of all IDs
///
/// \param listDeleted include deleted record in the list
virtual bool reorderRows (int baseIndex, const std::vector<int>& newOrder);
virtual bool reorderRows(int baseIndex, const std::vector<int>& newOrder);
///< Reorder the rows [baseIndex, baseIndex+newOrder.size()) according to the indices
/// given in \a newOrder (baseIndex+newOrder[0] specifies the new index of row baseIndex).
///
/// \return Success?
void save (int index, ESM::ESMWriter& writer) const;
const RefIdData& getDataSet() const; //I can't figure out a better name for this one :(
void save(int index, ESM::ESMWriter& writer) const;
const RefIdData& getDataSet() const; //I can't figure out a better name for this one :(
};
}

View file

@ -41,19 +41,19 @@ namespace CSMWorld
virtual int getSize() const = 0;
virtual const RecordBase& getRecord (int index) const = 0;
virtual const RecordBase& getRecord(int index) const = 0;
virtual RecordBase& getRecord (int index)= 0;
virtual RecordBase& getRecord(int index) = 0;
virtual void appendRecord (const std::string& id) = 0;
virtual void appendRecord(const std::string& id) = 0;
virtual void load (int index, ESM::ESMReader& reader, bool base) = 0;
virtual void load(int index, ESM::ESMReader& reader, bool base) = 0;
virtual void erase (int index, int count) = 0;
virtual void erase(int index, int count) = 0;
virtual std::string getId (int index) const = 0;
virtual std::string getId(int index) const = 0;
virtual void save (int index, ESM::ESMWriter& writer) const = 0;
virtual void save(int index, ESM::ESMWriter& writer) const = 0;
};
template<typename RecordT>
@ -63,90 +63,91 @@ namespace CSMWorld
virtual int getSize() const;
virtual const RecordBase& getRecord (int index) const;
virtual const RecordBase& getRecord(int index) const;
virtual RecordBase& getRecord (int index);
virtual RecordBase& getRecord(int index);
virtual void appendRecord (const std::string& id);
virtual void appendRecord(const std::string& id);
virtual void load (int index, ESM::ESMReader& reader, bool base);
virtual void load(int index, ESM::ESMReader& reader, bool base);
virtual void erase (int index, int count);
virtual void erase(int index, int count);
virtual std::string getId (int index) const;
virtual std::string getId(int index) const;
virtual void save (int index, ESM::ESMWriter& writer) const;
virtual void save(int index, ESM::ESMWriter& writer) const;
};
template<typename RecordT>
int RefIdDataContainer<RecordT>::getSize() const
{
return static_cast<int> (mContainer.size());
return static_cast<int>(mContainer.size());
}
template<typename RecordT>
const RecordBase& RefIdDataContainer<RecordT>::getRecord (int index) const
const RecordBase& RefIdDataContainer<RecordT>::getRecord(int index) const
{
return mContainer.at (index);
return mContainer.at(index);
}
template<typename RecordT>
RecordBase& RefIdDataContainer<RecordT>::getRecord (int index)
RecordBase& RefIdDataContainer<RecordT>::getRecord(int index)
{
return mContainer.at (index);
return mContainer.at(index);
}
template<typename RecordT>
void RefIdDataContainer<RecordT>::appendRecord (const std::string& id)
void RefIdDataContainer<RecordT>::appendRecord(const std::string& id)
{
Record<RecordT> record;
record.mModified.mId = id;
record.mModified.blank();
record.mState = RecordBase::State_ModifiedOnly;
mContainer.push_back (record);
mContainer.push_back(record);
}
template<typename RecordT>
void RefIdDataContainer<RecordT>::load (int index, ESM::ESMReader& reader, bool base)
void RefIdDataContainer<RecordT>::load(int index, ESM::ESMReader& reader, bool base)
{
(base ? mContainer.at (index).mBase : mContainer.at (index).mModified).load (reader);
(base ? mContainer.at(index).mBase : mContainer.at(index).mModified).load(reader);
}
template<typename RecordT>
void RefIdDataContainer<RecordT>::erase (int index, int count)
void RefIdDataContainer<RecordT>::erase(int index, int count)
{
if (index<0 || index+count>=getSize())
throw std::runtime_error ("invalid RefIdDataContainer index");
if (index < 0 || index + count >= getSize())
throw std::runtime_error("invalid RefIdDataContainer index");
mContainer.erase (mContainer.begin()+index, mContainer.begin()+index+count);
mContainer.erase(mContainer.begin() + index, mContainer.begin() + index + count);
}
template<typename RecordT>
std::string RefIdDataContainer<RecordT>::getId (int index) const
std::string RefIdDataContainer<RecordT>::getId(int index) const
{
return mContainer.at (index).get().mId;
return mContainer.at(index).get().mId;
}
template<typename RecordT>
void RefIdDataContainer<RecordT>::save (int index, ESM::ESMWriter& writer) const
void RefIdDataContainer<RecordT>::save(int index, ESM::ESMWriter& writer) const
{
CSMWorld::RecordBase::State state = mContainer.at (index).mState;
CSMWorld::RecordBase::State state = mContainer.at(index).mState;
if (state==CSMWorld::RecordBase::State_Modified ||
state==CSMWorld::RecordBase::State_ModifiedOnly)
if (state == CSMWorld::RecordBase::State_Modified ||
state == CSMWorld::RecordBase::State_ModifiedOnly)
{
std::string type;
for (int i=0; i<4; ++i)
/// \todo make endianess agnostic (change ESMWriter interface?)
type += reinterpret_cast<const char *> (&mContainer.at (index).mModified.sRecordId)[i];
writer.startRecord (type);
writer.writeHNCString ("NAME", getId (index));
mContainer.at (index).mModified.save (writer);
writer.endRecord (type);
for (int i = 0; i < 4; ++i)
/// \todo make endianess agnostic (change ESMWriter interface?)
type += reinterpret_cast<const char*>(&mContainer.at(index).mModified.sRecordId)[i];
writer.startRecord(type);
writer.writeHNCString("NAME", getId(index));
mContainer.at(index).mModified.save(writer);
writer.endRecord(type);
}
else if (state==CSMWorld::RecordBase::State_Deleted)
else if (state == CSMWorld::RecordBase::State_Deleted)
{
/// \todo write record with delete flag
}
@ -184,61 +185,63 @@ namespace CSMWorld
std::map<std::string, LocalIndex> mIndex;
std::map<UniversalId::Type, RefIdDataContainerBase *> mRecordContainers;
std::map<UniversalId::Type, RefIdDataContainerBase*> mRecordContainers;
void erase (const LocalIndex& index, int count);
void erase(const LocalIndex& index, int count);
///< Must not spill over into another type.
public:
RefIdData();
LocalIndex globalToLocalIndex (int index) const;
LocalIndex globalToLocalIndex(int index) const;
int localToGlobalIndex (const LocalIndex& index) const;
int localToGlobalIndex(const LocalIndex& index) const;
LocalIndex searchId (const std::string& id) const;
LocalIndex searchId(const std::string& id) const;
void erase (int index, int count);
void erase(int index, int count);
const RecordBase& getRecord (const LocalIndex& index) const;
const RecordBase& getRecord(const LocalIndex& index) const;
RecordBase& getRecord (const LocalIndex& index);
RecordBase& getRecord(const LocalIndex& index);
void appendRecord (UniversalId::Type type, const std::string& id);
void appendRecord(UniversalId::Type type, const std::string& id);
int getAppendIndex (UniversalId::Type type) const;
int getAppendIndex(UniversalId::Type type) const;
void load (const LocalIndex& index, ESM::ESMReader& reader, bool base);
void load(const LocalIndex& index, ESM::ESMReader& reader, bool base);
int getSize() const;
std::vector<std::string> getIds (bool listDeleted = true) const;
std::vector<std::string> getIds(bool listDeleted = true) const;
///< Return a sorted collection of all IDs
///
/// \param listDeleted include deleted record in the list
void save (int index, ESM::ESMWriter& writer) const;
//RECORD CONTAINERS ACCESS METHODS
const RefIdDataContainer<ESM::Book>& getBooks() const;
const RefIdDataContainer<ESM::Activator>& getActivators() const;
const RefIdDataContainer<ESM::Potion>& getPotions() const;
const RefIdDataContainer<ESM::Apparatus>& getApparati() const;
const RefIdDataContainer<ESM::Armor>& getArmors() const;
const RefIdDataContainer<ESM::Clothing>& getClothing() const;
const RefIdDataContainer<ESM::Container>& getContainers() const;
const RefIdDataContainer<ESM::Creature>& getCreatures() const;
const RefIdDataContainer<ESM::Door>& getDoors() const;
const RefIdDataContainer<ESM::Ingredient>& getIngredients() const;
const RefIdDataContainer<ESM::CreatureLevList>& getCreatureLevelledLists() const;
const RefIdDataContainer<ESM::ItemLevList>& getItemLevelledList() const;
const RefIdDataContainer<ESM::Light>& getLights() const;
const RefIdDataContainer<ESM::Lockpick>& getLocpicks() const;
const RefIdDataContainer<ESM::Miscellaneous>& getMiscellaneous() const;
const RefIdDataContainer<ESM::NPC>& getNPCs() const;
void save(int index, ESM::ESMWriter& writer) const;
//RECORD CONTAINERS ACCESS METHODS
const RefIdDataContainer<ESM::Book>& getBooks() const;
const RefIdDataContainer<ESM::Activator>& getActivators() const;
const RefIdDataContainer<ESM::Potion>& getPotions() const;
const RefIdDataContainer<ESM::Apparatus>& getApparati() const;
const RefIdDataContainer<ESM::Armor>& getArmors() const;
const RefIdDataContainer<ESM::Clothing>& getClothing() const;
const RefIdDataContainer<ESM::Container>& getContainers() const;
const RefIdDataContainer<ESM::Creature>& getCreatures() const;
const RefIdDataContainer<ESM::Door>& getDoors() const;
const RefIdDataContainer<ESM::Ingredient>& getIngredients() const;
const RefIdDataContainer<ESM::CreatureLevList>& getCreatureLevelledLists() const;
const RefIdDataContainer<ESM::ItemLevList>& getItemLevelledList() const;
const RefIdDataContainer<ESM::Light>& getLights() const;
const RefIdDataContainer<ESM::Lockpick>& getLocpicks() const;
const RefIdDataContainer<ESM::Miscellaneous>& getMiscellaneous() const;
const RefIdDataContainer<ESM::NPC>& getNPCs() const;
};
}
#endif