Put a timestamp an email in lofiles. Add the replay debugging script.
authorEric S. Raymond <esr@thyrsus.com>
Tue, 10 Oct 2006 09:25:53 +0000 (09:25 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 10 Oct 2006 09:25:53 +0000 (09:25 +0000)
And a tiny tweak to io.c.

src/io.c
src/replay [new file with mode: 0755]
src/sst.py

index 6d9a7e52491ef9a9af44b0ba3961208546f2e80d..6c312bf2aed4729023ec36e73ecc2364b11bd579 100644 (file)
--- 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 (executable)
index 0000000..9e5c196
--- /dev/null
@@ -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` </usr/tmp/sst-input.log >replay.log
+else
+    mv /usr/tmp/sst-input.log replay.log
+fi
+python sst.py -t -r replay.log
index 68d87a1840e8ee8c296647550d68af202f7cba60..74dcbaa3aee8ab27ce8b09f73e4e642330a0c2ca 100644 (file)
@@ -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)