6 return s.split(/\r?\n/).find_all() do |l| l[0, 2] != '//' end
11 mapstr = File.read("#{base}.map")
12 entstr = File.read("#{base}.ent")
15 File.open("#{base}.map~", "w") do |fh|
18 File.open("#{base}.ent~", "w") do |fh|
22 def brushparse(l, index)
25 while index < l.length()
42 raise SyntaxError, "in brush: " + l[index]
49 def entparse(l, index)
52 while index < l.length()
57 index, brush = brushparse(l, index + 1)
59 when %r{^"([^"]*)" "(.*)"$}
64 raise SyntaxError, "in entity: " + l[index]
69 entity[:brushes] = brushes
77 while index < l.length()
80 index, entity = entparse(l, index + 1)
85 raise SyntaxError, "in map: " + l[index]
105 next if k == :brushes
106 yield '"%s" "%s"' % [k, v]
109 e[:brushes].each() do |b|
119 entities.each() do |e|
126 map = mapparse(preprocess(mapstr))
127 ent = mapparse(preprocess(entstr))
134 when e['classname'] == 'light'
136 when e['classname'] == 'func_group'
139 submodels << e[:brushes]
145 when (e['classname'] == 'worldspawn') || (e['model'] && e['model'][0, 1] == '*')
147 e[:brushes] = submodels.shift()
151 File.open("#{base}.map", "w") do |fh|
152 mapout(ent + unchanged) do |l|
157 File.unlink("#{base}.ent")