diff --git a/apps/opencs/model/doc/savingstages.cpp b/apps/opencs/model/doc/savingstages.cpp index 610d2ab807..3ef465f39d 100644 --- a/apps/opencs/model/doc/savingstages.cpp +++ b/apps/opencs/model/doc/savingstages.cpp @@ -253,12 +253,12 @@ void CSMDoc::CollectionReferencesStage::perform(int stage, Messages& messages) if (record.isModified() || record.mState == CSMWorld::RecordBase::State_Deleted) { - ESM::RefId cellId = record.get().mOriginalCell.empty() ? record.get().mCell : record.get().mOriginalCell; + const ESM::RefId& cellId = record.get().mOriginalCell.empty() ? record.get().mCell : record.get().mOriginalCell; std::deque& indices = mState.getSubRecords()[cellId.getRefIdString()]; // collect moved references at the end of the container - bool interior = cellId.getRefIdString().substr(0, 1) != "#"; + bool interior = cellId.getRefIdString()[0] != '#'; std::ostringstream stream; if (!interior) { @@ -362,7 +362,7 @@ void CSMDoc::WriteCellCollectionStage::perform(int stage, Messages& messages) || references != mState.getSubRecords().end()) { CSMWorld::Cell cellRecord = cell.get(); - bool interior = cellRecord.mId.getRefIdString().substr(0, 1) != "#"; + bool interior = cellRecord.mId.getRefIdString()[0] != '#'; // count new references and adjust RefNumCount accordingsly unsigned int newRefNum = cellRecord.mRefNumCounter; @@ -447,7 +447,7 @@ void CSMDoc::WritePathgridCollectionStage::perform(int stage, Messages& messages { CSMWorld::Pathgrid record = pathgrid.get(); std::string recordIdString = record.mId.getRefIdString(); - if (recordIdString.substr(0, 1) == "#") + if (recordIdString[0] == '#') { std::istringstream stream(recordIdString.c_str()); char ignore; diff --git a/apps/opencs/model/tools/startscriptcheck.cpp b/apps/opencs/model/tools/startscriptcheck.cpp index 1e81967832..bf30133381 100644 --- a/apps/opencs/model/tools/startscriptcheck.cpp +++ b/apps/opencs/model/tools/startscriptcheck.cpp @@ -35,7 +35,7 @@ void CSMTools::StartScriptCheckStage::perform(int stage, CSMDoc::Messages& messa if ((mIgnoreBaseRecords && record.mState == CSMWorld::RecordBase::State_BaseOnly) || record.isDeleted()) return; - auto scriptId = record.get().mId; + const auto& scriptId = record.get().mId; CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_StartScript, scriptId); diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index 4a58a4fdf9..0c5852efd0 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -77,11 +77,14 @@ CSMDoc::OperationHolder* CSMTools::Tools::getVerifier() connect(&mVerifier, &CSMDoc::OperationHolder::done, this, &Tools::done); connect(&mVerifier, &CSMDoc::OperationHolder::reportMessage, this, &Tools::verifierMessage); - std::vector mandatoryIds{ "Day", "DaysPassed", "GameHour", "Month", "PCRace" }; std::vector mandatoryRefIds; - for (auto& id : mandatoryIds) - mandatoryRefIds.push_back(ESM::RefId::stringRefId(id)); + { + auto mandatoryIds = { "Day", "DaysPassed", "GameHour", "Month", "PCRace" }; + for (auto& id : mandatoryIds) + mandatoryRefIds.push_back(ESM::RefId::stringRefId(id)); + } + mVerifierOperation->appendStage(new MandatoryIdStage( mData.getGlobals(), CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Globals), mandatoryRefIds)); diff --git a/apps/opencs/model/world/infocollection.cpp b/apps/opencs/model/world/infocollection.cpp index 756009bf2a..b25f974bc7 100644 --- a/apps/opencs/model/world/infocollection.cpp +++ b/apps/opencs/model/world/infocollection.cpp @@ -143,12 +143,12 @@ int CSMWorld::InfoCollection::getInsertIndex(const std::string& id, UniversalId: int index = -1; const Info& info = static_cast*>(record)->get(); - auto topic = info.mTopicId; + const std::string& topic = info.mTopicId.getRefIdString(); // if the record has a prev, find its index value if (!info.mPrev.empty()) { - index = getInfoIndex(info.mPrev.getRefIdString(), topic.getRefIdString()); + index = getInfoIndex(info.mPrev.getRefIdString(), topic); if (index != -1) ++index; // if prev exists, set current index to one above prev @@ -158,13 +158,13 @@ int CSMWorld::InfoCollection::getInsertIndex(const std::string& id, UniversalId: if (index == -1 && !info.mNext.empty()) { // if next exists, use its index as the current index - index = getInfoIndex(info.mNext.getRefIdString(), topic.getRefIdString()); + index = getInfoIndex(info.mNext.getRefIdString(), topic); } // if next doesn't exist or not found (i.e. neither exist yet) then start a new one if (index == -1) { - Range range = getTopicRange(topic.getRefIdString()); // getTopicRange converts topic to lower case first + Range range = getTopicRange(topic); // getTopicRange converts topic to lower case first index = std::distance(getRecords().begin(), range.second); } diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 37b7c28378..57e77911c6 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -300,7 +300,7 @@ CSVRender::WorldspaceWidget::DropType CSVRender::WorldspaceWidget::getDropType( if (iter->getType() == CSMWorld::UniversalId::Type_Cell || iter->getType() == CSMWorld::UniversalId::Type_Cell_Missing) { - type = iter->getId().substr(0, 1) == "#" ? Type_CellsExterior : Type_CellsInterior; + type = iter->getId()[0] == '#' ? Type_CellsExterior : Type_CellsInterior; } else if (iter->getType() == CSMWorld::UniversalId::Type_DebugProfile) type = Type_DebugProfile; diff --git a/components/esm3/cellref.cpp b/components/esm3/cellref.cpp index b27df00ade..ef03326b9d 100644 --- a/components/esm3/cellref.cpp +++ b/components/esm3/cellref.cpp @@ -41,7 +41,7 @@ namespace ESM template void loadDataImpl(ESMReader& esm, bool& isDeleted, CellRef& cellRef) { - const auto getRefIdOrSkip = [&](ESM::RefId refId) { + const auto getRefIdOrSkip = [&](ESM::RefId& refId) { if constexpr (load) refId = esm.getRefId(); else