From: Eric S. Raymond Date: Sun, 13 Feb 2005 06:13:23 +0000 (+0000) Subject: Stas's fixes for torpedo and phaser animation. X-Git-Tag: 2.0~320 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=7de1f930478a9efcc3f093eb62414ec18d396f7b;p=super-star-trek.git Stas's fixes for torpedo and phaser animation. --- diff --git a/ai.c b/ai.c index d96f747..291c2f7 100644 --- a/ai.c +++ b/ai.c @@ -49,7 +49,7 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) ientesc=0; isatb=0; game.future[FSCMOVE]=0.2777+game.state.date; - game.future[FSCDBAS]=1e30; + game.future[FSCDBAS]=FOREVER; game.state.isx=iqx; game.state.isy=iqy; } @@ -330,7 +330,7 @@ static int movescom(int iqx, int iqy, int flag, int *ipage) isatb=0; ishere=0; ientesc=0; - game.future[FSCDBAS]=1e30; + game.future[FSCDBAS]=FOREVER; for_local_enemies(i) if (game.quad[game.kx[i]][game.ky[i]] == IHS) break; game.quad[game.kx[i]][game.ky[i]] = IHDOT; @@ -394,7 +394,7 @@ void scom(int *ipage) /* compute distances to starbases */ if (game.state.rembase <= 0) { /* nothing left to do */ - game.future[FSCMOVE] = 1e30; + game.future[FSCMOVE] = FOREVER; return; } sx = game.state.isx; @@ -498,7 +498,7 @@ void scom(int *ipage) } /* check for a base */ if (game.state.rembase == 0) { - game.future[FSCMOVE] = 1e30; + game.future[FSCMOVE] = FOREVER; } else for_starbases(i) { ibqx = game.state.baseqx[i]; @@ -509,7 +509,7 @@ void scom(int *ipage) iseenit = 0; isatb=1; game.future[FSCDBAS] = game.state.date + 1.0 +2.0*Rand(); - if (game.future[FCDBAS] < 1e30) game.future[FSCDBAS] += + if (game.future[FCDBAS] < FOREVER) game.future[FSCDBAS] += game.future[FCDBAS]-game.state.date; if (game.damage[DRADIO] > 0 && condit != IHDOCKED) return; /* no warning */ diff --git a/battle.c b/battle.c index 4b3cf90..985774b 100644 --- a/battle.c +++ b/battle.c @@ -176,7 +176,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, int i, int n) +void torpedo(double course, double r, int inx, int iny, double *hit, int i, int n) { int l, iquad=0, ix=0, iy=0, jx=0, jy=0, shoved=0, ll; @@ -202,8 +202,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i iy = y + 0.5; if (!VALID_SECTOR(ix, iy)) break; iquad=game.quad[ix][iy]; - tracktorpedo(x, y, ix, iy, wait, l, i, n, iquad); - wait = 1; + tracktorpedo(ix, iy, l, i, n); if (iquad==IHDOT) continue; /* hit something */ setwnd(message_window); @@ -518,7 +517,7 @@ void attack(int torps_ok) prout(" "); r = (Rand()+Rand())*0.5 -0.5; r += 0.002*game.kpower[l]*r; - torpedo(course, r, jx, jy, &hit, 0, 1, 1); + torpedo(course, r, jx, jy, &hit, 1, 1); if (game.state.remkl==0) finish(FWON); /* Klingons did themselves in! */ if (game.state.galaxy[quadx][quady].supernova || alldone) @@ -640,7 +639,7 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) game.state.cx[game.state.remcom] = 0; game.state.cy[game.state.remcom] = 0; game.state.remcom--; - game.future[FTBEAM] = 1e30; + game.future[FTBEAM] = FOREVER; if (game.state.remcom != 0) game.future[FTBEAM] = game.state.date + expran(1.0*incom/game.state.remcom); game.state.killc++; @@ -651,7 +650,7 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) case IHS: game.state.nscrem = ishere = game.state.isx = game.state.isy = isatb = iscate = 0; game.state.nsckill = 1; - game.future[FSCMOVE] = game.future[FSCDBAS] = 1e30; + game.future[FSCMOVE] = game.future[FSCDBAS] = FOREVER; break; } } @@ -664,8 +663,8 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom); /* Remove enemy ship from arrays describing local conditions */ - if (game.future[FCDBAS] < 1e30 && batx==quadx && baty==quady && type==IHC) - game.future[FCDBAS] = 1e30; + if (game.future[FCDBAS] < FOREVER && batx==quadx && baty==quady && type==IHC) + game.future[FCDBAS] = FOREVER; for_local_enemies(i) if (game.kx[i]==ix && game.ky[i]==iy) break; nenhere--; @@ -827,7 +826,7 @@ void photon(void) } if (shldup || condit == IHDOCKED) r *= 1.0 + 0.0001*shield; - torpedo(course[i], r, sectx, secty, &dummy, 0, i, n); + torpedo(course[i], r, sectx, secty, &dummy, i, n); if (alldone || game.state.galaxy[quadx][quady].supernova) return; } diff --git a/io.c b/io.c index 9b96802..b3e974e 100644 --- a/io.c +++ b/io.c @@ -302,11 +302,11 @@ void drawmaps(short l) if (game.options & OPTION_CURSES) { if (l == 1) sensor(); + setwnd(srscan_window); + wmove(curwnd, 0, 0); + enqueue("no"); + srscan(SCAN_FULL); if (l != 2) { - setwnd(srscan_window); - wmove(curwnd, 0, 0); - enqueue("no"); - srscan(SCAN_FULL); setwnd(report_window); wclear(report_window); wmove(report_window, 0, 0); @@ -320,25 +320,28 @@ void drawmaps(short l) } } +static void put_srscan_sym(int x, int y, char sym) +{ + wmove(srscan_window, x+1, y*2+2); + waddch(srscan_window, sym); + wrefresh(srscan_window); +} + void boom(int ii, int jj) /* enemy fall down, go boom */ { if (game.options & OPTION_CURSES) { - setwnd(srscan_window); drawmaps(2); - wmove(srscan_window, ii*2+3, jj+2); + setwnd(srscan_window); wattron(srscan_window, A_REVERSE); - waddch(srscan_window, game.quad[ii][jj]); - wrefresh(srscan_window); + put_srscan_sym(ii, jj, game.quad[ii][jj]); sound(500); delay(1000); nosound(); - wmove(srscan_window, ii*2+3, jj+2); wattroff(srscan_window, A_REVERSE); - waddch(srscan_window, game.quad[ii][jj]); - wrefresh(srscan_window); - setwnd(message_window); + put_srscan_sym(ii, jj, game.quad[ii][jj]); delay(500); + setwnd(message_window); } } @@ -355,7 +358,7 @@ void warble(void) prouts(" . . . . . "); } -void tracktorpedo(int x, int y, int ix, int iy, int wait, int l, int i, int n, int iquad) +void tracktorpedo(int ix, int iy, int l, int i, int n) /* torpedo-track animation */ { if (!game.options & OPTION_CURSES) { @@ -370,30 +373,31 @@ void tracktorpedo(int x, int y, int ix, int iy, int wait, int l, int i, int n, i } } else if (l==4 || l==9) skip(1); - proutn("%d - %d ", (int)x, (int)y); + proutn("%d - %d ", ix, iy); } else { if (game.damage[DSRSENS]==0 || condit==IHDOCKED) { - drawmaps(2); - delay((wait!=1)*400); - if ((game.quad[ix][iy]==IHDOT)||(game.quad[ix][iy]==IHBLANK)){ - game.quad[ix][iy]='+'; + if (i != 1 && l == 1) { drawmaps(2); - game.quad[ix][iy]=iquad; + delay(400); + } + if ((game.quad[ix][iy]==IHDOT)||(game.quad[ix][iy]==IHBLANK)){ + put_srscan_sym(ix, iy, '+'); sound(l*10); delay(100); nosound(); + put_srscan_sym(ix, iy, game.quad[ix][iy]); } else { - game.quad[ix][iy] |= DAMAGED; - drawmaps(2); - game.quad[ix][iy]=iquad; + wattron(curwnd, A_REVERSE); + put_srscan_sym(ix, iy, game.quad[ix][iy]); sound(500); delay(1000); nosound(); wattroff(curwnd, A_REVERSE); + put_srscan_sym(ix, iy, game.quad[ix][iy]); } } else { - proutn("%d - %d ", (int)x, (int)y); + proutn("%d - %d ", ix, iy); } } } diff --git a/planets.c b/planets.c index 5ea7479..68bb27c 100644 --- a/planets.c +++ b/planets.c @@ -17,7 +17,7 @@ static int consumeTime(void) } #endif // asave = future[FSNOVA]; -// future[FSNOVA] = 1e30; /* defer supernovas */ +// future[FSNOVA] = FOREVER; /* defer supernovas */ events(); /* Used to avoid if future[FSCMOVE] within time */ // future[FSNOVA] = asave; /*fails if game over, quadrant super-novas or we've moved to new quadrant*/ diff --git a/reports.c b/reports.c index 724b6fd..b074cd8 100644 --- a/reports.c +++ b/reports.c @@ -249,9 +249,7 @@ static void sectscan(int goodScan, int i, int j) if (game.quad[i][j] != ship) highvideo(); } - if (game.quad[i][j] & DAMAGED) - highvideo(); - proutn("%c ",game.quad[i][j] & ~DAMAGED); + proutn("%c ",game.quad[i][j]); textcolor(DEFAULT); } else @@ -343,7 +341,7 @@ int srscan(int l) else prout(" [Using Base's sensors]"); } - else proutn(" Short-range scan\n"); + else proutn(" Short-range scan"); if (goodScan && !game.damage[DRADIO]) { game.state.chart[quadx][quady].klingons = game.state.galaxy[quadx][quady].klingons; game.state.chart[quadx][quady].starbase = game.state.galaxy[quadx][quady].starbase; diff --git a/sst.h b/sst.h index dfc6dd2..c904fef 100644 --- a/sst.h +++ b/sst.h @@ -453,7 +453,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, int, int); +void torpedo(double, double, int, int, double *, int, int); void huh(void); void pause_game(int); void nova(int, int); @@ -479,7 +479,7 @@ void iostart(void); void setwnd(WINDOW *); 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 tracktorpedo(int ix, int iy, int l, int i, int n); void cgetline(char *, int); void waitfor(void); void setpassword(void);