SERGEEV dependencies cleaned out of battle.c
authorEric S. Raymond <esr@thyrsus.com>
Fri, 4 Feb 2005 13:18:15 +0000 (13:18 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 4 Feb 2005 13:18:15 +0000 (13:18 +0000)
battle.c
conio.c
io.c
sst.h

index d8dce472a4d38367118265a5b1b3d96c008a12b2..bcfd70788b72210b4350eee8d58f4aa5d08faf6b 100644 (file)
--- a/battle.c
+++ b/battle.c
@@ -174,7 +174,7 @@ void ram(int ibumpd, int ienm, int ix, int iy) {
        return;
 }
 
-void torpedo(double course, double r, int inx, int iny, double *hit, int wait) {
+void torpedo(double course, double r, int inx, int iny, double *hit, int wait, int i, int n) {
         int l, iquad=0, ix=0, iy=0, jx=0, jy=0, shoved=0, ll;
        int crx,cry;
        
@@ -201,39 +201,8 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int wait) {
                iy = y + 0.5;
                if (iy < 1 || iy > 10) break;
                iquad=game.quad[ix][iy];
-#ifndef SERGEEV
-               if (l==4 || l==9) skip(1);
-               proutn("%d - %d   ", (int)x, (int)y);
-#else
-                if (game.damage[DSRSENS]==0 || condit==IHDOCKED){
-                   drawmaps(2);
-                   delay((wait!=1)*400);
-                   wait=1;
-                   gotoxy(iy*2+3,ix+2);
-                   if ((game.quad[ix][iy]==IHDOT)||(game.quad[ix][iy]==IHBLANK)){
-                      game.quad[ix][iy]='+';
-                      drawmaps(2);
-                      game.quad[ix][iy]=iquad;
-                      sound(l*10);
-                      delay(100);
-                      nosound();
-                   }
-                   else {
-                        game.quad[ix][iy]|=128;
-                        drawmaps(2);
-                        game.quad[ix][iy]=iquad;
-                        _setcursortype(_NOCURSOR);
-                        sound(500);
-                        delay(1000);
-                        nosound();
-                        lowvideo();
-                        _setcursortype(_NORMALCURSOR);
-                   }
-                }
-                else {
-                 proutn("%d - %d   ", (int)x, (int)y);
-               }
-#endif /* SERGEEV */
+               tracktorpedo(x, y, ix, iy, wait, l, i, n, iquad);
+               wait = 1;
                if (iquad==IHDOT) continue;
                /* hit something */
                setwnd(LOWER_WINDOW);
@@ -401,15 +370,10 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int wait) {
                                         fabs(sin(bullseye-angle));
                                h1 = fabs(h1);
                                if (h1 >= 600) {
-#ifndef SERGEEV
-                                       prout(" destroyed.");
-#endif /* SERGEEV */
                                        game.quad[ix][iy] = IHDOT;
                                        ithere = 0;
                                        ithx = ithy = 0;
-#ifdef SERGEEV
                                         deadkl(ix, iy, iquad, ix, iy);
-#endif /* SERGEEV */
                                        return;
                                }
                                skip(1);
@@ -551,7 +515,7 @@ void attack(int k) {
                        prout("  ");
                        r = (Rand()+Rand())*0.5 -0.5;
                        r += 0.002*game.kpower[l]*r;
-                       torpedo(course, r, jx, jy, &hit, 0);
+                       torpedo(course, r, jx, jy, &hit, 0, 1, 1);
                        if (game.state.remkl==0) finish(FWON); /* Klingons did themselves in! */
                        if (game.state.galaxy[quadx][quady] == 1000 ||
                                alldone) return; /* Supernova or finished */
@@ -854,17 +818,7 @@ void photon(void) {
                        }
                }
                if (shldup || condit == IHDOCKED) r *= 1.0 + 0.0001*shield;
-#ifndef SERGEEV
-               if (n != 1) {
-                       skip(1);
-                       proutn("Track for torpedo number %d-  ", i);
-               }
-               else {
-                       skip(1);
-                       proutn("Torpedo track- ");
-               }
-#endif /* SERGEEV */
-               torpedo(course[i], r, sectx, secty, &dummy, i);
+               torpedo(course[i], r, sectx, secty, &dummy, 0, i, n);
                if (alldone || game.state.galaxy[quadx][quady]==1000) return;
        }
        if (game.state.remkl==0) finish(FWON);
@@ -1231,28 +1185,8 @@ void hittem(double *hits) {
                ii = game.kx[kk];
                jj = game.ky[kk];
                if (hit > 0.005) {
-#ifdef SERGEEV
-                       int crx, cry;
-                        if (game.damage[DSRSENS]==0){
-                           crx=wherex();
-                           cry=wherey();
-                           setwnd(LEFTUPPER_WINDOW);
-                           drawmaps(2);
-                           gotoxy(jj*2+3,ii+2);
-                           highvideo();
-                           proutn("%c", game.quad[ii][jj]);
-                           gotoxy(wherex()-1,wherey());
-                           sound(500);
-                           delay(1000);
-                           nosound();
-                           lowvideo();
-                           proutn("%c", game.quad[ii][jj]);
-                           setwnd(LOWER_WINDOW);
-                           gotoxy(crx,cry);
-                           _setcursortype(_NORMALCURSOR);
-                           delay(500);
-                        }
-#endif /* SERGEEV */
+                        if (game.damage[DSRSENS]==0)
+                           boom(ii, jj);
                        proutn("%d unit hit on ", (int)hit);
                }
                else
diff --git a/conio.c b/conio.c
index 1aca05ebe0b2cb2bd9bf553e20b911a19cd01161..27c38c3842786bcbe93d2aeb9134a649e4fc9bc4 100644 (file)
--- a/conio.c
+++ b/conio.c
@@ -226,7 +226,7 @@ void gettextinfo(struct text_info *inforec)
 } 
 
 void gotoxy (int x, int y)
-/* address cusor -- OK for this to be a no-op in TTY mode */
+/* address cursor -- OK for this to be a no-op in TTY mode */
 {
 #ifdef SERGEEV
    y--;
diff --git a/io.c b/io.c
index 444a5cb2c2923e509a3702b16756d729a5fc735b..a436c3333b7b41a3826fdf2f05ed48d1d9cbe04b 100644 (file)
--- a/io.c
+++ b/io.c
@@ -360,6 +360,31 @@ void drawmaps(short l) {
 #endif /* SERGEEV */
 }
 
+void boom(int ii, int jj)
+/* enemy fall down, go boom */ 
+{
+#ifdef SERGEEV
+    int crx, cry;
+    crx=wherex();
+    cry=wherey();
+    setwnd(LEFTUPPER_WINDOW);
+    drawmaps(2);
+    gotoxy(jj*2+3,ii+2);
+    highvideo();
+    proutn("%c", game.quad[ii][jj]);
+    gotoxy(wherex()-1,wherey());
+    sound(500);
+    delay(1000);
+    nosound();
+    lowvideo();
+    proutn("%c", game.quad[ii][jj]);
+    setwnd(LOWER_WINDOW);
+    gotoxy(crx,cry);
+    _setcursortype(_NORMALCURSOR);
+    delay(500);
+#endif /* SERGEEV */
+} 
+
 void warble(void)
 /* sound and visual effects for teleportation */
 {
@@ -378,6 +403,52 @@ void warble(void)
 #endif /* SERGEEV */
 }
 
+void tracktorpedo(int x, int y, int ix, int iy, int wait, int l, int i, int n, int iquad)
+/* torpedo-track animation */
+{
+#ifndef SERGEEV
+    if (l == 1) {
+       if (n != 1) {
+           skip(1);
+           proutn("Track for torpedo number %d-  ", i);
+       }
+       else {
+           skip(1);
+           proutn("Torpedo track- ");
+       }
+    } else if (l==4 || l==9) 
+       skip(1);
+    proutn("%d - %d   ", (int)x, (int)y);
+#else
+    if (game.damage[DSRSENS]==0 || condit==IHDOCKED) {
+       drawmaps(2);
+       delay((wait!=1)*400);
+       gotoxy(iy*2+3,ix+2);
+       if ((game.quad[ix][iy]==IHDOT)||(game.quad[ix][iy]==IHBLANK)){
+           game.quad[ix][iy]='+';
+           drawmaps(2);
+           game.quad[ix][iy]=iquad;
+           sound(l*10);
+           delay(100);
+           nosound();
+       }
+       else {
+           game.quad[ix][iy]|=128;
+           drawmaps(2);
+           game.quad[ix][iy]=iquad;
+           _setcursortype(_NOCURSOR);
+           sound(500);
+           delay(1000);
+           nosound();
+           lowvideo();
+           _setcursortype(_NORMALCURSOR);
+       }
+    } else {
+       proutn("%d - %d   ", (int)x, (int)y);
+    }
+#endif /* SERGEEV */
+}
+
 void setpassword(void) {
 #ifndef SERGEEV
        while (TRUE) {
diff --git a/sst.h b/sst.h
index f6c0960df0bb9b366814a3cb58fed6081d3190a7..0e3e52419e4fcf22b69cc4a9c728269811c238c3 100644 (file)
--- a/sst.h
+++ b/sst.h
@@ -410,7 +410,7 @@ void crmena(int, int, int, int, int);
 void deadkl(int, int, int, int, int);
 void timwrp(void);
 void movcom(void);
-void torpedo(double, double, int, int, double *, int);
+void torpedo(double, double, int, int, double *, int, int, int);
 void huh(void);
 void pause_game(int);
 void nova(int, int);
@@ -437,6 +437,8 @@ void iostart(int);
 void ioend(void);
 void setwnd(short);
 void warble(void);
+void boom(int ii, int jj);
+void tracktorpedo(int x, int y, int ix, int iy, int wait, int l, int i, int n, int iquad);
 void cgetline(char *, int);
 void waitfor(void);
 void setpassword(void);