diff --git a/src/Core/GameProject/AssetNameGeneration.cpp b/src/Core/GameProject/AssetNameGeneration.cpp index 0837cc3b..e86b26e9 100644 --- a/src/Core/GameProject/AssetNameGeneration.cpp +++ b/src/Core/GameProject/AssetNameGeneration.cpp @@ -284,7 +284,7 @@ void GenerateAssetNames(CGameProject *pProj) { CScriptLayer *pLayer = pArea->ScriptLayer(iLyr); - for (uint32 iInst = 0; iInst < pLayer->NumInstances(); iInst++) + for (size_t iInst = 0; iInst < pLayer->NumInstances(); iInst++) { CScriptObject* pInst = pLayer->InstanceByIndex(iInst); CStructProperty* pProperties = pInst->Template()->Properties(); diff --git a/src/Core/GameProject/CDependencyTree.cpp b/src/Core/GameProject/CDependencyTree.cpp index befe5e4e..4b142fd2 100644 --- a/src/Core/GameProject/CDependencyTree.cpp +++ b/src/Core/GameProject/CDependencyTree.cpp @@ -329,7 +329,7 @@ void CAreaDependencyTree::AddScriptLayer(CScriptLayer *pLayer, const std::vector mLayerOffsets.push_back(mChildren.size()); std::set UsedIDs; - for (uint32 iInst = 0; iInst < pLayer->NumInstances(); iInst++) + for (size_t iInst = 0; iInst < pLayer->NumInstances(); iInst++) { auto pTree = CScriptInstanceDependency::BuildTree(pLayer->InstanceByIndex(iInst)); ASSERT(pTree != nullptr); diff --git a/src/Core/Resource/Area/CGameArea.cpp b/src/Core/Resource/Area/CGameArea.cpp index 57ac4c11..705fe3ae 100644 --- a/src/Core/Resource/Area/CGameArea.cpp +++ b/src/Core/Resource/Area/CGameArea.cpp @@ -118,9 +118,9 @@ void CGameArea::ClearScriptLayers() mScriptLayers.clear(); } -uint32 CGameArea::TotalInstanceCount() const +size_t CGameArea::TotalInstanceCount() const { - uint32 Num = 0; + size_t Num = 0; for (const auto& layer : mScriptLayers) Num += layer->NumInstances(); @@ -164,30 +164,30 @@ CScriptObject* CGameArea::SpawnInstance(CScriptTemplate *pTemplate, uint32 SuggestedLayerIndex /*= -1*/ ) { // Verify we can fit another instance in this area. - uint32 NumInstances = TotalInstanceCount(); + const size_t NumInstances = TotalInstanceCount(); if (NumInstances >= 0xFFFF) { - errorf("Unable to spawn a new script instance; too many instances in area (%d)", NumInstances); + errorf("Unable to spawn a new script instance; too many instances in area (%zu)", NumInstances); return nullptr; } // Check whether the suggested instance ID is valid uint32 InstanceID = SuggestedID; - if (InstanceID != -1) + if (InstanceID != UINT32_MAX) { - if (mObjectMap.find(InstanceID) == mObjectMap.end()) - InstanceID = -1; + if (mObjectMap.find(InstanceID) == mObjectMap.cend()) + InstanceID = UINT32_MAX; } // If not valid (or if there's no suggested ID) then determine a new instance ID - if (InstanceID == -1) + if (InstanceID == UINT32_MAX) { // Determine layer index - uint32 LayerIndex = pLayer->AreaIndex(); + const uint32 LayerIndex = pLayer->AreaIndex(); - if (LayerIndex == -1) + if (LayerIndex == UINT32_MAX) { errorf("Unable to spawn a new script instance; invalid script layer passed in"); return nullptr; @@ -198,13 +198,14 @@ CScriptObject* CGameArea::SpawnInstance(CScriptTemplate *pTemplate, } // Spawn instance - CScriptObject *pInstance = new CScriptObject(InstanceID, this, pLayer, pTemplate); + auto* pInstance = new CScriptObject(InstanceID, this, pLayer, pTemplate); pInstance->EvaluateProperties(); pInstance->SetPosition(rkPosition); pInstance->SetRotation(rkRotation.ToEuler()); pInstance->SetScale(rkScale); pInstance->SetName(pTemplate->Name()); - if (pTemplate->Game() < EGame::EchoesDemo) pInstance->SetActive(true); + if (pTemplate->Game() < EGame::EchoesDemo) + pInstance->SetActive(true); pLayer->AddInstance(pInstance, SuggestedLayerIndex); mObjectMap[InstanceID] = pInstance; return pInstance; diff --git a/src/Core/Resource/Area/CGameArea.h b/src/Core/Resource/Area/CGameArea.h index 0f5816a2..02b1459f 100644 --- a/src/Core/Resource/Area/CGameArea.h +++ b/src/Core/Resource/Area/CGameArea.h @@ -75,7 +75,7 @@ public: void MergeTerrain(); void ClearTerrain(); void ClearScriptLayers(); - uint32 TotalInstanceCount() const; + size_t TotalInstanceCount() const; CScriptObject* InstanceByID(uint32 InstanceID); uint32 FindUnusedInstanceID() const; CScriptObject* SpawnInstance(CScriptTemplate* pTemplate, CScriptLayer* pLayer, diff --git a/src/Core/Resource/Cooker/CScriptCooker.cpp b/src/Core/Resource/Cooker/CScriptCooker.cpp index 08507a72..6c93c6ee 100644 --- a/src/Core/Resource/Cooker/CScriptCooker.cpp +++ b/src/Core/Resource/Cooker/CScriptCooker.cpp @@ -276,7 +276,7 @@ void CScriptCooker::WriteLayer(IOutputStream& rOut, CScriptLayer *pLayer) uint32 NumWrittenInstances = 0; rOut.WriteLong(0); - for (uint32 iInst = 0; iInst < pLayer->NumInstances(); iInst++) + for (size_t iInst = 0; iInst < pLayer->NumInstances(); iInst++) { CScriptObject *pInstance = pLayer->InstanceByIndex(iInst); diff --git a/src/Core/Resource/Script/CScriptLayer.h b/src/Core/Resource/Script/CScriptLayer.h index 62bb42c2..ed52ee96 100644 --- a/src/Core/Resource/Script/CScriptLayer.h +++ b/src/Core/Resource/Script/CScriptLayer.h @@ -53,7 +53,7 @@ public: mInstances.erase(it); } - void RemoveInstanceByIndex(uint32 Index) + void RemoveInstanceByIndex(size_t Index) { mInstances.erase(mInstances.begin() + Index); } @@ -69,7 +69,7 @@ public: mInstances.erase(it); } - void Reserve(uint32 Amount) + void Reserve(size_t Amount) { mInstances.reserve(Amount); } @@ -79,8 +79,8 @@ public: TString Name() const { return mLayerName; } bool IsActive() const { return mActive; } bool IsVisible() const { return mVisible; } - uint32 NumInstances() const { return mInstances.size(); } - CScriptObject* InstanceByIndex(uint32 Index) const { return mInstances[Index]; } + size_t NumInstances() const { return mInstances.size(); } + CScriptObject* InstanceByIndex(size_t Index) const { return mInstances[Index]; } CScriptObject* InstanceByID(uint32 ID) const { @@ -109,8 +109,8 @@ public: } // Operators - CScriptObject* operator[](uint32 Index) { return InstanceByIndex(Index); } - const CScriptObject* operator[](uint32 Index) const { return InstanceByIndex(Index); } + CScriptObject* operator[](size_t Index) { return InstanceByIndex(Index); } + const CScriptObject* operator[](size_t Index) const { return InstanceByIndex(Index); } }; #endif // CSCRIPTLAYER_H diff --git a/src/Editor/WorldEditor/CInstancesModel.cpp b/src/Editor/WorldEditor/CInstancesModel.cpp index 39ea8bf5..1068ac5c 100644 --- a/src/Editor/WorldEditor/CInstancesModel.cpp +++ b/src/Editor/WorldEditor/CInstancesModel.cpp @@ -174,35 +174,37 @@ QModelIndex CInstancesModel::parent(const QModelIndex& rkChild) const int CInstancesModel::rowCount(const QModelIndex& rkParent) const { - EIndexType Type = IndexType(rkParent); + const EIndexType Type = IndexType(rkParent); // Node types if (Type == EIndexType::Root) { return mBaseItems.count(); } + // Object types - else if (Type == EIndexType::NodeType) + if (Type == EIndexType::NodeType) { // Script Objects if (rkParent.row() == 0) { if (mModelType == EInstanceModelType::Layers) - return (mpArea ? mpArea->NumScriptLayers() : 0); - else - return mTemplateList.size(); + return mpArea ? static_cast(mpArea->NumScriptLayers()) : 0; + + return static_cast(mTemplateList.size()); } - else - return 0; + + return 0; } + // Instances - else if (Type == EIndexType::ObjectType) + if (Type == EIndexType::ObjectType) { const uint32 RowIndex = ((rkParent.internalId() & TYPES_ROW_INDEX_MASK) >> TYPES_ROW_INDEX_SHIFT); if (mModelType == EInstanceModelType::Layers) - return (mpArea ? mpArea->ScriptLayer(RowIndex)->NumInstances() : 0); - else - return mTemplateList[RowIndex]->NumObjects(); + return mpArea ? static_cast(mpArea->ScriptLayer(RowIndex)->NumInstances()) : 0; + + return static_cast(mTemplateList[RowIndex]->NumObjects()); } return 0;