Enable GNU realine keys, fix a small but fatal bug.
[super-star-trek.git] / sst.py
diff --git a/sst.py b/sst.py
index 7ca6caa3dbc69670078ffa7b4d627bd27d9d274b..8583af2c3ea94d94e466b9decebfb29e7b4ca257 100755 (executable)
--- a/sst.py
+++ b/sst.py
@@ -13,6 +13,13 @@ on how to modify (and how not to modify!) this code.
 """
 import os, sys, math, curses, time, readline, pickle, random, copy, gettext, getpass
 
+# This import only works on Unixes.  The intention is to enable
+# Ctrl-P, Ctrl-N, and friends in Cmd.
+try:
+    import readline
+except ImportError:
+    pass
+
 version = "2.1"
 
 docpath        = (".", "../doc", "/usr/share/doc/sst")
@@ -3114,12 +3121,12 @@ rows = linecount = 0        # for paging
 stdscr = None
 replayfp = None
 fullscreen_window = None
-srscan_window     = None
-report_window     = None
-status_window     = None
-lrscan_window     = None
-message_window    = None
-prompt_window     = None
+srscan_window     = None   # Short range scan
+report_window     = None   # Report legends for status window
+status_window     = None   # The status window itself
+lrscan_window     = None   # Long range scan
+message_window    = None   # Main window for scrolling text
+prompt_window     = None   # Prompt window at bottom of display
 curwnd = None
 
 def iostart():
@@ -5705,7 +5712,7 @@ def choose():
     game.state.remres = (game.inkling+4*game.incom)*game.intime
     game.inresor = game.state.remres
     if game.inkling > 50:
-        game.state.inbase += 1
+        game.inbase += 1
     return False
 
 def dropin(iquad=None):
@@ -5875,38 +5882,38 @@ commands = [
     ("TORPEDO",          0),
     ("PHOTONS",          0),
     ("MOVE",             0),
-    ("SHIELDS",           0),
+    ("SHIELDS",          0),
     ("DOCK",             0),
-    ("DAMAGES",           0),
+    ("DAMAGES",          0),
     ("CHART",            0),
     ("IMPULSE",          0),
     ("REST",             0),
     ("WARP",             0),
     ("SCORE",            0),
     ("SENSORS",          OPTION_PLANETS),
-    ("ORBIT",                OPTION_PLANETS),
+    ("ORBIT",            OPTION_PLANETS),
     ("TRANSPORT",        OPTION_PLANETS),
-    ("MINE",                OPTION_PLANETS),
-    ("CRYSTALS",          OPTION_PLANETS),
+    ("MINE",             OPTION_PLANETS),
+    ("CRYSTALS",         OPTION_PLANETS),
     ("SHUTTLE",          OPTION_PLANETS),
     ("PLANETS",          OPTION_PLANETS),
     ("REPORT",           0),
     ("COMPUTER",         0),
     ("COMMANDS",         0),
-    ("EMEXIT",                0),
-    ("PROBE",                OPTION_PROBE),
-    ("SAVE",                0),
-    ("FREEZE",                0),        # Synonym for SAVE
+    ("EMEXIT",           0),
+    ("PROBE",            OPTION_PROBE),
+    ("SAVE",             0),
+    ("FREEZE",           0),        # Synonym for SAVE
     ("ABANDON",          0),
     ("DESTRUCT",         0),
     ("DEATHRAY",         0),
     ("DEBUG",            0),
-    ("MAYDAY",                0),
-    ("SOS",                0),        # Synonym for MAYDAY
-    ("CALL",                0),        # Synonym for MAYDAY
-    ("QUIT",                0),
-    ("HELP",                0),
-    ("",                0),
+    ("MAYDAY",           0),
+    ("SOS",              0),        # Synonym for MAYDAY
+    ("CALL",             0),        # Synonym for MAYDAY
+    ("QUIT",             0),
+    ("HELP",             0),
+    ("",                 0),
 ]
 
 def listCommands():
@@ -6007,6 +6014,8 @@ def makemoves():
             if cmd == "":
                 listCommands()
                 continue
+            elif opt and not (opt & game.options):
+                huh()
             else:
                 break
         if cmd == "SRSCAN":                # srscan