]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/show.c
Remove option LANDSPIES, customize table land-chr instead
[empserver] / src / lib / subs / show.c
index a428cffb35f9cae9de316dd754e1bbb7c27a5bed..3ff4972ef92fb26335425a92d6b7ee16b5daff91 100644 (file)
@@ -79,9 +79,9 @@ make_mchr_index(struct chr_index chridx[], int tlev)
 
     n = 0;
     for (i = 0; mchr[i].m_name; i++) {
-       if (mchr[i].m_tech > tlev)
+       if (!mchr[i].m_name[0])
            continue;
-       if ((mchr[i].m_flags & M_TRADE) && !opt_TRADESHIPS)
+       if (mchr[i].m_tech > tlev)
            continue;
        chridx[n].type = i;
        chridx[n].tech = mchr[i].m_tech;
@@ -100,6 +100,8 @@ make_plchr_index(struct chr_index chridx[], int tlev)
 
     n = 0;
     for (i = 0; plchr[i].pl_name; i++) {
+       if (!plchr[i].pl_name[0])
+           continue;
        if (plchr[i].pl_tech > tlev)
            continue;
        chridx[n].type = i;
@@ -119,9 +121,9 @@ make_lchr_index(struct chr_index chridx[], int tlev)
 
     n = 0;
     for (i = 0; lchr[i].l_name; i++) {
-       if (lchr[i].l_tech > tlev)
+       if (!lchr[i].l_name[0])
            continue;
-       if ((lchr[i].l_flags & L_SPY) && !opt_LANDSPIES)
+       if (lchr[i].l_tech > tlev)
            continue;
        chridx[n].type = i;
        chridx[n].tech = lchr[i].l_tech;
@@ -132,6 +134,27 @@ make_lchr_index(struct chr_index chridx[], int tlev)
     return n;
 }
 
+static int
+make_nchr_index(struct chr_index chridx[], int tlev)
+{
+    struct natstr *natp = getnatp(player->cnum);
+    int i, n;
+
+    n = 0;
+    for (i = 0; nchr[i].n_name; i++) {
+       if (!nchr[i].n_name[0])
+           continue;
+       if (nchr[i].n_tech > tlev)
+           continue;
+       chridx[n].type = i;
+       chridx[n].tech = nchr[i].n_tech;
+       n++;
+    }
+    if (natp->nat_flags & NF_TECHLISTS)
+       qsort(chridx, n, sizeof(*chridx), chr_index_cmp);
+    return n;
+}
+
 void
 show_bridge(int tlev)
 {
@@ -165,15 +188,17 @@ show_nuke_stats(int tlev)
 void
 show_nuke_build(int tlev)
 {
+    struct chr_index chridx[sizeof(nchr) / sizeof(*nchr)];
+    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 (np = nchr; np->n_name; np++) {
+    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);
-       if (np->n_tech > tlev)
-           continue;
        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,
@@ -186,13 +211,14 @@ show_nuke_build(int tlev)
 void
 show_nuke_capab(int tlev)
 {
+    struct chr_index chridx[sizeof(nchr) / sizeof(*nchr)];
+    int n = make_nchr_index(chridx, tlev);
+    int i;
     struct nchrstr *np;
 
     pr("%13s blst dam lbs tech res $%7s abilities\n", "", "");
-
-    for (np = nchr; np->n_name; np++) {
-       if (np->n_tech > tlev)
-           continue;
+    for (i = 0; i < n; i++) {
+       np = &nchr[chridx[i].type];
        pr("%-13.13s %4d %3d %3d %4d %3.0f $%7d",
           np->n_name, np->n_blast, np->n_dam,
           np->n_weight, np->n_tech,
@@ -484,6 +510,8 @@ show_product(int tlev)
     pr("product    cost  raw materials  reso dep  level p.e.\n");
 
     for (pp = pchr; pp->p_sname; pp++) {
+       if (!pp->p_sname[0])
+           continue;
        pr("%7.7s %c  $%-3d ",
           pp->p_sname,
           pp->p_type < 0 ? ' ' : ichr[pp->p_type].i_mnem,