Partial reversion

* Made it so changes are made only to the import map_cache to relieve the main one from merge conflicts.
This commit is contained in:
aleos89 2019-07-23 10:22:19 -04:00
parent 61ffb1ce3d
commit 1cbd688761

View File

@ -150,7 +150,7 @@ int find_map(char *name)
for(i = 0; i < header.map_count; i++) { for(i = 0; i < header.map_count; i++) {
if(fread(&info, sizeof(info), 1, map_cache_fp) != 1) if(fread(&info, sizeof(info), 1, map_cache_fp) != 1)
printf("An error has occured in fread while reading \"%s\"\n", map_cache_fp); ShowError("An error has occured in fread while reading \"%s\"\n", map_cache_fp);
if(strcmp(name, info.name) == 0) // Map found if(strcmp(name, info.name) == 0) // Map found
return 1; return 1;
else // Map not found, jump to the beginning of the next map info header else // Map not found, jump to the beginning of the next map info header
@ -195,11 +195,9 @@ void process_args(int argc, char *argv[])
int do_init(int argc, char** argv) int do_init(int argc, char** argv)
{ {
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 */ /* setup pre-defined, #define-dependant */
map_cache_file = directory + "map_cache.dat"; 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);
@ -228,6 +226,9 @@ int do_init(int argc, char** argv)
// Open the map list // Open the map list
FILE *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());
@ -243,7 +244,7 @@ int do_init(int argc, char** argv)
header.map_count = 0; header.map_count = 0;
} else { } else {
if (fread(&header, sizeof(struct main_header), 1, map_cache_fp) != 1) if (fread(&header, sizeof(struct main_header), 1, map_cache_fp) != 1)
printf("An error has occured while reading \"%s\"\n", map_cache_fp); ShowError("An error has occured while reading \"%s\"\n", map_cache_fp);
header.file_size = GetULong((unsigned char *)&(header.file_size)); header.file_size = GetULong((unsigned char *)&(header.file_size));
header.map_count = GetUShort((unsigned char *)&(header.map_count)); header.map_count = GetUShort((unsigned char *)&(header.map_count));
} }
@ -279,13 +280,13 @@ int do_init(int argc, char** argv)
ShowStatus("Closing map list: %s\n", filename.c_str()); ShowStatus("Closing map list: %s\n", filename.c_str());
fclose(list); 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("Finalizing grfio\n"); ShowStatus("Finalizing grfio\n");
grfio_final(); grfio_final();