]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/show.c
show: Extend show item to show the power value
[empserver] / src / lib / subs / show.c
index 31fa44d00bd6ed502687d1c546b2219fdc57eef8..bab48c074763f9677fb935a635d59d28819564b6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2016, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@
  *     Jeff Bailey, 1990
  *     Steve McClure, 1996
  *     Ron Koenderink, 2005-2009
- *     Markus Armbruster, 2006-2011
+ *     Markus Armbruster, 2006-2016
  */
 
 #include <config.h>
@@ -192,16 +192,14 @@ show_nuke_build(int tlev)
     int n = make_nchr_index(chridx, tlev);
     int i;
     struct nchrstr *np;
-    int avail;
 
     pr("%13s lcm hcm  oil  rad avail tech res $\n", "");
 
     for (i = 0; i < n; i++) {
        np = &nchr[chridx[i].type];
-       avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
        pr("%-13.13s %3d %3d %4d %4d %5d %4d %3.0f $%6d\n",
-          np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
-          np->n_rad, avail, np->n_tech,
+          np->n_name, np->n_mat[I_LCM], np->n_mat[I_HCM],
+          np->n_mat[I_OIL], np->n_mat[I_RAD], np->n_bwork, np->n_tech,
           drnuke_const > MIN_DRNUKE_CONST ?
                ceil(np->n_tech * drnuke_const) : 0.0,
           np->n_cost);
@@ -242,8 +240,8 @@ show_ship_build(int tlev)
     for (i = 0; i < n; i++) {
        mp = &mchr[chridx[i].type];
        pr("%-25.25s %3d %3d %5d %4d $%d\n",
-          mp->m_name, mp->m_lcm, mp->m_hcm,
-          SHP_BLD_WORK(mp->m_lcm, mp->m_hcm), mp->m_tech, mp->m_cost);
+          mp->m_name, mp->m_mat[I_LCM], mp->m_mat[I_HCM],
+          mp->m_bwork, mp->m_tech, mp->m_cost);
     }
 }
 
@@ -333,9 +331,9 @@ show_plane_build(int tlev)
     for (i = 0; i < n; i++) {
        pp = &plchr[chridx[i].type];
        pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
-          pp->pl_name, pp->pl_lcm,
-          pp->pl_hcm, pp->pl_crew,
-          PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm), pp->pl_tech, pp->pl_cost);
+          pp->pl_name, pp->pl_mat[I_LCM],
+          pp->pl_mat[I_HCM], pp->pl_mat[I_MILIT],
+          pp->pl_bwork, pp->pl_tech, pp->pl_cost);
     }
 }
 
@@ -351,10 +349,10 @@ show_land_build(int tlev)
     for (i = 0; i < n; i++) {
        lp = &lchr[chridx[i].type];
        pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
-          lp->l_name, lp->l_lcm,
-          lp->l_hcm,
-          lp->l_gun,
-          LND_BLD_WORK(lp->l_lcm, lp->l_hcm), lp->l_tech, lp->l_cost);
+          lp->l_name, lp->l_mat[I_LCM],
+          lp->l_mat[I_HCM],
+          lp->l_mat[I_GUN],
+          lp->l_bwork, lp->l_tech, lp->l_cost);
     }
 }
 
@@ -488,12 +486,14 @@ show_item(int tlev)
 {
     struct ichrstr *ip;
 
-    pr("item value sell lbs    packing     melt  item\n");
-    pr("mnem                in no wh ur bk deno  name\n");
+    pr("item power value sell lbs    packing     melt  item\n");
+    pr("mnem                      in no wh ur bk deno  name\n");
 
     for (ip = ichr; ip->i_name; ip++) {
-       pr("   %c %5d %4s %3d %2d %2d %2d %2d %2d %4d  %s\n",
-          ip->i_mnem, ip->i_value, ip->i_sell ? "yes" : "no", ip->i_lbs,
+       pr("  %c  %5d %5d %4s %3d %2d %2d %2d %2d %2d %4d  %s\n",
+          ip->i_mnem, ip->i_power,
+          ip->i_value, ip->i_sell ? "yes" : "no",
+          ip->i_lbs,
           ip->i_pkg[IPKG], ip->i_pkg[NPKG], ip->i_pkg[WPKG],
           ip->i_pkg[UPKG], ip->i_pkg[BPKG],
           ip->i_melt_denom, ip->i_name);
@@ -516,7 +516,7 @@ show_product(int tlev)
           pp->p_sname,
           pp->p_type < 0 ? ' ' : ichr[pp->p_type].i_mnem,
           pp->p_cost);
-       (void)CANT_HAPPEN(MAXPRCON > 3); /* output has only three columns */
+       BUILD_ASSERT(MAXPRCON <= 3); /* output has only three columns */
        for (i = 0; i < 3; i++) {
            if (i < MAXPRCON && pp->p_camt[i]
                && pp->p_ctype[i] > I_NONE && pp->p_ctype[i] <= I_MAX)
@@ -605,7 +605,7 @@ show_updates(int n)
 }
 
 /*
- * Return T formatted according to RFC 2822.
+ * Return @t formatted according to RFC 2822.
  * The return value is statically allocated and overwritten on
  * subsequent calls.
  */
@@ -658,14 +658,9 @@ show_load(short item[])
 static void
 show_capab(int flags, struct symbol *table)
 {
-    int i;
-    char *p;
+    char buf[1024];
 
-    for (i = 0; i < 32; i++) {
-       if (!(flags & bit(i)))
-           continue;
-       p = symbol_by_value(bit(i), table);
-       if (p)
-           pr(" %s", p);
-    }
+    symbol_set_fmt(buf, sizeof(buf), flags, table, " ", 0);
+    if (*buf)
+       pr(" %s", buf);
 }