along the specified path. If it is no, then the retreat orders apply to
that ship only, and only that ship retreats.
.s1
-When a ship is added to a fleet, it is given the retreat orders of that
-fleet, if any exist.
+When a ship is added to a fleet, it is given the retreat orders of the
+first ship in that fleet that has fleet retreat orders and is in the
+same sector, if any exist.
.s1
Retreat orders are wiped when a ship navigates.
.s1
struct nstr_item nstr;
struct nstr_item ni;
struct lndstr land2;
- int r;
s_char buf[1024];
cp = getstarg(player->argp[1], "army? ", buf);
if (!snxtitem(&nstr, EF_LAND, player->argp[2]))
return RET_SYN;
count = 0;
- while (nxtitem(&nstr, (s_char *)&land)) {
+ while (nxtitem(&nstr, &land)) {
if (!player->owner)
continue;
- land.lnd_army = c;
- snxtitem(&ni, EF_LAND, cp);
- while ((r = nxtitem(&ni, (s_char *)&land2)) &&
- (land2.lnd_army != c)) ;
- if (r) {
- memcpy(land.lnd_rpath, land2.lnd_rpath, sizeof(land.lnd_rpath));
- land.lnd_rflags = land2.lnd_rflags;
+ if (land.lnd_army == c)
+ continue;
+ land.lnd_rflags &= ~RET_GROUP;
+ snxtitem_group(&ni, EF_LAND, c);
+ while (nxtitem(&ni, &land2)) {
+ if ((land2.lnd_rflags & RET_GROUP) == 0)
+ continue;
+ if (land2.lnd_x == land.lnd_x && land2.lnd_y == land.lnd_y) {
+ memcpy(land.lnd_rpath, land2.lnd_rpath,
+ sizeof(land.lnd_rpath));
+ land.lnd_rflags = land2.lnd_rflags;
+ break;
+ }
}
+ land.lnd_army = c;
putland(land.lnd_uid, &land);
count++;
}
struct nstr_item nstr;
struct nstr_item ni;
struct shpstr ship2;
- int r;
s_char buf[1024];
cp = getstarg(player->argp[1], "fleet? ", buf);
if (!snxtitem(&nstr, EF_SHIP, player->argp[2]))
return RET_SYN;
count = 0;
- while (nxtitem(&nstr, (s_char *)&ship)) {
+ while (nxtitem(&nstr, &ship)) {
if (!player->owner)
continue;
- ship.shp_fleet = c;
- snxtitem(&ni, EF_SHIP, cp);
- while ((r = nxtitem(&ni, (s_char *)&ship2))
- && (ship2.shp_fleet != c)) ;
- if (r) {
- memcpy(ship.shp_rpath, ship2.shp_rpath, sizeof(ship.shp_rpath));
- ship.shp_rflags = ship2.shp_rflags;
+ if (ship.shp_fleet == c)
+ continue;
+ ship.shp_rflags &= ~RET_GROUP;
+ snxtitem_group(&ni, EF_SHIP, c);
+ while (nxtitem(&ni, &ship2)) {
+ if ((ship2.shp_rflags & RET_GROUP) == 0)
+ continue;
+ if (ship2.shp_x == ship.shp_x && ship2.shp_y == ship.shp_y) {
+ memcpy(ship.shp_rpath, ship2.shp_rpath,
+ sizeof(ship.shp_rpath));
+ ship.shp_rflags = ship2.shp_rflags;
+ break;
+ }
}
+ ship.shp_fleet = c;
putship(ship.shp_uid, &ship);
count++;
}
c = ' ';
if (!snxtitem(&nstr, EF_PLANE, player->argp[2]))
return RET_SYN;
- for (count = 0; nxtitem(&nstr, (s_char *)&plane); count++) {
- if (plane.pln_own != player->cnum) {
- count--;
+ count = 0;
+ while (nxtitem(&nstr, (s_char *)&plane)) {
+ if (plane.pln_own != player->cnum)
+ continue;
+ if (plane.pln_wing == c)
continue;
- }
plane.pln_wing = c;
putplane(plane.pln_uid, &plane);
+ count++;
}
pr("%d plane%s added to wing `%c'\n", count, splur(count), c);
return RET_OK;