changeset 307:5930b33a0370

Minor refactoring
author Thibaut Girka <thib@sitedethib.com>
date Tue, 13 Mar 2012 19:52:42 +0100
parents 52d791bb7c32
children 7a464291dd9d
files pytouhou/game/enemy.py pytouhou/vm/eclrunner.py
diffstat 2 files changed, 6 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/enemy.py
+++ b/pytouhou/game/enemy.py
@@ -53,7 +53,7 @@ class Enemy(object):
         self.bullet_attributes = None
         self.bullet_launch_offset = (0, 0)
         self.death_callback = -1
-        self.boss_callback = None
+        self.boss_callback = -1
         self.low_life_callback = -1
         self.low_life_trigger = None
         self.timeout = -1
--- a/pytouhou/vm/eclrunner.py
+++ b/pytouhou/vm/eclrunner.py
@@ -108,13 +108,10 @@ class ECLMainRunner(object):
     @instruction(10)
     def resume_ecl(self, sub, instr_type, unk1, unk2):
         boss = self._game.boss
-        enemy = boss._enemy
         self._game.msg_wait = False
-        if enemy.boss_callback:
-            boss.frame = 0
-            boss.sub = enemy.boss_callback
-            boss.instruction_pointer = 0
-            enemy.boss_callback = None
+        if boss._enemy.boss_callback > -1:
+            boss.switch_to_sub(boss._enemy.boss_callback)
+            boss._enemy.boss_callback = -1
         else:
             raise Exception #TODO
 
@@ -142,9 +139,7 @@ class ECLRunner(object):
                           0., 0., 0., 0.,
                           0,  0,  0,  0]
         self.comparison_reg = 0
-        self.sub = sub
-        self.frame = 0
-        self.instruction_pointer = 0
+        self.switch_to_sub(sub)
 
         self.stack = []
 
@@ -839,9 +834,7 @@ class ECLRunner(object):
             elif proc._enemy.death_callback > 0:
                 #TODO: check
                 #TODO: refactor
-                proc.frame = 0
-                proc.instruction_pointer = 0
-                proc.sub = proc._enemy.death_callback
+                self.switch_to_sub(proc._enemy.death_callback)
                 proc._enemy.death_callback = -1