Esempio n. 1
0
int compare(Titem item1 , Titem item2) {
    if(compare_times(&item1, &item2)==1)
        return 1;
    else if(compare_times(&item1, &item2)==0)
        return 0;
    else
        return -1;
}
Esempio n. 2
0
struct time  get_largest_time(struct time times[10])
{
    int i;
    struct time largest = times[0];

    for(i=1; i <10; i ++)
    {
        //  check whether element is bigger than largest
        if ( compare_times(times[i], largest) > 0 )
              largest = times[i];
    }

    return largest;
}
Esempio n. 3
0
struct node* lookup(struct node *temp) {
	struct node *temp1;

        temp1 = head;
	while (temp1) {
		if (temp1->txid == temp->txid) {
			bool query_same = false; /*Query Should be Same*/
			bool checksum_zero = false;  /*One of the packets checksum shoul be 0 (then it is spoofed)*/
			bool ans_different = false; /*Answers should be completely different*/
			bool time_diff = false;   /*Time diff should be inside the threshold value*/
			bool complex_stuff = false;
	
			query_same = compare_queries(temp1->question, temp->question);
		
			checksum_zero = compare_checksum(temp1->uh_sum, temp->uh_sum);

//			ans_different = compare_answers(temp1->answers, temp1->ans_count, 
//							temp->answers, temp->ans_count);
	
			time_diff = compare_times(&(temp->tv), &(temp1->tv));	/*First arg is later time*/

			if (ans_different) {
				if (checksum_zero)
					complex_stuff = true;
			} else {		/*I'm really crazy here*/
				if (checksum_zero)
                                        complex_stuff = true;
			}
			
			if (query_same && complex_stuff && time_diff)
				break;
		}
		temp1 = temp1->next;
	}

	return temp1;
}
int compare(Titem item1 , Titem item2) {
    return compare_times(item1, item2);
}
Esempio n. 5
0
void android_main(struct android_app* state) {
	LOGD("android_main", "android_main() called");

    engine e;
    app_dummy();
    memset(&e, 0, sizeof(engine));
    state->userData = &e;
    state->onAppCmd = engine_handle_cmd;
    state->onInputEvent = engine_handle_input;
    e.app = state;

	int i = 0;
	int animating = FALSE;

	while (1) {
		int ident, events;
		struct android_poll_source* source;

		while ((ident = ALooper_pollAll(0, NULL, &events, (void**) &source)) >= 0) {

			LOGD("call_order", "while ((ident=ALooper_pollAll...");
			LOGD("ALooper_pollAll", "ALooper_pollAll");
			if (source != NULL) {
				source->process(state, source);
			}
			if (state->destroyRequested != 0) {
				return;
			}
		}

		if (e.animating) {

			if(wake_from_paused)	{
				init_sles_gain_focus(state);
				wake_from_paused = FALSE;
			}

			calc_frame_delta_time();
			update_elapsed_time();
//			calc_frame_rate();
//		    LOGD("android_main", "frame_delta %d", frame_delta);
			draw_frame();

			if(!sles_init_called && elapsed_time > (1*SEC_IN_US)) {
				create_init_sles_thread(state);
				sles_init_called = TRUE;
			    LOGD("android_main", "sles_init_called = TRUE");
			}

			if(!splash_fading_in && elapsed_time > (1*SEC_IN_US	)) {
				splash_fading_in = TRUE;
				screens[0].is_showing = TRUE;
				LOGD("android_main", "splash_fading_in = TRUE");
			}
			if(!splash_bg_fading_in && elapsed_time > (3*SEC_IN_US)) { //3
				splash_bg_fading_in = TRUE;
				screens[1].is_showing = TRUE;
				LOGD("android_main", "splash_bg_fading_in = TRUE");
			}

			if(sles_init_finished && splash_bg_fading_in && screens[1].alpha == 1.0) {
				sles_init_finished = FALSE;
				assign_time(&splash_fadeout_time);
				LOGD("android_main", "sles_init_finished");
			}

			if(!splash_bg_fading_out && compare_times(splash_fadeout_time, (1*SEC_IN_US))) {
				splash_bg_fading_out = TRUE;
				screens[1].fading_in = FALSE;
				screens[1].fading_out = TRUE;
				LOGD("android_main", "splash_bg_fading_out = TRUE");
			}

			if(!splash_fading_out && compare_times(splash_fadeout_time, (4*SEC_IN_US))) {
				splash_fading_out = TRUE;
				screens[0].fading_in = FALSE;
				screens[0].fading_out = TRUE;
				LOGD("android_main", "splash_fading_out = TRUE");
			}

			if(!show_gameplay && compare_times(splash_fadeout_time, (6*SEC_IN_US))) {
				show_gameplay = TRUE;
				assign_time(&touch_enable_time);
				start_loop();
				init_control_loop();
				LOGD("android_main", "show_gameplay = TRUE");
			}

			if(!touch_enabled && compare_times(touch_enable_time, (2*SEC_IN_US))) {
				touch_enabled = TRUE;
				LOGD("android_main", "touch_enabled = TRUE");
			}

			if (show_gameplay && buttons_activated) {
				if (compare_times(buttons_activated_time, INTERACTIVE_TTL)) {
					if (!all_buttons_busy_fading) {
						buttons[2].fading_out = TRUE;
					}
				}
			}

		}
	}
}
Esempio n. 6
0
/*
 * Displays result lists.
 * Copies the array of entrants, then performs bubble search
 * on the copied array, to order entrants by total time.
 * All entrants that have not completed the race yet
 * are listed at the bottom of the list.
 */
void display_results(){
    printf("\nFor which course? \n");
    char c;
    scanf(" %c", &c);
    if(TOTAL_ENTRANTS!=count_entrants("CC")){
        printf("WARNING: Some entrants are still on track.\n");
    }
    
    int i = 0, count = 0;
    for(i; i<TOTAL_ENTRANTS;i++){
        if(entrants[i].course->id==c) count++;
    }
    
    ENTRANT ents[count];
    i = 0;
    int j = 0;
    for(i;i<TOTAL_ENTRANTS;i++){
        if(entrants[i].course->id==c){
            ents[j] = entrants[i];
            j++;
        }
    }
    
    //Bubble sort.
    int swapped = 0;
    do{
        i =0;
        swapped = 0;
        for(i; i<count-1; i++){
            if(compare_times(&ents[i].total_time, 
                    &ents[i+1].total_time)<=0){
                        continue;
            }
            else{ //if items are in wrong order, they are swapped 
                ENTRANT temp = ents[i];
                ents[i] = ents[i+1];
                ents[i+1] = temp;
                swapped = 1;
            }
        }
        
    }while(swapped!=0); // ends when not a single swap occurred
    
    printf("Place  (Number) Name               "
            "                           Time\n");
    printf("==================================="
            "===============================\n");

    i = 0;
    for(i;i<count;i++){
        printf("%d", i+1);
        if(i+1<10) printf("      ");
        else if(i+1<100) printf("     ");
        else printf("    ");
        printf("(%02d) %s", ents[i].number, ents[i].name);
        int n = 0;
        //printing space between entrants name and time
        //so that everything is formated neatly
        for(n; n<50-strlen(ents[i].name); n++) printf(" ");
        if(ents[i].total_time.hours==99){
            //no time displayed if entrant still on track
            printf("-:--\n"); 
        }else display_time(ents[i].total_time);
    }
}