From fb1970ffc29ed5a17b6a07055d7759b8a6d3048c Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Fri, 23 Apr 2021 16:05:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=AD=98=E6=A1=A3=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.lua | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/main.lua b/main.lua index 1dc898d0..f69a211a 100644 --- a/main.lua +++ b/main.lua @@ -34,11 +34,13 @@ love.keyboard.setTextInput(false) love.mouse.setVisible(false) --Delete all files from too old version -for _,name in next,fs.getDirectoryItems("")do - if fs.getRealDirectory(name)==SAVEDIR and fs.getInfo(name).type~="directory"then - fs.remove(name) +function CLEAR(root) + for _,name in next,fs.getDirectoryItems(root or"")do + if fs.getRealDirectory(name)==SAVEDIR and fs.getInfo(name).type~="directory"then + fs.remove(name) + end end -end +end CLEAR() --Create directories for _,v in next,{"conf","record","replay","cache","lib"}do @@ -238,11 +240,9 @@ do local needSave local autoRestart - if STAT.extraRate then - STAT.finesseRate=5*(STAT.piece-STAT.extraRate) - end if type(STAT.version)~="number"then STAT.version=0 + needSave=true end if STAT.version<1300 then STAT.frame=math.floor(STAT.time*60) @@ -281,6 +281,14 @@ do end end + if STAT.version~=VERSION.code then + newVersionLaunch=true + STAT.version=VERSION.code + CLEAR("lib") + needSave=true + autoRestart=true + end + if RANKS.GM then RANKS.GM=0 end if RANKS.infinite then RANKS.infinite=6 end if RANKS.infinite_dig then RANKS.infinite_dig=6 end @@ -311,15 +319,10 @@ do needSave=true end - if STAT.version~=VERSION.code then - newVersionLaunch=true - STAT.version=VERSION.code - FILE.save(STAT,"conf/data","q") - end - if needSave then - FILE.save(RANKS,"conf/unlock","q") FILE.save(SETTING,"conf/settings","q") + FILE.save(RANKS,"conf/unlock","q") + FILE.save(STAT,"conf/data","q") end if autoRestart then love.event.quit("restart")