(unit_view): New, create by expanding shp_view() to work for

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().
This commit is contained in:
Ron Koenderink 2007-01-27 02:04:27 +00:00
parent aee2bc78e2
commit 7434da679e
5 changed files with 28 additions and 29 deletions

View file

@ -667,7 +667,6 @@ extern int shp_sweep(struct emp_qelem *, int, int, natid);
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);

View file

@ -45,3 +45,4 @@ struct ulist {
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 *);

View file

@ -255,13 +255,10 @@ do_unit_move(struct emp_qelem *ulist, int *together,
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");

View file

@ -735,29 +735,6 @@ shp_hit_mine(struct shpstr *sp, struct mchrstr *mcp)
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, &sect);
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)

View file

@ -176,3 +176,28 @@ unit_path(int together, struct empobj *unit, char *buf)
}
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, &sect);
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);
}
}