extern int pln_hitchance(struct plnstr *, int, int);
extern int pln_damage(struct plnstr *, coord, coord, char, int *, int);
extern int pln_identchance(struct plnstr *, int, int);
+extern int pln_is_in_orbit(struct plnstr *);
extern void pln_set_tech(struct plnstr *, int);
/* pr.c */
extern void pr(char *, ...) ATTRIBUTE((format (printf, 1, 2)));
prplane(&plane));
continue;
}
- if ((plane.pln_flags & PLN_LAUNCHED) && (pcp->pl_flags & P_O)) {
+ if (pln_is_in_orbit(&plane)) {
pr("%s already in orbit!\n", prplane(&plane));
continue;
}
while (!goodtarget && nxtitem(&ni, &plane)) {
if (!plane.pln_own)
continue;
- if (!(plane.pln_flags & PLN_LAUNCHED))
+ if (!pln_is_in_orbit(&plane))
continue;
goodtarget = 1;
pr(" %d", plane.pln_land);
break;
case 18:
- if ((plchr[(int)plane.pln_type].pl_flags & (P_O | P_M)) ==
- P_O) {
- pr(" %c",
- (plane.pln_flags & PLN_LAUNCHED) ? 'Y' : 'N');
- } else
- pr(" N");
+ pr(pln_is_in_orbit(&plane) ? " Y" : " N");
break;
case 19:
- if ((plchr[(int)plane.pln_type].pl_flags & (P_O | P_M)) ==
- P_O) {
- pr(" %c",
- (plane.pln_flags & PLN_SYNCHRONOUS) ? 'Y' : 'N');
- } else
- pr(" N");
+ pr(pln_is_in_orbit(&plane)
+ && (plane.pln_flags & PLN_SYNCHRONOUS)
+ ? " Y" : " N");
break;
case 20:
if (plane.pln_nuketype != -1) {
pr("%5dL", plane.pln_land);
else
pr(" ");
- if (plane.pln_flags & PLN_SYNCHRONOUS)
- pr(" geosync");
- else if (plane.pln_flags & PLN_LAUNCHED)
- pr(" orbit");
+ if (pln_is_in_orbit(&plane))
+ pr((plane.pln_flags & PLN_SYNCHRONOUS) ? " geosync" : " orbit");
else if (plane.pln_nuketype >= 0)
pr(" %-5.5s %c",
nchr[(int)plane.pln_nuketype].n_name,
return RET_FAIL;
}
- if (!(plane.pln_flags & PLN_LAUNCHED)) {
+ if (!pln_is_in_orbit(&plane)) {
pr("%s isn't in orbit\n", prplane(&plane));
return RET_FAIL;
}
while (nxtitem(&ni, &skyp->s_sat)) {
if (!skyp->s_sat.pln_own)
continue;
- if (!(skyp->s_sat.pln_flags & PLN_LAUNCHED))
+ if (!pln_is_in_orbit(&skyp->s_sat))
continue;
getsect(skyp->s_sat.pln_x, skyp->s_sat.pln_y, §);
n = scthash(skyp->s_sat.pln_x, skyp->s_sat.pln_y, TSIZE);
* actually made, except for satellites in orbit. Must be owned
* and must be a 60% airfield (except for VTOL planes).
*/
- if (((trade.trd_type == EF_PLANE) && !(tg.plane.pln_flags & PLN_LAUNCHED))
+ if (((trade.trd_type == EF_PLANE) && !pln_is_in_orbit(&tg.plane))
|| (trade.trd_type == EF_NUKE)) {
while (1) {
p = getstring("Destination sector: ", buf);
tg.nuke.nuk_x, tg.nuke.nuk_y);
break;
case EF_PLANE:
- if ((tg.plane.pln_flags & PLN_LAUNCHED) == 0) {
+ if (!pln_is_in_orbit(&tg.plane)) {
tg.plane.pln_x = trade.trd_x;
tg.plane.pln_y = trade.trd_y;
}
pr("%s has been hardened and can't be transported\n",
prplane(&plane));
return RET_FAIL;
- } else if ((plane.pln_flags & PLN_LAUNCHED) &&
- (plchr[type].pl_flags & P_O)) {
+ } else if (pln_is_in_orbit(&plane)) {
pr("%s is in space and can't be transported\n",
prplane(&plane));
return RET_FAIL;
plane.pln_uid);
continue;
}
- if (plane.pln_flags & PLN_LAUNCHED) {
+ if (pln_is_in_orbit(&plane)) {
pr("Plane %s is in orbit!\n", prplane(&plane));
continue;
}
+ if (plane.pln_flags & PLN_LAUNCHED)
+ continue;
n++;
pp = &plchr[(int)plane.pln_type];
avail = (PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm) * UPGR_COST + 99) / 100;
return ldround(cost * dist / pln_range_max(pp) + 5, 1);
}
+int
+pln_is_in_orbit(struct plnstr *pp)
+{
+ return (plchr[pp->pln_type].pl_flags & (P_M | P_O)) == P_O
+ && (pp->pln_flags & PLN_LAUNCHED);
+}
+
/*
* Set PP's tech to TLEV along with everything else that depends on it.
*/
x = deltx(&ns.range, (int)plane.pln_x);
y = delty(&ns.range, (int)plane.pln_y);
- if ((plane.pln_flags & PLN_LAUNCHED) && plane.pln_own != owner) {
+ if (pln_is_in_orbit(&plane) && plane.pln_own != owner) {
vis[y][x] = 100;
rad[y][x] = '$';
}
continue;
}
- if (pp->pln_flags & PLN_LAUNCHED) {
+ if (pln_is_in_orbit(pp)) {
if (!player->simulation && buildem == 0
&& !(pp->pln_flags & PLN_SYNCHRONOUS))
move_sat(pp);