(flee, army, wing): Print how many new members were added.

Previously, it printed how many were selected, which can include old
members of the group.

(flee, army): The rather obscure feature to assign the fleet's /
army's retreat orders to members was broken.  It ignored ownership,
and thus could copy some other player's retreat orders.  Abusable.
Copying the first member's retreat orders is less than useful, in
particular for group ~.  The code now chooses the first one in the
same sector with RET_GROUP set.  RET_GROUP is never set for group ~.
This commit is contained in:
Markus Armbruster 2005-05-30 14:56:02 +00:00
parent 33ae33b556
commit 18ee9a2f35
4 changed files with 39 additions and 24 deletions

View file

@ -52,8 +52,9 @@ is Yes, then every ship in that fleet with fleet retreat orders retreats
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

View file

@ -49,7 +49,6 @@ army(void)
struct nstr_item nstr;
struct nstr_item ni;
struct lndstr land2;
int r;
s_char buf[1024];
cp = getstarg(player->argp[1], "army? ", buf);
@ -65,17 +64,24 @@ army(void)
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++;
}

View file

@ -49,7 +49,6 @@ flee(void)
struct nstr_item nstr;
struct nstr_item ni;
struct shpstr ship2;
int r;
s_char buf[1024];
cp = getstarg(player->argp[1], "fleet? ", buf);
@ -65,17 +64,24 @@ flee(void)
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++;
}

View file

@ -61,13 +61,15 @@ wing(void)
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;