mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
lunatic/util/build.lua: in readdefs(), add option of requesting picnum->name mapping.
That is, the reverse of what is returned with the first outarg. Use that in lunatic/util/foreachmap.lua. DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@4499 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
1e5549dc2f
commit
4780912b40
2 changed files with 15 additions and 4 deletions
|
@ -607,14 +607,15 @@ function loadarts(filenames)
|
||||||
return tile
|
return tile
|
||||||
end
|
end
|
||||||
|
|
||||||
function readdefs(fn)
|
-- defs [, rdefs] = readdefs(fn [, alsoreverse])
|
||||||
|
function readdefs(fn, alsoreverse)
|
||||||
local fh, errmsg = io.open(fn)
|
local fh, errmsg = io.open(fn)
|
||||||
|
|
||||||
if (fh==nil) then
|
if (fh==nil) then
|
||||||
return nil, errmsg
|
return nil, errmsg
|
||||||
end
|
end
|
||||||
|
|
||||||
local defs = {}
|
local defs, rdefs = {}, nil
|
||||||
|
|
||||||
for line in fh:lines() do
|
for line in fh:lines() do
|
||||||
local defname, numstr = string.match(line, "#?%s*define%s+([%a_][%w_]+)%s+([0-9]+)")
|
local defname, numstr = string.match(line, "#?%s*define%s+([%a_][%w_]+)%s+([0-9]+)")
|
||||||
|
@ -623,6 +624,13 @@ function readdefs(fn)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if (alsoreverse) then
|
||||||
|
rdefs = {}
|
||||||
|
for defname, num in pairs(defs) do
|
||||||
|
rdefs[num] = defname
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
fh:close()
|
fh:close()
|
||||||
return defs
|
return defs, rdefs
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
-- $ ./findmaps.sh ~/.eduke32/ "sprite: .picnum>=d.CRACK1 and .picnum<=d.CRACK4"
|
-- $ ./findmaps.sh ~/.eduke32/ "sprite: .picnum>=d.CRACK1 and .picnum<=d.CRACK4"
|
||||||
-- (Now: no space between "d." and "CRACK" is necessary ".xxx" is translated to
|
-- (Now: no space between "d." and "CRACK" is necessary ".xxx" is translated to
|
||||||
-- "sprite[<current>].xxx" only if it's the name of a sprite member.)
|
-- "sprite[<current>].xxx" only if it's the name of a sprite member.)
|
||||||
|
-- The local 'rdefs' provides the reverse mapping: from picnums to tile names
|
||||||
|
-- (or nil).
|
||||||
|
|
||||||
-- Print all V9 maps along with their number of bunches and max(ceilings of a bunch)
|
-- 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'
|
-- $ prog='if (map.version==9) then print(map.numbunches.." ".. math.max(unpack(map.sectsperbunch[0],0)) .." "..fn) end'
|
||||||
|
@ -119,7 +121,8 @@ if (modname:sub(1,2) == "-e") then
|
||||||
if (x==tab[i]) then return true end
|
if (x==tab[i]) then return true end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local d=require('build').readdefs('../../names.h') or error('Need ../../names.h') -- XXX
|
local d,rdefs = require('build').readdefs('../../names.h',true)
|
||||||
|
if (not d) then error('Need ../../names.h') end -- XXX
|
||||||
local numsectors, numwalls, numsprites, sector, wall, sprite
|
local numsectors, numwalls, numsprites, sector, wall, sprite
|
||||||
return function (map, fn)
|
return function (map, fn)
|
||||||
numsectors, numwalls, numsprites = map.numsectors, map.numwalls, map.numsprites
|
numsectors, numwalls, numsprites = map.numsectors, map.numwalls, map.numsprites
|
||||||
|
|
Loading…
Reference in a new issue