Skip to content

Commit

Permalink
Merge pull request #32 from ozxybox/fix-helper-resources
Browse files Browse the repository at this point in the history
Fix FGD Helpers returning malformed resources
  • Loading branch information
TeamSpen210 authored Oct 7, 2024
2 parents 665dcdf + c16eb2c commit 19157fd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/srctools/_fgd_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,14 @@ def get_resources(self, entity: EntityDef) -> Iterator[str]:
for material in materials:
material = material.replace('\\', '/')

# Strip leading and trailing quotation marks if both present
if material.startswith('"') and material.endswith('"'):
material = material[1:-1]

# Don't append if the string is just empty!
if len(material) == 0:
continue

if not material.casefold().endswith('.vmt'):
material += '.vmt'
if not material.casefold().startswith('materials/'):
Expand Down Expand Up @@ -552,6 +560,14 @@ def get_resources(self, entity: EntityDef) -> Iterable[str]:
for mdl in models:
mdl = mdl.replace('\\', '/')

# Strip leading and trailing quotation marks if both present
if mdl.startswith('"') and mdl.endswith('"'):
mdl = mdl[1:-1]

# Don't append if the string is just empty!
if len(mdl) == 0:
continue

if not mdl.casefold().endswith('.mdl'):
mdl += '.mdl'
if not mdl.casefold().startswith('models/'):
Expand Down

0 comments on commit 19157fd

Please sign in to comment.