# HG changeset patch # User Thibaut Girka # Date 1341158771 -7200 # Node ID 72ef7e24b373b1762c4b7d3c9dd657a989c2209c # Parent 2350147cf0433cc5714f66416952dbdb90f49942 Fix MSG skipping. diff --git a/pytouhou/game/game.py b/pytouhou/game/game.py --- a/pytouhou/game/game.py +++ b/pytouhou/game/game.py @@ -258,10 +258,9 @@ class Game(object): def update_msg(self, keystate): - if keystate & 1 and not self.last_keystate & 1: + if any((keystate & k and not self.last_keystate & k) for k in (1, 256)): self.msg_runner.skip() - if keystate & 256 and self.msg_runner.allow_skip: - self.msg_runner.skip() + self.msg_runner.skipping = bool(keystate & 256) self.last_keystate = keystate self.msg_runner.run_iteration() diff --git a/pytouhou/vm/msgrunner.py b/pytouhou/vm/msgrunner.py --- a/pytouhou/vm/msgrunner.py +++ b/pytouhou/vm/msgrunner.py @@ -28,7 +28,7 @@ class NextStage(Exception): class MSGRunner(object): __metaclass__ = MetaRegistry __slots__ = ('_msg', '_game', 'frame', 'sleep_time', 'allow_skip', - 'frozen', 'faces', 'ended', 'instruction_pointer') + 'skipping', 'frozen', 'faces', 'ended', 'instruction_pointer') def __init__(self, msg, script, game): self._msg = msg.msgs[script + 10 * (game.players[0].state.character // 2)] @@ -36,6 +36,7 @@ class MSGRunner(object): self.frame = 0 self.sleep_time = 0 self.allow_skip = True + self.skipping = False self.frozen = False self.faces = [None, None] @@ -117,7 +118,8 @@ class MSGRunner(object): @instruction(4) def pause(self, duration): - self.sleep_time = duration + if not (self.skipping and self.allow_skip): + self.sleep_time = duration @instruction(5)