diff --git a/source/graphics/MapGenerator.cpp b/source/graphics/MapGenerator.cpp index 825e963d1e..4e61cd784e 100644 --- a/source/graphics/MapGenerator.cpp +++ b/source/graphics/MapGenerator.cpp @@ -63,7 +63,7 @@ void* CMapGeneratorWorker::RunThread(void *data) self->m_ScriptInterface = new ScriptInterface("RMS", "MapGenerator", ScriptInterface::CreateRuntime(g_ScriptRuntime, RMS_RUNTIME_SIZE)); // Run map generation scripts - if ((!self->Run()) || (self->m_Progress > 0)) + if (!self->Run() || self->m_Progress > 0) { // Don't leave progress in an unknown state, if generator failed, set it to -1 CScopeLock lock(self->m_WorkerMutex); @@ -198,19 +198,15 @@ std::vector CMapGeneratorWorker::GetCivData(ScriptInterface::CxPriv Status ret = vfs::GetPathnames(g_VFS, path, L"*.json", pathnames); if (ret == INFO::OK) { - for (VfsPaths::iterator it = pathnames.begin(); it != pathnames.end(); ++it) + for (const VfsPath& p : pathnames) { // Load JSON file CVFSFile file; - PSRETURN ret = file.Load(g_VFS, *it); + PSRETURN ret = file.Load(g_VFS, p); if (ret != PSRETURN_OK) - { - LOGERROR("CMapGeneratorWorker::GetCivData: Failed to load file '%s': %s", path.string8(), GetErrorString(ret)); - } + LOGERROR("CMapGeneratorWorker::GetCivData: Failed to load file '%s': %s", p.string8(), GetErrorString(ret)); else - { data.push_back(file.DecodeUTF8()); // assume it's UTF-8 - } } } else @@ -250,9 +246,7 @@ bool CMapGeneratorWorker::LoadScripts(const std::wstring& libraryName) { // Ignore libraries that are already loaded if (m_LoadedLibraries.find(libraryName) != m_LoadedLibraries.end()) - { return true; - } // Mark this as loaded, to prevent it recursively loading itself m_LoadedLibraries.insert(libraryName); @@ -264,13 +258,13 @@ bool CMapGeneratorWorker::LoadScripts(const std::wstring& libraryName) Status ret = vfs::GetPathnames(g_VFS, path, L"*.js", pathnames); if (ret == INFO::OK) { - for (VfsPaths::iterator it = pathnames.begin(); it != pathnames.end(); ++it) + for (const VfsPath& p : pathnames) { - LOGMESSAGE("Loading map generator script '%s'", it->string8()); + LOGMESSAGE("Loading map generator script '%s'", p.string8()); - if (!m_ScriptInterface->LoadGlobalScriptFile(*it)) + if (!m_ScriptInterface->LoadGlobalScriptFile(p)) { - LOGERROR("CMapGeneratorWorker::LoadScripts: Failed to load script '%s'", it->string8()); + LOGERROR("CMapGeneratorWorker::LoadScripts: Failed to load script '%s'", p.string8()); return false; } } diff --git a/source/simulation2/Simulation2.cpp b/source/simulation2/Simulation2.cpp index c48c83597e..428dd29ea7 100644 --- a/source/simulation2/Simulation2.cpp +++ b/source/simulation2/Simulation2.cpp @@ -832,14 +832,14 @@ static std::vector GetJSONData(const VfsPath& path) } std::vector data; - for (VfsPaths::const_iterator it = pathnames.begin(); it != pathnames.end(); ++it) + for (const VfsPath& p : pathnames) { // Load JSON file CVFSFile file; - PSRETURN ret = file.Load(g_VFS, *it); + PSRETURN ret = file.Load(g_VFS, p); if (ret != PSRETURN_OK) { - LOGERROR("GetJSONData: Failed to load file '%s': %s", path.string8(), GetErrorString(ret)); + LOGERROR("GetJSONData: Failed to load file '%s': %s", p.string8(), GetErrorString(ret)); continue; }