void client_main_loop (void) { int quit = 0; int engine_updated = 0; /* Set up the game */ reset_start_time (); update_avail_modules (0); screen_full_refresh (); if (no_init_help == 0) { block_help_exit = 1; help_flag = 1; if (make_dir_ok_flag) { activate_help ("ask-dir.hlp"); make_dir_ok_flag = 0; } else { activate_help ("opening.hlp"); } } /* Set speed */ #if defined (CS_PROFILE) || defined (START_FAST_SPEED) select_fast (); #else select_medium (); #endif /* Main Loop */ do { int key; /* Get timestamp for this iteration */ get_real_time(); /* Process events */ #if defined (LC_X11) call_event (); key = x_key_value; x_key_value = 0; #elif defined (WIN32) call_event (); key = GetKeystroke (); #else mouse_update (); key = vga_getkey (); #endif /* nothing happened if key == 0 XXX: right? */ /* GCS: I'm not sure */ if (key != 0) { process_keystrokes (key); } /* Simulate the timestep */ quit = execute_timestep (); } while (quit == 0); }
static int do_x_select(int fd, int wr) { int *xconn, xconnnum; int max = fd, i; fd_set rmask, wmask; if (!XInternalConnectionNumbers(display, &xconn, &xconnnum)) { perror("XInternalConnectionNumbers"); exit(1); } FD_ZERO(&rmask); FD_ZERO(&wmask); if (wr) FD_SET(fd, &wmask); else FD_SET(fd, &rmask); for (i = 0; i < xconnnum; i++) { FD_SET(xconn[i], &rmask); if (xconn[i] > max) max = xconn[i]; } i = select(max+1, &rmask, &wmask, NULL, NULL); if (i < 0) { perror("select"); exit(1); } for (i = 0; i < xconnnum; i++) if (FD_ISSET(xconn[i], &rmask)) XProcessInternalConnection(display, xconn[i]); XFree(xconn); process_keystrokes(); if (wr) return FD_ISSET(fd, &wmask); else return FD_ISSET(fd, &rmask); }