Fixed a fatal bug in torpedo firing with the curses interface.
[super-star-trek.git] / sst.py
diff --git a/sst.py b/sst.py
index c42171ea645df8d280aef91dfd851d401605417c..ee6b58a2347e7f2999c26a10795c15598a5dcc6d 100755 (executable)
--- a/sst.py
+++ b/sst.py
@@ -1099,7 +1099,8 @@ def torpedo(origin, bearing, dispersion, number, nburst):
        if iquad == '.':
            continue
        # hit something 
-       if not damaged(DSRSENS) or game.condition == "docked":
+        setwnd(message_window)
+        if not damaged(DSRSENS) or game.condition == "docked":
            skip(1)     # start new line after text track 
        if iquad in ('E', 'F'): # Hit our ship 
            skip(1)
@@ -3213,6 +3214,9 @@ def proutn(line):
        if curwnd == message_window and y >= my - 2:
            pause_game()
            clrscr()
+        # Uncomment this to debug curses problems
+        if logfp:
+            logfp.write("#curses: at %s proutn(%s)\n" % ((y, x), repr(line)))
        curwnd.addstr(line)
        curwnd.refresh()
     else:
@@ -3262,6 +3266,25 @@ def setwnd(wnd):
     "Change windows -- OK for this to be a no-op in tty mode."
     global curwnd
     if game.options & OPTION_CURSES:
+        # Uncomment this to debug curses problems
+        if logfp:
+            if wnd == fullscreen_window:
+                legend = "fullscreen"
+            elif wnd == srscan_window:
+                legend = "srscan"
+            elif wnd == report_window:
+                legend = "report"
+            elif wnd == status_window:
+                legend = "status"
+            elif wnd == lrscan_window:
+                legend = "lrscan"
+            elif wnd == message_window:
+                legend = "message"
+            elif wnd == prompt_window:
+                legend = "prompt"
+            else:
+                legend = "unknown"
+            logfp.write("#curses: setwnd(%s)\n" % legend)
         curwnd = wnd
         curses.curs_set(wnd == fullscreen_window or wnd == message_window or wnd == prompt_window)
 
@@ -6318,6 +6341,7 @@ if __name__ == '__main__':
             game.options |= OPTION_TTY
         seed = int(time.time())
         (options, arguments) = getopt.getopt(sys.argv[1:], "r:s:txV")
+        replay = False
         for (switch, val) in options:
             if switch == '-r':
                 try:
@@ -6332,6 +6356,7 @@ if __name__ == '__main__':
                     sys.stderr.write("sst2k: seed set to %s\n" % seed)
                     line = replayfp.readline().strip()
                     arguments += line.split()[2:]
+                    replay = True
                 except ValueError:
                     sys.stderr.write("sst: replay file %s is ill-formed\n"% val)
                     raise SystemExit(1)
@@ -6380,6 +6405,8 @@ if __name__ == '__main__':
                     game.alldone = False
                 else:
                     makemoves()
+                if replay:
+                    break
                 skip(1)
                 stars()
                 skip(1)