From bfbb0271173c7ce76175ffd779df506e7f008433 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 12 May 2020 19:53:16 -0400 Subject: [PATCH] CSlideShow: Collapse loop into std::all_of Same behavior, less code. We can also make this function fully internally linked, given it doesn't depend on instance state. --- Runtime/MP1/CSlideShow.cpp | 16 +++++++--------- Runtime/MP1/CSlideShow.hpp | 1 - 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Runtime/MP1/CSlideShow.cpp b/Runtime/MP1/CSlideShow.cpp index 57dd34af3..1ad833348 100644 --- a/Runtime/MP1/CSlideShow.cpp +++ b/Runtime/MP1/CSlideShow.cpp @@ -1,10 +1,16 @@ #include "Runtime/MP1/CSlideShow.hpp" -#include "Editor/ProjectManager.hpp" +#include +#include "Editor/ProjectManager.hpp" #include "Runtime/GameGlobalObjects.hpp" namespace urde { +namespace { +bool AreAllDepsLoaded(const std::vector>& deps) { + return std::all_of(deps.cbegin(), deps.cend(), [](const auto& dep) { return dep.IsLoaded(); }); +} +} // Anonymous namespace CSlideShow::CSlideShow() : CIOWin("SlideShow"), x130_(g_tweakSlideShow->GetX54()) { const SObjectTag* font = g_ResFactory->GetResourceIdByName(g_tweakSlideShow->GetFont()); @@ -58,14 +64,6 @@ bool CSlideShow::LoadTXTRDep(std::string_view name) { return false; } -bool CSlideShow::AreAllDepsLoaded(const std::vector>& deps) { - for (const TLockedToken& token : deps) { - if (!token.IsLoaded()) - return false; - } - return true; -} - CIOWin::EMessageReturn CSlideShow::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) { switch (msg.GetType()) { case EArchMsgType::TimerTick: { diff --git a/Runtime/MP1/CSlideShow.hpp b/Runtime/MP1/CSlideShow.hpp index 4d2689f72..0c6d9ecab 100644 --- a/Runtime/MP1/CSlideShow.hpp +++ b/Runtime/MP1/CSlideShow.hpp @@ -98,7 +98,6 @@ private: bool x135_24_ : 1 = true; bool LoadTXTRDep(std::string_view name); - static bool AreAllDepsLoaded(const std::vector>& deps); public: CSlideShow();