Don't store plane stats in struct plnstr
New pln_att(), pln_def(), pln_acc(), pln_range_max(), pln_load() replace the struct plnstr members with the same names. Make plane selectors att and def virtual.
This commit is contained in:
parent
d1a193ff07
commit
ffc5d0cfd7
15 changed files with 111 additions and 73 deletions
|
@ -90,7 +90,7 @@ arm(void)
|
|||
}
|
||||
}
|
||||
ncp = &nchr[nuke.nuk_type];
|
||||
if (pl.pln_load < ncp->n_weight) {
|
||||
if (pln_load(&pl) < ncp->n_weight) {
|
||||
pr("A %s cannot carry %s devices!\n",
|
||||
plc->pl_name, ncp->n_name);
|
||||
return RET_FAIL;
|
||||
|
|
|
@ -849,7 +849,7 @@ pinflak_planedamage(struct plnstr *pp, struct plchrstr *pcp, natid from,
|
|||
natid plane_owner;
|
||||
int dam;
|
||||
|
||||
dam = ac_flak_dam(flak, pp->pln_def, pcp->pl_flags);
|
||||
dam = ac_flak_dam(flak, pln_def(pp), pcp->pl_flags);
|
||||
disp = 0;
|
||||
plane_owner = pp->pln_own;
|
||||
eff = pp->pln_effic;
|
||||
|
|
|
@ -783,7 +783,6 @@ build_plane(struct sctstr *sp, struct plchrstr *pp, short *vec, int tlev)
|
|||
plane.pln_opy = 0;
|
||||
plane.pln_radius = 0;
|
||||
plane.pln_range = UCHAR_MAX; /* will be adjusted by pln_set_tech() */
|
||||
plane.pln_range_max = plane.pln_range;
|
||||
plane.pln_wing = 0;
|
||||
plane.pln_ship = -1;
|
||||
plane.pln_land = -1;
|
||||
|
|
|
@ -202,7 +202,7 @@ launch_as(struct plnstr *pp)
|
|||
pr("No satellites there!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
if (msl_hit(pp, plane.pln_def, EF_PLANE, N_SAT_KILL, N_SAT_KILL,
|
||||
if (msl_hit(pp, pln_def(&plane), EF_PLANE, N_SAT_KILL, N_SAT_KILL,
|
||||
prplane(&plane), sx, sy, plane.pln_own)) {
|
||||
dam = pln_damage(pp, sx, sy, 'p', &nukedam, 1);
|
||||
oldown = plane.pln_own;
|
||||
|
|
|
@ -228,22 +228,22 @@ pdump(void)
|
|||
pr(" %d", plane.pln_tech);
|
||||
break;
|
||||
case 8:
|
||||
pr(" %d", plane.pln_att);
|
||||
pr(" %d", pln_att(&plane));
|
||||
break;
|
||||
case 9:
|
||||
pr(" %d", plane.pln_def);
|
||||
pr(" %d", pln_def(&plane));
|
||||
break;
|
||||
case 10:
|
||||
pr(" %d", plane.pln_acc);
|
||||
pr(" %d", pln_acc(&plane));
|
||||
break;
|
||||
case 11:
|
||||
pr(" %d", plane.pln_range);
|
||||
break;
|
||||
case 12:
|
||||
pr(" %d", plane.pln_range_max);
|
||||
pr(" %d", pln_range_max(&plane));
|
||||
break;
|
||||
case 13:
|
||||
pr(" %d", plane.pln_load);
|
||||
pr(" %d", pln_load(&plane));
|
||||
break;
|
||||
case 14:
|
||||
pr(" %d", plchr[(int)plane.pln_type].pl_fuel);
|
||||
|
|
|
@ -66,7 +66,7 @@ plan(void)
|
|||
prxy("%4d,%-4d", plane.pln_x, plane.pln_y, player->cnum);
|
||||
pr(" %1.1s %c%3d%% %3d %3d %4d %3d %3d",
|
||||
&plane.pln_wing, plane.pln_off ? '!' : ' ', plane.pln_effic,
|
||||
plane.pln_mobil, plane.pln_def, plane.pln_tech,
|
||||
plane.pln_mobil, pln_def(&plane), plane.pln_tech,
|
||||
plane.pln_range, plane.pln_harden);
|
||||
if (plane.pln_ship >= 0)
|
||||
pr("%5dS", plane.pln_ship);
|
||||
|
|
|
@ -58,10 +58,10 @@ pstat(void)
|
|||
pr(" %3d%% %4d %3d %3d %3d %3d %4d %4d",
|
||||
plane.pln_effic,
|
||||
plane.pln_tech,
|
||||
plane.pln_att,
|
||||
plane.pln_def,
|
||||
plane.pln_acc,
|
||||
plane.pln_range_max, plane.pln_load,
|
||||
pln_att(&plane),
|
||||
pln_def(&plane),
|
||||
pln_acc(&plane),
|
||||
pln_range_max(&plane), pln_load(&plane),
|
||||
plchr[(int)plane.pln_type].pl_fuel);
|
||||
pr("\n");
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ range(void)
|
|||
{
|
||||
struct nstr_item np;
|
||||
struct plnstr plane;
|
||||
int i;
|
||||
int i, rmax;
|
||||
char *p;
|
||||
char buf[1024];
|
||||
|
||||
|
@ -56,8 +56,8 @@ range(void)
|
|||
return RET_SYN;
|
||||
if (!p || (i = atoi(p)) < 0)
|
||||
continue;
|
||||
plane.pln_range = (plane.pln_range_max < i) ?
|
||||
plane.pln_range_max : i;
|
||||
rmax = pln_range_max(&plane);
|
||||
plane.pln_range = MIN(rmax, i);
|
||||
pr("Plane %d range changed to %d\n",
|
||||
plane.pln_uid, plane.pln_range);
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ plane_sona(struct emp_qelem *plane_list, int x, int y,
|
|||
pcp = ip->pcp;
|
||||
if (!(pcp->pl_flags & P_A)) /* if it isn't an ASW plane */
|
||||
continue;
|
||||
range = (int)techfact(pp->pln_tech, (100.0 - pp->pln_acc) / 10.0);
|
||||
range = (int)techfact(pp->pln_tech, (100.0 - pln_acc(pp)) / 10.0);
|
||||
for (i = 0; getship(i, &s); i++) {
|
||||
targ = &s;
|
||||
if (targ->shp_own == pp->pln_own || targ->shp_own == 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue