Compare commits
No commits in common. "52316347dabd330aa9d64f6881f7cea33bbed445" and "f824e760e3519d9cf3b0bd5a61d9dcc307e47ab5" have entirely different histories.
52316347da
...
f824e760e3
@ -229,6 +229,7 @@ do
|
|||||||
|
|
||||||
for l in f:lines() do
|
for l in f:lines() do
|
||||||
local score = parseScore(l)
|
local score = parseScore(l)
|
||||||
|
print(score.name)
|
||||||
LiveStore[score.map] = $ or {}
|
LiveStore[score.map] = $ or {}
|
||||||
table.insert(LiveStore[score.map], score)
|
table.insert(LiveStore[score.map], score)
|
||||||
end
|
end
|
||||||
|
@ -1,94 +0,0 @@
|
|||||||
#!/bin/python
|
|
||||||
import sys
|
|
||||||
from os import linesep
|
|
||||||
|
|
||||||
if len(sys.argv) != 4 or not sys.argv[1] or not sys.argv[2] or not sys.argv[3]:
|
|
||||||
print("Usage: coldstore.py <leaderboard.txt> <coldstore.txt> <leaderboard_records.lua>")
|
|
||||||
quit()
|
|
||||||
|
|
||||||
leaderboard_txt = sys.argv[1]
|
|
||||||
coldstore_txt = sys.argv[2]
|
|
||||||
records_lua = sys.argv[3]
|
|
||||||
|
|
||||||
def ParseScore(score):
|
|
||||||
# Map Name Skin Color Time Splits Flags Stat
|
|
||||||
split = score.split("\t")
|
|
||||||
return {
|
|
||||||
"map": split[0],
|
|
||||||
"name": split[1],
|
|
||||||
"skin": split[2],
|
|
||||||
"color": split[3],
|
|
||||||
"time": int(split[4]),
|
|
||||||
"splits": split[5],
|
|
||||||
"flags": int(split[6]),
|
|
||||||
"stat": split[7]
|
|
||||||
}
|
|
||||||
|
|
||||||
# Compare scores
|
|
||||||
def CompareScore(a, b):
|
|
||||||
return a["time"] < b["time"]
|
|
||||||
|
|
||||||
F_SEP = 0xF
|
|
||||||
def SameScore(a, b):
|
|
||||||
return a["name"] == b["name"] and (a["flags"] & F_SEP) == (b["flags"] & F_SEP)
|
|
||||||
|
|
||||||
def LoadRecordsFromFile(path):
|
|
||||||
records = []
|
|
||||||
with open(path, "r") as f:
|
|
||||||
for line in f.readlines():
|
|
||||||
records.append(ParseScore(line.strip()))
|
|
||||||
return records
|
|
||||||
|
|
||||||
def AddScore(records, score):
|
|
||||||
mapid = score["map"]
|
|
||||||
mapTable = records.get(mapid) or []
|
|
||||||
|
|
||||||
for i in range(len(mapTable)):
|
|
||||||
scoreb = mapTable[i]
|
|
||||||
if SameScore(score, scoreb):
|
|
||||||
if CompareScore(score, scoreb):
|
|
||||||
mapTable[i] = score
|
|
||||||
records[mapid] = mapTable
|
|
||||||
return
|
|
||||||
mapTable.append(score)
|
|
||||||
records[mapid] = mapTable
|
|
||||||
|
|
||||||
# load leaderboard.txt and coldstore.txt
|
|
||||||
recordsList = LoadRecordsFromFile(leaderboard_txt)
|
|
||||||
recordsList.extend(LoadRecordsFromFile(coldstore_txt))
|
|
||||||
|
|
||||||
|
|
||||||
# construct the map tables
|
|
||||||
records = {}
|
|
||||||
for score in recordsList:
|
|
||||||
AddScore(records, score)
|
|
||||||
|
|
||||||
# convert records to flat list
|
|
||||||
recordsList = []
|
|
||||||
for mapTable in records.values():
|
|
||||||
for score in mapTable:
|
|
||||||
recordsList.append("\t".join([str(v) for v in list(score.values())]))
|
|
||||||
|
|
||||||
# truncate and write records to coldstore
|
|
||||||
with open(coldstore_txt, "w") as f:
|
|
||||||
for score in recordsList:
|
|
||||||
f.write(score + linesep)
|
|
||||||
|
|
||||||
luaA = """local ParseScore = lb_parse_score
|
|
||||||
local AddColdStore = lb_add_coldstore_record
|
|
||||||
local records = {
|
|
||||||
"""
|
|
||||||
luaB = """}
|
|
||||||
for _, str in ipairs(records) do
|
|
||||||
AddColdStore(ParseScore(str))
|
|
||||||
end
|
|
||||||
"""
|
|
||||||
# pack the records.lua file
|
|
||||||
with open(records_lua, "w") as f:
|
|
||||||
f.write(luaA)
|
|
||||||
for score in recordsList:
|
|
||||||
f.write("\"{}\",{}".format(score, linesep))
|
|
||||||
f.write(luaB)
|
|
||||||
|
|
||||||
# truncate leaderboard.txt
|
|
||||||
with open(leaderboard_txt, "w"): pass
|
|
Loading…
x
Reference in New Issue
Block a user