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:
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)
58 #include "prototypes.h"
69 } lookup_list[200]; /* Change this if there are ever more than 200 planes, ships
71 static int lookup_list_cnt = 0;
74 sort_lookup_list(void)
76 struct natstr *np = getnatp(player->cnum);
81 if (!(np->nat_flags & NF_TECHLISTS))
83 for (i = 0; i < lookup_list_cnt; i++) {
84 for (j = i; j < lookup_list_cnt; j++) {
85 if (lookup_list[j].tech < lookup_list[i].tech) {
87 lookup_list[j] = lookup_list[i];
95 make_new_list(int tlev, int type)
102 if (type == EF_PLANE) {
103 for (pp = plchr; pp->pl_name; pp++) {
104 if (pp->pl_tech > tlev)
106 lookup_list[lookup_list_cnt].l_u.pp = pp;
107 lookup_list[lookup_list_cnt].tech = pp->pl_tech;
110 } else if (type == EF_SHIP) {
111 for (mp = mchr; mp->m_name; mp++) {
112 if (mp->m_tech > tlev)
114 lookup_list[lookup_list_cnt].l_u.mp = mp;
115 lookup_list[lookup_list_cnt].tech = mp->m_tech;
118 } else if (type == EF_LAND) {
119 for (lp = lchr; lp->l_name; lp++) {
120 if (lp->l_tech > tlev)
122 lookup_list[lookup_list_cnt].l_u.lp = lp;
123 lookup_list[lookup_list_cnt].tech = lp->l_tech;
133 show_bridge(int tlev)
137 pr("Bridges require %g tech,", buil_bt);
138 pr(" %d hcm,", buil_bh);
139 pr(" %d workers,\n", 0);
140 pr("%d available workforce, and cost $%g\n",
141 (SCT_BLD_WORK(0, buil_bh) * SCT_MINEFF + 99) / 100,
148 if (tlev < buil_tower_bt)
150 pr("Bridge Towers require %g tech,", buil_tower_bt);
151 pr(" %d hcm,", buil_tower_bh);
152 pr(" %d workers,\n", 0);
153 pr("%d available workforce, and cost $%g\n",
154 (SCT_BLD_WORK(0, buil_tower_bh) * SCT_MINEFF + 99) / 100,
159 show_nuke_stats(int tlev)
161 show_nuke_capab(tlev);
165 show_nuke_build(int tlev)
170 pr("%13s lcm hcm oil rad avail tech res $\n", "");
172 for (np = nchr; np->n_name; np++) {
173 avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
174 if (np->n_tech > tlev)
176 pr("%-13.13s %3d %3d %4d %4d %5d %4d %3.0f $%6d\n",
177 np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
178 np->n_rad, avail, np->n_tech,
179 drnuke_const > MIN_DRNUKE_CONST ?
180 (np->n_tech * drnuke_const) + 1.0 : 0.0,
186 show_nuke_capab(int tlev)
192 pr("%13s blst dam lbs tech res $%7s abilities\n", "", "");
194 for (np = nchr; np->n_name; np++) {
195 if (np->n_tech > tlev)
197 pr("%-13.13s %4d %3d %3d %4d %3.0f $%7d ",
198 np->n_name, np->n_blast, np->n_dam,
199 np->n_weight, np->n_tech,
200 drnuke_const > MIN_DRNUKE_CONST ?
201 (np->n_tech * drnuke_const) + 1.0 : 0.0,
203 for (i = j = 0; i < 32; i++) {
204 if (!(np->n_flags & bit(i)))
206 if (NULL != (p = symbol_by_value(bit(i), nuke_chr_flags))) {
217 show_ship_build(int tlev)
222 pr("%25s lcm hcm avail tech $\n", "");
223 make_new_list(tlev, EF_SHIP);
224 for (n = 0; n < lookup_list_cnt; n++) {
225 mp = (struct mchrstr *)lookup_list[n].l_u.mp;
226 /* Can't show trade ships unless it's turned on */
227 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
230 pr("%-25.25s %3d %3d %5d %4d $%d\n",
231 mp->m_name, mp->m_lcm, mp->m_hcm,
232 SHP_BLD_WORK(mp->m_lcm, mp->m_hcm), mp->m_tech, mp->m_cost);
237 show_ship_stats(int tlev)
243 pr("%25s s v s r f l p", "");
250 pr("%25s p i p n i n l", "");
257 pr("%25s def d s y g r d n", "");
265 make_new_list(tlev, EF_SHIP);
266 for (scount = 0; scount < lookup_list_cnt; scount++) {
267 mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
268 /* Can't show trade ships unless it's turned on */
269 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
272 techdiff = (int)(tlev - mp->m_tech);
273 pr("%-25.25s %3d %2d %2d %2d %2d %2d ",
275 (short)SHP_DEF(mp->m_armor, techdiff),
276 (short)SHP_SPD(mp->m_speed, techdiff),
277 (short)SHP_VIS(mp->m_visib, techdiff),
279 (short)SHP_RNG(mp->m_frnge, techdiff),
280 (short)SHP_FIR(mp->m_glim, techdiff));
282 pr("%2d ", mp->m_nland);
283 pr("%2d ", mp->m_nplanes);
284 pr("%2d ", mp->m_nchoppers);
285 pr("%2d ", mp->m_nxlight);
287 pr("%3d/%1d ", mp->m_fuelc, mp->m_fuelu);
293 show_ship_capab(int tlev)
302 pr("%25s cargos & capabilities\n", "");
304 make_new_list(tlev, EF_SHIP);
305 for (scount = 0; scount < lookup_list_cnt; scount++) {
306 mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
307 /* Can't show trade ships unless it's turned on */
308 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
311 pr("%-25.25s ", mp->m_name);
313 for (i = I_NONE + 1; i <= I_MAX; ++i)
315 pr(" %d%c", mp->m_item[i], ichr[i].i_mnem);
317 for (j = n = 0; j < 32; j++) {
318 if (!(mp->m_flags & bit(j)))
320 if (NULL != (p = symbol_by_value(bit(j), ship_chr_flags))) {
331 show_plane_stats(int tlev)
336 pr("%25s acc load att def ran fuel stlth\n", "");
337 make_new_list(tlev, EF_PLANE);
338 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
339 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
340 pr("%-25.25s %3d %4d %3d %3d %3d %4d ",
342 (int)PLN_ACC(pp->pl_acc, (int)(tlev - pp->pl_tech)),
343 (int)PLN_LOAD(pp->pl_load, (int)(tlev - pp->pl_tech)),
344 (int)PLN_ATTDEF(pp->pl_att, (int)(tlev - pp->pl_tech)),
345 (int)PLN_ATTDEF(pp->pl_def, (int)(tlev - pp->pl_tech)),
346 (int)PLN_RAN(pp->pl_range, (int)(tlev - pp->pl_tech)),
348 pr("%4d%% ", pp->pl_stealth);
354 show_plane_capab(int tlev)
362 pr("%25s capabilities\n", "");
363 make_new_list(tlev, EF_PLANE);
364 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
365 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
366 pr("%-25.25s ", pp->pl_name);
368 for (i = n = 0; i < 32; i++) {
369 if (!(pp->pl_flags & bit(i)))
371 if (NULL != (p = symbol_by_value(bit(i), plane_chr_flags))) {
382 show_plane_build(int tlev)
387 pr("%25s lcm hcm crew avail tech $\n", "");
388 make_new_list(tlev, EF_PLANE);
389 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
390 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
391 pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
392 pp->pl_name, pp->pl_lcm,
393 pp->pl_hcm, pp->pl_crew,
394 PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm), pp->pl_tech, pp->pl_cost);
399 show_land_build(int tlev)
404 pr("%25s lcm hcm guns avail tech $\n", "");
405 make_new_list(tlev, EF_LAND);
406 for (n = 0; n < lookup_list_cnt; n++) {
407 lp = (struct lchrstr *)lookup_list[n].l_u.lp;
408 if ((lp->l_flags & L_SPY) && !opt_LANDSPIES)
410 pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
411 lp->l_name, lp->l_lcm,
414 LND_BLD_WORK(lp->l_lcm, lp->l_hcm), lp->l_tech, lp->l_cost);
419 show_land_capab(int tlev)
427 pr("%25s capabilities\n", "");
429 make_new_list(tlev, EF_LAND);
430 for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
431 lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
432 if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
435 pr("%-25s ", lcp->l_name);
437 for (i = I_NONE + 1; i <= I_MAX; ++i)
439 pr(" %d%c", lcp->l_item[i], ichr[i].i_mnem);
441 for (j = n = 0; j < 32; j++) {
442 if (!(lcp->l_flags & bit(j)))
444 if (NULL != (p = symbol_by_value(bit(j), land_chr_flags))) {
455 show_land_stats(int tlev)
461 pr("%25s s v s r r a f a a x l\n", "");
462 pr("%25s p i p a n c i m a f f p n\n", "");
463 pr("%25s att def vul d s y d g c r m f c u l d\n", "");
465 make_new_list(tlev, EF_LAND);
466 for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
467 lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
468 if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
471 ourtlev = (int)(tlev - lcp->l_tech);
472 pr("%-25s %1.1f %1.1f %3d ",
473 lcp->l_name, (float)LND_ATTDEF(lcp->l_att, ourtlev),
474 (float)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, lcp->l_dam, 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)
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);
519 pr("Infrastructure building - adding 1 point of efficiency costs:\n");
520 pr(" type lcms hcms mobility $$$$\n");
521 for (x = 0; intrchr[x].in_name; x++) {
522 pr("%-20s %4d %4d %8d %4d\n", intrchr[x].in_name,
523 intrchr[x].in_lcms, intrchr[x].in_hcms,
524 intrchr[x].in_mcost, intrchr[x].in_dcost);
529 show_sect_stats(int foo)
534 natp = getnatp(player->cnum);
535 for (x = 0; x <= SCT_MAXDEF; x++) {
536 if (dchr[x].d_mnem == 0)
539 pr(" base max max -- packing bonus -- max\n");
540 pr(" sector type mcost off def mil uw civ bar other pop\n");
543 pr("%c %-23s %3d %5.2f %5.2f %3d %3d %3d %3d %5d %5d\n",
544 dchr[x].d_mnem, dchr[x].d_name,
545 dchr[x].d_mcst, dchr[x].d_ostr,
547 ichr[I_MILIT].i_pkg[dchr[x].d_pkg],
548 ichr[I_UW].i_pkg[dchr[x].d_pkg],
549 ichr[I_CIVIL].i_pkg[dchr[x].d_pkg],
550 ichr[I_BAR].i_pkg[dchr[x].d_pkg],
551 ichr[I_LCM].i_pkg[dchr[x].d_pkg],
552 max_population(natp->nat_level[NAT_RLEV], x, 100));
557 show_sect_capab(int foo)
559 int x, first = 1, i, j;
562 for (x = 0; x <= SCT_MAXDEF; x++) {
563 if ((dchr[x].d_mnem == 0) || (dchr[x].d_prd == 0))
566 pr(" --- level --- reso \n");
567 pr(" sector type product use1 use2 use3 level min lag eff%% $$$ dep c\n");
573 pr("%c %-23s %-7s ", dchr[x].d_mnem, dchr[x].d_name,
575 (void)CANT_HAPPEN(MAXPRCON > 3); /* output has only three columns */
576 for (i = 0; i < 3; i++) {
579 && pchr[j].p_ctype[i] > I_NONE
580 && pchr[j].p_ctype[i] <= I_MAX) {
581 pr("%2d %c ", pchr[j].p_camt[i],
582 ichr[pchr[j].p_ctype[i]].i_name[0]);
587 switch (pchr[j].p_nlndx) {
604 pr("%-5s %3d %3d %4d %3d %3d %c",
608 pchr[j].p_effic, pchr[j].p_cost, pchr[j].p_nrdep,
609 pchr[j].p_type != I_NONE ? ichr[pchr[j].p_type].i_mnem : ' ');
620 pr("item value sell lbs packing melt item\n");
621 pr("mnem in rg wh ur bk deno name\n");
623 for (ip = ichr; ip->i_name; ip++) {
624 pr(" %c %5d %4s %3d %2d %2d %2d %2d %2d %4d %s\n",
625 ip->i_mnem, ip->i_value, ip->i_sell ? "yes" : "no", ip->i_lbs,
626 ip->i_pkg[IPKG], ip->i_pkg[NPKG], ip->i_pkg[WPKG],
627 ip->i_pkg[UPKG], ip->i_pkg[BPKG],
628 ip->i_melt_denom, ip->i_name);
637 pr("id category good will\n");
640 for (i = 1; i < N_MAX_VERB + 1; i++) {
641 pr("%-2d %-20.20s %4d\n", rpt[i].r_uid,
642 page_headings[rpt[i].r_newspage].name, rpt[i].r_good_will);
644 for (j = 0; j < NUM_RPTS; j++)
645 pr(" %s\n", rpt[i].r_newstory[j]);