From 98e7b3fd938edbe334de7bfc36aa2d721f6a3b50 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 6 Apr 2013 19:20:59 +0200 Subject: [PATCH] check for at least one playable race --- apps/opencs/model/tools/racecheck.cpp | 41 ++++++++++++++++++++------- apps/opencs/model/tools/racecheck.hpp | 5 ++++ 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/apps/opencs/model/tools/racecheck.cpp b/apps/opencs/model/tools/racecheck.cpp index 50bb08a7c6..1e7a4cab45 100644 --- a/apps/opencs/model/tools/racecheck.cpp +++ b/apps/opencs/model/tools/racecheck.cpp @@ -7,16 +7,7 @@ #include "../world/universalid.hpp" -CSMTools::RaceCheckStage::RaceCheckStage (const CSMWorld::IdCollection& races) -: mRaces (races) -{} - -int CSMTools::RaceCheckStage::setup() -{ - return mRaces.getSize(); -} - -void CSMTools::RaceCheckStage::perform (int stage, std::vector& messages) +void CSMTools::RaceCheckStage::performPerRecord (int stage, std::vector& messages) { const ESM::Race& race = mRaces.getRecord (stage).get(); @@ -43,5 +34,35 @@ void CSMTools::RaceCheckStage::perform (int stage, std::vector& mes if (race.mData.mWeight.mFemale<0) messages.push_back (id.toString() + "|female " + race.mId + " has negative weight"); + // remember playable flag + if (race.mData.mFlags & 0x1) + mPlayable = true; + /// \todo check data members that can't be edited in the table view +} + +void CSMTools::RaceCheckStage::performFinal (std::vector& messages) +{ + CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Races); + + if (!mPlayable) + messages.push_back (id.toString() + "|No playable race"); +} + +CSMTools::RaceCheckStage::RaceCheckStage (const CSMWorld::IdCollection& races) +: mRaces (races), mPlayable (false) +{} + +int CSMTools::RaceCheckStage::setup() +{ + mPlayable = false; + return mRaces.getSize()+1; +} + +void CSMTools::RaceCheckStage::perform (int stage, std::vector& messages) +{ + if (stage==mRaces.getSize()) + performFinal (messages); + else + performPerRecord (stage, messages); } \ No newline at end of file diff --git a/apps/opencs/model/tools/racecheck.hpp b/apps/opencs/model/tools/racecheck.hpp index e3f12599ba..155f799021 100644 --- a/apps/opencs/model/tools/racecheck.hpp +++ b/apps/opencs/model/tools/racecheck.hpp @@ -13,6 +13,11 @@ namespace CSMTools class RaceCheckStage : public Stage { const CSMWorld::IdCollection& mRaces; + bool mPlayable; + + void performPerRecord (int stage, std::vector& messages); + + void performFinal (std::vector& messages); public: