From: Eric S. Raymond Date: Mon, 14 Aug 2023 01:59:17 +0000 (-0400) Subject: Added options command, fixed some tests to be insensitive... X-Git-Tag: 2.8~52 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=705f58e2c77049fe02d20cb428fd1402af4d82b2;p=super-star-trek.git Added options command, fixed some tests to be insensitive... ...to the command list. --- diff --git a/doc/sst-doc.xml b/doc/sst-doc.xml index 6f7051f..b7c0681 100644 --- a/doc/sst-doc.xml +++ b/doc/sst-doc.xml @@ -942,7 +942,7 @@ will hurt your final score. Mnemonic: CAPTURE -Shortest abbreviation: CA +Shortest abbreviation: CAPTURE Full commands: CAPTURE @@ -1501,6 +1501,20 @@ Full command: CURSES Switch from tty to curses interface. Mainly useful for debugging, when continuing a replayed game. + +Option setting + + +Mnemonic: OP +Full command: OPTIONS + OPTIONS SET + OPTIONS CLEAR + + +Set or clear feature flags. With no argument, list feature flags. The verbs SET and CLEAR +are available to set or clear a list of feature flags following on the line. Mainly useful +for development and improving test coverage. + Miscellaneous Notes @@ -1657,6 +1671,7 @@ orientation. T TRANSPORT transporter W WARP <FACTOR> (none) CU CURSES (none) + OP OPTIONS (none) L. R. Scan: thousands digit: supernova hundreds digit: Klingons diff --git a/sst b/sst index 7cbccff..a95c9b7 100755 --- 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 @@ -5581,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(): @@ -6217,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), @@ -6229,7 +6290,7 @@ commands = [ ("QUIT", 0), ("HELP", 0), ("SCORE", 0), - ("CURSES", 0), + ("CURSES", 0), ("", 0), ] @@ -6453,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 diff --git a/test/test03.chk b/test/test03.chk index 3941efb..19efd30 100644 --- a/test/test03.chk +++ b/test/test03.chk @@ -51,17 +51,6 @@ Entering Quadrant 4 - 1. Enemy attack reduces shield strength to 87%, torpedoes left 10 Enemy attack reduces shield strength to 78%, torpedoes left 10 -COMMAND> laser auto -LEGAL COMMANDS ARE: -SRSCAN STATUS REQUEST LRSCAN -PHASERS TORPEDO PHOTONS MOVE SHIELDS -DOCK DAMAGES CHART IMPULSE REST -WARP SENSORS ORBIT TRANSPORT MINE -CRYSTALS SHUTTLE PLANETS REPORT COMPUTER -COMMANDS EMEXIT PROBE SAVE FREEZE -ABANDON DESTRUCT DEATHRAY CAPTURE CLOAK -DEBUG MAYDAY SOS CALL QUIT -HELP SCORE CURSES COMMAND> p a Weapons Officer Sulu- "High-speed shield control enabled, sir." diff --git a/test/test03.log b/test/test03.log index 8667f28..e806862 100644 --- a/test/test03.log +++ b/test/test03.log @@ -9,7 +9,6 @@ m a 3 1 1 10 m a 10 10 sh up m a 4 1 1 10 -laser auto p a 1883 p a diff --git a/test/test06.chk b/test/test06.chk index a3180a9..de8fcd6 100644 --- a/test/test06.chk +++ b/test/test06.chk @@ -158,17 +158,6 @@ COMMAND> orbit Helmsman Sulu- "Entering standard orbit, Sir." Sulu- "Entered orbit at altitude 7779.00 kilometers." -COMMAND> beam -LEGAL COMMANDS ARE: -SRSCAN STATUS REQUEST LRSCAN -PHASERS TORPEDO PHOTONS MOVE SHIELDS -DOCK DAMAGES CHART IMPULSE REST -WARP SENSORS ORBIT TRANSPORT MINE -CRYSTALS SHUTTLE PLANETS REPORT COMPUTER -COMMANDS EMEXIT PROBE SAVE FREEZE -ABANDON DESTRUCT DEATHRAY CAPTURE CLOAK -DEBUG MAYDAY SOS CALL QUIT -HELP SCORE CURSES COMMAND> shuttle Spock- "Captain, we have no information on this planet diff --git a/test/test06.log b/test/test06.log index 1575901..3c565bc 100644 --- a/test/test06.log +++ b/test/test06.log @@ -25,7 +25,6 @@ m a 2 5 m a 2 9 m a 4 9 orbit -beam shuttle crystals shuttle diff --git a/test/test08.chk b/test/test08.chk index 3fa8cd1..b898751 100644 --- a/test/test08.chk +++ b/test/test08.chk @@ -137,17 +137,6 @@ COMMAND> chart COMMAND> m a 1 10 -COMMAND> xhart -LEGAL COMMANDS ARE: -SRSCAN STATUS REQUEST LRSCAN -PHASERS TORPEDO PHOTONS MOVE SHIELDS -DOCK DAMAGES CHART IMPULSE REST -WARP SENSORS ORBIT TRANSPORT MINE -CRYSTALS SHUTTLE PLANETS REPORT COMPUTER -COMMANDS EMEXIT PROBE SAVE FREEZE -ABANDON DESTRUCT DEATHRAY CAPTURE CLOAK -DEBUG MAYDAY SOS CALL QUIT -HELP SCORE CURSES COMMAND> chart STAR CHART FOR THE KNOWN GALAXY 1 2 3 4 5 6 7 8 @@ -239,41 +228,6 @@ COMMAND> chart 7 | ..1 ..8 .11 ..5 ..4 ... ... ... | 8 | ..5 ..7 .19 ..5 ..7 ... ... ... | -COMMAND> chart 6 2 1 10 - STAR CHART FOR THE KNOWN GALAXY - 1 2 3 4 5 6 7 8 -1 | ..3 ..4 ..4 ..1 ..7 ..5 ..3 ..3 | -2 | ... ... ... .1. .1. ... ..7 ..3 | -3 | ... ... ... ... ... ... ... ... | -4 | ..1 ..2 ..7 ... ... ... ... ... | -5 | 209 <..5> ..2 ... ... ... ... ... | -6 | ..7 207 ..2 ..5 ..2 ... ... ... | -7 | ..1 ..8 .11 ..5 ..4 ... ... ... | -8 | ..5 ..7 .19 ..5 ..7 ... ... ... | - -COMMAND> n a 6 2 1 10 -LEGAL COMMANDS ARE: -SRSCAN STATUS REQUEST LRSCAN -PHASERS TORPEDO PHOTONS MOVE SHIELDS -DOCK DAMAGES CHART IMPULSE REST -WARP SENSORS ORBIT TRANSPORT MINE -CRYSTALS SHUTTLE PLANETS REPORT COMPUTER -COMMANDS EMEXIT PROBE SAVE FREEZE -ABANDON DESTRUCT DEATHRAY CAPTURE CLOAK -DEBUG MAYDAY SOS CALL QUIT -HELP SCORE CURSES -COMMAND> chart - STAR CHART FOR THE KNOWN GALAXY - 1 2 3 4 5 6 7 8 -1 | ..3 ..4 ..4 ..1 ..7 ..5 ..3 ..3 | -2 | ... ... ... .1. .1. ... ..7 ..3 | -3 | ... ... ... ... ... ... ... ... | -4 | ..1 ..2 ..7 ... ... ... ... ... | -5 | 209 <..5> ..2 ... ... ... ... ... | -6 | ..7 207 ..2 ..5 ..2 ... ... ... | -7 | ..1 ..8 .11 ..5 ..4 ... ... ... | -8 | ..5 ..7 .19 ..5 ..7 ... ... ... | - COMMAND> m a 6 2 1 10 Ensign Chekov- "Course laid in, Captain." diff --git a/test/test08.log b/test/test08.log index e0a70b6..6c17828 100644 --- a/test/test08.log +++ b/test/test08.log @@ -22,7 +22,6 @@ m a 6 10 dock chart m a 1 10 -xhart chart m a 7 4 1 10 chart @@ -34,9 +33,6 @@ sh up chart m a 5 2 10 10 chart -chart 6 2 1 10 -n a 6 2 1 10 -chart m a 6 2 1 10 m a 1 9 torp 2 5 9 5 9