Use builtin ZIP writing functionality for performance reasons.
This commit is contained in:
parent
3756979b6a
commit
ce0639fd40
4 changed files with 11 additions and 3537 deletions
3525
LibDeflate.lua
3525
LibDeflate.lua
File diff suppressed because it is too large
Load diff
|
@ -75,7 +75,7 @@ lsnes and it will display a message to the Lua console and stderr on how to use
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
* Only tested on Pirate Panic
|
* Only tested on Pirate Panic
|
||||||
* The pool files are gzipped Serpent data
|
* The pool files are PKZIP files with one file, data.serpent, containing Serpent-formatted data
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ _M.State = {
|
||||||
"MainbraceMayhemTopOfRope.lsmv", -- [6]
|
"MainbraceMayhemTopOfRope.lsmv", -- [6]
|
||||||
}
|
}
|
||||||
|
|
||||||
_M.Filename = _M.PoolDir .. _M.State[6]
|
_M.Filename = _M.PoolDir .. _M.State[4]
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Start game with specific powerup.
|
Start game with specific powerup.
|
||||||
|
|
19
pool.lua
19
pool.lua
|
@ -1,4 +1,4 @@
|
||||||
local callback, set_timer_timeout = callback, set_timer_timeout
|
local callback, set_timer_timeout, zip = callback, set_timer_timeout, zip
|
||||||
|
|
||||||
local base = string.gsub(@@LUA_SCRIPT_FILENAME@@, "(.*[/\\])(.*)", "%1")
|
local base = string.gsub(@@LUA_SCRIPT_FILENAME@@, "(.*[/\\])(.*)", "%1")
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ local Promise = dofile(base.."/promise.lua")
|
||||||
local config = dofile(base.."/config.lua")
|
local config = dofile(base.."/config.lua")
|
||||||
local util = dofile(base.."/util.lua")(Promise)
|
local util = dofile(base.."/util.lua")(Promise)
|
||||||
local serpent = dofile(base.."/serpent.lua")
|
local serpent = dofile(base.."/serpent.lua")
|
||||||
local libDeflate = dofile(base.."/LibDeflate.lua")
|
local zzlib = dofile(base.."/zzlib.lua")
|
||||||
|
|
||||||
local hasThreads = config.NeatConfig.Threads > 1
|
local hasThreads = config.NeatConfig.Threads > 1
|
||||||
|
|
||||||
|
@ -416,14 +416,12 @@ end
|
||||||
---@return Promise Promise A promise that resolves when the file is saved.
|
---@return Promise Promise A promise that resolves when the file is saved.
|
||||||
local function writeFile(filename)
|
local function writeFile(filename)
|
||||||
return util.promiseWrap(function ()
|
return util.promiseWrap(function ()
|
||||||
local file = io.open(filename, "w")
|
local file = zip.writer.new(filename)
|
||||||
|
file:create_file('data.serpent')
|
||||||
local dump = serpent.dump(pool)
|
local dump = serpent.dump(pool)
|
||||||
local zlib = libDeflate:CompressDeflate(dump)
|
file:write(dump)
|
||||||
file:write("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x00")
|
file:close_file()
|
||||||
file:write(zlib)
|
file:commit()
|
||||||
file:write(string.char(0,0,0,0))
|
|
||||||
file:write(bytes(#dump % (2^32)))
|
|
||||||
file:close()
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -437,7 +435,8 @@ local function loadFile(filename)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local contents = file:read("*all")
|
local contents = file:read("*all")
|
||||||
local decomp, _ = libDeflate:DecompressDeflate(contents:sub(11, #contents - 8))
|
file:close()
|
||||||
|
local decomp = zzlib.unzip(contents, 'data.serpent')
|
||||||
local ok, obj = serpent.load(decomp)
|
local ok, obj = serpent.load(decomp)
|
||||||
if not ok then
|
if not ok then
|
||||||
message("Error parsing pool file", 0x00990000)
|
message("Error parsing pool file", 0x00990000)
|
||||||
|
|
Loading…
Add table
Reference in a new issue