land_unit as well.
(do_unit_move): Add view option for land units using unit_view().
Combine ship and land viewing using the unit_view().
(shp_view): Remove, not used any more, replaced by unit_view().
extern int shp_check_nav(struct sctstr *, struct shpstr *);
extern int sect_has_dock(struct sctstr *);
extern int shp_hardtarget(struct shpstr *);
-extern void shp_view(struct emp_qelem *);
extern int shp_nav_one_sector(struct emp_qelem *, int, natid, int);
extern int shp_missile_defense(coord, coord, natid, int);
extern void shp_missdef(struct shpstr *, natid);
extern void unit_list(struct emp_qelem *);
extern void unit_put(struct emp_qelem *list, natid actor);
extern char *unit_path(int, struct empobj *, char *);
+extern void unit_view(struct emp_qelem *);
player->btused++;
continue;
case 'v':
- if (leader->ef_type != EF_SHIP)
- break;
- shp_view(ulist);
+ unit_view(ulist);
continue;
}
- direrr("`%c' to stop",
- type == EF_SHIP ? ", `%c' to view" : NULL, NULL);
+ direrr("`%c' to stop", ", `%c' to view", NULL);
pr(", `i' to list %s, `f' to change %s,\n",
type == EF_SHIP ? "ships" : "units",
type == EF_SHIP ? "flagship" : "leader");
return (int)m;
}
-void
-shp_view(struct emp_qelem *list)
-{
- struct sctstr sect;
- struct emp_qelem *qp;
- struct emp_qelem *next;
- struct ulist *mlp;
-
- for (qp = list->q_back; qp != list; qp = next) {
- next = qp->q_back;
- mlp = (struct ulist *)qp;
- getsect(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y, §);
- if (((struct mchrstr *)mlp->chrp)->m_flags & M_FOOD)
- mpr(mlp->unit.ship.shp_own, "[fert:%d] ", sect.sct_fertil);
- if (((struct mchrstr *)mlp->chrp)->m_flags & M_OIL)
- mpr(mlp->unit.ship.shp_own, "[oil:%d] ", sect.sct_oil);
- mpr(mlp->unit.ship.shp_own, "%s @ %s %d%% %s\n",
- prship(&mlp->unit.ship),
- xyas(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y, player->cnum),
- sect.sct_effic, dchr[sect.sct_type].d_name);
- }
-}
-
int
shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor,
int together)
}
return cp;
}
+
+void
+unit_view(struct emp_qelem *list)
+{
+ struct sctstr sect;
+ struct emp_qelem *qp;
+ struct emp_qelem *next;
+ struct ulist *ulp;
+
+ for (qp = list->q_back; qp != list; qp = next) {
+ next = qp->q_back;
+ ulp = (struct ulist *)qp;
+ getsect(ulp->unit.gen.x, ulp->unit.gen.y, §);
+ if (ulp->unit.ef_type == EF_SHIP) {
+ if (((struct mchrstr *)ulp->chrp)->m_flags & M_FOOD)
+ mpr(ulp->unit.gen.own, "[fert:%d] ", sect.sct_fertil);
+ if (((struct mchrstr *)ulp->chrp)->m_flags & M_OIL)
+ mpr(ulp->unit.gen.own, "[oil:%d] ", sect.sct_oil);
+ }
+ mpr(ulp->unit.gen.own, "%s @ %s %d%% %s\n",
+ obj_nameof(&ulp->unit.gen),
+ xyas(ulp->unit.gen.x, ulp->unit.gen.y, player->cnum),
+ sect.sct_effic, dchr[sect.sct_type].d_name);
+ }
+}