summaryrefslogtreecommitdiff
path: root/src/KingSystem/ActorSystem/actBaseProcUnit.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2020-08-27 23:57:44 +0200
committerGitHub <noreply@github.com>2020-08-27 23:57:44 +0200
commitc90e29946fba60199d6fc981a4ec0db3dcacc1f4 (patch)
treeb6e4f487fd2a3a9db64f01b26fdb78e15d5b85dc /src/KingSystem/ActorSystem/actBaseProcUnit.cpp
parent3e7d90f5bfbc54797e142332a21209c3e3956275 (diff)
parent965d34c712d6372c5112e8d9943e48de622a9d5a (diff)
Merge pull request #3 from notyouraveragehooman/master
baseProcUnit setProc, actionSetisntEventFlag ctor dtor
Diffstat (limited to 'src/KingSystem/ActorSystem/actBaseProcUnit.cpp')
-rw-r--r--src/KingSystem/ActorSystem/actBaseProcUnit.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/KingSystem/ActorSystem/actBaseProcUnit.cpp b/src/KingSystem/ActorSystem/actBaseProcUnit.cpp
index e69de29b..09bd6c81 100644
--- a/src/KingSystem/ActorSystem/actBaseProcUnit.cpp
+++ b/src/KingSystem/ActorSystem/actBaseProcUnit.cpp
@@ -0,0 +1,58 @@
+#include "KingSystem/ActorSystem/actBaseProcUnit.h"
+#include <prim/seadSafeString.h>
+#include <prim/seadScopedLock.h>
+#include "KingSystem/ActorSystem/actActorLinkConstDataAccess.h"
+#include "KingSystem/ActorSystem/actBaseProc.h"
+#include "KingSystem/Utils/Debug.h"
+
+namespace ksys::act {
+
+// NON_MATCHING: Equivalent but branches are off.
+bool BaseProcUnit::setProc(BaseProc* proc) {
+ bool ret;
+ static constexpr const char* sStateNames[] = {"Init", "Calc", "Sleep", "Delete"};
+
+ auto lock = sead::makeScopedLock(mCS);
+ if (mProc)
+ mProc = nullptr;
+
+ if (mHandle == &BaseProcHandle::sDummyHandle)
+ return false;
+
+ if (mHandle) {
+ if (mFlags != 1) {
+ sead::FixedSafeString<64> message;
+
+ if (proc)
+ message.format("%s, %d, %d, %s, ( %p:%p )", proc->getName().cstr(), mFlags,
+ proc->isInitialized(), sStateNames[u8(proc->getState())], this,
+ mHandle.load());
+ else
+ message.format("なし, %d, ?, ?, ( %p:%p )", mFlags, this, mHandle.load());
+
+ util::PrintDebug(message);
+ }
+ mProc = proc;
+ mFlags = 2;
+ ret = true;
+ } else {
+ sead::FixedSafeString<64> message;
+
+ if (proc)
+ message.format("%s, %d, %d, %s, ( %p:%p )", proc->getName().cstr(), mFlags,
+ proc->isInitialized(), sStateNames[u8(proc->getState())], this,
+ mHandle.load());
+ else
+ message.format("なし, %d, ?, ?, ( %p:%p )", mFlags, this, mHandle.load());
+
+ util::PrintDebug(message);
+ ret = false;
+ }
+ return ret;
+}
+
+bool BaseProcUnit::isParentHandleDefault() const {
+ return mHandle == &BaseProcHandle::sDummyHandle;
+}
+
+} // namespace ksys::act \ No newline at end of file