Properly loop over main and import
This commit is contained in:
parent
683e5f01a2
commit
a808526fdd
@ -195,15 +195,23 @@ void process_args(int argc, char *argv[])
|
|||||||
|
|
||||||
int do_init(int argc, char** argv)
|
int do_init(int argc, char** argv)
|
||||||
{
|
{
|
||||||
/* setup pre-defined, #define-dependant */
|
|
||||||
map_cache_file = std::string(db_path) + "/" + std::string(DBIMPORT) + "/map_cache.dat";
|
|
||||||
|
|
||||||
// Process the command-line arguments
|
// Process the command-line arguments
|
||||||
process_args(argc, argv);
|
process_args(argc, argv);
|
||||||
|
|
||||||
ShowStatus("Initializing grfio with %s\n", grf_list_file.c_str());
|
ShowStatus("Initializing grfio with %s\n", grf_list_file.c_str());
|
||||||
grfio_init(grf_list_file.c_str());
|
grfio_init(grf_list_file.c_str());
|
||||||
|
|
||||||
|
// Open the map list
|
||||||
|
FILE *list;
|
||||||
|
std::vector<std::string> directories = { std::string(db_path) + "/", std::string(db_path) + "/" + std::string(DBIMPORT) + "/" };
|
||||||
|
|
||||||
|
for (const auto &directory : directories) {
|
||||||
|
/* setup pre-defined, #define-dependant */
|
||||||
|
if (directory.find("import") != std::string::npos)
|
||||||
|
map_cache_file = std::string(db_path) + "/" + std::string(DBIMPORT) + "map_cache.dat";
|
||||||
|
else
|
||||||
|
map_cache_file = std::string(db_path) + "/" + std::string(DBPATH) + "/map_cache.dat";
|
||||||
|
|
||||||
// Attempt to open the map cache file and force rebuild if not found
|
// Attempt to open the map cache file and force rebuild if not found
|
||||||
ShowStatus("Opening map cache: %s\n", map_cache_file.c_str());
|
ShowStatus("Opening map cache: %s\n", map_cache_file.c_str());
|
||||||
if (!rebuild) {
|
if (!rebuild) {
|
||||||
@ -223,11 +231,6 @@ int do_init(int argc, char** argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the map list
|
|
||||||
FILE *list;
|
|
||||||
std::vector<std::string> directories = { std::string(db_path) + "/", std::string(db_path) + "/" + std::string(DBIMPORT) + "/" };
|
|
||||||
|
|
||||||
for (const auto &directory : directories) {
|
|
||||||
std::string filename = directory + map_list_file;
|
std::string filename = directory + map_list_file;
|
||||||
|
|
||||||
ShowStatus("Opening map list: %s\n", filename.c_str());
|
ShowStatus("Opening map list: %s\n", filename.c_str());
|
||||||
@ -279,16 +282,16 @@ int do_init(int argc, char** argv)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowStatus("Closing map list: %s\n", filename.c_str());
|
|
||||||
fclose(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write the main header and close the map cache
|
// Write the main header and close the map cache
|
||||||
ShowStatus("Closing map cache: %s\n", map_cache_file.c_str());
|
ShowStatus("Closing map cache: %s\n", map_cache_file.c_str());
|
||||||
fseek(map_cache_fp, 0, SEEK_SET);
|
fseek(map_cache_fp, 0, SEEK_SET);
|
||||||
fwrite(&header, sizeof(struct main_header), 1, map_cache_fp);
|
fwrite(&header, sizeof(struct main_header), 1, map_cache_fp);
|
||||||
fclose(map_cache_fp);
|
fclose(map_cache_fp);
|
||||||
|
|
||||||
|
ShowStatus("Closing map list: %s\n", filename.c_str());
|
||||||
|
fclose(list);
|
||||||
|
}
|
||||||
|
|
||||||
ShowStatus("Finalizing grfio\n");
|
ShowStatus("Finalizing grfio\n");
|
||||||
grfio_final();
|
grfio_final();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user