Fix various bugs reported by testyourmine

This commit is contained in:
Snesrev
2023-03-06 18:00:05 +01:00
parent 1666b7aaaf
commit 606e9a0ada
10 changed files with 49 additions and 22 deletions

View File

@@ -423,12 +423,24 @@ void RtlSaveSnapshot(const char *filename, bool saving_with_bug) {
fclose(f);
}
static const char *const kBugSaves[] = {
"shaktool", "shinespark", "bombtorizo", "chozo", "draygon", "draygon2", "golden-torizo", "motherbomb", "phantoon"
};
void RtlSaveLoad(int cmd, int slot) {
char name[128];
sprintf(name, "saves/save%d.sav", slot);
if (slot >= 256) {
int i = slot - 256;
if (cmd == kSaveLoad_Save || i >= sizeof(kBugSaves) / sizeof(kBugSaves[0]))
return;
sprintf(name, "saves/bug-%s.sav", kBugSaves[i]);
} else {
sprintf(name, "saves/save%d.sav", slot);
}
printf("*** %s slot %d\n",
cmd == kSaveLoad_Save ? "Saving" : cmd == kSaveLoad_Load ? "Loading" : "Replaying", slot);
if (cmd != kSaveLoad_Save) {
FILE *f = fopen(name, "rb");
if (f == NULL) {
printf("Failed fopen: %s\n", name);