Compress data files (reduces size by a factor 3-4)

This commit is contained in:
Gael-de-Sailly
2020-04-13 15:59:34 +02:00
parent da98a538bb
commit af7a7ce26d
4 changed files with 28 additions and 13 deletions

View File

@ -1,11 +1,12 @@
local function load_map(filename, bytes, signed)
local function load_map(filename, bytes, signed, size)
local file = io.open(filename, 'r')
local data = file:read('*all')
if #data < bytes*size then
data = minetest.decompress(data)
end
local map = {}
local size = math.floor(#data/bytes)
for i=1, size do
local i0, i1 = (i-1)*bytes+1, i*bytes
local elements = {data:byte(i0, i1)}