mirror of https://github.com/zeldaret/botw.git
ksys/act: Finish BaseProcLinkData
This commit is contained in:
parent
c9207a3cc3
commit
f92ab2f559
|
@ -89524,8 +89524,8 @@
|
|||
0x00000071011bc464,sinitBaseProcHandle,172,
|
||||
0x00000071011bc510,_ZN12BaseProcLinkC2Ev,20,_ZN4ksys3act12BaseProcLinkC1Ev
|
||||
0x00000071011bc524,_ZN12BaseProcLink12acquireActorER13ActorAccessorP9ActorBase,308,
|
||||
0x00000071011bc658,BaseProcLinkData::lockCritSectionOnGameThreadOrHavokThread,68,
|
||||
0x00000071011bc69c,BaseProcLinkData::checkIdAndEngaged,52,
|
||||
0x00000071011bc658,BaseProcLinkData::lockCritSectionOnGameThreadOrHavokThread,68,_ZN4ksys3act16BaseProcLinkData12lockIfNeededEv
|
||||
0x00000071011bc69c,BaseProcLinkData::checkIdAndEngaged,52,_ZNK4ksys3act16BaseProcLinkData7getProcEjb
|
||||
0x00000071011bc6d0,_ZN12BaseProcLink12fromAccessorER13ActorAccessor,276,
|
||||
0x00000071011bc7e4,BaseProcLink::checkHasActorById,40,
|
||||
0x00000071011bc80c,_ZN12BaseProcLinkeqERS_,152,
|
||||
|
|
Can't render this file because it is too large.
|
|
@ -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;
|
||||
|
|
|
@ -13,9 +13,20 @@ class BaseProc;
|
|||
class BaseProcLinkData {
|
||||
public:
|
||||
u32 id() const { return mId; }
|
||||
BaseProc* proc() const { return mProc; }
|
||||
s32 refCount() const { return mRefCount; }
|
||||
|
||||
/// Get the stored BaseProc.
|
||||
BaseProc* getProc() const { return mProc; }
|
||||
/// Get the stored BaseProc or nullptr if its ID or state are unexpected.
|
||||
/// @param id The expected ID.
|
||||
/// @param allow_deleted Whether to allow the BaseProc to be in the Delete state.
|
||||
BaseProc* getProc(u32 id, bool allow_deleted) const;
|
||||
|
||||
/// Locks the critical section if on a low priority thread and returns it;
|
||||
/// unlocking it is the responsibility of the caller.
|
||||
/// Returns nullptr if on a high priority thread. In that case, nothing needs to be done.
|
||||
sead::CriticalSection* lockIfNeeded();
|
||||
|
||||
private:
|
||||
friend class BaseProcLinkDataMgr;
|
||||
|
||||
|
|
Loading…
Reference in New Issue