From 4a1987ddecb6385db2b26402e066d9d79f851f7b Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Mon, 30 Dec 2013 18:41:16 +0100 Subject: [PATCH] correcting --- .../opencs/model/tools/referenceablecheck.cpp | 28 +----- apps/opencs/model/tools/tools.cpp | 93 ++++++++++--------- apps/opencs/model/world/refidcollection.hpp | 47 +++++----- 3 files changed, 74 insertions(+), 94 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index ad52c5962..3ca203bdf 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -945,18 +945,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI } else //checking if there is such class { - bool nosuchclass(true); - - for (int i = 0; i < mClasses.getSize(); ++i) - { - if (dynamic_cast(mClasses.getRecord(i).get()).mId == NPC.mClass) - { - nosuchclass = false; - break; - } - } - - if (nosuchclass) + if (mClasses.searchId(NPC.mClass)) { messages.push_back(id.toString() + "|" + NPC.mId + " has invalid class"); } @@ -1002,18 +991,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI messages.push_back(id.toString() + "|" + NPC.mId + " has negative rank"); } - bool nosuchfaction(true); - - for (int i = 0; i < mFactions.getSize(); ++i) - { - if (dynamic_cast(mFactions.getRecord(i).get()).mId == NPC.mFaction) - { - nosuchfaction = false; - break; - } - } - - if (nosuchfaction) + if (mFactions.searchId(NPC.mFaction) == -1) { messages.push_back(id.toString() + "|" + NPC.mId + " has invalid faction"); } @@ -1026,7 +1004,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI if (NPC.mHair.empty()) { - messages.push_back(id.toString() + "|" + NPC.mId + " has no har"); + messages.push_back(id.toString() + "|" + NPC.mId + " has no hair"); } //TODO: reputation, Disposition, rank, everything else diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index c25811ea4..64e39ad2f 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -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(this)->get(type); + return const_cast (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 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 SpellCheckStage (mData.getSpells())); - mVerifier->appendStage(new ReferenceableCheckStage(mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses(), mData.getFactions())); + 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::iterator iter(mReports.begin()); iter != mReports.end(); ++iter) + for (std::map::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,33 @@ 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::iterator iter = mActiveReports.find(type); + std::map::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()); } + diff --git a/apps/opencs/model/world/refidcollection.hpp b/apps/opencs/model/world/refidcollection.hpp index 1a21de8f4..328680d85 100644 --- a/apps/opencs/model/world/refidcollection.hpp +++ b/apps/opencs/model/world/refidcollection.hpp @@ -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 mColumns; - std::map mAdapters; + std::map 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,61 +55,62 @@ 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 getIds(bool listDeleted) const; + virtual std::vector 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& newOrder); + virtual bool reorderRows (int baseIndex, const std::vector& 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; + void save (int index, ESM::ESMWriter& writer) const; - const RefIdData& getDataSet() const; //I can't figure out a better name for this one :( + const RefIdData& getDataSet() const; //I can't figure out a better name for this one :( }; } #endif +