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"
62 } lookup_list[200]; /* Change this if there are ever more than 200 planes, ships
64 static int lookup_list_cnt = 0;
67 sort_lookup_list(void)
69 struct natstr *np = getnatp(player->cnum);
74 if (!(np->nat_flags & NF_TECHLISTS))
76 for (i = 0; i < lookup_list_cnt; i++) {
77 for (j = i; j < lookup_list_cnt; j++) {
78 if (lookup_list[j].tech < lookup_list[i].tech) {
80 lookup_list[j] = lookup_list[i];
88 make_new_list(int tlev, int type)
95 if (type == EF_PLANE) {
96 for (pp = plchr; pp->pl_name; pp++) {
97 if (pp->pl_tech > tlev)
99 lookup_list[lookup_list_cnt].l_u.pp = pp;
100 lookup_list[lookup_list_cnt].tech = pp->pl_tech;
103 } else if (type == EF_SHIP) {
104 for (mp = mchr; mp->m_name; mp++) {
105 if (mp->m_tech > tlev)
107 lookup_list[lookup_list_cnt].l_u.mp = mp;
108 lookup_list[lookup_list_cnt].tech = mp->m_tech;
111 } else if (type == EF_LAND) {
112 for (lp = lchr; lp->l_name; lp++) {
113 if (lp->l_tech > tlev)
115 lookup_list[lookup_list_cnt].l_u.lp = lp;
116 lookup_list[lookup_list_cnt].tech = lp->l_tech;
126 show_bridge(int tlev)
130 pr("Bridges require %g tech,", buil_bt);
131 pr(" %d hcm,", buil_bh);
132 pr(" %d workers,\n", 0);
133 pr("%d available workforce, and cost $%g\n",
134 (SCT_BLD_WORK(0, buil_bh) * SCT_MINEFF + 99) / 100,
141 if (tlev < buil_tower_bt)
143 pr("Bridge Towers require %g tech,", buil_tower_bt);
144 pr(" %d hcm,", buil_tower_bh);
145 pr(" %d workers,\n", 0);
146 pr("%d available workforce, and cost $%g\n",
147 (SCT_BLD_WORK(0, buil_tower_bh) * SCT_MINEFF + 99) / 100,
152 show_nuke_stats(int tlev)
154 show_nuke_capab(tlev);
158 show_nuke_build(int tlev)
163 pr("%13s lcm hcm oil rad avail tech res $\n", "");
165 for (np = nchr; np->n_name; np++) {
166 avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
167 if (np->n_tech > tlev)
169 pr("%-13.13s %3d %3d %4d %4d %5d %4d %3.0f $%6d\n",
170 np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
171 np->n_rad, avail, np->n_tech,
172 drnuke_const > MIN_DRNUKE_CONST ?
173 (np->n_tech * drnuke_const) + 1.0 : 0.0,
179 show_nuke_capab(int tlev)
185 pr("%13s blst dam lbs tech res $%7s abilities\n", "", "");
187 for (np = nchr; np->n_name; np++) {
188 if (np->n_tech > tlev)
190 pr("%-13.13s %4d %3d %3d %4d %3.0f $%7d ",
191 np->n_name, np->n_blast, np->n_dam,
192 np->n_weight, np->n_tech,
193 drnuke_const > MIN_DRNUKE_CONST ?
194 (np->n_tech * drnuke_const) + 1.0 : 0.0,
196 for (i = j = 0; i < 32; i++) {
197 if (!(np->n_flags & bit(i)))
199 if (NULL != (p = symbol_by_value(bit(i), nuke_chr_flags))) {
210 show_ship_build(int tlev)
215 pr("%25s lcm hcm avail tech $\n", "");
216 make_new_list(tlev, EF_SHIP);
217 for (n = 0; n < lookup_list_cnt; n++) {
218 mp = (struct mchrstr *)lookup_list[n].l_u.mp;
219 /* Can't show trade ships unless it's turned on */
220 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
223 pr("%-25.25s %3d %3d %5d %4d $%d\n",
224 mp->m_name, mp->m_lcm, mp->m_hcm,
225 SHP_BLD_WORK(mp->m_lcm, mp->m_hcm), mp->m_tech, mp->m_cost);
230 show_ship_stats(int tlev)
236 pr("%25s s v s r f l p", "");
243 pr("%25s p i p n i n l", "");
250 pr("%25s def d s y g r d n", "");
258 make_new_list(tlev, EF_SHIP);
259 for (scount = 0; scount < lookup_list_cnt; scount++) {
260 mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
261 /* Can't show trade ships unless it's turned on */
262 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
265 techdiff = (int)(tlev - mp->m_tech);
266 pr("%-25.25s %3d %2d %2d %2d %2d %2d ",
268 (short)SHP_DEF(mp->m_armor, techdiff),
269 (short)SHP_SPD(mp->m_speed, techdiff),
270 (short)SHP_VIS(mp->m_visib, techdiff),
272 (short)SHP_RNG(mp->m_frnge, techdiff),
273 (short)SHP_FIR(mp->m_glim, techdiff));
275 pr("%2d ", mp->m_nland);
276 pr("%2d ", mp->m_nplanes);
277 pr("%2d ", mp->m_nchoppers);
278 pr("%2d ", mp->m_nxlight);
280 pr("%3d/%1d ", mp->m_fuelc, mp->m_fuelu);
286 show_ship_capab(int tlev)
295 pr("%25s cargos & capabilities\n", "");
297 make_new_list(tlev, EF_SHIP);
298 for (scount = 0; scount < lookup_list_cnt; scount++) {
299 mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
300 /* Can't show trade ships unless it's turned on */
301 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
304 pr("%-25.25s ", mp->m_name);
306 for (i = I_NONE + 1; i <= I_MAX; ++i)
308 pr(" %d%c", mp->m_item[i], ichr[i].i_mnem);
310 for (j = n = 0; j < 32; j++) {
311 if (!(mp->m_flags & bit(j)))
313 if (NULL != (p = symbol_by_value(bit(j), ship_chr_flags))) {
324 show_plane_stats(int tlev)
329 pr("%25s acc load att def ran fuel stlth\n", "");
330 make_new_list(tlev, EF_PLANE);
331 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
332 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
333 pr("%-25.25s %3d %4d %3d %3d %3d %4d ",
335 (int)PLN_ACC(pp->pl_acc, (int)(tlev - pp->pl_tech)),
336 (int)PLN_LOAD(pp->pl_load, (int)(tlev - pp->pl_tech)),
337 (int)PLN_ATTDEF(pp->pl_att, (int)(tlev - pp->pl_tech)),
338 (int)PLN_ATTDEF(pp->pl_def, (int)(tlev - pp->pl_tech)),
339 (int)PLN_RAN(pp->pl_range, (int)(tlev - pp->pl_tech)),
341 pr("%4d%% ", pp->pl_stealth);
347 show_plane_capab(int tlev)
355 pr("%25s capabilities\n", "");
356 make_new_list(tlev, EF_PLANE);
357 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
358 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
359 pr("%-25.25s ", pp->pl_name);
361 for (i = n = 0; i < 32; i++) {
362 if (!(pp->pl_flags & bit(i)))
364 if (NULL != (p = symbol_by_value(bit(i), plane_chr_flags))) {
375 show_plane_build(int tlev)
380 pr("%25s lcm hcm crew avail tech $\n", "");
381 make_new_list(tlev, EF_PLANE);
382 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
383 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
384 pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
385 pp->pl_name, pp->pl_lcm,
386 pp->pl_hcm, pp->pl_crew,
387 PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm), pp->pl_tech, pp->pl_cost);
392 show_land_build(int tlev)
397 pr("%25s lcm hcm guns avail tech $\n", "");
398 make_new_list(tlev, EF_LAND);
399 for (n = 0; n < lookup_list_cnt; n++) {
400 lp = (struct lchrstr *)lookup_list[n].l_u.lp;
401 if ((lp->l_flags & L_SPY) && !opt_LANDSPIES)
403 pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
404 lp->l_name, lp->l_lcm,
407 LND_BLD_WORK(lp->l_lcm, lp->l_hcm), lp->l_tech, lp->l_cost);
412 show_land_capab(int tlev)
420 pr("%25s capabilities\n", "");
422 make_new_list(tlev, EF_LAND);
423 for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
424 lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
425 if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
428 pr("%-25s ", lcp->l_name);
430 for (i = I_NONE + 1; i <= I_MAX; ++i)
432 pr(" %d%c", lcp->l_item[i], ichr[i].i_mnem);
434 for (j = n = 0; j < 32; j++) {
435 if (!(lcp->l_flags & bit(j)))
437 if (NULL != (p = symbol_by_value(bit(j), land_chr_flags))) {
448 show_land_stats(int tlev)
454 pr("%25s s v s r r a f a a x l\n", "");
455 pr("%25s p i p a n c i m a f f p n\n", "");
456 pr("%25s att def vul d s y d g c r m f c u l d\n", "");
458 make_new_list(tlev, EF_LAND);
459 for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
460 lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
461 if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
464 ourtlev = (int)(tlev - lcp->l_tech);
465 pr("%-25s %1.1f %1.1f %3d ",
466 lcp->l_name, (float)LND_ATTDEF(lcp->l_att, ourtlev),
467 (float)LND_ATTDEF(lcp->l_def, ourtlev),
468 (int)LND_VUL(lcp->l_vul, ourtlev));
469 pr("%2d %2d %2d %2d ",
470 (int)LND_SPD(lcp->l_spd, ourtlev),
471 (int)LND_VIS(lcp->l_vis, ourtlev),
472 (int)LND_SPY(lcp->l_spy, ourtlev),
473 (int)LND_RAD(lcp->l_rad, ourtlev));
474 pr("%2d %2d %2d %2d %2d ",
475 (int)LND_FRG(lcp->l_frg, ourtlev),
476 (int)LND_ACC(lcp->l_acc, ourtlev),
477 (int)LND_DAM(lcp->l_dam, ourtlev),
478 (int)LND_AMM(lcp->l_ammo, lcp->l_dam, ourtlev),
479 (int)LND_AAF(lcp->l_aaf, ourtlev));
480 pr("%2d %2d %2d %2d ",
481 (int)LND_FC(lcp->l_fuelc, ourtlev),
482 (int)LND_FU(lcp->l_fuelu, ourtlev),
483 (int)LND_XPL(lcp->l_nxlight, ourtlev),
484 (int)LND_MXL(lcp->l_nland, ourtlev));
491 show_sect_build(int foo)
495 for (x = 0; x <= SCT_MAXDEF; x++) {
496 if (dchr[x].d_mnem == 0)
498 if (dchr[x].d_cost < 0)
500 if ((dchr[x].d_cost > 0) || (dchr[x].d_build != 1) ||
501 (dchr[x].d_lcms > 0) || (dchr[x].d_hcms > 0)) {
503 pr("sector type cost to des cost for 1%% eff lcms for 1%% hcms for 1%%\n");
506 pr("%-14c %-14d %-17d %-14d %d\n",
507 dchr[x].d_mnem, dchr[x].d_cost, dchr[x].d_build,
508 dchr[x].d_lcms, dchr[x].d_hcms);
512 pr("Infrastructure building - adding 1 point of efficiency costs:\n");
513 pr(" type lcms hcms mobility $$$$\n");
514 for (x = 0; intrchr[x].in_name; x++) {
515 pr("%-20s %4d %4d %8d %4d\n", intrchr[x].in_name,
516 intrchr[x].in_lcms, intrchr[x].in_hcms,
517 intrchr[x].in_mcost, intrchr[x].in_dcost);
522 show_sect_stats(int foo)
527 natp = getnatp(player->cnum);
528 for (x = 0; x <= SCT_MAXDEF; x++) {
529 if (dchr[x].d_mnem == 0)
532 pr(" base max max -- packing bonus -- max\n");
533 pr(" sector type mcost off def mil uw civ bar other pop\n");
536 pr("%c %-23s %3d %5.2f %5.2f %3d %3d %3d %3d %5d %5d\n",
537 dchr[x].d_mnem, dchr[x].d_name,
538 dchr[x].d_mcst, dchr[x].d_ostr,
540 ichr[I_MILIT].i_pkg[dchr[x].d_pkg],
541 ichr[I_UW].i_pkg[dchr[x].d_pkg],
542 ichr[I_CIVIL].i_pkg[dchr[x].d_pkg],
543 ichr[I_BAR].i_pkg[dchr[x].d_pkg],
544 ichr[I_LCM].i_pkg[dchr[x].d_pkg],
545 max_population(natp->nat_level[NAT_RLEV], x, 100));
550 show_sect_capab(int foo)
552 int x, first = 1, i, j;
555 for (x = 0; x <= SCT_MAXDEF; x++) {
556 if ((dchr[x].d_mnem == 0) || (dchr[x].d_prd == 0))
559 pr(" --- level --- reso \n");
560 pr(" sector type product use1 use2 use3 level min lag eff%% $$$ dep c\n");
566 pr("%c %-23s %-7s ", dchr[x].d_mnem, dchr[x].d_name,
568 (void)CANT_HAPPEN(MAXPRCON > 3); /* output has only three columns */
569 for (i = 0; i < 3; i++) {
572 && pchr[j].p_ctype[i] > I_NONE
573 && pchr[j].p_ctype[i] <= I_MAX) {
574 pr("%2d %c ", pchr[j].p_camt[i],
575 ichr[pchr[j].p_ctype[i]].i_name[0]);
580 switch (pchr[j].p_nlndx) {
597 pr("%-5s %3d %3d %4d %3d %3d %c",
601 pchr[j].p_effic, pchr[j].p_cost, pchr[j].p_nrdep,
602 pchr[j].p_type != I_NONE ? ichr[pchr[j].p_type].i_mnem : ' ');
613 pr("item value sell lbs packing melt item\n");
614 pr("mnem in rg wh ur bk deno name\n");
616 for (ip = ichr; ip->i_name; ip++) {
617 pr(" %c %5d %4s %3d %2d %2d %2d %2d %2d %4d %s\n",
618 ip->i_mnem, ip->i_value, ip->i_sell ? "yes" : "no", ip->i_lbs,
619 ip->i_pkg[IPKG], ip->i_pkg[NPKG], ip->i_pkg[WPKG],
620 ip->i_pkg[UPKG], ip->i_pkg[BPKG],
621 ip->i_melt_denom, ip->i_name);
630 pr("id category good will\n");
633 for (i = 1; i < N_MAX_VERB + 1; i++) {
634 pr("%-2d %-20.20s %4d\n", rpt[i].r_uid,
635 page_headings[rpt[i].r_newspage].name, rpt[i].r_good_will);
637 for (j = 0; j < NUM_RPTS; j++)
638 pr(" %s\n", rpt[i].r_newstory[j]);