From 8338889c466f3dc392a7a83598a65dcac8cbcc38 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 10 Dec 2023 23:54:53 +0200 Subject: [PATCH] misc: avoid assertion failure when state save fails --- libpcsxcore/misc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index e652cc48..0848c267 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -677,6 +677,10 @@ int SaveState(const char *file) { assert(!psxRegs.branching); assert(!psxRegs.cpuInRecursion); assert(!misc->magic); + + f = SaveFuncs.open(file, "wb"); + if (f == NULL) return -1; + misc->magic = MISC_MAGIC; misc->gteBusyCycle = psxRegs.gteBusyCycle; misc->muldivBusyCycle = psxRegs.muldivBusyCycle; @@ -687,9 +691,6 @@ int SaveState(const char *file) { misc->frame_counter = frame_counter; misc->CdromFrontendId = CdromFrontendId; - f = SaveFuncs.open(file, "wb"); - if (f == NULL) return -1; - psxCpu->Notify(R3000ACPU_NOTIFY_BEFORE_SAVE, NULL); SaveFuncs.write(f, (void *)PcsxHeader, 32); -- 2.39.2