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)
98 if (type == EF_PLANE) {
99 for (pp = plchr; pp->pl_name; pp++) {
100 if (pp->pl_tech > tlev)
102 lookup_list[lookup_list_cnt].l_u.pp = pp;
103 lookup_list[lookup_list_cnt].tech = pp->pl_tech;
106 } else if (type == EF_SHIP) {
107 for (mp = mchr; mp->m_name; mp++) {
108 if (mp->m_tech > tlev)
110 lookup_list[lookup_list_cnt].l_u.mp = mp;
111 lookup_list[lookup_list_cnt].tech = mp->m_tech;
114 } else if (type == EF_LAND) {
115 for (lp = lchr; lp->l_name; lp++) {
116 if (lp->l_tech > tlev)
118 lookup_list[lookup_list_cnt].l_u.lp = lp;
119 lookup_list[lookup_list_cnt].tech = lp->l_tech;
129 lookup(int key, struct symbol *table)
133 for (i = 0; table[i].name; i++)
134 if (key == table[i].value)
135 return table[i].name;
141 show_bridge(int tlev)
145 pr("Bridges require %g tech,", buil_bt);
147 pr(" %d hcm,", buil_bh);
148 else if (!opt_NO_LCMS)
149 pr(" %d lcm,", buil_bh);
150 pr(" %d workers,\n", 0);
151 pr("%d available workforce, and cost $%g\n",
152 (SCT_BLD_WORK(0, buil_bh) * SCT_MINEFF + 99) / 100,
159 if (tlev < buil_tower_bt)
161 pr("Bridge Towers require %g tech,", buil_tower_bt);
163 pr(" %d hcm,", buil_tower_bh);
164 else if (!opt_NO_LCMS)
165 pr(" %d lcm,", buil_tower_bh);
166 pr(" %d workers,\n", 0);
167 pr("%d available workforce, and cost $%g\n",
168 (SCT_BLD_WORK(0, buil_tower_bh) * SCT_MINEFF + 99) / 100,
173 show_nuke_stats(int tlev)
175 show_nuke_capab(tlev);
179 show_nuke_build(int tlev)
185 pr("%13s lcm hcm oil rad avail tech res $\n", "");
187 pr("%13s lcm hcm oil rad avail tech $\n", "");
189 for (np = nchr; np->n_name; np++) {
190 avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
191 if (np->n_tech > tlev)
194 pr("%-13.13s %3d %3d %4d %4d %5d %4d %3d $%6d\n",
195 np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
196 np->n_rad, avail, np->n_tech,
197 (int)(np->n_tech * drnuke_const) + 1, np->n_cost);
199 pr("%-13.13s %3d %3d %4d %4d %5d %4d $%6d\n",
200 np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
201 np->n_rad, avail, np->n_tech, np->n_cost);
206 show_nuke_capab(int tlev)
213 pr("%13s blst dam lbs tech res $%7s abilities\n", "", "");
215 pr("%13s blst dam lbs tech $%7s abilities\n", "", "");
217 for (np = nchr; np->n_name; np++) {
218 if (np->n_tech > tlev)
221 pr("%-13.13s %4d %3d %3d %4d %3d $%7d ",
222 np->n_name, np->n_blast, np->n_dam,
223 np->n_weight, np->n_tech,
224 (int)(np->n_tech * drnuke_const) + 1, np->n_cost);
225 else /* not DRNUKE */
226 pr("%-13.13s %4d %3d %3d %4d $%7d ",
227 np->n_name, np->n_blast, np->n_dam,
228 np->n_weight, np->n_tech, np->n_cost);
230 for (i = j = 0; i < 32; i++) {
231 if (!(np->n_flags & bit(i)))
233 if (NULL != (p = lookup(bit(i), nuke_chr_flags))) {
244 show_ship_build(int tlev)
249 pr("%25s lcm hcm avail tech $\n", "");
250 make_new_list(tlev, EF_SHIP);
251 for (n = 0; n < lookup_list_cnt; n++) {
252 mp = (struct mchrstr *)lookup_list[n].l_u.mp;
253 /* Can't show trade ships unless it's turned on */
254 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
257 pr("%-25.25s %3d %3d %5d %4d $%d\n",
258 mp->m_name, mp->m_lcm, mp->m_hcm,
259 SHP_BLD_WORK(mp->m_lcm, mp->m_hcm), mp->m_tech, mp->m_cost);
264 show_ship_stats(int tlev)
270 pr("%25s s v s r f l p", "");
277 pr("%25s p i p n i n l", "");
284 pr("%25s def d s y g r d n", "");
292 make_new_list(tlev, EF_SHIP);
293 for (scount = 0; scount < lookup_list_cnt; scount++) {
294 mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
295 /* Can't show trade ships unless it's turned on */
296 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
299 techdiff = (int)(tlev - mp->m_tech);
300 pr("%-25.25s %3d %2d %2d %2d %2d %2d ",
302 (short)SHP_DEF(mp->m_armor, techdiff),
303 (short)SHP_SPD(mp->m_speed, techdiff),
304 (short)SHP_VIS(mp->m_visib, techdiff),
306 (short)SHP_RNG(mp->m_frnge, techdiff),
307 (short)SHP_FIR(mp->m_glim, techdiff));
309 pr("%2d ", mp->m_nland);
310 pr("%2d ", mp->m_nplanes);
311 pr("%2d ", mp->m_nchoppers);
312 pr("%2d ", mp->m_nxlight);
314 pr("%3d/%1d ", mp->m_fuelc, mp->m_fuelu);
320 show_ship_capab(int tlev)
329 pr("%25s cargos & capabilities\n", "");
331 make_new_list(tlev, EF_SHIP);
332 for (scount = 0; scount < lookup_list_cnt; scount++) {
333 mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
334 /* Can't show trade ships unless it's turned on */
335 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
338 pr("%-25.25s ", mp->m_name);
340 for (i = I_NONE + 1; i <= I_MAX; ++i)
342 pr(" %d%c", mp->m_item[i], ichr[i].i_mnem);
344 for (j = n = 0; j < 32; j++) {
345 if (!(mp->m_flags & bit(j)))
347 if (NULL != (p = lookup(bit(j), ship_chr_flags))) {
358 show_plane_stats(int tlev)
363 pr("%25s acc load att def ran fuel stlth\n", "");
364 make_new_list(tlev, EF_PLANE);
365 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
366 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
367 pr("%-25.25s %3d %4d %3d %3d %3d %4d ",
369 (int)PLN_ACC(pp->pl_acc, (int)(tlev - pp->pl_tech)),
370 (int)PLN_LOAD(pp->pl_load, (int)(tlev - pp->pl_tech)),
371 (int)PLN_ATTDEF(pp->pl_att, (int)(tlev - pp->pl_tech)),
372 (int)PLN_ATTDEF(pp->pl_def, (int)(tlev - pp->pl_tech)),
373 (int)PLN_RAN(pp->pl_range, (int)(tlev - pp->pl_tech)),
375 pr("%4d%% ", pp->pl_stealth);
381 show_plane_capab(int tlev)
389 pr("%25s capabilities\n", "");
390 make_new_list(tlev, EF_PLANE);
391 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
392 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
393 pr("%-25.25s ", pp->pl_name);
395 for (i = n = 0; i < 32; i++) {
396 if (!(pp->pl_flags & bit(i)))
398 if (NULL != (p = lookup(bit(i), plane_chr_flags))) {
409 show_plane_build(int tlev)
414 pr("%25s lcm hcm crew avail tech $\n", "");
415 make_new_list(tlev, EF_PLANE);
416 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
417 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
418 pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
419 pp->pl_name, pp->pl_lcm,
420 pp->pl_hcm, pp->pl_crew,
421 PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm), pp->pl_tech, pp->pl_cost);
426 show_land_build(int tlev)
431 pr("%25s lcm hcm guns avail tech $\n", "");
432 make_new_list(tlev, EF_LAND);
433 for (n = 0; n < lookup_list_cnt; n++) {
434 lp = (struct lchrstr *)lookup_list[n].l_u.lp;
435 if ((lp->l_flags & L_SPY) && !opt_LANDSPIES)
437 pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
438 lp->l_name, lp->l_lcm,
441 LND_BLD_WORK(lp->l_lcm, lp->l_hcm), lp->l_tech, lp->l_cost);
446 show_land_capab(int tlev)
454 pr("%25s capabilities\n", "");
456 make_new_list(tlev, EF_LAND);
457 for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
458 lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
459 if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
462 pr("%-25s ", lcp->l_name);
464 for (i = I_NONE + 1; i <= I_MAX; ++i)
466 pr(" %d%c", lcp->l_item[i], ichr[i].i_mnem);
468 for (j = n = 0; j < 32; j++) {
469 if (!(lcp->l_flags & bit(j)))
471 if (NULL != (p = lookup(bit(j), land_chr_flags))) {
482 show_land_stats(int tlev)
488 pr("%25s s v s r r a f a a x l\n", "");
489 pr("%25s p i p a n c i m a f f p n\n", "");
490 pr("%25s att def vul d s y d g c r m f c u l d\n", "");
492 make_new_list(tlev, EF_LAND);
493 for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
494 lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
495 if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
498 ourtlev = (int)(tlev - lcp->l_tech);
499 pr("%-25s %1.1f %1.1f %3d ",
500 lcp->l_name, (float)LND_ATTDEF(lcp->l_att, ourtlev),
501 (float)LND_ATTDEF(lcp->l_def, ourtlev),
502 (int)LND_VUL(lcp->l_vul, ourtlev));
503 pr("%2d %2d %2d %2d ",
504 (int)LND_SPD(lcp->l_spd, ourtlev),
505 (int)LND_VIS(lcp->l_vis, ourtlev),
506 (int)LND_SPY(lcp->l_spy, ourtlev),
507 (int)LND_RAD(lcp->l_rad, ourtlev));
508 pr("%2d %2d %2d %2d %2d ",
509 (int)LND_FRG(lcp->l_frg, ourtlev),
510 (int)LND_ACC(lcp->l_acc, ourtlev),
511 (int)LND_DAM(lcp->l_dam, ourtlev),
512 (int)LND_AMM(lcp->l_ammo, lcp->l_dam, ourtlev),
513 (int)LND_AAF(lcp->l_aaf, ourtlev));
514 pr("%2d %2d %2d %2d ",
515 (int)LND_FC(lcp->l_fuelc, ourtlev),
516 (int)LND_FU(lcp->l_fuelu, ourtlev),
517 (int)LND_XPL(lcp->l_nxlight, ourtlev),
518 (int)LND_MXL(lcp->l_mxland, ourtlev));
525 show_sect_build(int foo)
529 for (x = 0; x <= SCT_MAXDEF; x++) {
530 if (dchr[x].d_mnem == 0)
532 if (dchr[x].d_cost < 0)
534 if ((dchr[x].d_cost > 0) || (dchr[x].d_build != 1) ||
535 (dchr[x].d_lcms > 0) || (dchr[x].d_hcms > 0)) {
537 pr("sector type cost to des cost for 1%% eff lcms for 1%% hcms for 1%%\n");
540 pr("%-14c %-14d %-17d %-14d %d\n",
541 dchr[x].d_mnem, dchr[x].d_cost, dchr[x].d_build,
542 dchr[x].d_lcms, dchr[x].d_hcms);
546 pr("Infrastructure building - adding 1 point of efficiency costs:\n");
547 pr(" type lcms hcms mobility $$$$\n");
548 for (x = 0; intrchr[x].in_name; x++) {
549 pr("%-20s %4d %4d %8d %4d\n", intrchr[x].in_name,
550 intrchr[x].in_lcms, intrchr[x].in_hcms,
551 intrchr[x].in_mcost, intrchr[x].in_dcost);
556 show_sect_stats(int foo)
561 natp = getnatp(player->cnum);
562 for (x = 0; x <= SCT_MAXDEF; x++) {
563 if (dchr[x].d_mnem == 0)
566 pr(" base max max -- packing bonus -- max\n");
567 pr(" sector type mcost off def mil uw civ bar other pop\n");
570 pr("%c %-23s %3d %5.2f %5.2f %3d %3d %3d %3d %5d %5d\n",
571 dchr[x].d_mnem, dchr[x].d_name,
572 dchr[x].d_mcst, dchr[x].d_ostr,
574 ichr[I_MILIT].i_pkg[dchr[x].d_pkg],
575 ichr[I_UW].i_pkg[dchr[x].d_pkg],
576 ichr[I_CIVIL].i_pkg[dchr[x].d_pkg],
577 ichr[I_BAR].i_pkg[dchr[x].d_pkg],
578 ichr[I_LCM].i_pkg[dchr[x].d_pkg],
579 max_population(natp->nat_level[NAT_RLEV], x, 100));
584 show_sect_capab(int foo)
586 int x, first = 1, i, j;
589 for (x = 0; x <= SCT_MAXDEF; x++) {
590 if ((dchr[x].d_mnem == 0) || (dchr[x].d_prd == 0))
593 pr(" --- level --- reso \n");
594 pr(" sector type product use1 use2 use3 level min lag eff%% $$$ dep c\n");
600 pr("%c %-23s %-7s ", dchr[x].d_mnem, dchr[x].d_name,
602 (void)CANT_HAPPEN(MAXPRCON > 3); /* output has only three columns */
603 for (i = 0; i < 3; i++) {
606 && pchr[j].p_ctype[i] > I_NONE
607 && pchr[j].p_ctype[i] <= I_MAX) {
608 pr("%2d %c ", pchr[j].p_camt[i],
609 ichr[pchr[j].p_ctype[i]].i_name[0]);
614 switch (pchr[j].p_nlndx) {
631 pr("%-5s %3d %3d %4d %3d %3d %c",
635 pchr[j].p_effic, pchr[j].p_cost, pchr[j].p_nrdep,
636 pchr[j].p_type != I_NONE ? ichr[pchr[j].p_type].i_mnem : ' ');