Ejemplo n.º 1
0
/**
 * Play Angband
 */
void play_game(bool new_game)
{
	/* Load a savefile or birth a character, or both */
	start_game(new_game);

	/* Get commands from the user, then process the game world until the
	 * command queue is empty and a new player command is needed */
	while (!player->is_dead && player->upkeep->playing) {
		cmd_get_hook(CMD_GAME);
		run_game_loop();
	}

	/* Close game on death or quitting */
	close_game();
}
Ejemplo n.º 2
0
/*
 * Get the next game command, with 'wait' indicating whether we
 * are prepared to wait for a command or require a quick return with
 * no command.
 */
errr cmd_get(cmd_context c, game_command *cmd, bool wait)
{

	/* If there are no commands queued, ask the UI for one. */
	if (cmd_head == cmd_tail)
	{
		cmd_get_hook(c, wait);
	}

	/* If we have a command ready, set it and return success. */
	if (cmd_head != cmd_tail)
	{

		*cmd = cmd_queue[cmd_tail++];
		if (cmd_tail == CMD_QUEUE_SIZE) cmd_tail = 0;

		return 0;
	}


	/* Failure to get a command. */
	return 1;
}