示例#1
0
void CObjectInfoDlg::OnChangeACE() 
{
	int acenum = m_AceType.GetCurSel();
	int acetype = 0;
	int table = 0;

	if (acenum == 0) table = 0;
	if (acenum == 1) table = 1;
	if (acenum == 2) table = 2;

	m_AceList.DeleteAllItems();

	int numaces;
	OINFO *oInfo;
	POSITION pos = g_dlls->GetStartPosition();
	DWORD nKey;

	// Find the DLL
	while (pos != NULL) 
	{
		g_dlls->GetNextAssoc(pos, nKey, oInfo);

		// Got it
		if (oInfo->extName == objname)
		{
			// Get the number of table entries
			numaces = oInfo->GetTable(table)->size();

			// Loop each ACE entry
			for (int i = 0; i < numaces; i++)
			{	
				// Get the pointer to current ACE
				ACESEntry2* pACE = oInfo->GetACEEntry(table, i);

				if(pACE == NULL || pACE->aceListName == "")
					continue; // Ignore null entries

				// Add name
				// Check for * (new)
				int item = -1;

				if (pACE->aceListName.Left(1) == "*")
					item = m_AceList.InsertItem(i, pACE->aceListName.Right(pACE->aceListName.GetLength() - 1), 0);
				else
					item = m_AceList.InsertItem(i, pACE->aceListName, 0);

				// Add number of parameters
				CString numberOfParameters;
				numberOfParameters.Format("%d", pACE->params.size());
				m_AceList.SetItemText(item, 1, numberOfParameters);

				// Add description
				m_AceList.SetItemText(item, 2, pACE->aceDisplayText);
			}

			break;
		}
	}
}
bool CTypeChecker::ObjectExpressionExists(CString objName, CString expName)
{
	objName.MakeLower();
	expName.MakeLower();

	CString movementName;
	ParseBehaviorExpression(objName, objName, movementName);

	CObjType* oT = LookupObjectType(objName, objMap);
	int DLLIndex;

	// Couldn't find object type: try family
	if (oT == NULL) {
		list<Family>::iterator f = find(pApp->families.begin(), pApp->families.end(), objName);

		// Not found
		if (f == pApp->families.end() || !f->is_in_use)
			return false;
		else {
			DLLIndex = f->DLLIndex;
			oT = pApp->FindObjTypeFromNumber(f->identifier);
		}
	}
	else DLLIndex = oT->DLLIndex;

	// Behavior under object: objName[movementName]
	if (movementName != "") {
		CBehavior* m = LookupBehavior(oT, movementName);
		if (m == NULL) return false;

		OINFO* oInfo = GetOINFO(m->BehaviorDLLIndex);

		int Count = oInfo->GetTable(2)->size();

		for (int i = 0; i < Count; i++) {
			CString Exp = oInfo->GetACEEntry(2, i)->aceDisplayText;
			Exp.MakeLower();
			if (Exp == expName)
				return true;
		}

		return false;
	}

	OINFO* oInfo = GetOINFO(DLLIndex);

	if (oInfo == NULL)
		return false;

	// get count
	int Count = oInfo->GetTable(2)->size();

	for (int i = 0; i < Count; i++)
	{
		CString Exp = oInfo->GetACEEntry(2, i)->aceDisplayText;
		Exp.MakeLower();
		if (Exp == expName)
			return true;
	}

	// Expression name not found: allow if OF_UNDEFINEDEXPRESSIONS set
	return (oInfo->ideFlags & OF_UNDEFINEDEXPRESSIONS)!=0;
}