Second round of merging Sergeev changes.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 28 Jan 2005 21:49:25 +0000 (21:49 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 28 Jan 2005 21:49:25 +0000 (21:49 +0000)
ai.c
battle.c
conio.c
finish.c
io.c
makefile
planets.c

diff --git a/ai.c b/ai.c
index 719c50c4bb51c62e659f9521aa71fb44ca67c937..ad550a14cdecba56c208324c855cc03c2d5b88ad 100644 (file)
--- a/ai.c
+++ b/ai.c
@@ -25,7 +25,7 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) {
        if (game.damage[DSRSENS] == 0.0 || game.damage[DLRSENS] == 0.0 ||
                condit == IHDOCKED) {
                crmena(1, ienm, 2, game.kx[loccom], game.ky[loccom]);
-               proutn(" escapes to %s (and regains strength).",
+               prout(" escapes to %s (and regains strength).",
                       cramlc(quadrant, iqx, iqy));
        }
        /* handle local matters related to escape */
@@ -252,9 +252,8 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) {
                if (game.damage[DSRSENS] == 0 || condit == IHDOCKED) {
                        proutn("***");
                        cramen(ienm);
-                       proutn(" from");
-                       cramlc(2, comx, comy);
-                       if (game.kdist[loccom] < dist1) proutn(" advances to");
+                       proutn(" from %s", cramlc(2, comx, comy));
+                       if (game.kdist[loccom] < dist1) proutn(" advances to ");
                        else proutn(" retreats to ");
                        prout(cramlc(sector, nextx, nexty));
                }
index 845aa832937bcd98f2fd2c2052ce6aacceba8fed..455801b9e2b43bc4b6366fcb4aa9fdbeec9f68c3 100644 (file)
--- a/battle.c
+++ b/battle.c
@@ -1235,7 +1235,7 @@ void phasers(void) {
 void hittem(double *hits) {
        double kp, kpow, wham, hit, dustfac, kpini;
 #ifdef SERGEEV
-       int cx, cy;
+       int crx, cry;
 #endif /* SERGEEV */
        int nenhr2=nenhere, k=1, kk=1, ii, jj, ienm;
 
diff --git a/conio.c b/conio.c
index 92598140141e2e12633872e123c3c08ab8fa2965..9c37ad5225c654155d7474ad6a1ea2ff3f0e56d5 100644 (file)
--- a/conio.c
+++ b/conio.c
@@ -31,6 +31,7 @@ char color_warning=1;
 int directvideo;
 WINDOW *conio_scr;
 
+#ifdef SERGEEV 
 /* Some internals... */
 static int colortab(int a) /* convert LINUX Color code to DOS-standard */
 {
@@ -46,6 +47,7 @@ static int colortab(int a) /* convert LINUX Color code to DOS-standard */
    }
    return COLOR_BLACK;
 } 
+#endif /* SERGEEV */
 
 static void docolor (int color) /* Set DOS-like text mode colors */
 {
index 2caf34d266830ee93dbfde9a8caec55b0e7cdda4..b19ce7f14242a9d30c9c8f405bcfe94a527e2ab0 100644 (file)
--- a/finish.c
+++ b/finish.c
@@ -1,3 +1,6 @@
+#ifdef SERGEEV
+#include <conio.h>
+#endif /* SERGEEV */
 #include "sst.h"
 #include <string.h>
 #include <time.h>
@@ -9,23 +12,34 @@ void dstrct() {
                prout("Computer damaged; cannot execute destruct sequence.");
                return;
        }
-       skip(1);
        prouts("---WORKING---"); skip(1);
-       prout("SELF-DESTRUCT-SEQUENCE-ACTIVATED");
+        prouts("SELF-DESTRUCT-SEQUENCE-ACTIVATED"); skip(1);
        prouts("   10"); skip(1);
        prouts("       9"); skip(1);
        prouts("          8"); skip(1);
        prouts("             7"); skip(1);
        prouts("                6"); skip(1);
+#ifdef SERGEEV
+       skip(1);
+#endif /* SERGEEV */
        prout("ENTER-CORRECT-PASSWORD-TO-CONTINUE-");
+#ifdef SERGEEV
+       skip(1);
+#endif /* SERGEEV */
        prout("SELF-DESTRUCT-SEQUENCE-OTHERWISE-");
+#ifdef SERGEEV
+       skip(1);
+#endif /* SERGEEV */
        prout("SELF-DESTRUCT-SEQUENCE-WILL-BE-ABORTED");
+#ifdef SERGEEV
+       skip(1);
+#endif /* SERGEEV */
        scan();
        chew();
        if (strcmp(game.passwd, citem) != 0) {
                prouts("PASSWORD-REJECTED;"); skip(1);
-               prout("CONTINUITY-EFFECTED");
-               skip(1);
+               prouts("CONTINUITY-EFFECTED");
+               skip(2);
                return;
        }
        prouts("PASSWORD-ACCEPTED"); skip(1);
@@ -38,7 +52,6 @@ void dstrct() {
                prouts("GOODBYE-CRUEL-WORLD");
                skip(1);
        }
-       skip(2);
        kaboom();
 }
 
@@ -69,13 +82,13 @@ void finish(FINTYPE ifin) {
        alldone = 1;
        skip(3);
        prout("It is stardate %.1f.", game.state.date);
-       prout("");
+        skip(1);
        switch (ifin) {
                case FWON: // Game has been won
                        if (game.state.nromrem != 0)
                                prout("The remaining %d Romulans surrender to Starfleet Command.",
                                           game.state.nromrem);
-                       
+
                        prout("You have smashed the Klingon invasion fleet and saved");
                        prout("the Federation.");
                        gamewon=1;
@@ -110,14 +123,19 @@ void finish(FINTYPE ifin) {
                                                        break;
                                                case 5:
                                                        skip(1);
-                                                       prout("Computer-  ERROR-ERROR-ERROR-ERROR");
+                                                        proutn("Computer-  ");
+                                                       prouts("ERROR-ERROR-ERROR-ERROR");
+                                                        skip(2);
+                                                        prouts("  YOUR-SKILL-HAS-EXCEEDED-THE-CAPACITY-OF-THIS-PROGRAM");
+                                                        skip(1);
+                                                        prouts("  THIS-PROGRAM-MUST-SURVIVE");
+                                                        skip(1);
+                                                        prouts("  THIS-PROGRAM-MUST-SURVIVE");
                                                        skip(1);
-                                                       prout("  YOUR-SKILL-HAS-EXCEEDED-THE-CAPACITY-OF-THIS-PROGRAM");
-                                                       prout("  THIS-PROGRAM-MUST-SURVIVE");
-                                                       prout("  THIS-PROGRAM-MUST-SURVIVE");
-                                                       prout("  THIS-PROGRAM-MUST-SURVIVE");
-                                                       prout("  THIS-PROGRAM-MUST?- MUST ? - SUR? ? -?  VI");
+                                                        prouts("  THIS-PROGRAM-MUST-SURVIVE");
                                                        skip(1);
+                                                        prouts("  THIS-PROGRAM-MUST?- MUST ? - SUR? ? -?  VI");
+                                                        skip(2);
                                                        prout("Now you can retire and write your own Star Trek game!");
                                                        skip(1);
                                                        break;
@@ -130,8 +148,7 @@ void finish(FINTYPE ifin) {
                                                        )
                                                        prout("You cannot get a citation, so...");
                                                else {
-                                                       prout("Do you want your Commodore Emeritus Citation printed?");
-                                                       proutn("(You need a 132 column printer.)");
+                                                       proutn("Do you want your Commodore Emeritus Citation printed? ");
                                                        chew();
                                                        if (ja()) {
                                                                igotit = 1;
@@ -307,8 +324,6 @@ void score(void) {
        double timused = game.state.date - indate;
        int ithperd, iwon, klship;
 
-       pause_game(0);
-
        iskill = skill;
        if ((timused == 0 || game.state.remkl != 0) && timused < 5.0) timused = 5.0;
        perdate = (game.state.killc + game.state.killk + game.state.nsckill)/timused;
@@ -341,7 +356,7 @@ void score(void) {
                prout("%6d Super-Commander destroyed          %5d",
                           game.state.nsckill, 200*game.state.nsckill);
        if (ithperd)
-               prout("%.2f Klingons per stardate              %5d",
+               prout("%6.2f Klingons per stardate              %5d",
                           perdate, ithperd);
        if (game.state.starkl)
                prout("%6d stars destroyed by your action     %5d",
@@ -364,7 +379,6 @@ void score(void) {
        if (alive==0)
                prout("Penalty for getting yourself killed        -200");
        if (gamewon) {
-               skip(1);
                proutn("Bonus for winning ");
                switch (skill) {
                        case 1: proutn("Novice game  "); break;
@@ -375,7 +389,7 @@ void score(void) {
                }
                prout("           %5d", iwon);
        }
-       skip(2);
+       skip(1);
        prout("TOTAL SCORE                               %5d", iscore);
 }
 
@@ -389,28 +403,38 @@ void plaque(void) {
        skip(2);
        
        while (fp == NULL) {
+#ifdef SERGEEV
+                proutn("File or device name for your plaque: ");
+                getline(winner, sizeof(winner));
+#else
                proutn("File or device name for your plaque:");
                fgets(winner, 128, stdin);
                winner[strlen(winner)-1] = '\0';
+#endif /* SERGEEV */
                fp = fopen(winner, "w");
                if (fp==NULL) {
-                       prout("Invalid name.");
+                        prout("Invalid name.");
                }
        }
 
-       proutn("Enter name to go on plaque (up to 30 characters):");
-       fgets(winner, 128, stdin);
-       winner[strlen(winner)-1] = '\0';
+        proutn("Enter name to go on plaque (up to 30 characters): ");
+        getline(winner, sizeof(winner));
+        proutn("Enter name to go on plaque (up to 30 characters): ");
+        getline(winner, sizeof(winner));
        winner[30] = '\0';
+#ifdef SERGEEV
+       nskip = 38 - strlen(winner)/2;
+#else
        nskip = 64 - strlen(winner)/2;
+#endif /* SERGEEV */
 
        fprintf(fp,"\n\n\n\n");
        /* --------DRAW ENTERPRISE PICTURE. */
-       fprintf(fp, "                                                                EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n" );
+        fprintf(fp, "                                       EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n" );
        fprintf(fp, "                                      EEE                      E  : :                                         :  E\n" );
        fprintf(fp, "                                    EE   EEE                   E  : :                   NCC-1701              :  E\n");
-       fprintf(fp, "                    EEEEEEEEEEEEEEEE        EEEEEEEEEEEEEEE    E  : :                                         : E\n");
-       fprintf(fp, "                     E                                     E    EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n");
+        fprintf(fp, "EEEEEEEEEEEEEEEE        EEEEEEEEEEEEEEE  : :                              : E\n");
+        fprintf(fp, " E                                     EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n");
        fprintf(fp, "                      EEEEEEEEE               EEEEEEEEEEEEE                 E  E\n");
        fprintf(fp, "                               EEEEEEE   EEEEE    E          E              E  E\n");
        fprintf(fp, "                                      EEE           E          E            E  E\n");
diff --git a/io.c b/io.c
index d67c23276c78a4af375b0e78d67eee45b8fa6a79..258da5513f9bd5eeaf7e14d169925e5bebcd7d15 100644 (file)
--- a/io.c
+++ b/io.c
@@ -169,14 +169,14 @@ void skip(int i) {
 }
 
 static void vproutn(char *fmt, va_list ap) {
-    char *strbuf, *p, *s;
-    vasprintf(&strbuf, fmt, ap);
-    p=s=strbuf;
+    char *s, *p;
+    vasprintf(&s, fmt, ap);
+    p=s;
     if ((curwnd==4)&&(wherey()==wnds[curwnd].wndbottom-wnds[curwnd].wndtop)){
-       if (strchr(strbuf,'\n')){
-          p=strchr(strbuf,'\n');
+       if (strchr(s,'\n')) {
+          p=strchr(s,'\n');
           p[0]=0;
-          cprintf("%s",strbuf);
+          cprintf("%s",s);
           p++;
           pause_game(0);
        }
@@ -188,7 +188,7 @@ static void vproutn(char *fmt, va_list ap) {
 //        setwnd(curwnd);
     if (strchr(s,'\n') || strchr(s,'\r')) clreol();
     cprintf("%s",p);
-    free(strbuf);
+    free(s);
 #endif /* SERGEEV */
 }
 
@@ -245,10 +245,11 @@ static void prchr(char *s){
 }
 
 static void vprouts(char *fmt, va_list ap) {
-    char *s;
+    char *s, *p;
     vasprintf(&s, fmt, ap);
-    while (*s) {
-        prchr(s++);
+    p=s;
+    while (*p) {
+        prchr(p++);
         delay(30);
     }
     free(s);
index 76b167ddf19f23968bdb6e716b42c2badd7a1a49..d047666a9ceefa1aa5307bd5e504377dd6052595 100644 (file)
--- a/makefile
+++ b/makefile
@@ -2,7 +2,7 @@
 
 VERS=$(shell sed <sst.spec -n -e '/Version: \(.*\)/s//\1/p')
 
-CFLAGS=     -O -g -DSSTDOC='"/usr/share/doc/sst/sst.doc"'
+CFLAGS= -O1 -g -Wall -DSSTDOC='"/usr/share/doc/sst/sst.doc"'
 
 .c.o:
        $(CC) $(CFLAGS) -c $<
index 3de87c34405b99a733bd54bc2ebb5e6a5e4c2288..ae7a7aad880e354214f97808eedf27afb819f99c 100644 (file)
--- a/planets.c
+++ b/planets.c
@@ -78,10 +78,16 @@ void orbit(void) {
        height = (1400.+7200.*Rand());
        prout("Sulu-  \"Entered orbit at altitude %.2f kilometers.\"", height);
        inorbit = 1;
-       return;
+#ifdef SERGEEV
+        ididit=1;
+#endif /* SERGEEV */
 }
 
 void sensor(void) {
+#ifdef SERGEEV
+    if (game.damage[DSRSENS] != 0.0) return;
+    if ((plnetx != 0)&&(game.state.plnets[iplnet].known == 0)) {
+#else
        skip(1);
        chew();
        if (game.damage[DSRSENS] != 0.0) {
@@ -92,6 +98,7 @@ void sensor(void) {
                prout("No planet in this quadrant.");
                return;
        }
+#endif /* SERGEEV */
        prout("Spock-  \"Sensor scan for %s-", cramlc(quadrant, quadx, quady));
        skip(1);
        prout("         Planet at %s is of class %s.", 
@@ -103,7 +110,9 @@ void sensor(void) {
        if (game.state.plnets[iplnet].crystals == 0) proutn(" no");
        prout(" dilithium crystals present.\"");
        if (game.state.plnets[iplnet].known == unknown) game.state.plnets[iplnet].known = known;
-       return;
+#ifdef SERGEEV
+    }
+#endif /* SERGEEV */
 }
 
 void beam(void) {
@@ -167,6 +176,9 @@ void beam(void) {
                skip(1);
                prout("Kirk-  \"Energize.\"");
        }
+#ifdef SERGEEV
+        ididit=1;
+#endif /* SERGEEV */
        skip(1);
        prouts("WWHOOOIIIIIRRRRREEEE.E.E.  .  .  .  .   .    .");
        skip(2);
@@ -193,8 +205,6 @@ void beam(void) {
 }
 
 void mine(void) {
-
-       ididit = 0;
        skip(1);
        chew();
        if (landed!= 1) {
@@ -220,11 +230,13 @@ void mine(void) {
        if (consumeTime()) return;
        prout("Mining operation complete.");
        imine = 1;
-       return;
+#ifdef SERGEEV
+        ididit=1;
+#endif /* SERGEEV */
 }
 
 void usecrystals(void) {
-
+       ididit=0;
        skip(1);
        chew();
        if (icrystl!=1) {
@@ -270,14 +282,15 @@ void usecrystals(void) {
        prout("   are going crazy, but I think it's");
        prout("   going to work!!  Congratulations, Sir!\"");
        cryprob *= 2.0;
-       return;
+#ifdef SERGEEV
+       ididit=1;
+#endif /* SERGEEV */
 }
 
 void shuttle(void) {
 
        chew();
        skip(1);
-       ididit = 0;
        if(game.damage[DSHUTTL] != 0.0) {
                if (game.damage[DSHUTTL] == -1.0) {
                        if (inorbit && game.state.plnets[iplnet].known == shuttle_down)
@@ -387,7 +400,6 @@ void shuttle(void) {
                return;
        }
 }
-               
 
 void deathray(void) {
        double r = Rand();