Implement toggle techlists for show nuke
This was probably neglected when the techlists feature was added in v4.0.0, because compiled-in nukes were sorted by tech, unlike ships, planes and land units. Customization can break that.
This commit is contained in:
parent
0846ebb440
commit
4c1f8ead27
1 changed files with 29 additions and 7 deletions
|
@ -132,6 +132,25 @@ make_lchr_index(struct chr_index chridx[], int tlev)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
make_nchr_index(struct chr_index chridx[], int tlev)
|
||||||
|
{
|
||||||
|
struct natstr *natp = getnatp(player->cnum);
|
||||||
|
int i, n;
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
for (i = 0; nchr[i].n_name; i++) {
|
||||||
|
if (nchr[i].n_tech > tlev)
|
||||||
|
continue;
|
||||||
|
chridx[n].type = i;
|
||||||
|
chridx[n].tech = nchr[i].n_tech;
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
if (natp->nat_flags & NF_TECHLISTS)
|
||||||
|
qsort(chridx, n, sizeof(*chridx), chr_index_cmp);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
show_bridge(int tlev)
|
show_bridge(int tlev)
|
||||||
{
|
{
|
||||||
|
@ -165,15 +184,17 @@ show_nuke_stats(int tlev)
|
||||||
void
|
void
|
||||||
show_nuke_build(int tlev)
|
show_nuke_build(int tlev)
|
||||||
{
|
{
|
||||||
|
struct chr_index chridx[sizeof(nchr) / sizeof(*nchr)];
|
||||||
|
int n = make_nchr_index(chridx, tlev);
|
||||||
|
int i;
|
||||||
struct nchrstr *np;
|
struct nchrstr *np;
|
||||||
int avail;
|
int avail;
|
||||||
|
|
||||||
pr("%13s lcm hcm oil rad avail tech res $\n", "");
|
pr("%13s lcm hcm oil rad avail tech res $\n", "");
|
||||||
|
|
||||||
for (np = nchr; np->n_name; np++) {
|
for (i = 0; i < n; i++) {
|
||||||
|
np = &nchr[chridx[i].type];
|
||||||
avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
|
avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
|
||||||
if (np->n_tech > tlev)
|
|
||||||
continue;
|
|
||||||
pr("%-13.13s %3d %3d %4d %4d %5d %4d %3.0f $%6d\n",
|
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_name, np->n_lcm, np->n_hcm, np->n_oil,
|
||||||
np->n_rad, avail, np->n_tech,
|
np->n_rad, avail, np->n_tech,
|
||||||
|
@ -186,13 +207,14 @@ show_nuke_build(int tlev)
|
||||||
void
|
void
|
||||||
show_nuke_capab(int tlev)
|
show_nuke_capab(int tlev)
|
||||||
{
|
{
|
||||||
|
struct chr_index chridx[sizeof(nchr) / sizeof(*nchr)];
|
||||||
|
int n = make_nchr_index(chridx, tlev);
|
||||||
|
int i;
|
||||||
struct nchrstr *np;
|
struct nchrstr *np;
|
||||||
|
|
||||||
pr("%13s blst dam lbs tech res $%7s abilities\n", "", "");
|
pr("%13s blst dam lbs tech res $%7s abilities\n", "", "");
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
for (np = nchr; np->n_name; np++) {
|
np = &nchr[chridx[i].type];
|
||||||
if (np->n_tech > tlev)
|
|
||||||
continue;
|
|
||||||
pr("%-13.13s %4d %3d %3d %4d %3.0f $%7d",
|
pr("%-13.13s %4d %3d %3d %4d %3.0f $%7d",
|
||||||
np->n_name, np->n_blast, np->n_dam,
|
np->n_name, np->n_blast, np->n_dam,
|
||||||
np->n_weight, np->n_tech,
|
np->n_weight, np->n_tech,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue