ksys/act: Implement act::acquireProc

This commit is contained in:
Léo Lam 2020-08-20 11:02:59 +02:00
parent 7e96f826c0
commit c9207a3cc3
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
5 changed files with 41 additions and 5 deletions

View File

@ -48,6 +48,7 @@ add_executable(uking
src/KingSystem/Terrain/teraSystem.h
src/KingSystem/Utils/Debug.h
src/KingSystem/Utils/StrTreeMap.h
src/KingSystem/Utils/Types.h
)

View File

@ -74114,7 +74114,7 @@
0x0000007100dca6d4,_ZN15ActorInstParams3BufaSERS0_,56,
0x0000007100dca70c,_ZN13ActorAccessorD2Ev,56,_ZN4ksys3act24ActorLinkConstDataAccessD1Ev
0x0000007100dca744,ActorAccessor::acquire,88,_ZN4ksys3act24ActorLinkConstDataAccess7acquireEPNS0_8BaseProcE
0x0000007100dca79c,act::acquireActorFromGameOrHavokThread,256,
0x0000007100dca79c,act::acquireActorFromGameOrHavokThread,256,_ZN4ksys3act11acquireProcEPNS0_24ActorLinkConstDataAccessEPNS0_8BaseProcERKN4sead14SafeStringBaseIcEE
0x0000007100dca89c,GameFramework::ctor,96,
0x0000007100dca8fc,GameFramework::dtor,64,
0x0000007100dca93c,GameFramework::dtorDelete,72,

Can't render this file because it is too large.

View File

@ -1,5 +1,7 @@
#include "KingSystem/ActorSystem/actActorLinkConstDataAccess.h"
#include "KingSystem/ActorSystem/actBaseProc.h"
#include "KingSystem/ActorSystem/actBaseProcMgr.h"
#include "KingSystem/Utils/Debug.h"
namespace ksys::act {
@ -20,9 +22,7 @@ bool ActorLinkConstDataAccess::acquire(BaseProc* proc) {
mProc = nullptr;
}
if (proc)
return proc->acquire(*this);
return false;
return proc && proc->acquire(*this);
}
bool ActorLinkConstDataAccess::hasProc(BaseProc* proc) const {
@ -33,4 +33,24 @@ void ActorLinkConstDataAccess::debugLog(s32, const sead::SafeString&) {
// Intentionally left empty.
}
bool acquireProc(ActorLinkConstDataAccess* accessor, BaseProc* proc, const sead::SafeString& from) {
bool acquired = false;
if (accessor) {
acquired = accessor->acquire(proc);
if (!acquired)
return false;
}
if (acquired || BaseProcMgr::instance()->isHighPriorityThread())
return true;
sead::FixedSafeString<256> message;
// (%s)Acquiring from a low priority thread. Please change via ActorLinkConstDataAccess
message.format("(%s)低スレッドからの取得です。ActorLinkConstDataAccess経由に変更お願いします",
from.cstr());
util::PrintDebug(message);
return false;
}
} // namespace ksys::act

View File

@ -21,16 +21,22 @@ public:
/// If an actor was already acquired, it is released.
bool acquire(BaseProc* proc);
void release() { acquire(nullptr); }
/// Checks whether the acquired BaseProc is `proc`.
bool hasProc(BaseProc* proc) const;
private:
void debugLog(s32, const sead::SafeString& method_name);
private:
bool mAcquired = false;
BaseProc* mProc = nullptr;
};
/// Acquire the specified BaseProc using `accessor`. Using ActorLinkConstDataAccess is mandatory
/// when acquiring from a low priority thread (see BaseProcMgr for a definition).
bool acquireProc(ActorLinkConstDataAccess* accessor, BaseProc* proc, const sead::SafeString& from);
} // namespace act
} // namespace ksys

View File

@ -0,0 +1,9 @@
#pragma once
#include <prim/seadSafeString.h>
namespace ksys::util {
inline void PrintDebug([[maybe_unused]] const sead::SafeString& message) {}
}