From 89939a23004d79e607ee2878a092abb36827309e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sat, 16 Oct 2021 14:51:18 +0200 Subject: [PATCH] ksys: Start adding PhysicsUserTag --- data/uking_functions.csv | 32 ++++++++--------- src/KingSystem/ActorSystem/CMakeLists.txt | 2 ++ .../ActorSystem/actPhysicsUserTag.cpp | 34 ++++++++++++++++++ .../ActorSystem/actPhysicsUserTag.h | 36 +++++++++++++++++++ src/KingSystem/Physics/CMakeLists.txt | 2 ++ src/KingSystem/Physics/System/physUserTag.cpp | 19 ++++++++++ src/KingSystem/Physics/System/physUserTag.h | 27 ++++++++++++++ 7 files changed, 136 insertions(+), 16 deletions(-) create mode 100644 src/KingSystem/ActorSystem/actPhysicsUserTag.cpp create mode 100644 src/KingSystem/ActorSystem/actPhysicsUserTag.h create mode 100644 src/KingSystem/Physics/System/physUserTag.cpp create mode 100644 src/KingSystem/Physics/System/physUserTag.h diff --git a/data/uking_functions.csv b/data/uking_functions.csv index f3b3e6d9..f34cbcdd 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -381,7 +381,7 @@ Address,Quality,Size,Name 0x0000007100009d70,U,000372,PlayerOrEnemy::rtti1impl 0x0000007100009ee4,U,000140, 0x0000007100009f70,U,000140, -0x0000007100009ffc,U,000140, +0x0000007100009ffc,O,000140,_ZNK4sead15RuntimeTypeInfo6DeriveIN4ksys4phys7UserTagEE9isDerivedEPKNS0_9InterfaceE 0x000000710000a088,U,000140, 0x000000710000a114,U,000316,CookResult::construct 0x000000710000a250,O,000384,_ZN4ksys8CookItemC1Ev @@ -1895,8 +1895,8 @@ Address,Quality,Size,Name 0x0000007100062008,U,000076, 0x0000007100062054,U,000204, 0x0000007100062120,U,000092, -0x000000710006217c,U,000012, -0x0000007100062188,U,000012, +0x000000710006217c,O,000012,_ZNK4ksys4phys7UserTag7getNameEv +0x0000007100062188,O,000012,_ZNK4ksys4phys7UserTag8getName2Ev 0x0000007100062194,U,000020, 0x00000071000621a8,U,000052, 0x00000071000621dc,O,000048,_ZN5uking6action14MotorcycleWaitC1ERKN4ksys3act2ai10ActionBase7InitArgE @@ -73725,20 +73725,20 @@ Address,Quality,Size,Name 0x0000007100d40250,U,000232,ActorConstraints::calc 0x0000007100d40338,U,000112, 0x0000007100d403a8,U,000060, -0x0000007100d403e4,U,000036, -0x0000007100d40408,U,000004,nullsub_3770 -0x0000007100d4040c,U,000004,j__ZdlPv_845 -0x0000007100d40410,U,000144,act::PhysicsUserTagStuff -0x0000007100d404a0,U,000016,getCollidedActorMaybeImpl +0x0000007100d403e4,O,000036,_ZN4ksys3act14PhysicsUserTagC1EPNS0_5ActorE +0x0000007100d40408,O,000004,_ZN4ksys3act14PhysicsUserTagD1Ev +0x0000007100d4040c,O,000004,_ZN4ksys3act14PhysicsUserTagD0Ev +0x0000007100d40410,O,000144,_ZNK4ksys3act14PhysicsUserTag8getActorEPNS0_24ActorLinkConstDataAccessEPNS0_5ActorE +0x0000007100d404a0,O,000016,_ZNK4ksys3act14PhysicsUserTag12acquireActorEPNS0_24ActorLinkConstDataAccessE 0x0000007100d404b0,U,000016, 0x0000007100d404c0,U,000352,stopTimerNoDisplayStuff 0x0000007100d40620,U,000112, -0x0000007100d40690,U,000012, +0x0000007100d40690,O,000012,_ZNK4ksys3act14PhysicsUserTag7getNameEv 0x0000007100d4069c,U,000064, 0x0000007100d406dc,U,000008, -0x0000007100d406e4,U,000028, -0x0000007100d40700,U,000204, -0x0000007100d407cc,U,000092, +0x0000007100d406e4,O,000028,_ZNK4ksys3act14PhysicsUserTag8getName2Ev +0x0000007100d40700,O,000204,_ZNK4ksys3act14PhysicsUserTag27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE +0x0000007100d407cc,O,000092,_ZNK4ksys3act14PhysicsUserTag18getRuntimeTypeInfoEv 0x0000007100d40828,U,000360,PlacementMap::ctor 0x0000007100d40990,U,000644,PlacementMap::dtor 0x0000007100d40c14,U,000072,PlacementMap::loadStaticMap_ @@ -79241,11 +79241,11 @@ Address,Quality,Size,Name 0x0000007100e8ed1c,U,001188, 0x0000007100e8f1c0,U,000744, 0x0000007100e8f4a8,U,000216, -0x0000007100e8f580,U,000004,nullsub_4006 +0x0000007100e8f580,O,000004,_ZN4ksys4phys7UserTagD2Ev 0x0000007100e8f584,U,000012, -0x0000007100e8f590,U,000112, -0x0000007100e8f600,U,000092, -0x0000007100e8f65c,U,000004,j__ZdlPv_932 +0x0000007100e8f590,O,000112,_ZNK4ksys4phys7UserTag27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE +0x0000007100e8f600,O,000092,_ZNK4ksys4phys7UserTag18getRuntimeTypeInfoEv +0x0000007100e8f65c,O,000004,_ZN4ksys4phys7UserTagD0Ev 0x0000007100e8f660,U,000104,UserEdgeActor::construct 0x0000007100e8f6c8,U,000004,j_Actor::m0_2 0x0000007100e8f6cc,U,000008, diff --git a/src/KingSystem/ActorSystem/CMakeLists.txt b/src/KingSystem/ActorSystem/CMakeLists.txt index c071fdf2..5c6a1b47 100644 --- a/src/KingSystem/ActorSystem/CMakeLists.txt +++ b/src/KingSystem/ActorSystem/CMakeLists.txt @@ -107,6 +107,8 @@ target_sources(uking PRIVATE actInstParamPack.cpp actInstParamPack.h actLifeRecoveryInfo.h + actPhysicsUserTag.cpp + actPhysicsUserTag.h actPlayerInfo.cpp actPlayerInfo.h actTag.h diff --git a/src/KingSystem/ActorSystem/actPhysicsUserTag.cpp b/src/KingSystem/ActorSystem/actPhysicsUserTag.cpp new file mode 100644 index 00000000..12f2f879 --- /dev/null +++ b/src/KingSystem/ActorSystem/actPhysicsUserTag.cpp @@ -0,0 +1,34 @@ +#include "KingSystem/ActorSystem/actPhysicsUserTag.h" +#include "KingSystem/ActorSystem/actActor.h" +#include "KingSystem/ActorSystem/actActorLinkConstDataAccess.h" +#include "KingSystem/ActorSystem/actBaseProcMgr.h" + +namespace ksys::act { + +PhysicsUserTag::PhysicsUserTag(Actor* actor) : mActor(actor) {} + +PhysicsUserTag::~PhysicsUserTag() = default; + +Actor* PhysicsUserTag::getActor(ActorLinkConstDataAccess* accessor, Actor* other_actor) const { + if (mActor != nullptr) { + if (mActor != other_actor && !BaseProcMgr::instance()->isAccessingProcSafe(mActor, nullptr)) + return mActor; + if (!acquireProc(accessor, mActor, "act::PhysicsUserTag")) + return nullptr; + } + return mActor; +} + +bool PhysicsUserTag::acquireActor(ActorLinkConstDataAccess* accessor) const { + return accessor->acquire(mActor); +} + +const sead::SafeString& PhysicsUserTag::getName() const { + return mActor->getName(); +} + +const sead::SafeString& PhysicsUserTag::getName2() const { + return getName(); +} + +} // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actPhysicsUserTag.h b/src/KingSystem/ActorSystem/actPhysicsUserTag.h new file mode 100644 index 00000000..0c47e866 --- /dev/null +++ b/src/KingSystem/ActorSystem/actPhysicsUserTag.h @@ -0,0 +1,36 @@ +#pragma once + +#include "KingSystem/Physics/System/physUserTag.h" +#include "KingSystem/Utils/Types.h" + +namespace ksys::act { + +class Actor; +class ActorLinkConstDataAccess; + +class PhysicsUserTag : public phys::UserTag { + SEAD_RTTI_OVERRIDE(PhysicsUserTag, phys::UserTag) + +public: + explicit PhysicsUserTag(Actor* actor); + ~PhysicsUserTag() override; + + Actor* getActor(ActorLinkConstDataAccess* accessor, Actor* other_actor) const; + bool acquireActor(ActorLinkConstDataAccess* accessor) const; + + void m2(void* a) override; + void m3(void* a, void* b, float c) override; + void m4() override; + void m5() override; + const sead::SafeString& getName() const override; + void m7() override; + const sead::SafeString& getName2() const override; + +private: + Actor* mActor = nullptr; + int _10 = -1; + u16 _14 = 0; +}; +KSYS_CHECK_SIZE_NX150(PhysicsUserTag, 0x18); + +} // namespace ksys::act diff --git a/src/KingSystem/Physics/CMakeLists.txt b/src/KingSystem/Physics/CMakeLists.txt index 738ff5d9..48a5745b 100644 --- a/src/KingSystem/Physics/CMakeLists.txt +++ b/src/KingSystem/Physics/CMakeLists.txt @@ -28,4 +28,6 @@ target_sources(uking PRIVATE System/physRagdollControllerKeyList.cpp System/physShapeParam.cpp System/physShapeParam.h + System/physUserTag.cpp + System/physUserTag.h ) diff --git a/src/KingSystem/Physics/System/physUserTag.cpp b/src/KingSystem/Physics/System/physUserTag.cpp new file mode 100644 index 00000000..165f8493 --- /dev/null +++ b/src/KingSystem/Physics/System/physUserTag.cpp @@ -0,0 +1,19 @@ +#include "KingSystem/Physics/System/physUserTag.h" + +namespace ksys::phys { + +void UserTag::m2(void* a) { + // FIXME +} + +void UserTag::m3(void* a, void* b, float c) { + // FIXME +} + +void UserTag::m4() {} + +void UserTag::m5() {} + +void UserTag::m7() {} + +} // namespace ksys::phys diff --git a/src/KingSystem/Physics/System/physUserTag.h b/src/KingSystem/Physics/System/physUserTag.h new file mode 100644 index 00000000..e4fb471f --- /dev/null +++ b/src/KingSystem/Physics/System/physUserTag.h @@ -0,0 +1,27 @@ +#pragma once + +#include +#include +#include "KingSystem/Utils/Types.h" + +namespace ksys::phys { + +class UserTag { + SEAD_RTTI_BASE(UserTag) +public: + UserTag() = default; + + // FIXME: names and types + virtual void m2(void* a); + // a and b are probably physics bodies? + virtual void m3(void* a, void* b, float c); + virtual void m4(); + virtual void m5(); + virtual const sead::SafeString& getName() const { return sead::SafeString::cEmptyString; } + virtual void m7(); + virtual const sead::SafeString& getName2() const { return sead::SafeString::cEmptyString; } + virtual ~UserTag() = default; +}; +KSYS_CHECK_SIZE_NX150(UserTag, 0x8); + +} // namespace ksys::phys