2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, 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)
57 #include "prototypes.h"
61 * This cruft really belongs in the empglb.c file.
70 struct lookup ship_flags[] = {
85 {M_SEMILAND, "semi-land"},
88 {M_ANTIMISSILE, "anti-missile"},
92 struct lookup land_flags[] = {
94 {L_ENGINEER, "engineer"},
96 {L_SECURITY, "security"},
101 {L_ASSAULT, "assault"},
110 struct lookup plane_flags[] = {
123 {P_H, "half-stealth"},
135 struct lookup nuke_flags[] = {
147 } lookup_list[200]; /* Change this if there are ever more than 200 planes, ships
149 static int lookup_list_cnt = 0;
152 sort_lookup_list(void)
154 struct natstr *np = getnatp(player->cnum);
155 struct look_list tmp;
159 if (!(np->nat_flags & NF_TECHLISTS))
161 for (i = 0; i < lookup_list_cnt; i++) {
162 for (j = i; j < lookup_list_cnt; j++) {
163 if (lookup_list[j].tech < lookup_list[i].tech) {
164 tmp = lookup_list[j];
165 lookup_list[j] = lookup_list[i];
166 lookup_list[i] = tmp;
173 make_new_list(int tlev, int type)
181 if (type == EF_PLANE) {
182 for (pp = plchr, count = 0; count < pln_maxno; count++, pp++) {
183 if (pp->pl_tech > tlev)
185 if (pp->pl_name == 0 || pp->pl_name[0] == '\0')
187 lookup_list[lookup_list_cnt].l_u.pp = pp;
188 lookup_list[lookup_list_cnt].tech = pp->pl_tech;
191 } else if (type == EF_SHIP) {
192 for (mp = mchr, count = 0; count < shp_maxno; count++, mp++) {
193 if (mp->m_tech > tlev)
195 if (mp->m_name == 0 || mp->m_name[0] == '\0')
197 lookup_list[lookup_list_cnt].l_u.mp = mp;
198 lookup_list[lookup_list_cnt].tech = mp->m_tech;
201 } else if (type == EF_LAND) {
202 for (lp = lchr, count = 0; count < lnd_maxno; count++, lp++) {
203 if (lp->l_tech > tlev)
205 if (lp->l_name == 0 || lp->l_name[0] == '\0')
207 lookup_list[lookup_list_cnt].l_u.lp = lp;
208 lookup_list[lookup_list_cnt].tech = lp->l_tech;
218 lookup(int key, struct lookup *table)
222 if ((match = intmatch(key, &table->key, sizeof(*table))) < 0)
224 return table[match].value;
228 show_bridge(int tlev)
232 pr("Bridges require %g tech,", buil_bt);
234 pr(" %d hcm,", buil_bh);
235 else if (!opt_NO_LCMS)
236 pr(" %d lcm,", buil_bh);
237 pr(" %d workers,\n", 0);
238 pr("%d available workforce, and cost $%g\n",
239 (SCT_BLD_WORK(0, buil_bh) * SCT_MINEFF + 99) / 100,
246 if (tlev < buil_tower_bt)
248 pr("Bridge Towers require %g tech,", buil_tower_bt);
250 pr(" %d hcm,", buil_tower_bh);
251 else if (!opt_NO_LCMS)
252 pr(" %d lcm,", buil_tower_bh);
253 pr(" %d workers,\n", 0);
254 pr("%d available workforce, and cost $%g\n",
255 (SCT_BLD_WORK(0, buil_tower_bh) * SCT_MINEFF + 99) / 100,
260 show_nuke_stats(int tlev)
262 show_nuke_capab(tlev);
266 show_nuke_build(int tlev)
268 register struct nchrstr *np;
273 pr("%13s lcm hcm oil rad avail tech res $\n", "");
275 pr("%13s lcm hcm oil rad avail tech $\n", "");
279 for (np = nchr, n = 0; n < N_MAXNUKE; np++, n++) {
280 avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
281 if (np->n_tech > tlev)
283 if (np->n_name == 0 || np->n_name[0] == '\0')
285 if (opt_NEUTRON == 0 && (np->n_flags & N_NEUT))
288 pr("%-13.13s %3d %3d %4d %4d %5d %4d %3d $%6d\n",
289 np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
290 np->n_rad, avail, np->n_tech,
291 (int)(np->n_tech * drnuke_const) + 1, np->n_cost);
292 else /* not DRNUKE */
293 pr("%-13.13s %3d %3d %4d %4d %5d %4d $%6d\n",
294 np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
295 np->n_rad, avail, np->n_tech, np->n_cost);
300 show_nuke_capab(int tlev)
302 register struct nchrstr *np;
303 register int i, j, n;
307 pr("%13s blst dam lbs tech res $%7s abilities\n", "", "");
309 pr("%13s blst dam lbs tech $%7s abilities\n", "", "");
313 for (np = nchr, n = 0; n < N_MAXNUKE; np++, n++) {
314 if (np->n_tech > tlev)
316 if (opt_NEUTRON == 0 && (np->n_flags & N_NEUT))
318 if (np->n_name == 0 || np->n_name[0] == '\0')
321 pr("%-13.13s %4d %3d %3d %4d %3d $%7d ",
322 np->n_name, np->n_blast, np->n_dam,
323 np->n_weight, np->n_tech,
324 (int)(np->n_tech * drnuke_const) + 1, np->n_cost);
325 else /* not DRNUKE */
326 pr("%-13.13s %4d %3d %3d %4d $%7d ",
327 np->n_name, np->n_blast, np->n_dam,
328 np->n_weight, np->n_tech, np->n_cost);
330 for (i = j = 0; i < 32; i++) {
331 if (!(np->n_flags & bit(i)))
333 if (NULL != (p = lookup(bit(i), nuke_flags))) {
344 show_ship_build(int tlev)
346 register struct mchrstr *mp;
349 pr("%25s lcm hcm avail tech $\n", "");
350 make_new_list(tlev, EF_SHIP);
351 for (n = 0; n < lookup_list_cnt; n++) {
352 mp = (struct mchrstr *)lookup_list[n].l_u.mp;
353 /* Can't show trade ships unless it's turned on */
354 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
357 pr("%-25.25s %3d %3d %5d %4d $%d\n",
358 mp->m_name, mp->m_lcm, mp->m_hcm,
359 SHP_BLD_WORK(mp->m_lcm, mp->m_hcm), mp->m_tech, mp->m_cost);
364 show_ship_stats(int tlev)
366 register struct mchrstr *mp;
370 pr("%25s s v s r f l p", "");
377 pr("%25s p i p n i n l", "");
384 pr("%25s def d s y g r d n", "");
392 make_new_list(tlev, EF_SHIP);
393 for (scount = 0; scount < lookup_list_cnt; scount++) {
394 mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
395 /* Can't show trade ships unless it's turned on */
396 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
399 techdiff = (int)(tlev - mp->m_tech);
400 pr("%-25.25s %3d %2d %2d %2d %2d %2d ",
402 (short)SHP_DEF(mp->m_armor, techdiff),
403 (short)SHP_SPD(mp->m_speed, techdiff),
404 (short)SHP_VIS(mp->m_visib, techdiff),
406 (short)SHP_RNG(mp->m_frnge, techdiff),
407 (short)SHP_FIR(mp->m_glim, techdiff));
409 pr("%2d ", mp->m_nland);
410 pr("%2d ", mp->m_nplanes);
411 pr("%2d ", mp->m_nchoppers);
412 pr("%2d ", mp->m_nxlight);
414 pr("%3d/%1d ", mp->m_fuelc, mp->m_fuelu);
420 show_ship_capab(int tlev)
422 register struct mchrstr *mp;
428 pr("%25s cargos & capabilities\n", "");
430 make_new_list(tlev, EF_SHIP);
431 for (scount = 0; scount < lookup_list_cnt; scount++) {
432 mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
433 /* Can't show trade ships unless it's turned on */
434 if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
437 pr("%-25.25s ", mp->m_name);
439 for (i = 0; i <= I_MAX; ++i)
441 pr(" %d%c", mp->m_item[i], ichr[i].i_mnem);
443 for (i = n = 0; i < 32; i++) {
444 if (!(mp->m_flags & bit(i)))
446 if (NULL != (p = lookup(bit(i), ship_flags))) {
457 show_plane_stats(int tlev)
459 register struct plchrstr *pp;
462 pr("%25s acc load att def ran fuel stlth\n", "");
463 make_new_list(tlev, EF_PLANE);
464 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
465 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
466 pr("%-25.25s %3d %4d %3d %3d %3d %4d ",
468 (int)PLN_ACC(pp->pl_acc, (int)(tlev - pp->pl_tech)),
469 (int)PLN_LOAD(pp->pl_load, (int)(tlev - pp->pl_tech)),
470 (int)PLN_ATTDEF(pp->pl_att, (int)(tlev - pp->pl_tech)),
471 (int)PLN_ATTDEF(pp->pl_def, (int)(tlev - pp->pl_tech)),
472 (int)PLN_RAN(pp->pl_range, (int)(tlev - pp->pl_tech)),
474 pr("%4d%% ", pp->pl_stealth);
480 show_plane_capab(int tlev)
482 register struct plchrstr *pp;
488 pr("%25s capabilities\n", "");
489 make_new_list(tlev, EF_PLANE);
490 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
491 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
492 pr("%-25.25s ", pp->pl_name);
494 for (i = n = 0; i < 32; i++) {
495 if (!(pp->pl_flags & bit(i)))
497 if (NULL != (p = lookup(bit(i), plane_flags))) {
508 show_plane_build(int tlev)
510 register struct plchrstr *pp;
513 pr("%25s lcm hcm crew avail tech $\n", "");
514 make_new_list(tlev, EF_PLANE);
515 for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
516 pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
517 pr("%-25.25s %3d %3d %3d %5d %4d $%d\n",
518 pp->pl_name, pp->pl_lcm,
519 pp->pl_hcm, pp->pl_crew,
520 PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm), pp->pl_tech, pp->pl_cost);
525 show_land_build(int tlev)
527 register struct lchrstr *lp;
530 pr("%25s lcm hcm guns avail tech $\n", "");
531 make_new_list(tlev, EF_LAND);
532 for (n = 0; n < lookup_list_cnt; n++) {
533 lp = (struct lchrstr *)lookup_list[n].l_u.lp;
534 if ((lp->l_flags & L_SPY) && !opt_LANDSPIES)
536 pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
537 lp->l_name, lp->l_lcm,
540 LND_BLD_WORK(lp->l_lcm, lp->l_hcm), lp->l_tech, lp->l_cost);
545 show_land_capab(int tlev)
552 pr("%25s capabilities\n", "");
554 make_new_list(tlev, EF_LAND);
555 for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
556 lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
557 if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
560 pr("%-25s ", lcp->l_name);
562 for (i = 0; i <= I_MAX; ++i)
564 pr(" %d%c", lcp->l_item[i], ichr[i].i_mnem);
566 for (i = n = 0; i < 32; i++) {
567 if (!(lcp->l_flags & bit(i)))
569 if (NULL != (p = lookup(bit(i), land_flags))) {
580 show_land_stats(int tlev)
586 pr("%25s s v s r r a f a a x l\n", "");
587 pr("%25s p i p a n c i m a f f p n\n", "");
588 pr("%25s att def vul d s y d g c r m f c u l d\n", "");
590 make_new_list(tlev, EF_LAND);
591 for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
592 lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
593 if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
596 ourtlev = (int)(tlev - lcp->l_tech);
597 pr("%-25s %1.1f %1.1f %3d ",
598 lcp->l_name, (float)LND_ATTDEF(lcp->l_att, ourtlev),
599 (float)LND_ATTDEF(lcp->l_def, ourtlev),
600 (int)LND_VUL(lcp->l_vul, ourtlev));
601 pr("%2d %2d %2d %2d ",
602 (int)LND_SPD(lcp->l_spd, ourtlev),
603 (int)LND_VIS(lcp->l_vis, ourtlev),
604 (int)LND_SPY(lcp->l_spy, ourtlev),
605 (int)LND_RAD(lcp->l_rad, ourtlev));
606 pr("%2d %2d %2d %2d %2d ",
607 (int)LND_FRG(lcp->l_frg, ourtlev),
608 (int)LND_ACC(lcp->l_acc, ourtlev),
609 (int)LND_DAM(lcp->l_dam, ourtlev),
610 (int)LND_AMM(lcp->l_ammo, lcp->l_dam, ourtlev),
611 (int)LND_AAF(lcp->l_aaf, ourtlev));
612 pr("%2d %2d %2d %2d ",
613 (int)LND_FC(lcp->l_fuelc, ourtlev),
614 (int)LND_FU(lcp->l_fuelu, ourtlev),
615 (int)LND_XPL(lcp->l_nxlight, ourtlev),
616 (int)LND_MXL(lcp->l_mxland, ourtlev));
623 show_sect_build(int foo)
625 register int x, first = 1;
627 for (x = 5; x < SCT_MAXDEF + 2; x++) {
628 if (dchr[x].d_mnem == 0)
630 if ((dchr[x].d_cost > 0) || (dchr[x].d_build != 1) ||
631 (dchr[x].d_lcms > 0) || (dchr[x].d_hcms > 0)) {
633 pr("sector type cost to des cost for 1%% eff lcms for 1%% hcms for 1%%\n");
636 pr("%-14c %-14d %-17d %-14d %d\n",
637 dchr[x].d_mnem, dchr[x].d_cost, dchr[x].d_build,
638 dchr[x].d_lcms, dchr[x].d_hcms);
642 pr("Infrastructure building - adding 1 point of efficiency costs:\n");
643 pr(" type lcms hcms mobility $$$$\n");
644 for (x = 0; intrchr[x].in_name; x++) {
645 pr("%-20s %4d %4d %8d %4d\n", intrchr[x].in_name,
646 intrchr[x].in_lcms, intrchr[x].in_hcms,
647 intrchr[x].in_mcost, intrchr[x].in_dcost);
652 show_sect_stats(int foo)
654 register int x, first = 1;
658 natp = getnatp(player->cnum);
660 sect.sct_effic = 100;
661 for (x = 0; x < SCT_MAXDEF + 2; x++) {
662 if (dchr[x].d_mnem == 0)
665 pr(" base max max -- packing bonus -- max\n");
666 pr(" sector type mcost off def mil uw civ bar other pop\n");
670 pr("%c %-23s %3d %5.2f %5.2f %3d %3d %3d %3d %5d %5d\n",
671 dchr[x].d_mnem, dchr[x].d_name,
672 dchr[x].d_mcst, dchr[x].d_ostr,
674 ichr[I_MILIT].i_pkg[dchr[x].d_pkg],
675 ichr[I_UW].i_pkg[dchr[x].d_pkg],
676 ichr[I_CIVIL].i_pkg[dchr[x].d_pkg],
677 ichr[I_BAR].i_pkg[dchr[x].d_pkg],
678 ichr[I_LCM].i_pkg[dchr[x].d_pkg],
679 max_pop(natp->nat_level[NAT_RLEV], §));
684 show_sect_capab(int foo)
686 register int x, first = 1, i, j;
689 char *outputs = " cmsgpidbfolhur";
691 for (x = 0; x < SCT_MAXDEF + 2; x++) {
692 if ((dchr[x].d_mnem == 0) || (dchr[x].d_prd == 0))
695 pr(" --- level --- reso \n");
696 pr(" sector type product use1 use2 use3 level min lag eff%% $$$ dep c\n");
702 pr("%c %-23s %-7s ", dchr[x].d_mnem, dchr[x].d_name,
704 /*for(i=0;i<MAXCHRNV;i++) */
705 /* XXX currently no more than 3 items actually used */
706 for (i = 0; i < 3; i++) {
707 if ((i < pchr[j].p_nv) && (pchr[j].p_vamt[i] > 0)) {
708 pr("%2d %c ", pchr[j].p_vamt[i],
709 ichr[pchr[j].p_vtype[i] & (~VT_ITEM)].i_name[0]);
714 switch (pchr[j].p_nlndx) {
732 c = outputs[pchr[j].p_type - VT_ITEM];
735 pr("%-5s %3d %3d %4d %3d %3d %c",
739 pchr[j].p_effic, pchr[j].p_cost, pchr[j].p_nrdep, c);