2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2005, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
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.
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.
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
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.
28 * show.c: General show routines
30 * Known contributors to this file:
37 * general routines that are callable to give info on things.
38 * currently, planes, ships, nukes and bridges. Tanks & regiments one day?
40 * Added nuke_flags to be consistent. Jeff Bailey 12/15/90
41 * (bailey@mcs.kent.edu)
56 #include "prototypes.h"
65 } lookup_list[200]; /* Change this if there are ever more than 200 planes, ships
67 static int lookup_list_cnt = 0;
70 sort_lookup_list(void)
72 struct natstr *np = getnatp(player->cnum);
77 if (!(np->nat_flags & NF_TECHLISTS))
79 for (i = 0; i < lookup_list_cnt; i++) {
80 for (j = i; j < lookup_list_cnt; j++) {
81 if (lookup_list[j].tech < lookup_list[i].tech) {
83 lookup_list[j] = lookup_list[i];
91 make_new_list(int tlev, int type)
99 if (type == EF_PLANE) {
100 for (pp = plchr, count = 0; count < pln_maxno; count++, pp++) {
101 if (pp->pl_tech > tlev)
103 if (pp->pl_name == 0 || pp->pl_name[0] == '\0')
105 lookup_list[lookup_list_cnt].l_u.pp = pp;
106 lookup_list[lookup_list_cnt].tech = pp->pl_tech;
109 } else if (type == EF_SHIP) {
110 for (mp = mchr, count = 0; count < shp_maxno; count++, mp++) {
111 if (mp->m_tech > tlev)
113 if (mp->m_name == 0 || mp->m_name[0] == '\0')
115 lookup_list[lookup_list_cnt].l_u.mp = mp;
116 lookup_list[lookup_list_cnt].tech = mp->m_tech;
119 } else if (type == EF_LAND) {
120 for (lp = lchr, count = 0; count < lnd_maxno; count++, lp++) {
121 if (lp->l_tech > tlev)
123 if (lp->l_name == 0 || lp->l_name[0] == '\0')
125 lookup_list[lookup_list_cnt].l_u.lp = lp;
126 lookup_list[lookup_list_cnt].tech = lp->l_tech;
136 lookup(int key, struct lookup *table)
140 if ((match = intmatch(key, &table->key, sizeof(*table))) < 0)
142 return table[match].value;
146 show_bridge(int tlev)
150 pr("Bridges require %g tech,", buil_bt);
152 pr(" %d hcm,", buil_bh);
153 else if (!opt_NO_LCMS)
154 pr(" %d lcm,", buil_bh);
155 pr(" %d workers,\n", 0);
156 pr("%d available workforce, and cost $%g\n",
157 (SCT_BLD_WORK(0, buil_bh) * SCT_MINEFF + 99) / 100,
164 if (tlev < buil_tower_bt)
166 pr("Bridge Towers require %g tech,", buil_tower_bt);
168 pr(" %d hcm,", buil_tower_bh);
169 else if (!opt_NO_LCMS)
170 pr(" %d lcm,", buil_tower_bh);
171 pr(" %d workers,\n", 0);
172 pr("%d available workforce, and cost $%g\n",
173 (SCT_BLD_WORK(0, buil_tower_bh) * SCT_MINEFF + 99) / 100,
178 show_nuke_stats(int tlev)
180 show_nuke_capab(tlev);
184 show_nuke_build(int tlev)
191 pr("%13s lcm hcm oil rad avail tech res $\n", "");
193 pr("%13s lcm hcm oil rad avail tech $\n", "");
197 for (np = nchr, n = 0; n < N_MAXNUKE; np++, n++) {
198 avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
199 if (np->n_tech > tlev)
201 if (np->n_name == 0 || np->n_name[0] == '\0')
203 if (opt_NEUTRON == 0 && (np->n_flags & N_NEUT))
206 pr("%-13.13s %3d %3d %4d %4d %5d %4d %3d $%6d\n",
207 np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
208 np->n_rad, avail, np->n_tech,
209 (int)(np->n_tech * drnuke_const) + 1, np->n_cost);
210 else /* not DRNUKE */
211 pr("%-13.13s %3d %3d %4d %4d %5d %4d $%6d\n",
212 np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
213 np->n_rad, avail, np->n_tech, np->n_cost);
218 show_nuke_capab(int tlev)
225 pr("%13s blst dam lbs tech res $%7s abilities\n", "", "");
227 pr("%13s blst dam lbs tech $%7s abilities\n", "", "");
231 for (np = nchr, n = 0; n < N_MAXNUKE; np++, n++) {
232 if (np->n_tech > tlev)
234 if (opt_NEUTRON == 0 && (np->n_flags & N_NEUT))
236 if (np->n_name == 0 || np->n_name[0] == '\0')
239 pr("%-13.13s %4d %3d %3d %4d %3d $%7d ",
240 np->n_name, np->n_blast, np->n_dam,
241 np->n_weight, np->n_tech,
242 (int)(np->n_tech * drnuke_const) + 1, np->n_cost);
243 else /* not DRNUKE */
244 pr("%-13.13s %4d %3d %3d %4d $%7d ",
245 np->n_name, np->n_blast, np->n_dam,
246 np->n_weight, np->n_tech, np->n_cost);
248 for (i = j = 0; i < 32; i++) {
249 if (!(np->n_flags & bit(i)))
251 if (NULL != (p = lookup(bit(i), nuke_chr_flags))) {
262 show_ship_build(int tlev)
267 pr("%25s lcm hcm avail tech $\n", "");
268 make_new_list(tlev, EF_SHIP);
269 for (n = 0; n < lookup_list_cnt; n++) {
270 mp = (struct mchrstr *)lookup_list[n].l_u.mp;
271 /* Can't show trade ships unless it's turned on */
272 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
275 pr("%-25.25s %3d %3d %5d %4d $%d\n",
276 mp->m_name, mp->m_lcm, mp->m_hcm,
277 SHP_BLD_WORK(mp->m_lcm, mp->m_hcm), mp->m_tech, mp->m_cost);
282 show_ship_stats(int tlev)
288 pr("%25s s v s r f l p", "");
295 pr("%25s p i p n i n l", "");
302 pr("%25s def d s y g r d n", "");
310 make_new_list(tlev, EF_SHIP);
311 for (scount = 0; scount < lookup_list_cnt; scount++) {
312 mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
313 /* Can't show trade ships unless it's turned on */
314 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
317 techdiff = (int)(tlev - mp->m_tech);
318 pr("%-25.25s %3d %2d %2d %2d %2d %2d ",
320 (short)SHP_DEF(mp->m_armor, techdiff),
321 (short)SHP_SPD(mp->m_speed, techdiff),
322 (short)SHP_VIS(mp->m_visib, techdiff),
324 (short)SHP_RNG(mp->m_frnge, techdiff),
325 (short)SHP_FIR(mp->m_glim, techdiff));
327 pr("%2d ", mp->m_nland);
328 pr("%2d ", mp->m_nplanes);
329 pr("%2d ", mp->m_nchoppers);
330 pr("%2d ", mp->m_nxlight);
332 pr("%3d/%1d ", mp->m_fuelc, mp->m_fuelu);
338 show_ship_capab(int tlev)
347 pr("%25s cargos & capabilities\n", "");
349 make_new_list(tlev, EF_SHIP);
350 for (scount = 0; scount < lookup_list_cnt; scount++) {
351 mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
352 /* Can't show trade ships unless it's turned on */
353 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
356 pr("%-25.25s ", mp->m_name);
358 for (i = I_NONE + 1; i <= I_MAX; ++i)
360 pr(" %d%c", mp->m_item[i], ichr[i].i_mnem);
362 for (j = n = 0; j < 32; j++) {
363 if (!(mp->m_flags & bit(j)))
365 if (NULL != (p = lookup(bit(j), ship_chr_flags))) {
376 show_plane_stats(int tlev)
381 pr("%25s acc load att def ran fuel stlth\n", "");
382 make_new_list(tlev, EF_PLANE);
383 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
384 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
385 pr("%-25.25s %3d %4d %3d %3d %3d %4d ",
387 (int)PLN_ACC(pp->pl_acc, (int)(tlev - pp->pl_tech)),
388 (int)PLN_LOAD(pp->pl_load, (int)(tlev - pp->pl_tech)),
389 (int)PLN_ATTDEF(pp->pl_att, (int)(tlev - pp->pl_tech)),
390 (int)PLN_ATTDEF(pp->pl_def, (int)(tlev - pp->pl_tech)),
391 (int)PLN_RAN(pp->pl_range, (int)(tlev - pp->pl_tech)),
393 pr("%4d%% ", pp->pl_stealth);
399 show_plane_capab(int tlev)
407 pr("%25s capabilities\n", "");
408 make_new_list(tlev, EF_PLANE);
409 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
410 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
411 pr("%-25.25s ", pp->pl_name);
413 for (i = n = 0; i < 32; i++) {
414 if (!(pp->pl_flags & bit(i)))
416 if (NULL != (p = lookup(bit(i), plane_chr_flags))) {
427 show_plane_build(int tlev)
432 pr("%25s lcm hcm crew avail tech $\n", "");
433 make_new_list(tlev, EF_PLANE);
434 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
435 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
436 pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
437 pp->pl_name, pp->pl_lcm,
438 pp->pl_hcm, pp->pl_crew,
439 PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm), pp->pl_tech, pp->pl_cost);
444 show_land_build(int tlev)
449 pr("%25s lcm hcm guns avail tech $\n", "");
450 make_new_list(tlev, EF_LAND);
451 for (n = 0; n < lookup_list_cnt; n++) {
452 lp = (struct lchrstr *)lookup_list[n].l_u.lp;
453 if ((lp->l_flags & L_SPY) && !opt_LANDSPIES)
455 pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
456 lp->l_name, lp->l_lcm,
459 LND_BLD_WORK(lp->l_lcm, lp->l_hcm), lp->l_tech, lp->l_cost);
464 show_land_capab(int tlev)
472 pr("%25s capabilities\n", "");
474 make_new_list(tlev, EF_LAND);
475 for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
476 lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
477 if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
480 pr("%-25s ", lcp->l_name);
482 for (i = I_NONE + 1; i <= I_MAX; ++i)
484 pr(" %d%c", lcp->l_item[i], ichr[i].i_mnem);
486 for (j = n = 0; j < 32; j++) {
487 if (!(lcp->l_flags & bit(j)))
489 if (NULL != (p = lookup(bit(j), land_chr_flags))) {
500 show_land_stats(int tlev)
506 pr("%25s s v s r r a f a a x l\n", "");
507 pr("%25s p i p a n c i m a f f p n\n", "");
508 pr("%25s att def vul d s y d g c r m f c u l d\n", "");
510 make_new_list(tlev, EF_LAND);
511 for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
512 lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
513 if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
516 ourtlev = (int)(tlev - lcp->l_tech);
517 pr("%-25s %1.1f %1.1f %3d ",
518 lcp->l_name, (float)LND_ATTDEF(lcp->l_att, ourtlev),
519 (float)LND_ATTDEF(lcp->l_def, ourtlev),
520 (int)LND_VUL(lcp->l_vul, ourtlev));
521 pr("%2d %2d %2d %2d ",
522 (int)LND_SPD(lcp->l_spd, ourtlev),
523 (int)LND_VIS(lcp->l_vis, ourtlev),
524 (int)LND_SPY(lcp->l_spy, ourtlev),
525 (int)LND_RAD(lcp->l_rad, ourtlev));
526 pr("%2d %2d %2d %2d %2d ",
527 (int)LND_FRG(lcp->l_frg, ourtlev),
528 (int)LND_ACC(lcp->l_acc, ourtlev),
529 (int)LND_DAM(lcp->l_dam, ourtlev),
530 (int)LND_AMM(lcp->l_ammo, lcp->l_dam, ourtlev),
531 (int)LND_AAF(lcp->l_aaf, ourtlev));
532 pr("%2d %2d %2d %2d ",
533 (int)LND_FC(lcp->l_fuelc, ourtlev),
534 (int)LND_FU(lcp->l_fuelu, ourtlev),
535 (int)LND_XPL(lcp->l_nxlight, ourtlev),
536 (int)LND_MXL(lcp->l_mxland, ourtlev));
543 show_sect_build(int foo)
547 for (x = 0; x <= SCT_MAXDEF; x++) {
548 if (dchr[x].d_mnem == 0)
550 if (dchr[x].d_cost < 0)
552 if ((dchr[x].d_cost > 0) || (dchr[x].d_build != 1) ||
553 (dchr[x].d_lcms > 0) || (dchr[x].d_hcms > 0)) {
555 pr("sector type cost to des cost for 1%% eff lcms for 1%% hcms for 1%%\n");
558 pr("%-14c %-14d %-17d %-14d %d\n",
559 dchr[x].d_mnem, dchr[x].d_cost, dchr[x].d_build,
560 dchr[x].d_lcms, dchr[x].d_hcms);
564 pr("Infrastructure building - adding 1 point of efficiency costs:\n");
565 pr(" type lcms hcms mobility $$$$\n");
566 for (x = 0; intrchr[x].in_name; x++) {
567 pr("%-20s %4d %4d %8d %4d\n", intrchr[x].in_name,
568 intrchr[x].in_lcms, intrchr[x].in_hcms,
569 intrchr[x].in_mcost, intrchr[x].in_dcost);
574 show_sect_stats(int foo)
579 natp = getnatp(player->cnum);
580 for (x = 0; x <= SCT_MAXDEF; x++) {
581 if (dchr[x].d_mnem == 0)
584 pr(" base max max -- packing bonus -- max\n");
585 pr(" sector type mcost off def mil uw civ bar other pop\n");
588 pr("%c %-23s %3d %5.2f %5.2f %3d %3d %3d %3d %5d %5d\n",
589 dchr[x].d_mnem, dchr[x].d_name,
590 dchr[x].d_mcst, dchr[x].d_ostr,
592 ichr[I_MILIT].i_pkg[dchr[x].d_pkg],
593 ichr[I_UW].i_pkg[dchr[x].d_pkg],
594 ichr[I_CIVIL].i_pkg[dchr[x].d_pkg],
595 ichr[I_BAR].i_pkg[dchr[x].d_pkg],
596 ichr[I_LCM].i_pkg[dchr[x].d_pkg],
597 max_population(natp->nat_level[NAT_RLEV], x, 100));
602 show_sect_capab(int foo)
604 int x, first = 1, i, j;
607 for (x = 0; x <= SCT_MAXDEF; x++) {
608 if ((dchr[x].d_mnem == 0) || (dchr[x].d_prd == 0))
611 pr(" --- level --- reso \n");
612 pr(" sector type product use1 use2 use3 level min lag eff%% $$$ dep c\n");
618 pr("%c %-23s %-7s ", dchr[x].d_mnem, dchr[x].d_name,
620 (void)CANT_HAPPEN(MAXPRCON > 3); /* output has only three columns */
621 for (i = 0; i < 3; i++) {
624 && pchr[j].p_ctype[i] > I_NONE
625 && pchr[j].p_ctype[i] <= I_MAX) {
626 pr("%2d %c ", pchr[j].p_camt[i],
627 ichr[pchr[j].p_ctype[i]].i_name[0]);
632 switch (pchr[j].p_nlndx) {
649 pr("%-5s %3d %3d %4d %3d %3d %c",
653 pchr[j].p_effic, pchr[j].p_cost, pchr[j].p_nrdep,
654 pchr[j].p_type != I_NONE ? ichr[pchr[j].p_type].i_mnem : ' ');