Example #1
0
long SensorSystem::scanMover (Mover* mover) {

	//---------------------------------------------------------------------
	// For now, I DO NOT return the largest contact. This should be
	// okay, since it'll just get caught during the next normal update next
	// frame.

	if (!enabled())
		return(0);

	if (mover->getExists() && (mover->getTeamId() != owner->getTeamId())) {
		long contactStatus = calcContactStatus(mover);
		if (isContact(mover)) 
		{
			if (contactStatus == CONTACT_NONE)
				removeContact(mover);
			else
			{
				modifyContact(mover, contactStatus == CONTACT_VISUAL ? true : false);
				//getLargest(currentLargest,mover,contactStatus);
			}
		}
		else 
		{
			if (contactStatus != CONTACT_NONE) 
			{
				addContact(mover, contactStatus == CONTACT_VISUAL ? true : false);
				//getLargest(currentLargest,mover,contactStatus);
				totalContacts++;
			}
		}
	}
	return(0);
}
Example #2
0
//---------------------------------------------------------------------------
long SensorSystem::scanBattlefield (void) 
{
	//NOW returns size of largest contact!
	long currentLargest = -1;
	
	if (!owner)
		Fatal(0, " Sensor has no owner ");

	if (!master)
		Fatal(0, " Sensor has no master ");

	if ((masterIndex == -1) || (range < 0.0))
		return(0);

	long numNewContacts = 0;

	long numMovers = ObjectManager->getNumMovers();
	for (long i = 0; i < numMovers; i++) 
	{
		MoverPtr mover = (MoverPtr)ObjectManager->getMover(i);
		if (mover->getExists() && (mover->getTeamId() != owner->getTeamId())) 
		{
			long contactStatus = calcContactStatus(mover);
			if (isContact(mover)) 
			{
				if (contactStatus == CONTACT_NONE)
					removeContact(mover);
				else
				{
					modifyContact(mover, contactStatus == CONTACT_VISUAL ? true : false);
					getLargest(currentLargest,mover,contactStatus);
				}
			}
			else 
			{
				if (contactStatus != CONTACT_NONE) 
				{
					addContact(mover, contactStatus == CONTACT_VISUAL ? true : false);
					getLargest(currentLargest,mover,contactStatus);
					numNewContacts++;
				}
			}
		}
	}

	totalContacts += numNewContacts;
	
	return(currentLargest);
}
Example #3
0
void SensorSystem::updateContacts (void) {

	if ((masterIndex == -1) || (range < 0.0))
		return;

	if (!enabled()) {
		clearContacts();
		return;
	}

	//---------------------------------------------------------------------
	// If we've already scanned this frame, don't bother updating contacts.
	// Otherwise, update contacts...
	if (scenarioTime == lastScanUpdate)
		return;

	long i = 0;
	while (i < numContacts) 
	{
		MoverPtr contact = (MoverPtr)ObjectManager->get(contacts[i] & 0x7FFF);
		long contactStatus = calcContactStatus(contact);
		if (contactStatus == CONTACT_NONE)
			removeContact(i);
		else 
		{
			contacts[i] =  contact->getHandle();
			if (contactStatus == CONTACT_VISUAL)
				contacts[i] |= 0x8000;
			modifyContact(contact, contactStatus == CONTACT_VISUAL);
			
/*			if (teamContactStatus < contactStatus) {
				//--------------------------------------------------
				// Better sensor info, so update the team sensors...
				contactInfo->contactStatus[owner->getTeamId()] = contactStatus;
				contactInfo->teamSpotter[owner->getTeamId()] = (unsigned char)owner->getHandle();
			}
*/			i++;
		}
	}
}
int main ()
{
	int menuOption;
	contactList contactList; 
    char name[40];
    char phone_number[9];
	char *email;
	char *mail;
	contactList.head=NULL;
  do
  {
    printf("(1) Find Contact by name\n");
    printf("(2) Find Contact by phone number\n");
    printf("(3) Show all contacts\n");
    printf("(4) Modify Contact information\n");
    printf("(5) Add contact\n");
    printf("(6) Delete contact\n");
    printf("(7) Load contacts from file\n");
    printf("(8) Quit\n");
    scanf("%d", &menuOption);
    fflush(stdin);
    switch (menuOption)
    {
        case 1: 
            printf("Enter name: \n");
            scanf(" %[^\n]s", name);
            findName(&contactList,  name);
            break;
        case 2:
			printf("Enter phone number: \n");
            scanf("%s", phone_number);
            findNumber(&contactList,  phone_number);
			break;
        case 3: 
			showAllContact(&contactList);
			break;
        case 4: 
			printf("Enter name: \n");
            scanf(" %[^\n]s", name);
			modifyContact(&contactList, name);
			break;
        case 5: 
            printf("Please enter name: ");
            scanf(" %[^\n]s", name);
            printf("Please enter phone number: ");
            scanf(" %[^\n]s", phone_number);
            printf("Please enter email address: ");
            email = getAddress();
			fflush(stdin);
            printf("Please enter mail address: ");
            mail = getAddress();
			fflush(stdin);
            addContact(&contactList, name, phone_number, email, mail);
            break;
        case 6: 
			printf("Enter name: \n");
            scanf(" %[^\n]s", name);
			deleteContact(&contactList,name);
			break;
        case 7: 
			loadFile(&contactList);
			break;
        case 8: 
			printf("Bye Bye!");
			break;
	}
  }while(menuOption != 8);
	

    return 0;
}