diff --git a/include/prototypes.h b/include/prototypes.h index 71d2b917..f1023bd9 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -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); diff --git a/include/unit.h b/include/unit.h index 7f21b9a6..162cfa90 100644 --- a/include/unit.h +++ b/include/unit.h @@ -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 *); diff --git a/src/lib/commands/navi.c b/src/lib/commands/navi.c index b017a054..db723bc9 100644 --- a/src/lib/commands/navi.c +++ b/src/lib/commands/navi.c @@ -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"); diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index cc990f33..e5b6b367 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -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, §); - 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) diff --git a/src/lib/subs/unitsub.c b/src/lib/subs/unitsub.c index 3afed19c..e45c0e67 100644 --- a/src/lib/subs/unitsub.c +++ b/src/lib/subs/unitsub.c @@ -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, §); + 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); + } +}