]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/show.c
Update copyright notice.
[empserver] / src / lib / subs / show.c
index d25989fb0c047f328c462d36c4b7136246fafe45..7acb52c6b8574e8f46cbbcdb793027e2edb2a947 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
  *     Jeff Bailey, 1990
  *     Steve McClure, 1996
  *     Ron Koenderink, 2005
+ *     Markus Armbruster, 2006
  */
 
 #include <config.h>
 
 #include <math.h>
-#include "misc.h"
-#include "player.h"
-#include "nuke.h"
-#include "ship.h"
-#include "land.h"
-#include "item.h"
-#include "plane.h"
-#include "sect.h"
-#include "optlist.h"
 #include "file.h"
+#include "item.h"
+#include "land.h"
 #include "nat.h"
-#include "prototypes.h"
-#include "nsc.h"
 #include "news.h"
+#include "nuke.h"
+#include "optlist.h"
+#include "plane.h"
+#include "player.h"
+#include "product.h"
+#include "prototypes.h"
+#include "sect.h"
+#include "ship.h"
 
 struct look_list {
     union {
@@ -59,8 +59,13 @@ struct look_list {
        struct mchrstr *mp;
     } l_u;
     int tech;
-} lookup_list[200];            /* Change this if there are ever more than 200 planes, ships
-                                  or land units. */
+};
+
+/*
+ * Change this if there are ever more than 200 ships, plane or land
+ * unit types.
+ */
+static struct look_list lookup_list[200];
 static int lookup_list_cnt = 0;
 
 static void
@@ -199,7 +204,7 @@ show_nuke_capab(int tlev)
            if (NULL != (p = symbol_by_value(bit(i), nuke_chr_flags))) {
                if (j++ > 0)
                    pr(" ");
-               pr(p);
+               pr("%s", p);
            }
        }
        pr("\n");
@@ -313,7 +318,7 @@ show_ship_capab(int tlev)
            if (NULL != (p = symbol_by_value(bit(j), ship_chr_flags))) {
                if (n++ > 0)
                    pr(" ");
-               pr(p);
+               pr("%s", p);
            }
        }
        pr("\n");
@@ -364,7 +369,7 @@ show_plane_capab(int tlev)
            if (NULL != (p = symbol_by_value(bit(i), plane_chr_flags))) {
                if (n++ > 0)
                    pr(" ");
-               pr(p);
+               pr("%s", p);
            }
        }
        pr("\n");
@@ -437,7 +442,7 @@ show_land_capab(int tlev)
            if (NULL != (p = symbol_by_value(bit(j), land_chr_flags))) {
                if (n++ > 0)
                    pr(" ");
-               pr(p);
+               pr("%s", p);
            }
        }
        pr("\n");
@@ -463,8 +468,9 @@ show_land_stats(int tlev)
 
        ourtlev = (int)(tlev - lcp->l_tech);
        pr("%-25s %1.1f %1.1f %3d ",
-          lcp->l_name, (float)LND_ATTDEF(lcp->l_att, ourtlev),
-          (float)LND_ATTDEF(lcp->l_def, ourtlev),
+          lcp->l_name,
+          LND_ATTDEF(lcp->l_att, ourtlev),
+          LND_ATTDEF(lcp->l_def, ourtlev),
           (int)LND_VUL(lcp->l_vul, ourtlev));
        pr("%2d %2d %2d %2d ",
           (int)LND_SPD(lcp->l_spd, ourtlev),
@@ -475,7 +481,7 @@ show_land_stats(int tlev)
           (int)LND_FRG(lcp->l_frg, ourtlev),
           (int)LND_ACC(lcp->l_acc, ourtlev),
           (int)LND_DAM(lcp->l_dam, ourtlev),
-          (int)LND_AMM(lcp->l_ammo, lcp->l_dam, ourtlev),
+          (int)LND_AMM(lcp->l_ammo, ourtlev),
           (int)LND_AAF(lcp->l_aaf, ourtlev));
        pr("%2d %2d %2d %2d ",
           (int)LND_FC(lcp->l_fuelc, ourtlev),
@@ -490,9 +496,10 @@ show_land_stats(int tlev)
 void
 show_sect_build(int foo)
 {
-    int x, first = 1;
+    int x, first;
 
-    for (x = 0; x <= SCT_MAXDEF; x++) {
+    first = 1;
+    for (x = 0; dchr[x].d_name; x++) {
        if (dchr[x].d_mnem == 0)
            continue;
        if (dchr[x].d_cost < 0)
@@ -508,13 +515,18 @@ show_sect_build(int foo)
               dchr[x].d_lcms, dchr[x].d_hcms);
        }
     }
-    pr("\n");
-    pr("Infrastructure building - adding 1 point of efficiency costs:\n");
-    pr("       type          lcms    hcms    mobility    $$$$\n");
+
+    first = 1;
     for (x = 0; intrchr[x].in_name; x++) {
-       pr("%-20s %4d    %4d    %8d    %4d\n", intrchr[x].in_name,
-          intrchr[x].in_lcms, intrchr[x].in_hcms,
+       if (!intrchr[x].in_enable)
+           continue;
+       if (first)
+           pr("\nInfrastructure building - adding 1 point of efficiency costs:\n"
+              "       type          lcms    hcms    mobility    $$$$\n");
+       pr("%-20s %4d    %4d    %8d    %4d\n",
+          intrchr[x].in_name, intrchr[x].in_lcms, intrchr[x].in_hcms,
           intrchr[x].in_mcost, intrchr[x].in_dcost);
+       first = 0;
     }
 }
 
@@ -525,18 +537,21 @@ show_sect_stats(int foo)
     struct natstr *natp;
 
     natp = getnatp(player->cnum);
-    for (x = 0; x <= SCT_MAXDEF; x++) {
+    for (x = 0; dchr[x].d_name; x++) {
        if (dchr[x].d_mnem == 0)
            continue;
        if (first) {
-           pr("                        base     max   max   --  packing bonus  --   max\n");
-           pr("  sector type           mcost    off   def   mil  uw civ bar other   pop\n");
+           pr("                        mob cost   max   max   --  packing bonus  --   max\n");
+           pr("  sector type            0%% 100%%   off   def   mil  uw civ bar other   pop\n");
            first = 0;
        }
-       pr("%c %-23s %3d  %5.2f %5.2f   %3d %3d %3d %3d %5d %5d\n",
-          dchr[x].d_mnem, dchr[x].d_name,
-          dchr[x].d_mcst, dchr[x].d_ostr,
-          dchr[x].d_dstr,
+       pr("%c %-21.21s", dchr[x].d_mnem, dchr[x].d_name);
+       if (dchr[x].d_mob0 < 0)
+           pr("  no way ");
+       else
+           pr(" %3.1f  %3.1f", dchr[x].d_mob0, dchr[x].d_mob1);
+       pr("  %5.2f %5.2f   %3d %3d %3d %3d %5d %5d\n",
+          dchr[x].d_ostr, dchr[x].d_dstr,
           ichr[I_MILIT].i_pkg[dchr[x].d_pkg],
           ichr[I_UW].i_pkg[dchr[x].d_pkg],
           ichr[I_CIVIL].i_pkg[dchr[x].d_pkg],
@@ -552,8 +567,8 @@ show_sect_capab(int foo)
     int x, first = 1, i, j;
     char *tmpstr;
 
-    for (x = 0; x <= SCT_MAXDEF; x++) {
-       if ((dchr[x].d_mnem == 0) || (dchr[x].d_prd == 0))
+    for (x = 0; dchr[x].d_name; x++) {
+       if (dchr[x].d_mnem == 0 || dchr[x].d_prd < 0)
            continue;
        if (first) {
            pr("                                                 --- level ---          reso \n");
@@ -563,8 +578,8 @@ show_sect_capab(int foo)
 
        j = dchr[x].d_prd;
 
-       pr("%c %-23s %-7s ", dchr[x].d_mnem, dchr[x].d_name,
-          pchr[j].p_sname);
+       pr("%c %-23s %-7s ",
+          dchr[x].d_mnem, dchr[x].d_name, pchr[j].p_sname);
        (void)CANT_HAPPEN(MAXPRCON > 3); /* output has only three columns */
        for (i = 0; i < 3; i++) {
            if (i < MAXPRCON
@@ -598,7 +613,7 @@ show_sect_capab(int foo)
           tmpstr,
           pchr[j].p_nlmin,
           pchr[j].p_nllag,
-          pchr[j].p_effic, pchr[j].p_cost, pchr[j].p_nrdep,
+          dchr[x].d_peffic, pchr[j].p_cost, pchr[j].p_nrdep,
           pchr[j].p_type != I_NONE ? ichr[pchr[j].p_type].i_mnem : ' ');
 
        pr("\n");