Skip to content

Commit

Permalink
Fix: Procedure calls in switch ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
glx22 committed Jun 3, 2020
1 parent 1d67cce commit 9ccffc3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nml/actions/action2var.py
Expand Up @@ -697,7 +697,7 @@ def parse_minmax(value, unit_str, action_list, act6, offset):

return_action_id = 0

def create_return_action(expr, feature, name, var_range):
def create_return_action(expr, feature, name, var_range, parent_action = None):
"""
Create a varaction2 to return the computed value
Expand Down Expand Up @@ -729,6 +729,10 @@ def create_return_action(expr, feature, name, var_range):
varaction2.default_result = expression.ConstantNumeric(0) # Bogus result, it's the nvar == 0 that matters
varaction2.default_comment = 'Return computed value'

if parent_action:
for proc in varact2parser.proc_call_list:
action2.add_ref(proc, parent_action, True)

ref = expression.SpriteGroupRef(expression.Identifier(name), [], None, varaction2)
action_list.append(varaction2)
return (action_list, ref)
Expand Down Expand Up @@ -926,7 +930,7 @@ def parse_result(value, action_list, act6, offset, parent_action, none_result, v
result = expression.ConstantNumeric(0)
else:
global return_action_id
extra_actions, result = create_return_action(value, parent_action.feature, "@return_action_{:d}".format(return_action_id), var_range)
extra_actions, result = create_return_action(value, parent_action.feature, "@return_action_{:d}".format(return_action_id), var_range, parent_action)
return_action_id += 1
action2.add_ref(result, parent_action)
action_list.extend(extra_actions)
Expand Down

0 comments on commit 9ccffc3

Please sign in to comment.