bool E_scene_main_game::load() { if (already_loaded) return true; clearScreen(); pGlobalInfos->GUI_SetEvenListener(this); AINew(); switch (pGlobalInfos->GetAILevel()) { case 0: min_per_game=3;// Add 1 second for animation time ;) break; case 7: min_per_game=90; break; default: min_per_game=pGlobalInfos->GetAILevel()*10; break; } #ifdef DEBUG printf("AI min_per_game is set to : %ld minutes\n",min_per_game); printf("A game is set to : %ld minutes\n",moves_to_tc); #endif //TODO : check pGlobalInfos to see if the player want 2D or 3D interface chessboard = new C3DGraphicChessboard(); // 3D Chessboard chessboard->load(); SquareXSelected=-1; SquareZSelected=-1; FutureXSquare=-1; FutureZSquare=-1; pGlobalInfos->GUI_setScene(GUI_SCENE_MAIN_GAME); pGlobalInfos->GUI_displayResult(no_result); player_color = WHITE; current_color = player_color; game_mode = pGlobalInfos->GetGameMode(); game_is_over=false; promotion=false; piece_for_promotion='q'; FAILE_AI_thread=NULL; AI_comp_is_done=false; init_fade_out(); fade_out=true; fade_in=false; finish_loading(); return true; }
static gboolean clicked_cb(WebKitDOMEventTarget* target, WebKitDOMEvent* event, DomDomviewFixture* fixture) { g_assert(fixture->clicked == FALSE); fixture->clicked = TRUE; finish_loading(fixture); return FALSE; }
static gboolean clickedCallback(WebKitDOMDOMWindow* view, WebKitDOMEvent* event, DomDomviewFixture* fixture) { WebKitDOMEventTarget* target; gushort phase; g_assert(event); g_assert(WEBKIT_DOM_IS_EVENT(event)); // We should catch this in the bubbling up phase, since we are connecting to the toplevel object phase = webkit_dom_event_get_event_phase(event); g_assert_cmpint(phase, ==, 3); target = webkit_dom_event_get_current_target(event); g_assert(target == WEBKIT_DOM_EVENT_TARGET(view)); g_assert(fixture->clicked == FALSE); fixture->clicked = TRUE; finish_loading(fixture); return FALSE; }
int main() { FILE *plane_list, *storm_list, *output_log_verbose, *output_log, *output_log_read, *verification_log, *statistics_log; //int sim_length = TIME_YEAR; init_simlib(); /* Set the log list to be ordered by event time */ list_rank[LIST_LOG] = EVENT_TIME; /* Set the in-port residence time list to be ordered by plane id */ list_rank[LIST_PLANE_PORT_TIME] = PLANE_ID; list_rank[LIST_AVG_PLANES_RUNWAY] = EVENT_TIME; list_rank[LIST_AVG_PLANES_DEBERTH] = EVENT_TIME; /* Set max attributes in a list to 9, for simlog */ maxatr = 10; storm_state = STORM_OFF; taxi_state = TAXI_IDLE; int i; for (i=0; i<NUMBER_OF_BERTHS; i++) { berths[i].state = BERTH_FREE; berths[i].time_unoccupied_last = 0; berths[i].time_unoccupied = 0; berths[i].time_loading = 0; berths[i].time_loading_last = 0; berths[i].time_occupied = 0; berths[i].time_occupied_last = 0; } stats.taxi_time_idle = 0; stats.taxi_time_idle_last = 0; stats.taxi_time_travelling = 0; stats.taxi_time_travelling_last = 0; stats.taxi_time_berthing_deberthing = 0; stats.taxi_time_berthing_deberthing_last = 0; /* initialize timest */ timest(0.0, 0); /* Load the input paramters for times and such */ FILE *input = fopen("config.ini", "r"); verification_log = fopen("verification.log", "w"); load_input_file(input, verification_log); fclose(input); /* initialize berths array to specified size */ //berths = (struct berth *)malloc(sizeof(struct berth)*G.num_berths); /* Generate the plane and storm list */ generate_input_files(); /* Schedule the plane landing and storm events using the input lists*/ plane_list = fopen("plane_list.dat", "r"); storm_list = fopen("storm_list.dat", "r"); schedule_input_list(plane_list); schedule_input_list(storm_list); fclose(plane_list); fclose(storm_list); plane_list = fopen("plane_list.dat", "r"); storm_list = fopen("storm_list.dat", "r"); verify_actors(storm_list, plane_list, verification_log); fclose(plane_list); fclose(storm_list); while(list_size[LIST_EVENT] != 0) { timing(); /* If sim time passes a year, exit the simulation. */ if ((int)sim_time>=G.sim_length) {//TIME_YEAR) { if (taxi_state == TAXI_IDLE) stats.taxi_time_idle += G.sim_length - stats.taxi_time_idle_last; if (taxi_state == TAXI_TRAVELLING_BERTHS || taxi_state == TAXI_TRAVELLING_RUNWAY) stats.taxi_time_travelling += G.sim_length - stats.taxi_time_travelling_last; if (taxi_state == TAXI_BERTHING || taxi_state == TAXI_DEBERTHING) stats.taxi_time_berthing_deberthing += G.sim_length - stats.taxi_time_berthing_deberthing_last; /* Because the stats.taxi_time_travelling isn't quite getting all of the time but I know that the idle and berthing/deberthing times are correct, I'm cheating and using those to figure out the travelling time. */ stats.taxi_time_travelling = G.sim_length - stats.taxi_time_idle - stats.taxi_time_berthing_deberthing; break; } /* printf("%.1f %.1f %s %s\n", sim_time/60, stats.taxi_time_berthing_deberthing/60.0f, strings_event[(int)transfer[EVENT_TYPE]], strings_taxi[taxi_state]); */ /* Main event handler switch */ switch(next_event_type) { case EVENT_LAND1: case EVENT_LAND2: case EVENT_LAND3: plane_land(next_event_type, transfer[EVENT_PLANE_ID]); break; case EVENT_STORM_START: storm_start(); break; case EVENT_STORM_END: storm_end(); break; case EVENT_BERTH: berth(transfer[BERTH_NUMBER]); break; case EVENT_DEBERTH: deberth(transfer[BERTH_NUMBER]); break; case EVENT_FINISH_LOADING: finish_loading(transfer[BERTH_NUMBER]); break; case EVENT_BERTH_FINISH: berth_finish(transfer[BERTH_NUMBER]); break; case EVENT_DEBERTH_FINISH: deberth_finish(transfer[BERTH_NUMBER]); break; case EVENT_TAXI_RETURNS_IDLE: taxi_returns(); break; } if (sim_time == 129705) printf("%d\n", taxi_state == TAXI_IDLE); /* Taxi handler */ switch (taxi_state) { case TAXI_IDLE: taxi_idle(); break; case TAXI_TRAVELLING_RUNWAY: taxi_travelling_runway(); break; case TAXI_TRAVELLING_BERTHS: taxi_travelling_berths(); break; case TAXI_BERTHING: taxi_berthing(); break; case TAXI_DEBERTHING: taxi_deberthing(); break; } }// end simulation loop printf("Log list size: %d\n", list_size[LIST_LOG]); output_log_verbose = fopen("output_log_verbose.csv", "w"); save_log_file_verbose(output_log_verbose); fclose(output_log_verbose); output_log = fopen("output_log.csv", "w"); save_log_file(output_log); fclose(output_log); /* output_log = fopen("output_log.csv", "w"); //verify_output(output_log, verification_log); fclose(output_log); fclose(verification_log); */ statistics_log = fopen("statistics.log", "w"); generate_statistics(statistics_log); fclose(statistics_log); /* Clean up files */ remove("plane_list.dat"); remove("storm_list.dat"); remove("storm_list.csv"); }