CScriptObject: Make use of size_t where applicable

Plays with standard containers nicer.
This commit is contained in:
Lioncash 2020-06-18 07:16:41 -04:00
parent 0cda26b105
commit 6f1d6a8649
13 changed files with 79 additions and 75 deletions

View File

@ -195,8 +195,8 @@ void CScriptCooker::WriteProperty(IOutputStream& rOut, IProperty* pProperty, voi
rOut.WriteShort((uint16) PropertiesToWrite.size()); rOut.WriteShort((uint16) PropertiesToWrite.size());
} }
for (uint32 PropertyIdx = 0; PropertyIdx < PropertiesToWrite.size(); PropertyIdx++) for (auto* property : PropertiesToWrite)
WriteProperty(rOut, PropertiesToWrite[PropertyIdx], pData, pStruct->IsAtomic()); WriteProperty(rOut, property, pData, pStruct->IsAtomic());
break; 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 // 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 // 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(); const uint32 ObjectType = pInstance->ObjectTypeID();
IsPrime1 ? rOut.WriteByte((uint8) ObjectType) : rOut.WriteLong(ObjectType); IsPrime1 ? rOut.WriteByte(static_cast<uint8>(ObjectType)) : rOut.WriteLong(ObjectType);
uint32 SizeOffset = rOut.Tell(); const uint32 SizeOffset = rOut.Tell();
IsPrime1 ? rOut.WriteLong(0) : rOut.WriteShort(0); IsPrime1 ? rOut.WriteLong(0) : rOut.WriteShort(0);
uint32 InstanceStart = rOut.Tell(); const uint32 InstanceStart = rOut.Tell();
uint32 InstanceID = (pInstance->Layer()->AreaIndex() << 26) | pInstance->InstanceID(); const uint32 InstanceID = (pInstance->Layer()->AreaIndex() << 26) | pInstance->InstanceID();
rOut.WriteLong(InstanceID); rOut.WriteLong(InstanceID);
uint32 NumLinks = pInstance->NumLinks(ELinkType::Outgoing); const size_t NumLinks = pInstance->NumLinks(ELinkType::Outgoing);
IsPrime1 ? rOut.WriteLong(NumLinks) : rOut.WriteShort((uint16) NumLinks); IsPrime1 ? rOut.WriteLong(static_cast<int32>(NumLinks)) : rOut.WriteShort(static_cast<uint16>(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->State());
rOut.WriteLong(pLink->Message()); rOut.WriteLong(pLink->Message());
rOut.WriteLong(pLink->ReceiverID()); rOut.WriteLong(pLink->ReceiverID());
} }
WriteProperty(rOut, pInstance->Template()->Properties(), pInstance->PropertyData(), false); WriteProperty(rOut, pInstance->Template()->Properties(), pInstance->PropertyData(), false);
uint32 InstanceEnd = rOut.Tell(); const uint32 InstanceEnd = rOut.Tell();
rOut.Seek(SizeOffset, SEEK_SET); rOut.Seek(SizeOffset, SEEK_SET);
uint32 Size = InstanceEnd - InstanceStart; const uint32 Size = InstanceEnd - InstanceStart;
IsPrime1 ? rOut.WriteLong(Size) : rOut.WriteShort((uint16) Size); IsPrime1 ? rOut.WriteLong(Size) : rOut.WriteShort(static_cast<uint16>(Size));
rOut.Seek(InstanceEnd, SEEK_SET); rOut.Seek(InstanceEnd, SEEK_SET);
} }
@ -269,7 +269,7 @@ void CScriptCooker::WriteLayer(IOutputStream& rOut, CScriptLayer *pLayer)
{ {
ASSERT(pLayer->Area()->Game() == mGame); 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 InstanceCountOffset = rOut.Tell();
uint32 NumWrittenInstances = 0; 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 // GenericCreature instances in DKCR always write to both SCLY and SCGN
if (mGame == EGame::DKCReturns && pInstance->ObjectTypeID() == FOURCC('GCTR')) if (mGame == EGame::DKCReturns && pInstance->ObjectTypeID() == FOURCC('GCTR'))
{
mGeneratedObjects.push_back(pInstance); mGeneratedObjects.push_back(pInstance);
}
// Instances receiving a Generate/Activate message (MP2) or a // Instances receiving a Generate/Activate message (MP2) or a
// Generate/Attach message (MP3+) should be written to SCGN, not SCLY // Generate/Attach message (MP3+) should be written to SCGN, not SCLY
else 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) if (mGame <= EGame::Echoes)
{ {
@ -304,7 +305,6 @@ void CScriptCooker::WriteLayer(IOutputStream& rOut, CScriptLayer *pLayer)
break; break;
} }
} }
else else
{ {
if (pLink->Message() == FOURCC('ATCH')) if (pLink->Message() == FOURCC('ATCH'))
@ -341,6 +341,6 @@ void CScriptCooker::WriteGeneratedLayer(IOutputStream& rOut)
rOut.WriteByte(1); // Version rOut.WriteByte(1); // Version
rOut.WriteLong(mGeneratedObjects.size()); rOut.WriteLong(mGeneratedObjects.size());
for (uint32 ObjectIdx = 0; ObjectIdx < mGeneratedObjects.size(); ObjectIdx++) for (auto* object : mGeneratedObjects)
WriteInstance(rOut, mGeneratedObjects[ObjectIdx]); WriteInstance(rOut, object);
} }

View File

@ -688,7 +688,7 @@ void CAreaLoader::SetUpObjects(CScriptLayer *pGenLayer)
CScriptObject *pInst = Iter->second; CScriptObject *pInst = Iter->second;
// Store outgoing connections // 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); CLink *pLink = pInst->Link(ELinkType::Outgoing, iCon);
mConnectionMap[pLink->ReceiverID()].push_back(pLink); mConnectionMap[pLink->ReceiverID()].push_back(pLink);

View File

@ -89,8 +89,8 @@ public:
uint32 Version() const { return mVersion; } uint32 Version() const { return mVersion; }
uint32 ObjectTypeID() const { return mpTemplate->ObjectID(); } uint32 ObjectTypeID() const { return mpTemplate->ObjectID(); }
CInstanceID InstanceID() const { return mInstanceID; } CInstanceID InstanceID() const { return mInstanceID; }
uint32 NumLinks(ELinkType Type) const { return (Type == ELinkType::Incoming ? mInLinks.size() : mOutLinks.size()); } size_t 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]); } CLink* Link(ELinkType Type, size_t Index) const { return (Type == ELinkType::Incoming ? mInLinks[Index] : mOutLinks[Index]); }
void* PropertyData() const { return (void*) mPropertyData.data(); } void* PropertyData() const { return (void*) mPropertyData.data(); }
CVector3f Position() const { return mPosition.IsValid() ? mPosition.Get() : CVector3f::Zero(); } CVector3f Position() const { return mPosition.IsValid() ? mPosition.Get() : CVector3f::Zero(); }

View File

@ -267,19 +267,19 @@ void CScriptNode::DrawSelection()
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity; CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
CGraphics::UpdateMVPBlock(); 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. // Don't draw in links if the other object is selected.
CLink *pLink = mpInstance->Link(ELinkType::Incoming, iIn); const CLink *pLink = mpInstance->Link(ELinkType::Incoming, iIn);
CScriptNode *pLinkNode = mpScene->NodeForInstanceID(pLink->SenderID()); const CScriptNode *pLinkNode = mpScene->NodeForInstanceID(pLink->SenderID());
if (pLinkNode && !pLinkNode->IsSelected()) if (pLinkNode && !pLinkNode->IsSelected())
CDrawUtil::DrawLine(CenterPoint(), pLinkNode->CenterPoint(), CColor::TransparentRed()); 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); const CLink *pLink = mpInstance->Link(ELinkType::Outgoing, iOut);
CScriptNode *pLinkNode = mpScene->NodeForInstanceID(pLink->ReceiverID()); const CScriptNode *pLinkNode = mpScene->NodeForInstanceID(pLink->ReceiverID());
if (pLinkNode) if (pLinkNode)
CDrawUtil::DrawLine(CenterPoint(), pLinkNode->CenterPoint(), CColor::TransparentGreen()); 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. // 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. // 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 // 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) 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); CScriptNode *pNode = mpScene->NodeForInstanceID(LinkedID);
pNode->GeneratePosition(); pNode->GeneratePosition();
mPosition = pNode->AbsolutePosition(); mPosition = pNode->AbsolutePosition();
@ -594,13 +594,12 @@ void CScriptNode::GeneratePosition()
mPosition.Z += (AABox().Size().Z / 2.f); mPosition.Z += (AABox().Size().Z / 2.f);
mPosition.Z += 2.f; mPosition.Z += 2.f;
} }
// For two or more links, average out the position of the connected objects. // For two or more links, average out the position of the connected objects.
else if (NumLinks >= 2) else if (NumLinks >= 2)
{ {
CVector3f NewPos = CVector3f::Zero(); 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()); 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()); 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<float>(NumLinks);
mPosition.X += 2.f; mPosition.X += 2.f;
} }

View File

@ -13,8 +13,8 @@ void CSplinePathExtra::PropertyModified(IProperty* pProperty)
{ {
if (pProperty == mPathColor.Property()) if (pProperty == mPathColor.Property())
{ {
for (auto it = mWaypoints.begin(); it != mWaypoints.end(); it++) for (auto* extra : mWaypoints)
(*it)->CheckColor(); extra->CheckColor();
} }
} }
@ -25,7 +25,7 @@ void CSplinePathExtra::PostLoad()
void CSplinePathExtra::FindAttachedWaypoints(std::set<CWaypointExtra*>& rChecked, CWaypointExtra* pWaypoint) void CSplinePathExtra::FindAttachedWaypoints(std::set<CWaypointExtra*>& rChecked, CWaypointExtra* pWaypoint)
{ {
if (rChecked.find(pWaypoint) != rChecked.end()) if (rChecked.find(pWaypoint) != rChecked.cend())
return; return;
rChecked.insert(pWaypoint); rChecked.insert(pWaypoint);
@ -35,8 +35,8 @@ void CSplinePathExtra::FindAttachedWaypoints(std::set<CWaypointExtra*>& rChecked
std::list<CWaypointExtra*> Attached; std::list<CWaypointExtra*> Attached;
pWaypoint->GetLinkedWaypoints(Attached); pWaypoint->GetLinkedWaypoints(Attached);
for (auto it = Attached.begin(); it != Attached.end(); it++) for (auto* extra : Attached)
FindAttachedWaypoints(rChecked, *it); FindAttachedWaypoints(rChecked, extra);
} }
void CSplinePathExtra::AddWaypoints() void CSplinePathExtra::AddWaypoints()
@ -46,12 +46,12 @@ void CSplinePathExtra::AddWaypoints()
std::set<CWaypointExtra*> CheckedWaypoints; std::set<CWaypointExtra*> 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 if ((pLink->State() == FOURCC('IS00') && pLink->Message() == FOURCC('ATCH')) || // InternalState00/Attach
(pLink->State() == FOURCC('MOTP') && pLink->Message() == FOURCC('ATCH')) ) // MotionPath/Attach (pLink->State() == FOURCC('MOTP') && pLink->Message() == FOURCC('ATCH'))) // MotionPath/Attach
{ {
CScriptNode* pNode = mpScene->NodeForInstanceID(pLink->ReceiverID()); CScriptNode* pNode = mpScene->NodeForInstanceID(pLink->ReceiverID());
@ -66,7 +66,7 @@ void CSplinePathExtra::AddWaypoints()
void CSplinePathExtra::RemoveWaypoint(CWaypointExtra *pWaypoint) 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) if (*it == pWaypoint)
{ {
@ -78,8 +78,8 @@ void CSplinePathExtra::RemoveWaypoint(CWaypointExtra *pWaypoint)
void CSplinePathExtra::ClearWaypoints() void CSplinePathExtra::ClearWaypoints()
{ {
for (auto it = mWaypoints.begin(); it != mWaypoints.end(); it++) for (auto* extra : mWaypoints)
(*it)->RemoveFromSplinePath(this); extra->RemoveFromSplinePath(this);
mWaypoints.clear(); mWaypoints.clear();
} }

View File

@ -60,7 +60,7 @@ void CWaypointExtra::AddToSplinePath(CSplinePathExtra *pPath)
void CWaypointExtra::RemoveFromSplinePath(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) if (*it == pPath)
{ {
@ -75,9 +75,9 @@ void CWaypointExtra::BuildLinks()
{ {
mLinks.clear(); 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)) if (IsPathLink(pLink))
{ {
@ -94,26 +94,33 @@ void CWaypointExtra::BuildLinks()
mLinksBuilt = true; mLinksBuilt = true;
} }
bool CWaypointExtra::IsPathLink(CLink *pLink) bool CWaypointExtra::IsPathLink(const CLink *pLink) const
{ {
bool Valid = false; bool Valid = false;
if (pLink->State() < 0xFF) 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 else
{ {
CFourCC State(pLink->State()); const CFourCC State(pLink->State());
CFourCC Message(pLink->Message()); const 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) // 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) if (Valid)
{ {
CScriptNode *pNode = mpScene->NodeForInstanceID(pLink->ReceiverID()); const CScriptNode *pNode = mpScene->NodeForInstanceID(pLink->ReceiverID());
if (pNode) if (pNode)
return pNode->Instance()->ObjectTypeID() == mpInstance->ObjectTypeID(); return pNode->Instance()->ObjectTypeID() == mpInstance->ObjectTypeID();

View File

@ -26,7 +26,7 @@ public:
void AddToSplinePath(CSplinePathExtra *pPath); void AddToSplinePath(CSplinePathExtra *pPath);
void RemoveFromSplinePath(CSplinePathExtra *pPath); void RemoveFromSplinePath(CSplinePathExtra *pPath);
void BuildLinks(); void BuildLinks();
bool IsPathLink(CLink *pLink); bool IsPathLink(const CLink *pLink) const;
void GetLinkedWaypoints(std::list<CWaypointExtra*>& rOut); void GetLinkedWaypoints(std::list<CWaypointExtra*>& rOut);
void OnTransformed(); void OnTransformed();

View File

@ -252,7 +252,7 @@ void CSceneViewport::FindConnectedObjects(uint32 InstanceID, bool SearchOutgoing
if (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); CLink *pLink = pInst->Link(ELinkType::Outgoing, iLink);
@ -263,7 +263,7 @@ void CSceneViewport::FindConnectedObjects(uint32 InstanceID, bool SearchOutgoing
if (SearchIncoming) 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); CLink *pLink = pInst->Link(ELinkType::Incoming, iLink);

View File

@ -16,7 +16,7 @@ void CAddLinkCommand::undo()
{ {
CScriptObject *pSender = mLink.Sender(); CScriptObject *pSender = mLink.Sender();
CScriptObject *pReceiver = mLink.Receiver(); 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); CLink *pLink = pSender->Link(ELinkType::Outgoing, SenderIndex);
pSender->RemoveLink(ELinkType::Outgoing, pLink); pSender->RemoveLink(ELinkType::Outgoing, pLink);
pReceiver->RemoveLink(ELinkType::Incoming, pLink); pReceiver->RemoveLink(ELinkType::Incoming, pLink);
@ -28,8 +28,8 @@ void CAddLinkCommand::undo()
void CAddLinkCommand::redo() void CAddLinkCommand::redo()
{ {
CLink *pLink = new CLink(mLink); CLink *pLink = new CLink(mLink);
pLink->Sender()->AddLink(ELinkType::Outgoing, pLink, -1); pLink->Sender()->AddLink(ELinkType::Outgoing, pLink);
pLink->Receiver()->AddLink(ELinkType::Incoming, pLink, -1); pLink->Receiver()->AddLink(ELinkType::Incoming, pLink);
mpEditor->OnLinksModified(mAffectedInstances.DereferenceList()); mpEditor->OnLinksModified(mAffectedInstances.DereferenceList());
} }

View File

@ -17,7 +17,7 @@ CCloneSelectionCommand::CCloneSelectionCommand(INodeEditor *pEditor)
CScriptNode *pScript = static_cast<CScriptNode*>(*It); CScriptNode *pScript = static_cast<CScriptNode*>(*It);
CScriptObject *pInst = pScript->Instance(); 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()); CScriptNode *pNode = mpEditor->Scene()->NodeForInstance(pInst->Link(ELinkType::Outgoing, iLink)->Receiver());
@ -85,7 +85,7 @@ void CCloneSelectionCommand::redo()
CScriptObject *pSrc = static_cast<CScriptNode*>(ToClone[iNode])->Instance(); CScriptObject *pSrc = static_cast<CScriptNode*>(ToClone[iNode])->Instance();
CScriptObject *pClone = static_cast<CScriptNode*>(ClonedNodes[iNode])->Instance(); CScriptObject *pClone = static_cast<CScriptNode*>(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); CLink *pSrcLink = pSrc->Link(ELinkType::Outgoing, iLink);

View File

@ -33,11 +33,11 @@ CDeleteSelectionCommand::CDeleteSelectionCommand(CWorldEditor *pEditor, const QS
rNode.pLayer = pInst->Layer(); rNode.pLayer = pInst->Layer();
rNode.LayerIndex = pInst->LayerIndex(); 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); 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); CLink *pLink = pInst->Link(Type, iLink);

View File

@ -93,7 +93,7 @@ void CPasteNodesCommand::redo()
{ {
CScriptObject *pInstance = static_cast<CScriptNode*>(pNode)->Instance(); CScriptObject *pInstance = static_cast<CScriptNode*>(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); CLink *pLink = pInstance->Link(ELinkType::Outgoing, iLink);
int Index = mpMimeData->IndexOfInstanceID(pLink->ReceiverID()); int Index = mpMimeData->IndexOfInstanceID(pLink->ReceiverID());
@ -103,7 +103,6 @@ void CPasteNodesCommand::redo()
CScriptObject *pNewTarget = static_cast<CScriptNode*>(PastedNodes[Index])->Instance(); CScriptObject *pNewTarget = static_cast<CScriptNode*>(PastedNodes[Index])->Instance();
pLink->SetReceiver(pNewTarget->InstanceID()); pLink->SetReceiver(pNewTarget->InstanceID());
} }
else if (mpMimeData->AreaID() != pArea->ID() || pArea->InstanceByID(pLink->ReceiverID()) == nullptr) else if (mpMimeData->AreaID() != pArea->ID() || pArea->InstanceByID(pLink->ReceiverID()) == nullptr)
{ {
CScriptObject *pSender = pLink->Sender(); CScriptObject *pSender = pLink->Sender();
@ -114,7 +113,6 @@ void CPasteNodesCommand::redo()
delete pLink; delete pLink;
iLink--; iLink--;
} }
else else
{ {
CScriptObject *pReceiver = pLink->Receiver(); CScriptObject *pReceiver = pLink->Receiver();

View File

@ -25,9 +25,9 @@ void CLinkModel::SetConnectionType(ELinkType Type)
int CLinkModel::rowCount(const QModelIndex&) const int CLinkModel::rowCount(const QModelIndex&) const
{ {
if (mpObject) if (mpObject)
return mpObject->NumLinks(mType); return static_cast<int>(mpObject->NumLinks(mType));
else return 0; return 0;
} }
int CLinkModel::columnCount(const QModelIndex& /*rkParent*/) const int CLinkModel::columnCount(const QModelIndex& /*rkParent*/) const