示例#1
0
int
main(int argc, char **argv)
{
    if (argc > 1)
	if (emp_config(argv[1]) < 0)
	    exit(1);
    print_config(stdout);
    exit(0);
}
示例#2
0
int
main(int argc, char *argv[])
{
    int opt;
    char *config_file = NULL;
    int i = 0;
    unsigned rnd_seed = 0;
    int seed_set = 0;

    program_name = argv[0];

    while ((opt = getopt(argc, argv, "ae:hioqR:s:v")) != EOF) {
	switch (opt) {
	case 'a':
	    AIRPORT_MARKER = 1;
	    break;
	case 'e':
	    config_file = optarg;
	    break;
	case 'i':
	    DISTINCT_ISLANDS = 0;
	    break;
	case 'o':
	    ORE = 0;
	    break;
	case 'q':
	    quiet = 1;
	    break;
	case 'R':
	    rnd_seed = strtoul(optarg, NULL, 10);
	    seed_set = 1;
	    break;
	case 's':
	    outfile = optarg;
	    break;
	case 'h':
	    usage();
	    exit(0);
	case 'v':
	    printf("%s\n\n%s", version, legal);
	    exit(0);
	default:
	    help(NULL);
	    exit(1);
	}
    }
    parse_args(argc - optind, argv + optind);

    if (!seed_set)
	rnd_seed = pick_seed();
    seed_prng(rnd_seed);
    empfile_init();
    if (emp_config(config_file) < 0)
	exit(1);
    empfile_fixup();

    allocate_memory();
    print_vars();

    qprint("\n        #*# ...fairland rips open a rift in the datumplane... #*#\n\n");
    qprint("seed is %u\n", rnd_seed);
    do {
	init();
	if (i)
	    qprint("\ntry #%d (out of %d)...\n", i + 1, NUMTRIES);
	qprint("placing capitals...\n");
	if (!drift())
	    qprint("fairland: unstable drift -- try increasisg DRIFT_MAX\n");
	qprint("growing continents...\n");
	grow_continents();
    } while (fl_status && ++i < NUMTRIES);
    if (fl_status) {
	fputs("ERROR: World not large enough to hold continents\n",
	      stderr);
	exit(1);
    }
    qprint("growing islands:");
    grow_islands();
    qprint("\nelevating land...\n");
    create_elevations();
    qprint("designating sectors...\n");
    if (ORE)
	qprint("adding resources...\n");
    write_newcap_script();

    if (chdir(gamedir)) {
	fprintf(stderr, "Can't chdir to %s (%s)\n", gamedir, strerror(errno));
	exit(EXIT_FAILURE);
    }
    if (!ef_open(EF_SECTOR, EFF_MEM | EFF_NOTIME))
	exit(1);
    write_sects();
    qprint("writing to sectors file...\n");
    if (!ef_close(EF_SECTOR))
	exit(1);

    output();
    qprint("\n\nA script for adding all the countries can be found in \"%s\".\n",
	   outfile);
    if (!ORE)
	qprint("\t*** Resources have not been added ***\n");
    exit(0);
}