Refactor so PWE compiles with the newly externalized LibCommon

This commit is contained in:
Aruki
2018-12-11 22:50:46 -07:00
parent dacd21d7fc
commit 2287b05bc3
298 changed files with 3192 additions and 3184 deletions

View File

@@ -9,7 +9,7 @@ class CAnimEventData : public CResource
struct SEvent
{
u32 mCharacterIndex;
uint32 mCharacterIndex;
CAssetID mAssetRef;
};
@@ -30,7 +30,7 @@ public:
void AddDependenciesToTree(CDependencyTree *pTree) const
{
for (u32 iEvt = 0; iEvt < mEvents.size(); iEvt++)
for (uint32 iEvt = 0; iEvt < mEvents.size(); iEvt++)
{
const SEvent& rkEvent = mEvents[iEvt];
CAssetID ID = rkEvent.mAssetRef;
@@ -43,11 +43,11 @@ public:
}
}
inline u32 NumEvents() const { return mEvents.size(); }
inline u32 EventCharacterIndex(u32 EventIdx) const { return mEvents[EventIdx].mCharacterIndex; }
inline CAssetID EventAssetRef(u32 EventIdx) const { return mEvents[EventIdx].mAssetRef; }
inline uint32 NumEvents() const { return mEvents.size(); }
inline uint32 EventCharacterIndex(uint32 EventIdx) const { return mEvents[EventIdx].mCharacterIndex; }
inline CAssetID EventAssetRef(uint32 EventIdx) const { return mEvents[EventIdx].mAssetRef; }
inline void AddEvent(u32 CharIdx, CAssetID AssetID) { mEvents.push_back( SEvent { CharIdx, AssetID } ); }
inline void AddEvent(uint32 CharIdx, CAssetID AssetID) { mEvents.push_back( SEvent { CharIdx, AssetID } ); }
};
#endif // CANIMEVENTDATA

View File

@@ -12,14 +12,14 @@
#include "Core/Resource/CResource.h"
#include "Core/Resource/TResPtr.h"
#include "Core/Resource/Model/CModel.h"
#include <Common/types.h>
#include <Common/BasicTypes.h>
#include <vector>
// Animation structures
struct SAdditiveAnim
{
u32 AnimID;
uint32 AnimID;
float FadeInTime;
float FadeOutTime;
};
@@ -32,15 +32,15 @@ struct SAnimation
struct STransition
{
u32 Unknown;
u32 AnimIdA;
u32 AnimIdB;
uint32 Unknown;
uint32 AnimIdA;
uint32 AnimIdB;
IMetaTransition *pMetaTrans;
};
struct SHalfTransition
{
u32 AnimID;
uint32 AnimID;
IMetaTransition *pMetaTrans;
};
@@ -62,7 +62,7 @@ struct SOverlayModel
struct SSetCharacter
{
u32 ID;
uint32 ID;
TString Name;
TResPtr<CModel> pModel;
TResPtr<CSkin> pSkin;
@@ -79,7 +79,7 @@ struct SSetCharacter
std::vector<CAssetID> SoundEffects;
std::vector<CAssetID> DKDependencies;
CAssetID SpatialPrimitives;
std::set<u32> UsedAnimationIndices;
std::set<uint32> UsedAnimationIndices;
};
class CAnimSet : public CResource
@@ -109,19 +109,19 @@ public:
~CAnimSet()
{
for (u32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
for (uint32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
delete mAnimations[iAnim].pMetaAnim;
for (u32 iTrans = 0; iTrans < mTransitions.size(); iTrans++)
for (uint32 iTrans = 0; iTrans < mTransitions.size(); iTrans++)
delete mTransitions[iTrans].pMetaTrans;
for (u32 iHalf = 0; iHalf < mHalfTransitions.size(); iHalf++)
for (uint32 iHalf = 0; iHalf < mHalfTransitions.size(); iHalf++)
delete mHalfTransitions[iHalf].pMetaTrans;
delete mpDefaultTransition;
// For MP2, anim events need to be cleaned up manually
for (u32 iEvent = 0; iEvent < mAnimEvents.size(); iEvent++)
for (uint32 iEvent = 0; iEvent < mAnimEvents.size(); iEvent++)
{
ASSERT(mAnimEvents[iEvent] && !mAnimEvents[iEvent]->Entry());
delete mAnimEvents[iEvent];
@@ -133,7 +133,7 @@ public:
CDependencyTree *pTree = new CDependencyTree();
// Character dependencies
for (u32 iChar = 0; iChar < mCharacters.size(); iChar++)
for (uint32 iChar = 0; iChar < mCharacters.size(); iChar++)
{
CSetCharacterDependency *pCharTree = CSetCharacterDependency::BuildTree( mCharacters[iChar] );
ASSERT(pCharTree);
@@ -143,7 +143,7 @@ public:
// Animation dependencies
if (Game() <= EGame::Echoes)
{
for (u32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
for (uint32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
{
CSetAnimationDependency *pAnimTree = CSetAnimationDependency::BuildTree(this, iAnim);
ASSERT(pAnimTree);
@@ -157,7 +157,7 @@ public:
std::set<CAnimPrimitive> PrimitiveSet;
// Animations
for (u32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
for (uint32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
{
const SAnimation& rkAnim = mAnimations[iAnim];
rkAnim.pMetaAnim->GetUniquePrimitives(PrimitiveSet);
@@ -174,7 +174,7 @@ public:
}
// Event sounds
for (u32 iSound = 0; iSound < rkChar.SoundEffects.size(); iSound++)
for (uint32 iSound = 0; iSound < rkChar.SoundEffects.size(); iSound++)
{
pTree->AddDependency(rkChar.SoundEffects[iSound]);
}
@@ -184,14 +184,14 @@ public:
{
const SSetCharacter& rkChar = mCharacters[0];
for (u32 iDep = 0; iDep < rkChar.DKDependencies.size(); iDep++)
for (uint32 iDep = 0; iDep < rkChar.DKDependencies.size(); iDep++)
pTree->AddDependency(rkChar.DKDependencies[iDep]);
}
return pTree;
}
CAnimation* FindAnimationAsset(u32 AnimID) const
CAnimation* FindAnimationAsset(uint32 AnimID) const
{
if (AnimID >= 0 && AnimID < mAnimPrimitives.size())
{
@@ -204,27 +204,27 @@ public:
void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
{
for (u32 iAnim = 0; iAnim < mAnimPrimitives.size(); iAnim++)
for (uint32 iAnim = 0; iAnim < mAnimPrimitives.size(); iAnim++)
rPrimSet.insert(mAnimPrimitives[iAnim]);
}
// Accessors
inline u32 NumCharacters() const { return mCharacters.size(); }
inline u32 NumAnimations() const { return mAnimations.size(); }
inline uint32 NumCharacters() const { return mCharacters.size(); }
inline uint32 NumAnimations() const { return mAnimations.size(); }
inline const SSetCharacter* Character(u32 Index) const
inline const SSetCharacter* Character(uint32 Index) const
{
ASSERT(Index >= 0 && Index < NumCharacters());
return &mCharacters[Index];
}
inline const SAnimation* Animation(u32 Index) const
inline const SAnimation* Animation(uint32 Index) const
{
ASSERT(Index >= 0 && Index < NumAnimations());
return &mAnimations[Index];
}
CAnimEventData* AnimationEventData(u32 Index) const
CAnimEventData* AnimationEventData(uint32 Index) const
{
ASSERT(Index >= 0 && Index < NumAnimations());

View File

@@ -1,6 +1,6 @@
#include "CAnimation.h"
#include <Math/CTransform4f.h>
#include <Math/MathUtil.h>
#include <Common/Math/CTransform4f.h>
#include <Common/Math/MathUtil.h>
CAnimation::CAnimation(CResourceEntry *pEntry /*= 0*/)
: CResource(pEntry)
@@ -8,7 +8,7 @@ CAnimation::CAnimation(CResourceEntry *pEntry /*= 0*/)
, mTickInterval(0.0333333f)
, mNumKeys(0)
{
for (u32 iBone = 0; iBone < 100; iBone++)
for (uint32 iBone = 0; iBone < 100; iBone++)
{
mBoneInfo[iBone].TranslationChannelIdx = 0xFF;
mBoneInfo[iBone].RotationChannelIdx = 0xFF;
@@ -23,7 +23,7 @@ CDependencyTree* CAnimation::BuildDependencyTree() const
return pTree;
}
void CAnimation::EvaluateTransform(float Time, u32 BoneID, CVector3f *pOutTranslation, CQuaternion *pOutRotation, CVector3f *pOutScale) const
void CAnimation::EvaluateTransform(float Time, uint32 BoneID, CVector3f *pOutTranslation, CQuaternion *pOutRotation, CVector3f *pOutScale) const
{
const bool kInterpolate = true;
if (!pOutTranslation && !pOutRotation && !pOutScale) return;
@@ -32,12 +32,12 @@ void CAnimation::EvaluateTransform(float Time, u32 BoneID, CVector3f *pOutTransl
if (Time >= mDuration) Time = mDuration;
if (Time >= FLT_EPSILON) Time -= FLT_EPSILON;
float t = fmodf(Time, mTickInterval) / mTickInterval;
u32 LowKey = (u32) (Time / mTickInterval);
uint32 LowKey = (uint32) (Time / mTickInterval);
if (LowKey == (mNumKeys - 1)) LowKey = mNumKeys - 2;
u8 ScaleChannel = mBoneInfo[BoneID].ScaleChannelIdx;
u8 RotChannel = mBoneInfo[BoneID].RotationChannelIdx;
u8 TransChannel = mBoneInfo[BoneID].TranslationChannelIdx;
uint8 ScaleChannel = mBoneInfo[BoneID].ScaleChannelIdx;
uint8 RotChannel = mBoneInfo[BoneID].RotationChannelIdx;
uint8 TransChannel = mBoneInfo[BoneID].TranslationChannelIdx;
if (ScaleChannel != 0xFF && pOutScale)
{
@@ -61,7 +61,7 @@ void CAnimation::EvaluateTransform(float Time, u32 BoneID, CVector3f *pOutTransl
}
}
bool CAnimation::HasTranslation(u32 BoneID) const
bool CAnimation::HasTranslation(uint32 BoneID) const
{
return (mBoneInfo[BoneID].TranslationChannelIdx != 0xFF);
}

View File

@@ -4,8 +4,8 @@
#include "Core/Resource/CResource.h"
#include "Core/Resource/TResPtr.h"
#include "Core/Resource/Animation/CAnimEventData.h"
#include <Math/CQuaternion.h>
#include <Math/CVector3f.h>
#include <Common/Math/CQuaternion.h>
#include <Common/Math/CVector3f.h>
#include <vector>
class CAnimation : public CResource
@@ -19,7 +19,7 @@ class CAnimation : public CResource
float mDuration;
float mTickInterval;
u32 mNumKeys;
uint32 mNumKeys;
std::vector<TScaleChannel> mScaleChannels;
std::vector<TRotationChannel> mRotationChannels;
@@ -27,9 +27,9 @@ class CAnimation : public CResource
struct SBoneChannelInfo
{
u8 ScaleChannelIdx;
u8 RotationChannelIdx;
u8 TranslationChannelIdx;
uint8 ScaleChannelIdx;
uint8 RotationChannelIdx;
uint8 TranslationChannelIdx;
};
SBoneChannelInfo mBoneInfo[100];
@@ -38,11 +38,11 @@ class CAnimation : public CResource
public:
CAnimation(CResourceEntry *pEntry = 0);
CDependencyTree* BuildDependencyTree() const;
void EvaluateTransform(float Time, u32 BoneID, CVector3f *pOutTranslation, CQuaternion *pOutRotation, CVector3f *pOutScale) const;
bool HasTranslation(u32 BoneID) const;
void EvaluateTransform(float Time, uint32 BoneID, CVector3f *pOutTranslation, CQuaternion *pOutRotation, CVector3f *pOutScale) const;
bool HasTranslation(uint32 BoneID) const;
inline float Duration() const { return mDuration; }
inline u32 NumKeys() const { return mNumKeys; }
inline uint32 NumKeys() const { return mNumKeys; }
inline float TickInterval() const { return mTickInterval; }
inline CAnimEventData* EventData() const { return mpEventData; }
};

View File

@@ -45,7 +45,7 @@ CAnimationParameters::CAnimationParameters(IInputStream& rSCLY, EGame Game)
else if (Game == EGame::DKCReturns)
{
u8 Flags = rSCLY.ReadByte();
uint8 Flags = rSCLY.ReadByte();
// 0x80 - CharacterAnimationSet is empty.
if (Flags & 0x80)
@@ -114,11 +114,11 @@ void CAnimationParameters::Write(IOutputStream& rSCLY)
else
{
if (!mCharacterID.IsValid())
rSCLY.WriteByte((u8) 0x80);
rSCLY.WriteByte((uint8) 0x80);
else
{
u8 Flag = 0;
uint8 Flag = 0;
if (mAnimIndex != -1) Flag |= 0x20;
if (mUnknown2 != 0 || mUnknown3 != 0) Flag |= 0x40;
@@ -156,7 +156,7 @@ void CAnimationParameters::Serialize(IArchive& rArc)
}
}
const SSetCharacter* CAnimationParameters::GetCurrentSetCharacter(s32 NodeIndex /*= -1*/)
const SSetCharacter* CAnimationParameters::GetCurrentSetCharacter(int32 NodeIndex /*= -1*/)
{
CAnimSet *pSet = AnimSet();
@@ -165,27 +165,27 @@ const SSetCharacter* CAnimationParameters::GetCurrentSetCharacter(s32 NodeIndex
if (NodeIndex == -1)
NodeIndex = mCharIndex;
if (mCharIndex != -1 && pSet->NumCharacters() > (u32) NodeIndex)
if (mCharIndex != -1 && pSet->NumCharacters() > (uint32) NodeIndex)
return pSet->Character(NodeIndex);
}
return nullptr;
}
CModel* CAnimationParameters::GetCurrentModel(s32 NodeIndex /*= -1*/)
CModel* CAnimationParameters::GetCurrentModel(int32 NodeIndex /*= -1*/)
{
const SSetCharacter *pkChar = GetCurrentSetCharacter(NodeIndex);
return pkChar ? pkChar->pModel : nullptr;
}
TString CAnimationParameters::GetCurrentCharacterName(s32 NodeIndex /*= -1*/)
TString CAnimationParameters::GetCurrentCharacterName(int32 NodeIndex /*= -1*/)
{
const SSetCharacter *pkChar = GetCurrentSetCharacter(NodeIndex);
return pkChar ? pkChar->Name : "";
}
// ************ ACCESSORS ************
u32 CAnimationParameters::Unknown(u32 Index)
uint32 CAnimationParameters::Unknown(uint32 Index)
{
// mAnimIndex isn't unknown, but I'm too lazy to move it because there's a lot
// of UI stuff that depends on these functions atm for accessing and editing parameters.
@@ -214,14 +214,14 @@ void CAnimationParameters::SetResource(const CAssetID& rkID)
CResourceEntry *pEntry = gpResourceStore->FindEntry(rkID);
if (!pEntry)
Log::Error("Invalid resource ID passed to CAnimationParameters: " + rkID.ToString());
errorf("Invalid resource ID passed to CAnimationParameters: %s", *rkID.ToString());
else if (pEntry->ResourceType() != eAnimSet && pEntry->ResourceType() != eCharacter)
Log::Error("Resource with invalid type passed to CAnimationParameters: " + pEntry->CookedAssetPath().GetFileName());
errorf("Resource with invalid type passed to CAnimationParameters: %s", *pEntry->CookedAssetPath().GetFileName());
}
}
}
void CAnimationParameters::SetUnknown(u32 Index, u32 Value)
void CAnimationParameters::SetUnknown(uint32 Index, uint32 Value)
{
switch (Index)
{

View File

@@ -10,10 +10,10 @@ class CAnimationParameters
EGame mGame;
CAssetID mCharacterID;
u32 mCharIndex;
u32 mAnimIndex;
u32 mUnknown2;
u32 mUnknown3;
uint32 mCharIndex;
uint32 mAnimIndex;
uint32 mUnknown2;
uint32 mUnknown3;
public:
CAnimationParameters();
@@ -22,18 +22,18 @@ public:
void Write(IOutputStream& rSCLY);
void Serialize(IArchive& rArc);
const SSetCharacter* GetCurrentSetCharacter(s32 NodeIndex = -1);
CModel* GetCurrentModel(s32 NodeIndex = -1);
TString GetCurrentCharacterName(s32 NodeIndex = -1);
const SSetCharacter* GetCurrentSetCharacter(int32 NodeIndex = -1);
CModel* GetCurrentModel(int32 NodeIndex = -1);
TString GetCurrentCharacterName(int32 NodeIndex = -1);
// Accessors
inline EGame Version() const { return mGame; }
inline CAssetID ID() const { return mCharacterID; }
inline CAnimSet* AnimSet() const { return (CAnimSet*) gpResourceStore->LoadResource(mCharacterID); }
inline u32 CharacterIndex() const { return mCharIndex; }
inline u32 AnimIndex() const { return mAnimIndex; }
inline void SetCharIndex(u32 Index) { mCharIndex = Index; }
inline void SetAnimIndex(u32 Index) { mAnimIndex = Index; }
inline EGame Version() const { return mGame; }
inline CAssetID ID() const { return mCharacterID; }
inline CAnimSet* AnimSet() const { return (CAnimSet*) gpResourceStore->LoadResource(mCharacterID); }
inline uint32 CharacterIndex() const { return mCharIndex; }
inline uint32 AnimIndex() const { return mAnimIndex; }
inline void SetCharIndex(uint32 Index) { mCharIndex = Index; }
inline void SetAnimIndex(uint32 Index) { mAnimIndex = Index; }
inline void SetGame(EGame Game)
{
@@ -49,9 +49,9 @@ public:
}
}
u32 Unknown(u32 Index);
uint32 Unknown(uint32 Index);
void SetResource(const CAssetID& rkID);
void SetUnknown(u32 Index, u32 Value);
void SetUnknown(uint32 Index, uint32 Value);
// Operators
inline CAnimationParameters& operator=(const CAnimationParameters& rkOther)

View File

@@ -2,8 +2,8 @@
#include "Core/Render/CBoneTransformData.h"
#include "Core/Render/CDrawUtil.h"
#include "Core/Render/CGraphics.h"
#include <Common/AssertMacro.h>
#include <Math/MathUtil.h>
#include <Common/Macros.h>
#include <Common/Math/MathUtil.h>
// ************ CBone ************
CBone::CBone(CSkeleton *pSkel)
@@ -37,7 +37,7 @@ void CBone::UpdateTransform(CBoneTransformData& rData, const SBoneTransformInfo&
rTransform *= mInvBind;
// Calculate children
for (u32 iChild = 0; iChild < mChildren.size(); iChild++)
for (uint32 iChild = 0; iChild < mChildren.size(); iChild++)
mChildren[iChild]->UpdateTransform(rData, TransformInfo, pAnim, Time, AnchorRoot);
}
@@ -70,13 +70,13 @@ CSkeleton::CSkeleton(CResourceEntry *pEntry /*= 0*/)
CSkeleton::~CSkeleton()
{
for (u32 iBone = 0; iBone < mBones.size(); iBone++)
for (uint32 iBone = 0; iBone < mBones.size(); iBone++)
delete mBones[iBone];
}
CBone* CSkeleton::BoneByID(u32 BoneID) const
CBone* CSkeleton::BoneByID(uint32 BoneID) const
{
for (u32 iBone = 0; iBone < mBones.size(); iBone++)
for (uint32 iBone = 0; iBone < mBones.size(); iBone++)
{
if (mBones[iBone]->ID() == BoneID)
return mBones[iBone];
@@ -87,7 +87,7 @@ CBone* CSkeleton::BoneByID(u32 BoneID) const
CBone* CSkeleton::BoneByName(const TString& rkBoneName) const
{
for (u32 iBone = 0; iBone < mBones.size(); iBone++)
for (uint32 iBone = 0; iBone < mBones.size(); iBone++)
{
if (mBones[iBone]->Name() == rkBoneName)
return mBones[iBone];
@@ -96,11 +96,11 @@ CBone* CSkeleton::BoneByName(const TString& rkBoneName) const
return nullptr;
}
u32 CSkeleton::MaxBoneID() const
uint32 CSkeleton::MaxBoneID() const
{
u32 ID = 0;
uint32 ID = 0;
for (u32 iBone = 0; iBone < mBones.size(); iBone++)
for (uint32 iBone = 0; iBone < mBones.size(); iBone++)
{
if (mBones[iBone]->ID() > ID)
ID = mBones[iBone]->ID();
@@ -121,7 +121,7 @@ void CSkeleton::Draw(FRenderOptions /*Options*/, const CBoneTransformData *pkDat
glLineWidth(1.f);
// Draw all child links first to minimize model matrix swaps.
for (u32 iBone = 0; iBone < mBones.size(); iBone++)
for (uint32 iBone = 0; iBone < mBones.size(); iBone++)
{
CBone *pBone = mBones[iBone];
CVector3f BonePos = pkData ? pBone->TransformedPosition(*pkData) : pBone->Position();
@@ -136,7 +136,7 @@ void CSkeleton::Draw(FRenderOptions /*Options*/, const CBoneTransformData *pkDat
}
// Draw child links
for (u32 iChild = 0; iChild < pBone->NumChildren(); iChild++)
for (uint32 iChild = 0; iChild < pBone->NumChildren(); iChild++)
{
CBone *pChild = pBone->ChildByIndex(iChild);
CVector3f ChildPos = pkData ? pChild->TransformedPosition(*pkData) : pChild->Position();
@@ -147,7 +147,7 @@ void CSkeleton::Draw(FRenderOptions /*Options*/, const CBoneTransformData *pkDat
// Draw bone spheres
CTransform4f BaseTransform = CGraphics::sMVPBlock.ModelMatrix;
for (u32 iBone = 0; iBone < mBones.size(); iBone++)
for (uint32 iBone = 0; iBone < mBones.size(); iBone++)
{
CBone *pBone = mBones[iBone];
CVector3f BonePos = pkData ? pBone->TransformedPosition(*pkData) : pBone->Position();
@@ -161,11 +161,11 @@ void CSkeleton::Draw(FRenderOptions /*Options*/, const CBoneTransformData *pkDat
}
}
std::pair<s32,float> CSkeleton::RayIntersect(const CRay& rkRay, const CBoneTransformData& rkData)
std::pair<int32,float> CSkeleton::RayIntersect(const CRay& rkRay, const CBoneTransformData& rkData)
{
std::pair<s32,float> Out(-1, FLT_MAX);
std::pair<int32,float> Out(-1, FLT_MAX);
for (u32 iBone = 0; iBone < mBones.size(); iBone++)
for (uint32 iBone = 0; iBone < mBones.size(); iBone++)
{
CBone *pBone = mBones[iBone];
CVector3f BonePos = pBone->TransformedPosition(rkData);

View File

@@ -4,10 +4,10 @@
#include "CAnimation.h"
#include "Core/Render/FRenderOptions.h"
#include "Core/Resource/CResource.h"
#include <Common/BasicTypes.h>
#include <Common/TString.h>
#include <Common/types.h>
#include <Math/CRay.h>
#include <Math/CVector3f.h>
#include <Common/Math/CRay.h>
#include <Common/Math/CVector3f.h>
class CBoneTransformData;
class CBone;
@@ -36,14 +36,14 @@ public:
CSkeleton(CResourceEntry *pEntry = 0);
~CSkeleton();
void UpdateTransform(CBoneTransformData& rData, CAnimation *pAnim, float Time, bool AnchorRoot);
CBone* BoneByID(u32 BoneID) const;
CBone* BoneByID(uint32 BoneID) const;
CBone* BoneByName(const TString& rkBoneName) const;
u32 MaxBoneID() const;
uint32 MaxBoneID() const;
void Draw(FRenderOptions Options, const CBoneTransformData *pkData);
std::pair<s32,float> RayIntersect(const CRay& rkRay, const CBoneTransformData& rkData);
std::pair<int32,float> RayIntersect(const CRay& rkRay, const CBoneTransformData& rkData);
inline u32 NumBones() const { return mBones.size(); }
inline uint32 NumBones() const { return mBones.size(); }
inline CBone* RootBone() const { return mpRootBone; }
};
@@ -54,7 +54,7 @@ class CBone
CSkeleton *mpSkeleton;
CBone *mpParent;
std::vector<CBone*> mChildren;
u32 mID;
uint32 mID;
CVector3f mPosition;
CVector3f mLocalPosition;
CQuaternion mRotation;
@@ -73,9 +73,9 @@ public:
// Accessors
inline CSkeleton* Skeleton() const { return mpSkeleton; }
inline CBone* Parent() const { return mpParent; }
inline u32 NumChildren() const { return mChildren.size(); }
inline CBone* ChildByIndex(u32 Index) const { return mChildren[Index]; }
inline u32 ID() const { return mID; }
inline uint32 NumChildren() const { return mChildren.size(); }
inline CBone* ChildByIndex(uint32 Index) const { return mChildren[Index]; }
inline uint32 ID() const { return mID; }
inline CVector3f Position() const { return mPosition; }
inline CVector3f LocalPosition() const { return mLocalPosition; }
inline CQuaternion Rotation() const { return mRotation; }

View File

@@ -18,14 +18,14 @@ class CSkin : public CResource
struct SVertGroup
{
SVertexWeights Weights;
u32 NumVertices;
uint32 NumVertices;
};
std::vector<SVertGroup> mVertGroups;
public:
CSkin(CResourceEntry *pEntry = 0) : CResource(pEntry) {}
const SVertexWeights& WeightsForVertex(u32 VertIdx)
const SVertexWeights& WeightsForVertex(uint32 VertIdx)
{
// Null weights bind everything to the root bone in case there is no matching vertex group
static const SVertexWeights skNullWeights = {
@@ -33,9 +33,9 @@ public:
{ 1.f, 0.f, 0.f, 0.f }
};
u32 Index = 0;
uint32 Index = 0;
for (u32 iGrp = 0; iGrp < mVertGroups.size(); iGrp++)
for (uint32 iGrp = 0; iGrp < mVertGroups.size(); iGrp++)
{
if (VertIdx < Index + mVertGroups[iGrp].NumVertices)
return mVertGroups[iGrp].Weights;

View File

@@ -34,10 +34,10 @@ public:
~CSourceAnimData()
{
for (u32 TransIdx = 0; TransIdx < mTransitions.size(); TransIdx++)
for (uint32 TransIdx = 0; TransIdx < mTransitions.size(); TransIdx++)
delete mTransitions[TransIdx].pTransition;
for (u32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++)
for (uint32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++)
delete mHalfTransitions[HalfIdx].pTransition;
delete mpDefaultTransition;
@@ -54,10 +54,10 @@ public:
void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
{
for (u32 TransIdx = 0; TransIdx < mTransitions.size(); TransIdx++)
for (uint32 TransIdx = 0; TransIdx < mTransitions.size(); TransIdx++)
mTransitions[TransIdx].pTransition->GetUniquePrimitives(rPrimSet);
for (u32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++)
for (uint32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++)
mHalfTransitions[HalfIdx].pTransition->GetUniquePrimitives(rPrimSet);
if (mpDefaultTransition)
@@ -80,7 +80,7 @@ public:
UsedTransitions.insert(mpDefaultTransition);
}
for (u32 TransitionIdx = 0; TransitionIdx < mTransitions.size(); TransitionIdx++)
for (uint32 TransitionIdx = 0; TransitionIdx < mTransitions.size(); TransitionIdx++)
{
const STransition& rkTransition = mTransitions[TransitionIdx];
IMetaTransition *pTransition = rkTransition.pTransition;
@@ -94,7 +94,7 @@ public:
}
}
for (u32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++)
for (uint32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++)
{
const SHalfTransition& rkHalfTrans = mHalfTransitions[HalfIdx];
IMetaTransition *pTransition = rkHalfTrans.pTransition;

View File

@@ -23,13 +23,13 @@ IMetaAnimation* CMetaAnimFactory::LoadFromStream(IInputStream& rInput, EGame Gam
return new CMetaAnimSequence(rInput, Game);
default:
Log::Error("Unrecognized meta-animation type: " + TString::FromInt32(Type, 0, 10));
errorf("Unrecognized meta-animation type: %d", Type);
return nullptr;
}
}
// ************ CMetaAnimationPlay ************
CMetaAnimPlay::CMetaAnimPlay(const CAnimPrimitive& rkPrimitive, float UnkA, u32 UnkB)
CMetaAnimPlay::CMetaAnimPlay(const CAnimPrimitive& rkPrimitive, float UnkA, uint32 UnkB)
: mPrimitive(rkPrimitive)
, mUnknownA(UnkA)
, mUnknownB(UnkB)
@@ -84,10 +84,10 @@ void CMetaAnimBlend::GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) con
// ************ CMetaAnimRandom ************
CMetaAnimRandom::CMetaAnimRandom(IInputStream& rInput, EGame Game)
{
u32 NumPairs = rInput.ReadLong();
uint32 NumPairs = rInput.ReadLong();
mProbabilityPairs.reserve(NumPairs);
for (u32 iAnim = 0; iAnim < NumPairs; iAnim++)
for (uint32 iAnim = 0; iAnim < NumPairs; iAnim++)
{
SAnimProbabilityPair Pair;
Pair.pAnim = gMetaAnimFactory.LoadFromStream(rInput, Game);
@@ -98,7 +98,7 @@ CMetaAnimRandom::CMetaAnimRandom(IInputStream& rInput, EGame Game)
CMetaAnimRandom::~CMetaAnimRandom()
{
for (u32 iPair = 0; iPair < mProbabilityPairs.size(); iPair++)
for (uint32 iPair = 0; iPair < mProbabilityPairs.size(); iPair++)
delete mProbabilityPairs[iPair].pAnim;
}
@@ -109,17 +109,17 @@ EMetaAnimationType CMetaAnimRandom::Type() const
void CMetaAnimRandom::GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
{
for (u32 iPair = 0; iPair < mProbabilityPairs.size(); iPair++)
for (uint32 iPair = 0; iPair < mProbabilityPairs.size(); iPair++)
mProbabilityPairs[iPair].pAnim->GetUniquePrimitives(rPrimSet);
}
// ************ CMetaAnimSequence ************
CMetaAnimSequence::CMetaAnimSequence(IInputStream& rInput, EGame Game)
{
u32 NumAnims = rInput.ReadLong();
uint32 NumAnims = rInput.ReadLong();
mAnimations.reserve(NumAnims);
for (u32 iAnim = 0; iAnim < NumAnims; iAnim++)
for (uint32 iAnim = 0; iAnim < NumAnims; iAnim++)
{
IMetaAnimation *pAnim = gMetaAnimFactory.LoadFromStream(rInput, Game);
mAnimations.push_back(pAnim);
@@ -128,7 +128,7 @@ CMetaAnimSequence::CMetaAnimSequence(IInputStream& rInput, EGame Game)
CMetaAnimSequence::~CMetaAnimSequence()
{
for (u32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
for (uint32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
delete mAnimations[iAnim];
}
@@ -139,6 +139,6 @@ EMetaAnimationType CMetaAnimSequence::Type() const
void CMetaAnimSequence::GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
{
for (u32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
for (uint32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
mAnimations[iAnim]->GetUniquePrimitives(rPrimSet);
}

View File

@@ -26,13 +26,13 @@ extern CMetaAnimFactory gMetaAnimFactory;
class CAnimPrimitive
{
TResPtr<CAnimation> mpAnim;
u32 mID;
uint32 mID;
TString mName;
public:
CAnimPrimitive() : mID(0) {}
CAnimPrimitive(const CAssetID& rkAnimAssetID, u32 CharAnimID, const TString& rkAnimName)
CAnimPrimitive(const CAssetID& rkAnimAssetID, uint32 CharAnimID, const TString& rkAnimName)
: mID(CharAnimID), mName(rkAnimName)
{
mpAnim = gpResourceStore->LoadResource(rkAnimAssetID);
@@ -50,7 +50,7 @@ public:
// Accessors
CAnimation* Animation() const { return mpAnim; }
u32 ID() const { return mID; }
uint32 ID() const { return mID; }
TString Name() const { return mName; }
};
@@ -73,10 +73,10 @@ class CMetaAnimPlay : public IMetaAnimation
protected:
CAnimPrimitive mPrimitive;
float mUnknownA;
u32 mUnknownB;
uint32 mUnknownB;
public:
CMetaAnimPlay(const CAnimPrimitive& rkPrimitive, float UnkA, u32 UnkB);
CMetaAnimPlay(const CAnimPrimitive& rkPrimitive, float UnkA, uint32 UnkB);
CMetaAnimPlay(IInputStream& rInput, EGame Game);
virtual EMetaAnimationType Type() const;
virtual void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const;
@@ -84,7 +84,7 @@ public:
// Accessors
inline CAnimPrimitive Primitive() const { return mPrimitive; }
inline float UnknownA() const { return mUnknownA; }
inline u32 UnknownB() const { return mUnknownB; }
inline uint32 UnknownB() const { return mUnknownB; }
};
// CMetaAnimBlend - blend between two animations
@@ -114,7 +114,7 @@ public:
struct SAnimProbabilityPair
{
IMetaAnimation *pAnim;
u32 Probability;
uint32 Probability;
};
// CMetaAnimRandom - play random animation

View File

@@ -24,7 +24,7 @@ IMetaTransition* CMetaTransFactory::LoadFromStream(IInputStream& rInput, EGame G
return new CMetaTransType4(rInput, Game);
default:
Log::Error("Unrecognized meta-transition type: " + TString::FromInt32(Type, 0, 10));
errorf("Unrecognized meta-transition type: %d", Type);
return nullptr;
}
}

View File

@@ -50,10 +50,10 @@ class CMetaTransTrans : public IMetaTransition
{
EMetaTransitionType mType;
float mUnknownA;
u32 mUnknownB;
uint32 mUnknownB;
bool mUnknownC;
bool mUnknownD;
u32 mUnknownE;
uint32 mUnknownE;
public:
CMetaTransTrans(EMetaTransitionType Type, IInputStream& rInput, EGame Game);

View File

@@ -21,11 +21,11 @@ CGameArea::~CGameArea()
delete mpCollision;
for (u32 iSCLY = 0; iSCLY < mScriptLayers.size(); iSCLY++)
for (uint32 iSCLY = 0; iSCLY < mScriptLayers.size(); iSCLY++)
delete mScriptLayers[iSCLY];
for (u32 iLyr = 0; iLyr < mLightLayers.size(); iLyr++)
for (u32 iLight = 0; iLight < mLightLayers[iLyr].size(); iLight++)
for (uint32 iLyr = 0; iLyr < mLightLayers.size(); iLyr++)
for (uint32 iLight = 0; iLight < mLightLayers[iLyr].size(); iLight++)
delete mLightLayers[iLyr][iLight];
}
@@ -49,13 +49,13 @@ CDependencyTree* CGameArea::BuildDependencyTree() const
}
// Extra deps
for (u32 iDep = 0; iDep < mExtraAreaDeps.size(); iDep++)
for (uint32 iDep = 0; iDep < mExtraAreaDeps.size(); iDep++)
pTree->AddDependency(mExtraAreaDeps[iDep]);
// Layer dependencies
std::vector<CAssetID> DummyDeps;
for (u32 iLayer = 0; iLayer < mScriptLayers.size(); iLayer++)
for (uint32 iLayer = 0; iLayer < mScriptLayers.size(); iLayer++)
{
const std::vector<CAssetID>& rkExtras = (mExtraLayerDeps.size() > iLayer ? mExtraLayerDeps[iLayer] : DummyDeps);
pTree->AddScriptLayer(mScriptLayers[iLayer], rkExtras);
@@ -77,12 +77,12 @@ void CGameArea::MergeTerrain()
if (mTerrainMerged) return;
// Nothing really complicated here - iterate through every terrain submesh, add each to a static model
for (u32 iMdl = 0; iMdl < mWorldModels.size(); iMdl++)
for (uint32 iMdl = 0; iMdl < mWorldModels.size(); iMdl++)
{
CModel *pMdl = mWorldModels[iMdl];
u32 SubmeshCount = pMdl->GetSurfaceCount();
uint32 SubmeshCount = pMdl->GetSurfaceCount();
for (u32 iSurf = 0; iSurf < SubmeshCount; iSurf++)
for (uint32 iSurf = 0; iSurf < SubmeshCount; iSurf++)
{
SSurface *pSurf = pMdl->GetSurface(iSurf);
CMaterial *pMat = mpMaterialSet->MaterialByIndex(pSurf->MaterialID);
@@ -118,11 +118,11 @@ void CGameArea::MergeTerrain()
void CGameArea::ClearTerrain()
{
for (u32 iModel = 0; iModel < mWorldModels.size(); iModel++)
for (uint32 iModel = 0; iModel < mWorldModels.size(); iModel++)
delete mWorldModels[iModel];
mWorldModels.clear();
for (u32 iStatic = 0; iStatic < mStaticWorldModels.size(); iStatic++)
for (uint32 iStatic = 0; iStatic < mStaticWorldModels.size(); iStatic++)
delete mStaticWorldModels[iStatic];
mStaticWorldModels.clear();
@@ -141,26 +141,26 @@ void CGameArea::ClearScriptLayers()
mScriptLayers.clear();
}
u32 CGameArea::TotalInstanceCount() const
uint32 CGameArea::TotalInstanceCount() const
{
u32 Num = 0;
uint32 Num = 0;
for (u32 iLyr = 0; iLyr < mScriptLayers.size(); iLyr++)
for (uint32 iLyr = 0; iLyr < mScriptLayers.size(); iLyr++)
Num += mScriptLayers[iLyr]->NumInstances();
return Num;
}
CScriptObject* CGameArea::InstanceByID(u32 InstanceID)
CScriptObject* CGameArea::InstanceByID(uint32 InstanceID)
{
auto it = mObjectMap.find(InstanceID);
if (it != mObjectMap.end()) return it->second;
else return nullptr;
}
u32 CGameArea::FindUnusedInstanceID() const
uint32 CGameArea::FindUnusedInstanceID() const
{
u32 InstanceID = (mWorldIndex << 16) | 1;
uint32 InstanceID = (mWorldIndex << 16) | 1;
while (true)
{
@@ -180,20 +180,20 @@ CScriptObject* CGameArea::SpawnInstance(CScriptTemplate *pTemplate,
const CVector3f& rkPosition /*= CVector3f::skZero*/,
const CQuaternion& rkRotation /*= CQuaternion::skIdentity*/,
const CVector3f& rkScale /*= CVector3f::skOne*/,
u32 SuggestedID /*= -1*/,
u32 SuggestedLayerIndex /*= -1*/ )
uint32 SuggestedID /*= -1*/,
uint32 SuggestedLayerIndex /*= -1*/ )
{
// Verify we can fit another instance in this area.
u32 NumInstances = TotalInstanceCount();
uint32 NumInstances = TotalInstanceCount();
if (NumInstances >= 0xFFFF)
{
Log::Error("Unable to spawn a new script instance; too many instances in area (" + TString::FromInt32(NumInstances, 0, 10) + ")");
errorf("Unable to spawn a new script instance; too many instances in area (%d)", NumInstances);
return nullptr;
}
// Check whether the suggested instance ID is valid
u32 InstanceID = SuggestedID;
uint32 InstanceID = SuggestedID;
if (InstanceID != -1)
{
@@ -205,11 +205,11 @@ CScriptObject* CGameArea::SpawnInstance(CScriptTemplate *pTemplate,
if (InstanceID == -1)
{
// Determine layer index
u32 LayerIndex = pLayer->AreaIndex();
uint32 LayerIndex = pLayer->AreaIndex();
if (LayerIndex == -1)
{
Log::Error("Unable to spawn a new script instance; invalid script layer passed in");
errorf("Unable to spawn a new script instance; invalid script layer passed in");
return nullptr;
}

View File

@@ -8,9 +8,9 @@
#include "Core/Resource/CPoiToWorld.h"
#include "Core/Resource/Model/CModel.h"
#include "Core/Resource/Model/CStaticModel.h"
#include <Common/types.h>
#include <Math/CQuaternion.h>
#include <Math/CTransform4f.h>
#include <Common/BasicTypes.h>
#include <Common/Math/CQuaternion.h>
#include <Common/Math/CTransform4f.h>
#include <unordered_map>
@@ -24,22 +24,22 @@ class CGameArea : public CResource
friend class CAreaLoader;
friend class CAreaCooker;
u32 mWorldIndex;
u32 mVertexCount;
u32 mTriangleCount;
uint32 mWorldIndex;
uint32 mVertexCount;
uint32 mTriangleCount;
bool mTerrainMerged;
CTransform4f mTransform;
CAABox mAABox;
// Data saved from the original file to help on recook
std::vector<std::vector<u8>> mSectionDataBuffers;
u32 mOriginalWorldMeshCount;
std::vector<std::vector<uint8>> mSectionDataBuffers;
uint32 mOriginalWorldMeshCount;
bool mUsesCompression;
struct SSectionNumber
{
CFourCC SectionID;
u32 Index;
uint32 Index;
};
std::vector<SSectionNumber> mSectionNumbers;
@@ -49,7 +49,7 @@ class CGameArea : public CResource
std::vector<CStaticModel*> mStaticWorldModels; // StaticTerrainModels is the merged terrain for faster rendering in the world editor
// Script
std::vector<CScriptLayer*> mScriptLayers;
std::unordered_map<u32, CScriptObject*> mObjectMap;
std::unordered_map<uint32, CScriptObject*> mObjectMap;
// Collision
CCollisionMeshGroup *mpCollision;
// Lights
@@ -73,38 +73,38 @@ public:
void MergeTerrain();
void ClearTerrain();
void ClearScriptLayers();
u32 TotalInstanceCount() const;
CScriptObject* InstanceByID(u32 InstanceID);
u32 FindUnusedInstanceID() const;
uint32 TotalInstanceCount() const;
CScriptObject* InstanceByID(uint32 InstanceID);
uint32 FindUnusedInstanceID() const;
CScriptObject* SpawnInstance(CScriptTemplate *pTemplate, CScriptLayer *pLayer,
const CVector3f& rkPosition = CVector3f::skZero,
const CQuaternion& rkRotation = CQuaternion::skIdentity,
const CVector3f& rkScale = CVector3f::skOne,
u32 SuggestedID = -1, u32 SuggestedLayerIndex = -1);
uint32 SuggestedID = -1, uint32 SuggestedLayerIndex = -1);
void AddInstanceToArea(CScriptObject *pInstance);
void DeleteInstance(CScriptObject *pInstance);
void ClearExtraDependencies();
// Inline Accessors
inline u32 WorldIndex() const { return mWorldIndex; }
inline CTransform4f Transform() const { return mTransform; }
inline CMaterialSet* Materials() const { return mpMaterialSet; }
inline u32 NumWorldModels() const { return mWorldModels.size(); }
inline u32 NumStaticModels() const { return mStaticWorldModels.size(); }
inline CModel* TerrainModel(u32 iMdl) const { return mWorldModels[iMdl]; }
inline CStaticModel* StaticModel(u32 iMdl) const { return mStaticWorldModels[iMdl]; }
inline CCollisionMeshGroup* Collision() const { return mpCollision; }
inline u32 NumScriptLayers() const { return mScriptLayers.size(); }
inline CScriptLayer* ScriptLayer(u32 Index) const { return mScriptLayers[Index]; }
inline u32 NumLightLayers() const { return mLightLayers.size(); }
inline u32 NumLights(u32 LayerIndex) const { return (LayerIndex < mLightLayers.size() ? mLightLayers[LayerIndex].size() : 0); }
inline CLight* Light(u32 LayerIndex, u32 LightIndex) const { return mLightLayers[LayerIndex][LightIndex]; }
inline CAssetID PathID() const { return mPathID; }
inline CPoiToWorld* PoiToWorldMap() const { return mpPoiToWorldMap; }
inline CAssetID PortalAreaID() const { return mPortalAreaID; }
inline CAABox AABox() const { return mAABox; }
inline uint32 WorldIndex() const { return mWorldIndex; }
inline CTransform4f Transform() const { return mTransform; }
inline CMaterialSet* Materials() const { return mpMaterialSet; }
inline uint32 NumWorldModels() const { return mWorldModels.size(); }
inline uint32 NumStaticModels() const { return mStaticWorldModels.size(); }
inline CModel* TerrainModel(uint32 iMdl) const { return mWorldModels[iMdl]; }
inline CStaticModel* StaticModel(uint32 iMdl) const { return mStaticWorldModels[iMdl]; }
inline CCollisionMeshGroup* Collision() const { return mpCollision; }
inline uint32 NumScriptLayers() const { return mScriptLayers.size(); }
inline CScriptLayer* ScriptLayer(uint32 Index) const { return mScriptLayers[Index]; }
inline uint32 NumLightLayers() const { return mLightLayers.size(); }
inline uint32 NumLights(uint32 LayerIndex) const { return (LayerIndex < mLightLayers.size() ? mLightLayers[LayerIndex].size() : 0); }
inline CLight* Light(uint32 LayerIndex, uint32 LightIndex) const { return mLightLayers[LayerIndex][LightIndex]; }
inline CAssetID PathID() const { return mPathID; }
inline CPoiToWorld* PoiToWorldMap() const { return mpPoiToWorldMap; }
inline CAssetID PortalAreaID() const { return mPortalAreaID; }
inline CAABox AABox() const { return mAABox; }
inline void SetWorldIndex(u32 NewWorldIndex) { mWorldIndex = NewWorldIndex; }
inline void SetWorldIndex(uint32 NewWorldIndex) { mWorldIndex = NewWorldIndex; }
};
#endif // CGAMEAREA_H

View File

@@ -10,8 +10,8 @@ class CAudioGroup : public CResource
friend class CAudioGroupLoader;
TString mGroupName;
u32 mGroupID;
std::vector<u16> mDefineIDs;
uint32 mGroupID;
std::vector<uint16> mDefineIDs;
public:
CAudioGroup(CResourceEntry *pEntry = 0)
@@ -20,10 +20,10 @@ public:
{}
// Accessors
inline TString GroupName() const { return mGroupName; }
inline u32 GroupID() const { return mGroupID; }
inline u32 NumSoundDefineIDs() const { return mDefineIDs.size(); }
inline u16 SoundDefineIDByIndex(u32 Index) const { return mDefineIDs[Index]; }
inline TString GroupName() const { return mGroupName; }
inline uint32 GroupID() const { return mGroupID; }
inline uint32 NumSoundDefineIDs() const { return mDefineIDs.size(); }
inline uint16 SoundDefineIDByIndex(uint32 Index) const { return mDefineIDs[Index]; }
};
#endif // CAUDIOGROUP

View File

@@ -7,14 +7,14 @@ class CAudioLookupTable : public CResource
{
DECLARE_RESOURCE_TYPE(eAudioLookupTable)
friend class CAudioGroupLoader;
std::vector<u16> mDefineIDs;
std::vector<uint16> mDefineIDs;
public:
CAudioLookupTable(CResourceEntry *pEntry = 0)
: CResource(pEntry)
{}
inline u16 FindSoundDefineID(u32 SoundID)
inline uint16 FindSoundDefineID(uint32 SoundID)
{
if (SoundID >= mDefineIDs.size()) return -1;
return mDefineIDs[SoundID];

View File

@@ -20,16 +20,16 @@ public:
{
CDependencyTree *pTree = new CDependencyTree();
for (u32 iSamp = 0; iSamp < mSamples.size(); iSamp++)
for (uint32 iSamp = 0; iSamp < mSamples.size(); iSamp++)
pTree->AddDependency(mSamples[iSamp]);
return pTree;
}
// Accessors
inline TString MacroName() const { return mMacroName; }
inline u32 NumSamples() const { return mSamples.size(); }
inline CAssetID SampleByIndex(u32 Index) const { return mSamples[Index]; }
inline TString MacroName() const { return mMacroName; }
inline uint32 NumSamples() const { return mSamples.size(); }
inline CAssetID SampleByIndex(uint32 Index) const { return mSamples[Index]; }
};
#endif // CAUDIOMACRO_H

View File

@@ -1,5 +1,5 @@
#include "CCollisionMaterial.h"
#include <Common/AssertMacro.h>
#include <Common/Macros.h>
#include <unordered_map>
ECollisionFlag CCollisionMaterial::SurfaceType(EGame Game) const
@@ -19,7 +19,7 @@ ECollisionFlag CCollisionMaterial::SurfaceType(EGame Game) const
// Determine which list we should use.
const ECollisionFlag* pkFlagArray;
u32 Num;
uint32 Num;
if (Game <= EGame::Prime)
{
@@ -33,7 +33,7 @@ ECollisionFlag CCollisionMaterial::SurfaceType(EGame Game) const
}
// Locate type.
for (u32 iType = 0; iType < Num; iType++)
for (uint32 iType = 0; iType < Num; iType++)
{
if (*this & pkFlagArray[iType])
return pkFlagArray[iType];

View File

@@ -51,7 +51,7 @@ enum ECollisionFlag
class CCollisionMaterial : public TFlags<ECollisionFlag>
{
friend class CCollisionLoader;
u64 mRawFlags;
uint64 mRawFlags;
public:
ECollisionFlag SurfaceType(EGame Game) const;
@@ -59,7 +59,7 @@ public:
bool IsFloor() const;
bool IsUnstandable(EGame Game) const;
inline u64 RawFlags() const { return mRawFlags; }
inline uint64 RawFlags() const { return mRawFlags; }
};
#endif // CCOLLISIONMATERIAL

View File

@@ -1,7 +1,7 @@
#include "CCollisionMesh.h"
#include "Core/Render/CRenderer.h"
#include "Core/Render/CDrawUtil.h"
#include <Common/AssertMacro.h>
#include <Common/Macros.h>
CCollisionMesh::CCollisionMesh()
{
@@ -43,11 +43,11 @@ void CCollisionMesh::BufferGL()
mIBO.Reserve(SortedTris.size() * 3);
mMaterialOffsets.reserve(mMaterials.size());
u32 CurMat = 0;
uint32 CurMat = 0;
for (u32 iTri = 0; iTri < SortedTris.size(); iTri++)
for (uint32 iTri = 0; iTri < SortedTris.size(); iTri++)
{
u16 Verts[3];
uint16 Verts[3];
CCollisionFace *pFace = &SortedTris[iTri];
CCollisionLine *pLineA = GetLine(pFace->Lines[0]);
@@ -75,7 +75,7 @@ void CCollisionMesh::BufferGL()
// Some faces have a property that indicates they need to be inverted
if (GetMaterial(pFace->MaterialIdx) & eCF_FlippedTri)
{
u16 V0 = Verts[0];
uint16 V0 = Verts[0];
Verts[0] = Verts[2];
Verts[2] = V0;
}
@@ -89,12 +89,12 @@ void CCollisionMesh::BufferGL()
CVector3f V0toV2 = (rVert2.Pos - rVert0.Pos).Normalized();
CVector3f FaceNormal = V0toV1.Cross(V0toV2).Normalized();
for (u32 iVtx = 0; iVtx < 3; iVtx++)
for (uint32 iVtx = 0; iVtx < 3; iVtx++)
{
CVertex Vtx;
Vtx.Position = mCollisionVertices[ Verts[iVtx] ].Pos;
Vtx.Normal = FaceNormal;
u16 Index = mVBO.AddVertex(Vtx);
uint16 Index = mVBO.AddVertex(Vtx);
mIBO.AddIndex(Index);
}
}
@@ -122,14 +122,14 @@ void CCollisionMesh::Draw()
mVBO.Unbind();
}
void CCollisionMesh::DrawMaterial(u32 MatIdx, bool Wireframe)
void CCollisionMesh::DrawMaterial(uint32 MatIdx, bool Wireframe)
{
if (!mBuffered) BufferGL();
ASSERT(MatIdx < mMaterials.size());
mVBO.Bind();
u32 StartIdx = (MatIdx == 0 ? 0 : mMaterialOffsets[MatIdx - 1]);
u32 NumElements = mMaterialOffsets[MatIdx] - StartIdx;
uint32 StartIdx = (MatIdx == 0 ? 0 : mMaterialOffsets[MatIdx - 1]);
uint32 NumElements = mMaterialOffsets[MatIdx] - StartIdx;
if (Wireframe)
{
@@ -153,17 +153,17 @@ void CCollisionMesh::DrawWireframe()
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
CCollisionMesh::CCollisionVertex* CCollisionMesh::GetVertex(u16 Index)
CCollisionMesh::CCollisionVertex* CCollisionMesh::GetVertex(uint16 Index)
{
return &mCollisionVertices[Index];
}
CCollisionMesh::CCollisionLine* CCollisionMesh::GetLine(u16 Index)
CCollisionMesh::CCollisionLine* CCollisionMesh::GetLine(uint16 Index)
{
return &mCollisionLines[Index];
}
CCollisionMesh::CCollisionFace* CCollisionMesh::GetFace(u16 Index)
CCollisionMesh::CCollisionFace* CCollisionMesh::GetFace(uint16 Index)
{
return &mCollisionFaces[Index];
}

View File

@@ -5,7 +5,7 @@
#include "CResource.h"
#include "Core/OpenGL/CVertexBuffer.h"
#include "Core/OpenGL/CIndexBuffer.h"
#include <Math/CAABox.h>
#include <Common/Math/CAABox.h>
class CCollisionMesh
{
@@ -19,12 +19,12 @@ class CCollisionMesh
struct SLeaf : public SOctreeNode
{
CAABox AABox;
std::vector<u16> FaceIndices;
std::vector<uint16> FaceIndices;
};
struct SBranch : public SOctreeNode
{
u16 Flags;
uint16 Flags;
SOctreeNode *pChildren[8];
};
@@ -34,29 +34,29 @@ class CCollisionMesh
class CCollisionVertex
{
public:
u32 MaterialIdx;
uint32 MaterialIdx;
CVector3f Pos;
};
class CCollisionLine
{
public:
u32 MaterialIdx;
u16 Vertices[2];
uint32 MaterialIdx;
uint16 Vertices[2];
};
class CCollisionFace
{
public:
u32 MaterialIdx;
u16 Lines[3];
uint32 MaterialIdx;
uint16 Lines[3];
};
CVertexBuffer mVBO;
CIndexBuffer mIBO;
u32 mVertexCount;
u32 mLineCount;
u32 mFaceCount;
uint32 mVertexCount;
uint32 mLineCount;
uint32 mFaceCount;
bool mBuffered;
CAABox mAABox;
@@ -65,12 +65,12 @@ class CCollisionMesh
std::vector<CCollisionVertex> mCollisionVertices;
std::vector<CCollisionLine> mCollisionLines;
std::vector<CCollisionFace> mCollisionFaces;
std::vector<u32> mMaterialOffsets;
std::vector<uint32> mMaterialOffsets;
bool mOctreeLoaded;
CCollisionVertex *GetVertex(u16 Index);
CCollisionLine *GetLine(u16 Index);
CCollisionFace *GetFace(u16 Index);
CCollisionVertex *GetVertex(uint16 Index);
CCollisionLine *GetLine(uint16 Index);
CCollisionFace *GetFace(uint16 Index);
public:
CCollisionMesh();
@@ -78,12 +78,12 @@ public:
void BufferGL();
void Draw();
void DrawMaterial(u32 MatIdx, bool Wireframe);
void DrawMaterial(uint32 MatIdx, bool Wireframe);
void DrawWireframe();
inline u32 NumMaterials() const { return mMaterials.size(); }
inline CCollisionMaterial& GetMaterial(u32 Index) { return mMaterials[Index]; }
inline const CAABox& BoundingBox() const { return mAABox; }
inline uint32 NumMaterials() const { return mMaterials.size(); }
inline CCollisionMaterial& GetMaterial(uint32 Index) { return mMaterials[Index]; }
inline const CAABox& BoundingBox() const { return mAABox; }
};
#endif // CCOLLISIONMESH_H

View File

@@ -20,9 +20,9 @@ public:
delete *it;
}
inline u32 NumMeshes() const { return mMeshes.size(); }
inline CCollisionMesh* MeshByIndex(u32 Index) const { return mMeshes[Index]; }
inline void AddMesh(CCollisionMesh *pMesh) { mMeshes.push_back(pMesh); }
inline uint32 NumMeshes() const { return mMeshes.size(); }
inline CCollisionMesh* MeshByIndex(uint32 Index) const { return mMeshes[Index]; }
inline void AddMesh(CCollisionMesh *pMesh) { mMeshes.push_back(pMesh); }
inline void Draw()
{

View File

@@ -12,8 +12,8 @@ public:
CDependencyGroup(CResourceEntry *pEntry = 0) : CResource(pEntry) {}
inline void Clear() { mDependencies.clear(); }
inline u32 NumDependencies() const { return mDependencies.size(); }
inline CAssetID DependencyByIndex(u32 Index) const { return mDependencies[Index]; }
inline uint32 NumDependencies() const { return mDependencies.size(); }
inline CAssetID DependencyByIndex(uint32 Index) const { return mDependencies[Index]; }
inline void AddDependency(const CAssetID& rkID)
{
@@ -41,7 +41,7 @@ public:
bool HasDependency(const CAssetID &rkID) const
{
for (u32 iDep = 0; iDep < mDependencies.size(); iDep++)
for (uint32 iDep = 0; iDep < mDependencies.size(); iDep++)
{
if (mDependencies[iDep] == rkID)
return true;

View File

@@ -15,7 +15,7 @@ CFont::~CFont()
{
}
inline float PtsToFloat(s32 Pt)
inline float PtsToFloat(int32 Pt)
{
// This is a bit of an arbitrary number but it works
// 1 / (1280 / 1.333333f / 2)
@@ -30,7 +30,7 @@ CDependencyTree* CFont::BuildDependencyTree() const
}
CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/, float /*AspectRatio*/,
CVector2f /*Position*/, CColor FillColor, CColor StrokeColor, u32 FontSize)
CVector2f /*Position*/, CColor FillColor, CColor StrokeColor, uint32 FontSize)
{
// WIP
if (!smBuffersInitialized) InitBuffers();
@@ -55,7 +55,7 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
if (FontSize == CFONT_DEFAULT_SIZE) Scale = 1.f;
else Scale = (float) FontSize / (mDefaultSize != 0 ? mDefaultSize : 18);
for (u32 iChar = 0; iChar < rkString.Length(); iChar++)
for (uint32 iChar = 0; iChar < rkString.Length(); iChar++)
{
// Get character, check for newline
char Char = rkString[iChar];
@@ -80,7 +80,7 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
{
if (pPrevGlyph->KerningIndex != -1)
{
for (u32 iKern = pPrevGlyph->KerningIndex; iKern < mKerningTable.size(); iKern++)
for (uint32 iKern = pPrevGlyph->KerningIndex; iKern < mKerningTable.size(); iKern++)
{
if (mKerningTable[iKern].CharacterA != pPrevGlyph->Character) break;
if (mKerningTable[iKern].CharacterB == rkString[iChar])
@@ -110,7 +110,7 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
GlyphTransform.Translate(CVector3f(XTrans, YTrans, 0.f));
// Get glyph layer
u8 GlyphLayer = pGlyph->RGBAChannel;
uint8 GlyphLayer = pGlyph->RGBAChannel;
if (mTextureFormat == 3) GlyphLayer *= 2;
else if (mTextureFormat == 8) GlyphLayer = 3;
@@ -126,7 +126,7 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
// Draw stroke
if ((mTextureFormat == 1) || (mTextureFormat == 3) || (mTextureFormat == 8))
{
u8 StrokeLayer;
uint8 StrokeLayer;
if (mTextureFormat == 1) StrokeLayer = 1;
else if (mTextureFormat == 3) StrokeLayer = GlyphLayer + 1;
else if (mTextureFormat == 8) StrokeLayer = GlyphLayer - 2;

View File

@@ -7,7 +7,7 @@
#include "Core/Resource/Model/CVertex.h"
#include "Core/OpenGL/CDynamicVertexBuffer.h"
#include "Core/OpenGL/CIndexBuffer.h"
#include <Common/types.h>
#include <Common/BasicTypes.h>
#include <string>
#include <unordered_map>
@@ -24,35 +24,35 @@ class CFont : public CResource
static CIndexBuffer smGlyphIndices; // This is the index buffer used to draw glyphs. It uses a triangle strip.
static bool smBuffersInitialized; // This bool indicates whether the vertex/index buffer have been initialized. Checked at the start of RenderString().
u32 mUnknown; // Value at offset 0x8. Not sure what this is. Including for experimentation purposes.
u32 mLineHeight; // Height of each line, in points
u32 mLineMargin; // Gap between lines, in points - this is added to the line height
u32 mVerticalOffset; // In points. This is used to reposition glyphs after the per-glyph vertical offset is applied
u32 mDefaultSize; // In points.
TString mFontName; // Self-explanatory
TResPtr<CTexture> mpFontTexture; // The texture used by this font
u32 mTextureFormat; // Indicates which layers on the texture are for what - multiple glyph layers or fill/stroke
uint32 mUnknown; // Value at offset 0x8. Not sure what this is. Including for experimentation purposes.
uint32 mLineHeight; // Height of each line, in points
uint32 mLineMargin; // Gap between lines, in points - this is added to the line height
uint32 mVerticalOffset; // In points. This is used to reposition glyphs after the per-glyph vertical offset is applied
uint32 mDefaultSize; // In points.
TString mFontName; // Self-explanatory
TResPtr<CTexture> mpFontTexture; // The texture used by this font
uint32 mTextureFormat; // Indicates which layers on the texture are for what - multiple glyph layers or fill/stroke
struct SGlyph
{
u16 Character; // The UTF-16 character that this glyph corresponds to
CVector2f TexCoords[4]; // The format only lists the min/max X/Y values; tracking absolute coordinates in memory is faster
s32 LeftPadding; // The amount of padding applied left of this glyph, in points
s32 RightPadding; // The amount of padding applied right of this glyph, in points
u32 Width; // The width of the glyph, in points
u32 Height; // The height of the glyph, in points
u32 PrintAdvance; // How far the print head advances horizontally after printing this glyph, in points
u32 BaseOffset; // Vertical offset for this glyph, in points; the font-wide offset is added to this
u32 KerningIndex; // Index into the kerning table of the first kerning pair for this glyph. -1 if no pairs.
u8 RGBAChannel; // Fonts can store multiple glyphs in the same space on different RGBA channels. This value corresponds to R, G, B, or A.
uint16 Character; // The UTF-16 character that this glyph corresponds to
CVector2f TexCoords[4]; // The format only lists the min/max X/Y values; tracking absolute coordinates in memory is faster
int32 LeftPadding; // The amount of padding applied left of this glyph, in points
int32 RightPadding; // The amount of padding applied right of this glyph, in points
uint32 Width; // The width of the glyph, in points
uint32 Height; // The height of the glyph, in points
uint32 PrintAdvance; // How far the print head advances horizontally after printing this glyph, in points
uint32 BaseOffset; // Vertical offset for this glyph, in points; the font-wide offset is added to this
uint32 KerningIndex; // Index into the kerning table of the first kerning pair for this glyph. -1 if no pairs.
uint8 RGBAChannel; // Fonts can store multiple glyphs in the same space on different RGBA channels. This value corresponds to R, G, B, or A.
};
std::unordered_map<u16, SGlyph> mGlyphs;
std::unordered_map<uint16, SGlyph> mGlyphs;
struct SKerningPair
{
u16 CharacterA; // Left character
u16 CharacterB; // Right character
s32 Adjust; // The horizontal offset to apply to CharacterB if this pair is encountered, in points
uint16 CharacterA; // Left character
uint16 CharacterB; // Right character
int32 Adjust; // The horizontal offset to apply to CharacterB if this pair is encountered, in points
};
std::vector<SKerningPair> mKerningTable; // The kerning table should be laid out in alphabetical order for the indices to work properly
@@ -64,7 +64,7 @@ public:
CVector2f RenderString(const TString& rkString, CRenderer *pRenderer, float AspectRatio,
CVector2f Position = CVector2f(0,0),
CColor FillColor = CColor::skWhite, CColor StrokeColor = CColor::skBlack,
u32 FontSize = CFONT_DEFAULT_SIZE);
uint32 FontSize = CFONT_DEFAULT_SIZE);
// Accessors
inline TString FontName() const { return mFontName; }

View File

@@ -177,7 +177,7 @@ CStructProperty* CLight::GetProperties() const
// ************ OTHER ************
void CLight::Load() const
{
u8 Index = (u8) CGraphics::sNumLights;
uint8 Index = (uint8) CGraphics::sNumLights;
if (Index >= 8) return;
CGraphics::SLightBlock::SGXLight *pLight = &CGraphics::sLightBlock.Lights[Index];

View File

@@ -4,7 +4,7 @@
#include "Core/Resource/Script/Property/Properties.h"
#include <Common/CColor.h>
#include <Common/FileIO/IInputStream.h>
#include <Math/CVector3f.h>
#include <Common/Math/CVector3f.h>
/* CLight is currently heavily based on the lights system from Metroid Prime,
* including code reverse engineered from the game's executable. Not yet sure
@@ -20,7 +20,7 @@ enum ELightType
class CLight
{
ELightType mType;
u32 mLayerIndex;
uint32 mLayerIndex;
CVector3f mPosition;
CVector3f mDirection;
CColor mColor;
@@ -30,7 +30,7 @@ class CLight
mutable float mCachedRadius;
mutable float mCachedIntensity;
mutable u8 mDirtyFlags;
mutable uint8 mDirtyFlags;
public:
CLight();
@@ -44,14 +44,14 @@ private:
public:
// Accessors
inline ELightType Type() const { return mType; }
inline u32 LayerIndex() const { return mLayerIndex; }
inline uint32 LayerIndex() const { return mLayerIndex; }
inline CVector3f Position() const { return mPosition; }
inline CVector3f Direction() const { return mDirection; }
inline CColor Color() const { return mColor; }
inline CVector3f DistAttenuation() const { return mDistAttenCoefficients; }
inline CVector3f AngleAttenuation() const { return mAngleAttenCoefficients; }
inline void SetLayer(u32 Index) { mLayerIndex = Index; }
inline void SetLayer(uint32 Index) { mLayerIndex = Index; }
inline void SetPosition(const CVector3f& rkPosition) { mPosition = rkPosition; }
inline void SetDirection(const CVector3f& rkDirection) { mDirection = rkDirection; }

View File

@@ -9,9 +9,9 @@
#include <iostream>
#include <GL/glew.h>
u64 CMaterial::sCurrentMaterial = 0;
uint64 CMaterial::sCurrentMaterial = 0;
CColor CMaterial::sCurrentTint = CColor::skWhite;
std::map<u64, CMaterial::SMaterialShader> CMaterial::smShaderMap;
std::map<uint64, CMaterial::SMaterialShader> CMaterial::smShaderMap;
CMaterial::CMaterial()
: mpShader(nullptr)
@@ -62,7 +62,7 @@ CMaterial::CMaterial(EGame Version, FVertexDescription VtxDesc)
CMaterial::~CMaterial()
{
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
for (uint32 iPass = 0; iPass < mPasses.size(); iPass++)
delete mPasses[iPass];
ClearShader();
@@ -76,7 +76,7 @@ CMaterial* CMaterial::Clone()
pOut->mVersion = mVersion;
pOut->mOptions = mOptions;
pOut->mVtxDesc = mVtxDesc;
for (u32 iKonst = 0; iKonst < 4; iKonst++)
for (uint32 iKonst = 0; iKonst < 4; iKonst++)
pOut->mKonstColors[iKonst] = mKonstColors[iKonst];
pOut->mBlendSrcFac = mBlendSrcFac;
pOut->mBlendDstFac = mBlendDstFac;
@@ -86,7 +86,7 @@ CMaterial* CMaterial::Clone()
pOut->mpIndirectTexture = mpIndirectTexture;
pOut->mPasses.resize(mPasses.size());
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
for (uint32 iPass = 0; iPass < mPasses.size(); iPass++)
pOut->mPasses[iPass] = mPasses[iPass]->Clone(pOut);
return pOut;
@@ -193,7 +193,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
// Set konst inputs
for (u32 iKonst = 0; iKonst < 4; iKonst++)
for (uint32 iKonst = 0; iKonst < 4; iKonst++)
CGraphics::sPixelBlock.Konst[iKonst] = mKonstColors[iKonst];
// Set color channels
@@ -205,7 +205,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
else glDepthMask(GL_FALSE);
// Load uniforms
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
for (uint32 iPass = 0; iPass < mPasses.size(); iPass++)
mPasses[iPass]->SetAnimCurrent(Options, iPass);
sCurrentMaterial = HashParameters();
@@ -214,7 +214,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
// If the passes are otherwise the same, update UV anims that use the model matrix
else
{
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
for (uint32 iPass = 0; iPass < mPasses.size(); iPass++)
{
EUVAnimMode mode = mPasses[iPass]->AnimMode();
@@ -225,7 +225,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
}
// Set up shader uniforms
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
for (uint32 iPass = 0; iPass < mPasses.size(); iPass++)
mPasses[iPass]->LoadTexture(iPass);
CShader *pShader = CShader::CurrentShader();
@@ -239,7 +239,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
return true;
}
u64 CMaterial::HashParameters()
uint64 CMaterial::HashParameters()
{
if (mRecalcHash)
{
@@ -255,10 +255,10 @@ u64 CMaterial::HashParameters()
Hash.HashLong(mEchoesUnknownA);
Hash.HashLong(mEchoesUnknownB);
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
for (uint32 iPass = 0; iPass < mPasses.size(); iPass++)
mPasses[iPass]->HashParameters(Hash);
u64 NewHash = Hash.GetHash64();
uint64 NewHash = Hash.GetHash64();
if (mParametersHash != NewHash)
ClearShader();
@@ -276,20 +276,20 @@ void CMaterial::Update()
mShaderStatus = eNoShader;
}
void CMaterial::SetNumPasses(u32 NumPasses)
void CMaterial::SetNumPasses(uint32 NumPasses)
{
if (NumPasses < mPasses.size())
{
for (u32 iPass = NumPasses; iPass < mPasses.size(); iPass++)
for (uint32 iPass = NumPasses; iPass < mPasses.size(); iPass++)
delete mPasses[iPass];
}
u32 OldCount = mPasses.size();
uint32 OldCount = mPasses.size();
mPasses.resize(NumPasses);
if (NumPasses > OldCount)
{
for (u32 iPass = OldCount; iPass < NumPasses; iPass++)
for (uint32 iPass = OldCount; iPass < NumPasses; iPass++)
mPasses[iPass] = new CMaterialPass(this);
}

View File

@@ -8,10 +8,10 @@
#include "Core/Render/FRenderOptions.h"
#include "Core/OpenGL/CShader.h"
#include <Common/BasicTypes.h>
#include <Common/CColor.h>
#include <Common/EGame.h>
#include <Common/Flags.h>
#include <Common/types.h>
#include <Common/FileIO/IInputStream.h>
class CMaterialSet;
@@ -48,14 +48,14 @@ private:
};
// Statics
static u64 sCurrentMaterial; // The hash for the currently bound material
static uint64 sCurrentMaterial; // The hash for the currently bound material
static CColor sCurrentTint; // The tint for the currently bound material
// Members
TString mName; // Name of the material
CShader *mpShader; // This material's generated shader. Created with GenerateShader().
EShaderStatus mShaderStatus; // A status variable so that PWE won't crash if a shader fails to compile.
u64 mParametersHash; // A hash of all the parameters that can identify this TEV setup.
uint64 mParametersHash; // A hash of all the parameters that can identify this TEV setup.
bool mRecalcHash; // Indicates the hash needs to be recalculated. Set true when parameters are changed.
bool mEnableBloom; // Bool that toggles bloom on or off. On by default on MP3 materials, off by default on MP1 materials.
@@ -66,8 +66,8 @@ private:
GLenum mBlendSrcFac; // Source blend factor
GLenum mBlendDstFac; // Dest blend factor
bool mLightingEnabled; // Color channel control flags; indicate whether lighting is enabled
u32 mEchoesUnknownA; // First unknown value introduced in Echoes. Included for cooking.
u32 mEchoesUnknownB; // Second unknown value introduced in Echoes. Included for cooking.
uint32 mEchoesUnknownA; // First unknown value introduced in Echoes. Included for cooking.
uint32 mEchoesUnknownB; // Second unknown value introduced in Echoes. Included for cooking.
TResPtr<CTexture> mpIndirectTexture; // Optional texture used for the indirect stage for reflections
std::vector<CMaterialPass*> mPasses;
@@ -78,7 +78,7 @@ private:
int NumReferences;
CShader *pShader;
};
static std::map<u64, SMaterialShader> smShaderMap;
static std::map<uint64, SMaterialShader> smShaderMap;
public:
CMaterial();
@@ -89,30 +89,30 @@ public:
void GenerateShader(bool AllowRegen = true);
void ClearShader();
bool SetCurrent(FRenderOptions Options);
u64 HashParameters();
uint64 HashParameters();
void Update();
void SetNumPasses(u32 NumPasses);
void SetNumPasses(uint32 NumPasses);
// Accessors
inline TString Name() const { return mName; }
inline EGame Version() const { return mVersion; }
inline FMaterialOptions Options() const { return mOptions; }
inline FVertexDescription VtxDesc() const { return mVtxDesc; }
inline GLenum BlendSrcFac() const { return mBlendSrcFac; }
inline GLenum BlendDstFac() const { return mBlendDstFac; }
inline CColor Konst(u32 KIndex) const { return mKonstColors[KIndex]; }
inline CTexture* IndTexture() const { return mpIndirectTexture; }
inline bool IsLightingEnabled() const { return mLightingEnabled; }
inline u32 EchoesUnknownA() const { return mEchoesUnknownA; }
inline u32 EchoesUnknownB() const { return mEchoesUnknownB; }
inline u32 PassCount() const { return mPasses.size(); }
inline CMaterialPass* Pass(u32 PassIndex) const { return mPasses[PassIndex]; }
inline TString Name() const { return mName; }
inline EGame Version() const { return mVersion; }
inline FMaterialOptions Options() const { return mOptions; }
inline FVertexDescription VtxDesc() const { return mVtxDesc; }
inline GLenum BlendSrcFac() const { return mBlendSrcFac; }
inline GLenum BlendDstFac() const { return mBlendDstFac; }
inline CColor Konst(uint32 KIndex) const { return mKonstColors[KIndex]; }
inline CTexture* IndTexture() const { return mpIndirectTexture; }
inline bool IsLightingEnabled() const { return mLightingEnabled; }
inline uint32 EchoesUnknownA() const { return mEchoesUnknownA; }
inline uint32 EchoesUnknownB() const { return mEchoesUnknownB; }
inline uint32 PassCount() const { return mPasses.size(); }
inline CMaterialPass* Pass(uint32 PassIndex) const { return mPasses[PassIndex]; }
inline void SetName(const TString& rkName) { mName = rkName; }
inline void SetOptions(FMaterialOptions Options) { mOptions = Options; Update(); }
inline void SetVertexDescription(FVertexDescription Desc) { mVtxDesc = Desc; Update(); }
inline void SetBlendMode(GLenum SrcFac, GLenum DstFac) { mBlendSrcFac = SrcFac; mBlendDstFac = DstFac; mRecalcHash = true; }
inline void SetKonst(const CColor& Konst, u32 KIndex) { mKonstColors[KIndex] = Konst; Update(); }
inline void SetKonst(const CColor& Konst, uint32 KIndex) { mKonstColors[KIndex] = Konst; Update(); }
inline void SetIndTexture(CTexture *pTex) { mpIndirectTexture = pTex; }
inline void SetLightingEnabled(bool Enabled) { mLightingEnabled = Enabled; Update(); }

View File

@@ -17,7 +17,7 @@ CMaterialPass::CMaterialPass(CMaterial *pParent)
, mTexCoordSource(0xFF)
, mAnimMode(eNoUVAnim)
{
for (u32 iParam = 0; iParam < 4; iParam++)
for (uint32 iParam = 0; iParam < 4; iParam++)
{
mColorInputs[iParam] = eZeroRGB;
mAlphaInputs[iParam] = eZeroAlpha;
@@ -35,7 +35,7 @@ CMaterialPass* CMaterialPass::Clone(CMaterial *pParent)
pOut->mPassType = mPassType;
pOut->mSettings = mSettings;
for (u32 iIn = 0; iIn < 4; iIn++)
for (uint32 iIn = 0; iIn < 4; iIn++)
{
pOut->mColorInputs[iIn] = mColorInputs[iIn];
pOut->mAlphaInputs[iIn] = mAlphaInputs[iIn];
@@ -50,7 +50,7 @@ CMaterialPass* CMaterialPass::Clone(CMaterial *pParent)
pOut->mpTexture = mpTexture;
pOut->mAnimMode = mAnimMode;
for (u32 iParam = 0; iParam < 4; iParam++)
for (uint32 iParam = 0; iParam < 4; iParam++)
pOut->mAnimParams[iParam] = mAnimParams[iParam];
pOut->mEnabled = mEnabled;
@@ -78,13 +78,13 @@ void CMaterialPass::HashParameters(CFNV1A& rHash)
}
}
void CMaterialPass::LoadTexture(u32 PassIndex)
void CMaterialPass::LoadTexture(uint32 PassIndex)
{
if (mpTexture)
mpTexture->Bind(PassIndex);
}
void CMaterialPass::SetAnimCurrent(FRenderOptions Options, u32 PassIndex)
void CMaterialPass::SetAnimCurrent(FRenderOptions Options, uint32 PassIndex)
{
if (mAnimMode == eNoUVAnim) return;
@@ -269,7 +269,7 @@ void CMaterialPass::SetRasSel(ETevRasSel Sel)
mpParentMat->Update();
}
void CMaterialPass::SetTexCoordSource(u32 Source)
void CMaterialPass::SetTexCoordSource(uint32 Source)
{
mTexCoordSource = Source;
mpParentMat->Update();
@@ -286,7 +286,7 @@ void CMaterialPass::SetAnimMode(EUVAnimMode Mode)
mpParentMat->Update();
}
void CMaterialPass::SetAnimParam(u32 ParamIndex, float Value)
void CMaterialPass::SetAnimParam(uint32 ParamIndex, float Value)
{
mAnimParams[ParamIndex] = Value;
}

View File

@@ -35,7 +35,7 @@ private:
ETevKSel mKColorSel;
ETevKSel mKAlphaSel;
ETevRasSel mRasSel;
u32 mTexCoordSource; // Should maybe be an enum but worried about conflicts with EVertexDescriptionn
uint32 mTexCoordSource; // Should maybe be an enum but worried about conflicts with EVertexDescriptionn
TResPtr<CTexture> mpTexture;
EUVAnimMode mAnimMode;
float mAnimParams[4];
@@ -46,8 +46,8 @@ public:
~CMaterialPass();
CMaterialPass* Clone(CMaterial *pParent);
void HashParameters(CFNV1A& rHash);
void LoadTexture(u32 PassIndex);
void SetAnimCurrent(FRenderOptions Options, u32 PassIndex);
void LoadTexture(uint32 PassIndex);
void SetAnimCurrent(FRenderOptions Options, uint32 PassIndex);
// Setters
void SetType(CFourCC Type);
@@ -58,27 +58,27 @@ public:
void SetKColorSel(ETevKSel Sel);
void SetKAlphaSel(ETevKSel Sel);
void SetRasSel(ETevRasSel Sel);
void SetTexCoordSource(u32 Source);
void SetTexCoordSource(uint32 Source);
void SetTexture(CTexture *pTex);
void SetAnimMode(EUVAnimMode Mode);
void SetAnimParam(u32 ParamIndex, float Value);
void SetAnimParam(uint32 ParamIndex, float Value);
void SetEnabled(bool Enabled);
// Getters
inline CFourCC Type() const { return mPassType; }
inline TString NamedType() const { return PassTypeName(mPassType); }
inline ETevColorInput ColorInput(u32 Input) const { return mColorInputs[Input]; }
inline ETevAlphaInput AlphaInput(u32 Input) const { return mAlphaInputs[Input]; }
inline ETevOutput ColorOutput() const { return mColorOutput; }
inline ETevOutput AlphaOutput() const { return mAlphaOutput; }
inline ETevKSel KColorSel() const { return mKColorSel; }
inline ETevKSel KAlphaSel() const { return mKAlphaSel; }
inline ETevRasSel RasSel() const { return mRasSel; }
inline u32 TexCoordSource() const { return mTexCoordSource; }
inline CTexture* Texture() const { return mpTexture; }
inline EUVAnimMode AnimMode() const { return mAnimMode; }
inline float AnimParam(u32 ParamIndex) const { return mAnimParams[ParamIndex]; }
inline bool IsEnabled() const { return mEnabled; }
inline CFourCC Type() const { return mPassType; }
inline TString NamedType() const { return PassTypeName(mPassType); }
inline ETevColorInput ColorInput(uint32 Input) const { return mColorInputs[Input]; }
inline ETevAlphaInput AlphaInput(uint32 Input) const { return mAlphaInputs[Input]; }
inline ETevOutput ColorOutput() const { return mColorOutput; }
inline ETevOutput AlphaOutput() const { return mAlphaOutput; }
inline ETevKSel KColorSel() const { return mKColorSel; }
inline ETevKSel KAlphaSel() const { return mKAlphaSel; }
inline ETevRasSel RasSel() const { return mRasSel; }
inline uint32 TexCoordSource() const { return mTexCoordSource; }
inline CTexture* Texture() const { return mpTexture; }
inline EUVAnimMode AnimMode() const { return mAnimMode; }
inline float AnimParam(uint32 ParamIndex) const { return mAnimParams[ParamIndex]; }
inline bool IsEnabled() const { return mEnabled; }
// Static
static TString PassTypeName(CFourCC Type);

View File

@@ -18,7 +18,7 @@ public:
~CMaterialSet()
{
for (u32 iMat = 0; iMat < mMaterials.size(); iMat++)
for (uint32 iMat = 0; iMat < mMaterials.size(); iMat++)
delete mMaterials[iMat];
}
@@ -27,18 +27,18 @@ public:
CMaterialSet *pOut = new CMaterialSet();
pOut->mMaterials.resize(mMaterials.size());
for (u32 iMat = 0; iMat < mMaterials.size(); iMat++)
for (uint32 iMat = 0; iMat < mMaterials.size(); iMat++)
pOut->mMaterials[iMat] = mMaterials[iMat]->Clone();
return pOut;
}
u32 NumMaterials()
uint32 NumMaterials()
{
return mMaterials.size();
}
CMaterial* MaterialByIndex(u32 Index)
CMaterial* MaterialByIndex(uint32 Index)
{
if (Index >= NumMaterials()) return nullptr;
return mMaterials[Index];
@@ -52,9 +52,9 @@ public:
return nullptr;
}
u32 MaterialIndexByName(const TString& rkName)
uint32 MaterialIndexByName(const TString& rkName)
{
for (u32 iMat = 0; iMat < mMaterials.size(); iMat++)
for (uint32 iMat = 0; iMat < mMaterials.size(); iMat++)
if (mMaterials[iMat]->Name() == rkName) return iMat;
return -1;
@@ -62,12 +62,12 @@ public:
void GetUsedTextureIDs(std::set<CAssetID>& rOut)
{
for (u32 iMat = 0; iMat < mMaterials.size(); iMat++)
for (uint32 iMat = 0; iMat < mMaterials.size(); iMat++)
{
CMaterial *pMat = mMaterials[iMat];
if (pMat->IndTexture()) rOut.insert(pMat->IndTexture()->ID());
for (u32 iPass = 0; iPass < pMat->PassCount(); iPass++)
for (uint32 iPass = 0; iPass < pMat->PassCount(); iPass++)
{
CTexture *pTex = pMat->Pass(iPass)->Texture();
if (pTex) rOut.insert(pTex->ID());

View File

@@ -11,7 +11,7 @@ CPoiToWorld::~CPoiToWorld()
delete *it;
}
void CPoiToWorld::AddPoi(u32 PoiID)
void CPoiToWorld::AddPoi(uint32 PoiID)
{
// Check if this POI already exists
auto it = mPoiLookupMap.find(PoiID);
@@ -26,7 +26,7 @@ void CPoiToWorld::AddPoi(u32 PoiID)
}
}
void CPoiToWorld::AddPoiMeshMap(u32 PoiID, u32 ModelID)
void CPoiToWorld::AddPoiMeshMap(uint32 PoiID, uint32 ModelID)
{
// Make sure the POI exists; the add function won't do anything if it does
AddPoi(PoiID);
@@ -43,7 +43,7 @@ void CPoiToWorld::AddPoiMeshMap(u32 PoiID, u32 ModelID)
pMap->ModelIDs.push_back(ModelID);
}
void CPoiToWorld::RemovePoi(u32 PoiID)
void CPoiToWorld::RemovePoi(uint32 PoiID)
{
for (auto it = mMaps.begin(); it != mMaps.end(); it++)
{
@@ -56,7 +56,7 @@ void CPoiToWorld::RemovePoi(u32 PoiID)
}
}
void CPoiToWorld::RemovePoiMeshMap(u32 PoiID, u32 ModelID)
void CPoiToWorld::RemovePoiMeshMap(uint32 PoiID, uint32 ModelID)
{
auto MapIt = mPoiLookupMap.find(PoiID);

View File

@@ -13,34 +13,34 @@ class CPoiToWorld : public CResource
public:
struct SPoiMap
{
u32 PoiID;
std::list<u32> ModelIDs;
uint32 PoiID;
std::list<uint32> ModelIDs;
};
private:
std::vector<SPoiMap*> mMaps;
std::map<u32,SPoiMap*> mPoiLookupMap;
std::map<uint32,SPoiMap*> mPoiLookupMap;
public:
CPoiToWorld(CResourceEntry *pEntry = 0);
~CPoiToWorld();
void AddPoi(u32 PoiID);
void AddPoiMeshMap(u32 PoiID, u32 ModelID);
void RemovePoi(u32 PoiID);
void RemovePoiMeshMap(u32 PoiID, u32 ModelID);
void AddPoi(uint32 PoiID);
void AddPoiMeshMap(uint32 PoiID, uint32 ModelID);
void RemovePoi(uint32 PoiID);
void RemovePoiMeshMap(uint32 PoiID, uint32 ModelID);
inline u32 NumMappedPOIs() const
inline uint32 NumMappedPOIs() const
{
return mMaps.size();
}
inline const SPoiMap* MapByIndex(u32 Index) const
inline const SPoiMap* MapByIndex(uint32 Index) const
{
return mMaps[Index];
}
inline const SPoiMap* MapByID(u32 InstanceID) const
inline const SPoiMap* MapByID(uint32 InstanceID) const
{
auto it = mPoiLookupMap.find(InstanceID);
@@ -50,7 +50,7 @@ public:
return nullptr;
}
bool HasPoiMappings(u32 InstanceID) const
bool HasPoiMappings(uint32 InstanceID) const
{
auto it = mPoiLookupMap.find(InstanceID);
return (it != mPoiLookupMap.end());

View File

@@ -1,5 +1,5 @@
#include "CResTypeInfo.h"
#include <Common/AssertMacro.h>
#include <Common/Macros.h>
#include <algorithm>
std::unordered_map<EResType, CResTypeInfo*> CResTypeInfo::smTypeMap;
@@ -19,7 +19,7 @@ CResTypeInfo::CResTypeInfo(EResType Type, const TString& rkTypeName, const TStri
bool CResTypeInfo::IsInGame(EGame Game) const
{
for (u32 iGame = 0; iGame < mCookedExtensions.size(); iGame++)
for (uint32 iGame = 0; iGame < mCookedExtensions.size(); iGame++)
{
if (mCookedExtensions[iGame].Game == Game)
return true;
@@ -33,7 +33,7 @@ CFourCC CResTypeInfo::CookedExtension(EGame Game) const
if (Game == EGame::Invalid)
Game = EGame::Prime;
for (u32 iGame = 0; iGame < mCookedExtensions.size(); iGame++)
for (uint32 iGame = 0; iGame < mCookedExtensions.size(); iGame++)
{
if (mCookedExtensions[iGame].Game == Game)
return mCookedExtensions[iGame].CookedExt;
@@ -90,7 +90,7 @@ CResTypeInfo* CResTypeInfo::TypeForCookedExtension(EGame Game, CFourCC Ext)
// Note UNKN is used to indicate unknown asset type
if (Ext != FOURCC('UNKN'))
{
Log::Error("Failed to find resource type for cooked extension: " + Ext.ToString());
errorf("Failed to find resource type for cooked extension: %s", *Ext.ToString());
DEBUG_BREAK;
}
sCachedTypeMap[Ext] = nullptr;

View File

@@ -8,7 +8,6 @@
#include "Core/GameProject/CResourceStore.h"
#include <Common/CAssetID.h>
#include <Common/CFourCC.h>
#include <Common/types.h>
#include <Common/TString.h>
#include <Common/Serialization/IArchive.h>

View File

@@ -6,7 +6,7 @@
// GUID representing a value stored in the save file for MP3/DKCR
class CSavedStateID
{
u64 m[2];
uint64 m[2];
public:
CSavedStateID()
@@ -15,7 +15,7 @@ public:
m[1] = 0;
}
CSavedStateID(u64 Part1, u64 Part2)
CSavedStateID(uint64 Part1, uint64 Part2)
{
m[0] = Part1;
m[1] = Part2;
@@ -29,12 +29,12 @@ public:
TString ToString()
{
u32 Part1 = (m[0] >> 32) & 0xFFFFFFFF;
u32 Part2 = (m[0] >> 16) & 0x0000FFFF;
u32 Part3 = (m[0] >> 00) & 0x0000FFFF;
u32 Part4 = (m[1] >> 48) & 0x0000FFFF;
u32 Part5 = (m[1] >> 32) & 0x0000FFFF;
u32 Part6 = (m[1] >> 00) & 0xFFFFFFFF;
uint32 Part1 = (m[0] >> 32) & 0xFFFFFFFF;
uint32 Part2 = (m[0] >> 16) & 0x0000FFFF;
uint32 Part3 = (m[0] >> 00) & 0x0000FFFF;
uint32 Part4 = (m[1] >> 48) & 0x0000FFFF;
uint32 Part5 = (m[1] >> 32) & 0x0000FFFF;
uint32 Part6 = (m[1] >> 00) & 0xFFFFFFFF;
return TString::Format("%08X-%04X-%04X-%04X-%04X%08X", Part1, Part2, Part3, Part4, Part5, Part6);
}
@@ -83,8 +83,7 @@ public:
ASSERT(Str.Size() == 32);
CSavedStateID Out;
Out.m[0] = Str.SubString(0, 16).ToInt64(16);
Out.m[1] = Str.SubString(16, 16).ToInt64(16);
Str.ToInt128(&Out.m[0]);
return Out;
}

View File

@@ -71,7 +71,7 @@ public:
// Corruption's SCAN has a list of all assets - just grab that
if (Game() >= EGame::CorruptionProto)
{
for (u32 iDep = 0; iDep < mDependencyList.size(); iDep++)
for (uint32 iDep = 0; iDep < mDependencyList.size(); iDep++)
{
pTree->AddDependency(mDependencyList[iDep]);
}
@@ -87,7 +87,7 @@ public:
if (Game() <= EGame::Prime)
{
for (u32 iImg = 0; iImg < 4; iImg++)
for (uint32 iImg = 0; iImg < 4; iImg++)
pTree->AddDependency(mScanImageTextures[iImg]);
}
@@ -98,7 +98,7 @@ public:
pTree->AddCharacterDependency(mLogbookAnimParams);
pTree->AddCharacterDependency(mUnknownAnimParams);
for (u32 iSec = 0; iSec < mSecondaryModels.size(); iSec++)
for (uint32 iSec = 0; iSec < mSecondaryModels.size(); iSec++)
{
const SScanInfoSecondaryModel& rkSecModel = mSecondaryModels[iSec];
pTree->AddDependency(rkSecModel.ModelID);
@@ -110,13 +110,13 @@ public:
}
// Accessors
inline CStringTable* ScanText() const { return mpStringTable; }
inline bool IsImportant() const { return mIsImportant; }
inline bool IsSlow() const { return mIsSlow; }
inline ELogbookCategory LogbookCategory() const { return mCategory; }
inline CAssetID GuiFrame() const { return mFrameID; }
inline CAssetID ScanImage(u32 ImgIndex) const { return mScanImageTextures[ImgIndex]; }
inline CAssetID LogbookDisplayAssetID() const { return (mLogbookAnimParams.ID().IsValid() ? mLogbookAnimParams.ID() : mLogbookModel); }
inline CStringTable* ScanText() const { return mpStringTable; }
inline bool IsImportant() const { return mIsImportant; }
inline bool IsSlow() const { return mIsSlow; }
inline ELogbookCategory LogbookCategory() const { return mCategory; }
inline CAssetID GuiFrame() const { return mFrameID; }
inline CAssetID ScanImage(uint32 ImgIndex) const { return mScanImageTextures[ImgIndex]; }
inline CAssetID LogbookDisplayAssetID() const { return (mLogbookAnimParams.ID().IsValid() ? mLogbookAnimParams.ID() : mLogbookModel); }
};
#endif // CSCAN_H

View File

@@ -14,12 +14,12 @@ public:
: CResource(pEntry)
{}
inline u32 NumStrings() const
inline uint32 NumStrings() const
{
return mStringList.size();
}
inline TString StringByIndex(u32 Index) const
inline TString StringByIndex(uint32 Index) const
{
ASSERT(Index >= 0 && Index < mStringList.size());
return mStringList[Index];

View File

@@ -2,9 +2,9 @@
#define CSTRINGTABLE_H
#include "CResource.h"
#include <Common/BasicTypes.h>
#include <Common/CFourCC.h>
#include <Common/TString.h>
#include <Common/types.h>
#include <vector>
class CStringTable : public CResource
@@ -13,7 +13,7 @@ class CStringTable : public CResource
friend class CStringLoader;
std::vector<TString> mStringNames;
u32 mNumStrings;
uint32 mNumStrings;
struct SLangTable
{
@@ -25,15 +25,15 @@ class CStringTable : public CResource
public:
CStringTable(CResourceEntry *pEntry = 0) : CResource(pEntry) {}
inline u32 NumStrings() const { return mNumStrings; }
inline u32 NumLanguages() const { return mLangTables.size(); }
inline CFourCC LanguageTag(u32 Index) const { return mLangTables[Index].Language; }
inline TString String(u32 LangIndex, u32 StringIndex) const { return mLangTables[LangIndex].Strings[StringIndex]; }
inline TString StringName(u32 StringIndex) const { return mStringNames[StringIndex]; }
inline uint32 NumStrings() const { return mNumStrings; }
inline uint32 NumLanguages() const { return mLangTables.size(); }
inline CFourCC LanguageTag(uint32 Index) const { return mLangTables[Index].Language; }
inline TString String(uint32 LangIndex, uint32 StringIndex) const { return mLangTables[LangIndex].Strings[StringIndex]; }
inline TString StringName(uint32 StringIndex) const { return mStringNames[StringIndex]; }
TString String(CFourCC Lang, u32 StringIndex) const
TString String(CFourCC Lang, uint32 StringIndex) const
{
for (u32 iLang = 0; iLang < NumLanguages(); iLang++)
for (uint32 iLang = 0; iLang < NumLanguages(); iLang++)
{
if (LanguageTag(iLang) == Lang)
return String(iLang, StringIndex);
@@ -48,15 +48,15 @@ public:
CDependencyTree *pTree = new CDependencyTree();
EIDLength IDLength = (Game() <= EGame::Echoes ? e32Bit : e64Bit);
for (u32 iLang = 0; iLang < mLangTables.size(); iLang++)
for (uint32 iLang = 0; iLang < mLangTables.size(); iLang++)
{
const SLangTable& rkTable = mLangTables[iLang];
for (u32 iStr = 0; iStr < rkTable.Strings.size(); iStr++)
for (uint32 iStr = 0; iStr < rkTable.Strings.size(); iStr++)
{
const TString& rkStr = rkTable.Strings[iStr];
for (u32 TagIdx = rkStr.IndexOf('&'); TagIdx != -1; TagIdx = rkStr.IndexOf('&', TagIdx + 1))
for (uint32 TagIdx = rkStr.IndexOf('&'); TagIdx != -1; TagIdx = rkStr.IndexOf('&', TagIdx + 1))
{
// Check for double ampersand (escape character in DKCR, not sure about other games)
if (rkStr.At(TagIdx + 1) == '&')
@@ -66,8 +66,8 @@ public:
}
// Get tag name and parameters
u32 NameEnd = rkStr.IndexOf('=', TagIdx);
u32 TagEnd = rkStr.IndexOf(';', TagIdx);
uint32 NameEnd = rkStr.IndexOf('=', TagIdx);
uint32 TagEnd = rkStr.IndexOf(';', TagIdx);
if (NameEnd == -1 || TagEnd == -1) continue;
TString TagName = rkStr.SubString(TagIdx + 1, NameEnd - TagIdx - 1);
@@ -93,7 +93,7 @@ public:
// Determine which params are textures based on image type
TStringList Params = ParamString.Split(",");
TString ImageType = Params.front();
u32 TexturesStart = -1;
uint32 TexturesStart = -1;
if (ImageType == "A")
TexturesStart = 2;
@@ -112,15 +112,14 @@ public:
else
{
Log::Error("Unrecognized image type: " + ImageType);
DEBUG_BREAK;
errorf("Unrecognized image type: %s", *ImageType);
continue;
}
// Load texture IDs
TStringList::iterator Iter = Params.begin();
for (u32 iParam = 0; iParam < Params.size(); iParam++, Iter++)
for (uint32 iParam = 0; iParam < Params.size(); iParam++, Iter++)
{
if (iParam >= TexturesStart)
{
@@ -149,7 +148,7 @@ public:
TString Out = rkStr;
int TagStart = -1;
for (u32 iChr = 0; iChr < Out.Size(); iChr++)
for (uint32 iChr = 0; iChr < Out.Size(); iChr++)
{
if (Out[iChr] == '&')
{

View File

@@ -16,11 +16,11 @@ CTexture::CTexture(CResourceEntry *pEntry /*= 0*/)
{
}
CTexture::CTexture(u32 Width, u32 Height)
CTexture::CTexture(uint32 Width, uint32 Height)
: mTexelFormat(eRGBA8)
, mSourceTexelFormat(eRGBA8)
, mWidth((u16) Width)
, mHeight((u16) Height)
, mWidth((uint16) Width)
, mHeight((uint16) Height)
, mNumMipMaps(1)
, mLinearSize(Width * Height * 4)
, mEnableMultisampling(false)
@@ -75,11 +75,11 @@ bool CTexture::BufferGL()
// The smallest mipmaps are probably not being loaded correctly, because mipmaps in GX textures have a minimum size depending on the format, and these don't.
// Not sure specifically what accomodations should be made to fix that though so whatever.
u32 MipSize = mLinearSize;
u32 MipOffset = 0;
u16 MipW = mWidth, MipH = mHeight;
uint32 MipSize = mLinearSize;
uint32 MipOffset = 0;
uint16 MipW = mWidth, MipH = mHeight;
for (u32 iMip = 0; iMip < mNumMipMaps; iMip++)
for (uint32 iMip = 0; iMip < mNumMipMaps; iMip++)
{
GLvoid *pData = (mBufferExists) ? (mpImgDataBuffer + MipOffset) : NULL;
@@ -115,7 +115,7 @@ bool CTexture::BufferGL()
return true;
}
void CTexture::Bind(u32 GLTextureUnit)
void CTexture::Bind(uint32 GLTextureUnit)
{
glActiveTexture(GL_TEXTURE0 + GLTextureUnit);
@@ -126,13 +126,13 @@ void CTexture::Bind(u32 GLTextureUnit)
glBindTexture(BindTarget, mTextureID);
}
void CTexture::Resize(u32 Width, u32 Height)
void CTexture::Resize(uint32 Width, uint32 Height)
{
if ((mWidth != Width) || (mHeight != Height))
{
DeleteBuffers();
mWidth = (u16) Width;
mHeight = (u16) Height;
mWidth = (uint16) Width;
mHeight = (uint16) Height;
mNumMipMaps = 1;
CalcLinearSize();
}
@@ -142,23 +142,23 @@ float CTexture::ReadTexelAlpha(const CVector2f& rkTexCoord)
{
// todo: support texel formats other than DXT1
// DXT1 is definitely the most complicated one anyway; try reusing CTextureDecoder functions for other formats
u32 TexelX = (u32) ((mWidth - 1) * rkTexCoord.X);
u32 TexelY = (u32) ((mHeight - 1) * (1.f - fmodf(rkTexCoord.Y, 1.f)));
uint32 TexelX = (uint32) ((mWidth - 1) * rkTexCoord.X);
uint32 TexelY = (uint32) ((mHeight - 1) * (1.f - fmodf(rkTexCoord.Y, 1.f)));
if (mTexelFormat == eDXT1 && mBufferExists)
{
CMemoryInStream Buffer(mpImgDataBuffer, mImgDataSize, IOUtil::kSystemEndianness);
// 8 bytes per 4x4 16-pixel block, left-to-right top-to-bottom
u32 BlockIdxX = TexelX / 4;
u32 BlockIdxY = TexelY / 4;
u32 BlocksPerRow = mWidth / 4;
uint32 BlockIdxX = TexelX / 4;
uint32 BlockIdxY = TexelY / 4;
uint32 BlocksPerRow = mWidth / 4;
u32 BufferPos = (8 * BlockIdxX) + (8 * BlockIdxY * BlocksPerRow);
uint32 BufferPos = (8 * BlockIdxX) + (8 * BlockIdxY * BlocksPerRow);
Buffer.Seek(BufferPos, SEEK_SET);
u16 PaletteA = Buffer.ReadShort();
u16 PaletteB = Buffer.ReadShort();
uint16 PaletteA = Buffer.ReadShort();
uint16 PaletteB = Buffer.ReadShort();
if (PaletteA > PaletteB)
{
@@ -168,13 +168,13 @@ float CTexture::ReadTexelAlpha(const CVector2f& rkTexCoord)
// We only care about alpha, which is only present on palette index 3.
// We don't need to calculate/decode the actual palette colors.
u32 BlockCol = (TexelX & 0xF) / 4;
u32 BlockRow = (TexelY & 0xF) / 4;
uint32 BlockCol = (TexelX & 0xF) / 4;
uint32 BlockRow = (TexelY & 0xF) / 4;
Buffer.Seek(BlockRow, SEEK_CUR);
u8 Row = Buffer.ReadByte();
u8 Shift = (u8) (6 - (BlockCol * 2));
u8 PaletteIndex = (Row >> Shift) & 0x3;
uint8 Row = Buffer.ReadByte();
uint8 Shift = (uint8) (6 - (BlockCol * 2));
uint8 PaletteIndex = (Row >> Shift) & 0x3;
return (PaletteIndex == 3 ? 0.f : 1.f);
}
@@ -196,12 +196,12 @@ bool CTexture::WriteDDS(IOutputStream& rOut)
rOut.WriteLong(0); // dwDepth
rOut.WriteLong(mNumMipMaps - 1); // dwMipMapCount
for (u32 iRes = 0; iRes < 11; iRes++)
for (uint32 iRes = 0; iRes < 11; iRes++)
rOut.WriteLong(0); // dwReserved1[11]
// DDS_PIXELFORMAT
rOut.WriteLong(32); // DDS_PIXELFORMAT.dwSize
u32 PFFlags = 0, PFBpp = 0, PFRBitMask = 0, PFGBitMask = 0, PFBBitMask = 0, PFABitMask = 0;
uint32 PFFlags = 0, PFBpp = 0, PFRBitMask = 0, PFGBitMask = 0, PFBBitMask = 0, PFABitMask = 0;
switch (mTexelFormat)
{
@@ -263,7 +263,7 @@ bool CTexture::WriteDDS(IOutputStream& rOut)
}
// ************ STATIC ************
u32 CTexture::FormatBPP(ETexelFormat Format)
uint32 CTexture::FormatBPP(ETexelFormat Format)
{
switch (Format)
{
@@ -291,18 +291,18 @@ u32 CTexture::FormatBPP(ETexelFormat Format)
void CTexture::CalcLinearSize()
{
float BytesPerPixel = FormatBPP(mTexelFormat) / 8.f;
mLinearSize = (u32) (mWidth * mHeight * BytesPerPixel);
mLinearSize = (uint32) (mWidth * mHeight * BytesPerPixel);
}
u32 CTexture::CalcTotalSize()
uint32 CTexture::CalcTotalSize()
{
float BytesPerPixel = FormatBPP(mTexelFormat) / 8.f;
u32 MipW = mWidth, MipH = mHeight;
u32 Size = 0;
uint32 MipW = mWidth, MipH = mHeight;
uint32 Size = 0;
for (u32 iMip = 0; iMip < mNumMipMaps; iMip++)
for (uint32 iMip = 0; iMip < mNumMipMaps; iMip++)
{
Size += (u32) (MipW * MipH * BytesPerPixel);
Size += (uint32) (MipW * MipH * BytesPerPixel);
MipW /= 2;
MipH /= 2;
}
@@ -325,23 +325,23 @@ void CTexture::CopyGLBuffer()
// Calculate buffer size
mImgDataSize = CalcTotalSize();
mpImgDataBuffer = new u8[mImgDataSize];
mpImgDataBuffer = new uint8[mImgDataSize];
mBufferExists = true;
// Get texture
u32 MipW = mWidth, MipH = mHeight, MipOffset = 0;
uint32 MipW = mWidth, MipH = mHeight, MipOffset = 0;
float BytesPerPixel = FormatBPP(mTexelFormat) / 8.f;
GLenum BindTarget = (mEnableMultisampling ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D);
glBindTexture(BindTarget, mTextureID);
for (u32 iMip = 0; iMip < mNumMipMaps; iMip++)
for (uint32 iMip = 0; iMip < mNumMipMaps; iMip++)
{
void *pData = mpImgDataBuffer + MipOffset;
glGetTexImage(BindTarget, iMip, GL_RGBA, GL_UNSIGNED_BYTE, pData);
MipOffset += (u32) (MipW * MipH * BytesPerPixel);
MipOffset += (uint32) (MipW * MipH * BytesPerPixel);
MipW /= 2;
MipH /= 2;
}

View File

@@ -3,9 +3,9 @@
#include "CResource.h"
#include "ETexelFormat.h"
#include <Common/BasicTypes.h>
#include <Common/FileIO.h>
#include <Common/types.h>
#include <Math/CVector2f.h>
#include <Common/Math/CVector2f.h>
#include <GL/glew.h>
@@ -15,38 +15,38 @@ class CTexture : public CResource
friend class CTextureDecoder;
friend class CTextureEncoder;
ETexelFormat mTexelFormat; // Format of decoded image data
ETexelFormat mSourceTexelFormat; // Format of input TXTR file
u16 mWidth, mHeight; // Image dimensions
u32 mNumMipMaps; // The number of mipmaps this texture has
u32 mLinearSize; // The size of the top level mipmap, in bytes
ETexelFormat mTexelFormat; // Format of decoded image data
ETexelFormat mSourceTexelFormat; // Format of input TXTR file
uint16 mWidth, mHeight; // Image dimensions
uint32 mNumMipMaps; // The number of mipmaps this texture has
uint32 mLinearSize; // The size of the top level mipmap, in bytes
bool mEnableMultisampling; // Whether multisample should be enabled (if this texture is a render target).
bool mBufferExists; // Indicates whether image data buffer has valid data
u8 *mpImgDataBuffer; // Pointer to image data buffer
u32 mImgDataSize; // Size of image data buffer
uint8 *mpImgDataBuffer; // Pointer to image data buffer
uint32 mImgDataSize; // Size of image data buffer
bool mGLBufferExists; // Indicates whether GL buffer has valid data
GLuint mTextureID; // ID for texture GL buffer
public:
CTexture(CResourceEntry *pEntry = 0);
CTexture(u32 Width, u32 Height);
CTexture(uint32 Width, uint32 Height);
~CTexture();
bool BufferGL();
void Bind(u32 GLTextureUnit);
void Resize(u32 Width, u32 Height);
void Bind(uint32 GLTextureUnit);
void Resize(uint32 Width, uint32 Height);
float ReadTexelAlpha(const CVector2f& rkTexCoord);
bool WriteDDS(IOutputStream& rOut);
// Accessors
ETexelFormat TexelFormat() const { return mTexelFormat; }
ETexelFormat SourceTexelFormat() const { return mSourceTexelFormat; }
u32 Width() const { return (u32) mWidth; }
u32 Height() const { return (u32) mHeight; }
u32 NumMipMaps() const { return mNumMipMaps; }
GLuint TextureID() const { return mTextureID; }
uint32 Width() const { return (uint32) mWidth; }
uint32 Height() const { return (uint32) mHeight; }
uint32 NumMipMaps() const { return mNumMipMaps; }
GLuint TextureID() const { return mTextureID; }
inline void SetMultisamplingEnabled(bool Enable)
{
@@ -57,12 +57,12 @@ public:
}
// Static
static u32 FormatBPP(ETexelFormat Format);
static uint32 FormatBPP(ETexelFormat Format);
// Private
private:
void CalcLinearSize();
u32 CalcTotalSize();
uint32 CalcTotalSize();
void CopyGLBuffer();
void DeleteBuffers();
};

View File

@@ -21,7 +21,7 @@ CDependencyTree* CWorld::BuildDependencyTree() const
{
CDependencyTree *pTree = new CDependencyTree();
for (u32 iArea = 0; iArea < mAreas.size(); iArea++)
for (uint32 iArea = 0; iArea < mAreas.size(); iArea++)
{
pTree->AddDependency(mAreas[iArea].AreaResID);
pTree->AddDependency(mAreas[iArea].pAreaName);
@@ -38,7 +38,7 @@ CDependencyTree* CWorld::BuildDependencyTree() const
void CWorld::SetAreaLayerInfo(CGameArea *pArea)
{
for (u32 iArea = 0; iArea < mAreas.size(); iArea++)
for (uint32 iArea = 0; iArea < mAreas.size(); iArea++)
{
if (mAreas[iArea].AreaResID == pArea->ID())
{
@@ -49,7 +49,7 @@ void CWorld::SetAreaLayerInfo(CGameArea *pArea)
SArea& AreaInfo = mAreas[pArea->WorldIndex()];
for (u32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++)
for (uint32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++)
{
if (AreaInfo.Layers.size() <= iLyr) break;
CScriptLayer *pLayer = pArea->ScriptLayer(iLyr);
@@ -68,7 +68,7 @@ TString CWorld::InGameName() const
return Entry()->Name();
}
TString CWorld::AreaInGameName(u32 AreaIndex) const
TString CWorld::AreaInGameName(uint32 AreaIndex) const
{
const SArea& rkArea = mAreas[AreaIndex];
@@ -78,9 +78,9 @@ TString CWorld::AreaInGameName(u32 AreaIndex) const
return "!!" + rkArea.InternalName;
}
u32 CWorld::AreaIndex(CAssetID AreaID) const
uint32 CWorld::AreaIndex(CAssetID AreaID) const
{
for (u32 AreaIdx = 0; AreaIdx < mAreas.size(); AreaIdx++)
for (uint32 AreaIdx = 0; AreaIdx < mAreas.size(); AreaIdx++)
{
if (mAreas[AreaIdx].AreaResID == AreaID)
return AreaIdx;

View File

@@ -6,7 +6,7 @@
#include "CStringTable.h"
#include "Core/Resource/Area/CGameArea.h"
#include "Core/Resource/Model/CModel.h"
#include <Math/CTransform4f.h>
#include <Common/Math/CTransform4f.h>
class CWorld : public CResource
{
@@ -21,7 +21,7 @@ class CWorld : public CResource
TResPtr<CResource> mpSaveWorld;
TResPtr<CModel> mpDefaultSkybox;
TResPtr<CResource> mpMapWorld;
u32 mTempleKeyWorldIndex;
uint32 mTempleKeyWorldIndex;
struct STimeAttackData
{
@@ -36,15 +36,15 @@ class CWorld : public CResource
struct SAudioGrp
{
CAssetID ResID;
u32 GroupID;
uint32 GroupID;
};
std::vector<SAudioGrp> mAudioGrps;
struct SMemoryRelay
{
u32 InstanceID;
u32 TargetID;
u16 Message;
uint32 InstanceID;
uint32 TargetID;
uint16 Message;
bool Active;
};
std::vector<SMemoryRelay> mMemoryRelays;
@@ -60,16 +60,16 @@ class CWorld : public CResource
bool AllowPakDuplicates;
std::vector<SMemoryRelay> MemoryRelays; // Only needed for MP1
std::vector<u16> AttachedAreaIDs;
std::vector<uint16> AttachedAreaIDs;
std::vector<TString> RelFilenames; // Needs to be removed & generated at cook; temporarily leaving for debugging
std::vector<u32> RelOffsets;
std::vector<uint32> RelOffsets;
struct SDock
{
struct SConnectingDock
{
u32 AreaIndex;
u32 DockIndex;
uint32 AreaIndex;
uint32 DockIndex;
};
std::vector<SConnectingDock> ConnectingDocks;
std::vector<CVector3f> DockCoordinates;
@@ -93,8 +93,8 @@ public:
CDependencyTree* BuildDependencyTree() const;
void SetAreaLayerInfo(CGameArea *pArea);
TString InGameName() const;
TString AreaInGameName(u32 AreaIndex) const;
u32 AreaIndex(CAssetID AreaID) const;
TString AreaInGameName(uint32 AreaIndex) const;
uint32 AreaIndex(CAssetID AreaID) const;
// Serialization
virtual void Serialize(IArchive& rArc);
@@ -114,16 +114,16 @@ public:
inline CModel* DefaultSkybox() const { return mpDefaultSkybox; }
inline CResource* MapWorld() const { return mpMapWorld; }
inline u32 NumAreas() const { return mAreas.size(); }
inline CAssetID AreaResourceID(u32 AreaIndex) const { return mAreas[AreaIndex].AreaResID; }
inline u32 AreaAttachedCount(u32 AreaIndex) const { return mAreas[AreaIndex].AttachedAreaIDs.size(); }
inline u32 AreaAttachedID(u32 AreaIndex, u32 AttachedIndex) const { return mAreas[AreaIndex].AttachedAreaIDs[AttachedIndex]; }
inline TString AreaInternalName(u32 AreaIndex) const { return mAreas[AreaIndex].InternalName; }
inline CStringTable* AreaName(u32 AreaIndex) const { return mAreas[AreaIndex].pAreaName; }
inline bool DoesAreaAllowPakDuplicates(u32 AreaIndex) const { return mAreas[AreaIndex].AllowPakDuplicates; }
inline uint32 NumAreas() const { return mAreas.size(); }
inline CAssetID AreaResourceID(uint32 AreaIndex) const { return mAreas[AreaIndex].AreaResID; }
inline uint32 AreaAttachedCount(uint32 AreaIndex) const { return mAreas[AreaIndex].AttachedAreaIDs.size(); }
inline uint32 AreaAttachedID(uint32 AreaIndex, uint32 AttachedIndex) const { return mAreas[AreaIndex].AttachedAreaIDs[AttachedIndex]; }
inline TString AreaInternalName(uint32 AreaIndex) const { return mAreas[AreaIndex].InternalName; }
inline CStringTable* AreaName(uint32 AreaIndex) const { return mAreas[AreaIndex].pAreaName; }
inline bool DoesAreaAllowPakDuplicates(uint32 AreaIndex) const { return mAreas[AreaIndex].AllowPakDuplicates; }
inline void SetName(const TString& rkName) { mName = rkName; }
inline void SetAreaAllowsPakDuplicates(u32 AreaIndex, bool Allow) { mAreas[AreaIndex].AllowPakDuplicates = Allow; }
inline void SetName(const TString& rkName) { mName = rkName; }
inline void SetAreaAllowsPakDuplicates(uint32 AreaIndex, bool Allow) { mAreas[AreaIndex].AllowPakDuplicates = Allow; }
};
#endif // CWORLD_H

View File

@@ -30,8 +30,8 @@ void CAreaCooker::DetermineSectionNumbersPrime()
// Determine how many sections are taken up by geometry...
// Each world mesh has 7-9 sections (depending on game) plus one section per surface.
u32 GeometrySections = 0;
u32 OriginalMeshCount = mpArea->mOriginalWorldMeshCount;
uint32 GeometrySections = 0;
uint32 OriginalMeshCount = mpArea->mOriginalWorldMeshCount;
switch (mVersion)
{
@@ -47,11 +47,11 @@ void CAreaCooker::DetermineSectionNumbersPrime()
break;
}
for (u32 iMesh = 0; iMesh < mpArea->mWorldModels.size(); iMesh++)
for (uint32 iMesh = 0; iMesh < mpArea->mWorldModels.size(); iMesh++)
GeometrySections += mpArea->mWorldModels[iMesh]->GetSurfaceCount();
// Set section numbers
u32 SecNum = GeometrySections;
uint32 SecNum = GeometrySections;
if (mVersion <= EGame::Prime) mAROTSecNum = SecNum++;
if (mVersion >= EGame::EchoesDemo) mFFFFSecNum = SecNum++;
@@ -81,7 +81,7 @@ void CAreaCooker::DetermineSectionNumbersCorruption()
{
// Because we're copying these from the original file (because not all the numbers
// are present in every file), we don't care about any of these except SCLY and SCGN.
for (u32 iNum = 0; iNum < mpArea->mSectionNumbers.size(); iNum++)
for (uint32 iNum = 0; iNum < mpArea->mSectionNumbers.size(); iNum++)
{
CGameArea::SSectionNumber& rNum = mpArea->mSectionNumbers[iNum];
if (rNum.SectionID == "SOBJ") mSCLYSecNum = rNum.Index;
@@ -124,7 +124,7 @@ void CAreaCooker::WritePrimeHeader(IOutputStream& rOut)
rOut.WriteToBoundary(32, 0);
}
for (u32 iSec = 0; iSec < mSectionSizes.size(); iSec++)
for (uint32 iSec = 0; iSec < mSectionSizes.size(); iSec++)
rOut.WriteLong(mSectionSizes[iSec]);
rOut.WriteToBoundary(32, 0);
@@ -144,14 +144,14 @@ void CAreaCooker::WriteCorruptionHeader(IOutputStream& rOut)
rOut.WriteLong(mpArea->mSectionNumbers.size());
rOut.WriteToBoundary(32, 0);
for (u32 iSec = 0; iSec < mSectionSizes.size(); iSec++)
for (uint32 iSec = 0; iSec < mSectionSizes.size(); iSec++)
rOut.WriteLong(mSectionSizes[iSec]);
rOut.WriteToBoundary(32, 0);
WriteCompressionHeader(rOut);
for (u32 iNum = 0; iNum < mpArea->mSectionNumbers.size(); iNum++)
for (uint32 iNum = 0; iNum < mpArea->mSectionNumbers.size(); iNum++)
{
CGameArea::SSectionNumber& rNum = mpArea->mSectionNumbers[iNum];
rOut.WriteLong(rNum.SectionID.ToLong());
@@ -162,7 +162,7 @@ void CAreaCooker::WriteCorruptionHeader(IOutputStream& rOut)
void CAreaCooker::WriteCompressionHeader(IOutputStream& rOut)
{
for (u32 iCmp = 0; iCmp < mCompressedBlocks.size(); iCmp++)
for (uint32 iCmp = 0; iCmp < mCompressedBlocks.size(); iCmp++)
{
SCompressedBlock& rBlock = mCompressedBlocks[iCmp];
bool IsCompressed = (rBlock.CompressedSize != 0);
@@ -190,37 +190,37 @@ void CAreaCooker::WritePrimeSCLY(IOutputStream& rOut)
rOut.WriteFourCC( FOURCC('SCLY') );
mVersion <= EGame::Prime ? rOut.WriteLong(1) : rOut.WriteByte(1);
u32 NumLayers = mpArea->mScriptLayers.size();
uint32 NumLayers = mpArea->mScriptLayers.size();
rOut.WriteLong(NumLayers);
u32 LayerSizesStart = rOut.Tell();
for (u32 LayerIdx = 0; LayerIdx < NumLayers; LayerIdx++)
uint32 LayerSizesStart = rOut.Tell();
for (uint32 LayerIdx = 0; LayerIdx < NumLayers; LayerIdx++)
rOut.WriteLong(0);
// SCLY
CScriptCooker ScriptCooker(mVersion, true);
std::vector<u32> LayerSizes(NumLayers);
std::vector<uint32> LayerSizes(NumLayers);
for (u32 LayerIdx = 0; LayerIdx < NumLayers; LayerIdx++)
for (uint32 LayerIdx = 0; LayerIdx < NumLayers; LayerIdx++)
{
u32 LayerStart = rOut.Tell();
uint32 LayerStart = rOut.Tell();
ScriptCooker.WriteLayer(rOut, mpArea->mScriptLayers[LayerIdx]);
// Pad the layer to 32 bytes
u32 LayerSize = rOut.Tell() - LayerStart;
u32 PaddedSize = (LayerSize + 31) & ~31;
u32 NumPadBytes = PaddedSize - LayerSize;
uint32 LayerSize = rOut.Tell() - LayerStart;
uint32 PaddedSize = (LayerSize + 31) & ~31;
uint32 NumPadBytes = PaddedSize - LayerSize;
for (u32 Pad = 0; Pad < NumPadBytes; Pad++)
for (uint32 Pad = 0; Pad < NumPadBytes; Pad++)
rOut.WriteByte(0);
LayerSizes[LayerIdx] = PaddedSize;
}
u32 LayersEnd = rOut.Tell();
uint32 LayersEnd = rOut.Tell();
rOut.Seek(LayerSizesStart, SEEK_SET);
for (u32 LayerIdx = 0; LayerIdx < NumLayers; LayerIdx++)
for (uint32 LayerIdx = 0; LayerIdx < NumLayers; LayerIdx++)
rOut.WriteLong(LayerSizes[LayerIdx]);
rOut.Seek(LayersEnd, SEEK_SET);
@@ -241,7 +241,7 @@ void CAreaCooker::WriteEchoesSCLY(IOutputStream& rOut)
// SCLY
CScriptCooker ScriptCooker(mVersion);
for (u32 LayerIdx = 0; LayerIdx < mpArea->mScriptLayers.size(); LayerIdx++)
for (uint32 LayerIdx = 0; LayerIdx < mpArea->mScriptLayers.size(); LayerIdx++)
{
rOut.WriteFourCC( FOURCC('SCLY') );
rOut.WriteByte(1);
@@ -261,7 +261,7 @@ void CAreaCooker::WriteDependencies(IOutputStream& rOut)
{
// Build dependency list
std::list<CAssetID> Dependencies;
std::list<u32> LayerOffsets;
std::list<uint32> LayerOffsets;
CAreaDependencyListBuilder Builder(mpArea->Entry());
Builder.BuildDependencyList(Dependencies, LayerOffsets);
@@ -289,7 +289,7 @@ void CAreaCooker::WriteModules(IOutputStream& rOut)
{
// Build module list
std::vector<TString> ModuleNames;
std::vector<u32> LayerOffsets;
std::vector<uint32> LayerOffsets;
CAreaDependencyTree *pAreaDeps = static_cast<CAreaDependencyTree*>(mpArea->Entry()->Dependencies());
pAreaDeps->GetModuleDependencies(mpArea->Game(), ModuleNames, LayerOffsets);
@@ -297,12 +297,12 @@ void CAreaCooker::WriteModules(IOutputStream& rOut)
// Write
rOut.WriteLong(ModuleNames.size());
for (u32 ModuleIdx = 0; ModuleIdx < ModuleNames.size(); ModuleIdx++)
for (uint32 ModuleIdx = 0; ModuleIdx < ModuleNames.size(); ModuleIdx++)
rOut.WriteString( ModuleNames[ModuleIdx] );
rOut.WriteLong(LayerOffsets.size());
for (u32 OffsetIdx = 0; OffsetIdx < LayerOffsets.size(); OffsetIdx++)
for (uint32 OffsetIdx = 0; OffsetIdx < LayerOffsets.size(); OffsetIdx++)
rOut.WriteLong(LayerOffsets[OffsetIdx]);
FinishSection(false);
@@ -320,10 +320,10 @@ void CAreaCooker::AddSectionToBlock()
void CAreaCooker::FinishSection(bool SingleSectionBlock)
{
// Our section data is now finished in mSection...
const u32 kSizeThreshold = 0x20000;
const uint32 kSizeThreshold = 0x20000;
mSectionData.WriteToBoundary(32, 0);
u32 SecSize = mSectionData.Size();
uint32 SecSize = mSectionData.Size();
mSectionSizes.push_back(SecSize);
// Only track compressed blocks for MP2+. Write everything to one block for MP1.
@@ -349,26 +349,26 @@ void CAreaCooker::FinishBlock()
{
if (mCurBlock.NumSections == 0) return;
std::vector<u8> CompressedBuf(mCompressedData.Size() * 2);
std::vector<uint8> CompressedBuf(mCompressedData.Size() * 2);
bool EnableCompression = (mVersion >= EGame::Echoes) && mpArea->mUsesCompression && !gkForceDisableCompression;
bool UseZlib = (mVersion == EGame::DKCReturns);
u32 CompressedSize = 0;
uint32 CompressedSize = 0;
bool WriteCompressedData = false;
if (EnableCompression)
{
bool Success = CompressionUtil::CompressSegmentedData((u8*) mCompressedData.Data(), mCompressedData.Size(), CompressedBuf.data(), CompressedSize, UseZlib, true);
u32 PadBytes = (32 - (CompressedSize % 32)) & 0x1F;
WriteCompressedData = Success && (CompressedSize + PadBytes < (u32) mCompressedData.Size());
bool Success = CompressionUtil::CompressSegmentedData((uint8*) mCompressedData.Data(), mCompressedData.Size(), CompressedBuf.data(), CompressedSize, UseZlib, true);
uint32 PadBytes = (32 - (CompressedSize % 32)) & 0x1F;
WriteCompressedData = Success && (CompressedSize + PadBytes < (uint32) mCompressedData.Size());
}
if (WriteCompressedData)
{
u32 PadBytes = 32 - (CompressedSize % 32);
uint32 PadBytes = 32 - (CompressedSize % 32);
PadBytes &= 0x1F;
for (u32 iPad = 0; iPad < PadBytes; iPad++)
for (uint32 iPad = 0; iPad < PadBytes; iPad++)
mAreaData.WriteByte(0);
mAreaData.WriteBytes(CompressedBuf.data(), CompressedSize);
@@ -400,7 +400,7 @@ bool CAreaCooker::CookMREA(CGameArea *pArea, IOutputStream& rOut)
Cooker.DetermineSectionNumbersCorruption();
// Write pre-SCLY data sections
for (u32 iSec = 0; iSec < Cooker.mSCLYSecNum; iSec++)
for (uint32 iSec = 0; iSec < Cooker.mSCLYSecNum; iSec++)
{
if (iSec == Cooker.mDepsSecNum)
Cooker.WriteDependencies(Cooker.mSectionData);
@@ -419,8 +419,8 @@ bool CAreaCooker::CookMREA(CGameArea *pArea, IOutputStream& rOut)
Cooker.WriteEchoesSCLY(Cooker.mSectionData);
// Write post-SCLY data sections
u32 PostSCLY = (Cooker.mVersion <= EGame::Prime ? Cooker.mSCLYSecNum + 1 : Cooker.mSCGNSecNum + 1);
for (u32 iSec = PostSCLY; iSec < pArea->mSectionDataBuffers.size(); iSec++)
uint32 PostSCLY = (Cooker.mVersion <= EGame::Prime ? Cooker.mSCLYSecNum + 1 : Cooker.mSCGNSecNum + 1);
for (uint32 iSec = PostSCLY; iSec < pArea->mSectionDataBuffers.size(); iSec++)
{
if (iSec == Cooker.mModulesSecNum)
Cooker.WriteModules(Cooker.mSectionData);
@@ -444,7 +444,7 @@ bool CAreaCooker::CookMREA(CGameArea *pArea, IOutputStream& rOut)
return true;
}
u32 CAreaCooker::GetMREAVersion(EGame Version)
uint32 CAreaCooker::GetMREAVersion(EGame Version)
{
switch (Version)
{

View File

@@ -11,28 +11,28 @@ class CAreaCooker
TResPtr<CGameArea> mpArea;
EGame mVersion;
std::vector<u32> mSectionSizes;
std::vector<uint32> mSectionSizes;
u32 mGeometrySecNum;
u32 mSCLYSecNum;
u32 mSCGNSecNum;
u32 mCollisionSecNum;
u32 mUnknownSecNum;
u32 mLightsSecNum;
u32 mVISISecNum;
u32 mPATHSecNum;
u32 mAROTSecNum;
u32 mFFFFSecNum;
u32 mPTLASecNum;
u32 mEGMCSecNum;
u32 mDepsSecNum;
u32 mModulesSecNum;
uint32 mGeometrySecNum;
uint32 mSCLYSecNum;
uint32 mSCGNSecNum;
uint32 mCollisionSecNum;
uint32 mUnknownSecNum;
uint32 mLightsSecNum;
uint32 mVISISecNum;
uint32 mPATHSecNum;
uint32 mAROTSecNum;
uint32 mFFFFSecNum;
uint32 mPTLASecNum;
uint32 mEGMCSecNum;
uint32 mDepsSecNum;
uint32 mModulesSecNum;
struct SCompressedBlock
{
u32 CompressedSize;
u32 DecompressedSize;
u32 NumSections;
uint32 CompressedSize;
uint32 DecompressedSize;
uint32 NumSections;
SCompressedBlock()
: CompressedSize(0), DecompressedSize(0), NumSections(0) {}
@@ -70,7 +70,7 @@ class CAreaCooker
public:
static bool CookMREA(CGameArea *pArea, IOutputStream& rOut);
static u32 GetMREAVersion(EGame Version);
static uint32 GetMREAVersion(EGame Version);
};
#endif // CAREACOOKER_H

View File

@@ -6,9 +6,9 @@ CMaterialCooker::CMaterialCooker()
{
}
u32 CMaterialCooker::ConvertFromVertexDescription(FVertexDescription VtxDesc)
uint32 CMaterialCooker::ConvertFromVertexDescription(FVertexDescription VtxDesc)
{
u32 Flags = 0;
uint32 Flags = 0;
if (VtxDesc & ePosition) Flags |= 0x00000003;
if (VtxDesc & eNormal) Flags |= 0x0000000C;
if (VtxDesc & eColor0) Flags |= 0x00000030;
@@ -36,14 +36,14 @@ void CMaterialCooker::WriteMatSetPrime(IOutputStream& rOut)
{
// Gather texture list from the materials before starting
mTextureIDs.clear();
u32 NumMats = mpSet->mMaterials.size();
uint32 NumMats = mpSet->mMaterials.size();
for (u32 iMat = 0; iMat < NumMats; iMat++)
for (uint32 iMat = 0; iMat < NumMats; iMat++)
{
CMaterial *pMat = mpSet->mMaterials[iMat];
u32 NumPasses = pMat->PassCount();
for (u32 iPass = 0; iPass < NumPasses; iPass++)
uint32 NumPasses = pMat->PassCount();
for (uint32 iPass = 0; iPass < NumPasses; iPass++)
{
CTexture *pTex = pMat->Pass(iPass)->Texture();
if (pTex)
@@ -58,21 +58,21 @@ void CMaterialCooker::WriteMatSetPrime(IOutputStream& rOut)
// Write texture IDs
rOut.WriteLong(mTextureIDs.size());
for (u32 iTex = 0; iTex < mTextureIDs.size(); iTex++)
for (uint32 iTex = 0; iTex < mTextureIDs.size(); iTex++)
rOut.WriteLong(mTextureIDs[iTex]);
// Write material offset filler
rOut.WriteLong(NumMats);
u32 MatOffsetsStart = rOut.Tell();
uint32 MatOffsetsStart = rOut.Tell();
for (u32 iMat = 0; iMat < NumMats; iMat++)
for (uint32 iMat = 0; iMat < NumMats; iMat++)
rOut.WriteLong(0);
// Write materials
u32 MatsStart = rOut.Tell();
std::vector<u32> MatEndOffsets(NumMats);
uint32 MatsStart = rOut.Tell();
std::vector<uint32> MatEndOffsets(NumMats);
for (u32 iMat = 0; iMat < NumMats; iMat++)
for (uint32 iMat = 0; iMat < NumMats; iMat++)
{
mpMat = mpSet->mMaterials[iMat];
WriteMaterialPrime(rOut);
@@ -80,10 +80,10 @@ void CMaterialCooker::WriteMatSetPrime(IOutputStream& rOut)
}
// Write material offsets
u32 MatsEnd = rOut.Tell();
uint32 MatsEnd = rOut.Tell();
rOut.Seek(MatOffsetsStart, SEEK_SET);
for (u32 iMat = 0; iMat < NumMats; iMat++)
for (uint32 iMat = 0; iMat < NumMats; iMat++)
rOut.WriteLong(MatEndOffsets[iMat]);
// Done!
@@ -98,19 +98,19 @@ void CMaterialCooker::WriteMatSetCorruption(IOutputStream& /*rOut*/)
void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
{
// Gather data from the passes before we start writing
u32 TexFlags = 0;
u32 NumKonst = 0;
std::vector<u32> TexIndices;
uint32 TexFlags = 0;
uint32 NumKonst = 0;
std::vector<uint32> TexIndices;
for (u32 iPass = 0; iPass < mpMat->mPasses.size(); iPass++)
for (uint32 iPass = 0; iPass < mpMat->mPasses.size(); iPass++)
{
CMaterialPass *pPass = mpMat->Pass(iPass);
if ((pPass->KColorSel() >= 0xC) || (pPass->KAlphaSel() >= 0x10))
{
// Determine the highest Konst index being used
u32 KColorIndex = pPass->KColorSel() % 4;
u32 KAlphaIndex = pPass->KAlphaSel() % 4;
uint32 KColorIndex = pPass->KColorSel() % 4;
uint32 KAlphaIndex = pPass->KAlphaSel() % 4;
if (KColorIndex >= NumKonst)
NumKonst = KColorIndex + 1;
@@ -122,9 +122,9 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
if (pPassTex != nullptr)
{
TexFlags |= (1 << iPass);
u32 TexID = pPassTex->ID().ToLong();
uint32 TexID = pPassTex->ID().ToLong();
for (u32 iTex = 0; iTex < mTextureIDs.size(); iTex++)
for (uint32 iTex = 0; iTex < mTextureIDs.size(); iTex++)
{
if (mTextureIDs[iTex] == TexID)
{
@@ -136,11 +136,11 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
}
// Get group index
u32 GroupIndex;
u64 MatHash = mpMat->HashParameters();
uint32 GroupIndex;
uint64 MatHash = mpMat->HashParameters();
bool NewHash = true;
for (u32 iHash = 0; iHash < mMaterialHashes.size(); iHash++)
for (uint32 iHash = 0; iHash < mMaterialHashes.size(); iHash++)
{
if (mMaterialHashes[iHash] == MatHash)
{
@@ -159,7 +159,7 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
// Start writing!
// Generate flags value
bool HasKonst = (NumKonst > 0);
u32 Flags;
uint32 Flags;
if (mVersion <= EGame::Prime)
Flags = 0x1003;
@@ -172,11 +172,11 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
// Texture indices
rOut.WriteLong(TexIndices.size());
for (u32 iTex = 0; iTex < TexIndices.size(); iTex++)
for (uint32 iTex = 0; iTex < TexIndices.size(); iTex++)
rOut.WriteLong(TexIndices[iTex]);
// Vertex description
u32 VtxFlags = ConvertFromVertexDescription( mpMat->VtxDesc() );
uint32 VtxFlags = ConvertFromVertexDescription( mpMat->VtxDesc() );
if (mVersion < EGame::Echoes)
VtxFlags &= 0x00FFFFFF;
@@ -197,14 +197,14 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
if (HasKonst)
{
rOut.WriteLong(NumKonst);
for (u32 iKonst = 0; iKonst < NumKonst; iKonst++)
for (uint32 iKonst = 0; iKonst < NumKonst; iKonst++)
rOut.WriteLong( mpMat->Konst(iKonst).ToLongRGBA() );
}
// Blend Mode
// Some modifications are done to convert the GLenum to the corresponding GX enum
u16 BlendSrcFac = (u16) mpMat->BlendSrcFac();
u16 BlendDstFac = (u16) mpMat->BlendDstFac();
uint16 BlendSrcFac = (uint16) mpMat->BlendSrcFac();
uint16 BlendDstFac = (uint16) mpMat->BlendDstFac();
if (BlendSrcFac >= 0x300) BlendSrcFac -= 0x2FE;
if (BlendDstFac >= 0x300) BlendDstFac -= 0x2FE;
rOut.WriteShort(BlendDstFac);
@@ -215,24 +215,24 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
rOut.WriteLong(0x3000 | (mpMat->IsLightingEnabled() ? 1 : 0));
// TEV
u32 NumPasses = mpMat->PassCount();
uint32 NumPasses = mpMat->PassCount();
rOut.WriteLong(NumPasses);
for (u32 iPass = 0; iPass < NumPasses; iPass++)
for (uint32 iPass = 0; iPass < NumPasses; iPass++)
{
CMaterialPass *pPass = mpMat->Pass(iPass);
u32 ColorInputFlags = ((pPass->ColorInput(0)) |
uint32 ColorInputFlags = ((pPass->ColorInput(0)) |
(pPass->ColorInput(1) << 5) |
(pPass->ColorInput(2) << 10) |
(pPass->ColorInput(3) << 15));
u32 AlphaInputFlags = ((pPass->AlphaInput(0)) |
uint32 AlphaInputFlags = ((pPass->AlphaInput(0)) |
(pPass->AlphaInput(1) << 5) |
(pPass->AlphaInput(2) << 10) |
(pPass->AlphaInput(3) << 15));
u32 ColorOpFlags = 0x100 | (pPass->ColorOutput() << 9);
u32 AlphaOpFlags = 0x100 | (pPass->AlphaOutput() << 9);
uint32 ColorOpFlags = 0x100 | (pPass->ColorOutput() << 9);
uint32 AlphaOpFlags = 0x100 | (pPass->AlphaOutput() << 9);
rOut.WriteLong(ColorInputFlags);
rOut.WriteLong(AlphaInputFlags);
@@ -245,37 +245,37 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
}
// TEV Tex/UV input selection
u32 CurTexIdx = 0;
uint32 CurTexIdx = 0;
for (u32 iPass = 0; iPass < NumPasses; iPass++)
for (uint32 iPass = 0; iPass < NumPasses; iPass++)
{
rOut.WriteShort(0); // Padding
if (mpMat->Pass(iPass)->Texture())
{
rOut.WriteByte((u8) CurTexIdx);
rOut.WriteByte((u8) CurTexIdx);
rOut.WriteByte((uint8) CurTexIdx);
rOut.WriteByte((uint8) CurTexIdx);
CurTexIdx++;
}
else
rOut.WriteShort((u16) 0xFFFF);
rOut.WriteShort((uint16) 0xFFFF);
}
// TexGen
u32 NumTexCoords = CurTexIdx; // TexIdx is currently equal to the tex coord count
uint32 NumTexCoords = CurTexIdx; // TexIdx is currently equal to the tex coord count
rOut.WriteLong(NumTexCoords);
u32 CurTexMtx = 0;
uint32 CurTexMtx = 0;
for (u32 iPass = 0; iPass < NumPasses; iPass++)
for (uint32 iPass = 0; iPass < NumPasses; iPass++)
{
CMaterialPass *pPass = mpMat->Pass(iPass);
if (pPass->Texture() == nullptr) continue;
u32 AnimType = pPass->AnimMode();
u32 CoordSource = pPass->TexCoordSource();
uint32 AnimType = pPass->AnimMode();
uint32 CoordSource = pPass->TexCoordSource();
u32 TexMtxIdx, PostMtxIdx;
uint32 TexMtxIdx, PostMtxIdx;
bool Normalize;
// No animation - set TexMtx and PostMtx to identity, disable normalization
@@ -304,21 +304,21 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
CurTexMtx += 3;
}
u32 TexGenFlags = (CoordSource << 4) | (TexMtxIdx << 9) | (Normalize << 14) | (PostMtxIdx << 15);
uint32 TexGenFlags = (CoordSource << 4) | (TexMtxIdx << 9) | (Normalize << 14) | (PostMtxIdx << 15);
rOut.WriteLong(TexGenFlags);
}
// Animations
u32 AnimSizeOffset = rOut.Tell();
u32 NumAnims = CurTexMtx; // CurTexMtx is currently equal to the anim count
uint32 AnimSizeOffset = rOut.Tell();
uint32 NumAnims = CurTexMtx; // CurTexMtx is currently equal to the anim count
rOut.WriteLong(0); // Anim size filler
u32 AnimsStart = rOut.Tell();
uint32 AnimsStart = rOut.Tell();
rOut.WriteLong(NumAnims);
for (u32 iPass = 0; iPass < NumPasses; iPass++)
for (uint32 iPass = 0; iPass < NumPasses; iPass++)
{
CMaterialPass *pPass = mpMat->Pass(iPass);
u32 AnimMode = pPass->AnimMode();
uint32 AnimMode = pPass->AnimMode();
if (AnimMode == eNoUVAnim) continue;
rOut.WriteLong(AnimMode);
@@ -336,8 +336,8 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
}
}
u32 AnimsEnd = rOut.Tell();
u32 AnimsSize = AnimsEnd - AnimsStart;
uint32 AnimsEnd = rOut.Tell();
uint32 AnimsSize = AnimsEnd - AnimsStart;
rOut.Seek(AnimSizeOffset, SEEK_SET);
rOut.WriteLong(AnimsSize);
rOut.Seek(AnimsEnd, SEEK_SET);

View File

@@ -10,11 +10,11 @@ class CMaterialCooker
CMaterialSet *mpSet;
CMaterial *mpMat;
EGame mVersion;
std::vector<u32> mTextureIDs;
std::vector<u64> mMaterialHashes;
std::vector<uint32> mTextureIDs;
std::vector<uint64> mMaterialHashes;
CMaterialCooker();
u32 ConvertFromVertexDescription(FVertexDescription VtxDesc);
uint32 ConvertFromVertexDescription(FVertexDescription VtxDesc);
void WriteMatSetPrime(IOutputStream& rOut);
void WriteMatSetCorruption(IOutputStream& rOut);
void WriteMaterialPrime(IOutputStream& rOut);

View File

@@ -20,27 +20,27 @@ void CModelCooker::GenerateSurfaceData()
// Get vertex attributes
mVtxAttribs = eNoAttributes;
for (u32 iMat = 0; iMat < mpModel->GetMatCount(); iMat++)
for (uint32 iMat = 0; iMat < mpModel->GetMatCount(); iMat++)
{
CMaterial *pMat = mpModel->GetMaterialByIndex(0, iMat);
mVtxAttribs |= pMat->VtxDesc();
}
// Get vertices
u32 MaxIndex = 0;
uint32 MaxIndex = 0;
for (u32 iSurf = 0; iSurf < mNumSurfaces; iSurf++)
for (uint32 iSurf = 0; iSurf < mNumSurfaces; iSurf++)
{
u32 NumPrimitives = mpModel->mSurfaces[iSurf]->Primitives.size();
uint32 NumPrimitives = mpModel->mSurfaces[iSurf]->Primitives.size();
for (u32 iPrim = 0; iPrim < NumPrimitives; iPrim++)
for (uint32 iPrim = 0; iPrim < NumPrimitives; iPrim++)
{
SSurface::SPrimitive *pPrim = &mpModel->mSurfaces[iSurf]->Primitives[iPrim];
u32 NumVerts = pPrim->Vertices.size();
uint32 NumVerts = pPrim->Vertices.size();
for (u32 iVtx = 0; iVtx < NumVerts; iVtx++)
for (uint32 iVtx = 0; iVtx < NumVerts; iVtx++)
{
u32 VertIndex = pPrim->Vertices[iVtx].ArrayPosition;
uint32 VertIndex = pPrim->Vertices[iVtx].ArrayPosition;
mVertices[VertIndex] = pPrim->Vertices[iVtx];
if (VertIndex > MaxIndex) MaxIndex = VertIndex;
@@ -66,17 +66,17 @@ void CModelCooker::WriteModelPrime(IOutputStream& rOut)
rOut.WriteLong(mpModel->IsSkinned() ? 6 : 5);
mpModel->mAABox.Write(rOut);
u32 NumSections = mNumMatSets + mNumSurfaces + 6;
uint32 NumSections = mNumMatSets + mNumSurfaces + 6;
rOut.WriteLong(NumSections);
rOut.WriteLong(mNumMatSets);
u32 SectionSizesOffset = rOut.Tell();
for (u32 iSec = 0; iSec < NumSections; iSec++)
uint32 SectionSizesOffset = rOut.Tell();
for (uint32 iSec = 0; iSec < NumSections; iSec++)
rOut.WriteLong(0);
rOut.WriteToBoundary(32, 0);
std::vector<u32> SectionSizes;
std::vector<uint32> SectionSizes;
SectionSizes.reserve(NumSections);
CSectionMgrOut SectionMgr;
@@ -84,7 +84,7 @@ void CModelCooker::WriteModelPrime(IOutputStream& rOut)
SectionMgr.Init(rOut);
// Materials
for (u32 iSet = 0; iSet < mNumMatSets; iSet++)
for (uint32 iSet = 0; iSet < mNumMatSets; iSet++)
{
CMaterialCooker::WriteCookedMatSet(mpModel->mMaterialSets[iSet], mVersion, rOut);
rOut.WriteToBoundary(32, 0);
@@ -92,33 +92,33 @@ void CModelCooker::WriteModelPrime(IOutputStream& rOut)
}
// Vertices
for (u32 iPos = 0; iPos < mNumVertices; iPos++)
for (uint32 iPos = 0; iPos < mNumVertices; iPos++)
mVertices[iPos].Position.Write(rOut);
rOut.WriteToBoundary(32, 0);
SectionMgr.AddSize(rOut);
// Normals
for (u32 iNrm = 0; iNrm < mNumVertices; iNrm++)
for (uint32 iNrm = 0; iNrm < mNumVertices; iNrm++)
mVertices[iNrm].Normal.Write(rOut);
rOut.WriteToBoundary(32, 0);
SectionMgr.AddSize(rOut);
// Colors
for (u32 iColor = 0; iColor < mNumVertices; iColor++)
for (uint32 iColor = 0; iColor < mNumVertices; iColor++)
mVertices[iColor].Color[0].Write(rOut);
rOut.WriteToBoundary(32, 0);
SectionMgr.AddSize(rOut);
// Float UV coordinates
for (u32 iTexSlot = 0; iTexSlot < 8; iTexSlot++)
for (uint32 iTexSlot = 0; iTexSlot < 8; iTexSlot++)
{
bool HasTexSlot = (mVtxAttribs & (eTex0 << iTexSlot)) != 0;
if (HasTexSlot)
{
for (u32 iTex = 0; iTex < mNumVertices; iTex++)
for (uint32 iTex = 0; iTex < mNumVertices; iTex++)
mVertices[iTex].Tex[iTexSlot].Write(rOut);
}
}
@@ -129,53 +129,53 @@ void CModelCooker::WriteModelPrime(IOutputStream& rOut)
// Surface offsets
rOut.WriteLong(mNumSurfaces);
u32 SurfaceOffsetsStart = rOut.Tell();
uint32 SurfaceOffsetsStart = rOut.Tell();
for (u32 iSurf = 0; iSurf < mNumSurfaces; iSurf++)
for (uint32 iSurf = 0; iSurf < mNumSurfaces; iSurf++)
rOut.WriteLong(0);
rOut.WriteToBoundary(32, 0);
SectionMgr.AddSize(rOut);
// Surfaces
u32 SurfacesStart = rOut.Tell();
std::vector<u32> SurfaceEndOffsets(mNumSurfaces);
uint32 SurfacesStart = rOut.Tell();
std::vector<uint32> SurfaceEndOffsets(mNumSurfaces);
for (u32 iSurf = 0; iSurf < mNumSurfaces; iSurf++)
for (uint32 iSurf = 0; iSurf < mNumSurfaces; iSurf++)
{
SSurface *pSurface = mpModel->GetSurface(iSurf);
pSurface->CenterPoint.Write(rOut);
rOut.WriteLong(pSurface->MaterialID);
rOut.WriteShort((u16) 0x8000);
u32 PrimTableSizeOffset = rOut.Tell();
rOut.WriteShort((uint16) 0x8000);
uint32 PrimTableSizeOffset = rOut.Tell();
rOut.WriteShort(0);
rOut.WriteLongLong(0);
rOut.WriteLong(0);
pSurface->ReflectionDirection.Write(rOut);
rOut.WriteToBoundary(32, 0);
u32 PrimTableStart = rOut.Tell();
uint32 PrimTableStart = rOut.Tell();
FVertexDescription VtxAttribs = mpModel->GetMaterialBySurface(0, iSurf)->VtxDesc();
for (u32 iPrim = 0; iPrim < pSurface->Primitives.size(); iPrim++)
for (uint32 iPrim = 0; iPrim < pSurface->Primitives.size(); iPrim++)
{
SSurface::SPrimitive *pPrimitive = &pSurface->Primitives[iPrim];
rOut.WriteByte((u8) pPrimitive->Type);
rOut.WriteShort((u16) pPrimitive->Vertices.size());
rOut.WriteByte((uint8) pPrimitive->Type);
rOut.WriteShort((uint16) pPrimitive->Vertices.size());
for (u32 iVert = 0; iVert < pPrimitive->Vertices.size(); iVert++)
for (uint32 iVert = 0; iVert < pPrimitive->Vertices.size(); iVert++)
{
CVertex *pVert = &pPrimitive->Vertices[iVert];
if (mVersion == EGame::Echoes)
{
for (u32 iMtxAttribs = 0; iMtxAttribs < 8; iMtxAttribs++)
for (uint32 iMtxAttribs = 0; iMtxAttribs < 8; iMtxAttribs++)
if (VtxAttribs & (ePosMtx << iMtxAttribs))
rOut.WriteByte(pVert->MatrixIndices[iMtxAttribs]);
}
u16 VertexIndex = (u16) pVert->ArrayPosition;
uint16 VertexIndex = (uint16) pVert->ArrayPosition;
if (VtxAttribs & ePosition)
rOut.WriteShort(VertexIndex);
@@ -189,23 +189,23 @@ void CModelCooker::WriteModelPrime(IOutputStream& rOut)
if (VtxAttribs & eColor1)
rOut.WriteShort(VertexIndex);
u16 TexOffset = 0;
for (u32 iTex = 0; iTex < 8; iTex++)
uint16 TexOffset = 0;
for (uint32 iTex = 0; iTex < 8; iTex++)
{
if (VtxAttribs & (eTex0 << iTex))
{
rOut.WriteShort(VertexIndex + TexOffset);
TexOffset += (u16) mNumVertices;
TexOffset += (uint16) mNumVertices;
}
}
}
}
rOut.WriteToBoundary(32, 0);
u32 PrimTableEnd = rOut.Tell();
u32 PrimTableSize = PrimTableEnd - PrimTableStart;
uint32 PrimTableEnd = rOut.Tell();
uint32 PrimTableSize = PrimTableEnd - PrimTableStart;
rOut.Seek(PrimTableSizeOffset, SEEK_SET);
rOut.WriteShort((u16) PrimTableSize);
rOut.WriteShort((uint16) PrimTableSize);
rOut.Seek(PrimTableEnd, SEEK_SET);
SectionMgr.AddSize(rOut);
@@ -215,7 +215,7 @@ void CModelCooker::WriteModelPrime(IOutputStream& rOut)
// Done writing the file - now we go back to fill in surface offsets + section sizes
rOut.Seek(SurfaceOffsetsStart, SEEK_SET);
for (u32 iSurf = 0; iSurf < mNumSurfaces; iSurf++)
for (uint32 iSurf = 0; iSurf < mNumSurfaces; iSurf++)
rOut.WriteLong(SurfaceEndOffsets[iSurf]);
rOut.Seek(SectionSizesOffset, SEEK_SET);
@@ -244,7 +244,7 @@ bool CModelCooker::CookCMDL(CModel *pModel, IOutputStream& rOut)
}
}
u32 CModelCooker::GetCMDLVersion(EGame Version)
uint32 CModelCooker::GetCMDLVersion(EGame Version)
{
switch (Version)
{

View File

@@ -9,10 +9,10 @@ class CModelCooker
{
TResPtr<CModel> mpModel;
EGame mVersion;
u32 mNumMatSets;
u32 mNumSurfaces;
u32 mNumVertices;
u8 mVertexFormat;
uint32 mNumMatSets;
uint32 mNumSurfaces;
uint32 mNumVertices;
uint8 mVertexFormat;
std::vector<CVertex> mVertices;
FVertexDescription mVtxAttribs;
@@ -23,7 +23,7 @@ class CModelCooker
public:
static bool CookCMDL(CModel *pModel, IOutputStream& rOut);
static u32 GetCMDLVersion(EGame Version);
static uint32 GetCMDLVersion(EGame Version);
};
#endif // CMODELCOOKER_H

View File

@@ -5,12 +5,12 @@ bool CPoiToWorldCooker::CookEGMC(CPoiToWorld *pPoiToWorld, IOutputStream& rOut)
// Create mappings list
struct SPoiMapping
{
u32 MeshID;
u32 PoiID;
uint32 MeshID;
uint32 PoiID;
};
std::vector<SPoiMapping> Mappings;
for (u32 iPoi = 0; iPoi < pPoiToWorld->NumMappedPOIs(); iPoi++)
for (uint32 iPoi = 0; iPoi < pPoiToWorld->NumMappedPOIs(); iPoi++)
{
const CPoiToWorld::SPoiMap *pkMap = pPoiToWorld->MapByIndex(iPoi);
@@ -26,7 +26,7 @@ bool CPoiToWorldCooker::CookEGMC(CPoiToWorld *pPoiToWorld, IOutputStream& rOut)
// Write EGMC
rOut.WriteLong(Mappings.size());
for (u32 iMap = 0; iMap < Mappings.size(); iMap++)
for (uint32 iMap = 0; iMap < Mappings.size(); iMap++)
{
rOut.WriteLong(Mappings[iMap].MeshID);
rOut.WriteLong(Mappings[iMap].PoiID);

View File

@@ -26,7 +26,7 @@ public:
case eWorld: return CWorldCooker::CookMLVL((CWorld*) pRes, rOutput);
default:
Log::Warning("Failed to cook " + pEntry->CookedExtension().ToString() + " asset; this resource type is not supported for cooking");
warnf("Failed to cook %s asset; this resource type is not supported for cooking", *pEntry->CookedExtension().ToString());
return false;
}
}

View File

@@ -7,7 +7,7 @@
void CScriptCooker::WriteProperty(IOutputStream& rOut, IProperty* pProperty, bool InAtomicStruct)
{
u32 SizeOffset = 0, PropStart = 0;
uint32 SizeOffset = 0, PropStart = 0;
void* pData = (mpArrayItemData ? mpArrayItemData : mpObject->PropertyData());
if (mGame >= EGame::EchoesDemo && !InAtomicStruct)
@@ -180,7 +180,7 @@ void CScriptCooker::WriteProperty(IOutputStream& rOut, IProperty* pProperty, boo
CStructProperty* pStruct = TPropCast<CStructProperty>(pProperty);
std::vector<IProperty*> PropertiesToWrite;
for (u32 ChildIdx = 0; ChildIdx < pStruct->NumChildren(); ChildIdx++)
for (uint32 ChildIdx = 0; ChildIdx < pStruct->NumChildren(); ChildIdx++)
{
IProperty *pChild = pStruct->ChildByIndex(ChildIdx);
@@ -193,10 +193,10 @@ void CScriptCooker::WriteProperty(IOutputStream& rOut, IProperty* pProperty, boo
if (mGame <= EGame::Prime)
rOut.WriteLong(PropertiesToWrite.size());
else
rOut.WriteShort((u16) PropertiesToWrite.size());
rOut.WriteShort((uint16) PropertiesToWrite.size());
}
for (u32 PropertyIdx = 0; PropertyIdx < PropertiesToWrite.size(); PropertyIdx++)
for (uint32 PropertyIdx = 0; PropertyIdx < PropertiesToWrite.size(); PropertyIdx++)
WriteProperty(rOut, PropertiesToWrite[PropertyIdx], pStruct->IsAtomic());
break;
@@ -205,12 +205,12 @@ void CScriptCooker::WriteProperty(IOutputStream& rOut, IProperty* pProperty, boo
case EPropertyType::Array:
{
CArrayProperty* pArray = TPropCast<CArrayProperty>(pProperty);
u32 Count = pArray->ArrayCount(pData);
uint32 Count = pArray->ArrayCount(pData);
rOut.WriteLong(Count);
void* pOldItemData = mpArrayItemData;
for (u32 ElementIdx = 0; ElementIdx < pArray->ArrayCount(pData); ElementIdx++)
for (uint32 ElementIdx = 0; ElementIdx < pArray->ArrayCount(pData); ElementIdx++)
{
mpArrayItemData = pArray->ItemPointer(pData, ElementIdx);
WriteProperty(rOut, pArray->ItemArchetype(), true);
@@ -224,9 +224,9 @@ void CScriptCooker::WriteProperty(IOutputStream& rOut, IProperty* pProperty, boo
if (SizeOffset != 0)
{
u32 PropEnd = rOut.Tell();
uint32 PropEnd = rOut.Tell();
rOut.Seek(SizeOffset, SEEK_SET);
rOut.WriteShort((u16) (PropEnd - PropStart));
rOut.WriteShort((uint16) (PropEnd - PropStart));
rOut.Seek(PropEnd, SEEK_SET);
}
}
@@ -240,20 +240,20 @@ void CScriptCooker::WriteInstance(IOutputStream& rOut, CScriptObject *pInstance)
// number of fields changed size between MP1 and 2, but they're still the same fields
bool IsPrime1 = (mGame <= EGame::Prime);
u32 ObjectType = pInstance->ObjectTypeID();
IsPrime1 ? rOut.WriteByte((u8) ObjectType) : rOut.WriteLong(ObjectType);
uint32 ObjectType = pInstance->ObjectTypeID();
IsPrime1 ? rOut.WriteByte((uint8) ObjectType) : rOut.WriteLong(ObjectType);
u32 SizeOffset = rOut.Tell();
uint32 SizeOffset = rOut.Tell();
IsPrime1 ? rOut.WriteLong(0) : rOut.WriteShort(0);
u32 InstanceStart = rOut.Tell();
u32 InstanceID = (pInstance->Layer()->AreaIndex() << 26) | pInstance->InstanceID();
uint32 InstanceStart = rOut.Tell();
uint32 InstanceID = (pInstance->Layer()->AreaIndex() << 26) | pInstance->InstanceID();
rOut.WriteLong(InstanceID);
u32 NumLinks = pInstance->NumLinks(eOutgoing);
IsPrime1 ? rOut.WriteLong(NumLinks) : rOut.WriteShort((u16) NumLinks);
uint32 NumLinks = pInstance->NumLinks(eOutgoing);
IsPrime1 ? rOut.WriteLong(NumLinks) : rOut.WriteShort((uint16) NumLinks);
for (u32 LinkIdx = 0; LinkIdx < NumLinks; LinkIdx++)
for (uint32 LinkIdx = 0; LinkIdx < NumLinks; LinkIdx++)
{
CLink *pLink = pInstance->Link(eOutgoing, LinkIdx);
rOut.WriteLong(pLink->State());
@@ -263,11 +263,11 @@ void CScriptCooker::WriteInstance(IOutputStream& rOut, CScriptObject *pInstance)
mpObject = pInstance;
WriteProperty(rOut, pInstance->Template()->Properties(), false);
u32 InstanceEnd = rOut.Tell();
uint32 InstanceEnd = rOut.Tell();
rOut.Seek(SizeOffset, SEEK_SET);
u32 Size = InstanceEnd - InstanceStart;
IsPrime1 ? rOut.WriteLong(Size) : rOut.WriteShort((u16) Size);
uint32 Size = InstanceEnd - InstanceStart;
IsPrime1 ? rOut.WriteLong(Size) : rOut.WriteShort((uint16) Size);
rOut.Seek(InstanceEnd, SEEK_SET);
}
@@ -277,11 +277,11 @@ void CScriptCooker::WriteLayer(IOutputStream& rOut, CScriptLayer *pLayer)
rOut.WriteByte( mGame <= EGame::Prime ? 0 : 1 ); // Version
u32 InstanceCountOffset = rOut.Tell();
u32 NumWrittenInstances = 0;
uint32 InstanceCountOffset = rOut.Tell();
uint32 NumWrittenInstances = 0;
rOut.WriteLong(0);
for (u32 iInst = 0; iInst < pLayer->NumInstances(); iInst++)
for (uint32 iInst = 0; iInst < pLayer->NumInstances(); iInst++)
{
CScriptObject *pInstance = pLayer->InstanceByIndex(iInst);
@@ -298,7 +298,7 @@ void CScriptCooker::WriteLayer(IOutputStream& rOut, CScriptLayer *pLayer)
// Generate/Attach message (MP3+) should be written to SCGN, not SCLY
else
{
for (u32 LinkIdx = 0; LinkIdx < pInstance->NumLinks(eIncoming); LinkIdx++)
for (uint32 LinkIdx = 0; LinkIdx < pInstance->NumLinks(eIncoming); LinkIdx++)
{
CLink *pLink = pInstance->Link(eIncoming, LinkIdx);
@@ -336,7 +336,7 @@ void CScriptCooker::WriteLayer(IOutputStream& rOut, CScriptLayer *pLayer)
}
}
u32 LayerEnd = rOut.Tell();
uint32 LayerEnd = rOut.Tell();
rOut.GoTo(InstanceCountOffset);
rOut.WriteLong(NumWrittenInstances);
rOut.GoTo(LayerEnd);
@@ -347,6 +347,6 @@ void CScriptCooker::WriteGeneratedLayer(IOutputStream& rOut)
rOut.WriteByte(1); // Version
rOut.WriteLong(mGeneratedObjects.size());
for (u32 ObjectIdx = 0; ObjectIdx < mGeneratedObjects.size(); ObjectIdx++)
for (uint32 ObjectIdx = 0; ObjectIdx < mGeneratedObjects.size(); ObjectIdx++)
WriteInstance(rOut, mGeneratedObjects[ObjectIdx]);
}

View File

@@ -1,17 +1,17 @@
#ifndef CBLOCKMGROUT_H
#define CBLOCKMGROUT_H
#include <Common/types.h>
#include <Common/BasicTypes.h>
#include <Common/FileIO/IOutputStream.h>
#include <vector>
// Small class to manage file sections for CMDL/MREA output
class CSectionMgrOut
{
u32 mSectionCount;
u32 mCurSectionStart;
u32 mCurSectionIndex;
std::vector<u32> mSectionSizes;
uint32 mSectionCount;
uint32 mCurSectionStart;
uint32 mCurSectionIndex;
std::vector<uint32> mSectionSizes;
public:
CSectionMgrOut()
@@ -20,7 +20,7 @@ public:
, mCurSectionIndex(0)
{}
void SetSectionCount(u32 Count)
void SetSectionCount(uint32 Count)
{
mSectionCount = Count;
mSectionSizes.resize(Count);
@@ -41,7 +41,7 @@ public:
void WriteSizes(IOutputStream& rOut)
{
for (u32 iSec = 0; iSec < mSectionCount; iSec++)
for (uint32 iSec = 0; iSec < mSectionCount; iSec++)
rOut.WriteLong(mSectionSizes[iSec]);
}
};

View File

@@ -14,19 +14,19 @@ void CTextureEncoder::WriteTXTR(IOutputStream& rTXTR)
rTXTR.WriteShort(mpTexture->mHeight);
rTXTR.WriteLong(mpTexture->mNumMipMaps);
u32 MipW = mpTexture->Width() / 4;
u32 MipH = mpTexture->Height() / 4;
uint32 MipW = mpTexture->Width() / 4;
uint32 MipH = mpTexture->Height() / 4;
CMemoryInStream Image(mpTexture->mpImgDataBuffer, mpTexture->mImgDataSize, IOUtil::eLittleEndian);
u32 MipOffset = Image.Tell();
uint32 MipOffset = Image.Tell();
for (u32 iMip = 0; iMip < mpTexture->mNumMipMaps; iMip++)
for (uint32 iMip = 0; iMip < mpTexture->mNumMipMaps; iMip++)
{
for (u32 iBlockY = 0; iBlockY < MipH; iBlockY += 2)
for (u32 iBlockX = 0; iBlockX < MipW; iBlockX += 2)
for (u32 iImgY = iBlockY; iImgY < iBlockY + 2; iImgY++)
for (u32 iImgX = iBlockX; iImgX < iBlockX + 2; iImgX++)
for (uint32 iBlockY = 0; iBlockY < MipH; iBlockY += 2)
for (uint32 iBlockX = 0; iBlockX < MipW; iBlockX += 2)
for (uint32 iImgY = iBlockY; iImgY < iBlockY + 2; iImgY++)
for (uint32 iImgX = iBlockX; iImgX < iBlockX + 2; iImgX++)
{
u32 SrcPos = ((iImgY * MipW) + iImgX) * 8;
uint32 SrcPos = ((iImgY * MipW) + iImgX) * 8;
Image.Seek(MipOffset + SrcPos, SEEK_SET);
ReadSubBlockCMPR(Image, rTXTR);
@@ -50,9 +50,9 @@ void CTextureEncoder::ReadSubBlockCMPR(IInputStream& rSource, IOutputStream& rDe
rDest.WriteShort(rSource.ReadShort());
rDest.WriteShort(rSource.ReadShort());
for (u32 iByte = 0; iByte < 4; iByte++)
for (uint32 iByte = 0; iByte < 4; iByte++)
{
u8 Byte = rSource.ReadByte();
uint8 Byte = rSource.ReadByte();
Byte = ((Byte & 0x3) << 6) | ((Byte & 0xC) << 2) | ((Byte & 0x30) >> 2) | ((Byte & 0xC0) >> 6);
rDest.WriteByte(Byte);
}
@@ -63,7 +63,7 @@ void CTextureEncoder::EncodeTXTR(IOutputStream& rTXTR, CTexture *pTex)
{
if (pTex->mTexelFormat != eDXT1)
{
Log::Error("Unsupported texel format for decoding");
errorf("Unsupported texel format for decoding");
return;
}

View File

@@ -53,7 +53,7 @@ bool CWorldCooker::CookMLVL(CWorld *pWorld, IOutputStream& rMLVL)
{
rMLVL.WriteLong( pWorld->mMemoryRelays.size() );
for (u32 iMem = 0; iMem < pWorld->mMemoryRelays.size(); iMem++)
for (uint32 iMem = 0; iMem < pWorld->mMemoryRelays.size(); iMem++)
{
CWorld::SMemoryRelay& rRelay = pWorld->mMemoryRelays[iMem];
rMLVL.WriteLong(rRelay.InstanceID);
@@ -68,7 +68,7 @@ bool CWorldCooker::CookMLVL(CWorld *pWorld, IOutputStream& rMLVL)
if (Game <= EGame::Prime) rMLVL.WriteLong(1); // Unknown
std::set<CAssetID> AudioGroups;
for (u32 iArea = 0; iArea < pWorld->mAreas.size(); iArea++)
for (uint32 iArea = 0; iArea < pWorld->mAreas.size(); iArea++)
{
// Area Header
CWorld::SArea& rArea = pWorld->mAreas[iArea];
@@ -87,7 +87,7 @@ bool CWorldCooker::CookMLVL(CWorld *pWorld, IOutputStream& rMLVL)
{
rMLVL.WriteLong( rArea.AttachedAreaIDs.size() );
for (u32 iAttach = 0; iAttach < rArea.AttachedAreaIDs.size(); iAttach++)
for (uint32 iAttach = 0; iAttach < rArea.AttachedAreaIDs.size(); iAttach++)
rMLVL.WriteShort(rArea.AttachedAreaIDs[iAttach]);
}
@@ -95,7 +95,7 @@ bool CWorldCooker::CookMLVL(CWorld *pWorld, IOutputStream& rMLVL)
if (Game <= EGame::Echoes)
{
std::list<CAssetID> Dependencies;
std::list<u32> LayerDependsOffsets;
std::list<uint32> LayerDependsOffsets;
CAreaDependencyListBuilder Builder(pAreaEntry);
Builder.BuildDependencyList(Dependencies, LayerDependsOffsets, &AudioGroups);
@@ -121,12 +121,12 @@ bool CWorldCooker::CookMLVL(CWorld *pWorld, IOutputStream& rMLVL)
{
rMLVL.WriteLong( rArea.Docks.size() );
for (u32 iDock = 0; iDock < rArea.Docks.size(); iDock++)
for (uint32 iDock = 0; iDock < rArea.Docks.size(); iDock++)
{
CWorld::SArea::SDock& rDock = rArea.Docks[iDock];
rMLVL.WriteLong( rDock.ConnectingDocks.size() );
for (u32 iCon = 0; iCon < rDock.ConnectingDocks.size(); iCon++)
for (uint32 iCon = 0; iCon < rDock.ConnectingDocks.size(); iCon++)
{
CWorld::SArea::SDock::SConnectingDock& rConDock = rDock.ConnectingDocks[iCon];
rMLVL.WriteLong(rConDock.AreaIndex);
@@ -135,7 +135,7 @@ bool CWorldCooker::CookMLVL(CWorld *pWorld, IOutputStream& rMLVL)
rMLVL.WriteLong( rDock.DockCoordinates.size() );
for (u32 iCoord = 0; iCoord < rDock.DockCoordinates.size(); iCoord++)
for (uint32 iCoord = 0; iCoord < rDock.DockCoordinates.size(); iCoord++)
rDock.DockCoordinates[iCoord].Write(rMLVL);
}
}
@@ -144,18 +144,18 @@ bool CWorldCooker::CookMLVL(CWorld *pWorld, IOutputStream& rMLVL)
if (Game == EGame::EchoesDemo || Game == EGame::Echoes)
{
std::vector<TString> ModuleNames;
std::vector<u32> ModuleLayerOffsets;
std::vector<uint32> ModuleLayerOffsets;
CAreaDependencyTree *pAreaDeps = static_cast<CAreaDependencyTree*>(pAreaEntry->Dependencies());
pAreaDeps->GetModuleDependencies(Game, ModuleNames, ModuleLayerOffsets);
rMLVL.WriteLong(ModuleNames.size());
for (u32 iMod = 0; iMod < ModuleNames.size(); iMod++)
for (uint32 iMod = 0; iMod < ModuleNames.size(); iMod++)
rMLVL.WriteString(ModuleNames[iMod]);
rMLVL.WriteLong(ModuleLayerOffsets.size());
for (u32 iOff = 0; iOff < ModuleLayerOffsets.size(); iOff++)
for (uint32 iOff = 0; iOff < ModuleLayerOffsets.size(); iOff++)
rMLVL.WriteLong(ModuleLayerOffsets[iOff]);
}
@@ -199,7 +199,7 @@ bool CWorldCooker::CookMLVL(CWorld *pWorld, IOutputStream& rMLVL)
// Write sorted audio group list to file
rMLVL.WriteLong(SortedAudioGroups.size());
for (u32 iGrp = 0; iGrp < SortedAudioGroups.size(); iGrp++)
for (uint32 iGrp = 0; iGrp < SortedAudioGroups.size(); iGrp++)
{
CAudioGroup *pGroup = SortedAudioGroups[iGrp];
rMLVL.WriteLong(pGroup->GroupID());
@@ -213,18 +213,18 @@ bool CWorldCooker::CookMLVL(CWorld *pWorld, IOutputStream& rMLVL)
rMLVL.WriteLong(pWorld->mAreas.size());
std::vector<TString> LayerNames;
std::vector<CSavedStateID> LayerStateIDs;
std::vector<u32> LayerNameOffsets;
std::vector<uint32> LayerNameOffsets;
// Layer Flags
for (u32 iArea = 0; iArea < pWorld->mAreas.size(); iArea++)
for (uint32 iArea = 0; iArea < pWorld->mAreas.size(); iArea++)
{
CWorld::SArea& rArea = pWorld->mAreas[iArea];
LayerNameOffsets.push_back(LayerNames.size());
rMLVL.WriteLong(rArea.Layers.size());
u64 LayerActiveFlags = -1;
uint64 LayerActiveFlags = -1;
for (u32 iLyr = 0; iLyr < rArea.Layers.size(); iLyr++)
for (uint32 iLyr = 0; iLyr < rArea.Layers.size(); iLyr++)
{
CWorld::SArea::SLayer& rLayer = rArea.Layers[iLyr];
if (!rLayer.Active)
@@ -240,7 +240,7 @@ bool CWorldCooker::CookMLVL(CWorld *pWorld, IOutputStream& rMLVL)
// Layer Names
rMLVL.WriteLong(LayerNames.size());
for (u32 iLyr = 0; iLyr < LayerNames.size(); iLyr++)
for (uint32 iLyr = 0; iLyr < LayerNames.size(); iLyr++)
rMLVL.WriteString(LayerNames[iLyr]);
// Layer Saved State IDs
@@ -248,20 +248,20 @@ bool CWorldCooker::CookMLVL(CWorld *pWorld, IOutputStream& rMLVL)
{
rMLVL.WriteLong(LayerStateIDs.size());
for (u32 iLyr = 0; iLyr < LayerStateIDs.size(); iLyr++)
for (uint32 iLyr = 0; iLyr < LayerStateIDs.size(); iLyr++)
LayerStateIDs[iLyr].Write(rMLVL);
}
// Layer Name Offsets
rMLVL.WriteLong(LayerNameOffsets.size());
for (u32 iOff = 0; iOff < LayerNameOffsets.size(); iOff++)
for (uint32 iOff = 0; iOff < LayerNameOffsets.size(); iOff++)
rMLVL.WriteLong(LayerNameOffsets[iOff]);
return true;
}
u32 CWorldCooker::GetMLVLVersion(EGame Version)
uint32 CWorldCooker::GetMLVLVersion(EGame Version)
{
switch (Version)
{

View File

@@ -2,15 +2,15 @@
#define CWORLDCOOKER_H
#include "Core/Resource/CWorld.h"
#include <Common/BasicTypes.h>
#include <Common/EGame.h>
#include <Common/types.h>
class CWorldCooker
{
CWorldCooker();
public:
static bool CookMLVL(CWorld *pWorld, IOutputStream& rOut);
static u32 GetMLVLVersion(EGame Version);
static uint32 GetMLVLVersion(EGame Version);
};
#endif // CWORLDCOOKER_H

View File

@@ -4,29 +4,29 @@
void CAnimEventLoader::LoadEvents(IInputStream& rEVNT)
{
u32 Version = rEVNT.ReadLong();
uint32 Version = rEVNT.ReadLong();
ASSERT(Version == 1 || Version == 2);
// Loop Events
u32 NumLoopEvents = rEVNT.ReadLong();
uint32 NumLoopEvents = rEVNT.ReadLong();
for (u32 iLoop = 0; iLoop < NumLoopEvents; iLoop++)
for (uint32 iLoop = 0; iLoop < NumLoopEvents; iLoop++)
{
LoadLoopEvent(rEVNT);
}
// User Events
u32 NumUserEvents = rEVNT.ReadLong();
uint32 NumUserEvents = rEVNT.ReadLong();
for (u32 iUser = 0; iUser < NumUserEvents; iUser++)
for (uint32 iUser = 0; iUser < NumUserEvents; iUser++)
{
LoadUserEvent(rEVNT);
}
// Effect Events
u32 NumEffectEvents = rEVNT.ReadLong();
uint32 NumEffectEvents = rEVNT.ReadLong();
for (u32 iFX = 0; iFX < NumEffectEvents; iFX++)
for (uint32 iFX = 0; iFX < NumEffectEvents; iFX++)
{
LoadEffectEvent(rEVNT);
}
@@ -34,21 +34,21 @@ void CAnimEventLoader::LoadEvents(IInputStream& rEVNT)
// Sound Events
if (Version == 2)
{
u32 NumSoundEvents = rEVNT.ReadLong();
uint32 NumSoundEvents = rEVNT.ReadLong();
for (u32 iSound = 0; iSound < NumSoundEvents; iSound++)
for (uint32 iSound = 0; iSound < NumSoundEvents; iSound++)
{
LoadSoundEvent(rEVNT);
}
}
}
s32 CAnimEventLoader::LoadEventBase(IInputStream& rEVNT)
int32 CAnimEventLoader::LoadEventBase(IInputStream& rEVNT)
{
rEVNT.Skip(0x2);
rEVNT.ReadString();
rEVNT.Skip(mGame < EGame::CorruptionProto ? 0x13 : 0x17);
s32 CharacterIndex = rEVNT.ReadLong();
int32 CharacterIndex = rEVNT.ReadLong();
rEVNT.Skip(mGame < EGame::CorruptionProto ? 0x4 : 0x18);
return CharacterIndex;
}
@@ -68,7 +68,7 @@ void CAnimEventLoader::LoadUserEvent(IInputStream& rEVNT)
void CAnimEventLoader::LoadEffectEvent(IInputStream& rEVNT)
{
s32 CharIndex = LoadEventBase(rEVNT);
int32 CharIndex = LoadEventBase(rEVNT);
rEVNT.Skip(mGame < EGame::CorruptionProto ? 0x8 : 0x4);
CAssetID ParticleID(rEVNT, mGame);
mpEventData->AddEvent(CharIndex, ParticleID);
@@ -83,12 +83,12 @@ void CAnimEventLoader::LoadEffectEvent(IInputStream& rEVNT)
void CAnimEventLoader::LoadSoundEvent(IInputStream& rEVNT)
{
s32 CharIndex = LoadEventBase(rEVNT);
int32 CharIndex = LoadEventBase(rEVNT);
// Metroid Prime 1/2
if (mGame <= EGame::Echoes)
{
u32 SoundID = rEVNT.ReadLong() & 0xFFFF;
uint32 SoundID = rEVNT.ReadLong() & 0xFFFF;
rEVNT.Skip(0x8);
if (mGame >= EGame::Echoes) rEVNT.Skip(0xC);
@@ -108,9 +108,9 @@ void CAnimEventLoader::LoadSoundEvent(IInputStream& rEVNT)
mpEventData->AddEvent(CharIndex, SoundID);
rEVNT.Skip(0x8);
for (u32 StructIdx = 0; StructIdx < 2; StructIdx++)
for (uint32 StructIdx = 0; StructIdx < 2; StructIdx++)
{
u32 StructType = rEVNT.ReadLong();
uint32 StructType = rEVNT.ReadLong();
ASSERT(StructType <= 2);
if (StructType == 1)
@@ -121,7 +121,7 @@ void CAnimEventLoader::LoadSoundEvent(IInputStream& rEVNT)
{
// This is a maya spline
rEVNT.Skip(2);
u32 KnotCount = rEVNT.ReadLong();
uint32 KnotCount = rEVNT.ReadLong();
rEVNT.Skip(0xA * KnotCount);
rEVNT.Skip(9);
}
@@ -159,18 +159,18 @@ CAnimEventData* CAnimEventLoader::LoadCorruptionCharacterEventSet(IInputStream&
rCHAR.ReadString(); // Skip set name
// Read effect events
u32 NumEffectEvents = rCHAR.ReadLong();
uint32 NumEffectEvents = rCHAR.ReadLong();
for (u32 EventIdx = 0; EventIdx < NumEffectEvents; EventIdx++)
for (uint32 EventIdx = 0; EventIdx < NumEffectEvents; EventIdx++)
{
rCHAR.ReadString();
Loader.LoadEffectEvent(rCHAR);
}
// Read sound events
u32 NumSoundEvents = rCHAR.ReadLong();
uint32 NumSoundEvents = rCHAR.ReadLong();
for (u32 EventIdx = 0; EventIdx < NumSoundEvents; EventIdx++)
for (uint32 EventIdx = 0; EventIdx < NumSoundEvents; EventIdx++)
{
rCHAR.ReadString();
Loader.LoadSoundEvent(rCHAR);

View File

@@ -11,7 +11,7 @@ class CAnimEventLoader
CAnimEventLoader() {}
void LoadEvents(IInputStream& rEVNT);
s32 LoadEventBase(IInputStream& rEVNT);
int32 LoadEventBase(IInputStream& rEVNT);
void LoadLoopEvent(IInputStream& rEVNT);
void LoadUserEvent(IInputStream& rEVNT);
void LoadEffectEvent(IInputStream& rEVNT);

View File

@@ -18,9 +18,9 @@ CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(IInputStream& rCHAR)
rChar.pModel = gpResourceStore->LoadResource<CModel>(rCHAR.ReadLongLong());
rChar.pSkin = gpResourceStore->LoadResource<CSkin>(rCHAR.ReadLongLong());
u32 NumOverlays = rCHAR.ReadLong();
uint32 NumOverlays = rCHAR.ReadLong();
for (u32 iOverlay = 0; iOverlay < NumOverlays; iOverlay++)
for (uint32 iOverlay = 0; iOverlay < NumOverlays; iOverlay++)
{
SOverlayModel Overlay;
Overlay.Type = (EOverlayType) rCHAR.ReadLong();
@@ -39,18 +39,18 @@ CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(IInputStream& rCHAR)
LoadParticleResourceData(rCHAR, &rChar, 10);
// Events
u32 NumEventSets = rCHAR.ReadLong();
uint32 NumEventSets = rCHAR.ReadLong();
for (u32 iSet = 0; iSet < NumEventSets; iSet++)
for (uint32 iSet = 0; iSet < NumEventSets; iSet++)
{
CAnimEventData *pEvents = CAnimEventLoader::LoadCorruptionCharacterEventSet(rCHAR);
pSet->mAnimEvents.push_back(pEvents);
}
// Animations
u32 NumAnimations = rCHAR.ReadLong();
uint32 NumAnimations = rCHAR.ReadLong();
for (u32 AnimIdx = 0; AnimIdx < NumAnimations; AnimIdx++)
for (uint32 AnimIdx = 0; AnimIdx < NumAnimations; AnimIdx++)
{
SAnimation Anim;
Anim.Name = rCHAR.ReadString();
@@ -59,23 +59,23 @@ CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(IInputStream& rCHAR)
}
// Animation Bounds
u32 NumAnimationBounds = rCHAR.ReadLong();
uint32 NumAnimationBounds = rCHAR.ReadLong();
rCHAR.Skip(NumAnimationBounds * 0x20);
rCHAR.Skip(1);
// Bool Array
u32 BoolArraySize = rCHAR.ReadLong();
uint32 BoolArraySize = rCHAR.ReadLong();
rCHAR.Skip(BoolArraySize);
// Collision Primitives
u32 NumPrimitiveSets = rCHAR.ReadLong();
uint32 NumPrimitiveSets = rCHAR.ReadLong();
for (u32 SetIdx = 0; SetIdx < NumPrimitiveSets; SetIdx++)
for (uint32 SetIdx = 0; SetIdx < NumPrimitiveSets; SetIdx++)
{
rCHAR.ReadString();
u32 NumPrimitives = rCHAR.ReadLong();
uint32 NumPrimitives = rCHAR.ReadLong();
for (u32 PrimIdx = 0; PrimIdx < NumPrimitives; PrimIdx++)
for (uint32 PrimIdx = 0; PrimIdx < NumPrimitives; PrimIdx++)
{
rCHAR.Skip(0x34);
rCHAR.ReadString();
@@ -84,9 +84,9 @@ CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(IInputStream& rCHAR)
}
// Sound Resources
u32 NumSounds = rCHAR.ReadLong();
uint32 NumSounds = rCHAR.ReadLong();
for (u32 SoundIdx = 0; SoundIdx < NumSounds; SoundIdx++)
for (uint32 SoundIdx = 0; SoundIdx < NumSounds; SoundIdx++)
{
CAssetID SoundID(rCHAR, e64Bit);
rChar.SoundEffects.push_back(SoundID);
@@ -99,7 +99,7 @@ CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(IInputStream& rCHAR)
CAnimSet* CAnimSetLoader::LoadReturnsCHAR(IInputStream& rCHAR)
{
rCHAR.Skip(0x14);
u8 Flag = rCHAR.ReadByte();
uint8 Flag = rCHAR.ReadByte();
rCHAR.Skip(1);
pSet->mCharacters.emplace_back( SSetCharacter() );;
@@ -111,9 +111,9 @@ CAnimSet* CAnimSetLoader::LoadReturnsCHAR(IInputStream& rCHAR)
rChar.pSkeleton = gpResourceStore->LoadResource<CSkeleton>( rCHAR.ReadLongLong() );
rChar.CollisionPrimitivesID = rCHAR.ReadLongLong();
u32 NumModels = rCHAR.ReadLong();
uint32 NumModels = rCHAR.ReadLong();
for (u32 ModelIdx = 0; ModelIdx < NumModels; ModelIdx++)
for (uint32 ModelIdx = 0; ModelIdx < NumModels; ModelIdx++)
{
rCHAR.ReadString();
CAssetID ModelID(rCHAR, EGame::DKCReturns);
@@ -133,9 +133,9 @@ CAnimSet* CAnimSetLoader::LoadReturnsCHAR(IInputStream& rCHAR)
}
// Animations
u32 NumAnims = rCHAR.ReadLong();
uint32 NumAnims = rCHAR.ReadLong();
for (u32 AnimIdx = 0; AnimIdx < NumAnims; AnimIdx++)
for (uint32 AnimIdx = 0; AnimIdx < NumAnims; AnimIdx++)
{
TString AnimName = rCHAR.ReadString();
CAssetID AnimID(rCHAR, EGame::DKCReturns);
@@ -156,21 +156,21 @@ CAnimSet* CAnimSetLoader::LoadReturnsCHAR(IInputStream& rCHAR)
// Anim ID Map
if (Flag & 0x20)
{
u32 NumIDs = rCHAR.ReadLong();
uint32 NumIDs = rCHAR.ReadLong();
rCHAR.Skip(NumIDs * 4);
}
// Transitions
if (Flag & 0x80)
{
u32 NumAdditiveAnims = rCHAR.ReadLong();
uint32 NumAdditiveAnims = rCHAR.ReadLong();
rCHAR.Skip(NumAdditiveAnims * 0x10);
u32 NumTransitionTypes = rCHAR.ReadLong();
uint32 NumTransitionTypes = rCHAR.ReadLong();
for (u32 TypeIdx = 0; TypeIdx < NumTransitionTypes; TypeIdx++)
for (uint32 TypeIdx = 0; TypeIdx < NumTransitionTypes; TypeIdx++)
{
u16 Type = rCHAR.ReadShort();
uint16 Type = rCHAR.ReadShort();
switch (Type)
{
@@ -184,15 +184,15 @@ CAnimSet* CAnimSetLoader::LoadReturnsCHAR(IInputStream& rCHAR)
rCHAR.Skip(0xC);
break;
default:
Log::FileError(rCHAR.GetSourceString(), rCHAR.Tell() - 2, "Invalid transition type: " + TString::FromInt32(Type, 0, 10));
errorf("%s [0x%X]: Invalid transition type: %d", *rCHAR.GetSourceString(), rCHAR.Tell() - 2, Type);
return pSet;
}
}
u32 NumFullTransitions = rCHAR.ReadLong();
uint32 NumFullTransitions = rCHAR.ReadLong();
rCHAR.Skip(NumFullTransitions * 0xC);
u32 NumHalfTransitions = rCHAR.ReadLong();
uint32 NumHalfTransitions = rCHAR.ReadLong();
rCHAR.Skip(NumHalfTransitions * 0x8);
rCHAR.Skip(0x8);
@@ -201,20 +201,20 @@ CAnimSet* CAnimSetLoader::LoadReturnsCHAR(IInputStream& rCHAR)
// Transform Bits
if (Flag & 0x40)
{
u32 NumTransformBits = rCHAR.ReadLong();
uint32 NumTransformBits = rCHAR.ReadLong();
rCHAR.Skip(NumTransformBits);
}
u32 NumUnknown = rCHAR.ReadLong();
uint32 NumUnknown = rCHAR.ReadLong();
rCHAR.Skip(NumUnknown * 4);
// Skel Joint Sets
u32 NumSkelJointSets = rCHAR.ReadLong();
uint32 NumSkelJointSets = rCHAR.ReadLong();
for (u32 SetIdx = 0; SetIdx < NumSkelJointSets; SetIdx++)
for (uint32 SetIdx = 0; SetIdx < NumSkelJointSets; SetIdx++)
{
rCHAR.Skip(4);
u32 NumUnknown2 = rCHAR.ReadLong();
uint32 NumUnknown2 = rCHAR.ReadLong();
rCHAR.Skip(0x20 + NumUnknown2);
}
@@ -222,12 +222,12 @@ CAnimSet* CAnimSetLoader::LoadReturnsCHAR(IInputStream& rCHAR)
if (Flag & 0x10)
{
// Don't need the extensions
u32 NumExtensions = rCHAR.ReadLong();
uint32 NumExtensions = rCHAR.ReadLong();
rCHAR.Skip(NumExtensions * 4);
u32 NumResources = rCHAR.ReadLong();
uint32 NumResources = rCHAR.ReadLong();
for (u32 ResIdx = 0; ResIdx < NumResources; ResIdx++)
for (uint32 ResIdx = 0; ResIdx < NumResources; ResIdx++)
{
CAssetID ResID(rCHAR, EGame::DKCReturns);
rCHAR.Skip(3);
@@ -242,21 +242,21 @@ CAnimSet* CAnimSetLoader::LoadReturnsCHAR(IInputStream& rCHAR)
void CAnimSetLoader::LoadPASDatabase(IInputStream& rPAS4)
{
// For now, just parse the data; don't store it
u32 Magic = rPAS4.ReadLong();
u32 AnimStateCount = rPAS4.ReadLong();
uint32 Magic = rPAS4.ReadLong();
uint32 AnimStateCount = rPAS4.ReadLong();
rPAS4.Seek(0x4, SEEK_CUR); // Skipping default anim state
ASSERT(Magic == FOURCC('PAS4'));
for (u32 iState = 0; iState < AnimStateCount; iState++)
for (uint32 iState = 0; iState < AnimStateCount; iState++)
{
rPAS4.Seek(0x4, SEEK_CUR); // Skipping unknown value
u32 ParmInfoCount = rPAS4.ReadLong();
u32 AnimInfoCount = rPAS4.ReadLong();
uint32 ParmInfoCount = rPAS4.ReadLong();
uint32 AnimInfoCount = rPAS4.ReadLong();
u32 Skip = 0;
for (u32 iParm = 0; iParm < ParmInfoCount; iParm++)
uint32 Skip = 0;
for (uint32 iParm = 0; iParm < ParmInfoCount; iParm++)
{
u32 Type = rPAS4.ReadLong();
uint32 Type = rPAS4.ReadLong();
rPAS4.Seek(0x8, SEEK_CUR);
switch (Type) {
@@ -274,39 +274,39 @@ void CAnimSetLoader::LoadPASDatabase(IInputStream& rPAS4)
}
}
for (u32 iInfo = 0; iInfo < AnimInfoCount; iInfo++)
for (uint32 iInfo = 0; iInfo < AnimInfoCount; iInfo++)
rPAS4.Seek(0x4 + Skip, SEEK_CUR);
}
}
void CAnimSetLoader::LoadParticleResourceData(IInputStream& rFile, SSetCharacter *pChar, u16 CharVersion)
void CAnimSetLoader::LoadParticleResourceData(IInputStream& rFile, SSetCharacter *pChar, uint16 CharVersion)
{
u32 ParticleCount = rFile.ReadLong();
uint32 ParticleCount = rFile.ReadLong();
pChar->GenericParticles.reserve(ParticleCount);
for (u32 iPart = 0; iPart < ParticleCount; iPart++)
for (uint32 iPart = 0; iPart < ParticleCount; iPart++)
pChar->GenericParticles.push_back( CAssetID(rFile, mGame) );
u32 SwooshCount = rFile.ReadLong();
uint32 SwooshCount = rFile.ReadLong();
pChar->SwooshParticles.reserve(SwooshCount);
for (u32 iSwoosh = 0; iSwoosh < SwooshCount; iSwoosh++)
for (uint32 iSwoosh = 0; iSwoosh < SwooshCount; iSwoosh++)
pChar->SwooshParticles.push_back( CAssetID(rFile, mGame) );
if (CharVersion >= 6 && mGame <= EGame::Echoes) rFile.Seek(0x4, SEEK_CUR);
u32 ElectricCount = rFile.ReadLong();
uint32 ElectricCount = rFile.ReadLong();
pChar->ElectricParticles.reserve(ElectricCount);
for (u32 iElec = 0; iElec < ElectricCount; iElec++)
for (uint32 iElec = 0; iElec < ElectricCount; iElec++)
pChar->ElectricParticles.push_back( CAssetID(rFile, mGame) );
if (mGame >= EGame::Echoes)
{
u32 SpawnCount = rFile.ReadLong();
uint32 SpawnCount = rFile.ReadLong();
pChar->SpawnParticles.reserve(SpawnCount);
for (u32 iSpawn = 0; iSpawn < SpawnCount; iSpawn++)
for (uint32 iSpawn = 0; iSpawn < SpawnCount; iSpawn++)
pChar->SpawnParticles.push_back( CAssetID(rFile, mGame) );
}
@@ -316,13 +316,13 @@ void CAnimSetLoader::LoadParticleResourceData(IInputStream& rFile, SSetCharacter
void CAnimSetLoader::LoadAnimationSet(IInputStream& rANCS)
{
u16 Version = rANCS.ReadShort();
uint16 Version = rANCS.ReadShort();
// Animations
u32 NumAnims = rANCS.ReadLong();
uint32 NumAnims = rANCS.ReadLong();
pSet->mAnimations.reserve(NumAnims);
for (u32 iAnim = 0; iAnim < NumAnims; iAnim++)
for (uint32 iAnim = 0; iAnim < NumAnims; iAnim++)
{
SAnimation Anim;
Anim.Name = rANCS.ReadString();
@@ -331,10 +331,10 @@ void CAnimSetLoader::LoadAnimationSet(IInputStream& rANCS)
}
// Transitions
u32 NumTransitions = rANCS.ReadLong();
uint32 NumTransitions = rANCS.ReadLong();
pSet->mTransitions.reserve(NumTransitions);
for (u32 iTrans = 0; iTrans < NumTransitions; iTrans++)
for (uint32 iTrans = 0; iTrans < NumTransitions; iTrans++)
{
STransition Trans;
Trans.Unknown = rANCS.ReadLong();
@@ -347,10 +347,10 @@ void CAnimSetLoader::LoadAnimationSet(IInputStream& rANCS)
pSet->mpDefaultTransition = gMetaTransFactory.LoadFromStream(rANCS, mGame);
// Additive Animations
u32 NumAdditive = rANCS.ReadLong();
uint32 NumAdditive = rANCS.ReadLong();
pSet->mAdditiveAnims.reserve(NumAdditive);
for (u32 iAdd = 0; iAdd < NumAdditive; iAdd++)
for (uint32 iAdd = 0; iAdd < NumAdditive; iAdd++)
{
SAdditiveAnim Anim;
Anim.AnimID = rANCS.ReadLong();
@@ -365,10 +365,10 @@ void CAnimSetLoader::LoadAnimationSet(IInputStream& rANCS)
// Half Transitions
if (Version > 2)
{
u32 NumHalfTransitions = rANCS.ReadLong();
uint32 NumHalfTransitions = rANCS.ReadLong();
pSet->mHalfTransitions.reserve(NumHalfTransitions);
for (u32 iTrans = 0; iTrans < NumHalfTransitions; iTrans++)
for (uint32 iTrans = 0; iTrans < NumHalfTransitions; iTrans++)
{
SHalfTransition Trans;
Trans.AnimID = rANCS.ReadLong();
@@ -381,11 +381,11 @@ void CAnimSetLoader::LoadAnimationSet(IInputStream& rANCS)
// Events
if (mGame >= EGame::EchoesDemo)
{
u32 EventDataCount = rANCS.ReadLong();
uint32 EventDataCount = rANCS.ReadLong();
pSet->mAnimEvents.reserve(EventDataCount);
ASSERT(EventDataCount == NumAnims);
for (u32 iEvent = 0; iEvent < EventDataCount; iEvent++)
for (uint32 iEvent = 0; iEvent < EventDataCount; iEvent++)
{
CAnimEventData *pData = CAnimEventLoader::LoadAnimSetEvents(rANCS);
pSet->mAnimEvents.push_back(pData);
@@ -398,16 +398,16 @@ void CAnimSetLoader::ProcessPrimitives()
// Find all unique anim primitives
std::set<CAnimPrimitive> UniquePrimitives;
for (u32 iAnim = 0; iAnim < pSet->mAnimations.size(); iAnim++)
for (uint32 iAnim = 0; iAnim < pSet->mAnimations.size(); iAnim++)
pSet->mAnimations[iAnim].pMetaAnim->GetUniquePrimitives(UniquePrimitives);
for (u32 iTrans = 0; iTrans < pSet->mTransitions.size(); iTrans++)
for (uint32 iTrans = 0; iTrans < pSet->mTransitions.size(); iTrans++)
pSet->mTransitions[iTrans].pMetaTrans->GetUniquePrimitives(UniquePrimitives);
if (pSet->mpDefaultTransition)
pSet->mpDefaultTransition->GetUniquePrimitives(UniquePrimitives);
for (u32 iTrans = 0; iTrans < pSet->mHalfTransitions.size(); iTrans++)
for (uint32 iTrans = 0; iTrans < pSet->mHalfTransitions.size(); iTrans++)
pSet->mHalfTransitions[iTrans].pMetaTrans->GetUniquePrimitives(UniquePrimitives);
if (mGame == EGame::CorruptionProto || mGame == EGame::Corruption)
@@ -422,7 +422,7 @@ void CAnimSetLoader::ProcessPrimitives()
for (auto Iter = UniquePrimitives.begin(); Iter != UniquePrimitives.end(); Iter++)
{
const CAnimPrimitive& rkPrim = *Iter;
u32 ID = rkPrim.ID();
uint32 ID = rkPrim.ID();
if (ID >= pSet->mAnimPrimitives.size())
pSet->mAnimPrimitives.resize(ID + 1);
@@ -439,7 +439,7 @@ void CAnimSetLoader::ProcessPrimitives()
std::set<CAnimPrimitive> DefaultTransPrimitives;
pSet->mpDefaultTransition->GetUniquePrimitives(DefaultTransPrimitives);
for (u32 iChar = 0; iChar < pSet->mCharacters.size(); iChar++)
for (uint32 iChar = 0; iChar < pSet->mCharacters.size(); iChar++)
{
SSetCharacter& rChar = pSet->mCharacters[iChar];
@@ -452,7 +452,7 @@ void CAnimSetLoader::ProcessPrimitives()
}
// Add animations referenced by used transitions
for (u32 iChar = 0; iChar < pSet->mCharacters.size(); iChar++)
for (uint32 iChar = 0; iChar < pSet->mCharacters.size(); iChar++)
{
SSetCharacter& rChar = pSet->mCharacters[iChar];
bool AddedNewAnims = true;
@@ -463,7 +463,7 @@ void CAnimSetLoader::ProcessPrimitives()
{
AddedNewAnims = false;
for (u32 iTrans = 0; iTrans < pSet->mTransitions.size(); iTrans++)
for (uint32 iTrans = 0; iTrans < pSet->mTransitions.size(); iTrans++)
{
STransition& rTrans = pSet->mTransitions[iTrans];
@@ -486,7 +486,7 @@ void CAnimSetLoader::ProcessPrimitives()
}
}
for (u32 iHalf = 0; iHalf < pSet->mHalfTransitions.size(); iHalf++)
for (uint32 iHalf = 0; iHalf < pSet->mHalfTransitions.size(); iHalf++)
{
SHalfTransition& rTrans = pSet->mHalfTransitions[iHalf];
@@ -517,10 +517,10 @@ CAnimSet* CAnimSetLoader::LoadANCS(IInputStream& rANCS, CResourceEntry *pEntry)
{
if (!rANCS.IsValid()) return nullptr;
u32 Magic = rANCS.ReadLong();
uint32 Magic = rANCS.ReadLong();
if (Magic != 0x00010001)
{
Log::FileError(rANCS.GetSourceString(), "Invalid ANCS magic: " + TString::HexString(Magic));
errorf("%s: Invalid ANCS magic: 0x%08X", *rANCS.GetSourceString(), Magic);
return nullptr;
}
@@ -528,15 +528,15 @@ CAnimSet* CAnimSetLoader::LoadANCS(IInputStream& rANCS, CResourceEntry *pEntry)
Loader.pSet = new CAnimSet(pEntry);
Loader.mGame = pEntry->Game();
u32 NodeCount = rANCS.ReadLong();
uint32 NodeCount = rANCS.ReadLong();
Loader.pSet->mCharacters.resize(NodeCount);
for (u32 iNode = 0; iNode < NodeCount; iNode++)
for (uint32 iNode = 0; iNode < NodeCount; iNode++)
{
SSetCharacter *pChar = &Loader.pSet->mCharacters[iNode];
pChar->ID = rANCS.ReadLong();
u16 CharVersion = rANCS.ReadShort();
uint16 CharVersion = rANCS.ReadShort();
if (iNode == 0 && Loader.mGame == EGame::Invalid)
{
Loader.mGame = (CharVersion == 0xA) ? EGame::Echoes : EGame::Prime;
@@ -549,9 +549,9 @@ CAnimSet* CAnimSetLoader::LoadANCS(IInputStream& rANCS, CResourceEntry *pEntry)
// Unfortunately that's all that's actually supported at the moment. Hope to expand later.
// Since there's no size value I have to actually read the rest of the node to reach the next one
u32 AnimCount = rANCS.ReadLong();
uint32 AnimCount = rANCS.ReadLong();
for (u32 iAnim = 0; iAnim < AnimCount; iAnim++)
for (uint32 iAnim = 0; iAnim < AnimCount; iAnim++)
{
rANCS.Seek(0x4, SEEK_CUR);
if (Loader.mGame == EGame::Prime) rANCS.Seek(0x1, SEEK_CUR);
@@ -564,20 +564,20 @@ CAnimSet* CAnimSetLoader::LoadANCS(IInputStream& rANCS, CResourceEntry *pEntry)
// Particles
Loader.LoadParticleResourceData(rANCS, pChar, CharVersion);
u32 AnimCount2 = rANCS.ReadLong();
for (u32 iAnim = 0; iAnim < AnimCount2; iAnim++)
uint32 AnimCount2 = rANCS.ReadLong();
for (uint32 iAnim = 0; iAnim < AnimCount2; iAnim++)
{
rANCS.ReadString();
rANCS.Seek(0x18, SEEK_CUR);
}
u32 EffectGroupCount = rANCS.ReadLong();
for (u32 iGrp = 0; iGrp < EffectGroupCount; iGrp++)
uint32 EffectGroupCount = rANCS.ReadLong();
for (uint32 iGrp = 0; iGrp < EffectGroupCount; iGrp++)
{
rANCS.ReadString();
u32 EffectCount = rANCS.ReadLong();
uint32 EffectCount = rANCS.ReadLong();
for (u32 iEffect = 0; iEffect < EffectCount; iEffect++)
for (uint32 iEffect = 0; iEffect < EffectCount; iEffect++)
{
rANCS.ReadString();
rANCS.Seek(0x4, SEEK_CUR);
@@ -596,11 +596,11 @@ CAnimSet* CAnimSetLoader::LoadANCS(IInputStream& rANCS, CResourceEntry *pEntry)
Overlay.SkinID = CAssetID(rANCS, e32Bit);
pChar->OverlayModels.push_back(Overlay);
u32 AnimIndexCount = rANCS.ReadLong();
uint32 AnimIndexCount = rANCS.ReadLong();
for (u32 iAnim = 0; iAnim < AnimIndexCount; iAnim++)
for (uint32 iAnim = 0; iAnim < AnimIndexCount; iAnim++)
{
u32 AnimIndex = rANCS.ReadLong();
uint32 AnimIndex = rANCS.ReadLong();
pChar->UsedAnimationIndices.insert(AnimIndex);
}
@@ -608,7 +608,7 @@ CAnimSet* CAnimSetLoader::LoadANCS(IInputStream& rANCS, CResourceEntry *pEntry)
{
pChar->SpatialPrimitives = rANCS.ReadLong();
rANCS.Seek(0x1, SEEK_CUR);
u32 UnknownCount2 = rANCS.ReadLong();
uint32 UnknownCount2 = rANCS.ReadLong();
rANCS.Seek(UnknownCount2 * 0x1C, SEEK_CUR);
}
}
@@ -625,7 +625,7 @@ CAnimSet* CAnimSetLoader::LoadCHAR(IInputStream& rCHAR, CResourceEntry *pEntry)
if (!rCHAR.IsValid()) return nullptr;
CAnimSetLoader Loader;
u8 Check = rCHAR.ReadByte();
uint8 Check = rCHAR.ReadByte();
if (Check == 0x5 || Check == 0x3)
{
@@ -641,7 +641,7 @@ CAnimSet* CAnimSetLoader::LoadCHAR(IInputStream& rCHAR, CResourceEntry *pEntry)
return Loader.LoadReturnsCHAR(rCHAR);
}
Log::FileError(rCHAR.GetSourceString(), "CHAR has invalid first byte: " + TString::HexString(Check, 2));
errorf("%s: CHAR has invalid first byte: 0x%02X", *rCHAR.GetSourceString(), Check);
return nullptr;
}
@@ -652,15 +652,15 @@ CSourceAnimData* CAnimSetLoader::LoadSAND(IInputStream& rSAND, CResourceEntry *p
// We only care about the transitions right now
CSourceAnimData *pData = new CSourceAnimData(pEntry);
u16 Unknown = rSAND.ReadShort(); // probably version
uint16 Unknown = rSAND.ReadShort(); // probably version
ASSERT(Unknown == 0);
// Transitions
u32 NumTransitions = rSAND.ReadLong();
uint32 NumTransitions = rSAND.ReadLong();
for (u32 TransitionIdx = 0; TransitionIdx < NumTransitions; TransitionIdx++)
for (uint32 TransitionIdx = 0; TransitionIdx < NumTransitions; TransitionIdx++)
{
u8 UnkByte = rSAND.ReadByte();
uint8 UnkByte = rSAND.ReadByte();
ASSERT(UnkByte == 0);
CSourceAnimData::STransition Transition;
@@ -671,11 +671,11 @@ CSourceAnimData* CAnimSetLoader::LoadSAND(IInputStream& rSAND, CResourceEntry *p
}
// Half Transitions
u32 NumHalfTransitions = rSAND.ReadLong();
uint32 NumHalfTransitions = rSAND.ReadLong();
for (u32 HalfIdx = 0; HalfIdx < NumHalfTransitions; HalfIdx++)
for (uint32 HalfIdx = 0; HalfIdx < NumHalfTransitions; HalfIdx++)
{
u8 UnkByte = rSAND.ReadByte();
uint8 UnkByte = rSAND.ReadByte();
ASSERT(UnkByte == 0);
CSourceAnimData::SHalfTransition HalfTrans;

View File

@@ -14,7 +14,7 @@ class CAnimSetLoader
CAnimSet* LoadCorruptionCHAR(IInputStream& rCHAR);
CAnimSet* LoadReturnsCHAR(IInputStream& rCHAR);
void LoadPASDatabase(IInputStream& rPAS4);
void LoadParticleResourceData(IInputStream& rFile, SSetCharacter *pChar, u16 Version);
void LoadParticleResourceData(IInputStream& rFile, SSetCharacter *pChar, uint16 Version);
void LoadAnimationSet(IInputStream& rANCS);
void ProcessPrimitives();

View File

@@ -1,7 +1,7 @@
#include "CAnimationLoader.h"
#include <Common/AssertMacro.h>
#include <Common/Macros.h>
#include <Common/Log.h>
#include <Math/MathUtil.h>
#include <Common/Math/MathUtil.h>
bool CAnimationLoader::UncompressedCheckEchoes()
{
@@ -10,29 +10,29 @@ bool CAnimationLoader::UncompressedCheckEchoes()
// a little weird because we have to make sure we don't try to seek or read anything
// past the end of the file. The +4 being added to each size we test is to account
// for the next size value of the next array.
u32 End = mpInput->Size();
uint32 End = mpInput->Size();
u32 NumRotIndices = mpInput->ReadLong();
uint32 NumRotIndices = mpInput->ReadLong();
if (mpInput->Tell() + NumRotIndices + 4 >= End) return false;
mpInput->Seek(NumRotIndices, SEEK_CUR);
u32 NumTransIndices = mpInput->ReadLong();
uint32 NumTransIndices = mpInput->ReadLong();
if (mpInput->Tell() + NumTransIndices + 4 >= End) return false;
mpInput->Seek(NumTransIndices, SEEK_CUR);
u32 NumScaleIndices = mpInput->ReadLong();
uint32 NumScaleIndices = mpInput->ReadLong();
if (mpInput->Tell() + NumScaleIndices + 4 >= End) return false;
mpInput->Seek(NumScaleIndices, SEEK_CUR);
u32 ScaleKeysSize = mpInput->ReadLong() * 0xC;
uint32 ScaleKeysSize = mpInput->ReadLong() * 0xC;
if (mpInput->Tell() + ScaleKeysSize + 4 >= End) return false;
mpInput->Seek(ScaleKeysSize, SEEK_CUR);
u32 RotKeysSize = mpInput->ReadLong() * 0x10;
uint32 RotKeysSize = mpInput->ReadLong() * 0x10;
if (mpInput->Tell() + RotKeysSize + 4 >= End) return false;
mpInput->Seek(RotKeysSize, SEEK_CUR);
u32 TransKeysSize = mpInput->ReadLong() * 0xC;
uint32 TransKeysSize = mpInput->ReadLong() * 0xC;
return (mpInput->Tell() + TransKeysSize == End);
}
@@ -40,7 +40,7 @@ EGame CAnimationLoader::UncompressedCheckVersion()
{
// Call this function after the bone channel index array
// No version number, so this is how we have to determine the version...
u32 Start = mpInput->Tell();
uint32 Start = mpInput->Tell();
bool Echoes = UncompressedCheckEchoes();
mpInput->Seek(Start, SEEK_SET);
return (Echoes ? EGame::Echoes : EGame::Prime);
@@ -57,17 +57,17 @@ void CAnimationLoader::ReadUncompressedANIM()
mpInput->Seek(0x4, SEEK_CUR); // Skip root bone ID
// Read bone channel info
u32 NumBoneChannels = 0;
u32 NumScaleChannels = 0;
u32 NumRotationChannels = 0;
u32 NumTranslationChannels = 0;
uint32 NumBoneChannels = 0;
uint32 NumScaleChannels = 0;
uint32 NumRotationChannels = 0;
uint32 NumTranslationChannels = 0;
// Bone channel list
u32 NumBoneIndices = mpInput->ReadLong();
uint32 NumBoneIndices = mpInput->ReadLong();
ASSERT(NumBoneIndices == 100);
std::vector<u8> BoneIndices(NumBoneIndices);
std::vector<uint8> BoneIndices(NumBoneIndices);
for (u32 iChan = 0; iChan < NumBoneIndices; iChan++)
for (uint32 iChan = 0; iChan < NumBoneIndices; iChan++)
{
BoneIndices[iChan] = mpInput->ReadByte();
@@ -79,14 +79,14 @@ void CAnimationLoader::ReadUncompressedANIM()
mGame = UncompressedCheckVersion();
// Echoes only - rotation channel indices
std::vector<u8> RotationIndices;
std::vector<uint8> RotationIndices;
if (mGame == EGame::Echoes)
{
u32 NumRotationIndices = mpInput->ReadLong();
uint32 NumRotationIndices = mpInput->ReadLong();
RotationIndices.resize(NumRotationIndices);
for (u32 iRot = 0; iRot < NumRotationIndices; iRot++)
for (uint32 iRot = 0; iRot < NumRotationIndices; iRot++)
{
RotationIndices[iRot] = mpInput->ReadByte();
@@ -100,7 +100,7 @@ void CAnimationLoader::ReadUncompressedANIM()
// In MP1 every bone channel has a rotation, so just copy the valid channels from the bone channel list.
RotationIndices.resize(NumBoneChannels);
for (u32 iBone = 0; iBone < BoneIndices.size(); iBone++)
for (uint32 iBone = 0; iBone < BoneIndices.size(); iBone++)
{
if (BoneIndices[iBone] != 0xFF)
{
@@ -111,10 +111,10 @@ void CAnimationLoader::ReadUncompressedANIM()
}
// Translation channel indices
u32 NumTransIndices = mpInput->ReadLong();
std::vector<u8> TransIndices(NumTransIndices);
uint32 NumTransIndices = mpInput->ReadLong();
std::vector<uint8> TransIndices(NumTransIndices);
for (u32 iTrans = 0; iTrans < NumTransIndices; iTrans++)
for (uint32 iTrans = 0; iTrans < NumTransIndices; iTrans++)
{
TransIndices[iTrans] = mpInput->ReadByte();
@@ -123,14 +123,14 @@ void CAnimationLoader::ReadUncompressedANIM()
}
// Echoes only - scale channel indices
std::vector<u8> ScaleIndices;
std::vector<uint8> ScaleIndices;
if (mGame == EGame::Echoes)
{
u32 NumScaleIndices = mpInput->ReadLong();
uint32 NumScaleIndices = mpInput->ReadLong();
ScaleIndices.resize(NumScaleIndices);
for (u32 iScale = 0; iScale < NumScaleIndices; iScale++)
for (uint32 iScale = 0; iScale < NumScaleIndices; iScale++)
{
ScaleIndices[iScale] = mpInput->ReadByte();
@@ -140,9 +140,9 @@ void CAnimationLoader::ReadUncompressedANIM()
}
// Set up bone channel info
for (u32 iBone = 0, iChan = 0; iBone < NumBoneIndices; iBone++)
for (uint32 iBone = 0, iChan = 0; iBone < NumBoneIndices; iBone++)
{
u8 BoneIdx = BoneIndices[iBone];
uint8 BoneIdx = BoneIndices[iBone];
if (BoneIdx != 0xFF)
{
@@ -166,11 +166,11 @@ void CAnimationLoader::ReadUncompressedANIM()
mpInput->Seek(0x4, SEEK_CUR); // Skipping scale key count
mpAnim->mScaleChannels.resize(NumScaleChannels);
for (u32 iScale = 0; iScale < NumScaleChannels; iScale++)
for (uint32 iScale = 0; iScale < NumScaleChannels; iScale++)
{
mpAnim->mScaleChannels[iScale].resize(mpAnim->mNumKeys);
for (u32 iKey = 0; iKey < mpAnim->mNumKeys; iKey++)
for (uint32 iKey = 0; iKey < mpAnim->mNumKeys; iKey++)
mpAnim->mScaleChannels[iScale][iKey] = CVector3f(*mpInput);
}
}
@@ -178,22 +178,22 @@ void CAnimationLoader::ReadUncompressedANIM()
mpInput->Seek(0x4, SEEK_CUR); // Skipping rotation key count
mpAnim->mRotationChannels.resize(NumRotationChannels);
for (u32 iRot = 0; iRot < NumRotationChannels; iRot++)
for (uint32 iRot = 0; iRot < NumRotationChannels; iRot++)
{
mpAnim->mRotationChannels[iRot].resize(mpAnim->mNumKeys);
for (u32 iKey = 0; iKey < mpAnim->mNumKeys; iKey++)
for (uint32 iKey = 0; iKey < mpAnim->mNumKeys; iKey++)
mpAnim->mRotationChannels[iRot][iKey] = CQuaternion(*mpInput);
}
mpInput->Seek(0x4, SEEK_CUR); // Skipping translation key count
mpAnim->mTranslationChannels.resize(NumTranslationChannels);
for (u32 iTrans = 0; iTrans < NumTranslationChannels; iTrans++)
for (uint32 iTrans = 0; iTrans < NumTranslationChannels; iTrans++)
{
mpAnim->mTranslationChannels[iTrans].resize(mpAnim->mNumKeys);
for (u32 iKey = 0; iKey < mpAnim->mNumKeys; iKey++)
for (uint32 iKey = 0; iKey < mpAnim->mNumKeys; iKey++)
mpAnim->mTranslationChannels[iTrans][iKey] = CVector3f(*mpInput);
}
@@ -225,17 +225,17 @@ void CAnimationLoader::ReadCompressedANIM()
mRotationDivisor = mpInput->ReadLong();
mTranslationMultiplier = mpInput->ReadFloat();
if (mGame == EGame::Echoes) mScaleMultiplier = mpInput->ReadFloat();
u32 NumBoneChannels = mpInput->ReadLong();
uint32 NumBoneChannels = mpInput->ReadLong();
mpInput->Seek(0x4, SEEK_CUR); // Skip unknown value
// Read key flags
u32 NumKeys = mpInput->ReadLong();
uint32 NumKeys = mpInput->ReadLong();
mpAnim->mNumKeys = NumKeys;
mKeyFlags.resize(NumKeys);
{
CBitStreamInWrapper BitStream(mpInput);
for (u32 iBit = 0; iBit < NumKeys; iBit++)
for (uint32 iBit = 0; iBit < NumKeys; iBit++)
mKeyFlags[iBit] = BitStream.ReadBit();
}
mpInput->Seek(mGame == EGame::Prime ? 0x8 : 0x4, SEEK_CUR);
@@ -246,7 +246,7 @@ void CAnimationLoader::ReadCompressedANIM()
mpAnim->mRotationChannels.resize(NumBoneChannels);
mpAnim->mTranslationChannels.resize(NumBoneChannels);
for (u32 iChan = 0; iChan < NumBoneChannels; iChan++)
for (uint32 iChan = 0; iChan < NumBoneChannels; iChan++)
{
SCompressedChannel& rChan = mCompressedChannels[iChan];
rChan.BoneID = (mGame == EGame::Prime ? mpInput->ReadLong() : mpInput->ReadByte());
@@ -256,13 +256,13 @@ void CAnimationLoader::ReadCompressedANIM()
if (rChan.NumRotationKeys > 0)
{
for (u32 iComp = 0; iComp < 3; iComp++)
for (uint32 iComp = 0; iComp < 3; iComp++)
{
rChan.Rotation[iComp] = mpInput->ReadShort();
rChan.RotationBits[iComp] = mpInput->ReadByte();
}
mpAnim->mBoneInfo[rChan.BoneID].RotationChannelIdx = (u8) iChan;
mpAnim->mBoneInfo[rChan.BoneID].RotationChannelIdx = (uint8) iChan;
}
else mpAnim->mBoneInfo[rChan.BoneID].RotationChannelIdx = 0xFF;
@@ -271,18 +271,18 @@ void CAnimationLoader::ReadCompressedANIM()
if (rChan.NumTranslationKeys > 0)
{
for (u32 iComp = 0; iComp < 3; iComp++)
for (uint32 iComp = 0; iComp < 3; iComp++)
{
rChan.Translation[iComp] = mpInput->ReadShort();
rChan.TranslationBits[iComp] = mpInput->ReadByte();
}
mpAnim->mBoneInfo[rChan.BoneID].TranslationChannelIdx = (u8) iChan;
mpAnim->mBoneInfo[rChan.BoneID].TranslationChannelIdx = (uint8) iChan;
}
else mpAnim->mBoneInfo[rChan.BoneID].TranslationChannelIdx = 0xFF;
// Read scale parameters
u8 ScaleIdx = 0xFF;
uint8 ScaleIdx = 0xFF;
if (mGame == EGame::Echoes)
{
@@ -290,13 +290,13 @@ void CAnimationLoader::ReadCompressedANIM()
if (rChan.NumScaleKeys > 0)
{
for (u32 iComp = 0; iComp < 3; iComp++)
for (uint32 iComp = 0; iComp < 3; iComp++)
{
rChan.Scale[iComp] = mpInput->ReadShort();
rChan.ScaleBits[iComp] = mpInput->ReadByte();
}
ScaleIdx = (u8) iChan;
ScaleIdx = (uint8) iChan;
}
}
mpAnim->mBoneInfo[rChan.BoneID].ScaleChannelIdx = ScaleIdx;
@@ -311,7 +311,7 @@ void CAnimationLoader::ReadCompressedAnimationData()
CBitStreamInWrapper BitStream(mpInput);
// Initialize
for (u32 iChan = 0; iChan < mCompressedChannels.size(); iChan++)
for (uint32 iChan = 0; iChan < mCompressedChannels.size(); iChan++)
{
SCompressedChannel& rChan = mCompressedChannels[iChan];
@@ -339,11 +339,11 @@ void CAnimationLoader::ReadCompressedAnimationData()
}
// Read keys
for (u32 iKey = 0; iKey < mpAnim->mNumKeys - 1; iKey++)
for (uint32 iKey = 0; iKey < mpAnim->mNumKeys - 1; iKey++)
{
bool KeyPresent = mKeyFlags[iKey+1];
for (u32 iChan = 0; iChan < mCompressedChannels.size(); iChan++)
for (uint32 iChan = 0; iChan < mCompressedChannels.size(); iChan++)
{
SCompressedChannel& rChan = mCompressedChannels[iChan];
@@ -356,9 +356,9 @@ void CAnimationLoader::ReadCompressedAnimationData()
if (KeyPresent)
{
rChan.Rotation[0] += (s16) BitStream.ReadBits(rChan.RotationBits[0]);
rChan.Rotation[1] += (s16) BitStream.ReadBits(rChan.RotationBits[1]);
rChan.Rotation[2] += (s16) BitStream.ReadBits(rChan.RotationBits[2]);
rChan.Rotation[0] += (int16) BitStream.ReadBits(rChan.RotationBits[0]);
rChan.Rotation[1] += (int16) BitStream.ReadBits(rChan.RotationBits[1]);
rChan.Rotation[2] += (int16) BitStream.ReadBits(rChan.RotationBits[2]);
}
CQuaternion Rotation = DequantizeRotation(WSign, rChan.Rotation[0], rChan.Rotation[1], rChan.Rotation[2]);
@@ -370,9 +370,9 @@ void CAnimationLoader::ReadCompressedAnimationData()
{
if (KeyPresent)
{
rChan.Translation[0] += (s16) BitStream.ReadBits(rChan.TranslationBits[0]);
rChan.Translation[1] += (s16) BitStream.ReadBits(rChan.TranslationBits[1]);
rChan.Translation[2] += (s16) BitStream.ReadBits(rChan.TranslationBits[2]);
rChan.Translation[0] += (int16) BitStream.ReadBits(rChan.TranslationBits[0]);
rChan.Translation[1] += (int16) BitStream.ReadBits(rChan.TranslationBits[1]);
rChan.Translation[2] += (int16) BitStream.ReadBits(rChan.TranslationBits[2]);
}
CVector3f Translate = CVector3f(rChan.Translation[0], rChan.Translation[1], rChan.Translation[2]) * mTranslationMultiplier;
@@ -384,9 +384,9 @@ void CAnimationLoader::ReadCompressedAnimationData()
{
if (KeyPresent)
{
rChan.Scale[0] += (s16) BitStream.ReadBits(rChan.ScaleBits[0]);
rChan.Scale[1] += (s16) BitStream.ReadBits(rChan.ScaleBits[1]);
rChan.Scale[2] += (s16) BitStream.ReadBits(rChan.ScaleBits[2]);
rChan.Scale[0] += (int16) BitStream.ReadBits(rChan.ScaleBits[0]);
rChan.Scale[1] += (int16) BitStream.ReadBits(rChan.ScaleBits[1]);
rChan.Scale[2] += (int16) BitStream.ReadBits(rChan.ScaleBits[2]);
}
CVector3f Scale = CVector3f(rChan.Scale[0], rChan.Scale[1], rChan.Scale[2]) * mScaleMultiplier;
@@ -396,26 +396,26 @@ void CAnimationLoader::ReadCompressedAnimationData()
}
// Fill in missing keys
u32 NumMissedKeys = 0;
uint32 NumMissedKeys = 0;
for (u32 iKey = 0; iKey < mpAnim->mNumKeys; iKey++)
for (uint32 iKey = 0; iKey < mpAnim->mNumKeys; iKey++)
{
if (!mKeyFlags[iKey])
NumMissedKeys++;
else if (NumMissedKeys > 0)
{
u32 FirstIndex = iKey - NumMissedKeys - 1;
u32 LastIndex = iKey;
u32 RelLastIndex = LastIndex - FirstIndex;
uint32 FirstIndex = iKey - NumMissedKeys - 1;
uint32 LastIndex = iKey;
uint32 RelLastIndex = LastIndex - FirstIndex;
for (u32 iMissed = 0; iMissed < NumMissedKeys; iMissed++)
for (uint32 iMissed = 0; iMissed < NumMissedKeys; iMissed++)
{
u32 KeyIndex = FirstIndex + iMissed + 1;
u32 RelKeyIndex = (KeyIndex - FirstIndex);
uint32 KeyIndex = FirstIndex + iMissed + 1;
uint32 RelKeyIndex = (KeyIndex - FirstIndex);
float Interp = (float) RelKeyIndex / (float) RelLastIndex;
for (u32 iChan = 0; iChan < mCompressedChannels.size(); iChan++)
for (uint32 iChan = 0; iChan < mCompressedChannels.size(); iChan++)
{
bool HasTranslationKeys = mCompressedChannels[iChan].NumTranslationKeys > 0;
bool HasRotationKeys = mCompressedChannels[iChan].NumRotationKeys > 0;
@@ -449,7 +449,7 @@ void CAnimationLoader::ReadCompressedAnimationData()
}
}
CQuaternion CAnimationLoader::DequantizeRotation(bool Sign, s16 X, s16 Y, s16 Z)
CQuaternion CAnimationLoader::DequantizeRotation(bool Sign, int16 X, int16 Y, int16 Z)
{
CQuaternion Out;
float Multiplier = Math::skHalfPi / (float) mRotationDivisor;
@@ -468,11 +468,11 @@ CAnimation* CAnimationLoader::LoadANIM(IInputStream& rANIM, CResourceEntry *pEnt
if (pEntry->Game() > EGame::Echoes)
return new CAnimation(pEntry);
u32 CompressionType = rANIM.ReadLong();
uint32 CompressionType = rANIM.ReadLong();
if (CompressionType != 0 && CompressionType != 2)
{
Log::FileError(rANIM.GetSourceString(), "Unknown ANIM compression type: " + TString::HexString(CompressionType, 2));
errorf("%s: Unknown ANIM compression type: %d", *rANIM.GetSourceString(), CompressionType);
return nullptr;
}

View File

@@ -14,21 +14,21 @@ class CAnimationLoader
// Compression data
std::vector<bool> mKeyFlags;
float mTranslationMultiplier;
u32 mRotationDivisor;
uint32 mRotationDivisor;
float mScaleMultiplier;
struct SCompressedChannel
{
u32 BoneID;
u16 NumRotationKeys;
s16 Rotation[3];
u8 RotationBits[3];
u16 NumTranslationKeys;
s16 Translation[3];
u8 TranslationBits[3];
u16 NumScaleKeys;
s16 Scale[3];
u8 ScaleBits[3];
uint32 BoneID;
uint16 NumRotationKeys;
int16 Rotation[3];
uint8 RotationBits[3];
uint16 NumTranslationKeys;
int16 Translation[3];
uint8 TranslationBits[3];
uint16 NumScaleKeys;
int16 Scale[3];
uint8 ScaleBits[3];
};
std::vector<SCompressedChannel> mCompressedChannels;
@@ -38,7 +38,7 @@ class CAnimationLoader
void ReadUncompressedANIM();
void ReadCompressedANIM();
void ReadCompressedAnimationData();
CQuaternion DequantizeRotation(bool Sign, s16 X, s16 Y, s16 Z);
CQuaternion DequantizeRotation(bool Sign, int16 X, int16 Y, int16 Z);
public:
static CAnimation* LoadANIM(IInputStream& rANIM, CResourceEntry *pEntry);

View File

@@ -46,7 +46,7 @@ void CAreaLoader::ReadHeaderPrime()
{
mpArea->mTransform = CTransform4f(*mpMREA);
mNumMeshes = mpMREA->ReadLong();
u32 mNumBlocks = mpMREA->ReadLong();
uint32 mNumBlocks = mpMREA->ReadLong();
mGeometryBlockNum = mpMREA->ReadLong();
mScriptLayerBlockNum = mpMREA->ReadLong();
@@ -76,7 +76,7 @@ void CAreaLoader::ReadGeometryPrime()
// Geometry
std::vector<CModel*> FileModels;
for (u32 iMesh = 0; iMesh < mNumMeshes; iMesh++)
for (uint32 iMesh = 0; iMesh < mNumMeshes; iMesh++)
{
CModel *pModel = CModelLoader::LoadWorldModel(*mpMREA, *mpSectionMgr, *mpArea->mpMaterialSet, mVersion);
FileModels.push_back(pModel);
@@ -87,9 +87,9 @@ void CAreaLoader::ReadGeometryPrime()
// For Echoes+, load surface mesh IDs, then skip to the start of the next mesh
else
{
u16 NumSurfaces = mpMREA->ReadShort();
uint16 NumSurfaces = mpMREA->ReadShort();
for (u32 iSurf = 0; iSurf < NumSurfaces; iSurf++)
for (uint32 iSurf = 0; iSurf < NumSurfaces; iSurf++)
{
mpMREA->Seek(0x2, SEEK_CUR);
pModel->GetSurface(iSurf)->MeshID = mpMREA->ReadShort();
@@ -106,7 +106,7 @@ void CAreaLoader::ReadGeometryPrime()
std::vector<CModel*> SplitModels;
CModelLoader::BuildWorldMeshes(FileModels, SplitModels, true);
for (u32 iMdl = 0; iMdl < SplitModels.size(); iMdl++)
for (uint32 iMdl = 0; iMdl < SplitModels.size(); iMdl++)
mpArea->AddWorldModel(SplitModels[iMdl]);
}
@@ -119,9 +119,9 @@ void CAreaLoader::ReadSCLYPrime()
mpSectionMgr->ToSection(mScriptLayerBlockNum);
CFourCC SCLY(*mpMREA);
if (SCLY != "SCLY")
if (SCLY != FOURCC('SCLY'))
{
Log::FileError(mpMREA->GetSourceString(), mpMREA->Tell() - 4, "Invalid SCLY magic: " + SCLY.ToString());
errorf("%s [0x%X]: Invalid SCLY magic: %s", *mpMREA->GetSourceString(), mpMREA->Tell() - 4, *SCLY.ToString());
return;
}
mpMREA->Seek(mVersion <= EGame::Prime ? 4 : 1, SEEK_CUR); // Skipping unknown value which is always 1
@@ -129,15 +129,15 @@ void CAreaLoader::ReadSCLYPrime()
// Read layer sizes
mNumLayers = mpMREA->ReadLong();
mpArea->mScriptLayers.resize(mNumLayers);
std::vector<u32> LayerSizes(mNumLayers);
std::vector<uint32> LayerSizes(mNumLayers);
for (u32 iLyr = 0; iLyr < mNumLayers; iLyr++)
for (uint32 iLyr = 0; iLyr < mNumLayers; iLyr++)
LayerSizes[iLyr] = mpMREA->ReadLong();
// SCLY
for (u32 iLyr = 0; iLyr < mNumLayers; iLyr++)
for (uint32 iLyr = 0; iLyr < mNumLayers; iLyr++)
{
u32 Next = mpMREA->Tell() + LayerSizes[iLyr];
uint32 Next = mpMREA->Tell() + LayerSizes[iLyr];
mpArea->mScriptLayers[iLyr] = CScriptLoader::LoadLayer(*mpMREA, mpArea, mVersion);
mpMREA->Seek(Next, SEEK_SET);
}
@@ -151,7 +151,7 @@ void CAreaLoader::ReadSCLYPrime()
CFourCC SCGN = mpMREA->ReadFourCC();
if (SCGN != FOURCC('SCGN'))
Log::FileError(mpMREA->GetSourceString(), mpMREA->Tell() - 4, "Invalid SCGN magic: " + SCGN.ToString());
errorf("%s [0x%X]: Invalid SCGN magic: %s", *mpMREA->GetSourceString(), mpMREA->Tell() - 4, SCGN.ToString());
else
{
@@ -168,17 +168,17 @@ void CAreaLoader::ReadLightsPrime()
{
mpSectionMgr->ToSection(mLightsBlockNum);
u32 BabeDead = mpMREA->ReadLong();
uint32 BabeDead = mpMREA->ReadLong();
if (BabeDead != 0xbabedead) return;
mpArea->mLightLayers.resize(2);
for (u32 iLyr = 0; iLyr < 2; iLyr++)
for (uint32 iLyr = 0; iLyr < 2; iLyr++)
{
u32 NumLights = mpMREA->ReadLong();
uint32 NumLights = mpMREA->ReadLong();
mpArea->mLightLayers[iLyr].resize(NumLights);
for (u32 iLight = 0; iLight < NumLights; iLight++)
for (uint32 iLight = 0; iLight < NumLights; iLight++)
{
ELightType Type = ELightType(mpMREA->ReadLong());
CVector3f Color(*mpMREA);
@@ -187,7 +187,7 @@ void CAreaLoader::ReadLightsPrime()
float Multiplier = mpMREA->ReadFloat();
float SpotCutoff = mpMREA->ReadFloat();
mpMREA->Seek(0x9, SEEK_CUR);
u32 FalloffType = mpMREA->ReadLong();
uint32 FalloffType = mpMREA->ReadLong();
mpMREA->Seek(0x4, SEEK_CUR);
// Relevant data is read - now we process and form a CLight out of it
@@ -253,7 +253,7 @@ void CAreaLoader::ReadHeaderEchoes()
mpArea->mTransform = CTransform4f(*mpMREA);
mNumMeshes = mpMREA->ReadLong();
if (mVersion == EGame::Echoes) mNumLayers = mpMREA->ReadLong();
u32 numBlocks = mpMREA->ReadLong();
uint32 numBlocks = mpMREA->ReadLong();
mGeometryBlockNum = mpMREA->ReadLong();
mScriptLayerBlockNum = mpMREA->ReadLong();
@@ -291,12 +291,12 @@ void CAreaLoader::ReadSCLYEchoes()
mpArea->mScriptLayers.resize(mNumLayers);
// SCLY
for (u32 iLyr = 0; iLyr < mNumLayers; iLyr++)
for (uint32 iLyr = 0; iLyr < mNumLayers; iLyr++)
{
CFourCC SCLY(*mpMREA);
if (SCLY != "SCLY")
if (SCLY != FOURCC('SCLY'))
{
Log::FileError(mpMREA->GetSourceString(), mpMREA->Tell() - 4, "Layer " + TString::FromInt32(iLyr, 0, 10) + " - Invalid SCLY magic: " + SCLY.ToString());
errorf("%s [0x%X]: Layer %d - Invalid SCLY magic: %s", *mpMREA->GetSourceString(), mpMREA->Tell() - 4, iLyr, *SCLY.ToString());
mpSectionMgr->ToNextSection();
continue;
}
@@ -308,9 +308,9 @@ void CAreaLoader::ReadSCLYEchoes()
// SCGN
CFourCC SCGN(*mpMREA);
if (SCGN != "SCGN")
if (SCGN != FOURCC('SCGN'))
{
Log::FileError(mpMREA->GetSourceString(), mpMREA->Tell() - 4, "Invalid SCGN magic: " + SCGN.ToString());
errorf("%s [0x%X]: Invalid SCGN magic: %s", *mpMREA->GetSourceString(), mpMREA->Tell() - 4, *SCGN.ToString());
return;
}
@@ -327,9 +327,9 @@ void CAreaLoader::ReadHeaderCorruption()
mpArea->mTransform = CTransform4f(*mpMREA);
mNumMeshes = mpMREA->ReadLong();
mNumLayers = mpMREA->ReadLong();
u32 NumSections = mpMREA->ReadLong();
uint32 NumSections = mpMREA->ReadLong();
mClusters.resize(mpMREA->ReadLong());
u32 SectionNumberCount = mpMREA->ReadLong();
uint32 SectionNumberCount = mpMREA->ReadLong();
mpMREA->SeekToBoundary(32);
mpSectionMgr = new CSectionMgrIn(NumSections, mpMREA);
@@ -337,10 +337,10 @@ void CAreaLoader::ReadHeaderCorruption()
ReadCompressedBlocks();
for (u32 iNum = 0; iNum < SectionNumberCount; iNum++)
for (uint32 iNum = 0; iNum < SectionNumberCount; iNum++)
{
CFourCC Type(*mpMREA);
u32 Num = mpMREA->ReadLong();
uint32 Num = mpMREA->ReadLong();
if (Type == "AABB") mBoundingBoxesBlockNum = Num;
else if (Type == "APTL") mPTLABlockNum = Num;
@@ -381,10 +381,10 @@ void CAreaLoader::ReadGeometryCorruption()
// Geometry
std::vector<CModel*> FileModels;
u32 CurWOBJSection = 1;
u32 CurGPUSection = mGPUBlockNum;
uint32 CurWOBJSection = 1;
uint32 CurGPUSection = mGPUBlockNum;
for (u32 iMesh = 0; iMesh < mNumMeshes; iMesh++)
for (uint32 iMesh = 0; iMesh < mNumMeshes; iMesh++)
{
CModel *pWorldModel = CModelLoader::LoadCorruptionWorldModel(*mpMREA, *mpSectionMgr, *mpArea->mpMaterialSet, CurWOBJSection, CurGPUSection, mVersion);
FileModels.push_back(pWorldModel);
@@ -394,9 +394,9 @@ void CAreaLoader::ReadGeometryCorruption()
// Load surface mesh IDs
mpSectionMgr->ToSection(CurWOBJSection - 2);
u16 NumSurfaces = mpMREA->ReadShort();
uint16 NumSurfaces = mpMREA->ReadShort();
for (u32 iSurf = 0; iSurf < NumSurfaces; iSurf++)
for (uint32 iSurf = 0; iSurf < NumSurfaces; iSurf++)
{
mpMREA->Seek(0x2, SEEK_CUR);
pWorldModel->GetSurface(iSurf)->MeshID = mpMREA->ReadShort();
@@ -406,7 +406,7 @@ void CAreaLoader::ReadGeometryCorruption()
std::vector<CModel*> SplitModels;
CModelLoader::BuildWorldMeshes(FileModels, SplitModels, true);
for (u32 iMdl = 0; iMdl < SplitModels.size(); iMdl++)
for (uint32 iMdl = 0; iMdl < SplitModels.size(); iMdl++)
mpArea->AddWorldModel(SplitModels[iMdl]);
mpArea->MergeTerrain();
@@ -417,28 +417,28 @@ void CAreaLoader::ReadDependenciesCorruption()
mpSectionMgr->ToSection(mDependenciesBlockNum);
// Read the offsets first so we can read the deps directly into their corresponding arrays
u32 NumDeps = mpMREA->ReadLong();
u32 DepsStart = mpMREA->Tell();
uint32 NumDeps = mpMREA->ReadLong();
uint32 DepsStart = mpMREA->Tell();
mpMREA->Skip(NumDeps * 0xC);
u32 NumOffsets = mpMREA->ReadLong();
std::vector<u32> Offsets(NumOffsets);
uint32 NumOffsets = mpMREA->ReadLong();
std::vector<uint32> Offsets(NumOffsets);
for (u32 OffsetIdx = 0; OffsetIdx < NumOffsets; OffsetIdx++)
for (uint32 OffsetIdx = 0; OffsetIdx < NumOffsets; OffsetIdx++)
Offsets[OffsetIdx] = mpMREA->ReadLong();
mpMREA->GoTo(DepsStart);
// Read layer dependencies
u32 NumLayers = NumOffsets - 1;
uint32 NumLayers = NumOffsets - 1;
mpArea->mExtraLayerDeps.resize(NumLayers);
for (u32 LayerIdx = 0; LayerIdx < NumLayers; LayerIdx++)
for (uint32 LayerIdx = 0; LayerIdx < NumLayers; LayerIdx++)
{
u32 NumLayerDeps = Offsets[LayerIdx+1] - Offsets[LayerIdx];
uint32 NumLayerDeps = Offsets[LayerIdx+1] - Offsets[LayerIdx];
mpArea->mExtraLayerDeps[LayerIdx].reserve(NumLayerDeps);
for (u32 DepIdx = 0; DepIdx < NumLayerDeps; DepIdx++)
for (uint32 DepIdx = 0; DepIdx < NumLayerDeps; DepIdx++)
{
CAssetID AssetID(*mpMREA, EGame::Corruption);
mpMREA->Skip(4);
@@ -447,10 +447,10 @@ void CAreaLoader::ReadDependenciesCorruption()
}
// Read area dependencies
u32 NumAreaDeps = NumDeps - Offsets[NumLayers];
uint32 NumAreaDeps = NumDeps - Offsets[NumLayers];
mpArea->mExtraAreaDeps.reserve(NumAreaDeps);
for (u32 DepIdx = 0; DepIdx < NumAreaDeps; DepIdx++)
for (uint32 DepIdx = 0; DepIdx < NumAreaDeps; DepIdx++)
{
CAssetID AssetID(*mpMREA, EGame::Corruption);
mpMREA->Skip(4);
@@ -462,17 +462,17 @@ void CAreaLoader::ReadLightsCorruption()
{
mpSectionMgr->ToSection(mLightsBlockNum);
u32 BabeDead = mpMREA->ReadLong();
uint32 BabeDead = mpMREA->ReadLong();
if (BabeDead != 0xbabedead) return;
mpArea->mLightLayers.resize(4);
for (u32 iLayer = 0; iLayer < 4; iLayer++)
for (uint32 iLayer = 0; iLayer < 4; iLayer++)
{
u32 NumLights = mpMREA->ReadLong();
uint32 NumLights = mpMREA->ReadLong();
mpArea->mLightLayers[iLayer].resize(NumLights);
for (u32 iLight = 0; iLight < NumLights; iLight++)
for (uint32 iLight = 0; iLight < NumLights; iLight++)
{
ELightType Type = (ELightType) mpMREA->ReadLong();
@@ -489,7 +489,7 @@ void CAreaLoader::ReadLightsCorruption()
float Multiplier = mpMREA->ReadFloat();
float SpotCutoff = mpMREA->ReadFloat();
mpMREA->Seek(0x9, SEEK_CUR);
u32 FalloffType = mpMREA->ReadLong();
uint32 FalloffType = mpMREA->ReadLong();
mpMREA->Seek(0x18, SEEK_CUR);
// Relevant data is read - now we process and form a CLight out of it
@@ -544,7 +544,7 @@ void CAreaLoader::ReadCompressedBlocks()
{
mTotalDecmpSize = 0;
for (u32 iClust = 0; iClust < mClusters.size(); iClust++)
for (uint32 iClust = 0; iClust < mClusters.size(); iClust++)
{
mClusters[iClust].BufferSize = mpMREA->ReadLong();
mClusters[iClust].DecompressedSize = mpMREA->ReadLong();
@@ -565,10 +565,10 @@ void CAreaLoader::Decompress()
if (mVersion < EGame::Echoes) return;
// Decompress clusters
mpDecmpBuffer = new u8[mTotalDecmpSize];
u32 Offset = 0;
mpDecmpBuffer = new uint8[mTotalDecmpSize];
uint32 Offset = 0;
for (u32 iClust = 0; iClust < mClusters.size(); iClust++)
for (uint32 iClust = 0; iClust < mClusters.size(); iClust++)
{
SCompressedCluster *pClust = &mClusters[iClust];
@@ -581,11 +581,11 @@ void CAreaLoader::Decompress()
else
{
u32 StartOffset = 32 - (mClusters[iClust].CompressedSize % 32); // For some reason they pad the beginning instead of the end
uint32 StartOffset = 32 - (mClusters[iClust].CompressedSize % 32); // For some reason they pad the beginning instead of the end
if (StartOffset != 32)
mpMREA->Seek(StartOffset, SEEK_CUR);
std::vector<u8> CompressedBuf(mClusters[iClust].CompressedSize);
std::vector<uint8> CompressedBuf(mClusters[iClust].CompressedSize);
mpMREA->ReadBytes(CompressedBuf.data(), CompressedBuf.size());
bool Success = CompressionUtil::DecompressSegmentedData(CompressedBuf.data(), CompressedBuf.size(), mpDecmpBuffer + Offset, pClust->DecompressedSize);
@@ -608,9 +608,9 @@ void CAreaLoader::LoadSectionDataBuffers()
mpArea->mSectionDataBuffers.resize(mpSectionMgr->NumSections());
mpSectionMgr->ToSection(0);
for (u32 iSec = 0; iSec < mpSectionMgr->NumSections(); iSec++)
for (uint32 iSec = 0; iSec < mpSectionMgr->NumSections(); iSec++)
{
u32 Size = mpSectionMgr->CurrentSectionSize();
uint32 Size = mpSectionMgr->CurrentSectionSize();
mpArea->mSectionDataBuffers[iSec].resize(Size);
mpMREA->ReadBytes(mpArea->mSectionDataBuffers[iSec].data(), mpArea->mSectionDataBuffers[iSec].size());
mpSectionMgr->ToNextSection();
@@ -645,14 +645,14 @@ void CAreaLoader::ReadEGMC()
void CAreaLoader::SetUpObjects(CScriptLayer *pGenLayer)
{
// Create instance map
for (u32 LayerIdx = 0; LayerIdx < mpArea->NumScriptLayers(); LayerIdx++)
for (uint32 LayerIdx = 0; LayerIdx < mpArea->NumScriptLayers(); LayerIdx++)
{
CScriptLayer *pLayer = mpArea->mScriptLayers[LayerIdx];
for (u32 InstIdx = 0; InstIdx < pLayer->NumInstances(); InstIdx++)
for (uint32 InstIdx = 0; InstIdx < pLayer->NumInstances(); InstIdx++)
{
CScriptObject *pInst = pLayer->InstanceByIndex(InstIdx);
u32 InstanceID = pInst->InstanceID();
uint32 InstanceID = pInst->InstanceID();
CScriptObject *pExisting = mpArea->InstanceByID(InstanceID);
ASSERT(pExisting == nullptr);
mpArea->mObjectMap[InstanceID] = pInst;
@@ -665,13 +665,13 @@ void CAreaLoader::SetUpObjects(CScriptLayer *pGenLayer)
while (pGenLayer->NumInstances() != 0)
{
CScriptObject *pInst = pGenLayer->InstanceByIndex(0);
u32 InstanceID = pInst->InstanceID();
uint32 InstanceID = pInst->InstanceID();
// Check if this is a duplicate of an existing instance (this only happens with DKCR GenericCreature as far as I'm aware)
if (mpArea->InstanceByID(InstanceID) != nullptr)
{
if (pInst->ObjectTypeID() != FOURCC('GCTR'))
Log::Write("Duplicate SCGN object: [" + pInst->Template()->Name() + "] " + pInst->InstanceName() + " (" + TString::HexString(pInst->InstanceID(), 8, false) + ")");
debugf("Duplicate SCGN object: [%s] %s (%08X)", *pInst->Template()->Name(), *pInst->InstanceName(), pInst->InstanceID());
pGenLayer->RemoveInstance(pInst);
delete pInst;
@@ -679,7 +679,7 @@ void CAreaLoader::SetUpObjects(CScriptLayer *pGenLayer)
else
{
u32 LayerIdx = (InstanceID >> 26) & 0x3F;
uint32 LayerIdx = (InstanceID >> 26) & 0x3F;
pInst->SetLayer( mpArea->ScriptLayer(LayerIdx) );
mpArea->mObjectMap[InstanceID] = pInst;
}
@@ -692,7 +692,7 @@ void CAreaLoader::SetUpObjects(CScriptLayer *pGenLayer)
CScriptObject *pInst = Iter->second;
// Store outgoing connections
for (u32 iCon = 0; iCon < pInst->NumLinks(eOutgoing); iCon++)
for (uint32 iCon = 0; iCon < pInst->NumLinks(eOutgoing); iCon++)
{
CLink *pLink = pInst->Link(eOutgoing, iCon);
mConnectionMap[pLink->ReceiverID()].push_back(pLink);
@@ -713,7 +713,7 @@ void CAreaLoader::SetUpObjects(CScriptLayer *pGenLayer)
// Store connections
for (auto it = mpArea->mObjectMap.begin(); it != mpArea->mObjectMap.end(); it++)
{
u32 InstanceID = it->first;
uint32 InstanceID = it->first;
auto iConMap = mConnectionMap.find(InstanceID);
if (iConMap != mConnectionMap.end())
@@ -732,16 +732,16 @@ CGameArea* CAreaLoader::LoadMREA(IInputStream& MREA, CResourceEntry *pEntry)
// Validation
if (!MREA.IsValid()) return nullptr;
u32 DeadBeef = MREA.ReadLong();
uint32 DeadBeef = MREA.ReadLong();
if (DeadBeef != 0xdeadbeef)
{
Log::FileError(MREA.GetSourceString(), "Invalid MREA magic: " + TString::HexString(DeadBeef));
errorf("%s: Invalid MREA magic: 0x%08X", *MREA.GetSourceString(), DeadBeef);
return nullptr;
}
// Header
Loader.mpArea = new CGameArea(pEntry);
u32 Version = MREA.ReadLong();
uint32 Version = MREA.ReadLong();
Loader.mVersion = GetFormatVersion(Version);
Loader.mpMREA = &MREA;
@@ -803,7 +803,7 @@ CGameArea* CAreaLoader::LoadMREA(IInputStream& MREA, CResourceEntry *pEntry)
}
break;
default:
Log::FileError(MREA.GetSourceString(), "Unsupported MREA version: " + TString::HexString(Version, 0));
errorf("%s: Unsupported MREA version: 0x%X", *MREA.GetSourceString(), Version);
Loader.mpArea.Delete();
return nullptr;
}
@@ -813,7 +813,7 @@ CGameArea* CAreaLoader::LoadMREA(IInputStream& MREA, CResourceEntry *pEntry)
return Loader.mpArea;
}
EGame CAreaLoader::GetFormatVersion(u32 Version)
EGame CAreaLoader::GetFormatVersion(uint32 Version)
{
switch (Version)
{

View File

@@ -17,38 +17,38 @@ class CAreaLoader
IInputStream *mpMREA;
CSectionMgrIn *mpSectionMgr;
EGame mVersion;
u32 mNumMeshes;
u32 mNumLayers;
uint32 mNumMeshes;
uint32 mNumLayers;
// Object connections
std::unordered_map<u32, std::vector<CLink*>> mConnectionMap;
std::unordered_map<uint32, std::vector<CLink*>> mConnectionMap;
// Compression
u8 *mpDecmpBuffer;
uint8 *mpDecmpBuffer;
bool mHasDecompressedBuffer;
std::vector<SCompressedCluster> mClusters;
u32 mTotalDecmpSize;
uint32 mTotalDecmpSize;
// Block numbers
u32 mGeometryBlockNum;
u32 mScriptLayerBlockNum;
u32 mCollisionBlockNum;
u32 mUnknownBlockNum;
u32 mLightsBlockNum;
u32 mVisiBlockNum;
u32 mPathBlockNum;
u32 mOctreeBlockNum;
u32 mScriptGeneratorBlockNum;
u32 mFFFFBlockNum;
u32 mPTLABlockNum;
u32 mEGMCBlockNum;
u32 mBoundingBoxesBlockNum;
u32 mDependenciesBlockNum;
u32 mGPUBlockNum;
u32 mRSOBlockNum;
uint32 mGeometryBlockNum;
uint32 mScriptLayerBlockNum;
uint32 mCollisionBlockNum;
uint32 mUnknownBlockNum;
uint32 mLightsBlockNum;
uint32 mVisiBlockNum;
uint32 mPathBlockNum;
uint32 mOctreeBlockNum;
uint32 mScriptGeneratorBlockNum;
uint32 mFFFFBlockNum;
uint32 mPTLABlockNum;
uint32 mEGMCBlockNum;
uint32 mBoundingBoxesBlockNum;
uint32 mDependenciesBlockNum;
uint32 mGPUBlockNum;
uint32 mRSOBlockNum;
struct SCompressedCluster {
u32 BufferSize, DecompressedSize, CompressedSize, NumSections;
uint32 BufferSize, DecompressedSize, CompressedSize, NumSections;
};
CAreaLoader();
@@ -82,7 +82,7 @@ class CAreaLoader
public:
static CGameArea* LoadMREA(IInputStream& rMREA, CResourceEntry *pEntry);
static EGame GetFormatVersion(u32 Version);
static EGame GetFormatVersion(uint32 Version);
};
#endif // CAREALOADER_H

View File

@@ -4,7 +4,7 @@ CAudioGroup* CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CResourceEntry *pE
{
// For now we only load sound define IDs and the group ID!
// Version check
u32 Check = rAGSC.PeekLong();
uint32 Check = rAGSC.PeekLong();
EGame Game = (Check == 0x1 ? EGame::Echoes : EGame::Prime);
CAudioGroup *pOut = new CAudioGroup(pEntry);
@@ -13,7 +13,7 @@ CAudioGroup* CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CResourceEntry *pE
{
rAGSC.ReadString();
pOut->mGroupName = rAGSC.ReadString();
u32 PoolSize = rAGSC.ReadLong();
uint32 PoolSize = rAGSC.ReadLong();
rAGSC.Seek(PoolSize + 0x4, SEEK_CUR);
}
@@ -22,21 +22,21 @@ CAudioGroup* CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CResourceEntry *pE
rAGSC.Seek(0x4, SEEK_CUR);
pOut->mGroupName = rAGSC.ReadString();
pOut->mGroupID = rAGSC.ReadShort();
u32 PoolSize = rAGSC.ReadLong();
uint32 PoolSize = rAGSC.ReadLong();
rAGSC.Seek(0xC + PoolSize, SEEK_CUR);
}
// Read needed data from the Proj chunk
u16 Peek = rAGSC.PeekShort();
uint16 Peek = rAGSC.PeekShort();
if (Peek != 0xFFFF)
{
u32 ProjStart = rAGSC.Tell();
uint32 ProjStart = rAGSC.Tell();
rAGSC.Seek(0x4, SEEK_CUR);
u16 GroupID = rAGSC.ReadShort();
u16 GroupType = rAGSC.ReadShort();
uint16 GroupID = rAGSC.ReadShort();
uint16 GroupType = rAGSC.ReadShort();
rAGSC.Seek(0x14, SEEK_CUR);
u32 SfxTableStart = rAGSC.ReadLong();
uint32 SfxTableStart = rAGSC.ReadLong();
if (Game == EGame::Prime)
pOut->mGroupID = GroupID;
@@ -46,10 +46,10 @@ CAudioGroup* CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CResourceEntry *pE
if (GroupType == 1)
{
rAGSC.Seek(ProjStart + SfxTableStart, SEEK_SET);
u16 NumSounds = rAGSC.ReadShort();
uint16 NumSounds = rAGSC.ReadShort();
rAGSC.Seek(0x2, SEEK_CUR);
for (u32 iSfx = 0; iSfx < NumSounds; iSfx++)
for (uint32 iSfx = 0; iSfx < NumSounds; iSfx++)
{
pOut->mDefineIDs.push_back( rAGSC.ReadShort() );
rAGSC.Seek(0x8, SEEK_CUR);
@@ -63,9 +63,9 @@ CAudioGroup* CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CResourceEntry *pE
CAudioLookupTable* CAudioGroupLoader::LoadATBL(IInputStream& rATBL, CResourceEntry *pEntry)
{
CAudioLookupTable *pOut = new CAudioLookupTable(pEntry);
u32 NumMacroIDs = rATBL.ReadLong();
uint32 NumMacroIDs = rATBL.ReadLong();
for (u32 iMacro = 0; iMacro < NumMacroIDs; iMacro++)
for (uint32 iMacro = 0; iMacro < NumMacroIDs; iMacro++)
pOut->mDefineIDs.push_back( rATBL.ReadShort() );
return pOut;
@@ -74,10 +74,10 @@ CAudioLookupTable* CAudioGroupLoader::LoadATBL(IInputStream& rATBL, CResourceEnt
CStringList* CAudioGroupLoader::LoadSTLC(IInputStream& rSTLC, CResourceEntry *pEntry)
{
CStringList *pOut = new CStringList(pEntry);
u32 NumStrings = rSTLC.ReadLong();
uint32 NumStrings = rSTLC.ReadLong();
pOut->mStringList.reserve(NumStrings);
for (u32 iStr = 0; iStr < NumStrings; iStr++)
for (uint32 iStr = 0; iStr < NumStrings; iStr++)
pOut->mStringList.push_back( rSTLC.ReadString() );
return pOut;

View File

@@ -32,14 +32,14 @@ void CCollisionLoader::ParseOBBNode(IInputStream& rDCLN)
if (!b) ParseOBBNode(rDCLN);
}
u32 NumFaces = rDCLN.ReadLong();
uint32 NumFaces = rDCLN.ReadLong();
rDCLN.Seek(NumFaces * 2, SEEK_CUR);
}
void CCollisionLoader::ReadPropertyFlags(IInputStream& rSrc)
{
CCollisionMaterial Material;
u64 RawFlags = (mVersion <= EGame::Prime ? rSrc.ReadLong() : rSrc.ReadLongLong());
uint64 RawFlags = (mVersion <= EGame::Prime ? rSrc.ReadLong() : rSrc.ReadLongLong());
Material.mRawFlags = RawFlags;
if (mVersion <= EGame::Prime)
@@ -116,27 +116,27 @@ void CCollisionLoader::ReadPropertyFlags(IInputStream& rSrc)
void CCollisionLoader::LoadCollisionIndices(IInputStream &rFile, bool BuildAABox)
{
// Properties
u32 PropSetCount = rFile.ReadLong();
for (u32 iProp = 0; iProp < PropSetCount; iProp++)
uint32 PropSetCount = rFile.ReadLong();
for (uint32 iProp = 0; iProp < PropSetCount; iProp++)
ReadPropertyFlags(rFile);
// Property indices for vertices/lines/faces
u32 VtxIndexCount = rFile.ReadLong();
std::vector<u8> VtxIndices(VtxIndexCount);
uint32 VtxIndexCount = rFile.ReadLong();
std::vector<uint8> VtxIndices(VtxIndexCount);
rFile.ReadBytes(VtxIndices.data(), VtxIndices.size());
u32 LineIndexCount = rFile.ReadLong();
std::vector<u8> LineIndices(LineIndexCount);
uint32 LineIndexCount = rFile.ReadLong();
std::vector<uint8> LineIndices(LineIndexCount);
rFile.ReadBytes(LineIndices.data(), LineIndices.size());
u32 FaceIndexCount = rFile.ReadLong();
std::vector<u8> FaceIndices(FaceIndexCount);
uint32 FaceIndexCount = rFile.ReadLong();
std::vector<uint8> FaceIndices(FaceIndexCount);
rFile.ReadBytes(FaceIndices.data(), FaceIndices.size());
// Lines
mpMesh->mLineCount = rFile.ReadLong();
mpMesh->mCollisionLines.resize(mpMesh->mLineCount);
for (u32 iLine = 0; iLine < mpMesh->mLineCount; iLine++)
for (uint32 iLine = 0; iLine < mpMesh->mLineCount; iLine++)
{
CCollisionMesh::CCollisionLine *pLine = &mpMesh->mCollisionLines[iLine];
pLine->Vertices[0] = rFile.ReadShort();
@@ -148,7 +148,7 @@ void CCollisionLoader::LoadCollisionIndices(IInputStream &rFile, bool BuildAABox
mpMesh->mFaceCount = rFile.ReadLong() / 3; // Not sure why they store it this way. It's inconsistent.
mpMesh->mCollisionFaces.resize(mpMesh->mFaceCount);
for (u32 iFace = 0; iFace < mpMesh->mFaceCount; iFace++)
for (uint32 iFace = 0; iFace < mpMesh->mFaceCount; iFace++)
{
CCollisionMesh::CCollisionFace *pFace = &mpMesh->mCollisionFaces[iFace];
pFace->Lines[0] = rFile.ReadShort();
@@ -160,7 +160,7 @@ void CCollisionLoader::LoadCollisionIndices(IInputStream &rFile, bool BuildAABox
// Echoes introduces a new data chunk; don't know what it is yet, skipping for now
if (mVersion >= EGame::Echoes)
{
u32 UnknownCount = rFile.ReadLong();
uint32 UnknownCount = rFile.ReadLong();
rFile.Seek(UnknownCount * 2, SEEK_CUR);
}
@@ -169,7 +169,7 @@ void CCollisionLoader::LoadCollisionIndices(IInputStream &rFile, bool BuildAABox
mpMesh->mCollisionVertices.resize(mpMesh->mVertexCount);
CAABox Bounds;
for (u32 iVtx = 0; iVtx < mpMesh->mVertexCount; iVtx++)
for (uint32 iVtx = 0; iVtx < mpMesh->mVertexCount; iVtx++)
{
CCollisionMesh::CCollisionVertex *pVtx = &mpMesh->mCollisionVertices[iVtx];
pVtx->Pos = CVector3f(rFile);
@@ -186,10 +186,10 @@ CCollisionMeshGroup* CCollisionLoader::LoadAreaCollision(IInputStream& rMREA)
CCollisionLoader loader;
rMREA.Seek(0x8, SEEK_CUR);
u32 DeafBabe = rMREA.ReadLong();
uint32 DeafBabe = rMREA.ReadLong();
if (DeafBabe != 0xDEAFBABE)
{
Log::FileError(rMREA.GetSourceString(), rMREA.Tell() - 4, "Invalid collision magic: " + TString::HexString(DeafBabe));
errorf("%s [0x%X]: Invalid collision magic: 0x%08X", *rMREA.GetSourceString(), rMREA.Tell() - 4, DeafBabe);
return nullptr;
}
@@ -201,7 +201,7 @@ CCollisionMeshGroup* CCollisionLoader::LoadAreaCollision(IInputStream& rMREA)
// Octree - structure is known, but not coding this right now
loader.mpMesh->mAABox = CAABox(rMREA);
rMREA.Seek(0x4, SEEK_CUR);
u32 OctreeSize = rMREA.ReadLong();
uint32 OctreeSize = rMREA.ReadLong();
rMREA.Seek(OctreeSize, SEEK_CUR); // Skipping the octree for now
loader.mpMesh->mOctreeLoaded = false;
@@ -218,15 +218,15 @@ CCollisionMeshGroup* CCollisionLoader::LoadDCLN(IInputStream& rDCLN, CResourceEn
CCollisionLoader Loader;
Loader.mpGroup = new CCollisionMeshGroup(pEntry);
u32 NumMeshes = rDCLN.ReadLong();
uint32 NumMeshes = rDCLN.ReadLong();
for (u32 iMesh = 0; iMesh < NumMeshes; iMesh++)
for (uint32 iMesh = 0; iMesh < NumMeshes; iMesh++)
{
u32 DeafBabe = rDCLN.ReadLong();
uint32 DeafBabe = rDCLN.ReadLong();
if (DeafBabe != 0xDEAFBABE)
{
Log::FileError(rDCLN.GetSourceString(), rDCLN.Tell() - 4, "Invalid collision magic: " + TString::HexString(DeafBabe));
errorf("%s [0x%X]: Invalid collision magic: 0x%08X", *rDCLN.GetSourceString(), rDCLN.Tell() - 4, DeafBabe);
Loader.mpGroup.Delete();
return nullptr;
}
@@ -250,7 +250,7 @@ CCollisionMeshGroup* CCollisionLoader::LoadDCLN(IInputStream& rDCLN, CResourceEn
return Loader.mpGroup;
}
EGame CCollisionLoader::GetFormatVersion(u32 Version)
EGame CCollisionLoader::GetFormatVersion(uint32 Version)
{
switch (Version)
{

View File

@@ -22,7 +22,7 @@ class CCollisionLoader
public:
static CCollisionMeshGroup* LoadAreaCollision(IInputStream& rMREA);
static CCollisionMeshGroup* LoadDCLN(IInputStream& rDCLN, CResourceEntry *pEntry);
static EGame GetFormatVersion(u32 Version);
static EGame GetFormatVersion(uint32 Version);
};
#endif // CCOLLISIONLOADER_H

View File

@@ -1,12 +1,12 @@
#include "CDependencyGroupLoader.h"
#include <Common/AssertMacro.h>
#include <Common/Macros.h>
EGame CDependencyGroupLoader::VersionTest(IInputStream& rDGRP, u32 DepCount)
EGame CDependencyGroupLoader::VersionTest(IInputStream& rDGRP, uint32 DepCount)
{
// Only difference between versions is asset ID length. Just check for EOF with 32-bit ID length.
u32 Start = rDGRP.Tell();
uint32 Start = rDGRP.Tell();
rDGRP.Seek(DepCount * 8, SEEK_CUR);
u32 Remaining = rDGRP.Size() - rDGRP.Tell();
uint32 Remaining = rDGRP.Size() - rDGRP.Tell();
EGame Game = EGame::CorruptionProto;
@@ -14,9 +14,9 @@ EGame CDependencyGroupLoader::VersionTest(IInputStream& rDGRP, u32 DepCount)
{
bool IsEOF = true;
for (u32 iRem = 0; iRem < Remaining; iRem++)
for (uint32 iRem = 0; iRem < Remaining; iRem++)
{
u8 Byte = rDGRP.ReadByte();
uint8 Byte = rDGRP.ReadByte();
if (Byte != 0xFF)
{
@@ -36,12 +36,12 @@ CDependencyGroup* CDependencyGroupLoader::LoadDGRP(IInputStream& rDGRP, CResourc
{
if (!rDGRP.IsValid()) return nullptr;
u32 NumDependencies = rDGRP.ReadLong();
uint32 NumDependencies = rDGRP.ReadLong();
EGame Game = VersionTest(rDGRP, NumDependencies);
CDependencyGroup *pGroup = new CDependencyGroup(pEntry);
for (u32 iDep = 0; iDep < NumDependencies; iDep++)
for (uint32 iDep = 0; iDep < NumDependencies; iDep++)
{
rDGRP.Seek(0x4, SEEK_CUR); // Skip dependency type
CAssetID AssetID(rDGRP, Game);

View File

@@ -7,7 +7,7 @@
class CDependencyGroupLoader
{
CDependencyGroupLoader() {}
static EGame VersionTest(IInputStream& rDGRP, u32 DepCount);
static EGame VersionTest(IInputStream& rDGRP, uint32 DepCount);
public:
static CDependencyGroup* LoadDGRP(IInputStream& rDGRP, CResourceEntry *pEntry);

View File

@@ -22,10 +22,10 @@ CFont* CFontLoader::LoadFont(IInputStream& rFONT)
else mpFont->mpFontTexture = gpResourceStore->LoadResource(rFONT.ReadLongLong(), eTexture);
mpFont->mTextureFormat = rFONT.ReadLong();
u32 NumGlyphs = rFONT.ReadLong();
uint32 NumGlyphs = rFONT.ReadLong();
mpFont->mGlyphs.reserve(NumGlyphs);
for (u32 iGlyph = 0; iGlyph < NumGlyphs; iGlyph++)
for (uint32 iGlyph = 0; iGlyph < NumGlyphs; iGlyph++)
{
CFont::SGlyph Glyph;
Glyph.Character = rFONT.ReadShort();
@@ -64,10 +64,10 @@ CFont* CFontLoader::LoadFont(IInputStream& rFONT)
mpFont->mGlyphs[Glyph.Character] = Glyph;
}
u32 NumKerningPairs = rFONT.ReadLong();
uint32 NumKerningPairs = rFONT.ReadLong();
mpFont->mKerningTable.reserve(NumKerningPairs);
for (u32 iKern = 0; iKern < NumKerningPairs; iKern++)
for (uint32 iKern = 0; iKern < NumKerningPairs; iKern++)
{
CFont::SKerningPair Pair;
Pair.CharacterA = rFONT.ReadShort();
@@ -84,17 +84,17 @@ CFont* CFontLoader::LoadFONT(IInputStream& rFONT, CResourceEntry *pEntry)
if (!rFONT.IsValid()) return nullptr;
CFourCC Magic(rFONT);
if (Magic != "FONT")
if (Magic != FOURCC('FONT'))
{
Log::FileError(rFONT.GetSourceString(), "Invalid FONT magic: " + TString::HexString(Magic.ToLong()));
errorf("%s: Invalid FONT magic: 0x%08X", *rFONT.GetSourceString(), Magic.ToLong());
return nullptr;
}
u32 FileVersion = rFONT.ReadLong();
uint32 FileVersion = rFONT.ReadLong();
EGame Version = GetFormatVersion(FileVersion);
if (Version == EGame::Invalid)
{
Log::FileError(rFONT.GetSourceString(), "Unsupported FONT version: " + TString::HexString(FileVersion, 0));
errorf("%s: Unsupported FONT version: %d", *rFONT.GetSourceString(), FileVersion);
return nullptr;
}
@@ -104,7 +104,7 @@ CFont* CFontLoader::LoadFONT(IInputStream& rFONT, CResourceEntry *pEntry)
return Loader.LoadFont(rFONT);
}
EGame CFontLoader::GetFormatVersion(u32 Version)
EGame CFontLoader::GetFormatVersion(uint32 Version)
{
switch (Version)
{

View File

@@ -15,7 +15,7 @@ class CFontLoader
public:
static CFont* LoadFONT(IInputStream& rFONT, CResourceEntry *pEntry);
static EGame GetFormatVersion(u32 Version);
static EGame GetFormatVersion(uint32 Version);
};
#endif // CFONTLOADER_H

View File

@@ -15,7 +15,7 @@ CMaterialLoader::~CMaterialLoader()
{
}
FVertexDescription CMaterialLoader::ConvertToVertexDescription(u32 VertexFlags)
FVertexDescription CMaterialLoader::ConvertToVertexDescription(uint32 VertexFlags)
{
FVertexDescription Desc;
if (VertexFlags & 0x00000003) Desc |= ePosition;
@@ -44,24 +44,24 @@ FVertexDescription CMaterialLoader::ConvertToVertexDescription(u32 VertexFlags)
void CMaterialLoader::ReadPrimeMatSet()
{
// Textures
u32 NumTextures = mpFile->ReadLong();
uint32 NumTextures = mpFile->ReadLong();
mTextures.resize(NumTextures);
for (u32 iTex = 0; iTex < NumTextures; iTex++)
for (uint32 iTex = 0; iTex < NumTextures; iTex++)
{
u32 TextureID = mpFile->ReadLong();
uint32 TextureID = mpFile->ReadLong();
mTextures[iTex] = gpResourceStore->LoadResource<CTexture>(TextureID);
}
// Materials
u32 NumMats = mpFile->ReadLong();
std::vector<u32> Offsets(NumMats);
for (u32 iMat = 0; iMat < NumMats; iMat++)
uint32 NumMats = mpFile->ReadLong();
std::vector<uint32> Offsets(NumMats);
for (uint32 iMat = 0; iMat < NumMats; iMat++)
Offsets[iMat] = mpFile->ReadLong();
u32 MatsStart = mpFile->Tell();
uint32 MatsStart = mpFile->Tell();
mpSet->mMaterials.resize(NumMats);
for (u32 iMat = 0; iMat < NumMats; iMat++)
for (uint32 iMat = 0; iMat < NumMats; iMat++)
{
mpSet->mMaterials[iMat] = ReadPrimeMaterial();
mpSet->mMaterials[iMat]->mVersion = mVersion;
@@ -79,12 +79,12 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
pMat->mOptions = (mpFile->ReadLong() & CMaterial::eAllMP1Settings);
// Textures
u32 NumTextures = mpFile->ReadLong();
std::vector<u32> TextureIndices(NumTextures);
uint32 NumTextures = mpFile->ReadLong();
std::vector<uint32> TextureIndices(NumTextures);
for (u32 iTex = 0; iTex < NumTextures; iTex++)
for (uint32 iTex = 0; iTex < NumTextures; iTex++)
{
u32 Index = mpFile->ReadLong();
uint32 Index = mpFile->ReadLong();
TextureIndices[iTex] = Index;
}
@@ -102,9 +102,9 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
// Konst
if (pMat->mOptions & CMaterial::eKonst)
{
u32 KonstCount = mpFile->ReadLong();
uint32 KonstCount = mpFile->ReadLong();
for (u32 iKonst = 0; iKonst < KonstCount; iKonst++)
for (uint32 iKonst = 0; iKonst < KonstCount; iKonst++)
{
if (iKonst >= 4) break;
pMat->mKonstColors[iKonst] = CColor(*mpFile, true);
@@ -119,33 +119,33 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
// Indirect texture
if (pMat->mOptions & CMaterial::eIndStage)
{
u32 IndTexIndex = mpFile->ReadLong();
uint32 IndTexIndex = mpFile->ReadLong();
pMat->mpIndirectTexture = mTextures[TextureIndices[IndTexIndex]];
}
// Color channels
u32 ChanCount = mpFile->ReadLong();
uint32 ChanCount = mpFile->ReadLong();
pMat->mLightingEnabled = ((mpFile->ReadLong() & 0x1) == 1);
mpFile->Seek((4 * ChanCount) - 4, SEEK_CUR);
// TEV
u32 TevCount = mpFile->ReadLong();
uint32 TevCount = mpFile->ReadLong();
pMat->mPasses.resize(TevCount);
for (u32 iTev = 0; iTev < TevCount; iTev++)
for (uint32 iTev = 0; iTev < TevCount; iTev++)
{
CMaterialPass *pPass = new CMaterialPass(pMat);
u32 ColorIn = mpFile->ReadLong();
u32 AlphaIn = mpFile->ReadLong();
uint32 ColorIn = mpFile->ReadLong();
uint32 AlphaIn = mpFile->ReadLong();
pPass->mColorOutput = (ETevOutput) ((mpFile->ReadLong() & 0x600) >> 9);
pPass->mAlphaOutput = (ETevOutput) ((mpFile->ReadLong() & 0x600) >> 9);
mpFile->Seek(0x1, SEEK_CUR); // Padding byte
pPass->mKAlphaSel = (ETevKSel) mpFile->ReadByte();
pPass->mKColorSel = (ETevKSel) mpFile->ReadByte();
pPass->mRasSel = (ETevRasSel) (u8) mpFile->ReadByte();
pPass->mRasSel = (ETevRasSel) (uint8) mpFile->ReadByte();
for (u32 iInput = 0; iInput < 4; iInput++)
for (uint32 iInput = 0; iInput < 4; iInput++)
{
pPass->mColorInputs[iInput] = (ETevColorInput) ((ColorIn >> (iInput * 5)) & 0xF);
pPass->mAlphaInputs[iInput] = (ETevAlphaInput) ((AlphaIn >> (iInput * 5)) & 0x7);
@@ -154,13 +154,13 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
pMat->mPasses[iTev] = pPass;
}
std::vector<u8> TevCoordIndices(TevCount);
for (u32 iTev = 0; iTev < TevCount; iTev++)
std::vector<uint8> TevCoordIndices(TevCount);
for (uint32 iTev = 0; iTev < TevCount; iTev++)
{
mpFile->Seek(0x2, SEEK_CUR);
CMaterialPass *pPass = pMat->Pass(iTev);
u8 TexSel = mpFile->ReadByte();
uint8 TexSel = mpFile->ReadByte();
if ((TexSel == 0xFF) || (TexSel >= TextureIndices.size()))
pPass->mpTexture = nullptr;
@@ -171,22 +171,22 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
}
// TexGens
u32 TexGenCount = mpFile->ReadLong();
std::vector<u32> TexGens(TexGenCount);
uint32 TexGenCount = mpFile->ReadLong();
std::vector<uint32> TexGens(TexGenCount);
for (u32 iTex = 0; iTex < TexGenCount; iTex++)
for (uint32 iTex = 0; iTex < TexGenCount; iTex++)
TexGens[iTex] = mpFile->ReadLong();
// UV animations
mpFile->Seek(0x4, SEEK_CUR); // Skipping UV anims size
u32 NumAnims = mpFile->ReadLong();
uint32 NumAnims = mpFile->ReadLong();
struct SUVAnim {
s32 Mode; float Params[4];
int32 Mode; float Params[4];
};
std::vector <SUVAnim> Anims(NumAnims);
for (u32 iAnim = 0; iAnim < NumAnims; iAnim++)
for (uint32 iAnim = 0; iAnim < NumAnims; iAnim++)
{
Anims[iAnim].Mode = mpFile->ReadLong();
@@ -210,16 +210,16 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
case 6: // Model Matrix
break;
default:
Log::FileError(mpFile->GetSourceString(), mpFile->Tell() - 4, "Unsupported animation mode encountered: " + TString::HexString((u32) Anims[iAnim].Mode));
errorf("%s [0x%X]: Unsupported animation mode encountered: %d", *mpFile->GetSourceString(), mpFile->Tell() - 4, Anims[iAnim].Mode);
break;
}
}
// Move TexGen and anims into passes
for (u32 iPass = 0; iPass < pMat->mPasses.size(); iPass++)
for (uint32 iPass = 0; iPass < pMat->mPasses.size(); iPass++)
{
CMaterialPass *pPass = pMat->mPasses[iPass];
u8 TexCoordIdx = TevCoordIndices[iPass];
uint8 TexCoordIdx = TevCoordIndices[iPass];
if ((TexGens.size() == 0) || (TexCoordIdx == 0xFF))
{
@@ -229,11 +229,11 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
else
{
pPass->mTexCoordSource = (u8) ((TexGens[TexCoordIdx] & 0x1F0) >> 4);
pPass->mTexCoordSource = (uint8) ((TexGens[TexCoordIdx] & 0x1F0) >> 4);
// Next step - find which animation is used by this pass
// Texture matrix is a reliable way to tell, because every UV anim mode generates a texture matrix
u32 TexMtxIdx = ((TexGens[TexCoordIdx] & 0x3E00) >> 9) / 3;
uint32 TexMtxIdx = ((TexGens[TexCoordIdx] & 0x3E00) >> 9) / 3;
if (TexMtxIdx == 10) pPass->mAnimMode = eNoUVAnim; // 10 is identity matrix; indicates no UV anim for this pass
@@ -241,7 +241,7 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
{
pPass->mAnimMode = (EUVAnimMode) Anims[TexMtxIdx].Mode;
for (u32 iParam = 0; iParam < 4; iParam++)
for (uint32 iParam = 0; iParam < 4; iParam++)
pPass->mAnimParams[iParam] = Anims[TexMtxIdx].Params[iParam];
}
}
@@ -252,13 +252,13 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
void CMaterialLoader::ReadCorruptionMatSet()
{
u32 NumMats = mpFile->ReadLong();
uint32 NumMats = mpFile->ReadLong();
mpSet->mMaterials.resize(NumMats);
for (u32 iMat = 0; iMat < NumMats; iMat++)
for (uint32 iMat = 0; iMat < NumMats; iMat++)
{
u32 Size = mpFile->ReadLong();
u32 Next = mpFile->Tell() + Size;
uint32 Size = mpFile->ReadLong();
uint32 Next = mpFile->Tell() + Size;
mpSet->mMaterials[iMat] = ReadCorruptionMaterial();
mpSet->mMaterials[iMat]->mVersion = mVersion;
mpSet->mMaterials[iMat]->mName = TString("Material #") + TString::FromInt32(iMat + 1, 0, 10);
@@ -273,7 +273,7 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
pMat->mEnableBloom = true;
// Flags
u32 Flags = mpFile->ReadLong();
uint32 Flags = mpFile->ReadLong();
if (Flags & 0x8)
{
pMat->mBlendSrcFac = GL_SRC_ALPHA;
@@ -317,7 +317,7 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
if (Type == "INT ")
{
CFourCC IntType = mpFile->ReadLong();
u8 IntVal = (u8) mpFile->ReadLong();
uint8 IntVal = (uint8) mpFile->ReadLong();
if (IntType == "OPAC")
{
@@ -352,14 +352,14 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
CMaterialPass *pPass = new CMaterialPass(pMat);
mPassOffsets.push_back(mpFile->Tell() - 4);
u32 Size = mpFile->ReadLong();
u32 Next = Size + mpFile->Tell();
uint32 Size = mpFile->ReadLong();
uint32 Next = Size + mpFile->Tell();
pPass->mPassType = mpFile->ReadLong();
pPass->mSettings = (CMaterialPass::EPassSettings) mpFile->ReadLong();
// Skip passes that don't have a texture. Honestly don't really know what to do with these right now
u64 TextureID = mpFile->ReadLongLong();
uint64 TextureID = mpFile->ReadLongLong();
if (TextureID == 0xFFFFFFFFFFFFFFFF)
{
//Log::FileWarning(mpFile->GetSourceString(), mPassOffsets.back(), "Skipping " + pPass->mPassType.ToString() + " pass with no texture");
@@ -369,8 +369,8 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
pPass->mpTexture = gpResourceStore->LoadResource<CTexture>(TextureID);
pPass->mTexCoordSource = 4 + (u8) mpFile->ReadLong();
u32 AnimSize = mpFile->ReadLong();
pPass->mTexCoordSource = 4 + (uint8) mpFile->ReadLong();
uint32 AnimSize = mpFile->ReadLong();
if (AnimSize > 0)
{
@@ -403,7 +403,7 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
case 11:
break;
default:
Log::FileError(mpFile->GetSourceString(), mpFile->Tell() - 8, "Unsupported animation mode encountered: " + TString::HexString((u32) pPass->mAnimMode));
errorf("%s [0x%X]: Unsupported animation mode encountered: %d", *mpFile->GetSourceString(), mpFile->Tell() - 8, pPass->mAnimMode);
break;
}
@@ -426,11 +426,11 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
void CMaterialLoader::CreateCorruptionPasses(CMaterial *pMat)
{
u32 NumPass = pMat->PassCount();
uint32 NumPass = pMat->PassCount();
bool Lightmap = false;
bool AlphaBlended = ((pMat->mBlendSrcFac == GL_SRC_ALPHA) && (pMat->mBlendDstFac == GL_ONE_MINUS_SRC_ALPHA));
for (u32 iPass = 0; iPass < NumPass; iPass++)
for (uint32 iPass = 0; iPass < NumPass; iPass++)
{
CMaterialPass *pPass = pMat->Pass(iPass);
CFourCC Type = pPass->Type();
@@ -611,8 +611,7 @@ void CMaterialLoader::CreateCorruptionPasses(CMaterial *pMat)
else
{
//
Log::FileError(mpFile->GetSourceString(), mPassOffsets[iPass], "Unsupported material pass type: " + Type.ToString());
errorf("%s [0x%X]: Unsupported material pass type: %s", *mpFile->GetSourceString(), mPassOffsets[iPass], *Type.ToString());
pPass->mEnabled = false;
}
}
@@ -664,7 +663,7 @@ CMaterialSet* CMaterialLoader::ImportAssimpMaterials(const aiScene *pScene, EGam
CMaterialSet *pOut = new CMaterialSet();
pOut->mMaterials.reserve(pScene->mNumMaterials);
for (u32 iMat = 0; iMat < pScene->mNumMaterials; iMat++)
for (uint32 iMat = 0; iMat < pScene->mNumMaterials; iMat++)
{
CMaterial *pMat = Loader.LoadAssimpMaterial(pScene->mMaterials[iMat]);
pOut->mMaterials.push_back(pMat);

View File

@@ -19,13 +19,13 @@ class CMaterialLoader
bool mHas0x400;
CColor mCorruptionColors[4];
u8 mCorruptionInts[5];
u32 mCorruptionFlags;
std::vector<u32> mPassOffsets;
uint8 mCorruptionInts[5];
uint32 mCorruptionFlags;
std::vector<uint32> mPassOffsets;
CMaterialLoader();
~CMaterialLoader();
FVertexDescription ConvertToVertexDescription(u32 VertexFlags);
FVertexDescription ConvertToVertexDescription(uint32 VertexFlags);
// Load Functions
void ReadPrimeMatSet();

View File

@@ -29,7 +29,7 @@ void CModelLoader::LoadAttribArrays(IInputStream& rModel)
mPositions.resize(mpSectionMgr->CurrentSectionSize() / 0x6);
float Divisor = 8192.f; // Might be incorrect! Needs verification via size comparison.
for (u32 iVtx = 0; iVtx < mPositions.size(); iVtx++)
for (uint32 iVtx = 0; iVtx < mPositions.size(); iVtx++)
{
float X = rModel.ReadShort() / Divisor;
float Y = rModel.ReadShort() / Divisor;
@@ -42,7 +42,7 @@ void CModelLoader::LoadAttribArrays(IInputStream& rModel)
{
mPositions.resize(mpSectionMgr->CurrentSectionSize() / 0xC);
for (u32 iVtx = 0; iVtx < mPositions.size(); iVtx++)
for (uint32 iVtx = 0; iVtx < mPositions.size(); iVtx++)
mPositions[iVtx] = CVector3f(rModel);
}
@@ -54,7 +54,7 @@ void CModelLoader::LoadAttribArrays(IInputStream& rModel)
mNormals.resize(mpSectionMgr->CurrentSectionSize() / 0x6);
float Divisor = (mVersion < EGame::DKCReturns) ? 32768.f : 16384.f;
for (u32 iVtx = 0; iVtx < mNormals.size(); iVtx++)
for (uint32 iVtx = 0; iVtx < mNormals.size(); iVtx++)
{
float X = rModel.ReadShort() / Divisor;
float Y = rModel.ReadShort() / Divisor;
@@ -66,7 +66,7 @@ void CModelLoader::LoadAttribArrays(IInputStream& rModel)
{
mNormals.resize(mpSectionMgr->CurrentSectionSize() / 0xC);
for (u32 iVtx = 0; iVtx < mNormals.size(); iVtx++)
for (uint32 iVtx = 0; iVtx < mNormals.size(); iVtx++)
mNormals[iVtx] = CVector3f(rModel);
}
@@ -75,7 +75,7 @@ void CModelLoader::LoadAttribArrays(IInputStream& rModel)
// Colors
mColors.resize(mpSectionMgr->CurrentSectionSize() / 4);
for (u32 iVtx = 0; iVtx < mColors.size(); iVtx++)
for (uint32 iVtx = 0; iVtx < mColors.size(); iVtx++)
mColors[iVtx] = CColor(rModel);
mpSectionMgr->ToNextSection();
@@ -84,7 +84,7 @@ void CModelLoader::LoadAttribArrays(IInputStream& rModel)
// Float UVs
mTex0.resize(mpSectionMgr->CurrentSectionSize() / 0x8);
for (u32 iVtx = 0; iVtx < mTex0.size(); iVtx++)
for (uint32 iVtx = 0; iVtx < mTex0.size(); iVtx++)
mTex0[iVtx] = CVector2f(rModel);
mpSectionMgr->ToNextSection();
@@ -95,7 +95,7 @@ void CModelLoader::LoadAttribArrays(IInputStream& rModel)
mTex1.resize(mpSectionMgr->CurrentSectionSize() / 0x4);
float Divisor = (mVersion < EGame::DKCReturns) ? 32768.f : 8192.f;
for (u32 iVtx = 0; iVtx < mTex1.size(); iVtx++)
for (uint32 iVtx = 0; iVtx < mTex1.size(); iVtx++)
{
float X = rModel.ReadShort() / Divisor;
float Y = rModel.ReadShort() / Divisor;
@@ -111,7 +111,7 @@ void CModelLoader::LoadSurfaceOffsets(IInputStream& rModel)
mSurfaceCount = rModel.ReadLong();
mSurfaceOffsets.resize(mSurfaceCount);
for (u32 iSurf = 0; iSurf < mSurfaceCount; iSurf++)
for (uint32 iSurf = 0; iSurf < mSurfaceCount; iSurf++)
mSurfaceOffsets[iSurf] = rModel.ReadLong();
mpSectionMgr->ToNextSection();
@@ -131,21 +131,21 @@ SSurface* CModelLoader::LoadSurface(IInputStream& rModel)
CMaterial *pMat = mMaterials[0]->MaterialByIndex(pSurf->MaterialID);
// Primitive table
u8 Flag = rModel.ReadByte();
u32 NextSurface = mpSectionMgr->NextOffset();
uint8 Flag = rModel.ReadByte();
uint32 NextSurface = mpSectionMgr->NextOffset();
while ((Flag != 0) && ((u32) rModel.Tell() < NextSurface))
while ((Flag != 0) && ((uint32) rModel.Tell() < NextSurface))
{
SSurface::SPrimitive Prim;
Prim.Type = EGXPrimitiveType(Flag & 0xF8);
u16 VertexCount = rModel.ReadShort();
uint16 VertexCount = rModel.ReadShort();
for (u16 iVtx = 0; iVtx < VertexCount; iVtx++)
for (uint16 iVtx = 0; iVtx < VertexCount; iVtx++)
{
CVertex Vtx;
FVertexDescription VtxDesc = pMat->VtxDesc();
for (u32 iMtxAttr = 0; iMtxAttr < 8; iMtxAttr++)
for (uint32 iMtxAttr = 0; iMtxAttr < 8; iMtxAttr++)
if (VtxDesc & (ePosMtx << iMtxAttr)) rModel.Seek(0x1, SEEK_CUR);
// Only thing to do here is check whether each attribute is present, and if so, read it.
@@ -155,7 +155,7 @@ SSurface* CModelLoader::LoadSurface(IInputStream& rModel)
// Position
if (VtxDesc & ePosition)
{
u16 PosIndex = rModel.ReadShort() & 0xFFFF;
uint16 PosIndex = rModel.ReadShort() & 0xFFFF;
Vtx.Position = mPositions[PosIndex];
Vtx.ArrayPosition = PosIndex;
@@ -167,7 +167,7 @@ SSurface* CModelLoader::LoadSurface(IInputStream& rModel)
Vtx.Normal = mNormals[rModel.ReadShort() & 0xFFFF];
// Color
for (u32 iClr = 0; iClr < 2; iClr++)
for (uint32 iClr = 0; iClr < 2; iClr++)
if (VtxDesc & (eColor0 << iClr))
Vtx.Color[iClr] = mColors[rModel.ReadShort() & 0xFFFF];
@@ -184,7 +184,7 @@ SSurface* CModelLoader::LoadSurface(IInputStream& rModel)
}
// Tex1-7
for (u32 iTex = 1; iTex < 7; iTex++)
for (uint32 iTex = 1; iTex < 7; iTex++)
if (VtxDesc & (eTex0 << iTex))
Vtx.Tex[iTex] = mTex0[rModel.ReadShort() & 0xFFFF];
}
@@ -192,7 +192,7 @@ SSurface* CModelLoader::LoadSurface(IInputStream& rModel)
else
{
// Tex0-7
for (u32 iTex = 0; iTex < 7; iTex++)
for (uint32 iTex = 0; iTex < 7; iTex++)
{
if (VtxDesc & (eTex0 << iTex))
{
@@ -235,7 +235,7 @@ void CModelLoader::LoadSurfaceHeaderPrime(IInputStream& rModel, SSurface *pSurf)
pSurf->MaterialID = rModel.ReadLong();
rModel.Seek(0xC, SEEK_CUR);
u32 ExtraSize = rModel.ReadLong();
uint32 ExtraSize = rModel.ReadLong();
pSurf->ReflectionDirection = CVector3f(rModel);
if (mVersion >= EGame::EchoesDemo)
@@ -260,10 +260,10 @@ void CModelLoader::LoadSurfaceHeaderDKCR(IInputStream& rModel, SSurface *pSurf)
{
pSurf->CenterPoint = CVector3f(rModel);
rModel.Seek(0xE, SEEK_CUR);
pSurf->MaterialID = (u32) rModel.ReadShort();
pSurf->MaterialID = (uint32) rModel.ReadShort();
rModel.Seek(0x2, SEEK_CUR);
mSurfaceUsingTex1 = (rModel.ReadByte() == 1);
u32 ExtraSize = rModel.ReadByte();
uint32 ExtraSize = rModel.ReadByte();
if (ExtraSize > 0)
{
@@ -288,7 +288,7 @@ SSurface* CModelLoader::LoadAssimpMesh(const aiMesh *pkMesh, CMaterialSet *pSet)
if (pkMesh->HasPositions()) Desc |= ePosition;
if (pkMesh->HasNormals()) Desc |= eNormal;
for (u32 iUV = 0; iUV < pkMesh->GetNumUVChannels(); iUV++)
for (uint32 iUV = 0; iUV < pkMesh->GetNumUVChannels(); iUV++)
Desc |= (eTex0 << iUV);
pMat->SetVertexDescription(Desc);
@@ -312,7 +312,7 @@ SSurface* CModelLoader::LoadAssimpMesh(const aiMesh *pkMesh, CMaterialSet *pSet)
SSurface::SPrimitive& rPrim = pSurf->Primitives[0];
// Check primitive type on first face
u32 NumIndices = pkMesh->mFaces[0].mNumIndices;
uint32 NumIndices = pkMesh->mFaces[0].mNumIndices;
if (NumIndices == 1) rPrim.Type = eGX_Points;
else if (NumIndices == 2) rPrim.Type = eGX_Lines;
else if (NumIndices == 3) rPrim.Type = eGX_Triangles;
@@ -321,7 +321,7 @@ SSurface* CModelLoader::LoadAssimpMesh(const aiMesh *pkMesh, CMaterialSet *pSet)
pSurf->CenterPoint = CVector3f::skZero;
pSurf->ReflectionDirection = CVector3f::skZero;
for (u32 iVtx = 0; iVtx < pkMesh->mNumVertices; iVtx++)
for (uint32 iVtx = 0; iVtx < pkMesh->mNumVertices; iVtx++)
{
aiVector3D AiPos = pkMesh->mVertices[iVtx];
pSurf->AABox.ExpandBounds(CVector3f(AiPos.x, AiPos.y, AiPos.z));
@@ -343,11 +343,11 @@ SSurface* CModelLoader::LoadAssimpMesh(const aiMesh *pkMesh, CMaterialSet *pSet)
pSurf->TriangleCount = (rPrim.Type == eGX_Triangles ? pkMesh->mNumFaces : 0);
// Create primitive
for (u32 iFace = 0; iFace < pkMesh->mNumFaces; iFace++)
for (uint32 iFace = 0; iFace < pkMesh->mNumFaces; iFace++)
{
for (u32 iIndex = 0; iIndex < NumIndices; iIndex++)
for (uint32 iIndex = 0; iIndex < NumIndices; iIndex++)
{
u32 Index = pkMesh->mFaces[iFace].mIndices[iIndex];
uint32 Index = pkMesh->mFaces[iFace].mIndices[iIndex];
// Create vertex and add it to the primitive
CVertex Vert;
@@ -365,7 +365,7 @@ SSurface* CModelLoader::LoadAssimpMesh(const aiMesh *pkMesh, CMaterialSet *pSet)
Vert.Normal = CVector3f(AiNrm.x, AiNrm.y, AiNrm.z);
}
for (u32 iTex = 0; iTex < pkMesh->GetNumUVChannels(); iTex++)
for (uint32 iTex = 0; iTex < pkMesh->GetNumUVChannels(); iTex++)
{
aiVector3D AiTex = pkMesh->mTextureCoords[iTex][Index];
Vert.Tex[iTex] = CVector2f(AiTex.x, AiTex.y);
@@ -387,16 +387,16 @@ CModel* CModelLoader::LoadCMDL(IInputStream& rCMDL, CResourceEntry *pEntry)
CModelLoader Loader;
// CMDL header - same across the three Primes, but different structure in DKCR
u32 Magic = rCMDL.ReadLong();
uint32 Magic = rCMDL.ReadLong();
u32 Version, BlockCount, MatSetCount;
uint32 Version, BlockCount, MatSetCount;
CAABox AABox;
// 0xDEADBABE - Metroid Prime seres
if (Magic == 0xDEADBABE)
{
Version = rCMDL.ReadLong();
u32 Flags = rCMDL.ReadLong();
uint32 Flags = rCMDL.ReadLong();
AABox = CAABox(rCMDL);
BlockCount = rCMDL.ReadLong();
MatSetCount = rCMDL.ReadLong();
@@ -410,7 +410,7 @@ CModel* CModelLoader::LoadCMDL(IInputStream& rCMDL, CResourceEntry *pEntry)
else if (Magic == 0x9381000A)
{
Version = Magic & 0xFFFF;
u32 Flags = rCMDL.ReadLong();
uint32 Flags = rCMDL.ReadLong();
AABox = CAABox(rCMDL);
BlockCount = rCMDL.ReadLong();
MatSetCount = rCMDL.ReadLong();
@@ -425,11 +425,11 @@ CModel* CModelLoader::LoadCMDL(IInputStream& rCMDL, CResourceEntry *pEntry)
if (Flags & 0x10)
{
rCMDL.Seek(0x4, SEEK_CUR);
u32 VisGroupCount = rCMDL.ReadLong();
uint32 VisGroupCount = rCMDL.ReadLong();
for (u32 iVis = 0; iVis < VisGroupCount; iVis++)
for (uint32 iVis = 0; iVis < VisGroupCount; iVis++)
{
u32 NameLength = rCMDL.ReadLong();
uint32 NameLength = rCMDL.ReadLong();
rCMDL.Seek(NameLength, SEEK_CUR);
}
@@ -439,7 +439,7 @@ CModel* CModelLoader::LoadCMDL(IInputStream& rCMDL, CResourceEntry *pEntry)
else
{
Log::FileError(rCMDL.GetSourceString(), "Invalid CMDL magic: " + TString::HexString(Magic));
errorf("%s: Invalid CMDL magic: 0x%08X", *rCMDL.GetSourceString(), Magic);
return nullptr;
}
@@ -448,7 +448,7 @@ CModel* CModelLoader::LoadCMDL(IInputStream& rCMDL, CResourceEntry *pEntry)
if (Loader.mVersion == EGame::Invalid)
{
Log::FileError(rCMDL.GetSourceString(), "Unsupported CMDL version: " + TString::HexString(Magic, 0));
errorf("%s: Unsupported CMDL version: 0x%X", *rCMDL.GetSourceString(), Magic);
return nullptr;
}
@@ -460,7 +460,7 @@ CModel* CModelLoader::LoadCMDL(IInputStream& rCMDL, CResourceEntry *pEntry)
// Materials
Loader.mMaterials.resize(MatSetCount);
for (u32 iSet = 0; iSet < MatSetCount; iSet++)
for (uint32 iSet = 0; iSet < MatSetCount; iSet++)
{
Loader.mMaterials[iSet] = CMaterialLoader::LoadMaterialSet(rCMDL, Loader.mVersion);
@@ -477,7 +477,7 @@ CModel* CModelLoader::LoadCMDL(IInputStream& rCMDL, CResourceEntry *pEntry)
Loader.LoadSurfaceOffsets(rCMDL);
pModel->mSurfaces.reserve(Loader.mSurfaceCount);
for (u32 iSurf = 0; iSurf < Loader.mSurfaceCount; iSurf++)
for (uint32 iSurf = 0; iSurf < Loader.mSurfaceCount; iSurf++)
{
SSurface *pSurf = Loader.LoadSurface(rCMDL);
pModel->mSurfaces.push_back(pSurf);
@@ -514,7 +514,7 @@ CModel* CModelLoader::LoadWorldModel(IInputStream& rMREA, CSectionMgrIn& rBlockM
pModel->mSurfaces.reserve(Loader.mSurfaceCount);
pModel->mHasOwnSurfaces = true;
for (u32 iSurf = 0; iSurf < Loader.mSurfaceCount; iSurf++)
for (uint32 iSurf = 0; iSurf < Loader.mSurfaceCount; iSurf++)
{
SSurface *pSurf = Loader.LoadSurface(rMREA);
pModel->mSurfaces.push_back(pSurf);
@@ -526,7 +526,7 @@ CModel* CModelLoader::LoadWorldModel(IInputStream& rMREA, CSectionMgrIn& rBlockM
return pModel;
}
CModel* CModelLoader::LoadCorruptionWorldModel(IInputStream& rMREA, CSectionMgrIn& rBlockMgr, CMaterialSet& rMatSet, u32 HeaderSecNum, u32 GPUSecNum, EGame Version)
CModel* CModelLoader::LoadCorruptionWorldModel(IInputStream& rMREA, CSectionMgrIn& rBlockMgr, CMaterialSet& rMatSet, uint32 HeaderSecNum, uint32 GPUSecNum, EGame Version)
{
CModelLoader Loader;
Loader.mpSectionMgr = &rBlockMgr;
@@ -550,7 +550,7 @@ CModel* CModelLoader::LoadCorruptionWorldModel(IInputStream& rMREA, CSectionMgrI
pModel->mSurfaces.reserve(Loader.mSurfaceCount);
pModel->mHasOwnSurfaces = true;
for (u32 iSurf = 0; iSurf < Loader.mSurfaceCount; iSurf++)
for (uint32 iSurf = 0; iSurf < Loader.mSurfaceCount; iSurf++)
{
SSurface *pSurf = Loader.LoadSurface(rMREA);
pModel->mSurfaces.push_back(pSurf);
@@ -565,18 +565,18 @@ CModel* CModelLoader::LoadCorruptionWorldModel(IInputStream& rMREA, CSectionMgrI
void CModelLoader::BuildWorldMeshes(const std::vector<CModel*>& rkIn, std::vector<CModel*>& rOut, bool DeleteInputModels)
{
// This function takes the gigantic models with all surfaces combined from MP2/3/DKCR and splits the surfaces to reform the original uncombined meshes.
std::map<u32, CModel*> OutputMap;
std::map<uint32, CModel*> OutputMap;
for (u32 iMdl = 0; iMdl < rkIn.size(); iMdl++)
for (uint32 iMdl = 0; iMdl < rkIn.size(); iMdl++)
{
CModel *pModel = rkIn[iMdl];
pModel->mHasOwnSurfaces = false;
pModel->mHasOwnMaterials = false;
for (u32 iSurf = 0; iSurf < pModel->mSurfaces.size(); iSurf++)
for (uint32 iSurf = 0; iSurf < pModel->mSurfaces.size(); iSurf++)
{
SSurface *pSurf = pModel->mSurfaces[iSurf];
u32 ID = (u32) pSurf->MeshID;
uint32 ID = (uint32) pSurf->MeshID;
auto Iter = OutputMap.find(ID);
// No model for this ID; create one!
@@ -619,9 +619,9 @@ CModel* CModelLoader::ImportAssimpNode(const aiNode *pkNode, const aiScene *pkSc
Loader.mpModel = new CModel(&rMatSet, true);
Loader.mpModel->mSurfaces.reserve(pkNode->mNumMeshes);
for (u32 iMesh = 0; iMesh < pkNode->mNumMeshes; iMesh++)
for (uint32 iMesh = 0; iMesh < pkNode->mNumMeshes; iMesh++)
{
u32 MeshIndex = pkNode->mMeshes[iMesh];
uint32 MeshIndex = pkNode->mMeshes[iMesh];
const aiMesh *pkMesh = pkScene->mMeshes[MeshIndex];
SSurface *pSurf = Loader.LoadAssimpMesh(pkMesh, &rMatSet);
@@ -634,7 +634,7 @@ CModel* CModelLoader::ImportAssimpNode(const aiNode *pkNode, const aiScene *pkSc
return Loader.mpModel;
}
EGame CModelLoader::GetFormatVersion(u32 Version)
EGame CModelLoader::GetFormatVersion(uint32 Version)
{
switch (Version)
{

View File

@@ -32,7 +32,7 @@ private:
CAABox mAABox;
EGame mVersion;
u32 mNumVertices;
uint32 mNumVertices;
std::vector<CVector3f> mPositions;
std::vector<CVector3f> mNormals;
std::vector<CColor> mColors;
@@ -40,8 +40,8 @@ private:
std::vector<CVector2f> mTex1;
bool mSurfaceUsingTex1;
u32 mSurfaceCount;
std::vector<u32> mSurfaceOffsets;
uint32 mSurfaceCount;
std::vector<uint32> mSurfaceOffsets;
FModelFlags mFlags;
@@ -59,10 +59,10 @@ private:
public:
static CModel* LoadCMDL(IInputStream& rCMDL, CResourceEntry *pEntry);
static CModel* LoadWorldModel(IInputStream& rMREA, CSectionMgrIn& rBlockMgr, CMaterialSet& rMatSet, EGame Version);
static CModel* LoadCorruptionWorldModel(IInputStream& rMREA, CSectionMgrIn& rBlockMgr, CMaterialSet& rMatSet, u32 HeaderSecNum, u32 GPUSecNum, EGame Version);
static CModel* LoadCorruptionWorldModel(IInputStream& rMREA, CSectionMgrIn& rBlockMgr, CMaterialSet& rMatSet, uint32 HeaderSecNum, uint32 GPUSecNum, EGame Version);
static void BuildWorldMeshes(const std::vector<CModel*>& rkIn, std::vector<CModel*>& rOut, bool DeleteInputModels);
static CModel* ImportAssimpNode(const aiNode *pkNode, const aiScene *pkScene, CMaterialSet& rMatSet);
static EGame GetFormatVersion(u32 Version);
static EGame GetFormatVersion(uint32 Version);
};
#endif // CMODELLOADER_H

View File

@@ -3,12 +3,12 @@
CPoiToWorld* CPoiToWorldLoader::LoadEGMC(IInputStream& rEGMC, CResourceEntry *pEntry)
{
CPoiToWorld *pOut = new CPoiToWorld(pEntry);
u32 NumMappings = rEGMC.ReadLong();
uint32 NumMappings = rEGMC.ReadLong();
for (u32 iMap = 0; iMap < NumMappings; iMap++)
for (uint32 iMap = 0; iMap < NumMappings; iMap++)
{
u32 MeshID = rEGMC.ReadLong();
u32 InstanceID = rEGMC.ReadLong() & 0x03FFFFFF;
uint32 MeshID = rEGMC.ReadLong();
uint32 InstanceID = rEGMC.ReadLong() & 0x03FFFFFF;
pOut->AddPoiMeshMap(InstanceID, MeshID);
}

View File

@@ -15,7 +15,7 @@ CScan* CScanLoader::LoadScanMP1(IInputStream& rSCAN)
mpScan->mCategory = (CScan::ELogbookCategory) rSCAN.ReadLong();
mpScan->mIsImportant = (rSCAN.ReadByte() == 1);
for (u32 iImg = 0; iImg < 4; iImg++)
for (uint32 iImg = 0; iImg < 4; iImg++)
{
mpScan->mScanImageTextures[iImg] = CAssetID(rSCAN, e32Bit);
rSCAN.Seek(0x18, SEEK_CUR);
@@ -28,40 +28,44 @@ CScan* CScanLoader::LoadScanMP2(IInputStream& rSCAN)
{
// The SCAN format in MP2 embeds a SNFO object using the same format as SCLY
// However since the contents of the file are consistent there's no need to delegate to CScriptLoader
rSCAN.Seek(0x1, SEEK_CUR);
u32 NumInstances = rSCAN.ReadLong();
rSCAN.Skip(0x1);
uint32 NumInstances = rSCAN.ReadLong();
if (NumInstances != 1) {
Log::FileError(rSCAN.GetSourceString(), "SCAN has multiple instances");
if (NumInstances != 1)
{
errorf("%s: SCAN has multiple instances", *rSCAN.GetSourceString());
return nullptr;
}
u32 ScanInfoStart = rSCAN.Tell();
uint32 ScanInfoStart = rSCAN.Tell();
CFourCC SNFO(rSCAN);
if (SNFO != "SNFO") {
Log::FileError(rSCAN.GetSourceString(), ScanInfoStart, "Unrecognized SCAN object type: " + SNFO.ToString());
if (SNFO != FOURCC('SNFO'))
{
errorf("%s [0x%X]: Unrecognized SCAN object type: %s", *rSCAN.GetSourceString(), ScanInfoStart, *SNFO.ToString());
return nullptr;
}
u16 InstanceSize = rSCAN.ReadShort();
u32 InstanceEnd = rSCAN.Tell() + InstanceSize;
rSCAN.Seek(0x4, SEEK_CUR);
uint16 InstanceSize = rSCAN.ReadShort();
uint32 InstanceEnd = rSCAN.Tell() + InstanceSize;
rSCAN.Skip(0x4);
u16 NumConnections = rSCAN.ReadShort();
if (NumConnections > 0) {
Log::FileWarning(rSCAN.GetSourceString(), ScanInfoStart, "SNFO object in SCAN has connections");
rSCAN.Seek(NumConnections * 0xC, SEEK_CUR);
uint16 NumConnections = rSCAN.ReadShort();
if (NumConnections > 0)
{
warnf("%s [0x%X]: SNFO object in SCAN has connections", *rSCAN.GetSourceString(), ScanInfoStart);
rSCAN.Skip(NumConnections * 0xC);
}
u32 BasePropID = rSCAN.ReadLong();
if (BasePropID != 0xFFFFFFFF) {
Log::FileError(rSCAN.GetSourceString(), rSCAN.Tell() - 4, "Invalid base property ID: " + TString::HexString(BasePropID));
uint32 BasePropID = rSCAN.ReadLong();
if (BasePropID != 0xFFFFFFFF)
{
errorf("%s [0x%X]: Invalid base property ID: 0x%08X", *rSCAN.GetSourceString(), rSCAN.Tell() - 4, BasePropID);
return nullptr;
}
rSCAN.Seek(0x2, SEEK_CUR);
u16 NumProperties = rSCAN.ReadShort();
rSCAN.Skip(0x2);
uint16 NumProperties = rSCAN.ReadShort();
switch (NumProperties)
{
@@ -77,7 +81,7 @@ CScan* CScanLoader::LoadScanMP2(IInputStream& rSCAN)
LoadParamsMP3(rSCAN, NumProperties);
break;
default:
Log::FileError(rSCAN.GetSourceString(), rSCAN.Tell() - 2, "Invalid SNFO property count: " + TString::HexString(NumProperties));
errorf("%s [0x%X]: Invalid SNFO property count: 0x%X", *rSCAN.GetSourceString(), rSCAN.Tell() - 2, NumProperties);
return nullptr;
}
@@ -85,9 +89,9 @@ CScan* CScanLoader::LoadScanMP2(IInputStream& rSCAN)
if (mpScan->Game() == EGame::Corruption)
{
rSCAN.GoTo(InstanceEnd);
u32 NumDeps = rSCAN.ReadLong();
uint32 NumDeps = rSCAN.ReadLong();
for (u32 DepIdx = 0; DepIdx < NumDeps; DepIdx++)
for (uint32 DepIdx = 0; DepIdx < NumDeps; DepIdx++)
{
rSCAN.Skip(4);
CAssetID ID(rSCAN, mpScan->Game());
@@ -98,16 +102,16 @@ CScan* CScanLoader::LoadScanMP2(IInputStream& rSCAN)
return mpScan;
}
void CScanLoader::LoadParamsMP2(IInputStream& rSCAN, u16 NumProperties)
void CScanLoader::LoadParamsMP2(IInputStream& rSCAN, uint16 NumProperties)
{
// Function begins after the SNFO property count
mpScan->mSecondaryModels.resize(9);
for (u32 iProp = 0; iProp < NumProperties; iProp++)
for (uint32 iProp = 0; iProp < NumProperties; iProp++)
{
u32 PropertyID = rSCAN.ReadLong();
u16 PropertySize = rSCAN.ReadShort();
u32 Next = rSCAN.Tell() + PropertySize;
uint32 PropertyID = rSCAN.ReadLong();
uint16 PropertySize = rSCAN.ReadShort();
uint32 Next = rSCAN.Tell() + PropertySize;
switch (PropertyID)
{
@@ -192,20 +196,20 @@ void CScanLoader::LoadParamsMP2(IInputStream& rSCAN, u16 NumProperties)
break;
}
rSCAN.Seek(Next, SEEK_SET);
rSCAN.GoTo(Next);
}
mpScan->mCategory = CScan::eNone;
}
void CScanLoader::LoadParamsMP3(IInputStream& rSCAN, u16 NumProperties)
void CScanLoader::LoadParamsMP3(IInputStream& rSCAN, uint16 NumProperties)
{
// Function begins after the SNFO property count
for (u32 iProp = 0; iProp < NumProperties; iProp++)
for (uint32 iProp = 0; iProp < NumProperties; iProp++)
{
u32 PropertyID = rSCAN.ReadLong();
u16 PropertySize = rSCAN.ReadShort();
u32 Next = rSCAN.Tell() + PropertySize;
uint32 PropertyID = rSCAN.ReadLong();
uint16 PropertySize = rSCAN.ReadShort();
uint32 Next = rSCAN.Tell() + PropertySize;
switch (PropertyID)
{
@@ -222,7 +226,7 @@ void CScanLoader::LoadParamsMP3(IInputStream& rSCAN, u16 NumProperties)
break;
}
rSCAN.Seek(Next, SEEK_SET);
rSCAN.GoTo(Next);
}
mpScan->mCategory = CScan::eNone;
@@ -230,13 +234,13 @@ void CScanLoader::LoadParamsMP3(IInputStream& rSCAN, u16 NumProperties)
void CScanLoader::LoadScanInfoSecondaryModel(IInputStream& rSCAN, CScan::SScanInfoSecondaryModel& rSecondaryModel)
{
u16 NumProperties = rSCAN.ReadShort();
uint16 NumProperties = rSCAN.ReadShort();
for (u32 iProp = 0; iProp < NumProperties; iProp++)
for (uint32 iProp = 0; iProp < NumProperties; iProp++)
{
u32 PropertyID = rSCAN.ReadLong();
u16 PropertySize = rSCAN.ReadShort();
u32 Next = rSCAN.Tell() + PropertySize;
uint32 PropertyID = rSCAN.ReadLong();
uint16 PropertySize = rSCAN.ReadShort();
uint32 Next = rSCAN.Tell() + PropertySize;
switch (PropertyID)
{
@@ -253,7 +257,7 @@ void CScanLoader::LoadScanInfoSecondaryModel(IInputStream& rSCAN, CScan::SScanIn
break;
}
rSCAN.Seek(Next, SEEK_SET);
rSCAN.GoTo(Next);
}
}
@@ -267,11 +271,11 @@ CScan* CScanLoader::LoadSCAN(IInputStream& rSCAN, CResourceEntry *pEntry)
* MP1 is the only one that starts with 5 so that is a consistent check for now
* Better version checks will be implemented when the other versions are
* better-understood. */
u32 FileVersion = rSCAN.ReadLong();
u32 Magic = rSCAN.ReadLong();
uint32 FileVersion = rSCAN.ReadLong();
uint32 Magic = rSCAN.ReadLong();
// Echoes+
if (CFourCC(FileVersion) == "SCAN")
if (FileVersion == FOURCC('SCAN'))
{
// The MP2 load function will check for MP3
CScanLoader Loader;
@@ -283,13 +287,13 @@ CScan* CScanLoader::LoadSCAN(IInputStream& rSCAN, CResourceEntry *pEntry)
if (Magic != 0x0BADBEEF)
{
Log::FileError(rSCAN.GetSourceString(), "Invalid SCAN magic: " + TString::HexString(Magic));
errorf("%s: Invalid SCAN magic: 0x%08X", *rSCAN.GetSourceString(), Magic);
return nullptr;
}
if (FileVersion != 5)
{
Log::FileError(rSCAN.GetSourceString(), "Unsupported SCAN version: " + TString::HexString(FileVersion, 0));
errorf("%s: Unsupported SCAN version: 0x%X", *rSCAN.GetSourceString(), FileVersion);
return nullptr;
}

View File

@@ -13,8 +13,8 @@ class CScanLoader
CScanLoader();
CScan* LoadScanMP1(IInputStream& rSCAN);
CScan* LoadScanMP2(IInputStream& rSCAN);
void LoadParamsMP2(IInputStream& rSCAN, u16 NumProperties);
void LoadParamsMP3(IInputStream& rSCAN, u16 NumProperties);
void LoadParamsMP2(IInputStream& rSCAN, uint16 NumProperties);
void LoadParamsMP3(IInputStream& rSCAN, uint16 NumProperties);
void LoadScanInfoSecondaryModel(IInputStream& rSCAN, CScan::SScanInfoSecondaryModel& rSecondaryModel);
public:

View File

@@ -19,7 +19,7 @@ CScriptLoader::CScriptLoader()
{
}
void CScriptLoader::ReadProperty(IProperty *pProp, u32 Size, IInputStream& rSCLY)
void CScriptLoader::ReadProperty(IProperty *pProp, uint32 Size, IInputStream& rSCLY)
{
void* pData = (mpArrayItemData ? mpArrayItemData : mpObj->mPropertyData.data());
@@ -69,8 +69,13 @@ void CScriptLoader::ReadProperty(IProperty *pProp, u32 Size, IInputStream& rSCLY
#if VALIDATE_PROPERTY_VALUES
if (!pChoice->HasValidValue(pData))
{
u32 Value = pChoice->ValueRef(pData);
Log::FileError(rSCLY.GetSourceString(), rSCLY.Tell() - 4, "Choice property \"" + pChoice->Name() + "\" (" + pChoice->IDString(true) + ") has unrecognized value: " + TString::HexString(Value));
uint32 Value = pChoice->ValueRef(pData);
errorf("%s [0x%X]: Choice property \"%s\" (%s) has unrecognized value: 0x%08X",
*rSCLY.GetSourceString(),
rSCLY.Tell() - 4,
*pChoice->Name(),
*pChoice->IDString(true),
Value);
}
#endif
break;
@@ -84,8 +89,13 @@ void CScriptLoader::ReadProperty(IProperty *pProp, u32 Size, IInputStream& rSCLY
#if VALIDATE_PROPERTY_VALUES
if (!pEnum->HasValidValue(pData))
{
u32 Value = pEnum->ValueRef(pData);
Log::FileError(rSCLY.GetSourceString(), rSCLY.Tell() - 4, "Enum property \"" + pEnum->Name() + "\" (" + pEnum->IDString(true) + ") has unrecognized value: " + TString::HexString(Value));
uint32 Value = pEnum->ValueRef(pData);
errorf("%s [0x%X]: Enum property \"%s\" (%s) has unrecognized value: 0x%08X",
*rSCLY.GetSourceString(),
rSCLY.Tell() - 4,
*pEnum->Name(),
*pEnum->IDString(true),
Value);
}
#endif
break;
@@ -97,11 +107,16 @@ void CScriptLoader::ReadProperty(IProperty *pProp, u32 Size, IInputStream& rSCLY
pFlags->ValueRef(pData) = rSCLY.ReadLong();
#if VALIDATE_PROPERTY_VALUES
u32 InvalidBits = pFlags->HasValidValue(pData);
uint32 InvalidBits = pFlags->HasValidValue(pData);
if (InvalidBits)
{
Log::FileWarning(rSCLY.GetSourceString(), rSCLY.Tell() - 4, "Flags property \"" + pFlags->Name() + "\" + (" + pFlags->IDString(true) + ") has unrecognized flags set: " + TString::HexString(InvalidBits));
warnf("%s [0x%X]: Flags property \"%s\" (%s) has unrecognized flags set: 0x%08X",
*rSCLY.GetSourceString(),
rSCLY.Tell() - 4,
*pFlags->Name(),
*pFlags->IDString(true),
InvalidBits);
}
#endif
break;
@@ -146,7 +161,14 @@ void CScriptLoader::ReadProperty(IProperty *pProp, u32 Size, IInputStream& rSCLY
bool Valid = rkFilter.Accepts(pEntry->ResourceType());
if (!Valid)
Log::FileWarning(rSCLY.GetSourceString(), rSCLY.Tell() - ID.Length(), "Asset property \"" + pAsset->Name() + "\" (" + pAsset->IDString(true) + ") has a reference to an illegal asset type: " + pEntry->CookedExtension());
{
warnf("%s [0x%X]: Asset property \"%s\" (%s) has a reference to an illegal asset type: %s",
*rSCLY.GetSourceString(),
rSCLY.Tell() - ID.Length(),
*pAsset->Name(),
*pAsset->IDString(true),
*pEntry->CookedExtension().ToString());
}
}
}
#endif
@@ -248,20 +270,20 @@ void CScriptLoader::ReadProperty(IProperty *pProp, u32 Size, IInputStream& rSCLY
void CScriptLoader::LoadStructMP1(IInputStream& rSCLY, CStructProperty* pStruct)
{
u32 StructStart = rSCLY.Tell();
uint32 StructStart = rSCLY.Tell();
// Verify property count
u32 PropertyCount = pStruct->NumChildren();
u32 Version = 0;
uint32 PropertyCount = pStruct->NumChildren();
uint32 Version = 0;
if (!pStruct->IsAtomic())
{
u32 FilePropCount = rSCLY.ReadLong();
uint32 FilePropCount = rSCLY.ReadLong();
//@todo version checking
}
// Parse properties
for (u32 ChildIndex = 0; ChildIndex < PropertyCount; ChildIndex++)
for (uint32 ChildIndex = 0; ChildIndex < PropertyCount; ChildIndex++)
{
IProperty *pProperty = pStruct->ChildByIndex(ChildIndex);
@@ -273,33 +295,33 @@ void CScriptLoader::LoadStructMP1(IInputStream& rSCLY, CStructProperty* pStruct)
CScriptObject* CScriptLoader::LoadObjectMP1(IInputStream& rSCLY)
{
u32 StartOffset = rSCLY.Tell();
u8 Type = rSCLY.ReadByte();
u32 Size = rSCLY.ReadLong();
u32 End = rSCLY.Tell() + Size;
uint32 StartOffset = rSCLY.Tell();
uint8 Type = rSCLY.ReadByte();
uint32 Size = rSCLY.ReadLong();
uint32 End = rSCLY.Tell() + Size;
CScriptTemplate *pTemplate = mpGameTemplate->TemplateByID((u32) Type);
CScriptTemplate *pTemplate = mpGameTemplate->TemplateByID((uint32) Type);
if (!pTemplate)
{
// No valid template for this object; can't load
Log::FileError(rSCLY.GetSourceString(), StartOffset, "Unknown object ID encountered: " + TString::HexString(Type, 2));
errorf("%s [0x%X]: Unknown object ID encountered: 0x%02X", *rSCLY.GetSourceString(), StartOffset, Type);
rSCLY.Seek(End, SEEK_SET);
return nullptr;
}
u32 InstanceID = rSCLY.ReadLong() & 0x03FFFFFF;
uint32 InstanceID = rSCLY.ReadLong() & 0x03FFFFFF;
if (InstanceID == 0x03FFFFFF) InstanceID = mpArea->FindUnusedInstanceID();
mpObj = new CScriptObject(InstanceID, mpArea, mpLayer, pTemplate);
// Load connections
u32 NumLinks = rSCLY.ReadLong();
uint32 NumLinks = rSCLY.ReadLong();
mpObj->mOutLinks.reserve(NumLinks);
for (u32 iLink = 0; iLink < NumLinks; iLink++)
for (uint32 iLink = 0; iLink < NumLinks; iLink++)
{
u32 State = rSCLY.ReadLong();
u32 Message = rSCLY.ReadLong();
u32 ReceiverID = rSCLY.ReadLong() & 0x03FFFFFF;
uint32 State = rSCLY.ReadLong();
uint32 Message = rSCLY.ReadLong();
uint32 ReceiverID = rSCLY.ReadLong() & 0x03FFFFFF;
CLink *pLink = new CLink(mpArea, State, Message, mpObj->mInstanceID, ReceiverID);
mpObj->mOutLinks.push_back(pLink);
@@ -318,15 +340,15 @@ CScriptObject* CScriptLoader::LoadObjectMP1(IInputStream& rSCLY)
CScriptLayer* CScriptLoader::LoadLayerMP1(IInputStream& rSCLY)
{
u32 LayerStart = rSCLY.Tell();
uint32 LayerStart = rSCLY.Tell();
rSCLY.Seek(0x1, SEEK_CUR); // One unknown byte at the start of each layer
u32 NumObjects = rSCLY.ReadLong();
uint32 NumObjects = rSCLY.ReadLong();
mpLayer = new CScriptLayer(mpArea);
mpLayer->Reserve(NumObjects);
for (u32 ObjectIndex = 0; ObjectIndex < NumObjects; ObjectIndex++)
for (uint32 ObjectIndex = 0; ObjectIndex < NumObjects; ObjectIndex++)
{
CScriptObject *pObject = LoadObjectMP1(rSCLY);
if (pObject)
@@ -334,7 +356,7 @@ CScriptLayer* CScriptLoader::LoadLayerMP1(IInputStream& rSCLY)
}
// Layer sizes are always a multiple of 32 - skip end padding before returning
u32 Remaining = 32 - ((rSCLY.Tell() - LayerStart) & 0x1F);
uint32 Remaining = 32 - ((rSCLY.Tell() - LayerStart) & 0x1F);
rSCLY.Seek(Remaining, SEEK_CUR);
return mpLayer;
}
@@ -342,19 +364,19 @@ CScriptLayer* CScriptLoader::LoadLayerMP1(IInputStream& rSCLY)
void CScriptLoader::LoadStructMP2(IInputStream& rSCLY, CStructProperty* pStruct)
{
// Verify property count
u32 ChildCount = pStruct->NumChildren();
uint32 ChildCount = pStruct->NumChildren();
if (!pStruct->IsAtomic())
ChildCount = rSCLY.ReadShort();
// Parse properties
for (u32 ChildIdx = 0; ChildIdx < ChildCount; ChildIdx++)
for (uint32 ChildIdx = 0; ChildIdx < ChildCount; ChildIdx++)
{
IProperty* pProperty = nullptr;
u32 PropertyStart = rSCLY.Tell();
u32 PropertyID = -1;
u16 PropertySize = 0;
u32 NextProperty = 0;
uint32 PropertyStart = rSCLY.Tell();
uint32 PropertyID = -1;
uint16 PropertySize = 0;
uint32 NextProperty = 0;
if (pStruct->IsAtomic())
{
@@ -369,7 +391,7 @@ void CScriptLoader::LoadStructMP2(IInputStream& rSCLY, CStructProperty* pStruct)
}
if (!pProperty)
Log::FileError(rSCLY.GetSourceString(), PropertyStart, "Can't find template for property " + TString::HexString(PropertyID) + " - skipping");
errorf("%s [0x%X]: Can't find template for property 0x%08X - skipping", *rSCLY.GetSourceString(), PropertyStart, PropertyID);
else
ReadProperty(pProperty, PropertySize, rSCLY);
@@ -380,33 +402,33 @@ void CScriptLoader::LoadStructMP2(IInputStream& rSCLY, CStructProperty* pStruct)
CScriptObject* CScriptLoader::LoadObjectMP2(IInputStream& rSCLY)
{
u32 ObjStart = rSCLY.Tell();
u32 ObjectID = rSCLY.ReadLong();
u16 ObjectSize = rSCLY.ReadShort();
u32 ObjEnd = rSCLY.Tell() + ObjectSize;
uint32 ObjStart = rSCLY.Tell();
uint32 ObjectID = rSCLY.ReadLong();
uint16 ObjectSize = rSCLY.ReadShort();
uint32 ObjEnd = rSCLY.Tell() + ObjectSize;
CScriptTemplate* pTemplate = mpGameTemplate->TemplateByID(ObjectID);
if (!pTemplate)
{
Log::FileError(rSCLY.GetSourceString(), ObjStart, "Unknown object ID encountered: " + CFourCC(ObjectID).ToString());
errorf("%s [0x%X]: Unknown object ID encountered: %s", *rSCLY.GetSourceString(), ObjStart, *CFourCC(ObjectID).ToString());
rSCLY.Seek(ObjEnd, SEEK_SET);
return nullptr;
}
u32 InstanceID = rSCLY.ReadLong() & 0x03FFFFFF;
uint32 InstanceID = rSCLY.ReadLong() & 0x03FFFFFF;
if (InstanceID == 0x03FFFFFF) InstanceID = mpArea->FindUnusedInstanceID();
mpObj = new CScriptObject(InstanceID, mpArea, mpLayer, pTemplate);
// Load connections
u32 NumConnections = rSCLY.ReadShort();
uint32 NumConnections = rSCLY.ReadShort();
mpObj->mOutLinks.reserve(NumConnections);
for (u32 LinkIdx = 0; LinkIdx < NumConnections; LinkIdx++)
for (uint32 LinkIdx = 0; LinkIdx < NumConnections; LinkIdx++)
{
u32 State = rSCLY.ReadLong();
u32 Message = rSCLY.ReadLong();
u32 ReceiverID = rSCLY.ReadLong() & 0x03FFFFFF;
uint32 State = rSCLY.ReadLong();
uint32 Message = rSCLY.ReadLong();
uint32 ReceiverID = rSCLY.ReadLong() & 0x03FFFFFF;
CLink* pLink = new CLink(mpArea, State, Message, mpObj->mInstanceID, ReceiverID);
mpObj->mOutLinks.push_back(pLink);
@@ -425,12 +447,12 @@ CScriptObject* CScriptLoader::LoadObjectMP2(IInputStream& rSCLY)
CScriptLayer* CScriptLoader::LoadLayerMP2(IInputStream& rSCLY)
{
rSCLY.Seek(0x1, SEEK_CUR); // Skipping version. todo: verify this?
u32 NumObjects = rSCLY.ReadLong();
uint32 NumObjects = rSCLY.ReadLong();
mpLayer = new CScriptLayer(mpArea);
mpLayer->Reserve(NumObjects);
for (u32 ObjectIdx = 0; ObjectIdx < NumObjects; ObjectIdx++)
for (uint32 ObjectIdx = 0; ObjectIdx < NumObjects; ObjectIdx++)
{
CScriptObject* pObject = LoadObjectMP2(rSCLY);
if (pObject)
@@ -452,7 +474,7 @@ CScriptLayer* CScriptLoader::LoadLayer(IInputStream& rSCLY, CGameArea *pArea, EG
if (!Loader.mpGameTemplate)
{
Log::Write("This game doesn't have a game template; couldn't load script layer");
debugf("This game doesn't have a game template; couldn't load script layer");
return nullptr;
}
@@ -474,7 +496,7 @@ CScriptObject* CScriptLoader::LoadInstance(IInputStream& rSCLY, CGameArea *pArea
if (!Loader.mpGameTemplate)
{
Log::Write("This game doesn't have a game template; couldn't load script instance");
debugf("This game doesn't have a game template; couldn't load script instance");
return nullptr;
}

View File

@@ -19,7 +19,7 @@ class CScriptLoader
void* mpArrayItemData;
CScriptLoader();
void ReadProperty(IProperty* pProp, u32 Size, IInputStream& rSCLY);
void ReadProperty(IProperty* pProp, uint32 Size, IInputStream& rSCLY);
void LoadStructMP1(IInputStream& rSCLY, CStructProperty* pStruct);
CScriptObject* LoadObjectMP1(IInputStream& rSCLY);

View File

@@ -1,7 +1,7 @@
#ifndef CSECTIONMGRIN_H
#define CSECTIONMGRIN_H
#include <Common/types.h>
#include <Common/BasicTypes.h>
#include <Common/FileIO/IInputStream.h>
#include <vector>
@@ -9,18 +9,18 @@
class CSectionMgrIn
{
IInputStream *mpInputStream;
std::vector<u32> mSectionSizes;
u32 mCurSec;
u32 mCurSecStart;
u32 mSecsStart;
std::vector<uint32> mSectionSizes;
uint32 mCurSec;
uint32 mCurSecStart;
uint32 mSecsStart;
public:
CSectionMgrIn(u32 Count, IInputStream* pSrc)
CSectionMgrIn(uint32 Count, IInputStream* pSrc)
: mpInputStream(pSrc)
{
mSectionSizes.resize(Count);
for (u32 iSec = 0; iSec < Count; iSec++)
for (uint32 iSec = 0; iSec < Count; iSec++)
mSectionSizes[iSec] = pSrc->ReadLong();
}
@@ -32,10 +32,10 @@ public:
mSecsStart = mCurSecStart;
}
void ToSection(u32 SecNum)
void ToSection(uint32 SecNum)
{
u32 Offset = mSecsStart;
for (u32 iSec = 0; iSec < SecNum; iSec++)
uint32 Offset = mSecsStart;
for (uint32 iSec = 0; iSec < SecNum; iSec++)
Offset += mSectionSizes[iSec];
mpInputStream->Seek(Offset, SEEK_SET);
@@ -50,10 +50,10 @@ public:
mCurSec++;
}
inline u32 NextOffset() { return mCurSecStart + mSectionSizes[mCurSec]; }
inline u32 CurrentSection() { return mCurSec; }
inline u32 CurrentSectionSize() { return mSectionSizes[mCurSec]; }
inline u32 NumSections() { return mSectionSizes.size(); }
inline uint32 NextOffset() { return mCurSecStart + mSectionSizes[mCurSec]; }
inline uint32 CurrentSection() { return mCurSec; }
inline uint32 CurrentSectionSize() { return mSectionSizes[mCurSec]; }
inline uint32 NumSections() { return mSectionSizes.size(); }
inline void SetInputStream(IInputStream *pIn) { mpInputStream = pIn; }
};

View File

@@ -1,12 +1,12 @@
#include "CSkeletonLoader.h"
#include <Common/AssertMacro.h>
#include <Common/Macros.h>
#include <Common/Log.h>
#include <vector>
void CSkeletonLoader::SetLocalBoneCoords(CBone *pBone)
{
for (u32 iChild = 0; iChild < pBone->NumChildren(); iChild++)
for (uint32 iChild = 0; iChild < pBone->NumChildren(); iChild++)
SetLocalBoneCoords(pBone->ChildByIndex(iChild));
if (pBone->mpParent)
@@ -17,7 +17,7 @@ void CSkeletonLoader::SetLocalBoneCoords(CBone *pBone)
void CSkeletonLoader::CalculateBoneInverseBindMatrices()
{
for (u32 iBone = 0; iBone < mpSkeleton->mBones.size(); iBone++)
for (uint32 iBone = 0; iBone < mpSkeleton->mBones.size(); iBone++)
{
CBone *pBone = mpSkeleton->mBones[iBone];
pBone->mInvBind = CTransform4f::TranslationMatrix(-pBone->Position());
@@ -36,18 +36,18 @@ CSkeleton* CSkeletonLoader::LoadCINF(IInputStream& rCINF, CResourceEntry *pEntry
if (rCINF.PeekLong() == 0x9E220006)
return pSkel;
u32 NumBones = rCINF.ReadLong();
uint32 NumBones = rCINF.ReadLong();
pSkel->mBones.reserve(NumBones);
// Read bones
struct SBoneInfo
{
u32 ParentID;
std::vector<u32> ChildIDs;
uint32 ParentID;
std::vector<uint32> ChildIDs;
};
std::vector<SBoneInfo> BoneInfo(NumBones);
for (u32 iBone = 0; iBone < NumBones; iBone++)
for (uint32 iBone = 0; iBone < NumBones; iBone++)
{
CBone *pBone = new CBone(pSkel);
pSkel->mBones.push_back(pBone);
@@ -62,7 +62,7 @@ CSkeleton* CSkeletonLoader::LoadCINF(IInputStream& rCINF, CResourceEntry *pEntry
// know) has at least two bones so the linked bone count will never be 0.
if (Game == EGame::Invalid)
{
u32 Check = rCINF.PeekLong();
uint32 Check = rCINF.PeekLong();
Game = ((Check > 100 || Check == 0) ? EGame::Echoes : EGame::Prime);
}
if (Game >= EGame::Echoes)
@@ -71,12 +71,12 @@ CSkeleton* CSkeletonLoader::LoadCINF(IInputStream& rCINF, CResourceEntry *pEntry
pBone->mLocalRotation = CQuaternion(rCINF);
}
u32 NumLinkedBones = rCINF.ReadLong();
uint32 NumLinkedBones = rCINF.ReadLong();
ASSERT(NumLinkedBones != 0);
for (u32 iLink = 0; iLink < NumLinkedBones; iLink++)
for (uint32 iLink = 0; iLink < NumLinkedBones; iLink++)
{
u32 LinkedID = rCINF.ReadLong();
uint32 LinkedID = rCINF.ReadLong();
if (LinkedID != BoneInfo[iBone].ParentID)
BoneInfo[iBone].ChildIDs.push_back(LinkedID);
@@ -84,22 +84,22 @@ CSkeleton* CSkeletonLoader::LoadCINF(IInputStream& rCINF, CResourceEntry *pEntry
}
// Fill in bone info
for (u32 iBone = 0; iBone < NumBones; iBone++)
for (uint32 iBone = 0; iBone < NumBones; iBone++)
{
CBone *pBone = pSkel->mBones[iBone];
SBoneInfo& rInfo = BoneInfo[iBone];
pBone->mpParent = pSkel->BoneByID(rInfo.ParentID);
for (u32 iChild = 0; iChild < rInfo.ChildIDs.size(); iChild++)
for (uint32 iChild = 0; iChild < rInfo.ChildIDs.size(); iChild++)
{
u32 ChildID = rInfo.ChildIDs[iChild];
uint32 ChildID = rInfo.ChildIDs[iChild];
CBone *pChild = pSkel->BoneByID(ChildID);
if (pChild)
pBone->mChildren.push_back(pChild);
else
Log::FileError(rCINF.GetSourceString(), "Bone " + TString::FromInt32(pBone->mID, 0, 10) + " has invalid child ID: " + TString::FromInt32(ChildID, 0, 10));
errorf("%s: Bone %d has invalid child ID: %d", *rCINF.GetSourceString(), pBone->mID, ChildID);
}
if (!pBone->mpParent)
@@ -107,7 +107,7 @@ CSkeleton* CSkeletonLoader::LoadCINF(IInputStream& rCINF, CResourceEntry *pEntry
if (!pSkel->mpRootBone)
pSkel->mpRootBone = pBone;
else
Log::FileError(rCINF.GetSourceString(), "Multiple root bones?");
errorf("%s: Multiple root bones?", *rCINF.GetSourceString());
}
}
@@ -115,16 +115,16 @@ CSkeleton* CSkeletonLoader::LoadCINF(IInputStream& rCINF, CResourceEntry *pEntry
Loader.CalculateBoneInverseBindMatrices();
// Skip bone ID array
u32 NumBoneIDs = rCINF.ReadLong();
uint32 NumBoneIDs = rCINF.ReadLong();
rCINF.Seek(NumBoneIDs * 4, SEEK_CUR);
// Read bone names
u32 NumBoneNames = rCINF.ReadLong();
uint32 NumBoneNames = rCINF.ReadLong();
for (u32 iName = 0; iName < NumBoneNames; iName++)
for (uint32 iName = 0; iName < NumBoneNames; iName++)
{
TString Name = rCINF.ReadString();
u32 BoneID = rCINF.ReadLong();
uint32 BoneID = rCINF.ReadLong();
pSkel->BoneByID(BoneID)->mName = Name;
}

View File

@@ -1,5 +1,5 @@
#include "CSkinLoader.h"
#include <Common/AssertMacro.h>
#include <Common/Macros.h>
// ************ STATIC ************
CSkin* CSkinLoader::LoadCSKR(IInputStream& rCSKR, CResourceEntry *pEntry)
@@ -11,18 +11,18 @@ CSkin* CSkinLoader::LoadCSKR(IInputStream& rCSKR, CResourceEntry *pEntry)
if (rCSKR.PeekLong() == FOURCC('SKIN'))
return pSkin;
u32 NumVertexGroups = rCSKR.ReadLong();
uint32 NumVertexGroups = rCSKR.ReadLong();
pSkin->mVertGroups.resize(NumVertexGroups);
for (u32 iGrp = 0; iGrp < NumVertexGroups; iGrp++)
for (uint32 iGrp = 0; iGrp < NumVertexGroups; iGrp++)
{
CSkin::SVertGroup& rGroup = pSkin->mVertGroups[iGrp];
u32 NumWeights = rCSKR.ReadLong();
uint32 NumWeights = rCSKR.ReadLong();
ASSERT(NumWeights <= 4);
for (u32 iWgt = 0; iWgt < NumWeights; iWgt++)
for (uint32 iWgt = 0; iWgt < NumWeights; iWgt++)
{
rGroup.Weights.Indices[iWgt] = (u8) rCSKR.ReadLong();
rGroup.Weights.Indices[iWgt] = (uint8) rCSKR.ReadLong();
rGroup.Weights.Weights[iWgt] = rCSKR.ReadFloat();
}

View File

@@ -8,20 +8,20 @@ void CStringLoader::LoadPrimeDemoSTRG(IInputStream& rSTRG)
mpStringTable->mLangTables.resize(1);
CStringTable::SLangTable* Lang = &mpStringTable->mLangTables[1];
Lang->Language = "ENGL";
u32 TableStart = rSTRG.Tell();
uint32 TableStart = rSTRG.Tell();
// Header
u32 NumStrings = rSTRG.ReadLong();
uint32 NumStrings = rSTRG.ReadLong();
Lang->Strings.resize(NumStrings);
mpStringTable->mNumStrings = NumStrings;
// String offsets (yeah, that wasn't much of a header)
std::vector<u32> StringOffsets(NumStrings);
for (u32 iOff = 0; iOff < StringOffsets.size(); iOff++)
std::vector<uint32> StringOffsets(NumStrings);
for (uint32 iOff = 0; iOff < StringOffsets.size(); iOff++)
StringOffsets[iOff] = rSTRG.ReadLong();
// Strings
for (u32 iStr = 0; iStr < NumStrings; iStr++)
for (uint32 iStr = 0; iStr < NumStrings; iStr++)
{
rSTRG.Seek(TableStart + StringOffsets[iStr], SEEK_SET);
Lang->Strings[iStr] = rSTRG.ReadWString().ToUTF8();
@@ -32,15 +32,15 @@ void CStringLoader::LoadPrimeSTRG(IInputStream& rSTRG)
{
// This function starts at 0x8 in the file, after magic/version
// Header
u32 NumLanguages = rSTRG.ReadLong();
u32 NumStrings = rSTRG.ReadLong();
uint32 NumLanguages = rSTRG.ReadLong();
uint32 NumStrings = rSTRG.ReadLong();
mpStringTable->mNumStrings = NumStrings;
// Language definitions
mpStringTable->mLangTables.resize(NumLanguages);
std::vector<u32> LangOffsets(NumLanguages);
std::vector<uint32> LangOffsets(NumLanguages);
for (u32 iLang = 0; iLang < NumLanguages; iLang++)
for (uint32 iLang = 0; iLang < NumLanguages; iLang++)
{
mpStringTable->mLangTables[iLang].Language = CFourCC(rSTRG);
LangOffsets[iLang] = rSTRG.ReadLong();
@@ -52,23 +52,23 @@ void CStringLoader::LoadPrimeSTRG(IInputStream& rSTRG)
LoadNameTable(rSTRG);
// Strings
u32 StringsStart = rSTRG.Tell();
for (u32 iLang = 0; iLang < NumLanguages; iLang++)
uint32 StringsStart = rSTRG.Tell();
for (uint32 iLang = 0; iLang < NumLanguages; iLang++)
{
rSTRG.Seek(StringsStart + LangOffsets[iLang], SEEK_SET);
if (mVersion == EGame::Prime) rSTRG.Seek(0x4, SEEK_CUR); // Skipping strings size
u32 LangStart = rSTRG.Tell();
uint32 LangStart = rSTRG.Tell();
CStringTable::SLangTable* pLang = &mpStringTable->mLangTables[iLang];
pLang->Strings.resize(NumStrings);
// Offsets
std::vector<u32> StringOffsets(NumStrings);
for (u32 iOff = 0; iOff < NumStrings; iOff++)
std::vector<uint32> StringOffsets(NumStrings);
for (uint32 iOff = 0; iOff < NumStrings; iOff++)
StringOffsets[iOff] = rSTRG.ReadLong();
// The actual strings
for (u32 iStr = 0; iStr < NumStrings; iStr++)
for (uint32 iStr = 0; iStr < NumStrings; iStr++)
{
rSTRG.Seek(LangStart + StringOffsets[iStr], SEEK_SET);
pLang->Strings[iStr] = rSTRG.ReadWString().ToUTF8();
@@ -80,8 +80,8 @@ void CStringLoader::LoadCorruptionSTRG(IInputStream& rSTRG)
{
// This function starts at 0x8 in the file, after magic/version
// Header
u32 NumLanguages = rSTRG.ReadLong();
u32 NumStrings = rSTRG.ReadLong();
uint32 NumLanguages = rSTRG.ReadLong();
uint32 NumStrings = rSTRG.ReadLong();
mpStringTable->mNumStrings = NumStrings;
// String names
@@ -89,30 +89,30 @@ void CStringLoader::LoadCorruptionSTRG(IInputStream& rSTRG)
// Language definitions
mpStringTable->mLangTables.resize(NumLanguages);
std::vector<std::vector<u32>> LangOffsets(NumLanguages);
std::vector<std::vector<uint32>> LangOffsets(NumLanguages);
for (u32 iLang = 0; iLang < NumLanguages; iLang++)
for (uint32 iLang = 0; iLang < NumLanguages; iLang++)
mpStringTable->mLangTables[iLang].Language = CFourCC(rSTRG);
for (u32 iLang = 0; iLang < NumLanguages; iLang++)
for (uint32 iLang = 0; iLang < NumLanguages; iLang++)
{
LangOffsets[iLang].resize(NumStrings);
rSTRG.Seek(0x4, SEEK_CUR); // Skipping total string size
for (u32 iStr = 0; iStr < NumStrings; iStr++)
for (uint32 iStr = 0; iStr < NumStrings; iStr++)
LangOffsets[iLang][iStr] = rSTRG.ReadLong();
}
// Strings
u32 StringsStart = rSTRG.Tell();
uint32 StringsStart = rSTRG.Tell();
for (u32 iLang = 0; iLang < NumLanguages; iLang++)
for (uint32 iLang = 0; iLang < NumLanguages; iLang++)
{
CStringTable::SLangTable *pLang = &mpStringTable->mLangTables[iLang];
pLang->Strings.resize(NumStrings);
for (u32 iStr = 0; iStr < NumStrings; iStr++)
for (uint32 iStr = 0; iStr < NumStrings; iStr++)
{
rSTRG.Seek(StringsStart + LangOffsets[iLang][iStr], SEEK_SET);
rSTRG.Seek(0x4, SEEK_CUR); // Skipping string size
@@ -125,18 +125,18 @@ void CStringLoader::LoadCorruptionSTRG(IInputStream& rSTRG)
void CStringLoader::LoadNameTable(IInputStream& rSTRG)
{
// Name table header
u32 NameCount = rSTRG.ReadLong();
u32 NameTableSize = rSTRG.ReadLong();
u32 NameTableStart = rSTRG.Tell();
u32 NameTableEnd = NameTableStart + NameTableSize;
uint32 NameCount = rSTRG.ReadLong();
uint32 NameTableSize = rSTRG.ReadLong();
uint32 NameTableStart = rSTRG.Tell();
uint32 NameTableEnd = NameTableStart + NameTableSize;
// Name definitions
struct SNameDef {
u32 NameOffset, StringIndex;
uint32 NameOffset, StringIndex;
};
std::vector<SNameDef> NameDefs(NameCount);
for (u32 iName = 0; iName < NameCount; iName++)
for (uint32 iName = 0; iName < NameCount; iName++)
{
NameDefs[iName].NameOffset = rSTRG.ReadLong() + NameTableStart;
NameDefs[iName].StringIndex = rSTRG.ReadLong();
@@ -144,7 +144,7 @@ void CStringLoader::LoadNameTable(IInputStream& rSTRG)
// Name strings
mpStringTable->mStringNames.resize(mpStringTable->mNumStrings);
for (u32 iName = 0; iName < NameCount; iName++)
for (uint32 iName = 0; iName < NameCount; iName++)
{
SNameDef *pDef = &NameDefs[iName];
rSTRG.Seek(pDef->NameOffset, SEEK_SET);
@@ -159,14 +159,14 @@ CStringTable* CStringLoader::LoadSTRG(IInputStream& rSTRG, CResourceEntry *pEntr
// Verify that this is a valid STRG
if (!rSTRG.IsValid()) return nullptr;
u32 Magic = rSTRG.ReadLong();
uint32 Magic = rSTRG.ReadLong();
EGame Version = EGame::Invalid;
if (Magic != 0x87654321)
{
// Check for MP1 Demo STRG format - no magic/version; the first value is actually the filesize
// so the best I can do is verify the first value actually points to the end of the file
if (Magic <= (u32) rSTRG.Size())
if (Magic <= (uint32) rSTRG.Size())
{
rSTRG.Seek(Magic, SEEK_SET);
if ((rSTRG.EoF()) || (rSTRG.ReadShort() == 0xFFFF))
@@ -175,19 +175,19 @@ CStringTable* CStringLoader::LoadSTRG(IInputStream& rSTRG, CResourceEntry *pEntr
if (Version != EGame::PrimeDemo)
{
Log::FileError(rSTRG.GetSourceString(), "Invalid STRG magic: " + TString::HexString(Magic));
errorf("%s: Invalid STRG magic: 0x%08X", *rSTRG.GetSourceString(), Magic);
return nullptr;
}
}
else
{
u32 FileVersion = rSTRG.ReadLong();
uint32 FileVersion = rSTRG.ReadLong();
Version = GetFormatVersion(FileVersion);
if (Version == EGame::Invalid)
{
Log::FileError(rSTRG.GetSourceString(), "Unsupported STRG version: " + TString::HexString(FileVersion, 0));
errorf("%s: Unsupported STRG version: 0x%X", *rSTRG.GetSourceString(), FileVersion);
return nullptr;
}
}
@@ -204,7 +204,7 @@ CStringTable* CStringLoader::LoadSTRG(IInputStream& rSTRG, CResourceEntry *pEntr
return Loader.mpStringTable;
}
EGame CStringLoader::GetFormatVersion(u32 Version)
EGame CStringLoader::GetFormatVersion(uint32 Version)
{
switch (Version)
{

View File

@@ -19,7 +19,7 @@ class CStringLoader
public:
static CStringTable* LoadSTRG(IInputStream &rSTRG, CResourceEntry *pEntry);
static EGame GetFormatVersion(u32 Version);
static EGame GetFormatVersion(uint32 Version);
};
#endif // CSTRINGLOADER_H

View File

@@ -10,27 +10,27 @@ static const float gskPixelsToBytes[] = {
};
// Bits per pixel for each GX texture format
static const u32 gskSourceBpp[] = {
static const uint32 gskSourceBpp[] = {
4, 8, 8, 16, 4, 8, 16, 16, 16, 32, 4
};
// Bits per pixel for each GX texture format when decoded
static const u32 gskOutputBpp[] = {
static const uint32 gskOutputBpp[] = {
16, 16, 16, 16, 16, 16, 16, 16, 32, 32, 4
};
// Size of one pixel in output data in bytes
static const u32 gskOutputPixelStride[] = {
static const uint32 gskOutputPixelStride[] = {
2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 8
};
// Block width for each GX texture format
static const u32 gskBlockWidth[] = {
static const uint32 gskBlockWidth[] = {
8, 8, 8, 4, 8, 8, 4, 4, 4, 4, 2
};
// Block height for each GX texture format
static const u32 gskBlockHeight[] = {
static const uint32 gskBlockHeight[] = {
8, 4, 4, 4, 8, 4, 4, 4, 4, 4, 2
};
@@ -49,7 +49,7 @@ CTexture* CTextureDecoder::CreateTexture()
pTex->mWidth = mWidth;
pTex->mHeight = mHeight;
pTex->mNumMipMaps = mNumMipMaps;
pTex->mLinearSize = (u32) (mWidth * mHeight * gskPixelsToBytes[mTexelFormat]);
pTex->mLinearSize = (uint32) (mWidth * mHeight * gskPixelsToBytes[mTexelFormat]);
pTex->mpImgDataBuffer = mpDataBuffer;
pTex->mImgDataSize = mDataBufferSize;
pTex->mBufferExists = true;
@@ -142,7 +142,7 @@ void CTextureDecoder::ReadTXTR(IInputStream& rTXTR)
mPaletteFormat = EGXPaletteFormat(rTXTR.ReadLong());
rTXTR.Seek(0x4, SEEK_CUR);
u32 PaletteEntryCount = (mTexelFormat == eGX_C4) ? 16 : 256;
uint32 PaletteEntryCount = (mTexelFormat == eGX_C4) ? 16 : 256;
mPalettes.resize(PaletteEntryCount * 2);
rTXTR.ReadBytes(mPalettes.data(), mPalettes.size());
@@ -155,16 +155,16 @@ void CTextureDecoder::ReadDDS(IInputStream& rDDS)
{
// Header
CFourCC Magic(rDDS);
if (Magic != "DDS ")
if (Magic != FOURCC('DDS '))
{
Log::FileError(rDDS.GetSourceString(), "Invalid DDS magic: " + TString::HexString(Magic.ToLong()));
errorf("%s: Invalid DDS magic: 0x%08X", *rDDS.GetSourceString(), Magic.ToLong());
return;
}
u32 ImageDataStart = rDDS.Tell() + rDDS.ReadLong();
uint32 ImageDataStart = rDDS.Tell() + rDDS.ReadLong();
rDDS.Seek(0x4, SEEK_CUR); // Skipping flags
mHeight = (u16) rDDS.ReadLong();
mWidth = (u16) rDDS.ReadLong();
mHeight = (uint16) rDDS.ReadLong();
mWidth = (uint16) rDDS.ReadLong();
rDDS.Seek(0x8, SEEK_CUR); // Skipping linear size + depth
mNumMipMaps = rDDS.ReadLong() + 1; // DDS doesn't seem to count the first mipmap
rDDS.Seek(0x2C, SEEK_CUR); // Skipping reserved
@@ -209,25 +209,25 @@ void CTextureDecoder::PartialDecodeGXTexture(IInputStream& TXTR)
// The decode needs to be adjusted to account for the padding and skip over it (since we don't have padding in OpenGL).
// Get image data size, create output buffer
u32 ImageStart = TXTR.Tell();
uint32 ImageStart = TXTR.Tell();
TXTR.Seek(0x0, SEEK_END);
u32 ImageSize = TXTR.Tell() - ImageStart;
uint32 ImageSize = TXTR.Tell() - ImageStart;
TXTR.Seek(ImageStart, SEEK_SET);
mDataBufferSize = ImageSize * (gskOutputBpp[mTexelFormat] / gskSourceBpp[mTexelFormat]);
if ((mHasPalettes) && (mPaletteFormat == ePalette_RGB5A3)) mDataBufferSize *= 2;
mpDataBuffer = new u8[mDataBufferSize];
mpDataBuffer = new uint8[mDataBufferSize];
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::kSystemEndianness);
// Initializing more stuff before we start the mipmap loop
u32 MipW = mWidth, MipH = mHeight;
u32 MipOffset = 0;
uint32 MipW = mWidth, MipH = mHeight;
uint32 MipOffset = 0;
u32 BWidth = gskBlockWidth[mTexelFormat];
u32 BHeight = gskBlockHeight[mTexelFormat];
uint32 BWidth = gskBlockWidth[mTexelFormat];
uint32 BHeight = gskBlockHeight[mTexelFormat];
u32 PixelStride = gskOutputPixelStride[mTexelFormat];
uint32 PixelStride = gskOutputPixelStride[mTexelFormat];
if (mHasPalettes && (mPaletteFormat == ePalette_RGB5A3))
PixelStride = 4;
@@ -245,20 +245,20 @@ void CTextureDecoder::PartialDecodeGXTexture(IInputStream& TXTR)
// This affects one texture that I know of - Echoes 3bb2c034.TXTR
bool BreakEarly = false;
for (u32 iMip = 0; iMip < mNumMipMaps; iMip++)
for (uint32 iMip = 0; iMip < mNumMipMaps; iMip++)
{
if (MipW < BWidth) MipW = BWidth;
if (MipH < BHeight) MipH = BHeight;
for (u32 iBlockY = 0; iBlockY < MipH; iBlockY += BHeight)
for (uint32 iBlockY = 0; iBlockY < MipH; iBlockY += BHeight)
{
for (u32 iBlockX = 0; iBlockX < MipW; iBlockX += BWidth)
for (uint32 iBlockX = 0; iBlockX < MipW; iBlockX += BWidth)
{
for (u32 iImgY = iBlockY; iImgY < iBlockY + BHeight; iImgY++)
for (uint32 iImgY = iBlockY; iImgY < iBlockY + BHeight; iImgY++)
{
for (u32 iImgX = iBlockX; iImgX < iBlockX + BWidth; iImgX++)
for (uint32 iImgX = iBlockX; iImgX < iBlockX + BWidth; iImgX++)
{
u32 DstPos = ((iImgY * MipW) + iImgX) * PixelStride;
uint32 DstPos = ((iImgY * MipW) + iImgX) * PixelStride;
Out.Seek(MipOffset + DstPos, SEEK_SET);
if (mTexelFormat == eGX_I4) ReadPixelsI4(TXTR, Out);
@@ -286,7 +286,7 @@ void CTextureDecoder::PartialDecodeGXTexture(IInputStream& TXTR)
if (BreakEarly) break;
}
u32 MipSize = (u32) (MipW * MipH * gskPixelsToBytes[mTexelFormat]);
uint32 MipSize = (uint32) (MipW * MipH * gskPixelsToBytes[mTexelFormat]);
if (mTexelFormat == eGX_CMPR) MipSize *= 16; // Since we're pretending the image is 1/4 its actual size, we have to multiply the size by 16 to get the correct offset
MipOffset += MipSize;
@@ -300,22 +300,22 @@ void CTextureDecoder::PartialDecodeGXTexture(IInputStream& TXTR)
void CTextureDecoder::FullDecodeGXTexture(IInputStream& rTXTR)
{
// Get image data size, create output buffer
u32 ImageStart = rTXTR.Tell();
uint32 ImageStart = rTXTR.Tell();
rTXTR.Seek(0x0, SEEK_END);
u32 ImageSize = rTXTR.Tell() - ImageStart;
uint32 ImageSize = rTXTR.Tell() - ImageStart;
rTXTR.Seek(ImageStart, SEEK_SET);
mDataBufferSize = ImageSize * (32 / gskSourceBpp[mTexelFormat]);
mpDataBuffer = new u8[mDataBufferSize];
mpDataBuffer = new uint8[mDataBufferSize];
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::kSystemEndianness);
// Initializing more stuff before we start the mipmap loop
u32 MipW = mWidth, MipH = mHeight;
u32 MipOffset = 0;
uint32 MipW = mWidth, MipH = mHeight;
uint32 MipOffset = 0;
u32 BWidth = gskBlockWidth[mTexelFormat];
u32 BHeight = gskBlockHeight[mTexelFormat];
uint32 BWidth = gskBlockWidth[mTexelFormat];
uint32 BHeight = gskBlockHeight[mTexelFormat];
// With CMPR, we're using a little trick.
// CMPR stores pixels in 8x8 blocks, with four 4x4 subblocks.
@@ -327,30 +327,30 @@ void CTextureDecoder::FullDecodeGXTexture(IInputStream& rTXTR)
MipH /= 4;
}
for (u32 iMip = 0; iMip < mNumMipMaps; iMip++)
for (uint32 iMip = 0; iMip < mNumMipMaps; iMip++)
{
for (u32 iBlockY = 0; iBlockY < MipH; iBlockY += BHeight)
for (u32 iBlockX = 0; iBlockX < MipW; iBlockX += BWidth) {
for (u32 iImgY = iBlockY; iImgY < iBlockY + BHeight; iImgY++) {
for (u32 iImgX = iBlockX; iImgX < iBlockX + BWidth; iImgX++)
for (uint32 iBlockY = 0; iBlockY < MipH; iBlockY += BHeight)
for (uint32 iBlockX = 0; iBlockX < MipW; iBlockX += BWidth) {
for (uint32 iImgY = iBlockY; iImgY < iBlockY + BHeight; iImgY++) {
for (uint32 iImgX = iBlockX; iImgX < iBlockX + BWidth; iImgX++)
{
u32 DstPos = (mTexelFormat == eGX_CMPR) ? ((iImgY * (MipW * 4)) + iImgX) * 16 : ((iImgY * MipW) + iImgX) * 4;
uint32 DstPos = (mTexelFormat == eGX_CMPR) ? ((iImgY * (MipW * 4)) + iImgX) * 16 : ((iImgY * MipW) + iImgX) * 4;
Out.Seek(MipOffset + DstPos, SEEK_SET);
// I4/C4/CMPR require reading more than one pixel at a time
if (mTexelFormat == eGX_I4)
{
u8 Byte = rTXTR.ReadByte();
uint8 Byte = rTXTR.ReadByte();
Out.WriteLong( DecodePixelI4(Byte, 0).ToLongARGB() );
Out.WriteLong( DecodePixelI4(Byte, 1).ToLongARGB() );
}
else if (mTexelFormat == eGX_C4)
{
u8 Byte = rTXTR.ReadByte();
uint8 Byte = rTXTR.ReadByte();
Out.WriteLong( DecodePixelC4(Byte, 0, mPaletteInput).ToLongARGB() );
Out.WriteLong( DecodePixelC4(Byte, 1, mPaletteInput).ToLongARGB() );
}
else if (mTexelFormat == eGX_CMPR) DecodeSubBlockCMPR(rTXTR, Out, (u16) (MipW * 4));
else if (mTexelFormat == eGX_CMPR) DecodeSubBlockCMPR(rTXTR, Out, (uint16) (MipW * 4));
else
{
@@ -371,7 +371,7 @@ void CTextureDecoder::FullDecodeGXTexture(IInputStream& rTXTR)
if (mTexelFormat == eGX_RGBA8) rTXTR.Seek(0x20, SEEK_CUR);
}
u32 MipSize = MipW * MipH * 4;
uint32 MipSize = MipW * MipH * 4;
if (mTexelFormat == eGX_CMPR) MipSize *= 16;
MipOffset += MipSize;
@@ -385,24 +385,24 @@ void CTextureDecoder::FullDecodeGXTexture(IInputStream& rTXTR)
void CTextureDecoder::DecodeDDS(IInputStream& rDDS)
{
// Get image data size, create output buffer
u32 ImageStart = rDDS.Tell();
uint32 ImageStart = rDDS.Tell();
rDDS.Seek(0x0, SEEK_END);
u32 ImageSize = rDDS.Tell() - ImageStart;
uint32 ImageSize = rDDS.Tell() - ImageStart;
rDDS.Seek(ImageStart, SEEK_SET);
mDataBufferSize = ImageSize;
if (mDDSInfo.Format == SDDSInfo::DXT1) mDataBufferSize *= 8;
else if (mDDSInfo.Format == SDDSInfo::RGBA) mDataBufferSize *= (32 / mDDSInfo.BitCount);
else mDataBufferSize *= 4;
mpDataBuffer = new u8[mDataBufferSize];
mpDataBuffer = new uint8[mDataBufferSize];
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::kSystemEndianness);
// Initializing more stuff before we start the mipmap loop
u32 MipW = mWidth, MipH = mHeight;
u32 MipOffset = 0;
uint32 MipW = mWidth, MipH = mHeight;
uint32 MipOffset = 0;
u32 BPP;
uint32 BPP;
switch (mDDSInfo.Format)
{
case SDDSInfo::RGBA:
@@ -426,14 +426,14 @@ void CTextureDecoder::DecodeDDS(IInputStream& rDDS)
MipH /= 4;
}
for (u32 iMip = 0; iMip < mNumMipMaps; iMip++)
for (uint32 iMip = 0; iMip < mNumMipMaps; iMip++)
{
// For DXT1 we can copy the image data as-is to load it
if (mDDSInfo.Format == SDDSInfo::DXT1)
{
Out.Seek(MipOffset, SEEK_SET);
u32 MipSize = MipW * MipH / 2;
std::vector<u8> MipBuffer(MipSize);
uint32 MipSize = MipW * MipH / 2;
std::vector<uint8> MipBuffer(MipSize);
rDDS.ReadBytes(MipBuffer.data(), MipBuffer.size());
Out.WriteBytes(MipBuffer.data(), MipBuffer.size());
MipOffset += MipSize;
@@ -447,11 +447,11 @@ void CTextureDecoder::DecodeDDS(IInputStream& rDDS)
// Otherwise we do a full decode to RGBA8
else
{
for (u32 Y = 0; Y < MipH; Y++)
for (uint32 Y = 0; Y < MipH; Y++)
{
for (u32 X = 0; X < MipW; X++)
for (uint32 X = 0; X < MipW; X++)
{
u32 OutPos = MipOffset;
uint32 OutPos = MipOffset;
if (mDDSInfo.Format == SDDSInfo::RGBA)
{
@@ -477,7 +477,7 @@ void CTextureDecoder::DecodeDDS(IInputStream& rDDS)
}
}
u32 MipSize = (mWidth * mHeight) * 4;
uint32 MipSize = (mWidth * mHeight) * 4;
if (mDDSInfo.Format != SDDSInfo::RGBA) MipSize *= 16;
MipOffset += MipSize;
@@ -495,7 +495,7 @@ void CTextureDecoder::DecodeDDS(IInputStream& rDDS)
// ************ READ PIXELS (PARTIAL DECODE) ************
void CTextureDecoder::ReadPixelsI4(IInputStream& rSrc, IOutputStream& rDst)
{
u8 Pixels = rSrc.ReadByte();
uint8 Pixels = rSrc.ReadByte();
rDst.WriteByte(Extend4to8(Pixels >> 4));
rDst.WriteByte(Extend4to8(Pixels >> 4));
rDst.WriteByte(Extend4to8(Pixels));
@@ -504,7 +504,7 @@ void CTextureDecoder::ReadPixelsI4(IInputStream& rSrc, IOutputStream& rDst)
void CTextureDecoder::ReadPixelI8(IInputStream& rSrc, IOutputStream& rDst)
{
u8 Pixel = rSrc.ReadByte();
uint8 Pixel = rSrc.ReadByte();
rDst.WriteByte(Pixel);
rDst.WriteByte(Pixel);
}
@@ -512,9 +512,9 @@ void CTextureDecoder::ReadPixelI8(IInputStream& rSrc, IOutputStream& rDst)
void CTextureDecoder::ReadPixelIA4(IInputStream& rSrc, IOutputStream& rDst)
{
// this can be left as-is for DDS conversion, but opengl doesn't support two components in one byte...
u8 Byte = rSrc.ReadByte();
u8 Alpha = Extend4to8(Byte >> 4);
u8 Lum = Extend4to8(Byte);
uint8 Byte = rSrc.ReadByte();
uint8 Alpha = Extend4to8(Byte >> 4);
uint8 Lum = Extend4to8(Byte);
rDst.WriteShort((Lum << 8) | Alpha);
}
@@ -529,19 +529,19 @@ void CTextureDecoder::ReadPixelsC4(IInputStream& rSrc, IOutputStream& rDst)
// this is the only way to get them to decode correctly for now.
// Commented-out code is proper C4 decoding. Dedicated font texture-decoding function
// is probably going to be necessary in the future.
u8 Byte = rSrc.ReadByte();
u8 Indices[2];
uint8 Byte = rSrc.ReadByte();
uint8 Indices[2];
Indices[0] = (Byte >> 4) & 0xF;
Indices[1] = Byte & 0xF;
for (u32 iIdx = 0; iIdx < 2; iIdx++)
for (uint32 iIdx = 0; iIdx < 2; iIdx++)
{
u8 R, G, B, A;
uint8 R, G, B, A;
((Indices[iIdx] >> 3) & 0x1) ? R = 0xFF : R = 0x0;
((Indices[iIdx] >> 2) & 0x1) ? G = 0xFF : G = 0x0;
((Indices[iIdx] >> 1) & 0x1) ? B = 0xFF : B = 0x0;
((Indices[iIdx] >> 0) & 0x1) ? A = 0xFF : A = 0x0;
u32 RGBA = (R << 24) | (G << 16) | (B << 8) | (A);
uint32 RGBA = (R << 24) | (G << 16) | (B << 8) | (A);
rDst.WriteLong(RGBA);
/*mPaletteInput.Seek(indices[i] * 2, SEEK_SET);
@@ -555,7 +555,7 @@ void CTextureDecoder::ReadPixelsC4(IInputStream& rSrc, IOutputStream& rDst)
void CTextureDecoder::ReadPixelC8(IInputStream& rSrc, IOutputStream& rDst)
{
// DKCR fonts use C8 :|
u8 Index = rSrc.ReadByte();
uint8 Index = rSrc.ReadByte();
/*u8 R, G, B, A;
((Index >> 3) & 0x1) ? R = 0xFF : R = 0x0;
@@ -580,8 +580,8 @@ void CTextureDecoder::ReadPixelRGB565(IInputStream& rSrc, IOutputStream& rDst)
void CTextureDecoder::ReadPixelRGB5A3(IInputStream& rSrc, IOutputStream& rDst)
{
u16 Pixel = rSrc.ReadShort();
u8 R, G, B, A;
uint16 Pixel = rSrc.ReadShort();
uint8 R, G, B, A;
if (Pixel & 0x8000) // RGB5
{
@@ -599,17 +599,17 @@ void CTextureDecoder::ReadPixelRGB5A3(IInputStream& rSrc, IOutputStream& rDst)
R = Extend4to8(Pixel >> 0);
}
u32 Color = (A << 24) | (R << 16) | (G << 8) | B;
uint32 Color = (A << 24) | (R << 16) | (G << 8) | B;
rDst.WriteLong(Color);
}
void CTextureDecoder::ReadPixelRGBA8(IInputStream& rSrc, IOutputStream& rDst)
{
u16 AR = rSrc.ReadShort();
uint16 AR = rSrc.ReadShort();
rSrc.Seek(0x1E, SEEK_CUR);
u16 GB = rSrc.ReadShort();
uint16 GB = rSrc.ReadShort();
rSrc.Seek(-0x20, SEEK_CUR);
u32 Pixel = (AR << 16) | GB;
uint32 Pixel = (AR << 16) | GB;
rDst.WriteLong(Pixel);
}
@@ -618,42 +618,42 @@ void CTextureDecoder::ReadSubBlockCMPR(IInputStream& rSrc, IOutputStream& rDst)
rDst.WriteShort(rSrc.ReadShort());
rDst.WriteShort(rSrc.ReadShort());
for (u32 iByte = 0; iByte < 4; iByte++)
for (uint32 iByte = 0; iByte < 4; iByte++)
{
u8 Byte = rSrc.ReadByte();
uint8 Byte = rSrc.ReadByte();
Byte = ((Byte & 0x3) << 6) | ((Byte & 0xC) << 2) | ((Byte & 0x30) >> 2) | ((Byte & 0xC0) >> 6);
rDst.WriteByte(Byte);
}
}
// ************ DECODE PIXELS (FULL DECODE TO RGBA8) ************
CColor CTextureDecoder::DecodePixelI4(u8 Byte, u8 WhichPixel)
CColor CTextureDecoder::DecodePixelI4(uint8 Byte, uint8 WhichPixel)
{
if (WhichPixel == 1) Byte >>= 4;
u8 Pixel = Extend4to8(Byte);
uint8 Pixel = Extend4to8(Byte);
return CColor::Integral(Pixel, Pixel, Pixel);
}
CColor CTextureDecoder::DecodePixelI8(u8 Byte)
CColor CTextureDecoder::DecodePixelI8(uint8 Byte)
{
return CColor::Integral(Byte, Byte, Byte);
}
CColor CTextureDecoder::DecodePixelIA4(u8 Byte)
CColor CTextureDecoder::DecodePixelIA4(uint8 Byte)
{
u8 Alpha = Extend4to8(Byte >> 4);
u8 Lum = Extend4to8(Byte);
uint8 Alpha = Extend4to8(Byte >> 4);
uint8 Lum = Extend4to8(Byte);
return CColor::Integral(Lum, Lum, Lum, Alpha);
}
CColor CTextureDecoder::DecodePixelIA8(u16 Short)
CColor CTextureDecoder::DecodePixelIA8(uint16 Short)
{
u8 Alpha = (Short >> 8) & 0xFF;
u8 Lum = Short & 0xFF;
uint8 Alpha = (Short >> 8) & 0xFF;
uint8 Lum = Short & 0xFF;
return CColor::Integral(Lum, Lum, Lum, Alpha);
}
CColor CTextureDecoder::DecodePixelC4(u8 Byte, u8 WhichPixel, IInputStream& rPaletteStream)
CColor CTextureDecoder::DecodePixelC4(uint8 Byte, uint8 WhichPixel, IInputStream& rPaletteStream)
{
if (WhichPixel == 1) Byte >>= 4;
Byte &= 0xF;
@@ -665,7 +665,7 @@ CColor CTextureDecoder::DecodePixelC4(u8 Byte, u8 WhichPixel, IInputStream& rPal
else return CColor::skTransparentBlack;
}
CColor CTextureDecoder::DecodePixelC8(u8 Byte, IInputStream& rPaletteStream)
CColor CTextureDecoder::DecodePixelC8(uint8 Byte, IInputStream& rPaletteStream)
{
rPaletteStream.Seek(Byte * 2, SEEK_SET);
if (mPaletteFormat == ePalette_IA8) return DecodePixelIA8(rPaletteStream.ReadShort());
@@ -674,39 +674,39 @@ CColor CTextureDecoder::DecodePixelC8(u8 Byte, IInputStream& rPaletteStream)
else return CColor::skTransparentBlack;
}
CColor CTextureDecoder::DecodePixelRGB565(u16 Short)
CColor CTextureDecoder::DecodePixelRGB565(uint16 Short)
{
u8 B = Extend5to8( (u8) (Short >> 11) );
u8 G = Extend6to8( (u8) (Short >> 5) );
u8 R = Extend5to8( (u8) (Short) );
uint8 B = Extend5to8( (uint8) (Short >> 11) );
uint8 G = Extend6to8( (uint8) (Short >> 5) );
uint8 R = Extend5to8( (uint8) (Short) );
return CColor::Integral(R, G, B, 0xFF);
}
CColor CTextureDecoder::DecodePixelRGB5A3(u16 Short)
CColor CTextureDecoder::DecodePixelRGB5A3(uint16 Short)
{
if (Short & 0x8000) // RGB5
{
u8 B = Extend5to8( (u8) (Short >> 10));
u8 G = Extend5to8( (u8) (Short >> 5));
u8 R = Extend5to8( (u8) (Short) );
uint8 B = Extend5to8( (uint8) (Short >> 10));
uint8 G = Extend5to8( (uint8) (Short >> 5));
uint8 R = Extend5to8( (uint8) (Short) );
return CColor::Integral(R, G, B, 0xFF);
}
else // RGB4A3
{
u8 A = Extend3to8( (u8) (Short >> 12) );
u8 B = Extend4to8( (u8) (Short >> 8) );
u8 G = Extend4to8( (u8) (Short >> 4) );
u8 R = Extend4to8( (u8) (Short) );
uint8 A = Extend3to8( (uint8) (Short >> 12) );
uint8 B = Extend4to8( (uint8) (Short >> 8) );
uint8 G = Extend4to8( (uint8) (Short >> 4) );
uint8 R = Extend4to8( (uint8) (Short) );
return CColor::Integral(R, G, B, A);
}
}
void CTextureDecoder::DecodeSubBlockCMPR(IInputStream& rSrc, IOutputStream& rDst, u16 Width)
void CTextureDecoder::DecodeSubBlockCMPR(IInputStream& rSrc, IOutputStream& rDst, uint16 Width)
{
CColor Palettes[4];
u16 PaletteA = rSrc.ReadShort();
u16 PaletteB = rSrc.ReadShort();
uint16 PaletteA = rSrc.ReadShort();
uint16 PaletteB = rSrc.ReadShort();
Palettes[0] = DecodePixelRGB565(PaletteA);
Palettes[1] = DecodePixelRGB565(PaletteB);
@@ -721,14 +721,14 @@ void CTextureDecoder::DecodeSubBlockCMPR(IInputStream& rSrc, IOutputStream& rDst
Palettes[3] = CColor::skTransparentBlack;
}
for (u32 iBlockY = 0; iBlockY < 4; iBlockY++)
for (uint32 iBlockY = 0; iBlockY < 4; iBlockY++)
{
u8 Byte = rSrc.ReadByte();
uint8 Byte = rSrc.ReadByte();
for (u32 iBlockX = 0; iBlockX < 4; iBlockX++)
for (uint32 iBlockX = 0; iBlockX < 4; iBlockX++)
{
u8 Shift = (u8) (6 - (iBlockX * 2));
u8 PaletteIndex = (Byte >> Shift) & 0x3;
uint8 Shift = (uint8) (6 - (iBlockX * 2));
uint8 PaletteIndex = (Byte >> Shift) & 0x3;
CColor Pixel = Palettes[PaletteIndex];
rDst.WriteLong(Pixel.ToLongARGB());
}
@@ -737,13 +737,13 @@ void CTextureDecoder::DecodeSubBlockCMPR(IInputStream& rSrc, IOutputStream& rDst
}
}
void CTextureDecoder::DecodeBlockBC1(IInputStream& rSrc, IOutputStream& rDst, u32 Width)
void CTextureDecoder::DecodeBlockBC1(IInputStream& rSrc, IOutputStream& rDst, uint32 Width)
{
// Very similar to the CMPR subblock function, but unfortunately a slight
// difference in the order the pixel indices are read requires a separate function
CColor Palettes[4];
u16 PaletteA = rSrc.ReadShort();
u16 PaletteB = rSrc.ReadShort();
uint16 PaletteA = rSrc.ReadShort();
uint16 PaletteB = rSrc.ReadShort();
Palettes[0] = DecodePixelRGB565(PaletteA);
Palettes[1] = DecodePixelRGB565(PaletteB);
@@ -758,14 +758,14 @@ void CTextureDecoder::DecodeBlockBC1(IInputStream& rSrc, IOutputStream& rDst, u3
Palettes[3] = CColor::skTransparentBlack;
}
for (u32 iBlockY = 0; iBlockY < 4; iBlockY++)
for (uint32 iBlockY = 0; iBlockY < 4; iBlockY++)
{
u8 Byte = rSrc.ReadByte();
uint8 Byte = rSrc.ReadByte();
for (u32 iBlockX = 0; iBlockX < 4; iBlockX++)
for (uint32 iBlockX = 0; iBlockX < 4; iBlockX++)
{
u8 Shift = (u8) (iBlockX * 2);
u8 PaletteIndex = (Byte >> Shift) & 0x3;
uint8 Shift = (uint8) (iBlockX * 2);
uint8 PaletteIndex = (Byte >> Shift) & 0x3;
CColor Pixel = Palettes[PaletteIndex];
rDst.WriteLong(Pixel.ToLongARGB());
}
@@ -774,11 +774,11 @@ void CTextureDecoder::DecodeBlockBC1(IInputStream& rSrc, IOutputStream& rDst, u3
}
}
void CTextureDecoder::DecodeBlockBC2(IInputStream& rSrc, IOutputStream& rDst, u32 Width)
void CTextureDecoder::DecodeBlockBC2(IInputStream& rSrc, IOutputStream& rDst, uint32 Width)
{
CColor CPalettes[4];
u16 PaletteA = rSrc.ReadShort();
u16 PaletteB = rSrc.ReadShort();
uint16 PaletteA = rSrc.ReadShort();
uint16 PaletteB = rSrc.ReadShort();
CPalettes[0] = DecodePixelRGB565(PaletteA);
CPalettes[1] = DecodePixelRGB565(PaletteB);
@@ -793,14 +793,14 @@ void CTextureDecoder::DecodeBlockBC2(IInputStream& rSrc, IOutputStream& rDst, u3
CPalettes[3] = CColor::skTransparentBlack;
}
for (u32 iBlockY = 0; iBlockY < 4; iBlockY++)
for (uint32 iBlockY = 0; iBlockY < 4; iBlockY++)
{
u8 Byte = rSrc.ReadByte();
uint8 Byte = rSrc.ReadByte();
for (u32 iBlockX = 0; iBlockX < 4; iBlockX++)
for (uint32 iBlockX = 0; iBlockX < 4; iBlockX++)
{
u8 Shift = (u8) (iBlockX * 2);
u8 PaletteIndex = (Byte >> Shift) & 0x3;
uint8 Shift = (uint8) (iBlockX * 2);
uint8 PaletteIndex = (Byte >> Shift) & 0x3;
CColor Pixel = CPalettes[PaletteIndex];
rDst.WriteLong(Pixel.ToLongARGB());
}
@@ -809,11 +809,11 @@ void CTextureDecoder::DecodeBlockBC2(IInputStream& rSrc, IOutputStream& rDst, u3
}
}
void CTextureDecoder::DecodeBlockBC3(IInputStream& rSrc, IOutputStream& rDst, u32 Width)
void CTextureDecoder::DecodeBlockBC3(IInputStream& rSrc, IOutputStream& rDst, uint32 Width)
{
CColor Palettes[4];
u16 PaletteA = rSrc.ReadShort();
u16 PaletteB = rSrc.ReadShort();
uint16 PaletteA = rSrc.ReadShort();
uint16 PaletteB = rSrc.ReadShort();
Palettes[0] = DecodePixelRGB565(PaletteA);
Palettes[1] = DecodePixelRGB565(PaletteB);
@@ -828,14 +828,14 @@ void CTextureDecoder::DecodeBlockBC3(IInputStream& rSrc, IOutputStream& rDst, u3
Palettes[3] = CColor::skTransparentBlack;
}
for (u32 iBlockY = 0; iBlockY < 4; iBlockY++)
for (uint32 iBlockY = 0; iBlockY < 4; iBlockY++)
{
u8 Byte = rSrc.ReadByte();
uint8 Byte = rSrc.ReadByte();
for (u32 iBlockX = 0; iBlockX < 4; iBlockX++)
for (uint32 iBlockX = 0; iBlockX < 4; iBlockX++)
{
u8 Shift = (u8) (iBlockX * 2);
u8 PaletteIndex = (Byte >> Shift) & 0x3;
uint8 Shift = (uint8) (iBlockX * 2);
uint8 PaletteIndex = (Byte >> Shift) & 0x3;
CColor Pixel = Palettes[PaletteIndex];
rDst.WriteLong(Pixel.ToLongARGB());
}
@@ -850,33 +850,33 @@ CColor CTextureDecoder::DecodeDDSPixel(IInputStream& /*rDDS*/)
}
// ************ UTILITY ************
u8 CTextureDecoder::Extend3to8(u8 In)
uint8 CTextureDecoder::Extend3to8(uint8 In)
{
In &= 0x7;
return (In << 5) | (In << 2) | (In >> 1);
}
u8 CTextureDecoder::Extend4to8(u8 In)
uint8 CTextureDecoder::Extend4to8(uint8 In)
{
In &= 0xF;
return (In << 4) | In;
}
u8 CTextureDecoder::Extend5to8(u8 In)
uint8 CTextureDecoder::Extend5to8(uint8 In)
{
In &= 0x1F;
return (In << 3) | (In >> 2);
}
u8 CTextureDecoder::Extend6to8(u8 In)
uint8 CTextureDecoder::Extend6to8(uint8 In)
{
In &= 0x3F;
return (In << 2) | (In >> 4);
}
u32 CTextureDecoder::CalculateShiftForMask(u32 BitMask)
uint32 CTextureDecoder::CalculateShiftForMask(uint32 BitMask)
{
u32 Shift = 32;
uint32 Shift = 32;
while (BitMask)
{
@@ -886,9 +886,9 @@ u32 CTextureDecoder::CalculateShiftForMask(u32 BitMask)
return Shift;
}
u32 CTextureDecoder::CalculateMaskBitCount(u32 BitMask)
uint32 CTextureDecoder::CalculateMaskBitCount(uint32 BitMask)
{
u32 Count = 0;
uint32 Count = 0;
while (BitMask)
{

View File

@@ -3,8 +3,8 @@
#include "Core/Resource/CTexture.h"
#include "Core/Resource/ETexelFormat.h"
#include <Common/BasicTypes.h>
#include <Common/CColor.h>
#include <Common/types.h>
#include <Common/FileIO.h>
@@ -12,26 +12,26 @@ class CTextureDecoder
{
CResourceEntry *mpEntry;
ETexelFormat mTexelFormat;
u16 mWidth, mHeight;
u32 mNumMipMaps;
uint16 mWidth, mHeight;
uint32 mNumMipMaps;
bool mHasPalettes;
EGXPaletteFormat mPaletteFormat;
std::vector<u8> mPalettes;
std::vector<uint8> mPalettes;
CMemoryInStream mPaletteInput;
struct SDDSInfo
{
enum { DXT1, DXT2, DXT3, DXT4, DXT5, RGBA } Format;
u32 Flags;
u32 BitCount;
u32 RBitMask, GBitMask, BBitMask, ABitMask;
u32 RShift, GShift, BShift, AShift;
u32 RSize, GSize, BSize, ASize;
uint32 Flags;
uint32 BitCount;
uint32 RBitMask, GBitMask, BBitMask, ABitMask;
uint32 RShift, GShift, BShift, AShift;
uint32 RSize, GSize, BSize, ASize;
} mDDSInfo;
u8 *mpDataBuffer;
u32 mDataBufferSize;
uint8 *mpDataBuffer;
uint32 mDataBufferSize;
// Private Functions
CTextureDecoder();
@@ -60,20 +60,20 @@ class CTextureDecoder
void ReadSubBlockCMPR(IInputStream& rSrc, IOutputStream& rDst);
// Decode Pixels (convert to RGBA8)
CColor DecodePixelI4(u8 Byte, u8 WhichPixel);
CColor DecodePixelI8(u8 Byte);
CColor DecodePixelIA4(u8 Byte);
CColor DecodePixelIA8(u16 Short);
CColor DecodePixelC4(u8 Byte, u8 WhichPixel, IInputStream& rPaletteStream);
CColor DecodePixelC8(u8 Byte, IInputStream& rPaletteStream);
CColor DecodePixelRGB565(u16 Short);
CColor DecodePixelRGB5A3(u16 Short);
CColor DecodePixelI4(uint8 Byte, uint8 WhichPixel);
CColor DecodePixelI8(uint8 Byte);
CColor DecodePixelIA4(uint8 Byte);
CColor DecodePixelIA8(uint16 Short);
CColor DecodePixelC4(uint8 Byte, uint8 WhichPixel, IInputStream& rPaletteStream);
CColor DecodePixelC8(uint8 Byte, IInputStream& rPaletteStream);
CColor DecodePixelRGB565(uint16 Short);
CColor DecodePixelRGB5A3(uint16 Short);
CColor DecodePixelRGBA8(IInputStream& rSrc, IOutputStream& rDst);
void DecodeSubBlockCMPR(IInputStream& rSrc, IOutputStream& rDst, u16 Width);
void DecodeSubBlockCMPR(IInputStream& rSrc, IOutputStream& rDst, uint16 Width);
void DecodeBlockBC1(IInputStream& rSrc, IOutputStream& rDst, u32 Width);
void DecodeBlockBC2(IInputStream& rSrc, IOutputStream& rDst, u32 Width);
void DecodeBlockBC3(IInputStream& rSrc, IOutputStream& rDst, u32 Width);
void DecodeBlockBC1(IInputStream& rSrc, IOutputStream& rDst, uint32 Width);
void DecodeBlockBC2(IInputStream& rSrc, IOutputStream& rDst, uint32 Width);
void DecodeBlockBC3(IInputStream& rSrc, IOutputStream& rDst, uint32 Width);
CColor DecodeDDSPixel(IInputStream& rDDS);
// Static
@@ -84,12 +84,12 @@ public:
static CTexture* DoFullDecode(CTexture *pTexture);
// Utility
static u8 Extend3to8(u8 In);
static u8 Extend4to8(u8 In);
static u8 Extend5to8(u8 In);
static u8 Extend6to8(u8 In);
static u32 CalculateShiftForMask(u32 BitMask);
static u32 CalculateMaskBitCount(u32 BitMask);
static uint8 Extend3to8(uint8 In);
static uint8 Extend4to8(uint8 In);
static uint8 Extend5to8(uint8 In);
static uint8 Extend6to8(uint8 In);
static uint32 CalculateShiftForMask(uint32 BitMask);
static uint32 CalculateMaskBitCount(uint32 BitMask);
};
#endif // CTEXTUREDECODER_H

View File

@@ -6,13 +6,13 @@
void CUnsupportedFormatLoader::PerformCheating(IInputStream& rFile, EGame Game, std::list<CAssetID>& rAssetList)
{
// Analyze file contents and check every sequence of 4/8 bytes for asset IDs
std::vector<u8> Data(rFile.Size() - rFile.Tell());
std::vector<uint8> Data(rFile.Size() - rFile.Tell());
rFile.ReadBytes(Data.data(), Data.size());
u32 MaxIndex = (Game <= EGame::Echoes ? Data.size() - 3 : Data.size() - 7);
uint32 MaxIndex = (Game <= EGame::Echoes ? Data.size() - 3 : Data.size() - 7);
CAssetID ID;
for (u32 iByte = 0; iByte < MaxIndex; iByte++)
for (uint32 iByte = 0; iByte < MaxIndex; iByte++)
{
if (Game <= EGame::Echoes)
{
@@ -23,14 +23,14 @@ void CUnsupportedFormatLoader::PerformCheating(IInputStream& rFile, EGame Game,
}
else
{
ID = ( ((u64) Data[iByte+0] << 56) |
((u64) Data[iByte+1] << 48) |
((u64) Data[iByte+2] << 40) |
((u64) Data[iByte+3] << 32) |
((u64) Data[iByte+4] << 24) |
((u64) Data[iByte+5] << 16) |
((u64) Data[iByte+6] << 8) |
((u64) Data[iByte+7] << 0) );
ID = ( ((uint64) Data[iByte+0] << 56) |
((uint64) Data[iByte+1] << 48) |
((uint64) Data[iByte+2] << 40) |
((uint64) Data[iByte+3] << 32) |
((uint64) Data[iByte+4] << 24) |
((uint64) Data[iByte+5] << 16) |
((uint64) Data[iByte+6] << 8) |
((uint64) Data[iByte+7] << 0) );
}
if (gpResourceStore->IsResourceRegistered(ID))
@@ -40,10 +40,10 @@ void CUnsupportedFormatLoader::PerformCheating(IInputStream& rFile, EGame Game,
CAudioMacro* CUnsupportedFormatLoader::LoadCAUD(IInputStream& rCAUD, CResourceEntry *pEntry)
{
u32 Magic = rCAUD.ReadLong();
uint32 Magic = rCAUD.ReadLong();
ASSERT(Magic == FOURCC('CAUD'));
u32 Version = rCAUD.ReadLong();
uint32 Version = rCAUD.ReadLong();
EGame Game = (Version == 0x2 ? EGame::CorruptionProto :
Version == 0x9 ? EGame::Corruption :
Version == 0xE ? EGame::DKCReturns :
@@ -66,19 +66,19 @@ CAudioMacro* CUnsupportedFormatLoader::LoadCAUD(IInputStream& rCAUD, CResourceEn
}
// Skip past the rest of the header
u32 NumVolGroups = rCAUD.ReadLong();
uint32 NumVolGroups = rCAUD.ReadLong();
for (u32 iVol = 0; iVol < NumVolGroups; iVol++)
for (uint32 iVol = 0; iVol < NumVolGroups; iVol++)
rCAUD.ReadString();
u32 SkipAmt = (Game == EGame::CorruptionProto ? 0x10 : 0x14);
uint32 SkipAmt = (Game == EGame::CorruptionProto ? 0x10 : 0x14);
rCAUD.Seek(SkipAmt, SEEK_CUR);
u32 NumSamples = rCAUD.ReadLong();
uint32 NumSamples = rCAUD.ReadLong();
for (u32 iSamp = 0; iSamp < NumSamples; iSamp++)
for (uint32 iSamp = 0; iSamp < NumSamples; iSamp++)
{
u32 SampleDataSize = rCAUD.ReadLong();
u32 SampleDataEnd = rCAUD.Tell() + SampleDataSize;
uint32 SampleDataSize = rCAUD.ReadLong();
uint32 SampleDataEnd = rCAUD.Tell() + SampleDataSize;
CAssetID SampleID(rCAUD, Game);
ASSERT(gpResourceStore->IsResourceRegistered(SampleID) == true);
@@ -92,7 +92,7 @@ CAudioMacro* CUnsupportedFormatLoader::LoadCAUD(IInputStream& rCAUD, CResourceEn
CDependencyGroup* CUnsupportedFormatLoader::LoadCSNG(IInputStream& rCSNG, CResourceEntry *pEntry)
{
u32 Magic = rCSNG.ReadLong();
uint32 Magic = rCSNG.ReadLong();
ASSERT(Magic == 0x2);
rCSNG.Seek(0x8, SEEK_CUR);
@@ -121,16 +121,16 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadDUMB(IInputStream& rDUMB, CResou
CDependencyGroup* CUnsupportedFormatLoader::LoadFRME(IInputStream& rFRME, CResourceEntry *pEntry)
{
u32 Version = rFRME.ReadLong();
uint32 Version = rFRME.ReadLong();
CDependencyGroup *pGroup = new CDependencyGroup(pEntry);
// Prime 1
if (Version == 0 || Version == 1)
{
rFRME.Seek(0xC, SEEK_CUR);
u32 NumWidgets = rFRME.ReadLong();
uint32 NumWidgets = rFRME.ReadLong();
for (u32 iWgt = 0; iWgt < NumWidgets; iWgt++)
for (uint32 iWgt = 0; iWgt < NumWidgets; iWgt++)
{
// Widget Header
CFourCC WidgetType = rFRME.ReadLong();
@@ -139,13 +139,13 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadFRME(IInputStream& rFRME, CResou
rFRME.Seek(0x18, SEEK_CUR);
// Head Widget / Base Widget
if (WidgetType == "HWIG" || WidgetType == "BWIG")
if (WidgetType == FOURCC('HWIG') || WidgetType == FOURCC('BWIG'))
{}
// Camera
else if (WidgetType == "CAMR")
else if (WidgetType == FOURCC('CAMR'))
{
u32 ProjectionType = rFRME.ReadLong();
uint32 ProjectionType = rFRME.ReadLong();
if (ProjectionType == 0)
rFRME.Seek(0x10, SEEK_CUR);
@@ -154,34 +154,34 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadFRME(IInputStream& rFRME, CResou
}
// Light
else if (WidgetType == "LITE")
else if (WidgetType == FOURCC('LITE'))
{
u32 LightType = rFRME.ReadLong();
uint32 LightType = rFRME.ReadLong();
rFRME.Seek(0x1C, SEEK_CUR);
if (LightType == 0) rFRME.Seek(0x4, SEEK_CUR);
}
// Meter
else if (WidgetType == "METR")
else if (WidgetType == FOURCC('METR'))
rFRME.Seek(0xA, SEEK_CUR);
// Group
else if (WidgetType == "GRUP")
else if (WidgetType == FOURCC('GRUP'))
rFRME.Seek(0x3, SEEK_CUR);
// Table Group
else if (WidgetType == "TBGP")
else if (WidgetType == FOURCC('TBGP'))
rFRME.Seek(0x23, SEEK_CUR);
// Model
else if (WidgetType == "MODL")
else if (WidgetType == FOURCC('MODL'))
{
pGroup->AddDependency( CAssetID(rFRME, e32Bit) ); // CMDL
rFRME.Seek(0x8, SEEK_CUR);
}
// Text Pane
else if (WidgetType == "TXPN")
else if (WidgetType == FOURCC('TXPN'))
{
rFRME.Seek(0x14, SEEK_CUR);
pGroup->AddDependency( CAssetID(rFRME, e32Bit) ); // FONT
@@ -195,33 +195,33 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadFRME(IInputStream& rFRME, CResou
}
// Image Pane
else if (WidgetType == "IMGP")
else if (WidgetType == FOURCC('IMGP'))
{
pGroup->AddDependency( CAssetID(rFRME, e32Bit) ); // TXTR
if (rFRME.ReadLong() != 0xFFFFFFFF) DEBUG_BREAK;
rFRME.Seek(0x4, SEEK_CUR);
u32 NumQuadCoords = rFRME.ReadLong();
uint32 NumQuadCoords = rFRME.ReadLong();
rFRME.Seek(NumQuadCoords * 0xC, SEEK_CUR);
u32 NumUVCoords = rFRME.ReadLong();
uint32 NumUVCoords = rFRME.ReadLong();
rFRME.Seek(NumUVCoords * 8, SEEK_CUR);
}
// Energy Bar
else if (WidgetType == "ENRG")
else if (WidgetType == FOURCC('ENRG'))
{
pGroup->AddDependency( CAssetID(rFRME, e32Bit) ); // TXTR
}
// Slider Group
else if (WidgetType == "SLGP")
else if (WidgetType == FOURCC('SLGP'))
{
rFRME.Seek(0x10, SEEK_CUR);
}
else
{
Log::Error("Unrecognized FRME widget type: " + WidgetType.ToString());
errorf("Unrecognized FRME widget type: %s", *WidgetType.ToString());
DEBUG_BREAK;
}
@@ -241,9 +241,9 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadFRME(IInputStream& rFRME, CResou
else if (Version == 0x10) Game = EGame::DKCReturns;
else Game = EGame::Corruption;
u32 NumDependencies = rFRME.ReadLong();
uint32 NumDependencies = rFRME.ReadLong();
for (u32 iDep = 0; iDep < NumDependencies; iDep++)
for (uint32 iDep = 0; iDep < NumDependencies; iDep++)
{
rFRME.Seek(0x4, SEEK_CUR);
pGroup->AddDependency( CAssetID(rFRME, Game) );
@@ -252,7 +252,7 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadFRME(IInputStream& rFRME, CResou
else
{
Log::Error("Unrecognized FRME version: " + TString::HexString(Version, 2));
errorf("Unrecognized FRME version: %d", Version);
delete pGroup;
return nullptr;
}
@@ -262,38 +262,38 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadFRME(IInputStream& rFRME, CResou
CDependencyGroup* CUnsupportedFormatLoader::LoadFSM2(IInputStream& rFSM2, CResourceEntry *pEntry)
{
u32 Magic = rFSM2.ReadLong();
uint32 Magic = rFSM2.ReadLong();
ASSERT(Magic == FOURCC('FSM2'));
CDependencyGroup *pOut = new CDependencyGroup(pEntry);
u32 Version = rFSM2.ReadLong();
u32 NumStates = rFSM2.ReadLong();
u32 NumUnkA = rFSM2.ReadLong();
u32 NumUnkB = rFSM2.ReadLong();
u32 NumUnkC = rFSM2.ReadLong();
uint32 Version = rFSM2.ReadLong();
uint32 NumStates = rFSM2.ReadLong();
uint32 NumUnkA = rFSM2.ReadLong();
uint32 NumUnkB = rFSM2.ReadLong();
uint32 NumUnkC = rFSM2.ReadLong();
ASSERT(Version == 1 || Version == 2);
for (u32 iState = 0; iState < NumStates; iState++)
for (uint32 iState = 0; iState < NumStates; iState++)
{
rFSM2.ReadString();
if (Version >= 2) rFSM2.Seek(0x10, SEEK_CUR);
u32 UnkCount = rFSM2.ReadLong();
uint32 UnkCount = rFSM2.ReadLong();
for (u32 iUnk = 0; iUnk < UnkCount; iUnk++)
for (uint32 iUnk = 0; iUnk < UnkCount; iUnk++)
{
rFSM2.ReadString();
rFSM2.Seek(0x4, SEEK_CUR);
}
}
for (u32 iUnkA = 0; iUnkA < NumUnkA; iUnkA++)
for (uint32 iUnkA = 0; iUnkA < NumUnkA; iUnkA++)
{
rFSM2.ReadString();
if (Version >= 2) rFSM2.Seek(0x10, SEEK_CUR);
rFSM2.Seek(0x4, SEEK_CUR);
u32 UnkCount = rFSM2.ReadLong();
uint32 UnkCount = rFSM2.ReadLong();
for (u32 iUnkA2 = 0; iUnkA2 < UnkCount; iUnkA2++)
for (uint32 iUnkA2 = 0; iUnkA2 < UnkCount; iUnkA2++)
{
rFSM2.ReadString();
rFSM2.Seek(0x4, SEEK_CUR);
@@ -302,26 +302,26 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadFSM2(IInputStream& rFSM2, CResou
rFSM2.Seek(0x1, SEEK_CUR);
}
for (u32 iUnkB = 0; iUnkB < NumUnkB; iUnkB++)
for (uint32 iUnkB = 0; iUnkB < NumUnkB; iUnkB++)
{
rFSM2.ReadString();
if (Version >= 2) rFSM2.Seek(0x10, SEEK_CUR);
u32 UnkCount = rFSM2.ReadLong();
uint32 UnkCount = rFSM2.ReadLong();
for (u32 iUnkB2 = 0; iUnkB2 < UnkCount; iUnkB2++)
for (uint32 iUnkB2 = 0; iUnkB2 < UnkCount; iUnkB2++)
{
rFSM2.ReadString();
rFSM2.Seek(0x4, SEEK_CUR);
}
}
for (u32 iUnkC = 0; iUnkC < NumUnkC; iUnkC++)
for (uint32 iUnkC = 0; iUnkC < NumUnkC; iUnkC++)
{
rFSM2.ReadString();
if (Version >= 2) rFSM2.Seek(0x10, SEEK_CUR);
u32 UnkCount = rFSM2.ReadLong();
uint32 UnkCount = rFSM2.ReadLong();
for (u32 iUnkC2 = 0; iUnkC2 < UnkCount; iUnkC2++)
for (uint32 iUnkC2 = 0; iUnkC2 < UnkCount; iUnkC2++)
{
rFSM2.ReadString();
rFSM2.Seek(0x4, SEEK_CUR);
@@ -354,7 +354,7 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadHIER(IInputStream& rHIER, CResou
CFourCC Magic = rHIER.ReadLong();
ASSERT(Magic == "HIER");
u32 NumNodes = rHIER.ReadLong();
uint32 NumNodes = rHIER.ReadLong();
CDependencyGroup *pOut = new CDependencyGroup(pEntry);
// Note: For some reason this file still exists in MP3 and it's identical to MP2, including with 32-bit asset IDs.
@@ -362,7 +362,7 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadHIER(IInputStream& rHIER, CResou
if (pEntry->Game() > EGame::Echoes)
return pOut;
for (u32 iNode = 0; iNode < NumNodes; iNode++)
for (uint32 iNode = 0; iNode < NumNodes; iNode++)
{
// NOTE: The SCAN ID isn't considered a real dependency!
pOut->AddDependency( rHIER.ReadLong() );
@@ -375,11 +375,11 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadHIER(IInputStream& rHIER, CResou
CDependencyGroup* CUnsupportedFormatLoader::LoadHINT(IInputStream& rHINT, CResourceEntry *pEntry)
{
u32 Magic = rHINT.ReadLong();
uint32 Magic = rHINT.ReadLong();
ASSERT(Magic == 0x00BADBAD);
// Determine version
u32 Version = rHINT.ReadLong();
uint32 Version = rHINT.ReadLong();
EGame Game;
if (Version == 0x1) Game = EGame::Prime;
@@ -387,15 +387,15 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadHINT(IInputStream& rHINT, CResou
else
{
Log::Error("Unrecognized HINT version: " + TString::FromInt32(Version, 0, 10));
errorf("Unrecognized HINT version: %d", Version);
return nullptr;
}
// Read main file
CDependencyGroup *pGroup = new CDependencyGroup(pEntry);
u32 NumHints = rHINT.ReadLong();
uint32 NumHints = rHINT.ReadLong();
for (u32 iHint = 0; iHint < NumHints; iHint++)
for (uint32 iHint = 0; iHint < NumHints; iHint++)
{
rHINT.ReadString(); // Skip hint name
rHINT.Seek(0x8, SEEK_CUR); // Skip unknown + appear time
@@ -413,9 +413,9 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadHINT(IInputStream& rHINT, CResou
else
{
u32 NumLocations = rHINT.ReadLong();
uint32 NumLocations = rHINT.ReadLong();
for (u32 iLoc = 0; iLoc < NumLocations; iLoc++)
for (uint32 iLoc = 0; iLoc < NumLocations; iLoc++)
{
rHINT.Seek(0x14, SEEK_CUR); // Skip world/area ID, area index
pGroup->AddDependency( CAssetID(rHINT, Game) ); // Objective string
@@ -436,13 +436,13 @@ CMapArea* CUnsupportedFormatLoader::LoadMAPA(IInputStream& /*rMAPA*/, CResourceE
// Find a MapWorld that contains this MapArea
CAssetID MapWorldID;
u32 WorldIndex = -1;
uint32 WorldIndex = -1;
for (TResourceIterator<eMapWorld> It; It; ++It)
{
CDependencyGroup *pGroup = (CDependencyGroup*) It->Load();
for (u32 AreaIdx = 0; AreaIdx < pGroup->NumDependencies(); AreaIdx++)
for (uint32 AreaIdx = 0; AreaIdx < pGroup->NumDependencies(); AreaIdx++)
{
if (pGroup->DependencyByIndex(AreaIdx) == MapAreaID)
{
@@ -479,16 +479,16 @@ CMapArea* CUnsupportedFormatLoader::LoadMAPA(IInputStream& /*rMAPA*/, CResourceE
CDependencyGroup* CUnsupportedFormatLoader::LoadMAPW(IInputStream& rMAPW, CResourceEntry *pEntry)
{
u32 Magic = rMAPW.ReadLong();
uint32 Magic = rMAPW.ReadLong();
ASSERT(Magic == 0xDEADF00D);
u32 Version = rMAPW.ReadLong();
uint32 Version = rMAPW.ReadLong();
ASSERT(Version == 1);
u32 NumAreas = rMAPW.ReadLong();
uint32 NumAreas = rMAPW.ReadLong();
// Version check
u32 AreasStart = rMAPW.Tell();
uint32 AreasStart = rMAPW.Tell();
rMAPW.Seek(NumAreas * 4, SEEK_CUR);
EIDLength IDLength = (rMAPW.EoF() || rMAPW.ReadLong() == 0xFFFFFFFF ? e32Bit : e64Bit);
rMAPW.Seek(AreasStart, SEEK_SET);
@@ -496,7 +496,7 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadMAPW(IInputStream& rMAPW, CResou
// Read MAPA IDs
CDependencyGroup *pGroup = new CDependencyGroup(pEntry);
for (u32 iArea = 0; iArea < NumAreas; iArea++)
for (uint32 iArea = 0; iArea < NumAreas; iArea++)
pGroup->AddDependency( CAssetID(rMAPW, IDLength) );
return pGroup;
@@ -504,24 +504,24 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadMAPW(IInputStream& rMAPW, CResou
CDependencyGroup* CUnsupportedFormatLoader::LoadMAPU(IInputStream& rMAPU, CResourceEntry *pEntry)
{
u32 Magic = rMAPU.ReadLong();
uint32 Magic = rMAPU.ReadLong();
ASSERT(Magic == 0xABCDEF01);
u32 Version = rMAPU.ReadLong();
uint32 Version = rMAPU.ReadLong();
ASSERT(Version == 0x1);
CDependencyGroup *pGroup = new CDependencyGroup(pEntry);
pGroup->AddDependency(rMAPU.ReadLong());
// Read worlds
u32 NumWorlds = rMAPU.ReadLong();
uint32 NumWorlds = rMAPU.ReadLong();
for (u32 iWorld = 0; iWorld < NumWorlds; iWorld++)
for (uint32 iWorld = 0; iWorld < NumWorlds; iWorld++)
{
rMAPU.ReadString(); // Skip world name
pGroup->AddDependency(rMAPU.ReadLong()); // World MLVL
rMAPU.Seek(0x30, SEEK_CUR); // Skip world map transform
u32 NumHexagons = rMAPU.ReadLong();
uint32 NumHexagons = rMAPU.ReadLong();
rMAPU.Seek(NumHexagons * 0x30, SEEK_CUR); // Skip hexagon transforms
rMAPU.Seek(0x10, SEEK_CUR); // Skip world color
}
@@ -532,16 +532,16 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadMAPU(IInputStream& rMAPU, CResou
CDependencyGroup* CUnsupportedFormatLoader::LoadRULE(IInputStream& rRULE, CResourceEntry *pEntry)
{
// RULE files can contain a reference to another RULE file, but has no other dependencies.
u32 Magic = rRULE.ReadLong();
uint32 Magic = rRULE.ReadLong();
ASSERT(Magic == FOURCC('RULE'));
CDependencyGroup *pGroup = new CDependencyGroup(pEntry);
rRULE.Seek(0x1, SEEK_CUR);
// Version test
u32 IDOffset = rRULE.Tell();
uint32 IDOffset = rRULE.Tell();
rRULE.Seek(0x4, SEEK_CUR);
u32 RuleSetCount = rRULE.ReadShort();
uint32 RuleSetCount = rRULE.ReadShort();
EIDLength IDLength = (RuleSetCount > 0xFF ? e64Bit : e32Bit);
rRULE.Seek(IDOffset, SEEK_SET);

View File

@@ -4,7 +4,7 @@
// ************ PARAMETER LOADING ************
bool CUnsupportedParticleLoader::ParseParticleParameter(IInputStream& rPART)
{
u32 ParamOffset = rPART.Tell();
uint32 ParamOffset = rPART.Tell();
CFourCC Param = rPART.ReadLong();
if (Param == FOURCC('_END'))
return false;
@@ -212,8 +212,7 @@ bool CUnsupportedParticleLoader::ParseParticleParameter(IInputStream& rPART)
break;
default:
Log::FileError(rPART.GetSourceString(), ParamOffset, "Unknown PART parameter: " + Param.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown PART parameter: %s", *rPART.GetSourceString(), ParamOffset, *Param.ToString());
return false;
}
@@ -222,7 +221,7 @@ bool CUnsupportedParticleLoader::ParseParticleParameter(IInputStream& rPART)
bool CUnsupportedParticleLoader::ParseElectricParameter(IInputStream& rELSC)
{
u32 ParamOffset = rELSC.Tell();
uint32 ParamOffset = rELSC.Tell();
CFourCC Param = rELSC.ReadLong();
if (Param == FOURCC('_END')) return false;
@@ -276,8 +275,7 @@ bool CUnsupportedParticleLoader::ParseElectricParameter(IInputStream& rELSC)
break;
default:
Log::FileError(rELSC.GetSourceString(), ParamOffset, "Unknown ELSC parameter: " + Param.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown ELSC parameter: %s", *rELSC.GetSourceString(), ParamOffset, *Param.ToString());
return false;
}
@@ -286,7 +284,7 @@ bool CUnsupportedParticleLoader::ParseElectricParameter(IInputStream& rELSC)
bool CUnsupportedParticleLoader::ParseSortedParameter(IInputStream& rSRSC)
{
u32 ParamOffset = rSRSC.Tell();
uint32 ParamOffset = rSRSC.Tell();
CFourCC Param = rSRSC.ReadLong();
if (Param == FOURCC('_END')) return false;
@@ -295,8 +293,7 @@ bool CUnsupportedParticleLoader::ParseSortedParameter(IInputStream& rSRSC)
else
{
Log::FileError(rSRSC.GetSourceString(), ParamOffset, "Unknown SRSC parameter: " + Param.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown SRSC parameter: %s", *rSRSC.GetSourceString(), ParamOffset, *Param.ToString());
return false;
}
@@ -305,7 +302,7 @@ bool CUnsupportedParticleLoader::ParseSortedParameter(IInputStream& rSRSC)
bool CUnsupportedParticleLoader::ParseSpawnParameter(IInputStream& rSPSC)
{
u32 ParamOffset = rSPSC.Tell();
uint32 ParamOffset = rSPSC.Tell();
CFourCC Param = rSPSC.ReadLong();
if (Param == FOURCC('_END')) return false;
@@ -354,8 +351,7 @@ bool CUnsupportedParticleLoader::ParseSpawnParameter(IInputStream& rSPSC)
break;
default:
Log::FileError(rSPSC.GetSourceString(), ParamOffset, "Unknown SPSC parameter: " + Param.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown SPSC parameter: %s", *rSPSC.GetSourceString(), ParamOffset, *Param.ToString());
return false;
}
@@ -364,7 +360,7 @@ bool CUnsupportedParticleLoader::ParseSpawnParameter(IInputStream& rSPSC)
bool CUnsupportedParticleLoader::ParseSwooshParameter(IInputStream& rSWHC)
{
u32 ParamOffset = rSWHC.Tell();
uint32 ParamOffset = rSWHC.Tell();
CFourCC Param = rSWHC.ReadLong();
if (Param == FOURCC('_END')) return false;
@@ -432,8 +428,7 @@ bool CUnsupportedParticleLoader::ParseSwooshParameter(IInputStream& rSWHC)
break;
default:
Log::FileError(rSWHC.GetSourceString(), ParamOffset, "Unknown SWHC parameter: " + Param.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown SWHC parameter: %s", *rSWHC.GetSourceString(), ParamOffset, *Param.ToString());
return false;
}
@@ -442,7 +437,7 @@ bool CUnsupportedParticleLoader::ParseSwooshParameter(IInputStream& rSWHC)
bool CUnsupportedParticleLoader::ParseDecalParameter(IInputStream& rDPSC)
{
u32 ParamOffset = rDPSC.Tell();
uint32 ParamOffset = rDPSC.Tell();
CFourCC Param = rDPSC.ReadLong();
if (Param == FOURCC('_END')) return false;
@@ -492,8 +487,7 @@ bool CUnsupportedParticleLoader::ParseDecalParameter(IInputStream& rDPSC)
break;
default:
Log::FileError(rDPSC.GetSourceString(), ParamOffset, "Unknown DPSC parameter: " + Param.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown DPSC parameter: %s", *rDPSC.GetSourceString(), ParamOffset, *Param.ToString());
return false;
}
@@ -502,7 +496,7 @@ bool CUnsupportedParticleLoader::ParseDecalParameter(IInputStream& rDPSC)
bool CUnsupportedParticleLoader::ParseWeaponParameter(IInputStream& rWPSC)
{
u32 ParamOffset = rWPSC.Tell();
uint32 ParamOffset = rWPSC.Tell();
CFourCC Param = rWPSC.ReadLong();
if (Param == FOURCC('_END')) return false;
@@ -604,8 +598,7 @@ bool CUnsupportedParticleLoader::ParseWeaponParameter(IInputStream& rWPSC)
break;
default:
Log::FileError(rWPSC.GetSourceString(), ParamOffset, "Unknown WPSC parameter: " + Param.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown WPSC parameter: %s", *rWPSC.GetSourceString(), ParamOffset, *Param.ToString());
return false;
}
@@ -614,12 +607,12 @@ bool CUnsupportedParticleLoader::ParseWeaponParameter(IInputStream& rWPSC)
bool CUnsupportedParticleLoader::ParseCollisionResponseParameter(IInputStream& rCRSC)
{
u32 ParamOffset = rCRSC.Tell();
uint32 ParamOffset = rCRSC.Tell();
CFourCC Param = rCRSC.ReadLong();
if (Param == FOURCC('_END')) return false;
// CRSC has way too many useless extra parameters that are never used to bother typing out, so just skip past them
u32 FuncPeek = rCRSC.PeekLong();
uint32 FuncPeek = rCRSC.PeekLong();
if (FuncPeek == FOURCC('NONE'))
{
@@ -732,8 +725,7 @@ bool CUnsupportedParticleLoader::ParseCollisionResponseParameter(IInputStream& r
break;
default:
Log::FileError(rCRSC.GetSourceString(), ParamOffset, "Unknown CRSC parameter: " + Param.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown CRSC parameter: %s", *rCRSC.GetSourceString(), ParamOffset, *Param.ToString());
return false;
}
@@ -742,7 +734,7 @@ bool CUnsupportedParticleLoader::ParseCollisionResponseParameter(IInputStream& r
bool CUnsupportedParticleLoader::ParseBurstFireParameter(IInputStream& rBFRC)
{
u32 ParamOffset = rBFRC.Tell();
uint32 ParamOffset = rBFRC.Tell();
CFourCC Param = rBFRC.ReadLong();
if (Param == FOURCC('_END')) return false;
@@ -775,8 +767,7 @@ bool CUnsupportedParticleLoader::ParseBurstFireParameter(IInputStream& rBFRC)
break;
default:
Log::FileError(rBFRC.GetSourceString(), ParamOffset, "Unknown BFRC parameter: " + Param.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown BFRC parameter: %s", *rBFRC.GetSourceString(), ParamOffset, *Param.ToString());
return false;
}
@@ -785,7 +776,7 @@ bool CUnsupportedParticleLoader::ParseBurstFireParameter(IInputStream& rBFRC)
bool CUnsupportedParticleLoader::ParseUserEvaluatorParameter(IInputStream& rUSRC)
{
u32 ParamOffset = rUSRC.Tell();
uint32 ParamOffset = rUSRC.Tell();
CFourCC Param = rUSRC.ReadLong();
if (Param == FOURCC('_END')) return false;
@@ -837,8 +828,7 @@ bool CUnsupportedParticleLoader::ParseUserEvaluatorParameter(IInputStream& rUSRC
break;
default:
Log::FileError(rUSRC.GetSourceString(), ParamOffset, "Unknown USRC parameter: " + Param.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown USRC parameter: %s", *rUSRC.GetSourceString(), ParamOffset, *Param.ToString());
return false;
}
@@ -847,7 +837,7 @@ bool CUnsupportedParticleLoader::ParseUserEvaluatorParameter(IInputStream& rUSRC
bool CUnsupportedParticleLoader::ParseTransformParameter(IInputStream& rXFSC)
{
u32 ParamOffset = rXFSC.Tell();
uint32 ParamOffset = rXFSC.Tell();
CFourCC Param = rXFSC.ReadLong();
if (Param == FOURCC('_END')) return false;
@@ -889,8 +879,7 @@ bool CUnsupportedParticleLoader::ParseTransformParameter(IInputStream& rXFSC)
break;
default:
Log::FileError(rXFSC.GetSourceString(), ParamOffset, "Unknown XFSC parameter: " + Param.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown XFSC parameter: %s", *rXFSC.GetSourceString(), ParamOffset, *Param.ToString());
return false;
}
@@ -900,7 +889,7 @@ bool CUnsupportedParticleLoader::ParseTransformParameter(IInputStream& rXFSC)
// ************ FUNCTION LOADING ************
void CUnsupportedParticleLoader::ParseBool(IInputStream& rFile)
{
u32 FuncOffset = rFile.Tell();
uint32 FuncOffset = rFile.Tell();
CFourCC Func = rFile.ReadLong();
switch (Func.ToLong())
@@ -913,15 +902,14 @@ void CUnsupportedParticleLoader::ParseBool(IInputStream& rFile)
break;
default:
Log::FileError(rFile.GetSourceString(), FuncOffset, "Unknown bool constant function: " + Func.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown bool constant function: %s", *rFile.GetSourceString(), FuncOffset, *Func.ToString());
break;
}
}
void CUnsupportedParticleLoader::ParseBoolFunction(IInputStream& rFile)
{
u32 FuncOffset = rFile.Tell();
uint32 FuncOffset = rFile.Tell();
CFourCC Func = rFile.ReadLong();
switch (Func.ToLong())
@@ -945,8 +933,7 @@ void CUnsupportedParticleLoader::ParseBoolFunction(IInputStream& rFile)
break;
default:
Log::FileError(rFile.GetSourceString(), FuncOffset, "Unknown bool function: " + Func.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown bool function: %s", *rFile.GetSourceString(), FuncOffset, *Func.ToString());
break;
}
}
@@ -954,12 +941,12 @@ void CUnsupportedParticleLoader::ParseBoolFunction(IInputStream& rFile)
void CUnsupportedParticleLoader::ParseBitfieldFunction(IInputStream& rFile)
{
// todo: probably not the correct way to do this...
rFile.Seek(0x10, SEEK_CUR);
rFile.Skip(0x10);
}
void CUnsupportedParticleLoader::ParseIntFunction(IInputStream& rFile)
{
u32 FuncOffset = rFile.Tell();
uint32 FuncOffset = rFile.Tell();
CFourCC Func = rFile.ReadLong();
switch (Func.ToLong())
@@ -1012,7 +999,7 @@ void CUnsupportedParticleLoader::ParseIntFunction(IInputStream& rFile)
case FOURCC('CNST'):
{
u32 Value = rFile.ReadLong();
uint32 Value = rFile.ReadLong();
ASSERT(gpResourceStore->FindEntry(CAssetID(Value)) == nullptr);
break;
}
@@ -1039,15 +1026,14 @@ void CUnsupportedParticleLoader::ParseIntFunction(IInputStream& rFile)
break;
default:
Log::FileError(rFile.GetSourceString(), FuncOffset, "Unknown int function: " + Func.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown int function: %s", *rFile.GetSourceString(), FuncOffset, *Func.ToString());
break;
}
}
void CUnsupportedParticleLoader::ParseFloatFunction(IInputStream& rFile)
{
u32 FuncOffset = rFile.Tell();
uint32 FuncOffset = rFile.Tell();
CFourCC Func = rFile.ReadLong();
switch (Func.ToLong())
@@ -1230,15 +1216,14 @@ void CUnsupportedParticleLoader::ParseFloatFunction(IInputStream& rFile)
break;
default:
Log::FileError(rFile.GetSourceString(), FuncOffset, "Unknown float function: " + Func.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown float function: %s", *rFile.GetSourceString(), FuncOffset, *Func.ToString());
break;
}
}
void CUnsupportedParticleLoader::ParseVectorFunction(IInputStream& rFile)
{
u32 FuncOffset = rFile.Tell();
uint32 FuncOffset = rFile.Tell();
CFourCC Func = rFile.ReadLong();
switch (Func.ToLong())
@@ -1364,15 +1349,14 @@ void CUnsupportedParticleLoader::ParseVectorFunction(IInputStream& rFile)
break;
default:
Log::FileError(rFile.GetSourceString(), FuncOffset, "Unknown vector function: " + Func.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown vector function: %s", *rFile.GetSourceString(), FuncOffset, *Func.ToString());
break;
}
}
void CUnsupportedParticleLoader::ParseModVectorFunction(IInputStream& rFile)
{
u32 FuncOffset = rFile.Tell();
uint32 FuncOffset = rFile.Tell();
CFourCC Func = rFile.ReadLong();
switch (Func.ToLong())
@@ -1453,15 +1437,14 @@ void CUnsupportedParticleLoader::ParseModVectorFunction(IInputStream& rFile)
break;
default:
Log::FileError(rFile.GetSourceString(), FuncOffset, "Unknown mod vector function: " + Func.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown mod vector function: %s", *rFile.GetSourceString(), FuncOffset, *Func.ToString());
break;
}
}
void CUnsupportedParticleLoader::ParseColorFunction(IInputStream& rFile)
{
u32 FuncOffset = rFile.Tell();
uint32 FuncOffset = rFile.Tell();
CFourCC Func = rFile.ReadLong();
switch (Func.ToLong())
@@ -1535,15 +1518,14 @@ void CUnsupportedParticleLoader::ParseColorFunction(IInputStream& rFile)
break;
default:
Log::FileError(rFile.GetSourceString(), FuncOffset, "Unknown color function: " + Func.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown color function: %s", *rFile.GetSourceString(), FuncOffset, *Func.ToString());
break;
}
}
void CUnsupportedParticleLoader::ParseRotationFunction(IInputStream& rFile)
{
u32 FuncOffset = rFile.Tell();
uint32 FuncOffset = rFile.Tell();
CFourCC Func = rFile.ReadLong();
switch (Func.ToLong())
@@ -1593,15 +1575,14 @@ void CUnsupportedParticleLoader::ParseRotationFunction(IInputStream& rFile)
break;
default:
Log::FileError(rFile.GetSourceString(), FuncOffset, "Unknown rotation function: " + Func.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown rotation function: %s", *rFile.GetSourceString(), FuncOffset, *Func.ToString());
break;
}
}
void CUnsupportedParticleLoader::ParseUVFunction(IInputStream& rFile)
{
u32 FuncOffset = rFile.Tell();
uint32 FuncOffset = rFile.Tell();
CFourCC Func = rFile.ReadLong();
switch (Func.ToLong())
@@ -1631,15 +1612,14 @@ void CUnsupportedParticleLoader::ParseUVFunction(IInputStream& rFile)
break;
default:
Log::FileError(rFile.GetSourceString(), FuncOffset, "Unknown UV function: " + Func.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown UV function: %s", *rFile.GetSourceString(), FuncOffset, *Func.ToString());
break;
}
}
void CUnsupportedParticleLoader::ParseEmitterFunction(IInputStream& rFile)
{
u32 FuncOffset = rFile.Tell();
uint32 FuncOffset = rFile.Tell();
CFourCC Func = rFile.ReadLong();
switch (Func.ToLong())
@@ -1691,15 +1671,14 @@ void CUnsupportedParticleLoader::ParseEmitterFunction(IInputStream& rFile)
break;
default:
Log::FileError(rFile.GetSourceString(), FuncOffset, "Unknown emitter function: " + Func.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown emitter function: %s", *rFile.GetSourceString(), FuncOffset, *Func.ToString());
break;
}
}
void CUnsupportedParticleLoader::ParseSoundFunction(IInputStream& rFile)
{
u32 FuncOffset = rFile.Tell();
uint32 FuncOffset = rFile.Tell();
CFourCC Func = rFile.ReadLong();
switch (Func.ToLong())
@@ -1709,7 +1688,7 @@ void CUnsupportedParticleLoader::ParseSoundFunction(IInputStream& rFile)
case FOURCC('CNST'):
{
u32 SoundID = rFile.ReadLong() & 0xFFFF;
uint32 SoundID = rFile.ReadLong() & 0xFFFF;
if (SoundID != 0xFFFF)
{
@@ -1721,14 +1700,14 @@ void CUnsupportedParticleLoader::ParseSoundFunction(IInputStream& rFile)
}
default:
Log::FileError(rFile.GetSourceString(), FuncOffset, "Unknown sound function: " + Func.ToString());
errorf("%s [0x%X]: Unknown sound function: %s", *rFile.GetSourceString(), FuncOffset, *Func.ToString());
break;
}
}
void CUnsupportedParticleLoader::ParseAssetFunction(IInputStream& rFile)
{
u32 FuncOffset = rFile.Tell();
uint32 FuncOffset = rFile.Tell();
CFourCC Func = rFile.ReadLong();
switch (Func.ToLong())
@@ -1741,8 +1720,7 @@ void CUnsupportedParticleLoader::ParseAssetFunction(IInputStream& rFile)
break;
default:
Log::FileError(rFile.GetSourceString(), FuncOffset, "Unknown asset function: " + Func.ToString());
DEBUG_BREAK;
errorf("%s [0x%X]: Unknown asset function: %s", *rFile.GetSourceString(), FuncOffset, *Func.ToString());
break;
}
}
@@ -1754,14 +1732,14 @@ void CUnsupportedParticleLoader::ParseSpawnSystemKeyframeData(IInputStream& rFil
ASSERT(Func == "CNST");
rFile.Seek(0x10, SEEK_CUR); // Skip unneeded values
u32 Count = rFile.ReadLong();
uint32 Count = rFile.ReadLong();
for (u32 iKey = 0; iKey < Count; iKey++)
for (uint32 iKey = 0; iKey < Count; iKey++)
{
rFile.Seek(0x4, SEEK_CUR); // Skip frame number
u32 InfoCount = rFile.ReadLong();
uint32 InfoCount = rFile.ReadLong();
for (u32 iInfo = 0; iInfo < InfoCount; iInfo++)
for (uint32 iInfo = 0; iInfo < InfoCount; iInfo++)
{
mpGroup->AddDependency( CAssetID(rFile, mpGroup->Game()) );
rFile.Seek(0xC, SEEK_CUR); // Skip unknown/unneeded values
@@ -1769,7 +1747,7 @@ void CUnsupportedParticleLoader::ParseSpawnSystemKeyframeData(IInputStream& rFil
}
}
void CUnsupportedParticleLoader::ParseKeyframeEmitterData(IInputStream& rFile, const CFourCC& rkFunc, u32 ElemSize)
void CUnsupportedParticleLoader::ParseKeyframeEmitterData(IInputStream& rFile, const CFourCC& rkFunc, uint32 ElemSize)
{
// Skip unneeded values
if (rkFunc == "KEYE" || rkFunc == "KEYP")
@@ -1777,7 +1755,7 @@ void CUnsupportedParticleLoader::ParseKeyframeEmitterData(IInputStream& rFile, c
else if (rkFunc == "KEYF")
rFile.Seek(0x1A, SEEK_CUR);
u32 KeyCount = rFile.ReadLong();
uint32 KeyCount = rFile.ReadLong();
rFile.Seek(KeyCount * ElemSize, SEEK_CUR);
if (rkFunc == "KEYF")
@@ -1793,11 +1771,11 @@ CDependencyGroup* CUnsupportedParticleLoader::LoadParticle(IInputStream& rFile,
// Validate DKCR asset header
if (pEntry->Game() == EGame::DKCReturns)
{
u32 AssetHeader = rFile.ReadLong();
uint32 AssetHeader = rFile.ReadLong();
if (AssetHeader != 0x6E190001)
{
Log::Error("Invalid DKCR particle header: " + TString::HexString(AssetHeader));
errorf("Invalid DKCR particle header: %08X", AssetHeader);
return Loader.mpGroup;
}
}
@@ -1824,7 +1802,7 @@ CDependencyGroup* CUnsupportedParticleLoader::LoadParticle(IInputStream& rFile,
case FOURCC('XFSM'): ShouldContinue = Loader.ParseTransformParameter(rFile); break;
default:
Log::Error("Unrecognized particle system magic: " + Magic.ToString());
errorf("Unrecognized particle system magic: %s", *Magic.ToString());
ShouldContinue = false;
break;
}

View File

@@ -38,7 +38,7 @@ class CUnsupportedParticleLoader
void ParseSoundFunction(IInputStream& rFile);
void ParseAssetFunction(IInputStream& rFile);
void ParseSpawnSystemKeyframeData(IInputStream& rFile);
void ParseKeyframeEmitterData(IInputStream& rFile, const CFourCC& rkFunc, u32 ElemSize);
void ParseKeyframeEmitterData(IInputStream& rFile, const CFourCC& rkFunc, uint32 ElemSize);
public:
static CDependencyGroup* LoadParticle(IInputStream& rPART, CResourceEntry *pEntry);

View File

@@ -34,10 +34,10 @@ void CWorldLoader::LoadPrimeMLVL(IInputStream& rMLVL)
// Memory relays - only in MP1
if (mVersion == EGame::Prime)
{
u32 NumMemoryRelays = rMLVL.ReadLong();
uint32 NumMemoryRelays = rMLVL.ReadLong();
mpWorld->mMemoryRelays.reserve(NumMemoryRelays);
for (u32 iMem = 0; iMem < NumMemoryRelays; iMem++)
for (uint32 iMem = 0; iMem < NumMemoryRelays; iMem++)
{
CWorld::SMemoryRelay MemRelay;
MemRelay.InstanceID = rMLVL.ReadLong();
@@ -49,11 +49,11 @@ void CWorldLoader::LoadPrimeMLVL(IInputStream& rMLVL)
}
// Areas - here's the real meat of the file
u32 NumAreas = rMLVL.ReadLong();
uint32 NumAreas = rMLVL.ReadLong();
if (mVersion == EGame::Prime) rMLVL.Seek(0x4, SEEK_CUR);
mpWorld->mAreas.resize(NumAreas);
for (u32 iArea = 0; iArea < NumAreas; iArea++)
for (uint32 iArea = 0; iArea < NumAreas; iArea++)
{
// Area header
CWorld::SArea *pArea = &mpWorld->mAreas[iArea];
@@ -64,34 +64,34 @@ void CWorldLoader::LoadPrimeMLVL(IInputStream& rMLVL)
pArea->AreaID = CAssetID(rMLVL, mVersion);
// Attached areas
u32 NumAttachedAreas = rMLVL.ReadLong();
uint32 NumAttachedAreas = rMLVL.ReadLong();
pArea->AttachedAreaIDs.reserve(NumAttachedAreas);
for (u32 iAttached = 0; iAttached < NumAttachedAreas; iAttached++)
for (uint32 iAttached = 0; iAttached < NumAttachedAreas; iAttached++)
pArea->AttachedAreaIDs.push_back( rMLVL.ReadShort() );
// Skip dependency list - this is very fast to regenerate so there's no use in caching it
if (mVersion < EGame::CorruptionProto)
{
rMLVL.Seek(0x4, SEEK_CUR);
u32 NumDependencies = rMLVL.ReadLong();
uint32 NumDependencies = rMLVL.ReadLong();
rMLVL.Seek(NumDependencies * 8, SEEK_CUR);
u32 NumDependencyOffsets = rMLVL.ReadLong();
uint32 NumDependencyOffsets = rMLVL.ReadLong();
rMLVL.Seek(NumDependencyOffsets * 4, SEEK_CUR);
}
// Docks
u32 NumDocks = rMLVL.ReadLong();
uint32 NumDocks = rMLVL.ReadLong();
pArea->Docks.resize(NumDocks);
for (u32 iDock = 0; iDock < NumDocks; iDock++)
for (uint32 iDock = 0; iDock < NumDocks; iDock++)
{
u32 NumConnectingDocks = rMLVL.ReadLong();
uint32 NumConnectingDocks = rMLVL.ReadLong();
CWorld::SArea::SDock* pDock = &pArea->Docks[iDock];
pDock->ConnectingDocks.reserve(NumConnectingDocks);
for (u32 iConnect = 0; iConnect < NumConnectingDocks; iConnect++)
for (uint32 iConnect = 0; iConnect < NumConnectingDocks; iConnect++)
{
CWorld::SArea::SDock::SConnectingDock ConnectingDock;
ConnectingDock.AreaIndex = rMLVL.ReadLong();
@@ -99,29 +99,29 @@ void CWorldLoader::LoadPrimeMLVL(IInputStream& rMLVL)
pDock->ConnectingDocks.push_back(ConnectingDock);
}
u32 NumCoordinates = rMLVL.ReadLong();
uint32 NumCoordinates = rMLVL.ReadLong();
ASSERT(NumCoordinates == 4);
pDock->DockCoordinates.resize(NumCoordinates);
for (u32 iCoord = 0; iCoord < NumCoordinates; iCoord++)
for (uint32 iCoord = 0; iCoord < NumCoordinates; iCoord++)
pDock->DockCoordinates[iCoord] = CVector3f(rMLVL);
}
// Rels
if ( (mVersion == EGame::EchoesDemo) || (mVersion == EGame::Echoes) )
{
u32 NumRels = rMLVL.ReadLong();
uint32 NumRels = rMLVL.ReadLong();
pArea->RelFilenames.resize(NumRels);
for (u32 iRel = 0; iRel < NumRels; iRel++)
for (uint32 iRel = 0; iRel < NumRels; iRel++)
pArea->RelFilenames[iRel] = rMLVL.ReadString();
if (mVersion == EGame::Echoes)
{
u32 NumRelOffsets = rMLVL.ReadLong(); // Don't know what these offsets correspond to
uint32 NumRelOffsets = rMLVL.ReadLong(); // Don't know what these offsets correspond to
pArea->RelOffsets.resize(NumRelOffsets);
for (u32 iOff = 0; iOff < NumRelOffsets; iOff++)
for (uint32 iOff = 0; iOff < NumRelOffsets; iOff++)
pArea->RelOffsets[iOff] = rMLVL.ReadLong();
}
}
@@ -138,32 +138,32 @@ void CWorldLoader::LoadPrimeMLVL(IInputStream& rMLVL)
// Audio Groups - we don't need this info as we regenerate it on cook
if (mVersion == EGame::Prime)
{
u32 NumAudioGrps = rMLVL.ReadLong();
uint32 NumAudioGrps = rMLVL.ReadLong();
rMLVL.Seek(0x8 * NumAudioGrps, SEEK_CUR);
rMLVL.Seek(0x1, SEEK_CUR); // Unknown values which are always 0
}
// Layer flags
rMLVL.Seek(0x4, SEEK_CUR); // Skipping redundant area count
for (u32 iArea = 0; iArea < NumAreas; iArea++)
for (uint32 iArea = 0; iArea < NumAreas; iArea++)
{
CWorld::SArea* pArea = &mpWorld->mAreas[iArea];
u32 NumLayers = rMLVL.ReadLong();
uint32 NumLayers = rMLVL.ReadLong();
if (NumLayers != pArea->Layers.size()) pArea->Layers.resize(NumLayers);
u64 LayerFlags = rMLVL.ReadLongLong();
for (u32 iLayer = 0; iLayer < NumLayers; iLayer++)
uint64 LayerFlags = rMLVL.ReadLongLong();
for (uint32 iLayer = 0; iLayer < NumLayers; iLayer++)
pArea->Layers[iLayer].Active = (((LayerFlags >> iLayer) & 0x1) == 1);
}
// Layer names
rMLVL.Seek(0x4, SEEK_CUR); // Skipping redundant layer count
for (u32 iArea = 0; iArea < NumAreas; iArea++)
for (uint32 iArea = 0; iArea < NumAreas; iArea++)
{
CWorld::SArea* pArea = &mpWorld->mAreas[iArea];
u32 NumLayers = pArea->Layers.size();
uint32 NumLayers = pArea->Layers.size();
for (u32 iLayer = 0; iLayer < NumLayers; iLayer++)
for (uint32 iLayer = 0; iLayer < NumLayers; iLayer++)
pArea->Layers[iLayer].LayerName = rMLVL.ReadString();
}
@@ -171,12 +171,12 @@ void CWorldLoader::LoadPrimeMLVL(IInputStream& rMLVL)
if (mVersion >= EGame::Corruption)
{
rMLVL.Seek(0x4, SEEK_CUR); // Skipping redundant layer count
for (u32 iArea = 0; iArea < NumAreas; iArea++)
for (uint32 iArea = 0; iArea < NumAreas; iArea++)
{
CWorld::SArea *pArea = &mpWorld->mAreas[iArea];
u32 NumLayers = pArea->Layers.size();
uint32 NumLayers = pArea->Layers.size();
for (u32 iLayer = 0; iLayer < NumLayers; iLayer++)
for (uint32 iLayer = 0; iLayer < NumLayers; iLayer++)
pArea->Layers[iLayer].LayerStateID = CSavedStateID(rMLVL);
}
}
@@ -204,10 +204,10 @@ void CWorldLoader::LoadReturnsMLVL(IInputStream& rMLVL)
mpWorld->mpDefaultSkybox = gpResourceStore->LoadResource<CModel>(rMLVL.ReadLongLong());
// Areas
u32 NumAreas = rMLVL.ReadLong();
uint32 NumAreas = rMLVL.ReadLong();
mpWorld->mAreas.resize(NumAreas);
for (u32 iArea = 0; iArea < NumAreas; iArea++)
for (uint32 iArea = 0; iArea < NumAreas; iArea++)
{
// Area header
CWorld::SArea *pArea = &mpWorld->mAreas[iArea];
@@ -225,36 +225,36 @@ void CWorldLoader::LoadReturnsMLVL(IInputStream& rMLVL)
// Layer flags
rMLVL.Seek(0x4, SEEK_CUR); // Skipping redundant area count
for (u32 iArea = 0; iArea < NumAreas; iArea++)
for (uint32 iArea = 0; iArea < NumAreas; iArea++)
{
CWorld::SArea* pArea = &mpWorld->mAreas[iArea];
u32 NumLayers = rMLVL.ReadLong();
uint32 NumLayers = rMLVL.ReadLong();
pArea->Layers.resize(NumLayers);
u64 LayerFlags = rMLVL.ReadLongLong();
for (u32 iLayer = 0; iLayer < NumLayers; iLayer++)
uint64 LayerFlags = rMLVL.ReadLongLong();
for (uint32 iLayer = 0; iLayer < NumLayers; iLayer++)
pArea->Layers[iLayer].Active = (((LayerFlags >> iLayer) & 0x1) == 1);
}
// Layer names
rMLVL.Seek(0x4, SEEK_CUR); // Skipping redundant layer count
for (u32 iArea = 0; iArea < NumAreas; iArea++)
for (uint32 iArea = 0; iArea < NumAreas; iArea++)
{
CWorld::SArea* pArea = &mpWorld->mAreas[iArea];
u32 NumLayers = pArea->Layers.size();
uint32 NumLayers = pArea->Layers.size();
for (u32 iLayer = 0; iLayer < NumLayers; iLayer++)
for (uint32 iLayer = 0; iLayer < NumLayers; iLayer++)
pArea->Layers[iLayer].LayerName = rMLVL.ReadString();
}
// Layer state IDs
rMLVL.Seek(0x4, SEEK_CUR); // Skipping redundant layer count
for (u32 iArea = 0; iArea < NumAreas; iArea++)
for (uint32 iArea = 0; iArea < NumAreas; iArea++)
{
CWorld::SArea *pArea = &mpWorld->mAreas[iArea];
u32 NumLayers = pArea->Layers.size();
uint32 NumLayers = pArea->Layers.size();
for (u32 iLayer = 0; iLayer < NumLayers; iLayer++)
for (uint32 iLayer = 0; iLayer < NumLayers; iLayer++)
pArea->Layers[iLayer].LayerStateID = CSavedStateID(rMLVL);
}
@@ -267,7 +267,7 @@ void CWorldLoader::GenerateEditorData()
if (mVersion <= EGame::Prime)
{
for (u32 iArea = 0; iArea < mpWorld->NumAreas(); iArea++)
for (uint32 iArea = 0; iArea < mpWorld->NumAreas(); iArea++)
{
CWorld::SArea& rArea = mpWorld->mAreas[iArea];
rArea.InternalName = pGameInfo->GetAreaName(rArea.AreaResID);
@@ -280,18 +280,18 @@ CWorld* CWorldLoader::LoadMLVL(IInputStream& rMLVL, CResourceEntry *pEntry)
{
if (!rMLVL.IsValid()) return nullptr;
u32 Magic = rMLVL.ReadLong();
uint32 Magic = rMLVL.ReadLong();
if (Magic != 0xDEAFBABE)
{
Log::FileError(rMLVL.GetSourceString(), "Invalid MLVL magic: " + TString::HexString(Magic));
errorf("%s: Invalid MLVL magic: 0x%08X", *rMLVL.GetSourceString(), Magic);
return nullptr;
}
u32 FileVersion = rMLVL.ReadLong();
uint32 FileVersion = rMLVL.ReadLong();
EGame Version = GetFormatVersion(FileVersion);
if (Version == EGame::Invalid)
{
Log::FileError(rMLVL.GetSourceString(), "Unsupported MLVL version: " + TString::HexString(FileVersion, 2));
errorf("%s: Unsupported MLVL version: 0x%X", *rMLVL.GetSourceString(), FileVersion);
return nullptr;
}
@@ -309,7 +309,7 @@ CWorld* CWorldLoader::LoadMLVL(IInputStream& rMLVL, CResourceEntry *pEntry)
return Loader.mpWorld;
}
EGame CWorldLoader::GetFormatVersion(u32 Version)
EGame CWorldLoader::GetFormatVersion(uint32 Version)
{
switch (Version)
{

View File

@@ -18,7 +18,7 @@ class CWorldLoader
public:
static CWorld* LoadMLVL(IInputStream& rMLVL, CResourceEntry *pEntry);
static EGame GetFormatVersion(u32 Version);
static EGame GetFormatVersion(uint32 Version);
};
#endif // CWORLDLOADER_H

View File

@@ -15,16 +15,16 @@ CBasicModel::CBasicModel(CResourceEntry *pEntry /*= 0*/)
CBasicModel::~CBasicModel()
{
if (mHasOwnSurfaces)
for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
for (uint32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
delete mSurfaces[iSurf];
}
u32 CBasicModel::GetVertexCount()
uint32 CBasicModel::GetVertexCount()
{
return mVertexCount;
}
u32 CBasicModel::GetTriangleCount()
uint32 CBasicModel::GetTriangleCount()
{
return mTriangleCount;
}
@@ -39,17 +39,17 @@ bool CBasicModel::IsBuffered()
return mBuffered;
}
u32 CBasicModel::GetSurfaceCount()
uint32 CBasicModel::GetSurfaceCount()
{
return mSurfaces.size();
}
CAABox CBasicModel::GetSurfaceAABox(u32 Surface)
CAABox CBasicModel::GetSurfaceAABox(uint32 Surface)
{
return mSurfaces[Surface]->AABox;
}
SSurface* CBasicModel::GetSurface(u32 Surface)
SSurface* CBasicModel::GetSurface(uint32 Surface)
{
return mSurfaces[Surface];
}

View File

@@ -4,15 +4,15 @@
#include "SSurface.h"
#include "Core/Resource/CResource.h"
#include "Core/OpenGL/CVertexBuffer.h"
#include <Math/CAABox.h>
#include <Common/Math/CAABox.h>
class CBasicModel : public CResource
{
DECLARE_RESOURCE_TYPE(eModel)
protected:
CAABox mAABox;
u32 mVertexCount;
u32 mTriangleCount;
uint32 mVertexCount;
uint32 mTriangleCount;
bool mBuffered;
bool mHasOwnMaterials;
bool mHasOwnSurfaces;
@@ -24,13 +24,13 @@ public:
CBasicModel(CResourceEntry *pEntry = 0);
~CBasicModel();
u32 GetVertexCount();
u32 GetTriangleCount();
uint32 GetVertexCount();
uint32 GetTriangleCount();
CAABox AABox();
bool IsBuffered();
u32 GetSurfaceCount();
CAABox GetSurfaceAABox(u32 Surface);
SSurface* GetSurface(u32 Surface);
uint32 GetSurfaceCount();
CAABox GetSurfaceAABox(uint32 Surface);
SSurface* GetSurface(uint32 Surface);
virtual void ClearGLBuffer() = 0;
};

View File

@@ -3,7 +3,7 @@
#include "Core/Render/CRenderer.h"
#include "Core/Resource/Area/CGameArea.h"
#include "Core/OpenGL/GLCommon.h"
#include <Common/AssertMacro.h>
#include <Common/Macros.h>
CModel::CModel(CResourceEntry *pEntry /*= 0*/)
: CBasicModel(pEntry)
@@ -25,7 +25,7 @@ CModel::CModel(CMaterialSet *pSet, bool OwnsMatSet)
CModel::~CModel()
{
if (mHasOwnMaterials)
for (u32 iMat = 0; iMat < mMaterialSets.size(); iMat++)
for (uint32 iMat = 0; iMat < mMaterialSets.size(); iMat++)
delete mMaterialSets[iMat];
}
@@ -35,7 +35,7 @@ CDependencyTree* CModel::BuildDependencyTree() const
CDependencyTree *pTree = new CDependencyTree();
std::set<CAssetID> TextureIDs;
for (u32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
for (uint32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
{
CMaterialSet *pSet = mMaterialSets[iSet];
pSet->GetUsedTextureIDs(TextureIDs);
@@ -56,21 +56,21 @@ void CModel::BufferGL()
mSurfaceIndexBuffers.resize(mSurfaces.size());
for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
for (uint32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
{
SSurface *pSurf = mSurfaces[iSurf];
u16 VBOStartOffset = (u16) mVBO.Size();
mVBO.Reserve((u16) pSurf->VertexCount);
uint16 VBOStartOffset = (uint16) mVBO.Size();
mVBO.Reserve((uint16) pSurf->VertexCount);
for (u32 iPrim = 0; iPrim < pSurf->Primitives.size(); iPrim++)
for (uint32 iPrim = 0; iPrim < pSurf->Primitives.size(); iPrim++)
{
SSurface::SPrimitive *pPrim = &pSurf->Primitives[iPrim];
CIndexBuffer *pIBO = InternalGetIBO(iSurf, pPrim->Type);
pIBO->Reserve(pPrim->Vertices.size() + 1); // Allocate enough space for this primitive, plus the restart index
std::vector<u16> Indices(pPrim->Vertices.size());
for (u32 iVert = 0; iVert < pPrim->Vertices.size(); iVert++)
std::vector<uint16> Indices(pPrim->Vertices.size());
for (uint32 iVert = 0; iVert < pPrim->Vertices.size(); iVert++)
Indices[iVert] = mVBO.AddIfUnique(pPrim->Vertices[iVert], VBOStartOffset);
// then add the indices to the IBO. We convert some primitives to strips to minimize draw calls.
@@ -92,7 +92,7 @@ void CModel::BufferGL()
}
}
for (u32 iIBO = 0; iIBO < mSurfaceIndexBuffers[iSurf].size(); iIBO++)
for (uint32 iIBO = 0; iIBO < mSurfaceIndexBuffers[iSurf].size(); iIBO++)
mSurfaceIndexBuffers[iSurf][iIBO].Buffer();
}
@@ -102,11 +102,11 @@ void CModel::BufferGL()
void CModel::GenerateMaterialShaders()
{
for (u32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
for (uint32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
{
CMaterialSet *pSet = mMaterialSets[iSet];
for (u32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
for (uint32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
{
CMaterial *pMat = pSet->MaterialByIndex(iMat);
pMat->GenerateShader(false);
@@ -121,14 +121,14 @@ void CModel::ClearGLBuffer()
mBuffered = false;
}
void CModel::Draw(FRenderOptions Options, u32 MatSet)
void CModel::Draw(FRenderOptions Options, uint32 MatSet)
{
if (!mBuffered) BufferGL();
for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
for (uint32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
DrawSurface(Options, iSurf, MatSet);
}
void CModel::DrawSurface(FRenderOptions Options, u32 Surface, u32 MatSet)
void CModel::DrawSurface(FRenderOptions Options, uint32 Surface, uint32 MatSet)
{
if (!mBuffered) BufferGL();
@@ -152,7 +152,7 @@ void CModel::DrawSurface(FRenderOptions Options, u32 Surface, u32 MatSet)
mVBO.Bind();
glLineWidth(1.f);
for (u32 iIBO = 0; iIBO < mSurfaceIndexBuffers[Surface].size(); iIBO++)
for (uint32 iIBO = 0; iIBO < mSurfaceIndexBuffers[Surface].size(); iIBO++)
{
CIndexBuffer *pIBO = &mSurfaceIndexBuffers[Surface][iIBO];
pIBO->DrawElements();
@@ -173,7 +173,7 @@ void CModel::DrawWireframe(FRenderOptions Options, CColor WireColor /*= CColor::
glBlendFunc(GL_ONE, GL_ZERO);
// Draw surfaces
for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
for (uint32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
DrawSurface(Options, iSurf, 0);
// Cleanup
@@ -198,11 +198,11 @@ void CModel::SetSkin(CSkin *pSkin)
else if (!pSkin && mVBO.VertexDesc().HasAnyFlags(kBoneFlags))
mVBO.SetVertexDesc(mVBO.VertexDesc() & ~kBoneFlags);
for (u32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
for (uint32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
{
CMaterialSet *pSet = mMaterialSets[iSet];
for (u32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
for (uint32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
{
CMaterial *pMat = pSet->MaterialByIndex(iMat);
FVertexDescription VtxDesc = pMat->VtxDesc();
@@ -223,23 +223,23 @@ void CModel::SetSkin(CSkin *pSkin)
}
}
u32 CModel::GetMatSetCount()
uint32 CModel::GetMatSetCount()
{
return mMaterialSets.size();
}
u32 CModel::GetMatCount()
uint32 CModel::GetMatCount()
{
if (mMaterialSets.empty()) return 0;
else return mMaterialSets[0]->NumMaterials();
}
CMaterialSet* CModel::GetMatSet(u32 MatSet)
CMaterialSet* CModel::GetMatSet(uint32 MatSet)
{
return mMaterialSets[MatSet];
}
CMaterial* CModel::GetMaterialByIndex(u32 MatSet, u32 Index)
CMaterial* CModel::GetMaterialByIndex(uint32 MatSet, uint32 Index)
{
if (MatSet >= mMaterialSets.size())
MatSet = mMaterialSets.size() - 1;
@@ -250,38 +250,38 @@ CMaterial* CModel::GetMaterialByIndex(u32 MatSet, u32 Index)
return mMaterialSets[MatSet]->MaterialByIndex(Index);
}
CMaterial* CModel::GetMaterialBySurface(u32 MatSet, u32 Surface)
CMaterial* CModel::GetMaterialBySurface(uint32 MatSet, uint32 Surface)
{
return GetMaterialByIndex(MatSet, mSurfaces[Surface]->MaterialID);
}
bool CModel::HasTransparency(u32 MatSet)
bool CModel::HasTransparency(uint32 MatSet)
{
if (MatSet >= mMaterialSets.size())
MatSet = mMaterialSets.size() - 1;
for (u32 iMat = 0; iMat < mMaterialSets[MatSet]->NumMaterials(); iMat++)
for (uint32 iMat = 0; iMat < mMaterialSets[MatSet]->NumMaterials(); iMat++)
if (mMaterialSets[MatSet]->MaterialByIndex(iMat)->Options() & CMaterial::eTransparent ) return true;
return false;
}
bool CModel::IsSurfaceTransparent(u32 Surface, u32 MatSet)
bool CModel::IsSurfaceTransparent(uint32 Surface, uint32 MatSet)
{
if (MatSet >= mMaterialSets.size())
MatSet = mMaterialSets.size() - 1;
u32 matID = mSurfaces[Surface]->MaterialID;
uint32 matID = mSurfaces[Surface]->MaterialID;
return (mMaterialSets[MatSet]->MaterialByIndex(matID)->Options() & CMaterial::eTransparent) != 0;
}
bool CModel::IsLightmapped() const
{
for (u32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
for (uint32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
{
CMaterialSet *pSet = mMaterialSets[iSet];
for (u32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
for (uint32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
{
CMaterial *pMat = pSet->MaterialByIndex(iMat);
if (pMat->Options().HasFlag(CMaterial::eLightmap))
@@ -291,12 +291,12 @@ bool CModel::IsLightmapped() const
return false;
}
CIndexBuffer* CModel::InternalGetIBO(u32 Surface, EGXPrimitiveType Primitive)
CIndexBuffer* CModel::InternalGetIBO(uint32 Surface, EGXPrimitiveType Primitive)
{
std::vector<CIndexBuffer> *pIBOs = &mSurfaceIndexBuffers[Surface];
GLenum Type = GXPrimToGLPrim(Primitive);
for (u32 iIBO = 0; iIBO < pIBOs->size(); iIBO++)
for (uint32 iIBO = 0; iIBO < pIBOs->size(); iIBO++)
{
if ((*pIBOs)[iIBO].GetPrimitiveType() == Type)
return &(*pIBOs)[iIBO];

View File

@@ -29,24 +29,24 @@ public:
void BufferGL();
void GenerateMaterialShaders();
void ClearGLBuffer();
void Draw(FRenderOptions Options, u32 MatSet);
void DrawSurface(FRenderOptions Options, u32 Surface, u32 MatSet);
void Draw(FRenderOptions Options, uint32 MatSet);
void DrawSurface(FRenderOptions Options, uint32 Surface, uint32 MatSet);
void DrawWireframe(FRenderOptions Options, CColor WireColor = CColor::skWhite);
void SetSkin(CSkin *pSkin);
u32 GetMatSetCount();
u32 GetMatCount();
CMaterialSet* GetMatSet(u32 MatSet);
CMaterial* GetMaterialByIndex(u32 MatSet, u32 Index);
CMaterial* GetMaterialBySurface(u32 MatSet, u32 Surface);
bool HasTransparency(u32 MatSet);
bool IsSurfaceTransparent(u32 Surface, u32 MatSet);
uint32 GetMatSetCount();
uint32 GetMatCount();
CMaterialSet* GetMatSet(uint32 MatSet);
CMaterial* GetMaterialByIndex(uint32 MatSet, uint32 Index);
CMaterial* GetMaterialBySurface(uint32 MatSet, uint32 Surface);
bool HasTransparency(uint32 MatSet);
bool IsSurfaceTransparent(uint32 Surface, uint32 MatSet);
bool IsLightmapped() const;
inline bool IsSkinned() const { return (mpSkin != nullptr); }
private:
CIndexBuffer* InternalGetIBO(u32 Surface, EGXPrimitiveType Primitive);
CIndexBuffer* InternalGetIBO(uint32 Surface, EGXPrimitiveType Primitive);
};
#endif // MODEL_H

View File

@@ -37,22 +37,22 @@ void CStaticModel::BufferGL()
mVBO.Clear();
mIBOs.clear();
for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
for (uint32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
{
SSurface *pSurf = mSurfaces[iSurf];
u16 VBOStartOffset = (u16) mVBO.Size();
mVBO.Reserve((u16) pSurf->VertexCount);
uint16 VBOStartOffset = (uint16) mVBO.Size();
mVBO.Reserve((uint16) pSurf->VertexCount);
for (u32 iPrim = 0; iPrim < pSurf->Primitives.size(); iPrim++)
for (uint32 iPrim = 0; iPrim < pSurf->Primitives.size(); iPrim++)
{
SSurface::SPrimitive *pPrim = &pSurf->Primitives[iPrim];
CIndexBuffer *pIBO = InternalGetIBO(pPrim->Type);
pIBO->Reserve(pPrim->Vertices.size() + 1); // Allocate enough space for this primitive, plus the restart index
// Next step: add new vertices to the VBO and create a small index buffer for the current primitive
std::vector<u16> Indices(pPrim->Vertices.size());
for (u32 iVert = 0; iVert < pPrim->Vertices.size(); iVert++)
std::vector<uint16> Indices(pPrim->Vertices.size());
for (uint32 iVert = 0; iVert < pPrim->Vertices.size(); iVert++)
Indices[iVert] = mVBO.AddIfUnique(pPrim->Vertices[iVert], VBOStartOffset);
// then add the indices to the IBO. We convert some primitives to strips to minimize draw calls.
@@ -76,15 +76,15 @@ void CStaticModel::BufferGL()
// Make sure the number of submesh offset vectors matches the number of IBOs, then add the offsets
while (mIBOs.size() > mSurfaceEndOffsets.size())
mSurfaceEndOffsets.emplace_back(std::vector<u32>(mSurfaces.size()));
mSurfaceEndOffsets.emplace_back(std::vector<uint32>(mSurfaces.size()));
for (u32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
mSurfaceEndOffsets[iIBO][iSurf] = mIBOs[iIBO].GetSize();
}
mVBO.Buffer();
for (u32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
mIBOs[iIBO].Buffer();
mBuffered = true;
@@ -115,7 +115,7 @@ void CStaticModel::Draw(FRenderOptions Options)
mVBO.Bind();
glLineWidth(1.f);
for (u32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
{
CIndexBuffer *pIBO = &mIBOs[iIBO];
pIBO->Bind();
@@ -127,7 +127,7 @@ void CStaticModel::Draw(FRenderOptions Options)
mVBO.Unbind();
}
void CStaticModel::DrawSurface(FRenderOptions Options, u32 Surface)
void CStaticModel::DrawSurface(FRenderOptions Options, uint32 Surface)
{
if (!mBuffered) BufferGL();
@@ -135,12 +135,12 @@ void CStaticModel::DrawSurface(FRenderOptions Options, u32 Surface)
glLineWidth(1.f);
if ((Options & eNoMaterialSetup) == 0) mpMaterial->SetCurrent(Options);
for (u32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
{
// Since there is a shared IBO for every mesh, we need two things to draw a single one: an offset and a size
u32 Offset = 0;
uint32 Offset = 0;
if (Surface > 0) Offset = mSurfaceEndOffsets[iIBO][Surface - 1];
u32 Size = mSurfaceEndOffsets[iIBO][Surface] - Offset;
uint32 Size = mSurfaceEndOffsets[iIBO][Surface] - Offset;
if (!Size) continue; // The chosen submesh doesn't use this IBO
@@ -164,7 +164,7 @@ void CStaticModel::DrawWireframe(FRenderOptions Options, CColor WireColor /*= CC
glBlendFunc(GL_ONE, GL_ZERO);
// Draw surfaces
for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
for (uint32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
DrawSurface(Options, iSurf);
// Cleanup
@@ -196,7 +196,7 @@ CIndexBuffer* CStaticModel::InternalGetIBO(EGXPrimitiveType Primitive)
{
GLenum type = GXPrimToGLPrim(Primitive);
for (u32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
{
if (mIBOs[iIBO].GetPrimitiveType() == type)
return &mIBOs[iIBO];

Some files were not shown because too many files have changed in this diff Show More