From 9488dc61f92fe2f026b3bd2aeac19ed9cf9b4737 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Mon, 28 Jun 2021 16:06:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E9=83=A8=E5=88=86=E7=89=B9?= =?UTF-8?q?=E6=AE=8A=E5=AD=98=E6=A1=A3=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.lua | 25 +++++++++---------- parts/data.lua | 7 +++++- parts/list.lua | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 14 deletions(-) diff --git a/main.lua b/main.lua index 0300fff1..b41d6d57 100644 --- a/main.lua +++ b/main.lua @@ -237,7 +237,6 @@ for i=1,#MODES do MODES[m.name],MODES[i]=M end -local modeTable={attacker_h="attacker_hard",attacker_u="attacker_ultimate",blind_e="blind_easy",blind_h="blind_hard",blind_l="blind_lunatic",blind_n="blind_normal",blind_u="blind_ultimate",c4wtrain_l="c4wtrain_lunatic",c4wtrain_n="c4wtrain_normal",defender_l="defender_lunatic",defender_n="defender_normal",dig_100l="dig_100",dig_10l="dig_10",dig_400l="dig_400",dig_40l="dig_40",dig_h="dig_hard",dig_u="dig_ultimate",drought_l="drought_lunatic",drought_n="drought_normal",marathon_h="marathon_hard",marathon_n="marathon_normal",pc_h="pcchallenge_hard",pc_l="pcchallenge_lunatic",pc_n="pcchallenge_normal",pctrain_l="pctrain_lunatic",pctrain_n="pctrain_normal",round_e="round_1",round_h="round_2",round_l="round_3",round_n="round_4",round_u="round_5",solo_e="solo_1",solo_h="solo_2",solo_l="solo_3",solo_n="solo_4",solo_u="solo_5",sprint_10l="sprint_10",sprint_20l="sprint_20",sprint_40l="sprint_40",sprint_400l="sprint_400",sprint_100l="sprint_100",sprint_1000l="sprint_1000",survivor_e="survivor_easy",survivor_h="survivor_hard",survivor_l="survivor_lunatic",survivor_n="survivor_normal",survivor_u="survivor_ultimate",tech_finesse_f="tech_finesse2",tech_h_plus="tech_hard2",tech_h="tech_hard",tech_l_plus="tech_lunatic2",tech_l="tech_lunatic",tech_n_plus="tech_normal2",tech_n="tech_normal",techmino49_e="techmino49_easy",techmino49_h="techmino49_hard",techmino49_u="techmino49_ultimate",techmino99_e="techmino99_easy",techmino99_h="techmino99_hard",techmino99_u="techmino99_ultimate",tsd_e="tsd_easy",tsd_h="tsd_hard",tsd_u="tsd_ultimate",master_extra="GM"} --Update data do local needSave,autoRestart @@ -278,19 +277,19 @@ do needSave=true end end - for k,v in next,modeTable do - if RANKS[v]then - RANKS[k]=RANKS[v] - RANKS[v]=nil + for k,v in next,oldModeNameTable do + if RANKS[k]then + RANKS[v]=RANKS[k] + RANKS[k]=nil end - v="record/"..v - if fs.getInfo(v..".dat")then - fs.write("record/"..k..".rec",fs.read(v..".dat")) - fs.remove(v..".dat") + k="record/"..k + if fs.getInfo(k..".dat")then + fs.write("record/"..v..".rec",fs.read(k..".dat")) + fs.remove(k..".dat") end - if fs.getInfo(v..".rec")then - fs.write("record/"..k..".rec",fs.read(v..".rec")) - fs.remove(v..".rec") + if fs.getInfo(k..".rec")then + fs.write("record/"..v..".rec",fs.read(k..".rec")) + fs.remove(k..".rec") end end if not RANKS.sprint_10l then @@ -315,7 +314,7 @@ for _,fileName in next,fs.getDirectoryItems("replay")do local date,mode,version,player,seed,setting,mod local fileData=fs.read('replay/'..fileName) date, fileData=STRING.readLine(fileData)date=date:gsub("[a-zA-Z]","") - mode, fileData=STRING.readLine(fileData)mode=modeTable[mode]or mode + mode, fileData=STRING.readLine(fileData)mode=oldModeNameTable[mode]or mode version,fileData=STRING.readLine(fileData) player, fileData=STRING.readLine(fileData)if player=="Local Player"then player="Stacker"end local success diff --git a/parts/data.lua b/parts/data.lua index d6904f26..a3f00d25 100644 --- a/parts/data.lua +++ b/parts/data.lua @@ -395,7 +395,12 @@ function DATA.parseReplay(fileName,ifFull) --Load metadata metaData,fileData=STRING.readLine(fileData) metaData=JSON.decode(metaData) - if not metaData or not text.modes[metaData.mode]then goto BREAK_cannotParse end + if not metaData then goto BREAK_cannotParse end + + --Convert ancient replays + metaData.mode=oldModeNameTable[metaData.mode]or metaData.mode + if not MODES[metaData.mode]then goto BREAK_cannotParse end + --Create replay object rep={ fileName=fileName, diff --git a/parts/list.lua b/parts/list.lua index 65610243..68cea7a6 100644 --- a/parts/list.lua +++ b/parts/list.lua @@ -286,6 +286,72 @@ do--SCS(spinCenters) {[0]=D,D,D,D},--O1 } end +oldModeNameTable={ + attacker_hard="attacker_h", + attacker_ultimate="attacker_u", + blind_easy="blind_e", + blind_hard="blind_h", + blind_lunatic="blind_l", + blind_normal="blind_n", + blind_ultimate="blind_u", + c4wtrain_lunatic="c4wtrain_l", + c4wtrain_normal="c4wtrain_n", + defender_lunatic="defender_l", + defender_normal="defender_n", + dig_100="dig_100l", + dig_10="dig_10l", + dig_400="dig_400l", + dig_40="dig_40l", + dig_hard="dig_h", + dig_ultimate="dig_u", + drought_lunatic="drought_l", + drought_normal="drought_n", + marathon_hard="marathon_h", + marathon_normal="marathon_n", + pcchallenge_hard="pc_h", + pcchallenge_lunatic="pc_l", + pcchallenge_normal="pc_n", + pctrain_lunatic="pctrain_l", + pctrain_normal="pctrain_n", + round_1="round_e", + round_2="round_h", + round_3="round_l", + round_4="round_n", + round_5="round_u", + solo_1="solo_e", + solo_2="solo_h", + solo_3="solo_l", + solo_4="solo_n", + solo_5="solo_u", + sprint_10="sprint_10l", + sprint_20="sprint_20l", + sprint_40="sprint_40l", + sprint_400="sprint_400l", + sprint_100="sprint_100l", + sprint_1000="sprint_1000l", + survivor_easy="survivor_e", + survivor_hard="survivor_h", + survivor_lunatic="survivor_l", + survivor_normal="survivor_n", + survivor_ultimate="survivor_u", + tech_finesse2="tech_finesse_f", + tech_hard2="tech_h_plus", + tech_hard="tech_h", + tech_lunatic2="tech_l_plus", + tech_lunatic="tech_l", + tech_normal2="tech_n_plus", + tech_normal="tech_n", + techmino49_easy="techmino49_e", + techmino49_hard="techmino49_h", + techmino49_ultimate="techmino49_u", + techmino99_easy="techmino99_e", + techmino99_hard="techmino99_h", + techmino99_ultimate="techmino99_u", + tsd_easy="tsd_e", + tsd_hard="tsd_h", + tsd_ultimate="tsd_u", + GM="master_extra", +} rankColor={ {.6,.3,.3}, {.7,.5,.3},