]> git.pond.sub.org Git - empserver/commitdiff
(unit_view): New, create by expanding shp_view() to work for
authorRon Koenderink <rkoenderink@yahoo.ca>
Sat, 27 Jan 2007 02:04:27 +0000 (02:04 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Sat, 27 Jan 2007 02:04:27 +0000 (02:04 +0000)
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().

include/prototypes.h
include/unit.h
src/lib/commands/navi.c
src/lib/subs/shpsub.c
src/lib/subs/unitsub.c

index 71d2b91761e8c6bfa26223ffa47cffc12c29b153..f1023bd9aaace90d748778b384fa531e91f82ff5 100644 (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);
index 7f21b9a6c7949409c80911658c32e1ef3da8aece..162cfa9032ac7fe1d7d7826a4d4e9b31747e7199 100644 (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 *);
index b017a0543440da1ab8f07562e1c5aa602d599e9d..db723bc9c2c9e916afc7942a176a10ab10b1833c 100644 (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");
index cc990f33af2bb3d3513b995fd0e11a62dabf0ca0..e5b6b3678ea3c32ce7e31f839b4c69a966646796 100644 (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)
index 3afed19c7d67e78e9835f1f1ec26fdbdf4cabb78..e45c0e671f25db63a60d97d23ed0081c9754bf3e 100644 (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);
+    }
+}