From f92ab2f5598789d9531bfe93e9abcc3dc4cc938d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Thu, 20 Aug 2020 12:19:00 +0200 Subject: ksys/act: Finish BaseProcLinkData --- src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp') diff --git a/src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp b/src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp index cc986835..8479ae09 100644 --- a/src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp +++ b/src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp @@ -2,11 +2,30 @@ #include #include #include "KingSystem/ActorSystem/actBaseProc.h" +#include "KingSystem/ActorSystem/actBaseProcMgr.h" namespace ksys::act { SEAD_SINGLETON_DISPOSER_IMPL(BaseProcLinkDataMgr) +BaseProc* BaseProcLinkData::getProc(u32 id, bool allow_deleted) const { + if (id == u32(-1) || mId != id) + return nullptr; + + if (!allow_deleted && mProc && mProc->getState() == BaseProc::State::Delete) + return nullptr; + + return mProc; +} + +sead::CriticalSection* BaseProcLinkData::lockIfNeeded() { + if (BaseProcMgr::instance()->isHighPriorityThread()) + return nullptr; + + mCS.lock(); + return &mCS; +} + bool BaseProcLinkDataMgr::acquireLink(BaseProc* proc) { auto lock = sead::makeScopedLock(mCS); s32 index = mIndex; -- cgit v1.2.3