//----------------------------------------------------------------------------- // Purpose: Checks for node entities with the same node ID. //----------------------------------------------------------------------------- static void CheckDuplicateNodeIDs(CListBox *pList, CMapWorld *pWorld) { EnumChildrenPos_t pos; CMapClass *pChild = pWorld->GetFirstDescendent(pos); while (pChild != NULL) { CMapEntity *pEntity = dynamic_cast<CMapEntity *>(pChild); if (pEntity && pEntity->IsNodeClass()) { if (FindDuplicateNodeID(pEntity, pWorld)) { AddError(pList, ErrorDuplicateNodeIDs, (DWORD)pWorld, pEntity); } } pChild = pWorld->GetNextDescendent(pos); } }
//----------------------------------------------------------------------------- // Purpose: Returns true if there is another node entity in the world with the // same node ID as the given entity. // Input : pNode - // pWorld - //----------------------------------------------------------------------------- bool FindDuplicateNodeID(CMapEntity *pNode, CMapWorld *pWorld) { EnumChildrenPos_t pos; CMapClass *pChild = pWorld->GetFirstDescendent(pos); while (pChild != NULL) { CMapEntity *pEntity = dynamic_cast<CMapEntity *>(pChild); if (pEntity && (pEntity != pNode) && pEntity->IsNodeClass()) { int nNodeID1 = pNode->GetNodeID(); int nNodeID2 = pEntity->GetNodeID(); if ((nNodeID1 != 0) && (nNodeID2 != 0) && (nNodeID1 == nNodeID2)) { return true; } } pChild = pWorld->GetNextDescendent(pos); } return false; }