Skip to content

Commit

Permalink
#277: Enforce lua_run casing via postcompiler
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSpen210 committed Sep 14, 2024
1 parent e42fc80 commit bf1aa35
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Fix various incorrect usages of the FGD `frustum()` helper.
* Normals are now correctly calculated when generating propcombined models. This requires all previous models to be rebuilt, unfortunately.
* Fix overlays not functioning with `material_modify_control` parent searching.
* #274: Force `light_environment` to use the required `SunSpreadAngle` casing.
* #274, #277: Force required keyvalue casing for `light_environment`'s `SunSpreadAngle` and `lua_run`'s `Code` keys.


--------------------
Expand Down
27 changes: 27 additions & 0 deletions transforms/fgd_tweaks/case_sensitive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Some keyvalues are case-sensitive, force the required casing."""
from srctools import VMF, logger

from hammeraddons.bsp_transform import Context, trans
from hammeraddons.bsp_transform.common import ent_description

LOGGER = logger.get_logger(__name__)


@trans('FGD - Fix key casing')
def force_case_sensitivity(ctx: Context) -> None:
"""Force case-sensitivity on some keyvalues that require it."""
fix_casing(ctx.vmf, 'light_environment', 'SunSpreadAngle')
fix_casing(ctx.vmf, 'light_directional', 'SunSpreadAngle')
fix_casing(ctx.vmf, 'lua_run', 'Code')


def fix_casing(vmf: VMF, classname: str, *keys: str) -> None:
"""Fix the casing for one entity."""
for ent in vmf.by_class[classname]:
for key in keys:
if value := ent.pop(key):
LOGGER.warning(
'Correcting case of "{}" for {}',
key, ent_description(ent),
)
ent[key] = value
10 changes: 0 additions & 10 deletions transforms/fgd_tweaks/light_sun_spread_angle.py

This file was deleted.

0 comments on commit bf1aa35

Please sign in to comment.