Compare commits
7 Commits
d9df5d6940
...
ghost
Author | SHA1 | Date | |
---|---|---|---|
adbdbb8c03 | |||
e833227b64 | |||
ef620772d9 | |||
46f787f543 | |||
d0e3698ee4 | |||
12ca9aca54 | |||
85e49ecd73 |
60
ghost.lua
60
ghost.lua
@ -75,6 +75,15 @@ local function Columns(line, sep)
|
||||
}
|
||||
end
|
||||
|
||||
local function compareTables(a, b, ...)
|
||||
for _, key in ipairs({...}) do
|
||||
if a[key] != b[key] then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
Ghosts = {
|
||||
map,
|
||||
players = {},
|
||||
@ -114,9 +123,16 @@ Ghosts = {
|
||||
this:reset()
|
||||
|
||||
local headers = Index:getMap(gamemap, mapChecksum(gamemap))
|
||||
local data
|
||||
local ok, data
|
||||
for _, header in ipairs(headers) do
|
||||
data = Ghost.read(header, Ghost.tableReader)
|
||||
ok, data = pcall(Ghost.read, header, Ghost.tableReader)
|
||||
if not ok then
|
||||
print(data)
|
||||
print("\x85\ERROR:\x80 invalid ghost data, removing entry")
|
||||
Index:remove(header)
|
||||
Index:write()
|
||||
continue
|
||||
end
|
||||
this:set(header, data)
|
||||
end
|
||||
end,
|
||||
@ -188,7 +204,7 @@ CV_RegisterVar({
|
||||
name = "lb_ghost_trans_prox",
|
||||
defaultvalue = 150,
|
||||
flags = CV_CALL,
|
||||
PossibleValue = CV_NATURAL,
|
||||
PossibleValue = CV_Natural,
|
||||
func = function(cv)
|
||||
transProximity = cv.value
|
||||
end
|
||||
@ -397,6 +413,10 @@ Server = {
|
||||
|
||||
transmitters = {},
|
||||
callback = function(cmd, handle)
|
||||
if handle.transmitters[cmd] then
|
||||
return
|
||||
end
|
||||
|
||||
local mapindex = Index:getMap(gamemap, mapChecksum(gamemap))
|
||||
local header = assert(mapindex[tonumber(cmd)])
|
||||
local data = Ghost.read(header, Ghost.stringReader)
|
||||
@ -449,7 +469,7 @@ Client = {
|
||||
end,
|
||||
|
||||
callback = function(data, this)
|
||||
local header
|
||||
local header, storedHeader
|
||||
local cmd = 1
|
||||
for str in data:gmatch("(.-)\n") do
|
||||
if Client.data:busy(cmd) then
|
||||
@ -457,7 +477,18 @@ Client = {
|
||||
end
|
||||
|
||||
header = Index.parseHeader(str)
|
||||
if not Index:find(header) then
|
||||
storedHeader = Index:find(header)
|
||||
if not (
|
||||
storedHeader
|
||||
and compareTables(
|
||||
header,
|
||||
storedHeader,
|
||||
"time",
|
||||
"flags",
|
||||
"skin",
|
||||
"color"
|
||||
)
|
||||
) then
|
||||
local tr = Transmitter("GC", {stream = true})
|
||||
tr:transmit(cmd)
|
||||
Client.data:listen(header, cmd)
|
||||
@ -559,7 +590,7 @@ local function open(filename, mode, fn)
|
||||
f:close()
|
||||
|
||||
if not ok then
|
||||
err = string.format("%s\n(%s (%s))", err, filename, mode)
|
||||
err = string.format("%s\n(\x82%s\x80 (%s))", err, filename, mode)
|
||||
end
|
||||
|
||||
return ok, err
|
||||
@ -582,6 +613,17 @@ Index = {
|
||||
this:setMap(header.map, header.checksum, map)
|
||||
end,
|
||||
|
||||
remove = function(this, header)
|
||||
local map = this:getMap(header.map, header.checksum)
|
||||
for i, h in ipairs(map) do
|
||||
if h.player == header.player then
|
||||
map[i] = nil
|
||||
this:setMap(header.map, header.checksum, map)
|
||||
return
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
find = function(this, header)
|
||||
local index = this:getMap(header.map, header.checksum)
|
||||
for i, h in ipairs(index) do
|
||||
@ -625,10 +667,10 @@ Index = {
|
||||
map = c:next(),
|
||||
checksum = c:next(),
|
||||
player = c:next(),
|
||||
time = c:next(),
|
||||
flags = c:next(),
|
||||
time = tonumber(c:next()),
|
||||
flags = tonumber(c:next()),
|
||||
skin = c:next(),
|
||||
color = c:next()
|
||||
color = tonumber(c:next())
|
||||
}
|
||||
end,
|
||||
|
||||
|
@ -1212,7 +1212,7 @@ local function saveTime(player)
|
||||
MapRecords = GetMapRecords(gamemap, mapChecksum(gamemap), ST_SEP)
|
||||
|
||||
-- Set the updated ScoreTable
|
||||
ScoreTable = MapRecords[Flags]
|
||||
ScoreTable = MapRecords[ST_SEP & Flags]
|
||||
|
||||
for i, score in ipairs(ScoreTable) do
|
||||
if score.name != player.name then continue end
|
||||
|
@ -90,7 +90,7 @@ end
|
||||
rawset(_G, "lb_transmitter", Transmitter)
|
||||
|
||||
addHook("ThinkFrame", function()
|
||||
if not #transmitters then return end
|
||||
if not (#transmitters and leveltime) then return end
|
||||
|
||||
local index = (leveltime % #transmitters) + 1
|
||||
local transmitter = transmitters[index]
|
||||
|
Reference in New Issue
Block a user