Use new snxtitem_cargo() to simplify a couple of loops
Change snxtitem_all() loops that skip everything but a carrier's cargo to use snxtitem_cargo() in scra(), scuttle_ship(), scuttle_land(), takeover_ship(), takeover_land(), trade_desc(), feed_ship().
This commit is contained in:
parent
3cf29456fe
commit
2a9b89693e
5 changed files with 138 additions and 198 deletions
|
@ -130,37 +130,31 @@ trade_desc(struct trdstr *tp, union empobj_storage *tgp)
|
|||
}
|
||||
pr("] #%d", tp->trd_unitid);
|
||||
if (opt_SHOWPLANE) {
|
||||
snxtitem_all(&ni, EF_PLANE);
|
||||
snxtitem_cargo(&ni, EF_PLANE, EF_SHIP, sp->shp_uid);
|
||||
while (nxtitem(&ni, &plane)) {
|
||||
if (plane.pln_ship == sp->shp_uid && plane.pln_own != 0) {
|
||||
pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
|
||||
plane.pln_tech,
|
||||
plane.pln_effic,
|
||||
plchr[(int)plane.pln_type].pl_name, plane.pln_uid);
|
||||
if (getnuke(nuk_on_plane(&plane), &nuke))
|
||||
pr("(%s)", nchr[nuke.nuk_type].n_name);
|
||||
}
|
||||
pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
|
||||
plane.pln_tech,
|
||||
plane.pln_effic,
|
||||
plchr[(int)plane.pln_type].pl_name, plane.pln_uid);
|
||||
if (getnuke(nuk_on_plane(&plane), &nuke))
|
||||
pr("(%s)", nchr[nuke.nuk_type].n_name);
|
||||
}
|
||||
snxtitem_all(&ni, EF_LAND);
|
||||
snxtitem_cargo(&ni, EF_LAND, EF_SHIP, sp->shp_uid);
|
||||
while (nxtitem(&ni, &land)) {
|
||||
if (land.lnd_ship == sp->shp_uid && land.lnd_own != 0) {
|
||||
pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
|
||||
land.lnd_tech,
|
||||
land.lnd_effic,
|
||||
lchr[(int)land.lnd_type].l_name, land.lnd_uid);
|
||||
if (pln_first_on_land(&land) >= 0) {
|
||||
snxtitem_all(&ni, EF_PLANE);
|
||||
while (nxtitem(&ni, &plane)) {
|
||||
if (plane.pln_land == land.lnd_uid) {
|
||||
pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
|
||||
plane.pln_tech,
|
||||
plane.pln_effic,
|
||||
plchr[(int)plane.pln_type].pl_name,
|
||||
plane.pln_uid);
|
||||
if (getnuke(nuk_on_plane(&plane), &nuke))
|
||||
pr("(%s)", nchr[nuke.nuk_type].n_name);
|
||||
}
|
||||
}
|
||||
pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
|
||||
land.lnd_tech,
|
||||
land.lnd_effic,
|
||||
lchr[(int)land.lnd_type].l_name, land.lnd_uid);
|
||||
if (pln_first_on_land(&land) >= 0) {
|
||||
snxtitem_cargo(&ni, EF_PLANE, EF_LAND, land.lnd_uid);
|
||||
while (nxtitem(&ni, &plane)) {
|
||||
pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
|
||||
plane.pln_tech,
|
||||
plane.pln_effic,
|
||||
plchr[(int)plane.pln_type].pl_name,
|
||||
plane.pln_uid);
|
||||
if (getnuke(nuk_on_plane(&plane), &nuke))
|
||||
pr("(%s)", nchr[nuke.nuk_type].n_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,16 +178,14 @@ trade_desc(struct trdstr *tp, union empobj_storage *tgp)
|
|||
}
|
||||
pr("] #%d", tp->trd_unitid);
|
||||
if (opt_SHOWPLANE) {
|
||||
snxtitem_all(&ni, EF_PLANE);
|
||||
snxtitem_cargo(&ni, EF_PLANE, EF_LAND, lp->lnd_uid);
|
||||
while (nxtitem(&ni, &plane)) {
|
||||
if (plane.pln_land == lp->lnd_uid && plane.pln_own != 0) {
|
||||
pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
|
||||
plane.pln_tech,
|
||||
plane.pln_effic,
|
||||
plchr[(int)plane.pln_type].pl_name, plane.pln_uid);
|
||||
if (getnuke(nuk_on_plane(&plane), &nuke))
|
||||
pr("(%s)", nchr[nuke.nuk_type].n_name);
|
||||
}
|
||||
pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
|
||||
plane.pln_tech,
|
||||
plane.pln_effic,
|
||||
plchr[(int)plane.pln_type].pl_name, plane.pln_uid);
|
||||
if (getnuke(nuk_on_plane(&plane), &nuke))
|
||||
pr("(%s)", nchr[nuke.nuk_type].n_name);
|
||||
}
|
||||
}
|
||||
getsect(lp->lnd_x, lp->lnd_y, §);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue