# HG changeset patch # User Thibaut Girka # Date 1315091368 -7200 # Node ID fda176f07d6deb72b755e3637fa19c8f305d09f3 # Parent a87a3c080585701139da4244611766b06d536a8e Fix add_int diff --git a/pytouhou/formats/ecl.py b/pytouhou/formats/ecl.py --- a/pytouhou/formats/ecl.py +++ b/pytouhou/formats/ecl.py @@ -31,7 +31,7 @@ class ECL(object): 8: ('if', 'set_random_float'), 9: ('iff', 'set_random_float2'), 10: ('i', 'store_x'), - 13: ('iii', 'set_random_int2'), + 13: ('iii', 'add_int'), 14: ('iii', 'substract_int'), 15: ('iii', 'multiply_int'), 16: ('iii', 'divide_int'), diff --git a/pytouhou/vm/eclrunner.py b/pytouhou/vm/eclrunner.py --- a/pytouhou/vm/eclrunner.py +++ b/pytouhou/vm/eclrunner.py @@ -202,11 +202,6 @@ class ECLRunner(object): self._setval(variable_id, self._enemy.x) - @instruction(13) - def set_random_int2(self, variable_id, minval, amp): - self._setval(variable_id, int(self._getval(minval)) + int(self._getval(amp)) * self._game_state.prng.rand_double()) - - @instruction(14) @instruction(21) def substract(self, variable_id, a, b): @@ -215,6 +210,14 @@ class ECLRunner(object): self._setval(variable_id, self._getval(a) - self._getval(b)) + @instruction(13) + @instruction(20) + def add(self, variable_id, a, b): + #TODO: 13 takes only ints and 20 only floats. + # The original engine dereferences the variables in the type it waits for, so this isn't exactly the correct implementation, but the data don't contain such case. + self._setval(variable_id, self._getval(a) + self._getval(b)) + + @instruction(15) def multiply_int(self, variable_id, a, b): #TODO: takes only ints. @@ -232,12 +235,6 @@ class ECLRunner(object): self._setval(variable_id, self._getval(a) % self._getval(b)) - @instruction(20) - def add_float(self, variable_id, a, b): - #TODO: takes only floats. - self._setval(variable_id, self._getval(a) + self._getval(b)) - - @instruction(23) def divide_float(self, variable_id, a, b): #TODO: takes only floats.