Compare commits
3 Commits
12ca9aca54
...
ef620772d9
Author | SHA1 | Date | |
---|---|---|---|
ef620772d9 | |||
46f787f543 | |||
d0e3698ee4 |
34
ghost.lua
34
ghost.lua
@ -123,9 +123,16 @@ Ghosts = {
|
|||||||
this:reset()
|
this:reset()
|
||||||
|
|
||||||
local headers = Index:getMap(gamemap, mapChecksum(gamemap))
|
local headers = Index:getMap(gamemap, mapChecksum(gamemap))
|
||||||
local data
|
local ok, data
|
||||||
for _, header in ipairs(headers) do
|
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)
|
this:set(header, data)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -406,6 +413,10 @@ Server = {
|
|||||||
|
|
||||||
transmitters = {},
|
transmitters = {},
|
||||||
callback = function(cmd, handle)
|
callback = function(cmd, handle)
|
||||||
|
if handle.transmitters[cmd] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local mapindex = Index:getMap(gamemap, mapChecksum(gamemap))
|
local mapindex = Index:getMap(gamemap, mapChecksum(gamemap))
|
||||||
local header = assert(mapindex[tonumber(cmd)])
|
local header = assert(mapindex[tonumber(cmd)])
|
||||||
local data = Ghost.read(header, Ghost.stringReader)
|
local data = Ghost.read(header, Ghost.stringReader)
|
||||||
@ -579,7 +590,7 @@ local function open(filename, mode, fn)
|
|||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
if not ok then
|
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
|
end
|
||||||
|
|
||||||
return ok, err
|
return ok, err
|
||||||
@ -602,6 +613,17 @@ Index = {
|
|||||||
this:setMap(header.map, header.checksum, map)
|
this:setMap(header.map, header.checksum, map)
|
||||||
end,
|
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)
|
find = function(this, header)
|
||||||
local index = this:getMap(header.map, header.checksum)
|
local index = this:getMap(header.map, header.checksum)
|
||||||
for i, h in ipairs(index) do
|
for i, h in ipairs(index) do
|
||||||
@ -645,10 +667,10 @@ Index = {
|
|||||||
map = c:next(),
|
map = c:next(),
|
||||||
checksum = c:next(),
|
checksum = c:next(),
|
||||||
player = c:next(),
|
player = c:next(),
|
||||||
time = c:next(),
|
time = tonumber(c:next()),
|
||||||
flags = c:next(),
|
flags = tonumber(c:next()),
|
||||||
skin = c:next(),
|
skin = c:next(),
|
||||||
color = c:next()
|
color = tonumber(c:next())
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user