From 29d86fb395ca01e4a4f65f02d67f5823a4ebba11 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 10 Oct 2006 09:25:53 +0000 Subject: [PATCH 1/1] Put a timestamp an email in lofiles. Add the replay debugging script. And a tiny tweak to io.c. --- src/io.c | 2 +- src/replay | 14 ++++++++++++++ src/sst.py | 5 ++++- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100755 src/replay diff --git a/src/io.c b/src/io.c index 6d9a7e5..6c312bf 100644 --- a/src/io.c +++ b/src/io.c @@ -86,7 +86,7 @@ void waitfor(void) /* wait for user action -- OK to do nothing if on a TTY */ { if (game.options & OPTION_CURSES) - getch(); + wgetch(prompt_window); } void announce(void) diff --git a/src/replay b/src/replay new file mode 100755 index 0000000..9e5c196 --- /dev/null +++ b/src/replay @@ -0,0 +1,14 @@ +#!/bin/sh +# Replay the last SST game. With arg, use only that many lines of the log +# +# Because the replay log captures the random-number seed, +# repeating this any number of times should produce identical games, +# unless the code changes. +# +if [ $1 ] +then + head -n `expr $1 + 2` replay.log +else + mv /usr/tmp/sst-input.log replay.log +fi +python sst.py -t -r replay.log diff --git a/src/sst.py b/src/sst.py index 68d87a1..74dcbaa 100644 --- a/src/sst.py +++ b/src/sst.py @@ -180,7 +180,7 @@ more: the LRSCAN command is no longer needed. (Controlled by OPTION_AUTOSCAN and turned off if game type is "plain" or "almy".) """ -import os,sys,math,curses,time,atexit,readline,cPickle,random,getopt,copy +import os, sys, math, curses, time, readline, cPickle, random, copy SSTDOC = "/usr/share/doc/sst/sst.doc" DOC_NAME = "sst.doc" @@ -6517,6 +6517,7 @@ def debugme(): atover(True) if __name__ == '__main__': + import getopt, socket try: global line, thing, game, idebug game = None @@ -6568,6 +6569,8 @@ if __name__ == '__main__': if logfp: logfp.write("# seed %s\n" % seed) logfp.write("# options %s\n" % " ".join(arguments)) + logfp.write("# recorded by %s@%s on %s\n" % \ + (os.getenv("LOGNAME"),socket.gethostname(),time.ctime())) random.seed(seed) scanner = sstscanner() map(scanner.append, arguments) -- 2.31.1