Skip to content

Commit

Permalink
Add: Basic range check for replace() (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
glx22 authored Oct 6, 2024
1 parent f00eefa commit b0406f4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nml/ast/replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ def __init__(self, param_list, sprite_list, name, pos):

def pre_process(self):
self.start_id = self.start_id.reduce(global_constants.const_list)
if isinstance(self.start_id, expression.ConstantNumeric):
generic.check_range(
self.start_id.value,
0,
4895 - len(self.sprite_list),
"replace-block parameter 1 'start'",
self.start_id.pos,
)

def debug_print(self, indentation):
generic.print_dbg(indentation, "Replace sprites starting at")
Expand Down

0 comments on commit b0406f4

Please sign in to comment.