(edit): natarg() no longer supports access to unused countries. Do

it by hand.  Switch to natargp() while we're at it.

(docountry): Remove redundant parameter nat.

(prnat): Change parameter from natid to struct natstr.
This commit is contained in:
Markus Armbruster 2006-01-06 21:31:11 +00:00
parent 1b9641d6d1
commit 1b63d30a51

View file

@ -59,7 +59,7 @@
#define END -1 #define END -1
static void benefit(natid who, int good); static void benefit(natid who, int good);
static int docountry(s_char op, int arg, s_char *p, float farg, natid nat, static int docountry(s_char op, int arg, s_char *p, float farg,
struct natstr *np); struct natstr *np);
static int doland(s_char op, int arg, s_char *p, struct sctstr *sect); static int doland(s_char op, int arg, s_char *p, struct sctstr *sect);
static int doplane(s_char op, int arg, s_char *p, struct plnstr *plane); static int doplane(s_char op, int arg, s_char *p, struct plnstr *plane);
@ -71,7 +71,7 @@ static void noise(struct sctstr *sptr, int public_amt, s_char *name,
static void pr_land(struct lndstr *land); static void pr_land(struct lndstr *land);
static void pr_plane(struct plnstr *plane); static void pr_plane(struct plnstr *plane);
static void pr_ship(struct shpstr *ship); static void pr_ship(struct shpstr *ship);
static void prnat(natid n); static void prnat(struct natstr *);
static void prsect(struct sctstr *sect); static void prsect(struct sctstr *sect);
@ -91,7 +91,6 @@ edit(void)
int arg_index = 3; int arg_index = 3;
coord x, y; coord x, y;
float farg; float farg;
natid nat;
struct natstr *np; struct natstr *np;
s_char buf[1024]; s_char buf[1024];
s_char ewhat; /* saves information from the command line s_char ewhat; /* saves information from the command line
@ -112,10 +111,12 @@ edit(void)
return RET_FAIL; return RET_FAIL;
break; break;
case 'c': case 'c':
if ((num = natarg(player->argp[2], "Country number? ")) < 0) if (!(ptr = getstarg(player->argp[2], "Country number? ", buf)))
return RET_SYN; return RET_SYN;
nat = (natid)num; if (isdigit(*ptr))
np = getnatp(nat); np = getnatp(atoi(ptr));
else
np = natargp(ptr, NULL);
break; break;
case 'p': case 'p':
if ((num = onearg(player->argp[2], "Plane number? ")) < 0) if ((num = onearg(player->argp[2], "Plane number? ")) < 0)
@ -148,7 +149,7 @@ edit(void)
prsect(&sect); prsect(&sect);
break; break;
case 'c': case 'c':
prnat(nat); prnat(np);
break; break;
case 'p': case 'p':
pr_plane(&plane); pr_plane(&plane);
@ -176,7 +177,7 @@ edit(void)
if (err == END) { if (err == END) {
switch (ewhat) { switch (ewhat) {
case 'c': case 'c':
prnat(nat); prnat(np);
break; break;
case 'l': case 'l':
prsect(&sect); prsect(&sect);
@ -200,7 +201,7 @@ edit(void)
switch (ewhat) { switch (ewhat) {
case 'c': case 'c':
farg = (float)atof(ptr); farg = (float)atof(ptr);
if ((err = docountry(thing[0], arg, ptr, farg, nat, np)) if ((err = docountry(thing[0], arg, ptr, farg, np))
!= RET_OK) != RET_OK)
return err; return err;
break; break;
@ -307,14 +308,11 @@ prsect(struct sctstr *sect)
static void static void
prnat(natid n) prnat(struct natstr *np)
{ {
struct natstr *np;
int i; int i;
if ((np = getnatp(n)) == 0) pr("Country #: %2d\n", np->nat_cnum);
return;
pr("Country #: %2d\n", n);
pr("Name <n>: %-20s\t", np->nat_cnam); pr("Name <n>: %-20s\t", np->nat_cnam);
pr("Representative <r>: %-20s\n", np->nat_pnam); pr("Representative <r>: %-20s\n", np->nat_pnam);
pr("BTUs <b>: %3d\t\t\t", np->nat_btu); pr("BTUs <b>: %3d\t\t\t", np->nat_btu);
@ -698,10 +696,11 @@ doland(s_char op, int arg, s_char *p, struct sctstr *sect)
static int static int
docountry(s_char op, int arg, s_char *p, float farg, natid nat, docountry(s_char op, int arg, s_char *p, float farg, struct natstr *np)
struct natstr *np)
{ {
coord newx, newy; coord newx, newy;
natid nat = np->nat_cnum;
switch (op) { switch (op) {
case 'n': case 'n':
pr("Country name changed from %s to %s\n", np->nat_cnam, p); pr("Country name changed from %s to %s\n", np->nat_cnam, p);