mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-27 09:20:51 +00:00
build.lua: add 'numbunches' field to map loader.
git-svn-id: https://svn.eduke32.com/eduke32@2966 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
948a716229
commit
a7eaac1add
1 changed files with 36 additions and 9 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
local ffi = require "ffi"
|
local ffi = require "ffi"
|
||||||
local io = require "io"
|
local io = require "io"
|
||||||
|
local bit = require "bit"
|
||||||
|
|
||||||
local error = error
|
local error = error
|
||||||
local assert = assert
|
local assert = assert
|
||||||
|
@ -104,6 +105,31 @@ local function set_secwalspr_mt(structar, maxidx)
|
||||||
return setmetatable({}, mt)
|
return setmetatable({}, mt)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function get_numyaxbunches(map)
|
||||||
|
if (map.version < 9) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local numbunches = 0
|
||||||
|
|
||||||
|
for i=0,map.numsectors-1 do
|
||||||
|
for cf=0,1 do
|
||||||
|
local sec = map.sector[i]
|
||||||
|
local stat = (cf==0) and sec.ceilingstat or sec.floorstat
|
||||||
|
local xpan = (cf==0) and sec.ceilingxpanning or sec.floorxpanning
|
||||||
|
|
||||||
|
if (bit.band(stat, 1024) ~= 0) then
|
||||||
|
if (xpan+1 > numbunches) then
|
||||||
|
numbunches = xpan+1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return numbunches
|
||||||
|
end
|
||||||
|
|
||||||
--== LOADBOARD ==--
|
--== LOADBOARD ==--
|
||||||
-- returns:
|
-- returns:
|
||||||
-- on failure, nil, errmsg
|
-- on failure, nil, errmsg
|
||||||
|
@ -115,7 +141,8 @@ end
|
||||||
-- wall=<cdata (array of walltype)>,
|
-- wall=<cdata (array of walltype)>,
|
||||||
-- sprite=nil or <cdata> (array of spritetype),
|
-- sprite=nil or <cdata> (array of spritetype),
|
||||||
-- start =
|
-- start =
|
||||||
-- { x=<num>, y=<num>, z=<num>, ang=<num>, sectnum=<num> }
|
-- { x=<num>, y=<num>, z=<num>, ang=<num>, sectnum=<num> },
|
||||||
|
-- numbunches = <num>,
|
||||||
-- }
|
-- }
|
||||||
function loadboard(filename)
|
function loadboard(filename)
|
||||||
local fh, errmsg = io.open(filename)
|
local fh, errmsg = io.open(filename)
|
||||||
|
@ -124,18 +151,16 @@ function loadboard(filename)
|
||||||
return nil, errmsg
|
return nil, errmsg
|
||||||
end
|
end
|
||||||
|
|
||||||
-- The table we'll return on success
|
|
||||||
local map = { start={} }
|
|
||||||
|
|
||||||
local cd = doread(fh, "int32_t", 4)
|
local cd = doread(fh, "int32_t", 4)
|
||||||
if (cd==nil) then
|
if (cd==nil) then
|
||||||
return nil, "Couldn't read header"
|
return nil, "Couldn't read header"
|
||||||
end
|
end
|
||||||
|
|
||||||
map.version = cd[0]
|
-- The table we'll return on success
|
||||||
map.start.x = cd[1]
|
local map = {
|
||||||
map.start.y = cd[2]
|
version = cd[0],
|
||||||
map.start.z = cd[3]
|
start = { x=cd[1], y=cd[2], z=cd[3] },
|
||||||
|
}
|
||||||
|
|
||||||
if (map.version < 7 or map.version > 9) then
|
if (map.version < 7 or map.version > 9) then
|
||||||
fh:close()
|
fh:close()
|
||||||
|
@ -196,13 +221,15 @@ function loadboard(filename)
|
||||||
if (map.numsprites~=0 and map.sprite == nil) then
|
if (map.numsprites~=0 and map.sprite == nil) then
|
||||||
return nil, "Couldn't read sprites"
|
return nil, "Couldn't read sprites"
|
||||||
end
|
end
|
||||||
|
fh:close()
|
||||||
|
|
||||||
map.sector = set_secwalspr_mt(map.sector, map.numsectors)
|
map.sector = set_secwalspr_mt(map.sector, map.numsectors)
|
||||||
map.wall = set_secwalspr_mt(map.wall, map.numwalls)
|
map.wall = set_secwalspr_mt(map.wall, map.numwalls)
|
||||||
map.sprite = set_secwalspr_mt(map.sprite, map.numsprites)
|
map.sprite = set_secwalspr_mt(map.sprite, map.numsprites)
|
||||||
|
|
||||||
|
map.numbunches = get_numyaxbunches(map)
|
||||||
|
|
||||||
-- done
|
-- done
|
||||||
fh:close()
|
|
||||||
return map
|
return map
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue