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.
This commit is contained in:
Kistaro Windrider 2023-01-02 15:04:27 -08:00
parent 7b931d1fba
commit 04d2a680dd
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -1915,24 +1915,23 @@ function persist:init0()
cartdata("ulimate_lizard_total_destruction_0_1") cartdata("ulimate_lizard_total_destruction_0_1")
self.init0 = self.read self.init0 = self.read
self:read() self:read()
self.ready=true
end end
function persist:read() function persist:read()
self.ready=false
local m = dget(0) == 0 local m = dget(0) == 0
self.music = m self.music = m
if m then music_on() else music_off() end if m then music_on() else music_off() end
self.max_level = dget(1) self.max_level = dget(1)
self.recent_level = dget(2) self.recent_level = dget(2)
self.ready=true
end end
function persist:wipe() function persist:wipe()
self.ready=false
for i=0,64 do for i=0,64 do
dset(i,0) dset(i,0)
end end
self:read() self:read()
self.ready=true
end end
function persist:lvlstart() function persist:lvlstart()