]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/unitsub.c
Fix navigate and march to find paths longer than 7 sectors again
[empserver] / src / lib / subs / unitsub.c
index 4e8e6c23c1346e991422082c7a023ce7ff26e486..4545d906121a70b2354a01972ef7966e1af2f024 100644 (file)
@@ -77,7 +77,7 @@ unit_list(struct emp_qelem *unit_list)
        return;
 
     if (type == EF_LAND)
-       pr("lnd#     land type       x,y    a  eff  sh gun xl  mu tech retr\n");
+       pr("lnd#     land type       x,y    a  eff mil  sh gun xl ln  mu tech retr\n");
     else
        pr("shp#     ship type       x,y   fl  eff mil  sh gun pn he xl ln mob tech\n");
 
@@ -95,9 +95,10 @@ unit_list(struct emp_qelem *unit_list)
        pr("%1.1s", &unit->group);
        pr("%4d%%", unit->effic);
        if (type == EF_LAND) {
+           pr("%4d", lnd->lnd_item[I_MILIT]);
            pr("%4d", lnd->lnd_item[I_SHELL]);
            pr("%4d", lnd->lnd_item[I_GUN]);
-           pr("%3d", lnd_nxlight(lnd));
+           pr("%3d%3d", lnd_nxlight(lnd), lnd_nland(lnd));
        } else {
            pr("%4d", shp->shp_item[I_MILIT]);
            pr("%4d", shp->shp_item[I_SHELL]);
@@ -150,7 +151,7 @@ unit_put(struct emp_qelem *list, natid actor)
 }
 
 char *
-unit_path(int together, struct empobj *unit, char *buf)
+unit_path(int together, struct empobj *unit, char *buf, size_t bufsz)
 {
     coord destx;
     coord desty;
@@ -195,13 +196,13 @@ unit_path(int together, struct empobj *unit, char *buf)
            return NULL;
        }
     }
-    len = path_find_route(buf, sizeof(buf), unit->x, unit->y, destx, desty);
+    len = path_find_route(buf, bufsz, unit->x, unit->y, destx, desty);
     if (len == 0 || unit->ef_type == EF_LAND) {
-       if (len + 1 < sizeof(buf))
+       if (len + 1 < bufsz)
            strcpy(buf + len, "h");
        len++;
     }
-    if (len >= sizeof(buf)) {
+    if (len >= bufsz) {
        pr("Can't handle path to %s, it's too long, sorry\n",
           xyas(destx, desty, player->cnum));
        return NULL;
@@ -243,13 +244,15 @@ unit_view(struct emp_qelem *list)
  * nukes).
  * Else update their location to the carrier's.  Any op sectors equal
  * to location get updated, too.
+ * Return number of units updated.
  */
-void
+int
 unit_update_cargo(struct empobj *carrier)
 {
     int cargo_type;
     struct nstr_item ni;
     union empobj_storage obj;
+    int n = 0;
 
     for (cargo_type = EF_PLANE; cargo_type <= EF_NUKE; cargo_type++) {
        snxtitem_cargo(&ni, cargo_type, carrier->ef_type, carrier->uid);
@@ -267,8 +270,10 @@ unit_update_cargo(struct empobj *carrier)
                obj.gen.y = carrier->y;
            }
            put_empobj(cargo_type, obj.gen.uid, &obj);
+           n++;
        }
     }
+    return n;
 }
 
 /*