//-----------------------------------------------------------------------------
// Purpose: Causes all objects in the world to update any object dependencies (pointers)
//			that they might be holding. This is a static function.
//-----------------------------------------------------------------------------
void CMapClass::UpdateAllDependencies(CMapClass *pObject)
{
	//
	// Try to locate the world object.
	//
	CMapWorld *pWorld;
	if (pObject == NULL)
	{
		CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
		if ((pDoc == NULL) || (pDoc->IsLoading()))
		{
			return;
		}
		
		pWorld = pDoc->GetMapWorld();
	}
	else
	{
		pWorld = pObject->GetWorldObject(pObject);
	}

	if (pWorld == NULL)
	{
		return;
	}

	//
	// We found the world. Tell all its children to update their dependencies
	// because of the given object.
	//
	EnumChildrenPos_t pos;
	CMapClass *pChild = pWorld->GetFirstDescendent(pos);
	while (pChild != NULL)
	{
		pChild->UpdateDependencies(pWorld, pObject);
		pChild = pWorld->GetNextDescendent(pos);
	}
}