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