From d11d8f4cd81681f133f5dee3a54e8e3c844ce8f6 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 27 Oct 2024 21:17:36 -0700 Subject: [PATCH] Start CModelData, cleanup CFactoryFnReturn usage --- config/GM8E01_00/symbols.txt | 2 +- config/GM8E01_01/symbols.txt | 2 +- include/Kyoto/Audio/CSfxManager.hpp | 5 ++++- include/Kyoto/CFactoryFnReturn.hpp | 16 ++++++++++++++ include/Kyoto/CFactoryMgr.hpp | 15 ------------- include/Kyoto/CResFactory.hpp | 12 +---------- include/Kyoto/IFactory.hpp | 21 +++++++++++++++++++ include/Kyoto/IObjFactory.hpp | 8 +++++++ include/Kyoto/Text/CStringTable.hpp | 8 +++++-- include/MetroidPrime/CMapArea.hpp | 3 ++- include/MetroidPrime/CModelData.hpp | 10 ++++++--- .../Factories/CCharacterFactory.hpp | 11 ++++++++++ .../Factories/CCharacterFactoryBuilder.hpp | 5 ++++- .../Factories/CScannableObjectInfo.hpp | 5 +++++ .../Factories/CStateMachineFactory.hpp | 2 +- include/MetroidPrime/Weapons/WeaponTypes.hpp | 9 ++++---- .../WorldFormat/CCollidableOBBTreeGroup.hpp | 5 +++++ src/Kyoto/Audio/CMidiManager.cpp | 2 +- src/Kyoto/Text/CStringTable.cpp | 6 +++--- .../Factories/CScannableObjectInfo.cpp | 1 - src/WorldFormat/CCollidableOBBTreeGroup.cpp | 1 - 21 files changed, 101 insertions(+), 48 deletions(-) create mode 100644 include/Kyoto/CFactoryFnReturn.hpp create mode 100644 include/Kyoto/IFactory.hpp create mode 100644 include/Kyoto/IObjFactory.hpp create mode 100644 include/MetroidPrime/Factories/CCharacterFactory.hpp diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index 15c07109..ceb02e76 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -19168,7 +19168,7 @@ skDoorVerts__15CMappableObject = .bss:0x8046C498; // type:object size:0x60 scope lbl_8046C4F8 = .bss:0x8046C4F8; // type:object size:0xC lbl_8046C504 = .bss:0x8046C504; // type:object size:0x1C data:4byte lbl_8046C520 = .bss:0x8046C520; // type:object size:0x18 data:4byte -lbl_8046C538 = .bss:0x8046C538; // type:object size:0x20 data:float +skNullAdvance = .bss:0x8046C538; // type:object size:0x20 scope:local data:float lbl_8046C558 = .bss:0x8046C558; // type:object size:0xC lbl_8046C564 = .bss:0x8046C564; // type:object size:0xC lbl_8046C570 = .bss:0x8046C570; // type:object size:0xA8 diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index 396bbc03..66a50856 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -19193,7 +19193,7 @@ skDoorVerts__15CMappableObject = .bss:0x8046C678; // type:object size:0x60 scope lbl_8046C4F8 = .bss:0x8046C6D8; // type:object size:0xC scope:local lbl_8046C504 = .bss:0x8046C6E4; // type:object size:0x1C scope:local data:4byte lbl_8046C520 = .bss:0x8046C700; // type:object size:0x18 scope:local data:4byte -lbl_8046C538 = .bss:0x8046C718; // type:object size:0x20 scope:local data:float +skNullAdvance = .bss:0x8046C718; // type:object size:0x20 data:float scope:local lbl_8046C558 = .bss:0x8046C738; // type:object size:0xC scope:local lbl_8046C564 = .bss:0x8046C744; // type:object size:0xC scope:local lbl_8046C570 = .bss:0x8046C750; // type:object size:0xA8 scope:local diff --git a/include/Kyoto/Audio/CSfxManager.hpp b/include/Kyoto/Audio/CSfxManager.hpp index a5eaac60..1f43a047 100644 --- a/include/Kyoto/Audio/CSfxManager.hpp +++ b/include/Kyoto/Audio/CSfxManager.hpp @@ -13,7 +13,7 @@ #include -#include +#include class CVector3f; class CSfxManager { @@ -243,4 +243,7 @@ public: static bool IsValidHandle(CSfxHandle handle); }; +CFactoryFnReturn FAudioTranslationTableFactory(const SObjectTag& obj, CInputStream& in, + const CVParamTransfer& xfer); + #endif // _CSFXMANAGER diff --git a/include/Kyoto/CFactoryFnReturn.hpp b/include/Kyoto/CFactoryFnReturn.hpp new file mode 100644 index 00000000..5d92cd62 --- /dev/null +++ b/include/Kyoto/CFactoryFnReturn.hpp @@ -0,0 +1,16 @@ +#ifndef _CFACTORYFNRETURN +#define _CFACTORYFNRETURN +#include + +class CFactoryFnReturn { +public: + template < typename T > + CFactoryFnReturn(T* ptr) : obj(TToken< T >::GetIObjObjectFor(ptr).release()) {} + + const rstl::auto_ptr< CObjOwnerDerivedFromIObjUntyped >& GetObjForTransfer() const { return obj; } + +private: + rstl::auto_ptr< CObjOwnerDerivedFromIObjUntyped > obj; +}; + +#endif // _CFACTORYFNRETURN diff --git a/include/Kyoto/CFactoryMgr.hpp b/include/Kyoto/CFactoryMgr.hpp index 6d9c46f2..923b184c 100644 --- a/include/Kyoto/CFactoryMgr.hpp +++ b/include/Kyoto/CFactoryMgr.hpp @@ -3,27 +3,12 @@ #include "types.h" -#include "Kyoto/IObjectStore.hpp" -#include "Kyoto/Streams/CInputStream.hpp" -#include "Kyoto/TToken.hpp" - class CFactoryMgr { public: private: uchar pad[0x38]; }; -class CFactoryFnReturn { -public: - template < typename T > - CFactoryFnReturn(T* ptr) : obj(TToken< T >::GetIObjObjectFor(ptr).release()) {} - const rstl::auto_ptr& GetObjForTransfer() const { return obj; } -private: - rstl::auto_ptr< CObjOwnerDerivedFromIObjUntyped > obj; -}; - -CFactoryFnReturn FStringTableFactory(const SObjectTag& tag, CInputStream& in, - const CVParamTransfer& xfer); #endif // _CFACTORYMGR diff --git a/include/Kyoto/CResFactory.hpp b/include/Kyoto/CResFactory.hpp index 8fcef8c8..a4360efe 100644 --- a/include/Kyoto/CResFactory.hpp +++ b/include/Kyoto/CResFactory.hpp @@ -6,20 +6,10 @@ #include "rstl/list.hpp" +#include #include "Kyoto/CFactoryMgr.hpp" #include "Kyoto/CResLoader.hpp" -class IFactory { -public: - virtual ~IFactory() {} - virtual CFactoryFnReturn Build(const SObjectTag&, const CVParamTransfer&) = 0; - virtual void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**) = 0; - virtual void CancelBuild(const SObjectTag&) = 0; - virtual bool CanBuild(const SObjectTag&) = 0; - virtual const SObjectTag* GetResourceIdByName(const char* name) const = 0; - // TODO -}; - class CResFactory : public IFactory { public: CResFactory(); diff --git a/include/Kyoto/IFactory.hpp b/include/Kyoto/IFactory.hpp new file mode 100644 index 00000000..84b3e337 --- /dev/null +++ b/include/Kyoto/IFactory.hpp @@ -0,0 +1,21 @@ +#ifndef _IFACTORY +#define _IFACTORY + +#include + +class SObjectTag; +class CVParamTransfer; +class IObj; + +class IFactory { +public: + virtual ~IFactory() {} + virtual CFactoryFnReturn Build(const SObjectTag&, const CVParamTransfer&) = 0; + virtual void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**) = 0; + virtual void CancelBuild(const SObjectTag&) = 0; + virtual bool CanBuild(const SObjectTag&) = 0; + virtual const SObjectTag* GetResourceIdByName(const char* name) const = 0; + // TODO +}; + +#endif // _IFACTORY diff --git a/include/Kyoto/IObjFactory.hpp b/include/Kyoto/IObjFactory.hpp new file mode 100644 index 00000000..e389f03d --- /dev/null +++ b/include/Kyoto/IObjFactory.hpp @@ -0,0 +1,8 @@ +#ifndef _CIOBJFACTORY +#define _CIOBJFACTORY + +class IObjFactory { + virtual ~IObjFactory() {}; +}; + +#endif // _CIOBJFACTORY diff --git a/include/Kyoto/Text/CStringTable.hpp b/include/Kyoto/Text/CStringTable.hpp index deeead15..44553923 100644 --- a/include/Kyoto/Text/CStringTable.hpp +++ b/include/Kyoto/Text/CStringTable.hpp @@ -3,10 +3,11 @@ #include "types.h" -#include "rstl/single_ptr.hpp" +#include -#include "Kyoto/Streams/CInputStream.hpp" +#include +class CInputStream; class CStringTable { int x0_stringCount; rstl::single_ptr< uchar > x4_data; @@ -19,4 +20,7 @@ public: extern CStringTable* gpStringTable; +CFactoryFnReturn FStringTableFactory(const SObjectTag& tag, CInputStream& in, + const CVParamTransfer& xfer); + #endif // _CSTRINGTABLE diff --git a/include/MetroidPrime/CMapArea.hpp b/include/MetroidPrime/CMapArea.hpp index 12dc1ea6..0a7ae73f 100644 --- a/include/MetroidPrime/CMapArea.hpp +++ b/include/MetroidPrime/CMapArea.hpp @@ -3,7 +3,7 @@ #include "MetroidPrime/CMappableObject.hpp" -#include "Kyoto/CFactoryMgr.hpp" +#include "Kyoto/CFactoryFnReturn.hpp" #include "Kyoto/Graphics/CColor.hpp" #include "Kyoto/Math/CAABox.hpp" #include "Kyoto/Math/CVector3f.hpp" @@ -11,6 +11,7 @@ #include "rstl/single_ptr.hpp" #include "rstl/vector.hpp" + class IWorld; class CWorld; diff --git a/include/MetroidPrime/CModelData.hpp b/include/MetroidPrime/CModelData.hpp index 4b564567..be2bb7cc 100644 --- a/include/MetroidPrime/CModelData.hpp +++ b/include/MetroidPrime/CModelData.hpp @@ -44,11 +44,15 @@ private: CHECK_SIZEOF(CAdvancementDeltas, 0x1c) class CStaticRes { - CAssetId x0_cmdlId; - CVector3f x4_scale; - public: CStaticRes(CAssetId id, const CVector3f& scale) : x0_cmdlId(id), x4_scale(scale) {} + + const CAssetId GetId() const { return x0_cmdlId; } + const CVector3f GetScale() const { return x4_scale; } + +private: + CAssetId x0_cmdlId; + CVector3f x4_scale; }; class CModelData { diff --git a/include/MetroidPrime/Factories/CCharacterFactory.hpp b/include/MetroidPrime/Factories/CCharacterFactory.hpp new file mode 100644 index 00000000..7c46301b --- /dev/null +++ b/include/MetroidPrime/Factories/CCharacterFactory.hpp @@ -0,0 +1,11 @@ +#ifndef _CCHARACTERFACTORY +#define _CCHARACTERFACTORY +#include +#include + + +class CCharacterFactory : IObjFactory { + +}; + +#endif // _CCHARACTERFACTORY diff --git a/include/MetroidPrime/Factories/CCharacterFactoryBuilder.hpp b/include/MetroidPrime/Factories/CCharacterFactoryBuilder.hpp index 4a4c5a65..d12148af 100644 --- a/include/MetroidPrime/Factories/CCharacterFactoryBuilder.hpp +++ b/include/MetroidPrime/Factories/CCharacterFactoryBuilder.hpp @@ -2,12 +2,15 @@ #define _CCHARACTERFACTORYBUILDER #include "types.h" +#include +class CAnimRes; +class CCharacterFactory; class CCharacterFactoryBuilder { public: CCharacterFactoryBuilder(); ~CCharacterFactoryBuilder(); - + TToken GetFactory(const CAnimRes& res); private: uchar pad[0x24]; }; diff --git a/include/MetroidPrime/Factories/CScannableObjectInfo.hpp b/include/MetroidPrime/Factories/CScannableObjectInfo.hpp index f360b8ed..d78ba547 100644 --- a/include/MetroidPrime/Factories/CScannableObjectInfo.hpp +++ b/include/MetroidPrime/Factories/CScannableObjectInfo.hpp @@ -9,6 +9,8 @@ #include "rstl/reserved_vector.hpp" #include "rstl/string.hpp" +#include + class CInputStream; class CScannableObjectInfo { public: @@ -35,4 +37,7 @@ private: rstl::reserved_vector< SBucket, 4 > x14_buckets; }; +CFactoryFnReturn FScannableObjectInfoFactory(const SObjectTag& tag, CInputStream& in, + const CVParamTransfer& xfer); + #endif // _CSCANNABLEOBJECTINFO diff --git a/include/MetroidPrime/Factories/CStateMachineFactory.hpp b/include/MetroidPrime/Factories/CStateMachineFactory.hpp index 46ca0821..9646ba22 100644 --- a/include/MetroidPrime/Factories/CStateMachineFactory.hpp +++ b/include/MetroidPrime/Factories/CStateMachineFactory.hpp @@ -1,7 +1,7 @@ #ifndef _CSTATEMACHINEFACTORY #define _CSTATEMACHINEFACTORY -#include +#include CFactoryFnReturn FAiFiniteStateMachineFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& xfer); diff --git a/include/MetroidPrime/Weapons/WeaponTypes.hpp b/include/MetroidPrime/Weapons/WeaponTypes.hpp index fcb2371d..5ec0bccb 100644 --- a/include/MetroidPrime/Weapons/WeaponTypes.hpp +++ b/include/MetroidPrime/Weapons/WeaponTypes.hpp @@ -28,15 +28,14 @@ class CWeaponMode { bool x4_26_instantKill : 1; public: - CWeaponMode(EWeaponType type = kWT_None, bool charged = false, bool comboed = false, - bool instaKill = false) + explicit CWeaponMode(EWeaponType type = kWT_None, const bool charged = false, + const bool comboed = false, const bool instaKill = false) : x0_weaponType(type) , x4_24_charged(charged) , x4_25_comboed(comboed) , x4_26_instantKill(instaKill) {} - - CWeaponMode(int type, int flags) - : x0_weaponType(EWeaponType(type)) {} + + CWeaponMode(int type, int flags) : x0_weaponType(EWeaponType(type)) {} EWeaponType GetType() const { return x0_weaponType; } diff --git a/include/WorldFormat/CCollidableOBBTreeGroup.hpp b/include/WorldFormat/CCollidableOBBTreeGroup.hpp index 9897a26f..eae7f5ac 100644 --- a/include/WorldFormat/CCollidableOBBTreeGroup.hpp +++ b/include/WorldFormat/CCollidableOBBTreeGroup.hpp @@ -8,6 +8,8 @@ #include "rstl/auto_ptr.hpp" #include "rstl/vector.hpp" +#include + class COBBTree; class CCollidableOBBTreeGroupContainer { @@ -40,4 +42,7 @@ private: CCollidableOBBTreeGroupContainer* x10_container; }; +CFactoryFnReturn FCollidableOBBTreeGroupFactory(const SObjectTag& tag, CInputStream& in, + const CVParamTransfer& xfer); + #endif // _CCOLLIDABLEOBBTREEGROUP diff --git a/src/Kyoto/Audio/CMidiManager.cpp b/src/Kyoto/Audio/CMidiManager.cpp index 5dd82bfe..e7df5ef3 100644 --- a/src/Kyoto/Audio/CMidiManager.cpp +++ b/src/Kyoto/Audio/CMidiManager.cpp @@ -3,7 +3,7 @@ #include "Kyoto/Audio/CAudioSys.hpp" -#include +#include #include rstl::reserved_vector< CMidiManager::CMidiWrapper, 3 > CMidiManager::mMidiWrappers; diff --git a/src/Kyoto/Text/CStringTable.cpp b/src/Kyoto/Text/CStringTable.cpp index c2715143..b1c91531 100644 --- a/src/Kyoto/Text/CStringTable.cpp +++ b/src/Kyoto/Text/CStringTable.cpp @@ -1,9 +1,9 @@ #include "Kyoto/Text/CStringTable.hpp" -#include "rstl/pair.hpp" -#include "rstl/vector.hpp" +#include -#include "Kyoto/CFactoryMgr.hpp" +#include +#include static FourCC mCurrentLanguage = 'ENGL'; static const wchar_t skInvalidString[] = L"Invalid"; diff --git a/src/MetroidPrime/Factories/CScannableObjectInfo.cpp b/src/MetroidPrime/Factories/CScannableObjectInfo.cpp index 14eed36a..237b873b 100644 --- a/src/MetroidPrime/Factories/CScannableObjectInfo.cpp +++ b/src/MetroidPrime/Factories/CScannableObjectInfo.cpp @@ -1,5 +1,4 @@ #include "MetroidPrime/Factories/CScannableObjectInfo.hpp" -#include "Kyoto/CFactoryMgr.hpp" #include "Kyoto/Basics/CBasics.hpp" #include "Kyoto/Streams/CInputStream.hpp" diff --git a/src/WorldFormat/CCollidableOBBTreeGroup.cpp b/src/WorldFormat/CCollidableOBBTreeGroup.cpp index 522eb073..a6b65dca 100644 --- a/src/WorldFormat/CCollidableOBBTreeGroup.cpp +++ b/src/WorldFormat/CCollidableOBBTreeGroup.cpp @@ -5,7 +5,6 @@ #include #include -#include #pragma inline_max_size(250) CFactoryFnReturn FCollidableOBBTreeGroupFactory(const SObjectTag& tag, CInputStream& in,