1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-04 02:41:19 +00:00

Merge branch 'cicontent' into 'master'

Use ciEqual to detect missing content files

See merge request OpenMW/openmw!3767
This commit is contained in:
jvoisin 2024-01-12 19:19:02 +00:00
commit 99164b3a0e
2 changed files with 7 additions and 4 deletions

View File

@ -16,6 +16,7 @@
#include <components/loadinglistener/loadinglistener.hpp>
#include <components/files/conversion.hpp>
#include <components/misc/algorithm.hpp>
#include <components/settings/values.hpp>
#include <osg/Image>
@ -81,10 +82,8 @@ std::map<int, int> MWState::StateManager::buildContentFileIndexMap(const ESM::ES
for (int iPrev = 0; iPrev < static_cast<int>(prev.size()); ++iPrev)
{
std::string id = Misc::StringUtils::lowerCase(prev[iPrev].name);
for (int iCurrent = 0; iCurrent < static_cast<int>(current.size()); ++iCurrent)
if (id == Misc::StringUtils::lowerCase(current[iCurrent]))
if (Misc::StringUtils::ciEqual(prev[iPrev].name, current[iCurrent]))
{
map.insert(std::make_pair(iPrev, iCurrent));
break;

View File

@ -3,6 +3,8 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "../misc/algorithm.hpp"
namespace ESM
{
void SavedGame::load(ESMReader& esm)
@ -67,7 +69,9 @@ namespace ESM
std::vector<std::string_view> missingFiles;
for (const std::string& contentFile : mContentFiles)
{
if (std::find(allContentFiles.begin(), allContentFiles.end(), contentFile) == allContentFiles.end())
auto it = std::find_if(allContentFiles.begin(), allContentFiles.end(),
[&](const std::string& file) { return Misc::StringUtils::ciEqual(file, contentFile); });
if (it == allContentFiles.end())
{
missingFiles.emplace_back(contentFile);
}