Add define for wiping save data if existing save data from vanilla or another hack exists (#579)

This commit is contained in:
Gregory Heskett authored and GitHub committed 2023-03-06 20:53:08 -05:00
1 parent be753ae220
commit 4c67e48456
2 files changed
+30

No files matched your search

+7
View File
@@ -29,6 +29,13 @@
#define BORDER_HEIGHT_CONSOLE 0
#define BORDER_HEIGHT_EMULATOR 0
/**
* Force the game to delete any existing save data originating from a different hack. This requires INTERNAL_ROM_NAME to be unique to work properly.
* It is recommended to enable this if any significant changes to the save file are made that could cause issues with this or other hacks.
* NOTE: Using save editors with this define will likely just end up wiping your save, since SM64 specific save editors most likely use hardcoded save magic.
*/
// #define UNIQUE_SAVE_DATA
/**
* Informs supported emulators to default to gamecube controller inputs.
*/
+23
View File
@@ -18,8 +18,13 @@
#endif
#include "puppycam2.h"
#ifdef UNIQUE_SAVE_DATA
u16 MENU_DATA_MAGIC = 0x4849;
u16 SAVE_FILE_MAGIC = 0x4441;
#else
#define MENU_DATA_MAGIC 0x4849
#define SAVE_FILE_MAGIC 0x4441
#endif
//STATIC_ASSERT(sizeof(struct SaveBuffer) == EEPROM_SIZE, "eeprom buffer size must match");
@@ -332,10 +337,28 @@ void save_file_copy(s32 srcFileIndex, s32 destFileIndex) {
save_file_do_save(destFileIndex);
}
#ifdef UNIQUE_SAVE_DATA
// This should only be called once on boot and never again.
static void calculate_unique_save_magic(void) {
u16 checksum = 0;
for (s32 i = 0; i < 20; i++) {
checksum += (u16) INTERNAL_ROM_NAME[i] << (i & 0x07);
}
MENU_DATA_MAGIC += checksum;
SAVE_FILE_MAGIC += checksum;
}
#endif
void save_file_load_all(void) {
s32 file;
s32 validSlots;
#ifdef UNIQUE_SAVE_DATA
calculate_unique_save_magic(); // This should only be called once on boot and never again.
#endif
gMainMenuDataModified = FALSE;
gSaveFileModified = FALSE;