2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 17:04:55 +00:00

Refactor ResId into CAssetId

This commit is contained in:
2017-08-12 22:26:14 -07:00
parent e0efcc0e5c
commit 870e8c80ee
176 changed files with 800 additions and 715 deletions

View File

@@ -11,7 +11,7 @@ bool CDecalManager::m_PoolInitialized = false;
s32 CDecalManager::m_FreeIndex = 63;
float CDecalManager::m_DeltaTimeSinceLastDecalCreation = 0.f;
s32 CDecalManager::m_LastDecalCreatedIndex = -1;
ResId CDecalManager::m_LastDecalCreatedAssetId = -1;
CAssetId CDecalManager::m_LastDecalCreatedAssetId = -1;
rstl::reserved_vector<CDecalManager::SDecal, 64> CDecalManager::m_DecalPool;
rstl::reserved_vector<s32, 64> CDecalManager::m_ActiveIndexList;

View File

@@ -26,7 +26,7 @@ class CDecalManager
static s32 m_FreeIndex;
static float m_DeltaTimeSinceLastDecalCreation;
static s32 m_LastDecalCreatedIndex;
static ResId m_LastDecalCreatedAssetId;
static CAssetId m_LastDecalCreatedAssetId;
static rstl::reserved_vector<SDecal, 64> m_DecalPool;
static rstl::reserved_vector<s32, 64> m_ActiveIndexList;
public:

View File

@@ -16,7 +16,7 @@ float CParticleDataFactory::GetReal(CInputStream& in)
return in.readFloatBig();
}
int32_t CParticleDataFactory::GetInt(CInputStream& in)
s32 CParticleDataFactory::GetInt(CInputStream& in)
{
return in.readInt32Big();
}
@@ -41,26 +41,26 @@ SParticleModel CParticleDataFactory::GetModel(CInputStream& in, CSimplePool* res
FourCC clsId = GetClassID(in);
if (clsId == SBIG('NONE'))
return {};
ResId id = in.readUint32Big();
if (!id)
CAssetId id = in.readUint32Big();
if (!id.IsValid())
return {};
return {resPool->GetObj({FOURCC('CMDL'), id}), true};
}
SChildGeneratorDesc CParticleDataFactory::GetChildGeneratorDesc(ResId res, CSimplePool* resPool, const std::vector<ResId>& tracker)
SChildGeneratorDesc CParticleDataFactory::GetChildGeneratorDesc(CAssetId res, CSimplePool* resPool, const std::vector<CAssetId>& tracker)
{
if (std::count(tracker.cbegin(), tracker.cend(), res) == 0)
return {resPool->GetObj({FOURCC('PART'), res}), true};
return {};
}
SChildGeneratorDesc CParticleDataFactory::GetChildGeneratorDesc(CInputStream& in, CSimplePool* resPool, const std::vector<ResId>& tracker)
SChildGeneratorDesc CParticleDataFactory::GetChildGeneratorDesc(CInputStream& in, CSimplePool* resPool, const std::vector<CAssetId>& tracker)
{
FourCC clsId = GetClassID(in);
if (clsId == SBIG('NONE'))
return {};
ResId id = in.readUint32Big();
if (!id)
CAssetId id = in.readUint32Big();
if (!id.IsValid())
return {};
return GetChildGeneratorDesc(id, resPool, tracker);
}
@@ -70,8 +70,8 @@ SSwooshGeneratorDesc CParticleDataFactory::GetSwooshGeneratorDesc(CInputStream&
FourCC clsId = GetClassID(in);
if (clsId == SBIG('NONE'))
return {};
ResId id = in.readUint32Big();
if (!id)
CAssetId id = in.readUint32Big();
if (!id.IsValid())
return {};
return {resPool->GetObj({FOURCC('SWHC'), id}), true};
}
@@ -81,8 +81,8 @@ SElectricGeneratorDesc CParticleDataFactory::GetElectricGeneratorDesc(CInputStre
FourCC clsId = GetClassID(in);
if (clsId == SBIG('NONE'))
return {};
ResId id = in.readUint32Big();
if (!id)
CAssetId id = in.readUint32Big();
if (!id.IsValid())
return {};
return {resPool->GetObj({FOURCC('ELSC'), id}), true};
}
@@ -97,7 +97,7 @@ CUVElement* CParticleDataFactory::GetTextureElement(CInputStream& in, CSimplePoo
FourCC subId = GetClassID(in);
if (subId == SBIG('NONE'))
return nullptr;
ResId id = in.readUint32Big();
CAssetId id = in.readUint32Big();
TToken<CTexture> txtr = resPool->GetObj({FOURCC('TXTR'), id});
return new CUVEConstant(std::move(txtr));
}
@@ -106,7 +106,7 @@ CUVElement* CParticleDataFactory::GetTextureElement(CInputStream& in, CSimplePoo
FourCC subId = GetClassID(in);
if (subId == SBIG('NONE'))
return nullptr;
ResId id = in.readUint32Big();
CAssetId id = in.readUint32Big();
CIntElement* a = GetIntElement(in);
CIntElement* b = GetIntElement(in);
CIntElement* c = GetIntElement(in);
@@ -827,13 +827,13 @@ CIntElement* CParticleDataFactory::GetIntElement(CInputStream& in)
CGenDescription* CParticleDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool)
{
std::vector<ResId> tracker;
std::vector<CAssetId> tracker;
tracker.reserve(8);
return CreateGeneratorDescription(in, tracker, 0, resPool);
}
CGenDescription* CParticleDataFactory::CreateGeneratorDescription(CInputStream& in, std::vector<ResId>& tracker,
ResId resId, CSimplePool* resPool)
CGenDescription* CParticleDataFactory::CreateGeneratorDescription(CInputStream& in, std::vector<CAssetId>& tracker,
CAssetId resId, CSimplePool* resPool)
{
if (std::count(tracker.cbegin(), tracker.cend(), resId) == 0)
{
@@ -851,7 +851,7 @@ CGenDescription* CParticleDataFactory::CreateGeneratorDescription(CInputStream&
}
bool CParticleDataFactory::CreateGPSM(CGenDescription* fillDesc, CInputStream& in,
std::vector<ResId>& tracker, CSimplePool* resPool)
std::vector<CAssetId>& tracker, CSimplePool* resPool)
{
CRandom16 rand{99};
CGlobalRandom gr(rand);

View File

@@ -76,8 +76,8 @@ class CParticleDataFactory
friend class CProjectileWeaponDataFactory;
static SParticleModel GetModel(CInputStream& in, CSimplePool* resPool);
static SChildGeneratorDesc GetChildGeneratorDesc(ResId res, CSimplePool* resPool, const std::vector<ResId>& tracker);
static SChildGeneratorDesc GetChildGeneratorDesc(CInputStream& in, CSimplePool* resPool, const std::vector<ResId>& tracker);
static SChildGeneratorDesc GetChildGeneratorDesc(CAssetId res, CSimplePool* resPool, const std::vector<CAssetId>& tracker);
static SChildGeneratorDesc GetChildGeneratorDesc(CInputStream& in, CSimplePool* resPool, const std::vector<CAssetId>& tracker);
static SSwooshGeneratorDesc GetSwooshGeneratorDesc(CInputStream& in, CSimplePool* resPool);
static SElectricGeneratorDesc GetElectricGeneratorDesc(CInputStream& in, CSimplePool* resPool);
static CUVElement* GetTextureElement(CInputStream& in, CSimplePool* resPool);
@@ -89,13 +89,13 @@ class CParticleDataFactory
static CIntElement* GetIntElement(CInputStream& in);
static float GetReal(CInputStream& in);
static int32_t GetInt(CInputStream& in);
static s32 GetInt(CInputStream& in);
static bool GetBool(CInputStream& in);
static FourCC GetClassID(CInputStream& in);
static CGenDescription* CreateGeneratorDescription(CInputStream& in, std::vector<ResId>& tracker,
ResId resId, CSimplePool* resPool);
static CGenDescription* CreateGeneratorDescription(CInputStream& in, std::vector<CAssetId>& tracker,
CAssetId resId, CSimplePool* resPool);
static bool CreateGPSM(CGenDescription* fillDesc, CInputStream& in,
std::vector<ResId>& tracker, CSimplePool* resPool);
std::vector<CAssetId>& tracker, CSimplePool* resPool);
static void LoadGPSMTokens(CGenDescription* desc);
public:
static CGenDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);

View File

@@ -95,14 +95,14 @@ bool CParticleElectricDataFactory::CreateELSM(CElectricDescription* desc, CInput
break;
case SBIG('GPSM'):
{
std::vector<ResId> tracker;
std::vector<CAssetId> tracker;
tracker.reserve(8);
desc->x50_GPSM = CPF::GetChildGeneratorDesc(in, resPool, tracker);
break;
}
case SBIG('EPSM'):
{
std::vector<ResId> tracker;
std::vector<CAssetId> tracker;
tracker.reserve(8);
desc->x60_EPSM = CPF::GetChildGeneratorDesc(in, resPool, tracker);
break;

View File

@@ -94,14 +94,14 @@ bool CProjectileWeaponDataFactory::CreateWPSM(CWeaponDescription* desc, CInputSt
break;
case SBIG('APSM'):
{
std::vector<ResId> tracker;
std::vector<CAssetId> tracker;
tracker.reserve(8);
desc->x34_APSM = CPF::GetChildGeneratorDesc(in, resPool, tracker);
break;
}
case SBIG('APS2'):
{
std::vector<ResId> tracker;
std::vector<CAssetId> tracker;
tracker.reserve(8);
desc->x44_APS2 = CPF::GetChildGeneratorDesc(in, resPool, tracker);
break;
@@ -123,8 +123,8 @@ bool CProjectileWeaponDataFactory::CreateWPSM(CWeaponDescription* desc, CInputSt
FourCC cid = CPF::GetClassID(in);
if (cid == SBIG('NONE'))
break;
ResId id = CPF::GetInt(in);
if (id)
CAssetId id = CPF::GetInt(in);
if (id.IsValid())
desc->x94_COLR = {resPool->GetObj({FOURCC('CRSC'), id}), true};
break;
}