compress stats into a single number

This commit is contained in:
Not
2022-09-15 01:06:23 +02:00
parent 6953f343dc
commit 2d4784f62e
2 changed files with 20 additions and 17 deletions

View File

@ -253,19 +253,19 @@ local function score_t(map, name, skin, color, time, splits, flags, stat)
}
end
local MSK_SPEED = 0xF0
local MSK_WEIGHT = 0xF
local function stat_t(speed, weight)
if speed and weight then
return {
["speed"] = speed,
["weight"] = weight
}
return (speed << 4) | weight
end
return nil
return 0
end
local function stat_str(stat)
if stat then
return string.format("%d%d", stat["speed"], stat["weight"])
return string.format("%d%d", (stat & MSK_SPEED) >> 4, stat & MSK_WEIGHT)
end
return "0"
@ -987,11 +987,11 @@ local function drawScore(v, player, pos, x, y, gui, faceRank, score, drawPos, te
local pskin = score["skin"] and skins[score["skin"]]
if stat and not (
pskin
and pskin.kartweight == stat["weight"]
and pskin.kartspeed == stat["speed"]
and pskin.kartweight == stat & MSK_WEIGHT
and pskin.kartspeed == (stat & MSK_SPEED) >> 4
) then
v.drawString(x + FACERANK_DIM - 2, y + 4, stat["speed"], V_HUDTRANS | VFLAGS, "small")
v.drawString(x + FACERANK_DIM - 2, y + 8, stat["weight"], V_HUDTRANS | VFLAGS, "small")
v.drawString(x + FACERANK_DIM - 2, y + 4, (stat & MSK_SPEED) >> 4, V_HUDTRANS | VFLAGS, "small")
v.drawString(x + FACERANK_DIM - 2, y + 8, stat & MSK_WEIGHT, V_HUDTRANS | VFLAGS, "small")
end
if gui == GUI_ON or (gui == GUI_SPLITS and showSplit) then