getvec(). This is safe, because the old code made single copies and
always flushed them back into the unit structures before flushing
those, in use_ammo(), or discarded both the copy and the unit
structure.
struct shpstr ship;
struct lndstr land;
struct nstr_item ni;
struct shpstr ship;
struct lndstr land;
struct nstr_item ni;
int dam, dam2, rel, rel2;
double tech;
struct sctstr firing;
struct nstr_sect ns;
struct flist *fp;
int dam, dam2, rel, rel2;
double tech;
struct sctstr firing;
struct nstr_sect ns;
struct flist *fp;
continue;
if (ship.shp_effic < 60)
continue;
continue;
if (ship.shp_effic < 60)
continue;
- if (getvec(VT_ITEM, vec, (caddr_t)&ship, EF_SHIP) < 0)
- continue;
+ gun = ship.shp_item[I_GUN];
+ shell = ship.shp_item[I_SHELL];
+
+ if (ship.shp_item[I_MILIT] < 1)
continue;
if (mchr[(int)ship.shp_type].m_flags & M_SUB) {
continue;
if (mchr[(int)ship.shp_type].m_flags & M_SUB) {
- if (vec[I_SHELL] < 3)
- vec[I_SHELL] += supply_commod(ship.shp_own,
- ship.shp_x, ship.shp_y,
- I_SHELL, 3 - vec[I_SHELL]);
- if (vec[I_SHELL] < 3)
+ if (shell < 3)
+ shell += supply_commod(ship.shp_own, ship.shp_x, ship.shp_y,
+ I_SHELL, 3 - shell);
+ if (shell < 3)
continue;
/*
if (ship.shp_mobil <= 0)
continue;
/*
if (ship.shp_mobil <= 0)
if (range < ni.curdist)
continue;
/* must have gun, shell, and milit to fire */
if (range < ni.curdist)
continue;
/* must have gun, shell, and milit to fire */
- if (vec[I_SHELL] < 1)
- vec[I_SHELL] += supply_commod(ship.shp_own,
- ship.shp_x, ship.shp_y,
- I_SHELL, 1);
+ if (shell < 1)
+ shell += supply_commod(ship.shp_own, ship.shp_x, ship.shp_y,
+ I_SHELL, 1);
/* only need 1 shell, so don't check that */
/* only need 1 shell, so don't check that */
- nshot = min(vec[I_GUN], vec[I_MILIT]);
+ nshot = min(gun, ship.shp_item[I_MILIT]);
nshot = min(nshot, ship.shp_glim);
if (nshot == 0)
continue;
nshot = min(nshot, ship.shp_glim);
if (nshot == 0)
continue;
if (!has_supply(&land))
continue;
if (!has_supply(&land))
continue;
- if (getvec(VT_ITEM, vec, (caddr_t)&land, EF_LAND) < 0)
- continue;
+ gun = land.lnd_item[I_GUN];
+ shell = land.lnd_item[I_SHELL];
- if (vec[I_MILIT] == 0 || vec[I_SHELL] == 0 || vec[I_GUN] == 0)
+ if (land.lnd_item[I_MILIT] == 0 || shell == 0 || gun == 0)
- dam2 = (int)landunitgun(land.lnd_effic, land.lnd_dam, vec[I_GUN],
- land.lnd_ammo, vec[I_SHELL]);
+ dam2 = (int)landunitgun(land.lnd_effic, land.lnd_dam, gun,
+ land.lnd_ammo, shell);
(*nfiring)++;
fp = (struct flist *)malloc(sizeof(struct flist));
(*nfiring)++;
fp = (struct flist *)malloc(sizeof(struct flist));
range = (double)roundrange(range);
if (range < ns.curdist)
continue;
range = (double)roundrange(range);
if (range < ns.curdist)
continue;
- if (getvec(VT_ITEM, vec, (caddr_t)&firing, EF_SECTOR) < 0)
- continue;
- if (vec[I_SHELL] < 1)
- vec[I_SHELL] += supply_commod(firing.sct_own,
- firing.sct_x, firing.sct_y,
- I_SHELL, 1);
- if (vec[I_GUN] == 0 || vec[I_MILIT] < 5 || vec[I_SHELL] == 0)
+
+ gun = firing.sct_item[I_GUN];
+ shell = firing.sct_item[I_SHELL];
+
+ if (shell < 1)
+ shell += supply_commod(firing.sct_own,
+ firing.sct_x, firing.sct_y,
+ I_SHELL, 1);
+ if (gun == 0 || firing.sct_item[I_MILIT] < 5 || shell == 0)
continue;
(*nfiring)++;
fp = (struct flist *)malloc(sizeof(struct flist));
continue;
(*nfiring)++;
fp = (struct flist *)malloc(sizeof(struct flist));
fp->type = targ_land;
add_to_fired_queue(&fp->queue, list);
nreport(firing.sct_own, N_FIRE_BACK, player->cnum, 1);
fp->type = targ_land;
add_to_fired_queue(&fp->queue, list);
nreport(firing.sct_own, N_FIRE_BACK, player->cnum, 1);
if (gun > 7)
gun = 7;
dam += landgun((int)firing.sct_effic, gun);
if (gun > 7)
gun = 7;
dam += landgun((int)firing.sct_effic, gun);