From 5ffef496ea53edeffda13d729052f097e7a61188 Mon Sep 17 00:00:00 2001 From: Ron Koenderink Date: Sat, 17 Dec 2005 20:18:54 +0000 Subject: [PATCH] (coun_list, repo_list, nati): Replace in-flux determination code with influx(). (influx): New. --- include/nat.h | 1 + src/lib/commands/coun.c | 5 +---- src/lib/commands/nati.c | 4 +--- src/lib/commands/repo.c | 7 +------ src/lib/common/nat.c | 15 +++++++++++++++ 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/include/nat.h b/include/nat.h index c31647d24..c210ef987 100644 --- a/include/nat.h +++ b/include/nat.h @@ -172,6 +172,7 @@ extern void putrel(struct natstr *np, natid them, int relate); extern void putreject(struct natstr *np, natid them, int how, int what); extern void putcontact(struct natstr *np, natid them, int contact); extern void agecontact(struct natstr *np); +extern int influx(struct natstr *np); /* nation flags */ #define NF_INFORM bit(0) /* Inform me of telegrams right away */ diff --git a/src/lib/commands/coun.c b/src/lib/commands/coun.c index 9e0e57dba..52c8f2216 100644 --- a/src/lib/commands/coun.c +++ b/src/lib/commands/coun.c @@ -68,7 +68,6 @@ static void coun_list(struct natstr *natp) { char *status; - struct sctstr sect; natid cn = natp->nat_cnum; pr("%3d ", cn); @@ -102,9 +101,7 @@ coun_list(struct natstr *natp) else if (natp->nat_stat & STAT_NORM) { status = "Active"; if (!opt_HIDDEN || player->god) { - getsect(natp->nat_xcap, natp->nat_ycap, §); - if (sect.sct_own != cn || - (sect.sct_type != SCT_CAPIT && sect.sct_type != SCT_MOUNT)) + if (influx(natp)) status = "In flux"; else if (natp->nat_money < 0) status = "Broke"; diff --git a/src/lib/commands/nati.c b/src/lib/commands/nati.c index a9b12141c..79ff79266 100644 --- a/src/lib/commands/nati.c +++ b/src/lib/commands/nati.c @@ -61,9 +61,7 @@ nati(void) pr(" Bureaucratic Time Units: %d\n", natp->nat_btu); if (natp->nat_stat & STAT_INUSE) { getsect(natp->nat_xcap, natp->nat_ycap, §); - if (!player->owner || (sect.sct_type != SCT_CAPIT && - sect.sct_type != SCT_MOUNT && - sect.sct_type != SCT_SANCT)) + if (influx(natp)) pr("No capital. (was at %s)\n", xyas(sect.sct_x, sect.sct_y, player->cnum)); else { diff --git a/src/lib/commands/repo.c b/src/lib/commands/repo.c index 7b8039590..d98231733 100644 --- a/src/lib/commands/repo.c +++ b/src/lib/commands/repo.c @@ -121,8 +121,6 @@ repo_header(void) static void repo_list(struct stats *stat, natid cn, struct natstr *natp) { - struct sctstr cap; - if (player->god) { pr(" %-3d %-14.14s ", cn, natp->nat_cnam); pr(" %7.2f %7.2f %7.2f %7.2f", @@ -139,13 +137,10 @@ repo_list(struct stats *stat, natid cn, struct natstr *natp) printdiff(stat->stat, stat->res, natp, NAT_RLEV); printdiff(stat->stat, stat->edu, natp, NAT_ELEV); printdiff(stat->stat, stat->hap, natp, NAT_HLEV); - getsect(natp->nat_xcap, natp->nat_ycap, &cap); if (opt_HIDDEN) { pr("\n"); } else { - if ((cap.sct_own != cn) || - (cap.sct_type != SCT_CAPIT && cap.sct_type != SCT_MOUNT) || - (natp->nat_flags & NF_SACKED)) + if (influx(natp)) pr("In flux\n"); else if (natp->nat_money <= 0) pr("Broke\n"); diff --git a/src/lib/common/nat.c b/src/lib/common/nat.c index e8bd47628..55940b325 100644 --- a/src/lib/common/nat.c +++ b/src/lib/common/nat.c @@ -170,3 +170,18 @@ putcontact(struct natstr *np, natid them, int contact) if (np->nat_contact[them] < contact) np->nat_contact[them] = contact; } + +int +influx(struct natstr *np) +{ + struct sctstr sect; + + getsect(np->nat_xcap, np->nat_ycap, §); + if (sect.sct_own != np->nat_cnum || + (sect.sct_type != SCT_CAPIT && sect.sct_type != SCT_MOUNT && + sect.sct_type != SCT_SANCT) || + (np->nat_flags & NF_SACKED)) + return 1; + else + return 0; +} -- 2.43.0