Created
October 9, 2021 19:47
-
-
Save andythenorth/64f3532ee4c148c5d7f9bf21ba36cda1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch(FEAT_INDUSTRIES, PARENT, increment_town_monthly_cycle_industry_counter, | |
[ | |
LOAD_PERM(${get_perm_num("this_cycle_industry_counter")}) < count_industries_in_town() | |
? | |
STORE_PERM( | |
LOAD_PERM(${get_perm_num("this_cycle_industry_counter")}) + 1, | |
${get_perm_num("this_cycle_industry_counter")} | |
) | |
: | |
0 | |
]) { | |
return; | |
} |
replace https://github.com/OpenTTD/nml/blob/master/nml/ast/switch.py#L130-L131 with
def is_read_only(self):
for result in [r.result for r in self.body.ranges] + [self.body.default]:
if result is not None and result.value is not None:
if not result.value.is_read_only():
return false
return self.expr.is_read_only()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Procedure monthly_town_loop is not read only (it writes to storage). However if the spurious STORE_PERM is not also used, the ${industry.id}__monthly_prod_change switch is evaluated as a constant result and optimised out.