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.
This commit is contained in:
Lioncash 2020-05-12 19:53:16 -04:00
parent fd2f2e146c
commit bfbb027117
2 changed files with 7 additions and 10 deletions

View File

@ -1,10 +1,16 @@
#include "Runtime/MP1/CSlideShow.hpp" #include "Runtime/MP1/CSlideShow.hpp"
#include "Editor/ProjectManager.hpp" #include <algorithm>
#include "Editor/ProjectManager.hpp"
#include "Runtime/GameGlobalObjects.hpp" #include "Runtime/GameGlobalObjects.hpp"
namespace urde { namespace urde {
namespace {
bool AreAllDepsLoaded(const std::vector<TLockedToken<CDependencyGroup>>& 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()) { CSlideShow::CSlideShow() : CIOWin("SlideShow"), x130_(g_tweakSlideShow->GetX54()) {
const SObjectTag* font = g_ResFactory->GetResourceIdByName(g_tweakSlideShow->GetFont()); const SObjectTag* font = g_ResFactory->GetResourceIdByName(g_tweakSlideShow->GetFont());
@ -58,14 +64,6 @@ bool CSlideShow::LoadTXTRDep(std::string_view name) {
return false; return false;
} }
bool CSlideShow::AreAllDepsLoaded(const std::vector<TLockedToken<CDependencyGroup>>& deps) {
for (const TLockedToken<CDependencyGroup>& token : deps) {
if (!token.IsLoaded())
return false;
}
return true;
}
CIOWin::EMessageReturn CSlideShow::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) { CIOWin::EMessageReturn CSlideShow::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) {
switch (msg.GetType()) { switch (msg.GetType()) {
case EArchMsgType::TimerTick: { case EArchMsgType::TimerTick: {

View File

@ -98,7 +98,6 @@ private:
bool x135_24_ : 1 = true; bool x135_24_ : 1 = true;
bool LoadTXTRDep(std::string_view name); bool LoadTXTRDep(std::string_view name);
static bool AreAllDepsLoaded(const std::vector<TLockedToken<CDependencyGroup>>& deps);
public: public:
CSlideShow(); CSlideShow();