From 2287b05bc31b55d5b318f2959081fac6e84d3fee Mon Sep 17 00:00:00 2001 From: Aruki Date: Tue, 11 Dec 2018 22:50:46 -0700 Subject: [PATCH] Refactor so PWE compiles with the newly externalized LibCommon --- externals/CodeGen | 1 + externals/LibCommon | 2 +- src/Core/CAudioManager.cpp | 20 +- src/Core/CAudioManager.h | 10 +- src/Core/CRayCollisionTester.cpp | 4 +- src/Core/CRayCollisionTester.h | 10 +- src/Core/CompressionUtil.cpp | 80 +++-- src/Core/CompressionUtil.h | 21 +- src/Core/Core.pro | 17 +- src/Core/GameProject/AssetNameGeneration.cpp | 72 ++--- src/Core/GameProject/CAssetNameMap.cpp | 24 +- src/Core/GameProject/CDependencyTree.cpp | 44 +-- src/Core/GameProject/CDependencyTree.h | 42 +-- src/Core/GameProject/CGameExporter.cpp | 106 +++---- src/Core/GameProject/CGameExporter.h | 11 +- src/Core/GameProject/CGameInfo.cpp | 2 +- src/Core/GameProject/CGameInfo.h | 2 +- src/Core/GameProject/CGameProject.cpp | 16 +- src/Core/GameProject/CGameProject.h | 5 +- src/Core/GameProject/COpeningBanner.cpp | 14 +- src/Core/GameProject/COpeningBanner.h | 4 +- src/Core/GameProject/CPackage.cpp | 78 ++--- src/Core/GameProject/CPackage.h | 4 +- src/Core/GameProject/CResourceEntry.cpp | 28 +- src/Core/GameProject/CResourceEntry.h | 5 +- src/Core/GameProject/CResourceStore.cpp | 36 +-- src/Core/GameProject/CResourceStore.h | 5 +- src/Core/GameProject/CVirtualDirectory.cpp | 28 +- src/Core/GameProject/CVirtualDirectory.h | 10 +- .../GameProject/DependencyListBuilders.cpp | 68 ++--- src/Core/GameProject/DependencyListBuilders.h | 10 +- src/Core/IProgressNotifier.h | 2 +- src/Core/OpenGL/CDynamicVertexBuffer.cpp | 12 +- src/Core/OpenGL/CDynamicVertexBuffer.h | 6 +- src/Core/OpenGL/CFramebuffer.cpp | 6 +- src/Core/OpenGL/CFramebuffer.h | 6 +- src/Core/OpenGL/CIndexBuffer.cpp | 30 +- src/Core/OpenGL/CIndexBuffer.h | 22 +- src/Core/OpenGL/CRenderbuffer.h | 8 +- src/Core/OpenGL/CShader.cpp | 51 ++-- src/Core/OpenGL/CShader.h | 4 +- src/Core/OpenGL/CShaderGenerator.cpp | 18 +- src/Core/OpenGL/CUniformBuffer.h | 12 +- src/Core/OpenGL/CVertexArrayManager.cpp | 4 +- src/Core/OpenGL/CVertexArrayManager.h | 2 +- src/Core/OpenGL/CVertexBuffer.cpp | 32 +- src/Core/OpenGL/CVertexBuffer.h | 8 +- src/Core/OpenGL/GLCommon.h | 2 +- src/Core/Render/CBoneTransformData.h | 24 +- src/Core/Render/CCamera.cpp | 4 +- src/Core/Render/CCamera.h | 14 +- src/Core/Render/CDrawUtil.cpp | 38 +-- src/Core/Render/CDrawUtil.h | 2 +- src/Core/Render/CGraphics.cpp | 24 +- src/Core/Render/CGraphics.h | 20 +- src/Core/Render/CRenderBucket.cpp | 4 +- src/Core/Render/CRenderBucket.h | 6 +- src/Core/Render/CRenderer.cpp | 20 +- src/Core/Render/CRenderer.h | 16 +- src/Core/Render/IRenderable.h | 2 +- src/Core/Render/SRenderablePtr.h | 6 +- src/Core/Render/SViewInfo.h | 10 +- src/Core/Resource/Animation/CAnimEventData.h | 12 +- src/Core/Resource/Animation/CAnimSet.h | 48 +-- src/Core/Resource/Animation/CAnimation.cpp | 18 +- src/Core/Resource/Animation/CAnimation.h | 18 +- .../Animation/CAnimationParameters.cpp | 22 +- .../Resource/Animation/CAnimationParameters.h | 32 +- src/Core/Resource/Animation/CSkeleton.cpp | 32 +- src/Core/Resource/Animation/CSkeleton.h | 22 +- src/Core/Resource/Animation/CSkin.h | 8 +- src/Core/Resource/Animation/CSourceAnimData.h | 12 +- .../Resource/Animation/IMetaAnimation.cpp | 20 +- src/Core/Resource/Animation/IMetaAnimation.h | 14 +- .../Resource/Animation/IMetaTransition.cpp | 2 +- src/Core/Resource/Animation/IMetaTransition.h | 4 +- src/Core/Resource/Area/CGameArea.cpp | 46 +-- src/Core/Resource/Area/CGameArea.h | 64 ++-- src/Core/Resource/CAudioGroup.h | 12 +- src/Core/Resource/CAudioLookupTable.h | 4 +- src/Core/Resource/CAudioMacro.h | 8 +- src/Core/Resource/CCollisionMaterial.cpp | 6 +- src/Core/Resource/CCollisionMaterial.h | 4 +- src/Core/Resource/CCollisionMesh.cpp | 26 +- src/Core/Resource/CCollisionMesh.h | 38 +-- src/Core/Resource/CCollisionMeshGroup.h | 6 +- src/Core/Resource/CDependencyGroup.h | 6 +- src/Core/Resource/CFont.cpp | 12 +- src/Core/Resource/CFont.h | 48 +-- src/Core/Resource/CLight.cpp | 2 +- src/Core/Resource/CLight.h | 10 +- src/Core/Resource/CMaterial.cpp | 32 +- src/Core/Resource/CMaterial.h | 44 +-- src/Core/Resource/CMaterialPass.cpp | 14 +- src/Core/Resource/CMaterialPass.h | 38 +-- src/Core/Resource/CMaterialSet.h | 16 +- src/Core/Resource/CPoiToWorld.cpp | 8 +- src/Core/Resource/CPoiToWorld.h | 22 +- src/Core/Resource/CResTypeInfo.cpp | 8 +- src/Core/Resource/CResource.h | 1 - src/Core/Resource/CSavedStateID.h | 19 +- src/Core/Resource/CScan.h | 20 +- src/Core/Resource/CStringList.h | 4 +- src/Core/Resource/CStringTable.h | 37 ++- src/Core/Resource/CTexture.cpp | 74 ++--- src/Core/Resource/CTexture.h | 36 +-- src/Core/Resource/CWorld.cpp | 12 +- src/Core/Resource/CWorld.h | 42 +-- src/Core/Resource/Cooker/CAreaCooker.cpp | 78 ++--- src/Core/Resource/Cooker/CAreaCooker.h | 38 +-- src/Core/Resource/Cooker/CMaterialCooker.cpp | 112 +++---- src/Core/Resource/Cooker/CMaterialCooker.h | 6 +- src/Core/Resource/Cooker/CModelCooker.cpp | 80 ++--- src/Core/Resource/Cooker/CModelCooker.h | 10 +- .../Resource/Cooker/CPoiToWorldCooker.cpp | 8 +- src/Core/Resource/Cooker/CResourceCooker.h | 2 +- src/Core/Resource/Cooker/CScriptCooker.cpp | 50 ++-- src/Core/Resource/Cooker/CSectionMgrOut.h | 14 +- src/Core/Resource/Cooker/CTextureEncoder.cpp | 24 +- src/Core/Resource/Cooker/CWorldCooker.cpp | 38 +-- src/Core/Resource/Cooker/CWorldCooker.h | 4 +- .../Resource/Factory/CAnimEventLoader.cpp | 42 +-- src/Core/Resource/Factory/CAnimEventLoader.h | 2 +- src/Core/Resource/Factory/CAnimSetLoader.cpp | 196 ++++++------ src/Core/Resource/Factory/CAnimSetLoader.h | 2 +- .../Resource/Factory/CAnimationLoader.cpp | 140 ++++----- src/Core/Resource/Factory/CAnimationLoader.h | 24 +- src/Core/Resource/Factory/CAreaLoader.cpp | 140 ++++----- src/Core/Resource/Factory/CAreaLoader.h | 46 +-- .../Resource/Factory/CAudioGroupLoader.cpp | 28 +- .../Resource/Factory/CCollisionLoader.cpp | 44 +-- src/Core/Resource/Factory/CCollisionLoader.h | 2 +- .../Factory/CDependencyGroupLoader.cpp | 16 +- .../Resource/Factory/CDependencyGroupLoader.h | 2 +- src/Core/Resource/Factory/CFontLoader.cpp | 18 +- src/Core/Resource/Factory/CFontLoader.h | 2 +- src/Core/Resource/Factory/CMaterialLoader.cpp | 109 ++++--- src/Core/Resource/Factory/CMaterialLoader.h | 8 +- src/Core/Resource/Factory/CModelLoader.cpp | 98 +++--- src/Core/Resource/Factory/CModelLoader.h | 10 +- .../Resource/Factory/CPoiToWorldLoader.cpp | 8 +- src/Core/Resource/Factory/CScanLoader.cpp | 96 +++--- src/Core/Resource/Factory/CScanLoader.h | 4 +- src/Core/Resource/Factory/CScriptLoader.cpp | 124 ++++---- src/Core/Resource/Factory/CScriptLoader.h | 2 +- src/Core/Resource/Factory/CSectionMgrIn.h | 28 +- src/Core/Resource/Factory/CSkeletonLoader.cpp | 40 +-- src/Core/Resource/Factory/CSkinLoader.cpp | 12 +- src/Core/Resource/Factory/CStringLoader.cpp | 74 ++--- src/Core/Resource/Factory/CStringLoader.h | 2 +- src/Core/Resource/Factory/CTextureDecoder.cpp | 278 +++++++++--------- src/Core/Resource/Factory/CTextureDecoder.h | 58 ++-- .../Factory/CUnsupportedFormatLoader.cpp | 170 +++++------ .../Factory/CUnsupportedParticleLoader.cpp | 140 ++++----- .../Factory/CUnsupportedParticleLoader.h | 2 +- src/Core/Resource/Factory/CWorldLoader.cpp | 94 +++--- src/Core/Resource/Factory/CWorldLoader.h | 2 +- src/Core/Resource/Model/CBasicModel.cpp | 12 +- src/Core/Resource/Model/CBasicModel.h | 16 +- src/Core/Resource/Model/CModel.cpp | 64 ++-- src/Core/Resource/Model/CModel.h | 20 +- src/Core/Resource/Model/CStaticModel.cpp | 32 +- src/Core/Resource/Model/CStaticModel.h | 4 +- src/Core/Resource/Model/CVertex.h | 12 +- src/Core/Resource/Model/EVertexAttribute.cpp | 6 +- src/Core/Resource/Model/EVertexAttribute.h | 4 +- src/Core/Resource/Model/SSurface.cpp | 18 +- src/Core/Resource/Model/SSurface.h | 18 +- src/Core/Resource/Script/CGameTemplate.cpp | 18 +- src/Core/Resource/Script/CGameTemplate.h | 32 +- src/Core/Resource/Script/CLink.h | 48 +-- src/Core/Resource/Script/CScriptLayer.h | 22 +- src/Core/Resource/Script/CScriptObject.cpp | 16 +- src/Core/Resource/Script/CScriptObject.h | 30 +- src/Core/Resource/Script/CScriptTemplate.cpp | 26 +- src/Core/Resource/Script/CScriptTemplate.h | 24 +- src/Core/Resource/Script/NGameList.cpp | 12 +- src/Core/Resource/Script/NPropertyMap.cpp | 77 +++-- src/Core/Resource/Script/NPropertyMap.h | 16 +- .../Script/Property/CAnimationProperty.h | 6 +- .../Resource/Script/Property/CArrayProperty.h | 34 +-- .../Resource/Script/Property/CByteProperty.h | 6 +- .../Resource/Script/Property/CEnumProperty.h | 24 +- .../Script/Property/CFlagsProperty.cpp | 4 +- .../Resource/Script/Property/CFlagsProperty.h | 16 +- .../Resource/Script/Property/CIntProperty.h | 2 +- .../Property/CPropertyNameGenerator.cpp | 7 +- .../Script/Property/CPropertyNameGenerator.h | 8 +- .../Script/Property/CSequenceProperty.h | 2 +- .../Resource/Script/Property/CShortProperty.h | 4 +- .../Resource/Script/Property/CSoundProperty.h | 2 +- .../Script/Property/CStructProperty.cpp | 20 +- .../Script/Property/CStructProperty.h | 4 +- .../Resource/Script/Property/IProperty.cpp | 36 +-- src/Core/Resource/Script/Property/IProperty.h | 43 +-- src/Core/SRayIntersection.h | 8 +- src/Core/Scene/CCharacterNode.cpp | 14 +- src/Core/Scene/CCharacterNode.h | 18 +- src/Core/Scene/CCollisionNode.cpp | 8 +- src/Core/Scene/CCollisionNode.h | 4 +- src/Core/Scene/CLightNode.cpp | 6 +- src/Core/Scene/CLightNode.h | 4 +- src/Core/Scene/CModelNode.cpp | 8 +- src/Core/Scene/CModelNode.h | 12 +- src/Core/Scene/CRootNode.h | 4 +- src/Core/Scene/CScene.cpp | 62 ++-- src/Core/Scene/CScene.h | 26 +- src/Core/Scene/CSceneNode.cpp | 24 +- src/Core/Scene/CSceneNode.h | 36 +-- src/Core/Scene/CScriptAttachNode.cpp | 4 +- src/Core/Scene/CScriptAttachNode.h | 2 +- src/Core/Scene/CScriptNode.cpp | 32 +- src/Core/Scene/CScriptNode.h | 16 +- src/Core/Scene/CStaticNode.cpp | 12 +- src/Core/Scene/CStaticNode.h | 4 +- .../ScriptExtra/CDamageableTriggerExtra.cpp | 14 +- .../ScriptExtra/CDamageableTriggerExtra.h | 2 +- src/Core/ScriptExtra/CDoorExtra.cpp | 2 +- src/Core/ScriptExtra/CDoorExtra.h | 2 +- src/Core/ScriptExtra/CRadiusSphereExtra.h | 2 +- src/Core/ScriptExtra/CSandwormExtra.cpp | 4 +- src/Core/ScriptExtra/CScriptExtra.h | 4 +- src/Core/ScriptExtra/CSplinePathExtra.cpp | 2 +- src/Core/ScriptExtra/CWaypointExtra.cpp | 8 +- src/Editor/CAboutDialog.ui | 2 +- src/Editor/CBasicViewport.cpp | 2 +- src/Editor/CBasicViewport.h | 6 +- src/Editor/CEditorApplication.cpp | 6 +- src/Editor/CErrorLogDialog.cpp | 4 +- src/Editor/CExportGameDialog.cpp | 8 +- src/Editor/CGeneratePropertyNamesDialog.cpp | 8 +- src/Editor/CGizmo.cpp | 22 +- src/Editor/CGizmo.h | 12 +- src/Editor/CLineRenderable.h | 2 +- src/Editor/CNodeCopyMimeData.h | 10 +- src/Editor/CNodeSelection.h | 6 +- src/Editor/CProgressBarNotifier.h | 2 +- src/Editor/CProjectSettingsDialog.cpp | 6 +- src/Editor/CPropertyNameValidator.cpp | 2 +- src/Editor/CSceneViewport.cpp | 10 +- src/Editor/CSceneViewport.h | 2 +- src/Editor/CSelectionIterator.h | 2 +- .../CharacterEditor/CCharacterEditor.cpp | 24 +- src/Editor/CharacterEditor/CCharacterEditor.h | 6 +- .../CCharacterEditorViewport.cpp | 2 +- .../CCharacterEditorViewport.h | 6 +- .../CSkeletonHierarchyModel.cpp | 4 +- src/Editor/Editor.pro | 17 +- src/Editor/INodeEditor.h | 2 +- src/Editor/ModelEditor/CModelEditorWindow.cpp | 34 +-- src/Editor/PropertyEdit/CPropertyDelegate.cpp | 10 +- src/Editor/PropertyEdit/CPropertyModel.cpp | 26 +- src/Editor/PropertyEdit/CPropertyModel.h | 6 +- src/Editor/PropertyEdit/CPropertyView.cpp | 12 +- .../ResourceBrowser/CResourceBrowser.cpp | 26 +- .../ResourceBrowser/CResourceDelegate.cpp | 2 +- .../ResourceBrowser/CResourceProxyModel.h | 20 +- .../ResourceBrowser/CResourceTableModel.cpp | 8 +- .../ResourceBrowser/CResourceTableModel.h | 4 +- .../CVirtualDirectoryModel.cpp | 8 +- src/Editor/TestDialog.cpp | 2 +- src/Editor/Undo/CAddLinkCommand.cpp | 2 +- src/Editor/Undo/CChangeLayerCommand.h | 2 +- src/Editor/Undo/CCloneSelectionCommand.cpp | 10 +- src/Editor/Undo/CCreateInstanceCommand.h | 2 +- src/Editor/Undo/CDeleteLinksCommand.cpp | 2 +- src/Editor/Undo/CDeleteLinksCommand.h | 10 +- src/Editor/Undo/CDeleteSelectionCommand.cpp | 6 +- src/Editor/Undo/CDeleteSelectionCommand.h | 16 +- src/Editor/Undo/CEditLinkCommand.h | 4 +- src/Editor/Undo/CPasteNodesCommand.cpp | 2 +- .../Undo/ICreateDeleteDirectoryCommand.h | 2 +- src/Editor/Undo/ObjReferences.h | 12 +- src/Editor/Widgets/CSelectResourcePanel.cpp | 2 +- src/Editor/Widgets/WStringPreviewPanel.cpp | 2 +- src/Editor/Widgets/WTextureGLWidget.cpp | 4 +- src/Editor/Widgets/WTextureGLWidget.h | 6 +- src/Editor/Widgets/WVectorEditor.h | 2 +- .../CCollisionRenderSettingsDialog.cpp | 10 +- src/Editor/WorldEditor/CInstancesModel.cpp | 26 +- src/Editor/WorldEditor/CLayerModel.cpp | 2 +- src/Editor/WorldEditor/CLinkDialog.cpp | 4 +- src/Editor/WorldEditor/CLinkDialog.h | 4 +- src/Editor/WorldEditor/CLinkModel.cpp | 2 +- src/Editor/WorldEditor/CPoiMapModel.cpp | 6 +- src/Editor/WorldEditor/CStateMessageModel.h | 16 +- .../WorldEditor/CTemplateEditDialog.cpp | 2 +- src/Editor/WorldEditor/CTemplateListView.h | 2 +- src/Editor/WorldEditor/CWorldEditor.cpp | 16 +- src/Editor/WorldEditor/CWorldEditor.h | 4 +- src/Editor/WorldEditor/CWorldInfoSidebar.cpp | 4 +- src/Editor/WorldEditor/CWorldTreeModel.cpp | 10 +- src/Editor/WorldEditor/WCreateTab.cpp | 2 +- src/Editor/WorldEditor/WEditorProperties.cpp | 4 +- src/Editor/WorldEditor/WInstancesTab.cpp | 20 +- src/Editor/WorldEditor/WModifyTab.cpp | 8 +- src/Editor/main.cpp | 12 +- templates/PropertyMap.xml | 12 +- 298 files changed, 3192 insertions(+), 3184 deletions(-) create mode 160000 externals/CodeGen diff --git a/externals/CodeGen b/externals/CodeGen new file mode 160000 index 00000000..42038000 --- /dev/null +++ b/externals/CodeGen @@ -0,0 +1 @@ +Subproject commit 42038000181a5fa5b92f2abfb74d91b7bec25040 diff --git a/externals/LibCommon b/externals/LibCommon index 252e4c7e..49179325 160000 --- a/externals/LibCommon +++ b/externals/LibCommon @@ -1 +1 @@ -Subproject commit 252e4c7e96099c0f684b96d57eb9d947278d565b +Subproject commit 4917932573b3e6539113886c537a473550d3bbff diff --git a/src/Core/CAudioManager.cpp b/src/Core/CAudioManager.cpp index 540063b6..08ee74e0 100644 --- a/src/Core/CAudioManager.cpp +++ b/src/Core/CAudioManager.cpp @@ -28,13 +28,13 @@ void CAudioManager::LoadAssets() }); // Create SFX Define ID -> AGSC map - for (u32 iGrp = 0; iGrp < mAudioGroups.size(); iGrp++) + for (uint iGrp = 0; iGrp < mAudioGroups.size(); iGrp++) { CAudioGroup *pGroup = mAudioGroups[iGrp]; - for (u32 iSnd = 0; iSnd < pGroup->NumSoundDefineIDs(); iSnd++) + for (uint iSnd = 0; iSnd < pGroup->NumSoundDefineIDs(); iSnd++) { - u16 DefineID = pGroup->SoundDefineIDByIndex(iSnd); + uint16 DefineID = pGroup->SoundDefineIDByIndex(iSnd); ASSERT(mSfxIdMap.find(DefineID) == mSfxIdMap.end()); mSfxIdMap[DefineID] = pGroup; } @@ -64,7 +64,7 @@ void CAudioManager::ClearAssets() mSfxIdMap.clear(); } -SSoundInfo CAudioManager::GetSoundInfo(u32 SoundID) +SSoundInfo CAudioManager::GetSoundInfo(uint32 SoundID) { SSoundInfo Out; Out.SoundID = SoundID; @@ -84,18 +84,18 @@ SSoundInfo CAudioManager::GetSoundInfo(u32 SoundID) return Out; } -void CAudioManager::LogSoundInfo(u32 SoundID) +void CAudioManager::LogSoundInfo(uint32 SoundID) { SSoundInfo SoundInfo = GetSoundInfo(SoundID); if (SoundInfo.DefineID != 0xFFFF) { if (mpProject->Game() >= EGame::EchoesDemo) - Log::Write("Sound Name: " + SoundInfo.Name); + debugf("Sound Name: %s", *SoundInfo.Name); - Log::Write("Sound ID: " + TString::HexString(SoundInfo.SoundID, 4)); - Log::Write("Define ID: " + TString::HexString(SoundInfo.DefineID, 4)); - Log::Write("Audio Group: " + SoundInfo.pAudioGroup->Entry()->Name()); - Log::Write(""); + debugf("Sound ID: 0x%04x", SoundInfo.SoundID); + debugf("Define ID: 0x%04x", SoundInfo.DefineID); + debugf("Audio Group: %s", *SoundInfo.pAudioGroup->Entry()->Name()); + debugf(""); } } diff --git a/src/Core/CAudioManager.h b/src/Core/CAudioManager.h index 74cd8e30..0c242bb0 100644 --- a/src/Core/CAudioManager.h +++ b/src/Core/CAudioManager.h @@ -12,8 +12,8 @@ struct SSoundInfo { CAudioGroup *pAudioGroup; TString Name; - u32 SoundID; - u16 DefineID; + uint32 SoundID; + uint16 DefineID; }; class CAudioManager @@ -23,14 +23,14 @@ class CAudioManager std::vector> mAudioGroups; TResPtr mpAudioLookupTable; TResPtr mpSfxNameList; - std::unordered_map mSfxIdMap; + std::unordered_map mSfxIdMap; public: CAudioManager(CGameProject *pProj); void LoadAssets(); void ClearAssets(); - SSoundInfo GetSoundInfo(u32 SoundID); - void LogSoundInfo(u32 SoundID); + SSoundInfo GetSoundInfo(uint32 SoundID); + void LogSoundInfo(uint32 SoundID); }; #endif // CAUDIOMANAGER diff --git a/src/Core/CRayCollisionTester.cpp b/src/Core/CRayCollisionTester.cpp index 7fee55a9..34d06500 100644 --- a/src/Core/CRayCollisionTester.cpp +++ b/src/Core/CRayCollisionTester.cpp @@ -10,7 +10,7 @@ CRayCollisionTester::~CRayCollisionTester() { } -void CRayCollisionTester::AddNode(CSceneNode *pNode, u32 ComponentIndex, float Distance) +void CRayCollisionTester::AddNode(CSceneNode *pNode, uint32 ComponentIndex, float Distance) { mBoxIntersectList.emplace_back(SRayIntersection()); SRayIntersection& rIntersection = mBoxIntersectList.back(); @@ -22,7 +22,7 @@ void CRayCollisionTester::AddNode(CSceneNode *pNode, u32 ComponentIndex, float D void CRayCollisionTester::AddNodeModel(CSceneNode *pNode, CBasicModel *pModel) { // Check each of the model's surfaces and queue them for further testing if they hit - for (u32 iSurf = 0; iSurf < pModel->GetSurfaceCount(); iSurf++) + for (uint32 iSurf = 0; iSurf < pModel->GetSurfaceCount(); iSurf++) { std::pair SurfResult = pModel->GetSurfaceAABox(iSurf).Transformed(pNode->Transform()).IntersectsRay(mRay); diff --git a/src/Core/CRayCollisionTester.h b/src/Core/CRayCollisionTester.h index b45a8112..355b1092 100644 --- a/src/Core/CRayCollisionTester.h +++ b/src/Core/CRayCollisionTester.h @@ -4,10 +4,10 @@ #include "SRayIntersection.h" #include "Core/Render/SViewInfo.h" #include "Core/Resource/Model/CBasicModel.h" -#include -#include -#include -#include +#include +#include +#include +#include #include @@ -23,7 +23,7 @@ public: ~CRayCollisionTester(); const CRay& Ray() const { return mRay; } - void AddNode(CSceneNode *pNode, u32 AssetIndex, float Distance); + void AddNode(CSceneNode *pNode, uint32 AssetIndex, float Distance); void AddNodeModel(CSceneNode *pNode, CBasicModel *pModel); SRayIntersection TestNodes(const SViewInfo& rkViewInfo); }; diff --git a/src/Core/CompressionUtil.cpp b/src/Core/CompressionUtil.cpp index ab7ef7d7..ab0bb833 100644 --- a/src/Core/CompressionUtil.cpp +++ b/src/Core/CompressionUtil.cpp @@ -1,14 +1,12 @@ #include "CompressionUtil.h" -#include -#include -#include +#include #include #include namespace CompressionUtil { - TString ErrorText_zlib(s32 Error) + const char* ErrorText_zlib(int32 Error) { switch (Error) { @@ -25,7 +23,7 @@ namespace CompressionUtil } } - TString ErrorText_LZO(s32 Error) + const char* ErrorText_LZO(int32 Error) { switch (Error) { @@ -48,7 +46,7 @@ namespace CompressionUtil } // ************ DECOMPRESS ************ - bool DecompressZlib(u8 *pSrc, u32 SrcLen, u8 *pDst, u32 DstLen, u32& rTotalOut) + bool DecompressZlib(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut) { // Initialize z_stream z_stream z; @@ -61,7 +59,7 @@ namespace CompressionUtil z.next_out = pDst; // Attempt decompress - s32 Error = inflateInit(&z); + int32 Error = inflateInit(&z); if (!Error) { @@ -76,42 +74,42 @@ namespace CompressionUtil // Check for errors if (Error && Error != Z_STREAM_END) { - Log::Error("zlib error: " + ErrorText_zlib(Error)); + errorf("zlib error: %s", ErrorText_zlib(Error)); return false; } else return true; } - bool DecompressLZO(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut) + bool DecompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut) { lzo_init(); lzo_uint TotalOut; - s32 Error = lzo1x_decompress(pSrc, SrcLen, pDst, &TotalOut, LZO1X_MEM_DECOMPRESS); - rTotalOut = (u32) TotalOut; + int32 Error = lzo1x_decompress(pSrc, SrcLen, pDst, &TotalOut, LZO1X_MEM_DECOMPRESS); + rTotalOut = (uint32) TotalOut; if (Error) { - Log::Error("LZO error: " + ErrorText_LZO(Error)); + errorf("LZO error: %s", ErrorText_LZO(Error)); return false; } return true; } - bool DecompressSegmentedData(u8 *pSrc, u32 SrcLen, u8 *pDst, u32 DstLen) + bool DecompressSegmentedData(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen) { - u8 *pSrcEnd = pSrc + SrcLen; - u8 *pDstEnd = pDst + DstLen; + uint8 *pSrcEnd = pSrc + SrcLen; + uint8 *pDstEnd = pDst + DstLen; while ((pSrc < pSrcEnd) && (pDst < pDstEnd)) { // Read size value (this method is Endian-independent) - u8 ByteA = *pSrc++; - u8 ByteB = *pSrc++; - s16 Size = (ByteA << 8) | ByteB; + uint8 ByteA = *pSrc++; + uint8 ByteB = *pSrc++; + int16 Size = (ByteA << 8) | ByteB; - u32 TotalOut; + uint32 TotalOut; // Negative size denotes uncompressed data. if (Size < 0) @@ -126,13 +124,13 @@ namespace CompressionUtil else { // Check for zlib magic - u8 ByteC = pSrc[0]; - u8 ByteD = pSrc[1]; - u16 PeekMagic = (ByteC << 8) | ByteD; + uint8 ByteC = pSrc[0]; + uint8 ByteD = pSrc[1]; + uint16 PeekMagic = (ByteC << 8) | ByteD; if (PeekMagic == 0x78DA || PeekMagic == 0x789C || PeekMagic == 0x7801) { - bool Success = DecompressZlib(pSrc, Size, pDst, (u32) (pDstEnd - pDst), TotalOut); + bool Success = DecompressZlib(pSrc, Size, pDst, (uint32) (pDstEnd - pDst), TotalOut); if (!Success) return false; } @@ -152,7 +150,7 @@ namespace CompressionUtil } // ************ COMPRESS ************ - bool CompressZlib(u8 *pSrc, u32 SrcLen, u8 *pDst, u32 DstLen, u32& rTotalOut) + bool CompressZlib(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut) { z_stream z; z.zalloc = Z_NULL; @@ -163,7 +161,7 @@ namespace CompressionUtil z.avail_out = DstLen; z.next_out = pDst; - s32 Error = deflateInit(&z, 9); + int32 Error = deflateInit(&z, 9); if (!Error) { @@ -177,46 +175,46 @@ namespace CompressionUtil if (Error && Error != Z_STREAM_END) { - Log::Error("zlib error: " + ErrorText_zlib(Error)); + errorf("zlib error: %s", ErrorText_zlib(Error)); return false; } else return true; } - bool CompressLZO(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut) + bool CompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut) { lzo_init(); - u8 *pWorkMem = new u8[LZO1X_999_MEM_COMPRESS]; - s32 Error = lzo1x_999_compress(pSrc, SrcLen, pDst, (lzo_uint*) &rTotalOut, pWorkMem); + uint8 *pWorkMem = new uint8[LZO1X_999_MEM_COMPRESS]; + int32 Error = lzo1x_999_compress(pSrc, SrcLen, pDst, (lzo_uint*) &rTotalOut, pWorkMem); delete[] pWorkMem; if (Error) { - Log::Error("LZO error: " + ErrorText_LZO(Error)); + errorf("LZO error: %s", ErrorText_LZO(Error)); return false; } return true; } - bool CompressSegmentedData(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut, bool IsZlib, bool AllowUncompressedSegments) + bool CompressSegmentedData(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut, bool IsZlib, bool AllowUncompressedSegments) { - u8 *pSrcEnd = pSrc + SrcLen; - u8 *pDstStart = pDst; + uint8 *pSrcEnd = pSrc + SrcLen; + uint8 *pDstStart = pDst; while (pSrc < pSrcEnd) { // Each segment is compressed separately. Segment size should always be 0x4000 unless there's less than 0x4000 bytes left. - u16 Size; - u32 Remaining = (u32) (pSrcEnd - pSrc); + uint16 Size; + uint32 Remaining = (uint32) (pSrcEnd - pSrc); - if (Remaining < 0x4000) Size = (u16) Remaining; + if (Remaining < 0x4000) Size = (uint16) Remaining; else Size = 0x4000; - std::vector Compressed(Size * 2); - u32 TotalOut; + std::vector Compressed(Size * 2); + uint32 TotalOut; if (IsZlib) CompressZlib(pSrc, Size, Compressed.data(), Compressed.size(), TotalOut); @@ -248,16 +246,16 @@ namespace CompressionUtil pDst += TotalOut; } - rTotalOut = (u32) (pDst - pDstStart); + rTotalOut = (uint32) (pDst - pDstStart); return true; } - bool CompressZlibSegmented(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut, bool AllowUncompressedSegments) + bool CompressZlibSegmented(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut, bool AllowUncompressedSegments) { return CompressSegmentedData(pSrc, SrcLen, pDst, rTotalOut, true, AllowUncompressedSegments); } - bool CompressLZOSegmented(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut, bool AllowUncompressedSegments) + bool CompressLZOSegmented(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut, bool AllowUncompressedSegments) { return CompressSegmentedData(pSrc, SrcLen, pDst, rTotalOut, false, AllowUncompressedSegments); } diff --git a/src/Core/CompressionUtil.h b/src/Core/CompressionUtil.h index a19d254f..193c7815 100644 --- a/src/Core/CompressionUtil.h +++ b/src/Core/CompressionUtil.h @@ -1,26 +1,23 @@ #ifndef COMPRESSIONUTIL_H #define COMPRESSIONUTIL_H +#include #include #include -#include namespace CompressionUtil { - TString ErrorText_zlib(s32 Error); - TString ErrorText_LZO(s32 Error); - // Decompression - bool DecompressZlib(u8 *pSrc, u32 SrcLen, u8 *pDst, u32 DstLen, u32& rTotalOut); - bool DecompressLZO(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut); - bool DecompressSegmentedData(u8 *pSrc, u32 SrcLen, u8 *pDst, u32 DstLen); + bool DecompressZlib(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut); + bool DecompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut); + bool DecompressSegmentedData(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen); // Compression - bool CompressZlib(u8 *pSrc, u32 SrcLen, u8 *pDst, u32 DstLen, u32& rTotalOut); - bool CompressLZO(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut); - bool CompressSegmentedData(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut, bool IsZlib, bool AllowUncompressedSegments); - bool CompressZlibSegmented(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut, bool AllowUncompressedSegments); - bool CompressLZOSegmented(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut, bool AllowUncompressedSegments); + bool CompressZlib(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut); + bool CompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut); + bool CompressSegmentedData(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut, bool IsZlib, bool AllowUncompressedSegments); + bool CompressZlibSegmented(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut, bool AllowUncompressedSegments); + bool CompressLZOSegmented(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut, bool AllowUncompressedSegments); } #endif // COMPRESSIONUTIL_H diff --git a/src/Core/Core.pro b/src/Core/Core.pro index f16b114c..fb72c1b8 100644 --- a/src/Core/Core.pro +++ b/src/Core/Core.pro @@ -27,17 +27,15 @@ CONFIG (debug, debug|release) { TARGET = Cored # Debug Libs - LIBS += -L$$BUILD_DIR/Common/ -lCommond \ - -L$$BUILD_DIR/Math/ -lMathd \ - -L$$EXTERNALS_DIR/assimp/lib/Debug -lassimp-vc140-mt \ + LIBS += -L$$EXTERNALS_DIR/assimp/lib/Debug -lassimp-vc140-mt \ + -L$$EXTERNALS_DIR/LibCommon/Build -lLibCommond \ -L$$EXTERNALS_DIR/nod/lib/Debug -lnod \ -L$$EXTERNALS_DIR/nod/logvisor/Debug -llogvisor \ -L$$EXTERNALS_DIR/zlib/lib/ -lzlibd # Debug Target Dependencies win32 { - PRE_TARGETDEPS += $$BUILD_DIR/Common/Commond.lib \ - $$BUILD_DIR/Math/Mathd.lib + PRE_TARGETDEPS += $$EXTERNALS_DIR/LibCommon/Build/LibCommond.lib } } @@ -47,17 +45,15 @@ CONFIG (release, debug|release) { TARGET = Core # Release Libs - LIBS += -L$$BUILD_DIR/Common/ -lCommon \ - -L$$BUILD_DIR/Math/ -lMath \ - -L$$EXTERNALS_DIR/assimp/lib/Release -lassimp-vc140-mt \ + LIBS += -L$$EXTERNALS_DIR/assimp/lib/Release -lassimp-vc140-mt \ + -L$$EXTERNALS_DIR/LibCommon/Build -lLibCommon \ -L$$EXTERNALS_DIR/nod/lib/Release -lnod \ -L$$EXTERNALS_DIR/nod/logvisor/Release -llogvisor \ -L$$EXTERNALS_DIR/zlib/lib/ -lzlib # Release Target Dependencies win32 { - PRE_TARGETDEPS += $$BUILD_DIR/Common/Common.lib \ - $$BUILD_DIR/Math/Math.lib + PRE_TARGETDEPS += $$EXTERNALS_DIR/LibCommon/Build/LibCommon.lib } } @@ -70,6 +66,7 @@ INCLUDEPATH += $$PWE_MAIN_INCLUDE \ $$EXTERNALS_DIR/assimp/include \ $$EXTERNALS_DIR/CodeGen/include \ $$EXTERNALS_DIR/glew-2.1.0/include \ + $$EXTERNALS_DIR/LibCommon/Source \ $$EXTERNALS_DIR/lzo-2.10/include \ $$EXTERNALS_DIR/nod/include \ $$EXTERNALS_DIR/nod/logvisor/include \ diff --git a/src/Core/GameProject/AssetNameGeneration.cpp b/src/Core/GameProject/AssetNameGeneration.cpp index 5edf2343..c2d289d1 100644 --- a/src/Core/GameProject/AssetNameGeneration.cpp +++ b/src/Core/GameProject/AssetNameGeneration.cpp @@ -7,7 +7,7 @@ #include "Core/Resource/CWorld.h" #include "Core/Resource/Animation/CAnimSet.h" #include "Core/Resource/Script/CScriptLayer.h" -#include +#include #define REVERT_AUTO_NAMES 1 #define PROCESS_PACKAGES 1 @@ -85,12 +85,12 @@ void ApplyGeneratedName(CResourceEntry *pEntry, const TString& rkDir, const TStr void GenerateAssetNames(CGameProject *pProj) { - Log::Write("*** Generating Asset Names ***"); + debugf("*** Generating Asset Names ***"); CResourceStore *pStore = pProj->ResourceStore(); #if REVERT_AUTO_NAMES // Revert all auto-generated asset names back to default to prevent name conflicts resulting in inconsistent results. - Log::Write("Reverting auto-generated names"); + debugf("Reverting auto-generated names"); for (CResourceIterator It(pStore); It; ++It) { @@ -106,13 +106,13 @@ void GenerateAssetNames(CGameProject *pProj) #if PROCESS_PACKAGES // Generate names for package named resources - Log::Write("Processing packages"); + debugf("Processing packages"); - for (u32 iPkg = 0; iPkg < pProj->NumPackages(); iPkg++) + for (uint32 iPkg = 0; iPkg < pProj->NumPackages(); iPkg++) { CPackage *pPkg = pProj->PackageByIndex(iPkg); - for (u32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++) + for (uint32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++) { const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes); if (rkRes.Name.EndsWith("NODEPEND")) continue; @@ -128,7 +128,7 @@ void GenerateAssetNames(CGameProject *pProj) #if PROCESS_WORLDS // Generate world/area names - Log::Write("Processing worlds"); + debugf("Processing worlds"); const TString kWorldsRoot = "Worlds/"; for (TResourceIterator It(pStore); It; ++It) @@ -165,15 +165,15 @@ void GenerateAssetNames(CGameProject *pProj) ApplyGeneratedName(pSkyEntry, WorldDir + "sky/cooked/", WorldName + "_sky"); // Move sky textures - for (u32 iSet = 0; iSet < pSkyModel->GetMatSetCount(); iSet++) + for (uint32 iSet = 0; iSet < pSkyModel->GetMatSetCount(); iSet++) { CMaterialSet *pSet = pSkyModel->GetMatSet(iSet); - for (u32 iMat = 0; iMat < pSet->NumMaterials(); iMat++) + for (uint32 iMat = 0; iMat < pSet->NumMaterials(); iMat++) { CMaterial *pMat = pSet->MaterialByIndex(iMat); - for (u32 iPass = 0; iPass < pMat->PassCount(); iPass++) + for (uint32 iPass = 0; iPass < pMat->PassCount(); iPass++) { CMaterialPass *pPass = pMat->Pass(iPass); @@ -197,7 +197,7 @@ void GenerateAssetNames(CGameProject *pProj) } // Areas - for (u32 iArea = 0; iArea < pWorld->NumAreas(); iArea++) + for (uint32 iArea = 0; iArea < pWorld->NumAreas(); iArea++) { // Determine area name TString AreaName = pWorld->AreaInternalName(iArea); @@ -233,15 +233,15 @@ void GenerateAssetNames(CGameProject *pProj) CGameArea *pArea = (CGameArea*) pAreaEntry->Load(); // Area lightmaps - u32 LightmapNum = 0; + uint32 LightmapNum = 0; CMaterialSet *pMaterials = pArea->Materials(); - for (u32 iMat = 0; iMat < pMaterials->NumMaterials(); iMat++) + for (uint32 iMat = 0; iMat < pMaterials->NumMaterials(); iMat++) { CMaterial *pMat = pMaterials->MaterialByIndex(iMat); bool FoundLightmap = false; - for (u32 iPass = 0; iPass < pMat->PassCount(); iPass++) + for (uint32 iPass = 0; iPass < pMat->PassCount(); iPass++) { CMaterialPass *pPass = pMat->Pass(iPass); @@ -277,11 +277,11 @@ void GenerateAssetNames(CGameProject *pProj) } // Generate names from script instance names - for (u32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++) + for (uint32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++) { CScriptLayer *pLayer = pArea->ScriptLayer(iLyr); - for (u32 iInst = 0; iInst < pLayer->NumInstances(); iInst++) + for (uint32 iInst = 0; iInst < pLayer->NumInstances(); iInst++) { CScriptObject* pInst = pLayer->InstanceByIndex(iInst); CStructProperty* pProperties = pInst->Template()->Properties(); @@ -327,7 +327,7 @@ void GenerateAssetNames(CGameProject *pProj) if (Name.EndsWith(".STRG", false)) { - u32 StringPropID = (pProj->Game() <= EGame::Prime ? 0x4 : 0x9182250C); + uint32 StringPropID = (pProj->Game() <= EGame::Prime ? 0x4 : 0x9182250C); CAssetProperty *pStringProperty = TPropCast(pProperties->ChildByID(StringPropID)); ASSERT(pStringProperty); // Temporary assert to remind myself later to update this code when uncooked properties are added to the template @@ -353,7 +353,7 @@ void GenerateAssetNames(CGameProject *pProj) else if (pInst->ObjectTypeID() == 0x0 || pInst->ObjectTypeID() == FOURCC('ACTR') || pInst->ObjectTypeID() == 0x8 || pInst->ObjectTypeID() == FOURCC('PLAT')) { - u32 ModelPropID = (pProj->Game() <= EGame::Prime ? (pInst->ObjectTypeID() == 0x0 ? 0xA : 0x6) : 0xC27FFA8F); + uint32 ModelPropID = (pProj->Game() <= EGame::Prime ? (pInst->ObjectTypeID() == 0x0 ? 0xA : 0x6) : 0xC27FFA8F); CAssetProperty *pModelProperty = TPropCast(pProperties->ChildByID(ModelPropID)); ASSERT(pModelProperty); // Temporary assert to remind myself later to update this code when uncooked properties are added to the template @@ -396,22 +396,22 @@ void GenerateAssetNames(CGameProject *pProj) #if PROCESS_MODELS // Generate Model Lightmap names - Log::Write("Processing model lightmaps"); + debugf("Processing model lightmaps"); for (TResourceIterator It(pStore); It; ++It) { CModel *pModel = (CModel*) It->Load(); - u32 LightmapNum = 0; + uint32 LightmapNum = 0; - for (u32 iSet = 0; iSet < pModel->GetMatSetCount(); iSet++) + for (uint32 iSet = 0; iSet < pModel->GetMatSetCount(); iSet++) { CMaterialSet *pSet = pModel->GetMatSet(iSet); - for (u32 iMat = 0; iMat < pSet->NumMaterials(); iMat++) + for (uint32 iMat = 0; iMat < pSet->NumMaterials(); iMat++) { CMaterial *pMat = pSet->MaterialByIndex(iMat); - for (u32 iPass = 0; iPass < pMat->PassCount(); iPass++) + for (uint32 iPass = 0; iPass < pMat->PassCount(); iPass++) { CMaterialPass *pPass = pMat->Pass(iPass); @@ -439,7 +439,7 @@ void GenerateAssetNames(CGameProject *pProj) #if PROCESS_AUDIO_GROUPS // Generate Audio Group names - Log::Write("Processing audio groups"); + debugf("Processing audio groups"); const TString kAudioGrpDir = "Audio/"; for (TResourceIterator It(pStore); It; ++It) @@ -452,7 +452,7 @@ void GenerateAssetNames(CGameProject *pProj) #if PROCESS_AUDIO_MACROS // Process audio macro/sample names - Log::Write("Processing audio macros"); + debugf("Processing audio macros"); const TString kSfxDir = "Audio/Uncategorized/"; for (TResourceIterator It(pStore); It; ++It) @@ -461,7 +461,7 @@ void GenerateAssetNames(CGameProject *pProj) TString MacroName = pMacro->MacroName(); ApplyGeneratedName(*It, kSfxDir, MacroName); - for (u32 iSamp = 0; iSamp < pMacro->NumSamples(); iSamp++) + for (uint32 iSamp = 0; iSamp < pMacro->NumSamples(); iSamp++) { CAssetID SampleID = pMacro->SampleByIndex(iSamp); CResourceEntry *pSample = pStore->FindEntry(SampleID); @@ -484,7 +484,7 @@ void GenerateAssetNames(CGameProject *pProj) #if PROCESS_ANIM_CHAR_SETS // Generate animation format names // Hacky syntax because animsets are under eAnimSet in MP1/2 and eCharacter in MP3/DKCR - Log::Write("Processing animation data"); + debugf("Processing animation data"); CResourceIterator *pIter = (pProj->Game() <= EGame::Echoes ? (CResourceIterator*) new TResourceIterator : (CResourceIterator*) new TResourceIterator); CResourceIterator& It = *pIter; @@ -494,7 +494,7 @@ void GenerateAssetNames(CGameProject *pProj) TString NewSetName; CAnimSet *pSet = (CAnimSet*) It->Load(); - for (u32 iChar = 0; iChar < pSet->NumCharacters(); iChar++) + for (uint32 iChar = 0; iChar < pSet->NumCharacters(); iChar++) { const SSetCharacter *pkChar = pSet->Character(iChar); @@ -516,7 +516,7 @@ void GenerateAssetNames(CGameProject *pProj) } } - for (u32 iOverlay = 0; iOverlay < pkChar->OverlayModels.size(); iOverlay++) + for (uint32 iOverlay = 0; iOverlay < pkChar->OverlayModels.size(); iOverlay++) { const SOverlayModel& rkOverlay = pkChar->OverlayModels[iOverlay]; @@ -573,7 +573,7 @@ void GenerateAssetNames(CGameProject *pProj) #if PROCESS_STRINGS // Generate string names - Log::Write("Processing strings"); + debugf("Processing strings"); const TString kStringsDir = "Strings/Uncategorized/"; for (TResourceIterator It(pStore); It; ++It) @@ -582,12 +582,12 @@ void GenerateAssetNames(CGameProject *pProj) CStringTable *pString = (CStringTable*) It->Load(); TString String; - for (u32 iStr = 0; iStr < pString->NumStrings() && String.IsEmpty(); iStr++) + for (uint32 iStr = 0; iStr < pString->NumStrings() && String.IsEmpty(); iStr++) String = CStringTable::StripFormatting( pString->String("ENGL", iStr) ).Trimmed(); if (!String.IsEmpty()) { - TString Name = String.SubString(0, Math::Min(String.Size(), 50)).Trimmed(); + TString Name = String.SubString(0, Math::Min(String.Size(), 50)).Trimmed(); Name.Replace("\n", " "); while (Name.EndsWith(".") || TString::IsWhitespace(Name.Back())) @@ -600,7 +600,7 @@ void GenerateAssetNames(CGameProject *pProj) #if PROCESS_SCANS // Generate scan names - Log::Write("Processing scans"); + debugf("Processing scans"); for (TResourceIterator It(pStore); It; ++It) { if (It->IsNamed()) continue; @@ -628,7 +628,7 @@ void GenerateAssetNames(CGameProject *pProj) CResourceEntry *pEntry = pStore->FindEntry(FrameID); if (pEntry) ApplyGeneratedName(pEntry, pEntry->DirectoryPath(), "ScanFrame"); - for (u32 iImg = 0; iImg < 4; iImg++) + for (uint32 iImg = 0; iImg < 4; iImg++) { CAssetID ImageID = pScan->ScanImage(iImg); CResourceEntry *pImgEntry = pStore->FindEntry(ImageID); @@ -640,7 +640,7 @@ void GenerateAssetNames(CGameProject *pProj) #if PROCESS_FONTS // Generate font names - Log::Write("Processing fonts"); + debugf("Processing fonts"); for (TResourceIterator It(pStore); It; ++It) { CFont *pFont = (CFont*) It->Load(); @@ -659,5 +659,5 @@ void GenerateAssetNames(CGameProject *pProj) pStore->RootDirectory()->DeleteEmptySubdirectories(); pStore->ConditionalSaveStore(); - Log::Write("*** Asset Name Generation FINISHED ***"); + debugf("*** Asset Name Generation FINISHED ***"); } diff --git a/src/Core/GameProject/CAssetNameMap.cpp b/src/Core/GameProject/CAssetNameMap.cpp index 65615eb1..357e58d7 100644 --- a/src/Core/GameProject/CAssetNameMap.cpp +++ b/src/Core/GameProject/CAssetNameMap.cpp @@ -18,15 +18,15 @@ bool CAssetNameMap::LoadAssetNames(TString Path /*= ""*/) } else { - TString ExpectedIDLength = (mIDLength == e32Bit ? "32-bit" : "64-bit"); - TString GotIDLength = (FileIDLength == e32Bit ? "32-bit" : "64-bit"); - Log::Error("Failed to load asset names; expected " + ExpectedIDLength + " IDs, got " + GotIDLength); + debugf("Failed to load asset names; expected %s IDs, got %s", + mIDLength == e32Bit ? "32-bit" : "64-bit", + FileIDLength == e32Bit ? "32-bit" : "64-bit" ); return false; } } else { - Log::Error("Failed to load asset names; couldn't open XML."); + errorf("Failed to load asset names; couldn't open XML."); return false; } } @@ -117,9 +117,9 @@ void CAssetNameMap::CopyFromStore(CResourceStore *pStore /*= gpResourceStore*/) TString OldPath = NameInfo.FullPath(); TString NewPath = NewNameInfo.FullPath(); - Log::Warning("Detected name conflict when copying asset name from the resource store; renaming."); - Log::Warning("\tOld Path: " + OldPath); - Log::Warning("\tNew Path: " + NewPath); + warnf("Detected name conflict when copying asset name from the resource store; renaming."); + warnf("\tOld Path: %s", *OldPath); + warnf("\tNew Path: %s", *NewPath); NameInfo.Name = NewNameInfo.Name; } @@ -160,7 +160,7 @@ void CAssetNameMap::PostLoadValidate() // Verify the name/path is valid if (!CResourceStore::IsValidResourcePath(rkInfo.Directory, rkInfo.Name)) { - Log::Error("Invalid resource path in asset name map: " + rkInfo.Directory + rkInfo.Name + "." + rkInfo.Type.ToString()); + errorf("Invalid resource path in asset name map: %s%s.%s", *rkInfo.Directory, *rkInfo.Name, *rkInfo.Type.ToString()); Iter = mMap.erase(Iter); FoundErrors = true; } @@ -168,7 +168,7 @@ void CAssetNameMap::PostLoadValidate() // Verify correct ID length if (Iter->first.Length() != mIDLength) { - Log::Error("Incorrect asset ID length in asset name map: " + Iter->first.ToString()); + errorf("Incorrect asset ID length in asset name map: %s", *Iter->first.ToString()); Iter = mMap.erase(Iter); FoundErrors = true; } @@ -178,13 +178,11 @@ void CAssetNameMap::PostLoadValidate() // If we detected any dupes, then this map can't be used if (!Dupes.empty()) { - Log::Error("Asset name map is invalid and cannot be used! Duplicate asset entries detected:"); + errorf("Asset name map is invalid and cannot be used! Duplicate asset entries detected:"); for (auto Iter = Dupes.begin(); Iter != Dupes.end(); Iter++) { - const SAssetNameInfo& rkInfo = *Iter; - TString FullPath = rkInfo.FullPath(); - Log::Error("\t" + FullPath); + warnf("\t%s", Iter->FullPath()); } mMap.clear(); diff --git a/src/Core/GameProject/CDependencyTree.cpp b/src/Core/GameProject/CDependencyTree.cpp index ce8e062e..ea8b7119 100644 --- a/src/Core/GameProject/CDependencyTree.cpp +++ b/src/Core/GameProject/CDependencyTree.cpp @@ -9,13 +9,13 @@ // ************ IDependencyNode ************ IDependencyNode::~IDependencyNode() { - for (u32 iChild = 0; iChild < mChildren.size(); iChild++) + for (uint32 iChild = 0; iChild < mChildren.size(); iChild++) delete mChildren[iChild]; } bool IDependencyNode::HasDependency(const CAssetID& rkID) const { - for (u32 iChild = 0; iChild < mChildren.size(); iChild++) + for (uint32 iChild = 0; iChild < mChildren.size(); iChild++) { if (mChildren[iChild]->HasDependency(rkID)) return true; @@ -26,7 +26,7 @@ bool IDependencyNode::HasDependency(const CAssetID& rkID) const void IDependencyNode::GetAllResourceReferences(std::set& rOutSet) const { - for (u32 iChild = 0; iChild < mChildren.size(); iChild++) + for (uint32 iChild = 0; iChild < mChildren.size(); iChild++) mChildren[iChild]->GetAllResourceReferences(rOutSet); } @@ -158,7 +158,7 @@ void CScriptInstanceDependency::ParseStructDependencies(CScriptInstanceDependenc // Recursive function for parsing script dependencies and loading them into the script instance dependency void* pPropertyData = pInstance->PropertyData(); - for (u32 PropertyIdx = 0; PropertyIdx < pStruct->NumChildren(); PropertyIdx++) + for (uint32 PropertyIdx = 0; PropertyIdx < pStruct->NumChildren(); PropertyIdx++) { IProperty *pProp = pStruct->ChildByIndex(PropertyIdx); EPropertyType Type = pProp->Type(); @@ -170,7 +170,7 @@ void CScriptInstanceDependency::ParseStructDependencies(CScriptInstanceDependenc else if (Type == EPropertyType::Sound) { - u32 SoundID = TPropCast(pProp)->Value(pPropertyData); + uint32 SoundID = TPropCast(pProp)->Value(pPropertyData); if (SoundID != -1) { @@ -246,13 +246,13 @@ CSetCharacterDependency* CSetCharacterDependency::BuildTree(const SSetCharacter& &rkChar.EffectParticles }; - for (u32 iVec = 0; iVec < 5; iVec++) + for (uint32 iVec = 0; iVec < 5; iVec++) { - for (u32 iPart = 0; iPart < pkParticleVectors[iVec]->size(); iPart++) + for (uint32 iPart = 0; iPart < pkParticleVectors[iVec]->size(); iPart++) pTree->AddDependency(pkParticleVectors[iVec]->at(iPart)); } - for (u32 iOverlay = 0; iOverlay < rkChar.OverlayModels.size(); iOverlay++) + for (uint32 iOverlay = 0; iOverlay < rkChar.OverlayModels.size(); iOverlay++) { const SOverlayModel& rkOverlay = rkChar.OverlayModels[iOverlay]; pTree->AddDependency(rkOverlay.ModelID); @@ -276,13 +276,13 @@ void CSetAnimationDependency::Serialize(IArchive& rArc) << SerialParameter("Children", mChildren); } -CSetAnimationDependency* CSetAnimationDependency::BuildTree(const CAnimSet *pkOwnerSet, u32 AnimIndex) +CSetAnimationDependency* CSetAnimationDependency::BuildTree(const CAnimSet *pkOwnerSet, uint32 AnimIndex) { CSetAnimationDependency *pTree = new CSetAnimationDependency; const SAnimation *pkAnim = pkOwnerSet->Animation(AnimIndex); // Find relevant character indices - for (u32 iChar = 0; iChar < pkOwnerSet->NumCharacters(); iChar++) + for (uint32 iChar = 0; iChar < pkOwnerSet->NumCharacters(); iChar++) { const SSetCharacter *pkChar = pkOwnerSet->Character(iChar); @@ -340,7 +340,7 @@ void CAreaDependencyTree::AddScriptLayer(CScriptLayer *pLayer, const std::vector mLayerOffsets.push_back(mChildren.size()); std::set UsedIDs; - for (u32 iInst = 0; iInst < pLayer->NumInstances(); iInst++) + for (uint32 iInst = 0; iInst < pLayer->NumInstances(); iInst++) { CScriptInstanceDependency *pTree = CScriptInstanceDependency::BuildTree( pLayer->InstanceByIndex(iInst) ); ASSERT(pTree != nullptr); @@ -355,34 +355,34 @@ void CAreaDependencyTree::AddScriptLayer(CScriptLayer *pLayer, const std::vector delete pTree; } - for (u32 iDep = 0; iDep < rkExtraDeps.size(); iDep++) + for (uint32 iDep = 0; iDep < rkExtraDeps.size(); iDep++) AddDependency(rkExtraDeps[iDep]); } -void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector& rModuleDepsOut, std::vector& rModuleLayerOffsetsOut) const +void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector& rModuleDepsOut, std::vector& rModuleLayerOffsetsOut) const { CGameTemplate *pGame = NGameList::GetGameTemplate(Game); // Output module list will be split per-script layer // The output offset list contains two offsets per layer - start index and end index - for (u32 iLayer = 0; iLayer < mLayerOffsets.size(); iLayer++) + for (uint32 iLayer = 0; iLayer < mLayerOffsets.size(); iLayer++) { - u32 StartIdx = mLayerOffsets[iLayer]; - u32 EndIdx = (iLayer == mLayerOffsets.size() - 1 ? mChildren.size() : mLayerOffsets[iLayer + 1]); + uint32 StartIdx = mLayerOffsets[iLayer]; + uint32 EndIdx = (iLayer == mLayerOffsets.size() - 1 ? mChildren.size() : mLayerOffsets[iLayer + 1]); - u32 ModuleStartIdx = rModuleDepsOut.size(); + uint32 ModuleStartIdx = rModuleDepsOut.size(); rModuleLayerOffsetsOut.push_back(ModuleStartIdx); // Keep track of which types we've already checked on this layer to speed things up a little... - std::set UsedObjectTypes; + std::set UsedObjectTypes; - for (u32 iInst = StartIdx; iInst < EndIdx; iInst++) + for (uint32 iInst = StartIdx; iInst < EndIdx; iInst++) { IDependencyNode *pNode = mChildren[iInst]; if (pNode->Type() != eDNT_ScriptInstance) continue; CScriptInstanceDependency *pInst = static_cast(pNode); - u32 ObjType = pInst->ObjectType(); + uint32 ObjType = pInst->ObjectType(); if (UsedObjectTypes.find(ObjType) == UsedObjectTypes.end()) { @@ -390,12 +390,12 @@ void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector CScriptTemplate *pTemplate = pGame->TemplateByID(ObjType); const std::vector& rkModules = pTemplate->RequiredModules(); - for (u32 iMod = 0; iMod < rkModules.size(); iMod++) + for (uint32 iMod = 0; iMod < rkModules.size(); iMod++) { TString ModuleName = rkModules[iMod]; bool NewModule = true; - for (u32 iUsed = ModuleStartIdx; iUsed < rModuleDepsOut.size(); iUsed++) + for (uint32 iUsed = ModuleStartIdx; iUsed < rModuleDepsOut.size(); iUsed++) { if (rModuleDepsOut[iUsed] == ModuleName) { diff --git a/src/Core/GameProject/CDependencyTree.h b/src/Core/GameProject/CDependencyTree.h index bbab2248..12469298 100644 --- a/src/Core/GameProject/CDependencyTree.h +++ b/src/Core/GameProject/CDependencyTree.h @@ -2,9 +2,9 @@ #define CDEPENDENCYTREE #include "CResourceEntry.h" -#include #include #include +#include class CScriptLayer; class CScriptObject; @@ -44,8 +44,8 @@ public: static IDependencyNode* ArchiveConstructor(EDependencyNodeType Type); // Accessors - inline u32 NumChildren() const { return mChildren.size(); } - inline IDependencyNode* ChildByIndex(u32 Index) const { return mChildren[Index]; } + inline uint NumChildren() const { return mChildren.size(); } + inline IDependencyNode* ChildByIndex(uint Index) const { return mChildren[Index]; } }; // Basic dependency tree; this class is sufficient for most resource types. @@ -109,7 +109,7 @@ public: class CCharPropertyDependency : public CPropertyDependency { protected: - u32 mUsedChar; + int mUsedChar; public: CCharPropertyDependency() @@ -117,7 +117,7 @@ public: , mUsedChar(-1) {} - CCharPropertyDependency(const TString& rkPropID, const CAssetID& rkAssetID, u32 UsedChar) + CCharPropertyDependency(const TString& rkPropID, const CAssetID& rkAssetID, int UsedChar) : CPropertyDependency(rkPropID, rkAssetID) , mUsedChar(UsedChar) {} @@ -126,21 +126,21 @@ public: virtual void Serialize(IArchive& rArc); // Accessors - inline u32 UsedChar() const { return mUsedChar; } + inline int UsedChar() const { return mUsedChar; } }; // Node representing a script object. Indicates the type of object. class CScriptInstanceDependency : public IDependencyNode { protected: - u32 mObjectType; + uint mObjectType; public: virtual EDependencyNodeType Type() const; virtual void Serialize(IArchive& rArc); // Accessors - inline u32 ObjectType() const { return mObjectType; } + inline uint ObjectType() const { return mObjectType; } // Static static CScriptInstanceDependency* BuildTree(CScriptObject *pInstance); @@ -152,17 +152,17 @@ protected: class CSetCharacterDependency : public CDependencyTree { protected: - u32 mCharSetIndex; + uint32 mCharSetIndex; public: CSetCharacterDependency() : CDependencyTree() {} - CSetCharacterDependency(u32 SetIndex) : CDependencyTree(), mCharSetIndex(SetIndex) {} + CSetCharacterDependency(uint32 SetIndex) : CDependencyTree(), mCharSetIndex(SetIndex) {} virtual EDependencyNodeType Type() const; virtual void Serialize(IArchive& rArc); // Accessors - inline u32 CharSetIndex() const { return mCharSetIndex; } + inline uint32 CharSetIndex() const { return mCharSetIndex; } // Static static CSetCharacterDependency* BuildTree(const SSetCharacter& rkChar); @@ -172,7 +172,7 @@ public: class CSetAnimationDependency : public CDependencyTree { protected: - std::set mCharacterIndices; + std::set mCharacterIndices; public: CSetAnimationDependency() : CDependencyTree() {} @@ -181,36 +181,36 @@ public: virtual void Serialize(IArchive& rArc); // Accessors - inline bool IsUsedByCharacter(u32 CharIdx) const { return mCharacterIndices.find(CharIdx) != mCharacterIndices.end(); } + inline bool IsUsedByCharacter(uint32 CharIdx) const { return mCharacterIndices.find(CharIdx) != mCharacterIndices.end(); } inline bool IsUsedByAnyCharacter() const { return !mCharacterIndices.empty(); } // Static - static CSetAnimationDependency* BuildTree(const CAnimSet *pkOwnerSet, u32 AnimIndex); + static CSetAnimationDependency* BuildTree(const CAnimSet *pkOwnerSet, uint32 AnimIndex); }; // Node representing an animation event. Indicates which character index uses this event. class CAnimEventDependency : public CResourceDependency { protected: - u32 mCharIndex; + uint32 mCharIndex; public: CAnimEventDependency() : CResourceDependency() {} - CAnimEventDependency(const CAssetID& rkID, u32 CharIndex) + CAnimEventDependency(const CAssetID& rkID, uint32 CharIndex) : CResourceDependency(rkID), mCharIndex(CharIndex) {} virtual EDependencyNodeType Type() const; virtual void Serialize(IArchive& rArc); // Accessors - inline u32 CharIndex() const { return mCharIndex; } + inline uint32 CharIndex() const { return mCharIndex; } }; // Node representing an area. Tracks dependencies on a per-instance basis and can separate dependencies of different script layers. class CAreaDependencyTree : public CDependencyTree { protected: - std::vector mLayerOffsets; + std::vector mLayerOffsets; public: CAreaDependencyTree() : CDependencyTree() {} @@ -219,11 +219,11 @@ public: virtual void Serialize(IArchive& rArc); void AddScriptLayer(CScriptLayer *pLayer, const std::vector& rkExtraDeps); - void GetModuleDependencies(EGame Game, std::vector& rModuleDepsOut, std::vector& rModuleLayerOffsetsOut) const; + void GetModuleDependencies(EGame Game, std::vector& rModuleDepsOut, std::vector& rModuleLayerOffsetsOut) const; // Accessors - inline u32 NumScriptLayers() const { return mLayerOffsets.size(); } - inline u32 ScriptLayerOffset(u32 LayerIdx) const { return mLayerOffsets[LayerIdx]; } + inline uint32 NumScriptLayers() const { return mLayerOffsets.size(); } + inline uint32 ScriptLayerOffset(uint32 LayerIdx) const { return mLayerOffsets[LayerIdx]; } }; #endif // CDEPENDENCYTREE diff --git a/src/Core/GameProject/CGameExporter.cpp b/src/Core/GameProject/CGameExporter.cpp index a03d13c0..81479ffd 100644 --- a/src/Core/GameProject/CGameExporter.cpp +++ b/src/Core/GameProject/CGameExporter.cpp @@ -5,7 +5,7 @@ #include "Core/CompressionUtil.h" #include "Core/Resource/CWorld.h" #include "Core/Resource/Script/CGameTemplate.h" -#include +#include #include #include #include @@ -92,7 +92,7 @@ bool CGameExporter::Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAs return !mpProgress->ShouldCancel(); } -void CGameExporter::LoadResource(const CAssetID& rkID, std::vector& rBuffer) +void CGameExporter::LoadResource(const CAssetID& rkID, std::vector& rBuffer) { SResourceInstance *pInst = FindResourceInstance(rkID); if (pInst) LoadResource(*pInst, rBuffer); @@ -268,7 +268,7 @@ void CGameExporter::LoadPaks() if (!Pak.IsValid()) { - Log::Error("Couldn't open pak: " + PakPath); + errorf("Couldn't open pak: %s", *PakPath); continue; } @@ -278,38 +278,38 @@ void CGameExporter::LoadPaks() // MP1-MP3Proto if (mGame < EGame::Corruption) { - u32 PakVersion = Pak.ReadLong(); + uint32 PakVersion = Pak.ReadLong(); Pak.Seek(0x4, SEEK_CUR); ASSERT(PakVersion == 0x00030005); // Echoes demo disc has a pak that ends right here. if (!Pak.EoF()) { - u32 NumNamedResources = Pak.ReadLong(); + uint32 NumNamedResources = Pak.ReadLong(); ASSERT(NumNamedResources > 0); - for (u32 iName = 0; iName < NumNamedResources; iName++) + for (uint32 iName = 0; iName < NumNamedResources; iName++) { CFourCC ResType = Pak.ReadLong(); CAssetID ResID(Pak, mGame); - u32 NameLen = Pak.ReadLong(); + uint32 NameLen = Pak.ReadLong(); TString Name = Pak.ReadString(NameLen); pPackage->AddResource(Name, ResID, ResType); } - u32 NumResources = Pak.ReadLong(); + uint32 NumResources = Pak.ReadLong(); // Keep track of which areas have duplicate resources std::set PakResourceSet; bool AreaHasDuplicates = true; // Default to true so that first area is always considered as having duplicates - for (u32 iRes = 0; iRes < NumResources; iRes++) + for (uint32 iRes = 0; iRes < NumResources; iRes++) { bool Compressed = (Pak.ReadLong() == 1); CFourCC ResType = Pak.ReadLong(); CAssetID ResID(Pak, mGame); - u32 ResSize = Pak.ReadLong(); - u32 ResOffset = Pak.ReadLong(); + uint32 ResSize = Pak.ReadLong(); + uint32 ResOffset = Pak.ReadLong(); if (mResourceMap.find(ResID) == mResourceMap.end()) mResourceMap[ResID] = SResourceInstance { PakPath, ResID, ResType, ResOffset, ResSize, Compressed, false }; @@ -333,37 +333,37 @@ void CGameExporter::LoadPaks() // MP3 + DKCR else { - u32 PakVersion = Pak.ReadLong(); - u32 PakHeaderLen = Pak.ReadLong(); + uint32 PakVersion = Pak.ReadLong(); + uint32 PakHeaderLen = Pak.ReadLong(); Pak.Seek(PakHeaderLen - 0x8, SEEK_CUR); ASSERT(PakVersion == 2); struct SPakSection { - CFourCC Type; u32 Size; + CFourCC Type; uint32 Size; }; std::vector PakSections; - u32 NumPakSections = Pak.ReadLong(); + uint32 NumPakSections = Pak.ReadLong(); ASSERT(NumPakSections == 3); - for (u32 iSec = 0; iSec < NumPakSections; iSec++) + for (uint32 iSec = 0; iSec < NumPakSections; iSec++) { CFourCC Type = Pak.ReadLong(); - u32 Size = Pak.ReadLong(); + uint32 Size = Pak.ReadLong(); PakSections.push_back(SPakSection { Type, Size }); } Pak.SeekToBoundary(64); - for (u32 iSec = 0; iSec < NumPakSections; iSec++) + for (uint32 iSec = 0; iSec < NumPakSections; iSec++) { - u32 Next = Pak.Tell() + PakSections[iSec].Size; + uint32 Next = Pak.Tell() + PakSections[iSec].Size; // Named Resources if (PakSections[iSec].Type == "STRG") { - u32 NumNamedResources = Pak.ReadLong(); + uint32 NumNamedResources = Pak.ReadLong(); - for (u32 iName = 0; iName < NumNamedResources; iName++) + for (uint32 iName = 0; iName < NumNamedResources; iName++) { TString Name = Pak.ReadString(); CFourCC ResType = Pak.ReadLong(); @@ -375,20 +375,20 @@ void CGameExporter::LoadPaks() else if (PakSections[iSec].Type == "RSHD") { ASSERT(PakSections[iSec + 1].Type == "DATA"); - u32 DataStart = Next; - u32 NumResources = Pak.ReadLong(); + uint32 DataStart = Next; + uint32 NumResources = Pak.ReadLong(); // Keep track of which areas have duplicate resources std::set PakResourceSet; bool AreaHasDuplicates = true; // Default to true so that first area is always considered as having duplicates - for (u32 iRes = 0; iRes < NumResources; iRes++) + for (uint32 iRes = 0; iRes < NumResources; iRes++) { bool Compressed = (Pak.ReadLong() == 1); CFourCC Type = Pak.ReadLong(); CAssetID ResID(Pak, mGame); - u32 Size = Pak.ReadLong(); - u32 Offset = DataStart + Pak.ReadLong(); + uint32 Size = Pak.ReadLong(); + uint32 Offset = DataStart + Pak.ReadLong(); if (mResourceMap.find(ResID) == mResourceMap.end()) mResourceMap[ResID] = SResourceInstance { PakPath, ResID, Type, Offset, Size, Compressed, false }; @@ -425,7 +425,7 @@ void CGameExporter::LoadPaks() #endif } -void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vector& rBuffer) +void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vector& rBuffer) { CFileInStream Pak(rkResource.PakFile, IOUtil::eBigEndian); @@ -440,15 +440,15 @@ void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vecto if (mGame <= EGame::CorruptionProto) { - std::vector CompressedData(rkResource.PakSize); + std::vector CompressedData(rkResource.PakSize); - u32 UncompressedSize = Pak.ReadLong(); + uint32 UncompressedSize = Pak.ReadLong(); rBuffer.resize(UncompressedSize); Pak.ReadBytes(CompressedData.data(), CompressedData.size()); if (ZlibCompressed) { - u32 TotalOut; + uint32 TotalOut; CompressionUtil::DecompressZlib(CompressedData.data(), CompressedData.size(), rBuffer.data(), rBuffer.size(), TotalOut); } else @@ -462,40 +462,40 @@ void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vecto CFourCC Magic = Pak.ReadLong(); ASSERT(Magic == "CMPD"); - u32 NumBlocks = Pak.ReadLong(); + uint32 NumBlocks = Pak.ReadLong(); struct SCompressedBlock { - u32 CompressedSize; u32 UncompressedSize; + uint32 CompressedSize; uint32 UncompressedSize; }; std::vector CompressedBlocks; - u32 TotalUncompressedSize = 0; - for (u32 iBlock = 0; iBlock < NumBlocks; iBlock++) + uint32 TotalUncompressedSize = 0; + for (uint32 iBlock = 0; iBlock < NumBlocks; iBlock++) { - u32 CompressedSize = (Pak.ReadLong() & 0x00FFFFFF); - u32 UncompressedSize = Pak.ReadLong(); + uint32 CompressedSize = (Pak.ReadLong() & 0x00FFFFFF); + uint32 UncompressedSize = Pak.ReadLong(); TotalUncompressedSize += UncompressedSize; CompressedBlocks.push_back( SCompressedBlock { CompressedSize, UncompressedSize } ); } rBuffer.resize(TotalUncompressedSize); - u32 Offset = 0; + uint32 Offset = 0; - for (u32 iBlock = 0; iBlock < NumBlocks; iBlock++) + for (uint32 iBlock = 0; iBlock < NumBlocks; iBlock++) { - u32 CompressedSize = CompressedBlocks[iBlock].CompressedSize; - u32 UncompressedSize = CompressedBlocks[iBlock].UncompressedSize; + uint32 CompressedSize = CompressedBlocks[iBlock].CompressedSize; + uint32 UncompressedSize = CompressedBlocks[iBlock].UncompressedSize; // Block is compressed if (CompressedSize != UncompressedSize) { - std::vector CompressedData(CompressedBlocks[iBlock].CompressedSize); + std::vector CompressedData(CompressedBlocks[iBlock].CompressedSize); Pak.ReadBytes(CompressedData.data(), CompressedData.size()); if (ZlibCompressed) { - u32 TotalOut; + uint32 TotalOut; CompressionUtil::DecompressZlib(CompressedData.data(), CompressedData.size(), rBuffer.data() + Offset, UncompressedSize, TotalOut); } else @@ -570,7 +570,7 @@ void CGameExporter::ExportResourceEditorData() CWorld *pWorld = (CWorld*) It->Load(); // Set area duplicate flags - for (u32 iArea = 0; iArea < pWorld->NumAreas(); iArea++) + for (uint32 iArea = 0; iArea < pWorld->NumAreas(); iArea++) { CAssetID AreaID = pWorld->AreaResourceID(iArea); auto Find = mAreaDuplicateMap.find(AreaID); @@ -612,7 +612,7 @@ void CGameExporter::ExportResource(SResourceInstance& rRes) { if (!rRes.Exported) { - std::vector ResourceData; + std::vector ResourceData; LoadResource(rRes, ResourceData); // Register resource and write to file @@ -657,11 +657,11 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID) // Find the original world name in the package resource names TString WorldName; - for (u32 iPkg = 0; iPkg < mpProject->NumPackages(); iPkg++) + for (uint32 iPkg = 0; iPkg < mpProject->NumPackages(); iPkg++) { CPackage *pPkg = mpProject->PackageByIndex(iPkg); - for (u32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++) + for (uint32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++) { const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes); @@ -712,8 +712,8 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID) // MP2 demo - Use text between the first and second underscores else if (mGame == EGame::EchoesDemo) { - u32 UnderscoreA = WorldName.IndexOf('_'); - u32 UnderscoreB = WorldName.IndexOf('_', UnderscoreA + 1); + uint32 UnderscoreA = WorldName.IndexOf('_'); + uint32 UnderscoreB = WorldName.IndexOf('_', UnderscoreA + 1); if (UnderscoreA != UnderscoreB && UnderscoreA != -1 && UnderscoreB != -1) WorldName = WorldName.SubString(UnderscoreA + 1, UnderscoreB - UnderscoreA - 1); @@ -722,8 +722,8 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID) // MP2 - Remove text before first underscore and after last underscore, strip remaining underscores (except multiplayer maps, which have one underscore) else if (mGame == EGame::Echoes) { - u32 FirstUnderscore = WorldName.IndexOf('_'); - u32 LastUnderscore = WorldName.LastIndexOf('_'); + uint32 FirstUnderscore = WorldName.IndexOf('_'); + uint32 LastUnderscore = WorldName.LastIndexOf('_'); if (FirstUnderscore != LastUnderscore && FirstUnderscore != -1 && LastUnderscore != -1) { @@ -739,14 +739,14 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID) if (WorldName.StartsWith('!')) WorldName = WorldName.ChopFront(1); - u32 LastUnderscore = WorldName.LastIndexOf('_'); + uint32 LastUnderscore = WorldName.LastIndexOf('_'); WorldName = WorldName.ChopBack(WorldName.Size() - LastUnderscore); } // MP3 - Remove text after last underscore else if (mGame == EGame::Corruption) { - u32 LastUnderscore = WorldName.LastIndexOf('_'); + uint32 LastUnderscore = WorldName.LastIndexOf('_'); if (LastUnderscore != -1 && !WorldName.StartsWith("front_end_")) WorldName = WorldName.ChopBack(WorldName.Size() - LastUnderscore); @@ -755,7 +755,7 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID) // DKCR - Remove text prior to first underscore else if (mGame == EGame::DKCReturns) { - u32 Underscore = WorldName.IndexOf('_'); + uint32 Underscore = WorldName.IndexOf('_'); WorldName = WorldName.ChopFront(Underscore + 1); } } diff --git a/src/Core/GameProject/CGameExporter.h b/src/Core/GameProject/CGameExporter.h index ea1727f0..40462f0f 100644 --- a/src/Core/GameProject/CGameExporter.h +++ b/src/Core/GameProject/CGameExporter.h @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -54,8 +53,8 @@ class CGameExporter TString PakFile; CAssetID ResourceID; CFourCC ResourceType; - u32 PakOffset; - u32 PakSize; + uint32 PakOffset; + uint32 PakSize; bool Compressed; bool Exported; }; @@ -76,7 +75,7 @@ class CGameExporter public: CGameExporter(EDiscType DiscType, EGame Game, bool FrontEnd, ERegion Region, const TString& rkGameName, const TString& rkGameID, float BuildVersion); bool Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAssetNameMap *pNameMap, CGameInfo *pGameInfo, IProgressNotifier *pProgress); - void LoadResource(const CAssetID& rkID, std::vector& rBuffer); + void LoadResource(const CAssetID& rkID, std::vector& rBuffer); bool ShouldExportDiscNode(const nod::Node *pkNode, bool IsInRoot); inline TString ProjectPath() const { return mProjectPath; } @@ -85,7 +84,7 @@ protected: bool ExtractDiscData(); bool ExtractDiscNodeRecursive(const nod::Node *pkNode, const TString& rkDir, bool RootNode, const nod::ExtractionContext& rkContext); void LoadPaks(); - void LoadResource(const SResourceInstance& rkResource, std::vector& rBuffer); + void LoadResource(const SResourceInstance& rkResource, std::vector& rBuffer); void ExportCookedResources(); void ExportResourceEditorData(); void ExportResource(SResourceInstance& rRes); @@ -94,7 +93,7 @@ protected: // Convenience Functions inline SResourceInstance* FindResourceInstance(const CAssetID& rkID) { - u64 IntegralID = rkID.ToLongLong(); + uint64 IntegralID = rkID.ToLongLong(); auto Found = mResourceMap.find(IntegralID); return (Found == mResourceMap.end() ? nullptr : &Found->second); } diff --git a/src/Core/GameProject/CGameInfo.cpp b/src/Core/GameProject/CGameInfo.cpp index 940eb541..651d7270 100644 --- a/src/Core/GameProject/CGameInfo.cpp +++ b/src/Core/GameProject/CGameInfo.cpp @@ -49,7 +49,7 @@ void CGameInfo::Serialize(IArchive& rArc) TString CGameInfo::GetBuildName(float BuildVer, ERegion Region) const { - for (u32 iBuild = 0; iBuild < mBuilds.size(); iBuild++) + for (uint32 iBuild = 0; iBuild < mBuilds.size(); iBuild++) { const SBuildInfo& rkBuildInfo = mBuilds[iBuild]; diff --git a/src/Core/GameProject/CGameInfo.h b/src/Core/GameProject/CGameInfo.h index 096862b3..2be177f4 100644 --- a/src/Core/GameProject/CGameInfo.h +++ b/src/Core/GameProject/CGameInfo.h @@ -1,7 +1,7 @@ #ifndef CGAMEINFO #define CGAMEINFO -#include +#include #include #include #include diff --git a/src/Core/GameProject/CGameProject.cpp b/src/Core/GameProject/CGameProject.cpp index ca54a52b..83abf73e 100644 --- a/src/Core/GameProject/CGameProject.cpp +++ b/src/Core/GameProject/CGameProject.cpp @@ -14,7 +14,7 @@ CGameProject::~CGameProject() gpResourceStore = nullptr; } - for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++) + for (uint32 iPkg = 0; iPkg < mPackages.size(); iPkg++) delete mPackages[iPkg]; delete mpAudioManager; @@ -45,7 +45,7 @@ bool CGameProject::Serialize(IArchive& rArc) if (!rArc.IsReader()) { - for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++) + for (uint32 iPkg = 0; iPkg < mPackages.size(); iPkg++) PackageList.push_back( mPackages[iPkg]->DefinitionPath(true) ); } @@ -56,7 +56,7 @@ bool CGameProject::Serialize(IArchive& rArc) { ASSERT(mPackages.empty()); - for (u32 iPkg = 0; iPkg < PackageList.size(); iPkg++) + for (uint32 iPkg = 0; iPkg < PackageList.size(); iPkg++) { const TString& rkPackagePath = PackageList[iPkg]; TString PackageName = rkPackagePath.GetFileName(false); @@ -122,7 +122,7 @@ bool CGameProject::MergeISO(const TString& rkIsoPath, nod::DiscWii *pOriginalIso void CGameProject::GetWorldList(std::list& rOut) const { - for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++) + for (uint32 iPkg = 0; iPkg < mPackages.size(); iPkg++) { CPackage *pPkg = mPackages[iPkg]; @@ -130,7 +130,7 @@ void CGameProject::GetWorldList(std::list& rOut) const // Construct a sorted list of worlds in this package std::list PackageWorlds; - for (u32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++) + for (uint32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++) { const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes); @@ -153,11 +153,11 @@ void CGameProject::GetWorldList(std::list& rOut) const CAssetID CGameProject::FindNamedResource(const TString& rkName) const { - for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++) + for (uint32 iPkg = 0; iPkg < mPackages.size(); iPkg++) { CPackage *pPkg = mPackages[iPkg]; - for (u32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++) + for (uint32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++) { const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes); @@ -171,7 +171,7 @@ CAssetID CGameProject::FindNamedResource(const TString& rkName) const CPackage* CGameProject::FindPackage(const TString& rkName) const { - for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++) + for (uint32 iPkg = 0; iPkg < mPackages.size(); iPkg++) { CPackage *pPackage = mPackages[iPkg]; diff --git a/src/Core/GameProject/CGameProject.h b/src/Core/GameProject/CGameProject.h index 6ea5001f..2d9dfa51 100644 --- a/src/Core/GameProject/CGameProject.h +++ b/src/Core/GameProject/CGameProject.h @@ -11,7 +11,6 @@ #include #include #include -#include #include namespace nod { class DiscWii; } @@ -92,8 +91,8 @@ public: inline void SetProjectName(const TString& rkName) { mProjectName = rkName; } inline TString Name() const { return mProjectName; } - inline u32 NumPackages() const { return mPackages.size(); } - inline CPackage* PackageByIndex(u32 Index) const { return mPackages[Index]; } + inline uint32 NumPackages() const { return mPackages.size(); } + inline CPackage* PackageByIndex(uint32 Index) const { return mPackages[Index]; } inline void AddPackage(CPackage *pPackage) { mPackages.push_back(pPackage); } inline CResourceStore* ResourceStore() const { return mpResourceStore; } inline CGameInfo* GameInfo() const { return mpGameInfo; } diff --git a/src/Core/GameProject/COpeningBanner.cpp b/src/Core/GameProject/COpeningBanner.cpp index fca194a4..9886ca4a 100644 --- a/src/Core/GameProject/COpeningBanner.cpp +++ b/src/Core/GameProject/COpeningBanner.cpp @@ -22,10 +22,10 @@ TString COpeningBanner::EnglishGameName() const // this and prevent the string-reading function from overrunning the buffer CMemoryInStream Banner(mBannerData.data(), mBannerData.size(), IOUtil::eBigEndian); - u32 CharSize = mWii ? 2 : 1; - u32 MaxLen = MaxGameNameLength(); + uint32 CharSize = mWii ? 2 : 1; + uint32 MaxLen = MaxGameNameLength(); - std::vector NameBuffer((MaxLen + 1) * CharSize, 0); + std::vector NameBuffer((MaxLen + 1) * CharSize, 0); Banner.GoTo( mWii ? 0xB0 : 0x1860 ); Banner.ReadBytes(NameBuffer.data(), MaxLen * CharSize); @@ -36,9 +36,9 @@ TString COpeningBanner::EnglishGameName() const void COpeningBanner::SetEnglishGameName(const TString& rkName) { CMemoryOutStream Banner(mBannerData.data(), mBannerData.size(), IOUtil::eBigEndian); - u32 PadCount = 0; + uint32 PadCount = 0; - u32 MaxLen = MaxGameNameLength(); + uint32 MaxLen = MaxGameNameLength(); ASSERT(rkName.Size() <= MaxLen); if (mWii) @@ -54,7 +54,7 @@ void COpeningBanner::SetEnglishGameName(const TString& rkName) PadCount = MaxLen - rkName.Size(); } - for (u32 Pad = 0; Pad < PadCount; Pad++) + for (uint32 Pad = 0; Pad < PadCount; Pad++) Banner.WriteByte(0); } @@ -65,7 +65,7 @@ void COpeningBanner::Save() Banner.WriteBytes(mBannerData.data(), mBannerData.size()); } -u32 COpeningBanner::MaxGameNameLength() const +uint32 COpeningBanner::MaxGameNameLength() const { return (mWii ? 21 : 64); } diff --git a/src/Core/GameProject/COpeningBanner.h b/src/Core/GameProject/COpeningBanner.h index 6f5fe0e2..f5745739 100644 --- a/src/Core/GameProject/COpeningBanner.h +++ b/src/Core/GameProject/COpeningBanner.h @@ -9,7 +9,7 @@ class CGameProject; class COpeningBanner { CGameProject *mpProj; - std::vector mBannerData; + std::vector mBannerData; bool mWii; public: @@ -18,7 +18,7 @@ public: void SetEnglishGameName(const TString& rkName); void Save(); - u32 MaxGameNameLength() const; + uint32 MaxGameNameLength() const; }; #endif // COPENINGBANNER_H diff --git a/src/Core/GameProject/CPackage.cpp b/src/Core/GameProject/CPackage.cpp index d8a0f8ca..07669de7 100644 --- a/src/Core/GameProject/CPackage.cpp +++ b/src/Core/GameProject/CPackage.cpp @@ -3,7 +3,7 @@ #include "CGameProject.h" #include "Core/CompressionUtil.h" #include "Core/Resource/Cooker/CWorldCooker.h" -#include +#include #include #include #include @@ -69,7 +69,7 @@ void CPackage::Cook(IProgressNotifier *pProgress) CPackageDependencyListBuilder Builder(this); std::list AssetList; Builder.BuildDependencyList(true, AssetList); - Log::Write(TString::FromInt32(AssetList.size(), 0, 10) + " assets in " + Name() + ".pak"); + debugf("%d assets in %s.pak", AssetList.size(), *Name()); // Write new pak TString PakPath = CookedPackagePath(false); @@ -77,19 +77,19 @@ void CPackage::Cook(IProgressNotifier *pProgress) if (!Pak.IsValid()) { - Log::Error("Couldn't cook package " + CookedPackagePath(true) + "; unable to open package for writing"); + errorf("Couldn't cook package %s; unable to open package for writing", *CookedPackagePath(true)); return; } EGame Game = mpProject->Game(); - u32 Alignment = (Game <= EGame::CorruptionProto ? 0x20 : 0x40); - u32 AlignmentMinusOne = Alignment - 1; + uint32 Alignment = (Game <= EGame::CorruptionProto ? 0x20 : 0x40); + uint32 AlignmentMinusOne = Alignment - 1; - u32 TocOffset = 0; - u32 NamesSize = 0; - u32 ResTableOffset = 0; - u32 ResTableSize = 0; - u32 ResDataSize = 0; + uint32 TocOffset = 0; + uint32 NamesSize = 0; + uint32 ResTableOffset = 0; + uint32 ResTableSize = 0; + uint32 ResDataSize = 0; // Write MP1 pak header if (Game <= EGame::CorruptionProto) @@ -123,7 +123,7 @@ void CPackage::Cook(IProgressNotifier *pProgress) Pak.WriteToBoundary(0x40, 0); // Named Resources - u32 NamesStart = Pak.Tell(); + uint32 NamesStart = Pak.Tell(); Pak.WriteLong(mResources.size()); for (auto Iter = mResources.begin(); Iter != mResources.end(); Iter++) @@ -143,7 +143,7 @@ void CPackage::Cook(IProgressNotifier *pProgress) Pak.WriteLong(AssetList.size()); CAssetID Dummy = CAssetID::InvalidID(Game); - for (u32 iRes = 0; iRes < AssetList.size(); iRes++) + for (uint32 iRes = 0; iRes < AssetList.size(); iRes++) { Pak.WriteLongLong(0); Dummy.Write(Pak); @@ -157,18 +157,18 @@ void CPackage::Cook(IProgressNotifier *pProgress) struct SResourceTableInfo { CResourceEntry *pEntry; - u32 Offset; - u32 Size; + uint32 Offset; + uint32 Size; bool Compressed; }; std::vector ResourceTableData(AssetList.size()); - u32 ResIdx = 0; - u32 ResDataOffset = Pak.Tell(); + uint32 ResIdx = 0; + uint32 ResDataOffset = Pak.Tell(); for (auto Iter = AssetList.begin(); Iter != AssetList.end() && !pProgress->ShouldCancel(); Iter++, ResIdx++) { // Initialize entry, recook assets if needed - u32 AssetOffset = Pak.Tell(); + uint32 AssetOffset = Pak.Tell(); CAssetID ID = *Iter; CResourceEntry *pEntry = gpResourceStore->FindEntry(ID); ASSERT(pEntry != nullptr); @@ -193,15 +193,15 @@ void CPackage::Cook(IProgressNotifier *pProgress) // Load resource data CFileInStream CookedAsset(pEntry->CookedAssetPath(), IOUtil::eBigEndian); ASSERT(CookedAsset.IsValid()); - u32 ResourceSize = CookedAsset.Size(); + uint32 ResourceSize = CookedAsset.Size(); - std::vector ResourceData(ResourceSize); + std::vector ResourceData(ResourceSize); CookedAsset.ReadBytes(ResourceData.data(), ResourceData.size()); // Check if this asset should be compressed; there are a few resource types that are // always compressed, and some types that are compressed if they're over a certain size EResType Type = pEntry->ResourceType(); - u32 CompressThreshold = (Game <= EGame::CorruptionProto ? 0x400 : 0x80); + uint32 CompressThreshold = (Game <= EGame::CorruptionProto ? 0x400 : 0x80); bool ShouldAlwaysCompress = (Type == eTexture || Type == eModel || Type == eSkin || Type == eAnimSet || Type == eAnimation || Type == eFont); @@ -230,8 +230,8 @@ void CPackage::Cook(IProgressNotifier *pProgress) else { - u32 CompressedSize; - std::vector CompressedData(ResourceData.size() * 2); + uint32 CompressedSize; + std::vector CompressedData(ResourceData.size() * 2); bool Success = false; if (Game <= EGame::EchoesDemo || Game == EGame::DKCReturns) @@ -242,9 +242,9 @@ void CPackage::Cook(IProgressNotifier *pProgress) // Make sure that the compressed data is actually smaller, accounting for padding + uncompressed size value if (Success) { - u32 CompressionHeaderSize = (Game <= EGame::CorruptionProto ? 4 : 0x10); - u32 PaddedUncompressedSize = (ResourceSize + AlignmentMinusOne) & ~AlignmentMinusOne; - u32 PaddedCompressedSize = (CompressedSize + CompressionHeaderSize + AlignmentMinusOne) & ~AlignmentMinusOne; + uint32 CompressionHeaderSize = (Game <= EGame::CorruptionProto ? 4 : 0x10); + uint32 PaddedUncompressedSize = (ResourceSize + AlignmentMinusOne) & ~AlignmentMinusOne; + uint32 PaddedCompressedSize = (CompressedSize + CompressionHeaderSize + AlignmentMinusOne) & ~AlignmentMinusOne; Success = (PaddedCompressedSize < PaddedUncompressedSize); } @@ -307,7 +307,7 @@ void CPackage::Cook(IProgressNotifier *pProgress) // Write resource table for real Pak.Seek(ResTableOffset+4, SEEK_SET); - for (u32 iRes = 0; iRes < AssetList.size(); iRes++) + for (uint32 iRes = 0; iRes < AssetList.size(); iRes++) { const SResourceTableInfo& rkInfo = ResourceTableData[iRes]; CResourceEntry *pEntry = rkInfo.pEntry; @@ -321,7 +321,7 @@ void CPackage::Cook(IProgressNotifier *pProgress) // Clear recook flag mNeedsRecook = false; - Log::Write("Finished writing " + PakPath); + debugf("Finished writing %s", *PakPath); } Save(); @@ -346,31 +346,31 @@ void CPackage::CompareOriginalAssetList(const std::list& rkNewList) if (!Pak.IsValid() || Pak.Size() == 0) { - Log::Error("Failed to compare to original asset list; couldn't open the original pak"); + errorf("Failed to compare to original asset list; couldn't open the original pak"); return; } // Determine pak version - u32 PakVersion = Pak.ReadLong(); + uint32 PakVersion = Pak.ReadLong(); std::set OldListSet; // Read MP1/2 pak if (PakVersion == 0x00030005) { Pak.Seek(0x4, SEEK_CUR); - u32 NumNamedResources = Pak.ReadLong(); + uint32 NumNamedResources = Pak.ReadLong(); - for (u32 iName = 0; iName < NumNamedResources; iName++) + for (uint32 iName = 0; iName < NumNamedResources; iName++) { Pak.Seek(0x8, SEEK_CUR); - u32 NameLen = Pak.ReadLong(); + uint32 NameLen = Pak.ReadLong(); Pak.Seek(NameLen, SEEK_CUR); } // Build a set out of the original pak resource list - u32 NumResources = Pak.ReadLong(); + uint32 NumResources = Pak.ReadLong(); - for (u32 iRes = 0; iRes < NumResources; iRes++) + for (uint32 iRes = 0; iRes < NumResources; iRes++) { Pak.Seek(0x8, SEEK_CUR); OldListSet.insert( CAssetID(Pak, e32Bit) ); @@ -386,15 +386,15 @@ void CPackage::CompareOriginalAssetList(const std::list& rkNewList) // Skip named resources Pak.Seek(0x44, SEEK_SET); CFourCC StringSecType = Pak.ReadLong(); - u32 StringSecSize = Pak.ReadLong(); + uint32 StringSecSize = Pak.ReadLong(); ASSERT(StringSecType == "STRG"); Pak.Seek(0x80 + StringSecSize, SEEK_SET); // Read resource table - u32 NumResources = Pak.ReadLong(); + uint32 NumResources = Pak.ReadLong(); - for (u32 iRes = 0; iRes < NumResources; iRes++) + for (uint32 iRes = 0; iRes < NumResources; iRes++) { Pak.Seek(0x8, SEEK_CUR); OldListSet.insert( CAssetID(Pak, e64Bit) ); @@ -411,7 +411,7 @@ void CPackage::CompareOriginalAssetList(const std::list& rkNewList) { CResourceEntry *pEntry = gpResourceStore->FindEntry(ID); TString Extension = (pEntry ? "." + pEntry->CookedExtension() : ""); - Log::Error("Missing resource: " + ID.ToString() + Extension); + warnf("Missing resource: %s%s", *ID.ToString(), *Extension); } } @@ -424,7 +424,7 @@ void CPackage::CompareOriginalAssetList(const std::list& rkNewList) { CResourceEntry *pEntry = gpResourceStore->FindEntry(ID); TString Extension = (pEntry ? "." + pEntry->CookedExtension() : ""); - Log::Error("Extra resource: " + ID.ToString() + Extension); + warnf("Extra resource: %s%s", *ID.ToString(), *Extension); } } } diff --git a/src/Core/GameProject/CPackage.h b/src/Core/GameProject/CPackage.h index 20458f7a..2997cceb 100644 --- a/src/Core/GameProject/CPackage.h +++ b/src/Core/GameProject/CPackage.h @@ -71,8 +71,8 @@ public: inline TString Name() const { return mPakName; } inline TString Path() const { return mPakPath; } inline CGameProject* Project() const { return mpProject; } - inline u32 NumNamedResources() const { return mResources.size(); } - inline const SNamedResource& NamedResourceByIndex(u32 Idx) const { return mResources[Idx]; } + inline uint32 NumNamedResources() const { return mResources.size(); } + inline const SNamedResource& NamedResourceByIndex(uint32 Idx) const { return mResources[Idx]; } inline bool NeedsRecook() const { return mNeedsRecook; } inline void SetPakName(TString NewName) { mPakName = NewName; } diff --git a/src/Core/GameProject/CResourceEntry.cpp b/src/Core/GameProject/CResourceEntry.cpp index 9d643ae6..5a4f7fa7 100644 --- a/src/Core/GameProject/CResourceEntry.cpp +++ b/src/Core/GameProject/CResourceEntry.cpp @@ -96,7 +96,7 @@ bool CResourceEntry::LoadMetadata() } else { - Log::Error(Path + ": Failed to load metadata file!"); + errorf("%s: Failed to load metadata file!", *Path); } return false; @@ -174,7 +174,7 @@ void CResourceEntry::UpdateDependencies() if (!mpResource) { - Log::Error("Unable to update cached dependencies; failed to load resource"); + errorf("Unable to update cached dependencies; failed to load resource"); mpDependencies = new CDependencyTree(); return; } @@ -237,7 +237,7 @@ bool CResourceEntry::IsInDirectory(CVirtualDirectory *pDir) const return false; } -u64 CResourceEntry::Size() const +uint64 CResourceEntry::Size() const { if (mCachedSize == -1) { @@ -294,8 +294,7 @@ bool CResourceEntry::Save(bool SkipCacheSave /*= false*/) if (!Writer.Save()) { - Log::Error("Failed to save raw resource: " + Path); - DEBUG_BREAK; + errorf("Failed to save raw resource: %s", *Path); return false; } @@ -309,7 +308,7 @@ bool CResourceEntry::Save(bool SkipCacheSave /*= false*/) if (!CookSuccess) { - Log::Error("Failed to save resource: " + Name() + "." + CookedExtension().ToString()); + errorf("Failed to save resource: %s.%s", *Name(), *CookedExtension().ToString()); return false; } } @@ -324,7 +323,7 @@ bool CResourceEntry::Save(bool SkipCacheSave /*= false*/) mpStore->ConditionalSaveStore(); // Flag dirty any packages that contain this resource. - for (u32 iPkg = 0; iPkg < mpStore->Project()->NumPackages(); iPkg++) + for (uint32 iPkg = 0; iPkg < mpStore->Project()->NumPackages(); iPkg++) { CPackage *pPkg = mpStore->Project()->PackageByIndex(iPkg); @@ -352,7 +351,7 @@ bool CResourceEntry::Cook() CFileOutStream File(Path, IOUtil::eBigEndian); if (!File.IsValid()) { - Log::Error("Failed to open cooked file for writing: " + Path); + errorf("Failed to open cooked file for writing: %s", *Path); return false; } @@ -390,7 +389,7 @@ CResource* CResourceEntry::Load() if (!Reader.IsValid()) { - Log::Error("Failed to load raw resource; falling back on cooked. Raw path: " + RawAssetPath()); + errorf("Failed to load raw resource; falling back on cooked. Raw path: %s", *RawAssetPath()); delete mpResource; mpResource = nullptr; } @@ -414,7 +413,7 @@ CResource* CResourceEntry::Load() if (!File.IsValid()) { - Log::Error("Failed to open cooked resource: " + CookedAssetPath(true)); + errorf("Failed to open cooked resource: %s", *CookedAssetPath(true)); return nullptr; } @@ -423,7 +422,7 @@ CResource* CResourceEntry::Load() else { - Log::Error("Couldn't locate resource: " + CookedAssetPath(true)); + errorf("Couldn't locate resource: %s", *CookedAssetPath(true)); return nullptr; } } @@ -500,7 +499,10 @@ bool CResourceEntry::MoveAndRename(const TString& rkDir, const TString& rkName, TString NewRawPath = RawAssetPath(); TString NewMetaPath = MetadataFilePath(); - Log::Write("MOVING RESOURCE: " + FileUtil::MakeRelative(OldCookedPath, mpStore->ResourcesDir()) + " --> " + FileUtil::MakeRelative(NewCookedPath, mpStore->ResourcesDir())); + debugf("MOVING RESOURCE: %s --> %s", + *FileUtil::MakeRelative(OldCookedPath, mpStore->ResourcesDir()), + *FileUtil::MakeRelative(NewCookedPath, mpStore->ResourcesDir()) + ); // If the old/new paths are the same then we should have already exited as CanMoveTo() should have returned false ASSERT(OldCookedPath != NewCookedPath && OldRawPath != NewRawPath && OldMetaPath != NewMetaPath); @@ -586,7 +588,7 @@ bool CResourceEntry::MoveAndRename(const TString& rkDir, const TString& rkName, // Otherwise, revert changes and let the caller know the move failed else { - Log::Error("MOVE FAILED: " + MoveFailReason); + errorf("MOVE FAILED: %s", *MoveFailReason); mpDirectory = pOldDir; mName = OldName; mpStore->ConditionalDeleteDirectory(pNewDir, false); diff --git a/src/Core/GameProject/CResourceEntry.h b/src/Core/GameProject/CResourceEntry.h index da329df2..023ce8b9 100644 --- a/src/Core/GameProject/CResourceEntry.h +++ b/src/Core/GameProject/CResourceEntry.h @@ -8,7 +8,6 @@ #include #include #include -#include class CResource; class CGameProject; @@ -37,7 +36,7 @@ class CResourceEntry FResEntryFlags mFlags; mutable bool mMetadataDirty; - mutable u64 mCachedSize; + mutable uint64 mCachedSize; mutable TString mCachedUppercaseName; // This is used to speed up case-insensitive sorting and filtering. // Private constructor @@ -66,7 +65,7 @@ public: CFourCC CookedExtension() const; TString MetadataFilePath(bool Relative = false) const; bool IsInDirectory(CVirtualDirectory *pDir) const; - u64 Size() const; + uint64 Size() const; bool NeedsRecook() const; bool Save(bool SkipCacheSave = false); bool Cook(); diff --git a/src/Core/GameProject/CResourceStore.cpp b/src/Core/GameProject/CResourceStore.cpp index 28fd041d..726f8ff4 100644 --- a/src/Core/GameProject/CResourceStore.cpp +++ b/src/Core/GameProject/CResourceStore.cpp @@ -4,7 +4,7 @@ #include "CResourceIterator.h" #include "Core/IUIRelay.h" #include "Core/Resource/CResource.h" -#include +#include #include #include #include @@ -54,7 +54,7 @@ void RecursiveGetListOfEmptyDirectories(CVirtualDirectory *pDir, TStringList& rO } else { - for (u32 SubIdx = 0; SubIdx < pDir->NumSubdirectories(); SubIdx++) + for (uint32 SubIdx = 0; SubIdx < pDir->NumSubdirectories(); SubIdx++) RecursiveGetListOfEmptyDirectories(pDir->SubdirectoryByIndex(SubIdx), rOutList); } } @@ -65,12 +65,12 @@ bool CResourceStore::SerializeDatabaseCache(IArchive& rArc) if (rArc.ParamBegin("Resources", 0)) { // Serialize resources - u32 ResourceCount = mResourceEntries.size(); + uint32 ResourceCount = mResourceEntries.size(); rArc << SerialParameter("ResourceCount", ResourceCount); if (rArc.IsReader()) { - for (u32 ResIdx = 0; ResIdx < ResourceCount; ResIdx++) + for (uint32 ResIdx = 0; ResIdx < ResourceCount; ResIdx++) { if (rArc.ParamBegin("Resource", 0)) { @@ -195,12 +195,12 @@ void CResourceStore::CloseProject() // If there are, that means something didn't clean up resource references properly on project close!!! if (!mLoadedResources.empty()) { - Log::Error(TString::FromInt32(mLoadedResources.size(), 0, 10) + " resources still loaded on project close:"); + warnf("%d resources still loaded on project close:", mLoadedResources.size()); for (auto Iter = mLoadedResources.begin(); Iter != mLoadedResources.end(); Iter++) { CResourceEntry *pEntry = Iter->second; - Log::Write("\t" + pEntry->Name() + "." + pEntry->CookedExtension().ToString()); + warnf("\t%s.%s", *pEntry->Name(), *pEntry->CookedExtension().ToString()); } ASSERT(false); @@ -325,7 +325,7 @@ bool CResourceStore::BuildFromDirectory(bool ShouldGenerateCacheFile) if (!pTypeInfo) { - Log::Error("Found resource but couldn't register because failed to identify resource type: " + RelPath); + errorf("Found resource but couldn't register because failed to identify resource type: %s", *RelPath); continue; } @@ -389,7 +389,7 @@ CResourceEntry* CResourceStore::RegisterResource(const CAssetID& rkID, EResType CResourceEntry *pEntry = FindEntry(rkID); if (pEntry) - Log::Error("Attempted to register resource that's already tracked in the database: " + rkID.ToString() + " / " + rkDir + " / " + rkName); + errorf("Attempted to register resource that's already tracked in the database: %s / %s / %s", *rkID.ToString(), *rkDir, *rkName); else { @@ -401,7 +401,7 @@ CResourceEntry* CResourceStore::RegisterResource(const CAssetID& rkID, EResType } else - Log::Error("Invalid resource path, failed to register: " + rkDir + rkName); + errorf("Invalid resource path, failed to register: %s%s", *rkDir, *rkName); } return pEntry; @@ -419,7 +419,7 @@ CResource* CResourceStore::LoadResource(const CAssetID& rkID) else { // Resource doesn't seem to exist - Log::Error("Can't find requested resource with ID \"" + rkID.ToString() + "\".");; + warnf("Can't find requested resource with ID \"%s\"", *rkID.ToString()); return nullptr; } } @@ -440,7 +440,7 @@ CResource* CResourceStore::LoadResource(const CAssetID& rkID, EResType Type) CResTypeInfo *pGotType = pRes->TypeInfo(); ASSERT(pExpectedType && pGotType); - Log::Error("Resource with ID \"" + rkID.ToString() + "\" requested with the wrong type; expected " + pExpectedType->TypeName() + " asset, got " + pGotType->TypeName() + " asset"); + errorf("Resource with ID \"%s\" requested with the wrong type; expected %s asset, get %s asset", *rkID.ToString(), *pExpectedType->TypeName(), *pGotType->TypeName()); return nullptr; } } @@ -487,7 +487,7 @@ void CResourceStore::TrackLoadedResource(CResourceEntry *pEntry) void CResourceStore::DestroyUnreferencedResources() { // This can be updated to avoid the do-while loop when reference lookup is implemented. - u32 NumDeleted; + uint32 NumDeleted; do { @@ -546,7 +546,7 @@ void CResourceStore::ImportNamesFromPakContentsTxt(const TString& rkTxtPath, boo if (!pContentsFile) { - Log::Error("Failed to open .contents.txt file: " + rkTxtPath); + errorf("Failed to open .contents.txt file: %s", *rkTxtPath); return; } @@ -559,12 +559,12 @@ void CResourceStore::ImportNamesFromPakContentsTxt(const TString& rkTxtPath, boo TString Line(LineBuffer); if (Line.IsEmpty()) break; - u32 IDStart = Line.IndexOfPhrase("0x") + 2; + uint32 IDStart = Line.IndexOfPhrase("0x") + 2; if (IDStart == 1) continue; - u32 IDEnd = Line.IndexOf(" \t", IDStart); - u32 PathStart = IDEnd + 1; - u32 PathEnd = Line.Size() - 5; + uint32 IDEnd = Line.IndexOf(" \t", IDStart); + uint32 PathStart = IDEnd + 1; + uint32 PathEnd = Line.Size() - 5; TString IDStr = Line.SubString(IDStart, IDEnd - IDStart); TString Path = Line.SubString(PathStart, PathEnd - PathStart); @@ -576,7 +576,7 @@ void CResourceStore::ImportNamesFromPakContentsTxt(const TString& rkTxtPath, boo if (pEntry) { // Chop name to just after "x_rep" - u32 RepStart = Path.IndexOfPhrase("_rep"); + uint32 RepStart = Path.IndexOfPhrase("_rep"); if (RepStart != -1) Path = Path.ChopFront(RepStart + 5); diff --git a/src/Core/GameProject/CResourceStore.h b/src/Core/GameProject/CResourceStore.h index 019d62f6..10c82bea 100644 --- a/src/Core/GameProject/CResourceStore.h +++ b/src/Core/GameProject/CResourceStore.h @@ -7,7 +7,6 @@ #include #include #include -#include #include #include @@ -82,8 +81,8 @@ public: inline TString ResourcesDir() const { return IsEditorStore() ? DatabaseRootPath() : DatabaseRootPath() + "Resources/"; } inline TString DatabasePath() const { return DatabaseRootPath() + "ResourceDatabaseCache.bin"; } inline CVirtualDirectory* RootDirectory() const { return mpDatabaseRoot; } - inline u32 NumTotalResources() const { return mResourceEntries.size(); } - inline u32 NumLoadedResources() const { return mLoadedResources.size(); } + inline uint32 NumTotalResources() const { return mResourceEntries.size(); } + inline uint32 NumLoadedResources() const { return mLoadedResources.size(); } inline bool IsCacheDirty() const { return mDatabaseCacheDirty; } inline void SetCacheDirty() { mDatabaseCacheDirty = true; } diff --git a/src/Core/GameProject/CVirtualDirectory.cpp b/src/Core/GameProject/CVirtualDirectory.cpp index 42818952..47463edd 100644 --- a/src/Core/GameProject/CVirtualDirectory.cpp +++ b/src/Core/GameProject/CVirtualDirectory.cpp @@ -22,7 +22,7 @@ CVirtualDirectory::CVirtualDirectory(CVirtualDirectory *pParent, const TString& CVirtualDirectory::~CVirtualDirectory() { - for (u32 iSub = 0; iSub < mSubdirectories.size(); iSub++) + for (uint32 iSub = 0; iSub < mSubdirectories.size(); iSub++) delete mSubdirectories[iSub]; } @@ -31,7 +31,7 @@ bool CVirtualDirectory::IsEmpty(bool CheckFilesystem) const if (!mResources.empty()) return false; - for (u32 iSub = 0; iSub < mSubdirectories.size(); iSub++) + for (uint32 iSub = 0; iSub < mSubdirectories.size(); iSub++) if (!mSubdirectories[iSub]->IsEmpty(CheckFilesystem)) return false; @@ -66,10 +66,10 @@ CVirtualDirectory* CVirtualDirectory::GetRoot() CVirtualDirectory* CVirtualDirectory::FindChildDirectory(const TString& rkName, bool AllowCreate) { - u32 SlashIdx = rkName.IndexOf("\\/"); + uint32 SlashIdx = rkName.IndexOf("\\/"); TString DirName = (SlashIdx == -1 ? rkName : rkName.SubString(0, SlashIdx)); - for (u32 iSub = 0; iSub < mSubdirectories.size(); iSub++) + for (uint32 iSub = 0; iSub < mSubdirectories.size(); iSub++) { CVirtualDirectory *pChild = mSubdirectories[iSub]; @@ -126,7 +126,7 @@ CResourceEntry* CVirtualDirectory::FindChildResource(const TString& rkPath) CResourceEntry* CVirtualDirectory::FindChildResource(const TString& rkName, EResType Type) { - for (u32 iRes = 0; iRes < mResources.size(); iRes++) + for (uint32 iRes = 0; iRes < mResources.size(); iRes++) { if (rkName.CaseInsensitiveCompare(mResources[iRes]->Name()) && mResources[iRes]->ResourceType() == Type) return mResources[iRes]; @@ -150,14 +150,14 @@ bool CVirtualDirectory::AddChild(const TString &rkPath, CResourceEntry *pEntry) else if (IsValidDirectoryPath(rkPath)) { - u32 SlashIdx = rkPath.IndexOf("\\/"); + uint32 SlashIdx = rkPath.IndexOf("\\/"); TString DirName = (SlashIdx == -1 ? rkPath : rkPath.SubString(0, SlashIdx)); TString Remaining = (SlashIdx == -1 ? "" : rkPath.SubString(SlashIdx + 1, rkPath.Size() - SlashIdx)); // Check if this subdirectory already exists CVirtualDirectory *pSubdir = nullptr; - for (u32 iSub = 0; iSub < mSubdirectories.size(); iSub++) + for (uint32 iSub = 0; iSub < mSubdirectories.size(); iSub++) { if (mSubdirectories[iSub]->Name() == DirName) { @@ -264,7 +264,7 @@ void CVirtualDirectory::SortSubdirectories() bool CVirtualDirectory::Rename(const TString& rkNewName) { - Log::Write("MOVING DIRECTORY: " + FullPath() + " -> " + mpParent->FullPath() + rkNewName + '/'); + debugf("MOVING DIRECTORY: %s --> %s", *FullPath(), *mpParent->FullPath() + rkNewName + '/'); if (!IsRoot()) { @@ -283,7 +283,7 @@ bool CVirtualDirectory::Rename(const TString& rkNewName) } } - Log::Error("DIRECTORY MOVE FAILED"); + errorf("DIRECTORY MOVE FAILED"); return false; } @@ -309,7 +309,7 @@ bool CVirtualDirectory::Delete() void CVirtualDirectory::DeleteEmptySubdirectories() { - for (u32 SubdirIdx = 0; SubdirIdx < mSubdirectories.size(); SubdirIdx++) + for (uint32 SubdirIdx = 0; SubdirIdx < mSubdirectories.size(); SubdirIdx++) { CVirtualDirectory *pDir = mSubdirectories[SubdirIdx]; @@ -332,7 +332,7 @@ bool CVirtualDirectory::CreateFilesystemDirectory() bool CreateSuccess = FileUtil::MakeDirectory(AbsPath); if (!CreateSuccess) - Log::Error("FAILED to create filesystem directory: " + AbsPath); + errorf("FAILED to create filesystem directory: %s", *AbsPath); return CreateSuccess; } @@ -345,14 +345,14 @@ bool CVirtualDirectory::SetParent(CVirtualDirectory *pParent) ASSERT(!pParent->IsDescendantOf(this)); if (mpParent == pParent) return true; - Log::Write("MOVING DIRECTORY: " + FullPath() + " -> " + pParent->FullPath() + mName + '/'); + debugf("MOVING DIRECTORY: %s -> %s", *FullPath(), *(pParent->FullPath() + mName + '/')); // Check for a conflict CVirtualDirectory *pConflictDir = pParent->FindChildDirectory(mName, false); if (pConflictDir) { - Log::Error("DIRECTORY MOVE FAILED: Conflicting directory exists at the destination path!"); + errorf("DIRECTORY MOVE FAILED: Conflicting directory exists at the destination path!"); return false; } @@ -369,7 +369,7 @@ bool CVirtualDirectory::SetParent(CVirtualDirectory *pParent) } else { - Log::Error("DIRECTORY MOVE FAILED: Filesystem move operation failed!"); + errorf("DIRECTORY MOVE FAILED: Filesystem move operation failed!"); mpParent->AddChild(this); return false; } diff --git a/src/Core/GameProject/CVirtualDirectory.h b/src/Core/GameProject/CVirtualDirectory.h index 737023bc..bf57c789 100644 --- a/src/Core/GameProject/CVirtualDirectory.h +++ b/src/Core/GameProject/CVirtualDirectory.h @@ -3,7 +3,7 @@ /* Virtual directory system used to look up resources by their location in the filesystem. */ #include "Core/Resource/EResType.h" -#include +#include #include #include @@ -51,10 +51,10 @@ public: inline bool IsRoot() const { return !mpParent; } inline TString Name() const { return mName; } - inline u32 NumSubdirectories() const { return mSubdirectories.size(); } - inline CVirtualDirectory* SubdirectoryByIndex(u32 Index) { return mSubdirectories[Index]; } - inline u32 NumResources() const { return mResources.size(); } - inline CResourceEntry* ResourceByIndex(u32 Index) { return mResources[Index]; } + inline uint32 NumSubdirectories() const { return mSubdirectories.size(); } + inline CVirtualDirectory* SubdirectoryByIndex(uint32 Index) { return mSubdirectories[Index]; } + inline uint32 NumResources() const { return mResources.size(); } + inline CResourceEntry* ResourceByIndex(uint32 Index) { return mResources[Index]; } }; #endif // CVIRTUALDIRECTORY diff --git a/src/Core/GameProject/DependencyListBuilders.cpp b/src/Core/GameProject/DependencyListBuilders.cpp index 2ea79dac..43926736 100644 --- a/src/Core/GameProject/DependencyListBuilders.cpp +++ b/src/Core/GameProject/DependencyListBuilders.cpp @@ -1,7 +1,7 @@ #include "DependencyListBuilders.h" // ************ CCharacterUsageMap ************ -bool CCharacterUsageMap::IsCharacterUsed(const CAssetID& rkID, u32 CharacterIndex) const +bool CCharacterUsageMap::IsCharacterUsed(const CAssetID& rkID, uint32 CharacterIndex) const { if (mpStore->Game() >= EGame::CorruptionProto) return true; auto Find = mUsageMap.find(rkID); @@ -18,7 +18,7 @@ bool CCharacterUsageMap::IsAnimationUsed(const CAssetID& rkID, CSetAnimationDepe if (Find == mUsageMap.end()) return false; const std::vector& rkUsageList = Find->second; - for (u32 iChar = 0; iChar < rkUsageList.size(); iChar++) + for (uint32 iChar = 0; iChar < rkUsageList.size(); iChar++) { if (rkUsageList[iChar] && pAnim->IsUsedByCharacter(iChar)) return true; @@ -37,7 +37,7 @@ void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, CResourceEntry *pEntr { ASSERT(pEntry->ResourceType() == eArea); - for (u32 iArea = 0; iArea < pWorld->NumAreas(); iArea++) + for (uint32 iArea = 0; iArea < pWorld->NumAreas(); iArea++) { if (pWorld->AreaResourceID(iArea) == pEntry->ID()) { @@ -47,12 +47,12 @@ void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, CResourceEntry *pEntr } } -void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, u32 AreaIndex) +void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, uint32 AreaIndex) { // We only need to search forward from this area to other areas that both use the same character(s) + have duplicates enabled Clear(); - for (u32 iArea = AreaIndex; iArea < pWorld->NumAreas(); iArea++) + for (uint32 iArea = AreaIndex; iArea < pWorld->NumAreas(); iArea++) { if (!mIsInitialArea && mStillLookingIDs.empty()) break; mCurrentAreaAllowsDupes = pWorld->DoesAreaAllowPakDuplicates(iArea); @@ -66,7 +66,7 @@ void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, u32 AreaIndex) } } -void CCharacterUsageMap::FindUsagesForLayer(CResourceEntry *pAreaEntry, u32 LayerIndex) +void CCharacterUsageMap::FindUsagesForLayer(CResourceEntry *pAreaEntry, uint32 LayerIndex) { Clear(); mLayerIndex = LayerIndex; @@ -76,10 +76,10 @@ void CCharacterUsageMap::FindUsagesForLayer(CResourceEntry *pAreaEntry, u32 Laye // Only examine dependencies of the particular layer specified by the caller bool IsLastLayer = (mLayerIndex == pTree->NumScriptLayers() - 1); - u32 StartIdx = pTree->ScriptLayerOffset(mLayerIndex); - u32 EndIdx = (IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(mLayerIndex + 1)); + uint32 StartIdx = pTree->ScriptLayerOffset(mLayerIndex); + uint32 EndIdx = (IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(mLayerIndex + 1)); - for (u32 iInst = StartIdx; iInst < EndIdx; iInst++) + for (uint32 iInst = StartIdx; iInst < EndIdx; iInst++) ParseDependencyNode(pTree->ChildByIndex(iInst)); } @@ -101,11 +101,11 @@ void CCharacterUsageMap::DebugPrintContents() std::vector& rUsedList = Iter->second; CAnimSet *pSet = mpStore->LoadResource(ID); - for (u32 iChar = 0; iChar < pSet->NumCharacters(); iChar++) + for (uint32 iChar = 0; iChar < pSet->NumCharacters(); iChar++) { bool Used = (rUsedList.size() > iChar && rUsedList[iChar]); TString CharName = pSet->Character(iChar)->Name; - Log::Write(ID.ToString() + " : Char " + TString::FromInt32(iChar, 0, 10) + " : " + CharName + " : " + (Used ? "USED" : "UNUSED")); + debugf("%s : Char %d : %s : %s", *ID.ToString(), iChar, *CharName, (Used ? "USED" : "UNUSED")); } } } @@ -141,7 +141,7 @@ void CCharacterUsageMap::ParseDependencyNode(IDependencyNode *pNode) } std::vector& rUsageList = mUsageMap[ResID]; - u32 UsedChar = pDep->UsedChar(); + uint32 UsedChar = pDep->UsedChar(); if (rUsageList.size() <= UsedChar) rUsageList.resize(UsedChar + 1, false); @@ -164,7 +164,7 @@ void CCharacterUsageMap::ParseDependencyNode(IDependencyNode *pNode) // Look for sub-dependencies of the current node else { - for (u32 iChild = 0; iChild < pNode->NumChildren(); iChild++) + for (uint32 iChild = 0; iChild < pNode->NumChildren(); iChild++) ParseDependencyNode(pNode->ChildByIndex(iChild)); } } @@ -176,7 +176,7 @@ void CPackageDependencyListBuilder::BuildDependencyList(bool AllowDuplicates, st FindUniversalAreaAssets(); // Iterate over all resources and parse their dependencies - for (u32 iRes = 0; iRes < mpkPackage->NumNamedResources(); iRes++) + for (uint32 iRes = 0; iRes < mpkPackage->NumNamedResources(); iRes++) { const SNamedResource& rkRes = mpkPackage->NamedResourceByIndex(iRes); CResourceEntry *pEntry = mpStore->FindEntry(rkRes.ID); @@ -240,7 +240,7 @@ void CPackageDependencyListBuilder::AddDependency(CResourceEntry *pCurEntry, con if (mEnableDuplicates) { - for (u32 iArea = 0; iArea < mpWorld->NumAreas(); iArea++) + for (uint32 iArea = 0; iArea < mpWorld->NumAreas(); iArea++) { if (mpWorld->AreaResourceID(iArea) == rkID) { @@ -285,7 +285,7 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE else if (Type == eDNT_AnimEvent) { CAnimEventDependency *pDep = static_cast(pNode); - u32 CharIndex = pDep->CharIndex(); + uint32 CharIndex = pDep->CharIndex(); if (CharIndex == -1 || mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, CharIndex)) AddDependency(pCurEntry, pDep->ID(), rOut); @@ -313,11 +313,11 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE { if (Type == eDNT_ScriptInstance) { - u32 ObjType = static_cast(pNode)->ObjectType(); + uint32 ObjType = static_cast(pNode)->ObjectType(); mIsPlayerActor = (ObjType == 0x4C || ObjType == FOURCC('PLAC')); } - for (u32 iChild = 0; iChild < pNode->NumChildren(); iChild++) + for (uint32 iChild = 0; iChild < pNode->NumChildren(); iChild++) EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), rOut); if (Type == eDNT_ScriptInstance) @@ -333,7 +333,7 @@ void CPackageDependencyListBuilder::FindUniversalAreaAssets() if (pPackage) { // Iterate over all the package contents, keep track of all universal area assets - for (u32 ResIdx = 0; ResIdx < pPackage->NumNamedResources(); ResIdx++) + for (uint32 ResIdx = 0; ResIdx < pPackage->NumNamedResources(); ResIdx++) { const SNamedResource& rkRes = pPackage->NamedResourceByIndex(ResIdx); @@ -349,7 +349,7 @@ void CPackageDependencyListBuilder::FindUniversalAreaAssets() if (pUniverseWorld) { // Area IDs - for (u32 AreaIdx = 0; AreaIdx < pUniverseWorld->NumAreas(); AreaIdx++) + for (uint32 AreaIdx = 0; AreaIdx < pUniverseWorld->NumAreas(); AreaIdx++) { CAssetID AreaID = pUniverseWorld->AreaResourceID(AreaIdx); @@ -362,7 +362,7 @@ void CPackageDependencyListBuilder::FindUniversalAreaAssets() if (pMapWorld) { - for (u32 DepIdx = 0; DepIdx < pMapWorld->NumDependencies(); DepIdx++) + for (uint32 DepIdx = 0; DepIdx < pMapWorld->NumDependencies(); DepIdx++) { CAssetID DepID = pMapWorld->DependencyByIndex(DepIdx); @@ -378,14 +378,14 @@ void CPackageDependencyListBuilder::FindUniversalAreaAssets() } // ************ CAreaDependencyListBuilder ************ -void CAreaDependencyListBuilder::BuildDependencyList(std::list& rAssetsOut, std::list& rLayerOffsetsOut, std::set *pAudioGroupsOut) +void CAreaDependencyListBuilder::BuildDependencyList(std::list& rAssetsOut, std::list& rLayerOffsetsOut, std::set *pAudioGroupsOut) { CAreaDependencyTree *pTree = static_cast(mpAreaEntry->Dependencies()); // Fill area base used assets set (don't actually add to list yet) - u32 BaseEndIndex = (pTree->NumScriptLayers() > 0 ? pTree->ScriptLayerOffset(0) : pTree->NumChildren()); + uint32 BaseEndIndex = (pTree->NumScriptLayers() > 0 ? pTree->ScriptLayerOffset(0) : pTree->NumChildren()); - for (u32 iDep = 0; iDep < BaseEndIndex; iDep++) + for (uint32 iDep = 0; iDep < BaseEndIndex; iDep++) { CResourceDependency *pRes = static_cast(pTree->ChildByIndex(iDep)); ASSERT(pRes->Type() == eDNT_ResourceDependency); @@ -393,17 +393,17 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list& rAsset } // Get dependencies of each layer - for (u32 iLyr = 0; iLyr < pTree->NumScriptLayers(); iLyr++) + for (uint32 iLyr = 0; iLyr < pTree->NumScriptLayers(); iLyr++) { mLayerUsedAssets.clear(); mCharacterUsageMap.FindUsagesForLayer(mpAreaEntry, iLyr); rLayerOffsetsOut.push_back(rAssetsOut.size()); bool IsLastLayer = (iLyr == pTree->NumScriptLayers() - 1); - u32 StartIdx = pTree->ScriptLayerOffset(iLyr); - u32 EndIdx = (IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(iLyr + 1)); + uint32 StartIdx = pTree->ScriptLayerOffset(iLyr); + uint32 EndIdx = (IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(iLyr + 1)); - for (u32 iChild = StartIdx; iChild < EndIdx; iChild++) + for (uint32 iChild = StartIdx; iChild < EndIdx; iChild++) { IDependencyNode *pNode = pTree->ChildByIndex(iChild); @@ -412,7 +412,7 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list& rAsset CScriptInstanceDependency *pInst = static_cast(pNode); mIsPlayerActor = (pInst->ObjectType() == 0x4C || pInst->ObjectType() == FOURCC('PLAC')); - for (u32 iDep = 0; iDep < pInst->NumChildren(); iDep++) + for (uint32 iDep = 0; iDep < pInst->NumChildren(); iDep++) { CPropertyDependency *pDep = static_cast(pInst->ChildByIndex(iDep)); @@ -452,7 +452,7 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list& rAsset mLayerUsedAssets.clear(); rLayerOffsetsOut.push_back(rAssetsOut.size()); - for (u32 iDep = 0; iDep < BaseEndIndex; iDep++) + for (uint32 iDep = 0; iDep < BaseEndIndex; iDep++) { CResourceDependency *pDep = static_cast(pTree->ChildByIndex(iDep)); AddDependency(pDep->ID(), rAssetsOut, pAudioGroupsOut); @@ -525,7 +525,7 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr else if (Type == eDNT_AnimEvent) { CAnimEventDependency *pDep = static_cast(pNode); - u32 CharIndex = pDep->CharIndex(); + uint32 CharIndex = pDep->CharIndex(); if (CharIndex == -1 || mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, CharIndex)) AddDependency(pDep->ID(), rOut, pAudioGroupsOut); @@ -534,10 +534,10 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr else if (Type == eDNT_SetCharacter) { // Note: For MP1/2 PlayerActor, always treat as if Empty Suit is the only used one - const u32 kEmptySuitIndex = (mGame >= EGame::EchoesDemo ? 3 : 5); + const uint32 kEmptySuitIndex = (mGame >= EGame::EchoesDemo ? 3 : 5); CSetCharacterDependency *pChar = static_cast(pNode); - u32 SetIndex = pChar->CharSetIndex(); + uint32 SetIndex = pChar->CharSetIndex(); ParseChildren = mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, pChar->CharSetIndex()) || (mIsPlayerActor && SetIndex == kEmptySuitIndex); } @@ -552,7 +552,7 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr if (ParseChildren) { - for (u32 iChild = 0; iChild < pNode->NumChildren(); iChild++) + for (uint32 iChild = 0; iChild < pNode->NumChildren(); iChild++) EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), rOut, pAudioGroupsOut); } } diff --git a/src/Core/GameProject/DependencyListBuilders.h b/src/Core/GameProject/DependencyListBuilders.h index ede95d9c..de878b0c 100644 --- a/src/Core/GameProject/DependencyListBuilders.h +++ b/src/Core/GameProject/DependencyListBuilders.h @@ -13,7 +13,7 @@ class CCharacterUsageMap std::map> mUsageMap; std::set mStillLookingIDs; CResourceStore *mpStore; - u32 mLayerIndex; + uint32 mLayerIndex; bool mIsInitialArea; bool mCurrentAreaAllowsDupes; @@ -22,12 +22,12 @@ public: : mpStore(pStore), mLayerIndex(-1), mIsInitialArea(true), mCurrentAreaAllowsDupes(false) {} - bool IsCharacterUsed(const CAssetID& rkID, u32 CharacterIndex) const; + bool IsCharacterUsed(const CAssetID& rkID, uint32 CharacterIndex) const; bool IsAnimationUsed(const CAssetID& rkID, CSetAnimationDependency *pAnim) const; void FindUsagesForAsset(CResourceEntry *pEntry); void FindUsagesForArea(CWorld *pWorld, CResourceEntry *pEntry); - void FindUsagesForArea(CWorld *pWorld, u32 AreaIndex); - void FindUsagesForLayer(CResourceEntry *pAreaEntry, u32 LayerIndex); + void FindUsagesForArea(CWorld *pWorld, uint32 AreaIndex); + void FindUsagesForLayer(CResourceEntry *pAreaEntry, uint32 LayerIndex); void Clear(); void DebugPrintContents(); @@ -91,7 +91,7 @@ public: ASSERT(mpAreaEntry->ResourceType() == eArea); } - void BuildDependencyList(std::list& rAssetsOut, std::list& rLayerOffsetsOut, std::set *pAudioGroupsOut = nullptr); + void BuildDependencyList(std::list& rAssetsOut, std::list& rLayerOffsetsOut, std::set *pAudioGroupsOut = nullptr); void AddDependency(const CAssetID& rkID, std::list& rOut, std::set *pAudioGroupsOut); void EvaluateDependencyNode(CResourceEntry *pCurEntry, IDependencyNode *pNode, std::list& rOut, std::set *pAudioGroupsOut); }; diff --git a/src/Core/IProgressNotifier.h b/src/Core/IProgressNotifier.h index 8eefeb15..e2dc2b06 100644 --- a/src/Core/IProgressNotifier.h +++ b/src/Core/IProgressNotifier.h @@ -2,7 +2,7 @@ #define IPROGRESSNOTIFIER_H #include -#include +#include class IProgressNotifier { diff --git a/src/Core/OpenGL/CDynamicVertexBuffer.cpp b/src/Core/OpenGL/CDynamicVertexBuffer.cpp index 1403df43..6359cb12 100644 --- a/src/Core/OpenGL/CDynamicVertexBuffer.cpp +++ b/src/Core/OpenGL/CDynamicVertexBuffer.cpp @@ -1,7 +1,7 @@ #include "CDynamicVertexBuffer.h" #include "CVertexArrayManager.h" -static const u32 gskAttribSize[] = { +static const uint32 gskAttribSize[] = { 0xC, 0xC, 0x4, 0x4, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8 }; @@ -18,7 +18,7 @@ CDynamicVertexBuffer::~CDynamicVertexBuffer() ClearBuffers(); } -void CDynamicVertexBuffer::SetVertexCount(u32 NumVerts) +void CDynamicVertexBuffer::SetVertexCount(uint32 NumVerts) { ClearBuffers(); mNumVertices = NumVerts; @@ -44,7 +44,7 @@ void CDynamicVertexBuffer::SetActiveAttribs(FVertexDescription AttribFlags) void CDynamicVertexBuffer::BufferAttrib(EVertexAttribute Attrib, const void *pkData) { - u32 Index; + uint32 Index; switch (Attrib) { @@ -69,7 +69,7 @@ void CDynamicVertexBuffer::BufferAttrib(EVertexAttribute Attrib, const void *pkD void CDynamicVertexBuffer::ClearBuffers() { - for (u32 iAttrib = 0; iAttrib < 12; iAttrib++) + for (uint32 iAttrib = 0; iAttrib < 12; iAttrib++) { int Bit = 1 << iAttrib; @@ -86,7 +86,7 @@ GLuint CDynamicVertexBuffer::CreateVAO() glGenVertexArrays(1, &VertexArray); glBindVertexArray(VertexArray); - for (u32 iAttrib = 0; iAttrib < 12; iAttrib++) + for (uint32 iAttrib = 0; iAttrib < 12; iAttrib++) { bool HasAttrib = ((3 << (iAttrib * 2)) != 0); @@ -121,7 +121,7 @@ void CDynamicVertexBuffer::InitBuffers() { if (mBufferedFlags) ClearBuffers(); - for (u32 iAttrib = 0; iAttrib < 12; iAttrib++) + for (uint32 iAttrib = 0; iAttrib < 12; iAttrib++) { bool HasAttrib = ((3 << (iAttrib * 2)) != 0); diff --git a/src/Core/OpenGL/CDynamicVertexBuffer.h b/src/Core/OpenGL/CDynamicVertexBuffer.h index 7042700a..0969b4a2 100644 --- a/src/Core/OpenGL/CDynamicVertexBuffer.h +++ b/src/Core/OpenGL/CDynamicVertexBuffer.h @@ -2,7 +2,7 @@ #define CDYNAMICVERTEXBUFFER_H #include "Core/Resource/Model/EVertexAttribute.h" -#include +#include #include #include @@ -11,13 +11,13 @@ class CDynamicVertexBuffer { FVertexDescription mAttribFlags; FVertexDescription mBufferedFlags; - u32 mNumVertices; + uint32 mNumVertices; GLuint mAttribBuffers[12]; public: CDynamicVertexBuffer(); ~CDynamicVertexBuffer(); - void SetVertexCount(u32 NumVerts); + void SetVertexCount(uint32 NumVerts); void Bind(); void Unbind(); void SetActiveAttribs(FVertexDescription AttribFlags); diff --git a/src/Core/OpenGL/CFramebuffer.cpp b/src/Core/OpenGL/CFramebuffer.cpp index 72584d6a..43da6578 100644 --- a/src/Core/OpenGL/CFramebuffer.cpp +++ b/src/Core/OpenGL/CFramebuffer.cpp @@ -11,7 +11,7 @@ CFramebuffer::CFramebuffer() { } -CFramebuffer::CFramebuffer(u32 Width, u32 Height) +CFramebuffer::CFramebuffer(uint32 Width, uint32 Height) : mpRenderbuffer(nullptr) , mpTexture(nullptr) , mWidth(0) @@ -60,7 +60,7 @@ void CFramebuffer::Bind(GLenum Target /*= GL_FRAMEBUFFER*/) glBindFramebuffer(Target, mFramebuffer); } -void CFramebuffer::Resize(u32 Width, u32 Height) +void CFramebuffer::Resize(uint32 Width, uint32 Height) { if ((mWidth != Width) || (mHeight != Height)) { @@ -109,7 +109,7 @@ void CFramebuffer::InitBuffers() mStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (mStatus != GL_FRAMEBUFFER_COMPLETE) - Log::Error("Framebuffer not complete; error " + TString::HexString((u32) mStatus, 0)); + errorf("Framebuffer not complete; error 0x%X", mStatus); } // ************ STATIC ************ diff --git a/src/Core/OpenGL/CFramebuffer.h b/src/Core/OpenGL/CFramebuffer.h index bb2c2b04..cd395123 100644 --- a/src/Core/OpenGL/CFramebuffer.h +++ b/src/Core/OpenGL/CFramebuffer.h @@ -10,7 +10,7 @@ class CFramebuffer GLuint mFramebuffer; CRenderbuffer *mpRenderbuffer; CTexture *mpTexture; - u32 mWidth, mHeight; + uint32 mWidth, mHeight; bool mEnableMultisampling; bool mInitialized; GLenum mStatus; @@ -20,11 +20,11 @@ class CFramebuffer public: CFramebuffer(); - CFramebuffer(u32 Width, u32 Height); + CFramebuffer(uint32 Width, uint32 Height); ~CFramebuffer(); void Init(); void Bind(GLenum Target = GL_FRAMEBUFFER); - void Resize(u32 Width, u32 Height); + void Resize(uint32 Width, uint32 Height); void SetMultisamplingEnabled(bool Enable); // Accessors diff --git a/src/Core/OpenGL/CIndexBuffer.cpp b/src/Core/OpenGL/CIndexBuffer.cpp index 14576d84..e67cd300 100644 --- a/src/Core/OpenGL/CIndexBuffer.cpp +++ b/src/Core/OpenGL/CIndexBuffer.cpp @@ -17,19 +17,19 @@ CIndexBuffer::~CIndexBuffer() glDeleteBuffers(1, &mIndexBuffer); } -void CIndexBuffer::AddIndex(u16 Index) +void CIndexBuffer::AddIndex(uint16 Index) { mIndices.push_back(Index); } -void CIndexBuffer::AddIndices(u16 *pIndices, u32 Count) +void CIndexBuffer::AddIndices(uint16 *pIndices, uint Count) { Reserve(Count); - for (u32 iIdx = 0; iIdx < Count; iIdx++) + for (uint iIdx = 0; iIdx < Count; iIdx++) mIndices.push_back(*pIndices++); } -void CIndexBuffer::Reserve(u32 Size) +void CIndexBuffer::Reserve(uint Size) { mIndices.reserve(mIndices.size() + Size); } @@ -50,7 +50,7 @@ void CIndexBuffer::Buffer() glGenBuffers(1, &mIndexBuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, mIndices.size() * sizeof(u16), mIndices.data(), GL_STATIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, mIndices.size() * sizeof(uint16), mIndices.data(), GL_STATIC_DRAW); mBuffered = true; } @@ -72,7 +72,7 @@ void CIndexBuffer::DrawElements() Unbind(); } -void CIndexBuffer::DrawElements(u32 Offset, u32 Size) +void CIndexBuffer::DrawElements(uint Offset, uint Size) { Bind(); glDrawElements(mPrimitiveType, Size, GL_UNSIGNED_SHORT, (char*)0 + (Offset * 2)); @@ -84,7 +84,7 @@ bool CIndexBuffer::IsBuffered() return mBuffered; } -u32 CIndexBuffer::GetSize() +uint CIndexBuffer::GetSize() { return mIndices.size(); } @@ -99,11 +99,11 @@ void CIndexBuffer::SetPrimitiveType(GLenum Type) mPrimitiveType = Type; } -void CIndexBuffer::TrianglesToStrips(u16 *pIndices, u32 Count) +void CIndexBuffer::TrianglesToStrips(uint16 *pIndices, uint Count) { Reserve(Count + (Count / 3)); - for (u32 iIdx = 0; iIdx < Count; iIdx += 3) + for (uint iIdx = 0; iIdx < Count; iIdx += 3) { mIndices.push_back(*pIndices++); mIndices.push_back(*pIndices++); @@ -112,12 +112,12 @@ void CIndexBuffer::TrianglesToStrips(u16 *pIndices, u32 Count) } } -void CIndexBuffer::FansToStrips(u16 *pIndices, u32 Count) +void CIndexBuffer::FansToStrips(uint16 *pIndices, uint Count) { Reserve(Count); - u16 FirstIndex = *pIndices; + uint16 FirstIndex = *pIndices; - for (u32 iIdx = 2; iIdx < Count; iIdx += 3) + for (uint iIdx = 2; iIdx < Count; iIdx += 3) { mIndices.push_back(pIndices[iIdx - 1]); mIndices.push_back(pIndices[iIdx]); @@ -130,11 +130,11 @@ void CIndexBuffer::FansToStrips(u16 *pIndices, u32 Count) } } -void CIndexBuffer::QuadsToStrips(u16 *pIndices, u32 Count) +void CIndexBuffer::QuadsToStrips(uint16 *pIndices, uint Count) { - Reserve((u32) (Count * 1.25)); + Reserve((uint) (Count * 1.25)); - u32 iIdx = 3; + uint iIdx = 3; for (; iIdx < Count; iIdx += 4) { mIndices.push_back(pIndices[iIdx - 2]); diff --git a/src/Core/OpenGL/CIndexBuffer.h b/src/Core/OpenGL/CIndexBuffer.h index 3264a5be..95ae04ac 100644 --- a/src/Core/OpenGL/CIndexBuffer.h +++ b/src/Core/OpenGL/CIndexBuffer.h @@ -1,14 +1,14 @@ #ifndef CINDEXBUFFER_H #define CINDEXBUFFER_H -#include -#include +#include +#include #include class CIndexBuffer { GLuint mIndexBuffer; - std::vector mIndices; + std::vector mIndices; GLenum mPrimitiveType; bool mBuffered; @@ -16,24 +16,24 @@ public: CIndexBuffer(); CIndexBuffer(GLenum Type); ~CIndexBuffer(); - void AddIndex(u16 Index); - void AddIndices(u16 *pIndices, u32 Count); - void Reserve(u32 Size); + void AddIndex(uint16 Index); + void AddIndices(uint16 *pIndices, uint Count); + void Reserve(uint Size); void Clear(); void Buffer(); void Bind(); void Unbind(); void DrawElements(); - void DrawElements(u32 Offset, u32 Size); + void DrawElements(uint Offset, uint Size); bool IsBuffered(); - u32 GetSize(); + uint GetSize(); GLenum GetPrimitiveType(); void SetPrimitiveType(GLenum Type); - void TrianglesToStrips(u16 *pIndices, u32 Count); - void FansToStrips(u16 *pIndices, u32 Count); - void QuadsToStrips(u16 *pIndices, u32 Count); + void TrianglesToStrips(uint16 *pIndices, uint Count); + void FansToStrips(uint16 *pIndices, uint Count); + void QuadsToStrips(uint16 *pIndices, uint Count); }; #endif // CINDEXBUFFER_H diff --git a/src/Core/OpenGL/CRenderbuffer.h b/src/Core/OpenGL/CRenderbuffer.h index 9175af60..be796bbc 100644 --- a/src/Core/OpenGL/CRenderbuffer.h +++ b/src/Core/OpenGL/CRenderbuffer.h @@ -1,13 +1,13 @@ #ifndef CRENDERBUFFER_H #define CRENDERBUFFER_H -#include +#include #include class CRenderbuffer { GLuint mRenderbuffer; - u32 mWidth, mHeight; + uint mWidth, mHeight; bool mEnableMultisampling; bool mInitialized; @@ -20,7 +20,7 @@ public: { } - CRenderbuffer::CRenderbuffer(u32 Width, u32 Height) + CRenderbuffer::CRenderbuffer(uint Width, uint Height) : mWidth(Width) , mHeight(Height) , mEnableMultisampling(false) @@ -41,7 +41,7 @@ public: InitStorage(); } - inline void CRenderbuffer::Resize(u32 Width, u32 Height) + inline void CRenderbuffer::Resize(uint Width, uint Height) { mWidth = Width; mHeight = Height; diff --git a/src/Core/OpenGL/CShader.cpp b/src/Core/OpenGL/CShader.cpp index 13c48e7c..e28fcb78 100644 --- a/src/Core/OpenGL/CShader.cpp +++ b/src/Core/OpenGL/CShader.cpp @@ -1,16 +1,15 @@ #include "CShader.h" #include "Core/Render/CGraphics.h" +#include #include #include -#include -#include #include #include bool gDebugDumpShaders = false; -u64 gFailedCompileCount = 0; -u64 gSuccessfulCompileCount = 0; +uint64 gFailedCompileCount = 0; +uint64 gSuccessfulCompileCount = 0; CShader* CShader::spCurrentShader = nullptr; int CShader::smNumShaders = 0; @@ -58,8 +57,8 @@ bool CShader::CompileVertexSource(const char* pkSource) if (CompileStatus == GL_FALSE) { TString Out = "dump/BadVS_" + std::to_string(gFailedCompileCount) + ".txt"; - Log::Error("Unable to compile vertex shader; dumped to " + Out); DumpShaderSource(mVertexShader, Out); + errorf("Unable to compile vertex shader; dumped to %s", *Out); gFailedCompileCount++; glDeleteShader(mVertexShader); @@ -70,8 +69,8 @@ bool CShader::CompileVertexSource(const char* pkSource) else if (gDebugDumpShaders == true) { TString Out = "dump/VS_" + TString::FromInt64(gSuccessfulCompileCount, 8, 10) + ".txt"; - Log::Write("Debug shader dumping enabled; dumped to " + Out); DumpShaderSource(mVertexShader, Out); + debugf("Debug shader dumping enabled; dumped to %s", *Out); gSuccessfulCompileCount++; } @@ -93,7 +92,7 @@ bool CShader::CompilePixelSource(const char* pkSource) if (CompileStatus == GL_FALSE) { TString Out = "dump/BadPS_" + TString::FromInt64(gFailedCompileCount, 8, 10) + ".txt"; - Log::Error("Unable to compile pixel shader; dumped to " + Out); + errorf("Unable to compile pixel shader; dumped to %s", *Out); DumpShaderSource(mPixelShader, Out); gFailedCompileCount++; @@ -105,7 +104,7 @@ bool CShader::CompilePixelSource(const char* pkSource) else if (gDebugDumpShaders == true) { TString Out = "dump/PS_" + TString::FromInt64(gSuccessfulCompileCount, 8, 10) + ".txt"; - Log::Write("Debug shader dumping enabled; dumped to " + Out); + debugf("Debug shader dumping enabled; dumped to %s", *Out); DumpShaderSource(mPixelShader, Out); gSuccessfulCompileCount++; @@ -136,7 +135,7 @@ bool CShader::LinkShaders() if (LinkStatus == GL_FALSE) { TString Out = "dump/BadLink_" + TString::FromInt64(gFailedCompileCount, 8, 10) + ".txt"; - Log::Error("Unable to link shaders. Dumped error log to " + Out); + errorf("Unable to link shaders. Dumped error log to %s", *Out); GLint LogLen; glGetProgramiv(mProgram, GL_INFO_LOG_LENGTH, &LogLen); @@ -188,13 +187,13 @@ GLuint CShader::GetUniformBlockIndex(const char* pkUniformBlock) return glGetUniformBlockIndex(mProgram, pkUniformBlock); } -void CShader::SetTextureUniforms(u32 NumTextures) +void CShader::SetTextureUniforms(uint32 NumTextures) { - for (u32 iTex = 0; iTex < NumTextures; iTex++) + for (uint32 iTex = 0; iTex < NumTextures; iTex++) glUniform1i(mTextureUniforms[iTex], iTex); } -void CShader::SetNumLights(u32 NumLights) +void CShader::SetNumLights(uint32 NumLights) { glUniform1i(mNumLightsUniform, NumLights); } @@ -219,26 +218,18 @@ CShader* CShader::FromResourceFile(const TString& rkShaderName) { TString VertexShaderFilename = "../resources/shaders/" + rkShaderName + ".vs"; TString PixelShaderFilename = "../resources/shaders/" + rkShaderName + ".ps"; - CTextInStream VertexShaderFile(VertexShaderFilename); - CTextInStream PixelShaderFile(PixelShaderFilename); + TString VertexShaderText, PixelShaderText; - if (!VertexShaderFile.IsValid()) - Log::Error("Couldn't load vertex shader file for " + rkShaderName); - if (!PixelShaderFile.IsValid()) - Log::Error("Error: Couldn't load pixel shader file for " + rkShaderName); - if ((!VertexShaderFile.IsValid()) || (!PixelShaderFile.IsValid())) return nullptr; - - std::stringstream VertexShader; - while (!VertexShaderFile.EoF()) - VertexShader << VertexShaderFile.GetString(); - - std::stringstream PixelShader; - while (!PixelShaderFile.EoF()) - PixelShader << PixelShaderFile.GetString(); + if (!FileUtil::LoadFileToString(VertexShaderFilename, VertexShaderText)) + errorf("Couldn't load vertex shader file for %s", *rkShaderName); + if (!FileUtil::LoadFileToString(PixelShaderFilename, PixelShaderText)) + errorf("Couldn't load pixel shader file for %s", *rkShaderName); + if (VertexShaderText.IsEmpty() || PixelShaderText.IsEmpty()) + return nullptr; CShader *pShader = new CShader(); - pShader->CompileVertexSource(VertexShader.str().c_str()); - pShader->CompilePixelSource(PixelShader.str().c_str()); + pShader->CompileVertexSource(*VertexShaderText); + pShader->CompilePixelSource(*PixelShaderText); pShader->LinkShaders(); return pShader; } @@ -256,7 +247,7 @@ void CShader::KillCachedShader() // ************ PRIVATE ************ void CShader::CacheCommonUniforms() { - for (u32 iTex = 0; iTex < 8; iTex++) + for (uint32 iTex = 0; iTex < 8; iTex++) { TString TexUniform = "Texture" + TString::FromInt32(iTex); mTextureUniforms[iTex] = glGetUniformLocation(mProgram, *TexUniform); diff --git a/src/Core/OpenGL/CShader.h b/src/Core/OpenGL/CShader.h index edc1c762..eed9e7b6 100644 --- a/src/Core/OpenGL/CShader.h +++ b/src/Core/OpenGL/CShader.h @@ -37,8 +37,8 @@ public: GLuint GetProgramID(); GLuint GetUniformLocation(const char* pkUniform); GLuint GetUniformBlockIndex(const char* pkUniformBlock); - void SetTextureUniforms(u32 NumTextures); - void SetNumLights(u32 NumLights); + void SetTextureUniforms(uint32 NumTextures); + void SetNumLights(uint32 NumLights); void SetCurrent(); // Static diff --git a/src/Core/OpenGL/CShaderGenerator.cpp b/src/Core/OpenGL/CShaderGenerator.cpp index 9487ba42..178d2b22 100644 --- a/src/Core/OpenGL/CShaderGenerator.cpp +++ b/src/Core/OpenGL/CShaderGenerator.cpp @@ -1,5 +1,5 @@ #include "CShaderGenerator.h" -#include +#include #include #include #include @@ -179,7 +179,7 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& rkMat) if (VtxDesc & eColor0) ShaderCode << "out vec4 Color0;\n"; if (VtxDesc & eColor1) ShaderCode << "out vec4 Color1;\n"; - for (u32 iPass = 0; iPass < rkMat.PassCount(); iPass++) + for (uint32 iPass = 0; iPass < rkMat.PassCount(); iPass++) if (rkMat.Pass(iPass)->TexCoordSource() != 0xFF) ShaderCode << "out vec3 Tex" << iPass << ";\n"; @@ -332,9 +332,9 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& rkMat) ShaderCode << " \n" << " // TexGen\n"; - u32 PassCount = rkMat.PassCount(); + uint32 PassCount = rkMat.PassCount(); - for (u32 iPass = 0; iPass < PassCount; iPass++) + for (uint32 iPass = 0; iPass < PassCount; iPass++) { CMaterialPass *pPass = rkMat.Pass(iPass); if (pPass->TexCoordSource() == 0xFF) continue; @@ -378,9 +378,9 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat) if (VtxDesc & eColor0) ShaderCode << "in vec4 Color0;\n"; if (VtxDesc & eColor1) ShaderCode << "in vec4 Color1;\n"; - u32 PassCount = rkMat.PassCount(); + uint32 PassCount = rkMat.PassCount(); - for (u32 iPass = 0; iPass < PassCount; iPass++) + for (uint32 iPass = 0; iPass < PassCount; iPass++) if (rkMat.Pass(iPass)->TexCoordSource() != 0xFF) ShaderCode << "in vec3 Tex" << iPass << ";\n"; @@ -396,7 +396,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat) << " float LightmapMultiplier;\n" << "};\n\n"; - for (u32 iPass = 0; iPass < PassCount; iPass++) + for (uint32 iPass = 0; iPass < PassCount; iPass++) if (rkMat.Pass(iPass)->Texture() != nullptr) ShaderCode << "uniform sampler2D Texture" << iPass << ";\n"; @@ -413,7 +413,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat) << " \n"; bool Lightmap = false; - for (u32 iPass = 0; iPass < PassCount; iPass++) + for (uint32 iPass = 0; iPass < PassCount; iPass++) { const CMaterialPass *pPass = rkMat.Pass(iPass); CFourCC PassType = pPass->Type(); @@ -451,7 +451,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat) if (pPass->RasSel() != eRasColorNull) ShaderCode << " Ras = " << gkRasSel[pPass->RasSel()] << ";\n"; - for (u8 iInput = 0; iInput < 4; iInput++) + for (uint8 iInput = 0; iInput < 4; iInput++) { char TevChar = iInput + 0x41; // the current stage number represented as an ASCII letter; eg 0 is 'A' diff --git a/src/Core/OpenGL/CUniformBuffer.h b/src/Core/OpenGL/CUniformBuffer.h index 7e1889a3..04e936fc 100644 --- a/src/Core/OpenGL/CUniformBuffer.h +++ b/src/Core/OpenGL/CUniformBuffer.h @@ -1,13 +1,13 @@ #ifndef CUNIFORMBUFFER_H #define CUNIFORMBUFFER_H -#include +#include #include class CUniformBuffer { GLuint mUniformBuffer; - u32 mBufferSize; + uint mBufferSize; public: @@ -17,7 +17,7 @@ public: SetBufferSize(0); } - CUniformBuffer(u32 Size) + CUniformBuffer(uint Size) { glGenBuffers(1, &mUniformBuffer); SetBufferSize(Size); @@ -52,20 +52,20 @@ public: Unbind(); } - void BufferRange(const void *pkData, u32 Offset, u32 Size) + void BufferRange(const void *pkData, uint Offset, uint Size) { Bind(); glBufferSubData(GL_UNIFORM_BUFFER, Offset, Size, pkData); Unbind(); } - void SetBufferSize(u32 Size) + void SetBufferSize(uint Size) { mBufferSize = Size; InitializeBuffer(); } - u32 GetBufferSize() + uint GetBufferSize() { return mBufferSize; } diff --git a/src/Core/OpenGL/CVertexArrayManager.cpp b/src/Core/OpenGL/CVertexArrayManager.cpp index 2dffb345..715a2494 100644 --- a/src/Core/OpenGL/CVertexArrayManager.cpp +++ b/src/Core/OpenGL/CVertexArrayManager.cpp @@ -94,12 +94,12 @@ CVertexArrayManager* CVertexArrayManager::Current() void CVertexArrayManager::DeleteAllArraysForVBO(CVertexBuffer *pVBO) { - for (u32 iVAM = 0; iVAM < sVAManagers.size(); iVAM++) + for (uint32 iVAM = 0; iVAM < sVAManagers.size(); iVAM++) sVAManagers[iVAM]->DeleteVAO(pVBO); } void CVertexArrayManager::DeleteAllArraysForVBO(CDynamicVertexBuffer *pVBO) { - for (u32 iVAM = 0; iVAM < sVAManagers.size(); iVAM++) + for (uint32 iVAM = 0; iVAM < sVAManagers.size(); iVAM++) sVAManagers[iVAM]->DeleteVAO(pVBO); } diff --git a/src/Core/OpenGL/CVertexArrayManager.h b/src/Core/OpenGL/CVertexArrayManager.h index 0d732990..e14f8bb4 100644 --- a/src/Core/OpenGL/CVertexArrayManager.h +++ b/src/Core/OpenGL/CVertexArrayManager.h @@ -12,7 +12,7 @@ class CVertexArrayManager { std::unordered_map mVBOMap; std::unordered_map mDynamicVBOMap; - u32 mVectorIndex; + uint32 mVectorIndex; static std::vector sVAManagers; static CVertexArrayManager *spCurrentManager; diff --git a/src/Core/OpenGL/CVertexBuffer.cpp b/src/Core/OpenGL/CVertexBuffer.cpp index 7640c1b9..7a38d07b 100644 --- a/src/Core/OpenGL/CVertexBuffer.cpp +++ b/src/Core/OpenGL/CVertexBuffer.cpp @@ -21,7 +21,7 @@ CVertexBuffer::~CVertexBuffer() glDeleteBuffers(14, mAttribBuffers); } -u16 CVertexBuffer::AddVertex(const CVertex& rkVtx) +uint16 CVertexBuffer::AddVertex(const CVertex& rkVtx) { if (mPositions.size() == 0xFFFF) throw std::overflow_error("VBO contains too many vertices"); @@ -30,10 +30,10 @@ u16 CVertexBuffer::AddVertex(const CVertex& rkVtx) if (mVtxDesc & eColor0) mColors[0].push_back(rkVtx.Color[0]); if (mVtxDesc & eColor1) mColors[1].push_back(rkVtx.Color[1]); - for (u32 iTex = 0; iTex < 8; iTex++) + for (uint32 iTex = 0; iTex < 8; iTex++) if (mVtxDesc & (eTex0 << iTex)) mTexCoords[iTex].push_back(rkVtx.Tex[iTex]); - for (u32 iMtx = 0; iMtx < 8; iMtx++) + for (uint32 iMtx = 0; iMtx < 8; iMtx++) if (mVtxDesc & (ePosMtx << iMtx)) mTexCoords[iMtx].push_back(rkVtx.MatrixIndices[iMtx]); if (mVtxDesc.HasAnyFlags(eBoneIndices | eBoneWeights) && mpSkin) @@ -46,11 +46,11 @@ u16 CVertexBuffer::AddVertex(const CVertex& rkVtx) return (mPositions.size() - 1); } -u16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, u16 Start) +uint16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, uint16 Start) { if (Start < mPositions.size()) { - for (u16 iVert = Start; iVert < mPositions.size(); iVert++) + for (uint16 iVert = Start; iVert < mPositions.size(); iVert++) { // I use a bool because "continue" doesn't work properly within the iTex loop bool Unique = false; @@ -68,7 +68,7 @@ u16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, u16 Start) if (rkVtx.Color[1] != mColors[1][iVert]) Unique = true; if (!Unique) - for (u32 iTex = 0; iTex < 8; iTex++) + for (uint32 iTex = 0; iTex < 8; iTex++) if ((mVtxDesc & (eTex0 << iTex))) if (rkVtx.Tex[iTex] != mTexCoords[iTex][iVert]) { @@ -80,7 +80,7 @@ u16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, u16 Start) { const SVertexWeights& rkWeights = mpSkin->WeightsForVertex(rkVtx.ArrayPosition); - for (u32 iWgt = 0; iWgt < 4; iWgt++) + for (uint32 iWgt = 0; iWgt < 4; iWgt++) { if ( ((mVtxDesc & eBoneIndices) && (rkWeights.Indices[iWgt] != mBoneIndices[iVert][iWgt])) || ((mVtxDesc & eBoneWeights) && (rkWeights.Weights[iWgt] != mBoneWeights[iVert][iWgt])) ) @@ -98,9 +98,9 @@ u16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, u16 Start) return AddVertex(rkVtx); } -void CVertexBuffer::Reserve(u16 Size) +void CVertexBuffer::Reserve(uint16 Size) { - u32 ReserveSize = mPositions.size() + Size; + uint32 ReserveSize = mPositions.size() + Size; if (mVtxDesc & ePosition) mPositions.reserve(ReserveSize); @@ -114,7 +114,7 @@ void CVertexBuffer::Reserve(u16 Size) if (mVtxDesc & eColor1) mColors[1].reserve(ReserveSize); - for (u32 iTex = 0; iTex < 8; iTex++) + for (uint32 iTex = 0; iTex < 8; iTex++) if (mVtxDesc & (eTex0 << iTex)) mTexCoords[iTex].reserve(ReserveSize); @@ -136,7 +136,7 @@ void CVertexBuffer::Clear() mColors[0].clear(); mColors[1].clear(); - for (u32 iTex = 0; iTex < 8; iTex++) + for (uint32 iTex = 0; iTex < 8; iTex++) mTexCoords[iTex].clear(); mBoneIndices.clear(); @@ -155,7 +155,7 @@ void CVertexBuffer::Buffer() // Generate buffers glGenBuffers(14, mAttribBuffers); - for (u32 iAttrib = 0; iAttrib < 14; iAttrib++) + for (uint32 iAttrib = 0; iAttrib < 14; iAttrib++) { int Attrib = (ePosition << iAttrib); bool HasAttrib = ((mVtxDesc & Attrib) != 0); @@ -171,7 +171,7 @@ void CVertexBuffer::Buffer() else if (iAttrib < 4) { - u8 Index = (u8) (iAttrib - 2); + uint8 Index = (uint8) (iAttrib - 2); glBindBuffer(GL_ARRAY_BUFFER, mAttribBuffers[iAttrib]); glBufferData(GL_ARRAY_BUFFER, mColors[Index].size() * sizeof(CColor), mColors[Index].data(), GL_STATIC_DRAW); @@ -179,7 +179,7 @@ void CVertexBuffer::Buffer() else if (iAttrib < 12) { - u8 Index = (u8) (iAttrib - 4); + uint8 Index = (uint8) (iAttrib - 4); glBindBuffer(GL_ARRAY_BUFFER, mAttribBuffers[iAttrib]); glBufferData(GL_ARRAY_BUFFER, mTexCoords[Index].size() * sizeof(CVector2f), mTexCoords[Index].data(), GL_STATIC_DRAW); @@ -234,7 +234,7 @@ void CVertexBuffer::SetSkin(CSkin *pSkin) mpSkin = pSkin; } -u32 CVertexBuffer::Size() +uint32 CVertexBuffer::Size() { return mPositions.size(); } @@ -245,7 +245,7 @@ GLuint CVertexBuffer::CreateVAO() glGenVertexArrays(1, &VertexArray); glBindVertexArray(VertexArray); - for (u32 iAttrib = 0; iAttrib < 14; iAttrib++) + for (uint32 iAttrib = 0; iAttrib < 14; iAttrib++) { int Attrib = (ePosition << iAttrib); bool HasAttrib = ((mVtxDesc & Attrib) != 0); diff --git a/src/Core/OpenGL/CVertexBuffer.h b/src/Core/OpenGL/CVertexBuffer.h index 4a9c8058..4cc4242b 100644 --- a/src/Core/OpenGL/CVertexBuffer.h +++ b/src/Core/OpenGL/CVertexBuffer.h @@ -25,9 +25,9 @@ public: CVertexBuffer(); CVertexBuffer(FVertexDescription Desc); ~CVertexBuffer(); - u16 AddVertex(const CVertex& rkVtx); - u16 AddIfUnique(const CVertex& rkVtx, u16 Start); - void Reserve(u16 Size); + uint16 AddVertex(const CVertex& rkVtx); + uint16 AddIfUnique(const CVertex& rkVtx, uint16 Start); + void Reserve(uint16 Size); void Clear(); void Buffer(); void Bind(); @@ -36,7 +36,7 @@ public: FVertexDescription VertexDesc(); void SetVertexDesc(FVertexDescription Desc); void SetSkin(CSkin *pSkin); - u32 Size(); + uint32 Size(); GLuint CreateVAO(); }; diff --git a/src/Core/OpenGL/GLCommon.h b/src/Core/OpenGL/GLCommon.h index 1bc5bdf0..c6b40b32 100644 --- a/src/Core/OpenGL/GLCommon.h +++ b/src/Core/OpenGL/GLCommon.h @@ -1,7 +1,7 @@ #ifndef GLCOMMON_H #define GLCOMMON_H -#include +#include #include enum EBlendFactor diff --git a/src/Core/Render/CBoneTransformData.h b/src/Core/Render/CBoneTransformData.h index 7517cbd3..07e0a3ce 100644 --- a/src/Core/Render/CBoneTransformData.h +++ b/src/Core/Render/CBoneTransformData.h @@ -2,8 +2,8 @@ #define CBONETRANSFORMDATA #include "Core/Resource/Animation/CSkeleton.h" -#include -#include +#include +#include #include class CBoneTransformData @@ -11,16 +11,16 @@ class CBoneTransformData std::vector mBoneMatrices; public: - CBoneTransformData() { } - CBoneTransformData(CSkeleton *pSkel) { ResizeToSkeleton(pSkel); } - inline void ResizeToSkeleton(CSkeleton *pSkel) { mBoneMatrices.resize(pSkel ? pSkel->MaxBoneID() + 1 : 0); } - inline CTransform4f& BoneMatrix(u32 BoneID) { return mBoneMatrices[BoneID]; } - inline const CTransform4f& BoneMatrix(u32 BoneID) const { return mBoneMatrices[BoneID]; } - inline const void* Data() const { return mBoneMatrices.data(); } - inline u32 DataSize() const { return mBoneMatrices.size() * sizeof(CTransform4f); } - inline u32 NumTrackedBones() const { return mBoneMatrices.size(); } - inline CTransform4f& operator[](u32 BoneIndex) { return BoneMatrix(BoneIndex); } - inline const CTransform4f& operator[](u32 BoneIndex) const { return BoneMatrix(BoneIndex); } + CBoneTransformData() { } + CBoneTransformData(CSkeleton *pSkel) { ResizeToSkeleton(pSkel); } + inline void ResizeToSkeleton(CSkeleton *pSkel) { mBoneMatrices.resize(pSkel ? pSkel->MaxBoneID() + 1 : 0); } + inline CTransform4f& BoneMatrix(uint32 BoneID) { return mBoneMatrices[BoneID]; } + inline const CTransform4f& BoneMatrix(uint32 BoneID) const { return mBoneMatrices[BoneID]; } + inline const void* Data() const { return mBoneMatrices.data(); } + inline uint32 DataSize() const { return mBoneMatrices.size() * sizeof(CTransform4f); } + inline uint32 NumTrackedBones() const { return mBoneMatrices.size(); } + inline CTransform4f& operator[](uint32 BoneIndex) { return BoneMatrix(BoneIndex); } + inline const CTransform4f& operator[](uint32 BoneIndex) const { return BoneMatrix(BoneIndex); } }; #endif // CBONETRANSFORMDATA diff --git a/src/Core/Render/CCamera.cpp b/src/Core/Render/CCamera.cpp index c1ecb4f1..ec9e4bb7 100644 --- a/src/Core/Render/CCamera.cpp +++ b/src/Core/Render/CCamera.cpp @@ -1,7 +1,7 @@ #include "CCamera.h" #include "CGraphics.h" -#include -#include +#include +#include CCamera::CCamera() : mMode(eFreeCamera) diff --git a/src/Core/Render/CCamera.h b/src/Core/Render/CCamera.h index 694066f6..c49b64bf 100644 --- a/src/Core/Render/CCamera.h +++ b/src/Core/Render/CCamera.h @@ -1,15 +1,15 @@ #ifndef CCAMERA_H #define CCAMERA_H -#include +#include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include enum ECameraMoveMode { diff --git a/src/Core/Render/CDrawUtil.cpp b/src/Core/Render/CDrawUtil.cpp index 7c37c17b..8d3f2fd7 100644 --- a/src/Core/Render/CDrawUtil.cpp +++ b/src/Core/Render/CDrawUtil.cpp @@ -2,7 +2,7 @@ #include "CGraphics.h" #include "Core/GameProject/CResourceStore.h" #include -#include +#include #include // ************ MEMBER INITIALIZATION ************ @@ -85,7 +85,7 @@ void CDrawUtil::DrawSquare(const float *pTexCoords) Init(); // Set tex coords - for (u32 iTex = 0; iTex < 8; iTex++) + for (uint32 iTex = 0; iTex < 8; iTex++) { EVertexAttribute TexAttrib = (EVertexAttribute) (eTex0 << (iTex *2)); mSquareVertices.BufferAttrib(TexAttrib, pTexCoords); @@ -357,7 +357,7 @@ CShader* CDrawUtil::GetTextShader() return mpTextShader; } -void CDrawUtil::LoadCheckerboardTexture(u32 GLTextureUnit) +void CDrawUtil::LoadCheckerboardTexture(uint32 GLTextureUnit) { Init(); mpCheckerTexture->Bind(GLTextureUnit); @@ -390,7 +390,7 @@ void CDrawUtil::Init() { if (!mDrawUtilInitialized) { - Log::Write("Initializing CDrawUtil"); + debugf("Initializing CDrawUtil"); InitGrid(); InitSquare(); InitLine(); @@ -406,7 +406,7 @@ void CDrawUtil::Init() void CDrawUtil::InitGrid() { - Log::Write("Creating grid"); + debugf("Creating grid"); const int kGridSize = 501; // must be odd const float kGridSpacing = 1.f; @@ -416,7 +416,7 @@ void CDrawUtil::InitGrid() mGridVertices.SetVertexDesc(ePosition); mGridVertices.Reserve(kGridSize * 4); - for (s32 i = MinIdx; i <= MaxIdx; i++) + for (int32 i = MinIdx; i <= MaxIdx; i++) { if (i == 0) continue; mGridVertices.AddVertex(CVector3f(MinIdx * kGridSpacing, i * kGridSpacing, 0.0f)); @@ -432,13 +432,13 @@ void CDrawUtil::InitGrid() int NumIndices = kGridSize * 4; mGridIndices.Reserve(NumIndices); - for (u16 i = 0; i < NumIndices; i++) mGridIndices.AddIndex(i); + for (uint16 i = 0; i < NumIndices; i++) mGridIndices.AddIndex(i); mGridIndices.SetPrimitiveType(GL_LINES); } void CDrawUtil::InitSquare() { - Log::Write("Creating square"); + debugf("Creating square"); mSquareVertices.SetActiveAttribs(ePosition | eNormal | eTex0 | eTex1 | eTex2 | eTex3 | eTex4 | eTex5 | eTex6 | eTex7); @@ -468,7 +468,7 @@ void CDrawUtil::InitSquare() mSquareVertices.BufferAttrib(ePosition, SquareVertices); mSquareVertices.BufferAttrib(eNormal, SquareNormals); - for (u32 iTex = 0; iTex < 8; iTex++) + for (uint32 iTex = 0; iTex < 8; iTex++) { EVertexAttribute Attrib = (EVertexAttribute) (eTex0 << (iTex *2)); mSquareVertices.BufferAttrib(Attrib, SquareTexCoords); @@ -484,7 +484,7 @@ void CDrawUtil::InitSquare() void CDrawUtil::InitLine() { - Log::Write("Creating line"); + debugf("Creating line"); mLineVertices.SetActiveAttribs(ePosition); mLineVertices.SetVertexCount(2); @@ -496,13 +496,13 @@ void CDrawUtil::InitLine() void CDrawUtil::InitCube() { - Log::Write("Creating cube"); + debugf("Creating cube"); mpCubeModel = gpEditorStore->LoadResource("Cube.CMDL"); } void CDrawUtil::InitWireCube() { - Log::Write("Creating wire cube"); + debugf("Creating wire cube"); mWireCubeVertices.SetVertexDesc(ePosition); mWireCubeVertices.Reserve(8); mWireCubeVertices.AddVertex(CVector3f(-0.5f, -0.5f, -0.5f)); @@ -514,7 +514,7 @@ void CDrawUtil::InitWireCube() mWireCubeVertices.AddVertex(CVector3f( 0.5f, 0.5f, 0.5f)); mWireCubeVertices.AddVertex(CVector3f(-0.5f, 0.5f, 0.5f)); - u16 Indices[] = { + uint16 Indices[] = { 0, 1, 1, 2, 2, 3, @@ -528,26 +528,26 @@ void CDrawUtil::InitWireCube() 2, 6, 3, 5 }; - mWireCubeIndices.AddIndices(Indices, sizeof(Indices) / sizeof(u16)); + mWireCubeIndices.AddIndices(Indices, sizeof(Indices) / sizeof(uint16)); mWireCubeIndices.SetPrimitiveType(GL_LINES); } void CDrawUtil::InitSphere() { - Log::Write("Creating sphere"); + debugf("Creating sphere"); mpSphereModel = gpEditorStore->LoadResource("Sphere.CMDL"); mpDoubleSidedSphereModel = gpEditorStore->LoadResource("SphereDoubleSided.CMDL"); } void CDrawUtil::InitWireSphere() { - Log::Write("Creating wire sphere"); + debugf("Creating wire sphere"); mpWireSphereModel = gpEditorStore->LoadResource("WireSphere.CMDL"); } void CDrawUtil::InitShaders() { - Log::Write("Creating shaders"); + debugf("Creating shaders"); mpColorShader = CShader::FromResourceFile("ColorShader"); mpColorShaderLighting = CShader::FromResourceFile("ColorShaderLighting"); mpBillboardShader = CShader::FromResourceFile("BillboardShader"); @@ -559,7 +559,7 @@ void CDrawUtil::InitShaders() void CDrawUtil::InitTextures() { - Log::Write("Loading textures"); + debugf("Loading textures"); mpCheckerTexture = gpEditorStore->LoadResource("Checkerboard.TXTR"); mpLightTextures[0] = gpEditorStore->LoadResource("LightAmbient.TXTR"); @@ -577,7 +577,7 @@ void CDrawUtil::Shutdown() { if (mDrawUtilInitialized) { - Log::Write("Shutting down"); + debugf("Shutting down"); delete mpColorShader; delete mpColorShaderLighting; delete mpTextureShader; diff --git a/src/Core/Render/CDrawUtil.h b/src/Core/Render/CDrawUtil.h index 91c33fda..7daa7d39 100644 --- a/src/Core/Render/CDrawUtil.h +++ b/src/Core/Render/CDrawUtil.h @@ -92,7 +92,7 @@ public: static void UseCollisionShader(bool IsFloor, bool IsUnstandable, const CColor& TintColor = CColor::skWhite); static CShader* GetTextShader(); - static void LoadCheckerboardTexture(u32 GLTextureUnit); + static void LoadCheckerboardTexture(uint32 GLTextureUnit); static CTexture* GetLightTexture(ELightType Type); static CTexture* GetLightMask(ELightType Type); static CModel* GetCubeModel(); diff --git a/src/Core/Render/CGraphics.cpp b/src/Core/Render/CGraphics.cpp index 42bf3d97..441e18f9 100644 --- a/src/Core/Render/CGraphics.cpp +++ b/src/Core/Render/CGraphics.cpp @@ -9,8 +9,8 @@ CUniformBuffer* CGraphics::mpVertexBlockBuffer; CUniformBuffer* CGraphics::mpPixelBlockBuffer; CUniformBuffer* CGraphics::mpLightBlockBuffer; CUniformBuffer* CGraphics::mpBoneTransformBuffer; -u32 CGraphics::mContextIndices = 0; -u32 CGraphics::mActiveContext = -1; +uint32 CGraphics::mContextIndices = 0; +uint32 CGraphics::mActiveContext = -1; bool CGraphics::mInitialized = false; std::vector CGraphics::mVAMs; bool CGraphics::mIdentityBoneTransforms = false; @@ -21,7 +21,7 @@ CGraphics::SPixelBlock CGraphics::sPixelBlock; CGraphics::SLightBlock CGraphics::sLightBlock; CGraphics::ELightingMode CGraphics::sLightMode; -u32 CGraphics::sNumLights; +uint32 CGraphics::sNumLights; const CColor CGraphics::skDefaultAmbientColor = CColor(0.5f, 0.5f, 0.5f, 1.f); CColor CGraphics::sAreaAmbientColor = CColor::skBlack; float CGraphics::sWorldLightMultiplier; @@ -36,12 +36,12 @@ void CGraphics::Initialize() { if (!mInitialized) { - Log::Write("Initializing GLEW"); + debugf("Initializing GLEW"); glewExperimental = true; glewInit(); glGetError(); // This is to work around a glew bug - error is always set after initializing - Log::Write("Creating uniform buffers"); + debugf("Creating uniform buffers"); mpMVPBlockBuffer = new CUniformBuffer(sizeof(sMVPBlock)); mpVertexBlockBuffer = new CUniformBuffer(sizeof(sVertexBlock)); mpPixelBlockBuffer = new CUniformBuffer(sizeof(sPixelBlock)); @@ -66,7 +66,7 @@ void CGraphics::Shutdown() { if (mInitialized) { - Log::Write("Shutting down CGraphics"); + debugf("Shutting down CGraphics"); delete mpMVPBlockBuffer; delete mpVertexBlockBuffer; delete mpPixelBlockBuffer; @@ -121,11 +121,11 @@ GLuint CGraphics::BoneTransformBlockBindingPoint() return 4; } -u32 CGraphics::GetContextIndex() +uint32 CGraphics::GetContextIndex() { - for (u32 iCon = 0; iCon < 32; iCon++) + for (uint32 iCon = 0; iCon < 32; iCon++) { - u32 Mask = (1 << iCon); + uint32 Mask = (1 << iCon); if ((mContextIndices & Mask) == 0) { mContextIndices |= Mask; @@ -141,19 +141,19 @@ u32 CGraphics::GetContextIndex() return -1; } -u32 CGraphics::GetActiveContext() +uint32 CGraphics::GetActiveContext() { return mActiveContext; } -void CGraphics::ReleaseContext(u32 Index) +void CGraphics::ReleaseContext(uint32 Index) { if (Index < 32) mContextIndices &= ~(1 << Index); if (mActiveContext == Index) mActiveContext = -1; delete mVAMs[Index]; } -void CGraphics::SetActiveContext(u32 Index) +void CGraphics::SetActiveContext(uint32 Index) { mActiveContext = Index; mVAMs[Index]->SetCurrent(); diff --git a/src/Core/Render/CGraphics.h b/src/Core/Render/CGraphics.h index ea94a8fd..c38444cd 100644 --- a/src/Core/Render/CGraphics.h +++ b/src/Core/Render/CGraphics.h @@ -6,9 +6,9 @@ #include "Core/OpenGL/CVertexArrayManager.h" #include "Core/Resource/CLight.h" #include -#include -#include -#include +#include +#include +#include #include /** @@ -25,8 +25,8 @@ class CGraphics static CUniformBuffer *mpPixelBlockBuffer; static CUniformBuffer *mpLightBlockBuffer; static CUniformBuffer *mpBoneTransformBuffer; - static u32 mContextIndices; - static u32 mActiveContext; + static uint32 mContextIndices; + static uint32 mActiveContext; static bool mInitialized; static std::vector mVAMs; static bool mIdentityBoneTransforms; @@ -81,7 +81,7 @@ public: // Lighting-related enum ELightingMode { eNoLighting, eBasicLighting, eWorldLighting }; static ELightingMode sLightMode; - static u32 sNumLights; + static uint32 sNumLights; static const CColor skDefaultAmbientColor; static CColor sAreaAmbientColor; static float sWorldLightMultiplier; @@ -99,10 +99,10 @@ public: static GLuint PixelBlockBindingPoint(); static GLuint LightBlockBindingPoint(); static GLuint BoneTransformBlockBindingPoint(); - static u32 GetContextIndex(); - static u32 GetActiveContext(); - static void ReleaseContext(u32 Index); - static void SetActiveContext(u32 Index); + static uint32 GetContextIndex(); + static uint32 GetActiveContext(); + static void ReleaseContext(uint32 Index); + static void SetActiveContext(uint32 Index); static void SetDefaultLighting(); static void SetupAmbientColor(); static void SetIdentityMVP(); diff --git a/src/Core/Render/CRenderBucket.cpp b/src/Core/Render/CRenderBucket.cpp index 47700e67..d05a43fa 100644 --- a/src/Core/Render/CRenderBucket.cpp +++ b/src/Core/Render/CRenderBucket.cpp @@ -32,7 +32,7 @@ void CRenderBucket::CSubBucket::Sort(const CCamera* pkCamera, bool DebugVisualiz if (DebugVisualization) { - for (u32 iPtr = 0; iPtr < mSize; iPtr++) + for (uint32 iPtr = 0; iPtr < mSize; iPtr++) { SRenderablePtr *pPtr = &mRenderables[iPtr]; CVector3f Point = pPtr->AABox.ClosestPointAlongVector(pkCamera->Direction()); @@ -63,7 +63,7 @@ void CRenderBucket::CSubBucket::Draw(const SViewInfo& rkViewInfo) { FRenderOptions Options = rkViewInfo.pRenderer->RenderOptions(); - for (u32 iPtr = 0; iPtr < mSize; iPtr++) + for (uint32 iPtr = 0; iPtr < mSize; iPtr++) { const SRenderablePtr& rkPtr = mRenderables[iPtr]; diff --git a/src/Core/Render/CRenderBucket.h b/src/Core/Render/CRenderBucket.h index 26f4182e..fed30fa5 100644 --- a/src/Core/Render/CRenderBucket.h +++ b/src/Core/Render/CRenderBucket.h @@ -6,7 +6,7 @@ #include "CGraphics.h" #include "FRenderOptions.h" #include "SRenderablePtr.h" -#include +#include #include #include @@ -17,8 +17,8 @@ class CRenderBucket class CSubBucket { std::vector mRenderables; - u32 mEstSize; - u32 mSize; + uint32 mEstSize; + uint32 mSize; public: CSubBucket() diff --git a/src/Core/Render/CRenderer.cpp b/src/Core/Render/CRenderer.cpp index 0967f695..1e262eae 100644 --- a/src/Core/Render/CRenderer.cpp +++ b/src/Core/Render/CRenderer.cpp @@ -4,7 +4,7 @@ #include "CGraphics.h" #include "Core/GameProject/CResourceStore.h" #include "Core/Resource/Factory/CTextureDecoder.h" -#include +#include #include #include @@ -13,7 +13,7 @@ #include // ************ STATIC MEMBER INITIALIZATION ************ -u32 CRenderer::sNumRenderers = 0; +uint32 CRenderer::sNumRenderers = 0; // ************ INITIALIZATION ************ CRenderer::CRenderer() @@ -99,14 +99,14 @@ void CRenderer::SetClearColor(const CColor& rkClear) glClearColor(mClearColor.R, mClearColor.G, mClearColor.B, mClearColor.A); } -void CRenderer::SetViewportSize(u32 Width, u32 Height) +void CRenderer::SetViewportSize(uint32 Width, uint32 Height) { mViewportWidth = Width; mViewportHeight = Height; mBloomHScale = ((float) Width / 640); mBloomVScale = ((float) Height / 528); - mBloomWidth = (u32) (320 * mBloomHScale); - mBloomHeight = (u32) (224 * mBloomVScale); + mBloomWidth = (uint32) (320 * mBloomHScale); + mBloomHeight = (uint32) (224 * mBloomVScale); mBloomHScale = 1.f / mBloomHScale; mBloomVScale = 1.f / mBloomVScale; } @@ -161,8 +161,8 @@ void CRenderer::RenderBloom() CColor::Integral(53, 53, 53), CColor::Integral(17, 17, 17) }; - u32 BloomWidth = (mBloomMode == eBloom ? mBloomWidth : mViewportWidth); - u32 BloomHeight = (mBloomMode == eBloom ? mBloomHeight : mViewportHeight); + uint32 BloomWidth = (mBloomMode == eBloom ? mBloomWidth : mViewportWidth); + uint32 BloomHeight = (mBloomMode == eBloom ? mBloomHeight : mViewportHeight); float BloomHScale = (mBloomMode == eBloom ? mBloomHScale : 0); float BloomVScale = (mBloomMode == eBloom ? mBloomVScale : 0); @@ -199,7 +199,7 @@ void CRenderer::RenderBloom() mBloomFramebuffers[0].Texture()->Bind(0); CDrawUtil::DrawSquare(); - for (u32 iPass = 0; iPass < 6; iPass++) + for (uint32 iPass = 0; iPass < 6; iPass++) { CDrawUtil::UseTextureShader(skTintColors[iPass]); CVector3f Translate(skHOffset[iPass] * BloomHScale, 0.f, 0.f); @@ -219,7 +219,7 @@ void CRenderer::RenderBloom() mBloomFramebuffers[1].Texture()->Bind(0); CDrawUtil::DrawSquare(); - for (u32 iPass = 0; iPass < 6; iPass++) + for (uint32 iPass = 0; iPass < 6; iPass++) { CDrawUtil::UseTextureShader(skTintColors[iPass]); CVector3f Translate(0.f, skVOffset[iPass] * BloomVScale, 0.f); @@ -353,4 +353,4 @@ void CRenderer::InitFramebuffer() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } -u32 gDrawCount; +uint32 gDrawCount; diff --git a/src/Core/Render/CRenderer.h b/src/Core/Render/CRenderer.h index 869c7993..75758e5e 100644 --- a/src/Core/Render/CRenderer.h +++ b/src/Core/Render/CRenderer.h @@ -16,8 +16,8 @@ #include "Core/Scene/CSceneNode.h" #include -#include -#include +#include +#include #include @@ -33,10 +33,10 @@ private: EBloomMode mBloomMode; bool mDrawGrid; CColor mClearColor; - u32 mContextIndex; + uint32 mContextIndex; bool mInitialized; - u32 mViewportWidth, mViewportHeight; - u32 mBloomWidth, mBloomHeight; + uint32 mViewportWidth, mViewportHeight; + uint32 mBloomWidth, mBloomHeight; float mBloomHScale, mBloomVScale; CFramebuffer mSceneFramebuffer; @@ -50,7 +50,7 @@ private: CRenderBucket mUIBucket; // Static Members - static u32 sNumRenderers; + static uint32 sNumRenderers; public: // Initialization @@ -67,7 +67,7 @@ public: void ToggleAlphaDisabled(bool Enable); void SetBloom(EBloomMode BloomMode); void SetClearColor(const CColor& rkClear); - void SetViewportSize(u32 Width, u32 Height); + void SetViewportSize(uint32 Width, uint32 Height); // Render void RenderBuckets(const SViewInfo& rkViewInfo); @@ -83,6 +83,6 @@ private: void InitFramebuffer(); }; -extern u32 gDrawCount; +extern uint32 gDrawCount; #endif // RENDERMANAGER_H diff --git a/src/Core/Render/IRenderable.h b/src/Core/Render/IRenderable.h index 394bf9fb..21bad974 100644 --- a/src/Core/Render/IRenderable.h +++ b/src/Core/Render/IRenderable.h @@ -4,7 +4,7 @@ #include "ERenderCommand.h" #include "FRenderOptions.h" #include "SViewInfo.h" -#include +#include class CRenderer; diff --git a/src/Core/Render/SRenderablePtr.h b/src/Core/Render/SRenderablePtr.h index 21f9dadf..55d47a2e 100644 --- a/src/Core/Render/SRenderablePtr.h +++ b/src/Core/Render/SRenderablePtr.h @@ -3,13 +3,13 @@ #include "ERenderCommand.h" #include "IRenderable.h" -#include -#include +#include +#include struct SRenderablePtr { IRenderable *pRenderable; - u32 ComponentIndex; + uint32 ComponentIndex; CAABox AABox; ERenderCommand Command; }; diff --git a/src/Core/Render/SViewInfo.h b/src/Core/Render/SViewInfo.h index 2c75e3d0..dc5c6a7a 100644 --- a/src/Core/Render/SViewInfo.h +++ b/src/Core/Render/SViewInfo.h @@ -3,14 +3,14 @@ #include "Core/Resource/CCollisionMaterial.h" #include "Core/Scene/FShowFlags.h" -#include -#include -#include +#include +#include +#include struct SCollisionRenderSettings { - u64 HighlightMask; - u64 HideMask; + uint64 HighlightMask; + uint64 HideMask; CCollisionMaterial HideMaterial; bool DrawWireframe; diff --git a/src/Core/Resource/Animation/CAnimEventData.h b/src/Core/Resource/Animation/CAnimEventData.h index ffdce5f3..98771fef 100644 --- a/src/Core/Resource/Animation/CAnimEventData.h +++ b/src/Core/Resource/Animation/CAnimEventData.h @@ -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 diff --git a/src/Core/Resource/Animation/CAnimSet.h b/src/Core/Resource/Animation/CAnimSet.h index 17f928a8..3946c8e5 100644 --- a/src/Core/Resource/Animation/CAnimSet.h +++ b/src/Core/Resource/Animation/CAnimSet.h @@ -12,14 +12,14 @@ #include "Core/Resource/CResource.h" #include "Core/Resource/TResPtr.h" #include "Core/Resource/Model/CModel.h" -#include +#include #include // 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 pModel; TResPtr pSkin; @@ -79,7 +79,7 @@ struct SSetCharacter std::vector SoundEffects; std::vector DKDependencies; CAssetID SpatialPrimitives; - std::set UsedAnimationIndices; + std::set 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 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& 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()); diff --git a/src/Core/Resource/Animation/CAnimation.cpp b/src/Core/Resource/Animation/CAnimation.cpp index 66732ff7..f621c0e7 100644 --- a/src/Core/Resource/Animation/CAnimation.cpp +++ b/src/Core/Resource/Animation/CAnimation.cpp @@ -1,6 +1,6 @@ #include "CAnimation.h" -#include -#include +#include +#include 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); } diff --git a/src/Core/Resource/Animation/CAnimation.h b/src/Core/Resource/Animation/CAnimation.h index de68d444..b11c633d 100644 --- a/src/Core/Resource/Animation/CAnimation.h +++ b/src/Core/Resource/Animation/CAnimation.h @@ -4,8 +4,8 @@ #include "Core/Resource/CResource.h" #include "Core/Resource/TResPtr.h" #include "Core/Resource/Animation/CAnimEventData.h" -#include -#include +#include +#include #include class CAnimation : public CResource @@ -19,7 +19,7 @@ class CAnimation : public CResource float mDuration; float mTickInterval; - u32 mNumKeys; + uint32 mNumKeys; std::vector mScaleChannels; std::vector 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; } }; diff --git a/src/Core/Resource/Animation/CAnimationParameters.cpp b/src/Core/Resource/Animation/CAnimationParameters.cpp index 5d61bc99..9a28f580 100644 --- a/src/Core/Resource/Animation/CAnimationParameters.cpp +++ b/src/Core/Resource/Animation/CAnimationParameters.cpp @@ -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) { diff --git a/src/Core/Resource/Animation/CAnimationParameters.h b/src/Core/Resource/Animation/CAnimationParameters.h index f4687f5b..5f21b06e 100644 --- a/src/Core/Resource/Animation/CAnimationParameters.h +++ b/src/Core/Resource/Animation/CAnimationParameters.h @@ -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) diff --git a/src/Core/Resource/Animation/CSkeleton.cpp b/src/Core/Resource/Animation/CSkeleton.cpp index 6dd93b3b..a4960117 100644 --- a/src/Core/Resource/Animation/CSkeleton.cpp +++ b/src/Core/Resource/Animation/CSkeleton.cpp @@ -2,8 +2,8 @@ #include "Core/Render/CBoneTransformData.h" #include "Core/Render/CDrawUtil.h" #include "Core/Render/CGraphics.h" -#include -#include +#include +#include // ************ 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 CSkeleton::RayIntersect(const CRay& rkRay, const CBoneTransformData& rkData) +std::pair CSkeleton::RayIntersect(const CRay& rkRay, const CBoneTransformData& rkData) { - std::pair Out(-1, FLT_MAX); + std::pair 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); diff --git a/src/Core/Resource/Animation/CSkeleton.h b/src/Core/Resource/Animation/CSkeleton.h index 578de2c8..f4395ae7 100644 --- a/src/Core/Resource/Animation/CSkeleton.h +++ b/src/Core/Resource/Animation/CSkeleton.h @@ -4,10 +4,10 @@ #include "CAnimation.h" #include "Core/Render/FRenderOptions.h" #include "Core/Resource/CResource.h" +#include #include -#include -#include -#include +#include +#include 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 RayIntersect(const CRay& rkRay, const CBoneTransformData& rkData); + std::pair 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 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; } diff --git a/src/Core/Resource/Animation/CSkin.h b/src/Core/Resource/Animation/CSkin.h index 07e84a96..ada61454 100644 --- a/src/Core/Resource/Animation/CSkin.h +++ b/src/Core/Resource/Animation/CSkin.h @@ -18,14 +18,14 @@ class CSkin : public CResource struct SVertGroup { SVertexWeights Weights; - u32 NumVertices; + uint32 NumVertices; }; std::vector 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; diff --git a/src/Core/Resource/Animation/CSourceAnimData.h b/src/Core/Resource/Animation/CSourceAnimData.h index 1a3eab6b..7d68d9e0 100644 --- a/src/Core/Resource/Animation/CSourceAnimData.h +++ b/src/Core/Resource/Animation/CSourceAnimData.h @@ -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& 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; diff --git a/src/Core/Resource/Animation/IMetaAnimation.cpp b/src/Core/Resource/Animation/IMetaAnimation.cpp index 6dbec57c..6436d4ad 100644 --- a/src/Core/Resource/Animation/IMetaAnimation.cpp +++ b/src/Core/Resource/Animation/IMetaAnimation.cpp @@ -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& 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& 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& rPrimSet) const { - for (u32 iAnim = 0; iAnim < mAnimations.size(); iAnim++) + for (uint32 iAnim = 0; iAnim < mAnimations.size(); iAnim++) mAnimations[iAnim]->GetUniquePrimitives(rPrimSet); } diff --git a/src/Core/Resource/Animation/IMetaAnimation.h b/src/Core/Resource/Animation/IMetaAnimation.h index dded5923..52ca8fde 100644 --- a/src/Core/Resource/Animation/IMetaAnimation.h +++ b/src/Core/Resource/Animation/IMetaAnimation.h @@ -26,13 +26,13 @@ extern CMetaAnimFactory gMetaAnimFactory; class CAnimPrimitive { TResPtr 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& 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 diff --git a/src/Core/Resource/Animation/IMetaTransition.cpp b/src/Core/Resource/Animation/IMetaTransition.cpp index 7be47e2e..f7ff5419 100644 --- a/src/Core/Resource/Animation/IMetaTransition.cpp +++ b/src/Core/Resource/Animation/IMetaTransition.cpp @@ -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; } } diff --git a/src/Core/Resource/Animation/IMetaTransition.h b/src/Core/Resource/Animation/IMetaTransition.h index ff82d580..c7cfc6a0 100644 --- a/src/Core/Resource/Animation/IMetaTransition.h +++ b/src/Core/Resource/Animation/IMetaTransition.h @@ -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); diff --git a/src/Core/Resource/Area/CGameArea.cpp b/src/Core/Resource/Area/CGameArea.cpp index edf4c6a8..933bfb55 100644 --- a/src/Core/Resource/Area/CGameArea.cpp +++ b/src/Core/Resource/Area/CGameArea.cpp @@ -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 DummyDeps; - for (u32 iLayer = 0; iLayer < mScriptLayers.size(); iLayer++) + for (uint32 iLayer = 0; iLayer < mScriptLayers.size(); iLayer++) { const std::vector& 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; } diff --git a/src/Core/Resource/Area/CGameArea.h b/src/Core/Resource/Area/CGameArea.h index 6372dc4e..ea85f459 100644 --- a/src/Core/Resource/Area/CGameArea.h +++ b/src/Core/Resource/Area/CGameArea.h @@ -8,9 +8,9 @@ #include "Core/Resource/CPoiToWorld.h" #include "Core/Resource/Model/CModel.h" #include "Core/Resource/Model/CStaticModel.h" -#include -#include -#include +#include +#include +#include #include @@ -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> mSectionDataBuffers; - u32 mOriginalWorldMeshCount; + std::vector> mSectionDataBuffers; + uint32 mOriginalWorldMeshCount; bool mUsesCompression; struct SSectionNumber { CFourCC SectionID; - u32 Index; + uint32 Index; }; std::vector mSectionNumbers; @@ -49,7 +49,7 @@ class CGameArea : public CResource std::vector mStaticWorldModels; // StaticTerrainModels is the merged terrain for faster rendering in the world editor // Script std::vector mScriptLayers; - std::unordered_map mObjectMap; + std::unordered_map 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 diff --git a/src/Core/Resource/CAudioGroup.h b/src/Core/Resource/CAudioGroup.h index cb9bffd8..0b83ffcb 100644 --- a/src/Core/Resource/CAudioGroup.h +++ b/src/Core/Resource/CAudioGroup.h @@ -10,8 +10,8 @@ class CAudioGroup : public CResource friend class CAudioGroupLoader; TString mGroupName; - u32 mGroupID; - std::vector mDefineIDs; + uint32 mGroupID; + std::vector 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 diff --git a/src/Core/Resource/CAudioLookupTable.h b/src/Core/Resource/CAudioLookupTable.h index fc2c1f70..6141d67e 100644 --- a/src/Core/Resource/CAudioLookupTable.h +++ b/src/Core/Resource/CAudioLookupTable.h @@ -7,14 +7,14 @@ class CAudioLookupTable : public CResource { DECLARE_RESOURCE_TYPE(eAudioLookupTable) friend class CAudioGroupLoader; - std::vector mDefineIDs; + std::vector 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]; diff --git a/src/Core/Resource/CAudioMacro.h b/src/Core/Resource/CAudioMacro.h index 9d858742..d9b933eb 100644 --- a/src/Core/Resource/CAudioMacro.h +++ b/src/Core/Resource/CAudioMacro.h @@ -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 diff --git a/src/Core/Resource/CCollisionMaterial.cpp b/src/Core/Resource/CCollisionMaterial.cpp index c7369489..faee1931 100644 --- a/src/Core/Resource/CCollisionMaterial.cpp +++ b/src/Core/Resource/CCollisionMaterial.cpp @@ -1,5 +1,5 @@ #include "CCollisionMaterial.h" -#include +#include #include 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]; diff --git a/src/Core/Resource/CCollisionMaterial.h b/src/Core/Resource/CCollisionMaterial.h index 021fdf8c..e1ed6dd9 100644 --- a/src/Core/Resource/CCollisionMaterial.h +++ b/src/Core/Resource/CCollisionMaterial.h @@ -51,7 +51,7 @@ enum ECollisionFlag class CCollisionMaterial : public TFlags { 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 diff --git a/src/Core/Resource/CCollisionMesh.cpp b/src/Core/Resource/CCollisionMesh.cpp index b5744919..593aefac 100644 --- a/src/Core/Resource/CCollisionMesh.cpp +++ b/src/Core/Resource/CCollisionMesh.cpp @@ -1,7 +1,7 @@ #include "CCollisionMesh.h" #include "Core/Render/CRenderer.h" #include "Core/Render/CDrawUtil.h" -#include +#include 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]; } diff --git a/src/Core/Resource/CCollisionMesh.h b/src/Core/Resource/CCollisionMesh.h index bd9bbe59..7b8dee04 100644 --- a/src/Core/Resource/CCollisionMesh.h +++ b/src/Core/Resource/CCollisionMesh.h @@ -5,7 +5,7 @@ #include "CResource.h" #include "Core/OpenGL/CVertexBuffer.h" #include "Core/OpenGL/CIndexBuffer.h" -#include +#include class CCollisionMesh { @@ -19,12 +19,12 @@ class CCollisionMesh struct SLeaf : public SOctreeNode { CAABox AABox; - std::vector FaceIndices; + std::vector 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 mCollisionVertices; std::vector mCollisionLines; std::vector mCollisionFaces; - std::vector mMaterialOffsets; + std::vector 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 diff --git a/src/Core/Resource/CCollisionMeshGroup.h b/src/Core/Resource/CCollisionMeshGroup.h index 8d4d2328..4fce38df 100644 --- a/src/Core/Resource/CCollisionMeshGroup.h +++ b/src/Core/Resource/CCollisionMeshGroup.h @@ -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() { diff --git a/src/Core/Resource/CDependencyGroup.h b/src/Core/Resource/CDependencyGroup.h index 39b7a353..e3e5d7d3 100644 --- a/src/Core/Resource/CDependencyGroup.h +++ b/src/Core/Resource/CDependencyGroup.h @@ -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; diff --git a/src/Core/Resource/CFont.cpp b/src/Core/Resource/CFont.cpp index 6b4d05fd..b8ef9734 100644 --- a/src/Core/Resource/CFont.cpp +++ b/src/Core/Resource/CFont.cpp @@ -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; diff --git a/src/Core/Resource/CFont.h b/src/Core/Resource/CFont.h index 1d67bb12..a1895b5d 100644 --- a/src/Core/Resource/CFont.h +++ b/src/Core/Resource/CFont.h @@ -7,7 +7,7 @@ #include "Core/Resource/Model/CVertex.h" #include "Core/OpenGL/CDynamicVertexBuffer.h" #include "Core/OpenGL/CIndexBuffer.h" -#include +#include #include #include @@ -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 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 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 mGlyphs; + std::unordered_map 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 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; } diff --git a/src/Core/Resource/CLight.cpp b/src/Core/Resource/CLight.cpp index 6ca99f67..ebca5424 100644 --- a/src/Core/Resource/CLight.cpp +++ b/src/Core/Resource/CLight.cpp @@ -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]; diff --git a/src/Core/Resource/CLight.h b/src/Core/Resource/CLight.h index 83b1877c..f2e549a5 100644 --- a/src/Core/Resource/CLight.h +++ b/src/Core/Resource/CLight.h @@ -4,7 +4,7 @@ #include "Core/Resource/Script/Property/Properties.h" #include #include -#include +#include /* 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; } diff --git a/src/Core/Resource/CMaterial.cpp b/src/Core/Resource/CMaterial.cpp index d3a9e5bc..a71ee814 100644 --- a/src/Core/Resource/CMaterial.cpp +++ b/src/Core/Resource/CMaterial.cpp @@ -9,9 +9,9 @@ #include #include -u64 CMaterial::sCurrentMaterial = 0; +uint64 CMaterial::sCurrentMaterial = 0; CColor CMaterial::sCurrentTint = CColor::skWhite; -std::map CMaterial::smShaderMap; +std::map 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); } diff --git a/src/Core/Resource/CMaterial.h b/src/Core/Resource/CMaterial.h index e87bf056..9e9cc6ed 100644 --- a/src/Core/Resource/CMaterial.h +++ b/src/Core/Resource/CMaterial.h @@ -8,10 +8,10 @@ #include "Core/Render/FRenderOptions.h" #include "Core/OpenGL/CShader.h" +#include #include #include #include -#include #include 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 mpIndirectTexture; // Optional texture used for the indirect stage for reflections std::vector mPasses; @@ -78,7 +78,7 @@ private: int NumReferences; CShader *pShader; }; - static std::map smShaderMap; + static std::map 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(); } diff --git a/src/Core/Resource/CMaterialPass.cpp b/src/Core/Resource/CMaterialPass.cpp index 319ee936..c5838a18 100644 --- a/src/Core/Resource/CMaterialPass.cpp +++ b/src/Core/Resource/CMaterialPass.cpp @@ -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; } diff --git a/src/Core/Resource/CMaterialPass.h b/src/Core/Resource/CMaterialPass.h index 5fe98288..7f21de19 100644 --- a/src/Core/Resource/CMaterialPass.h +++ b/src/Core/Resource/CMaterialPass.h @@ -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 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); diff --git a/src/Core/Resource/CMaterialSet.h b/src/Core/Resource/CMaterialSet.h index 219fc07c..476ad1c0 100644 --- a/src/Core/Resource/CMaterialSet.h +++ b/src/Core/Resource/CMaterialSet.h @@ -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& 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()); diff --git a/src/Core/Resource/CPoiToWorld.cpp b/src/Core/Resource/CPoiToWorld.cpp index 3cd124b5..b4a55868 100644 --- a/src/Core/Resource/CPoiToWorld.cpp +++ b/src/Core/Resource/CPoiToWorld.cpp @@ -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); diff --git a/src/Core/Resource/CPoiToWorld.h b/src/Core/Resource/CPoiToWorld.h index 262e4358..8bcc95dc 100644 --- a/src/Core/Resource/CPoiToWorld.h +++ b/src/Core/Resource/CPoiToWorld.h @@ -13,34 +13,34 @@ class CPoiToWorld : public CResource public: struct SPoiMap { - u32 PoiID; - std::list ModelIDs; + uint32 PoiID; + std::list ModelIDs; }; private: std::vector mMaps; - std::map mPoiLookupMap; + std::map 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()); diff --git a/src/Core/Resource/CResTypeInfo.cpp b/src/Core/Resource/CResTypeInfo.cpp index 8b6c081a..dd491478 100644 --- a/src/Core/Resource/CResTypeInfo.cpp +++ b/src/Core/Resource/CResTypeInfo.cpp @@ -1,5 +1,5 @@ #include "CResTypeInfo.h" -#include +#include #include std::unordered_map 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; diff --git a/src/Core/Resource/CResource.h b/src/Core/Resource/CResource.h index a2d5868e..e385ca2b 100644 --- a/src/Core/Resource/CResource.h +++ b/src/Core/Resource/CResource.h @@ -8,7 +8,6 @@ #include "Core/GameProject/CResourceStore.h" #include #include -#include #include #include diff --git a/src/Core/Resource/CSavedStateID.h b/src/Core/Resource/CSavedStateID.h index 5cfed855..417a0ed9 100644 --- a/src/Core/Resource/CSavedStateID.h +++ b/src/Core/Resource/CSavedStateID.h @@ -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; } diff --git a/src/Core/Resource/CScan.h b/src/Core/Resource/CScan.h index f99febd3..2b88a43f 100644 --- a/src/Core/Resource/CScan.h +++ b/src/Core/Resource/CScan.h @@ -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 diff --git a/src/Core/Resource/CStringList.h b/src/Core/Resource/CStringList.h index f4a4232b..8a4b7b73 100644 --- a/src/Core/Resource/CStringList.h +++ b/src/Core/Resource/CStringList.h @@ -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]; diff --git a/src/Core/Resource/CStringTable.h b/src/Core/Resource/CStringTable.h index 7863e31e..8ed8ce88 100644 --- a/src/Core/Resource/CStringTable.h +++ b/src/Core/Resource/CStringTable.h @@ -2,9 +2,9 @@ #define CSTRINGTABLE_H #include "CResource.h" +#include #include #include -#include #include class CStringTable : public CResource @@ -13,7 +13,7 @@ class CStringTable : public CResource friend class CStringLoader; std::vector 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] == '&') { diff --git a/src/Core/Resource/CTexture.cpp b/src/Core/Resource/CTexture.cpp index 9c33a5e1..81079a12 100644 --- a/src/Core/Resource/CTexture.cpp +++ b/src/Core/Resource/CTexture.cpp @@ -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; } diff --git a/src/Core/Resource/CTexture.h b/src/Core/Resource/CTexture.h index 6688fba0..600b0af9 100644 --- a/src/Core/Resource/CTexture.h +++ b/src/Core/Resource/CTexture.h @@ -3,9 +3,9 @@ #include "CResource.h" #include "ETexelFormat.h" +#include #include -#include -#include +#include #include @@ -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(); }; diff --git a/src/Core/Resource/CWorld.cpp b/src/Core/Resource/CWorld.cpp index 22c5417d..78d05b46 100644 --- a/src/Core/Resource/CWorld.cpp +++ b/src/Core/Resource/CWorld.cpp @@ -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; diff --git a/src/Core/Resource/CWorld.h b/src/Core/Resource/CWorld.h index 01cffd72..76259e6b 100644 --- a/src/Core/Resource/CWorld.h +++ b/src/Core/Resource/CWorld.h @@ -6,7 +6,7 @@ #include "CStringTable.h" #include "Core/Resource/Area/CGameArea.h" #include "Core/Resource/Model/CModel.h" -#include +#include class CWorld : public CResource { @@ -21,7 +21,7 @@ class CWorld : public CResource TResPtr mpSaveWorld; TResPtr mpDefaultSkybox; TResPtr 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 mAudioGrps; struct SMemoryRelay { - u32 InstanceID; - u32 TargetID; - u16 Message; + uint32 InstanceID; + uint32 TargetID; + uint16 Message; bool Active; }; std::vector mMemoryRelays; @@ -60,16 +60,16 @@ class CWorld : public CResource bool AllowPakDuplicates; std::vector MemoryRelays; // Only needed for MP1 - std::vector AttachedAreaIDs; + std::vector AttachedAreaIDs; std::vector RelFilenames; // Needs to be removed & generated at cook; temporarily leaving for debugging - std::vector RelOffsets; + std::vector RelOffsets; struct SDock { struct SConnectingDock { - u32 AreaIndex; - u32 DockIndex; + uint32 AreaIndex; + uint32 DockIndex; }; std::vector ConnectingDocks; std::vector 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 diff --git a/src/Core/Resource/Cooker/CAreaCooker.cpp b/src/Core/Resource/Cooker/CAreaCooker.cpp index a0a73135..43664e9c 100644 --- a/src/Core/Resource/Cooker/CAreaCooker.cpp +++ b/src/Core/Resource/Cooker/CAreaCooker.cpp @@ -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 LayerSizes(NumLayers); + std::vector 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 Dependencies; - std::list LayerOffsets; + std::list LayerOffsets; CAreaDependencyListBuilder Builder(mpArea->Entry()); Builder.BuildDependencyList(Dependencies, LayerOffsets); @@ -289,7 +289,7 @@ void CAreaCooker::WriteModules(IOutputStream& rOut) { // Build module list std::vector ModuleNames; - std::vector LayerOffsets; + std::vector LayerOffsets; CAreaDependencyTree *pAreaDeps = static_cast(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 CompressedBuf(mCompressedData.Size() * 2); + std::vector 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) { diff --git a/src/Core/Resource/Cooker/CAreaCooker.h b/src/Core/Resource/Cooker/CAreaCooker.h index fe9b0e01..afd39724 100644 --- a/src/Core/Resource/Cooker/CAreaCooker.h +++ b/src/Core/Resource/Cooker/CAreaCooker.h @@ -11,28 +11,28 @@ class CAreaCooker TResPtr mpArea; EGame mVersion; - std::vector mSectionSizes; + std::vector 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 diff --git a/src/Core/Resource/Cooker/CMaterialCooker.cpp b/src/Core/Resource/Cooker/CMaterialCooker.cpp index 8f775746..57fe0b5e 100644 --- a/src/Core/Resource/Cooker/CMaterialCooker.cpp +++ b/src/Core/Resource/Cooker/CMaterialCooker.cpp @@ -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 MatEndOffsets(NumMats); + uint32 MatsStart = rOut.Tell(); + std::vector 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 TexIndices; + uint32 TexFlags = 0; + uint32 NumKonst = 0; + std::vector 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); diff --git a/src/Core/Resource/Cooker/CMaterialCooker.h b/src/Core/Resource/Cooker/CMaterialCooker.h index 70beefa1..277b1068 100644 --- a/src/Core/Resource/Cooker/CMaterialCooker.h +++ b/src/Core/Resource/Cooker/CMaterialCooker.h @@ -10,11 +10,11 @@ class CMaterialCooker CMaterialSet *mpSet; CMaterial *mpMat; EGame mVersion; - std::vector mTextureIDs; - std::vector mMaterialHashes; + std::vector mTextureIDs; + std::vector mMaterialHashes; CMaterialCooker(); - u32 ConvertFromVertexDescription(FVertexDescription VtxDesc); + uint32 ConvertFromVertexDescription(FVertexDescription VtxDesc); void WriteMatSetPrime(IOutputStream& rOut); void WriteMatSetCorruption(IOutputStream& rOut); void WriteMaterialPrime(IOutputStream& rOut); diff --git a/src/Core/Resource/Cooker/CModelCooker.cpp b/src/Core/Resource/Cooker/CModelCooker.cpp index ffecd12c..d5ec628d 100644 --- a/src/Core/Resource/Cooker/CModelCooker.cpp +++ b/src/Core/Resource/Cooker/CModelCooker.cpp @@ -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 SectionSizes; + std::vector 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 SurfaceEndOffsets(mNumSurfaces); + uint32 SurfacesStart = rOut.Tell(); + std::vector 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) { diff --git a/src/Core/Resource/Cooker/CModelCooker.h b/src/Core/Resource/Cooker/CModelCooker.h index c0364511..2ffc64de 100644 --- a/src/Core/Resource/Cooker/CModelCooker.h +++ b/src/Core/Resource/Cooker/CModelCooker.h @@ -9,10 +9,10 @@ class CModelCooker { TResPtr mpModel; EGame mVersion; - u32 mNumMatSets; - u32 mNumSurfaces; - u32 mNumVertices; - u8 mVertexFormat; + uint32 mNumMatSets; + uint32 mNumSurfaces; + uint32 mNumVertices; + uint8 mVertexFormat; std::vector 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 diff --git a/src/Core/Resource/Cooker/CPoiToWorldCooker.cpp b/src/Core/Resource/Cooker/CPoiToWorldCooker.cpp index 096e0677..8bbe2894 100644 --- a/src/Core/Resource/Cooker/CPoiToWorldCooker.cpp +++ b/src/Core/Resource/Cooker/CPoiToWorldCooker.cpp @@ -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 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); diff --git a/src/Core/Resource/Cooker/CResourceCooker.h b/src/Core/Resource/Cooker/CResourceCooker.h index c1e6a1db..30cede34 100644 --- a/src/Core/Resource/Cooker/CResourceCooker.h +++ b/src/Core/Resource/Cooker/CResourceCooker.h @@ -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; } } diff --git a/src/Core/Resource/Cooker/CScriptCooker.cpp b/src/Core/Resource/Cooker/CScriptCooker.cpp index 3f659621..0cb467c9 100644 --- a/src/Core/Resource/Cooker/CScriptCooker.cpp +++ b/src/Core/Resource/Cooker/CScriptCooker.cpp @@ -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(pProperty); std::vector 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(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]); } diff --git a/src/Core/Resource/Cooker/CSectionMgrOut.h b/src/Core/Resource/Cooker/CSectionMgrOut.h index 1f49bf7c..cc4aba7a 100644 --- a/src/Core/Resource/Cooker/CSectionMgrOut.h +++ b/src/Core/Resource/Cooker/CSectionMgrOut.h @@ -1,17 +1,17 @@ #ifndef CBLOCKMGROUT_H #define CBLOCKMGROUT_H -#include +#include #include #include // Small class to manage file sections for CMDL/MREA output class CSectionMgrOut { - u32 mSectionCount; - u32 mCurSectionStart; - u32 mCurSectionIndex; - std::vector mSectionSizes; + uint32 mSectionCount; + uint32 mCurSectionStart; + uint32 mCurSectionIndex; + std::vector 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]); } }; diff --git a/src/Core/Resource/Cooker/CTextureEncoder.cpp b/src/Core/Resource/Cooker/CTextureEncoder.cpp index a462020a..acb8d785 100644 --- a/src/Core/Resource/Cooker/CTextureEncoder.cpp +++ b/src/Core/Resource/Cooker/CTextureEncoder.cpp @@ -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; } diff --git a/src/Core/Resource/Cooker/CWorldCooker.cpp b/src/Core/Resource/Cooker/CWorldCooker.cpp index 3ec30206..0128d6ce 100644 --- a/src/Core/Resource/Cooker/CWorldCooker.cpp +++ b/src/Core/Resource/Cooker/CWorldCooker.cpp @@ -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 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 Dependencies; - std::list LayerDependsOffsets; + std::list 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 ModuleNames; - std::vector ModuleLayerOffsets; + std::vector ModuleLayerOffsets; CAreaDependencyTree *pAreaDeps = static_cast(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 LayerNames; std::vector LayerStateIDs; - std::vector LayerNameOffsets; + std::vector 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) { diff --git a/src/Core/Resource/Cooker/CWorldCooker.h b/src/Core/Resource/Cooker/CWorldCooker.h index 96a3cca3..2b0987ad 100644 --- a/src/Core/Resource/Cooker/CWorldCooker.h +++ b/src/Core/Resource/Cooker/CWorldCooker.h @@ -2,15 +2,15 @@ #define CWORLDCOOKER_H #include "Core/Resource/CWorld.h" +#include #include -#include class CWorldCooker { CWorldCooker(); public: static bool CookMLVL(CWorld *pWorld, IOutputStream& rOut); - static u32 GetMLVLVersion(EGame Version); + static uint32 GetMLVLVersion(EGame Version); }; #endif // CWORLDCOOKER_H diff --git a/src/Core/Resource/Factory/CAnimEventLoader.cpp b/src/Core/Resource/Factory/CAnimEventLoader.cpp index a0072c82..0a9cd79b 100644 --- a/src/Core/Resource/Factory/CAnimEventLoader.cpp +++ b/src/Core/Resource/Factory/CAnimEventLoader.cpp @@ -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); diff --git a/src/Core/Resource/Factory/CAnimEventLoader.h b/src/Core/Resource/Factory/CAnimEventLoader.h index 91a9c7ad..e25ed186 100644 --- a/src/Core/Resource/Factory/CAnimEventLoader.h +++ b/src/Core/Resource/Factory/CAnimEventLoader.h @@ -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); diff --git a/src/Core/Resource/Factory/CAnimSetLoader.cpp b/src/Core/Resource/Factory/CAnimSetLoader.cpp index d505b92f..1c2e2320 100644 --- a/src/Core/Resource/Factory/CAnimSetLoader.cpp +++ b/src/Core/Resource/Factory/CAnimSetLoader.cpp @@ -18,9 +18,9 @@ CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(IInputStream& rCHAR) rChar.pModel = gpResourceStore->LoadResource(rCHAR.ReadLongLong()); rChar.pSkin = gpResourceStore->LoadResource(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( 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 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 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; diff --git a/src/Core/Resource/Factory/CAnimSetLoader.h b/src/Core/Resource/Factory/CAnimSetLoader.h index 296cdb6e..d2406343 100644 --- a/src/Core/Resource/Factory/CAnimSetLoader.h +++ b/src/Core/Resource/Factory/CAnimSetLoader.h @@ -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(); diff --git a/src/Core/Resource/Factory/CAnimationLoader.cpp b/src/Core/Resource/Factory/CAnimationLoader.cpp index 23827ddf..5c579ffa 100644 --- a/src/Core/Resource/Factory/CAnimationLoader.cpp +++ b/src/Core/Resource/Factory/CAnimationLoader.cpp @@ -1,7 +1,7 @@ #include "CAnimationLoader.h" -#include +#include #include -#include +#include 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 BoneIndices(NumBoneIndices); + std::vector 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 RotationIndices; + std::vector 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 TransIndices(NumTransIndices); + uint32 NumTransIndices = mpInput->ReadLong(); + std::vector 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 ScaleIndices; + std::vector 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; } diff --git a/src/Core/Resource/Factory/CAnimationLoader.h b/src/Core/Resource/Factory/CAnimationLoader.h index c1b25c8b..3889f310 100644 --- a/src/Core/Resource/Factory/CAnimationLoader.h +++ b/src/Core/Resource/Factory/CAnimationLoader.h @@ -14,21 +14,21 @@ class CAnimationLoader // Compression data std::vector 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 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); diff --git a/src/Core/Resource/Factory/CAreaLoader.cpp b/src/Core/Resource/Factory/CAreaLoader.cpp index 737b94f1..c18ada0c 100644 --- a/src/Core/Resource/Factory/CAreaLoader.cpp +++ b/src/Core/Resource/Factory/CAreaLoader.cpp @@ -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 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 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 LayerSizes(mNumLayers); + std::vector 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 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 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 Offsets(NumOffsets); + uint32 NumOffsets = mpMREA->ReadLong(); + std::vector 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 CompressedBuf(mClusters[iClust].CompressedSize); + std::vector 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) { diff --git a/src/Core/Resource/Factory/CAreaLoader.h b/src/Core/Resource/Factory/CAreaLoader.h index 9f5c1539..0101bf6e 100644 --- a/src/Core/Resource/Factory/CAreaLoader.h +++ b/src/Core/Resource/Factory/CAreaLoader.h @@ -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> mConnectionMap; + std::unordered_map> mConnectionMap; // Compression - u8 *mpDecmpBuffer; + uint8 *mpDecmpBuffer; bool mHasDecompressedBuffer; std::vector 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 diff --git a/src/Core/Resource/Factory/CAudioGroupLoader.cpp b/src/Core/Resource/Factory/CAudioGroupLoader.cpp index 3b1a038c..b0e5b0b3 100644 --- a/src/Core/Resource/Factory/CAudioGroupLoader.cpp +++ b/src/Core/Resource/Factory/CAudioGroupLoader.cpp @@ -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; diff --git a/src/Core/Resource/Factory/CCollisionLoader.cpp b/src/Core/Resource/Factory/CCollisionLoader.cpp index ad045ca5..d58b5f9f 100644 --- a/src/Core/Resource/Factory/CCollisionLoader.cpp +++ b/src/Core/Resource/Factory/CCollisionLoader.cpp @@ -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 VtxIndices(VtxIndexCount); + uint32 VtxIndexCount = rFile.ReadLong(); + std::vector VtxIndices(VtxIndexCount); rFile.ReadBytes(VtxIndices.data(), VtxIndices.size()); - u32 LineIndexCount = rFile.ReadLong(); - std::vector LineIndices(LineIndexCount); + uint32 LineIndexCount = rFile.ReadLong(); + std::vector LineIndices(LineIndexCount); rFile.ReadBytes(LineIndices.data(), LineIndices.size()); - u32 FaceIndexCount = rFile.ReadLong(); - std::vector FaceIndices(FaceIndexCount); + uint32 FaceIndexCount = rFile.ReadLong(); + std::vector 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) { diff --git a/src/Core/Resource/Factory/CCollisionLoader.h b/src/Core/Resource/Factory/CCollisionLoader.h index 91f3b90c..4e8f8a79 100644 --- a/src/Core/Resource/Factory/CCollisionLoader.h +++ b/src/Core/Resource/Factory/CCollisionLoader.h @@ -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 diff --git a/src/Core/Resource/Factory/CDependencyGroupLoader.cpp b/src/Core/Resource/Factory/CDependencyGroupLoader.cpp index 94888b1d..d9d811af 100644 --- a/src/Core/Resource/Factory/CDependencyGroupLoader.cpp +++ b/src/Core/Resource/Factory/CDependencyGroupLoader.cpp @@ -1,12 +1,12 @@ #include "CDependencyGroupLoader.h" -#include +#include -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); diff --git a/src/Core/Resource/Factory/CDependencyGroupLoader.h b/src/Core/Resource/Factory/CDependencyGroupLoader.h index cf5094c9..41dee6bb 100644 --- a/src/Core/Resource/Factory/CDependencyGroupLoader.h +++ b/src/Core/Resource/Factory/CDependencyGroupLoader.h @@ -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); diff --git a/src/Core/Resource/Factory/CFontLoader.cpp b/src/Core/Resource/Factory/CFontLoader.cpp index a9ad91e0..d4033f0e 100644 --- a/src/Core/Resource/Factory/CFontLoader.cpp +++ b/src/Core/Resource/Factory/CFontLoader.cpp @@ -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) { diff --git a/src/Core/Resource/Factory/CFontLoader.h b/src/Core/Resource/Factory/CFontLoader.h index 6f9aa8ef..ea610087 100644 --- a/src/Core/Resource/Factory/CFontLoader.h +++ b/src/Core/Resource/Factory/CFontLoader.h @@ -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 diff --git a/src/Core/Resource/Factory/CMaterialLoader.cpp b/src/Core/Resource/Factory/CMaterialLoader.cpp index e7cdb6e4..9f488f0a 100644 --- a/src/Core/Resource/Factory/CMaterialLoader.cpp +++ b/src/Core/Resource/Factory/CMaterialLoader.cpp @@ -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(TextureID); } // Materials - u32 NumMats = mpFile->ReadLong(); - std::vector Offsets(NumMats); - for (u32 iMat = 0; iMat < NumMats; iMat++) + uint32 NumMats = mpFile->ReadLong(); + std::vector 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 TextureIndices(NumTextures); + uint32 NumTextures = mpFile->ReadLong(); + std::vector 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 TevCoordIndices(TevCount); - for (u32 iTev = 0; iTev < TevCount; iTev++) + std::vector 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 TexGens(TexGenCount); + uint32 TexGenCount = mpFile->ReadLong(); + std::vector 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 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(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); diff --git a/src/Core/Resource/Factory/CMaterialLoader.h b/src/Core/Resource/Factory/CMaterialLoader.h index f88ace15..2adb9985 100644 --- a/src/Core/Resource/Factory/CMaterialLoader.h +++ b/src/Core/Resource/Factory/CMaterialLoader.h @@ -19,13 +19,13 @@ class CMaterialLoader bool mHas0x400; CColor mCorruptionColors[4]; - u8 mCorruptionInts[5]; - u32 mCorruptionFlags; - std::vector mPassOffsets; + uint8 mCorruptionInts[5]; + uint32 mCorruptionFlags; + std::vector mPassOffsets; CMaterialLoader(); ~CMaterialLoader(); - FVertexDescription ConvertToVertexDescription(u32 VertexFlags); + FVertexDescription ConvertToVertexDescription(uint32 VertexFlags); // Load Functions void ReadPrimeMatSet(); diff --git a/src/Core/Resource/Factory/CModelLoader.cpp b/src/Core/Resource/Factory/CModelLoader.cpp index 0782db26..4f5e8bd2 100644 --- a/src/Core/Resource/Factory/CModelLoader.cpp +++ b/src/Core/Resource/Factory/CModelLoader.cpp @@ -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& rkIn, std::vector& 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 OutputMap; + std::map 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) { diff --git a/src/Core/Resource/Factory/CModelLoader.h b/src/Core/Resource/Factory/CModelLoader.h index 96201786..1aa7d242 100644 --- a/src/Core/Resource/Factory/CModelLoader.h +++ b/src/Core/Resource/Factory/CModelLoader.h @@ -32,7 +32,7 @@ private: CAABox mAABox; EGame mVersion; - u32 mNumVertices; + uint32 mNumVertices; std::vector mPositions; std::vector mNormals; std::vector mColors; @@ -40,8 +40,8 @@ private: std::vector mTex1; bool mSurfaceUsingTex1; - u32 mSurfaceCount; - std::vector mSurfaceOffsets; + uint32 mSurfaceCount; + std::vector 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& rkIn, std::vector& 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 diff --git a/src/Core/Resource/Factory/CPoiToWorldLoader.cpp b/src/Core/Resource/Factory/CPoiToWorldLoader.cpp index 9fe28a4d..8e528f10 100644 --- a/src/Core/Resource/Factory/CPoiToWorldLoader.cpp +++ b/src/Core/Resource/Factory/CPoiToWorldLoader.cpp @@ -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); } diff --git a/src/Core/Resource/Factory/CScanLoader.cpp b/src/Core/Resource/Factory/CScanLoader.cpp index c160eb40..2031db9b 100644 --- a/src/Core/Resource/Factory/CScanLoader.cpp +++ b/src/Core/Resource/Factory/CScanLoader.cpp @@ -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; } diff --git a/src/Core/Resource/Factory/CScanLoader.h b/src/Core/Resource/Factory/CScanLoader.h index 26b82eb7..b75333f5 100644 --- a/src/Core/Resource/Factory/CScanLoader.h +++ b/src/Core/Resource/Factory/CScanLoader.h @@ -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: diff --git a/src/Core/Resource/Factory/CScriptLoader.cpp b/src/Core/Resource/Factory/CScriptLoader.cpp index 39cc8e09..bfee0941 100644 --- a/src/Core/Resource/Factory/CScriptLoader.cpp +++ b/src/Core/Resource/Factory/CScriptLoader.cpp @@ -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; } diff --git a/src/Core/Resource/Factory/CScriptLoader.h b/src/Core/Resource/Factory/CScriptLoader.h index 26e94f94..4bacd59b 100644 --- a/src/Core/Resource/Factory/CScriptLoader.h +++ b/src/Core/Resource/Factory/CScriptLoader.h @@ -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); diff --git a/src/Core/Resource/Factory/CSectionMgrIn.h b/src/Core/Resource/Factory/CSectionMgrIn.h index 9a1271b1..b71e84dd 100644 --- a/src/Core/Resource/Factory/CSectionMgrIn.h +++ b/src/Core/Resource/Factory/CSectionMgrIn.h @@ -1,7 +1,7 @@ #ifndef CSECTIONMGRIN_H #define CSECTIONMGRIN_H -#include +#include #include #include @@ -9,18 +9,18 @@ class CSectionMgrIn { IInputStream *mpInputStream; - std::vector mSectionSizes; - u32 mCurSec; - u32 mCurSecStart; - u32 mSecsStart; + std::vector 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; } }; diff --git a/src/Core/Resource/Factory/CSkeletonLoader.cpp b/src/Core/Resource/Factory/CSkeletonLoader.cpp index ed7c1b27..52c63d23 100644 --- a/src/Core/Resource/Factory/CSkeletonLoader.cpp +++ b/src/Core/Resource/Factory/CSkeletonLoader.cpp @@ -1,12 +1,12 @@ #include "CSkeletonLoader.h" -#include +#include #include #include 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 ChildIDs; + uint32 ParentID; + std::vector ChildIDs; }; std::vector 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; } diff --git a/src/Core/Resource/Factory/CSkinLoader.cpp b/src/Core/Resource/Factory/CSkinLoader.cpp index 9d8152f2..8f58ae53 100644 --- a/src/Core/Resource/Factory/CSkinLoader.cpp +++ b/src/Core/Resource/Factory/CSkinLoader.cpp @@ -1,5 +1,5 @@ #include "CSkinLoader.h" -#include +#include // ************ 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(); } diff --git a/src/Core/Resource/Factory/CStringLoader.cpp b/src/Core/Resource/Factory/CStringLoader.cpp index 63453681..8e6b924e 100644 --- a/src/Core/Resource/Factory/CStringLoader.cpp +++ b/src/Core/Resource/Factory/CStringLoader.cpp @@ -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 StringOffsets(NumStrings); - for (u32 iOff = 0; iOff < StringOffsets.size(); iOff++) + std::vector 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 LangOffsets(NumLanguages); + std::vector 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 StringOffsets(NumStrings); - for (u32 iOff = 0; iOff < NumStrings; iOff++) + std::vector 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> LangOffsets(NumLanguages); + std::vector> 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 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) { diff --git a/src/Core/Resource/Factory/CStringLoader.h b/src/Core/Resource/Factory/CStringLoader.h index 8d236612..c1e9bff0 100644 --- a/src/Core/Resource/Factory/CStringLoader.h +++ b/src/Core/Resource/Factory/CStringLoader.h @@ -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 diff --git a/src/Core/Resource/Factory/CTextureDecoder.cpp b/src/Core/Resource/Factory/CTextureDecoder.cpp index d8247096..45138991 100644 --- a/src/Core/Resource/Factory/CTextureDecoder.cpp +++ b/src/Core/Resource/Factory/CTextureDecoder.cpp @@ -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 MipBuffer(MipSize); + uint32 MipSize = MipW * MipH / 2; + std::vector 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) { diff --git a/src/Core/Resource/Factory/CTextureDecoder.h b/src/Core/Resource/Factory/CTextureDecoder.h index 711ccaaf..26ee5b1c 100644 --- a/src/Core/Resource/Factory/CTextureDecoder.h +++ b/src/Core/Resource/Factory/CTextureDecoder.h @@ -3,8 +3,8 @@ #include "Core/Resource/CTexture.h" #include "Core/Resource/ETexelFormat.h" +#include #include -#include #include @@ -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 mPalettes; + std::vector 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 diff --git a/src/Core/Resource/Factory/CUnsupportedFormatLoader.cpp b/src/Core/Resource/Factory/CUnsupportedFormatLoader.cpp index 63cc2a31..2905cdff 100644 --- a/src/Core/Resource/Factory/CUnsupportedFormatLoader.cpp +++ b/src/Core/Resource/Factory/CUnsupportedFormatLoader.cpp @@ -6,13 +6,13 @@ void CUnsupportedFormatLoader::PerformCheating(IInputStream& rFile, EGame Game, std::list& rAssetList) { // Analyze file contents and check every sequence of 4/8 bytes for asset IDs - std::vector Data(rFile.Size() - rFile.Tell()); + std::vector 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 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); diff --git a/src/Core/Resource/Factory/CUnsupportedParticleLoader.cpp b/src/Core/Resource/Factory/CUnsupportedParticleLoader.cpp index 7501f603..5f7904d3 100644 --- a/src/Core/Resource/Factory/CUnsupportedParticleLoader.cpp +++ b/src/Core/Resource/Factory/CUnsupportedParticleLoader.cpp @@ -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; } diff --git a/src/Core/Resource/Factory/CUnsupportedParticleLoader.h b/src/Core/Resource/Factory/CUnsupportedParticleLoader.h index d58d85aa..99880d58 100644 --- a/src/Core/Resource/Factory/CUnsupportedParticleLoader.h +++ b/src/Core/Resource/Factory/CUnsupportedParticleLoader.h @@ -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); diff --git a/src/Core/Resource/Factory/CWorldLoader.cpp b/src/Core/Resource/Factory/CWorldLoader.cpp index 90015c92..c589d301 100644 --- a/src/Core/Resource/Factory/CWorldLoader.cpp +++ b/src/Core/Resource/Factory/CWorldLoader.cpp @@ -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(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) { diff --git a/src/Core/Resource/Factory/CWorldLoader.h b/src/Core/Resource/Factory/CWorldLoader.h index a1771f8a..ad14c069 100644 --- a/src/Core/Resource/Factory/CWorldLoader.h +++ b/src/Core/Resource/Factory/CWorldLoader.h @@ -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 diff --git a/src/Core/Resource/Model/CBasicModel.cpp b/src/Core/Resource/Model/CBasicModel.cpp index 03ab4e33..f4b3622d 100644 --- a/src/Core/Resource/Model/CBasicModel.cpp +++ b/src/Core/Resource/Model/CBasicModel.cpp @@ -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]; } diff --git a/src/Core/Resource/Model/CBasicModel.h b/src/Core/Resource/Model/CBasicModel.h index 69d1e93b..b0cc55bc 100644 --- a/src/Core/Resource/Model/CBasicModel.h +++ b/src/Core/Resource/Model/CBasicModel.h @@ -4,15 +4,15 @@ #include "SSurface.h" #include "Core/Resource/CResource.h" #include "Core/OpenGL/CVertexBuffer.h" -#include +#include 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; }; diff --git a/src/Core/Resource/Model/CModel.cpp b/src/Core/Resource/Model/CModel.cpp index c337a40b..97fc2afb 100644 --- a/src/Core/Resource/Model/CModel.cpp +++ b/src/Core/Resource/Model/CModel.cpp @@ -3,7 +3,7 @@ #include "Core/Render/CRenderer.h" #include "Core/Resource/Area/CGameArea.h" #include "Core/OpenGL/GLCommon.h" -#include +#include 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 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 Indices(pPrim->Vertices.size()); - for (u32 iVert = 0; iVert < pPrim->Vertices.size(); iVert++) + std::vector 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 *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]; diff --git a/src/Core/Resource/Model/CModel.h b/src/Core/Resource/Model/CModel.h index ae79c3ad..7c78b9a3 100644 --- a/src/Core/Resource/Model/CModel.h +++ b/src/Core/Resource/Model/CModel.h @@ -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 diff --git a/src/Core/Resource/Model/CStaticModel.cpp b/src/Core/Resource/Model/CStaticModel.cpp index d4586b5d..167747cd 100644 --- a/src/Core/Resource/Model/CStaticModel.cpp +++ b/src/Core/Resource/Model/CStaticModel.cpp @@ -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 Indices(pPrim->Vertices.size()); - for (u32 iVert = 0; iVert < pPrim->Vertices.size(); iVert++) + std::vector 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(mSurfaces.size())); + mSurfaceEndOffsets.emplace_back(std::vector(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]; diff --git a/src/Core/Resource/Model/CStaticModel.h b/src/Core/Resource/Model/CStaticModel.h index 9926eac1..bc008cc4 100644 --- a/src/Core/Resource/Model/CStaticModel.h +++ b/src/Core/Resource/Model/CStaticModel.h @@ -12,7 +12,7 @@ class CStaticModel : public CBasicModel { CMaterial *mpMaterial; std::vector mIBOs; - std::vector> mSurfaceEndOffsets; + std::vector> mSurfaceEndOffsets; bool mTransparent; public: @@ -25,7 +25,7 @@ public: void GenerateMaterialShaders(); void ClearGLBuffer(); void Draw(FRenderOptions Options); - void DrawSurface(FRenderOptions Options, u32 Surface); + void DrawSurface(FRenderOptions Options, uint32 Surface); void DrawWireframe(FRenderOptions Options, CColor WireColor = CColor::skWhite); CMaterial* GetMaterial(); diff --git a/src/Core/Resource/Model/CVertex.h b/src/Core/Resource/Model/CVertex.h index 041061b1..416e901f 100644 --- a/src/Core/Resource/Model/CVertex.h +++ b/src/Core/Resource/Model/CVertex.h @@ -2,25 +2,25 @@ #define CVERTEX_H #include -#include -#include +#include +#include #include -typedef std::array TBoneIndices; +typedef std::array TBoneIndices; typedef std::array TBoneWeights; class CVertex { public: - u32 ArrayPosition; // Position of this vertex in the input model file. - // This is needed to resave without breaking rigging. + uint32 ArrayPosition; // Position of this vertex in the input model file. + // This is needed to resave without breaking rigging. CVector3f Position; CVector3f Normal; CColor Color[2]; CVector2f Tex[8]; TBoneIndices BoneIndices; TBoneWeights BoneWeights; - u8 MatrixIndices[8]; + uint8 MatrixIndices[8]; CVertex() {} diff --git a/src/Core/Resource/Model/EVertexAttribute.cpp b/src/Core/Resource/Model/EVertexAttribute.cpp index 20cd6d81..d430a894 100644 --- a/src/Core/Resource/Model/EVertexAttribute.cpp +++ b/src/Core/Resource/Model/EVertexAttribute.cpp @@ -1,9 +1,9 @@ #include "EVertexAttribute.h" #include -const u32 gkNumVertexAttribs = 22; +const uint32 gkNumVertexAttribs = 22; -u32 VertexAttributeSize(EVertexAttribute Attrib) +uint32 VertexAttributeSize(EVertexAttribute Attrib) { switch (Attrib) { @@ -26,7 +26,7 @@ u32 VertexAttributeSize(EVertexAttribute Attrib) case eBoneIndices: return 0x04; default: - Log::Error("AttributeSize(): Unknown vertex attribute: " + TString::FromInt32(Attrib, 0, 10)); + errorf("AttributeSize(): Unknown vertex attribute: %d", Attrib); return 0x00; } } diff --git a/src/Core/Resource/Model/EVertexAttribute.h b/src/Core/Resource/Model/EVertexAttribute.h index 6943b06f..95ba9006 100644 --- a/src/Core/Resource/Model/EVertexAttribute.h +++ b/src/Core/Resource/Model/EVertexAttribute.h @@ -31,8 +31,8 @@ enum EVertexAttribute }; DECLARE_FLAGS(EVertexAttribute, FVertexDescription) -extern const u32 gkNumVertexAttribs; -u32 VertexAttributeSize(EVertexAttribute Attrib); +extern const uint32 gkNumVertexAttribs; +uint32 VertexAttributeSize(EVertexAttribute Attrib); #endif // EVERTEXATTRIBUTE diff --git a/src/Core/Resource/Model/SSurface.cpp b/src/Core/Resource/Model/SSurface.cpp index 23282650..e3623936 100644 --- a/src/Core/Resource/Model/SSurface.cpp +++ b/src/Core/Resource/Model/SSurface.cpp @@ -1,36 +1,36 @@ #include "SSurface.h" #include "Core/Render/CDrawUtil.h" #include "Core/CRayCollisionTester.h" -#include +#include std::pair SSurface::IntersectsRay(const CRay& rkRay, bool AllowBackfaces, float LineThreshold) { bool Hit = false; float HitDist; - for (u32 iPrim = 0; iPrim < Primitives.size(); iPrim++) + for (uint32 iPrim = 0; iPrim < Primitives.size(); iPrim++) { SPrimitive *pPrim = &Primitives[iPrim]; - u32 NumVerts = pPrim->Vertices.size(); + uint32 NumVerts = pPrim->Vertices.size(); // Triangles if ((pPrim->Type == eGX_Triangles) || (pPrim->Type == eGX_TriangleFan) || (pPrim->Type == eGX_TriangleStrip)) { - u32 NumTris; + uint32 NumTris; if (pPrim->Type == eGX_Triangles) NumTris = NumVerts / 3; else NumTris = NumVerts - 2; - for (u32 iTri = 0; iTri < NumTris; iTri++) + for (uint32 iTri = 0; iTri < NumTris; iTri++) { CVector3f VtxA, VtxB, VtxC; // Get the three vertices that make up the current tri if (pPrim->Type == eGX_Triangles) { - u32 VertIndex = iTri * 3; + uint32 VertIndex = iTri * 3; VtxA = pPrim->Vertices[VertIndex].Position; VtxB = pPrim->Vertices[VertIndex+1].Position; VtxC = pPrim->Vertices[VertIndex+2].Position; @@ -77,19 +77,19 @@ std::pair SSurface::IntersectsRay(const CRay& rkRay, bool AllowBackf // Lines if ((pPrim->Type == eGX_Lines) || (pPrim->Type == eGX_LineStrip)) { - u32 NumLines; + uint32 NumLines; if (pPrim->Type == eGX_Lines) NumLines = NumVerts / 2; else NumLines = NumVerts - 1; - for (u32 iLine = 0; iLine < NumLines; iLine++) + for (uint32 iLine = 0; iLine < NumLines; iLine++) { CVector3f VtxA, VtxB; // Get the two vertices that make up the current line - u32 Index = (pPrim->Type == eGX_Lines ? iLine * 2 : iLine); + uint32 Index = (pPrim->Type == eGX_Lines ? iLine * 2 : iLine); VtxA = pPrim->Vertices[Index].Position; VtxB = pPrim->Vertices[Index+1].Position; diff --git a/src/Core/Resource/Model/SSurface.h b/src/Core/Resource/Model/SSurface.h index 5c5a76c2..5729cc0f 100644 --- a/src/Core/Resource/Model/SSurface.h +++ b/src/Core/Resource/Model/SSurface.h @@ -5,23 +5,23 @@ #include "Core/Resource/CMaterialSet.h" #include "Core/OpenGL/GLCommon.h" #include "Core/SRayIntersection.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include // Should prolly be a class struct SSurface { - u32 VertexCount; - u32 TriangleCount; + uint32 VertexCount; + uint32 TriangleCount; CAABox AABox; CVector3f CenterPoint; - u32 MaterialID; + uint32 MaterialID; CVector3f ReflectionDirection; - u16 MeshID; + uint16 MeshID; struct SPrimitive { diff --git a/src/Core/Resource/Script/CGameTemplate.cpp b/src/Core/Resource/Script/CGameTemplate.cpp index 01d0ef18..7959b001 100644 --- a/src/Core/Resource/Script/CGameTemplate.cpp +++ b/src/Core/Resource/Script/CGameTemplate.cpp @@ -55,7 +55,7 @@ void CGameTemplate::Load(const TString& kFilePath) void CGameTemplate::Save() { - Log::Write("Saving game template: " + mSourceFile); + debugf("Saving game template: %s", *mSourceFile); CXMLWriter Writer(mSourceFile, "Game", 0, mGame); ASSERT(Writer.IsValid()); Serialize(Writer); @@ -109,7 +109,7 @@ void CGameTemplate::SaveGameTemplates(bool ForceAll /*= false*/) const TString kOutPath = kGameDir + Path.Path; FileUtil::MakeDirectory( kOutPath.GetFileDirectory() ); - Log::Write("Saving property template: " + kOutPath); + debugf("Saving property template: %s", *kOutPath); CXMLWriter Writer(kOutPath, "PropertyTemplate", 0, Game()); ASSERT(Writer.IsValid()); @@ -120,12 +120,12 @@ void CGameTemplate::SaveGameTemplates(bool ForceAll /*= false*/) } } -u32 CGameTemplate::GameVersion(TString VersionName) +uint32 CGameTemplate::GameVersion(TString VersionName) { return -1; } -CScriptTemplate* CGameTemplate::TemplateByID(u32 ObjectID) +CScriptTemplate* CGameTemplate::TemplateByID(uint32 ObjectID) { auto it = mScriptTemplates.find(ObjectID); @@ -140,13 +140,13 @@ CScriptTemplate* CGameTemplate::TemplateByID(const CFourCC& ObjectID) return TemplateByID(ObjectID.ToLong()); } -CScriptTemplate* CGameTemplate::TemplateByIndex(u32 Index) +CScriptTemplate* CGameTemplate::TemplateByIndex(uint32 Index) { auto it = mScriptTemplates.begin(); return (std::next(it, Index))->second.pTemplate.get(); } -SState CGameTemplate::StateByID(u32 StateID) +SState CGameTemplate::StateByID(uint32 StateID) { auto Iter = mStates.find(StateID); @@ -161,14 +161,14 @@ SState CGameTemplate::StateByID(const CFourCC& State) return StateByID(State.ToLong()); } -SState CGameTemplate::StateByIndex(u32 Index) +SState CGameTemplate::StateByIndex(uint32 Index) { auto Iter = mStates.begin(); Iter = std::next(Iter, Index); return SState(Iter->first, Iter->second); } -SMessage CGameTemplate::MessageByID(u32 MessageID) +SMessage CGameTemplate::MessageByID(uint32 MessageID) { auto Iter = mMessages.find(MessageID); @@ -183,7 +183,7 @@ SMessage CGameTemplate::MessageByID(const CFourCC& MessageID) return MessageByID(MessageID.ToLong()); } -SMessage CGameTemplate::MessageByIndex(u32 Index) +SMessage CGameTemplate::MessageByIndex(uint32 Index) { auto Iter = mMessages.begin(); Iter = std::next(Iter, Index); diff --git a/src/Core/Resource/Script/CGameTemplate.h b/src/Core/Resource/Script/CGameTemplate.h index 49789187..f88a6962 100644 --- a/src/Core/Resource/Script/CGameTemplate.h +++ b/src/Core/Resource/Script/CGameTemplate.h @@ -4,8 +4,8 @@ #include "CLink.h" #include "CScriptTemplate.h" #include "Core/Resource/Script/Property/Properties.h" +#include #include -#include #include /** Serialization aid @@ -15,15 +15,15 @@ struct SObjId { union { - u32 ID; + uint32 ID; CFourCC ID_4CC; }; inline SObjId() {} - inline SObjId(u32 InID) : ID(InID) {} + inline SObjId(uint32 InID) : ID(InID) {} inline SObjId(CFourCC InID) : ID_4CC(InID) {} - inline operator u32() const { return ID; } + inline operator uint32() const { return ID; } inline operator CFourCC() const { return ID_4CC; } void Serialize(IArchive& Arc) @@ -117,27 +117,27 @@ public: void Save(); void SaveGameTemplates(bool ForceAll = false); - u32 GameVersion(TString VersionName); - CScriptTemplate* TemplateByID(u32 ObjectID); + uint32 GameVersion(TString VersionName); + CScriptTemplate* TemplateByID(uint32 ObjectID); CScriptTemplate* TemplateByID(const CFourCC& ObjectID); - CScriptTemplate* TemplateByIndex(u32 Index); - SState StateByID(u32 StateID); + CScriptTemplate* TemplateByIndex(uint32 Index); + SState StateByID(uint32 StateID); SState StateByID(const CFourCC& StateID); - SState StateByIndex(u32 Index); - SMessage MessageByID(u32 MessageID); + SState StateByIndex(uint32 Index); + SMessage MessageByID(uint32 MessageID); SMessage MessageByID(const CFourCC& MessageID); - SMessage MessageByIndex(u32 Index); + SMessage MessageByIndex(uint32 Index); IProperty* FindPropertyArchetype(const TString& kTypeName); TString GetPropertyArchetypeFilePath(const TString& kTypeName); bool RenamePropertyArchetype(const TString& kTypeName, const TString& kNewTypeName); TString GetGameDirectory() const; // Inline Accessors - inline EGame Game() const { return mGame; } - inline u32 NumScriptTemplates() const { return mScriptTemplates.size(); } - inline u32 NumStates() const { return mStates.size(); } - inline u32 NumMessages() const { return mMessages.size(); } - inline bool IsLoadedSuccessfully() { return mFullyLoaded; } + inline EGame Game() const { return mGame; } + inline uint32 NumScriptTemplates() const { return mScriptTemplates.size(); } + inline uint32 NumStates() const { return mStates.size(); } + inline uint32 NumMessages() const { return mMessages.size(); } + inline bool IsLoadedSuccessfully() { return mFullyLoaded; } }; #endif // CGAMETEMPLATE_H diff --git a/src/Core/Resource/Script/CLink.h b/src/Core/Resource/Script/CLink.h index 8dbaec96..173360a6 100644 --- a/src/Core/Resource/Script/CLink.h +++ b/src/Core/Resource/Script/CLink.h @@ -3,13 +3,13 @@ #include "CScriptObject.h" #include "Core/Resource/Area/CGameArea.h" +#include #include -#include struct SState { union { - u32 ID; + uint32 ID; CFourCC ID_4CC; }; TString Name; @@ -17,7 +17,7 @@ struct SState SState() {} - SState(u32 InID, const TString& kInName) + SState(uint32 InID, const TString& kInName) : ID(InID) , Name(kInName) {} @@ -36,7 +36,7 @@ struct SState struct SMessage { union { - u32 ID; + uint32 ID; CFourCC ID_4CC; }; TString Name; @@ -44,7 +44,7 @@ struct SMessage SMessage() {} - SMessage(u32 InID, const TString& kInName) + SMessage(uint32 InID, const TString& kInName) : ID(InID) , Name(kInName) {} @@ -63,10 +63,10 @@ struct SMessage class CLink { CGameArea *mpArea; - u32 mStateID; - u32 mMessageID; - u32 mSenderID; - u32 mReceiverID; + uint32 mStateID; + uint32 mMessageID; + uint32 mSenderID; + uint32 mReceiverID; public: CLink(CGameArea *pArea) @@ -77,7 +77,7 @@ public: , mReceiverID(-1) {} - CLink(CGameArea *pArea, u32 StateID, u32 MessageID, u32 SenderID, u32 ReceiverID) + CLink(CGameArea *pArea, uint32 StateID, uint32 MessageID, uint32 SenderID, uint32 ReceiverID) : mpArea(pArea) , mStateID(StateID) , mMessageID(MessageID) @@ -85,9 +85,9 @@ public: , mReceiverID(ReceiverID) {} - void SetSender(u32 NewSenderID, u32 Index = -1) + void SetSender(uint32 NewSenderID, uint32 Index = -1) { - u32 OldSenderID = mSenderID; + uint32 OldSenderID = mSenderID; CScriptObject *pOldSender = mpArea->InstanceByID(OldSenderID); CScriptObject *pNewSender = mpArea->InstanceByID(NewSenderID); @@ -96,9 +96,9 @@ public: pNewSender->AddLink(eOutgoing, this, Index); } - void SetReceiver(u32 NewReceiverID, u32 Index = -1) + void SetReceiver(uint32 NewReceiverID, uint32 Index = -1) { - u32 OldReceiverID = mSenderID; + uint32 OldReceiverID = mSenderID; CScriptObject *pOldReceiver = mpArea->InstanceByID(OldReceiverID); CScriptObject *pNewReceiver = mpArea->InstanceByID(NewReceiverID); @@ -107,13 +107,13 @@ public: pNewReceiver->AddLink(eIncoming, this, Index); } - u32 SenderIndex() const + uint32 SenderIndex() const { CScriptObject *pSender = mpArea->InstanceByID(mSenderID); if (pSender) { - for (u32 iLink = 0; iLink < pSender->NumLinks(eOutgoing); iLink++) + for (uint32 iLink = 0; iLink < pSender->NumLinks(eOutgoing); iLink++) { if (pSender->Link(eOutgoing, iLink) == this) return iLink; @@ -123,13 +123,13 @@ public: return -1; } - u32 ReceiverIndex() const + uint32 ReceiverIndex() const { CScriptObject *pReceiver = mpArea->InstanceByID(mReceiverID); if (pReceiver) { - for (u32 iLink = 0; iLink < pReceiver->NumLinks(eIncoming); iLink++) + for (uint32 iLink = 0; iLink < pReceiver->NumLinks(eIncoming); iLink++) { if (pReceiver->Link(eIncoming, iLink) == this) return iLink; @@ -156,15 +156,15 @@ public: // Accessors inline CGameArea* Area() const { return mpArea; } - inline u32 State() const { return mStateID; } - inline u32 Message() const { return mMessageID; } - inline u32 SenderID() const { return mSenderID; } - inline u32 ReceiverID() const { return mReceiverID; } + inline uint32 State() const { return mStateID; } + inline uint32 Message() const { return mMessageID; } + inline uint32 SenderID() const { return mSenderID; } + inline uint32 ReceiverID() const { return mReceiverID; } inline CScriptObject* Sender() const { return mpArea->InstanceByID(mSenderID); } inline CScriptObject* Receiver() const { return mpArea->InstanceByID(mReceiverID); } - inline void SetState(u32 StateID) { mStateID = StateID; } - inline void SetMessage(u32 MessageID) { mMessageID = MessageID; } + inline void SetState(uint32 StateID) { mStateID = StateID; } + inline void SetMessage(uint32 MessageID) { mMessageID = MessageID; } }; diff --git a/src/Core/Resource/Script/CScriptLayer.h b/src/Core/Resource/Script/CScriptLayer.h index 6769c9b3..b516e8a6 100644 --- a/src/Core/Resource/Script/CScriptLayer.h +++ b/src/Core/Resource/Script/CScriptLayer.h @@ -3,7 +3,7 @@ #include "CScriptObject.h" #include "Core/Resource/CDependencyGroup.h" -#include +#include #include #include @@ -30,7 +30,7 @@ public: } // Data Manipulation - void AddInstance(CScriptObject *pObject, u32 Index = -1) + void AddInstance(CScriptObject *pObject, uint32 Index = -1) { if (Index != -1 && Index < mInstances.size()) { @@ -55,12 +55,12 @@ public: } } - void RemoveInstanceByIndex(u32 Index) + void RemoveInstanceByIndex(uint32 Index) { mInstances.erase(mInstances.begin() + Index); } - void RemoveInstanceByID(u32 ID) + void RemoveInstanceByID(uint32 ID) { for (auto it = mInstances.begin(); it != mInstances.end(); it++) { @@ -72,7 +72,7 @@ public: } } - void Reserve(u32 Amount) + void Reserve(uint32 Amount) { mInstances.reserve(Amount); } @@ -82,10 +82,10 @@ public: inline TString Name() const { return mLayerName; } inline bool IsActive() const { return mActive; } inline bool IsVisible() const { return mVisible; } - inline u32 NumInstances() const { return mInstances.size(); } - inline CScriptObject* InstanceByIndex(u32 Index) const { return mInstances[Index]; } + inline uint32 NumInstances() const { return mInstances.size(); } + inline CScriptObject* InstanceByIndex(uint32 Index) const { return mInstances[Index]; } - inline CScriptObject* InstanceByID(u32 ID) const + inline CScriptObject* InstanceByID(uint32 ID) const { for (auto it = mInstances.begin(); it != mInstances.end(); it++) { @@ -100,9 +100,9 @@ public: inline void SetActive(bool Active) { mActive = Active; } inline void SetVisible(bool Visible) { mVisible = Visible; } - inline u32 AreaIndex() const + inline uint32 AreaIndex() const { - for (u32 iLyr = 0; iLyr < mpArea->NumScriptLayers(); iLyr++) + for (uint32 iLyr = 0; iLyr < mpArea->NumScriptLayers(); iLyr++) { if (mpArea->ScriptLayer(iLyr) == this) return iLyr; @@ -112,7 +112,7 @@ public: } // Operators - CScriptObject* operator[](u32 Index) { return InstanceByIndex(Index); } + CScriptObject* operator[](uint32 Index) { return InstanceByIndex(Index); } }; #endif // CSCRIPTLAYER_H diff --git a/src/Core/Resource/Script/CScriptObject.cpp b/src/Core/Resource/Script/CScriptObject.cpp index e2af2012..b2b36450 100644 --- a/src/Core/Resource/Script/CScriptObject.cpp +++ b/src/Core/Resource/Script/CScriptObject.cpp @@ -3,7 +3,7 @@ #include "CGameTemplate.h" #include "Core/Resource/Animation/CAnimSet.h" -CScriptObject::CScriptObject(u32 InstanceID, CGameArea *pArea, CScriptLayer *pLayer, CScriptTemplate *pTemplate) +CScriptObject::CScriptObject(uint32 InstanceID, CGameArea *pArea, CScriptLayer *pLayer, CScriptTemplate *pTemplate) : mpTemplate(pTemplate) , mpArea(pArea) , mpLayer(pLayer) @@ -16,7 +16,7 @@ CScriptObject::CScriptObject(u32 InstanceID, CGameArea *pArea, CScriptLayer *pLa // Init properties CStructProperty* pProperties = pTemplate->Properties(); - u32 PropertiesSize = pProperties->DataSize(); + uint32 PropertiesSize = pProperties->DataSize(); mPropertyData.resize( PropertiesSize ); void* pData = mPropertyData.data(); @@ -41,7 +41,7 @@ CScriptObject::~CScriptObject() mpTemplate->RemoveObject(this); // Note: Incoming links will be deleted by the sender. - for (u32 iLink = 0; iLink < mOutLinks.size(); iLink++) + for (uint32 iLink = 0; iLink < mOutLinks.size(); iLink++) delete mOutLinks[iLink]; } @@ -97,7 +97,7 @@ bool CScriptObject::IsEditorProperty(IProperty *pProp) ); } -void CScriptObject::SetLayer(CScriptLayer *pLayer, u32 NewLayerIndex) +void CScriptObject::SetLayer(CScriptLayer *pLayer, uint32 NewLayerIndex) { ASSERT(pLayer != nullptr); @@ -109,11 +109,11 @@ void CScriptObject::SetLayer(CScriptLayer *pLayer, u32 NewLayerIndex) } } -u32 CScriptObject::LayerIndex() const +uint32 CScriptObject::LayerIndex() const { if (!mpLayer) return -1; - for (u32 iInst = 0; iInst < mpLayer->NumInstances(); iInst++) + for (uint32 iInst = 0; iInst < mpLayer->NumInstances(); iInst++) { if (mpLayer->InstanceByIndex(iInst) == this) return iInst; @@ -135,7 +135,7 @@ bool CScriptObject::HasNearVisibleActivation() const if (mIsCheckingNearVisibleActivation) return false; mIsCheckingNearVisibleActivation = true; - for (u32 iLink = 0; iLink < mInLinks.size(); iLink++) + for (uint32 iLink = 0; iLink < mInLinks.size(); iLink++) { CLink *pLink = mInLinks[iLink]; @@ -183,7 +183,7 @@ bool CScriptObject::HasNearVisibleActivation() const return false; } -void CScriptObject::AddLink(ELinkType Type, CLink *pLink, u32 Index /*= -1*/) +void CScriptObject::AddLink(ELinkType Type, CLink *pLink, uint32 Index /*= -1*/) { std::vector *pLinkVec = (Type == eIncoming ? &mInLinks : &mOutLinks); diff --git a/src/Core/Resource/Script/CScriptObject.h b/src/Core/Resource/Script/CScriptObject.h index d8870cff..ff2a149e 100644 --- a/src/Core/Resource/Script/CScriptObject.h +++ b/src/Core/Resource/Script/CScriptObject.h @@ -24,9 +24,9 @@ class CScriptObject CScriptTemplate *mpTemplate; CGameArea *mpArea; CScriptLayer *mpLayer; - u32 mVersion; + uint32 mVersion; - u32 mInstanceID; + uint32 mInstanceID; std::vector mOutLinks; std::vector mInLinks; std::vector mPropertyData; @@ -40,8 +40,8 @@ class CScriptObject TResPtr mpDisplayAsset; TResPtr mpCollision; - u32 mActiveCharIndex; - u32 mActiveAnimIndex; + uint32 mActiveCharIndex; + uint32 mActiveAnimIndex; bool mHasInGameModel; EVolumeShape mVolumeShape; @@ -51,7 +51,7 @@ class CScriptObject mutable bool mIsCheckingNearVisibleActivation; public: - CScriptObject(u32 InstanceID, CGameArea *pArea, CScriptLayer *pLayer, CScriptTemplate *pTemplate); + CScriptObject(uint32 InstanceID, CGameArea *pArea, CScriptLayer *pLayer, CScriptTemplate *pTemplate); ~CScriptObject(); void CopyProperties(CScriptObject* pObject); @@ -60,11 +60,11 @@ public: void EvaluateCollisionModel(); void EvaluateVolume(); bool IsEditorProperty(IProperty *pProp); - void SetLayer(CScriptLayer *pLayer, u32 NewLayerIndex = -1); - u32 LayerIndex() const; + void SetLayer(CScriptLayer *pLayer, uint32 NewLayerIndex = -1); + uint32 LayerIndex() const; bool HasNearVisibleActivation() const; - void AddLink(ELinkType Type, CLink *pLink, u32 Index = -1); + void AddLink(ELinkType Type, CLink *pLink, uint32 Index = -1); void RemoveLink(ELinkType Type, CLink *pLink); void BreakAllLinks(); @@ -73,11 +73,11 @@ public: CGameTemplate* GameTemplate() const { return mpTemplate->GameTemplate(); } CGameArea* Area() const { return mpArea; } CScriptLayer* Layer() const { return mpLayer; } - u32 Version() const { return mVersion; } - u32 ObjectTypeID() const { return mpTemplate->ObjectID(); } - u32 InstanceID() const { return mInstanceID; } - u32 NumLinks(ELinkType Type) const { return (Type == eIncoming ? mInLinks.size() : mOutLinks.size()); } - CLink* Link(ELinkType Type, u32 Index) const { return (Type == eIncoming ? mInLinks[Index] : mOutLinks[Index]); } + uint32 Version() const { return mVersion; } + uint32 ObjectTypeID() const { return mpTemplate->ObjectID(); } + uint32 InstanceID() const { return mInstanceID; } + uint32 NumLinks(ELinkType Type) const { return (Type == eIncoming ? mInLinks.size() : mOutLinks.size()); } + CLink* Link(ELinkType Type, uint32 Index) const { return (Type == eIncoming ? mInLinks[Index] : mOutLinks[Index]); } void* PropertyData() const { return (void*) mPropertyData.data(); } CVector3f Position() const { return mPosition.IsValid() ? mPosition.Get() : CVector3f::skZero; } @@ -88,8 +88,8 @@ public: bool HasInGameModel() const { return mHasInGameModel; } CStructRef LightParameters() const { return mLightParameters; } CResource* DisplayAsset() const { return mpDisplayAsset; } - u32 ActiveCharIndex() const { return mActiveCharIndex; } - u32 ActiveAnimIndex() const { return mActiveAnimIndex; } + uint32 ActiveCharIndex() const { return mActiveCharIndex; } + uint32 ActiveAnimIndex() const { return mActiveAnimIndex; } CCollisionMeshGroup* Collision() const { return mpCollision; } EVolumeShape VolumeShape() const { return mVolumeShape; } float VolumeScale() const { return mVolumeScale; } diff --git a/src/Core/Resource/Script/CScriptTemplate.cpp b/src/Core/Resource/Script/CScriptTemplate.cpp index 186e8435..5c517c6a 100644 --- a/src/Core/Resource/Script/CScriptTemplate.cpp +++ b/src/Core/Resource/Script/CScriptTemplate.cpp @@ -27,7 +27,7 @@ CScriptTemplate::CScriptTemplate(CGameTemplate *pGame) } // New constructor -CScriptTemplate::CScriptTemplate(CGameTemplate* pInGame, u32 InObjectID, const TString& kInFilePath) +CScriptTemplate::CScriptTemplate(CGameTemplate* pInGame, uint32 InObjectID, const TString& kInFilePath) : mRotationType(eRotationEnabled) , mScaleType(eScaleEnabled) , mPreviewScale(1.f) @@ -98,7 +98,7 @@ void CScriptTemplate::Save(bool Force) { if (IsDirty() || Force) { - Log::Write("Saving script template: " + mSourceFile); + debugf("Saving script template: %s", *mSourceFile); CXMLWriter Writer(mSourceFile, "ScriptObject", 0, mpGame->Game()); ASSERT(Writer.IsValid()); Serialize(Writer); @@ -128,13 +128,13 @@ EVolumeShape CScriptTemplate::VolumeShape(CScriptObject *pObj) { if (pObj->Template() != this) { - Log::Error(pObj->Template()->Name() + " instance somehow called VolumeShape() on " + Name() + " template"); + errorf("%s instance somehow called VolumeShape() on %s template", *pObj->Template()->Name(), *Name()); return eInvalidShape; } if (mVolumeShape == eConditionalShape) { - s32 Index = CheckVolumeConditions(pObj, true); + int32 Index = CheckVolumeConditions(pObj, true); if (Index == -1) return eInvalidShape; else return mVolumeConditions[Index].Shape; } @@ -145,20 +145,20 @@ float CScriptTemplate::VolumeScale(CScriptObject *pObj) { if (pObj->Template() != this) { - Log::Error(pObj->Template()->Name() + " instance somehow called VolumeScale() on " + Name() + " template"); + errorf("%s instance somehow called VolumeScale() on %s template", *pObj->Template()->Name(), *Name()); return -1; } if (mVolumeShape == eConditionalShape) { - s32 Index = CheckVolumeConditions(pObj, false); + int32 Index = CheckVolumeConditions(pObj, false); if (Index == -1) return mVolumeScale; else return mVolumeConditions[Index].Scale; } else return mVolumeScale; } -s32 CScriptTemplate::CheckVolumeConditions(CScriptObject *pObj, bool LogErrors) +int32 CScriptTemplate::CheckVolumeConditions(CScriptObject *pObj, bool LogErrors) { // Private function if (mVolumeShape == eConditionalShape) @@ -195,20 +195,20 @@ s32 CScriptTemplate::CheckVolumeConditions(CScriptObject *pObj, bool LogErrors) } // Test and check whether any of the conditions are true - for (u32 LinkIdx = 0; LinkIdx < mVolumeConditions.size(); LinkIdx++) + for (uint32 LinkIdx = 0; LinkIdx < mVolumeConditions.size(); LinkIdx++) { if (mVolumeConditions[LinkIdx].Value == Val) return LinkIdx; } if (LogErrors) - Log::Error(pObj->Template()->Name() + " instance " + TString::HexString(pObj->InstanceID()) + " has unexpected volume shape value of " + TString::HexString((u32) Val, 0)); + errorf("%s instance %08X has unexpected volume shape value of 0x%X", *pObj->Template()->Name(), pObj->InstanceID(), Val); } return -1; } -CResource* CScriptTemplate::FindDisplayAsset(void* pPropertyData, u32& rOutCharIndex, u32& rOutAnimIndex, bool& rOutIsInGame) +CResource* CScriptTemplate::FindDisplayAsset(void* pPropertyData, uint32& rOutCharIndex, uint32& rOutAnimIndex, bool& rOutIsInGame) { rOutCharIndex = -1; rOutAnimIndex = -1; @@ -236,8 +236,8 @@ CResource* CScriptTemplate::FindDisplayAsset(void* pPropertyData, u32& rOutCharI if (pRes) { - u32 MaxNumChars = static_cast(pRes)->NumCharacters(); - rOutCharIndex = (it->ForceNodeIndex >= 0 && it->ForceNodeIndex < (s32) MaxNumChars ? it->ForceNodeIndex : Params.CharacterIndex()); + uint32 MaxNumChars = static_cast(pRes)->NumCharacters(); + rOutCharIndex = (it->ForceNodeIndex >= 0 && it->ForceNodeIndex < (int32) MaxNumChars ? it->ForceNodeIndex : Params.CharacterIndex()); rOutAnimIndex = Params.AnimIndex(); } } @@ -297,7 +297,7 @@ CCollisionMeshGroup* CScriptTemplate::FindCollision(void* pPropertyData) // ************ OBJECT TRACKING ************ -u32 CScriptTemplate::NumObjects() const +uint32 CScriptTemplate::NumObjects() const { return mObjectList.size(); } diff --git a/src/Core/Resource/Script/CScriptTemplate.h b/src/Core/Resource/Script/CScriptTemplate.h index 62f35422..0ee2c097 100644 --- a/src/Core/Resource/Script/CScriptTemplate.h +++ b/src/Core/Resource/Script/CScriptTemplate.h @@ -5,8 +5,8 @@ #include "EVolumeShape.h" #include "Core/Resource/Model/CModel.h" #include "Core/Resource/CCollisionMeshGroup.h" +#include #include -#include #include #include @@ -64,14 +64,14 @@ private: } AssetSource; TIDString AssetLocation; - s32 ForceNodeIndex; // Force animsets to use specific node instead of one from property + int32 ForceNodeIndex; // Force animsets to use specific node instead of one from property void Serialize(IArchive& Arc) { Arc << SerialParameter("Type", AssetType, SH_Attribute) << SerialParameter("Source", AssetSource, SH_Attribute) << SerialParameter("Location", AssetLocation, SH_Attribute) - << SerialParameter("ForceCharacterIndex", ForceNodeIndex, SH_Attribute | SH_Optional, (s32) -1); + << SerialParameter("ForceCharacterIndex", ForceNodeIndex, SH_Attribute | SH_Optional, (int32) -1); } }; @@ -90,7 +90,7 @@ private: TIDString mVolumeConditionIDString; TString mSourceFile; - u32 mObjectID; + uint32 mObjectID; // Editor Properties TIDString mNameIDString; @@ -111,7 +111,7 @@ private: CStructProperty* mpLightParametersProperty; struct SVolumeCondition { - u32 Value; + uint32 Value; EVolumeShape Shape; float Scale; @@ -132,7 +132,7 @@ public: // Old constructor CScriptTemplate(CGameTemplate *pGame); // New constructor - CScriptTemplate(CGameTemplate* pGame, u32 ObjectID, const TString& kFilePath); + CScriptTemplate(CGameTemplate* pGame, uint32 ObjectID, const TString& kFilePath); ~CScriptTemplate(); void Serialize(IArchive& rArc); void Save(bool Force = false); @@ -141,7 +141,7 @@ public: // Property Fetching EVolumeShape VolumeShape(CScriptObject *pObj); float VolumeScale(CScriptObject *pObj); - CResource* FindDisplayAsset(void* pPropertyData, u32& rOutCharIndex, u32& rOutAnimIndex, bool& rOutIsInGame); + CResource* FindDisplayAsset(void* pPropertyData, uint32& rOutCharIndex, uint32& rOutAnimIndex, bool& rOutIsInGame); CCollisionMeshGroup* FindCollision(void* pPropertyData); // Accessors @@ -150,12 +150,12 @@ public: inline ERotationType RotationType() const { return mRotationType; } inline EScaleType ScaleType() const { return mScaleType; } inline float PreviewScale() const { return mPreviewScale; } - inline u32 ObjectID() const { return mObjectID; } + inline uint32 ObjectID() const { return mObjectID; } inline bool IsVisible() const { return mVisible; } inline TString SourceFile() const { return mSourceFile; } inline CStructProperty* Properties() const { return mpProperties.get(); } - inline u32 NumAttachments() const { return mAttachments.size(); } - const SAttachment& Attachment(u32 Index) const { return mAttachments[Index]; } + inline uint32 NumAttachments() const { return mAttachments.size(); } + const SAttachment& Attachment(uint32 Index) const { return mAttachments[Index]; } const std::vector& RequiredModules() const { return mModules; } inline CStringProperty* NameProperty() const { return mpNameProperty; } @@ -170,14 +170,14 @@ public: inline bool IsDirty() const { return mDirty || mpProperties->IsDirty(); } // Object Tracking - u32 NumObjects() const; + uint32 NumObjects() const; const std::list& ObjectList() const; void AddObject(CScriptObject *pObject); void RemoveObject(CScriptObject *pObject); void SortObjects(); private: - s32 CheckVolumeConditions(CScriptObject *pObj, bool LogErrors); + int32 CheckVolumeConditions(CScriptObject *pObj, bool LogErrors); }; #endif // CSCRIPTTEMPLATE_H diff --git a/src/Core/Resource/Script/NGameList.cpp b/src/Core/Resource/Script/NGameList.cpp index 7d910ba2..e5077a20 100644 --- a/src/Core/Resource/Script/NGameList.cpp +++ b/src/Core/Resource/Script/NGameList.cpp @@ -50,11 +50,11 @@ bool IsGameTemplateLoaded(EGame Game) inline void SerializeGameList(IArchive& Arc) { // Serialize the number of games with valid GameInfos. - u32 NumGames = 0; + uint32 NumGames = 0; if (Arc.IsWriter()) { - for (u32 GameIdx = 0; GameIdx < (u32) EGame::Max; GameIdx++) + for (uint32 GameIdx = 0; GameIdx < (uint32) EGame::Max; GameIdx++) { if ( gGameList[GameIdx].IsValid ) NumGames++; @@ -64,7 +64,7 @@ inline void SerializeGameList(IArchive& Arc) Arc.SerializeArraySize(NumGames); // Serialize the actual game info - for (u32 GameIdx = 0; GameIdx < (u32) EGame::Max; GameIdx++) + for (uint32 GameIdx = 0; GameIdx < (uint32) EGame::Max; GameIdx++) { // Skip games that don't have game templates when writing. if (Arc.IsWriter() && !gGameList[GameIdx].IsValid) @@ -77,7 +77,7 @@ inline void SerializeGameList(IArchive& Arc) Arc << SerialParameter("ID", Game, SH_Attribute); ASSERT( Game != EGame::Invalid ); - gGameList[ (u32) Game ].Serialize(Arc); + gGameList[ (uint32) Game ].Serialize(Arc); Arc.ParamEnd(); } } @@ -86,7 +86,7 @@ inline void SerializeGameList(IArchive& Arc) void LoadGameList() { ASSERT(!gLoadedGameList); - Log::Write("Loading game list"); + debugf("Loading game list"); CXMLReader Reader(gkGameListPath); ASSERT(Reader.IsValid()); @@ -99,7 +99,7 @@ void LoadGameList() void SaveGameList() { ASSERT(gLoadedGameList); - Log::Write("Saving game list"); + debugf("Saving game list"); CXMLWriter Writer(gkGameListPath, "GameList"); ASSERT(Writer.IsValid()); diff --git a/src/Core/Resource/Script/NPropertyMap.cpp b/src/Core/Resource/Script/NPropertyMap.cpp index 5c52b12e..2d6b05aa 100644 --- a/src/Core/Resource/Script/NPropertyMap.cpp +++ b/src/Core/Resource/Script/NPropertyMap.cpp @@ -24,14 +24,14 @@ bool gMapIsDirty = false; bool gMapIsLoaded = false; /** Mapping of typename hashes back to the original string */ -std::unordered_map gHashToTypeName; +std::unordered_map gHashToTypeName; /** Register a hash -> name mapping */ -inline void RegisterTypeName(u32 TypeHash, TString TypeName) +inline void RegisterTypeName(uint32 TypeHash, TString TypeName) { ASSERT( !TypeName.IsEmpty() ); ASSERT( TypeName != "Unknown" ); - gHashToTypeName.emplace( std::make_pair(std::move(TypeHash), std::move(TypeName)) ); + gHashToTypeName.emplace( std::make_pair(std::move(TypeHash), std::move(TypeName)) ); } /** Key structure for name map lookups */ @@ -40,11 +40,11 @@ struct SNameKey union { struct { - u32 TypeHash; - u32 ID; + uint32 TypeHash; + uint32 ID; }; struct { - u64 Key; + uint64 Key; }; }; @@ -52,7 +52,7 @@ struct SNameKey : TypeHash(-1), ID(-1) {} - SNameKey(u32 InTypeHash, u32 InID) + SNameKey(uint32 InTypeHash, uint32 InID) : TypeHash(InTypeHash), ID(InID) {} @@ -92,7 +92,7 @@ struct KeyHash { inline size_t operator()(const SNameKey& kKey) const { - return std::hash()(kKey.Key); + return std::hash()(kKey.Key); } }; @@ -125,7 +125,7 @@ struct SNameValue std::map gNameMap; /** Legacy map that only includes the ID in the key */ -std::map gLegacyNameMap; +std::map gLegacyNameMap; /** Internal: Creates a name key for the given property. */ SNameKey CreateKey(IProperty* pProperty) @@ -136,7 +136,7 @@ SNameKey CreateKey(IProperty* pProperty) return Key; } -SNameKey CreateKey(u32 ID, const char* pkTypeName) +SNameKey CreateKey(uint32 ID, const char* pkTypeName) { return SNameKey( CCRC32::StaticHashString(pkTypeName), ID ); } @@ -145,7 +145,7 @@ SNameKey CreateKey(u32 ID, const char* pkTypeName) void LoadMap() { ASSERT( !gMapIsLoaded ); - Log::Write("Loading property map"); + debugf("Loading property map"); if ( gkUseLegacyMapForNameLookups ) { @@ -191,7 +191,7 @@ void SaveMap(bool Force /*= false*/) else return; } - Log::Write("Saving property map"); + debugf("Saving property map"); if( gMapIsDirty || Force ) { @@ -247,7 +247,7 @@ const char* GetPropertyName(IProperty* pInProperty) /** Given a property name and type, returns the name of the property. * This requires you to provide the exact type string used in the hash. */ -const char* GetPropertyName(u32 ID, const char* pkTypeName) +const char* GetPropertyName(uint32 ID, const char* pkTypeName) { // Does not support legacy map ConditionalLoadMap(); @@ -258,7 +258,7 @@ const char* GetPropertyName(u32 ID, const char* pkTypeName) } /** Calculate the property ID of a given name/type. */ -u32 CalculatePropertyID(const char* pkName, const char* pkTypeName) +uint32 CalculatePropertyID(const char* pkName, const char* pkTypeName) { CCRC32 CRC; CRC.Hash(pkName); @@ -267,7 +267,7 @@ u32 CalculatePropertyID(const char* pkName, const char* pkTypeName) } /** Returns whether the specified ID is in the map. */ -bool IsValidPropertyID(u32 ID, const char* pkTypeName, bool* pOutIsValid /*= nullptr*/) +bool IsValidPropertyID(uint32 ID, const char* pkTypeName, bool* pOutIsValid /*= nullptr*/) { SNameKey Key = CreateKey(ID, pkTypeName); auto MapFind = gNameMap.find(Key); @@ -285,7 +285,7 @@ bool IsValidPropertyID(u32 ID, const char* pkTypeName, bool* pOutIsValid /*= nul } /** Retrieves a list of all properties that match the requested property ID. */ -void RetrievePropertiesWithID(u32 ID, const char* pkTypeName, std::list& OutList) +void RetrievePropertiesWithID(uint32 ID, const char* pkTypeName, std::list& OutList) { SNameKey Key = CreateKey(ID, pkTypeName); auto MapFind = gNameMap.find(Key); @@ -298,7 +298,7 @@ void RetrievePropertiesWithID(u32 ID, const char* pkTypeName, std::list& OutSet) +void RetrieveXMLsWithProperty(uint32 ID, const char* pkTypeName, std::set& OutSet) { SNameKey Key = CreateKey(ID, pkTypeName); auto MapFind = gNameMap.find(Key); @@ -316,7 +316,7 @@ void RetrieveXMLsWithProperty(u32 ID, const char* pkTypeName, std::set& } /** Updates the name of a given property in the map */ -void SetPropertyName(u32 ID, const char* pkTypeName, const char* pkNewName) +void SetPropertyName(uint32 ID, const char* pkTypeName, const char* pkNewName) { if( gkUseLegacyMapForUpdates ) { @@ -362,8 +362,8 @@ void SetPropertyName(u32 ID, const char* pkTypeName, const char* pkNewName) /** Change a type name of a property. */ void ChangeTypeName(IProperty* pProperty, const char* pkOldTypeName, const char* pkNewTypeName) { - u32 OldTypeHash = CCRC32::StaticHashString(pkOldTypeName); - u32 NewTypeHash = CCRC32::StaticHashString(pkNewTypeName); + uint32 OldTypeHash = CCRC32::StaticHashString(pkOldTypeName); + uint32 NewTypeHash = CCRC32::StaticHashString(pkNewTypeName); if (OldTypeHash == NewTypeHash) { @@ -422,8 +422,8 @@ void ChangeTypeName(IProperty* pProperty, const char* pkOldTypeName, const char* /** Change a type name. */ void ChangeTypeNameGlobally(const char* pkOldTypeName, const char* pkNewTypeName) { - u32 OldTypeHash = CCRC32::StaticHashString(pkOldTypeName); - u32 NewTypeHash = CCRC32::StaticHashString(pkNewTypeName); + uint32 OldTypeHash = CCRC32::StaticHashString(pkOldTypeName); + uint32 NewTypeHash = CCRC32::StaticHashString(pkNewTypeName); if (OldTypeHash == NewTypeHash) { @@ -494,6 +494,35 @@ void RegisterProperty(IProperty* pProperty) } else { + // If we didn't find the property name, check for int<->choice conversions + if (MapFind == gNameMap.end()) + { + if (pProperty->Type() == EPropertyType::Int) + { + uint32 ChoiceHash = CCRC32::StaticHashString("choice"); + SNameKey ChoiceKey(ChoiceHash, pProperty->ID()); + MapFind = gNameMap.find(ChoiceKey); + } + else if (pProperty->Type() == EPropertyType::Choice) + { + uint32 IntHash = CCRC32::StaticHashString("int"); + SNameKey IntKey(IntHash, pProperty->ID()); + MapFind = gNameMap.find(IntKey); + } + } + + // If we still didn't find it, register the property name in the map + if (MapFind == gNameMap.end()) + { + SNameValue Value; + Value.Name = "Unknown"; + Value.IsValid = false; + gNameMap[Key] = Value; + MapFind = gNameMap.find(Key); + RegisterTypeName(Key.TypeHash, pProperty->HashableTypeName()); + } + + // We should have a valid iterator at this point no matter what. ASSERT(MapFind != gNameMap.end()); pProperty->SetName( MapFind->second.Name ); } @@ -536,7 +565,7 @@ CIterator::~CIterator() delete mpImpl; } -u32 CIterator::ID() const +uint32 CIterator::ID() const { return mpImpl->mIter->first.ID; } @@ -548,7 +577,7 @@ const char* CIterator::Name() const const char* CIterator::TypeName() const { - u32 TypeHash = mpImpl->mIter->first.TypeHash; + uint32 TypeHash = mpImpl->mIter->first.TypeHash; auto Find = gHashToTypeName.find(TypeHash); ASSERT(Find != gHashToTypeName.end()); return *Find->second; diff --git a/src/Core/Resource/Script/NPropertyMap.h b/src/Core/Resource/Script/NPropertyMap.h index 0e6171fc..5821f07d 100644 --- a/src/Core/Resource/Script/NPropertyMap.h +++ b/src/Core/Resource/Script/NPropertyMap.h @@ -1,7 +1,7 @@ #ifndef NPROPERTYMAP_H #define NPROPERTYMAP_H -#include +#include #include "Core/Resource/Script/Property/IProperty.h" /** NPropertyMap: Namespace for property ID -> name mappings */ @@ -20,25 +20,25 @@ const char* GetPropertyName(IProperty* pProperty); /** Given a property name and type, returns the name of the property. * This requires you to provide the exact type string used in the hash. */ -const char* GetPropertyName(u32 ID, const char* pkTypeName); +const char* GetPropertyName(uint32 ID, const char* pkTypeName); /** Calculate the property ID of a given name/type. */ -u32 CalculatePropertyID(const char* pkName, const char* pkTypeName); +uint32 CalculatePropertyID(const char* pkName, const char* pkTypeName); /** * Returns whether the specified name is in the map. * If the ID is valid and pOutIsValid is non-null, it will return whether the current name is correct. */ -bool IsValidPropertyID(u32 ID, const char* pkTypeName, bool* pOutIsValid = nullptr); +bool IsValidPropertyID(uint32 ID, const char* pkTypeName, bool* pOutIsValid = nullptr); /** Retrieves a list of all properties that match the requested property ID. */ -void RetrievePropertiesWithID(u32 ID, const char* pkTypeName, std::list& OutList); +void RetrievePropertiesWithID(uint32 ID, const char* pkTypeName, std::list& OutList); /** Retrieves a list of all XML templates that contain a given property ID. */ -void RetrieveXMLsWithProperty(u32 ID, const char* pkTypeName, std::set& OutSet); +void RetrieveXMLsWithProperty(uint32 ID, const char* pkTypeName, std::set& OutSet); /** Updates the name of a given property in the map */ -void SetPropertyName(u32 ID, const char* pkTypeName, const char* pkNewName); +void SetPropertyName(uint32 ID, const char* pkTypeName, const char* pkNewName); /** Change a type name of a property. */ void ChangeTypeName(IProperty* pProperty, const char* pkOldTypeName, const char* pkNewTypeName); @@ -62,7 +62,7 @@ public: CIterator(); ~CIterator(); - u32 ID() const; + uint32 ID() const; const char* Name() const; const char* TypeName() const; diff --git a/src/Core/Resource/Script/Property/CAnimationProperty.h b/src/Core/Resource/Script/Property/CAnimationProperty.h index 0014b522..30ce08f4 100644 --- a/src/Core/Resource/Script/Property/CAnimationProperty.h +++ b/src/Core/Resource/Script/Property/CAnimationProperty.h @@ -3,7 +3,7 @@ #include "IProperty.h" -class CAnimationProperty : public TSerializeableTypedProperty< u32, EPropertyType::Animation > +class CAnimationProperty : public TSerializeableTypedProperty< uint32, EPropertyType::Animation > { friend class IProperty; @@ -15,12 +15,12 @@ protected: public: virtual void SerializeValue(void* pData, IArchive& rArc) const { - rArc.SerializePrimitive( (u32&) ValueRef(pData), SH_HexDisplay ); + rArc.SerializePrimitive( (uint32&) ValueRef(pData), SH_HexDisplay ); } virtual TString ValueAsString(void* pData) const { - return TString::HexString( (u32) Value(pData) ); + return TString::HexString( (uint32) Value(pData) ); } }; diff --git a/src/Core/Resource/Script/Property/CArrayProperty.h b/src/Core/Resource/Script/Property/CArrayProperty.h index 6a6da8e8..1c5cfdc7 100644 --- a/src/Core/Resource/Script/Property/CArrayProperty.h +++ b/src/Core/Resource/Script/Property/CArrayProperty.h @@ -20,7 +20,7 @@ struct SScriptArray /** You probably shouldn't use this on intrinsic classes; script only */ /** @todo proper support of default values for arrays (this would be used for prefabs) */ -class CArrayProperty : public TTypedProperty +class CArrayProperty : public TTypedProperty { friend class IProperty; @@ -37,7 +37,7 @@ class CArrayProperty : public TTypedProperty return *( (SScriptArray*) RawValuePtr(pData) ); } - u32 _InternalArrayCount(void* pPropertyData) const + uint32 _InternalArrayCount(void* pPropertyData) const { std::vector& rArray = _GetInternalArray(pPropertyData).Array; return rArray.size() / ItemSize(); @@ -50,12 +50,12 @@ protected: {} public: - virtual u32 DataSize() const + virtual uint32 DataSize() const { return sizeof(SScriptArray); } - virtual u32 DataAlignment() const + virtual uint32 DataAlignment() const { return alignof(SScriptArray); } @@ -112,13 +112,13 @@ public: virtual void SerializeValue(void* pData, IArchive& Arc) const { - u32 Count = ArrayCount(pData); + uint32 Count = ArrayCount(pData); Arc.SerializeArraySize(Count); if (Arc.IsReader()) Resize(pData, Count); - for (u32 ItemIdx = 0; ItemIdx < Count; ItemIdx++) + for (uint32 ItemIdx = 0; ItemIdx < Count; ItemIdx++) { if (Arc.ParamBegin("ArrayElement", 0)) { @@ -142,14 +142,14 @@ public: mpItemArchetype->Initialize(this, mpScriptTemplate, 0); } - u32 ArrayCount(void* pPropertyData) const + uint32 ArrayCount(void* pPropertyData) const { return ValueRef(pPropertyData); } - void Resize(void* pPropertyData, u32 NewCount) const + void Resize(void* pPropertyData, uint32 NewCount) const { - u32 OldCount = _InternalArrayCount(pPropertyData); + uint32 OldCount = _InternalArrayCount(pPropertyData); if (OldCount != NewCount) { @@ -158,21 +158,21 @@ public: // Handle destruction of old elements if (OldCount > NewCount) { - for (u32 ItemIdx = NewCount; ItemIdx < OldCount; ItemIdx++) + for (uint32 ItemIdx = NewCount; ItemIdx < OldCount; ItemIdx++) { void* pItemPtr = ItemPointer(pPropertyData, ItemIdx); mpItemArchetype->Destruct(pItemPtr); } } - u32 NewSize = NewCount * ItemSize(); + uint32 NewSize = NewCount * ItemSize(); rArray.Array.resize(NewSize); rArray.Count = NewCount; // Handle construction of new elements if (NewCount > OldCount) { - for (u32 ItemIdx = OldCount; ItemIdx < NewCount; ItemIdx++) + for (uint32 ItemIdx = OldCount; ItemIdx < NewCount; ItemIdx++) { void* pItemPtr = ItemPointer(pPropertyData, ItemIdx); mpItemArchetype->Construct(pItemPtr); @@ -181,19 +181,19 @@ public: } } - void* ItemPointer(void* pPropertyData, u32 ItemIndex) const + void* ItemPointer(void* pPropertyData, uint32 ItemIndex) const { ASSERT(_InternalArrayCount(pPropertyData) > ItemIndex); std::vector& rArray = _GetInternalArray(pPropertyData).Array; - u32 MyItemSize = ItemSize(); + uint32 MyItemSize = ItemSize(); ASSERT(rArray.size() >= (MyItemSize * (ItemIndex+1))); return rArray.data() + (MyItemSize * ItemIndex); } - u32 ItemSize() const + uint32 ItemSize() const { - u32 ItemAlign = mpItemArchetype->DataAlignment(); - u32 ItemSize = ALIGN(mpItemArchetype->DataSize(), ItemAlign); + uint32 ItemAlign = mpItemArchetype->DataAlignment(); + uint32 ItemSize = ALIGN(mpItemArchetype->DataSize(), ItemAlign); return ItemSize; } diff --git a/src/Core/Resource/Script/Property/CByteProperty.h b/src/Core/Resource/Script/Property/CByteProperty.h index 218fcef1..b23cfa1a 100644 --- a/src/Core/Resource/Script/Property/CByteProperty.h +++ b/src/Core/Resource/Script/Property/CByteProperty.h @@ -3,7 +3,7 @@ #include "IProperty.h" -class CByteProperty : public TNumericalProperty< s8, EPropertyType::Byte > +class CByteProperty : public TNumericalProperty< int8, EPropertyType::Byte > { friend class IProperty; @@ -15,12 +15,12 @@ protected: public: virtual void SerializeValue(void* pData, IArchive& Arc) const { - Arc.SerializePrimitive( (u8&) ValueRef(pData), 0 ); + Arc.SerializePrimitive( (int8&) ValueRef(pData), 0 ); } virtual TString ValueAsString(void* pData) const { - return TString::FromInt32( (s32) Value(pData), 0, 10 ); + return TString::FromInt32( (int32) Value(pData), 0, 10 ); } }; diff --git a/src/Core/Resource/Script/Property/CEnumProperty.h b/src/Core/Resource/Script/Property/CEnumProperty.h index aaaa6e31..8a53fc70 100644 --- a/src/Core/Resource/Script/Property/CEnumProperty.h +++ b/src/Core/Resource/Script/Property/CEnumProperty.h @@ -11,20 +11,20 @@ * In PWE, however, they are both implemented the same way under the hood. */ template -class TEnumPropertyBase : public TSerializeableTypedProperty +class TEnumPropertyBase : public TSerializeableTypedProperty { friend class IProperty; struct SEnumValue { TString Name; - u32 ID; + uint32 ID; SEnumValue() : ID(0) {} - SEnumValue(const TString& rkInName, u32 InID) + SEnumValue(const TString& rkInName, uint32 InID) : Name(rkInName), ID(InID) {} @@ -70,7 +70,7 @@ public: TTypedProperty::Serialize(rArc); TEnumPropertyBase* pArchetype = static_cast(mpArchetype); - u32 DefaultValueFlags = SH_HexDisplay | (pArchetype || Game() <= EGame::Prime ? SH_Optional : 0); + uint32 DefaultValueFlags = SH_HexDisplay | (pArchetype || Game() <= EGame::Prime ? SH_Optional : 0); rArc << SerialParameter("DefaultValue", mDefaultValue, DefaultValueFlags, pArchetype ? pArchetype->mDefaultValue : 0); @@ -88,7 +88,7 @@ public: virtual void SerializeValue(void* pData, IArchive& Arc) const { - Arc.SerializePrimitive( (u32&) ValueRef(pData), 0 ); + Arc.SerializePrimitive( (uint32&) ValueRef(pData), 0 ); } virtual void InitFromArchetype(IProperty* pOther) @@ -103,16 +103,16 @@ public: return TString::FromInt32( Value(pData), 0, 10 ); } - void AddValue(TString ValueName, u32 ValueID) + void AddValue(TString ValueName, uint32 ValueID) { mValues.push_back( SEnumValue(ValueName, ValueID) ); } - inline u32 NumPossibleValues() const { return mValues.size(); } + inline uint32 NumPossibleValues() const { return mValues.size(); } - u32 ValueIndex(u32 ID) const + uint32 ValueIndex(uint32 ID) const { - for (u32 ValueIdx = 0; ValueIdx < mValues.size(); ValueIdx++) + for (uint32 ValueIdx = 0; ValueIdx < mValues.size(); ValueIdx++) { if (mValues[ValueIdx].ID == ID) { @@ -122,13 +122,13 @@ public: return -1; } - u32 ValueID(u32 Index) const + uint32 ValueID(uint32 Index) const { ASSERT(Index >= 0 && Index < mValues.size()); return mValues[Index].ID; } - TString ValueName(u32 Index) const + TString ValueName(uint32 Index) const { ASSERT(Index >= 0 && Index < mValues.size()); return mValues[Index].Name; @@ -138,7 +138,7 @@ public: { if (mValues.empty()) return true; int ID = ValueRef(pPropertyData); - u32 Index = ValueIndex(ID); + uint32 Index = ValueIndex(ID); return Index >= 0 && Index < mValues.size(); } diff --git a/src/Core/Resource/Script/Property/CFlagsProperty.cpp b/src/Core/Resource/Script/Property/CFlagsProperty.cpp index 53006f4d..9349f29a 100644 --- a/src/Core/Resource/Script/Property/CFlagsProperty.cpp +++ b/src/Core/Resource/Script/Property/CFlagsProperty.cpp @@ -26,7 +26,7 @@ void CFlagsProperty::PostInitialize() void CFlagsProperty::SerializeValue(void* pData, IArchive& rArc) const { - rArc.SerializePrimitive( (u32&) ValueRef(pData), SH_HexDisplay ); + rArc.SerializePrimitive( (uint32&) ValueRef(pData), SH_HexDisplay ); } void CFlagsProperty::InitFromArchetype(IProperty* pOther) @@ -46,7 +46,7 @@ TString CFlagsProperty::ValueAsString(void* pData) const * Checks whether there are any unrecognized bits toggled on in the property value. * Returns the mask of any invalid bits. If all bits are valid, returns 0. */ -u32 CFlagsProperty::HasValidValue(void* pPropertyData) +uint32 CFlagsProperty::HasValidValue(void* pPropertyData) { if (!mAllFlags) return 0; return ValueRef(pPropertyData) & ~mAllFlags; diff --git a/src/Core/Resource/Script/Property/CFlagsProperty.h b/src/Core/Resource/Script/Property/CFlagsProperty.h index 78838267..61cc3236 100644 --- a/src/Core/Resource/Script/Property/CFlagsProperty.h +++ b/src/Core/Resource/Script/Property/CFlagsProperty.h @@ -3,20 +3,20 @@ #include "IProperty.h" -class CFlagsProperty : public TSerializeableTypedProperty +class CFlagsProperty : public TSerializeableTypedProperty { friend class IProperty; struct SBitFlag { TString Name; - u32 Mask; + uint32 Mask; SBitFlag() : Mask(0) {} - SBitFlag(const TString& rkInName, u32 InMask) + SBitFlag(const TString& rkInName, uint32 InMask) : Name(rkInName), Mask(InMask) {} @@ -32,7 +32,7 @@ class CFlagsProperty : public TSerializeableTypedProperty mBitFlags; - u32 mAllFlags; + uint32 mAllFlags; CFlagsProperty(EGame Game) : TSerializeableTypedProperty(Game) @@ -40,18 +40,18 @@ class CFlagsProperty : public TSerializeableTypedProperty= 0 && Idx < mBitFlags.size()); return mBitFlags[Idx].Name; } - inline u32 FlagMask(u32 Idx) const + inline uint32 FlagMask(uint32 Idx) const { ASSERT(Idx >= 0 && Idx < mBitFlags.size()); return mBitFlags[Idx].Mask; @@ -67,7 +67,7 @@ public: * Checks whether there are any unrecognized bits toggled on in the property value. * Returns the mask of any invalid bits. If all bits are valid, returns 0. */ - u32 HasValidValue(void* pPropertyData); + uint32 HasValidValue(void* pPropertyData); }; #endif // CFLAGSPROPERTY_H diff --git a/src/Core/Resource/Script/Property/CIntProperty.h b/src/Core/Resource/Script/Property/CIntProperty.h index dd62ca4b..3d1d5c73 100644 --- a/src/Core/Resource/Script/Property/CIntProperty.h +++ b/src/Core/Resource/Script/Property/CIntProperty.h @@ -3,7 +3,7 @@ #include "IProperty.h" -class CIntProperty : public TNumericalProperty< s32, EPropertyType::Int > +class CIntProperty : public TNumericalProperty< int32, EPropertyType::Int > { friend class IProperty; diff --git a/src/Core/Resource/Script/Property/CPropertyNameGenerator.cpp b/src/Core/Resource/Script/Property/CPropertyNameGenerator.cpp index 8b627c9a..ad1216ed 100644 --- a/src/Core/Resource/Script/Property/CPropertyNameGenerator.cpp +++ b/src/Core/Resource/Script/Property/CPropertyNameGenerator.cpp @@ -178,7 +178,7 @@ void CPropertyNameGenerator::Generate(const SPropertyNameGenerationParameters& r CCRC32 FullHash = BaseHash; const char* pkTypeName = *mTypeNames[TypeIdx]; FullHash.Hash( pkTypeName ); - u32 PropertyID = FullHash.Digest(); + uint32 PropertyID = FullHash.Digest(); // Check if this hash is a property ID if (IsValidPropertyID(PropertyID, pkTypeName, rkParams)) @@ -234,8 +234,7 @@ void CPropertyNameGenerator::Generate(const SPropertyNameGenerationParameters& r DelimitedXmlList += *Iter + "\n"; } - TString LogMsg = TString::Format("%s [%s] : 0x%08X\n", *PropertyName.Name, *PropertyName.Type, PropertyName.ID) + DelimitedXmlList; - Log::Write(LogMsg); + debugf("%s [%s] : 0x%08X\n%s", *PropertyName.Name, *PropertyName.Type, PropertyName.ID, *DelimitedXmlList); } } } @@ -258,7 +257,7 @@ void CPropertyNameGenerator::Generate(const SPropertyNameGenerationParameters& r } /** Returns whether a given property ID is valid */ -bool CPropertyNameGenerator::IsValidPropertyID(u32 ID, const char*& pkType, const SPropertyNameGenerationParameters& rkParams) +bool CPropertyNameGenerator::IsValidPropertyID(uint32 ID, const char*& pkType, const SPropertyNameGenerationParameters& rkParams) { if (!mValidTypePairMap.empty()) { diff --git a/src/Core/Resource/Script/Property/CPropertyNameGenerator.h b/src/Core/Resource/Script/Property/CPropertyNameGenerator.h index c5d1caaa..d9ef6979 100644 --- a/src/Core/Resource/Script/Property/CPropertyNameGenerator.h +++ b/src/Core/Resource/Script/Property/CPropertyNameGenerator.h @@ -15,7 +15,7 @@ enum class ENameCasing /** ID/type pairing for ID pool */ struct SPropertyIdTypePair { - u32 ID; + uint32 ID; const char* pkType; }; @@ -55,7 +55,7 @@ struct SGeneratedPropertyName { TString Name; TString Type; - u32 ID; + uint32 ID; std::set XmlList; }; @@ -78,7 +78,7 @@ class CPropertyNameGenerator std::vector mTypeNames; /** Mapping of valid ID/type pairs; if empty, all property names in NPropertyMap are allowed */ - std::unordered_map mValidTypePairMap; + std::unordered_map mValidTypePairMap; /** List of words */ struct SWord @@ -105,7 +105,7 @@ public: void Generate(const SPropertyNameGenerationParameters& rkParams, IProgressNotifier* pProgressNotifier); /** Returns whether a given property ID is valid */ - bool IsValidPropertyID(u32 ID, const char*& pkType, const SPropertyNameGenerationParameters& rkParams); + bool IsValidPropertyID(uint32 ID, const char*& pkType, const SPropertyNameGenerationParameters& rkParams); /** Accessors */ bool IsRunning() const diff --git a/src/Core/Resource/Script/Property/CSequenceProperty.h b/src/Core/Resource/Script/Property/CSequenceProperty.h index 4439b7a9..59f49228 100644 --- a/src/Core/Resource/Script/Property/CSequenceProperty.h +++ b/src/Core/Resource/Script/Property/CSequenceProperty.h @@ -3,7 +3,7 @@ #include "IProperty.h" -class CSequenceProperty : public TTypedProperty< s32, EPropertyType::Sequence > +class CSequenceProperty : public TTypedProperty< int32, EPropertyType::Sequence > { friend class IProperty; diff --git a/src/Core/Resource/Script/Property/CShortProperty.h b/src/Core/Resource/Script/Property/CShortProperty.h index 906cc463..4b5ad2a2 100644 --- a/src/Core/Resource/Script/Property/CShortProperty.h +++ b/src/Core/Resource/Script/Property/CShortProperty.h @@ -3,7 +3,7 @@ #include "IProperty.h" -class CShortProperty : public TNumericalProperty< s16, EPropertyType::Short > +class CShortProperty : public TNumericalProperty< int16, EPropertyType::Short > { friend class IProperty; @@ -20,7 +20,7 @@ public: virtual TString ValueAsString(void* pData) const { - return TString::FromInt32( (s32) Value(pData), 0, 10 ); + return TString::FromInt32( (int32) Value(pData), 0, 10 ); } }; diff --git a/src/Core/Resource/Script/Property/CSoundProperty.h b/src/Core/Resource/Script/Property/CSoundProperty.h index be1b22c1..d15f748e 100644 --- a/src/Core/Resource/Script/Property/CSoundProperty.h +++ b/src/Core/Resource/Script/Property/CSoundProperty.h @@ -3,7 +3,7 @@ #include "IProperty.h" -class CSoundProperty : public TSerializeableTypedProperty< s32, EPropertyType::Sound > +class CSoundProperty : public TSerializeableTypedProperty< int32, EPropertyType::Sound > { friend class IProperty; diff --git a/src/Core/Resource/Script/Property/CStructProperty.cpp b/src/Core/Resource/Script/Property/CStructProperty.cpp index 2de5c53b..c8afc521 100644 --- a/src/Core/Resource/Script/Property/CStructProperty.cpp +++ b/src/Core/Resource/Script/Property/CStructProperty.cpp @@ -14,7 +14,7 @@ void CStructProperty::PostInitialize() ASSERT( IsRootParent() || mpArchetype != nullptr ); } -u32 CStructProperty::DataSize() const +uint32 CStructProperty::DataSize() const { if (!mChildren.empty()) { @@ -27,7 +27,7 @@ u32 CStructProperty::DataSize() const } } -u32 CStructProperty::DataAlignment() const +uint32 CStructProperty::DataAlignment() const { // Structs are aligned to the first child property. return (mChildren.empty() ? 1 : mChildren[0]->DataAlignment()); @@ -102,10 +102,10 @@ void CStructProperty::Serialize(IArchive& rArc) // We've initialized from the archetypes, now serialize parameter overrides if (rArc.ParamBegin("SubProperties", 0)) { - u32 NumChildOverrides; + uint32 NumChildOverrides; rArc.SerializeArraySize(NumChildOverrides); - for (u32 ChildIdx = 0; ChildIdx < NumChildOverrides; ChildIdx++) + for (uint32 ChildIdx = 0; ChildIdx < NumChildOverrides; ChildIdx++) { if (rArc.ParamBegin("Element", SH_IgnoreName)) { @@ -113,7 +113,7 @@ void CStructProperty::Serialize(IArchive& rArc) // We don't really need the type, but it's a good sanity check, and it's also good practice // to guarantee that parameters are read in order, as some serializers are order-dependent. EPropertyType ChildType; - u32 ChildID; + uint32 ChildID; rArc << SerialParameter("Type", ChildType, SH_Attribute) << SerialParameter("ID", ChildID, SH_Attribute | SH_HexDisplay ); @@ -134,7 +134,7 @@ void CStructProperty::Serialize(IArchive& rArc) // Check if any properties need to override parameters from their archetype. std::vector PropertiesToSerialize; - for (u32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) + for (uint32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) { if (mChildren[ChildIdx]->ShouldSerialize()) { @@ -142,7 +142,7 @@ void CStructProperty::Serialize(IArchive& rArc) } } - u32 NumChildOverrides = PropertiesToSerialize.size(); + uint32 NumChildOverrides = PropertiesToSerialize.size(); if (NumChildOverrides > 0) { @@ -158,7 +158,7 @@ void CStructProperty::Serialize(IArchive& rArc) void CStructProperty::SerializeValue(void* pData, IArchive& Arc) const { - for (u32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) + for (uint32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) { if (Arc.ParamBegin("Property", 0)) { @@ -176,7 +176,7 @@ void CStructProperty::InitFromArchetype(IProperty* pOther) _ClearChildren(); mChildren.reserve( pOther->NumChildren() ); - for (u32 ChildIdx = 0; ChildIdx < pOther->NumChildren(); ChildIdx++) + for (uint32 ChildIdx = 0; ChildIdx < pOther->NumChildren(); ChildIdx++) { IProperty* pChild = CreateCopy( pOther->ChildByIndex(ChildIdx) ); mChildren.push_back( pChild ); @@ -188,7 +188,7 @@ bool CStructProperty::ShouldSerialize() const if (IProperty::ShouldSerialize()) return true; - for (u32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) + for (uint32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) { if (mChildren[ChildIdx]->ShouldSerialize()) return true; diff --git a/src/Core/Resource/Script/Property/CStructProperty.h b/src/Core/Resource/Script/Property/CStructProperty.h index adbd8f39..af0ea193 100644 --- a/src/Core/Resource/Script/Property/CStructProperty.h +++ b/src/Core/Resource/Script/Property/CStructProperty.h @@ -19,8 +19,8 @@ protected: public: virtual EPropertyType Type() const; virtual void PostInitialize(); - virtual u32 DataSize() const; - virtual u32 DataAlignment() const; + virtual uint32 DataSize() const; + virtual uint32 DataAlignment() const; virtual void Construct(void* pData) const; virtual void Destruct(void* pData) const; virtual bool MatchesDefault(void* pData) const; diff --git a/src/Core/Resource/Script/Property/IProperty.cpp b/src/Core/Resource/Script/Property/IProperty.cpp index 28480644..3ef3b74e 100644 --- a/src/Core/Resource/Script/Property/IProperty.cpp +++ b/src/Core/Resource/Script/Property/IProperty.cpp @@ -76,7 +76,7 @@ void IProperty::Serialize(IArchive& rArc) { // Always serialize ID first! ID is always required (except for root properties, which have an ID of 0xFFFFFFFF) // because they are needed to look up the correct property to apply parameter overrides to. - rArc << SerialParameter("ID", mID, SH_HexDisplay | SH_Attribute | SH_Optional, (u32) 0xFFFFFFFF); + rArc << SerialParameter("ID", mID, SH_HexDisplay | SH_Attribute | SH_Optional, (uint32) 0xFFFFFFFF); // Now we can serialize the archetype reference and initialize if needed if ( ((mpArchetype && mpArchetype->IsRootParent()) || rArc.IsReader()) && rArc.CanSkipParameters() ) @@ -149,7 +149,7 @@ bool IProperty::ShouldSerialize() const mMaxVersion != mpArchetype->mMaxVersion; } -void IProperty::Initialize(IProperty* pInParent, CScriptTemplate* pInTemplate, u32 InOffset) +void IProperty::Initialize(IProperty* pInParent, CScriptTemplate* pInTemplate, uint32 InOffset) { // Make sure we only get initialized once. ASSERT( (mFlags & EPropertyFlag::IsInitialized) == 0 ); @@ -199,7 +199,7 @@ void IProperty::Initialize(IProperty* pInParent, CScriptTemplate* pInTemplate, u PostInitialize(); // Now, route initialization to any child properties... - u32 ChildOffset = mOffset; + uint32 ChildOffset = mOffset; for (int ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) { @@ -231,9 +231,9 @@ void* IProperty::RawValuePtr(void* pData) const return pValuePtr; } -IProperty* IProperty::ChildByID(u32 ID) const +IProperty* IProperty::ChildByID(uint32 ID) const { - for (u32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) + for (uint32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) { if (mChildren[ChildIdx]->mID == ID) return mChildren[ChildIdx]; @@ -248,13 +248,13 @@ IProperty* IProperty::ChildByIDString(const TIDString& rkIdString) // some ID strings are formatted with 8 characters and some with 2 (plus the beginning "0x") ASSERT(rkIdString.Size() >= 4); - u32 IDEndPos = rkIdString.IndexOf(':'); - u32 NextChildID = -1; + uint32 IDEndPos = rkIdString.IndexOf(':'); + uint32 NextChildID = -1; if (IDEndPos == -1) - NextChildID = rkIdString.ToInt32(); + NextChildID = rkIdString.ToInt32(16); else - NextChildID = rkIdString.SubString(2, IDEndPos - 2).ToInt32(); + NextChildID = rkIdString.SubString(2, IDEndPos - 2).ToInt32(16); if (NextChildID == 0xFFFFFFFF) { @@ -278,7 +278,7 @@ void IProperty::GatherAllSubInstances(std::list& OutList, bool Recur { OutList.push_back(this); - for( u32 SubIdx = 0; SubIdx < mSubInstances.size(); SubIdx++ ) + for( uint32 SubIdx = 0; SubIdx < mSubInstances.size(); SubIdx++ ) { IProperty* pSubInstance = mSubInstances[SubIdx]; @@ -310,7 +310,7 @@ TString IProperty::GetTemplateFileName() pTemplateRoot = pTemplateRoot->RootParent(); // Now that we have the base property of our template, we can return the file path. - static const u32 kChopAmount = strlen("../templates/"); + static const uint32 kChopAmount = strlen("../templates/"); if (pTemplateRoot->ScriptTemplate()) { @@ -378,7 +378,7 @@ void IProperty::MarkDirty() mFlags &= ~(EPropertyFlag::HasCachedNameCheck | EPropertyFlag::HasCorrectPropertyName); // Mark sub-instances as dirty since they may need to resave as well - for (u32 SubIdx = 0; SubIdx < mSubInstances.size(); SubIdx++) + for (uint32 SubIdx = 0; SubIdx < mSubInstances.size(); SubIdx++) { mSubInstances[SubIdx]->MarkDirty(); } @@ -454,7 +454,7 @@ bool IProperty::ConvertType(EPropertyType NewType, IProperty* pNewArchetype /*= // Swap out our parent's reference to us to point to the new property. if (mpParent) { - for (u32 SiblingIdx = 0; SiblingIdx < mpParent->mChildren.size(); SiblingIdx++) + for (uint32 SiblingIdx = 0; SiblingIdx < mpParent->mChildren.size(); SiblingIdx++) { IProperty* pSibling = mpParent->mChildren[SiblingIdx]; if (pSibling == this) @@ -466,7 +466,7 @@ bool IProperty::ConvertType(EPropertyType NewType, IProperty* pNewArchetype /*= } // Change all our child properties to be parented under the new property. (Is this adoption?) - for (u32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) + for (uint32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) { mChildren[ChildIdx]->mpParent = pNewProperty; pNewProperty->mChildren.push_back(mChildren[ChildIdx]); @@ -478,7 +478,7 @@ bool IProperty::ConvertType(EPropertyType NewType, IProperty* pNewArchetype /*= // Note that when the sub-instances complete their conversion, they delete themselves. // The IProperty destructor removes the property from the archetype's sub-instance list. // So we shouldn't use a for loop, instead we should just wait until the array is empty - u32 SubCount = mSubInstances.size(); + uint32 SubCount = mSubInstances.size(); while (!mSubInstances.empty()) { @@ -542,7 +542,7 @@ bool IProperty::HasAccurateName() CCRC32 Hash; Hash.Hash(*mName); Hash.Hash(HashableTypeName()); - u32 GeneratedID = Hash.Digest(); + uint32 GeneratedID = Hash.Digest(); // Some choice properties are incorrectly declared as ints, so account for // this and allow matching ints against choice typenames as well. @@ -619,7 +619,7 @@ IProperty* IProperty::CreateCopy(IProperty* pArchetype) IProperty* IProperty::CreateIntrinsic(EPropertyType Type, EGame Game, - u32 Offset, + uint32 Offset, const TString& rkName) { IProperty* pOut = Create(Type, Game); @@ -631,7 +631,7 @@ IProperty* IProperty::CreateIntrinsic(EPropertyType Type, IProperty* IProperty::CreateIntrinsic(EPropertyType Type, IProperty* pParent, - u32 Offset, + uint32 Offset, const TString& rkName) { // pParent should always be valid. diff --git a/src/Core/Resource/Script/Property/IProperty.h b/src/Core/Resource/Script/Property/IProperty.h index f492fee8..4f3f4d01 100644 --- a/src/Core/Resource/Script/Property/IProperty.h +++ b/src/Core/Resource/Script/Property/IProperty.h @@ -3,8 +3,9 @@ #include "Core/Resource/Animation/CAnimationParameters.h" #include -#include -#include +#include +#include +#include #include @@ -17,7 +18,7 @@ class CStructProperty; typedef TString TIDString; /** Property flags */ -enum class EPropertyFlag : u32 +enum class EPropertyFlag : uint32 { /** Property has been fully initialized and has had PostLoad called */ IsInitialized = 0x1, @@ -139,10 +140,10 @@ protected: CScriptTemplate* mpScriptTemplate; /** Offset of this property within the property block */ - u32 mOffset; + uint32 mOffset; /** Property ID. This ID is used to uniquely identify this property within this struct. */ - u32 mID; + uint32 mID; /** Property metadata */ TString mName; @@ -166,8 +167,8 @@ public: /** Interface */ virtual EPropertyType Type() const = 0; - virtual u32 DataSize() const = 0; - virtual u32 DataAlignment() const = 0; + virtual uint32 DataSize() const = 0; + virtual uint32 DataAlignment() const = 0; virtual void Construct(void* pData) const = 0; virtual void Destruct(void* pData) const = 0; virtual bool MatchesDefault(void* pData) const = 0; @@ -187,9 +188,9 @@ public: virtual bool ShouldSerialize() const; /** Utility methods */ - void Initialize(IProperty* pInParent, CScriptTemplate* pInTemplate, u32 InOffset); + void Initialize(IProperty* pInParent, CScriptTemplate* pInTemplate, uint32 InOffset); void* RawValuePtr(void* pData) const; - IProperty* ChildByID(u32 ID) const; + IProperty* ChildByID(uint32 ID) const; IProperty* ChildByIDString(const TIDString& rkIdString); void GatherAllSubInstances(std::list& OutList, bool Recursive); TString GetTemplateFileName(); @@ -206,8 +207,8 @@ public: /** Accessors */ EGame Game() const; inline ECookPreference CookPreference() const; - inline u32 NumChildren() const; - inline IProperty* ChildByIndex(u32 ChildIndex) const; + inline uint32 NumChildren() const; + inline IProperty* ChildByIndex(uint32 ChildIndex) const; inline IProperty* Parent() const; inline IProperty* RootParent(); inline IProperty* Archetype() const; @@ -217,8 +218,8 @@ public: inline TString Description() const; inline TString Suffix() const; inline TIDString IDString(bool FullyQualified) const; - inline u32 Offset() const; - inline u32 ID() const; + inline uint32 Offset() const; + inline uint32 ID() const; inline bool IsInitialized() const { return mFlags.HasFlag(EPropertyFlag::IsInitialized); } inline bool IsArchetype() const { return mFlags.HasFlag(EPropertyFlag::IsArchetype); } @@ -237,12 +238,12 @@ public: static IProperty* CreateIntrinsic(EPropertyType Type, EGame Game, - u32 Offset, + uint32 Offset, const TString& rkName); static IProperty* CreateIntrinsic(EPropertyType Type, IProperty* pParent, - u32 Offset, + uint32 Offset, const TString& rkName); static IProperty* ArchiveConstructor(EPropertyType Type, @@ -254,12 +255,12 @@ inline ECookPreference IProperty::CookPreference() const return mCookPreference; } -inline u32 IProperty::NumChildren() const +inline uint32 IProperty::NumChildren() const { return mChildren.size(); } -inline IProperty* IProperty::ChildByIndex(u32 ChildIndex) const +inline IProperty* IProperty::ChildByIndex(uint32 ChildIndex) const { ASSERT(ChildIndex >= 0 && ChildIndex < mChildren.size()); return mChildren[ChildIndex]; @@ -331,12 +332,12 @@ inline TString IProperty::IDString(bool FullyQualified) const return TString::HexString(mID); } -inline u32 IProperty::Offset() const +inline uint32 IProperty::Offset() const { return mOffset; } -inline u32 IProperty::ID() const +inline uint32 IProperty::ID() const { return mID; } @@ -360,8 +361,8 @@ protected: public: virtual EPropertyType Type() const { return PropEnum; } - virtual u32 DataSize() const { return sizeof(PropType); } - virtual u32 DataAlignment() const { return alignof(PropType); } + virtual uint32 DataSize() const { return sizeof(PropType); } + virtual uint32 DataAlignment() const { return alignof(PropType); } virtual void Construct(void* pData) const { new(ValuePtr(pData)) PropType(mDefaultValue); } virtual void Destruct(void* pData) const { ValueRef(pData).~PropType(); } virtual bool MatchesDefault(void* pData) const { return ValueRef(pData) == mDefaultValue; } diff --git a/src/Core/SRayIntersection.h b/src/Core/SRayIntersection.h index f0f586ca..0c51ed56 100644 --- a/src/Core/SRayIntersection.h +++ b/src/Core/SRayIntersection.h @@ -1,8 +1,8 @@ #ifndef SRAYINTERSECTION #define SRAYINTERSECTION -#include -#include +#include +#include class CSceneNode; @@ -12,12 +12,12 @@ struct SRayIntersection float Distance; CVector3f HitPoint; CSceneNode *pNode; - u32 ComponentIndex; + uint ComponentIndex; SRayIntersection() : Hit(false), Distance(0.f), HitPoint(CVector3f::skZero), pNode(nullptr), ComponentIndex(-1) {} - SRayIntersection(bool _Hit, float _Distance, CVector3f _HitPoint, CSceneNode *_pNode, u32 _ComponentIndex) + SRayIntersection(bool _Hit, float _Distance, CVector3f _HitPoint, CSceneNode *_pNode, uint _ComponentIndex) : Hit(_Hit), Distance(_Distance), HitPoint(_HitPoint), pNode(_pNode), ComponentIndex(_ComponentIndex) {} }; diff --git a/src/Core/Scene/CCharacterNode.cpp b/src/Core/Scene/CCharacterNode.cpp index fe2c3e17..6eb63d11 100644 --- a/src/Core/Scene/CCharacterNode.cpp +++ b/src/Core/Scene/CCharacterNode.cpp @@ -2,7 +2,7 @@ #include "Core/Render/CRenderer.h" #include -CCharacterNode::CCharacterNode(CScene *pScene, u32 NodeID, CAnimSet *pChar /*= 0*/, CSceneNode *pParent /*= 0*/) +CCharacterNode::CCharacterNode(CScene *pScene, uint32 NodeID, CAnimSet *pChar /*= 0*/, CSceneNode *pParent /*= 0*/) : CSceneNode(pScene, NodeID, pParent) , mAnimated(true) , mAnimTime(0.f) @@ -19,7 +19,7 @@ void CCharacterNode::PostLoad() { if (mpCharacter) { - for (u32 iChar = 0; iChar < mpCharacter->NumCharacters(); iChar++) + for (uint32 iChar = 0; iChar < mpCharacter->NumCharacters(); iChar++) mpCharacter->Character(iChar)->pModel->BufferGL(); } } @@ -78,7 +78,7 @@ void CCharacterNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderCom } } -SRayIntersection CCharacterNode::RayNodeIntersectTest(const CRay& rkRay, u32 /*AssetID*/, const SViewInfo& rkViewInfo) +SRayIntersection CCharacterNode::RayNodeIntersectTest(const CRay& rkRay, uint32 /*AssetID*/, const SViewInfo& rkViewInfo) { // Check for bone under ray. Doesn't check for model intersections atm if (mpCharacter && rkViewInfo.ShowFlags.HasFlag(eShowSkeletons)) @@ -88,7 +88,7 @@ SRayIntersection CCharacterNode::RayNodeIntersectTest(const CRay& rkRay, u32 /*A if (pSkel) { UpdateTransformData(); - std::pair Hit = pSkel->RayIntersect(rkRay, mTransformData); + std::pair Hit = pSkel->RayIntersect(rkRay, mTransformData); if (Hit.first != -1) { @@ -106,7 +106,7 @@ SRayIntersection CCharacterNode::RayNodeIntersectTest(const CRay& rkRay, u32 /*A return SRayIntersection(); } -CVector3f CCharacterNode::BonePosition(u32 BoneID) +CVector3f CCharacterNode::BonePosition(uint32 BoneID) { UpdateTransformData(); CSkeleton *pSkel = (mpCharacter ? mpCharacter->Character(mActiveCharSet)->pSkeleton : nullptr); @@ -128,7 +128,7 @@ void CCharacterNode::SetCharSet(CAnimSet *pChar) mLocalAABox = CAABox::skOne; } -void CCharacterNode::SetActiveChar(u32 CharIndex) +void CCharacterNode::SetActiveChar(uint32 CharIndex) { mActiveCharSet = CharIndex; ConditionalSetDirty(); @@ -142,7 +142,7 @@ void CCharacterNode::SetActiveChar(u32 CharIndex) } } -void CCharacterNode::SetActiveAnim(u32 AnimIndex) +void CCharacterNode::SetActiveAnim(uint32 AnimIndex) { mActiveAnim = AnimIndex; ConditionalSetDirty(); diff --git a/src/Core/Scene/CCharacterNode.h b/src/Core/Scene/CCharacterNode.h index 7707cd84..a5803cf8 100644 --- a/src/Core/Scene/CCharacterNode.h +++ b/src/Core/Scene/CCharacterNode.h @@ -9,30 +9,30 @@ class CCharacterNode : public CSceneNode { TResPtr mpCharacter; CBoneTransformData mTransformData; - u32 mActiveCharSet; - u32 mActiveAnim; + uint32 mActiveCharSet; + uint32 mActiveAnim; bool mAnimated; float mAnimTime; mutable bool mTransformDataDirty; public: - explicit CCharacterNode(CScene *pScene, u32 NodeID, CAnimSet *pChar = 0, CSceneNode *pParent = 0); + explicit CCharacterNode(CScene *pScene, uint32 NodeID, CAnimSet *pChar = 0, CSceneNode *pParent = 0); virtual ENodeType NodeType(); virtual void PostLoad(); virtual void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); virtual void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); - virtual SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo); + virtual SRayIntersection RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo); - CVector3f BonePosition(u32 BoneID); + CVector3f BonePosition(uint32 BoneID); void SetCharSet(CAnimSet *pChar); - void SetActiveChar(u32 CharIndex); - void SetActiveAnim(u32 AnimIndex); + void SetActiveChar(uint32 CharIndex); + void SetActiveAnim(uint32 AnimIndex); inline CAnimSet* Character() const { return mpCharacter; } - inline u32 ActiveCharIndex() const { return mActiveCharSet; } - inline u32 ActiveAnimIndex() const { return mActiveAnim; } + inline uint32 ActiveCharIndex() const { return mActiveCharSet; } + inline uint32 ActiveAnimIndex() const { return mActiveAnim; } inline CAnimation* CurrentAnim() const { return (mAnimated && mpCharacter ? mpCharacter->FindAnimationAsset(mActiveAnim) : nullptr); } inline bool IsAnimated() const { return (mAnimated && CurrentAnim() != nullptr); } diff --git a/src/Core/Scene/CCollisionNode.cpp b/src/Core/Scene/CCollisionNode.cpp index 53719494..ea969464 100644 --- a/src/Core/Scene/CCollisionNode.cpp +++ b/src/Core/Scene/CCollisionNode.cpp @@ -4,7 +4,7 @@ #include "Core/Render/CGraphics.h" #include "Core/Render/CRenderer.h" -CCollisionNode::CCollisionNode(CScene *pScene, u32 NodeID, CSceneNode *pParent, CCollisionMeshGroup *pCollision) +CCollisionNode::CCollisionNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent, CCollisionMeshGroup *pCollision) : CSceneNode(pScene, NodeID, pParent) { SetCollision(pCollision); @@ -47,11 +47,11 @@ void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ER CColor BaseTint = TintColor(rkViewInfo); - for (u32 iMesh = 0; iMesh < mpCollision->NumMeshes(); iMesh++) + for (uint32 iMesh = 0; iMesh < mpCollision->NumMeshes(); iMesh++) { CCollisionMesh *pMesh = mpCollision->MeshByIndex(iMesh); - for (u32 iMat = 0; iMat < pMesh->NumMaterials(); iMat++) + for (uint32 iMat = 0; iMat < pMesh->NumMaterials(); iMat++) { CCollisionMaterial& rMat = pMesh->GetMaterial(iMat); @@ -95,7 +95,7 @@ void CCollisionNode::RayAABoxIntersectTest(CRayCollisionTester& /*rTester*/, con // todo } -SRayIntersection CCollisionNode::RayNodeIntersectTest(const CRay& /*rkRay*/, u32 /*AssetID*/, const SViewInfo& /*rkViewInfo*/) +SRayIntersection CCollisionNode::RayNodeIntersectTest(const CRay& /*rkRay*/, uint32 /*AssetID*/, const SViewInfo& /*rkViewInfo*/) { // todo SRayIntersection Result; diff --git a/src/Core/Scene/CCollisionNode.h b/src/Core/Scene/CCollisionNode.h index 0b6d3e68..e54ebc24 100644 --- a/src/Core/Scene/CCollisionNode.h +++ b/src/Core/Scene/CCollisionNode.h @@ -9,12 +9,12 @@ class CCollisionNode : public CSceneNode TResPtr mpCollision; public: - CCollisionNode(CScene *pScene, u32 NodeID, CSceneNode *pParent = 0, CCollisionMeshGroup *pCollision = 0); + CCollisionNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent = 0, CCollisionMeshGroup *pCollision = 0); ENodeType NodeType(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo); - SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo); + SRayIntersection RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo); void SetCollision(CCollisionMeshGroup *pCollision); }; diff --git a/src/Core/Scene/CLightNode.cpp b/src/Core/Scene/CLightNode.cpp index 6b418b62..f5b7a05d 100644 --- a/src/Core/Scene/CLightNode.cpp +++ b/src/Core/Scene/CLightNode.cpp @@ -2,9 +2,9 @@ #include "Core/Render/CDrawUtil.h" #include "Core/Render/CGraphics.h" #include "Core/Render/CRenderer.h" -#include +#include -CLightNode::CLightNode(CScene *pScene, u32 NodeID, CSceneNode *pParent, CLight *pLight) +CLightNode::CLightNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent, CLight *pLight) : CSceneNode(pScene, NodeID, pParent) , mpLight(pLight) { @@ -63,7 +63,7 @@ void CLightNode::RayAABoxIntersectTest(CRayCollisionTester& rTester, const SView if (BoxResult.first) rTester.AddNode(this, 0, BoxResult.second); } -SRayIntersection CLightNode::RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo) +SRayIntersection CLightNode::RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo) { // todo: come up with a better way to share this code between CScriptNode and CLightNode SRayIntersection Out; diff --git a/src/Core/Scene/CLightNode.h b/src/Core/Scene/CLightNode.h index 7734bf83..2b76abb8 100644 --- a/src/Core/Scene/CLightNode.h +++ b/src/Core/Scene/CLightNode.h @@ -8,13 +8,13 @@ class CLightNode : public CSceneNode { CLight *mpLight; public: - CLightNode(CScene *pScene, u32 NodeID, CSceneNode *pParent = 0, CLight *Light = 0); + CLightNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent = 0, CLight *Light = 0); ENodeType NodeType(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& ViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo); - SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); + SRayIntersection RayNodeIntersectTest(const CRay &Ray, uint32 AssetID, const SViewInfo& ViewInfo); CStructRef GetProperties() const; void PropertyModified(IProperty* pProperty); bool AllowsRotate() const { return false; } diff --git a/src/Core/Scene/CModelNode.cpp b/src/Core/Scene/CModelNode.cpp index 6b01d945..21751125 100644 --- a/src/Core/Scene/CModelNode.cpp +++ b/src/Core/Scene/CModelNode.cpp @@ -2,9 +2,9 @@ #include "Core/Render/CDrawUtil.h" #include "Core/Render/CRenderer.h" #include "Core/Render/CGraphics.h" -#include +#include -CModelNode::CModelNode(CScene *pScene, u32 NodeID, CSceneNode *pParent, CModel *pModel) +CModelNode::CModelNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent, CModel *pModel) : CSceneNode(pScene, NodeID, pParent) , mWorldModel(false) , mForceAlphaOn(false) @@ -40,7 +40,7 @@ void CModelNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo { pRenderer->AddMesh(this, -1, AABox(), false, eDrawOpaqueParts); - for (u32 iSurf = 0; iSurf < mpModel->GetSurfaceCount(); iSurf++) + for (uint32 iSurf = 0; iSurf < mpModel->GetSurfaceCount(); iSurf++) { if (mpModel->IsSurfaceTransparent(iSurf, mActiveMatSet)) pRenderer->AddMesh(this, iSurf, mpModel->GetSurfaceAABox(iSurf).Transformed(Transform()), true, eDrawTransparentParts); @@ -129,7 +129,7 @@ void CModelNode::RayAABoxIntersectTest(CRayCollisionTester& rTester, const SView rTester.AddNodeModel(this, mpModel); } -SRayIntersection CModelNode::RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo) +SRayIntersection CModelNode::RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo) { SRayIntersection Out; Out.pNode = this; diff --git a/src/Core/Scene/CModelNode.h b/src/Core/Scene/CModelNode.h index 1c0ef115..7a52a2fd 100644 --- a/src/Core/Scene/CModelNode.h +++ b/src/Core/Scene/CModelNode.h @@ -7,7 +7,7 @@ class CModelNode : public CSceneNode { TResPtr mpModel; - u32 mActiveMatSet; + uint32 mActiveMatSet; bool mWorldModel; bool mForceAlphaOn; CColor mTintColor; @@ -15,7 +15,7 @@ class CModelNode : public CSceneNode CColor mScanOverlayColor; public: - explicit CModelNode(CScene *pScene, u32 NodeID, CSceneNode *pParent = 0, CModel *pModel = 0); + explicit CModelNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent = 0, CModel *pModel = 0); virtual ENodeType NodeType(); virtual void PostLoad(); @@ -23,13 +23,13 @@ public: virtual void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); virtual void DrawSelection(); virtual void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& rkViewInfo); - virtual SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& rkViewInfo); + virtual SRayIntersection RayNodeIntersectTest(const CRay &Ray, uint32 AssetID, const SViewInfo& rkViewInfo); virtual CColor TintColor(const SViewInfo& rkViewInfo) const; // Setters void SetModel(CModel *pModel); - inline void SetMatSet(u32 MatSet) { mActiveMatSet = MatSet; } + inline void SetMatSet(uint32 MatSet) { mActiveMatSet = MatSet; } inline void SetWorldModel(bool World) { mWorldModel = World; } inline void ForceAlphaEnabled(bool Enable) { mForceAlphaOn = Enable; } inline void SetTintColor(const CColor& rkTintColor) { mTintColor = rkTintColor; } @@ -37,9 +37,9 @@ public: inline void SetScanOverlayEnabled(bool Enable) { mEnableScanOverlay = Enable; } inline void SetScanOverlayColor(const CColor& rkColor) { mScanOverlayColor = rkColor; } inline CModel* Model() const { return mpModel; } - inline u32 MatSet() const { return mActiveMatSet; } + inline uint32 MatSet() const { return mActiveMatSet; } inline bool IsWorldModel() const { return mWorldModel; } - inline u32 FindMeshID() const { return mpModel->GetSurface(0)->MeshID; } + inline uint32 FindMeshID() const { return mpModel->GetSurface(0)->MeshID; } }; #endif // CMODELNODE_H diff --git a/src/Core/Scene/CRootNode.h b/src/Core/Scene/CRootNode.h index 46ead301..cfce4aca 100644 --- a/src/Core/Scene/CRootNode.h +++ b/src/Core/Scene/CRootNode.h @@ -8,7 +8,7 @@ class CRootNode : public CSceneNode { public: - explicit CRootNode(CScene *pScene, u32 NodeID, CSceneNode *pParent = 0) + explicit CRootNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent = 0) : CSceneNode(pScene, NodeID, pParent) {} ~CRootNode() {} @@ -19,7 +19,7 @@ public: inline void RayAABoxIntersectTest(CRayCollisionTester&, const SViewInfo&) {} - inline SRayIntersection RayNodeIntersectTest(const CRay &, u32, const SViewInfo&) + inline SRayIntersection RayNodeIntersectTest(const CRay &, uint32, const SViewInfo&) { return SRayIntersection(); } diff --git a/src/Core/Scene/CScene.cpp b/src/Core/Scene/CScene.cpp index e5034d80..451add82 100644 --- a/src/Core/Scene/CScene.cpp +++ b/src/Core/Scene/CScene.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include @@ -29,22 +29,22 @@ CScene::~CScene() delete mpSceneRootNode; } -bool CScene::IsNodeIDUsed(u32 ID) const +bool CScene::IsNodeIDUsed(uint32 ID) const { return (mNodeMap.find(ID) != mNodeMap.end()); } -u32 CScene::CreateNodeID(u32 SuggestedID /*= -1*/) const +uint32 CScene::CreateNodeID(uint32 SuggestedID /*= -1*/) const { if (SuggestedID != -1) { if (IsNodeIDUsed(SuggestedID)) - Log::Error("Suggested node ID is already being used! New ID will be created."); + errorf("Suggested node ID is already being used! New ID will be created."); else return SuggestedID; } - u32 ID = 0; + uint32 ID = 0; while (IsNodeIDUsed(ID)) ID++; @@ -52,11 +52,11 @@ u32 CScene::CreateNodeID(u32 SuggestedID /*= -1*/) const return ID; } -CModelNode* CScene::CreateModelNode(CModel *pModel, u32 NodeID /*= -1*/) +CModelNode* CScene::CreateModelNode(CModel *pModel, uint32 NodeID /*= -1*/) { if (pModel == nullptr) return nullptr; - u32 ID = CreateNodeID(NodeID); + uint32 ID = CreateNodeID(NodeID); CModelNode *pNode = new CModelNode(this, ID, mpAreaRootNode, pModel); mNodes[eModelNode].push_back(pNode); mNodeMap[ID] = pNode; @@ -64,11 +64,11 @@ CModelNode* CScene::CreateModelNode(CModel *pModel, u32 NodeID /*= -1*/) return pNode; } -CStaticNode* CScene::CreateStaticNode(CStaticModel *pModel, u32 NodeID /*= -1*/) +CStaticNode* CScene::CreateStaticNode(CStaticModel *pModel, uint32 NodeID /*= -1*/) { if (pModel == nullptr) return nullptr; - u32 ID = CreateNodeID(NodeID); + uint32 ID = CreateNodeID(NodeID); CStaticNode *pNode = new CStaticNode(this, ID, mpAreaRootNode, pModel); mNodes[eStaticNode].push_back(pNode); mNodeMap[ID] = pNode; @@ -76,11 +76,11 @@ CStaticNode* CScene::CreateStaticNode(CStaticModel *pModel, u32 NodeID /*= -1*/) return pNode; } -CCollisionNode* CScene::CreateCollisionNode(CCollisionMeshGroup *pMesh, u32 NodeID /*= -1*/) +CCollisionNode* CScene::CreateCollisionNode(CCollisionMeshGroup *pMesh, uint32 NodeID /*= -1*/) { if (pMesh == nullptr) return nullptr; - u32 ID = CreateNodeID(NodeID); + uint32 ID = CreateNodeID(NodeID); CCollisionNode *pNode = new CCollisionNode(this, ID, mpAreaRootNode, pMesh); mNodes[eCollisionNode].push_back(pNode); mNodeMap[ID] = pNode; @@ -88,12 +88,12 @@ CCollisionNode* CScene::CreateCollisionNode(CCollisionMeshGroup *pMesh, u32 Node return pNode; } -CScriptNode* CScene::CreateScriptNode(CScriptObject *pObj, u32 NodeID /*= -1*/) +CScriptNode* CScene::CreateScriptNode(CScriptObject *pObj, uint32 NodeID /*= -1*/) { if (pObj == nullptr) return nullptr; - u32 ID = CreateNodeID(NodeID); - u32 InstanceID = pObj->InstanceID(); + uint32 ID = CreateNodeID(NodeID); + uint32 InstanceID = pObj->InstanceID(); CScriptNode *pNode = new CScriptNode(this, ID, mpAreaRootNode, pObj); mNodes[eScriptNode].push_back(pNode); @@ -114,11 +114,11 @@ CScriptNode* CScene::CreateScriptNode(CScriptObject *pObj, u32 NodeID /*= -1*/) return pNode; } -CLightNode* CScene::CreateLightNode(CLight *pLight, u32 NodeID /*= -1*/) +CLightNode* CScene::CreateLightNode(CLight *pLight, uint32 NodeID /*= -1*/) { if (pLight == nullptr) return nullptr; - u32 ID = CreateNodeID(NodeID); + uint32 ID = CreateNodeID(NodeID); CLightNode *pNode = new CLightNode(this, ID, mpAreaRootNode, pLight); mNodes[eLightNode].push_back(pNode); mNodeMap[ID] = pNode; @@ -183,9 +183,9 @@ void CScene::SetActiveArea(CWorld *pWorld, CGameArea *pArea) mpAreaRootNode = new CRootNode(this, -1, mpSceneRootNode); // Create static nodes - u32 Count = mpArea->NumStaticModels(); + uint32 Count = mpArea->NumStaticModels(); - for (u32 iMdl = 0; iMdl < Count; iMdl++) + for (uint32 iMdl = 0; iMdl < Count; iMdl++) { CStaticNode *pNode = CreateStaticNode(mpArea->StaticModel(iMdl)); pNode->SetName("Static World Model " + TString::FromInt32(iMdl, 0, 10)); @@ -194,7 +194,7 @@ void CScene::SetActiveArea(CWorld *pWorld, CGameArea *pArea) // Create model nodes Count = mpArea->NumWorldModels(); - for (u32 iMdl = 0; iMdl < Count; iMdl++) + for (uint32 iMdl = 0; iMdl < Count; iMdl++) { CModel *pModel = mpArea->TerrainModel(iMdl); CModelNode *pNode = CreateModelNode(pModel); @@ -204,15 +204,15 @@ void CScene::SetActiveArea(CWorld *pWorld, CGameArea *pArea) CreateCollisionNode(mpArea->Collision()); - u32 NumLayers = mpArea->NumScriptLayers(); + uint32 NumLayers = mpArea->NumScriptLayers(); - for (u32 iLyr = 0; iLyr < NumLayers; iLyr++) + for (uint32 iLyr = 0; iLyr < NumLayers; iLyr++) { CScriptLayer *pLayer = mpArea->ScriptLayer(iLyr); - u32 NumObjects = pLayer->NumInstances(); + uint32 NumObjects = pLayer->NumInstances(); mNodes[eScriptNode].reserve(mNodes[eScriptNode].size() + NumObjects); - for (u32 iObj = 0; iObj < NumObjects; iObj++) + for (uint32 iObj = 0; iObj < NumObjects; iObj++) { CScriptObject *pObj = pLayer->InstanceByIndex(iObj); CreateScriptNode(pObj); @@ -227,14 +227,14 @@ void CScene::SetActiveArea(CWorld *pWorld, CGameArea *pArea) pScript->BuildLightList(mpArea); } - u32 NumLightLayers = mpArea->NumLightLayers(); + uint32 NumLightLayers = mpArea->NumLightLayers(); CGraphics::sAreaAmbientColor = CColor::skBlack; - for (u32 iLyr = 0; iLyr < NumLightLayers; iLyr++) + for (uint32 iLyr = 0; iLyr < NumLightLayers; iLyr++) { - u32 NumLights = mpArea->NumLights(iLyr); + uint32 NumLights = mpArea->NumLights(iLyr); - for (u32 iLit = 0; iLit < NumLights; iLit++) + for (uint32 iLit = 0; iLit < NumLights; iLit++) { CLight *pLight = mpArea->Light(iLyr, iLit); @@ -246,7 +246,7 @@ void CScene::SetActiveArea(CWorld *pWorld, CGameArea *pArea) } mRanPostLoad = false; - Log::Write( TString::FromInt32(CSceneNode::NumNodes(), 0, 10) + " nodes" ); + debugf("%d nodes", CSceneNode::NumNodes()); } void CScene::PostLoad() @@ -306,7 +306,7 @@ SRayIntersection CScene::SceneRayCast(const CRay& rkRay, const SViewInfo& rkView return Tester.TestNodes(rkViewInfo); } -CSceneNode* CScene::NodeByID(u32 NodeID) +CSceneNode* CScene::NodeByID(uint32 NodeID) { auto it = mNodeMap.find(NodeID); @@ -314,7 +314,7 @@ CSceneNode* CScene::NodeByID(u32 NodeID) else return nullptr; } -CScriptNode* CScene::NodeForInstanceID(u32 InstanceID) +CScriptNode* CScene::NodeForInstanceID(uint32 InstanceID) { auto it = mScriptMap.find(InstanceID); @@ -345,7 +345,7 @@ CModel* CScene::ActiveSkybox() { bool SkyEnabled = false; - for (u32 iAtt = 0; iAtt < mAreaAttributesObjects.size(); iAtt++) + for (uint32 iAtt = 0; iAtt < mAreaAttributesObjects.size(); iAtt++) { const CAreaAttributes& rkAttributes = mAreaAttributesObjects[iAtt]; if (rkAttributes.IsSkyEnabled()) SkyEnabled = true; diff --git a/src/Core/Scene/CScene.h b/src/Core/Scene/CScene.h index b62ba986..fdab20f6 100644 --- a/src/Core/Scene/CScene.h +++ b/src/Core/Scene/CScene.h @@ -15,7 +15,7 @@ #include "Core/Resource/CWorld.h" #include "Core/CAreaAttributes.h" #include "Core/SRayIntersection.h" -#include +#include #include #include @@ -27,7 +27,7 @@ class CScene bool mSplitTerrain; bool mRanPostLoad; - u32 mNumNodes; + uint32 mNumNodes; CRootNode *mpSceneRootNode; std::unordered_map> mNodes; @@ -39,30 +39,30 @@ class CScene std::vector mAreaAttributesObjects; // Node Management - std::unordered_map mNodeMap; - std::unordered_map mScriptMap; + std::unordered_map mNodeMap; + std::unordered_map mScriptMap; public: CScene(); ~CScene(); // Scene Management - bool IsNodeIDUsed(u32 ID) const; - u32 CreateNodeID(u32 SuggestedID = -1) const; + bool IsNodeIDUsed(uint32 ID) const; + uint32 CreateNodeID(uint32 SuggestedID = -1) const; - CModelNode* CreateModelNode(CModel *pModel, u32 NodeID = -1); - CStaticNode* CreateStaticNode(CStaticModel *pModel, u32 NodeID = -1); - CCollisionNode* CreateCollisionNode(CCollisionMeshGroup *pMesh, u32 NodeID = -1); - CScriptNode* CreateScriptNode(CScriptObject *pObj, u32 NodeID = -1); - CLightNode* CreateLightNode(CLight *pLight, u32 NodeID = -1); + CModelNode* CreateModelNode(CModel *pModel, uint32 NodeID = -1); + CStaticNode* CreateStaticNode(CStaticModel *pModel, uint32 NodeID = -1); + CCollisionNode* CreateCollisionNode(CCollisionMeshGroup *pMesh, uint32 NodeID = -1); + CScriptNode* CreateScriptNode(CScriptObject *pObj, uint32 NodeID = -1); + CLightNode* CreateLightNode(CLight *pLight, uint32 NodeID = -1); void DeleteNode(CSceneNode *pNode); void SetActiveArea(CWorld *pWorld, CGameArea *pArea); void PostLoad(); void ClearScene(); void AddSceneToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); SRayIntersection SceneRayCast(const CRay& rkRay, const SViewInfo& rkViewInfo); - CSceneNode* NodeByID(u32 NodeID); - CScriptNode* NodeForInstanceID(u32 InstanceID); + CSceneNode* NodeByID(uint32 NodeID); + CScriptNode* NodeForInstanceID(uint32 InstanceID); CScriptNode* NodeForInstance(CScriptObject *pObj); CLightNode* NodeForLight(CLight *pLight); CModel* ActiveSkybox(); diff --git a/src/Core/Scene/CSceneNode.cpp b/src/Core/Scene/CSceneNode.cpp index 89709237..1f9c107a 100644 --- a/src/Core/Scene/CSceneNode.cpp +++ b/src/Core/Scene/CSceneNode.cpp @@ -4,15 +4,15 @@ #include "Core/Render/CGraphics.h" #include "Core/Render/CDrawUtil.h" #include "Core/Resource/Area/CGameArea.h" -#include -#include +#include +#include #include -u32 CSceneNode::smNumNodes = 0; +uint32 CSceneNode::smNumNodes = 0; CColor CSceneNode::skSelectionTint = CColor::Integral(39, 154, 167); -CSceneNode::CSceneNode(CScene *pScene, u32 NodeID, CSceneNode *pParent) +CSceneNode::CSceneNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent) : mpScene(pScene) , mpParent(pParent) , _mID(NodeID) @@ -134,7 +134,7 @@ void CSceneNode::BuildLightList(CGameArea *pArea) mLightCount = 0; mAmbientColor = CColor::skBlack; - u32 Index = mLightLayerIndex; + uint32 Index = mLightLayerIndex; if ((pArea->NumLightLayers() <= Index) || (pArea->NumLights(Index) == 0)) Index = 0; struct SLightEntry { @@ -151,10 +151,10 @@ void CSceneNode::BuildLightList(CGameArea *pArea) std::vector LightEntries; // Default ambient color to white if there are no lights on the selected layer - u32 NumLights = pArea->NumLights(Index); + uint32 NumLights = pArea->NumLights(Index); if (NumLights == 0) mAmbientColor = CColor::skWhite; - for (u32 iLight = 0; iLight < NumLights; iLight++) + for (uint32 iLight = 0; iLight < NumLights; iLight++) { CLight* pLight = pArea->Light(Index, iLight); @@ -179,7 +179,7 @@ void CSceneNode::BuildLightList(CGameArea *pArea) std::sort(LightEntries.begin(), LightEntries.end()); mLightCount = (LightEntries.size() > 8) ? 8 : LightEntries.size(); - for (u32 iLight = 0; iLight < mLightCount; iLight++) + for (uint32 iLight = 0; iLight < mLightCount; iLight++) mLights[iLight] = LightEntries[iLight].pLight; } @@ -205,7 +205,7 @@ void CSceneNode::LoadLights(const SViewInfo& rkViewInfo) // World lighting: world ambient color, node dynamic lights CGraphics::sVertexBlock.COLOR0_Amb = mAmbientColor; - for (u32 iLight = 0; iLight < mLightCount; iLight++) + for (uint32 iLight = 0; iLight < mLightCount; iLight++) mLights[iLight]->Load(); break; } @@ -214,7 +214,7 @@ void CSceneNode::LoadLights(const SViewInfo& rkViewInfo) CGraphics::UpdateLightBlock(); } -void CSceneNode::AddModelToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet) +void CSceneNode::AddModelToRenderer(CRenderer *pRenderer, CModel *pModel, uint32 MatSet) { ASSERT(pModel); @@ -228,7 +228,7 @@ void CSceneNode::AddModelToRenderer(CRenderer *pRenderer, CModel *pModel, u32 Ma } } -void CSceneNode::DrawModelParts(CModel *pModel, FRenderOptions Options, u32 MatSet, ERenderCommand RenderCommand) +void CSceneNode::DrawModelParts(CModel *pModel, FRenderOptions Options, uint32 MatSet, ERenderCommand RenderCommand) { // Common rendering functionality if (RenderCommand == eDrawMesh) @@ -239,7 +239,7 @@ void CSceneNode::DrawModelParts(CModel *pModel, FRenderOptions Options, u32 MatS bool DrawOpaque = (RenderCommand == eDrawMesh || RenderCommand == eDrawOpaqueParts); bool DrawTransparent = (RenderCommand == eDrawMesh || RenderCommand == eDrawTransparentParts); - for (u32 iSurf = 0; iSurf < pModel->GetSurfaceCount(); iSurf++) + for (uint32 iSurf = 0; iSurf < pModel->GetSurfaceCount(); iSurf++) { bool ShouldRender = ( (DrawOpaque && DrawTransparent) || (DrawOpaque && !pModel->IsSurfaceTransparent(iSurf, MatSet)) || diff --git a/src/Core/Scene/CSceneNode.h b/src/Core/Scene/CSceneNode.h index 1a0f45a2..ef2b2ba8 100644 --- a/src/Core/Scene/CSceneNode.h +++ b/src/Core/Scene/CSceneNode.h @@ -8,13 +8,13 @@ #include "Core/Resource/Area/CGameArea.h" #include "Core/Resource/CLight.h" #include "Core/CRayCollisionTester.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include class CRenderer; class CScene; @@ -30,10 +30,10 @@ private: bool _mInheritsRotation; bool _mInheritsScale; - u32 _mID; + uint32 _mID; protected: - static u32 smNumNodes; + static uint32 smNumNodes; TString mName; CSceneNode *mpParent; CScene *mpScene; @@ -48,13 +48,13 @@ protected: bool mVisible; std::list mChildren; - u32 mLightLayerIndex; - u32 mLightCount; + uint32 mLightLayerIndex; + uint32 mLightCount; CLight* mLights[8]; CColor mAmbientColor; public: - explicit CSceneNode(CScene *pScene, u32 NodeID, CSceneNode *pParent = 0); + explicit CSceneNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent = 0); virtual ~CSceneNode(); virtual ENodeType NodeType() = 0; virtual void PostLoad() {} @@ -62,7 +62,7 @@ public: virtual void AddToRenderer(CRenderer* /*pRenderer*/, const SViewInfo& /*rkViewInfo*/) {} virtual void DrawSelection(); virtual void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo); - virtual SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo) = 0; + virtual SRayIntersection RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo) = 0; virtual bool AllowsTranslate() const { return true; } virtual bool AllowsRotate() const { return true; } virtual bool AllowsScale() const { return true; } @@ -80,8 +80,8 @@ public: void LoadModelMatrix(); void BuildLightList(CGameArea *pArea); void LoadLights(const SViewInfo& rkViewInfo); - void AddModelToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet); - void DrawModelParts(CModel *pModel, FRenderOptions Options, u32 MatSet, ERenderCommand RenderCommand); + void AddModelToRenderer(CRenderer *pRenderer, CModel *pModel, uint32 MatSet); + void DrawModelParts(CModel *pModel, FRenderOptions Options, uint32 MatSet, ERenderCommand RenderCommand); void DrawBoundingBox() const; void DrawRotationArrow() const; @@ -107,12 +107,12 @@ public: TString Name() const { return mName; } CSceneNode* Parent() const { return mpParent; } CScene* Scene() const { return mpScene; } - u32 ID() const { return _mID; } + uint32 ID() const { return _mID; } CVector3f LocalPosition() const { return mPosition; } CQuaternion LocalRotation() const { return mRotation; } CVector3f LocalScale() const { return mScale; } CVector3f CenterPoint() const { return AABox().Center(); } - u32 LightLayerIndex() const { return mLightLayerIndex; } + uint32 LightLayerIndex() const { return mLightLayerIndex; } bool MarkedVisible() const { return mVisible; } bool IsMouseHovering() const { return mMouseHovering; } bool IsSelected() const { return mSelected; } @@ -126,7 +126,7 @@ public: void SetRotation(const CQuaternion& rkRotation) { mRotation = rkRotation; MarkTransformChanged(); } void SetRotation(const CVector3f& rkRotEuler) { mRotation = CQuaternion::FromEuler(rkRotEuler); MarkTransformChanged(); } void SetScale(const CVector3f& rkScale) { mScale = rkScale; MarkTransformChanged(); } - void SetLightLayerIndex(u32 Index) { mLightLayerIndex = Index; } + void SetLightLayerIndex(uint32 Index) { mLightLayerIndex = Index; } void SetMouseHovering(bool Hovering) { mMouseHovering = Hovering; } void SetSelected(bool Selected) { mSelected = Selected; } void SetVisible(bool Visible) { mVisible = Visible; } diff --git a/src/Core/Scene/CScriptAttachNode.cpp b/src/Core/Scene/CScriptAttachNode.cpp index 8ec74b1d..5a6f4334 100644 --- a/src/Core/Scene/CScriptAttachNode.cpp +++ b/src/Core/Scene/CScriptAttachNode.cpp @@ -2,7 +2,7 @@ #include "CScriptNode.h" #include "Core/Render/CRenderer.h" #include "Core/Resource/Script/Property/IProperty.h" -#include +#include CScriptAttachNode::CScriptAttachNode(CScene *pScene, const SAttachment& rkAttachment, CScriptNode *pParent) : CSceneNode(pScene, -1, pParent) @@ -117,7 +117,7 @@ void CScriptAttachNode::RayAABoxIntersectTest(CRayCollisionTester& rTester, cons rTester.AddNodeModel(this, pModel); } -SRayIntersection CScriptAttachNode::RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo) +SRayIntersection CScriptAttachNode::RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo) { FRenderOptions Options = rkViewInfo.pRenderer->RenderOptions(); diff --git a/src/Core/Scene/CScriptAttachNode.h b/src/Core/Scene/CScriptAttachNode.h index 67145017..4882ef65 100644 --- a/src/Core/Scene/CScriptAttachNode.h +++ b/src/Core/Scene/CScriptAttachNode.h @@ -31,7 +31,7 @@ public: void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo); - SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo); + SRayIntersection RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo); inline IProperty* AttachProperty() const { return mpAttachAssetProp; } inline TString LocatorName() const { return mLocatorName; } diff --git a/src/Core/Scene/CScriptNode.cpp b/src/Core/Scene/CScriptNode.cpp index 186fd789..96394023 100644 --- a/src/Core/Scene/CScriptNode.cpp +++ b/src/Core/Scene/CScriptNode.cpp @@ -8,10 +8,10 @@ #include "Core/Resource/Script/CGameTemplate.h" #include "Core/Resource/Script/CScriptLayer.h" #include "Core/ScriptExtra/CScriptExtra.h" -#include -#include +#include +#include -CScriptNode::CScriptNode(CScene *pScene, u32 NodeID, CSceneNode *pParent, CScriptObject *pInstance) +CScriptNode::CScriptNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent, CScriptObject *pInstance) : CSceneNode(pScene, NodeID, pParent) , mGameModeVisibility(eUntested) , mpVolumePreviewNode(nullptr) @@ -58,7 +58,7 @@ CScriptNode::CScriptNode(CScene *pScene, u32 NodeID, CSceneNode *pParent, CScrip } // Create attachment nodes - for (u32 iAttach = 0; iAttach < pTemp->NumAttachments(); iAttach++) + for (uint32 iAttach = 0; iAttach < pTemp->NumAttachments(); iAttach++) { const SAttachment& rkAttach = pTemp->Attachment(iAttach); CScriptAttachNode *pAttach = new CScriptAttachNode(pScene, rkAttach, this); @@ -141,7 +141,7 @@ void CScriptNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInf if (rkViewInfo.ShowFlags & eShowObjectGeometry || rkViewInfo.GameMode) { - for (u32 iAttach = 0; iAttach < mAttachments.size(); iAttach++) + for (uint32 iAttach = 0; iAttach < mAttachments.size(); iAttach++) mAttachments[iAttach]->AddToRenderer(pRenderer, rkViewInfo); if (rkViewInfo.ViewFrustum.BoxInFrustum(AABox())) @@ -267,7 +267,7 @@ void CScriptNode::DrawSelection() CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity; CGraphics::UpdateMVPBlock(); - for (u32 iIn = 0; iIn < mpInstance->NumLinks(eIncoming); iIn++) + for (uint32 iIn = 0; iIn < mpInstance->NumLinks(eIncoming); iIn++) { // Don't draw in links if the other object is selected. CLink *pLink = mpInstance->Link(eIncoming, iIn); @@ -275,7 +275,7 @@ void CScriptNode::DrawSelection() if (pLinkNode && !pLinkNode->IsSelected()) CDrawUtil::DrawLine(CenterPoint(), pLinkNode->CenterPoint(), CColor::skTransparentRed); } - for (u32 iOut = 0; iOut < mpInstance->NumLinks(eOutgoing); iOut++) + for (uint32 iOut = 0; iOut < mpInstance->NumLinks(eOutgoing); iOut++) { CLink *pLink = mpInstance->Link(eOutgoing, iOut); CScriptNode *pLinkNode = mpScene->NodeForInstanceID(pLink->ReceiverID()); @@ -340,11 +340,11 @@ void CScriptNode::RayAABoxIntersectTest(CRayCollisionTester& rTester, const SVie // Run ray check on child nodes as well mpCollisionNode->RayAABoxIntersectTest(rTester, rkViewInfo); - for (u32 iAttach = 0; iAttach < mAttachments.size(); iAttach++) + for (uint32 iAttach = 0; iAttach < mAttachments.size(); iAttach++) mAttachments[iAttach]->RayAABoxIntersectTest(rTester, rkViewInfo); } -SRayIntersection CScriptNode::RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo) +SRayIntersection CScriptNode::RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo) { FRenderOptions Options = rkViewInfo.pRenderer->RenderOptions(); @@ -514,7 +514,7 @@ void CScriptNode::PropertyModified(IProperty* pProp) SetLightLayerIndex(mpLightParameters->LightLayerIndex()); // Notify attachments - for (u32 AttachIdx = 0; AttachIdx < mAttachments.size(); AttachIdx++) + for (uint32 AttachIdx = 0; AttachIdx < mAttachments.size(); AttachIdx++) { CScriptAttachNode* pAttachNode = mAttachments[AttachIdx]; @@ -572,12 +572,12 @@ void CScriptNode::GeneratePosition() // Ideal way to generate the position is to find a spot close to where it's being used. // To do this I check the location of the objects that this one is linked to. - u32 NumLinks = mpInstance->NumLinks(eIncoming) + mpInstance->NumLinks(eOutgoing); + uint32 NumLinks = mpInstance->NumLinks(eIncoming) + mpInstance->NumLinks(eOutgoing); // In the case of one link, apply an offset so the new position isn't the same place as the object it's linked to if (NumLinks == 1) { - u32 LinkedID = (mpInstance->NumLinks(eIncoming) > 0 ? mpInstance->Link(eIncoming, 0)->SenderID() : mpInstance->Link(eOutgoing, 0)->ReceiverID()); + uint32 LinkedID = (mpInstance->NumLinks(eIncoming) > 0 ? mpInstance->Link(eIncoming, 0)->SenderID() : mpInstance->Link(eOutgoing, 0)->ReceiverID()); CScriptNode *pNode = mpScene->NodeForInstanceID(LinkedID); pNode->GeneratePosition(); mPosition = pNode->AbsolutePosition(); @@ -591,7 +591,7 @@ void CScriptNode::GeneratePosition() { CVector3f NewPos = CVector3f::skZero; - for (u32 iIn = 0; iIn < mpInstance->NumLinks(eIncoming); iIn++) + for (uint32 iIn = 0; iIn < mpInstance->NumLinks(eIncoming); iIn++) { CScriptNode *pNode = mpScene->NodeForInstanceID(mpInstance->Link(eIncoming, iIn)->SenderID()); @@ -602,7 +602,7 @@ void CScriptNode::GeneratePosition() } } - for (u32 iOut = 0; iOut < mpInstance->NumLinks(eOutgoing); iOut++) + for (uint32 iOut = 0; iOut < mpInstance->NumLinks(eOutgoing); iOut++) { CScriptNode *pNode = mpScene->NodeForInstanceID(mpInstance->Link(eOutgoing, iOut)->ReceiverID()); @@ -718,7 +718,7 @@ CVector2f CScriptNode::BillboardScale() const return Out * 0.5f * Template()->PreviewScale(); } -CTransform4f CScriptNode::BoneTransform(u32 BoneID, EAttachType AttachType, bool Absolute) const +CTransform4f CScriptNode::BoneTransform(uint32 BoneID, EAttachType AttachType, bool Absolute) const { CTransform4f Out; CSkeleton *pSkel = ActiveSkeleton(); @@ -750,7 +750,7 @@ void CScriptNode::SetDisplayAsset(CResource *pRes) mLocalAABox = (pModel ? pModel->AABox() : CAABox::skOne); MarkTransformChanged(); - for (u32 iAttach = 0; iAttach < mAttachments.size(); iAttach++) + for (uint32 iAttach = 0; iAttach < mAttachments.size(); iAttach++) mAttachments[iAttach]->ParentDisplayAssetChanged(pRes); if (mpExtra) diff --git a/src/Core/Scene/CScriptNode.h b/src/Core/Scene/CScriptNode.h index af358cad..f321b990 100644 --- a/src/Core/Scene/CScriptNode.h +++ b/src/Core/Scene/CScriptNode.h @@ -16,8 +16,8 @@ class CScriptNode : public CSceneNode CScriptExtra *mpExtra; TResPtr mpDisplayAsset; - u32 mCharIndex; - u32 mAnimIndex; + uint32 mCharIndex; + uint32 mAnimIndex; CCollisionNode *mpCollisionNode; std::vector mAttachments; @@ -33,7 +33,7 @@ class CScriptNode : public CSceneNode } mGameModeVisibility; public: - CScriptNode(CScene *pScene, u32 NodeID, CSceneNode *pParent = 0, CScriptObject *pObject = 0); + CScriptNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent = 0, CScriptObject *pObject = 0); ENodeType NodeType(); void PostLoad(); void OnTransformed(); @@ -41,7 +41,7 @@ public: void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo); - SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo); + SRayIntersection RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo); bool AllowsRotate() const; bool AllowsScale() const; bool IsVisible() const; @@ -60,7 +60,7 @@ public: bool HasPreviewVolume() const; CAABox PreviewVolumeAABox() const; CVector2f BillboardScale() const; - CTransform4f BoneTransform(u32 BoneID, EAttachType AttachType, bool Absolute) const; + CTransform4f BoneTransform(uint32 BoneID, EAttachType AttachType, bool Absolute) const; CModel* ActiveModel() const; CAnimSet* ActiveAnimSet() const; @@ -69,9 +69,9 @@ public: CTexture* ActiveBillboard() const; bool UsesModel() const; - inline u32 NumAttachments() const { return mAttachments.size(); } - inline CScriptAttachNode* Attachment(u32 Index) const { return mAttachments[Index]; } - inline CResource* DisplayAsset() const { return mpDisplayAsset; } + inline uint32 NumAttachments() const { return mAttachments.size(); } + inline CScriptAttachNode* Attachment(uint32 Index) const { return mAttachments[Index]; } + inline CResource* DisplayAsset() const { return mpDisplayAsset; } protected: void SetDisplayAsset(CResource *pRes); diff --git a/src/Core/Scene/CStaticNode.cpp b/src/Core/Scene/CStaticNode.cpp index 0accc717..ae80cb01 100644 --- a/src/Core/Scene/CStaticNode.cpp +++ b/src/Core/Scene/CStaticNode.cpp @@ -2,9 +2,9 @@ #include "Core/Render/CGraphics.h" #include "Core/Render/CDrawUtil.h" #include "Core/Render/CRenderer.h" -#include +#include -CStaticNode::CStaticNode(CScene *pScene, u32 NodeID, CSceneNode *pParent, CStaticModel *pModel) +CStaticNode::CStaticNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent, CStaticModel *pModel) : CSceneNode(pScene, NodeID, pParent) , mpModel(pModel) { @@ -38,8 +38,8 @@ void CStaticNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInf else { - u32 NumSurfaces = mpModel->GetSurfaceCount(); - for (u32 iSurf = 0; iSurf < NumSurfaces; iSurf++) + uint32 NumSurfaces = mpModel->GetSurfaceCount(); + for (uint32 iSurf = 0; iSurf < NumSurfaces; iSurf++) { CAABox TransformedBox = mpModel->GetSurfaceAABox(iSurf).Transformed(Transform()); @@ -102,7 +102,7 @@ void CStaticNode::RayAABoxIntersectTest(CRayCollisionTester& rTester, const SVie if (BoxResult.first) { - for (u32 iSurf = 0; iSurf < mpModel->GetSurfaceCount(); iSurf++) + for (uint32 iSurf = 0; iSurf < mpModel->GetSurfaceCount(); iSurf++) { std::pair SurfResult = mpModel->GetSurfaceAABox(iSurf).Transformed(Transform()).IntersectsRay(rkRay); @@ -112,7 +112,7 @@ void CStaticNode::RayAABoxIntersectTest(CRayCollisionTester& rTester, const SVie } } -SRayIntersection CStaticNode::RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo) +SRayIntersection CStaticNode::RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo) { SRayIntersection Out; Out.pNode = this; diff --git a/src/Core/Scene/CStaticNode.h b/src/Core/Scene/CStaticNode.h index 5cf3876d..1d835328 100644 --- a/src/Core/Scene/CStaticNode.h +++ b/src/Core/Scene/CStaticNode.h @@ -9,14 +9,14 @@ class CStaticNode : public CSceneNode CStaticModel *mpModel; public: - CStaticNode(CScene *pScene, u32 NodeID, CSceneNode *pParent = 0, CStaticModel *pModel = 0); + CStaticNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent = 0, CStaticModel *pModel = 0); ENodeType NodeType(); void PostLoad(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo); - SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo); + SRayIntersection RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo); }; #endif // CSTATICNODE_H diff --git a/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp b/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp index f05b108a..9decf736 100644 --- a/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp +++ b/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp @@ -1,14 +1,14 @@ #include "CDamageableTriggerExtra.h" #include "Core/Render/CDrawUtil.h" #include "Core/Render/CRenderer.h" -#include -#include +#include +#include CDamageableTriggerExtra::CDamageableTriggerExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent) : CScriptExtra(pInstance, pScene, pParent) , mpMat(nullptr) { - for (u32 iTex = 0; iTex < 3; iTex++) + for (uint32 iTex = 0; iTex < 3; iTex++) mpTextures[iTex] = nullptr; SetInheritance(true, false, false); @@ -25,7 +25,7 @@ CDamageableTriggerExtra::CDamageableTriggerExtra(CScriptObject *pInstance, CScen if (mPlaneSize.IsValid()) PropertyModified(mPlaneSize.Property()); // Fetch textures - for (u32 TextureIdx = 0; TextureIdx < 3; TextureIdx++) + for (uint32 TextureIdx = 0; TextureIdx < 3; TextureIdx++) { mTextureAssets[TextureIdx] = CAssetRef(pInstance->PropertyData(), pProperties->ChildByIndex(6 + TextureIdx)); if (mTextureAssets[TextureIdx].IsValid()) PropertyModified(mTextureAssets[TextureIdx].Property()); @@ -134,7 +134,7 @@ CDamageableTriggerExtra::ERenderSide CDamageableTriggerExtra::RenderSideForDirec { // Get the index of the largest XYZ component CVector3f AbsDir(Math::Abs(rkDir.X), Math::Abs(rkDir.Y), Math::Abs(rkDir.Z)); - u32 Max = (AbsDir.X > AbsDir.Y ? 0 : 1); + uint32 Max = (AbsDir.X > AbsDir.Y ? 0 : 1); Max = (AbsDir[Max] > AbsDir.Z ? Max : 2); // Check whether the direction is positive or negative. If the absolute value of the component matches the input one, then it's positive. @@ -187,7 +187,7 @@ void CDamageableTriggerExtra::PropertyModified(IProperty* pProperty) else { - for (u32 TextureIdx = 0; TextureIdx < 3; TextureIdx++) + for (uint32 TextureIdx = 0; TextureIdx < 3; TextureIdx++) { if (pProperty == mTextureAssets[TextureIdx].Property()) { @@ -280,7 +280,7 @@ void CDamageableTriggerExtra::RayAABoxIntersectTest(CRayCollisionTester& rTester } } -SRayIntersection CDamageableTriggerExtra::RayNodeIntersectTest(const CRay& rkRay, u32 /*ComponentIndex*/, const SViewInfo& /*rkViewInfo*/) +SRayIntersection CDamageableTriggerExtra::RayNodeIntersectTest(const CRay& rkRay, uint32 /*ComponentIndex*/, const SViewInfo& /*rkViewInfo*/) { // The bounding box and all other tests already passed in RayAABoxIntersectTest, so we // already know that we have a positive. diff --git a/src/Core/ScriptExtra/CDamageableTriggerExtra.h b/src/Core/ScriptExtra/CDamageableTriggerExtra.h index a0a9bb6a..b6cf007e 100644 --- a/src/Core/ScriptExtra/CDamageableTriggerExtra.h +++ b/src/Core/ScriptExtra/CDamageableTriggerExtra.h @@ -41,7 +41,7 @@ public: void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo); - SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 ComponentIndex, const SViewInfo& rkViewInfo); + SRayIntersection RayNodeIntersectTest(const CRay& rkRay, uint32 ComponentIndex, const SViewInfo& rkViewInfo); }; #endif // CDAMAGEABLETRIGGEREXTRA_H diff --git a/src/Core/ScriptExtra/CDoorExtra.cpp b/src/Core/ScriptExtra/CDoorExtra.cpp index 91ec5a4a..adf9713e 100644 --- a/src/Core/ScriptExtra/CDoorExtra.cpp +++ b/src/Core/ScriptExtra/CDoorExtra.cpp @@ -103,7 +103,7 @@ void CDoorExtra::RayAABoxIntersectTest(CRayCollisionTester& rTester, const SView rTester.AddNodeModel(this, mpShieldModel); } -SRayIntersection CDoorExtra::RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo) +SRayIntersection CDoorExtra::RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo) { FRenderOptions Options = rkViewInfo.pRenderer->RenderOptions(); diff --git a/src/Core/ScriptExtra/CDoorExtra.h b/src/Core/ScriptExtra/CDoorExtra.h index 4667e56f..fa55c94b 100644 --- a/src/Core/ScriptExtra/CDoorExtra.h +++ b/src/Core/ScriptExtra/CDoorExtra.h @@ -20,7 +20,7 @@ public: void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo); - SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo); + SRayIntersection RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo); }; #endif // CDOOREXTRA_H diff --git a/src/Core/ScriptExtra/CRadiusSphereExtra.h b/src/Core/ScriptExtra/CRadiusSphereExtra.h index 008fc3fc..e7c41384 100644 --- a/src/Core/ScriptExtra/CRadiusSphereExtra.h +++ b/src/Core/ScriptExtra/CRadiusSphereExtra.h @@ -6,7 +6,7 @@ class CRadiusSphereExtra : public CScriptExtra { // Sphere visualization for objects that have a float radius property. - u32 mObjectType; + uint32 mObjectType; CFloatRef mRadius; public: diff --git a/src/Core/ScriptExtra/CSandwormExtra.cpp b/src/Core/ScriptExtra/CSandwormExtra.cpp index 705cc6a1..3d8fa827 100644 --- a/src/Core/ScriptExtra/CSandwormExtra.cpp +++ b/src/Core/ScriptExtra/CSandwormExtra.cpp @@ -4,7 +4,7 @@ CSandwormExtra::CSandwormExtra(CScriptObject* pInstance, CScene* pScene, CScript : CScriptExtra(pInstance, pScene, pParent) { // The back pincers need to be flipped 180 degrees - for (u32 AttachIdx = 0; AttachIdx < pParent->NumAttachments(); AttachIdx++) + for (uint32 AttachIdx = 0; AttachIdx < pParent->NumAttachments(); AttachIdx++) { CScriptAttachNode *pAttach = pParent->Attachment(AttachIdx); @@ -21,7 +21,7 @@ void CSandwormExtra::PropertyModified(IProperty* pProp) { if (pProp == mPincersScale) { - for (u32 AttachIdx = 0; AttachIdx < mpScriptNode->NumAttachments(); AttachIdx++) + for (uint32 AttachIdx = 0; AttachIdx < mpScriptNode->NumAttachments(); AttachIdx++) { CScriptAttachNode* pAttach = mpScriptNode->Attachment(AttachIdx); pAttach->SetScale( CVector3f(mPincersScale) ); diff --git a/src/Core/ScriptExtra/CScriptExtra.h b/src/Core/ScriptExtra/CScriptExtra.h index ec5812e0..0734173a 100644 --- a/src/Core/ScriptExtra/CScriptExtra.h +++ b/src/Core/ScriptExtra/CScriptExtra.h @@ -3,7 +3,7 @@ #include "Core/Scene/CSceneNode.h" #include "Core/Scene/CScriptNode.h" -#include +#include /* CScriptExtra is a class that allows for additional coded behavior on any given * script object type. Subclass IScriptExtra, add the new class to CScriptExtra.cpp, @@ -36,7 +36,7 @@ public: // Default implementations for CSceneNode virtual ENodeType NodeType() { return eScriptExtraNode; } virtual void RayAABoxIntersectTest(CRayCollisionTester& /*rTester*/, const SViewInfo& /*rkViewInfo*/) {} - virtual SRayIntersection RayNodeIntersectTest(const CRay& /*rkRay*/, u32 /*AssetID*/, const SViewInfo& /*rkViewInfo*/) + virtual SRayIntersection RayNodeIntersectTest(const CRay& /*rkRay*/, uint32 /*AssetID*/, const SViewInfo& /*rkViewInfo*/) { SRayIntersection out; out.Hit = false; diff --git a/src/Core/ScriptExtra/CSplinePathExtra.cpp b/src/Core/ScriptExtra/CSplinePathExtra.cpp index 5a933939..b802213f 100644 --- a/src/Core/ScriptExtra/CSplinePathExtra.cpp +++ b/src/Core/ScriptExtra/CSplinePathExtra.cpp @@ -46,7 +46,7 @@ void CSplinePathExtra::AddWaypoints() std::set CheckedWaypoints; - for (u32 LinkIdx = 0; LinkIdx < mpInstance->NumLinks(eOutgoing); LinkIdx++) + for (uint32 LinkIdx = 0; LinkIdx < mpInstance->NumLinks(eOutgoing); LinkIdx++) { CLink* pLink = mpInstance->Link(eOutgoing, LinkIdx); diff --git a/src/Core/ScriptExtra/CWaypointExtra.cpp b/src/Core/ScriptExtra/CWaypointExtra.cpp index d6862f79..3a3cdc73 100644 --- a/src/Core/ScriptExtra/CWaypointExtra.cpp +++ b/src/Core/ScriptExtra/CWaypointExtra.cpp @@ -79,7 +79,7 @@ void CWaypointExtra::BuildLinks() { mLinks.clear(); - for (u32 iLink = 0; iLink < mpInstance->NumLinks(eOutgoing); iLink++) + for (uint32 iLink = 0; iLink < mpInstance->NumLinks(eOutgoing); iLink++) { CLink *pLink = mpInstance->Link(eOutgoing, iLink); @@ -130,7 +130,7 @@ void CWaypointExtra::GetLinkedWaypoints(std::list& rOut) { if (!mLinksBuilt) BuildLinks(); - for (u32 iLink = 0; iLink < mLinks.size(); iLink++) + for (uint32 iLink = 0; iLink < mLinks.size(); iLink++) { const SWaypointLink& rkLink = mLinks[iLink]; CWaypointExtra *pExtra = static_cast(rkLink.pWaypoint->Extra()); @@ -140,7 +140,7 @@ void CWaypointExtra::GetLinkedWaypoints(std::list& rOut) void CWaypointExtra::OnTransformed() { - for (u32 iLink = 0; iLink < mLinks.size(); iLink++) + for (uint32 iLink = 0; iLink < mLinks.size(); iLink++) { SWaypointLink& rLink = mLinks[iLink]; rLink.LineAABB = CAABox::skInfinite; @@ -162,7 +162,7 @@ void CWaypointExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkView if (!rkViewInfo.GameMode && (rkViewInfo.ShowFlags & eShowObjectGeometry) && mpParent->IsVisible() && !mpParent->IsSelected()) { - for (u32 iLink = 0; iLink < mLinks.size(); iLink++) + for (uint32 iLink = 0; iLink < mLinks.size(); iLink++) { CScriptNode *pNode = mLinks[iLink].pWaypoint; diff --git a/src/Editor/CAboutDialog.ui b/src/Editor/CAboutDialog.ui index 0a1da497..985d27c7 100644 --- a/src/Editor/CAboutDialog.ui +++ b/src/Editor/CAboutDialog.ui @@ -23,7 +23,7 @@ - <html><head/><body><p><span style=" font-size:12pt; font-weight:600;">%APP_FULL_NAME%</span></p><p>%APP_NAME% is developed by <span style=" font-weight:600;">Aruki</span>.<br/>All the games it edits are developed by <span style=" font-weight:600;">Retro Studios</span> and published by <span style=" font-weight:600;">Nintendo</span>.</p><p>Special thanks to:</p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The community at <span style=" font-weight:600;">Metroid2002</span> that contributed to reverse engineering the game and documenting its internals and file formats; in particular, <span style=" font-weight:600;">Antidote</span> and <span style=" font-weight:600;">jackoalan</span>, among others!</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Claris: </span>In addition to helping reverse engineer a few formats (in particular MLVL and MREA), also contributed greatly to putting together the script object templates and documenting object properties.</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Bearborg:</span> Lots of testing and feedback, plus the UI icons and some script object assets.</li><li style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Omega: </span>Script object assets.</li></ul><p>Check the <a href="http://www.metroid2002.com/retromodding/wiki/Retro_Modding_Wiki"><span style=" text-decoration: underline; color:#007af4;">Retro Modding Wiki</span></a> for file format documentation.</p><p>If you enjoy Prime World Editor and want to support its continued development, you can support me on <a href="https://www.patreon.com/arukibree"><span style=" text-decoration: underline; color:#007af4;">Patreon</span></a>!</p><p>%APP_NAME% uses <span style=" font-weight:600;">Assimp</span> (Open Asset Import Library).<br/>Copyright © 2006-2015 assimp team<br/>All rights reserved.</p></body></html> + <html><head/><body><p><span style=" font-size:12pt; font-weight:600;">%APP_FULL_NAME%</span></p><p>%APP_NAME% is developed by <span style=" font-weight:600;">Aruki</span>.<br/>All the games it edits are developed by <span style=" font-weight:600;">Retro Studios</span> and published by <span style=" font-weight:600;">Nintendo</span>.</p><p>Special thanks to:</p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The community at <span style=" font-weight:600;">Metroid2002</span> that contributed to reverse engineering the game and documenting its internals and file formats; in particular, <span style=" font-weight:600;">Antidote</span> and <span style=" font-weight:600;">jackoalan</span>, among others!</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Claris: </span>In addition to helping reverse engineer a few formats (in particular MLVL and MREA), also contributed greatly to putting together the script object templates and documenting object properties.</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Bearborg:</span> Lots of testing and feedback, plus the UI icons and some script object assets.</li><li style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Omega: </span>Script object assets.</li></ul><p>Check the <a href="http://www.metroid2002.com/retromodding/wiki/Retro_Modding_Wiki"><span style=" text-decoration: underline; color:#007af4;">Retro Modding Wiki</span></a> for file format documentation.</p><p>%APP_NAME% uses <span style=" font-weight:600;">Assimp</span> (Open Asset Import Library).<br/>Copyright © 2006-2015 assimp team<br/>All rights reserved.</p></body></html> true diff --git a/src/Editor/CBasicViewport.cpp b/src/Editor/CBasicViewport.cpp index 69c362e5..e10b8af0 100644 --- a/src/Editor/CBasicViewport.cpp +++ b/src/Editor/CBasicViewport.cpp @@ -1,5 +1,5 @@ #include "CBasicViewport.h" -#include +#include #include #include diff --git a/src/Editor/CBasicViewport.h b/src/Editor/CBasicViewport.h index 01337254..19bf7d05 100644 --- a/src/Editor/CBasicViewport.h +++ b/src/Editor/CBasicViewport.h @@ -2,9 +2,9 @@ #define CEDITORGLWIDGET_H #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/Editor/CEditorApplication.cpp b/src/Editor/CEditorApplication.cpp index 423af69d..91dadbfd 100644 --- a/src/Editor/CEditorApplication.cpp +++ b/src/Editor/CEditorApplication.cpp @@ -7,7 +7,7 @@ #include "Editor/ModelEditor/CModelEditorWindow.h" #include "Editor/ResourceBrowser/CResourceBrowser.h" #include "Editor/WorldEditor/CWorldEditor.h" -#include +#include #include #include @@ -134,7 +134,7 @@ void CEditorApplication::EditResource(CResourceEntry *pEntry) if (It->Dependencies()->HasDependency(pEntry->ID())) { CWorld *pWorld = (CWorld*) It->Load(); - u32 AreaIdx = pWorld->AreaIndex(pEntry->ID()); + uint32 AreaIdx = pWorld->AreaIndex(pEntry->ID()); if (AreaIdx != -1) { @@ -179,7 +179,7 @@ bool CEditorApplication::CookAllDirtyPackages() ASSERT(mpActiveProject != nullptr); QList PackageList; - for (u32 iPkg = 0; iPkg < mpActiveProject->NumPackages(); iPkg++) + for (uint32 iPkg = 0; iPkg < mpActiveProject->NumPackages(); iPkg++) { CPackage *pPackage = mpActiveProject->PackageByIndex(iPkg); diff --git a/src/Editor/CErrorLogDialog.cpp b/src/Editor/CErrorLogDialog.cpp index 8bb15043..8d5886c5 100644 --- a/src/Editor/CErrorLogDialog.cpp +++ b/src/Editor/CErrorLogDialog.cpp @@ -18,7 +18,7 @@ CErrorLogDialog::~CErrorLogDialog() bool CErrorLogDialog::GatherErrors() { - const TStringList& rkErrors = Log::GetErrorLog(); + const TStringList& rkErrors = NLog::GetErrorLog(); if (rkErrors.empty()) return false; QString DialogString; @@ -46,6 +46,6 @@ bool CErrorLogDialog::GatherErrors() } ui->ErrorLogTextEdit->setText(DialogString); - Log::ClearErrorLog(); + NLog::ClearErrorLog(); return true; } diff --git a/src/Editor/CExportGameDialog.cpp b/src/Editor/CExportGameDialog.cpp index 693960fe..0d204b73 100644 --- a/src/Editor/CExportGameDialog.cpp +++ b/src/Editor/CExportGameDialog.cpp @@ -3,7 +3,7 @@ #include "CProgressDialog.h" #include "UICommon.h" -#include +#include #include #include #include @@ -273,13 +273,13 @@ float CExportGameDialog::FindBuildVersion() // Get DOL buffer std::unique_ptr pDolData = mpDisc->getDataPartition()->getDOLBuf(); - u32 DolSize = (u32) mpDisc->getDataPartition()->getDOLSize(); + uint32 DolSize = (uint32) mpDisc->getDataPartition()->getDOLSize(); // Find build info string const char *pkSearchText = "!#$MetroidBuildInfo!#$"; const int SearchTextSize = strlen(pkSearchText); - for (u32 SearchIdx = 0; SearchIdx < DolSize - SearchTextSize + 1; SearchIdx++) + for (uint32 SearchIdx = 0; SearchIdx < DolSize - SearchTextSize + 1; SearchIdx++) { int Match = 0; @@ -297,7 +297,7 @@ float CExportGameDialog::FindBuildVersion() } } - Log::Error("Failed to find MetroidBuildInfo string. Build Version will be set to 0."); + errorf("Failed to find MetroidBuildInfo string. Build Version will be set to 0."); return 0.f; } diff --git a/src/Editor/CGeneratePropertyNamesDialog.cpp b/src/Editor/CGeneratePropertyNamesDialog.cpp index bb9053e3..17c0ee66 100644 --- a/src/Editor/CGeneratePropertyNamesDialog.cpp +++ b/src/Editor/CGeneratePropertyNamesDialog.cpp @@ -51,11 +51,11 @@ void CGeneratePropertyNamesDialog::AddToIDPool(IProperty* pProperty) { if (!pProperty->UsesNameMap()) { - Log::Error("Failed to add property " + pProperty->IDString(false) + " to the generator ID pool because it doesn't use the name map"); + errorf("Failed to add property %s to the generator ID pool because it doesn't use the name map", *pProperty->IDString(false)); return; } - u32 ID = pProperty->ID(); + uint32 ID = pProperty->ID(); const char* pkTypeName = pProperty->HashableTypeName(); mIdPairs << SPropertyIdTypePair { ID, pkTypeName }; @@ -73,7 +73,7 @@ void CGeneratePropertyNamesDialog::AddToIDPool(IProperty* pProperty) /** Populate the ID pool with the children of the given property */ void CGeneratePropertyNamesDialog::AddChildrenToIDPool(IProperty* pProperty, bool Recursive) { - for (u32 ChildIdx = 0; ChildIdx < pProperty->NumChildren(); ChildIdx++) + for (uint32 ChildIdx = 0; ChildIdx < pProperty->NumChildren(); ChildIdx++) { IProperty* pChild = pProperty->ChildByIndex(ChildIdx); @@ -287,7 +287,7 @@ void CGeneratePropertyNamesDialog::ApplyChanges() for (int ItemIdx = 0; ItemIdx < mCheckedItems.size(); ItemIdx++) { QTreeWidgetItem* pItem = mCheckedItems[ItemIdx]; - u32 ID = TO_TSTRING( pItem->text(2) ).ToInt32(); + uint32 ID = TO_TSTRING( pItem->text(2) ).ToInt32(16); TString Type = TO_TSTRING( pItem->text(1) ); TString NewName = TO_TSTRING( pItem->text(0) ); diff --git a/src/Editor/CGizmo.cpp b/src/Editor/CGizmo.cpp index c62ad703..4268996d 100644 --- a/src/Editor/CGizmo.cpp +++ b/src/Editor/CGizmo.cpp @@ -1,5 +1,5 @@ #include "CGizmo.h" -#include +#include #include #include #include @@ -47,14 +47,14 @@ void CGizmo::AddToRenderer(CRenderer *pRenderer, const SViewInfo&) SModelPart *pPart = mpCurrentParts; // Add all parts to renderer - for (u32 iPart = 0; iPart < mNumCurrentParts; iPart++) + for (uint32 iPart = 0; iPart < mNumCurrentParts; iPart++) { CModel *pModel = pPart->pModel; // Determine whether to use the mat set for regular (0) or highlight (1) FGizmoAxes PartAxes = pPart->ModelAxes; bool IsHighlighted = (PartAxes != eNone) && ((mSelectedAxes & PartAxes) == pPart->ModelAxes); - u32 SetID = (IsHighlighted ? 1 : 0); + uint32 SetID = (IsHighlighted ? 1 : 0); // Add to renderer... pRenderer->AddMesh(this, iPart, pModel->AABox().Transformed(mTransform), pModel->HasTransparency(SetID), eDrawMesh, eForeground); @@ -85,7 +85,7 @@ void CGizmo::Draw(FRenderOptions /*Options*/, int ComponentIndex, ERenderCommand // Choose material set FGizmoAxes PartAxes = pPart[ComponentIndex].ModelAxes; bool IsHighlighted = (PartAxes != eNone) && ((mSelectedAxes & PartAxes) == pPart[ComponentIndex].ModelAxes); - u32 SetID = (IsHighlighted ? 1 : 0); + uint32 SetID = (IsHighlighted ? 1 : 0); // Draw model pPart[ComponentIndex].pModel->Draw((FRenderOptions) 0, SetID); @@ -141,7 +141,7 @@ bool CGizmo::CheckSelectedAxes(const CRay& rkRay) }; std::list Results; - for (u32 iPart = 0; iPart < mNumCurrentParts; iPart++) + for (uint32 iPart = 0; iPart < mNumCurrentParts; iPart++) { if (!pPart->EnableRayCast) { @@ -162,7 +162,7 @@ bool CGizmo::CheckSelectedAxes(const CRay& rkRay) bool Hit = false; float Dist; - for (u32 iSurf = 0; iSurf < pModel->GetSurfaceCount(); iSurf++) + for (uint32 iSurf = 0; iSurf < pModel->GetSurfaceCount(); iSurf++) { // Skip surface/box check - since we use lines the boxes might be too small SSurface *pSurf = pModel->GetSurface(iSurf); @@ -209,11 +209,11 @@ bool CGizmo::CheckSelectedAxes(const CRay& rkRay) return (mSelectedAxes != eNone); } -u32 CGizmo::NumSelectedAxes() +uint32 CGizmo::NumSelectedAxes() { - u32 Out = 0; + uint32 Out = 0; - for (u32 iAxis = 1; iAxis < 8; iAxis <<= 1) + for (uint32 iAxis = 1; iAxis < 8; iAxis <<= 1) if (mSelectedAxes & FGizmoAxes(iAxis)) Out++; return Out; @@ -291,7 +291,7 @@ bool CGizmo::TransformFromInput(const CRay& rkRay, CCamera& rCamera) { // Create translate plane CVector3f AxisA, AxisB; - u32 NumAxes = NumSelectedAxes(); + uint32 NumAxes = NumSelectedAxes(); if (NumAxes == 1) { @@ -541,7 +541,7 @@ void CGizmo::LoadModels() { if (!smModelsLoaded) { - Log::Write("Loading transform gizmo models"); + debugf("Loading transform gizmo models"); smTranslateModels[CGIZMO_TRANSLATE_X] = SModelPart(eX, true, false, gpEditorStore->LoadResource("editor/TranslateX.CMDL")); smTranslateModels[CGIZMO_TRANSLATE_Y] = SModelPart(eY, true, false, gpEditorStore->LoadResource("editor/TranslateY.CMDL")); diff --git a/src/Editor/CGizmo.h b/src/Editor/CGizmo.h index 15c4f1a3..8b79bbe2 100644 --- a/src/Editor/CGizmo.h +++ b/src/Editor/CGizmo.h @@ -2,10 +2,10 @@ #define CGIZMO_H #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -115,7 +115,7 @@ private: ModelAxes(Axes), EnableRayCast(RayCastOn), IsBillboard(Billboard), pModel(_pModel) {} }; SModelPart *mpCurrentParts; - u32 mNumCurrentParts; + uint32 mNumCurrentParts; // Static static bool smModelsLoaded; @@ -134,7 +134,7 @@ public: void DecrementSize(); void UpdateForCamera(const CCamera& rkCamera); bool CheckSelectedAxes(const CRay& rkRay); - u32 NumSelectedAxes(); + uint32 NumSelectedAxes(); void ResetSelectedAxes(); void StartTransform(); bool TransformFromInput(const CRay& rkRay, CCamera& rkCamera); diff --git a/src/Editor/CLineRenderable.h b/src/Editor/CLineRenderable.h index 2bcb9961..2e72da13 100644 --- a/src/Editor/CLineRenderable.h +++ b/src/Editor/CLineRenderable.h @@ -2,7 +2,7 @@ #define CLINERENDERABLE #include -#include +#include #include #include #include diff --git a/src/Editor/CNodeCopyMimeData.h b/src/Editor/CNodeCopyMimeData.h index 4b523877..a0004ffb 100644 --- a/src/Editor/CNodeCopyMimeData.h +++ b/src/Editor/CNodeCopyMimeData.h @@ -2,7 +2,7 @@ #define CNODECOPYMIMEDATA #include -#include +#include #include #include #include @@ -24,7 +24,7 @@ public: CQuaternion Rotation; CVector3f Scale; - u32 OriginalInstanceID; + uint32 OriginalInstanceID; std::vector InstanceData; }; @@ -51,7 +51,7 @@ public: CNodeSelection *pSelection = pEditor->Selection(); mCopiedNodes.resize(pSelection->Size()); - u32 NodeIndex = 0; + uint32 NodeIndex = 0; CVector3f FirstNodePos; bool SetFirstNodePos = false; @@ -75,7 +75,7 @@ public: Cooker.WriteInstance(Out, static_cast(*It)->Instance()); // Replace instance ID with 0xFFFFFFFF to force it to generate a new one. - Out.Seek(mGame <= ePrime ? 0x5 : 0x6, SEEK_SET); + Out.Seek(mGame <= EGame::Prime ? 0x5 : 0x6, SEEK_SET); Out.WriteLong(0xFFFFFFFF); if (!SetFirstNodePos) @@ -91,7 +91,7 @@ public: } } - int IndexOfInstanceID(u32 InstanceID) const + int IndexOfInstanceID(uint32 InstanceID) const { for (int iNode = 0; iNode < mCopiedNodes.size(); iNode++) { diff --git a/src/Editor/CNodeSelection.h b/src/Editor/CNodeSelection.h index 7734e4e5..c2bad006 100644 --- a/src/Editor/CNodeSelection.h +++ b/src/Editor/CNodeSelection.h @@ -107,12 +107,12 @@ public: return mCachedBounds; } - inline u32 Size() const { return mSelectedNodes.size(); } + inline uint32 Size() const { return mSelectedNodes.size(); } inline bool IsEmpty() const { return Size() == 0; } - inline CSceneNode* At(u32 Index) const { return mSelectedNodes[Index]; } + inline CSceneNode* At(uint32 Index) const { return mSelectedNodes[Index]; } inline CSceneNode* Front() const { return mSelectedNodes.front(); } inline CSceneNode* Back() const { return mSelectedNodes.back(); } - inline CSceneNode* operator[](u32 Index) const { return mSelectedNodes[Index]; } + inline CSceneNode* operator[](uint32 Index) const { return mSelectedNodes[Index]; } inline void UpdateBounds() { mBoundsDirty = true; } inline void SetAllowedNodeTypes(FNodeFlags Types) { mAllowedNodes = Types; } inline bool IsAllowedType(ENodeType Type) const { return (mAllowedNodes & Type) != 0; } diff --git a/src/Editor/CProgressBarNotifier.h b/src/Editor/CProgressBarNotifier.h index 78f3c6a6..538a58c5 100644 --- a/src/Editor/CProgressBarNotifier.h +++ b/src/Editor/CProgressBarNotifier.h @@ -1,7 +1,7 @@ #ifndef CPROGRESSBARNOTIFIER_H #define CPROGRESSBARNOTIFIER_H -#include +#include #include #include diff --git a/src/Editor/CProjectSettingsDialog.cpp b/src/Editor/CProjectSettingsDialog.cpp index 9ad4e746..761a9b05 100644 --- a/src/Editor/CProjectSettingsDialog.cpp +++ b/src/Editor/CProjectSettingsDialog.cpp @@ -5,7 +5,7 @@ #include "CProgressDialog.h" #include "UICommon.h" #include "Editor/ResourceBrowser/CResourceBrowser.h" -#include +#include #include #include @@ -101,7 +101,7 @@ void CProjectSettingsDialog::SetupPackagesList() mpUI->PackagesList->clear(); if (!mpProject) return; - for (u32 iPkg = 0; iPkg < mpProject->NumPackages(); iPkg++) + for (uint32 iPkg = 0; iPkg < mpProject->NumPackages(); iPkg++) { CPackage *pPackage = mpProject->PackageByIndex(iPkg); ASSERT(pPackage != nullptr); @@ -114,7 +114,7 @@ void CProjectSettingsDialog::SetupPackagesList() void CProjectSettingsDialog::CookPackage() { - u32 PackageIdx = mpUI->PackagesList->currentRow(); + uint32 PackageIdx = mpUI->PackagesList->currentRow(); if (PackageIdx != -1) { diff --git a/src/Editor/CPropertyNameValidator.cpp b/src/Editor/CPropertyNameValidator.cpp index 28a60f1e..31018f6f 100644 --- a/src/Editor/CPropertyNameValidator.cpp +++ b/src/Editor/CPropertyNameValidator.cpp @@ -30,7 +30,7 @@ QValidator::State CPropertyNameValidator::validate(QString& rInput, int&) const CCRC32 Hash; Hash.Hash( rInput.toStdString().c_str() ); Hash.Hash( *TypeName ); - u32 PropertyID = Hash.Digest(); + uint32 PropertyID = Hash.Digest(); if (PropertyID != mpProperty->ID()) { diff --git a/src/Editor/CSceneViewport.cpp b/src/Editor/CSceneViewport.cpp index 136b7b85..906db6ce 100644 --- a/src/Editor/CSceneViewport.cpp +++ b/src/Editor/CSceneViewport.cpp @@ -236,7 +236,7 @@ QMouseEvent CSceneViewport::CreateMouseEvent() return QMouseEvent(QEvent::MouseMove, mapFromGlobal(QCursor::pos()), Qt::NoButton, qApp->mouseButtons(), qApp->keyboardModifiers()); } -void CSceneViewport::FindConnectedObjects(u32 InstanceID, bool SearchOutgoing, bool SearchIncoming, QList& rIDList) +void CSceneViewport::FindConnectedObjects(uint32 InstanceID, bool SearchOutgoing, bool SearchIncoming, QList& rIDList) { CScriptNode *pScript = mpScene->NodeForInstanceID(InstanceID); if (!pScript) return; @@ -246,7 +246,7 @@ void CSceneViewport::FindConnectedObjects(u32 InstanceID, bool SearchOutgoing, b if (SearchOutgoing) { - for (u32 iLink = 0; iLink < pInst->NumLinks(eOutgoing); iLink++) + for (uint32 iLink = 0; iLink < pInst->NumLinks(eOutgoing); iLink++) { CLink *pLink = pInst->Link(eOutgoing, iLink); @@ -257,7 +257,7 @@ void CSceneViewport::FindConnectedObjects(u32 InstanceID, bool SearchOutgoing, b if (SearchIncoming) { - for (u32 iLink = 0; iLink < pInst->NumLinks(eIncoming); iLink++) + for (uint32 iLink = 0; iLink < pInst->NumLinks(eIncoming); iLink++) { CLink *pLink = pInst->Link(eIncoming, iLink); @@ -430,13 +430,13 @@ void CSceneViewport::OnToggleSelect() void CSceneViewport::OnSelectConnected() { - QList InstanceIDs; + QList InstanceIDs; bool SearchOutgoing = (sender() == mpSelectConnectedOutgoingAction || sender() == mpSelectConnectedAllAction); bool SearchIncoming = (sender() == mpSelectConnectedIncomingAction || sender() == mpSelectConnectedAllAction); FindConnectedObjects(static_cast(mpMenuNode)->Instance()->InstanceID(), SearchOutgoing, SearchIncoming, InstanceIDs); QList Nodes; - foreach (u32 ID, InstanceIDs) + foreach (uint32 ID, InstanceIDs) Nodes << mpScene->NodeForInstanceID(ID); bool ShouldClear = ((qApp->keyboardModifiers() & Qt::ControlModifier) == 0); diff --git a/src/Editor/CSceneViewport.h b/src/Editor/CSceneViewport.h index 7851e05f..6e1a77c2 100644 --- a/src/Editor/CSceneViewport.h +++ b/src/Editor/CSceneViewport.h @@ -72,7 +72,7 @@ public: protected: void CreateContextMenu(); QMouseEvent CreateMouseEvent(); - void FindConnectedObjects(u32 InstanceID, bool SearchOutgoing, bool SearchIncoming, QList& rIDList); + void FindConnectedObjects(uint32 InstanceID, bool SearchOutgoing, bool SearchIncoming, QList& rIDList); signals: void InputProcessed(const SRayIntersection& rkIntersect, QMouseEvent *pEvent); diff --git a/src/Editor/CSelectionIterator.h b/src/Editor/CSelectionIterator.h index b9e1bb13..9f92d88a 100644 --- a/src/Editor/CSelectionIterator.h +++ b/src/Editor/CSelectionIterator.h @@ -6,7 +6,7 @@ class CSelectionIterator { CNodeSelection *mpSelection; - u32 mCurrentIndex; + uint32 mCurrentIndex; public: CSelectionIterator(CNodeSelection *pSelection) diff --git a/src/Editor/CharacterEditor/CCharacterEditor.cpp b/src/Editor/CharacterEditor/CCharacterEditor.cpp index 9aca335c..84637c05 100644 --- a/src/Editor/CharacterEditor/CCharacterEditor.cpp +++ b/src/Editor/CharacterEditor/CCharacterEditor.cpp @@ -1,8 +1,8 @@ #include "CCharacterEditor.h" #include "ui_CCharacterEditor.h" #include "Editor/UICommon.h" -#include -#include +#include +#include #include #include #include @@ -43,7 +43,7 @@ CCharacterEditor::CCharacterEditor(CAnimSet *pSet, QWidget *parent) mpAnimComboBox->setMinimumWidth(175); ui->ToolBar->addWidget(mpAnimComboBox); - connect(ui->Viewport, SIGNAL(HoverBoneChanged(u32)), this, SLOT(OnViewportHoverBoneChanged(u32))); + connect(ui->Viewport, SIGNAL(HoverBoneChanged(uint32)), this, SLOT(OnViewportHoverBoneChanged(uint32))); connect(ui->Viewport, SIGNAL(ViewportClick(QMouseEvent*)), this, SLOT(OnViewportClick())); connect(ui->ActionShowGrid, SIGNAL(toggled(bool)), this, SLOT(ToggleGrid(bool))); connect(ui->ActionShowMesh, SIGNAL(toggled(bool)), this, SLOT(ToggleMeshVisible(bool))); @@ -185,7 +185,7 @@ void CCharacterEditor::SetActiveAnimSet(CAnimSet *pSet) mpCharComboBox->blockSignals(true); mpCharComboBox->clear(); - for (u32 iChar = 0; iChar < mpSet->NumCharacters(); iChar++) + for (uint32 iChar = 0; iChar < mpSet->NumCharacters(); iChar++) mpCharComboBox->addItem( TO_QSTRING(mpSet->Character(iChar)->Name) ); SetActiveCharacterIndex(0); @@ -195,7 +195,7 @@ void CCharacterEditor::SetActiveAnimSet(CAnimSet *pSet) mpAnimComboBox->blockSignals(true); mpAnimComboBox->clear(); - for (u32 iAnim = 0; iAnim < mpSet->NumAnimations(); iAnim++) + for (uint32 iAnim = 0; iAnim < mpSet->NumAnimations(); iAnim++) mpAnimComboBox->addItem( TO_QSTRING(mpSet->Animation(iAnim)->Name) ); SetActiveAnimation(0); @@ -276,7 +276,7 @@ void CCharacterEditor::RefreshViewport() ui->Viewport->Render(); } -void CCharacterEditor::OnViewportHoverBoneChanged(u32 BoneID) +void CCharacterEditor::OnViewportHoverBoneChanged(uint32 BoneID) { if (BoneID == 0xFFFFFFFF) ui->StatusBar->clearMessage(); @@ -286,7 +286,7 @@ void CCharacterEditor::OnViewportHoverBoneChanged(u32 BoneID) void CCharacterEditor::OnViewportClick() { - u32 HoverBoneID = ui->Viewport->HoverBoneID(); + uint32 HoverBoneID = ui->Viewport->HoverBoneID(); CSkeleton *pSkel = (mpSet ? mpSet->Character(mCurrentChar)->pSkeleton : nullptr); CBone *pBone = (pSkel ? pSkel->BoneByID(HoverBoneID) : nullptr); @@ -313,13 +313,13 @@ void CCharacterEditor::OnSkeletonTreeSelectionChanged(const QModelIndex& rkIndex void CCharacterEditor::SetActiveCharacterIndex(int CharIndex) { mCurrentChar = CharIndex; - mpCharNode->SetActiveChar((u32) CharIndex); + mpCharNode->SetActiveChar((uint32) CharIndex); } void CCharacterEditor::SetActiveAnimation(int AnimIndex) { mCurrentAnim = AnimIndex; - mpCharNode->SetActiveAnim((u32) AnimIndex); + mpCharNode->SetActiveAnim((uint32) AnimIndex); ui->AnimSlider->blockSignals(true); ui->AnimSlider->setMaximum((int) (CurrentAnimation() ? CurrentAnimation()->Duration() * 1000 : 0)); @@ -339,7 +339,7 @@ void CCharacterEditor::PrevAnim() void CCharacterEditor::NextAnim() { - u32 MaxAnim = (mpSet ? mpSet->NumAnimations() - 1 : 0); + uint32 MaxAnim = (mpSet ? mpSet->NumAnimations() - 1 : 0); if (mCurrentAnim < MaxAnim) SetActiveAnimation(mCurrentAnim + 1); } @@ -363,12 +363,12 @@ void CCharacterEditor::SetAnimTime(float Time) mpCharNode->SetAnimTime(Time); CAnimation *pAnim = CurrentAnimation(); - u32 NumKeys = 1, CurKey = 0; + uint32 NumKeys = 1, CurKey = 0; if (pAnim) { NumKeys = pAnim->NumKeys(); - CurKey = Math::Min((u32) (Time / pAnim->TickInterval()) + 1, NumKeys - 1); + CurKey = Math::Min((uint32) (Time / pAnim->TickInterval()) + 1, NumKeys - 1); } ui->FrameLabel->setText(QString("Frame %1 / %2 (%3s/%4s)").arg(CurKey).arg(NumKeys - 1).arg(mAnimTime, 0, 'f', 3).arg(pAnim ? pAnim->Duration() : 0.f, 0, 'f', 3)); diff --git a/src/Editor/CharacterEditor/CCharacterEditor.h b/src/Editor/CharacterEditor/CCharacterEditor.h index ef67adaa..05045979 100644 --- a/src/Editor/CharacterEditor/CCharacterEditor.h +++ b/src/Editor/CharacterEditor/CCharacterEditor.h @@ -29,8 +29,8 @@ class CCharacterEditor : public IEditor QComboBox *mpAnimComboBox; TResPtr mpSet; - u32 mCurrentChar; - u32 mCurrentAnim; + uint32 mCurrentChar; + uint32 mCurrentAnim; bool mBindPose; // Playback Controls @@ -62,7 +62,7 @@ public slots: void ToggleBindPose(bool Enable); void ToggleOrbit(bool Enable); void RefreshViewport(); - void OnViewportHoverBoneChanged(u32 BoneID); + void OnViewportHoverBoneChanged(uint32 BoneID); void OnViewportClick(); void OnSkeletonTreeSelectionChanged(const QModelIndex& rkIndex); void SetActiveCharacterIndex(int CharIndex); diff --git a/src/Editor/CharacterEditor/CCharacterEditorViewport.cpp b/src/Editor/CharacterEditor/CCharacterEditorViewport.cpp index e80ed178..524dc2c6 100644 --- a/src/Editor/CharacterEditor/CCharacterEditorViewport.cpp +++ b/src/Editor/CharacterEditor/CCharacterEditorViewport.cpp @@ -28,7 +28,7 @@ void CCharacterEditorViewport::SetNode(CCharacterNode *pNode) void CCharacterEditorViewport::CheckUserInput() { - u32 HoverBoneID = -1; + uint32 HoverBoneID = -1; if (underMouse() && !IsMouseInputActive()) { diff --git a/src/Editor/CharacterEditor/CCharacterEditorViewport.h b/src/Editor/CharacterEditor/CCharacterEditorViewport.h index 241c3c0d..d0140573 100644 --- a/src/Editor/CharacterEditor/CCharacterEditorViewport.h +++ b/src/Editor/CharacterEditor/CCharacterEditorViewport.h @@ -12,7 +12,7 @@ class CCharacterEditorViewport : public CBasicViewport CCharacterNode *mpCharNode; CGridRenderable mGrid; CRenderer *mpRenderer; - u32 mHoverBone; + uint32 mHoverBone; bool mGridEnabled; public: @@ -24,11 +24,11 @@ public: void OnResize(); void OnMouseClick(QMouseEvent *pEvent); - inline u32 HoverBoneID() const { return mHoverBone; } + inline uint32 HoverBoneID() const { return mHoverBone; } inline void SetGridEnabled(bool Enable) { mGridEnabled = Enable; } signals: - void HoverBoneChanged(u32 BoneID); + void HoverBoneChanged(uint32 BoneID); void ViewportClick(QMouseEvent *pEvent); }; diff --git a/src/Editor/CharacterEditor/CSkeletonHierarchyModel.cpp b/src/Editor/CharacterEditor/CSkeletonHierarchyModel.cpp index 638a1df2..0067563e 100644 --- a/src/Editor/CharacterEditor/CSkeletonHierarchyModel.cpp +++ b/src/Editor/CharacterEditor/CSkeletonHierarchyModel.cpp @@ -40,7 +40,7 @@ QModelIndex CSkeletonHierarchyModel::parent(const QModelIndex& rkChild) const { CBone *pGrandparent = pParent->Parent(); - for (u32 iChild = 0; iChild < pGrandparent->NumChildren(); iChild++) + for (uint32 iChild = 0; iChild < pGrandparent->NumChildren(); iChild++) { if (pGrandparent->ChildByIndex(iChild) == pParent) return createIndex(iChild, 0, pParent); @@ -88,7 +88,7 @@ QModelIndex CSkeletonHierarchyModel::IndexForBone(CBone *pBone) const QModelIndex ParentIndex = IndexForBone(pParent); - for (u32 iChild = 0; iChild < pParent->NumChildren(); iChild++) + for (uint32 iChild = 0; iChild < pParent->NumChildren(); iChild++) { if (pParent->ChildByIndex(iChild) == pBone) return index(iChild, 0, ParentIndex); diff --git a/src/Editor/Editor.pro b/src/Editor/Editor.pro index c86ba1af..0aa28452 100644 --- a/src/Editor/Editor.pro +++ b/src/Editor/Editor.pro @@ -33,18 +33,16 @@ CONFIG(debug, debug|release) { TARGET = PrimeWorldEditor-debug # Debug Libs - LIBS += -L$$BUILD_DIR/Common/ -lCommond \ - -L$$BUILD_DIR/Math/ -lMathd \ - -L$$BUILD_DIR/Core/ -lCored \ + LIBS += -L$$BUILD_DIR/Core/ -lCored \ -L$$EXTERNALS_DIR/assimp/lib/Debug -lassimp-vc140-mt \ + -L$$EXTERNALS_DIR/LibCommon/Build -lLibCommond \ -L$$EXTERNALS_DIR/nod/lib/Debug -lnod \ -L$$EXTERNALS_DIR/nod/logvisor/Debug -llogvisor \ -L$$EXTERNALS_DIR/zlib/lib/ -lzlibd # Debug Target Dependencies win32 { - PRE_TARGETDEPS += $$BUILD_DIR/Common/Commond.lib \ - $$BUILD_DIR/Math/Mathd.lib \ + PRE_TARGETDEPS += $$EXTERNALS_DIR/LibCommon/Build/LibCommond.lib \ $$BUILD_DIR/Core/Cored.lib } } @@ -57,18 +55,16 @@ CONFIG(release, debug|release) { TARGET = PrimeWorldEditor # Release Libs - LIBS += -L$$BUILD_DIR/Common/ -lCommon \ - -L$$BUILD_DIR/Math/ -lMath \ - -L$$BUILD_DIR/Core/ -lCore \ + LIBS += -L$$BUILD_DIR/Core/ -lCore \ -L$$EXTERNALS_DIR/assimp/lib/Release -lassimp-vc140-mt \ + -L$$EXTERNALS_DIR/LibCommon/Build -lLibCommon \ -L$$EXTERNALS_DIR/nod/lib/Release -lnod \ -L$$EXTERNALS_DIR/nod/logvisor/Release -llogvisor \ -L$$EXTERNALS_DIR/zlib/lib/ -lzlib # Release Target Dependencies win32 { - PRE_TARGETDEPS += $$BUILD_DIR/Common/Common.lib \ - $$BUILD_DIR/Math/Math.lib \ + PRE_TARGETDEPS += $$EXTERNALS_DIR/LibCommon/Build/LibCommon.lib \ $$BUILD_DIR/Core/Core.lib } } @@ -82,6 +78,7 @@ INCLUDEPATH += $$PWE_MAIN_INCLUDE \ $$EXTERNALS_DIR/assimp/include \ $$EXTERNALS_DIR/CodeGen/include \ $$EXTERNALS_DIR/glew-2.1.0/include \ + $$EXTERNALS_DIR/LibCommon/Source \ $$EXTERNALS_DIR/lzo-2.10/include \ $$EXTERNALS_DIR/nod/include \ $$EXTERNALS_DIR/nod/logvisor/include \ diff --git a/src/Editor/INodeEditor.h b/src/Editor/INodeEditor.h index f95369d3..cd34c09a 100644 --- a/src/Editor/INodeEditor.h +++ b/src/Editor/INodeEditor.h @@ -4,7 +4,7 @@ #include "IEditor.h" #include "CGizmo.h" #include "CNodeSelection.h" -#include +#include #include #include diff --git a/src/Editor/ModelEditor/CModelEditorWindow.cpp b/src/Editor/ModelEditor/CModelEditorWindow.cpp index 53416b62..d1feab0a 100644 --- a/src/Editor/ModelEditor/CModelEditorWindow.cpp +++ b/src/Editor/ModelEditor/CModelEditorWindow.cpp @@ -163,10 +163,10 @@ void CModelEditorWindow::SetActiveModel(CModel *pModel) mpCurrentModel = pModel; ui->Viewport->Camera().SetOrbit(pModel->AABox()); - u32 NumVertices = (pModel ? pModel->GetVertexCount() : 0); - u32 NumTriangles = (pModel ? pModel->GetTriangleCount() : 0); - u32 NumMats = (pModel ? pModel->GetMatCount() : 0); - u32 NumMatSets = (pModel ? pModel->GetMatSetCount() : 0); + uint32 NumVertices = (pModel ? pModel->GetVertexCount() : 0); + uint32 NumTriangles = (pModel ? pModel->GetTriangleCount() : 0); + uint32 NumMats = (pModel ? pModel->GetMatCount() : 0); + uint32 NumMatSets = (pModel ? pModel->GetMatSetCount() : 0); ui->MeshInfoLabel->setText(QString::number(NumVertices) + " vertices, " + QString::number(NumTriangles) + " triangles"); ui->MatInfoLabel->setText(QString::number(NumMats) + " materials, " + QString::number(NumMatSets) + " set" + (NumMatSets == 1 ? "" : "s")); @@ -174,7 +174,7 @@ void CModelEditorWindow::SetActiveModel(CModel *pModel) ui->SetSelectionComboBox->blockSignals(true); ui->SetSelectionComboBox->clear(); - for (u32 iSet = 0; iSet < NumMatSets; iSet++) + for (uint32 iSet = 0; iSet < NumMatSets; iSet++) ui->SetSelectionComboBox->addItem("Set #" + QString::number(iSet + 1)); ui->SetSelectionComboBox->setCurrentIndex(0); @@ -184,7 +184,7 @@ void CModelEditorWindow::SetActiveModel(CModel *pModel) ui->MatSelectionComboBox->blockSignals(true); ui->MatSelectionComboBox->clear(); - for (u32 iMat = 0; iMat < NumMats; iMat++) + for (uint32 iMat = 0; iMat < NumMats; iMat++) { TString MatName = pModel->GetMaterialByIndex(0, iMat)->Name(); ui->MatSelectionComboBox->addItem(TO_QSTRING(MatName)); @@ -206,7 +206,7 @@ void CModelEditorWindow::SetActiveMaterial(int MatIndex) { if (!mpCurrentModel) return; - u32 SetIndex = ui->SetSelectionComboBox->currentIndex(); + uint32 SetIndex = ui->SetSelectionComboBox->currentIndex(); mpCurrentMat = mpCurrentModel->GetMaterialByIndex(SetIndex, MatIndex); ui->Viewport->SetActiveMaterial(mpCurrentMat); if (!mpCurrentMat) return; @@ -224,8 +224,8 @@ void CModelEditorWindow::SetActiveMaterial(int MatIndex) ui->EnableLightmapCheck->setChecked( Settings & CMaterial::eLightmap ); ui->EnableDynamicLightingCheck->setChecked( mpCurrentMat->IsLightingEnabled() ); - u32 SrcFac = (u32) mpCurrentMat->BlendSrcFac(); - u32 DstFac = (u32) mpCurrentMat->BlendDstFac(); + uint32 SrcFac = (uint32) mpCurrentMat->BlendSrcFac(); + uint32 DstFac = (uint32) mpCurrentMat->BlendDstFac(); if (SrcFac >= 0x300) SrcFac -= 0x2FE; if (DstFac >= 0x300) DstFac -= 0x2FE; ui->SourceBlendComboBox->setCurrentIndex(SrcFac); @@ -236,7 +236,7 @@ void CModelEditorWindow::SetActiveMaterial(int MatIndex) else ui->IndTextureResSelector->Clear(); - for (u32 iKonst = 0; iKonst < 4; iKonst++) + for (uint32 iKonst = 0; iKonst < 4; iKonst++) { QColor Color; CColor KColor = mpCurrentMat->Konst(iKonst); @@ -251,11 +251,11 @@ void CModelEditorWindow::SetActiveMaterial(int MatIndex) else if (iKonst == 3) ui->KonstColorPickerD->SetColor(Color); } - u32 PassCount = mpCurrentMat->PassCount(); + uint32 PassCount = mpCurrentMat->PassCount(); ui->PassTable->clear(); ui->PassTable->setRowCount(PassCount); - for (u32 iPass = 0; iPass < PassCount; iPass++) + for (uint32 iPass = 0; iPass < PassCount; iPass++) { CMaterialPass *pPass = mpCurrentMat->Pass(iPass); @@ -303,10 +303,10 @@ void CModelEditorWindow::SetActivePass(int PassIndex) mIgnoreSignals = true; mpCurrentPass = mpCurrentMat->Pass(PassIndex); - u32 KColor = mpCurrentPass->KColorSel(); - u32 KAlpha = mpCurrentPass->KAlphaSel(); - u32 Ras = mpCurrentPass->RasSel(); - u32 TexCoordSrc = mpCurrentPass->TexCoordSource(); + uint32 KColor = mpCurrentPass->KColorSel(); + uint32 KAlpha = mpCurrentPass->KAlphaSel(); + uint32 Ras = mpCurrentPass->RasSel(); + uint32 TexCoordSrc = mpCurrentPass->TexCoordSource(); if (KColor >= 0xC) KColor -= 4; if (KAlpha >= 0x10) KAlpha -= 8; if (Ras == 0xFF) Ras = 7; @@ -330,7 +330,7 @@ void CModelEditorWindow::SetActivePass(int PassIndex) ui->TevAlpha4ComboBox->setCurrentIndex(mpCurrentPass->AlphaInput(3)); ui->TevAlphaOutputComboBox->setCurrentIndex(mpCurrentPass->AlphaOutput()); - s32 AnimMode = mpCurrentPass->AnimMode(); + int32 AnimMode = mpCurrentPass->AnimMode(); ui->AnimTypeComboBox->setCurrentIndex(AnimMode + 1); UpdateAnimParamUI(AnimMode); diff --git a/src/Editor/PropertyEdit/CPropertyDelegate.cpp b/src/Editor/PropertyEdit/CPropertyDelegate.cpp index a284e398..25b7f635 100644 --- a/src/Editor/PropertyEdit/CPropertyDelegate.cpp +++ b/src/Editor/PropertyEdit/CPropertyDelegate.cpp @@ -130,7 +130,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie QComboBox *pComboBox = new QComboBox(pParent); CEnumProperty* pEnum = TPropCast(pProp); - for (u32 ValueIdx = 0; ValueIdx < pEnum->NumPossibleValues(); ValueIdx++) + for (uint32 ValueIdx = 0; ValueIdx < pEnum->NumPossibleValues(); ValueIdx++) pComboBox->addItem(TO_QSTRING(pEnum->ValueName(ValueIdx))); CONNECT_RELAY(pComboBox, rkIndex, currentIndexChanged(int)) @@ -344,7 +344,7 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd { QCheckBox *pCheckBox = static_cast(pEditor); CFlagsProperty* pFlags = TPropCast(pProp); - u32 Mask = pFlags->FlagMask(rkIndex.row()); + uint32 Mask = pFlags->FlagMask(rkIndex.row()); bool Set = (pFlags->Value(pData) & Mask) != 0; pCheckBox->setChecked(Set); } @@ -386,7 +386,7 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo { QCheckBox* pCheckBox = static_cast(pEditor); CFlagsProperty* pFlags = static_cast(pProp); - u32 Mask = pFlags->FlagMask(rkIndex.row()); + uint32 Mask = pFlags->FlagMask(rkIndex.row()); int Flags = pFlags->Value(pData); if (pCheckBox->isChecked()) Flags |= Mask; @@ -580,7 +580,7 @@ QWidget* CPropertyDelegate::CreateCharacterEditor(QWidget *pParent, const QModel if (pAnimSet) { - for (u32 CharIdx = 0; CharIdx < pAnimSet->NumCharacters(); CharIdx++) + for (uint32 CharIdx = 0; CharIdx < pAnimSet->NumCharacters(); CharIdx++) pComboBox->addItem(TO_QSTRING(pAnimSet->Character(CharIdx)->Name)); } @@ -617,7 +617,7 @@ void CPropertyDelegate::SetCharacterEditorData(QWidget *pEditor, const QModelInd else if (Type == EPropertyType::Int && !pEditor->hasFocus()) { int UnkIndex = (Params.Version() <= EGame::Echoes ? rkIndex.row() - 2 : rkIndex.row() - 1); - u32 Value = Params.Unknown(UnkIndex); + uint32 Value = Params.Unknown(UnkIndex); static_cast(pEditor)->setValue(Value); } } diff --git a/src/Editor/PropertyEdit/CPropertyModel.cpp b/src/Editor/PropertyEdit/CPropertyModel.cpp index 90ff7d0d..2128b216 100644 --- a/src/Editor/PropertyEdit/CPropertyModel.cpp +++ b/src/Editor/PropertyEdit/CPropertyModel.cpp @@ -41,10 +41,10 @@ int CPropertyModel::RecursiveBuildArrays(IProperty* pProperty, int ParentID) if (pProperty->Type() == EPropertyType::Array) { CArrayProperty* pArray = TPropCast(pProperty); - u32 ArrayCount = pArray->ArrayCount(mpPropertyData); + uint32 ArrayCount = pArray->ArrayCount(mpPropertyData); void* pOldData = mpPropertyData; - for (u32 ElementIdx = 0; ElementIdx < ArrayCount; ElementIdx++) + for (uint32 ElementIdx = 0; ElementIdx < ArrayCount; ElementIdx++) { mpPropertyData = pArray->ItemPointer(pOldData, ElementIdx); int NewChildID = RecursiveBuildArrays( pArray->ItemArchetype(), MyID ); @@ -55,7 +55,7 @@ int CPropertyModel::RecursiveBuildArrays(IProperty* pProperty, int ParentID) } else { - for (u32 ChildIdx = 0; ChildIdx < pProperty->NumChildren(); ChildIdx++) + for (uint32 ChildIdx = 0; ChildIdx < pProperty->NumChildren(); ChildIdx++) { int NewChildID = RecursiveBuildArrays( pProperty->ChildByIndex(ChildIdx), MyID ); mProperties[MyID].ChildIDs.push_back(NewChildID); @@ -336,7 +336,7 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const case EPropertyType::Sound: { CSoundProperty* pSound = TPropCast(pProp); - u32 SoundID = pSound->Value(pData); + uint32 SoundID = pSound->Value(pData); if (SoundID == -1) return "[None]"; SSoundInfo SoundInfo = mpProject->AudioManager()->GetSoundInfo(SoundID); @@ -368,8 +368,8 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const if (Role == Qt::ToolTipRole) { CEnumProperty *pEnum = TPropCast(pProp); - u32 ValueID = pEnum->Value(pData); - u32 ValueIndex = pEnum->ValueIndex(ValueID); + uint32 ValueID = pEnum->Value(pData); + uint32 ValueIndex = pEnum->ValueIndex(ValueID); return TO_QSTRING( pEnum->ValueName(ValueIndex) ); } else return ""; @@ -377,7 +377,7 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const // Display the element count for arrays case EPropertyType::Array: { - u32 Count = TPropCast(pProp)->Value(pData); + uint32 Count = TPropCast(pProp)->Value(pData); return QString("%1 element%2").arg(Count).arg(Count != 1 ? "s" : ""); } @@ -542,7 +542,7 @@ void CPropertyModel::NotifyPropertyModified(const QModelIndex& rkIndex) emit PropertyModified(rkIndex); } -void CPropertyModel::ArrayAboutToBeResized(const QModelIndex& rkIndex, u32 NewSize) +void CPropertyModel::ArrayAboutToBeResized(const QModelIndex& rkIndex, uint32 NewSize) { QModelIndex Index = rkIndex.sibling(rkIndex.row(), 0); IProperty* pProperty = PropertyForIndex(Index, false); @@ -550,7 +550,7 @@ void CPropertyModel::ArrayAboutToBeResized(const QModelIndex& rkIndex, u32 NewSi ASSERT(pArray); void* pArrayData = DataPointerForIndex(Index); - u32 OldSize = pArray->ArrayCount(pArrayData); + uint32 OldSize = pArray->ArrayCount(pArrayData); if (NewSize != OldSize) { @@ -561,7 +561,7 @@ void CPropertyModel::ArrayAboutToBeResized(const QModelIndex& rkIndex, u32 NewSi } } -void CPropertyModel::ArrayResized(const QModelIndex& rkIndex, u32 OldSize) +void CPropertyModel::ArrayResized(const QModelIndex& rkIndex, uint32 OldSize) { QModelIndex Index = rkIndex.sibling(rkIndex.row(), 0); IProperty* pProperty = PropertyForIndex(Index, false); @@ -569,7 +569,7 @@ void CPropertyModel::ArrayResized(const QModelIndex& rkIndex, u32 OldSize) ASSERT(pArray); void* pArrayData = DataPointerForIndex(Index); - u32 NewSize = pArray->ArrayCount(pArrayData); + uint32 NewSize = pArray->ArrayCount(pArrayData); if (NewSize != OldSize) { @@ -580,7 +580,7 @@ void CPropertyModel::ArrayResized(const QModelIndex& rkIndex, u32 OldSize) // add new elements void* pOldData = mpPropertyData; - for (u32 ElementIdx = OldSize; ElementIdx < NewSize; ElementIdx++) + for (uint32 ElementIdx = OldSize; ElementIdx < NewSize; ElementIdx++) { mpPropertyData = pArray->ItemPointer(pArrayData, ElementIdx); int NewChildID = RecursiveBuildArrays( pArray->ItemArchetype(), ID ); @@ -593,7 +593,7 @@ void CPropertyModel::ArrayResized(const QModelIndex& rkIndex, u32 OldSize) else { // remove old elements - for (u32 ElementIdx = NewSize; ElementIdx < OldSize; ElementIdx++) + for (uint32 ElementIdx = NewSize; ElementIdx < OldSize; ElementIdx++) { int ChildID = mProperties[ID].ChildIDs[ElementIdx]; ClearSlot(ChildID); diff --git a/src/Editor/PropertyEdit/CPropertyModel.h b/src/Editor/PropertyEdit/CPropertyModel.h index 64dbb059..349cabde 100644 --- a/src/Editor/PropertyEdit/CPropertyModel.h +++ b/src/Editor/PropertyEdit/CPropertyModel.h @@ -47,9 +47,9 @@ public: QModelIndex parent(const QModelIndex& rkChild) const; Qt::ItemFlags flags(const QModelIndex& rkIndex) const; - void ArrayAboutToBeResized(const QModelIndex& rkIndex, u32 NewSize); - void ArrayResized(const QModelIndex& rkIndex, u32 OldSize); - void ResizeArray(const QModelIndex& rkIndex, u32 NewSize); + void ArrayAboutToBeResized(const QModelIndex& rkIndex, uint32 NewSize); + void ArrayResized(const QModelIndex& rkIndex, uint32 OldSize); + void ResizeArray(const QModelIndex& rkIndex, uint32 NewSize); void ClearSlot(int ID); EPropertyType GetEffectiveFieldType(IProperty* pProperty) const; diff --git a/src/Editor/PropertyEdit/CPropertyView.cpp b/src/Editor/PropertyEdit/CPropertyView.cpp index 0561a8e0..79f534ce 100644 --- a/src/Editor/PropertyEdit/CPropertyView.cpp +++ b/src/Editor/PropertyEdit/CPropertyView.cpp @@ -163,13 +163,14 @@ void CPropertyView::UpdateEditorProperties(const QModelIndex& rkParent) void CPropertyView::SetPersistentEditors(const QModelIndex& rkParent) { - u32 NumChildren = mpModel->rowCount(rkParent); + uint32 NumChildren = mpModel->rowCount(rkParent); - for (u32 iChild = 0; iChild < NumChildren; iChild++) + for (uint32 iChild = 0; iChild < NumChildren; iChild++) { QModelIndex ChildIndex = mpModel->index(iChild, 1, rkParent); IProperty *pProp = mpModel->PropertyForIndex(ChildIndex, false); EPropertyType Type = (pProp ? pProp->Type() : EPropertyType::Invalid); + bool IsAnimSet = false; // Handle persistent editors under character properties if (!pProp && ChildIndex.internalId() & 0x80000000) @@ -180,6 +181,7 @@ void CPropertyView::SetPersistentEditors(const QModelIndex& rkParent) { EGame Game = mpObject->Area()->Game(); Type = mpDelegate->DetermineCharacterPropType(Game, ChildIndex); + IsAnimSet = true; } if (pProp->Type() == EPropertyType::Flags) @@ -197,7 +199,7 @@ void CPropertyView::SetPersistentEditors(const QModelIndex& rkParent) case EPropertyType::Enum: case EPropertyType::Choice: - if (TPropCast(pProp)->NumPossibleValues() > 0) + if (IsAnimSet || TPropCast(pProp)->NumPossibleValues() > 0) openPersistentEditor(ChildIndex); break; @@ -213,9 +215,9 @@ void CPropertyView::SetPersistentEditors(const QModelIndex& rkParent) void CPropertyView::ClosePersistentEditors(const QModelIndex& rkIndex) { - u32 NumChildren = mpModel->rowCount(rkIndex); + uint32 NumChildren = mpModel->rowCount(rkIndex); - for (u32 iChild = 0; iChild < NumChildren; iChild++) + for (uint32 iChild = 0; iChild < NumChildren; iChild++) { QModelIndex ChildIndex = rkIndex.child(iChild, 1); closePersistentEditor(ChildIndex); diff --git a/src/Editor/ResourceBrowser/CResourceBrowser.cpp b/src/Editor/ResourceBrowser/CResourceBrowser.cpp index 57b85a97..40c70b5c 100644 --- a/src/Editor/ResourceBrowser/CResourceBrowser.cpp +++ b/src/Editor/ResourceBrowser/CResourceBrowser.cpp @@ -504,7 +504,7 @@ bool CResourceBrowser::CreateDirectory() { TString DirNameBase = "New Folder"; TString DirName = DirNameBase; - u32 AppendNum = 0; + uint32 AppendNum = 0; while (mpSelectedDir->FindChildDirectory(DirName, false) != nullptr) { @@ -631,6 +631,7 @@ void CResourceBrowser::FindAssetByID() { EGame Game = mpStore->Game(); EIDLength IDLength = CAssetID::GameIDLength(Game); + bool WasValid = false; if (StringAssetID.IsHexString(false, IDLength * 2)) { @@ -638,20 +639,27 @@ void CResourceBrowser::FindAssetByID() StringAssetID = StringAssetID.ChopFront(2); // Find the resource entry - CAssetID ID = (IDLength == e32Bit ? StringAssetID.ToInt32(16) : StringAssetID.ToInt64(16)); - CResourceEntry *pEntry = mpStore->FindEntry(ID); + if ( (IDLength == e32Bit && StringAssetID.Length() == 8) || + (IDLength == e64Bit && StringAssetID.Length() == 16) ) + { + CAssetID ID = (IDLength == e32Bit ? StringAssetID.ToInt32(16) : StringAssetID.ToInt64(16)); + CResourceEntry *pEntry = mpStore->FindEntry(ID); + WasValid = true; - if (pEntry) - SelectResource(pEntry, true); + if (pEntry) + SelectResource(pEntry, true); - // User entered unrecognized ID - else - UICommon::ErrorMsg(this, QString("Couldn't find any asset with ID %1").arg(QStringAssetID)); + // User entered valid but unrecognized ID + else + UICommon::ErrorMsg(this, QString("Couldn't find any asset with ID %1").arg(QStringAssetID)); + } } // User entered invalid string - else + if (!WasValid) + { UICommon::ErrorMsg(this, "The entered string is not a valid asset ID!"); + } } // User entered nothing, don't do anything diff --git a/src/Editor/ResourceBrowser/CResourceDelegate.cpp b/src/Editor/ResourceBrowser/CResourceDelegate.cpp index eb6f693b..ab8b0102 100644 --- a/src/Editor/ResourceBrowser/CResourceDelegate.cpp +++ b/src/Editor/ResourceBrowser/CResourceDelegate.cpp @@ -160,7 +160,7 @@ QWidget* CResourceBrowserDelegate::createEditor(QWidget *pParent, const QStyleOp // Set the max length to 150. Limit should be 255 but FileUtil::MoveFile doesn't // seem to want to work with filenames that long. Not sure why. - u32 MaxLength = 150; + uint32 MaxLength = 150; pLineEdit->setMaxLength(MaxLength); return pLineEdit; diff --git a/src/Editor/ResourceBrowser/CResourceProxyModel.h b/src/Editor/ResourceBrowser/CResourceProxyModel.h index 7fe3be0f..2410a821 100644 --- a/src/Editor/ResourceBrowser/CResourceProxyModel.h +++ b/src/Editor/ResourceBrowser/CResourceProxyModel.h @@ -21,9 +21,9 @@ private: ESortMode mSortMode; QSet mTypeFilter; - u64 mCompareID; - u64 mCompareMask; - u32 mCompareBitLength; + uint64 mCompareID; + uint64 mCompareMask; + uint32 mCompareBitLength; public: explicit CResourceProxyModel(QObject *pParent = 0) @@ -97,17 +97,17 @@ public: if (mCompareBitLength > 0) { - u32 IDBitLength = pEntry->ID().Length() * 8; + uint32 IDBitLength = pEntry->ID().Length() * 8; if (mCompareBitLength <= IDBitLength) { - u64 ID = pEntry->ID().ToLongLong(); - u32 MaxShift = IDBitLength - mCompareBitLength; + uint64 ID = pEntry->ID().ToLongLong(); + uint32 MaxShift = IDBitLength - mCompareBitLength; - for (u32 Shift = 0; Shift <= MaxShift; Shift += 4) + for (uint32 Shift = 0; Shift <= MaxShift; Shift += 4) { - u64 ShiftCompare = mCompareID << Shift; - u64 Mask = mCompareMask << Shift; + uint64 ShiftCompare = mCompareID << Shift; + uint64 Mask = mCompareMask << Shift; if ((ID & Mask) == ShiftCompare) { @@ -173,7 +173,7 @@ public slots: if (IDString.Size() <= 16 && IDString.IsHexString()) { mCompareBitLength = IDString.Size() * 4; - mCompareMask = ((u64) 1 << mCompareBitLength) - 1; + mCompareMask = ((uint64) 1 << mCompareBitLength) - 1; mCompareID = IDString.ToInt64(16); if (mCompareMask == 0) diff --git a/src/Editor/ResourceBrowser/CResourceTableModel.cpp b/src/Editor/ResourceBrowser/CResourceTableModel.cpp index 768025c1..57e32b4b 100644 --- a/src/Editor/ResourceBrowser/CResourceTableModel.cpp +++ b/src/Editor/ResourceBrowser/CResourceTableModel.cpp @@ -217,10 +217,10 @@ void CResourceTableModel::FillEntryList(CVirtualDirectory *pDir, bool AssetListM if (!pDir->IsRoot()) mDirectories << pDir->Parent(); - for (u32 iDir = 0; iDir < pDir->NumSubdirectories(); iDir++) + for (uint32 iDir = 0; iDir < pDir->NumSubdirectories(); iDir++) mDirectories << pDir->SubdirectoryByIndex(iDir); - for (u32 iRes = 0; iRes < pDir->NumResources(); iRes++) + for (uint32 iRes = 0; iRes < pDir->NumResources(); iRes++) { CResourceEntry *pEntry = pDir->ResourceByIndex(iRes); @@ -258,7 +258,7 @@ void CResourceTableModel::DisplayEntryList(QList& rkEntries, co void CResourceTableModel::RecursiveAddDirectoryContents(CVirtualDirectory *pDir) { - for (u32 iRes = 0; iRes < pDir->NumResources(); iRes++) + for (uint32 iRes = 0; iRes < pDir->NumResources(); iRes++) { CResourceEntry *pEntry = pDir->ResourceByIndex(iRes); @@ -269,7 +269,7 @@ void CResourceTableModel::RecursiveAddDirectoryContents(CVirtualDirectory *pDir) } } - for (u32 iDir = 0; iDir < pDir->NumSubdirectories(); iDir++) + for (uint32 iDir = 0; iDir < pDir->NumSubdirectories(); iDir++) RecursiveAddDirectoryContents(pDir->SubdirectoryByIndex(iDir)); } diff --git a/src/Editor/ResourceBrowser/CResourceTableModel.h b/src/Editor/ResourceBrowser/CResourceTableModel.h index c7b16de5..4aca1389 100644 --- a/src/Editor/ResourceBrowser/CResourceTableModel.h +++ b/src/Editor/ResourceBrowser/CResourceTableModel.h @@ -50,8 +50,8 @@ protected: public: // Accessors - inline u32 NumDirectories() const { return mDirectories.size(); } - inline u32 NumResources() const { return mEntries.size(); } + inline uint32 NumDirectories() const { return mDirectories.size(); } + inline uint32 NumResources() const { return mEntries.size(); } inline CVirtualDirectory* CurrentDir() const { return mpCurrentDir; } inline bool IsDisplayingAssetList() const { return mIsAssetListMode; } inline bool IsDisplayingUserEntryList() const { return mIsDisplayingUserEntryList; } diff --git a/src/Editor/ResourceBrowser/CVirtualDirectoryModel.cpp b/src/Editor/ResourceBrowser/CVirtualDirectoryModel.cpp index 82c4288f..d8e52972 100644 --- a/src/Editor/ResourceBrowser/CVirtualDirectoryModel.cpp +++ b/src/Editor/ResourceBrowser/CVirtualDirectoryModel.cpp @@ -27,7 +27,7 @@ QModelIndex CVirtualDirectoryModel::index(int Row, int Column, const QModelIndex CVirtualDirectory *pDir = IndexDirectory(rkParent); - if (pDir && pDir->NumSubdirectories() > (u32) Row) + if (pDir && pDir->NumSubdirectories() > (uint32) Row) return createIndex(Row, Column, pDir->SubdirectoryByIndex(Row)); else if (!pDir) @@ -47,7 +47,7 @@ QModelIndex CVirtualDirectoryModel::parent(const QModelIndex& rkChild) const if (pGrandparent) { - for (u32 iSub = 0; iSub < pGrandparent->NumSubdirectories(); iSub++) + for (uint32 iSub = 0; iSub < pGrandparent->NumSubdirectories(); iSub++) { if (pGrandparent->SubdirectoryByIndex(iSub) == pParent) return createIndex(iSub, 0, pParent); @@ -207,7 +207,7 @@ QModelIndex CVirtualDirectoryModel::GetIndexForDirectory(CVirtualDirectory *pDir { bool Found = false; - for (u32 iDir = 0; iDir < pParent->NumSubdirectories(); iDir++) + for (uint32 iDir = 0; iDir < pParent->NumSubdirectories(); iDir++) { if (pParent->SubdirectoryByIndex(iDir) == pDir) { @@ -253,7 +253,7 @@ bool CVirtualDirectoryModel::GetProposedIndex(QString Path, QModelIndex& rOutPar if (FullPath.EndsWith('/') || FullPath.EndsWith('\\')) FullPath = FullPath.ChopBack(1); - u32 LastSlash = FullPath.LastIndexOf("\\/"); + uint32 LastSlash = FullPath.LastIndexOf("\\/"); TString ParentPath = FullPath.ChopBack( FullPath.Size() - LastSlash ); // Find parent index diff --git a/src/Editor/TestDialog.cpp b/src/Editor/TestDialog.cpp index e6b8b159..3cbc5d1f 100644 --- a/src/Editor/TestDialog.cpp +++ b/src/Editor/TestDialog.cpp @@ -26,7 +26,7 @@ void TestDialog::OnSpinBoxChanged(int NewValue) void TestDialog::OnFind() { - u32 SoundID = ui->spinBox->value(); + uint32 SoundID = ui->spinBox->value(); CGameProject *pProj = gpEdApp->ActiveProject(); if (pProj) diff --git a/src/Editor/Undo/CAddLinkCommand.cpp b/src/Editor/Undo/CAddLinkCommand.cpp index cb65c53d..6e6d45aa 100644 --- a/src/Editor/Undo/CAddLinkCommand.cpp +++ b/src/Editor/Undo/CAddLinkCommand.cpp @@ -16,7 +16,7 @@ void CAddLinkCommand::undo() { CScriptObject *pSender = mLink.Sender(); CScriptObject *pReceiver = mLink.Receiver(); - u32 SenderIndex = pSender->NumLinks(eOutgoing) - 1; + uint32 SenderIndex = pSender->NumLinks(eOutgoing) - 1; CLink *pLink = pSender->Link(eOutgoing, SenderIndex); pSender->RemoveLink(eOutgoing, pLink); pReceiver->RemoveLink(eIncoming, pLink); diff --git a/src/Editor/Undo/CChangeLayerCommand.h b/src/Editor/Undo/CChangeLayerCommand.h index ecfcf2d5..26861569 100644 --- a/src/Editor/Undo/CChangeLayerCommand.h +++ b/src/Editor/Undo/CChangeLayerCommand.h @@ -9,7 +9,7 @@ class CChangeLayerCommand : public IUndoCommand { CNodePtrList mNodes; - QMap mOldLayers; + QMap mOldLayers; CScriptLayer *mpNewLayer; CWorldEditor *mpEditor; diff --git a/src/Editor/Undo/CCloneSelectionCommand.cpp b/src/Editor/Undo/CCloneSelectionCommand.cpp index 897f7abc..5bb38023 100644 --- a/src/Editor/Undo/CCloneSelectionCommand.cpp +++ b/src/Editor/Undo/CCloneSelectionCommand.cpp @@ -17,7 +17,7 @@ CCloneSelectionCommand::CCloneSelectionCommand(INodeEditor *pEditor) CScriptNode *pScript = static_cast(*It); CScriptObject *pInst = pScript->Instance(); - for (u32 iLink = 0; iLink < pInst->NumLinks(eOutgoing); iLink++) + for (uint32 iLink = 0; iLink < pInst->NumLinks(eOutgoing); iLink++) { CScriptNode *pNode = mpEditor->Scene()->NodeForInstance(pInst->Link(eOutgoing, iLink)->Receiver()); @@ -52,8 +52,8 @@ void CCloneSelectionCommand::redo() { QList ToClone = mNodesToClone.DereferenceList(); QList ClonedNodes; - QList ToCloneInstanceIDs; - QList ClonedInstanceIDs; + QList ToCloneInstanceIDs; + QList ClonedInstanceIDs; // Clone nodes foreach (CSceneNode *pNode, ToClone) @@ -85,12 +85,12 @@ void CCloneSelectionCommand::redo() CScriptObject *pSrc = static_cast(ToClone[iNode])->Instance(); CScriptObject *pClone = static_cast(ClonedNodes[iNode])->Instance(); - for (u32 iLink = 0; iLink < pSrc->NumLinks(eOutgoing); iLink++) + for (uint32 iLink = 0; iLink < pSrc->NumLinks(eOutgoing); iLink++) { CLink *pSrcLink = pSrc->Link(eOutgoing, iLink); // If we're cloning the receiver then target the cloned receiver instead of the original one. - u32 ReceiverID = pSrcLink->ReceiverID(); + uint32 ReceiverID = pSrcLink->ReceiverID(); if (ToCloneInstanceIDs.contains(ReceiverID)) ReceiverID = ClonedInstanceIDs[ToCloneInstanceIDs.indexOf(ReceiverID)]; diff --git a/src/Editor/Undo/CCreateInstanceCommand.h b/src/Editor/Undo/CCreateInstanceCommand.h index ee430a1d..50dd0728 100644 --- a/src/Editor/Undo/CCreateInstanceCommand.h +++ b/src/Editor/Undo/CCreateInstanceCommand.h @@ -15,7 +15,7 @@ class CCreateInstanceCommand : public IUndoCommand CScene *mpScene; CGameArea *mpArea; CScriptTemplate *mpTemplate; - u32 mLayerIndex; + uint32 mLayerIndex; CVector3f mSpawnPosition; CNodePtrList mOldSelection; diff --git a/src/Editor/Undo/CDeleteLinksCommand.cpp b/src/Editor/Undo/CDeleteLinksCommand.cpp index fd335680..529315f4 100644 --- a/src/Editor/Undo/CDeleteLinksCommand.cpp +++ b/src/Editor/Undo/CDeleteLinksCommand.cpp @@ -1,7 +1,7 @@ #include "CDeleteLinksCommand.h" #include -CDeleteLinksCommand::CDeleteLinksCommand(CWorldEditor *pEditor, CScriptObject *pObject, ELinkType Type, const QVector& rkIndices) +CDeleteLinksCommand::CDeleteLinksCommand(CWorldEditor *pEditor, CScriptObject *pObject, ELinkType Type, const QVector& rkIndices) : IUndoCommand("Delete Links") , mpEditor(pEditor) { diff --git a/src/Editor/Undo/CDeleteLinksCommand.h b/src/Editor/Undo/CDeleteLinksCommand.h index c5fa84a6..93502bb9 100644 --- a/src/Editor/Undo/CDeleteLinksCommand.h +++ b/src/Editor/Undo/CDeleteLinksCommand.h @@ -12,18 +12,18 @@ class CDeleteLinksCommand : public IUndoCommand struct SDeletedLink { - u32 State; - u32 Message; + uint32 State; + uint32 Message; CInstancePtr pSender; CInstancePtr pReceiver; - u32 SenderIndex; - u32 ReceiverIndex; + uint32 SenderIndex; + uint32 ReceiverIndex; }; QVector mLinks; public: CDeleteLinksCommand() {} - CDeleteLinksCommand(CWorldEditor *pEditor, CScriptObject *pObject, ELinkType Type, const QVector& rkIndices); + CDeleteLinksCommand(CWorldEditor *pEditor, CScriptObject *pObject, ELinkType Type, const QVector& rkIndices); void undo(); void redo(); bool AffectsCleanState() const { return true; } diff --git a/src/Editor/Undo/CDeleteSelectionCommand.cpp b/src/Editor/Undo/CDeleteSelectionCommand.cpp index dc72a585..9a2d8779 100644 --- a/src/Editor/Undo/CDeleteSelectionCommand.cpp +++ b/src/Editor/Undo/CDeleteSelectionCommand.cpp @@ -33,11 +33,11 @@ CDeleteSelectionCommand::CDeleteSelectionCommand(CWorldEditor *pEditor, const QS rNode.pLayer = pInst->Layer(); rNode.LayerIndex = pInst->LayerIndex(); - for (u32 iType = 0; iType < 2; iType++) + for (uint32 iType = 0; iType < 2; iType++) { ELinkType Type = (iType == 0 ? eOutgoing : eIncoming); - for (u32 iLink = 0; iLink < pInst->NumLinks(Type); iLink++) + for (uint32 iLink = 0; iLink < pInst->NumLinks(Type); iLink++) { CLink *pLink = pInst->Link(Type, iLink); @@ -87,7 +87,7 @@ CDeleteSelectionCommand::CDeleteSelectionCommand(CWorldEditor *pEditor, const QS void CDeleteSelectionCommand::undo() { QList NewNodes; - QList NewInstanceIDs; + QList NewInstanceIDs; // Spawn nodes for (int iNode = 0; iNode < mDeletedNodes.size(); iNode++) diff --git a/src/Editor/Undo/CDeleteSelectionCommand.h b/src/Editor/Undo/CDeleteSelectionCommand.h index 7ab3d5ad..f039c426 100644 --- a/src/Editor/Undo/CDeleteSelectionCommand.h +++ b/src/Editor/Undo/CDeleteSelectionCommand.h @@ -20,7 +20,7 @@ class CDeleteSelectionCommand : public IUndoCommand { // Node Info CNodePtr NodePtr; - u32 NodeID; + uint32 NodeID; CVector3f Position; CQuaternion Rotation; CVector3f Scale; @@ -28,19 +28,19 @@ class CDeleteSelectionCommand : public IUndoCommand // Instance Info CGameArea *pArea; CScriptLayer *pLayer; - u32 LayerIndex; + uint32 LayerIndex; std::vector InstanceData; }; QVector mDeletedNodes; struct SDeletedLink { - u32 State; - u32 Message; - u32 SenderID; - u32 SenderIndex; - u32 ReceiverID; - u32 ReceiverIndex; + uint32 State; + uint32 Message; + uint32 SenderID; + uint32 SenderIndex; + uint32 ReceiverID; + uint32 ReceiverIndex; CInstancePtr pSender; CInstancePtr pReceiver; }; diff --git a/src/Editor/Undo/CEditLinkCommand.h b/src/Editor/Undo/CEditLinkCommand.h index afb1570b..f7768e9d 100644 --- a/src/Editor/Undo/CEditLinkCommand.h +++ b/src/Editor/Undo/CEditLinkCommand.h @@ -13,8 +13,8 @@ class CEditLinkCommand : public IUndoCommand CLink mOldLink; CLink mNewLink; - u32 mOldSenderIndex; - u32 mOldReceiverIndex; + uint32 mOldSenderIndex; + uint32 mOldReceiverIndex; CInstancePtrList mAffectedInstances; diff --git a/src/Editor/Undo/CPasteNodesCommand.cpp b/src/Editor/Undo/CPasteNodesCommand.cpp index eadf91c0..33e96d0e 100644 --- a/src/Editor/Undo/CPasteNodesCommand.cpp +++ b/src/Editor/Undo/CPasteNodesCommand.cpp @@ -93,7 +93,7 @@ void CPasteNodesCommand::redo() { CScriptObject *pInstance = static_cast(pNode)->Instance(); - for (u32 iLink = 0; iLink < pInstance->NumLinks(eOutgoing); iLink++) + for (uint32 iLink = 0; iLink < pInstance->NumLinks(eOutgoing); iLink++) { CLink *pLink = pInstance->Link(eOutgoing, iLink); int Index = mpMimeData->IndexOfInstanceID(pLink->ReceiverID()); diff --git a/src/Editor/Undo/ICreateDeleteDirectoryCommand.h b/src/Editor/Undo/ICreateDeleteDirectoryCommand.h index 6c72c9fa..56802162 100644 --- a/src/Editor/Undo/ICreateDeleteDirectoryCommand.h +++ b/src/Editor/Undo/ICreateDeleteDirectoryCommand.h @@ -52,7 +52,7 @@ protected: } else { - Log::Write("Directory delete failed, directory is not empty: " + mParentPath + mDirName); + debugf("Directory delete failed, directory is not empty: %s", *(mParentPath + mDirName)); } } } diff --git a/src/Editor/Undo/ObjReferences.h b/src/Editor/Undo/ObjReferences.h index fd3ee307..c1818f6e 100644 --- a/src/Editor/Undo/ObjReferences.h +++ b/src/Editor/Undo/ObjReferences.h @@ -54,7 +54,7 @@ class CNodePtr { - u32 mNodeID; + uint32 mNodeID; CScene *mpScene; bool mValid; @@ -70,7 +70,7 @@ public: } inline bool Valid() const { return mValid; } - inline u32 NodeID() const { return mNodeID; } + inline uint32 NodeID() const { return mNodeID; } inline CScene* Scene() const { return mpScene; } inline CSceneNode* operator* () const { return mValid ? mpScene->NodeByID(mNodeID) : nullptr; } inline CSceneNode* operator->() const { return mValid ? mpScene->NodeByID(mNodeID) : nullptr; } @@ -84,7 +84,7 @@ public: class CInstancePtr { - u32 mInstanceID; + uint32 mInstanceID; CGameArea *mpArea; bool mValid; @@ -99,7 +99,7 @@ public: mValid = pInst ? true : false; } - inline u32 InstanceID() const { return mInstanceID; } + inline uint32 InstanceID() const { return mInstanceID; } inline CGameArea* Area() const { return mpArea; } inline CScriptObject* operator* () const { return mValid ? mpArea->InstanceByID(mInstanceID) : nullptr; } inline CScriptObject* operator->() const { return mValid ? mpArea->InstanceByID(mInstanceID) : nullptr; } @@ -114,7 +114,7 @@ public: class CLinkPtr { CInstancePtr mpInstance; - u32 mLinkIndex; + uint32 mLinkIndex; bool mValid; public: @@ -128,7 +128,7 @@ public: mValid = pLink ? true : false; } - inline u32 LinkIndex() const { return mLinkIndex; } + inline uint32 LinkIndex() const { return mLinkIndex; } inline CLink* operator* () const { return mValid ? mpInstance->Link(eOutgoing, mLinkIndex) : nullptr; } inline CLink* operator->() const { return mValid ? mpInstance->Link(eOutgoing, mLinkIndex) : nullptr; } inline CLinkPtr& operator=(CLink *pLink) { SetLink(pLink); return *this; } diff --git a/src/Editor/Widgets/CSelectResourcePanel.cpp b/src/Editor/Widgets/CSelectResourcePanel.cpp index 0fe9919b..3969ff9c 100644 --- a/src/Editor/Widgets/CSelectResourcePanel.cpp +++ b/src/Editor/Widgets/CSelectResourcePanel.cpp @@ -1,7 +1,7 @@ #include "CSelectResourcePanel.h" #include "ui_CSelectResourcePanel.h" #include "Editor/CEditorApplication.h" -#include +#include #include #include diff --git a/src/Editor/Widgets/WStringPreviewPanel.cpp b/src/Editor/Widgets/WStringPreviewPanel.cpp index 4aa2ae9a..45fe4df4 100644 --- a/src/Editor/Widgets/WStringPreviewPanel.cpp +++ b/src/Editor/Widgets/WStringPreviewPanel.cpp @@ -39,7 +39,7 @@ void WStringPreviewPanel::SetResource(CResource *pRes) CStringTable *pString = static_cast(pRes); mLabels.reserve(pString->NumStrings()); - for (u32 iStr = 0; iStr < pString->NumStrings(); iStr++) + for (uint32 iStr = 0; iStr < pString->NumStrings(); iStr++) { QString text = TO_QSTRING(pString->String("ENGL", iStr)); QLabel *pLabel = new QLabel(text, this); diff --git a/src/Editor/Widgets/WTextureGLWidget.cpp b/src/Editor/Widgets/WTextureGLWidget.cpp index 563e1d16..4057f0fb 100644 --- a/src/Editor/Widgets/WTextureGLWidget.cpp +++ b/src/Editor/Widgets/WTextureGLWidget.cpp @@ -1,5 +1,5 @@ #include "WTextureGLWidget.h" -#include +#include #include #include #include @@ -146,7 +146,7 @@ void WTextureGLWidget::CalcCheckerCoords() } // Finally, apply translation/scale - for (u32 iCoord = 0; iCoord < 4; iCoord++) + for (uint32 iCoord = 0; iCoord < 4; iCoord++) { mCheckerCoords[iCoord] += Trans; mCheckerCoords[iCoord] *= 10.f; diff --git a/src/Editor/Widgets/WTextureGLWidget.h b/src/Editor/Widgets/WTextureGLWidget.h index 97078ea3..68dd5752 100644 --- a/src/Editor/Widgets/WTextureGLWidget.h +++ b/src/Editor/Widgets/WTextureGLWidget.h @@ -1,8 +1,8 @@ #ifndef WTEXTUREGLWIDGET_H #define WTEXTUREGLWIDGET_H -#include -#include +#include +#include #include #include @@ -19,7 +19,7 @@ class WTextureGLWidget : public QOpenGLWidget float mTexAspectRatio; CTransform4f mTexTransform; CVector2f mCheckerCoords[4]; - u32 mContextID; + uint32 mContextID; bool mInitialized; public: diff --git a/src/Editor/Widgets/WVectorEditor.h b/src/Editor/Widgets/WVectorEditor.h index 9a515cc5..ca6a1970 100644 --- a/src/Editor/Widgets/WVectorEditor.h +++ b/src/Editor/Widgets/WVectorEditor.h @@ -2,7 +2,7 @@ #define WVECTOREDITOR_H #include "WDraggableSpinBox.h" -#include +#include #include #include diff --git a/src/Editor/WorldEditor/CCollisionRenderSettingsDialog.cpp b/src/Editor/WorldEditor/CCollisionRenderSettingsDialog.cpp index 4e8f50d6..d31379de 100644 --- a/src/Editor/WorldEditor/CCollisionRenderSettingsDialog.cpp +++ b/src/Editor/WorldEditor/CCollisionRenderSettingsDialog.cpp @@ -69,14 +69,14 @@ void CCollisionRenderSettingsDialog::SetupWidgets() void CCollisionRenderSettingsDialog::OnHideMaskChanged(QString NewMask) { TString MaskStr = TO_TSTRING(NewMask); - u64 Mask = (MaskStr.IsHexString() ? MaskStr.ToInt64(16) : 0); + uint64 Mask = (MaskStr.IsHexString() ? MaskStr.ToInt64(16) : 0); mpEditor->Viewport()->CollisionRenderSettings().HideMask = Mask; } void CCollisionRenderSettingsDialog::OnHighlightMaskChanged(QString NewMask) { TString MaskStr = TO_TSTRING(NewMask); - u64 Mask = (MaskStr.IsHexString() ? MaskStr.ToInt64(16) : 0); + uint64 Mask = (MaskStr.IsHexString() ? MaskStr.ToInt64(16) : 0); mpEditor->Viewport()->CollisionRenderSettings().HighlightMask = Mask; } @@ -108,9 +108,9 @@ void CCollisionRenderSettingsDialog::OnBackfacesToggled(bool Enable) void CCollisionRenderSettingsDialog::OnHideCheckboxesToggled() { CCollisionMaterial& rMat = mpEditor->Viewport()->CollisionRenderSettings().HideMaterial; - mpUi->HideShootThruCheckBox->isChecked() ? rMat |= eCF_ShootThru : rMat &= ~eCF_ShootThru; + mpUi->HideShootThruCheckBox->isChecked() ? rMat |= eCF_ShootThru : rMat &= ~eCF_ShootThru; mpUi->HideCameraThruCheckBox->isChecked() ? rMat |= eCF_CameraThru : rMat &= ~eCF_CameraThru; - mpUi->HideScanThruCheckBox->isChecked() ? rMat |= eCF_ScanThru : rMat &= ~eCF_ScanThru; + mpUi->HideScanThruCheckBox->isChecked() ? rMat |= eCF_ScanThru : rMat &= ~eCF_ScanThru; mpUi->HideAiWalkThruCheckBox->isChecked() ? rMat |= eCF_AiWalkThru : rMat &= ~eCF_AiWalkThru; - mpUi->HideAiBlockCheckBox->isChecked() ? rMat |= eCF_AiBlock : rMat &= ~eCF_AiBlock; + mpUi->HideAiBlockCheckBox->isChecked() ? rMat |= eCF_AiBlock : rMat &= ~eCF_AiBlock; } diff --git a/src/Editor/WorldEditor/CInstancesModel.cpp b/src/Editor/WorldEditor/CInstancesModel.cpp index fb35f39f..9f8222e0 100644 --- a/src/Editor/WorldEditor/CInstancesModel.cpp +++ b/src/Editor/WorldEditor/CInstancesModel.cpp @@ -91,7 +91,7 @@ QModelIndex CInstancesModel::index(int Row, int Column, const QModelIndex& rkPar // Instance index else if (Type == eObjectTypeIndex) { - u32 RootRow = rkParent.parent().row(); + uint32 RootRow = rkParent.parent().row(); // Object if (RootRow == 0) @@ -99,7 +99,7 @@ QModelIndex CInstancesModel::index(int Row, int Column, const QModelIndex& rkPar if (mModelType == eLayers) { CScriptLayer *pLayer = mpArea->ScriptLayer(rkParent.row()); - if ((u32) Row >= pLayer->NumInstances()) + if ((uint32) Row >= pLayer->NumInstances()) return QModelIndex(); else return createIndex(Row, Column, (*pLayer)[Row]); @@ -108,7 +108,7 @@ QModelIndex CInstancesModel::index(int Row, int Column, const QModelIndex& rkPar else if (mModelType == eTypes) { const std::list& list = mTemplateList[rkParent.row()]->ObjectList(); - if ((u32) Row >= list.size()) + if ((uint32) Row >= list.size()) return QModelIndex(); else { @@ -135,7 +135,7 @@ QModelIndex CInstancesModel::parent(const QModelIndex& rkChild) const // Node type parent if (Type == eObjectTypeIndex) { - u32 NodeTypeRow = (rkChild.internalId() & TYPES_NODE_TYPE_MASK) >> TYPES_NODE_TYPE_SHIFT; + uint32 NodeTypeRow = (rkChild.internalId() & TYPES_NODE_TYPE_MASK) >> TYPES_NODE_TYPE_SHIFT; return createIndex(NodeTypeRow, 0, quint64(0)); } @@ -148,7 +148,7 @@ QModelIndex CInstancesModel::parent(const QModelIndex& rkChild) const { CScriptLayer *pLayer = pObj->Layer(); - for (u32 iLyr = 0; iLyr < mpArea->NumScriptLayers(); iLyr++) + for (uint32 iLyr = 0; iLyr < mpArea->NumScriptLayers(); iLyr++) { if (mpArea->ScriptLayer(iLyr) == pLayer) return createIndex(iLyr, 0, (iLyr << TYPES_ROW_INDEX_SHIFT) | 1); @@ -196,7 +196,7 @@ int CInstancesModel::rowCount(const QModelIndex& rkParent) const // Instances else if (Type == eObjectTypeIndex) { - u32 RowIndex = ((rkParent.internalId() & TYPES_ROW_INDEX_MASK) >> TYPES_ROW_INDEX_SHIFT); + uint32 RowIndex = ((rkParent.internalId() & TYPES_ROW_INDEX_MASK) >> TYPES_ROW_INDEX_SHIFT); if (mModelType == eLayers) return (mpArea ? mpArea->ScriptLayer(RowIndex)->NumInstances() : 0); else @@ -338,7 +338,7 @@ CScriptLayer* CInstancesModel::IndexLayer(const QModelIndex& rkIndex) const if ((mModelType != eLayers) || (IndexNodeType(rkIndex) != eScriptType) || (IndexType(rkIndex) != eObjectTypeIndex)) return nullptr; - u32 RowIndex = ((rkIndex.internalId() & TYPES_ROW_INDEX_MASK) >> TYPES_ROW_INDEX_SHIFT); + uint32 RowIndex = ((rkIndex.internalId() & TYPES_ROW_INDEX_MASK) >> TYPES_ROW_INDEX_SHIFT); return mpArea->ScriptLayer(RowIndex); } @@ -347,7 +347,7 @@ CScriptTemplate* CInstancesModel::IndexTemplate(const QModelIndex& rkIndex) cons if ((mModelType != eTypes) || (IndexNodeType(rkIndex) != eScriptType) || (IndexType(rkIndex) != eObjectTypeIndex)) return nullptr; - u32 RowIndex = ((rkIndex.internalId() & TYPES_ROW_INDEX_MASK) >> TYPES_ROW_INDEX_SHIFT); + uint32 RowIndex = ((rkIndex.internalId() & TYPES_ROW_INDEX_MASK) >> TYPES_ROW_INDEX_SHIFT); return mTemplateList[RowIndex]; } @@ -480,7 +480,7 @@ void CInstancesModel::PropertyModified(CScriptObject *pInst, IProperty *pProp) if (mModelType == eLayers) { - u32 Index = pInst->Layer()->AreaIndex(); + uint32 Index = pInst->Layer()->AreaIndex(); QModelIndex LayerIndex = index(Index, 0, ScriptRoot); QModelIndex InstIndex = index(pInst->LayerIndex(), 0, LayerIndex); emit dataChanged(InstIndex, InstIndex); @@ -488,11 +488,11 @@ void CInstancesModel::PropertyModified(CScriptObject *pInst, IProperty *pProp) else { - u32 Index = mTemplateList.indexOf(pInst->Template()); + uint32 Index = mTemplateList.indexOf(pInst->Template()); QModelIndex TempIndex = index(Index, 0, ScriptRoot); QList InstList = QList::fromStdList(pInst->Template()->ObjectList()); - u32 InstIdx = InstList.indexOf(pInst); + uint32 InstIdx = InstList.indexOf(pInst); QModelIndex InstIndex = index(InstIdx, 0, TempIndex); emit dataChanged(InstIndex, InstIndex); } @@ -570,9 +570,9 @@ void CInstancesModel::GenerateList() if (mpCurrentGame) { - u32 NumTemplates = mpCurrentGame->NumScriptTemplates(); + uint32 NumTemplates = mpCurrentGame->NumScriptTemplates(); - for (u32 iTemp = 0; iTemp < NumTemplates; iTemp++) + for (uint32 iTemp = 0; iTemp < NumTemplates; iTemp++) { CScriptTemplate *pTemp = mpCurrentGame->TemplateByIndex(iTemp); diff --git a/src/Editor/WorldEditor/CLayerModel.cpp b/src/Editor/WorldEditor/CLayerModel.cpp index 8bac661c..6358c4dd 100644 --- a/src/Editor/WorldEditor/CLayerModel.cpp +++ b/src/Editor/WorldEditor/CLayerModel.cpp @@ -34,7 +34,7 @@ void CLayerModel::SetArea(CGameArea *pArea) CScriptLayer* CLayerModel::Layer(const QModelIndex& index) const { if (!mpArea) return nullptr; - u32 NumLayers = mpArea->NumScriptLayers(); + uint32 NumLayers = mpArea->NumScriptLayers(); if (index.row() < (int) NumLayers) return mpArea->ScriptLayer(index.row()); diff --git a/src/Editor/WorldEditor/CLinkDialog.cpp b/src/Editor/WorldEditor/CLinkDialog.cpp index fff95781..ea1630b2 100644 --- a/src/Editor/WorldEditor/CLinkDialog.cpp +++ b/src/Editor/WorldEditor/CLinkDialog.cpp @@ -127,12 +127,12 @@ void CLinkDialog::SetReceiver(CScriptObject *pReceiver) } } -u32 CLinkDialog::State() const +uint32 CLinkDialog::State() const { return mSenderStateModel.State(ui->SenderStateComboBox->currentIndex()); } -u32 CLinkDialog::Message() const +uint32 CLinkDialog::Message() const { return mReceiverMessageModel.Message(ui->ReceiverMessageComboBox->currentIndex()); } diff --git a/src/Editor/WorldEditor/CLinkDialog.h b/src/Editor/WorldEditor/CLinkDialog.h index c6f12a40..96f12019 100644 --- a/src/Editor/WorldEditor/CLinkDialog.h +++ b/src/Editor/WorldEditor/CLinkDialog.h @@ -37,8 +37,8 @@ public: void SetGame(CGameTemplate *pGame); void SetSender(CScriptObject *pSender); void SetReceiver(CScriptObject *pReceiver); - u32 State() const; - u32 Message() const; + uint32 State() const; + uint32 Message() const; void UpdateOkEnabled(); void UpdateSenderNameLabel(); diff --git a/src/Editor/WorldEditor/CLinkModel.cpp b/src/Editor/WorldEditor/CLinkModel.cpp index 2774e263..b5767eaa 100644 --- a/src/Editor/WorldEditor/CLinkModel.cpp +++ b/src/Editor/WorldEditor/CLinkModel.cpp @@ -48,7 +48,7 @@ QVariant CLinkModel::data(const QModelIndex& rkIndex, int Role) const case 0: // Column 0 - Target Object { - u32 TargetID = (mType == eIncoming ? pLink->SenderID() : pLink->ReceiverID()); + uint32 TargetID = (mType == eIncoming ? pLink->SenderID() : pLink->ReceiverID()); CScriptObject *pTarget = mpObject->Area()->InstanceByID(TargetID); if (pTarget) diff --git a/src/Editor/WorldEditor/CPoiMapModel.cpp b/src/Editor/WorldEditor/CPoiMapModel.cpp index 0be9e0a0..77fd3702 100644 --- a/src/Editor/WorldEditor/CPoiMapModel.cpp +++ b/src/Editor/WorldEditor/CPoiMapModel.cpp @@ -142,7 +142,7 @@ bool CPoiMapModel::IsModelMapped(const QModelIndex& rkIndex, CModelNode *pNode) CScriptNode* CPoiMapModel::PoiNodePointer(const QModelIndex& rkIndex) const { - if ((u32) rkIndex.row() < mpPoiToWorld->NumMappedPOIs()) + if ((uint32) rkIndex.row() < mpPoiToWorld->NumMappedPOIs()) { const CPoiToWorld::SPoiMap *pkMap = mpPoiToWorld->MapByIndex(rkIndex.row()); return mpEditor->Scene()->NodeForInstanceID(pkMap->PoiID); @@ -171,7 +171,7 @@ void CPoiMapModel::OnMapChange(CWorld*, CGameArea *pArea) if (mpPoiToWorld) { // Create an ID -> Model Node lookup map - QMap NodeMap; + QMap NodeMap; for (CSceneIterator It(mpEditor->Scene(), eModelNode, true); !It.DoneIterating(); ++It) { @@ -180,7 +180,7 @@ void CPoiMapModel::OnMapChange(CWorld*, CGameArea *pArea) } // Create internal model map - for (u32 iPoi = 0; iPoi < mpPoiToWorld->NumMappedPOIs(); iPoi++) + for (uint32 iPoi = 0; iPoi < mpPoiToWorld->NumMappedPOIs(); iPoi++) { const CPoiToWorld::SPoiMap *pkMap = mpPoiToWorld->MapByIndex(iPoi); CScriptNode *pPoiNode = mpEditor->Scene()->NodeForInstanceID(pkMap->PoiID); diff --git a/src/Editor/WorldEditor/CStateMessageModel.h b/src/Editor/WorldEditor/CStateMessageModel.h index 9017a64d..b96586c8 100644 --- a/src/Editor/WorldEditor/CStateMessageModel.h +++ b/src/Editor/WorldEditor/CStateMessageModel.h @@ -21,11 +21,11 @@ public: private: struct SEntry { - u32 ID; + uint32 ID; QString Name; SEntry() {} - SEntry(u32 _ID, const QString& rkName) + SEntry(uint32 _ID, const QString& rkName) : ID(_ID), Name(rkName) {} bool operator<(const SEntry& rkOther) const @@ -71,7 +71,7 @@ public: if (mType == eStates) { - for (u32 iState = 0; iState < pGame->NumStates(); iState++) + for (uint32 iState = 0; iState < pGame->NumStates(); iState++) { SState State = pGame->StateByIndex(iState); mEntries << SEntry(State.ID, TO_QSTRING(State.Name)); @@ -80,7 +80,7 @@ public: else { - for (u32 iMsg = 0; iMsg < pGame->NumMessages(); iMsg++) + for (uint32 iMsg = 0; iMsg < pGame->NumMessages(); iMsg++) { SMessage Message = pGame->MessageByIndex(iMsg); mEntries << SEntry(Message.ID, TO_QSTRING(Message.Name)); @@ -91,7 +91,7 @@ public: endResetModel(); } - u32 StateIndex(u32 StateID) const + uint32 StateIndex(uint32 StateID) const { if (mType == eMessages) return -1; @@ -104,7 +104,7 @@ public: return -1; } - u32 MessageIndex(u32 MessageID) const + uint32 MessageIndex(uint32 MessageID) const { if (mType == eStates) return -1; @@ -122,12 +122,12 @@ public: mpScript = pScript; } - inline u32 State(u32 Index) const + inline uint32 State(uint32 Index) const { return (mType == eStates ? mEntries[Index].ID : 0); } - inline u32 Message(u32 Index) const + inline uint32 Message(uint32 Index) const { return (mType == eMessages ? mEntries[Index].ID : 0); } diff --git a/src/Editor/WorldEditor/CTemplateEditDialog.cpp b/src/Editor/WorldEditor/CTemplateEditDialog.cpp index e8887d09..e6aa0a23 100644 --- a/src/Editor/WorldEditor/CTemplateEditDialog.cpp +++ b/src/Editor/WorldEditor/CTemplateEditDialog.cpp @@ -319,7 +319,7 @@ void CTemplateEditDialog::FindEquivalentProperties(IProperty* pProperty) if (pScript) { - u32 ObjectID = pScript->ObjectID(); + uint32 ObjectID = pScript->ObjectID(); CScriptTemplate* pEquivalentScript = pGame->TemplateByID(ObjectID); if (pEquivalentScript) diff --git a/src/Editor/WorldEditor/CTemplateListView.h b/src/Editor/WorldEditor/CTemplateListView.h index fce239f3..917d36c5 100644 --- a/src/Editor/WorldEditor/CTemplateListView.h +++ b/src/Editor/WorldEditor/CTemplateListView.h @@ -64,7 +64,7 @@ public: if (mpGame) { - for (u32 iTemp = 0; iTemp < mpGame->NumScriptTemplates(); iTemp++) + for (uint32 iTemp = 0; iTemp < mpGame->NumScriptTemplates(); iTemp++) mTemplates << mpGame->TemplateByIndex(iTemp); qSort(mTemplates.begin(), mTemplates.end(), [](CScriptTemplate *pLeft, CScriptTemplate *pRight) -> bool { diff --git a/src/Editor/WorldEditor/CWorldEditor.cpp b/src/Editor/WorldEditor/CWorldEditor.cpp index 7be2dd6a..379140e1 100644 --- a/src/Editor/WorldEditor/CWorldEditor.cpp +++ b/src/Editor/WorldEditor/CWorldEditor.cpp @@ -43,7 +43,7 @@ CWorldEditor::CWorldEditor(QWidget *parent) , mpNewLinkSender(nullptr) , mpNewLinkReceiver(nullptr) { - Log::Write("Creating World Editor"); + debugf("Creating World Editor"); ui->setupUi(this); UpdateWindowTitle(); @@ -127,7 +127,7 @@ CWorldEditor::CWorldEditor(QWidget *parent) mpOpenRecentMenu = new QMenu(this); ui->ActionOpenRecent->setMenu(mpOpenRecentMenu); - for (u32 iAct = 0; iAct < mskMaxRecentProjects; iAct++) + for (uint32 iAct = 0; iAct < mskMaxRecentProjects; iAct++) { QAction *pAction = new QAction(this); pAction->setVisible(false); @@ -292,9 +292,9 @@ bool CWorldEditor::SetArea(CWorld *pWorld, int AreaIndex) QString AreaName = TO_QSTRING(mpWorld->AreaInGameName(AreaIndex)); if (CurrentGame() < EGame::DKCReturns) - Log::Write("Loaded area: " + mpArea->Entry()->Name() + " (" + TO_TSTRING(AreaName) + ")"); + debugf("Loaded area: %s (%s)", *mpArea->Entry()->Name(), *TO_TSTRING(AreaName)); else - Log::Write("Loaded level: World " + mpWorld->Entry()->Name() + " / Area " + mpArea->Entry()->Name() + " (" + TO_TSTRING(AreaName) + ")"); + debugf("Loaded level: World %s / Area %s (%s)", *mpWorld->Entry()->Name(), *mpArea->Entry()->Name(), *TO_TSTRING(AreaName)); // Update paste action OnClipboardDataModified(); @@ -1087,8 +1087,8 @@ void CWorldEditor::OnUnlinkClicked() if (UnlinkIncoming) { - QVector LinkIndices; - for (u32 iLink = 0; iLink < pInst->NumLinks(eIncoming); iLink++) + QVector LinkIndices; + for (uint32 iLink = 0; iLink < pInst->NumLinks(eIncoming); iLink++) LinkIndices << iLink; CDeleteLinksCommand *pCmd = new CDeleteLinksCommand(this, pInst, eIncoming, LinkIndices); @@ -1097,8 +1097,8 @@ void CWorldEditor::OnUnlinkClicked() if (UnlinkOutgoing) { - QVector LinkIndices; - for (u32 iLink = 0; iLink < pInst->NumLinks(eOutgoing); iLink++) + QVector LinkIndices; + for (uint32 iLink = 0; iLink < pInst->NumLinks(eOutgoing); iLink++) LinkIndices << iLink; CDeleteLinksCommand *pCmd = new CDeleteLinksCommand(this, pInst, eOutgoing, LinkIndices); diff --git a/src/Editor/WorldEditor/CWorldEditor.h b/src/Editor/WorldEditor/CWorldEditor.h index 0d95c07d..3f96adb2 100644 --- a/src/Editor/WorldEditor/CWorldEditor.h +++ b/src/Editor/WorldEditor/CWorldEditor.h @@ -14,8 +14,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/Editor/WorldEditor/CWorldInfoSidebar.cpp b/src/Editor/WorldEditor/CWorldInfoSidebar.cpp index 805886ed..22bbc39f 100644 --- a/src/Editor/WorldEditor/CWorldInfoSidebar.cpp +++ b/src/Editor/WorldEditor/CWorldInfoSidebar.cpp @@ -128,9 +128,9 @@ void CWorldInfoSidebar::OnWorldTreeClicked(QModelIndex Index) mpUI->AttachedAreasList->clear(); - for (u32 iAtt = 0; iAtt < pWorld->AreaAttachedCount(AreaIndex); iAtt++) + for (uint32 iAtt = 0; iAtt < pWorld->AreaAttachedCount(AreaIndex); iAtt++) { - u32 AttachedIdx = pWorld->AreaAttachedID(AreaIndex, iAtt); + uint32 AttachedIdx = pWorld->AreaAttachedID(AreaIndex, iAtt); QString Name = TO_QSTRING( pWorld->AreaInGameName(AttachedIdx) ); mpUI->AttachedAreasList->addItem(Name); } diff --git a/src/Editor/WorldEditor/CWorldTreeModel.cpp b/src/Editor/WorldEditor/CWorldTreeModel.cpp index a042f051..5e38b36c 100644 --- a/src/Editor/WorldEditor/CWorldTreeModel.cpp +++ b/src/Editor/WorldEditor/CWorldTreeModel.cpp @@ -59,7 +59,7 @@ QVariant CWorldTreeModel::data(const QModelIndex& rkIndex, int Role) const // are often missing, confusing, or just straight-up inaccurate, which makes the internal name a better // means of telling worlds apart. // For DKCR worlds, we only display the world name in the first column. - u32 InternalNameCol = (gpEdApp->ActiveProject()->Game() >= EGame::Corruption ? 0 : 1); + uint32 InternalNameCol = (gpEdApp->ActiveProject()->Game() >= EGame::Corruption ? 0 : 1); // Internal name if (rkIndex.column() == InternalNameCol) @@ -241,7 +241,7 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj) Info.pWorld = pWorld; // Add areas - for (u32 iArea = 0; iArea < pWorld->NumAreas(); iArea++) + for (uint32 iArea = 0; iArea < pWorld->NumAreas(); iArea++) { CAssetID AreaID = pWorld->AreaResourceID(iArea); CResourceEntry *pAreaEntry = pWorld->Entry()->ResourceStore()->FindEntry(AreaID); @@ -282,7 +282,7 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj) CAssetID WorldID; TString WorldName; - u32 IDSplit = Line.IndexOf(' '); + uint32 IDSplit = Line.IndexOf(' '); if (IDSplit != -1) { @@ -292,8 +292,8 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj) // Get world name TString WorldPath = (IDSplit == -1 ? "" : Line.SubString(IDSplit + 1, Line.Size() - IDSplit - 1)); - u32 UnderscoreIdx = WorldPath.IndexOf('_'); - u32 WorldDirEnd = WorldPath.IndexOf("\\/", UnderscoreIdx); + uint32 UnderscoreIdx = WorldPath.IndexOf('_'); + uint32 WorldDirEnd = WorldPath.IndexOf("\\/", UnderscoreIdx); if (UnderscoreIdx != -1 && WorldDirEnd != -1) WorldName = WorldPath.SubString(UnderscoreIdx + 1, WorldDirEnd - UnderscoreIdx - 1); diff --git a/src/Editor/WorldEditor/WCreateTab.cpp b/src/Editor/WorldEditor/WCreateTab.cpp index 411ba85d..4c3ab4e4 100644 --- a/src/Editor/WorldEditor/WCreateTab.cpp +++ b/src/Editor/WorldEditor/WCreateTab.cpp @@ -73,7 +73,7 @@ void WCreateTab::OnLayersChanged() ui->SpawnLayerComboBox->blockSignals(true); ui->SpawnLayerComboBox->clear(); - for (u32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++) + for (uint32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++) ui->SpawnLayerComboBox->addItem(TO_QSTRING(pArea->ScriptLayer(iLyr)->Name())); ui->SpawnLayerComboBox->setCurrentIndex(0); diff --git a/src/Editor/WorldEditor/WEditorProperties.cpp b/src/Editor/WorldEditor/WEditorProperties.cpp index e032c193..7a5244f3 100644 --- a/src/Editor/WorldEditor/WEditorProperties.cpp +++ b/src/Editor/WorldEditor/WEditorProperties.cpp @@ -78,7 +78,7 @@ void WEditorProperties::SetLayerComboBox() { CScriptNode *pScript = static_cast(mpDisplayNode); CScriptLayer *pLayer = pScript->Instance()->Layer(); - for (u32 iLyr = 0; iLyr < mpEditor->ActiveArea()->NumScriptLayers(); iLyr++) + for (uint32 iLyr = 0; iLyr < mpEditor->ActiveArea()->NumScriptLayers(); iLyr++) { if (mpEditor->ActiveArea()->ScriptLayer(iLyr) == pLayer) { @@ -161,7 +161,7 @@ void WEditorProperties::OnLayersModified() if (pArea) { - for (u32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++) + for (uint32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++) mpLayersComboBox->addItem(TO_QSTRING(pArea->ScriptLayer(iLyr)->Name())); } diff --git a/src/Editor/WorldEditor/WInstancesTab.cpp b/src/Editor/WorldEditor/WInstancesTab.cpp index 50acce63..b7bc5097 100644 --- a/src/Editor/WorldEditor/WInstancesTab.cpp +++ b/src/Editor/WorldEditor/WInstancesTab.cpp @@ -288,7 +288,7 @@ void WInstancesTab::OnHideAllExceptTypeAction() { CGameArea *pArea = mpEditor->ActiveArea(); - for (u32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++) + for (uint32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++) { CScriptLayer *pLayer = pArea->ScriptLayer(iLyr); pLayer->SetVisible( pLayer == mpMenuLayer ? true : false ); @@ -302,7 +302,7 @@ void WInstancesTab::OnHideAllExceptTypeAction() EGame Game = mpEditor->CurrentGame(); CGameTemplate *pGame = NGameList::GetGameTemplate(Game); - for (u32 iTemp = 0; iTemp < pGame->NumScriptTemplates(); iTemp++) + for (uint32 iTemp = 0; iTemp < pGame->NumScriptTemplates(); iTemp++) { CScriptTemplate *pTemplate = pGame->TemplateByIndex(iTemp); pTemplate->SetVisible( pTemplate == mpMenuTemplate ? true : false ); @@ -322,7 +322,7 @@ void WInstancesTab::OnUnhideAllTypes() { CGameArea *pArea = mpEditor->ActiveArea(); - for (u32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++) + for (uint32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++) pArea->ScriptLayer(iLyr)->SetVisible(true); mpLayersModel->dataChanged( mpLayersModel->index(0, 2, TypeParent), mpLayersModel->index(mpLayersModel->rowCount(TypeParent) - 1, 2, TypeParent) ); @@ -333,7 +333,7 @@ void WInstancesTab::OnUnhideAllTypes() EGame Game = mpEditor->CurrentGame(); CGameTemplate *pGame = NGameList::GetGameTemplate(Game); - for (u32 iTemp = 0; iTemp < pGame->NumScriptTemplates(); iTemp++) + for (uint32 iTemp = 0; iTemp < pGame->NumScriptTemplates(); iTemp++) pGame->TemplateByIndex(iTemp)->SetVisible(true); mpTypesModel->dataChanged( mpTypesModel->index(0, 2, TypeParent), mpTypesModel->index(mpTypesModel->rowCount(TypeParent) - 1, 2, TypeParent) ); @@ -353,7 +353,7 @@ void WInstancesTab::OnUnhideAll() { CGameArea *pArea = mpEditor->ActiveArea(); - for (u32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++) + for (uint32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++) pArea->ScriptLayer(iLyr)->SetVisible(true); mpLayersModel->dataChanged( mpLayersModel->index(0, 2, LayersRoot), mpLayersModel->index(mpLayersModel->rowCount(LayersRoot) - 1, 2, LayersRoot) ); @@ -367,21 +367,21 @@ void WInstancesTab::OnUnhideAll() EGame Game = mpEditor->CurrentGame(); CGameTemplate *pGame = NGameList::GetGameTemplate(Game); - for (u32 iTemp = 0; iTemp < pGame->NumScriptTemplates(); iTemp++) + for (uint32 iTemp = 0; iTemp < pGame->NumScriptTemplates(); iTemp++) pGame->TemplateByIndex(iTemp)->SetVisible(true); mpTypesModel->dataChanged( mpTypesModel->index(0, 2, TypesRoot), mpTypesModel->index(mpTypesModel->rowCount(TypesRoot) - 1, 2, TypesRoot) ); } // Emit data changed on all instances - for (u32 iModel = 0; iModel < 2; iModel++) + for (uint32 iModel = 0; iModel < 2; iModel++) { CInstancesModel *pModel = (iModel == 0 ? mpLayersModel : mpTypesModel); QModelIndex Base = pModel->index(0, 0); - u32 NumRows = pModel->rowCount(Base); + uint32 NumRows = pModel->rowCount(Base); - for (u32 iRow = 0; iRow < NumRows; iRow++) + for (uint32 iRow = 0; iRow < NumRows; iRow++) { QModelIndex RowIndex = pModel->index(iRow, 2, Base); pModel->dataChanged( pModel->index(0, 2, RowIndex), pModel->index(pModel->rowCount(RowIndex) - 1, 2, RowIndex) ); @@ -393,7 +393,7 @@ void WInstancesTab::OnUnhideAll() void WInstancesTab::ExpandTopLevelItems() { - for (u32 iModel = 0; iModel < 2; iModel++) + for (uint32 iModel = 0; iModel < 2; iModel++) { QAbstractItemModel *pModel = (iModel == 0 ? &mLayersProxyModel : &mTypesProxyModel); QTreeView *pView = (iModel == 0 ? ui->LayersTreeView : ui->TypesTreeView); diff --git a/src/Editor/WorldEditor/WModifyTab.cpp b/src/Editor/WorldEditor/WModifyTab.cpp index afc28146..644db8ca 100644 --- a/src/Editor/WorldEditor/WModifyTab.cpp +++ b/src/Editor/WorldEditor/WModifyTab.cpp @@ -147,13 +147,13 @@ void WModifyTab::OnLinksSelectionModified() { if (sender() == ui->InLinksTableView->selectionModel()) { - u32 NumSelectedRows = ui->InLinksTableView->selectionModel()->selectedRows().size(); + uint32 NumSelectedRows = ui->InLinksTableView->selectionModel()->selectedRows().size(); ui->EditIncomingConnectionButton->setEnabled(NumSelectedRows == 1); ui->DeleteIncomingConnectionButton->setEnabled(NumSelectedRows > 0); } else { - u32 NumSelectedRows = ui->OutLinksTableView->selectionModel()->selectedRows().size(); + uint32 NumSelectedRows = ui->OutLinksTableView->selectionModel()->selectedRows().size(); ui->EditOutgoingConnectionButton->setEnabled(NumSelectedRows == 1); ui->DeleteOutgoingConnectionButton->setEnabled(NumSelectedRows > 0); } @@ -229,7 +229,7 @@ void WModifyTab::OnDeleteLinksClicked() if (!SelectedIndices.isEmpty()) { - QVector Indices; + QVector Indices; for (int iIdx = 0; iIdx < SelectedIndices.size(); iIdx++) Indices << SelectedIndices[iIdx].row(); @@ -265,7 +265,7 @@ void WModifyTab::OnLinkTableDoubleClick(QModelIndex Index) { // The link table will only be visible if the selected node is a script node CScriptNode *pNode = static_cast(mpSelectedNode); - u32 InstanceID; + uint32 InstanceID; if (sender() == ui->InLinksTableView) InstanceID = pNode->Instance()->Link(eIncoming, Index.row())->SenderID(); diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index 562ec11c..872089bf 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -16,10 +16,10 @@ void QtLogRedirect(QtMsgType Type, const QMessageLogContext& /*rkContext*/, cons { switch (Type) { - case QtDebugMsg: Log::Write(TString("Qt Debug: ") + TO_TSTRING(rkMessage)); break; - case QtWarningMsg: Log::Write(TString("Qt Warning: ") + TO_TSTRING(rkMessage)); break; - case QtCriticalMsg: Log::Write(TString("Qt Critical: ") + TO_TSTRING(rkMessage)); break; - case QtFatalMsg: Log::Write(TString("Qt Fatal: ") + TO_TSTRING(rkMessage)); break; + case QtDebugMsg: debugf("Qt Debug: %s", *TO_TSTRING(rkMessage)); break; + case QtWarningMsg: warnf ("Qt Warning: %s", *TO_TSTRING(rkMessage)); break; + case QtCriticalMsg: errorf("Qt Critical: %s", *TO_TSTRING(rkMessage)); break; + case QtFatalMsg: fatalf("Qt Fatal: %s", *TO_TSTRING(rkMessage)); break; } } @@ -46,7 +46,7 @@ public: SetupPalette(); // Init log - bool Initialized = Log::InitLog("primeworldeditor.log"); + bool Initialized = NLog::InitLog("primeworldeditor.log"); if (!Initialized) QMessageBox::warning(0, "Error", "Couldn't open log file. Logging will not work for this session."); qInstallMessageHandler(QtLogRedirect); @@ -55,7 +55,7 @@ public: if (!gpEditorStore->AreAllEntriesValid()) { - Log::Write("Editor store has invalid entries. Rebuilding database..."); + debugf("Editor store has invalid entries. Rebuilding database..."); gpEditorStore->RebuildFromDirectory(); gpEditorStore->ConditionalSaveStore(); } diff --git a/templates/PropertyMap.xml b/templates/PropertyMap.xml index 6190c74b..fdb64dfc 100644 --- a/templates/PropertyMap.xml +++ b/templates/PropertyMap.xml @@ -1927,7 +1927,7 @@ - + @@ -6601,10 +6601,6 @@ - - - - @@ -13861,10 +13857,6 @@ - - - - @@ -34235,7 +34227,7 @@ - +