projects
/
super-star-trek.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Two sources of vast confusion in reading the C code are these:
[super-star-trek.git]
/
src
/
battle.c
diff --git
a/src/battle.c
b/src/battle.c
index 387bfa9f88449353b2b5f7bc321669981a0adf45..78baae9eab970dbf4a127991fbf873c154c63937 100644
(file)
--- a/
src/battle.c
+++ b/
src/battle.c
@@
-239,9
+239,9
@@
void ram(bool ibumpd, feature ienm, coord w)
}
game.shldup = false;
prout(_("***Shields are down."));
}
game.shldup = false;
prout(_("***Shields are down."));
- if (
KLINGREM
) {
-
pause_game(true
);
- d
rep
rt();
+ if (
game.state.remkl + game.state.remcom + game.state.nscrem
) {
+
announce(
);
+ d
amagerepo
rt();
}
else
finish(FWON);
}
else
finish(FWON);
@@
-335,7
+335,7
@@
void torpedo(double course, double r, coord in, double *hit, int i, int n)
case IHR: /* Hit a regular enemy */
case IHK:
/* find the enemy */
case IHR: /* Hit a regular enemy */
case IHK:
/* find the enemy */
- for
_local_enemies(ll
)
+ for
(ll = 1; ll <= game.nenhere; ll++
)
if (same(w, game.ks[ll]))
break;
kp = fabs(game.kpower[ll]);
if (same(w, game.ks[ll]))
break;
kp = fabs(game.kpower[ll]);
@@
-380,7
+380,7
@@
void torpedo(double course, double r, coord in, double *hit, int i, int n)
case IHB: /* Hit a base */
skip(1);
prout(_("***STARBASE DESTROYED.."));
case IHB: /* Hit a base */
skip(1);
prout(_("***STARBASE DESTROYED.."));
- for
_starbases(ll
) {
+ for
(ll = 1; ll <= game.state.rembase; ll++
) {
if (same(game.state.baseq[ll], game.quadrant)) {
game.state.baseq[ll]=game.state.baseq[game.state.rembase];
break;
if (same(game.state.baseq[ll], game.quadrant)) {
game.state.baseq[ll]=game.state.baseq[game.state.rembase];
break;
@@
-399,7
+399,7
@@
void torpedo(double course, double r, coord in, double *hit, int i, int n)
prout(_(" destroyed."));
game.state.nplankl++;
q->planet = NOPLANET;
prout(_(" destroyed."));
game.state.nplankl++;
q->planet = NOPLANET;
-
DESTROY(&game.state.plnets[game.iplnet])
;
+
game.state.planets[game.iplnet].pclass = destroyed
;
game.iplnet = 0;
invalidate(game.plnet);
game.quad[w.x][w.y] = IHDOT;
game.iplnet = 0;
invalidate(game.plnet);
game.quad[w.x][w.y] = IHDOT;
@@
-413,7
+413,7
@@
void torpedo(double course, double r, coord in, double *hit, int i, int n)
prout(_(" destroyed."));
game.state.nworldkl++;
q->planet = NOPLANET;
prout(_(" destroyed."));
game.state.nworldkl++;
q->planet = NOPLANET;
-
DESTROY(&game.state.plnets[game.iplnet])
;
+
game.state.planets[game.iplnet].pclass = destroyed
;
game.iplnet = 0;
invalidate(game.plnet);
game.quad[w.x][w.y] = IHDOT;
game.iplnet = 0;
invalidate(game.plnet);
game.quad[w.x][w.y] = IHDOT;
@@
-501,9
+501,9
@@
void torpedo(double course, double r, coord in, double *hit, int i, int n)
game.quad[w.x][w.y]=IHDOT;
game.quad[jw.x][jw.y]=iquad;
prout(_(" displaced by blast to %s "), cramlc(sector, jw));
game.quad[w.x][w.y]=IHDOT;
game.quad[jw.x][jw.y]=iquad;
prout(_(" displaced by blast to %s "), cramlc(sector, jw));
- for
_local_enemies(ll
)
+ for
(ll = 1; ll <= game.nenhere; ll++
)
game.kdist[ll] = game.kavgd[ll] = distance(game.sector,game.ks[ll]);
game.kdist[ll] = game.kavgd[ll] = distance(game.sector,game.ks[ll]);
- sortkl();
+ sortkl
ings
();
return;
}
skip(1);
return;
}
skip(1);
@@
-538,7
+538,8
@@
static void fry(double hit)
if (loop2 < loop1)
continue;
ktr += 1;
if (loop2 < loop1)
continue;
ktr += 1;
- if (ktr==3) skip(1);
+ if (ktr==3)
+ skip(1);
proutn(_(" and "));
}
proutn(device[j]);
proutn(_(" and "));
}
proutn(device[j]);
@@
-569,7
+570,7
@@
void attack(bool torps_ok)
/* Tholian gewts to move before attacking */
if (game.ithere)
/* Tholian gewts to move before attacking */
if (game.ithere)
- movetho();
+ movetho
lian
();
/* if you have just entered the RNZ, you'll get a warning */
if (game.neutz) { /* The one chance not to be attacked */
/* if you have just entered the RNZ, you'll get a warning */
if (game.neutz) { /* The one chance not to be attacked */
@@
-579,7
+580,7
@@
void attack(bool torps_ok)
/* commanders get a chance to tac-move towards you */
if ((((game.comhere || game.ishere) && !game.justin) || game.skill == SKILL_EMERITUS) && torps_ok)
/* commanders get a chance to tac-move towards you */
if ((((game.comhere || game.ishere) && !game.justin) || game.skill == SKILL_EMERITUS) && torps_ok)
- mov
com
();
+ mov
eklings
();
/* if no enemies remain after movement, we're done */
if (game.nenhere==0 || (game.nenhere==1 && iqhere && !iqengry))
/* if no enemies remain after movement, we're done */
if (game.nenhere==0 || (game.nenhere==1 && iqhere && !iqengry))
@@
-596,8
+597,9
@@
void attack(bool torps_ok)
if (game.skill <= SKILL_FAIR)
where = sector;
if (game.skill <= SKILL_FAIR)
where = sector;
- for_local_enemies(loop) {
- if (game.kpower[loop] < 0) continue; /* too weak to attack */
+ for (loop = 1; loop <= game.nenhere; loop++) {
+ if (game.kpower[loop] < 0)
+ continue; /* too weak to attack */
/* compute hit strength and diminish shield power */
r = Rand();
/* Increase chance of photon torpedos if docked or enemy energy low */
/* compute hit strength and diminish shield power */
r = Rand();
/* Increase chance of photon torpedos if docked or enemy energy low */
@@
-617,7
+619,8
@@
void attack(bool torps_ok)
(iquad==IHS && r > 0.07) ||
(iquad==IHQUEST && r > 0.05);
if (usephasers) { /* Enemy uses phasers */
(iquad==IHS && r > 0.07) ||
(iquad==IHQUEST && r > 0.05);
if (usephasers) { /* Enemy uses phasers */
- if (game.condition == docked) continue; /* Don't waste the effort! */
+ if (game.condition == docked)
+ continue; /* Don't waste the effort! */
attempt = true; /* Attempt to attack */
dustfac = 0.8+0.05*Rand();
hit = game.kpower[loop]*pow(dustfac,game.kavgd[loop]);
attempt = true; /* Attempt to attack */
dustfac = 0.8+0.05*Rand();
hit = game.kpower[loop]*pow(dustfac,game.kavgd[loop]);
@@
-636,7
+639,7
@@
void attack(bool torps_ok)
r = (Rand()+Rand())*0.5 -0.5;
r += 0.002*game.kpower[loop]*r;
torpedo(course, r, jay, &hit, 1, 1);
r = (Rand()+Rand())*0.5 -0.5;
r += 0.002*game.kpower[loop]*r;
torpedo(course, r, jay, &hit, 1, 1);
- if (
KLINGREM
==0)
+ if (
(game.state.remkl + game.state.remcom + game.state.nscrem)
==0)
finish(FWON); /* Klingons did themselves in! */
if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova || game.alldone)
return; /* Supernova or finished */
finish(FWON); /* Klingons did themselves in! */
if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova || game.alldone)
return; /* Supernova or finished */
@@
-719,9
+722,9
@@
void attack(bool torps_ok)
}
}
/* After attack, reset average distance to enemies */
}
}
/* After attack, reset average distance to enemies */
- for
_local_enemies(loop
)
+ for
(loop = 1; loop <= game.nenhere; loop++
)
game.kavgd[loop] = game.kdist[loop];
game.kavgd[loop] = game.kdist[loop];
- sortkl();
+ sortkl
ings
();
return;
}
return;
}
@@
-755,7
+758,7
@@
void deadkl(coord w, feature type, coord mv)
switch (type) {
case IHC:
game.comhere = false;
switch (type) {
case IHC:
game.comhere = false;
- for
_commanders (i
)
+ for
(i = 1; i <= game.state.remcom; i++
)
if (same(game.state.kcmdr[i], game.quadrant))
break;
game.state.kcmdr[i] = game.state.kcmdr[game.state.remcom];
if (same(game.state.kcmdr[i], game.quadrant))
break;
game.state.kcmdr[i] = game.state.kcmdr[game.state.remcom];
@@
-786,15
+789,16
@@
void deadkl(coord w, feature type, coord mv)
/* For each kind of enemy, finish message to player */
prout(_(" destroyed."));
game.quad[w.x][w.y] = IHDOT;
/* For each kind of enemy, finish message to player */
prout(_(" destroyed."));
game.quad[w.x][w.y] = IHDOT;
- if (
KLINGREM
==0)
+ if (
(game.state.remkl + game.state.remcom + game.state.nscrem)
==0)
return;
return;
- game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom);
+ game.state.remtime = game.state.remkl + game.state.remcom > 0 ?
+ game.state.remres/(game.state.remkl + 4*game.state.remcom) : 99;
/* Remove enemy ship from arrays describing local conditions */
if (is_scheduled(FCDBAS) && same(game.battle, game.quadrant) && type==IHC)
unschedule(FCDBAS);
/* Remove enemy ship from arrays describing local conditions */
if (is_scheduled(FCDBAS) && same(game.battle, game.quadrant) && type==IHC)
unschedule(FCDBAS);
- for
_local_enemies(i
)
+ for
(i = 1; i <= game.nenhere; i++
)
if (same(game.ks[i], w))
break;
game.nenhere--;
if (same(game.ks[i], w))
break;
game.nenhere--;
@@
-963,7
+967,7
@@
void photon(void)
if (game.alldone || game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova)
return;
}
if (game.alldone || game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova)
return;
}
- if (
KLINGREM
==0)
+ if (
(game.state.remkl + game.state.remcom + game.state.nscrem)
==0)
finish(FWON);
}
finish(FWON);
}
@@
-1135,9
+1139,10
@@
void phasers(void)
irec=0;
do {
chew();
irec=0;
do {
chew();
- if (!kz) for_local_enemies(i)
- irec+=fabs(game.kpower[i])/(PHASEFAC*pow(0.90,game.kdist[i]))*
- (1.01+0.05*Rand()) + 1.0;
+ if (!kz)
+ for (i = 1; i <= game.nenhere; i++)
+ irec += fabs(game.kpower[i])/(PHASEFAC*pow(0.90,game.kdist[i]))*
+ (1.01+0.05*Rand()) + 1.0;
kz=1;
proutn(_("%d units required. "), irec);
chew();
kz=1;
proutn(_("%d units required. "), irec);
chew();
@@
-1172,7
+1177,7
@@
void phasers(void)
if (game.nenhere) {
extra = 0.0;
powrem = rpow;
if (game.nenhere) {
extra = 0.0;
powrem = rpow;
- for
_local_enemies(i
) {
+ for
(i = 1; i <= game.nenhere; i++
) {
hits[i] = 0.0;
if (powrem <= 0)
continue;
hits[i] = 0.0;
if (powrem <= 0)
continue;
@@
-1364,7
+1369,7
@@
void hittem(double *hits)
skip(1);
if (kpow == 0) {
deadkl(w, ienm, w);
skip(1);
if (kpow == 0) {
deadkl(w, ienm, w);
- if (
KLINGREM
==0)
+ if (
(game.state.remkl + game.state.remcom + game.state.nscrem)
==0)
finish(FWON);
if (game.alldone)
return;
finish(FWON);
if (game.alldone)
return;