Clean up unified unit loop in retreat()
Factor common code out of the type conditional. Widens the "as flt?" column to match the "as army?" column.
This commit is contained in:
parent
6b311f39da
commit
700089dd42
1 changed files with 26 additions and 37 deletions
|
@ -65,7 +65,8 @@ retreat(short type)
|
||||||
union empobj_storage unit;
|
union empobj_storage unit;
|
||||||
int rflags;
|
int rflags;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
char *what;
|
char *name, *rpath, *what;
|
||||||
|
int *rflagsp;
|
||||||
char buf1[1024];
|
char buf1[1024];
|
||||||
char buf2[1024];
|
char buf2[1024];
|
||||||
|
|
||||||
|
@ -164,53 +165,41 @@ retreat(short type)
|
||||||
if (!player->owner || unit.gen.own == 0)
|
if (!player->owner || unit.gen.own == 0)
|
||||||
continue;
|
continue;
|
||||||
if (type == EF_SHIP) {
|
if (type == EF_SHIP) {
|
||||||
if (pq != NULL) {
|
|
||||||
strncpy(unit.ship.shp_rpath, pq, sizeof(unit.ship.shp_rpath) - 1);
|
|
||||||
unit.ship.shp_rflags = rflags;
|
|
||||||
putship(unit.ship.shp_uid, &unit.ship);
|
|
||||||
}
|
|
||||||
if (nunits++ == 0) {
|
if (nunits++ == 0) {
|
||||||
if (player->god)
|
if (player->god)
|
||||||
pr("own ");
|
pr("own ");
|
||||||
pr("shp# ship type x,y fl path as flt? flags\n");
|
pr("shp# ship type x,y fl path as flt? flags\n");
|
||||||
}
|
}
|
||||||
if (player->god)
|
name = mchr[unit.ship.shp_type].m_name;
|
||||||
pr("%3d ", unit.ship.shp_own);
|
rpath = unit.ship.shp_rpath;
|
||||||
pr("%4d ", ni.cur);
|
rflagsp = &unit.ship.shp_rflags;
|
||||||
pr("%-16.16s ", mchr[unit.ship.shp_type].m_name);
|
|
||||||
prxy("%4d,%-4d ", unit.ship.shp_x, unit.ship.shp_y, player->cnum);
|
|
||||||
pr("%1.1s", &unit.ship.shp_fleet);
|
|
||||||
pr(" %-11s", unit.ship.shp_rpath);
|
|
||||||
rflags = unit.ship.shp_rflags;
|
|
||||||
if (rflags & RET_GROUP)
|
|
||||||
pr("Yes ");
|
|
||||||
else
|
|
||||||
pr(" ");
|
|
||||||
} else {
|
} else {
|
||||||
if (pq != NULL) {
|
|
||||||
strncpy(unit.land.lnd_rpath, pq, sizeof(unit.land.lnd_rpath) - 1);
|
|
||||||
unit.land.lnd_rflags = rflags;
|
|
||||||
putland(unit.land.lnd_uid, &unit.land);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nunits++ == 0) {
|
if (nunits++ == 0) {
|
||||||
if (player->god)
|
if (player->god)
|
||||||
pr("own ");
|
pr("own ");
|
||||||
pr("lnd# unit type x,y ar path as army? flags\n");
|
pr("lnd# unit type x,y ar path as army? flags\n");
|
||||||
}
|
}
|
||||||
if (player->god)
|
name = lchr[unit.land.lnd_type].l_name;
|
||||||
pr("%3d ", unit.land.lnd_own);
|
rpath = unit.land.lnd_rpath;
|
||||||
pr("%4d ", ni.cur);
|
rflagsp = &unit.land.lnd_rflags;
|
||||||
pr("%-16.16s ", lchr[unit.land.lnd_type].l_name);
|
|
||||||
prxy("%4d,%-4d ", unit.land.lnd_x, unit.land.lnd_y, player->cnum);
|
|
||||||
pr("%1.1s", &unit.land.lnd_army);
|
|
||||||
pr(" %-11s", unit.land.lnd_rpath);
|
|
||||||
rflags = unit.land.lnd_rflags;
|
|
||||||
if (rflags & RET_GROUP)
|
|
||||||
pr("Yes ");
|
|
||||||
else
|
|
||||||
pr(" ");
|
|
||||||
}
|
}
|
||||||
|
if (pq) {
|
||||||
|
strncpy(rpath, pq, RET_LEN - 1);
|
||||||
|
*rflagsp = rflags;
|
||||||
|
put_empobj(type, unit.gen.uid, &unit);
|
||||||
|
}
|
||||||
|
if (player->god)
|
||||||
|
pr("%3d ", unit.gen.own);
|
||||||
|
pr("%4d ", ni.cur);
|
||||||
|
pr("%-16.16s ", name);
|
||||||
|
prxy("%4d,%-4d ", unit.gen.x, unit.gen.y, player->cnum);
|
||||||
|
pr("%1.1s", &unit.gen.group);
|
||||||
|
pr(" %-11s", rpath);
|
||||||
|
rflags = *rflagsp;
|
||||||
|
if (rflags & RET_GROUP)
|
||||||
|
pr("Yes ");
|
||||||
|
else
|
||||||
|
pr(" ");
|
||||||
if (rflags & RET_INJURED)
|
if (rflags & RET_INJURED)
|
||||||
pr("I");
|
pr("I");
|
||||||
if (rflags & RET_TORPED)
|
if (rflags & RET_TORPED)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue