//-----------------------------------------------------------------------------
// Purpose: Replaces any missing textures with the default texture.
// Input  : pError - 
//-----------------------------------------------------------------------------
static void FixInvalidTexture(MapError *pError)
{
	CMapSolid *pSolid = (CMapSolid *)pError->pObjects[0];

	int nFaces = pSolid->GetFaceCount();
	for (int i = 0; i < nFaces; i++)
	{
		CMapFace *pFace = pSolid->GetFace(i);
		if (pFace != NULL)
		{
			IEditorTexture *pTex = pFace->GetTexture();
			if (pTex != NULL)
			{
				if (pTex->IsDummy())
				{
					pFace->SetTexture(GetDefaultTextureName());
				}
			}
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pSolid - 
//			*pList - 
// Output : static BOOL
//-----------------------------------------------------------------------------
static BOOL AddUsedTextures(CMapSolid *pSolid, CUsedTextureList *pList)
{
	if (!pSolid->IsVisible())
		return TRUE;

	int nFaces = pSolid->GetFaceCount();
	IEditorTexture *pLastTex = NULL;
	int nLastElement = 0;

	for (int i = 0; i < nFaces; i++)
	{
		CMapFace *pFace = pSolid->GetFace(i);

		UsedTexture_t Tex;
		Tex.pTex = pFace->GetTexture();
		Tex.nUsageCount = 0;

		if (Tex.pTex != NULL)
		{
			if (Tex.pTex != pLastTex)
			{
				int nElement = pList->Find(Tex.pTex);
				if (nElement == -1)
				{
					nElement = pList->AddToTail(Tex);
				}

				nLastElement = nElement;
				pLastTex = Tex.pTex;
			}

			pList->Element(nLastElement).nUsageCount++;
		}
	}

	return TRUE;
}