Remove columns lnd, pln from spy report to fix spy unit leak
The values in these columns were computed by count_sect_units() and count_sect_planes(), which included land units and planes in the count that aren't shown by prunits() and prplanes(), namely own and embarked units. Confusing. Moreover, count_sect_planes() and prunits() rolled dice separately for spy units. This could leak the presence of spies even when prunits() didn't show them. All fixable, but not worth the trouble; just remove the counts.
This commit is contained in:
parent
c658d1e08d
commit
a233ecfea9
5 changed files with 4 additions and 56 deletions
|
@ -180,7 +180,6 @@ extern void lnd_submil(struct lndstr *, int);
|
||||||
extern void lnd_takemob(struct emp_qelem *, double);
|
extern void lnd_takemob(struct emp_qelem *, double);
|
||||||
extern int lnd_spyval(struct lndstr *);
|
extern int lnd_spyval(struct lndstr *);
|
||||||
extern void intelligence_report(int, struct lndstr *, int, char *);
|
extern void intelligence_report(int, struct lndstr *, int, char *);
|
||||||
extern int count_sect_units(struct sctstr *);
|
|
||||||
extern void count_units(struct shpstr *);
|
extern void count_units(struct shpstr *);
|
||||||
extern void lnd_count_units(struct lndstr *);
|
extern void lnd_count_units(struct lndstr *);
|
||||||
extern void lnd_mar(struct emp_qelem *, double *, double *, int *, natid);
|
extern void lnd_mar(struct emp_qelem *, double *, double *, int *, natid);
|
||||||
|
|
|
@ -559,7 +559,6 @@ extern void take_plane_off_ship(struct plnstr *, struct shpstr *);
|
||||||
extern void take_plane_off_land(struct plnstr *, struct lndstr *);
|
extern void take_plane_off_land(struct plnstr *, struct lndstr *);
|
||||||
extern void plane_sweep(struct emp_qelem *, coord, coord);
|
extern void plane_sweep(struct emp_qelem *, coord, coord);
|
||||||
extern void count_land_planes(struct lndstr *);
|
extern void count_land_planes(struct lndstr *);
|
||||||
extern int count_sect_planes(struct sctstr *);
|
|
||||||
extern int put_plane_on_land(struct plnstr *, struct lndstr *);
|
extern int put_plane_on_land(struct plnstr *, struct lndstr *);
|
||||||
extern int pln_hitchance(struct plnstr *, int, int);
|
extern int pln_hitchance(struct plnstr *, int, int);
|
||||||
extern int pln_damage(struct plnstr *, coord, coord, char, int *, int);
|
extern int pln_damage(struct plnstr *, coord, coord, char, int *, int);
|
||||||
|
|
|
@ -100,7 +100,7 @@ spy(void)
|
||||||
pr("SPY report\n");
|
pr("SPY report\n");
|
||||||
prdate();
|
prdate();
|
||||||
pr(" old sct rd rl def\n");
|
pr(" old sct rd rl def\n");
|
||||||
pr(" sect de own own eff eff eff eff civ mil shl gun pet food bars lnd pln\n");
|
pr(" sect de own own eff eff eff eff civ mil shl gun pet food bars\n");
|
||||||
while (nxtsct(&nstr, &from)) {
|
while (nxtsct(&nstr, &from)) {
|
||||||
if (!player->owner && !player->god)
|
if (!player->owner && !player->god)
|
||||||
continue;
|
continue;
|
||||||
|
@ -202,7 +202,7 @@ static void
|
||||||
spy_report(struct sctstr *sp)
|
spy_report(struct sctstr *sp)
|
||||||
{
|
{
|
||||||
prxy("%4d,%-4d", sp->sct_x, sp->sct_y, player->cnum);
|
prxy("%4d,%-4d", sp->sct_x, sp->sct_y, player->cnum);
|
||||||
pr(" %c%c %3d %3d %3d %3d %3d %3d %4d %4d %4d %3d %4d %4d %4d %3d %3d\n",
|
pr(" %c%c %3d %3d %3d %3d %3d %3d %4d %4d %4d %3d %4d %4d %4d\n",
|
||||||
dchr[sp->sct_type].d_mnem,
|
dchr[sp->sct_type].d_mnem,
|
||||||
sp->sct_newtype == sp->sct_type ? ' ' : dchr[sp->sct_newtype].d_mnem,
|
sp->sct_newtype == sp->sct_type ? ' ' : dchr[sp->sct_newtype].d_mnem,
|
||||||
sp->sct_own,
|
sp->sct_own,
|
||||||
|
@ -217,9 +217,7 @@ spy_report(struct sctstr *sp)
|
||||||
roundintby(sp->sct_item[I_GUN], 10),
|
roundintby(sp->sct_item[I_GUN], 10),
|
||||||
roundintby(sp->sct_item[I_PETROL], 10),
|
roundintby(sp->sct_item[I_PETROL], 10),
|
||||||
roundintby(sp->sct_item[I_FOOD], 10),
|
roundintby(sp->sct_item[I_FOOD], 10),
|
||||||
roundintby(sp->sct_item[I_BAR], 10),
|
roundintby(sp->sct_item[I_BAR], 10));
|
||||||
count_sect_units(sp),
|
|
||||||
count_sect_planes(sp));
|
|
||||||
prunits(sp->sct_x, sp->sct_y);
|
prunits(sp->sct_x, sp->sct_y);
|
||||||
prplanes(sp->sct_x, sp->sct_y);
|
prplanes(sp->sct_x, sp->sct_y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ lnd_take_casualty(int combat_mode, struct ulist *llp, int cas)
|
||||||
* defending unit.. find a place to send it
|
* defending unit.. find a place to send it
|
||||||
* strategy: look for the most-populated
|
* strategy: look for the most-populated
|
||||||
* adjacent sector that is owned by the unit
|
* adjacent sector that is owned by the unit
|
||||||
* player->owner. Charge mob..
|
* owner. Charge mob..
|
||||||
*/
|
*/
|
||||||
biggest = -1;
|
biggest = -1;
|
||||||
nowned = 0;
|
nowned = 0;
|
||||||
|
@ -386,34 +386,6 @@ intelligence_report(int destination, struct lndstr *lp, int spy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Used by the spy command to count land units in a sector. If used
|
|
||||||
for anything else, you may want to reconsider, because this doesn't
|
|
||||||
always count spies. :) */
|
|
||||||
int
|
|
||||||
count_sect_units(struct sctstr *sp)
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
struct nstr_item ni;
|
|
||||||
struct lndstr land;
|
|
||||||
|
|
||||||
snxtitem_all(&ni, EF_LAND);
|
|
||||||
while (nxtitem(&ni, &land)) {
|
|
||||||
if (!land.lnd_own)
|
|
||||||
continue;
|
|
||||||
if (land.lnd_x != sp->sct_x || land.lnd_y != sp->sct_y)
|
|
||||||
continue;
|
|
||||||
/* Don't always see spies */
|
|
||||||
if (lchr[(int)land.lnd_type].l_flags & L_SPY) {
|
|
||||||
if (!(chance(LND_SPY_DETECT_CHANCE(land.lnd_effic))))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/* Got here, report it */
|
|
||||||
++count;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
count_units(struct shpstr *sp)
|
count_units(struct shpstr *sp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1070,26 +1070,6 @@ count_land_planes(struct lndstr *lp)
|
||||||
putland(lp->lnd_uid, lp);
|
putland(lp->lnd_uid, lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
count_sect_planes(struct sctstr *sp)
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
struct nstr_item ni;
|
|
||||||
struct plnstr plane;
|
|
||||||
|
|
||||||
snxtitem_all(&ni, EF_PLANE);
|
|
||||||
while (nxtitem(&ni, &plane)) {
|
|
||||||
if (!plane.pln_own)
|
|
||||||
continue;
|
|
||||||
if (plane.pln_flags & PLN_LAUNCHED)
|
|
||||||
continue;
|
|
||||||
if (plane.pln_x == sp->sct_x && plane.pln_y == sp->sct_y)
|
|
||||||
++count;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
pln_hitchance(struct plnstr *pp, int hardtarget, int type)
|
pln_hitchance(struct plnstr *pp, int hardtarget, int type)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue