X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=sst;h=e0784217561cd5239a2709e5e38131666203519f;hb=067b4f263065939c1ba4fed037124ed076f69f98;hp=7cbccffa28dd4efe463357015b2200d01b692fc6;hpb=60da46b4bd74b207ac9ec57498ead4be6a659c81;p=super-star-trek.git diff --git a/sst b/sst index 7cbccff..e078421 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 @@ -6716,7 +6779,6 @@ if __name__ == '__main__': game.options |= OPTION_TTY seed = int(time.time()) (options, arguments) = getopt.getopt(sys.argv[1:], "cr:s:txV") - replay = False for (switch, val) in options: if switch == '-r': # pylint: disable=raise-missing-from @@ -6733,7 +6795,6 @@ if __name__ == '__main__': seed = eval(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) @@ -6766,7 +6827,7 @@ if __name__ == '__main__': sys.exit(1) if logfp: logfp.write("# seed %s\n" % seed) - logfp.write("# options %s\n" % " ".join(arguments)) + logfp.write("# arguments %s\n" % " ".join(arguments)) logfp.write("# SST2K version %s\n" % version) logfp.write("# recorded by %s@%s on %s\n" % \ (getpass.getuser(),socket.getfqdn(),time.ctime())) @@ -6786,7 +6847,7 @@ if __name__ == '__main__': game.alldone = False else: makemoves() - if replay: + if replayfp: break skip(1) stars()