1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 11:53:53 +00:00

Use C++11-style loops in the StateManager

This commit is contained in:
Andrei Kortunov 2020-05-29 12:26:02 +04:00
parent 7109378658
commit 48b3fe5733

View file

@ -240,12 +240,8 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
ESM::ESMWriter writer; ESM::ESMWriter writer;
const std::vector<std::string>& current = for (const std::string& contentFile : MWBase::Environment::get().getWorld()->getContentFiles())
MWBase::Environment::get().getWorld()->getContentFiles(); writer.addMaster(contentFile, 0); // not using the size information anyway -> use value of 0
for (std::vector<std::string>::const_iterator iter (current.begin()); iter!=current.end();
++iter)
writer.addMaster (*iter, 0); // not using the size information anyway -> use value of 0
writer.setFormat (ESM::SavedGame::sCurrentFormat); writer.setFormat (ESM::SavedGame::sCurrentFormat);
@ -346,10 +342,10 @@ void MWState::StateManager::quickSave (std::string name)
if (currentCharacter) if (currentCharacter)
{ {
for (Character::SlotIterator it = currentCharacter->begin(); it != currentCharacter->end(); ++it) for (auto& save : *currentCharacter)
{ {
//Visiting slots allows the quicksave finder to find the oldest quicksave //Visiting slots allows the quicksave finder to find the oldest quicksave
saveFinder.visitSave(&*it); saveFinder.visitSave(&save);
} }
} }
@ -360,12 +356,10 @@ void MWState::StateManager::quickSave (std::string name)
void MWState::StateManager::loadGame(const std::string& filepath) void MWState::StateManager::loadGame(const std::string& filepath)
{ {
for (CharacterIterator it = mCharacterManager.begin(); it != mCharacterManager.end(); ++it) for (const auto& character : mCharacterManager)
{ {
const MWState::Character& character = *it; for (const auto& slot : character)
for (MWState::Character::SlotIterator slotIt = character.begin(); slotIt != character.end(); ++slotIt)
{ {
const MWState::Slot& slot = *slotIt;
if (slot.mPath == boost::filesystem::path(filepath)) if (slot.mPath == boost::filesystem::path(filepath))
{ {
loadGame(&character, slot.mPath.string()); loadGame(&character, slot.mPath.string());
@ -630,13 +624,12 @@ bool MWState::StateManager::verifyProfile(const ESM::SavedGame& profile) const
{ {
const std::vector<std::string>& selectedContentFiles = MWBase::Environment::get().getWorld()->getContentFiles(); const std::vector<std::string>& selectedContentFiles = MWBase::Environment::get().getWorld()->getContentFiles();
bool notFound = false; bool notFound = false;
for (std::vector<std::string>::const_iterator it = profile.mContentFiles.begin(); for (const std::string& contentFile : profile.mContentFiles)
it != profile.mContentFiles.end(); ++it)
{ {
if (std::find(selectedContentFiles.begin(), selectedContentFiles.end(), *it) if (std::find(selectedContentFiles.begin(), selectedContentFiles.end(), contentFile)
== selectedContentFiles.end()) == selectedContentFiles.end())
{ {
Log(Debug::Warning) << "Warning: Saved game dependency " << *it << " is missing."; Log(Debug::Warning) << "Warning: Saved game dependency " << contentFile << " is missing.";
notFound = true; notFound = true;
} }
} }