From 6f1d6a8649ca409cf0a89e1dabebbd58df44d42e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 18 Jun 2020 07:16:41 -0400 Subject: [PATCH] CScriptObject: Make use of size_t where applicable Plays with standard containers nicer. --- src/Core/Resource/Cooker/CScriptCooker.cpp | 44 ++++++++++----------- src/Core/Resource/Factory/CAreaLoader.cpp | 2 +- src/Core/Resource/Script/CScriptObject.h | 4 +- src/Core/Scene/CScriptNode.cpp | 23 ++++++----- src/Core/ScriptExtra/CSplinePathExtra.cpp | 24 +++++------ src/Core/ScriptExtra/CWaypointExtra.cpp | 29 ++++++++------ src/Core/ScriptExtra/CWaypointExtra.h | 2 +- src/Editor/CSceneViewport.cpp | 4 +- src/Editor/Undo/CAddLinkCommand.cpp | 6 +-- src/Editor/Undo/CCloneSelectionCommand.cpp | 4 +- src/Editor/Undo/CDeleteSelectionCommand.cpp | 4 +- src/Editor/Undo/CPasteNodesCommand.cpp | 4 +- src/Editor/WorldEditor/CLinkModel.cpp | 4 +- 13 files changed, 79 insertions(+), 75 deletions(-) diff --git a/src/Core/Resource/Cooker/CScriptCooker.cpp b/src/Core/Resource/Cooker/CScriptCooker.cpp index 96f67989..941959fe 100644 --- a/src/Core/Resource/Cooker/CScriptCooker.cpp +++ b/src/Core/Resource/Cooker/CScriptCooker.cpp @@ -195,8 +195,8 @@ void CScriptCooker::WriteProperty(IOutputStream& rOut, IProperty* pProperty, voi rOut.WriteShort((uint16) PropertiesToWrite.size()); } - for (uint32 PropertyIdx = 0; PropertyIdx < PropertiesToWrite.size(); PropertyIdx++) - WriteProperty(rOut, PropertiesToWrite[PropertyIdx], pData, pStruct->IsAtomic()); + for (auto* property : PropertiesToWrite) + WriteProperty(rOut, property, pData, pStruct->IsAtomic()); break; } @@ -233,35 +233,35 @@ void CScriptCooker::WriteInstance(IOutputStream& rOut, CScriptObject *pInstance) // Note the format is pretty much the same between games; the main difference is a // number of fields changed size between MP1 and 2, but they're still the same fields - bool IsPrime1 = (mGame <= EGame::Prime); + const bool IsPrime1 = mGame <= EGame::Prime; - uint32 ObjectType = pInstance->ObjectTypeID(); - IsPrime1 ? rOut.WriteByte((uint8) ObjectType) : rOut.WriteLong(ObjectType); + const uint32 ObjectType = pInstance->ObjectTypeID(); + IsPrime1 ? rOut.WriteByte(static_cast(ObjectType)) : rOut.WriteLong(ObjectType); - uint32 SizeOffset = rOut.Tell(); + const uint32 SizeOffset = rOut.Tell(); IsPrime1 ? rOut.WriteLong(0) : rOut.WriteShort(0); - uint32 InstanceStart = rOut.Tell(); - uint32 InstanceID = (pInstance->Layer()->AreaIndex() << 26) | pInstance->InstanceID(); + const uint32 InstanceStart = rOut.Tell(); + const uint32 InstanceID = (pInstance->Layer()->AreaIndex() << 26) | pInstance->InstanceID(); rOut.WriteLong(InstanceID); - uint32 NumLinks = pInstance->NumLinks(ELinkType::Outgoing); - IsPrime1 ? rOut.WriteLong(NumLinks) : rOut.WriteShort((uint16) NumLinks); + const size_t NumLinks = pInstance->NumLinks(ELinkType::Outgoing); + IsPrime1 ? rOut.WriteLong(static_cast(NumLinks)) : rOut.WriteShort(static_cast(NumLinks)); - for (uint32 LinkIdx = 0; LinkIdx < NumLinks; LinkIdx++) + for (size_t LinkIdx = 0; LinkIdx < NumLinks; LinkIdx++) { - CLink *pLink = pInstance->Link(ELinkType::Outgoing, LinkIdx); + const CLink *pLink = pInstance->Link(ELinkType::Outgoing, LinkIdx); rOut.WriteLong(pLink->State()); rOut.WriteLong(pLink->Message()); rOut.WriteLong(pLink->ReceiverID()); } WriteProperty(rOut, pInstance->Template()->Properties(), pInstance->PropertyData(), false); - uint32 InstanceEnd = rOut.Tell(); + const uint32 InstanceEnd = rOut.Tell(); rOut.Seek(SizeOffset, SEEK_SET); - uint32 Size = InstanceEnd - InstanceStart; - IsPrime1 ? rOut.WriteLong(Size) : rOut.WriteShort((uint16) Size); + const uint32 Size = InstanceEnd - InstanceStart; + IsPrime1 ? rOut.WriteLong(Size) : rOut.WriteShort(static_cast(Size)); rOut.Seek(InstanceEnd, SEEK_SET); } @@ -269,7 +269,7 @@ void CScriptCooker::WriteLayer(IOutputStream& rOut, CScriptLayer *pLayer) { ASSERT(pLayer->Area()->Game() == mGame); - rOut.WriteByte( mGame <= EGame::Prime ? 0 : 1 ); // Version + rOut.WriteByte(mGame <= EGame::Prime ? 0 : 1); // Version uint32 InstanceCountOffset = rOut.Tell(); uint32 NumWrittenInstances = 0; @@ -286,15 +286,16 @@ void CScriptCooker::WriteLayer(IOutputStream& rOut, CScriptLayer *pLayer) { // GenericCreature instances in DKCR always write to both SCLY and SCGN if (mGame == EGame::DKCReturns && pInstance->ObjectTypeID() == FOURCC('GCTR')) + { mGeneratedObjects.push_back(pInstance); - + } // Instances receiving a Generate/Activate message (MP2) or a // Generate/Attach message (MP3+) should be written to SCGN, not SCLY else { - for (uint32 LinkIdx = 0; LinkIdx < pInstance->NumLinks(ELinkType::Incoming); LinkIdx++) + for (size_t LinkIdx = 0; LinkIdx < pInstance->NumLinks(ELinkType::Incoming); LinkIdx++) { - CLink *pLink = pInstance->Link(ELinkType::Incoming, LinkIdx); + const CLink *pLink = pInstance->Link(ELinkType::Incoming, LinkIdx); if (mGame <= EGame::Echoes) { @@ -304,7 +305,6 @@ void CScriptCooker::WriteLayer(IOutputStream& rOut, CScriptLayer *pLayer) break; } } - else { if (pLink->Message() == FOURCC('ATCH')) @@ -341,6 +341,6 @@ void CScriptCooker::WriteGeneratedLayer(IOutputStream& rOut) rOut.WriteByte(1); // Version rOut.WriteLong(mGeneratedObjects.size()); - for (uint32 ObjectIdx = 0; ObjectIdx < mGeneratedObjects.size(); ObjectIdx++) - WriteInstance(rOut, mGeneratedObjects[ObjectIdx]); + for (auto* object : mGeneratedObjects) + WriteInstance(rOut, object); } diff --git a/src/Core/Resource/Factory/CAreaLoader.cpp b/src/Core/Resource/Factory/CAreaLoader.cpp index 90e137d5..ef2da26e 100644 --- a/src/Core/Resource/Factory/CAreaLoader.cpp +++ b/src/Core/Resource/Factory/CAreaLoader.cpp @@ -688,7 +688,7 @@ void CAreaLoader::SetUpObjects(CScriptLayer *pGenLayer) CScriptObject *pInst = Iter->second; // Store outgoing connections - for (uint32 iCon = 0; iCon < pInst->NumLinks(ELinkType::Outgoing); iCon++) + for (size_t iCon = 0; iCon < pInst->NumLinks(ELinkType::Outgoing); iCon++) { CLink *pLink = pInst->Link(ELinkType::Outgoing, iCon); mConnectionMap[pLink->ReceiverID()].push_back(pLink); diff --git a/src/Core/Resource/Script/CScriptObject.h b/src/Core/Resource/Script/CScriptObject.h index 79c6c7fc..5f315a22 100644 --- a/src/Core/Resource/Script/CScriptObject.h +++ b/src/Core/Resource/Script/CScriptObject.h @@ -89,8 +89,8 @@ public: uint32 Version() const { return mVersion; } uint32 ObjectTypeID() const { return mpTemplate->ObjectID(); } CInstanceID InstanceID() const { return mInstanceID; } - uint32 NumLinks(ELinkType Type) const { return (Type == ELinkType::Incoming ? mInLinks.size() : mOutLinks.size()); } - CLink* Link(ELinkType Type, uint32 Index) const { return (Type == ELinkType::Incoming ? mInLinks[Index] : mOutLinks[Index]); } + size_t NumLinks(ELinkType Type) const { return (Type == ELinkType::Incoming ? mInLinks.size() : mOutLinks.size()); } + CLink* Link(ELinkType Type, size_t Index) const { return (Type == ELinkType::Incoming ? mInLinks[Index] : mOutLinks[Index]); } void* PropertyData() const { return (void*) mPropertyData.data(); } CVector3f Position() const { return mPosition.IsValid() ? mPosition.Get() : CVector3f::Zero(); } diff --git a/src/Core/Scene/CScriptNode.cpp b/src/Core/Scene/CScriptNode.cpp index 825fe389..6357d58c 100644 --- a/src/Core/Scene/CScriptNode.cpp +++ b/src/Core/Scene/CScriptNode.cpp @@ -267,19 +267,19 @@ void CScriptNode::DrawSelection() CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity; CGraphics::UpdateMVPBlock(); - for (uint32 iIn = 0; iIn < mpInstance->NumLinks(ELinkType::Incoming); iIn++) + for (size_t iIn = 0; iIn < mpInstance->NumLinks(ELinkType::Incoming); iIn++) { // Don't draw in links if the other object is selected. - CLink *pLink = mpInstance->Link(ELinkType::Incoming, iIn); - CScriptNode *pLinkNode = mpScene->NodeForInstanceID(pLink->SenderID()); + const CLink *pLink = mpInstance->Link(ELinkType::Incoming, iIn); + const CScriptNode *pLinkNode = mpScene->NodeForInstanceID(pLink->SenderID()); if (pLinkNode && !pLinkNode->IsSelected()) CDrawUtil::DrawLine(CenterPoint(), pLinkNode->CenterPoint(), CColor::TransparentRed()); } - for (uint32 iOut = 0; iOut < mpInstance->NumLinks(ELinkType::Outgoing); iOut++) + for (size_t iOut = 0; iOut < mpInstance->NumLinks(ELinkType::Outgoing); iOut++) { - CLink *pLink = mpInstance->Link(ELinkType::Outgoing, iOut); - CScriptNode *pLinkNode = mpScene->NodeForInstanceID(pLink->ReceiverID()); + const CLink *pLink = mpInstance->Link(ELinkType::Outgoing, iOut); + const CScriptNode *pLinkNode = mpScene->NodeForInstanceID(pLink->ReceiverID()); if (pLinkNode) CDrawUtil::DrawLine(CenterPoint(), pLinkNode->CenterPoint(), CColor::TransparentGreen()); } @@ -581,12 +581,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. - uint32 NumLinks = mpInstance->NumLinks(ELinkType::Incoming) + mpInstance->NumLinks(ELinkType::Outgoing); + const size_t NumLinks = mpInstance->NumLinks(ELinkType::Incoming) + mpInstance->NumLinks(ELinkType::Outgoing); // 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) { - uint32 LinkedID = (mpInstance->NumLinks(ELinkType::Incoming) > 0 ? mpInstance->Link(ELinkType::Incoming, 0)->SenderID() : mpInstance->Link(ELinkType::Outgoing, 0)->ReceiverID()); + const uint32 LinkedID = (mpInstance->NumLinks(ELinkType::Incoming) > 0 ? mpInstance->Link(ELinkType::Incoming, 0)->SenderID() : mpInstance->Link(ELinkType::Outgoing, 0)->ReceiverID()); CScriptNode *pNode = mpScene->NodeForInstanceID(LinkedID); pNode->GeneratePosition(); mPosition = pNode->AbsolutePosition(); @@ -594,13 +594,12 @@ void CScriptNode::GeneratePosition() mPosition.Z += (AABox().Size().Z / 2.f); mPosition.Z += 2.f; } - // For two or more links, average out the position of the connected objects. else if (NumLinks >= 2) { CVector3f NewPos = CVector3f::Zero(); - for (uint32 iIn = 0; iIn < mpInstance->NumLinks(ELinkType::Incoming); iIn++) + for (size_t iIn = 0; iIn < mpInstance->NumLinks(ELinkType::Incoming); iIn++) { CScriptNode *pNode = mpScene->NodeForInstanceID(mpInstance->Link(ELinkType::Incoming, iIn)->SenderID()); @@ -611,7 +610,7 @@ void CScriptNode::GeneratePosition() } } - for (uint32 iOut = 0; iOut < mpInstance->NumLinks(ELinkType::Outgoing); iOut++) + for (size_t iOut = 0; iOut < mpInstance->NumLinks(ELinkType::Outgoing); iOut++) { CScriptNode *pNode = mpScene->NodeForInstanceID(mpInstance->Link(ELinkType::Outgoing, iOut)->ReceiverID()); @@ -622,7 +621,7 @@ void CScriptNode::GeneratePosition() } } - mPosition = NewPos / (float) NumLinks; + mPosition = NewPos / static_cast(NumLinks); mPosition.X += 2.f; } diff --git a/src/Core/ScriptExtra/CSplinePathExtra.cpp b/src/Core/ScriptExtra/CSplinePathExtra.cpp index 130251e2..29ff6a5f 100644 --- a/src/Core/ScriptExtra/CSplinePathExtra.cpp +++ b/src/Core/ScriptExtra/CSplinePathExtra.cpp @@ -13,8 +13,8 @@ void CSplinePathExtra::PropertyModified(IProperty* pProperty) { if (pProperty == mPathColor.Property()) { - for (auto it = mWaypoints.begin(); it != mWaypoints.end(); it++) - (*it)->CheckColor(); + for (auto* extra : mWaypoints) + extra->CheckColor(); } } @@ -25,7 +25,7 @@ void CSplinePathExtra::PostLoad() void CSplinePathExtra::FindAttachedWaypoints(std::set& rChecked, CWaypointExtra* pWaypoint) { - if (rChecked.find(pWaypoint) != rChecked.end()) + if (rChecked.find(pWaypoint) != rChecked.cend()) return; rChecked.insert(pWaypoint); @@ -35,8 +35,8 @@ void CSplinePathExtra::FindAttachedWaypoints(std::set& rChecked std::list Attached; pWaypoint->GetLinkedWaypoints(Attached); - for (auto it = Attached.begin(); it != Attached.end(); it++) - FindAttachedWaypoints(rChecked, *it); + for (auto* extra : Attached) + FindAttachedWaypoints(rChecked, extra); } void CSplinePathExtra::AddWaypoints() @@ -46,12 +46,12 @@ void CSplinePathExtra::AddWaypoints() std::set CheckedWaypoints; - for (uint32 LinkIdx = 0; LinkIdx < mpInstance->NumLinks(ELinkType::Outgoing); LinkIdx++) + for (size_t LinkIdx = 0; LinkIdx < mpInstance->NumLinks(ELinkType::Outgoing); LinkIdx++) { - CLink* pLink = mpInstance->Link(ELinkType::Outgoing, LinkIdx); + const CLink* pLink = mpInstance->Link(ELinkType::Outgoing, LinkIdx); - if ( (pLink->State() == FOURCC('IS00') && pLink->Message() == FOURCC('ATCH')) || // InternalState00/Attach - (pLink->State() == FOURCC('MOTP') && pLink->Message() == FOURCC('ATCH')) ) // MotionPath/Attach + if ((pLink->State() == FOURCC('IS00') && pLink->Message() == FOURCC('ATCH')) || // InternalState00/Attach + (pLink->State() == FOURCC('MOTP') && pLink->Message() == FOURCC('ATCH'))) // MotionPath/Attach { CScriptNode* pNode = mpScene->NodeForInstanceID(pLink->ReceiverID()); @@ -66,7 +66,7 @@ void CSplinePathExtra::AddWaypoints() void CSplinePathExtra::RemoveWaypoint(CWaypointExtra *pWaypoint) { - for (auto it = mWaypoints.begin(); it != mWaypoints.end(); it++) + for (auto it = mWaypoints.begin(); it != mWaypoints.end(); ++it) { if (*it == pWaypoint) { @@ -78,8 +78,8 @@ void CSplinePathExtra::RemoveWaypoint(CWaypointExtra *pWaypoint) void CSplinePathExtra::ClearWaypoints() { - for (auto it = mWaypoints.begin(); it != mWaypoints.end(); it++) - (*it)->RemoveFromSplinePath(this); + for (auto* extra : mWaypoints) + extra->RemoveFromSplinePath(this); mWaypoints.clear(); } diff --git a/src/Core/ScriptExtra/CWaypointExtra.cpp b/src/Core/ScriptExtra/CWaypointExtra.cpp index caaf8153..c34022c9 100644 --- a/src/Core/ScriptExtra/CWaypointExtra.cpp +++ b/src/Core/ScriptExtra/CWaypointExtra.cpp @@ -60,7 +60,7 @@ void CWaypointExtra::AddToSplinePath(CSplinePathExtra *pPath) void CWaypointExtra::RemoveFromSplinePath(CSplinePathExtra *pPath) { - for (auto it = mPaths.begin(); it != mPaths.end(); it++) + for (auto it = mPaths.begin(); it != mPaths.end(); ++it) { if (*it == pPath) { @@ -75,9 +75,9 @@ void CWaypointExtra::BuildLinks() { mLinks.clear(); - for (uint32 iLink = 0; iLink < mpInstance->NumLinks(ELinkType::Outgoing); iLink++) + for (size_t iLink = 0; iLink < mpInstance->NumLinks(ELinkType::Outgoing); iLink++) { - CLink *pLink = mpInstance->Link(ELinkType::Outgoing, iLink); + const CLink *pLink = mpInstance->Link(ELinkType::Outgoing, iLink); if (IsPathLink(pLink)) { @@ -94,26 +94,33 @@ void CWaypointExtra::BuildLinks() mLinksBuilt = true; } -bool CWaypointExtra::IsPathLink(CLink *pLink) +bool CWaypointExtra::IsPathLink(const CLink *pLink) const { bool Valid = false; if (pLink->State() < 0xFF) { - if (pLink->State() == 0x1 && pLink->Message() == 0x8) Valid = true; // Arrived / Next (MP1) + // Arrived / Next (MP1) + if (pLink->State() == 0x1 && pLink->Message() == 0x8) + Valid = true; } - else { - CFourCC State(pLink->State()); - CFourCC Message(pLink->Message()); - if (State == FOURCC('ARRV') && Message == FOURCC('NEXT')) Valid = true; // Arrived / Next (MP2) - if (State == FOURCC('NEXT') && Message == FOURCC('ATCH')) Valid = true; // Next / Attach (MP3/DKCR) + const CFourCC State(pLink->State()); + const CFourCC Message(pLink->Message()); + + // Arrived / Next (MP2) + if (State == FOURCC('ARRV') && Message == FOURCC('NEXT')) + Valid = true; + + // Next / Attach (MP3/DKCR) + if (State == FOURCC('NEXT') && Message == FOURCC('ATCH')) + Valid = true; } if (Valid) { - CScriptNode *pNode = mpScene->NodeForInstanceID(pLink->ReceiverID()); + const CScriptNode *pNode = mpScene->NodeForInstanceID(pLink->ReceiverID()); if (pNode) return pNode->Instance()->ObjectTypeID() == mpInstance->ObjectTypeID(); diff --git a/src/Core/ScriptExtra/CWaypointExtra.h b/src/Core/ScriptExtra/CWaypointExtra.h index dc9c9db6..443f09d8 100644 --- a/src/Core/ScriptExtra/CWaypointExtra.h +++ b/src/Core/ScriptExtra/CWaypointExtra.h @@ -26,7 +26,7 @@ public: void AddToSplinePath(CSplinePathExtra *pPath); void RemoveFromSplinePath(CSplinePathExtra *pPath); void BuildLinks(); - bool IsPathLink(CLink *pLink); + bool IsPathLink(const CLink *pLink) const; void GetLinkedWaypoints(std::list& rOut); void OnTransformed(); diff --git a/src/Editor/CSceneViewport.cpp b/src/Editor/CSceneViewport.cpp index 2b70b522..121883dd 100644 --- a/src/Editor/CSceneViewport.cpp +++ b/src/Editor/CSceneViewport.cpp @@ -252,7 +252,7 @@ void CSceneViewport::FindConnectedObjects(uint32 InstanceID, bool SearchOutgoing if (SearchOutgoing) { - for (uint32 iLink = 0; iLink < pInst->NumLinks(ELinkType::Outgoing); iLink++) + for (size_t iLink = 0; iLink < pInst->NumLinks(ELinkType::Outgoing); iLink++) { CLink *pLink = pInst->Link(ELinkType::Outgoing, iLink); @@ -263,7 +263,7 @@ void CSceneViewport::FindConnectedObjects(uint32 InstanceID, bool SearchOutgoing if (SearchIncoming) { - for (uint32 iLink = 0; iLink < pInst->NumLinks(ELinkType::Incoming); iLink++) + for (size_t iLink = 0; iLink < pInst->NumLinks(ELinkType::Incoming); iLink++) { CLink *pLink = pInst->Link(ELinkType::Incoming, iLink); diff --git a/src/Editor/Undo/CAddLinkCommand.cpp b/src/Editor/Undo/CAddLinkCommand.cpp index 3a916ef2..4d00bf82 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(); - uint32 SenderIndex = pSender->NumLinks(ELinkType::Outgoing) - 1; + const size_t SenderIndex = pSender->NumLinks(ELinkType::Outgoing) - 1; CLink *pLink = pSender->Link(ELinkType::Outgoing, SenderIndex); pSender->RemoveLink(ELinkType::Outgoing, pLink); pReceiver->RemoveLink(ELinkType::Incoming, pLink); @@ -28,8 +28,8 @@ void CAddLinkCommand::undo() void CAddLinkCommand::redo() { CLink *pLink = new CLink(mLink); - pLink->Sender()->AddLink(ELinkType::Outgoing, pLink, -1); - pLink->Receiver()->AddLink(ELinkType::Incoming, pLink, -1); + pLink->Sender()->AddLink(ELinkType::Outgoing, pLink); + pLink->Receiver()->AddLink(ELinkType::Incoming, pLink); mpEditor->OnLinksModified(mAffectedInstances.DereferenceList()); } diff --git a/src/Editor/Undo/CCloneSelectionCommand.cpp b/src/Editor/Undo/CCloneSelectionCommand.cpp index deab49c4..094d4261 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 (uint32 iLink = 0; iLink < pInst->NumLinks(ELinkType::Outgoing); iLink++) + for (size_t iLink = 0; iLink < pInst->NumLinks(ELinkType::Outgoing); iLink++) { CScriptNode *pNode = mpEditor->Scene()->NodeForInstance(pInst->Link(ELinkType::Outgoing, iLink)->Receiver()); @@ -85,7 +85,7 @@ void CCloneSelectionCommand::redo() CScriptObject *pSrc = static_cast(ToClone[iNode])->Instance(); CScriptObject *pClone = static_cast(ClonedNodes[iNode])->Instance(); - for (uint32 iLink = 0; iLink < pSrc->NumLinks(ELinkType::Outgoing); iLink++) + for (size_t iLink = 0; iLink < pSrc->NumLinks(ELinkType::Outgoing); iLink++) { CLink *pSrcLink = pSrc->Link(ELinkType::Outgoing, iLink); diff --git a/src/Editor/Undo/CDeleteSelectionCommand.cpp b/src/Editor/Undo/CDeleteSelectionCommand.cpp index 970983a6..ca68a124 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 (uint32 iType = 0; iType < 2; iType++) + for (size_t iType = 0; iType < 2; iType++) { ELinkType Type = (iType == 0 ? ELinkType::Outgoing : ELinkType::Incoming); - for (uint32 iLink = 0; iLink < pInst->NumLinks(Type); iLink++) + for (size_t iLink = 0; iLink < pInst->NumLinks(Type); iLink++) { CLink *pLink = pInst->Link(Type, iLink); diff --git a/src/Editor/Undo/CPasteNodesCommand.cpp b/src/Editor/Undo/CPasteNodesCommand.cpp index 11f37262..00285ca5 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 (uint32 iLink = 0; iLink < pInstance->NumLinks(ELinkType::Outgoing); iLink++) + for (size_t iLink = 0; iLink < pInstance->NumLinks(ELinkType::Outgoing); iLink++) { CLink *pLink = pInstance->Link(ELinkType::Outgoing, iLink); int Index = mpMimeData->IndexOfInstanceID(pLink->ReceiverID()); @@ -103,7 +103,6 @@ void CPasteNodesCommand::redo() CScriptObject *pNewTarget = static_cast(PastedNodes[Index])->Instance(); pLink->SetReceiver(pNewTarget->InstanceID()); } - else if (mpMimeData->AreaID() != pArea->ID() || pArea->InstanceByID(pLink->ReceiverID()) == nullptr) { CScriptObject *pSender = pLink->Sender(); @@ -114,7 +113,6 @@ void CPasteNodesCommand::redo() delete pLink; iLink--; } - else { CScriptObject *pReceiver = pLink->Receiver(); diff --git a/src/Editor/WorldEditor/CLinkModel.cpp b/src/Editor/WorldEditor/CLinkModel.cpp index f2972c2e..971aa19d 100644 --- a/src/Editor/WorldEditor/CLinkModel.cpp +++ b/src/Editor/WorldEditor/CLinkModel.cpp @@ -25,9 +25,9 @@ void CLinkModel::SetConnectionType(ELinkType Type) int CLinkModel::rowCount(const QModelIndex&) const { if (mpObject) - return mpObject->NumLinks(mType); + return static_cast(mpObject->NumLinks(mType)); - else return 0; + return 0; } int CLinkModel::columnCount(const QModelIndex& /*rkParent*/) const