From 4c3ff8ac78499d53339de7d67081e99582a9fb75 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 19 Sep 2006 08:05:42 +0000 Subject: [PATCH] Improvements to the testing machinery, including the replay option. --- TODO | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/sst-doc.xml | 8 +++++- doc/sst.xml | 40 ++++++++++++++++++++++++++--- src/events.c | 4 +-- src/io.c | 5 +++- src/sst.c | 39 +++++++++++++++++----------- src/sst.h | 4 +-- 7 files changed, 141 insertions(+), 26 deletions(-) diff --git a/TODO b/TODO index 893194a..57dd604 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,72 @@ Super Star Trek TO-DO list +Bugs: + +----------------------------------------------------------------------------- + Short-range scan + 1 2 3 4 5 6 7 8 9 10 + 1 E . . . . . . . . . Stardate 3800.9, Time Left 6.14 + 2 . . . . . . . . . C Condition RED, 0 DAMAGES + 3 . @ . * . . . . . . Position 1 - 3 , 1 - 1 + 4 . . . . . . . . . . Life Support ACTIVE + 5 . . . . . . . . . . Warp Factor 5.0 + 6 . . . . . . . . . . Energy 3871.68 + 7 . . . . * . . . . . Torpedoes 10 + 8 . . . . . . . . . . Shields UP, 92% 2294.3 units + 9 . . . . . . R . . . Klingons Left 8 +10 . . . . . . * . . . Major system Capella IV (Kohath) + + +COMMAND> phot 2 +Target sector for torpedo number 1- 2 10 +Target sector for torpedo number 2- 2 10 + +***Commander at Sector 2 - 10 damaged-- displaced by blast to Sector 3 - 10 + + +***Commander at Sector 2 - 10 destroyed. +=== ATTACK! + +***TORPEDO INCOMING From Unknown?? at Sector 3 - 10 + +Torpedo missed. +----------------------------------------------------------------------------- + +Here's the log that reproduces it + +----------------------------------------------------------------------------- +seed 1158606492 +sr +phasers +auto +391 +sensors +planets +lr +chart +probe +y +n +a +1 8 +shields up +sr +m a 10 10 + +chart +m a 1 3 1 1 + +n +chart +sr +phot 2 +2 10 +2 10 +----------------------------------------------------------------------------- + +The bug is the 'Unknown??' in the incoming-torpedo message. What +happened here is that the Commander launched a torp just before being +killed. The torpedo knows its origin but not who fired it. Short-term items: diff --git a/doc/sst-doc.xml b/doc/sst-doc.xml index 3e47dee..7cd86db 100644 --- a/doc/sst-doc.xml +++ b/doc/sst-doc.xml @@ -1440,6 +1440,11 @@ inform you how long the base under attack can last. Since the Super-Commander is more powerful than an ordinary commander, he can destroy a base more quickly. +Inhabited worlds can be attacked, enslaved, and forced to +build more Klingon starships. They will send out a distress call +by subspace radio when they are attacked, and you will lose contact +with them when they are enslaved. + The Super-Commander travels around the galaxy at a speed of about warp 6 or 7. His movement is strictly time based; the more time passes, the further he can go. @@ -1507,11 +1512,12 @@ the game, your kill rate is based on a minimum of 5 stardates. You lose— +300 points for each inhabited world you destroy, 200 points if you get yourself killed, 100 points for each starbase you destroy, 100 points for each starship you lose, 45 points for each time you had to call for help, -10 points for each planet you destroyed, +10 points for each uninhabited planet you destroyed, 5 points for each star you destroyed, and 1 point for each casualty you incurred. diff --git a/doc/sst.xml b/doc/sst.xml index 5a56584..a1ab4b6 100644 --- a/doc/sst.xml +++ b/doc/sst.xml @@ -15,8 +15,10 @@ sst --t -command + -r filename + -t + -x + command @@ -38,10 +40,17 @@ url='http://sst.berlios.de/sst-doc.html'>browseable. On systems where /usr/share/doc/sst/ is a legal filename, it will probably be installed there as well. -There is one option -t, which forces the original pure-tty mode. +The option -t forces the original pure-tty mode. Normally sst tries to come up in full-screen mode that assumes it is running on a cursor-addressable terminal or terminal emulator. +The option -r sets up replay of a session logfile. Commands +in the logfile are executed, then additional commands are taken +from stdin as normal. The -r option forces -t mode. + +The option -x enables some debugging features of interest +probably only to sst2k developers. + Input tokens for the setup prompts will be read from the remainder of the command line before standard input. Thus, for example, you can invoke the program as @@ -54,11 +63,34 @@ sst regular medium good fancy mode (all features enabled). +FILES + + +/usr/share/doc/sst/sst.doc + +Documentation file. + + + +sst-input.log + +Where user input is saved to (send this with your bug reports). + + + +emsave.trk + +Save file produced by EMEXIT command. + + + + + AUTHORS Super Star Trek was designed and written by David Matuszek, Paul Reynolds, and Don Smith in the 1970s. It was resurrected by Tom Almy. The screen-oriented interface is by Stas Sergeev. This version has -been cleaned up and documented by Eric S. Raymond +been improved, cleaned up and documented by Eric S. Raymond esr@snark.thyrsus.com. There is a project page. diff --git a/src/events.c b/src/events.c index 7d43921..b6a1687 100644 --- a/src/events.c +++ b/src/events.c @@ -410,7 +410,7 @@ void events(void) } break; case FDISTR: /* inhabited system issues distress call */ - schedule(FDISTR, expran(0.5*game.intime)); + unschedule(FDISTR); /* try a whole bunch of times to find something suitable */ i = 100; do { @@ -434,8 +434,6 @@ void events(void) ev = schedule(FENSLV, expran(game.intime)); ev->quadrant = w; q->status = distressed; - if (idebug) - prout("=== Distress call set at %d, %d.", w.x, w.y); /* tell the captain about it if we can */ if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED) diff --git a/src/io.c b/src/io.c index 5d4ea9a..dc4ce74 100644 --- a/src/io.c +++ b/src/io.c @@ -203,7 +203,10 @@ void cgetline(char *line, int max) strcat(line, "\n"); wrefresh(curwnd); } else { - fgets(line, max, stdin); + if (replayfp && !feof(replayfp)) + fgets(line, max, replayfp); + else + fgets(line, max, stdin); } if (logfp) fputs(line, logfp); diff --git a/src/sst.c b/src/sst.c index 90b2b30..7fbbfc2 100644 --- a/src/sst.c +++ b/src/sst.c @@ -176,8 +176,7 @@ double perdate; char citem[10]; int seed; // the random-number seed bool idebug; // debug mode -bool randready; // Has the random-number generator initialized? -FILE *logfp; +FILE *logfp, *replayfp; char *device[NDEVICES] = { "S. R. Sensors", @@ -595,8 +594,20 @@ int main(int argc, char **argv) else game.options |= OPTION_TTY; - while ((option = getopt(argc, argv, "tx")) != -1) { + seed = (int)time(NULL); + while ((option = getopt(argc, argv, "r:tx")) != -1) { switch (option) { + case 'r': + replayfp = fopen(optarg, "r"); + if (replayfp == NULL) { + fprintf(stderr, "sst: can't open replay file %s\n", optarg); + exit(1); + } + if (fscanf(replayfp, "seed %d\n", &seed) != 1) { + fprintf(stderr, "sst: replay file %s is ill-formed\n", optarg); + exit(1); + } + /* FALL THROUGH */ case 't': game.options |= OPTION_TTY; game.options &=~ OPTION_CURSES; @@ -612,8 +623,10 @@ int main(int argc, char **argv) /* where to save the input in case of bugs */ logfp = fopen("sst-input.log", "w"); setlinebuf(logfp); + fprintf(logfp, "seed %d\n", seed); + srand(seed); - randomize(); + srand(seed); iostart(); line[0] = '\0'; @@ -715,14 +728,6 @@ double expran(double avrage) double Rand(void) { - if (!randready) { - if (seed == 0) - seed = (unsigned)time(NULL); - if (logfp) - fprintf(logfp, "seed %d\n", seed); - srand(seed); - randready = true; - } return rand()/(1.0 + (double)RAND_MAX); } @@ -884,12 +889,16 @@ void debugme(void) case FENSLV: proutn("Enlavement "); break; case FREPRO: proutn("Klingon Build "); break; } - if (is_scheduled(i)) + if (is_scheduled(i)) { proutn("%.2f", scheduled(i)-game.state.date); - else + if (i == FENSLV || i == FREPRO) { + ev = findevent(i); + proutn(" in %d-%d", ev->quadrant.x,ev->quadrant.y); + } + } else proutn("never"); - chew(); proutn("? "); + chew(); key = scan(); if (key == 'n') { unschedule(i); diff --git a/src/sst.h b/src/sst.h index 6ecd3d3..e9a805f 100644 --- a/src/sst.h +++ b/src/sst.h @@ -178,6 +178,7 @@ extern int is_scheduled(int); extern event *schedule(int, double); extern void postpone(int, double); extern double scheduled(int); +#define findevent(evtype) &game.future[evtype] #define SSTMAGIC "SST2.0\n" @@ -281,9 +282,8 @@ extern double perdate; extern double aaitem; extern char citem[10]; extern int seed; -extern bool randready; extern bool idebug; -extern FILE *logfp; +extern FILE *logfp, *replayfp; /* the Space Thingy's global state should *not* be saved! */ extern coord thing; -- 2.31.1