CToken fix

Initial CRSC
This commit is contained in:
Phillip Stephens 2016-02-15 23:01:55 -08:00
parent 6614171283
commit 18e34b4dce
7 changed files with 189 additions and 4 deletions

View File

@ -21,8 +21,10 @@ CToken CSimplePool::GetObj(const SObjectTag& tag, const CVParamTransfer& paramXf
return CToken(iter->second);
// TODO: There is some logic missing here, need to figure out what it's doing
CObjectReference* ret = new CObjectReference(*this, x30_factory.Build(tag, paramXfer), tag, paramXfer);
if (ret->GetObject())
return CToken(ret);
return CToken(ret);
return CToken();
}
CToken CSimplePool::GetObj(const SObjectTag& tag)

View File

@ -233,7 +233,12 @@ public:
TToken(T* obj)
: CToken(GetIObjObjectFor(std::unique_ptr<T>(obj))) {}
TToken& operator=(T* obj) {*this = CToken(GetIObjObjectFor(obj)); return this;}
T* GetObj() {return static_cast<TObjOwnerDerivedFromIObj<T>*>(CToken::GetObj())->GetObj();}
T* GetObj()
{
if (CToken::GetObj())
return static_cast<TObjOwnerDerivedFromIObj<T>*>(CToken::GetObj())->GetObj();
return nullptr;
}
T* operator->() {return GetObj();}
};

View File

@ -1,10 +1,147 @@
#include "CCollisionResponseData.hpp"
#include "CParticleDataFactory.hpp"
#include "CDecalDescription.hpp"
#include "CSimplePool.hpp"
#include "CRandom16.hpp"
namespace pshag
{
CCollisionResponseData::CCollisionResponseData(CInputStream& in, CSimplePool* resPool)
static const std::vector<FourCC> SFXTypes =
{
SBIG('DSFX'),SBIG('CSFX'),SBIG('MSFX'),SBIG('GRFX'),
SBIG('ICFX'),SBIG('GOFX'),SBIG('WSFX'),SBIG('WTFX'),
SBIG('2MUD'),SBIG('2LAV'),SBIG('2SAN'),SBIG('2PRJ'),
SBIG('DCFX'),SBIG('DSFX'),SBIG('DSHX'),SBIG('DEFX'),
SBIG('ESFX'),SBIG('SHFX'),SBIG('BEFX'),SBIG('WWFX'),
SBIG('TAFX'),SBIG('GTFX'),SBIG('SPFX'),SBIG('FPFX'),
SBIG('FFFX'),SBIG('PAFX'),SBIG('BMFX'),SBIG('BFFX'),
SBIG('PBFX'),SBIG('IBFX'),SBIG('4SVA'),SBIG('4RPR'),
SBIG('4MTR'),SBIG('4PDS'),SBIG('4FLB'),SBIG('4DRN'),
SBIG('4MRE'),SBIG('CZFX'),SBIG('JZAS'),SBIG('2ISE'),
SBIG('2BSE'),SBIG('2ATB'),SBIG('2ATA'),SBIG('BSFX'),
SBIG('WSFX'),SBIG('TSFX'),SBIG('GSFX'),SBIG('SSFX'),
SBIG('FSFX'),SBIG('SFFX'),SBIG('PSFX'),SBIG('MSFX'),
SBIG('SBFX'),SBIG('PBSX'),SBIG('IBSX'),SBIG('5SVA'),
SBIG('5RPR'),SBIG('5MTR'),SBIG('5PDS'),SBIG('5FLB'),
SBIG('5DRN'),SBIG('5MRE'),SBIG('CSFX'),SBIG('JZPS'),
SBIG('4ISE'),SBIG('4BSE'),SBIG('4ATB'),SBIG('4ATA'),
SBIG('BHFX'),SBIG('WHFX'),SBIG('THFX'),SBIG('GHFX'),
SBIG('SHFX'),SBIG('FHFX'),SBIG('HFFX'),SBIG('PHFX'),
SBIG('MHFX'),SBIG('HBFX'),SBIG('PBHX'),SBIG('IBHX'),
SBIG('6SVA'),SBIG('6RPR'),SBIG('6MTR'),SBIG('6PDS'),
SBIG('6FLB'),SBIG('6DRN'),SBIG('6MRE'),SBIG('CHFX'),
SBIG('JZHS'),SBIG('6ISE'),SBIG('6BSE'),SBIG('6ATB'),
SBIG('6ATA')
};
static const std::vector<FourCC> GeneratorTypes =
{
SBIG('DEFS'),SBIG('CRTS'),SBIG('MTLS'),SBIG('GRAS'),
SBIG('ICEE'),SBIG('GOOO'),SBIG('WODS'),SBIG('WATR'),
SBIG('1MUD'),SBIG('1LAV'),SBIG('1SAN'),SBIG('1PRJ'),
SBIG('DCHR'),SBIG('DCHS'),SBIG('DCSH'),SBIG('DENM'),
SBIG('DESP'),SBIG('DESH'),SBIG('BTLE'),SBIG('WASP'),
SBIG('TALP'),SBIG('PTGM'),SBIG('SPIR'),SBIG('FPIR'),
SBIG('FFLE'),SBIG('PARA'),SBIG('BMON'),SBIG('BFLR'),
SBIG('PBOS'),SBIG('IBOS'),SBIG('1SVA'),SBIG('1RPR'),
SBIG('1MTR'),SBIG('1PDS'),SBIG('1FLB'),SBIG('1DRN'),
SBIG('1MRE'),SBIG('CHOZ'),SBIG('JZAP'),SBIG('1ISE'),
SBIG('1BSE'),SBIG('1ATB'),SBIG('1ATA'),SBIG('BTSP'),
SBIG('WWSP'),SBIG('TASP'),SBIG('TGSP'),SBIG('SPSP'),
SBIG('FPSP'),SBIG('FFSP'),SBIG('PSSP'),SBIG('BMSP'),
SBIG('BFSP'),SBIG('PBSP'),SBIG('IBSP'),SBIG('2SVA'),
SBIG('2RPR'),SBIG('2MTR'),SBIG('2PDS'),SBIG('2FLB'),
SBIG('2DRN'),SBIG('2MRE'),SBIG('CHSP'),SBIG('JZSP'),
SBIG('3ISE'),SBIG('3BSE'),SBIG('3ATB'),SBIG('3ATA'),
SBIG('BTSH'),SBIG('WWSH'),SBIG('TASH'),SBIG('TGSH'),
SBIG('SPSH'),SBIG('FPSH'),SBIG('FFSH'),SBIG('PSSH'),
SBIG('BMSH'),SBIG('BFSH'),SBIG('PBSH'),SBIG('IBSH'),
SBIG('3SVA'),SBIG('3RPR'),SBIG('3MTR'),SBIG('3PDS'),
SBIG('3FLB'),SBIG('3DRN'),SBIG('3MRE'),SBIG('CHSH'),
SBIG('JZSH'),SBIG('5ISE'),SBIG('5BSE'),SBIG('5ATB'),
SBIG('5ATA'),
};
static const std::vector<FourCC> DecalTypes =
{
SBIG('NCDL'),SBIG('DDCL'),SBIG('CODL'),SBIG('MEDL'),
SBIG('GRDL'),SBIG('ICDL'),SBIG('GODL'),SBIG('WODL'),
SBIG('WTDL'),SBIG('3MUD'),SBIG('3LAV'),SBIG('3SAN'),
SBIG('CHDL'),SBIG('ENDL')
};
using CPF = CParticleDataFactory;
bool CCollisionResponseData::CheckAndAddDecalToResponse(FourCC clsId, CInputStream& in, CSimplePool* resPool)
{
return false;
}
bool CCollisionResponseData::CheckAndAddSoundFXToResponse(FourCC clsId, CInputStream& in)
{
int i = 0;
for (const FourCC& type : SFXTypes)
{
if (type == clsId)
{
FourCC cls = CPF::GetClassID(in);
if (cls == SBIG('NONE'))
return true;
x10[i] = CPF::GetInt(in);
return true;
}
i++;
}
return false;
}
bool CCollisionResponseData::CheckAndAddParticleSystemToResponse(FourCC clsId, CInputStream& in, CSimplePool* resPool)
{
return false;
}
bool CCollisionResponseData::CheckAndAddResourceToResponse(FourCC clsId, CInputStream& in, CSimplePool* resPool)
{
if (CheckAndAddParticleSystemToResponse(clsId, in, resPool))
return true;
if (CheckAndAddSoundFXToResponse(clsId, in))
return true;
if (CheckAndAddDecalToResponse(clsId, in, resPool))
return true;
return false;
}
CCollisionResponseData::CCollisionResponseData(CInputStream& in, CSimplePool* resPool)
: x30_RNGE(50.f), x34_FOFF(0.2f)
{
x0.resize(94);
x10.resize(94);
x20.resize(94);
FourCC clsId = CPF::GetClassID(in);
if (clsId == SBIG('CRSM'))
{
CRandom16 rand{99};
CGlobalRandom gr(rand);
while (clsId != SBIG('_END'))
{
clsId = CPF::GetClassID(in);
if (CheckAndAddResourceToResponse(clsId, in, resPool))
continue;
if (clsId == SBIG('RNGE'))
{
CPF::GetClassID(in);
x30_RNGE = CPF::GetReal(in);
}
else if (clsId == SBIG('FOFF'))
{
CPF::GetClassID(in);
x34_FOFF = CPF::GetReal(in);
}
}
}
}
std::unique_ptr<IObj> FCollisionResponseDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms)

View File

@ -9,9 +9,46 @@
namespace pshag
{
class CSimplePool;
class CGenDescription;
class CDecalDescription;
enum class EWeaponCollisionResponseTypes
{
Unknown0, Unknown1, Unknown2, Unknown3, Unknown4,
Unknown5, Unknown6, Unknown7, Unknown8, Unknown9,
Unknown10,Unknown11,Unknown12,Unknown13,Unknown14,
Unknown15,Unknown16,Unknown17,Unknown18,Unknown19,
Unknown20,Unknown21,Unknown22,Unknown23,Unknown24,
Unknown25,Unknown26,Unknown27,Unknown28,Unknown29,
Unknown30,Unknown31,Unknown32,Unknown33,Unknown34,
Unknown35,Unknown36,Unknown37,Unknown38,Unknown39,
Unknown40,Unknown41,Unknown42,Unknown43,Unknown44,
Unknown45,Unknown46,Unknown47,Unknown48,Unknown49,
Unknown50,Unknown51,Unknown52,Unknown53,Unknown54,
Unknown55,Unknown56,Unknown57,Unknown58,Unknown59,
Unknown60,Unknown61,Unknown62,Unknown63,Unknown64,
Unknown65,Unknown66,Unknown67,Unknown68,Unknown69,
Unknown70,Unknown71,Unknown72,Unknown73,Unknown74,
Unknown75,Unknown76,Unknown77,Unknown78,Unknown79,
Unknown80,Unknown81,Unknown82,Unknown83,Unknown84,
Unknown85,Unknown86,Unknown87,Unknown88,Unknown89,
Unknown90,Unknown91,Unknown92,Unknown93
};
class CCollisionResponseData
{
std::vector<TLockedToken<CGenDescription>> x0;
std::vector<s32> x10;
std::vector<TLockedToken<CDecalDescription>> x20;
float x30_RNGE;
float x34_FOFF;
void AddParticleSystemToResponse(EWeaponCollisionResponseTypes type, CInputStream& in, CSimplePool* resPool);
bool CheckAndAddDecalToResponse(FourCC clsId, CInputStream& in, CSimplePool* resPool);
bool CheckAndAddSoundFXToResponse(FourCC clsId, CInputStream& in);
bool CheckAndAddParticleSystemToResponse(FourCC clsId, CInputStream& in, CSimplePool* resPool);
bool CheckAndAddResourceToResponse(FourCC clsId, CInputStream& in, CSimplePool* resPool);
public:
CCollisionResponseData(CInputStream& in, CSimplePool* resPool);
};

View File

@ -5,14 +5,17 @@ namespace pshag
bool CEESimpleEmitter::GetValue(int frame, Zeus::CVector3f& pPos, Zeus::CVector3f& pVel) const
{
return false;
}
bool CVESphere::GetValue(int frame, Zeus::CVector3f& pPos, Zeus::CVector3f& pVel) const
{
return false;
}
bool CVEAngleSphere::GetValue(int frame, Zeus::CVector3f& pPos, Zeus::CVector3f& pVel) const
{
return false;
}
}

View File

@ -30,7 +30,7 @@ public:
Zeus::CVector3f*,
Zeus::CColor*,
float*, float*) {}
void Activate(bool) { x28_activated = true; }
void Activate(bool val) { x28_activated = val; }
bool IsActivated() { return x28_activated; }
FourCC Get4CharID() { return FOURCC('FWRP'); }
};

View File

@ -53,6 +53,7 @@ struct SElectricGeneratorDesc
class CParticleDataFactory
{
friend class CDecalDataFactory;
friend class CCollisionResponseData;
friend class CParticleElectricDataFactory;
friend class CParticleSwooshDataFactory;
friend class CProjectileWeaponDataFactory;