mirror of
https://github.com/freedoom/freedoom.git
synced 2025-09-01 13:25:46 -04:00
textures: Only include patches needed by textures.
Now that #1 is fixed, we can be certain that all patches needed for compatibility are definitely being included in the PNAMES lists. It therefore isn't necessary to include every patch in the patches/ directory in every WAD. Extend the build-textures script to generate a text file containing the list of PNAMES, and include this from the main config file. That way, each IWAD only gets the patches it explicitly needs.
This commit is contained in:
parent
8226ee624d
commit
71b30afa92
6 changed files with 43 additions and 91 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,7 +9,6 @@ lumps/freedm.lmp
|
|||
sprites/jond/placeholder/*.gif
|
||||
wads/*.wad
|
||||
wads/*.zip
|
||||
pnames.txt
|
||||
wad*.txt
|
||||
*.bak
|
||||
*.pyc
|
||||
|
|
14
Makefile
14
Makefile
|
@ -58,18 +58,15 @@ force:
|
|||
lumps/freedoom.lmp lumps/freedm.lmp: force
|
||||
echo $(VERSION) > $@
|
||||
|
||||
pnames.txt:
|
||||
scripts/extract-pnames.py -a > $@
|
||||
|
||||
# update wadinfo.txt
|
||||
|
||||
wadinfo.txt: buildcfg.txt force pnames.txt
|
||||
wadinfo.txt: buildcfg.txt force
|
||||
$(CPP) -P -DDOOM2 < $< | scripts/wadinfo-builder.py > $@
|
||||
wadinfo_phase1.txt: buildcfg.txt force pnames.txt
|
||||
wadinfo_phase1.txt: buildcfg.txt force
|
||||
$(CPP) -P -DDOOM1 -DULTDOOM < $< | scripts/wadinfo-builder.py -dummy > $@
|
||||
wadinfo_phase2.txt: buildcfg.txt force pnames.txt
|
||||
wadinfo_phase2.txt: buildcfg.txt force
|
||||
$(CPP) -P -DDOOM2 < $< | scripts/wadinfo-builder.py -dummy > $@
|
||||
wadinfo_freedm.txt : buildcfg.txt force pnames.txt
|
||||
wadinfo_freedm.txt : buildcfg.txt force
|
||||
$(CPP) -P -DFREEDM < $< | scripts/wadinfo-builder.py -dummy > $@
|
||||
|
||||
%.wad.gz: %.wad
|
||||
|
@ -122,8 +119,7 @@ clean:
|
|||
./wadinfo.txt ./wadinfo_phase1.txt \
|
||||
./wadinfo_phase2.txt ./wadinfo_freedm.txt \
|
||||
./lumps/freedoom.lmp \
|
||||
./lumps/freedm.lmp \
|
||||
pnames.txt
|
||||
./lumps/freedm.lmp
|
||||
-rmdir $(WADS)
|
||||
|
||||
$(MAKE) -C graphics/text clean
|
||||
|
|
10
buildcfg.txt
10
buildcfg.txt
|
@ -2557,7 +2557,15 @@ YSKUB0 7 18
|
|||
|
||||
[patches]
|
||||
|
||||
#include "pnames.txt"
|
||||
#ifdef DOOM1
|
||||
#include "lumps/textures/phase1/pnames.txt"
|
||||
#else
|
||||
#ifdef FREEDM
|
||||
#include "lumps/textures/freedm/pnames.txt"
|
||||
#else
|
||||
#include "lumps/textures/phase2/pnames.txt"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
[flats]
|
||||
|
||||
|
|
|
@ -10,25 +10,29 @@ phase1/texture1.lmp:
|
|||
-compat_pnames=doom1/pnames.txt \
|
||||
-output_texture1=phase1/texture1.lmp \
|
||||
-output_texture2=phase1/texture2.lmp \
|
||||
-output_pnames=phase1/pnames.lmp
|
||||
-output_pnames=phase1/pnames.lmp \
|
||||
-output_pnames_txt=phase1/pnames.txt
|
||||
|
||||
phase2/texture1.lmp:
|
||||
$(CPP) -DDOOM1 -DDOOM2 < textures.cfg | \
|
||||
./build-textures -compat_texture1=doom2/texture1.txt \
|
||||
-compat_pnames=doom2/pnames.txt \
|
||||
-output_texture1=phase2/texture1.lmp \
|
||||
-output_pnames=phase2/pnames.lmp
|
||||
-output_pnames=phase2/pnames.lmp \
|
||||
-output_pnames_txt=phase2/pnames.txt
|
||||
|
||||
freedm/texture1.lmp:
|
||||
$(CPP) -DDOOM1 -DDOOM2 -DFREEDM < textures.cfg | \
|
||||
./build-textures -compat_texture1=doom2/texture1.txt \
|
||||
-compat_pnames=doom2/pnames.txt \
|
||||
-output_texture1=freedm/texture1.lmp \
|
||||
-output_pnames=freedm/pnames.lmp
|
||||
-output_pnames=freedm/pnames.lmp \
|
||||
-output_pnames_txt=freedm/pnames.txt
|
||||
|
||||
|
||||
clean:
|
||||
rm -f phase1/texture1.lmp phase1/texture2.lmp phase1/pnames.lmp \
|
||||
phase2/texture1.lmp phase2/pnames.lmp \
|
||||
freedm/texture1.lmp freedm/pnames.lmp
|
||||
phase1/pnames.txt \
|
||||
phase2/texture1.lmp phase2/pnames.lmp phase2/pnames.txt \
|
||||
freedm/texture1.lmp freedm/pnames.lmp freedm/pnames.txt
|
||||
|
||||
|
|
|
@ -96,10 +96,11 @@ class TextureSet(collections.OrderedDict):
|
|||
Returns:
|
||||
Index into the PNAMES list where this patch can be found.
|
||||
"""
|
||||
pname = pname.upper()
|
||||
try:
|
||||
return self.pnames.index(pname)
|
||||
except ValueError:
|
||||
self.pnames.append(pname.upper())
|
||||
self.pnames.append(pname)
|
||||
return len(self.pnames) - 1
|
||||
|
||||
def add_texture(self, name, width=0, height=0):
|
||||
|
@ -114,6 +115,7 @@ class TextureSet(collections.OrderedDict):
|
|||
width: Width of the texture in pixels.
|
||||
height: Height of the texture in pixels.
|
||||
"""
|
||||
name = name.upper()
|
||||
self[name] = Texture(width, height, [])
|
||||
|
||||
def add_texture_patch(self, txname, patch, x, y):
|
||||
|
@ -125,6 +127,7 @@ class TextureSet(collections.OrderedDict):
|
|||
x: X offset for the patch in pixels.
|
||||
y: Y offset for the patch in pixels.
|
||||
"""
|
||||
txname = txname.upper()
|
||||
texture = self[txname]
|
||||
tp = TexturePatch(self.pname_index(patch), x, y)
|
||||
texture.patches.append(tp)
|
||||
|
@ -185,6 +188,17 @@ def read_names_file(filename):
|
|||
result.append(line.upper())
|
||||
return result
|
||||
|
||||
def write_names_file(names, filename):
|
||||
"""Write a list of names to a file.
|
||||
|
||||
Args:
|
||||
names: List of names to write.
|
||||
filename: Filename to write them to.
|
||||
"""
|
||||
with open(filename, "w") as f:
|
||||
for name in names:
|
||||
f.write("%s\n" % name)
|
||||
|
||||
def load_compat_textures(textures, compat_file):
|
||||
"""Pre-populate a texture set from a compatibility file.
|
||||
|
||||
|
@ -276,6 +290,7 @@ Full list of arguments:
|
|||
-output_texture1: Path to the TEXTURE1 lump to generate (required).
|
||||
-output_texture2: Path to the TEXTURE2 lump to generate.
|
||||
-output_pnames: Path to the PNAMES lump to generate (required).
|
||||
-output_pnames_txt: Path to a text file to save a list of PNAMES.
|
||||
-compat_texture1: File containing compatibility list of TEXTURE1 textures
|
||||
-compat_texture2: File containing compatibility list of TEXTURE2 textures
|
||||
-compat_pnames: File containing compatibility list of PNAMES
|
||||
|
@ -293,7 +308,8 @@ def parse_command_line(args):
|
|||
|
||||
# Parse command line:
|
||||
valid_args = ("compat_texture1", "compat_texture2", "compat_pnames",
|
||||
"output_texture1", "output_texture2", "output_pnames")
|
||||
"output_texture1", "output_texture2", "output_pnames",
|
||||
"output_pnames_txt")
|
||||
result = {arg: None for arg in valid_args}
|
||||
|
||||
for arg in args:
|
||||
|
@ -349,4 +365,6 @@ texture1.write_texture_lump(args["output_texture1"])
|
|||
if args["output_texture2"]:
|
||||
texture2.write_texture_lump(args["output_texture2"])
|
||||
write_pnames_lump(pnames, args["output_pnames"])
|
||||
if args["output_pnames_txt"]:
|
||||
write_names_file(sorted(pnames), args["output_pnames_txt"])
|
||||
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||
# Contributors to the Freedoom project. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the freedoom project nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import glob
|
||||
|
||||
texture_re = re.compile(r'\*\s+(\w+)')
|
||||
|
||||
# Parse a TEXTURE1 file and generate a list of patches
|
||||
|
||||
def parse_texture_file():
|
||||
patches = {}
|
||||
|
||||
for line in sys.stdin:
|
||||
match = texture_re.match(line)
|
||||
|
||||
if match:
|
||||
name = match.group(1)
|
||||
|
||||
patches[name] = True
|
||||
|
||||
print("; autogenerated patch list\n")
|
||||
|
||||
for name in sorted(patches.keys()):
|
||||
print(name)
|
||||
|
||||
# Generate a full list of textures from the files in the
|
||||
# patches/ directory
|
||||
|
||||
def list_all_textures():
|
||||
print("; autogenerated patch list\n")
|
||||
|
||||
for filename in sorted(glob.glob("patches/*.gif")):
|
||||
base = os.path.basename(filename)
|
||||
patch_name = base[0:-4]
|
||||
print(patch_name)
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
parse_texture_file()
|
||||
elif sys.argv[1] == "-a":
|
||||
list_all_textures()
|
||||
else:
|
||||
print("Usage: extract-pnames.py [-a]")
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue