diff --git a/src/loadsave.cc b/src/loadsave.cc index 90f09c3..a0fa76b 100644 --- a/src/loadsave.cc +++ b/src/loadsave.cc @@ -169,7 +169,6 @@ static int _GameMap2Slot(File* stream); static int _SlotMap2Game(File* stream); static int _mygets(char* dest, File* stream); static int _copy_file(const char* existingFileName, const char* newFileName); -static int _MapDirErase(const char* path, const char* extension); static int _SaveBackup(); static int _RestoreSave(); static int _LoadObjDudeCid(File* stream); @@ -340,9 +339,9 @@ void _InitLoadSave() _slot_cursor = 0; _patches = settings.system.master_patches_path.c_str(); - _MapDirErase("MAPS\\", "SAV"); - _MapDirErase(PROTO_DIR_NAME "\\" CRITTERS_DIR_NAME "\\", PROTO_FILE_EXT); - _MapDirErase(PROTO_DIR_NAME "\\" ITEMS_DIR_NAME "\\", PROTO_FILE_EXT); + MapDirErase("MAPS\\", "SAV"); + MapDirErase(PROTO_DIR_NAME "\\" CRITTERS_DIR_NAME "\\", PROTO_FILE_EXT); + MapDirErase(PROTO_DIR_NAME "\\" ITEMS_DIR_NAME "\\", PROTO_FILE_EXT); configGetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_AUTO_QUICK_SAVE, &quickSaveSlots); if (quickSaveSlots > 0 && quickSaveSlots <= 10) { @@ -353,9 +352,9 @@ void _InitLoadSave() // 0x47B85C void _ResetLoadSave() { - _MapDirErase("MAPS\\", "SAV"); - _MapDirErase(PROTO_DIR_NAME "\\" CRITTERS_DIR_NAME "\\", PROTO_FILE_EXT); - _MapDirErase(PROTO_DIR_NAME "\\" ITEMS_DIR_NAME "\\", PROTO_FILE_EXT); + MapDirErase("MAPS\\", "SAV"); + MapDirErase(PROTO_DIR_NAME "\\" CRITTERS_DIR_NAME "\\", PROTO_FILE_EXT); + MapDirErase(PROTO_DIR_NAME "\\" ITEMS_DIR_NAME "\\", PROTO_FILE_EXT); } // SaveGame @@ -1570,7 +1569,7 @@ static int lsgPerformSaveGame() debugPrint("\nLOADSAVE: ** Error opening save game for writing! **\n"); _RestoreSave(); snprintf(_gmpath, sizeof(_gmpath), "%s\\%s%.2d\\", "SAVEGAME", "SLOT", _slot_cursor + 1); - _MapDirErase(_gmpath, "BAK"); + MapDirErase(_gmpath, "BAK"); _partyMemberUnPrepSave(); backgroundSoundResume(); return -1; @@ -1583,7 +1582,7 @@ static int lsgPerformSaveGame() fileClose(_flptr); _RestoreSave(); snprintf(_gmpath, sizeof(_gmpath), "%s\\%s%.2d\\", "SAVEGAME", "SLOT", _slot_cursor + 1); - _MapDirErase(_gmpath, "BAK"); + MapDirErase(_gmpath, "BAK"); _partyMemberUnPrepSave(); backgroundSoundResume(); return -1; @@ -1597,7 +1596,7 @@ static int lsgPerformSaveGame() fileClose(_flptr); _RestoreSave(); snprintf(_gmpath, sizeof(_gmpath), "%s\\%s%.2d\\", "SAVEGAME", "SLOT", _slot_cursor + 1); - _MapDirErase(_gmpath, "BAK"); + MapDirErase(_gmpath, "BAK"); _partyMemberUnPrepSave(); backgroundSoundResume(); return -1; @@ -1678,7 +1677,7 @@ static int lsgPerformSaveGame() } snprintf(_gmpath, sizeof(_gmpath), "%s\\%s%.2d\\", "SAVEGAME", "SLOT", _slot_cursor + 1); - _MapDirErase(_gmpath, "BAK"); + MapDirErase(_gmpath, "BAK"); gLoadSaveMessageListItem.num = 140; if (messageListGetItem(&gLoadSaveMessageList, &gLoadSaveMessageListItem)) { @@ -1771,7 +1770,7 @@ static int lsgLoadGameInSlot(int slot) } snprintf(_str, sizeof(_str), "%s\\", "MAPS"); - _MapDirErase(_str, "BAK"); + MapDirErase(_str, "BAK"); _proto_dude_update_gender(); // Game Loaded. @@ -2487,7 +2486,7 @@ static int _GameMap2Slot(File* stream) snprintf(_gmpath, sizeof(_gmpath), "%s\\%s%.2d\\", "SAVEGAME", "SLOT", _slot_cursor + 1); - if (_MapDirErase(_gmpath, "SAV") == -1) { + if (MapDirErase(_gmpath, "SAV") == -1) { fileNameListFree(&fileNameList, 0); return -1; } @@ -2566,19 +2565,19 @@ static int _SlotMap2Game(File* stream) snprintf(_str0, sizeof(_str0), "%s\\", PROTO_DIR_NAME "\\" CRITTERS_DIR_NAME); - if (_MapDirErase(_str0, PROTO_FILE_EXT) == -1) { + if (MapDirErase(_str0, PROTO_FILE_EXT) == -1) { debugPrint("LOADSAVE: returning 3\n"); return -1; } snprintf(_str0, sizeof(_str0), "%s\\", PROTO_DIR_NAME "\\" ITEMS_DIR_NAME); - if (_MapDirErase(_str0, PROTO_FILE_EXT) == -1) { + if (MapDirErase(_str0, PROTO_FILE_EXT) == -1) { debugPrint("LOADSAVE: returning 4\n"); return -1; } snprintf(_str0, sizeof(_str0), "%s\\", "MAPS"); - if (_MapDirErase(_str0, "SAV") == -1) { + if (MapDirErase(_str0, "SAV") == -1) { debugPrint("LOADSAVE: returning 5\n"); return -1; } @@ -2749,11 +2748,11 @@ void lsgInit() { char path[COMPAT_MAX_PATH]; snprintf(path, sizeof(path), "%s\\", "MAPS"); - _MapDirErase(path, "SAV"); + MapDirErase(path, "SAV"); } // 0x480040 -static int _MapDirErase(const char* relativePath, const char* extension) +int MapDirErase(const char* relativePath, const char* extension) { char path[COMPAT_MAX_PATH]; snprintf(path, sizeof(path), "%s*.%s", relativePath, extension); diff --git a/src/loadsave.h b/src/loadsave.h index 32e1263..567548e 100644 --- a/src/loadsave.h +++ b/src/loadsave.h @@ -20,6 +20,7 @@ int lsgSaveGame(int mode); int lsgLoadGame(int mode); bool _isLoadingGame(); void lsgInit(); +int MapDirErase(const char* path, const char* extension); int _MapDirEraseFile_(const char* a1, const char* a2); } // namespace fallout