]> git.pond.sub.org Git - empserver/blob - src/lib/subs/show.c
(at_minimum, blocksig, emp_bitinit, filelogerror, iceil, ifloor,
[empserver] / src / lib / subs / show.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                           Ken Stevens, Steve McClure
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  *  ---
21  *
22  *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23  *  related information and legal notices. It is expected that any future
24  *  projects/authors will amend these files as needed.
25  *
26  *  ---
27  *
28  *  show.c: General show routines
29  * 
30  *  Known contributors to this file:
31  *     Julian Onions, 1988
32  *     Jeff Bailey, 1990
33  *     Steve McClure, 1996
34  */
35
36 /*
37  * general routines that are callable to give info on things.
38  * currently, planes, ships, nukes and bridges. Tanks & regiments one day?
39  *
40  * Added nuke_flags to be consistent. Jeff Bailey 12/15/90
41  *                                    (bailey@mcs.kent.edu)
42  */
43
44 #include "misc.h"
45 #include "player.h"
46 #include "nuke.h"
47 #include "var.h"
48 #include "ship.h"
49 #include "land.h"
50 #include "item.h"
51 #include "plane.h"
52 #include "sect.h"
53 #include "optlist.h"
54 #include "file.h"
55 #include "nat.h"
56 #include "prototypes.h"
57
58 double sqrt(double);
59 double logx(double, double);
60
61 /*
62  * This cruft really belongs in the empglb.c file.
63  * Yuck.
64  */
65
66 struct lookup {
67     int key;
68     s_char *value;
69 };
70
71 struct lookup ship_flags[] = {
72     {M_FOOD, "fish"},
73     {M_TORP, "torp"},
74     {M_DCH, "dchrg"},
75     {M_FLY, "plane"},
76     {M_MSL, "miss"},
77     {M_OIL, "oil"},
78     {M_SONAR, "sonar"},
79     {M_MINE, "mine"},
80     {M_SWEEP, "sweep"},
81     {M_SUB, "sub"},
82     {M_SPY, "spy"},
83     {M_LAND, "land"},
84     {M_SUBT, "sub-torp"},
85     {M_TRADE, "trade"},
86     {M_SEMILAND, "semi-land"},
87     {M_OILER, "oiler"},
88     {M_SUPPLY, "supply"},
89     {M_ANTIMISSILE, "anti-missile"},
90     {0, 0}
91 };
92
93 struct lookup land_flags[] = {
94     {L_XLIGHT, "xlight"},
95     {L_ENGINEER, "engineer"},
96     {L_SUPPLY, "supply"},
97     {L_SECURITY, "security"},
98     {L_LIGHT, "light"},
99     {L_MARINE, "marine"},
100     {L_RECON, "recon"},
101     {L_RADAR, "radar"},
102     {L_ASSAULT, "assault"},
103     {L_FLAK, "flak"},
104     {L_SPY, "spy"},
105     {L_TRAIN, "train"},
106     {L_HEAVY, "heavy"},
107     {0, 0}
108 };
109
110
111 struct lookup plane_flags[] = {
112     {P_T, "tactical"},
113     {P_B, "bomber"},
114     {P_F, "intercept"},
115     {P_C, "cargo"},
116     {P_V, "VTOL"},
117     {P_M, "missile"},
118     {P_L, "light"},
119     {P_S, "spy"},
120     {P_I, "image"},
121     {P_O, "satellite"},
122     {P_X, "stealth"},
123     {P_N, "SDI"},
124     {P_H, "half-stealth"},
125     {P_E, "x-light"},
126     {P_K, "helo"},
127     {P_A, "ASW"},
128     {P_P, "para"},
129     {P_ESC, "escort"},
130     {P_MINE, "mine"},
131     {P_SWEEP, "sweep"},
132     {P_MAR, "marine"},
133     {0, 0}
134 };
135
136 struct lookup nuke_flags[] = {
137     {N_NEUT, "neutron"},
138     {0, 0}
139 };
140
141 struct look_list {
142     union {
143         struct lchrstr *lp;
144         struct plchrstr *pp;
145         struct mchrstr *mp;
146         int value;
147     } l_u;
148     int tech;
149 } lookup_list[200];             /* Change this if there are ever more than 200 planes, ships
150                                    or land units. */
151 static int lookup_list_cnt = 0;
152
153 static void
154 sort_lookup_list(void)
155 {
156     struct natstr *np = getnatp(player->cnum);
157     struct look_list tmp;
158     int i;
159     int j;
160
161     if (!(np->nat_flags & NF_TECHLISTS))
162         return;
163     for (i = 0; i < lookup_list_cnt; i++) {
164         for (j = i; j < lookup_list_cnt; j++) {
165             if (lookup_list[j].tech < lookup_list[i].tech) {
166                 tmp = lookup_list[j];
167                 lookup_list[j] = lookup_list[i];
168                 lookup_list[i] = tmp;
169             }
170         }
171     }
172 }
173
174 static
175     void
176 make_new_list(int tlev, int type)
177 {
178     struct plchrstr *pp;
179     struct lchrstr *lp;
180     struct mchrstr *mp;
181     int count;
182
183     lookup_list_cnt = 0;
184     if (type == EF_PLANE) {
185         for (pp = plchr, count = 0; count < pln_maxno; count++, pp++) {
186             if (pp->pl_tech > tlev)
187                 continue;
188             if (pp->pl_name == 0 || pp->pl_name[0] == '\0')
189                 continue;
190             lookup_list[lookup_list_cnt].l_u.pp = pp;
191             lookup_list[lookup_list_cnt].tech = pp->pl_tech;
192             lookup_list_cnt++;
193         }
194     } else if (type == EF_SHIP) {
195         for (mp = mchr, count = 0; count < shp_maxno; count++, mp++) {
196             if (mp->m_tech > tlev)
197                 continue;
198             if (mp->m_name == 0 || mp->m_name[0] == '\0')
199                 continue;
200             lookup_list[lookup_list_cnt].l_u.mp = mp;
201             lookup_list[lookup_list_cnt].tech = mp->m_tech;
202             lookup_list_cnt++;
203         }
204     } else if (type == EF_LAND) {
205         for (lp = lchr, count = 0; count < lnd_maxno; count++, lp++) {
206             if (lp->l_tech > tlev)
207                 continue;
208             if (lp->l_name == 0 || lp->l_name[0] == '\0')
209                 continue;
210             lookup_list[lookup_list_cnt].l_u.lp = lp;
211             lookup_list[lookup_list_cnt].tech = lp->l_tech;
212             lookup_list_cnt++;
213         }
214     } else
215         return;
216
217     sort_lookup_list();
218 }
219
220 static
221 s_char *
222 lookup(int key, struct lookup *table)
223 {
224     int match;
225
226     if ((match = intmatch(key, &table->key, sizeof(*table))) < 0)
227         return 0;
228     return table[match].value;
229 }
230
231 void
232 show_bridge(int tlev)
233 {
234     extern double buil_bt, buil_bc;
235     extern int buil_bh;
236
237     if (tlev < buil_bt)
238         return;
239     pr("Bridges require %g tech,", buil_bt);
240     if (!opt_NO_HCMS)
241         pr(" %d hcm,", buil_bh);
242     else if (!opt_NO_LCMS)
243         pr(" %d lcm,", buil_bh);
244     pr(" %d workers,\n", buil_bh * 2);
245     pr("%d available workforce, and cost $%g\n",
246        1 + (buil_bh * 40 / 100), buil_bc);
247 }
248
249 void
250 show_tower(int tlev)
251 {
252     extern double buil_tower_bt, buil_tower_bc;
253     extern int buil_tower_bh;
254
255     if (tlev < buil_tower_bt)
256         return;
257     pr("Bridge Towers require %g tech,", buil_tower_bt);
258     if (!opt_NO_HCMS)
259         pr(" %d hcm,", buil_tower_bh);
260     else if (!opt_NO_LCMS)
261         pr(" %d lcm,", buil_tower_bh);
262     pr(" %d workers,\n", buil_tower_bh * 2);
263     pr("%d available workforce, and cost $%g\n",
264        1 + (buil_tower_bh * 40 / 100), buil_tower_bc);
265 }
266
267 void
268 show_item(int tlev)
269 {
270     register struct ichrstr *ip;
271     register int n;
272
273     pr("item   value sell lbs   packing   item\n");
274     pr("mnemo                 rg wh ur bk name\n");
275
276     for (n = 1; n <= itm_maxno; n++) {
277         ip = &ichr[n];
278         pr("     %c %5d %4s %3d %2d %2d %2d %2d %s\n",
279            ip->i_mnem, ip->i_value, (ip->i_sell == 1) ? "yes" : "no",
280            ip->i_lbs, ip->i_pkg[NPKG], ip->i_pkg[WPKG], ip->i_pkg[UPKG],
281            ip->i_pkg[BPKG], ip->i_name);
282     }
283 }
284 void
285 show_nuke_stats(int tlev)
286 {
287     show_nuke_capab(tlev);
288 }
289
290 void
291 show_nuke_build(int tlev)
292 {
293     register struct nchrstr *np;
294     register int n;
295     register int avail;
296     extern float drnuke_const;
297
298     if (opt_DRNUKE)
299         pr("%13s lcm hcm  oil  rad avail tech res $\n", "");
300     else
301         pr("%13s lcm hcm  oil  rad avail tech $\n", "");
302
303     if (opt_NONUKES)
304         return;
305     for (np = nchr, n = 0; n < N_MAXNUKE; np++, n++) {
306         avail =
307             (4 + np->n_rad + np->n_oil + np->n_lcm + np->n_hcm * 2) / 5;
308         if (np->n_tech > tlev)
309             continue;
310         if (np->n_name == 0 || np->n_name[0] == '\0')
311             continue;
312         if (opt_NEUTRON == 0 && (np->n_flags & N_NEUT))
313             continue;
314         if (opt_DRNUKE)
315             pr("%-13.13s %3d %3d %4d %4d %5d %4d %3d $%6d\n",
316                np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
317                np->n_rad, avail, np->n_tech,
318                (int)(np->n_tech * drnuke_const) + 1, np->n_cost);
319         else                    /* not DRNUKE */
320             pr("%-13.13s %3d %3d %4d %4d %5d %4d $%6d\n",
321                np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
322                np->n_rad, avail, np->n_tech, np->n_cost);
323     }
324 }
325
326 void
327 show_nuke_capab(int tlev)
328 {
329     register struct nchrstr *np;
330     register int i, j, n;
331     s_char *p;
332     extern float drnuke_const;
333
334     if (opt_DRNUKE)
335         pr("%13s blst dam lbs tech res $%7s abilities\n", "", "");
336     else
337         pr("%13s blst dam lbs tech $%7s abilities\n", "", "");
338
339     if (opt_NONUKES)
340         return;
341     for (np = nchr, n = 0; n < N_MAXNUKE; np++, n++) {
342         if (np->n_tech > tlev)
343             continue;
344         if (opt_NEUTRON == 0 && (np->n_flags & N_NEUT))
345             continue;
346         if (np->n_name == 0 || np->n_name[0] == '\0')
347             continue;
348         if (opt_DRNUKE)
349             pr("%-13.13s %4d %3d %3d %4d %3d $%7d ",
350                np->n_name, np->n_blast, np->n_dam,
351                np->n_weight, np->n_tech,
352                (int)(np->n_tech * drnuke_const) + 1, np->n_cost);
353         else                    /* not DRNUKE */
354             pr("%-13.13s %4d %3d %3d %4d $%7d ",
355                np->n_name, np->n_blast, np->n_dam,
356                np->n_weight, np->n_tech, np->n_cost);
357
358         for (i = j = 0; i < 32; i++) {
359             if (!(np->n_flags & bit(i)))
360                 continue;
361             if (NULL != (p = lookup(bit(i), nuke_flags))) {
362                 if (j++ > 0)
363                     pr(" ");
364                 pr(p);
365             }
366         }
367         pr("\n");
368     }
369 }
370
371 void
372 show_ship_build(int tlev)
373 {
374     register struct mchrstr *mp;
375     register int n;
376
377     pr("%25s lcm hcm avail tech $\n", "");
378     make_new_list(tlev, EF_SHIP);
379     for (n = 0; n < lookup_list_cnt; n++) {
380         mp = (struct mchrstr *)lookup_list[n].l_u.mp;
381         /* Can't show trade ships unless it's turned on */
382         if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
383             continue;
384
385         pr("%-25.25s %3d %3d %5d %4d $%d\n",
386            mp->m_name, mp->m_lcm, mp->m_hcm,
387            20 + mp->m_lcm + mp->m_hcm * 2, mp->m_tech, mp->m_cost);
388     }
389 }
390
391 void
392 show_ship_stats(int tlev)
393 {
394     register struct mchrstr *mp;
395     int scount;
396     int techdiff;
397
398     pr("%25s      s  v  s  r  f  l  p", "");
399     pr("  h");
400     pr("  x");
401     if (opt_FUEL)
402         pr("  fuel");
403     pr("\n");
404
405     pr("%25s      p  i  p  n  i  n  l", "");
406     pr("  e");
407     pr("  p");
408     if (opt_FUEL)
409         pr("   c/u");
410     pr("\n");
411
412     pr("%25s def  d  s  y  g  r  d  n", "");
413     pr("  l");
414     pr("  l");
415     if (opt_FUEL)
416         pr("      ");
417     pr("\n");
418
419
420     make_new_list(tlev, EF_SHIP);
421     for (scount = 0; scount < lookup_list_cnt; scount++) {
422         mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
423         /* Can't show trade ships unless it's turned on */
424         if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
425             continue;
426
427         techdiff = (int)(tlev - mp->m_tech);
428         pr("%-25.25s %3d %2d %2d %2d %2d %2d ",
429            mp->m_name,
430            (short)SHP_DEF(mp->m_armor, techdiff),
431            (short)SHP_SPD(mp->m_speed, techdiff),
432            (short)SHP_VIS(mp->m_visib, techdiff),
433            mp->m_vrnge,
434            (short)SHP_RNG(mp->m_frnge, techdiff),
435            (short)SHP_FIR(mp->m_glim, techdiff));
436
437         pr("%2d ", mp->m_nland);
438         pr("%2d ", mp->m_nplanes);
439         pr("%2d ", mp->m_nchoppers);
440         pr("%2d ", mp->m_nxlight);
441         if (opt_FUEL)
442             pr("%3d/%1d ", mp->m_fuelc, mp->m_fuelu);
443         pr("\n");
444     }
445 }
446
447 void
448 show_ship_capab(int tlev)
449 {
450     register struct mchrstr *mp;
451     register u_short *ap;
452     register u_char *type;
453     register int i;
454     register int it;
455     int scount;
456     int n;
457     s_char c;
458     s_char *p;
459
460     pr("%25s cargos & capabilities\n", "");
461
462     make_new_list(tlev, EF_SHIP);
463     for (scount = 0; scount < lookup_list_cnt; scount++) {
464         mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
465         /* Can't show trade ships unless it's turned on */
466         if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
467             continue;
468
469         pr("%-25.25s ", mp->m_name);
470
471         /*
472          * should use vector stuff
473          */
474         for (ap = mp->m_vamt, type = mp->m_vtype, i = 0;
475              i < mp->m_nv; i++, ap++, type++) {
476             it = unitem((int)*type);
477             if (it > 0 && it <= I_MAX && ichr[it].i_name != 0)
478                 c = ichr[it].i_name[0];
479             else
480                 c = '?';
481             pr(" %d%c", *ap, c);
482         }
483         pr(" ");
484         for (i = n = 0; i < 32; i++) {
485             if (!(mp->m_flags & bit(i)))
486                 continue;
487             if (NULL != (p = lookup(bit(i), ship_flags))) {
488                 if (n++ > 0)
489                     pr(" ");
490                 pr(p);
491             }
492         }
493         pr("\n");
494     }
495 }
496
497 void
498 show_plane_stats(int tlev)
499 {
500     register struct plchrstr *pp;
501     int pcount;
502
503     pr("%25s acc load att def ran fuel stlth\n", "");
504     make_new_list(tlev, EF_PLANE);
505     for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
506         pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
507         pr("%-25.25s %3d %4d %3d %3d %3d %4d ",
508            pp->pl_name,
509            (int)PLN_ACC(pp->pl_acc, (int)(tlev - pp->pl_tech)),
510            (int)PLN_LOAD(pp->pl_load, (int)(tlev - pp->pl_tech)),
511            (int)PLN_ATTDEF(pp->pl_att, (int)(tlev - pp->pl_tech)),
512            (int)PLN_ATTDEF(pp->pl_def, (int)(tlev - pp->pl_tech)),
513            (int)PLN_RAN(pp->pl_range, (int)(tlev - pp->pl_tech)),
514            pp->pl_fuel);
515         pr("%4d%% ", pp->pl_stealth);
516         pr("\n");
517     }
518 }
519
520 void
521 show_plane_capab(int tlev)
522 {
523     register struct plchrstr *pp;
524     register int i;
525     int pcount;
526     int n;
527     s_char *p;
528
529     pr("%25s capabilities\n", "");
530     make_new_list(tlev, EF_PLANE);
531     for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
532         pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
533         pr("%-25.25s  ", pp->pl_name);
534
535         for (i = n = 0; i < 32; i++) {
536             if (!(pp->pl_flags & bit(i)))
537                 continue;
538             if (NULL != (p = lookup(bit(i), plane_flags))) {
539                 if (n++ > 0)
540                     pr(" ");
541                 pr(p);
542             }
543         }
544         pr("\n");
545     }
546 }
547
548 void
549 show_plane_build(int tlev)
550 {
551     register struct plchrstr *pp;
552     register int pcount;
553
554     pr("%25s lcm hcm crew avail tech  $\n", "");
555     make_new_list(tlev, EF_PLANE);
556     for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
557         pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
558         pr("%-25.25s %3d %3d %3d %5d %4d $%d\n",
559            pp->pl_name, pp->pl_lcm,
560            pp->pl_hcm, pp->pl_crew,
561            20 + 2 * pp->pl_hcm + pp->pl_lcm, pp->pl_tech, pp->pl_cost);
562     }
563 }
564
565 void
566 show_land_build(int tlev)
567 {
568     register struct lchrstr *lp;
569     register int n;
570
571     pr("%25s lcm hcm guns avail tech  $\n", "");
572     make_new_list(tlev, EF_LAND);
573     for (n = 0; n < lookup_list_cnt; n++) {
574         lp = (struct lchrstr *)lookup_list[n].l_u.lp;
575         if ((lp->l_flags & L_SPY) && !opt_LANDSPIES)
576             continue;
577         pr("%-25.25s %3d %3d %4d %5d %4d  $%d\n",
578            lp->l_name, lp->l_lcm,
579            lp->l_hcm,
580            lp->l_gun,
581            20 + lp->l_lcm + (lp->l_hcm * 2), lp->l_tech, lp->l_cost);
582     }
583 }
584
585 void
586 show_land_capab(int tlev)
587 {
588     struct lchrstr *lcp;
589     int lcount;
590     register u_short *ap;
591     register u_char *type;
592     register int i, n;
593     register int it;
594     register s_char *p, c;
595
596     pr("%25s capabilities\n", "");
597
598     make_new_list(tlev, EF_LAND);
599     for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
600         lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
601         if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
602             continue;
603
604         pr("%-25s ", lcp->l_name);
605
606         /*
607          * should use vector stuff
608          */
609         for (ap = lcp->l_vamt, type = lcp->l_vtype, i = 0;
610              i < lcp->l_nv; i++, ap++, type++) {
611             it = unitem((int)*type);
612             if (it > 0 && it <= I_MAX && ichr[it].i_name != 0)
613                 c = ichr[it].i_name[0];
614             else
615                 c = '?';
616             pr(" %d%c", *ap, c);
617         }
618         pr(" ");
619         for (i = n = 0; i < 32; i++) {
620             if (!(lcp->l_flags & bit(i)))
621                 continue;
622             if (NULL != (p = lookup(bit(i), land_flags))) {
623                 if (n++ > 0)
624                     pr(" ");
625                 pr(p);
626             }
627         }
628         pr("\n");
629     }
630 }
631
632 void
633 show_land_stats(int tlev)
634 {
635     struct lchrstr *lcp;
636     int lcount;
637     int ourtlev;
638
639     pr("%25s              s  v  s  r  r  a  f  a  a        x  l\n", "");
640     pr("%25s              p  i  p  a  n  c  i  m  a  f  f  p  n\n", "");
641     pr("%25s att def vul  d  s  y  d  g  c  r  m  f  c  u  l  d\n", "");
642
643     make_new_list(tlev, EF_LAND);
644     for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
645         lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
646         if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
647             continue;
648
649         ourtlev = (int)(tlev - lcp->l_tech);
650         pr("%-25s %1.1f %1.1f %3d ",
651            lcp->l_name, (float)LND_ATTDEF(lcp->l_att, ourtlev),
652            (float)LND_ATTDEF(lcp->l_def, ourtlev),
653            (int)LND_VUL(lcp->l_vul, ourtlev));
654         pr("%2d %2d %2d %2d ",
655            (int)LND_SPD(lcp->l_spd, ourtlev),
656            (int)LND_VIS(lcp->l_vis, ourtlev),
657            (int)LND_SPY(lcp->l_spy, ourtlev),
658            (int)LND_RAD(lcp->l_rad, ourtlev));
659         pr("%2d %2d %2d %2d %2d ",
660            (int)LND_FRG(lcp->l_frg, ourtlev),
661            (int)LND_ACC(lcp->l_acc, ourtlev),
662            (int)LND_DAM(lcp->l_dam, ourtlev),
663            (int)LND_AMM(lcp->l_ammo, lcp->l_dam, ourtlev),
664            (int)LND_AAF(lcp->l_aaf, ourtlev));
665         pr("%2d %2d %2d %2d ",
666            (int)LND_FC(lcp->l_fuelc, ourtlev),
667            (int)LND_FU(lcp->l_fuelu, ourtlev),
668            (int)LND_XPL(lcp->l_nxlight, ourtlev),
669            (int)LND_MXL(lcp->l_mxland, ourtlev));
670
671         pr("\n");
672     }
673 }
674
675 void
676 show_sect_build(int foo)
677 {
678     register int x, first = 1;
679
680     for (x = 5; x < SCT_MAXDEF + 2; x++) {
681         if (dchr[x].d_mnem == 0)
682             continue;
683         if ((dchr[x].d_cost > 0) || (dchr[x].d_build != 1) ||
684             (dchr[x].d_lcms > 0) || (dchr[x].d_hcms > 0)) {
685             if (first) {
686                 pr("sector type    cost to des    cost for 1%% eff   lcms for 1%%    hcms for 1%%\n");
687                 first = 0;
688             }
689             pr("%-14c %-14d %-17d %-14d %d\n",
690                dchr[x].d_mnem, dchr[x].d_cost, dchr[x].d_build,
691                dchr[x].d_lcms, dchr[x].d_hcms);
692         }
693     }
694     pr("\n");
695     pr("Infrastructure building - adding 1 point of efficiency costs:\n");
696     pr("       type          lcms    hcms    mobility    $$$$\n");
697     for (x = 0; intrchr[x].in_name; x++) {
698         pr("%-20s %4d    %4d    %8d    %4d\n", intrchr[x].in_name,
699            intrchr[x].in_lcms, intrchr[x].in_hcms,
700            intrchr[x].in_mcost, intrchr[x].in_dcost);
701     }
702 }
703
704 void
705 show_sect_stats(int foo)
706 {
707     register int x, first = 1;
708     struct sctstr sect;
709     struct natstr *natp;
710
711     natp = getnatp(player->cnum);
712     /* We fake this */
713     sect.sct_effic = 100;
714     for (x = 0; x < SCT_MAXDEF + 2; x++) {
715         if (dchr[x].d_mnem == 0)
716             continue;
717         if (first) {
718             pr("                        base     max   max   --  packing bonus  --   max\n");
719             pr("  sector type           mcost    off   def   mil  uw civ bar other   pop\n");
720             first = 0;
721         }
722         sect.sct_type = x;
723         pr("%c %-23s %3d  %5.2f %5.2f   %3d %3d %3d %3d %5d %5d\n",
724            dchr[x].d_mnem, dchr[x].d_name,
725            dchr[x].d_mcst, dchr[x].d_ostr,
726            dchr[x].d_dstr,
727            ichr[I_MILIT].i_pkg[dchr[x].d_pkg],
728            ichr[I_UW].i_pkg[dchr[x].d_pkg],
729            ichr[I_CIVIL].i_pkg[dchr[x].d_pkg],
730            ichr[I_BAR].i_pkg[dchr[x].d_pkg],
731            ichr[I_LCM].i_pkg[dchr[x].d_pkg],
732            max_pop(natp->nat_level[NAT_RLEV], &sect));
733     }
734 }
735
736 void
737 show_sect_capab(int foo)
738 {
739     register int x, first = 1, i, j;
740     char *tmpstr;
741     char c;
742     char *outputs = " cmsgpidbfolhur";
743
744     for (x = 0; x < SCT_MAXDEF + 2; x++) {
745         if ((dchr[x].d_mnem == 0) || (dchr[x].d_prd == 0))
746             continue;
747         if (first) {
748             pr("                                                 --- level ---          reso \n");
749             pr("  sector type             product use1 use2 use3 level min lag eff%% $$$ dep c\n");
750             first = 0;
751         }
752
753         j = dchr[x].d_prd;
754
755         pr("%c %-23s %-7s ", dchr[x].d_mnem, dchr[x].d_name,
756            pchr[j].p_sname);
757         /*for(i=0;i<MAXCHRNV;i++) */
758         /* XXX currently no more than 3 items actually used */
759         for (i = 0; i < 3; i++) {
760             if ((i < pchr[j].p_nv) && (pchr[j].p_vamt[i] > 0)) {
761                 pr("%2d %c ", pchr[j].p_vamt[i],
762                    ichr[pchr[j].p_vtype[i] & (~VT_ITEM)].i_name[0]);
763             } else {
764                 pr("     ");
765             }
766         }
767         switch (pchr[j].p_nlndx) {
768         case NAT_TLEV:
769             tmpstr = "tech";
770             break;
771         case NAT_ELEV:
772             tmpstr = "edu";
773             break;
774         case NAT_RLEV:
775             tmpstr = "res";
776             break;
777         case NAT_HLEV:
778             tmpstr = "hap";
779             break;
780         default:
781             tmpstr = " ";
782             break;
783         }
784         if (pchr[j].p_type)
785             c = outputs[pchr[j].p_type - VT_ITEM];
786         else
787             c = ' ';
788         pr("%-5s %3d %3d %4d %3d %3d %c",
789            tmpstr,
790            pchr[j].p_nlmin,
791            pchr[j].p_nllag,
792            pchr[j].p_effic, pchr[j].p_cost, pchr[j].p_nrdep, c);
793
794         pr("\n");
795     }
796 }