diff options
| author | Léo Lam <leo@leolam.fr> | 2020-08-27 23:57:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-27 23:57:44 +0200 |
| commit | c90e29946fba60199d6fc981a4ec0db3dcacc1f4 (patch) | |
| tree | b6e4f487fd2a3a9db64f01b26fdb78e15d5b85dc /src | |
| parent | 3e7d90f5bfbc54797e142332a21209c3e3956275 (diff) | |
| parent | 965d34c712d6372c5112e8d9943e48de622a9d5a (diff) | |
Merge pull request #3 from notyouraveragehooman/master
baseProcUnit setProc, actionSetisntEventFlag ctor dtor
Diffstat (limited to 'src')
| -rw-r--r-- | src/Game/Action/actionSetInstEventFlag.cpp | 11 | ||||
| -rw-r--r-- | src/Game/Action/actionSetInstEventFlag.h | 18 | ||||
| -rw-r--r-- | src/KingSystem/ActorSystem/actAiAction.h | 2 | ||||
| -rw-r--r-- | src/KingSystem/ActorSystem/actBaseProc.h | 14 | ||||
| -rw-r--r-- | src/KingSystem/ActorSystem/actBaseProcHandle.cpp | 29 | ||||
| -rw-r--r-- | src/KingSystem/ActorSystem/actBaseProcHandle.h | 30 | ||||
| -rw-r--r-- | src/KingSystem/ActorSystem/actBaseProcUnit.cpp | 58 | ||||
| -rw-r--r-- | src/KingSystem/ActorSystem/actBaseProcUnit.h | 9 |
8 files changed, 158 insertions, 13 deletions
diff --git a/src/Game/Action/actionSetInstEventFlag.cpp b/src/Game/Action/actionSetInstEventFlag.cpp new file mode 100644 index 00000000..bc179765 --- /dev/null +++ b/src/Game/Action/actionSetInstEventFlag.cpp @@ -0,0 +1,11 @@ +#include "Game/Action/actionSetInstEventFlag.h" +#include "KingSystem/ActorSystem/actActor.h" + +namespace uking::action { + +SetInstEventFlagAction::SetInstEventFlagAction(const ksys::act::ai::ClassArg& arg) + : ksys::act::ai::Action(arg) {} + +SetInstEventFlagAction::~SetInstEventFlagAction() = default; + +} // namespace uking::action
\ No newline at end of file diff --git a/src/Game/Action/actionSetInstEventFlag.h b/src/Game/Action/actionSetInstEventFlag.h new file mode 100644 index 00000000..7dac0a32 --- /dev/null +++ b/src/Game/Action/actionSetInstEventFlag.h @@ -0,0 +1,18 @@ +#pragma once + +#include "KingSystem/ActorSystem/actAiAction.h" +#include "KingSystem/ActorSystem/actAiParam.h" +#include "KingSystem/Utils/Types.h" + +namespace uking::action { + +class SetInstEventFlagAction : public ksys::act::ai::Action { +public: + SetInstEventFlagAction(const ksys::act::ai::ClassArg& arg); + ~SetInstEventFlagAction() override; + + void oneShot() override; +}; +KSYS_CHECK_SIZE_NX150(SetInstEventFlagAction, 0x20); + +} // namespace uking::action
\ No newline at end of file diff --git a/src/KingSystem/ActorSystem/actAiAction.h b/src/KingSystem/ActorSystem/actAiAction.h index be96de6d..ba0bf61d 100644 --- a/src/KingSystem/ActorSystem/actAiAction.h +++ b/src/KingSystem/ActorSystem/actAiAction.h @@ -11,6 +11,8 @@ public: virtual void enter() {} virtual void loadParams() {} + + virtual void oneShot() {} }; KSYS_CHECK_SIZE_NX150(Action, 0x20); diff --git a/src/KingSystem/ActorSystem/actBaseProc.h b/src/KingSystem/ActorSystem/actBaseProc.h index 1c9aa7cc..c7636998 100644 --- a/src/KingSystem/ActorSystem/actBaseProc.h +++ b/src/KingSystem/ActorSystem/actBaseProc.h @@ -9,6 +9,7 @@ #include <prim/seadSafeString.h> #include <prim/seadTypedBitFlag.h> #include <thread/seadAtomic.h> +#include "KingSystem/ActorSystem/actBaseProcHandle.h" #include "KingSystem/ActorSystem/actBaseProcJob.h" #include "KingSystem/ActorSystem/actBaseProcMap.h" #include "KingSystem/Utils/StrTreeMap.h" @@ -23,17 +24,7 @@ class BaseProc; class BaseProcLinkData; class BaseProcJobHandler; class BaseProcUnit; - -class BaseProcHandle { -public: - BaseProcHandle(); - ~BaseProcHandle(); - -private: - BaseProcUnit* mUnit; - u8 mFlag; -}; -KSYS_CHECK_SIZE_NX150(BaseProcHandle, 0x10); +class BaseProcHandle; /// Actor base class that encapsulates all the low-level actor lifetime logic. class BaseProc { @@ -100,6 +91,7 @@ public: return mState == State::Delete || mStateFlags.isOn(StateFlags::RequestDelete); } + bool isInitialized() const { return mFlags.isOn(Flags::Initialized); } /// For BaseProcLink or ActorLinkConstDataAccess. bool acquire(ActorLinkConstDataAccess& accessor); BaseProcLinkData* getBaseProcLinkData() const { return mBaseProcLinkData; } diff --git a/src/KingSystem/ActorSystem/actBaseProcHandle.cpp b/src/KingSystem/ActorSystem/actBaseProcHandle.cpp new file mode 100644 index 00000000..5603b5be --- /dev/null +++ b/src/KingSystem/ActorSystem/actBaseProcHandle.cpp @@ -0,0 +1,29 @@ +#include "KingSystem/ActorSystem/actBaseProcHandle.h" + +namespace ksys::act { + +BaseProcHandle::BaseProcHandle() { + mUnit = nullptr; + mFlag = 0; +} + +BaseProcHandle::~BaseProcHandle() { + if (mUnit) { + mUnit->deleteProc(0, this); + mUnit = nullptr; + } + mFlag = 0; +} + +bool BaseProcHandle::procReady() { + return mUnit && mUnit->isReady(); +} + +BaseProc* BaseProcHandle::getProc() { + if (mUnit) + return mUnit->getProc(); + + return nullptr; +} + +} // namespace ksys::act
\ No newline at end of file diff --git a/src/KingSystem/ActorSystem/actBaseProcHandle.h b/src/KingSystem/ActorSystem/actBaseProcHandle.h new file mode 100644 index 00000000..c0a74ee0 --- /dev/null +++ b/src/KingSystem/ActorSystem/actBaseProcHandle.h @@ -0,0 +1,30 @@ +#pragma once + +#include <basis/seadTypes.h> +#include "KingSystem/ActorSystem/actBaseProc.h" +#include "KingSystem/ActorSystem/actBaseProcUnit.h" +#include "KingSystem/Utils/Types.h" + +namespace ksys::act { + +class BaseProcUnit; +class BaseProc; + +class BaseProcHandle { +public: + BaseProcHandle(); + ~BaseProcHandle(); + + bool procReady(); + + BaseProc* getProc(); + + static BaseProcHandle sDummyHandle; + +private: + BaseProcUnit* mUnit; + u8 mFlag; +}; +KSYS_CHECK_SIZE_NX150(BaseProcHandle, 0x10); + +} // namespace ksys::act
\ No newline at end of file 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 diff --git a/src/KingSystem/ActorSystem/actBaseProcUnit.h b/src/KingSystem/ActorSystem/actBaseProcUnit.h index 7bfe7e28..f3ef3f34 100644 --- a/src/KingSystem/ActorSystem/actBaseProcUnit.h +++ b/src/KingSystem/ActorSystem/actBaseProcUnit.h @@ -1,7 +1,9 @@ #pragma once #include <basis/seadTypes.h> +#include <thread/seadAtomic.h> #include <thread/seadCriticalSection.h> +#include "KingSystem/ActorSystem/actBaseProcHandle.h" namespace ksys::act { @@ -10,15 +12,18 @@ class BaseProcHandle; class BaseProcUnit { public: - bool deleteProc(void*, BaseProcHandle* handle); + bool deleteProc(u32, BaseProcHandle* handle); bool setProc(BaseProc* proc); void unlinkProc(BaseProc* proc); void cleanUp(BaseProc* proc, bool set_flag_5); bool isParentHandleDefault() const; + BaseProc* getProc() const { return mProc; } + bool isReady() const { return mFlags == 2; } + private: u32 mFlags; - BaseProcHandle* mHandle; + sead::Atomic<BaseProcHandle*> mHandle; BaseProc* mProc; // FIXME: // BaseProcRequest mRequest; |
