/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2016, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire is free software: you can redistribute it and/or modify
* Jeff Bailey, 1990
* Steve McClure, 1996
* Ron Koenderink, 2005-2009
- * Markus Armbruster, 2006-2016
+ * Markus Armbruster, 2006-2021
*/
#include <config.h>
#include <math.h>
-#include "file.h"
#include "game.h"
#include "item.h"
#include "land.h"
void
show_nuke_build(int tlev)
{
- struct chr_index chridx[sizeof(nchr) / sizeof(*nchr)];
+ struct chr_index chridx[ARRAY_SIZE(nchr)];
int n = make_nchr_index(chridx, tlev);
int i;
struct nchrstr *np;
for (i = 0; i < n; i++) {
np = &nchr[chridx[i].type];
pr("%-13.13s %3d %3d %4d %4d %5d %4d %3.0f $%6d\n",
- np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
- np->n_rad, np->n_bwork, np->n_tech,
+ np->n_name, np->n_mat[I_LCM], np->n_mat[I_HCM],
+ np->n_mat[I_OIL], np->n_mat[I_RAD], np->n_bwork, np->n_tech,
drnuke_const > MIN_DRNUKE_CONST ?
ceil(np->n_tech * drnuke_const) : 0.0,
np->n_cost);
void
show_nuke_capab(int tlev)
{
- struct chr_index chridx[sizeof(nchr) / sizeof(*nchr)];
+ struct chr_index chridx[ARRAY_SIZE(nchr)];
int n = make_nchr_index(chridx, tlev);
int i;
struct nchrstr *np;
void
show_ship_build(int tlev)
{
- struct chr_index chridx[sizeof(mchr) / sizeof(*mchr)];
+ struct chr_index chridx[ARRAY_SIZE(mchr)];
int n = make_mchr_index(chridx, tlev);
int i;
struct mchrstr *mp;
for (i = 0; i < n; i++) {
mp = &mchr[chridx[i].type];
pr("%-25.25s %3d %3d %5d %4d $%d\n",
- mp->m_name, mp->m_lcm, mp->m_hcm,
+ mp->m_name, mp->m_mat[I_LCM], mp->m_mat[I_HCM],
mp->m_bwork, mp->m_tech, mp->m_cost);
}
}
void
show_ship_stats(int tlev)
{
- struct chr_index chridx[sizeof(mchr) / sizeof(*mchr)];
+ struct chr_index chridx[ARRAY_SIZE(mchr)];
int n = make_mchr_index(chridx, tlev);
int i;
struct mchrstr *mp;
void
show_ship_capab(int tlev)
{
- struct chr_index chridx[sizeof(mchr) / sizeof(*mchr)];
+ struct chr_index chridx[ARRAY_SIZE(mchr)];
int n = make_mchr_index(chridx, tlev);
int i;
struct mchrstr *mp;
- pr("%25s cargos & capabilities\n", "");
+ pr("%25s cargoes & capabilities\n", "");
for (i = 0; i < n; i++) {
mp = &mchr[chridx[i].type];
pr("%-25.25s ", mp->m_name);
void
show_plane_stats(int tlev)
{
- struct chr_index chridx[sizeof(plchr) / sizeof(*plchr)];
+ struct chr_index chridx[ARRAY_SIZE(plchr)];
int n = make_plchr_index(chridx, tlev);
int i;
struct plchrstr *pp;
void
show_plane_capab(int tlev)
{
- struct chr_index chridx[sizeof(plchr) / sizeof(*plchr)];
+ struct chr_index chridx[ARRAY_SIZE(plchr)];
int n = make_plchr_index(chridx, tlev);
int i;
struct plchrstr *pp;
void
show_plane_build(int tlev)
{
- struct chr_index chridx[sizeof(plchr) / sizeof(*plchr)];
+ struct chr_index chridx[ARRAY_SIZE(plchr)];
int n = make_plchr_index(chridx, tlev);
int i;
struct plchrstr *pp;
for (i = 0; i < n; i++) {
pp = &plchr[chridx[i].type];
pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
- pp->pl_name, pp->pl_lcm,
- pp->pl_hcm, pp->pl_crew,
+ pp->pl_name, pp->pl_mat[I_LCM],
+ pp->pl_mat[I_HCM], pp->pl_mat[I_MILIT],
pp->pl_bwork, pp->pl_tech, pp->pl_cost);
}
}
void
show_land_build(int tlev)
{
- struct chr_index chridx[sizeof(lchr) / sizeof(*lchr)];
+ struct chr_index chridx[ARRAY_SIZE(lchr)];
int n = make_lchr_index(chridx, tlev);
int i;
struct lchrstr *lp;
for (i = 0; i < n; i++) {
lp = &lchr[chridx[i].type];
pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
- lp->l_name, lp->l_lcm,
- lp->l_hcm,
- lp->l_gun,
+ lp->l_name, lp->l_mat[I_LCM],
+ lp->l_mat[I_HCM],
+ lp->l_mat[I_GUN],
lp->l_bwork, lp->l_tech, lp->l_cost);
}
}
void
show_land_capab(int tlev)
{
- struct chr_index chridx[sizeof(lchr) / sizeof(*lchr)];
+ struct chr_index chridx[ARRAY_SIZE(lchr)];
int n = make_lchr_index(chridx, tlev);
int i;
struct lchrstr *lcp;
void
show_land_stats(int tlev)
{
- struct chr_index chridx[sizeof(lchr) / sizeof(*lchr)];
+ struct chr_index chridx[ARRAY_SIZE(lchr)];
int n = make_lchr_index(chridx, tlev);
int i;
struct lchrstr *lcp;
{
int i, first;
- pr(" desig build 100%% eff maint\n"
- "sector type $ lcm hcm $ $\n");
+ pr(" build 100%% efficiency maint\n"
+ "sector type lcm hcm avail $ $\n");
for (i = 0; dchr[i].d_name; i++) {
if (dchr[i].d_mnem == 0)
continue;
if (dchr[i].d_mob0 < 0)
continue;
- if (dchr[i].d_cost <= 0 && dchr[i].d_build == 1
- && dchr[i].d_lcms == 0 && dchr[i].d_hcms == 0
+ if (dchr[i].d_cost == 100
+ && !dchr[i].d_mat[I_LCM] && !dchr[i].d_mat[I_HCM]
&& dchr[i].d_maint == 0)
continue; /* the usual, skip */
- pr("%c %-21.21s", dchr[i].d_mnem, dchr[i].d_name);
- if (dchr[i].d_cost < 0)
- pr(" can't");
- else
- pr(" %5d", dchr[i].d_cost);
- pr(" %5d%5d %5d %5d\n",
- 100 * dchr[i].d_lcms,
- 100 * dchr[i].d_hcms,
- 100 * dchr[i].d_build,
+ pr("%c %-21.21s %4d %4d %5d %5d %5d\n",
+ dchr[i].d_mnem, dchr[i].d_name,
+ dchr[i].d_mat[I_LCM], dchr[i].d_mat[I_HCM],
+ dchr[i].d_bwork, dchr[i].d_cost,
dchr[i].d_maint * etu_per_update);
}
- pr("any other 0 0 0 100 0\n");
+ pr("any other 0 0 100 100 0\n");
first = 1;
for (i = 0; intrchr[i].in_name; i++) {
if (!intrchr[i].in_enable)
continue;
if (first)
- pr("\nInfrastructure building - adding 1 point of efficiency costs:\n"
- " type lcms hcms mobility $$$$\n");
- pr("%-20s %4d %4d %8d %4d\n",
- intrchr[i].in_name, intrchr[i].in_lcms, intrchr[i].in_hcms,
- intrchr[i].in_mcost, intrchr[i].in_dcost);
+ pr("\n build 100%% efficiency\n"
+ "infrastructure type lcm hcm mobil $\n");
+ pr("%-23.23s %4d %4d %5d %5d\n",
+ intrchr[i].in_name,
+ intrchr[i].in_mat[I_LCM], intrchr[i].in_mat[I_HCM],
+ intrchr[i].in_bmobil, intrchr[i].in_cost);
first = 0;
}
}
{
int i;
- pr(" sector type product p.e.\n");
+ pr(" sector type product p.e. capabilities\n");
for (i = 0; dchr[i].d_name; i++) {
- if (dchr[i].d_mnem == 0 || dchr[i].d_prd < 0)
+ if (dchr[i].d_mnem == 0 || (dchr[i].d_prd < 0 && !dchr[i].d_flags))
continue;
- pr("%c %-23s %-7s %4d%%\n",
- dchr[i].d_mnem, dchr[i].d_name, pchr[dchr[i].d_prd].p_sname,
- dchr[i].d_peffic);
+ pr("%c %-23s ",
+ dchr[i].d_mnem, dchr[i].d_name);
+ if (dchr[i].d_prd >= 0)
+ pr("%-7s %4d%% ",
+ pchr[dchr[i].d_prd].p_sname, dchr[i].d_peffic);
+ else
+ pr(" ");
+ show_capab(dchr[i].d_flags, sect_chr_flags);
+ pr("\n");
}
}
{
struct ichrstr *ip;
- pr("item value sell lbs packing melt item\n");
+ pr("item power sell lbs packing melt item\n");
pr("mnem in no wh ur bk deno name\n");
for (ip = ichr; ip->i_name; ip++) {
- pr(" %c %5d %4s %3d %2d %2d %2d %2d %2d %4d %s\n",
- ip->i_mnem, ip->i_value, ip->i_sell ? "yes" : "no", ip->i_lbs,
+ pr(" %c %5d %4s %3d %2d %2d %2d %2d %2d %4d %s\n",
+ ip->i_mnem, ip->i_power,
+ ip->i_sell ? "yes" : "no",
+ ip->i_lbs,
ip->i_pkg[IPKG], ip->i_pkg[NPKG], ip->i_pkg[WPKG],
ip->i_pkg[UPKG], ip->i_pkg[BPKG],
ip->i_melt_denom, ip->i_name);
int i;
char *lev;
- pr("product cost raw materials reso dep level p.e.\n");
+ pr("product cost raw materials avail reso dep level p.e.\n");
for (pp = pchr; pp->p_sname; pp++) {
if (!pp->p_sname[0])
else
pr(" ");
}
+ pr(" %8d", pp->p_bwork);
if (pp->p_nrndx)
- pr(" %5.5s %3d ",
+ pr(" %5.5s %3d ",
symbol_by_value(pp->p_nrndx, resources), pp->p_nrdep);
else
- pr(" ");
+ pr(" ");
if (pp->p_nlndx < 0)
pr("1.0\n");
else {
int i, j;
pr("id category good will\n");
- pr(" messsages\n");
+ pr(" messages\n");
for (i = 1; i < N_MAX_VERB + 1; i++) {
if (rpt[i].r_newspage == N_NOTUSED)
}
/*
- * Show update policy and up to N scheduled updates.
+ * Show update policy and up to @n scheduled updates.
*/
void
show_updates(int n)
fmttime2822(time_t t)
{
static char buf[32];
-#if defined(_WIN32)
- size_t n;
- int nn;
- TIME_ZONE_INFORMATION tzi;
- long time_offset;
- struct tm *time;
-
- time = localtime(&t);
-
- n = strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S", time);
- if (CANT_HAPPEN(n == 0)) {
- buf[0] = 0;
- return buf;
- }
- GetTimeZoneInformation(&tzi);
- time_offset = -(tzi.Bias +
- (time->tm_isdst ? tzi.DaylightBias : tzi.StandardBias));
-
- nn = _snprintf(buf + n, sizeof(buf) - n, " %+03d%02d",
- time_offset / 60, abs(time_offset) % 60);
- if (CANT_HAPPEN(nn <= 0 || nn + n >= sizeof(buf)))
- buf[0] = 0;
-#else
- size_t n = strftime(buf, sizeof(buf), "%a, %d %b %Y %T %z",
+ size_t n = strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S %z",
localtime(&t));
if (CANT_HAPPEN(n == 0))
buf[0] = 0;
-#endif
return buf;
}