2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2006, 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 files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future projects/authors will amend these files as needed.
28 * show.c: General show routines
30 * Known contributors to this file:
34 * Ron Koenderink, 2005
35 * Markus Armbruster, 2006
52 #include "prototypes.h"
66 * Change this if there are ever more than 200 ships, plane or land
69 static struct look_list lookup_list[200];
70 static int lookup_list_cnt = 0;
73 sort_lookup_list(void)
75 struct natstr *np = getnatp(player->cnum);
80 if (!(np->nat_flags & NF_TECHLISTS))
82 for (i = 0; i < lookup_list_cnt; i++) {
83 for (j = i; j < lookup_list_cnt; j++) {
84 if (lookup_list[j].tech < lookup_list[i].tech) {
86 lookup_list[j] = lookup_list[i];
94 make_new_list(int tlev, int type)
101 if (type == EF_PLANE) {
102 for (pp = plchr; pp->pl_name; pp++) {
103 if (pp->pl_tech > tlev)
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; mp->m_name; mp++) {
111 if (mp->m_tech > tlev)
113 lookup_list[lookup_list_cnt].l_u.mp = mp;
114 lookup_list[lookup_list_cnt].tech = mp->m_tech;
117 } else if (type == EF_LAND) {
118 for (lp = lchr; lp->l_name; lp++) {
119 if (lp->l_tech > tlev)
121 lookup_list[lookup_list_cnt].l_u.lp = lp;
122 lookup_list[lookup_list_cnt].tech = lp->l_tech;
132 show_bridge(int tlev)
136 pr("Bridges require %g tech,", buil_bt);
137 pr(" %d hcm,", buil_bh);
138 pr(" %d workers,\n", 0);
139 pr("%d available workforce, and cost $%g\n",
140 (SCT_BLD_WORK(0, buil_bh) * SCT_MINEFF + 99) / 100,
147 if (tlev < buil_tower_bt)
149 pr("Bridge Towers require %g tech,", buil_tower_bt);
150 pr(" %d hcm,", buil_tower_bh);
151 pr(" %d workers,\n", 0);
152 pr("%d available workforce, and cost $%g\n",
153 (SCT_BLD_WORK(0, buil_tower_bh) * SCT_MINEFF + 99) / 100,
158 show_nuke_stats(int tlev)
160 show_nuke_capab(tlev);
164 show_nuke_build(int tlev)
169 pr("%13s lcm hcm oil rad avail tech res $\n", "");
171 for (np = nchr; np->n_name; np++) {
172 avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
173 if (np->n_tech > tlev)
175 pr("%-13.13s %3d %3d %4d %4d %5d %4d %3.0f $%6d\n",
176 np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
177 np->n_rad, avail, np->n_tech,
178 drnuke_const > MIN_DRNUKE_CONST ?
179 (np->n_tech * drnuke_const) + 1.0 : 0.0,
185 show_nuke_capab(int tlev)
191 pr("%13s blst dam lbs tech res $%7s abilities\n", "", "");
193 for (np = nchr; np->n_name; np++) {
194 if (np->n_tech > tlev)
196 pr("%-13.13s %4d %3d %3d %4d %3.0f $%7d ",
197 np->n_name, np->n_blast, np->n_dam,
198 np->n_weight, np->n_tech,
199 drnuke_const > MIN_DRNUKE_CONST ?
200 (np->n_tech * drnuke_const) + 1.0 : 0.0,
202 for (i = j = 0; i < 32; i++) {
203 if (!(np->n_flags & bit(i)))
205 if (NULL != (p = symbol_by_value(bit(i), nuke_chr_flags))) {
216 show_ship_build(int tlev)
221 pr("%25s lcm hcm avail tech $\n", "");
222 make_new_list(tlev, EF_SHIP);
223 for (n = 0; n < lookup_list_cnt; n++) {
224 mp = (struct mchrstr *)lookup_list[n].l_u.mp;
225 /* Can't show trade ships unless it's turned on */
226 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
229 pr("%-25.25s %3d %3d %5d %4d $%d\n",
230 mp->m_name, mp->m_lcm, mp->m_hcm,
231 SHP_BLD_WORK(mp->m_lcm, mp->m_hcm), mp->m_tech, mp->m_cost);
236 show_ship_stats(int tlev)
242 pr("%25s s v s r f l p", "");
249 pr("%25s p i p n i n l", "");
256 pr("%25s def d s y g r d n", "");
264 make_new_list(tlev, EF_SHIP);
265 for (scount = 0; scount < lookup_list_cnt; scount++) {
266 mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
267 /* Can't show trade ships unless it's turned on */
268 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
271 techdiff = (int)(tlev - mp->m_tech);
272 pr("%-25.25s %3d %2d %2d %2d %2d %2d ",
274 (short)SHP_DEF(mp->m_armor, techdiff),
275 (short)SHP_SPD(mp->m_speed, techdiff),
276 (short)SHP_VIS(mp->m_visib, techdiff),
278 (short)SHP_RNG(mp->m_frnge, techdiff),
279 (short)SHP_FIR(mp->m_glim, techdiff));
281 pr("%2d ", mp->m_nland);
282 pr("%2d ", mp->m_nplanes);
283 pr("%2d ", mp->m_nchoppers);
284 pr("%2d ", mp->m_nxlight);
286 pr("%3d/%1d ", mp->m_fuelc, mp->m_fuelu);
292 show_ship_capab(int tlev)
301 pr("%25s cargos & capabilities\n", "");
303 make_new_list(tlev, EF_SHIP);
304 for (scount = 0; scount < lookup_list_cnt; scount++) {
305 mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
306 /* Can't show trade ships unless it's turned on */
307 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
310 pr("%-25.25s ", mp->m_name);
312 for (i = I_NONE + 1; i <= I_MAX; ++i)
314 pr(" %d%c", mp->m_item[i], ichr[i].i_mnem);
316 for (j = n = 0; j < 32; j++) {
317 if (!(mp->m_flags & bit(j)))
319 if (NULL != (p = symbol_by_value(bit(j), ship_chr_flags))) {
330 show_plane_stats(int tlev)
335 pr("%25s acc load att def ran fuel stlth\n", "");
336 make_new_list(tlev, EF_PLANE);
337 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
338 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
339 pr("%-25.25s %3d %4d %3d %3d %3d %4d ",
341 (int)PLN_ACC(pp->pl_acc, (int)(tlev - pp->pl_tech)),
342 (int)PLN_LOAD(pp->pl_load, (int)(tlev - pp->pl_tech)),
343 (int)PLN_ATTDEF(pp->pl_att, (int)(tlev - pp->pl_tech)),
344 (int)PLN_ATTDEF(pp->pl_def, (int)(tlev - pp->pl_tech)),
345 (int)PLN_RAN(pp->pl_range, (int)(tlev - pp->pl_tech)),
347 pr("%4d%% ", pp->pl_stealth);
353 show_plane_capab(int tlev)
361 pr("%25s capabilities\n", "");
362 make_new_list(tlev, EF_PLANE);
363 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
364 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
365 pr("%-25.25s ", pp->pl_name);
367 for (i = n = 0; i < 32; i++) {
368 if (!(pp->pl_flags & bit(i)))
370 if (NULL != (p = symbol_by_value(bit(i), plane_chr_flags))) {
381 show_plane_build(int tlev)
386 pr("%25s lcm hcm crew avail tech $\n", "");
387 make_new_list(tlev, EF_PLANE);
388 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
389 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
390 pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
391 pp->pl_name, pp->pl_lcm,
392 pp->pl_hcm, pp->pl_crew,
393 PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm), pp->pl_tech, pp->pl_cost);
398 show_land_build(int tlev)
403 pr("%25s lcm hcm guns avail tech $\n", "");
404 make_new_list(tlev, EF_LAND);
405 for (n = 0; n < lookup_list_cnt; n++) {
406 lp = (struct lchrstr *)lookup_list[n].l_u.lp;
407 if ((lp->l_flags & L_SPY) && !opt_LANDSPIES)
409 pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
410 lp->l_name, lp->l_lcm,
413 LND_BLD_WORK(lp->l_lcm, lp->l_hcm), lp->l_tech, lp->l_cost);
418 show_land_capab(int tlev)
426 pr("%25s capabilities\n", "");
428 make_new_list(tlev, EF_LAND);
429 for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
430 lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
431 if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
434 pr("%-25s ", lcp->l_name);
436 for (i = I_NONE + 1; i <= I_MAX; ++i)
438 pr(" %d%c", lcp->l_item[i], ichr[i].i_mnem);
440 for (j = n = 0; j < 32; j++) {
441 if (!(lcp->l_flags & bit(j)))
443 if (NULL != (p = symbol_by_value(bit(j), land_chr_flags))) {
454 show_land_stats(int tlev)
460 pr("%25s s v s r r a f a a x l\n", "");
461 pr("%25s p i p a n c i m a f f p n\n", "");
462 pr("%25s att def vul d s y d g c r m f c u l d\n", "");
464 make_new_list(tlev, EF_LAND);
465 for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
466 lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
467 if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
470 ourtlev = (int)(tlev - lcp->l_tech);
471 pr("%-25s %1.1f %1.1f %3d ",
473 LND_ATTDEF(lcp->l_att, ourtlev),
474 LND_ATTDEF(lcp->l_def, ourtlev),
475 (int)LND_VUL(lcp->l_vul, ourtlev));
476 pr("%2d %2d %2d %2d ",
477 (int)LND_SPD(lcp->l_spd, ourtlev),
478 (int)LND_VIS(lcp->l_vis, ourtlev),
479 (int)LND_SPY(lcp->l_spy, ourtlev),
480 (int)LND_RAD(lcp->l_rad, ourtlev));
481 pr("%2d %2d %2d %2d %2d ",
482 (int)LND_FRG(lcp->l_frg, ourtlev),
483 (int)LND_ACC(lcp->l_acc, ourtlev),
484 (int)LND_DAM(lcp->l_dam, ourtlev),
485 (int)LND_AMM(lcp->l_ammo, ourtlev),
486 (int)LND_AAF(lcp->l_aaf, ourtlev));
487 pr("%2d %2d %2d %2d ",
488 (int)LND_FC(lcp->l_fuelc, ourtlev),
489 (int)LND_FU(lcp->l_fuelu, ourtlev),
490 (int)LND_XPL(lcp->l_nxlight, ourtlev),
491 (int)LND_MXL(lcp->l_nland, ourtlev));
498 show_sect_build(int foo)
503 for (x = 0; dchr[x].d_name; x++) {
504 if (dchr[x].d_mnem == 0)
506 if (dchr[x].d_cost < 0)
508 if ((dchr[x].d_cost > 0) || (dchr[x].d_build != 1) ||
509 (dchr[x].d_lcms > 0) || (dchr[x].d_hcms > 0)) {
511 pr("sector type cost to des cost for 1%% eff lcms for 1%% hcms for 1%%\n");
514 pr("%-14c %-14d %-17d %-14d %d\n",
515 dchr[x].d_mnem, dchr[x].d_cost, dchr[x].d_build,
516 dchr[x].d_lcms, dchr[x].d_hcms);
521 for (x = 0; intrchr[x].in_name; x++) {
522 if (!intrchr[x].in_enable)
525 pr("\nInfrastructure building - adding 1 point of efficiency costs:\n"
526 " type lcms hcms mobility $$$$\n");
527 pr("%-20s %4d %4d %8d %4d\n",
528 intrchr[x].in_name, intrchr[x].in_lcms, intrchr[x].in_hcms,
529 intrchr[x].in_mcost, intrchr[x].in_dcost);
535 show_sect_stats(int foo)
540 natp = getnatp(player->cnum);
541 for (x = 0; dchr[x].d_name; x++) {
542 if (dchr[x].d_mnem == 0)
545 pr(" mob cost max max -- packing bonus -- max\n");
546 pr(" sector type 0%% 100%% off def mil uw civ bar other pop\n");
549 pr("%c %-21.21s", dchr[x].d_mnem, dchr[x].d_name);
550 if (dchr[x].d_mob0 < 0)
553 pr(" %3.1f %3.1f", dchr[x].d_mob0, dchr[x].d_mob1);
554 pr(" %5.2f %5.2f %3d %3d %3d %3d %5d %5d\n",
555 dchr[x].d_ostr, dchr[x].d_dstr,
556 ichr[I_MILIT].i_pkg[dchr[x].d_pkg],
557 ichr[I_UW].i_pkg[dchr[x].d_pkg],
558 ichr[I_CIVIL].i_pkg[dchr[x].d_pkg],
559 ichr[I_BAR].i_pkg[dchr[x].d_pkg],
560 ichr[I_LCM].i_pkg[dchr[x].d_pkg],
561 max_population(natp->nat_level[NAT_RLEV], x, 100));
566 show_sect_capab(int foo)
568 int x, first = 1, i, j;
571 for (x = 0; dchr[x].d_name; x++) {
572 if (dchr[x].d_mnem == 0 || dchr[x].d_prd < 0)
575 pr(" --- level --- reso \n");
576 pr(" sector type product use1 use2 use3 level min lag eff%% $$$ dep c\n");
583 dchr[x].d_mnem, dchr[x].d_name, pchr[j].p_sname);
584 (void)CANT_HAPPEN(MAXPRCON > 3); /* output has only three columns */
585 for (i = 0; i < 3; i++) {
588 && pchr[j].p_ctype[i] > I_NONE
589 && pchr[j].p_ctype[i] <= I_MAX) {
590 pr("%2d %c ", pchr[j].p_camt[i],
591 ichr[pchr[j].p_ctype[i]].i_name[0]);
596 switch (pchr[j].p_nlndx) {
613 pr("%-5s %3d %3d %4d %3d %3d %c",
617 dchr[x].d_peffic, pchr[j].p_cost, pchr[j].p_nrdep,
618 pchr[j].p_type != I_NONE ? ichr[pchr[j].p_type].i_mnem : ' ');
629 pr("item value sell lbs packing melt item\n");
630 pr("mnem in rg wh ur bk deno name\n");
632 for (ip = ichr; ip->i_name; ip++) {
633 pr(" %c %5d %4s %3d %2d %2d %2d %2d %2d %4d %s\n",
634 ip->i_mnem, ip->i_value, ip->i_sell ? "yes" : "no", ip->i_lbs,
635 ip->i_pkg[IPKG], ip->i_pkg[NPKG], ip->i_pkg[WPKG],
636 ip->i_pkg[UPKG], ip->i_pkg[BPKG],
637 ip->i_melt_denom, ip->i_name);
646 pr("id category good will\n");
649 for (i = 1; i < N_MAX_VERB + 1; i++) {
650 pr("%-2d %-20.20s %4d\n", rpt[i].r_uid,
651 page_headings[rpt[i].r_newspage].name, rpt[i].r_good_will);
653 for (j = 0; j < NUM_RPTS; j++)
654 pr(" %s\n", rpt[i].r_newstory[j]);