Ejemplo n.º 1
0
int main (
	int argc
	, char **argv
	, char **envp
)
{
	parse_argv(argc, argv);

	create_queues( /* no args */ );
	create_players( /* no args */ );

	signal(SIGINT, parent_sig_int);
	sleep(sleep_time_seconds);
	scorer(scorer_queue);

	stop_players( /* no args */ );
	close_queues( /* no args */ );
	remove_queues( /* no args */ );

	return(EXIT_SUCCESS);
}
int main (
	int argc
	, char **argv
	, char **envp
)
{
	parse_argv(argc, argv);

	create_queues( /* no args */ );
	create_players( /* no args */ );
	//size_queues();

	// i should probably install a SIGCHLD handler too.  I'd have to
	// keep track of if the child is exiting on an error or as expected.
	signal(SIGINT, parent_sig_int);
	sleep(sleep_time_seconds);
	scorer(scorer_queue);

	stop_players_threads( /* no args */ );
	close_queues( /* no args */ );
	remove_queues( /* no args */ );

	return(EXIT_SUCCESS);
}
Ejemplo n.º 3
0
/*
 * create_match_state
 *
 * TODO: Fill this function block in once we tie down what this actually does.
 *
 * Returns: A pointer to the new object or NULL on failure.
 */
MATCH_STATE *create_match_state(unsigned int hard_cap,
                                unsigned int game_length_s,
                                char *disc_graphic_filename,
                                char *grass_tile_filename,
                                char *offensive_xml_file,
                                char *defensive_xml_file,
                                int (*state_callback)(AUTOMATON_STATE ***, int),
                                int (*event_callback)(AUTOMATON_EVENT ***))
{
  MATCH_STATE *state;

  /*
   * Allocate the memory for the new object.
   */
  state = (MATCH_STATE *) DT_MALLOC(sizeof(MATCH_STATE));

  /*
   * Set the throw to null to start, this will be created when the user starts
   * a throw.
   */
  state->match_throw = create_throw();

  /*
   * Create a disc object for this game.
   */
  state->disc = create_disc(disc_graphic_filename);

  /*
   * The disc path starts as null so that we know when the first one has
   * been created.
   */
  state->disc_path = NULL;

  /*
   * Initialise the pitch objects associated with the match.
   */
  state->pitch = create_pitch(grass_tile_filename);

  /*
   * Initialise the camera handler associated with the match.
   */
  state->camera_handler = create_camera_handler();

  /*
   * Initialise the input handlers for the mouse and the keyboard.
   */
  state->key_input_state = create_key_input_state();
  state->mouse_input_state = create_mouse_input_state();

  /*
   * Initialise the animation handler. This does not load any animations as this
   * is done by the load_animation_data function.
   */
  state->animation_handler = create_animation_handler();

  /*
   * Create the timer objects for use in the game.
   */
  state->match_stats = create_match_stats(game_length_s,
                                          hard_cap);

  /*
   * Create the automaton handler, passing in the location of the two xml files
   * means that this whole structure is constructed here. This will tell us
   * what the default states are for the two teams.
   */
  state->automaton_handler = create_automaton_handler(offensive_xml_file,
                                                      defensive_xml_file,
                                                      state_callback,
                                                      event_callback,
                                                      state);
  if (NULL == state->automaton_handler)
  {
    destroy_match_state(state);
    state = NULL;
    goto EXIT_LABEL;
  }

  /*
   * Create the teams.
   */
  state->teams[0] = create_team();
  state->teams[1] = create_team();
  state->players_per_team = PLAYERS_PER_TEAM;
  create_players(state->teams,
                 state->players_per_team,
                 state->automaton_handler);

EXIT_LABEL:

  return(state);
}