Don't store land unit stats in struct lndstr, part 2

struct lndstr members lnd_spy, lnd_rad, lnd_ammo, lnd_fuelc,
lnd_fuelu, lnd_maxlight, lnd_maxlight are mere copies of struct
lchrstr members l_spy, l_rad, l_ammo, l_fuelc, l_fuelu, l_nxlight,
l_nland.  Remove them.

Make land unit selectors spy, rmax, ammo, fuelc, fuelu, maxlight
virtual.
This commit is contained in:
Markus Armbruster 2008-03-04 21:27:30 +01:00
parent cdf1bcfa22
commit c75d19b082
12 changed files with 57 additions and 57 deletions

View file

@ -293,7 +293,7 @@ fuel(void)
if ((oil_amt + pet_amt) == 0)
sector = 0;
if ((item.land.lnd_fuelu == 0)
if (lcp->l_fuelu == 0
&& (item.land.lnd_own == player->cnum)) {
pr("%s does not use fuel!\n", prland(&item.land));
continue;
@ -303,7 +303,7 @@ fuel(void)
land_fuel = item.land.lnd_fuel;
oil_amt = sect.sct_item[I_OIL];
pet_amt = sect.sct_item[I_PETROL];
max_amt = item.land.lnd_fuelc - land_fuel;
max_amt = lcp->l_fuelc - land_fuel;
if (max_amt == 0) {
pr("%s already has a full fuel load.\n",
@ -385,7 +385,7 @@ fuel(void)
land_fuel = item.land.lnd_fuel;
oil_amt = item2.land.lnd_item[I_OIL];
pet_amt = item2.land.lnd_item[I_PETROL];
max_amt = item.land.lnd_fuelc - land_fuel;
max_amt = lcp->l_fuelc - land_fuel;
if (max_amt == 0) {
pr("%s already has a full fuel load.\n",

View file

@ -409,10 +409,10 @@ ldump(void)
pr(" %d", lnd_vis(&land));
break;
case 33:
pr(" %d", land.lnd_spy);
pr(" %d", lchr[land.lnd_type].l_spy);
break;
case 34:
pr(" %d", land.lnd_rad);
pr(" %d", lchr[land.lnd_type].l_rad);
break;
case 35:
pr(" %d", lnd_frg(&land));
@ -424,7 +424,7 @@ ldump(void)
pr(" %d", lnd_dam(&land));
break;
case 38:
pr(" %d", land.lnd_ammo);
pr(" %d", lchr[land.lnd_type].l_ammo);
break;
case 39:
pr(" %d", lnd_aaf(&land));

View file

@ -745,14 +745,15 @@ load_plane_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
char *p;
char prompt[512];
char buf[1024];
struct lchrstr *lcp = lchr + lp->lnd_type;
if (!lp->lnd_maxlight) {
if (!lcp->l_nxlight) {
if (noisy)
pr("%s cannot carry extra-light planes.\n", prland(lp));
return 0;
}
count_land_planes(lp);
if (load_unload == LOAD && lp->lnd_nxlight >= lp->lnd_maxlight) {
if (load_unload == LOAD && lp->lnd_nxlight >= lcp->l_nxlight) {
if (noisy)
pr("%s doesn't have room for any more extra-light planes\n",
prland(lp));
@ -931,7 +932,8 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
lnd_count_units(lp);
if (load_unload == LOAD && lp->lnd_nland >= lp->lnd_maxland) {
if (load_unload == LOAD
&& lp->lnd_nland >= lchr[lp->lnd_type].l_nland) {
if (noisy) {
if (lp->lnd_nland)
pr("%s doesn't have room for any more land units!\n",
@ -1003,7 +1005,7 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
/* Fit unit on ship */
if (load_unload == LOAD) {
lnd_count_units(lp);
if (lp->lnd_nland >= lp->lnd_maxland) {
if (lp->lnd_nland >= lchr[lp->lnd_type].l_nland) {
if (noisy) {
if (lp->lnd_nland)
pr("%s doesn't have room for any more land units!\n",

View file

@ -207,7 +207,7 @@ look_land(struct lndstr *lookland)
int i;
int dist;
drange = techfact(lookland->lnd_tech, lookland->lnd_spy);
drange = techfact(lookland->lnd_tech, lchr[lookland->lnd_type].l_spy);
drange *= lookland->lnd_effic / 100.0;
range = ldround(drange, 1);

View file

@ -42,6 +42,7 @@ lsta(void)
int nunits;
struct nstr_item ni;
struct lndstr land;
struct lchrstr *lcp;
if (!snxtitem(&ni, EF_LAND, player->argp[1]))
return RET_SYN;
@ -50,6 +51,7 @@ lsta(void)
while (nxtitem(&ni, &land)) {
if (!player->owner || land.lnd_own == 0)
continue;
lcp = lchr + land.lnd_type;
count_land_planes(&land);
if (nunits++ == 0) {
@ -57,16 +59,16 @@ lsta(void)
pr(" %16.16s p i p a n c i m a\n", "");
pr("lnd# %16.16s x,y eff tech att def vul d s y d g c r m f\n", "unit-type");
}
pr("%4d %-16.16s ", land.lnd_uid, lchr[(int)land.lnd_type].l_name);
pr("%4d %-16.16s ", land.lnd_uid, lcp->l_name);
prxy("%4d,%-4d", land.lnd_x, land.lnd_y, player->cnum);
pr(" %3d%% %3d %1.1f %1.1f %3d ",
land.lnd_effic, land.lnd_tech, lnd_att(&land), lnd_def(&land),
lnd_vul(&land));
pr("%2d %2d %2d %2d ",
lnd_spd(&land), lnd_vis(&land), land.lnd_spy, land.lnd_rad);
lnd_spd(&land), lnd_vis(&land), lcp->l_spy, lcp->l_rad);
pr("%2d %2d %2d %2d %2d ",
lnd_frg(&land),
lnd_acc(&land), lnd_dam(&land), land.lnd_ammo, lnd_aaf(&land));
lnd_frg(&land), lnd_acc(&land), lnd_dam(&land),
lcp->l_ammo, lnd_aaf(&land));
pr("\n");
}
if (nunits == 0) {

View file

@ -112,7 +112,8 @@ radar(short type)
pr("Units on ships can't use radar!\n");
continue;
}
tech = techfact(item.land.lnd_tech, item.land.lnd_spy);
tech = techfact(item.land.lnd_tech,
lchr[item.land.lnd_type].l_spy);
}
pr("%s at ", obj_nameof(&item.gen));

View file

@ -72,7 +72,6 @@ lrange(void)
{
struct nstr_item np;
struct lndstr land;
struct lchrstr *lcp;
int i;
char *p;
char prompt[128];
@ -83,7 +82,6 @@ lrange(void)
while (nxtitem(&np, &land)) {
if (!player->owner || land.lnd_own == 0)
continue;
lcp = &lchr[(int)land.lnd_type];
sprintf(prompt, "New range for %s? ", prland(&land));
if ((p = getstarg(player->argp[2], prompt, buf)) == 0)
return RET_SYN;
@ -91,7 +89,7 @@ lrange(void)
return RET_SYN;
if ((i = atoi(p)) < 0)
continue;
land.lnd_rad_max = (i < land.lnd_rad) ? i : land.lnd_rad;
land.lnd_rad_max = MIN(i, lchr[land.lnd_type].l_rad);
pr("%s reaction radius changed to %d\n",
prland(&land), land.lnd_rad_max);
putland(land.lnd_uid, &land);