]> git.pond.sub.org Git - empserver/blob - src/lib/subs/show.c
(show, show_item): No new `show' features without matching machine
[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 void
175 make_new_list(int tlev, int type)
176 {
177     struct plchrstr *pp;
178     struct lchrstr *lp;
179     struct mchrstr *mp;
180     int count;
181
182     lookup_list_cnt = 0;
183     if (type == EF_PLANE) {
184         for (pp = plchr, count = 0; count < pln_maxno; count++, pp++) {
185             if (pp->pl_tech > tlev)
186                 continue;
187             if (pp->pl_name == 0 || pp->pl_name[0] == '\0')
188                 continue;
189             lookup_list[lookup_list_cnt].l_u.pp = pp;
190             lookup_list[lookup_list_cnt].tech = pp->pl_tech;
191             lookup_list_cnt++;
192         }
193     } else if (type == EF_SHIP) {
194         for (mp = mchr, count = 0; count < shp_maxno; count++, mp++) {
195             if (mp->m_tech > tlev)
196                 continue;
197             if (mp->m_name == 0 || mp->m_name[0] == '\0')
198                 continue;
199             lookup_list[lookup_list_cnt].l_u.mp = mp;
200             lookup_list[lookup_list_cnt].tech = mp->m_tech;
201             lookup_list_cnt++;
202         }
203     } else if (type == EF_LAND) {
204         for (lp = lchr, count = 0; count < lnd_maxno; count++, lp++) {
205             if (lp->l_tech > tlev)
206                 continue;
207             if (lp->l_name == 0 || lp->l_name[0] == '\0')
208                 continue;
209             lookup_list[lookup_list_cnt].l_u.lp = lp;
210             lookup_list[lookup_list_cnt].tech = lp->l_tech;
211             lookup_list_cnt++;
212         }
213     } else
214         return;
215
216     sort_lookup_list();
217 }
218
219 static s_char *
220 lookup(int key, struct lookup *table)
221 {
222     int match;
223
224     if ((match = intmatch(key, &table->key, sizeof(*table))) < 0)
225         return 0;
226     return table[match].value;
227 }
228
229 void
230 show_bridge(int tlev)
231 {
232     extern double buil_bt, buil_bc;
233     extern int buil_bh;
234
235     if (tlev < buil_bt)
236         return;
237     pr("Bridges require %g tech,", buil_bt);
238     if (!opt_NO_HCMS)
239         pr(" %d hcm,", buil_bh);
240     else if (!opt_NO_LCMS)
241         pr(" %d lcm,", buil_bh);
242     pr(" %d workers,\n", buil_bh * 2);
243     pr("%d available workforce, and cost $%g\n",
244        1 + (buil_bh * 40 / 100), buil_bc);
245 }
246
247 void
248 show_tower(int tlev)
249 {
250     extern double buil_tower_bt, buil_tower_bc;
251     extern int buil_tower_bh;
252
253     if (tlev < buil_tower_bt)
254         return;
255     pr("Bridge Towers require %g tech,", buil_tower_bt);
256     if (!opt_NO_HCMS)
257         pr(" %d hcm,", buil_tower_bh);
258     else if (!opt_NO_LCMS)
259         pr(" %d lcm,", buil_tower_bh);
260     pr(" %d workers,\n", buil_tower_bh * 2);
261     pr("%d available workforce, and cost $%g\n",
262        1 + (buil_tower_bh * 40 / 100), buil_tower_bc);
263 }
264
265 void
266 show_nuke_stats(int tlev)
267 {
268     show_nuke_capab(tlev);
269 }
270
271 void
272 show_nuke_build(int tlev)
273 {
274     register struct nchrstr *np;
275     register int n;
276     register int avail;
277     extern float drnuke_const;
278
279     if (opt_DRNUKE)
280         pr("%13s lcm hcm  oil  rad avail tech res $\n", "");
281     else
282         pr("%13s lcm hcm  oil  rad avail tech $\n", "");
283
284     if (opt_NONUKES)
285         return;
286     for (np = nchr, n = 0; n < N_MAXNUKE; np++, n++) {
287         avail =
288             (4 + np->n_rad + np->n_oil + np->n_lcm + np->n_hcm * 2) / 5;
289         if (np->n_tech > tlev)
290             continue;
291         if (np->n_name == 0 || np->n_name[0] == '\0')
292             continue;
293         if (opt_NEUTRON == 0 && (np->n_flags & N_NEUT))
294             continue;
295         if (opt_DRNUKE)
296             pr("%-13.13s %3d %3d %4d %4d %5d %4d %3d $%6d\n",
297                np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
298                np->n_rad, avail, np->n_tech,
299                (int)(np->n_tech * drnuke_const) + 1, np->n_cost);
300         else                    /* not DRNUKE */
301             pr("%-13.13s %3d %3d %4d %4d %5d %4d $%6d\n",
302                np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
303                np->n_rad, avail, np->n_tech, np->n_cost);
304     }
305 }
306
307 void
308 show_nuke_capab(int tlev)
309 {
310     register struct nchrstr *np;
311     register int i, j, n;
312     s_char *p;
313     extern float drnuke_const;
314
315     if (opt_DRNUKE)
316         pr("%13s blst dam lbs tech res $%7s abilities\n", "", "");
317     else
318         pr("%13s blst dam lbs tech $%7s abilities\n", "", "");
319
320     if (opt_NONUKES)
321         return;
322     for (np = nchr, n = 0; n < N_MAXNUKE; np++, n++) {
323         if (np->n_tech > tlev)
324             continue;
325         if (opt_NEUTRON == 0 && (np->n_flags & N_NEUT))
326             continue;
327         if (np->n_name == 0 || np->n_name[0] == '\0')
328             continue;
329         if (opt_DRNUKE)
330             pr("%-13.13s %4d %3d %3d %4d %3d $%7d ",
331                np->n_name, np->n_blast, np->n_dam,
332                np->n_weight, np->n_tech,
333                (int)(np->n_tech * drnuke_const) + 1, np->n_cost);
334         else                    /* not DRNUKE */
335             pr("%-13.13s %4d %3d %3d %4d $%7d ",
336                np->n_name, np->n_blast, np->n_dam,
337                np->n_weight, np->n_tech, np->n_cost);
338
339         for (i = j = 0; i < 32; i++) {
340             if (!(np->n_flags & bit(i)))
341                 continue;
342             if (NULL != (p = lookup(bit(i), nuke_flags))) {
343                 if (j++ > 0)
344                     pr(" ");
345                 pr(p);
346             }
347         }
348         pr("\n");
349     }
350 }
351
352 void
353 show_ship_build(int tlev)
354 {
355     register struct mchrstr *mp;
356     register int n;
357
358     pr("%25s lcm hcm avail tech $\n", "");
359     make_new_list(tlev, EF_SHIP);
360     for (n = 0; n < lookup_list_cnt; n++) {
361         mp = (struct mchrstr *)lookup_list[n].l_u.mp;
362         /* Can't show trade ships unless it's turned on */
363         if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
364             continue;
365
366         pr("%-25.25s %3d %3d %5d %4d $%d\n",
367            mp->m_name, mp->m_lcm, mp->m_hcm,
368            20 + mp->m_lcm + mp->m_hcm * 2, mp->m_tech, mp->m_cost);
369     }
370 }
371
372 void
373 show_ship_stats(int tlev)
374 {
375     register struct mchrstr *mp;
376     int scount;
377     int techdiff;
378
379     pr("%25s      s  v  s  r  f  l  p", "");
380     pr("  h");
381     pr("  x");
382     if (opt_FUEL)
383         pr("  fuel");
384     pr("\n");
385
386     pr("%25s      p  i  p  n  i  n  l", "");
387     pr("  e");
388     pr("  p");
389     if (opt_FUEL)
390         pr("   c/u");
391     pr("\n");
392
393     pr("%25s def  d  s  y  g  r  d  n", "");
394     pr("  l");
395     pr("  l");
396     if (opt_FUEL)
397         pr("      ");
398     pr("\n");
399
400
401     make_new_list(tlev, EF_SHIP);
402     for (scount = 0; scount < lookup_list_cnt; scount++) {
403         mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
404         /* Can't show trade ships unless it's turned on */
405         if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
406             continue;
407
408         techdiff = (int)(tlev - mp->m_tech);
409         pr("%-25.25s %3d %2d %2d %2d %2d %2d ",
410            mp->m_name,
411            (short)SHP_DEF(mp->m_armor, techdiff),
412            (short)SHP_SPD(mp->m_speed, techdiff),
413            (short)SHP_VIS(mp->m_visib, techdiff),
414            mp->m_vrnge,
415            (short)SHP_RNG(mp->m_frnge, techdiff),
416            (short)SHP_FIR(mp->m_glim, techdiff));
417
418         pr("%2d ", mp->m_nland);
419         pr("%2d ", mp->m_nplanes);
420         pr("%2d ", mp->m_nchoppers);
421         pr("%2d ", mp->m_nxlight);
422         if (opt_FUEL)
423             pr("%3d/%1d ", mp->m_fuelc, mp->m_fuelu);
424         pr("\n");
425     }
426 }
427
428 void
429 show_ship_capab(int tlev)
430 {
431     register struct mchrstr *mp;
432     register u_short *ap;
433     register u_char *type;
434     register int i;
435     register int it;
436     int scount;
437     int n;
438     s_char c;
439     s_char *p;
440
441     pr("%25s cargos & capabilities\n", "");
442
443     make_new_list(tlev, EF_SHIP);
444     for (scount = 0; scount < lookup_list_cnt; scount++) {
445         mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
446         /* Can't show trade ships unless it's turned on */
447         if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
448             continue;
449
450         pr("%-25.25s ", mp->m_name);
451
452         /*
453          * should use vector stuff
454          */
455         for (ap = mp->m_vamt, type = mp->m_vtype, i = 0;
456              i < mp->m_nv; i++, ap++, type++) {
457             it = unitem((int)*type);
458             if (it > 0 && it <= I_MAX && ichr[it].i_name != 0)
459                 c = ichr[it].i_name[0];
460             else
461                 c = '?';
462             pr(" %d%c", *ap, c);
463         }
464         pr(" ");
465         for (i = n = 0; i < 32; i++) {
466             if (!(mp->m_flags & bit(i)))
467                 continue;
468             if (NULL != (p = lookup(bit(i), ship_flags))) {
469                 if (n++ > 0)
470                     pr(" ");
471                 pr(p);
472             }
473         }
474         pr("\n");
475     }
476 }
477
478 void
479 show_plane_stats(int tlev)
480 {
481     register struct plchrstr *pp;
482     int pcount;
483
484     pr("%25s acc load att def ran fuel stlth\n", "");
485     make_new_list(tlev, EF_PLANE);
486     for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
487         pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
488         pr("%-25.25s %3d %4d %3d %3d %3d %4d ",
489            pp->pl_name,
490            (int)PLN_ACC(pp->pl_acc, (int)(tlev - pp->pl_tech)),
491            (int)PLN_LOAD(pp->pl_load, (int)(tlev - pp->pl_tech)),
492            (int)PLN_ATTDEF(pp->pl_att, (int)(tlev - pp->pl_tech)),
493            (int)PLN_ATTDEF(pp->pl_def, (int)(tlev - pp->pl_tech)),
494            (int)PLN_RAN(pp->pl_range, (int)(tlev - pp->pl_tech)),
495            pp->pl_fuel);
496         pr("%4d%% ", pp->pl_stealth);
497         pr("\n");
498     }
499 }
500
501 void
502 show_plane_capab(int tlev)
503 {
504     register struct plchrstr *pp;
505     register int i;
506     int pcount;
507     int n;
508     s_char *p;
509
510     pr("%25s capabilities\n", "");
511     make_new_list(tlev, EF_PLANE);
512     for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
513         pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
514         pr("%-25.25s  ", pp->pl_name);
515
516         for (i = n = 0; i < 32; i++) {
517             if (!(pp->pl_flags & bit(i)))
518                 continue;
519             if (NULL != (p = lookup(bit(i), plane_flags))) {
520                 if (n++ > 0)
521                     pr(" ");
522                 pr(p);
523             }
524         }
525         pr("\n");
526     }
527 }
528
529 void
530 show_plane_build(int tlev)
531 {
532     register struct plchrstr *pp;
533     register int pcount;
534
535     pr("%25s lcm hcm crew avail tech  $\n", "");
536     make_new_list(tlev, EF_PLANE);
537     for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
538         pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
539         pr("%-25.25s %3d %3d %3d %5d %4d $%d\n",
540            pp->pl_name, pp->pl_lcm,
541            pp->pl_hcm, pp->pl_crew,
542            20 + 2 * pp->pl_hcm + pp->pl_lcm, pp->pl_tech, pp->pl_cost);
543     }
544 }
545
546 void
547 show_land_build(int tlev)
548 {
549     register struct lchrstr *lp;
550     register int n;
551
552     pr("%25s lcm hcm guns avail tech  $\n", "");
553     make_new_list(tlev, EF_LAND);
554     for (n = 0; n < lookup_list_cnt; n++) {
555         lp = (struct lchrstr *)lookup_list[n].l_u.lp;
556         if ((lp->l_flags & L_SPY) && !opt_LANDSPIES)
557             continue;
558         pr("%-25.25s %3d %3d %4d %5d %4d  $%d\n",
559            lp->l_name, lp->l_lcm,
560            lp->l_hcm,
561            lp->l_gun,
562            20 + lp->l_lcm + (lp->l_hcm * 2), lp->l_tech, lp->l_cost);
563     }
564 }
565
566 void
567 show_land_capab(int tlev)
568 {
569     struct lchrstr *lcp;
570     int lcount;
571     register u_short *ap;
572     register u_char *type;
573     register int i, n;
574     register int it;
575     register s_char *p, c;
576
577     pr("%25s capabilities\n", "");
578
579     make_new_list(tlev, EF_LAND);
580     for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
581         lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
582         if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
583             continue;
584
585         pr("%-25s ", lcp->l_name);
586
587         /*
588          * should use vector stuff
589          */
590         for (ap = lcp->l_vamt, type = lcp->l_vtype, i = 0;
591              i < lcp->l_nv; i++, ap++, type++) {
592             it = unitem((int)*type);
593             if (it > 0 && it <= I_MAX && ichr[it].i_name != 0)
594                 c = ichr[it].i_name[0];
595             else
596                 c = '?';
597             pr(" %d%c", *ap, c);
598         }
599         pr(" ");
600         for (i = n = 0; i < 32; i++) {
601             if (!(lcp->l_flags & bit(i)))
602                 continue;
603             if (NULL != (p = lookup(bit(i), land_flags))) {
604                 if (n++ > 0)
605                     pr(" ");
606                 pr(p);
607             }
608         }
609         pr("\n");
610     }
611 }
612
613 void
614 show_land_stats(int tlev)
615 {
616     struct lchrstr *lcp;
617     int lcount;
618     int ourtlev;
619
620     pr("%25s              s  v  s  r  r  a  f  a  a        x  l\n", "");
621     pr("%25s              p  i  p  a  n  c  i  m  a  f  f  p  n\n", "");
622     pr("%25s att def vul  d  s  y  d  g  c  r  m  f  c  u  l  d\n", "");
623
624     make_new_list(tlev, EF_LAND);
625     for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
626         lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
627         if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
628             continue;
629
630         ourtlev = (int)(tlev - lcp->l_tech);
631         pr("%-25s %1.1f %1.1f %3d ",
632            lcp->l_name, (float)LND_ATTDEF(lcp->l_att, ourtlev),
633            (float)LND_ATTDEF(lcp->l_def, ourtlev),
634            (int)LND_VUL(lcp->l_vul, ourtlev));
635         pr("%2d %2d %2d %2d ",
636            (int)LND_SPD(lcp->l_spd, ourtlev),
637            (int)LND_VIS(lcp->l_vis, ourtlev),
638            (int)LND_SPY(lcp->l_spy, ourtlev),
639            (int)LND_RAD(lcp->l_rad, ourtlev));
640         pr("%2d %2d %2d %2d %2d ",
641            (int)LND_FRG(lcp->l_frg, ourtlev),
642            (int)LND_ACC(lcp->l_acc, ourtlev),
643            (int)LND_DAM(lcp->l_dam, ourtlev),
644            (int)LND_AMM(lcp->l_ammo, lcp->l_dam, ourtlev),
645            (int)LND_AAF(lcp->l_aaf, ourtlev));
646         pr("%2d %2d %2d %2d ",
647            (int)LND_FC(lcp->l_fuelc, ourtlev),
648            (int)LND_FU(lcp->l_fuelu, ourtlev),
649            (int)LND_XPL(lcp->l_nxlight, ourtlev),
650            (int)LND_MXL(lcp->l_mxland, ourtlev));
651
652         pr("\n");
653     }
654 }
655
656 void
657 show_sect_build(int foo)
658 {
659     register int x, first = 1;
660
661     for (x = 5; x < SCT_MAXDEF + 2; x++) {
662         if (dchr[x].d_mnem == 0)
663             continue;
664         if ((dchr[x].d_cost > 0) || (dchr[x].d_build != 1) ||
665             (dchr[x].d_lcms > 0) || (dchr[x].d_hcms > 0)) {
666             if (first) {
667                 pr("sector type    cost to des    cost for 1%% eff   lcms for 1%%    hcms for 1%%\n");
668                 first = 0;
669             }
670             pr("%-14c %-14d %-17d %-14d %d\n",
671                dchr[x].d_mnem, dchr[x].d_cost, dchr[x].d_build,
672                dchr[x].d_lcms, dchr[x].d_hcms);
673         }
674     }
675     pr("\n");
676     pr("Infrastructure building - adding 1 point of efficiency costs:\n");
677     pr("       type          lcms    hcms    mobility    $$$$\n");
678     for (x = 0; intrchr[x].in_name; x++) {
679         pr("%-20s %4d    %4d    %8d    %4d\n", intrchr[x].in_name,
680            intrchr[x].in_lcms, intrchr[x].in_hcms,
681            intrchr[x].in_mcost, intrchr[x].in_dcost);
682     }
683 }
684
685 void
686 show_sect_stats(int foo)
687 {
688     register int x, first = 1;
689     struct sctstr sect;
690     struct natstr *natp;
691
692     natp = getnatp(player->cnum);
693     /* We fake this */
694     sect.sct_effic = 100;
695     for (x = 0; x < SCT_MAXDEF + 2; x++) {
696         if (dchr[x].d_mnem == 0)
697             continue;
698         if (first) {
699             pr("                        base     max   max   --  packing bonus  --   max\n");
700             pr("  sector type           mcost    off   def   mil  uw civ bar other   pop\n");
701             first = 0;
702         }
703         sect.sct_type = x;
704         pr("%c %-23s %3d  %5.2f %5.2f   %3d %3d %3d %3d %5d %5d\n",
705            dchr[x].d_mnem, dchr[x].d_name,
706            dchr[x].d_mcst, dchr[x].d_ostr,
707            dchr[x].d_dstr,
708            ichr[I_MILIT].i_pkg[dchr[x].d_pkg],
709            ichr[I_UW].i_pkg[dchr[x].d_pkg],
710            ichr[I_CIVIL].i_pkg[dchr[x].d_pkg],
711            ichr[I_BAR].i_pkg[dchr[x].d_pkg],
712            ichr[I_LCM].i_pkg[dchr[x].d_pkg],
713            max_pop(natp->nat_level[NAT_RLEV], &sect));
714     }
715 }
716
717 void
718 show_sect_capab(int foo)
719 {
720     register int x, first = 1, i, j;
721     char *tmpstr;
722     char c;
723     char *outputs = " cmsgpidbfolhur";
724
725     for (x = 0; x < SCT_MAXDEF + 2; x++) {
726         if ((dchr[x].d_mnem == 0) || (dchr[x].d_prd == 0))
727             continue;
728         if (first) {
729             pr("                                                 --- level ---          reso \n");
730             pr("  sector type             product use1 use2 use3 level min lag eff%% $$$ dep c\n");
731             first = 0;
732         }
733
734         j = dchr[x].d_prd;
735
736         pr("%c %-23s %-7s ", dchr[x].d_mnem, dchr[x].d_name,
737            pchr[j].p_sname);
738         /*for(i=0;i<MAXCHRNV;i++) */
739         /* XXX currently no more than 3 items actually used */
740         for (i = 0; i < 3; i++) {
741             if ((i < pchr[j].p_nv) && (pchr[j].p_vamt[i] > 0)) {
742                 pr("%2d %c ", pchr[j].p_vamt[i],
743                    ichr[pchr[j].p_vtype[i] & (~VT_ITEM)].i_name[0]);
744             } else {
745                 pr("     ");
746             }
747         }
748         switch (pchr[j].p_nlndx) {
749         case NAT_TLEV:
750             tmpstr = "tech";
751             break;
752         case NAT_ELEV:
753             tmpstr = "edu";
754             break;
755         case NAT_RLEV:
756             tmpstr = "res";
757             break;
758         case NAT_HLEV:
759             tmpstr = "hap";
760             break;
761         default:
762             tmpstr = " ";
763             break;
764         }
765         if (pchr[j].p_type)
766             c = outputs[pchr[j].p_type - VT_ITEM];
767         else
768             c = ' ';
769         pr("%-5s %3d %3d %4d %3d %3d %c",
770            tmpstr,
771            pchr[j].p_nlmin,
772            pchr[j].p_nllag,
773            pchr[j].p_effic, pchr[j].p_cost, pchr[j].p_nrdep, c);
774
775         pr("\n");
776     }
777 }