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_hitchance(struct plnstr *, int, int);
|
||||||
extern int pln_damage(struct plnstr *, coord, coord, char, int *, int);
|
extern int pln_damage(struct plnstr *, coord, coord, char, int *, int);
|
||||||
extern int pln_identchance(struct plnstr *, 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);
|
extern void pln_set_tech(struct plnstr *, int);
|
||||||
/* pr.c */
|
/* pr.c */
|
||||||
extern void pr(char *, ...) ATTRIBUTE((format (printf, 1, 2)));
|
extern void pr(char *, ...) ATTRIBUTE((format (printf, 1, 2)));
|
||||||
|
|
|
@ -82,7 +82,7 @@ laun(void)
|
||||||
prplane(&plane));
|
prplane(&plane));
|
||||||
continue;
|
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));
|
pr("%s already in orbit!\n", prplane(&plane));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ launch_as(struct plnstr *pp)
|
||||||
while (!goodtarget && nxtitem(&ni, &plane)) {
|
while (!goodtarget && nxtitem(&ni, &plane)) {
|
||||||
if (!plane.pln_own)
|
if (!plane.pln_own)
|
||||||
continue;
|
continue;
|
||||||
if (!(plane.pln_flags & PLN_LAUNCHED))
|
if (!pln_is_in_orbit(&plane))
|
||||||
continue;
|
continue;
|
||||||
goodtarget = 1;
|
goodtarget = 1;
|
||||||
|
|
||||||
|
|
|
@ -258,20 +258,12 @@ pdump(void)
|
||||||
pr(" %d", plane.pln_land);
|
pr(" %d", plane.pln_land);
|
||||||
break;
|
break;
|
||||||
case 18:
|
case 18:
|
||||||
if ((plchr[(int)plane.pln_type].pl_flags & (P_O | P_M)) ==
|
pr(pln_is_in_orbit(&plane) ? " Y" : " N");
|
||||||
P_O) {
|
|
||||||
pr(" %c",
|
|
||||||
(plane.pln_flags & PLN_LAUNCHED) ? 'Y' : 'N');
|
|
||||||
} else
|
|
||||||
pr(" N");
|
|
||||||
break;
|
break;
|
||||||
case 19:
|
case 19:
|
||||||
if ((plchr[(int)plane.pln_type].pl_flags & (P_O | P_M)) ==
|
pr(pln_is_in_orbit(&plane)
|
||||||
P_O) {
|
&& (plane.pln_flags & PLN_SYNCHRONOUS)
|
||||||
pr(" %c",
|
? " Y" : " N");
|
||||||
(plane.pln_flags & PLN_SYNCHRONOUS) ? 'Y' : 'N');
|
|
||||||
} else
|
|
||||||
pr(" N");
|
|
||||||
break;
|
break;
|
||||||
case 20:
|
case 20:
|
||||||
if (plane.pln_nuketype != -1) {
|
if (plane.pln_nuketype != -1) {
|
||||||
|
|
|
@ -74,10 +74,8 @@ plan(void)
|
||||||
pr("%5dL", plane.pln_land);
|
pr("%5dL", plane.pln_land);
|
||||||
else
|
else
|
||||||
pr(" ");
|
pr(" ");
|
||||||
if (plane.pln_flags & PLN_SYNCHRONOUS)
|
if (pln_is_in_orbit(&plane))
|
||||||
pr(" geosync");
|
pr((plane.pln_flags & PLN_SYNCHRONOUS) ? " geosync" : " orbit");
|
||||||
else if (plane.pln_flags & PLN_LAUNCHED)
|
|
||||||
pr(" orbit");
|
|
||||||
else if (plane.pln_nuketype >= 0)
|
else if (plane.pln_nuketype >= 0)
|
||||||
pr(" %-5.5s %c",
|
pr(" %-5.5s %c",
|
||||||
nchr[(int)plane.pln_nuketype].n_name,
|
nchr[(int)plane.pln_nuketype].n_name,
|
||||||
|
|
|
@ -65,7 +65,7 @@ sate(void)
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(plane.pln_flags & PLN_LAUNCHED)) {
|
if (!pln_is_in_orbit(&plane)) {
|
||||||
pr("%s isn't in orbit\n", prplane(&plane));
|
pr("%s isn't in orbit\n", prplane(&plane));
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ skyw(void)
|
||||||
while (nxtitem(&ni, &skyp->s_sat)) {
|
while (nxtitem(&ni, &skyp->s_sat)) {
|
||||||
if (!skyp->s_sat.pln_own)
|
if (!skyp->s_sat.pln_own)
|
||||||
continue;
|
continue;
|
||||||
if (!(skyp->s_sat.pln_flags & PLN_LAUNCHED))
|
if (!pln_is_in_orbit(&skyp->s_sat))
|
||||||
continue;
|
continue;
|
||||||
getsect(skyp->s_sat.pln_x, skyp->s_sat.pln_y, §);
|
getsect(skyp->s_sat.pln_x, skyp->s_sat.pln_y, §);
|
||||||
n = scthash(skyp->s_sat.pln_x, skyp->s_sat.pln_y, TSIZE);
|
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
|
* actually made, except for satellites in orbit. Must be owned
|
||||||
* and must be a 60% airfield (except for VTOL planes).
|
* 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)) {
|
|| (trade.trd_type == EF_NUKE)) {
|
||||||
while (1) {
|
while (1) {
|
||||||
p = getstring("Destination sector: ", buf);
|
p = getstring("Destination sector: ", buf);
|
||||||
|
@ -364,7 +364,7 @@ check_trade(void)
|
||||||
tg.nuke.nuk_x, tg.nuke.nuk_y);
|
tg.nuke.nuk_x, tg.nuke.nuk_y);
|
||||||
break;
|
break;
|
||||||
case EF_PLANE:
|
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_x = trade.trd_x;
|
||||||
tg.plane.pln_y = trade.trd_y;
|
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",
|
pr("%s has been hardened and can't be transported\n",
|
||||||
prplane(&plane));
|
prplane(&plane));
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
} else if ((plane.pln_flags & PLN_LAUNCHED) &&
|
} else if (pln_is_in_orbit(&plane)) {
|
||||||
(plchr[type].pl_flags & P_O)) {
|
|
||||||
pr("%s is in space and can't be transported\n",
|
pr("%s is in space and can't be transported\n",
|
||||||
prplane(&plane));
|
prplane(&plane));
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
|
|
|
@ -272,10 +272,12 @@ pupgr(void)
|
||||||
plane.pln_uid);
|
plane.pln_uid);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (plane.pln_flags & PLN_LAUNCHED) {
|
if (pln_is_in_orbit(&plane)) {
|
||||||
pr("Plane %s is in orbit!\n", prplane(&plane));
|
pr("Plane %s is in orbit!\n", prplane(&plane));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (plane.pln_flags & PLN_LAUNCHED)
|
||||||
|
continue;
|
||||||
n++;
|
n++;
|
||||||
pp = &plchr[(int)plane.pln_type];
|
pp = &plchr[(int)plane.pln_type];
|
||||||
avail = (PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm) * UPGR_COST + 99) / 100;
|
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);
|
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.
|
* 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);
|
x = deltx(&ns.range, (int)plane.pln_x);
|
||||||
y = delty(&ns.range, (int)plane.pln_y);
|
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;
|
vis[y][x] = 100;
|
||||||
rad[y][x] = '$';
|
rad[y][x] = '$';
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ prod_plane(int etus, int natnum, struct bp *bp, int buildem)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pp->pln_flags & PLN_LAUNCHED) {
|
if (pln_is_in_orbit(pp)) {
|
||||||
if (!player->simulation && buildem == 0
|
if (!player->simulation && buildem == 0
|
||||||
&& !(pp->pln_flags & PLN_SYNCHRONOUS))
|
&& !(pp->pln_flags & PLN_SYNCHRONOUS))
|
||||||
move_sat(pp);
|
move_sat(pp);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue