Skip to content

Commit

Permalink
Add option to strip cubemaps from the BSP
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSpen210 committed Nov 29, 2022
1 parent 761e420 commit b6d4101
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
* Added icon for `npc_heli_avoidsphere`.
* Change propcombine/geocable to log just the number of culled models, not every single file.
* TF2 now has VScript support, updated FGDs to include the corresponding options.
* Add new blocklist/allowlist options to permit fine-grained control of which files get packed.
* Added new blocklist/allowlist options to permit fine-grained control of which files get packed.
* A specific option was added to strip existing cubemap files from the map, if this is necessary to fix crashes while building cubemaps.

--------------------

Expand Down
12 changes: 12 additions & 0 deletions src/hammeraddons/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
PATHS_NAME: Final = 'srctools_paths.vdf'
GAME_KEY: Final = 'gameinfo_path'

# Matches cubemap files. Put here, so we can write it into the docstring.
CUBEMAP_REGEX = r"materials/maps/.*/(c[0-9-]+_[0-9-]+_[0-9-]+|cubemapdefault)(\.hdr)?\.vtf"

PATHS_CONF_STARTER: Final = '''\
// This config contains a list of directories which can be referenced by the main config.
// Keeping this a separate file allows the main config to be shared in a mod team, while this
Expand Down Expand Up @@ -269,6 +272,15 @@ def packfile_filters(block: Keyvalues, kind: str) -> Iterator[re_Pattern[str]]:
destination, not the BSP pakfile.
""")

PACK_STRIP_CUBEMAPS = Opt.boolean(
'pack_strip_cubemaps', False,
f"""If set, strip the generated cubemap files from the BSP. This is necessary for 2013-branch
games to allow cubemaps to be built properly.
This is equivalent to adding {CUBEMAP_REGEX!r} as a regex "pack_blocklist".
"""
)

PACK_TAGS = Opt.block(
'pack_tags', Keyvalues('', [
Keyvalues('hl2', '0'),
Expand Down
3 changes: 3 additions & 0 deletions src/hammeraddons/postcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ async def main(argv: List[str]) -> None:
pack_allowlist = list(config.packfile_filters(conf.opts.get(config.PACK_ALLOWLIST), 'allowlist'))
pack_blocklist = list(config.packfile_filters(conf.opts.get(config.PACK_BLOCKLIST), 'blocklist'))

if conf.opts.get(config.PACK_STRIP_CUBEMAPS):
pack_blocklist.append(re.compile(config.CUBEMAP_REGEX))

LOGGER.debug('Packing allowlist={}, blocklist={}', pack_allowlist, pack_blocklist)

def pack_callback(path: str) -> Optional[bool]:
Expand Down

0 comments on commit b6d4101

Please sign in to comment.