void LoadFolder(Folder *pFolder, int iconsize, bool is_visible, HWND hwnd) { struct pidl_node *pidl_list; LPCITEMIDLIST pIDFolder; pidl_list = get_folder_pidl_list (pFolder->path); pFolder->pidl_list = pidl_list; if (NULL==pidl_list) return; pIDFolder = first_pidl(pidl_list); pFolder->id_notify = add_change_notify_entry(hwnd, pIDFolder); Item **ppItems = &pFolder->items; while (pidl_list) { LPCITEMIDLIST pIDFolder = first_pidl(pidl_list); struct enum_files *ef; if (ef_open(pIDFolder, &ef) && is_visible) { while (ef_next(ef)) { int attr; struct pidl_node *pidl; if (0 == ef_getpidl(ef, &pidl)) continue; ef_getattr(ef, &attr); Item *item = new Item; item->is_folder = 0 != (attr & ef_folder); item->data = pidl; sh_get_icon_and_name(first_pidl(pidl), &item->hIcon, iconsize, item->szTip, sizeof item->szTip); // add item to the list item -> next = *ppItems, *ppItems = item; } ef_close(ef); } pidl_list = pidl_list -> next; } pFolder->items = join_folders(pFolder->items); }
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); }