reject records missing checksum
This commit is contained in:
parent
08c1af3073
commit
34da7e2929
@ -13,6 +13,11 @@ records_lua = sys.argv[3]
|
|||||||
def ParseScore(score):
|
def ParseScore(score):
|
||||||
# Map Name Skin Color Time Splits Flags Stat
|
# Map Name Skin Color Time Splits Flags Stat
|
||||||
split = score.split("\t")
|
split = score.split("\t")
|
||||||
|
|
||||||
|
checksum = ""
|
||||||
|
if len(split) > 8:
|
||||||
|
checksum = split[8]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"map": split[0],
|
"map": split[0],
|
||||||
"name": split[1],
|
"name": split[1],
|
||||||
@ -21,7 +26,8 @@ def ParseScore(score):
|
|||||||
"time": int(split[4]),
|
"time": int(split[4]),
|
||||||
"splits": split[5],
|
"splits": split[5],
|
||||||
"flags": int(split[6]),
|
"flags": int(split[6]),
|
||||||
"stat": split[7]
|
"stat": split[7],
|
||||||
|
"checksum": checksum
|
||||||
}
|
}
|
||||||
|
|
||||||
# Compare scores
|
# Compare scores
|
||||||
@ -65,14 +71,20 @@ for score in recordsList:
|
|||||||
|
|
||||||
# convert records to flat list
|
# convert records to flat list
|
||||||
recordsList = []
|
recordsList = []
|
||||||
|
rejected = []
|
||||||
for mapTable in records.values():
|
for mapTable in records.values():
|
||||||
for score in mapTable:
|
for score in mapTable:
|
||||||
recordsList.append("\t".join([str(v) for v in list(score.values())]))
|
scoreStr = "\t".join([str(v) for v in list(score.values())])
|
||||||
|
# only allow records with checksums
|
||||||
|
if score["checksum"] != "":
|
||||||
|
recordsList.append(scoreStr)
|
||||||
|
else:
|
||||||
|
rejected.append(scoreStr)
|
||||||
|
|
||||||
# truncate and write records to coldstore
|
# truncate and write records to coldstore
|
||||||
with open(coldstore_txt, "w") as f:
|
with open(coldstore_txt, "w") as f:
|
||||||
for score in recordsList:
|
for score in recordsList:
|
||||||
f.write(score + linesep)
|
f.write(score + linesep)
|
||||||
|
|
||||||
luaA = """local ParseScore = lb_parse_score
|
luaA = """local ParseScore = lb_parse_score
|
||||||
local AddColdStore = lb_add_coldstore_record
|
local AddColdStore = lb_add_coldstore_record
|
||||||
@ -90,5 +102,7 @@ with open(records_lua, "w") as f:
|
|||||||
f.write("\"{}\",{}".format(score, linesep))
|
f.write("\"{}\",{}".format(score, linesep))
|
||||||
f.write(luaB)
|
f.write(luaB)
|
||||||
|
|
||||||
# truncate leaderboard.txt
|
# truncate and rewrite rejected scores to leaderboard.txt
|
||||||
with open(leaderboard_txt, "w"): pass
|
with open(leaderboard_txt, "w") as f:
|
||||||
|
for score in rejected:
|
||||||
|
f.write(score + linesep)
|
||||||
|
Loading…
Reference in New Issue
Block a user