mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
build.lua: add .sectsperbunch to map table, useful for TROR stats w/ findmaps.sh
Also, sync MAXBUNCHES to new limit in lunatic/defs_common.lua. git-svn-id: https://svn.eduke32.com/eduke32@3665 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
ec5cd930e0
commit
0dba35b207
3 changed files with 42 additions and 22 deletions
|
@ -287,7 +287,7 @@ enum {
|
|||
MAXTILES = 30720,
|
||||
MAXSPRITESONSCREEN = 4096,
|
||||
|
||||
MAXBUNCHES = 256,
|
||||
MAXBUNCHES = 512,
|
||||
CEILING = 0,
|
||||
FLOOR = 1,
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ local function get_numyaxbunches(map)
|
|||
end
|
||||
|
||||
local numbunches = 0
|
||||
local sectsperbunch = { [0]={}, [1]={} }
|
||||
|
||||
for i=0,map.numsectors-1 do
|
||||
for cf=0,1 do
|
||||
|
@ -129,11 +130,18 @@ local function get_numyaxbunches(map)
|
|||
if (xpan+1 > numbunches) then
|
||||
numbunches = xpan+1
|
||||
end
|
||||
|
||||
if (sectsperbunch[cf][xpan]==nil) then
|
||||
sectsperbunch[cf][xpan] = 1
|
||||
else
|
||||
sectsperbunch[cf][xpan] = sectsperbunch[cf][xpan]+1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return numbunches
|
||||
map.numbunches = numbunches
|
||||
map.sectsperbunch = sectsperbunch
|
||||
end
|
||||
|
||||
--== sprite canonicalizer ==--
|
||||
|
@ -195,6 +203,10 @@ end
|
|||
-- start =
|
||||
-- { x=<num>, y=<num>, z=<num>, ang=<num>, sectnum=<num> },
|
||||
-- numbunches = <num>,
|
||||
-- sectsperbunch = {
|
||||
-- [0] = { [<bunchnum>]=<number of ceilings> },
|
||||
-- [1] = { [<bunchnum>]=<number of floors> }
|
||||
-- }
|
||||
-- }
|
||||
function loadboard(filename, do_canonicalize_sprite)
|
||||
local fh, errmsg = io.open(filename)
|
||||
|
@ -284,7 +296,7 @@ function loadboard(filename, do_canonicalize_sprite)
|
|||
map.wall = set_secwalspr_mt(map.wall, map.numwalls)
|
||||
map.sprite = set_secwalspr_mt(map.sprite, map.numsprites)
|
||||
|
||||
map.numbunches = get_numyaxbunches(map)
|
||||
get_numyaxbunches(map)
|
||||
|
||||
-- done
|
||||
return map
|
||||
|
@ -389,11 +401,7 @@ function readdefs(fn)
|
|||
|
||||
local defs = {}
|
||||
|
||||
while (true) do
|
||||
local line = fh:read()
|
||||
if (line == nil) then
|
||||
break
|
||||
end
|
||||
for line in fh:lines() do
|
||||
local defname, numstr = string.match(line, "#?%s*define%s+([%a_][%w_]+)%s+([0-9]+)")
|
||||
if (defname) then
|
||||
defs[defname] = tonumber(numstr)
|
||||
|
|
|
@ -16,10 +16,14 @@
|
|||
|
||||
-- forxcode example: print sprite numbers with lotag < -1 (interpreting lotag it as signed),
|
||||
-- and for each matching sprite also print its lotag and picnum:
|
||||
-- ./findmaps.sh ~/.eduke32/ "sprite: .lotag < -1 :: io. write(', '.. .lotag .. ' ' .. .picnum)"
|
||||
-- $ ./findmaps.sh ~/.eduke32/ "sprite: .lotag < -1 :: io. write(', '.. .lotag .. ' ' .. .picnum)"
|
||||
|
||||
-- The local 'd' provides defs loaded from ../../names.h, example:
|
||||
-- ./findmaps.sh ~/.eduke32/ "sprite: .picnum>=d. CRACK1 and .picnum<=d. CRACK4"
|
||||
-- $ ./findmaps.sh ~/.eduke32/ "sprite: .picnum>=d. CRACK1 and .picnum<=d. CRACK4"
|
||||
|
||||
-- Print all V9 maps along with their number of bunches and max(ceilings of a bunch)
|
||||
-- $ prog='if (map.version==9) then print(map.numbunches.." ".. math.max(unpack(map.sectsperbunch[0],0)) .." "..fn) end'
|
||||
-- $ ./findmaps.sh ~/.eduke32 "$prog" |sort -n -k 2
|
||||
|
||||
local B = require "build"
|
||||
local string = require "string"
|
||||
|
@ -45,6 +49,14 @@ end
|
|||
|
||||
local modname = string.gsub(arg[1], "%.lua$", "")
|
||||
|
||||
function sum(tab, initidx)
|
||||
local s = 0
|
||||
for i=(initidx or 1),#tab do
|
||||
s = s + tab[i]
|
||||
end
|
||||
return s
|
||||
end
|
||||
|
||||
local mod
|
||||
if (modname:sub(1,2) == "-e") then
|
||||
local body = modname:sub(3)
|
||||
|
@ -68,25 +80,25 @@ if (modname:sub(1,2) == "-e") then
|
|||
perxcode = ""
|
||||
end
|
||||
|
||||
assert(what=="sector" or what=="wall" or what=="sprite")
|
||||
|
||||
body =
|
||||
"for i=0,num"..what.."s-1 do\n"..
|
||||
" if ("..body..") then\n"..
|
||||
(onlyfiles and "io.write(fn); return\n" or "io.write(fn..': '..i)\n") ..
|
||||
perxcode .. "io.write('\\n')"..
|
||||
"\n end\n"..
|
||||
perxcode .. "io.write('\\n')\n"..
|
||||
" end\n"..
|
||||
"end\n"
|
||||
end
|
||||
|
||||
local successfunc, errmsg = loadstring(
|
||||
"local d=require('build').readdefs('../../names.h') or error('Need ../../names.h')\n".. -- XXX
|
||||
"local numsectors, numwalls, numsprites\n"
|
||||
.."local sector, wall, sprite\n"
|
||||
.."return function (map, fn) \n"
|
||||
.." numsectors, numwalls, numsprites = map.numsectors, map.numwalls, map.numsprites\n"
|
||||
.." sector, wall, sprite = map.sector, map.wall, map.sprite\n"
|
||||
..body.."\n"
|
||||
.."end"
|
||||
)
|
||||
local successfunc, errmsg = loadstring([[
|
||||
local d=require('build').readdefs('../../names.h') or error('Need ../../names.h') -- XXX
|
||||
local numsectors, numwalls, numsprites, sector, wall, sprite
|
||||
return function (map, fn)
|
||||
numsectors, numwalls, numsprites = map.numsectors, map.numwalls, map.numsprites
|
||||
sector, wall, sprite = map.sector, map.wall, map.sprite
|
||||
]]..body
|
||||
.." end")
|
||||
|
||||
if (successfunc==nil) then
|
||||
io.stderr:write("Error loading string: "..errmsg.."\n")
|
||||
|
|
Loading…
Reference in a new issue