prnat() prnatid(): New, common country name (#number) formatting
prnat() is more convenient when you already got the struct natstr *. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
383bbff603
commit
61a32b8b69
10 changed files with 65 additions and 58 deletions
|
@ -181,6 +181,8 @@ extern struct natstr *nat_reset(struct natstr *, natid, char *, char *,
|
|||
enum nat_status);
|
||||
|
||||
extern int check_nat_name(char *, natid);
|
||||
extern char *prnat(struct natstr *);
|
||||
extern char *prnatid(natid);
|
||||
|
||||
extern int grant_btus(struct natstr *, int);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* Known contributors to this file:
|
||||
* Steve McClure, 2000
|
||||
* Markus Armbruster, 2004-2011
|
||||
* Markus Armbruster, 2004-2013
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -110,17 +110,15 @@ add(void)
|
|||
}
|
||||
if (stat == STAT_UNUSED
|
||||
? natp->nat_stat >= STAT_SANCT : natp->nat_stat != STAT_UNUSED) {
|
||||
pr("Country %s (#%d) status is %s.\n"
|
||||
pr("Country %s status is %s.\n"
|
||||
"%s it in this state is normally a bad idea.",
|
||||
natp->nat_cnam, natp->nat_cnum,
|
||||
symbol_by_value(natp->nat_stat, nation_status),
|
||||
prnat(natp), symbol_by_value(natp->nat_stat, nation_status),
|
||||
stat == STAT_UNUSED ? "Deleting" : "Replacing");
|
||||
if (!askyn("Are you sure? "))
|
||||
return RET_FAIL;
|
||||
}
|
||||
if (getplayer(natp->nat_cnum)) {
|
||||
pr("%s (#%d) is logged in!\n",
|
||||
natp->nat_cnam, natp->nat_cnum);
|
||||
pr("%s is logged in!\n", prnat(natp));
|
||||
return RET_FAIL;
|
||||
}
|
||||
nat_reset(natp, natp->nat_cnum, cntryname, pname, stat);
|
||||
|
|
|
@ -368,7 +368,7 @@ print_ship(struct shpstr *ship)
|
|||
|
||||
if (!(natp = getnatp(ship->shp_own)))
|
||||
return;
|
||||
pr("%s (#%d) %s\n", natp->nat_cnam, ship->shp_own, prship(ship));
|
||||
pr("%s %s\n", prnat(natp), prship(ship));
|
||||
pr("UID <U>: %d\n", ship->shp_uid);
|
||||
pr("Owner <O>: %d\t\t\t", ship->shp_own);
|
||||
pr("Location <L>: %s\n", xyas(ship->shp_x, ship->shp_y, player->cnum));
|
||||
|
@ -441,9 +441,9 @@ edit_sect(struct sctstr *sect, char op, int arg, char *p)
|
|||
if (arg < 0)
|
||||
return RET_SYN;
|
||||
newown = (natid)LIMIT_TO(arg, 0, MAXNOC - 1);
|
||||
pr("Owner of %s changed from %s (#%d) to %s (#%d).\n",
|
||||
pr("Owner of %s changed from %s to %s.\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum),
|
||||
cname(sect->sct_own), sect->sct_own, cname(newown), newown);
|
||||
prnatid(sect->sct_own), prnatid(newown));
|
||||
if (sect->sct_own) {
|
||||
wu(player->cnum, sect->sct_own,
|
||||
"Sector %s lost to deity intervention\n",
|
||||
|
@ -462,10 +462,9 @@ edit_sect(struct sctstr *sect, char op, int arg, char *p)
|
|||
if (arg < 0)
|
||||
return RET_SYN;
|
||||
oldown = (natid)LIMIT_TO(arg, 0, MAXNOC - 1);
|
||||
pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
|
||||
pr("Old owner of %s changed from %s to %s.\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum),
|
||||
cname(sect->sct_oldown),
|
||||
sect->sct_oldown, cname(oldown), oldown);
|
||||
prnatid(sect->sct_oldown), prnatid(oldown));
|
||||
sect->sct_oldown = oldown;
|
||||
break;
|
||||
case 'e':
|
||||
|
@ -525,9 +524,9 @@ edit_sect(struct sctstr *sect, char op, int arg, char *p)
|
|||
case 'X':
|
||||
old = sect->sct_che_target;
|
||||
new = LIMIT_TO(arg, 0, MAXNOC - 1);
|
||||
pr("Che target of %s changed from %s (#%d) to %s (#%d).\n",
|
||||
pr("Che target of %s changed from %s to %s.\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum),
|
||||
cname(old), old, cname(new), new);
|
||||
prnatid(old), prnatid(new));
|
||||
sect->sct_che_target = new;
|
||||
if (new == 0)
|
||||
sect->sct_che = 0;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
* Ken Stevens, 1995
|
||||
* Steve McClure, 1998
|
||||
* Ron Koenderink, 2005
|
||||
* Markus Armbruster, 2004-2011
|
||||
* Markus Armbruster, 2004-2013
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -150,17 +150,17 @@ sendmessage(struct natstr *to, char *message, int verbose)
|
|||
|
||||
if (verbose)
|
||||
if (to)
|
||||
pr_flash(other, "FLASH from %s (#%d) @ %02d:%02d%s\n",
|
||||
cname(player->cnum), player->cnum, tm->tm_hour,
|
||||
tm->tm_min, message);
|
||||
pr_flash(other, "FLASH from %s @ %02d:%02d%s\n",
|
||||
prnatid(player->cnum),
|
||||
tm->tm_hour, tm->tm_min, message);
|
||||
else
|
||||
pr_flash(other, "BROADCAST from %s (#%d) @ %02d:%02d%s\n",
|
||||
cname(player->cnum), player->cnum, tm->tm_hour,
|
||||
tm->tm_min, message);
|
||||
pr_flash(other, "BROADCAST from %s @ %02d:%02d%s\n",
|
||||
prnatid(player->cnum),
|
||||
tm->tm_hour, tm->tm_min, message);
|
||||
|
||||
else
|
||||
pr_flash(other, "%s (#%d): %s\n",
|
||||
cname(player->cnum), player->cnum, message);
|
||||
pr_flash(other, "%s: %s\n",
|
||||
prnatid(player->cnum), message);
|
||||
sent++;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
*
|
||||
* Known contributors to this file:
|
||||
* Ron Koenderink, 2006-2007
|
||||
* Markus Armbruster, 2004-2013
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -120,11 +121,9 @@ void look_at_sect(struct sctstr *sp, int mult)
|
|||
int civ, mil;
|
||||
int ours = player->god || sp->sct_own == player->cnum;
|
||||
|
||||
if (sp->sct_own == player->cnum)
|
||||
pr("Your ");
|
||||
else
|
||||
pr("%s (#%d) ", cname(sp->sct_own), sp->sct_own);
|
||||
pr("%s", dchr[sp->sct_type].d_name);
|
||||
pr("%s %s",
|
||||
sp->sct_own == player->cnum ? "Your" : prnatid(sp->sct_own),
|
||||
dchr[sp->sct_type].d_name);
|
||||
pr(" %d%% efficient ",
|
||||
ours ? sp->sct_effic : roundintby(sp->sct_effic, mult));
|
||||
civ = sp->sct_item[I_CIVIL];
|
||||
|
@ -194,8 +193,8 @@ look_ship(struct shpstr *lookship)
|
|||
/* subs at sea only seen by sonar */
|
||||
if (tmcp->m_flags & M_SUB && sect.sct_type == SCT_WATER)
|
||||
continue;
|
||||
pr("%s (#%d) %s @ %s\n",
|
||||
cname(sp->shp_own), sp->shp_own, prship(sp),
|
||||
pr("%s %s @ %s\n",
|
||||
prnatid(sp->shp_own), prship(sp),
|
||||
xyas(sp->shp_x, sp->shp_y, player->cnum));
|
||||
if (opt_HIDDEN)
|
||||
setcont(player->cnum, sp->shp_own, FOUND_LOOK);
|
||||
|
@ -240,9 +239,9 @@ look_land(struct lndstr *lookland)
|
|||
if (dist > vrange)
|
||||
continue;
|
||||
|
||||
pr("%s (#%d) %s (approx %d mil) @ %s\n",
|
||||
cname(lp->lnd_own), lp->lnd_own,
|
||||
prland(lp), roundintby(lp->lnd_item[I_MILIT], 20),
|
||||
pr("%s %s (approx %d mil) @ %s\n",
|
||||
prnatid(lp->lnd_own), prland(lp),
|
||||
roundintby(lp->lnd_item[I_MILIT], 20),
|
||||
xyas(lp->lnd_x, lp->lnd_y, player->cnum));
|
||||
if (opt_HIDDEN)
|
||||
setcont(player->cnum, lp->lnd_own, FOUND_LOOK);
|
||||
|
@ -260,9 +259,9 @@ look_land(struct lndstr *lookland)
|
|||
if (dist > vrange)
|
||||
continue;
|
||||
|
||||
pr("%s (#%d) %s @ %s\n",
|
||||
cname(pp->pln_own), pp->pln_own,
|
||||
prplane(pp), xyas(pp->pln_x, pp->pln_y, player->cnum));
|
||||
pr("%s %s @ %s\n",
|
||||
prnatid(pp->pln_own), prplane(pp),
|
||||
xyas(pp->pln_x, pp->pln_y, player->cnum));
|
||||
if (opt_HIDDEN)
|
||||
setcont(player->cnum, pp->pln_own, FOUND_LOOK);
|
||||
}
|
||||
|
|
|
@ -100,9 +100,9 @@ setsector(void)
|
|||
case 'w':
|
||||
if ((amt < 0) || (amt > MAXNOC - 1))
|
||||
return RET_SYN;
|
||||
pr("Owner of %s changed from %s (#%d) to %s (#%d).\n",
|
||||
pr("Owner of %s changed from %s to %s.\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum),
|
||||
cname(sect.sct_own), sect.sct_own, cname(amt), amt);
|
||||
prnatid(sect.sct_own), prnatid(amt));
|
||||
if (sect.sct_own) {
|
||||
wu(player->cnum, sect.sct_own,
|
||||
"Sector %s lost to deity intervention\n",
|
||||
|
@ -117,10 +117,9 @@ setsector(void)
|
|||
case 'l':
|
||||
if ((amt < 0) || (amt > MAXNOC - 1))
|
||||
return RET_SYN;
|
||||
pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
|
||||
pr("Old owner of %s changed from %s to %s.\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum),
|
||||
cname(sect.sct_oldown),
|
||||
sect.sct_oldown, cname(amt), amt);
|
||||
prnatid(sect.sct_oldown), prnatid(amt));
|
||||
sect.sct_oldown = (natid)amt;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
* Known contributors to this file:
|
||||
* Dave Pare, 1986
|
||||
* Steve McClure, 1998-2000
|
||||
* Markus Armbruster, 2005-2011
|
||||
* Markus Armbruster, 2005-2013
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -138,18 +138,16 @@ spy(void)
|
|||
pr("Spy deported from %s\n",
|
||||
xyas(nx, ny, player->cnum));
|
||||
if (own != 0)
|
||||
wu(0, own, "%s (#%d) spy deported from %s\n",
|
||||
cname(player->cnum), player->cnum,
|
||||
xyas(nx, ny, own));
|
||||
wu(0, own, "%s spy deported from %s\n",
|
||||
prnat(natp), xyas(nx, ny, own));
|
||||
} else {
|
||||
/* execute spy */
|
||||
pr("BANG!! A spy was shot in %s\n",
|
||||
xyas(nx, ny, player->cnum));
|
||||
military--;
|
||||
if (own != 0)
|
||||
wu(0, own, "%s (#%d) spy caught in %s\n",
|
||||
cname(player->cnum), player->cnum,
|
||||
xyas(nx, ny, own));
|
||||
wu(0, own, "%s spy caught in %s\n",
|
||||
prnat(natp), xyas(nx, ny, own));
|
||||
nreport(player->cnum, N_SPY_SHOT, own, 1);
|
||||
}
|
||||
if (opt_HIDDEN)
|
||||
|
|
|
@ -550,8 +550,8 @@ board_abort(struct combat *off, struct combat *def)
|
|||
pr("Victim ship moves faster than you do!\n");
|
||||
if (def->own)
|
||||
wu(0, def->own,
|
||||
"%s (#%d) %s failed to catch %s\n",
|
||||
cname(aship.shp_own), aship.shp_own,
|
||||
"%s %s failed to catch %s\n",
|
||||
prnatid(aship.shp_own),
|
||||
pr_com(0, off, def->own), pr_com(0, def, def->own));
|
||||
return abort_attack();
|
||||
}
|
||||
|
@ -1982,8 +1982,8 @@ att_fight(int combat_mode, struct combat *off, struct emp_qelem *olist,
|
|||
nreport(player->cnum, news_item, def->own, 1);
|
||||
if (def->own) {
|
||||
wu(0, def->own,
|
||||
"%s (#%d) lost %d troops %s %s\nWe lost %d troops defending\n",
|
||||
cname(player->cnum), player->cnum, a_cas,
|
||||
"%s lost %d troops %s %s\nWe lost %d troops defending\n",
|
||||
prnatid(player->cnum), a_cas,
|
||||
action, pr_com(0, def, def->own), d_cas);
|
||||
}
|
||||
|
||||
|
@ -2155,8 +2155,8 @@ att_empty_attack(int combat_mode, int ototal, struct combat *def)
|
|||
if (ototal <= 0) {
|
||||
if (def->own && player->cnum != def->own) {
|
||||
wu(0, def->own,
|
||||
"%s (#%d) considered %sing you @%s\n",
|
||||
cname(player->cnum), player->cnum,
|
||||
"%s considered %sing you @%s\n",
|
||||
prnatid(player->cnum),
|
||||
att_mode[combat_mode], xyas(def->x, def->y, def->own));
|
||||
}
|
||||
pr("No troops for %s...\n", att_mode[combat_mode]);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
* nat.c: Nation subroutines
|
||||
*
|
||||
* Known contributors to this file:
|
||||
* Markus Armbruster, 2009-2011
|
||||
* Markus Armbruster, 2009-2013
|
||||
* Ron Koenderink, 2008-2009
|
||||
*/
|
||||
|
||||
|
@ -72,3 +72,15 @@ check_nat_name(char *cname, natid cnum)
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *
|
||||
prnat(struct natstr *np)
|
||||
{
|
||||
return prbuf("%s (#%d)", np->nat_cnam, np->nat_cnum);
|
||||
}
|
||||
|
||||
char *
|
||||
prnatid(natid cnum)
|
||||
{
|
||||
return prbuf("%s (#%d)", cname(cnum), cnum);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* Known contributors to this file:
|
||||
* Dave Pare, 1994
|
||||
* Markus Armbruster, 2005-2011
|
||||
* Markus Armbruster, 2005-2013
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -91,8 +91,8 @@ setrel(natid us, natid them, int rel)
|
|||
cname(them), whichway, relates[rel]);
|
||||
if (!(getrejects(us, themnp) & REJ_TELE))
|
||||
mpr(them,
|
||||
"Country %s (#%d) has %s their relations with you to \"%s\"!\n",
|
||||
cname(us), us, whichway, relates[rel]);
|
||||
"Country %s has %s their relations with you to \"%s\"!\n",
|
||||
prnat(mynp), whichway, relates[rel]);
|
||||
|
||||
putrel(mynp, them, rel);
|
||||
putnat(mynp);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue