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

Even more elses

This commit is contained in:
AnyOldName3 2025-04-10 18:32:52 +01:00
parent 37dc1a6a76
commit 48572e4c96

View file

@ -63,21 +63,17 @@ namespace ESM
const auto indexIt = mIndex.find(index); const auto indexIt = mIndex.find(index);
if (indexIt == mIndex.end()) if (indexIt == mIndex.end())
throw std::logic_error("ESMReader at index " + std::to_string(index) + " has not been created yet"); throw std::logic_error("ESMReader at index " + std::to_string(index) + " has not been created yet");
else switch (indexIt->second->mState)
{ {
switch (indexIt->second->mState) case State::Busy:
{ case State::Free:
case State::Busy: return indexIt->second->mReader.getName();
case State::Free: case State::Closed:
return indexIt->second->mReader.getName(); if (indexIt->second->mName)
case State::Closed: return *indexIt->second->mName;
if (indexIt->second->mName) throw std::logic_error("ESMReader at index " + std::to_string(index) + " has forgotten its filename");
return *indexIt->second->mName; default:
throw std::logic_error( throw std::logic_error("ESMReader at index " + std::to_string(index) + " in unknown state");
"ESMReader at index " + std::to_string(index) + " has forgotten its filename");
default:
throw std::logic_error("ESMReader at index " + std::to_string(index) + " in unknown state");
}
} }
} }
@ -86,23 +82,19 @@ namespace ESM
const auto indexIt = mIndex.find(index); const auto indexIt = mIndex.find(index);
if (indexIt == mIndex.end()) if (indexIt == mIndex.end())
return 0; return 0;
else switch (indexIt->second->mState)
{ {
switch (indexIt->second->mState) case State::Busy:
{ case State::Free:
case State::Busy: if (!indexIt->second->mReader.getName().empty())
case State::Free: return indexIt->second->mReader.getFileSize();
if (!indexIt->second->mReader.getName().empty()) throw std::logic_error("ESMReader at index " + std::to_string(index) + " has not been opened yet");
return indexIt->second->mReader.getFileSize(); case State::Closed:
throw std::logic_error("ESMReader at index " + std::to_string(index) + " has not been opened yet"); if (indexIt->second->mFileSize)
case State::Closed: return *indexIt->second->mFileSize;
if (indexIt->second->mFileSize) throw std::logic_error("ESMReader at index " + std::to_string(index) + " has forgotten its file size");
return *indexIt->second->mFileSize; default:
throw std::logic_error( throw std::logic_error("ESMReader at index " + std::to_string(index) + " in unknown state");
"ESMReader at index " + std::to_string(index) + " has forgotten its file size");
default:
throw std::logic_error("ESMReader at index " + std::to_string(index) + " in unknown state");
}
} }
} }