Skip to content

Commit

Permalink
Start CModelData, cleanup CFactoryFnReturn usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Antidote committed Oct 28, 2024
1 parent c41440e commit d11d8f4
Show file tree
Hide file tree
Showing 21 changed files with 101 additions and 48 deletions.
2 changes: 1 addition & 1 deletion config/GM8E01_00/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/GM8E01_01/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion include/Kyoto/Audio/CSfxManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <musyx/musyx.h>

#include <Kyoto/CFactoryMgr.hpp>
#include <Kyoto/CFactoryFnReturn.hpp>

class CVector3f;
class CSfxManager {
Expand Down Expand Up @@ -243,4 +243,7 @@ class CSfxManager {
static bool IsValidHandle(CSfxHandle handle);
};

CFactoryFnReturn FAudioTranslationTableFactory(const SObjectTag& obj, CInputStream& in,
const CVParamTransfer& xfer);

#endif // _CSFXMANAGER
16 changes: 16 additions & 0 deletions include/Kyoto/CFactoryFnReturn.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef _CFACTORYFNRETURN
#define _CFACTORYFNRETURN
#include <Kyoto/TToken.hpp>

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
15 changes: 0 additions & 15 deletions include/Kyoto/CFactoryMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CObjOwnerDerivedFromIObjUntyped>& GetObjForTransfer() const { return obj; }
private:
rstl::auto_ptr< CObjOwnerDerivedFromIObjUntyped > obj;
};

CFactoryFnReturn FStringTableFactory(const SObjectTag& tag, CInputStream& in,
const CVParamTransfer& xfer);

#endif // _CFACTORYMGR
12 changes: 1 addition & 11 deletions include/Kyoto/CResFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,10 @@

#include "rstl/list.hpp"

#include <Kyoto/IFactory.hpp>
#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();
Expand Down
21 changes: 21 additions & 0 deletions include/Kyoto/IFactory.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef _IFACTORY
#define _IFACTORY

#include <Kyoto/CFactoryFnReturn.hpp>

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
8 changes: 8 additions & 0 deletions include/Kyoto/IObjFactory.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef _CIOBJFACTORY
#define _CIOBJFACTORY

class IObjFactory {
virtual ~IObjFactory() {};
};

#endif // _CIOBJFACTORY
8 changes: 6 additions & 2 deletions include/Kyoto/Text/CStringTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

#include "types.h"

#include "rstl/single_ptr.hpp"
#include <rstl/single_ptr.hpp>

#include "Kyoto/Streams/CInputStream.hpp"
#include <Kyoto/CFactoryFnReturn.hpp>

class CInputStream;
class CStringTable {
int x0_stringCount;
rstl::single_ptr< uchar > x4_data;
Expand All @@ -19,4 +20,7 @@ class CStringTable {

extern CStringTable* gpStringTable;

CFactoryFnReturn FStringTableFactory(const SObjectTag& tag, CInputStream& in,
const CVParamTransfer& xfer);

#endif // _CSTRINGTABLE
3 changes: 2 additions & 1 deletion include/MetroidPrime/CMapArea.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

#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"

#include "rstl/single_ptr.hpp"
#include "rstl/vector.hpp"


class IWorld;
class CWorld;

Expand Down
10 changes: 7 additions & 3 deletions include/MetroidPrime/CModelData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@ struct CAdvancementDeltas {
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 {
Expand Down
11 changes: 11 additions & 0 deletions include/MetroidPrime/Factories/CCharacterFactory.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef _CCHARACTERFACTORY
#define _CCHARACTERFACTORY
#include <Kyoto/IObjFactory.hpp>
#include <Kyoto/CResFactory.hpp>


class CCharacterFactory : IObjFactory {

};

#endif // _CCHARACTERFACTORY
5 changes: 4 additions & 1 deletion include/MetroidPrime/Factories/CCharacterFactoryBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
#define _CCHARACTERFACTORYBUILDER

#include "types.h"
#include <Kyoto/TToken.hpp>

class CAnimRes;
class CCharacterFactory;
class CCharacterFactoryBuilder {
public:
CCharacterFactoryBuilder();
~CCharacterFactoryBuilder();

TToken<CCharacterFactory> GetFactory(const CAnimRes& res);
private:
uchar pad[0x24];
};
Expand Down
5 changes: 5 additions & 0 deletions include/MetroidPrime/Factories/CScannableObjectInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "rstl/reserved_vector.hpp"
#include "rstl/string.hpp"

#include <Kyoto/CFactoryFnReturn.hpp>

class CInputStream;
class CScannableObjectInfo {
public:
Expand All @@ -35,4 +37,7 @@ class CScannableObjectInfo {
rstl::reserved_vector< SBucket, 4 > x14_buckets;
};

CFactoryFnReturn FScannableObjectInfoFactory(const SObjectTag& tag, CInputStream& in,
const CVParamTransfer& xfer);

#endif // _CSCANNABLEOBJECTINFO
2 changes: 1 addition & 1 deletion include/MetroidPrime/Factories/CStateMachineFactory.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _CSTATEMACHINEFACTORY
#define _CSTATEMACHINEFACTORY

#include <Kyoto/CFactoryMgr.hpp>
#include <Kyoto/CFactoryFnReturn.hpp>

CFactoryFnReturn FAiFiniteStateMachineFactory(const SObjectTag& tag, CInputStream& in,
const CVParamTransfer& xfer);
Expand Down
9 changes: 4 additions & 5 deletions include/MetroidPrime/Weapons/WeaponTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
5 changes: 5 additions & 0 deletions include/WorldFormat/CCollidableOBBTreeGroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "rstl/auto_ptr.hpp"
#include "rstl/vector.hpp"

#include <Kyoto/CFactoryFnReturn.hpp>

class COBBTree;

class CCollidableOBBTreeGroupContainer {
Expand Down Expand Up @@ -40,4 +42,7 @@ class CCollidableOBBTreeGroup : public CCollisionPrimitive {
CCollidableOBBTreeGroupContainer* x10_container;
};

CFactoryFnReturn FCollidableOBBTreeGroupFactory(const SObjectTag& tag, CInputStream& in,
const CVParamTransfer& xfer);

#endif // _CCOLLIDABLEOBBTREEGROUP
2 changes: 1 addition & 1 deletion src/Kyoto/Audio/CMidiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "Kyoto/Audio/CAudioSys.hpp"

#include <Kyoto/CFactoryMgr.hpp>
#include <Kyoto/CFactoryFnReturn.hpp>
#include <Kyoto/Streams/CInputStream.hpp>

rstl::reserved_vector< CMidiManager::CMidiWrapper, 3 > CMidiManager::mMidiWrappers;
Expand Down
6 changes: 3 additions & 3 deletions src/Kyoto/Text/CStringTable.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "Kyoto/Text/CStringTable.hpp"

#include "rstl/pair.hpp"
#include "rstl/vector.hpp"
#include <Kyoto/Streams/CInputStream.hpp>

#include "Kyoto/CFactoryMgr.hpp"
#include <rstl/pair.hpp>
#include <rstl/vector.hpp>

static FourCC mCurrentLanguage = 'ENGL';
static const wchar_t skInvalidString[] = L"Invalid";
Expand Down
1 change: 0 additions & 1 deletion src/MetroidPrime/Factories/CScannableObjectInfo.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "MetroidPrime/Factories/CScannableObjectInfo.hpp"
#include "Kyoto/CFactoryMgr.hpp"

#include "Kyoto/Basics/CBasics.hpp"
#include "Kyoto/Streams/CInputStream.hpp"
Expand Down
1 change: 0 additions & 1 deletion src/WorldFormat/CCollidableOBBTreeGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <WorldFormat/CCollidableOBBTree.hpp>
#include <WorldFormat/COBBTree.hpp>

#include <Kyoto/CFactoryMgr.hpp>

#pragma inline_max_size(250)
CFactoryFnReturn FCollidableOBBTreeGroupFactory(const SObjectTag& tag, CInputStream& in,
Expand Down

0 comments on commit d11d8f4

Please sign in to comment.