projects
/
super-star-trek.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
More magic-number chasing.
[super-star-trek.git]
/
ai.c
diff --git
a/ai.c
b/ai.c
index ad550a14cdecba56c208324c855cc03c2d5b88ad..0fe92c8ff8b1c1282b1065db1ed4819162d102af 100644
(file)
--- a/
ai.c
+++ b/
ai.c
@@
-3,9
+3,9
@@
static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) {
int iqx, iqy, l;
static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) {
int iqx, iqy, l;
- iqx = quadx+(lookx+
9)/10
- 1;
- iqy = quady+(looky+
9)/10
- 1;
- if (iqx < 1 || iqx >
8 || iqy < 1 || iqy > 8
||
+ iqx = quadx+(lookx+
(QUADSIZE-1))/QUADSIZE
- 1;
+ iqy = quady+(looky+
(QUADSIZE-1))/QUADSIZE
- 1;
+ if (iqx < 1 || iqx >
GALSIZE || iqy < 1 || iqy > GALSIZE
||
game.state.galaxy[iqx][iqy] > 899)
return 0; /* no can do -- neg energy, supernovae, or >8 Klingons */
if (ienm == IHR) return 0; /* Romulans cannot escape! */
game.state.galaxy[iqx][iqy] > 899)
return 0; /* no can do -- neg energy, supernovae, or >8 Klingons */
if (ienm == IHR) return 0; /* Romulans cannot escape! */
@@
-39,8
+39,8
@@
static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) {
nenhere--;
if (condit != IHDOCKED) newcnd();
/* Handle global matters related to escape */
nenhere--;
if (condit != IHDOCKED) newcnd();
/* Handle global matters related to escape */
- game.state.galaxy[quadx][quady] -=
100
;
- game.state.galaxy[iqx][iqy] +=
100
;
+ game.state.galaxy[quadx][quady] -=
ENEMY_PLACE
;
+ game.state.galaxy[iqx][iqy] +=
ENEMY_PLACE
;
if (ienm==IHS) {
ishere=0;
iscate=0;
if (ienm==IHS) {
ishere=0;
iscate=0;
@@
-84,7
+84,7
@@
static void movebaddy(int comx, int comy, int loccom, int ienm) {
if (ienm==IHS &&
(game.kpower[loccom] <= 500.0 || (condit==IHDOCKED && game.damage[DPHOTON]==0))) {
irun = 1;
if (ienm==IHS &&
(game.kpower[loccom] <= 500.0 || (condit==IHDOCKED && game.damage[DPHOTON]==0))) {
irun = 1;
- motion = -
10
;
+ motion = -
QUADSIZE
;
}
else {
/* decide whether to advance, retreat, or hold position */
}
else {
/* decide whether to advance, retreat, or hold position */
@@
-165,7
+165,7
@@
static void movebaddy(int comx, int comy, int loccom, int ienm) {
/* calcuate preferred number of steps */
nsteps = motion < 0 ? -motion : motion;
if (motion > 0 && nsteps > mdist) nsteps = mdist; /* don't overshoot */
/* calcuate preferred number of steps */
nsteps = motion < 0 ? -motion : motion;
if (motion > 0 && nsteps > mdist) nsteps = mdist; /* don't overshoot */
- if (nsteps >
10) nsteps = 10
; /* This shouldn't be necessary */
+ if (nsteps >
QUADSIZE) nsteps = QUADSIZE
; /* This shouldn't be necessary */
if (nsteps < 1) nsteps = 1; /* This shouldn't be necessary */
#ifdef DEBUG
if (idebug) {
if (nsteps < 1) nsteps = 1; /* This shouldn't be necessary */
#ifdef DEBUG
if (idebug) {
@@
-196,14
+196,14
@@
static void movebaddy(int comx, int comy, int loccom, int ienm) {
success = 0;
attempts = 0; /* Settle mysterious hang problem */
while (attempts++ < 20 && !success) {
success = 0;
attempts = 0; /* Settle mysterious hang problem */
while (attempts++ < 20 && !success) {
- if (lookx < 1 || lookx >
10
) {
+ if (lookx < 1 || lookx >
QUADSIZE
) {
if (motion < 0 && tryexit(lookx, looky, ienm, loccom, irun))
return;
if (krawlx == mx || my == 0) break;
lookx = nextx + krawlx;
krawlx = -krawlx;
}
if (motion < 0 && tryexit(lookx, looky, ienm, loccom, irun))
return;
if (krawlx == mx || my == 0) break;
lookx = nextx + krawlx;
krawlx = -krawlx;
}
- else if (looky < 1 || looky >
10
) {
+ else if (looky < 1 || looky >
QUADSIZE
) {
if (motion < 0 && tryexit(lookx, looky, ienm, loccom, irun))
return;
if (krawly == my || mx == 0) break;
if (motion < 0 && tryexit(lookx, looky, ienm, loccom, irun))
return;
if (krawly == my || mx == 0) break;
@@
-302,7
+302,7
@@
static int movescom(int iqx, int iqy, int flag, int *ipage) {
int i;
if ((iqx==quadx && iqy==quady) ||
int i;
if ((iqx==quadx && iqy==quady) ||
- iqx < 1 || iqx >
8 || iqy < 1 || iqy > 8
||
+ iqx < 1 || iqx >
GALSIZE || iqy < 1 || iqy > GALSIZE
||
game.state.galaxy[iqx][iqy] > 899) return 1;
if (flag) {
/* Avoid quadrants with bases if we want to avoid Enterprise */
game.state.galaxy[iqx][iqy] > 899) return 1;
if (flag) {
/* Avoid quadrants with bases if we want to avoid Enterprise */
@@
-311,10
+311,10
@@
static int movescom(int iqx, int iqy, int flag, int *ipage) {
}
if (justin && !iscate) return 1;
/* do the move */
}
if (justin && !iscate) return 1;
/* do the move */
- game.state.galaxy[game.state.isx][game.state.isy] -=
100
;
+ game.state.galaxy[game.state.isx][game.state.isy] -=
ENEMY_PLACE
;
game.state.isx = iqx;
game.state.isy = iqy;
game.state.isx = iqx;
game.state.isy = iqy;
- game.state.galaxy[game.state.isx][game.state.isy] +=
100
;
+ game.state.galaxy[game.state.isx][game.state.isy] +=
ENEMY_PLACE
;
if (ishere) {
/* SC has scooted, Remove him from current quadrant */
iscate=0;
if (ishere) {
/* SC has scooted, Remove him from current quadrant */
iscate=0;
@@
-364,8
+364,8
@@
static int movescom(int iqx, int iqy, int flag, int *ipage) {
void scom(int *ipage) {
int i, i2, j, ideltax, ideltay, ibqx, ibqy, sx, sy, ifindit, iwhichb;
int iqx, iqy;
void scom(int *ipage) {
int i, i2, j, ideltax, ideltay, ibqx, ibqy, sx, sy, ifindit, iwhichb;
int iqx, iqy;
- int basetbl[
6
];
- double bdist[
6
];
+ int basetbl[
BASEMAX
];
+ double bdist[
BASEMAX
];
int flag;
#ifdef DEBUG
if (idebug) prout("SCOM");
int flag;
#ifdef DEBUG
if (idebug) prout("SCOM");
@@
-546,15
+546,15
@@
void movetho(void) {
if (ithere==0 || justin == 1) return;
if (ithx == 1 && ithy == 1) {
if (ithere==0 || justin == 1) return;
if (ithx == 1 && ithy == 1) {
- idx = 1; idy =
10
;
+ idx = 1; idy =
QUADSIZE
;
}
}
- else if (ithx == 1 && ithy ==
10
) {
- idx =
10; idy = 10
;
+ else if (ithx == 1 && ithy ==
QUADSIZE
) {
+ idx =
QUADSIZE; idy = QUADSIZE
;
}
}
- else if (ithx ==
10 && ithy == 10
) {
- idx =
10
; idy = 1;
+ else if (ithx ==
QUADSIZE && ithy == QUADSIZE
) {
+ idx =
QUADSIZE
; idy = 1;
}
}
- else if (ithx ==
10
&& ithy == 1) {
+ else if (ithx ==
QUADSIZE
&& ithy == 1) {
idx = 1; idy = 1;
}
else {
idx = 1; idy = 1;
}
else {
@@
-588,11
+588,11
@@
void movetho(void) {
game.ky[nenhere]=ithy;
/* check to see if all holes plugged */
game.ky[nenhere]=ithy;
/* check to see if all holes plugged */
- for (i = 1; i <
1
1; i++) {
+ for (i = 1; i <
QUADSIZE+
1; i++) {
if (game.quad[1][i]!=IHWEB && game.quad[1][i]!=IHT) return;
if (game.quad[1][i]!=IHWEB && game.quad[1][i]!=IHT) return;
- if (game.quad[
10][i]!=IHWEB && game.quad[10
][i]!=IHT) return;
+ if (game.quad[
QUADSIZE][i]!=IHWEB && game.quad[QUADSIZE
][i]!=IHT) return;
if (game.quad[i][1]!=IHWEB && game.quad[i][1]!=IHT) return;
if (game.quad[i][1]!=IHWEB && game.quad[i][1]!=IHT) return;
- if (game.quad[i][
10]!=IHWEB && game.quad[i][10
]!=IHT) return;
+ if (game.quad[i][
QUADSIZE]!=IHWEB && game.quad[i][QUADSIZE
]!=IHT) return;
}
/* All plugged up -- Tholian splits */
game.quad[ithx][ithy]=IHWEB;
}
/* All plugged up -- Tholian splits */
game.quad[ithx][ithy]=IHWEB;