]> git.pond.sub.org Git - empserver/commitdiff
Replace getvec() by direct, read-only item access in some cases where
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 5 Mar 2004 10:38:58 +0000 (10:38 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Fri, 5 Mar 2004 10:38:58 +0000 (10:38 +0000)
that's obviously correct.

23 files changed:
src/lib/commands/bomb.c
src/lib/commands/budg.c
src/lib/commands/carg.c
src/lib/commands/cens.c
src/lib/commands/comm.c
src/lib/commands/dump.c
src/lib/commands/edit.c
src/lib/commands/land.c
src/lib/commands/ldump.c
src/lib/commands/nuke.c
src/lib/commands/prod.c
src/lib/commands/sabo.c
src/lib/commands/sdump.c
src/lib/commands/shi.c
src/lib/subs/lndsub.c
src/lib/subs/move.c
src/lib/subs/retreat.c
src/lib/subs/satmap.c
src/lib/update/bp.c
src/lib/update/plane.c
src/lib/update/prepare.c
src/lib/update/revolt.c
src/lib/update/sail.c

index f2fefd811f7909ad1bb28d7ab059b0231de5059a..407b2f651d494092f4f9cccffdc60d00fc1f2fa7 100644 (file)
@@ -220,7 +220,6 @@ pin_bomb(struct emp_qelem *list, struct sctstr *target)
     int type;
     int bad;
     s_char *p;
-    int vec[I_MAX + 1];
     struct plist *plp;
     struct emp_qelem *qp;
     int bestacc;
@@ -253,7 +252,6 @@ pin_bomb(struct emp_qelem *list, struct sctstr *target)
     }
     nplanes = planesatxy(target->sct_x, target->sct_y, 0, 0, list);
     nunits = unitsatxy(target->sct_x, target->sct_y, 0, 0);
-    getvec(VT_ITEM, vec, (s_char *)target, EF_SECTOR);
   retry:
     p = getstring("Bomb what? (ship, plane, land unit, efficiency, commodities) ",
                  buf);
@@ -333,7 +331,7 @@ pin_bomb(struct emp_qelem *list, struct sctstr *target)
        }
 
        for (i = 0; i < nbomb; i++) {
-           if (!vec[bombcomm[i]])
+           if (!target->sct_item[bombcomm[i]])
                continue;
            break;
        }
@@ -425,15 +423,13 @@ comm_bomb(struct emp_qelem *list, struct sctstr *target)
     int i;
     int amt, before;
     struct ichrstr *ip;
-    int vec[I_MAX + 1];
     struct emp_qelem *qp;
     struct sctstr sect;
     int dam = 0;
     int nukedam;
 
-    getvec(VT_ITEM, vec, (s_char *)target, EF_SECTOR);
     for (i = 0; i < nbomb; i++) {
-       if (vec[bombcomm[i]] == 0)
+       if (target->sct_item[bombcomm[i]] == 0)
            continue;
        if (opt_SUPER_BARS && bombcomm[i] == I_BAR)
            continue;
index 58021320c25b838ea0edbda8937ccdf2a640d307..2a5de74301e1950f0f8c4c98e61740c08ec18b27 100644 (file)
@@ -326,7 +326,6 @@ calc_all(long int (*p_sect)[2], int *taxes, int *Ncivs, int *Nuws,
     int n, civ_tax, uw_tax, mil_pay;
     struct sctstr *sp;
     int etu = etu_per_update;
-    int vec[I_MAX + 1];
     long tmp_money;
 
     lnd_money[player->cnum] = sea_money[player->cnum] = 0;
@@ -341,14 +340,13 @@ calc_all(long int (*p_sect)[2], int *taxes, int *Ncivs, int *Nuws,
        if (sp->sct_own == player->cnum) {
            sp->sct_updated = 0;
            tax(sp, np, etu, &pop, &civ_tax, &uw_tax, &mil_pay);
-           getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR);
-           *Ncivs += vec[I_CIVIL];
-           *Nuws += vec[I_UW];
+           *Ncivs += sp->sct_item[I_CIVIL];
+           *Nuws += sp->sct_item[I_UW];
            *taxes += civ_tax + uw_tax;
            *mil += mil_pay;
            if (sp->sct_type == SCT_BANK) {
                *bars += bank_income(sp, etu);
-               *Nbars += vec[I_BAR];
+               *Nbars += sp->sct_item[I_BAR];
            }
        }
     }
index 0ff9d2f785379dbf586126f8d98af23914d16dc2..9df0304394dc93331c9d6c37f3101b6e9b4fcacc 100644 (file)
@@ -50,7 +50,6 @@ carg(void)
     int nships;
     struct nstr_item ni;
     struct shpstr ship;
-    int vec[I_MAX + 1];
 
     if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
        return RET_SYN;
@@ -71,17 +70,16 @@ carg(void)
        prxy("%4d,%-4d ", ship.shp_x, ship.shp_y, player->cnum);
        pr(" %1c", ship.shp_fleet);
        pr("%4d%%", ship.shp_effic);
-       getvec(VT_ITEM, vec, (s_char *)&ship, EF_SHIP);
-       pr("%4d", vec[I_SHELL]);
-       pr("%4d", vec[I_GUN]);
-       pr("%4d", vec[I_PETROL]);
-       pr("%4d", vec[I_IRON]);
-       pr("%4d", vec[I_DUST]);
-       pr("%4d", vec[I_BAR]);
-       pr("%4d", vec[I_OIL]);
-       pr("%4d", vec[I_LCM]);
-       pr("%4d", vec[I_HCM]);
-       pr("%4d\n", vec[I_RAD]);
+       pr("%4d", ship.shp_item[I_SHELL]);
+       pr("%4d", ship.shp_item[I_GUN]);
+       pr("%4d", ship.shp_item[I_PETROL]);
+       pr("%4d", ship.shp_item[I_IRON]);
+       pr("%4d", ship.shp_item[I_DUST]);
+       pr("%4d", ship.shp_item[I_BAR]);
+       pr("%4d", ship.shp_item[I_OIL]);
+       pr("%4d", ship.shp_item[I_LCM]);
+       pr("%4d", ship.shp_item[I_HCM]);
+       pr("%4d\n", ship.shp_item[I_RAD]);
        if (opt_SHIPNAMES) {
            if (ship.shp_name[0] != 0) {
                pr("       %s\n", ship.shp_name);
@@ -105,7 +103,6 @@ lcarg(void)
     int nunits;
     struct nstr_item ni;
     struct lndstr land;
-    int vec[I_MAX + 1];
 
     if (!snxtitem(&ni, EF_LAND, player->argp[1]))
        return RET_SYN;
@@ -126,17 +123,16 @@ lcarg(void)
        prxy("%4d,%-4d ", land.lnd_x, land.lnd_y, player->cnum);
        pr(" %1c", land.lnd_army);
        pr("%4d%%", land.lnd_effic);
-       getvec(VT_ITEM, vec, (s_char *)&land, EF_LAND);
-       pr("%4d", vec[I_SHELL]);
-       pr("%4d", vec[I_GUN]);
-       pr("%4d", vec[I_PETROL]);
-       pr("%4d", vec[I_IRON]);
-       pr("%4d", vec[I_DUST]);
-       pr("%4d", vec[I_BAR]);
-       pr("%4d", vec[I_OIL]);
-       pr("%4d", vec[I_LCM]);
-       pr("%4d", vec[I_HCM]);
-       pr("%4d\n", vec[I_RAD]);
+       pr("%4d", land.lnd_item[I_SHELL]);
+       pr("%4d", land.lnd_item[I_GUN]);
+       pr("%4d", land.lnd_item[I_PETROL]);
+       pr("%4d", land.lnd_item[I_IRON]);
+       pr("%4d", land.lnd_item[I_DUST]);
+       pr("%4d", land.lnd_item[I_BAR]);
+       pr("%4d", land.lnd_item[I_OIL]);
+       pr("%4d", land.lnd_item[I_LCM]);
+       pr("%4d", land.lnd_item[I_HCM]);
+       pr("%4d\n", land.lnd_item[I_RAD]);
     }
     if (nunits == 0) {
        if (player->argp[1])
index 83e7b3078cafa4fdc8f42e4bb139821ae39205c5..a46e1bb85d7173c9c1c0d46efedd8276c06ec5b0 100644 (file)
@@ -54,7 +54,6 @@ cens(void)
     int n;
     struct nstr_sect nstr;
     s_char dirstr[20];
-    int vec[I_MAX + 1];
 
     if (!snxtsct(&nstr, player->argp[1]))
        return RET_SYN;
@@ -94,11 +93,10 @@ cens(void)
        pr("%c ", n == 0 ? '.' : '0' + (n / 100));
        pr("%c", sect.sct_own != sect.sct_oldown ? '*' : ' ');
 
-       getvec(VT_ITEM, vec, (s_char *)&sect, EF_SECTOR);
-       pr("%5d", vec[I_CIVIL]);
-       pr("%5d", vec[I_MILIT]);
-       pr("%5d", vec[I_UW]);
-       pr("%5d", vec[I_FOOD]);
+       pr("%5d", sect.sct_item[I_CIVIL]);
+       pr("%5d", sect.sct_item[I_MILIT]);
+       pr("%5d", sect.sct_item[I_UW]);
+       pr("%5d", sect.sct_item[I_FOOD]);
        pr("%4d%%", sect.sct_work);
        pr("%5d", sect.sct_avail);
        if (!player->god) {
index aabfd5c243f5ccd93897c63e5f7f0238e67816d0..2a5445214e5e2cf9fc3f484b6ecb673950b937d9 100644 (file)
@@ -52,7 +52,6 @@ comm(void)
     int nsect;
     int n;
     struct nstr_sect nstr;
-    int item[I_MAX + 1];
 
     if (!snxtsct(&nstr, player->argp[1]))
        return RET_SYN;
@@ -75,7 +74,6 @@ comm(void)
        }
        if (player->god)
            pr("%3d", sect.sct_own);
-       getvec(VT_ITEM, item, (s_char *)&sect, EF_SECTOR);
        prxy("%4d,%-4d", nstr.x, nstr.y, player->cnum);
        pr(" %c", dchr[sect.sct_type].d_mnem);
        pr(" %c", dirstr[sect.sct_del[I_SHELL] & 0x7]);
@@ -98,16 +96,16 @@ comm(void)
        prthresh("%c", sect.sct_dist[I_LCM]);
        prthresh("%c", sect.sct_dist[I_HCM]);
        prthresh("%c", sect.sct_dist[I_RAD]);
-       pr("%4d", item[I_SHELL]);
-       pr("%4d", item[I_GUN]);
-       pr("%5d", item[I_PETROL]);
-       pr("%5d", item[I_IRON]);
-       pr("%5d", item[I_DUST]);
-       pr("%4d", item[I_BAR]);
-       pr("%5d", item[I_OIL]);
-       pr("%5d", item[I_LCM]);
-       pr("%5d", item[I_HCM]);
-       pr("%4d", item[I_RAD]);
+       pr("%4d", sect.sct_item[I_SHELL]);
+       pr("%4d", sect.sct_item[I_GUN]);
+       pr("%5d", sect.sct_item[I_PETROL]);
+       pr("%5d", sect.sct_item[I_IRON]);
+       pr("%5d", sect.sct_item[I_DUST]);
+       pr("%4d", sect.sct_item[I_BAR]);
+       pr("%5d", sect.sct_item[I_OIL]);
+       pr("%5d", sect.sct_item[I_LCM]);
+       pr("%5d", sect.sct_item[I_HCM]);
+       pr("%4d", sect.sct_item[I_RAD]);
        pr("\n");
     }
     if (nsect == 0) {
index d84f3fa2552962a69c634f1fc8413ff75d6ad44a..3f981349e34a73d8141873221edbba5433fc0d59 100644 (file)
@@ -52,7 +52,6 @@ dump(void)
     int nsect;
     int n, i;
     struct nstr_sect nstr;
-    int item[I_MAX + 1];
     int field[128];
     struct natstr *np;
     time_t now;
@@ -510,7 +509,6 @@ dump(void)
 /* census */
        if (player->god)
            pr("%d ", sect.sct_own);
-       getvec(VT_ITEM, item, (s_char *)&sect, EF_SECTOR);
        pr("%d %d", xrel(np, nstr.x), yrel(np, nstr.y));
 
        set_coastal(&sect);
@@ -564,47 +562,47 @@ dump(void)
                pr("%d", sect.sct_terr);
                break;
            case 15:
-               pr("%d", item[I_CIVIL]);
+               pr("%d", sect.sct_item[I_CIVIL]);
                break;
            case 16:
-               pr("%d", item[I_MILIT]);
+               pr("%d", sect.sct_item[I_MILIT]);
                break;
            case 17:
-               pr("%d", item[I_UW]);
+               pr("%d", sect.sct_item[I_UW]);
                break;
            case 18:
-               pr("%d", item[I_FOOD]);
+               pr("%d", sect.sct_item[I_FOOD]);
                break;
 /* commodity */
            case 19:
-               pr("%d", item[I_SHELL]);
+               pr("%d", sect.sct_item[I_SHELL]);
                break;
            case 20:
-               pr("%d", item[I_GUN]);
+               pr("%d", sect.sct_item[I_GUN]);
                break;
            case 21:
-               pr("%d", item[I_PETROL]);
+               pr("%d", sect.sct_item[I_PETROL]);
                break;
            case 22:
-               pr("%d", item[I_IRON]);
+               pr("%d", sect.sct_item[I_IRON]);
                break;
            case 23:
-               pr("%d", item[I_DUST]);
+               pr("%d", sect.sct_item[I_DUST]);
                break;
            case 24:
-               pr("%d", item[I_BAR]);
+               pr("%d", sect.sct_item[I_BAR]);
                break;
            case 25:
-               pr("%d", item[I_OIL]);
+               pr("%d", sect.sct_item[I_OIL]);
                break;
            case 26:
-               pr("%d", item[I_LCM]);
+               pr("%d", sect.sct_item[I_LCM]);
                break;
            case 27:
-               pr("%d", item[I_HCM]);
+               pr("%d", sect.sct_item[I_HCM]);
                break;
            case 28:
-               pr("%d", item[I_RAD]);
+               pr("%d", sect.sct_item[I_RAD]);
                break;
 /* cutoff */
            case 29:
index c5064ac85fb4bf91258d0d493ef9b415727d6e83..80ac29f39899b0dfb6016033ef6b9b69151096c4 100644 (file)
@@ -363,7 +363,6 @@ pr_plane(struct plnstr *plane)
 static void
 pr_land(struct lndstr *land)
 {
-    int vec[I_MAX + 1];
     struct lchrstr *lcp;
 
     lcp = &lchr[(int)land->lnd_type];
@@ -386,29 +385,27 @@ pr_land(struct lndstr *land)
     pr("Retreat percentage <Z>: %d\n", (int)land->lnd_retreat);
     pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
        land->lnd_rpath, (int)land->lnd_rflags);
-    getvec(VT_ITEM, vec, (s_char *)land, EF_LAND);
     pr("civ mil  uw food shl gun  pet  irn  dst  oil  lcm  hcm rad\n");
     pr("  c   m   u    f   s   g    p    i    d    o    l    h   r\n");
-    pr("%3d", vec[I_CIVIL]);
-    pr("%4d", vec[I_MILIT]);
-    pr("%4d", vec[I_UW]);
-    pr("%5d", vec[I_FOOD]);
-    pr("%4d", vec[I_SHELL]);
-    pr("%4d", vec[I_GUN]);
-    pr("%5d", vec[I_PETROL]);
-    pr("%5d", vec[I_IRON]);
-    pr("%5d", vec[I_DUST]);
-    pr("%5d", vec[I_OIL]);
-    pr("%5d", vec[I_LCM]);
-    pr("%5d", vec[I_HCM]);
-    pr("%4d", vec[I_RAD]);
+    pr("%3d", land->lnd_item[I_CIVIL]);
+    pr("%4d", land->lnd_item[I_MILIT]);
+    pr("%4d", land->lnd_item[I_UW]);
+    pr("%5d", land->lnd_item[I_FOOD]);
+    pr("%4d", land->lnd_item[I_SHELL]);
+    pr("%4d", land->lnd_item[I_GUN]);
+    pr("%5d", land->lnd_item[I_PETROL]);
+    pr("%5d", land->lnd_item[I_IRON]);
+    pr("%5d", land->lnd_item[I_DUST]);
+    pr("%5d", land->lnd_item[I_OIL]);
+    pr("%5d", land->lnd_item[I_LCM]);
+    pr("%5d", land->lnd_item[I_HCM]);
+    pr("%4d", land->lnd_item[I_RAD]);
     pr("\n");
 }
 
 static void
 pr_ship(struct shpstr *ship)
 {
-    int vec[I_MAX + 1];
     struct natstr *natp;
 
     if ((natp = getnatp(ship->shp_own)) == 0)
@@ -432,24 +429,23 @@ pr_ship(struct shpstr *ship)
     pr("Fuel <B>: %d\n", (int)ship->shp_fuel);
     pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
        ship->shp_rpath, (int)ship->shp_rflags);
-    getvec(VT_ITEM, vec, (s_char *)ship, EF_SHIP);
     pr("Plague Stage <a>: %d\n", ship->shp_pstage);
     pr("Plague Time <b>: %d\n", ship->shp_ptime);
     pr("civ mil  uw food shl gun  pet  irn  dst  oil  lcm  hcm rad\n");
     pr("  c   m   u    f   s   g    p    i    d    o    l    h   r\n");
-    pr("%3d", vec[I_CIVIL]);
-    pr("%4d", vec[I_MILIT]);
-    pr("%4d", vec[I_UW]);
-    pr("%5d", vec[I_FOOD]);
-    pr("%4d", vec[I_SHELL]);
-    pr("%4d", vec[I_GUN]);
-    pr("%5d", vec[I_PETROL]);
-    pr("%5d", vec[I_IRON]);
-    pr("%5d", vec[I_DUST]);
-    pr("%5d", vec[I_OIL]);
-    pr("%5d", vec[I_LCM]);
-    pr("%5d", vec[I_HCM]);
-    pr("%4d", vec[I_RAD]);
+    pr("%3d", ship->shp_item[I_CIVIL]);
+    pr("%4d", ship->shp_item[I_MILIT]);
+    pr("%4d", ship->shp_item[I_UW]);
+    pr("%5d", ship->shp_item[I_FOOD]);
+    pr("%4d", ship->shp_item[I_SHELL]);
+    pr("%4d", ship->shp_item[I_GUN]);
+    pr("%5d", ship->shp_item[I_PETROL]);
+    pr("%5d", ship->shp_item[I_IRON]);
+    pr("%5d", ship->shp_item[I_DUST]);
+    pr("%5d", ship->shp_item[I_OIL]);
+    pr("%5d", ship->shp_item[I_LCM]);
+    pr("%5d", ship->shp_item[I_HCM]);
+    pr("%4d", ship->shp_item[I_RAD]);
     pr("\n");
 }
 
index c21279f7e21827d8bc3de2115dd4eb00b350a351..db4309ebb5d0e8ad77c5bdb16b672f0b7757c6a9 100644 (file)
@@ -49,7 +49,6 @@ land(void)
     int nunits;
     struct nstr_item ni;
     struct lndstr land;
-    int vec[I_MAX + 1];
 
     if (!snxtitem(&ni, EF_LAND, player->argp[1]))
        return RET_SYN;
@@ -88,8 +87,7 @@ land(void)
        pr("%4d", lnd_getmil(&land));
        pr("%4d", land.lnd_harden);
        pr("%4d", land.lnd_mobil);
-       getvec(VT_ITEM, vec, (s_char *)&land, EF_LAND);
-       pr("%4d", vec[I_FOOD]);
+       pr("%4d", land.lnd_item[I_FOOD]);
        if (opt_FUEL)
            pr("%3d", land.lnd_fuel);
        pr("%4d ", land.lnd_tech);
index 0a9b793fb8052fb8314a8322f2dd199052dc731f..fbd6cb32c47d262cde6c6f2e253d2064bdeec390 100644 (file)
@@ -51,7 +51,6 @@ ldump(void)
     int field[128];
     struct nstr_item ni;
     struct lndstr land;
-    int vec[I_MAX + 1];
     int n, i;
     struct natstr *np;
     time_t now;
@@ -308,7 +307,6 @@ ldump(void)
            pr("%3d ", land.lnd_own);
        pr("%d", ni.cur);
        n = 0;
-       getvec(VT_ITEM, vec, (s_char *)&land, EF_LAND);
        while (field[n]) {
            switch (field[n++]) {
            case 1:
@@ -339,7 +337,7 @@ ldump(void)
                pr(" %d", land.lnd_mobil);
                break;
            case 9:
-               pr(" %d", vec[I_FOOD]);
+               pr(" %d", land.lnd_item[I_FOOD]);
                break;
            case 10:
                if (opt_FUEL)
@@ -369,34 +367,34 @@ ldump(void)
                pr(" %d", land.lnd_ship);
                break;
            case 18:
-               pr(" %d", vec[I_SHELL]);
+               pr(" %d", land.lnd_item[I_SHELL]);
                break;
            case 19:
-               pr(" %d", vec[I_GUN]);
+               pr(" %d", land.lnd_item[I_GUN]);
                break;
            case 20:
-               pr(" %d", vec[I_PETROL]);
+               pr(" %d", land.lnd_item[I_PETROL]);
                break;
            case 21:
-               pr(" %d", vec[I_IRON]);
+               pr(" %d", land.lnd_item[I_IRON]);
                break;
            case 22:
-               pr(" %d", vec[I_DUST]);
+               pr(" %d", land.lnd_item[I_DUST]);
                break;
            case 23:
-               pr(" %d", vec[I_BAR]);
+               pr(" %d", land.lnd_item[I_BAR]);
                break;
            case 24:
-               pr(" %d", vec[I_OIL]);
+               pr(" %d", land.lnd_item[I_OIL]);
                break;
            case 25:
-               pr(" %d", vec[I_LCM]);
+               pr(" %d", land.lnd_item[I_LCM]);
                break;
            case 26:
-               pr(" %d", vec[I_HCM]);
+               pr(" %d", land.lnd_item[I_HCM]);
                break;
            case 27:
-               pr(" %d", vec[I_RAD]);
+               pr(" %d", land.lnd_item[I_RAD]);
                break;
            case 28:
                pr(" %1.2f", (float)land.lnd_att);
index bc619b9704f1968d2b0cb60d039f1c2103f3ba0a..5b5b0026a5e7a3ed2158fb4cf71316d54d5e8ca3 100644 (file)
@@ -52,7 +52,6 @@ nuke(void)
     struct nstr_item nstr;
     struct nukstr nuk;
     struct sctstr sect;
-    int item[I_MAX + 1];
 
     if (!snxtitem(&nstr, EF_NUKE, player->argp[1]))
        return RET_SYN;
@@ -68,7 +67,6 @@ nuke(void)
            pr("  sect        eff num nuke-type         lcm   hcm   oil   rad avail\n");
        }
        getsect(nuk.nuk_x, nuk.nuk_y, &sect);
-       getvec(VT_ITEM, item, (s_char *)&sect, EF_SECTOR);
        first_nuke = 1;
        show_comm = 0;
        if (sect.sct_type == SCT_NUKE && sect.sct_effic >= 60)
@@ -94,10 +92,10 @@ nuke(void)
                pr("%-16.16s ", nchr[i].n_name);
 
                if (show_comm) {
-                   pr("%5d ", item[I_LCM]);
-                   pr("%5d ", item[I_HCM]);
-                   pr("%5d ", item[I_OIL]);
-                   pr("%5d ", item[I_RAD]);
+                   pr("%5d ", sect.sct_item[I_LCM]);
+                   pr("%5d ", sect.sct_item[I_HCM]);
+                   pr("%5d ", sect.sct_item[I_OIL]);
+                   pr("%5d ", sect.sct_item[I_RAD]);
                    pr("%5d", sect.sct_avail);
                    show_comm = 0;
                }
index 6b78a7d5dde319268a1257921247a4fe0490b1e2..397a0f2865981e0cb6a1d2723504997d5b73b895 100644 (file)
@@ -51,16 +51,13 @@ count_pop(register int n)
     register int i;
     register int pop = 0;
     struct sctstr *sp;
-    int vec[I_MAX + 1];
 
     for (i = 0; NULL != (sp = getsectid(i)); i++) {
        if (sp->sct_own != n)
            continue;
        if (sp->sct_oldown != n)
            continue;
-       if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0)
-           continue;
-       pop += vec[I_CIVIL];
+       pop += sp->sct_item[I_CIVIL];
     }
     return pop;
 }
@@ -99,8 +96,7 @@ prod(void)
     int c;
     s_char maxc[3][10];
     s_char use[3][10];
-    int items[I_MAX + 1];
-    int vec[I_MAX + 1], lcms, hcms;
+    int lcms, hcms;
     int civs = 0;
     int uws = 0;
     int bwork;
@@ -118,12 +114,11 @@ prod(void)
     while (nxtsct(&nstr, &sect)) {
        if (!player->owner)
            continue;
-       getvec(VT_ITEM, items, (s_char *)&sect, EF_SECTOR);
 
-       civs = min(9999, (int)((obrate * (double)etu_per_update + 1.0)
-                              * (double)items[I_CIVIL]));
-       uws = min(9999, (int)((uwbrate * (double)etu_per_update + 1.0)
-                             * (double)items[I_UW]));
+       civs = min(9999, (int)((obrate * etu_per_update + 1.0)
+                              * sect.sct_item[I_CIVIL]));
+       uws = min(9999, (int)((uwbrate * etu_per_update + 1.0)
+                             * sect.sct_item[I_UW]));
        if (opt_RES_POP) {
            natp = getnatp(sect.sct_own);
            maxpop = max_pop((float)natp->nat_level[NAT_RLEV], &sect);
@@ -136,9 +131,9 @@ prod(void)
 
        /* This isn't quite right, since research might rise/fall */
        /* during the update, but it's the best we can really do  */
-       wforce = (int)(((double)civs * (double)sect.sct_work)
-                      / 100.0 + (double)uws +
-                      (double)items[I_MILIT] * 2.0 / 5.0);
+       wforce = (int)(((double)civs * sect.sct_work) / 100.0
+                      + uws
+                      + sect.sct_item[I_MILIT] * 2.0 / 5.0);
        work = (double)etu_per_update *(double)wforce / 100.0;
        if (opt_ROLLOVER_AVAIL) {
            if (sect.sct_type == sect.sct_newtype) {
@@ -179,9 +174,9 @@ prod(void)
                        civs = min(9999, civs);
                        uws = min(9999, uws);
                    }
-                   wforce =
-                       (int)((civs * sect.sct_work) / 100.0 + uws +
-                             items[I_MILIT] * 2 / 5.0);
+                   wforce = (int)(((double)civs * sect.sct_work) / 100.0
+                                  + uws
+                                  + sect.sct_item[I_MILIT] * 2 / 5.0);
                    work = etu_per_update * wforce / 100.0;
                    bwork = min((int)(work / 2), bwork);
                }
@@ -190,15 +185,14 @@ prod(void)
            if (twork > bwork) {
                twork = bwork;
            }
-           getvec(VT_ITEM, vec, (s_char *)&sect, EF_SECTOR);
            if (dchr[type].d_lcms > 0) {
-               lcms = vec[I_LCM];
+               lcms = sect.sct_item[I_LCM];
                lcms /= dchr[type].d_lcms;
                if (twork > lcms)
                    twork = lcms;
            }
            if (dchr[type].d_hcms > 0) {
-               hcms = vec[I_HCM];
+               hcms = sect.sct_item[I_HCM];
                hcms /= dchr[type].d_hcms;
                if (twork > hcms)
                    twork = hcms;
@@ -378,8 +372,8 @@ prod(void)
            int enlisted;
            int civs;
 
-           civs = min(999, (int)((obrate * (double)etu_per_update + 1.0)
-                                 * (double)items[I_CIVIL]));
+           civs = min(999, (int)((obrate * etu_per_update + 1.0)
+                                 * sect.sct_item[I_CIVIL]));
            natp = getnatp(sect.sct_own);
            maxpop = max_pop((float)natp->nat_level[NAT_RLEV], &sect);
            civs = min(civs, maxpop);
@@ -387,9 +381,11 @@ prod(void)
               rise/fall during the update, but it's the best
               we can really do  */
            enlisted = 0;
-           maxmil = (civs / 2) - items[I_MILIT];
+           maxmil = (civs / 2) - sect.sct_item[I_MILIT];
            if (maxmil > 0) {
-               enlisted = (etu_per_update * (10 + items[I_MILIT]) * 0.05);
+               enlisted = (etu_per_update
+                           * (10 + sect.sct_item[I_MILIT])
+                           * 0.05);
                if (enlisted > maxmil)
                    enlisted = maxmil;
            }
index 1a9f189594d53ae614fc09e93b5c10e4dd04e0ed..da11654f5d794296c14cb21e07aa2f7c22983daf 100644 (file)
@@ -44,7 +44,6 @@ sabo(void)
     struct lndstr land;
     struct sctstr sect;
     double odds;
-    int vec[I_MAX + 1];
     int dam;
 
     if (!snxtitem(&ni, EF_LAND, player->argp[1]))
@@ -85,12 +84,13 @@ sabo(void)
            continue;
        }
 
-       getvec(VT_ITEM, vec, (s_char *)&sect, EF_SECTOR);
        dam = landgun(3 * land.lnd_effic, 7);
-       if (vec[I_SHELL] > 20)
-           dam += seagun(land.lnd_effic, random() % (vec[I_SHELL] / 10));
-       if (vec[I_PETROL] > 100)
-           dam += seagun(land.lnd_effic, random() % (vec[I_PETROL] / 50));
+       if (sect.sct_item[I_SHELL] > 20)
+           dam += seagun(land.lnd_effic,
+                         random() % (sect.sct_item[I_SHELL] / 10));
+       if (sect.sct_item[I_PETROL] > 100)
+           dam += seagun(land.lnd_effic,
+                         random() % (sect.sct_item[I_PETROL] / 50));
 
        pr("Explosion in %s causes %d damage.\n",
           xyas(land.lnd_x, land.lnd_y, land.lnd_own), dam);
index 3de18b0ff7dfacc8831b4e923e2810ef1958c0e7..ed17fa49ae63ec3b6d52e5c55356ec9e13aafd18 100644 (file)
@@ -50,7 +50,6 @@ sdump(void)
     int nships;
     struct nstr_item ni;
     struct shpstr ship;
-    int vec[I_MAX + 1];
     int field[128];
     struct natstr *np;
     int n, i;
@@ -280,7 +279,6 @@ sdump(void)
            pr("%3d ", ship.shp_own);
        pr("%d", ni.cur);
        n = 0;
-       getvec(VT_ITEM, vec, (s_char *)&ship, EF_SHIP);
        while (field[n]) {
            switch (field[n++]) {
            case 1:
@@ -302,16 +300,16 @@ sdump(void)
                pr(" %d", ship.shp_effic);
                break;
            case 6:
-               pr(" %d", vec[I_CIVIL]);
+               pr(" %d", ship.shp_item[I_CIVIL]);
                break;
            case 7:
-               pr(" %d", vec[I_MILIT]);
+               pr(" %d", ship.shp_item[I_MILIT]);
                break;
            case 8:
-               pr(" %d", vec[I_UW]);
+               pr(" %d", ship.shp_item[I_UW]);
                break;
            case 9:
-               pr(" %d", vec[I_FOOD]);
+               pr(" %d", ship.shp_item[I_FOOD]);
                break;
            case 10:
                pr(" %d", ship.shp_nplane);
@@ -338,34 +336,34 @@ sdump(void)
                pr(" %d", ship.shp_tech);
                break;
            case 17:
-               pr(" %d", vec[I_SHELL]);
+               pr(" %d", ship.shp_item[I_SHELL]);
                break;
            case 18:
-               pr(" %d", vec[I_GUN]);
+               pr(" %d", ship.shp_item[I_GUN]);
                break;
            case 19:
-               pr(" %d", vec[I_PETROL]);
+               pr(" %d", ship.shp_item[I_PETROL]);
                break;
            case 20:
-               pr(" %d", vec[I_IRON]);
+               pr(" %d", ship.shp_item[I_IRON]);
                break;
            case 21:
-               pr(" %d", vec[I_DUST]);
+               pr(" %d", ship.shp_item[I_DUST]);
                break;
            case 22:
-               pr(" %d", vec[I_BAR]);
+               pr(" %d", ship.shp_item[I_BAR]);
                break;
            case 23:
-               pr(" %d", vec[I_OIL]);
+               pr(" %d", ship.shp_item[I_OIL]);
                break;
            case 24:
-               pr(" %d", vec[I_LCM]);
+               pr(" %d", ship.shp_item[I_LCM]);
                break;
            case 25:
-               pr(" %d", vec[I_HCM]);
+               pr(" %d", ship.shp_item[I_HCM]);
                break;
            case 26:
-               pr(" %d", vec[I_RAD]);
+               pr(" %d", ship.shp_item[I_RAD]);
                break;
            case 27:
                pr(" %d", ship.shp_armor);
index 6c8a6fefcbdab636c0e99f7d822df4fd660ce281..f83f34f913bb6ab071e6eee8082ce716497b6623 100644 (file)
@@ -50,7 +50,6 @@ shi(void)
     int nships;
     struct nstr_item ni;
     struct shpstr ship;
-    int vec[I_MAX + 1];
 
     if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
        return RET_SYN;
@@ -85,11 +84,10 @@ shi(void)
        pr("%1c", ship.shp_fleet);
        pr("%4d%%", ship.shp_effic);
 
-       getvec(VT_ITEM, vec, (s_char *)&ship, EF_SHIP);
-       pr("%4d", vec[I_CIVIL]);
-       pr("%4d", vec[I_MILIT]);
-       pr("%4d", vec[I_UW]);
-       pr("%4d", vec[I_FOOD]);
+       pr("%4d", ship.shp_item[I_CIVIL]);
+       pr("%4d", ship.shp_item[I_MILIT]);
+       pr("%4d", ship.shp_item[I_UW]);
+       pr("%4d", ship.shp_item[I_FOOD]);
 
        pr("%3d", ship.shp_nplane);
        pr("%3d", ship.shp_nchoppers);
index 221286f2070ba4685a1d1af54f2940093645eab9..7e5512367bb971bb4dd56660ca0e10ec20a68fca 100644 (file)
@@ -785,7 +785,6 @@ lnd_list(struct emp_qelem *land_list)
     struct emp_qelem *next;
     struct llist *llp;
     struct lndstr *lnd;
-    int vec[I_MAX + 1];
 
     pr("lnd#     land type       x,y    a  eff  sh gun xl  mu tech retr fuel\n");
 
@@ -798,9 +797,8 @@ lnd_list(struct emp_qelem *land_list)
        prxy("%4d,%-4d ", lnd->lnd_x, lnd->lnd_y, llp->land.lnd_own);
        pr("%1c", lnd->lnd_army);
        pr("%4d%%", lnd->lnd_effic);
-       getvec(VT_ITEM, vec, (s_char *)lnd, EF_LAND);
-       pr("%4d", vec[I_SHELL]);
-       pr("%4d", vec[I_GUN]);
+       pr("%4d", lnd->lnd_item[I_SHELL]);
+       pr("%4d", lnd->lnd_item[I_GUN]);
        count_land_planes(lnd);
        pr("%3d", lnd->lnd_nxlight);
        pr("%4d", lnd->lnd_mobil);
index aebc72ef3599b90059f68dd8da6f18b792363eb3..7843710f3bee84d4fae2bac92eeb974ce5641b11 100644 (file)
@@ -55,7 +55,6 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
 {
     struct sctstr sect, ending_sect;
     struct sctstr next, dsect;
-    int vec[I_MAX + 1];
     coord curx, cury, oldx, oldy;
     coord tmpx, tmpy;
     coord dx, dy;
@@ -191,9 +190,10 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
                *movstr = 0;
                continue;
            }
-           getvec(VT_ITEM, vec, (s_char *)&next, EF_SECTOR);
            sect_mcost = sector_mcost(&next, MOB_ROAD);
-           if ((!player->owner && (!exploring || vec[I_MILIT] || vec[I_CIVIL]))
+           if ((!player->owner && (!exploring
+                                   || next.sct_item[I_MILIT]
+                                   || next.sct_item[I_CIVIL]))
                || sect_mcost == -1.0) {
                /* already-owned, or prohibited terrain */
                pr("You can't go there...\n");
@@ -258,7 +258,6 @@ move_map(s_char *what, coord curx, coord cury, s_char *arg)
     s_char range[128];
     s_char view[7];
     int i;
-    int vec[I_MAX + 1];
     int changed = 0;
 
     np = getnatp(player->cnum);
@@ -295,13 +294,13 @@ move_map(s_char *what, coord curx, coord cury, s_char *arg)
        writemap(player->cnum);
     if (!getsect(curx, cury, &sect))
        return RET_FAIL;
-    getvec(VT_ITEM, vec, (s_char *)&sect, EF_SECTOR);
     pr("    %c %c      eff   mob   civ  mil   uw food  work  avail\n",
        view[0], view[1]);
     pr("   %c %c %c     %3d   %3d  %4d %4d %4d %4d   %3d   %3d\n",
        view[2], view[3], view[4],
-       sect.sct_effic, sect.sct_mobil, vec[I_CIVIL], vec[I_MILIT],
-       vec[I_UW], vec[I_FOOD], sect.sct_work, sect.sct_avail);
+       sect.sct_effic, sect.sct_mobil,
+       sect.sct_item[I_CIVIL], sect.sct_item[I_MILIT], sect.sct_item[I_UW],
+       sect.sct_item[I_FOOD], sect.sct_work, sect.sct_avail);
     pr("    %c %c\n", view[5], view[6]);
     return RET_OK;
 }
index 5ccf57d0992b79fb449d2b106e5536a141733c7f..8818f48487a59a7c56828609a204f84492a339d9 100644 (file)
@@ -146,7 +146,6 @@ retreat_ship1(struct shpstr *sp, s_char code, int orig)
     int shells;
     double mobcost;
     struct mchrstr *mcp;
-    int vec[I_MAX + 1];
     int time_to_stop;
 
     sp->shp_mission = 0;
@@ -178,8 +177,7 @@ retreat_ship1(struct shpstr *sp, s_char code, int orig)
        }
     }
     /* check crew - uws don't count */
-    getvec(VT_ITEM, vec, (s_char *)sp, EF_SHIP);
-    if (vec[I_MILIT] == 0 && vec[I_CIVIL] == 0) {
+    if (sp->shp_item[I_MILIT] == 0 && sp->shp_item[I_CIVIL] == 0) {
        wu(0, sp->shp_own,
           "%s %s,\nbut had no crew, and couldn't retreat!\n", prship(sp),
           conditions[findcondition(code)].desc[orig]);
index 2112b51f6837991b949c1ad0f9cb693843daae42..107e97eeb1e8d52ed1cdfc76df7d9cf08dec1ead 100644 (file)
@@ -283,13 +283,11 @@ sathead(void)
 void
 satdisp(struct sctstr *sp, int acc, int showstuff)
 {
-    int vec[I_MAX + 1], first;
+    int first;
     struct nstr_item ni;
     struct shpstr ship;
     struct lndstr land;
 
-    if (getvec(VT_ITEM, vec, (caddr_t)sp, EF_SECTOR) < 0)
-       return;
     prxy("%4d,%-4d   ", sp->sct_x, sp->sct_y, player->cnum);
     pr("%c  %3d  %3d %3d %3d %3d %4d %4d %4d %4d %4d %4d %5d\n",
        dchr[sp->sct_type].d_mnem,
@@ -297,10 +295,13 @@ satdisp(struct sctstr *sp, int acc, int showstuff)
        roundintby((int)sp->sct_road, acc / 2),
        roundintby((int)sp->sct_rail, acc / 2),
        roundintby((int)sp->sct_defense, acc / 2),
-       roundintby(vec[I_CIVIL], acc), roundintby(vec[I_MILIT], acc),
-       roundintby(vec[I_SHELL], acc), roundintby(vec[I_GUN], acc),
-       roundintby(vec[I_IRON], acc), roundintby(vec[I_PETROL], acc),
-       roundintby(vec[I_FOOD], acc));
+       roundintby(sp->sct_item[I_CIVIL], acc),
+       roundintby(sp->sct_item[I_MILIT], acc),
+       roundintby(sp->sct_item[I_SHELL], acc),
+       roundintby(sp->sct_item[I_GUN], acc),
+       roundintby(sp->sct_item[I_IRON], acc),
+       roundintby(sp->sct_item[I_PETROL], acc),
+       roundintby(sp->sct_item[I_FOOD], acc));
     map_set(player->cnum, sp->sct_x, sp->sct_y, dchr[sp->sct_type].d_mnem,
            0);
     if (!showstuff)
index 8c03bdc981336218389f17e7a4c7b0b66e405669..2b376a3c49f2a47219ea8df4f8bb30244e69d19e 100644 (file)
@@ -56,11 +56,9 @@ gt_bg_nmbr(int *bp, struct sctstr *sp, int comm)
 {
     int *wp;
     int cm;
-    int svec[I_MAX + 1];
 
     if ((cm = bud_key[comm]) == 0) {
-       getvec(VT_ITEM, svec, (s_char *)sp, EF_SECTOR);
-       return svec[comm];
+       return sp->sct_item[comm];
     } else {
        wp = get_wp(bp, sp, cm);
        return *wp;
@@ -82,16 +80,13 @@ pt_bg_nmbr(int *bp, struct sctstr *sp, int comm, int amount)
 void
 fill_update_array(int *bp, struct sctstr *sp)
 {
-    int vec[I_MAX + 1];
     int i, k;
     int *wp;
 
-    if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0)
-       return;
     for (i = 1; i <= I_MAX; i++)
        if ((k = bud_key[i]) != 0) {
            wp = get_wp(bp, sp, k);
-           *wp = vec[i];
+           *wp = sp->sct_item[i];
        }
     wp = get_wp(bp, sp, bud_key[I_MAX + 1]);
     *wp = sp->sct_avail;
index 4a547978ff0c7568e55d8fcd7f28b6d94b64d5c1..8fb773d31a19561191721f8cf97efc6e324e5b25 100644 (file)
@@ -66,7 +66,6 @@ prod_plane(int etus, int natnum, int *bp, int buildem)
     int left, build;
     int lcm_needed, hcm_needed;
     int mil_needed;
-    int svec[I_MAX + 1];
     int mvec[I_MAX + 1];
     int n, k = 0;
     struct shpstr *shp;
@@ -126,7 +125,6 @@ prod_plane(int etus, int natnum, int *bp, int buildem)
        np = getnatp(pp->pln_own);
        desc = &plchr[(int)pp->pln_type];
        sp = getsectp(pp->pln_x, pp->pln_y);
-       getvec(VT_ITEM, svec, (s_char *)sp, EF_SECTOR);
        mult = 1;
        if (np->nat_level[NAT_TLEV] < pp->pln_tech * 0.85)
            mult = 2;
@@ -178,10 +176,8 @@ prod_plane(int etus, int natnum, int *bp, int buildem)
                avail = gt_bg_nmbr(bp, sp, I_MAX + 1) * 100;
 
            if (pp->pln_ship >= 0) {
-               int vec[I_MAX + 1];
                shp = getshipp(pp->pln_ship);
-               getvec(VT_ITEM, vec, (s_char *)shp, EF_SHIP);
-               avail += (etus * vec[I_MILIT] / 2);
+               avail += (etus * shp->shp_item[I_MILIT] / 2);
            }
            w_p_eff = 20 + (desc->pl_lcm + 2 * desc->pl_hcm);
            delta = roundavg((double)avail / w_p_eff);
index c18621d653f47b9a1a4cc844c7ac9d2043354983..07b08a751dde6eb388a2a9c51c47ef6d2080c307 100644 (file)
@@ -170,10 +170,5 @@ upd_slmilcosts(natid n, int etu)
 int
 bank_income(struct sctstr *sp, int etu)
 {
-    int vec[I_MAX + 1];
-
-    if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0)
-       return 0;
-    else
-       return (int)(vec[I_BAR] * etu * bankint * sp->sct_effic / 100);
+    return (int)(sp->sct_item[I_BAR] * etu * bankint * sp->sct_effic / 100);
 }
index e6f27d826036c7a2468a7e7cd6e750497c50c895..13da78b9ac77d95a87dc995d6ba12dd16ad40d87 100644 (file)
@@ -148,7 +148,6 @@ guerrilla(struct sctstr *sp)
     int convert;
     natid actor;
     natid victim;
-    int vec[I_MAX + 1];
     int tmp;
     int min_mil;
     int val;
@@ -162,16 +161,13 @@ guerrilla(struct sctstr *sp)
     move = 0;
     if (!sp->sct_che)
        return;
-    if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0)
-       return;
-    civ = vec[I_CIVIL];
-
-    uw = vec[I_UW];
+    civ = sp->sct_item[I_CIVIL];
+    uw = sp->sct_item[I_UW];
     victim = sp->sct_own;
     actor = sp->sct_oldown;
     che = sp->sct_che;
+    mil = sp->sct_item[I_MILIT];
 
-    mil = vec[I_MILIT];
     snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
 
     while (NULL != (lp = (struct lndstr *)nxtitemp(&ni, 0))) {
index bd0613cca2c02d8df3e0447f5d32d25f98e60059..46811081279c9593f45d4d4b5ac3b084ae287d4d 100644 (file)
@@ -211,7 +211,6 @@ sail_nav_fleet(struct fltheadstr *fltp)
 {
     struct fltelemstr *fe;
     struct shpstr *sp, ship;
-    int vec[I_MAX + 1];
     struct sctstr *sectp;
     int error = 0;
     s_char *s, *p;
@@ -253,8 +252,7 @@ sail_nav_fleet(struct fltheadstr *fltp)
     }
     for (fe = fltp->head; fe; fe = fe->next) {
        sp = getshipp(fe->num);
-       getvec(VT_ITEM, vec, (s_char *)sp, EF_SHIP);
-       if (vec[I_MILIT] == 0 && vec[I_CIVIL] == 0) {
+       if (sp->shp_item[I_MILIT] == 0 && sp->shp_item[I_CIVIL] == 0) {
            wu(0, fltp->own,
               "   ship #%d (%s) is crewless and can't go on\n",
               fe->num, cname(fe->own));