From 03235bf0a274b7dfd1e95a1a58f2662ffbbececc Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 27 Dec 2013 22:13:55 +0100 Subject: [PATCH] NPC. Still WIP. --- .../opencs/model/tools/referenceablecheck.cpp | 260 +++++++++++++++++- .../opencs/model/tools/referenceablecheck.hpp | 9 +- apps/opencs/model/world/refiddata.cpp | 229 ++++++++------- apps/opencs/model/world/refiddata.hpp | 4 + components/esm/loadnpc.hpp | 2 +- 5 files changed, 383 insertions(+), 121 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index d37808810..6d06d6151 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "../world/record.hpp" @@ -22,7 +23,10 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefId mIngredientsSize(mReferencables.getIngredients().getSize()), mCreaturesLevListsSize(mReferencables.getCreatureLevelledLists().getSize()), mItemLevelledListsSize(mReferencables.getItemLevelledList().getSize()), - mLightsSize(mReferencables.getLights().getSize()) + mLightsSize(mReferencables.getLights().getSize()), + mLockpicksSize(mReferencables.getLocpicks().getSize()), + mMiscellaneousSize(mReferencables.getMiscellaneous().getSize()), + mNPCsSize(mReferencables.getNPCs().getSize()) { } @@ -111,11 +115,35 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str if (stage < mItemLevelledListsSize) { - mItemLevelledListCheck(stage, mReferencables.getItemLevelledList(), messages); + itemLevelledListCheck(stage, mReferencables.getItemLevelledList(), messages); return; } stage -= mItemLevelledListsSize; + + if (stage < mLightsSize) + { + lightCheck(stage, mReferencables.getLights(), messages); + return; + } + + stage -= mLightsSize; + + if (stage < mLockpicksSize) + { + lockpickCheck(stage, mReferencables.getLocpicks(), messages); + return; + } + + stage -= mLockpicksSize; + + if (stage < mMiscellaneousSize) + { + miscCheck(stage, mReferencables.getMiscellaneous(), messages); + return; + } + + stage -= mMiscellaneousSize; } int CSMTools::ReferenceableCheckStage::setup() @@ -602,7 +630,7 @@ void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(int stage, const C const ESM::CreatureLevList& CreatureLevList = (static_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_CreatureLevelledList, CreatureLevList.mId); //CreatureLevList but Type_CreatureLevelledList :/ - for (int i = 0; i < CreatureLevList.mList.size(); ++i) + for (unsigned i = 0; i < CreatureLevList.mList.size(); ++i) { if (CreatureLevList.mList[i].mId.empty()) { @@ -614,14 +642,9 @@ void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(int stage, const C messages.push_back(id.toString() + "|" + CreatureLevList.mId + " contains item with non-positive level"); } } - - if (CreatureLevList.mChanceNone < 0 or CreatureLevList.mChanceNone > 100) - { - messages.push_back(id.toString() + "|" + CreatureLevList.mId + " chance to be empty is not beetween 0 and 100"); - } } -void CSMTools::ReferenceableCheckStage::mItemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::ItemLevList >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::itemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::ItemLevList >& records, std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -633,7 +656,7 @@ void CSMTools::ReferenceableCheckStage::mItemLevelledListCheck(int stage, const const ESM::ItemLevList& ItemLevList = (static_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_ItemLevelledList, ItemLevList.mId); - for (int i = 0; i < ItemLevList.mList.size(); ++i) + for (unsigned i = 0; i < ItemLevList.mList.size(); ++i) { if (ItemLevList.mList[i].mId.empty()) { @@ -645,9 +668,222 @@ void CSMTools::ReferenceableCheckStage::mItemLevelledListCheck(int stage, const messages.push_back(id.toString() + "|" + ItemLevList.mId + " contains item with non-positive level"); } } +} - if (ItemLevList.mChanceNone < 0 or ItemLevList.mChanceNone > 100) +void CSMTools::ReferenceableCheckStage::lightCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Light >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Light& Light = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Light, Light.mId); + + if (Light.mData.mRadius < 0) { - messages.push_back(id.toString() + "|" + ItemLevList.mId + " chance to be empty is not beetween 0 and 100"); + messages.push_back(id.toString() + "|" + Light.mId + " has negative light radius"); } + + if (Light.mData.mFlags & ESM::Light::Carry) + { + if (Light.mIcon.empty()) //Needs to be checked with carrable flag + { + messages.push_back(id.toString() + "|" + Light.mId + " has no icon"); + } + + if (Light.mData.mWeight < 0) //probabbly needs to be checked only for carrable lights TODO + { + messages.push_back(id.toString() + "|" + Light.mId + " has negative weight"); + } + + if (Light.mData.mValue < 0) //probabbly needs to be checked only for carrable lights TODO + { + messages.push_back(id.toString() + "|" + Light.mId + " has negative value"); + } + + if (Light.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Light.mId + " has no model"); + } + + if (Light.mData.mTime < 0) + { + messages.push_back(id.toString() + "|" + Light.mId + " has negative duration"); + } + } +} + +void CSMTools::ReferenceableCheckStage::lockpickCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Lockpick >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Lockpick& Lockpick = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Lockpick, Lockpick.mId); + + //Checking for name + if (Lockpick.mName.empty()) + { + messages.push_back(id.toString() + "|" + Lockpick.mId + " has an empty name"); + } + + //Checking for weight + if (Lockpick.mData.mWeight < 0) + { + messages.push_back(id.toString() + "|" + Lockpick.mId + " has negative weight"); + } + + //Checking for value + if (Lockpick.mData.mValue < 0) + { + messages.push_back(id.toString() + "|" + Lockpick.mId + " has negative value"); + } + +//checking for model + if (Lockpick.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Lockpick.mId + " has no model"); + } + + //checking for icon + if (Lockpick.mIcon.empty()) + { + messages.push_back(id.toString() + "|" + Lockpick.mId + " has no icon"); + } + + if (Lockpick.mData.mQuality <= 0) + { + messages.push_back(id.toString() + "|" + Lockpick.mId + " has non-positive quality"); + } + + if (Lockpick.mData.mUses <= 0) + { + messages.push_back(id.toString() + "|" + Lockpick.mId + " has no uses left"); + } +} + +void CSMTools::ReferenceableCheckStage::miscCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Miscellaneous >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Miscellaneous& Miscellaneous = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Miscellaneous, Miscellaneous.mId); + + //Checking for name + if (Miscellaneous.mName.empty()) + { + messages.push_back(id.toString() + "|" + Miscellaneous.mId + " has an empty name"); + } + + //Checking for weight + if (Miscellaneous.mData.mWeight < 0) + { + messages.push_back(id.toString() + "|" + Miscellaneous.mId + " has negative weight"); + } + + //Checking for value + if (Miscellaneous.mData.mValue < 0) + { + messages.push_back(id.toString() + "|" + Miscellaneous.mId + " has negative value"); + } + +//checking for model + if (Miscellaneous.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Miscellaneous.mId + " has no model"); + } + + //checking for icon + if (Miscellaneous.mIcon.empty()) + { + messages.push_back(id.toString() + "|" + Miscellaneous.mId + " has no icon"); + } +} + +void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::NPC >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::NPC& NPC = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Npc, NPC.mId); + + + + short level(NPC.mNpdt52.mLevel); + char Disposition(NPC.mNpdt52.mDisposition); + char Reputation(NPC.mNpdt52.mReputation); + char Rank(NPC.mNpdt52.mRank); + //Don't know what unknown is for + int Gold(NPC.mNpdt52.mGold); + + if (NPC.mNpdtType == 12) + { + if (NPC.mFlags ^ ESM::NPC::Flags::Autocalc) + { + messages.push_back(id.toString() + "|" + NPC.mId + " mNpdtType and flags mismatch!"); //should not happend? + return; + } + + level = NPC.mNpdt12.mLevel; + Disposition = NPC.mNpdt12.mDisposition; + Reputation = NPC.mNpdt12.mReputation; + Rank = NPC.mNpdt12.mRank; + Gold = NPC.mNpdt12.mGold; + } + else + { + if (NPC.mNpdt52.mHealth < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " health is negative value"); + } + + if (NPC.mNpdt52.mMana < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " mana is negative value"); + } + + if (NPC.mNpdt52.mFatigue < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " fatigue is negative value"); + } + } + + if (level < 1) + { + messages.push_back(id.toString() + "|" + NPC.mId + " level is non positive"); + } + + if (Gold < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " gold is negative value"); + } + + if (NPC.mName.empty()) + { + messages.push_back(id.toString() + "|" + NPC.mId + " has any empty name"); + } + + if (NPC.mClass.empty()) + { + messages.push_back(id.toString() + "|" + NPC.mId + " has any empty class"); + } + + //TODO: reputation, Disposition, rank, everything else } diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 6bffc2b25..d4f7697ae 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -28,7 +28,11 @@ namespace CSMTools void doorCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void ingredientCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); - void mItemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void itemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void lightCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void lockpickCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void miscCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void npcCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); const CSMWorld::RefIdData mReferencables; @@ -46,6 +50,9 @@ namespace CSMTools const int mCreaturesLevListsSize; const int mItemLevelledListsSize; const int mLightsSize; + const int mLockpicksSize; + const int mMiscellaneousSize; + const int mNPCsSize; }; } #endif // REFERENCEABLECHECKSTAGE_H diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 54e2cd12f..9c0a857a5 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -9,187 +9,187 @@ CSMWorld::RefIdDataContainerBase::~RefIdDataContainerBase() {} CSMWorld::RefIdData::RefIdData() { - mRecordContainers.insert (std::make_pair (UniversalId::Type_Activator, &mActivators)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Potion, &mPotions)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Apparatus, &mApparati)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Armor, &mArmors)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Book, &mBooks)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Clothing, &mClothing)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Container, &mContainers)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Creature, &mCreatures)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Door, &mDoors)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Ingredient, &mIngredients)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_CreatureLevelledList, - &mCreatureLevelledLists)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_ItemLevelledList, &mItemLevelledLists)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Light, &mLights)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Lockpick, &mLockpicks)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Miscellaneous, &mMiscellaneous)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Npc, &mNpcs)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Probe, &mProbes)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Repair, &mRepairs)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Static, &mStatics)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Weapon, &mWeapons)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Activator, &mActivators)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Potion, &mPotions)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Apparatus, &mApparati)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Armor, &mArmors)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Book, &mBooks)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Clothing, &mClothing)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Container, &mContainers)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Creature, &mCreatures)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Door, &mDoors)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Ingredient, &mIngredients)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_CreatureLevelledList, + &mCreatureLevelledLists)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_ItemLevelledList, &mItemLevelledLists)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Light, &mLights)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Lockpick, &mLockpicks)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Miscellaneous, &mMiscellaneous)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Npc, &mNpcs)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Probe, &mProbes)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Repair, &mRepairs)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Static, &mStatics)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Weapon, &mWeapons)); } -CSMWorld::RefIdData::LocalIndex CSMWorld::RefIdData::globalToLocalIndex (int index) const +CSMWorld::RefIdData::LocalIndex CSMWorld::RefIdData::globalToLocalIndex(int index) const { - for (std::map::const_iterator iter ( - mRecordContainers.begin()); iter!=mRecordContainers.end(); ++iter) + for (std::map::const_iterator iter( + mRecordContainers.begin()); iter != mRecordContainers.end(); ++iter) { - if (indexsecond->getSize()) - return LocalIndex (index, iter->first); + if (index < iter->second->getSize()) + return LocalIndex(index, iter->first); index -= iter->second->getSize(); } - throw std::runtime_error ("RefIdData index out of range"); + throw std::runtime_error("RefIdData index out of range"); } -int CSMWorld::RefIdData::localToGlobalIndex (const LocalIndex& index) - const +int CSMWorld::RefIdData::localToGlobalIndex(const LocalIndex& index) +const { - std::map::const_iterator end = - mRecordContainers.find (index.second); + std::map::const_iterator end = + mRecordContainers.find(index.second); - if (end==mRecordContainers.end()) - throw std::logic_error ("invalid local index type"); + if (end == mRecordContainers.end()) + throw std::logic_error("invalid local index type"); int globalIndex = index.first; - for (std::map::const_iterator iter ( - mRecordContainers.begin()); iter!=end; ++iter) + for (std::map::const_iterator iter( + mRecordContainers.begin()); iter != end; ++iter) globalIndex += iter->second->getSize(); return globalIndex; } -CSMWorld::RefIdData::LocalIndex CSMWorld::RefIdData::searchId ( +CSMWorld::RefIdData::LocalIndex CSMWorld::RefIdData::searchId( const std::string& id) const { - std::string id2 = Misc::StringUtils::lowerCase (id); + std::string id2 = Misc::StringUtils::lowerCase(id); - std::map >::const_iterator iter = mIndex.find (id2); + std::map >::const_iterator iter = mIndex.find(id2); - if (iter==mIndex.end()) - return std::make_pair (-1, CSMWorld::UniversalId::Type_None); + if (iter == mIndex.end()) + return std::make_pair(-1, CSMWorld::UniversalId::Type_None); return iter->second; } -void CSMWorld::RefIdData::erase (int index, int count) +void CSMWorld::RefIdData::erase(int index, int count) { - LocalIndex localIndex = globalToLocalIndex (index); + LocalIndex localIndex = globalToLocalIndex(index); - std::map::const_iterator iter = - mRecordContainers.find (localIndex.second); + std::map::const_iterator iter = + mRecordContainers.find(localIndex.second); - while (count>0 && iter!=mRecordContainers.end()) + while (count > 0 && iter != mRecordContainers.end()) { int size = iter->second->getSize(); - if (localIndex.first+count>size) + if (localIndex.first + count > size) { - erase (localIndex, size-localIndex.first); - count -= size-localIndex.first; + erase(localIndex, size - localIndex.first); + count -= size - localIndex.first; ++iter; - if (iter==mRecordContainers.end()) - throw std::runtime_error ("invalid count value for erase operation"); + if (iter == mRecordContainers.end()) + throw std::runtime_error("invalid count value for erase operation"); localIndex.first = 0; localIndex.second = iter->first; } else { - erase (localIndex, count); + erase(localIndex, count); count = 0; } } } -const CSMWorld::RecordBase& CSMWorld::RefIdData::getRecord (const LocalIndex& index) const +const CSMWorld::RecordBase& CSMWorld::RefIdData::getRecord(const LocalIndex& index) const { - std::map::const_iterator iter = - mRecordContainers.find (index.second); + std::map::const_iterator iter = + mRecordContainers.find(index.second); - if (iter==mRecordContainers.end()) - throw std::logic_error ("invalid local index type"); + if (iter == mRecordContainers.end()) + throw std::logic_error("invalid local index type"); - return iter->second->getRecord (index.first); + return iter->second->getRecord(index.first); } -CSMWorld::RecordBase& CSMWorld::RefIdData::getRecord (const LocalIndex& index) +CSMWorld::RecordBase& CSMWorld::RefIdData::getRecord(const LocalIndex& index) { - std::map::iterator iter = - mRecordContainers.find (index.second); + std::map::iterator iter = + mRecordContainers.find(index.second); - if (iter==mRecordContainers.end()) - throw std::logic_error ("invalid local index type"); + if (iter == mRecordContainers.end()) + throw std::logic_error("invalid local index type"); - return iter->second->getRecord (index.first); + return iter->second->getRecord(index.first); } -void CSMWorld::RefIdData::appendRecord (UniversalId::Type type, const std::string& id) +void CSMWorld::RefIdData::appendRecord(UniversalId::Type type, const std::string& id) { - std::map::iterator iter = - mRecordContainers.find (type); + std::map::iterator iter = + mRecordContainers.find(type); - if (iter==mRecordContainers.end()) - throw std::logic_error ("invalid local index type"); + if (iter == mRecordContainers.end()) + throw std::logic_error("invalid local index type"); - iter->second->appendRecord (id); + iter->second->appendRecord(id); - mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (id), - LocalIndex (iter->second->getSize()-1, type))); + mIndex.insert(std::make_pair(Misc::StringUtils::lowerCase(id), + LocalIndex(iter->second->getSize() - 1, type))); } -int CSMWorld::RefIdData::getAppendIndex (UniversalId::Type type) const +int CSMWorld::RefIdData::getAppendIndex(UniversalId::Type type) const { int index = 0; - for (std::map::const_iterator iter ( - mRecordContainers.begin()); iter!=mRecordContainers.end(); ++iter) + for (std::map::const_iterator iter( + mRecordContainers.begin()); iter != mRecordContainers.end(); ++iter) { index += iter->second->getSize(); - if (type==iter->first) + if (type == iter->first) break; } return index; } -void CSMWorld::RefIdData::load (const LocalIndex& index, ESM::ESMReader& reader, bool base) +void CSMWorld::RefIdData::load(const LocalIndex& index, ESM::ESMReader& reader, bool base) { - std::map::iterator iter = - mRecordContainers.find (index.second); + std::map::iterator iter = + mRecordContainers.find(index.second); - if (iter==mRecordContainers.end()) - throw std::logic_error ("invalid local index type"); + if (iter == mRecordContainers.end()) + throw std::logic_error("invalid local index type"); - iter->second->load (index.first, reader, base); + iter->second->load(index.first, reader, base); } -void CSMWorld::RefIdData::erase (const LocalIndex& index, int count) +void CSMWorld::RefIdData::erase(const LocalIndex& index, int count) { - std::map::iterator iter = - mRecordContainers.find (index.second); + std::map::iterator iter = + mRecordContainers.find(index.second); - if (iter==mRecordContainers.end()) - throw std::logic_error ("invalid local index type"); + if (iter == mRecordContainers.end()) + throw std::logic_error("invalid local index type"); - for (int i=index.first; i::iterator result = - mIndex.find (Misc::StringUtils::lowerCase (iter->second->getId (i))); + mIndex.find(Misc::StringUtils::lowerCase(iter->second->getId(i))); - if (result!=mIndex.end()) - mIndex.erase (result); + if (result != mIndex.end()) + mIndex.erase(result); } - iter->second->erase (index.first, count); + iter->second->erase(index.first, count); } int CSMWorld::RefIdData::getSize() const @@ -197,39 +197,39 @@ int CSMWorld::RefIdData::getSize() const return mIndex.size(); } -std::vector CSMWorld::RefIdData::getIds (bool listDeleted) const +std::vector CSMWorld::RefIdData::getIds(bool listDeleted) const { std::vector ids; - for (std::map::const_iterator iter (mIndex.begin()); iter!=mIndex.end(); - ++iter) + for (std::map::const_iterator iter(mIndex.begin()); iter != mIndex.end(); + ++iter) { - if (listDeleted || !getRecord (iter->second).isDeleted()) + if (listDeleted || !getRecord(iter->second).isDeleted()) { - std::map::const_iterator container = - mRecordContainers.find (iter->second.second); + std::map::const_iterator container = + mRecordContainers.find(iter->second.second); - if (container==mRecordContainers.end()) - throw std::logic_error ("Invalid referenceable ID type"); + if (container == mRecordContainers.end()) + throw std::logic_error("Invalid referenceable ID type"); - ids.push_back (container->second->getId (iter->second.first)); + ids.push_back(container->second->getId(iter->second.first)); } } return ids; } -void CSMWorld::RefIdData::save (int index, ESM::ESMWriter& writer) const +void CSMWorld::RefIdData::save(int index, ESM::ESMWriter& writer) const { - LocalIndex localIndex = globalToLocalIndex (index); + LocalIndex localIndex = globalToLocalIndex(index); - std::map::const_iterator iter = - mRecordContainers.find (localIndex.second); + std::map::const_iterator iter = + mRecordContainers.find(localIndex.second); - if (iter==mRecordContainers.end()) - throw std::logic_error ("invalid local index type"); + if (iter == mRecordContainers.end()) + throw std::logic_error("invalid local index type"); - iter->second->save (localIndex.first, writer); + iter->second->save(localIndex.first, writer); } const CSMWorld::RefIdDataContainer< ESM::Book >& CSMWorld::RefIdData::getBooks() const @@ -296,3 +296,18 @@ const CSMWorld::RefIdDataContainer< ESM::Light >& CSMWorld::RefIdData::getLights { return mLights; } + +const CSMWorld::RefIdDataContainer< ESM::Lockpick >& CSMWorld::RefIdData::getLocpicks() const +{ + return mLockpicks; +} + +const CSMWorld::RefIdDataContainer< ESM::Miscellaneous >& CSMWorld::RefIdData::getMiscellaneous() const +{ + return mMiscellaneous; +} + +const CSMWorld::RefIdDataContainer< ESM::NPC >& CSMWorld::RefIdData::getNPCs() const +{ + return mNpcs; +} diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 6b6e01e01..8aa3c2522 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -234,7 +234,11 @@ namespace CSMWorld const RefIdDataContainer& getCreatureLevelledLists() const; const RefIdDataContainer& getItemLevelledList() const; const RefIdDataContainer& getLights() const; + const RefIdDataContainer& getLocpicks() const; + const RefIdDataContainer& getMiscellaneous() const; + const RefIdDataContainer& getNPCs() const; }; } #endif + diff --git a/components/esm/loadnpc.hpp b/components/esm/loadnpc.hpp index 1eac8d64f..08f678b45 100644 --- a/components/esm/loadnpc.hpp +++ b/components/esm/loadnpc.hpp @@ -105,7 +105,7 @@ struct NPC char mNpdtType; NPDTstruct52 mNpdt52; - NPDTstruct12 mNpdt12; // Use this if npdt52.gold == -10 + NPDTstruct12 mNpdt12; //for autocalculated characters int mFlags;