Clean up how snxtitem() parses country names
Old code didn't check for natarg() failure, but relied on sarg_type("-1") returning NS_UNDEF.
This commit is contained in:
parent
fc00db8f5d
commit
bd34378900
1 changed files with 6 additions and 4 deletions
|
@ -55,11 +55,10 @@ snxtitem(struct nstr_item *np, int type, char *str)
|
|||
{
|
||||
struct range range;
|
||||
int list[NS_LSIZE];
|
||||
int n;
|
||||
int cnum, n;
|
||||
coord cx, cy;
|
||||
int dist;
|
||||
int flags;
|
||||
char natnumber[16];
|
||||
char prompt[128];
|
||||
char buf[1024];
|
||||
|
||||
|
@ -76,8 +75,11 @@ snxtitem(struct nstr_item *np, int type, char *str)
|
|||
return 0;
|
||||
}
|
||||
if (type == EF_NATION && isalpha(*str)) {
|
||||
sprintf(natnumber, "%d", natarg(str, NULL));
|
||||
str = natnumber;
|
||||
cnum = natarg(str, NULL);
|
||||
if (cnum < 0)
|
||||
return 0;
|
||||
sprintf(buf, "%d", cnum);
|
||||
str = buf;
|
||||
}
|
||||
flags = ef_flags(type);
|
||||
switch (sarg_type(str)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue