]> git.pond.sub.org Git - empserver/commitdiff
Remove columns lnd, pln from spy report to fix spy unit leak
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 14 Jun 2008 16:55:29 +0000 (18:55 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 14 Jun 2008 16:55:29 +0000 (18:55 +0200)
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.

include/land.h
include/prototypes.h
src/lib/commands/spy.c
src/lib/subs/lndsub.c
src/lib/subs/plnsub.c

index bb25c8119c8317ba4f85d257920f3ef19adb3d34..48742630554ab8b5724ac996e23bd3c8e8905986 100644 (file)
@@ -180,7 +180,6 @@ extern void lnd_submil(struct lndstr *, int);
 extern void lnd_takemob(struct emp_qelem *, double);
 extern int lnd_spyval(struct lndstr *);
 extern void intelligence_report(int, struct lndstr *, int, char *);
-extern int count_sect_units(struct sctstr *);
 extern void count_units(struct shpstr *);
 extern void lnd_count_units(struct lndstr *);
 extern void lnd_mar(struct emp_qelem *, double *, double *, int *, natid);
index ef2ad0dc2ca41f3b1362cadf791d1ced99ca55a7..b60f22d2bf0e5d2f702a33f51329b39e3c6a5e22 100644 (file)
@@ -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 plane_sweep(struct emp_qelem *, coord, coord);
 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 pln_hitchance(struct plnstr *, int, int);
 extern int pln_damage(struct plnstr *, coord, coord, char, int *, int);
index d1b806a2183c584c025e42bdd80de79b04ae0367..290ea056672a4a8e0a8a4e850e2849104b35b0f5 100644 (file)
@@ -100,7 +100,7 @@ spy(void)
     pr("SPY report\n");
     prdate();
     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)) {
        if (!player->owner && !player->god)
            continue;
@@ -202,7 +202,7 @@ static void
 spy_report(struct sctstr *sp)
 {
     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,
        sp->sct_newtype == sp->sct_type ? ' ' : dchr[sp->sct_newtype].d_mnem,
        sp->sct_own,
@@ -217,9 +217,7 @@ spy_report(struct sctstr *sp)
        roundintby(sp->sct_item[I_GUN], 10),
        roundintby(sp->sct_item[I_PETROL], 10),
        roundintby(sp->sct_item[I_FOOD], 10),
-       roundintby(sp->sct_item[I_BAR], 10),
-       count_sect_units(sp),
-       count_sect_planes(sp));
+       roundintby(sp->sct_item[I_BAR], 10));
     prunits(sp->sct_x, sp->sct_y);
     prplanes(sp->sct_x, sp->sct_y);
 }
index 395ffcf2fdbb63422f2ab5ea26686ae353669c6f..88670898cb1dd5bbca0d6e88b78b007273d2c6d8 100644 (file)
@@ -216,7 +216,7 @@ lnd_take_casualty(int combat_mode, struct ulist *llp, int cas)
             * defending unit.. find a place to send it
             * strategy: look for the most-populated 
             * adjacent sector that is owned by the unit
-            * player->owner. Charge mob..
+            * owner. Charge mob..
             */
            biggest = -1;
            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
 count_units(struct shpstr *sp)
 {
index c60eae46a69bcbc7fbd058a676dd291f43e03939..065e2729181bf38dba4f381079440cab8579695c 100644 (file)
@@ -1070,26 +1070,6 @@ count_land_planes(struct lndstr *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
 pln_hitchance(struct plnstr *pp, int hardtarget, int type)
 {