From 04d2a680ddc13b48b13f858eab9cd66e08693d3e Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Mon, 2 Jan 2023 15:04:27 -0800 Subject: [PATCH] block writes while reading Disabling writes during "wipe" and "first load" is not quite semantically what we want, it's writes during read we want to block. This happens because turning the music on or off tries to save the state, and it's easier to just ignore that persistence request than to rework the music code so it doesn't. "wipe" and "first load" are when we're actually reading (and enacting) state, but it's the act of reading rather than those two acts that should block writes. It is also unwilling to write until it's done its first read, which I think is a feature; it makes it harder to accidentally blank out the player's data. --- chameleonic.p8 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/chameleonic.p8 b/chameleonic.p8 index 5424692..efd6ae6 100644 --- a/chameleonic.p8 +++ b/chameleonic.p8 @@ -1915,24 +1915,23 @@ function persist:init0() cartdata("ulimate_lizard_total_destruction_0_1") self.init0 = self.read self:read() - self.ready=true end function persist:read() + self.ready=false local m = dget(0) == 0 self.music = m if m then music_on() else music_off() end self.max_level = dget(1) self.recent_level = dget(2) + self.ready=true end function persist:wipe() - self.ready=false for i=0,64 do dset(i,0) end self:read() - self.ready=true end function persist:lvlstart()