Distinguish between planes "in orbit" and "launched"
Use new pln_is_in_orbit() when we want to test for orbit specifically, and test PLN_LAUNCHED when we want to test whether the plane not sitting in the sector (because it is flying). This distinction is pointless at this time, because the only way PLN_LAUNCHED gets set is when a satellite goes into orbit. It will become useful in a later commit, which will use PLN_LAUNCHED to mark flying planes.
This commit is contained in:
parent
5e930f5fdf
commit
8006543878
12 changed files with 26 additions and 27 deletions
|
@ -569,6 +569,7 @@ extern int put_plane_on_land(struct plnstr *, struct lndstr *);
|
|||
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)));
|
||||
|
|
|
@ -82,7 +82,7 @@ laun(void)
|
|||
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;
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ launch_as(struct plnstr *pp)
|
|||
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;
|
||||
|
||||
|
|
|
@ -258,20 +258,12 @@ pdump(void)
|
|||
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) {
|
||||
|
|
|
@ -74,10 +74,8 @@ plan(void)
|
|||
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,
|
||||
|
|
|
@ -65,7 +65,7 @@ sate(void)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ skyw(void)
|
|||
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);
|
||||
|
|
|
@ -184,7 +184,7 @@ trad(void)
|
|||
* 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);
|
||||
|
@ -364,7 +364,7 @@ check_trade(void)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -175,8 +175,7 @@ tran_plane(void)
|
|||
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;
|
||||
|
|
|
@ -272,10 +272,12 @@ pupgr(void)
|
|||
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;
|
||||
|
|
|
@ -1236,6 +1236,13 @@ pln_mobcost(int dist, struct plnstr *pp, int flags)
|
|||
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.
|
||||
*/
|
||||
|
|
|
@ -145,7 +145,7 @@ radmap2(int owner,
|
|||
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] = '$';
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ prod_plane(int etus, int natnum, struct bp *bp, int buildem)
|
|||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue