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
51 #include "prototypes.h"
65 * Change this if there are ever more than 200 ships, plane or land
68 static struct look_list lookup_list[200];
69 static int lookup_list_cnt = 0;
72 sort_lookup_list(void)
74 struct natstr *np = getnatp(player->cnum);
79 if (!(np->nat_flags & NF_TECHLISTS))
81 for (i = 0; i < lookup_list_cnt; i++) {
82 for (j = i; j < lookup_list_cnt; j++) {
83 if (lookup_list[j].tech < lookup_list[i].tech) {
85 lookup_list[j] = lookup_list[i];
93 make_new_list(int tlev, int type)
100 if (type == EF_PLANE) {
101 for (pp = plchr; pp->pl_name; pp++) {
102 if (pp->pl_tech > tlev)
104 lookup_list[lookup_list_cnt].l_u.pp = pp;
105 lookup_list[lookup_list_cnt].tech = pp->pl_tech;
108 } else if (type == EF_SHIP) {
109 for (mp = mchr; mp->m_name; mp++) {
110 if (mp->m_tech > tlev)
112 lookup_list[lookup_list_cnt].l_u.mp = mp;
113 lookup_list[lookup_list_cnt].tech = mp->m_tech;
116 } else if (type == EF_LAND) {
117 for (lp = lchr; lp->l_name; lp++) {
118 if (lp->l_tech > tlev)
120 lookup_list[lookup_list_cnt].l_u.lp = lp;
121 lookup_list[lookup_list_cnt].tech = lp->l_tech;
131 show_bridge(int tlev)
135 pr("Bridges require %g tech,", buil_bt);
136 pr(" %d hcm,", buil_bh);
137 pr(" %d workers,\n", 0);
138 pr("%d available workforce, and cost $%g\n",
139 (SCT_BLD_WORK(0, buil_bh) * SCT_MINEFF + 99) / 100,
146 if (tlev < buil_tower_bt)
148 pr("Bridge Towers require %g tech,", buil_tower_bt);
149 pr(" %d hcm,", buil_tower_bh);
150 pr(" %d workers,\n", 0);
151 pr("%d available workforce, and cost $%g\n",
152 (SCT_BLD_WORK(0, buil_tower_bh) * SCT_MINEFF + 99) / 100,
157 show_nuke_stats(int tlev)
159 show_nuke_capab(tlev);
163 show_nuke_build(int tlev)
168 pr("%13s lcm hcm oil rad avail tech res $\n", "");
170 for (np = nchr; np->n_name; np++) {
171 avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
172 if (np->n_tech > tlev)
174 pr("%-13.13s %3d %3d %4d %4d %5d %4d %3.0f $%6d\n",
175 np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
176 np->n_rad, avail, np->n_tech,
177 drnuke_const > MIN_DRNUKE_CONST ?
178 (np->n_tech * drnuke_const) + 1.0 : 0.0,
184 show_nuke_capab(int tlev)
190 pr("%13s blst dam lbs tech res $%7s abilities\n", "", "");
192 for (np = nchr; np->n_name; np++) {
193 if (np->n_tech > tlev)
195 pr("%-13.13s %4d %3d %3d %4d %3.0f $%7d ",
196 np->n_name, np->n_blast, np->n_dam,
197 np->n_weight, np->n_tech,
198 drnuke_const > MIN_DRNUKE_CONST ?
199 (np->n_tech * drnuke_const) + 1.0 : 0.0,
201 for (i = j = 0; i < 32; i++) {
202 if (!(np->n_flags & bit(i)))
204 if (NULL != (p = symbol_by_value(bit(i), nuke_chr_flags))) {
215 show_ship_build(int tlev)
220 pr("%25s lcm hcm avail tech $\n", "");
221 make_new_list(tlev, EF_SHIP);
222 for (n = 0; n < lookup_list_cnt; n++) {
223 mp = (struct mchrstr *)lookup_list[n].l_u.mp;
224 /* Can't show trade ships unless it's turned on */
225 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
228 pr("%-25.25s %3d %3d %5d %4d $%d\n",
229 mp->m_name, mp->m_lcm, mp->m_hcm,
230 SHP_BLD_WORK(mp->m_lcm, mp->m_hcm), mp->m_tech, mp->m_cost);
235 show_ship_stats(int tlev)
241 pr("%25s s v s r f l p", "");
248 pr("%25s p i p n i n l", "");
255 pr("%25s def d s y g r d n", "");
263 make_new_list(tlev, EF_SHIP);
264 for (scount = 0; scount < lookup_list_cnt; scount++) {
265 mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
266 /* Can't show trade ships unless it's turned on */
267 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
270 techdiff = (int)(tlev - mp->m_tech);
271 pr("%-25.25s %3d %2d %2d %2d %2d %2d ",
273 (short)SHP_DEF(mp->m_armor, techdiff),
274 (short)SHP_SPD(mp->m_speed, techdiff),
275 (short)SHP_VIS(mp->m_visib, techdiff),
277 (short)SHP_RNG(mp->m_frnge, techdiff),
278 (short)SHP_FIR(mp->m_glim, techdiff));
280 pr("%2d ", mp->m_nland);
281 pr("%2d ", mp->m_nplanes);
282 pr("%2d ", mp->m_nchoppers);
283 pr("%2d ", mp->m_nxlight);
285 pr("%3d/%1d ", mp->m_fuelc, mp->m_fuelu);
291 show_ship_capab(int tlev)
300 pr("%25s cargos & capabilities\n", "");
302 make_new_list(tlev, EF_SHIP);
303 for (scount = 0; scount < lookup_list_cnt; scount++) {
304 mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
305 /* Can't show trade ships unless it's turned on */
306 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
309 pr("%-25.25s ", mp->m_name);
311 for (i = I_NONE + 1; i <= I_MAX; ++i)
313 pr(" %d%c", mp->m_item[i], ichr[i].i_mnem);
315 for (j = n = 0; j < 32; j++) {
316 if (!(mp->m_flags & bit(j)))
318 if (NULL != (p = symbol_by_value(bit(j), ship_chr_flags))) {
329 show_plane_stats(int tlev)
334 pr("%25s acc load att def ran fuel stlth\n", "");
335 make_new_list(tlev, EF_PLANE);
336 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
337 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
338 pr("%-25.25s %3d %4d %3d %3d %3d %4d ",
340 (int)PLN_ACC(pp->pl_acc, (int)(tlev - pp->pl_tech)),
341 (int)PLN_LOAD(pp->pl_load, (int)(tlev - pp->pl_tech)),
342 (int)PLN_ATTDEF(pp->pl_att, (int)(tlev - pp->pl_tech)),
343 (int)PLN_ATTDEF(pp->pl_def, (int)(tlev - pp->pl_tech)),
344 (int)PLN_RAN(pp->pl_range, (int)(tlev - pp->pl_tech)),
346 pr("%4d%% ", pp->pl_stealth);
352 show_plane_capab(int tlev)
360 pr("%25s capabilities\n", "");
361 make_new_list(tlev, EF_PLANE);
362 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
363 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
364 pr("%-25.25s ", pp->pl_name);
366 for (i = n = 0; i < 32; i++) {
367 if (!(pp->pl_flags & bit(i)))
369 if (NULL != (p = symbol_by_value(bit(i), plane_chr_flags))) {
380 show_plane_build(int tlev)
385 pr("%25s lcm hcm crew avail tech $\n", "");
386 make_new_list(tlev, EF_PLANE);
387 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
388 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
389 pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
390 pp->pl_name, pp->pl_lcm,
391 pp->pl_hcm, pp->pl_crew,
392 PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm), pp->pl_tech, pp->pl_cost);
397 show_land_build(int tlev)
402 pr("%25s lcm hcm guns avail tech $\n", "");
403 make_new_list(tlev, EF_LAND);
404 for (n = 0; n < lookup_list_cnt; n++) {
405 lp = (struct lchrstr *)lookup_list[n].l_u.lp;
406 if ((lp->l_flags & L_SPY) && !opt_LANDSPIES)
408 pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
409 lp->l_name, lp->l_lcm,
412 LND_BLD_WORK(lp->l_lcm, lp->l_hcm), lp->l_tech, lp->l_cost);
417 show_land_capab(int tlev)
425 pr("%25s capabilities\n", "");
427 make_new_list(tlev, EF_LAND);
428 for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
429 lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
430 if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
433 pr("%-25s ", lcp->l_name);
435 for (i = I_NONE + 1; i <= I_MAX; ++i)
437 pr(" %d%c", lcp->l_item[i], ichr[i].i_mnem);
439 for (j = n = 0; j < 32; j++) {
440 if (!(lcp->l_flags & bit(j)))
442 if (NULL != (p = symbol_by_value(bit(j), land_chr_flags))) {
453 show_land_stats(int tlev)
459 pr("%25s s v s r r a f a a x l\n", "");
460 pr("%25s p i p a n c i m a f f p n\n", "");
461 pr("%25s att def vul d s y d g c r m f c u l d\n", "");
463 make_new_list(tlev, EF_LAND);
464 for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
465 lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
466 if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
469 ourtlev = (int)(tlev - lcp->l_tech);
470 pr("%-25s %1.1f %1.1f %3d ",
472 LND_ATTDEF(lcp->l_att, ourtlev),
473 LND_ATTDEF(lcp->l_def, ourtlev),
474 (int)LND_VUL(lcp->l_vul, ourtlev));
475 pr("%2d %2d %2d %2d ",
476 (int)LND_SPD(lcp->l_spd, ourtlev),
477 (int)LND_VIS(lcp->l_vis, ourtlev),
478 (int)LND_SPY(lcp->l_spy, ourtlev),
479 (int)LND_RAD(lcp->l_rad, ourtlev));
480 pr("%2d %2d %2d %2d %2d ",
481 (int)LND_FRG(lcp->l_frg, ourtlev),
482 (int)LND_ACC(lcp->l_acc, ourtlev),
483 (int)LND_DAM(lcp->l_dam, ourtlev),
484 (int)LND_AMM(lcp->l_ammo, lcp->l_dam, ourtlev),
485 (int)LND_AAF(lcp->l_aaf, ourtlev));
486 pr("%2d %2d %2d %2d ",
487 (int)LND_FC(lcp->l_fuelc, ourtlev),
488 (int)LND_FU(lcp->l_fuelu, ourtlev),
489 (int)LND_XPL(lcp->l_nxlight, ourtlev),
490 (int)LND_MXL(lcp->l_nland, ourtlev));
497 show_sect_build(int foo)
502 for (x = 0; x <= SCT_MAXDEF; x++) {
503 if (dchr[x].d_mnem == 0)
505 if (dchr[x].d_cost < 0)
507 if ((dchr[x].d_cost > 0) || (dchr[x].d_build != 1) ||
508 (dchr[x].d_lcms > 0) || (dchr[x].d_hcms > 0)) {
510 pr("sector type cost to des cost for 1%% eff lcms for 1%% hcms for 1%%\n");
513 pr("%-14c %-14d %-17d %-14d %d\n",
514 dchr[x].d_mnem, dchr[x].d_cost, dchr[x].d_build,
515 dchr[x].d_lcms, dchr[x].d_hcms);
520 for (x = 0; intrchr[x].in_name; x++) {
521 if (!intrchr[x].in_enable)
524 pr("\nInfrastructure building - adding 1 point of efficiency costs:\n"
525 " type lcms hcms mobility $$$$\n");
526 pr("%-20s %4d %4d %8d %4d\n",
527 intrchr[x].in_name, intrchr[x].in_lcms, intrchr[x].in_hcms,
528 intrchr[x].in_mcost, intrchr[x].in_dcost);
534 show_sect_stats(int foo)
539 natp = getnatp(player->cnum);
540 for (x = 0; x <= SCT_MAXDEF; x++) {
541 if (dchr[x].d_mnem == 0)
544 pr(" mob cost max max -- packing bonus -- max\n");
545 pr(" sector type base eff off def mil uw civ bar other pop\n");
548 pr("%c %-23s", dchr[x].d_mnem, dchr[x].d_name);
549 if (dchr[x].d_mcst <= 0)
552 pr(" %2d %2d", dchr[x].d_mcst, dchr[x].d_emcst);
553 pr(" %5.2f %5.2f %3d %3d %3d %3d %5d %5d\n",
554 dchr[x].d_ostr, dchr[x].d_dstr,
555 ichr[I_MILIT].i_pkg[dchr[x].d_pkg],
556 ichr[I_UW].i_pkg[dchr[x].d_pkg],
557 ichr[I_CIVIL].i_pkg[dchr[x].d_pkg],
558 ichr[I_BAR].i_pkg[dchr[x].d_pkg],
559 ichr[I_LCM].i_pkg[dchr[x].d_pkg],
560 max_population(natp->nat_level[NAT_RLEV], x, 100));
565 show_sect_capab(int foo)
567 int x, first = 1, i, j;
570 for (x = 0; x <= SCT_MAXDEF; x++) {
571 if (dchr[x].d_mnem == 0 || dchr[x].d_prd < 0)
574 pr(" --- level --- reso \n");
575 pr(" sector type product use1 use2 use3 level min lag eff%% $$$ dep c\n");
582 dchr[x].d_mnem, dchr[x].d_name, pchr[j].p_sname);
583 (void)CANT_HAPPEN(MAXPRCON > 3); /* output has only three columns */
584 for (i = 0; i < 3; i++) {
587 && pchr[j].p_ctype[i] > I_NONE
588 && pchr[j].p_ctype[i] <= I_MAX) {
589 pr("%2d %c ", pchr[j].p_camt[i],
590 ichr[pchr[j].p_ctype[i]].i_name[0]);
595 switch (pchr[j].p_nlndx) {
612 pr("%-5s %3d %3d %4d %3d %3d %c",
616 dchr[x].d_peffic, pchr[j].p_cost, pchr[j].p_nrdep,
617 pchr[j].p_type != I_NONE ? ichr[pchr[j].p_type].i_mnem : ' ');
628 pr("item value sell lbs packing melt item\n");
629 pr("mnem in rg wh ur bk deno name\n");
631 for (ip = ichr; ip->i_name; ip++) {
632 pr(" %c %5d %4s %3d %2d %2d %2d %2d %2d %4d %s\n",
633 ip->i_mnem, ip->i_value, ip->i_sell ? "yes" : "no", ip->i_lbs,
634 ip->i_pkg[IPKG], ip->i_pkg[NPKG], ip->i_pkg[WPKG],
635 ip->i_pkg[UPKG], ip->i_pkg[BPKG],
636 ip->i_melt_denom, ip->i_name);
645 pr("id category good will\n");
648 for (i = 1; i < N_MAX_VERB + 1; i++) {
649 pr("%-2d %-20.20s %4d\n", rpt[i].r_uid,
650 page_headings[rpt[i].r_newspage].name, rpt[i].r_good_will);
652 for (j = 0; j < NUM_RPTS; j++)
653 pr(" %s\n", rpt[i].r_newstory[j]);