int main(int argc, char** argv) { #ifdef USE_ICONV setlocale(LC_ALL, ""); #endif if (argc != 2) { fprintf(stderr,"usage: narcdec <file>\n"); return 1; } else { open_map_file(argv[1]); extract_arc_files_main(); /* 16 is normal, and we might add header parsing so.. */ if ((arcfile_size - arcfile_understood) <= 16) { printf("Done %d files.\n", arcfile_files_extracted); } else { printf("Done %d files. %d bytes not understood\n", arcfile_files_extracted, (int)(arcfile_size - arcfile_understood)); } return 0; } }
void open_uo_data_files( void ) { string filename; // map1 uses map0 + 'dif' files, unless there is a map1.mul (newer clients) // same for staidx and statics mapfile = open_map_file("map", uo_mapid); sidxfile = open_map_file("staidx", uo_mapid); statfile = open_map_file("statics", uo_mapid); if (FileExists( (config.uo_datafile_root + "verdata.mul").c_str() )) { verfile = open_uo_file( "verdata.mul" ); } else { verfile = NULL; } tilefile = open_uo_file( "tiledata.mul" ); if (uo_usedif) { filename = "stadifl" + tostring(uo_mapid) + ".mul"; if (FileExists( config.uo_datafile_root + filename )) { stadifl_file = open_uo_file( filename ); filename = "stadifi" + tostring(uo_mapid) + ".mul"; stadifi_file = open_uo_file( filename ); filename = "stadif" + tostring(uo_mapid) + ".mul"; stadif_file = open_uo_file( filename ); } filename = "mapdifl" + tostring(uo_mapid) + ".mul"; if (FileExists( config.uo_datafile_root + filename )) { mapdifl_file = open_uo_file( filename ); filename = "mapdif" + tostring(uo_mapid) + ".mul"; mapdif_file = open_uo_file( filename ); } } }
int main(int argc, char* argv[]) { char *mapPath, *agentPath; //The location of the files int rows, cols, maxSteps; //Dimensions of the map and the max steps char** map; //Character map //Check the command line args if (argc != 4) { handler_exit(1); } mapPath = argv[1]; agentPath = argv[3]; long tempL; char** tempP = NULL; tempL = strtol(argv[2], tempP, 10); if (tempL < 1 || tempL > INT_MAX) { handler_exit(2); } //Set variables needed later in the program - max steps, map and agents maxSteps = (int)tempL; map = open_map_file(mapPath, &rows, &cols); get_num_agents(agentPath); agents = (AgentData *)malloc(sizeof(AgentData)*numAgents); get_agents(agentPath, rows, cols); //Set up signal handling signal(SIGINT, sig_handler); signal(SIGCHLD, sig_handler); //Start agents start_agents(rows, cols, map); //Start the game for (int i = 0; i < maxSteps; i++) { //Let each agent take turns, process their move and print the map for(int j = 0; j < numAgents; j++) { agent_move(j); check_move(map, j, rows, cols); print_map(map, rows, cols); } } //No agent succeeded with given steps handler_exit(10); }
void Annotator::index_map() throw (AnnotatorException) { if (gwafile == NULL) { return; } if (map_index != NULL) { for (unsigned int i = 0u; i < map_index_size; ++i) { free(map_index[i].name); map_index[i].name = NULL; } free(map_index); map_index = NULL; } if (map_chromosomes != NULL) { for (unsigned int i = 0u; i < map_index_size; ++i) { free(map_chromosomes[i]); map_chromosomes[i] = NULL; } free(map_chromosomes); map_chromosomes = NULL; } if (map_positions != NULL) { free(map_positions); map_positions = NULL; } map_index_size = 0u; current_map_heap_size = 0u; try { open_map_file(); process_map_file_header(); process_map_file_data(); close_map_file(); } catch (AnnotatorException &e) { e.add_message("Annotator", "index_map()", __LINE__, 20); throw; } }