Exemplo n.º 1
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pError - 
//-----------------------------------------------------------------------------
static void FixDuplicateKeys(MapError *pError)
{
	// find duplicate keys in keyvalues and kill them
	CMapEntity *pEntity = (CMapEntity *)pError->pObjects[0];
	int nKeyValues = pEntity->GetKeyValueCount();

DoAgain:

	for (int i = 0; i < nKeyValues; i++)
	{
		for (int j = 0; j < nKeyValues; j++)
		{
			if (i == j)
			{
				continue;
			}

			if (!strcmpi(pEntity->GetKey(i), pEntity->GetKey(j)))
			{
				pEntity->RemoveKey(i);
				//--kv.nkv;
				goto DoAgain;
			}
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pObject - 
//			FindObject - 
// Output : Returns true if the object matches the search criteria, false if not.
//-----------------------------------------------------------------------------
bool FindCheck(CMapClass *pObject, FindObject_t &FindObject)
{
	CMapEntity *pEntity = dynamic_cast <CMapEntity *>(pObject);
	if (!pEntity)
	{
		return false;
	}

	if (FindObject.bVisiblesOnly && !pObject->IsVisible())
	{
		return false;
	}

	//
	// Search keyvalues.
	//
	int nKeyCount = pEntity->GetKeyValueCount();
	for (int i = 0; i < nKeyCount; i++)
	{
		const char *pszValue = pEntity->GetKeyValue(i);
		if (pszValue && MatchString(pszValue, FindObject))
		{
			return true;
		}
	}

	//
	// Search connections.
	//
	POSITION pos = pEntity->Connections_GetHeadPosition();
	while (pos)
	{
		CEntityConnection *pConn = pEntity->Connections_GetNext(pos);
		if (pConn)
		{
			if (MatchString(pConn->GetTargetName(), FindObject) ||
				MatchString(pConn->GetParam(), FindObject))
			{
				return true;
			}
		}
	}

	return false;
}
Exemplo n.º 3
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pError - 
//-----------------------------------------------------------------------------
static void FixUnusedKeyvalues(MapError *pError)
{
	CMapEntity *pEntity = (CMapEntity*) pError->pObjects[0];

	GDclass *pClass = pEntity->GetClass();
	if (!pClass)
	{
		return;
	}

	int nKeyValues = pEntity->GetKeyValueCount();
	for (int i = nKeyValues - 1; i >= 0; i--)
	{
		if (pClass->VarForName(pEntity->GetKey(i)) == NULL)
		{
			pEntity->DeleteKeyValue(pEntity->GetKey(i));
		}
	}
}