Remove debris from test comment.
[super-star-trek.git] / sst
diff --git a/sst b/sst
index 94bc397b2c0f8e5df713a84398b8098e03c80dc6..a95c9b7372d8da1f1cb7c700c73122567c7bd21f 100755 (executable)
--- a/sst
+++ b/sst
@@ -316,6 +316,29 @@ OPTION_ALMY       = 0x02000000        # user chose Almy variant
 OPTION_COLOR      = 0x04000000        # enable color display (ESR, 2010)
 OPTION_DOTFILL    = 0x08000000        # fix dotfill glitch in chart (ESR, 2019)
 
+option_names = {
+    "ALL": OPTION_ALL,
+    "TTY": OPTION_TTY,
+    "IOMODES": OPTION_IOMODES,
+    "PLANETS": OPTION_PLANETS,
+    "THOLIAN": OPTION_THOLIAN,
+    "THINGY": OPTION_THINGY,
+    "PROBE": OPTION_PROBE,
+    "SHOWME": OPTION_SHOWME,
+    "RAMMING": OPTION_RAMMING,
+    "MVBADDY": OPTION_MVBADDY,
+    "BLKHOLE": OPTION_BLKHOLE,
+    "BASE": OPTION_BASE,
+    "WORLDS": OPTION_WORLDS,
+    "AUTOSCAN": OPTION_AUTOSCAN,
+    "CAPTURE": OPTION_CAPTURE,
+    "CLOAK": OPTION_CLOAK,
+    "PLAIN": OPTION_PLAIN,
+    "ALMY": OPTION_ALMY,
+    "COLOR": OPTION_COLOR,
+    "DOTFILL": OPTION_DOTFILL,
+    }
+
 # Define devices
 DSRSENS         = 0
 DLRSENS         = 1
@@ -4009,39 +4032,35 @@ def getcourse(isprobe):
             scanner.chew()
             iprompt = True
             key = scanner.nexttok()
-        if key != "IHREAL":
-            huh()
-            raise TrekError
-        xi = int(round(scanner.real))-1
-        key = scanner.nexttok()
-        if key != "IHREAL":
-            huh()
+        scanner.push(scanner.token)    # Something IHREAL or IHALPHA awaits us
+        first = scanner.getcoord()
+        if first is None:
             raise TrekError
-        xj = int(round(scanner.real))-1
-        key = scanner.nexttok()
-        if key == "IHREAL":
-            # both quadrant and sector specified
-            xk = int(round(scanner.real))-1
-            key = scanner.nexttok()
-            if key != "IHREAL":
-                huh()
+        scanner.nexttok()
+        if scanner.type == "IHEOL":
+            second = None
+        else:
+            scanner.push(scanner.token)
+            second = scanner.getcoord()
+            if second is None:
                 raise TrekError
-            xl = int(round(scanner.real))-1
-            dquad.i = xi
-            dquad.j = xj
-            dsect.i = xk
-            dsect.j = xl
+        scanner.chew()
+        if second is not None:
+            dquad.i = first.i
+            dquad.j = first.j
+            dsect.i = second.i
+            dsect.j = second.j
         else:
             # only one pair of numbers was specified
             if isprobe:
                 # only quadrant specified -- go to center of dest quad
-                dquad.i = xi
-                dquad.j = xj
-                dsect.j = dsect.i = 4        # preserves 1-origin behavior
+                dquad.i = first.i
+                dquad.j = first.j
+                dsect.j = dsect.i = (QUADSIZE/2)-1        # preserves 1-origin behavior
             else:
                 # only sector specified
-                dsect.i = xi
-                dsect.j = xj
+                dsect.i = first.i
+                dsect.j = first.j
             itemp = "normal"
         if not dquad.valid_quadrant() or not dsect.valid_sector():
             huh()
@@ -5585,6 +5604,42 @@ def eta():
             skip(1)
             return
 
+# This is new in SST2K.
+
+def goptions():
+    mode = scanner.nexttok()
+    if mode == "IHEOL":
+        active = []
+        for k, v in option_names.items():
+            if (v & game.options) and k != "ALL":
+                active.append(k)
+        active.sort()
+        prout(str(" ".join(active)))
+    elif scanner.token in {"set", "clear"}:
+        mode = scanner.token
+        changemask = 0
+        while True:
+            scanner.nexttok()
+            if scanner.type == "IHEOL":
+                break
+            if scanner.token.upper() in option_names:
+                changemask |= option_names[scanner.token.upper()]
+            else:
+                prout(_("No such option as ") + scanner.token)
+        if mode == "set":
+            if (not (game.options & OPTION_CURSES)) and (changemask & OPTION_CURSES):
+                iostart()
+            game.options |= changemask
+        elif mode == "clear":
+            if (game.options & OPTION_CURSES) and (not (changemask & OPTION_CURSES)):
+                ioend()
+            game.options &=~ changemask
+        prout(_("Acknowledged, Captain."))
+    else:
+        huh()
+    scanner.chew()
+    skip(1)
+
 # Code from setup.c begins here
 
 def prelim():
@@ -6221,7 +6276,9 @@ commands = [
     ("PROBE",            OPTION_PROBE),
     ("SAVE",             0),
     ("FREEZE",           0),        # Synonym for SAVE
+    ("OPTIONS",          0),
     ("ABANDON",          0),
+    # No abbreviations accepted after this point
     ("DESTRUCT",         0),
     ("DEATHRAY",         0),
     ("CAPTURE",          OPTION_CAPTURE),
@@ -6233,7 +6290,7 @@ commands = [
     ("QUIT",             0),
     ("HELP",             0),
     ("SCORE",            0),
-    ("CURSES",            0),
+    ("CURSES",           0),
     ("",                 0),
 ]
 
@@ -6457,6 +6514,8 @@ def makemoves():
         elif cmd == "CURSES":
             game.options |= (OPTION_CURSES | OPTION_COLOR)
             iostart()
+        elif cmd == "OPTIONS":
+            goptions()
         while True:
             if game.alldone:
                 break                # Game has ended
@@ -6539,7 +6598,7 @@ class sstscanner:
         # Get a token from the user
         self.real = 0.0
         self.token = ''
-        # Fill the token quue if nothing here
+        # Fill the token queue if nothing here
         while not self.inqueue:
             sline = cgetline()
             if curwnd==prompt_window: