diff options
| author | Léo Lam <leo@leolam.fr> | 2020-08-20 12:19:00 +0200 |
|---|---|---|
| committer | Léo Lam <leo@leolam.fr> | 2020-08-20 12:19:13 +0200 |
| commit | f92ab2f5598789d9531bfe93e9abcc3dc4cc938d (patch) | |
| tree | fe9041301ac4887a05d151ec325308531d553e49 /src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp | |
| parent | c9207a3cc3e18c6746998d5d99f6ed5f38a83c86 (diff) | |
ksys/act: Finish BaseProcLinkData
Diffstat (limited to 'src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp')
| -rw-r--r-- | src/KingSystem/ActorSystem/actBaseProcLinkDataMgr.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
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 <prim/seadScopedLock.h> #include <thread/seadThread.h> #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; |
