Permit no-op country name change again

Commit aa5861d1 (v4.3.20) made add, edit and change reject a country
name that is already in use.  Even if it's used by the same country.
Relax that.
This commit is contained in:
Markus Armbruster 2011-10-30 15:43:56 +01:00
parent 9b2e906ea1
commit 062c660e28
5 changed files with 9 additions and 8 deletions

View file

@ -180,7 +180,7 @@ extern int influx(struct natstr *np);
extern struct natstr *nat_reset(struct natstr *, enum nat_status,
coord, coord);
extern int check_nat_name(char *cname);
extern int check_nat_name(char *, natid);
extern int grant_btus(struct natstr *, int);

View file

@ -28,6 +28,7 @@
*
* Known contributors to this file:
* Steve McClure, 2000
* Markus Armbruster, 2004-2011
*/
#include <config.h>
@ -84,7 +85,7 @@ add(void)
p = getstarg(player->argp[2], "Country name? ", buf);
if (!p)
return RET_SYN;
if (!check_nat_name(p))
if (!check_nat_name(p, coun))
return RET_FAIL;
strcpy(cntryname, p);
p = getstarg(player->argp[3], "Representative? ", buf);

View file

@ -77,7 +77,7 @@ chan(void)
p = getstarg(player->argp[2], "New country name -- ", buf);
if (!p)
return RET_SYN;
if (!check_nat_name(p))
if (!check_nat_name(p, player->cnum))
return RET_FAIL;
player->dolcost += charge;
player->btused += btucost;

View file

@ -31,7 +31,7 @@
* Chad Zabel, 1994
* Steve McClure, 1998-2000
* Ron Koenderink, 2003-2009
* Markus Armbruster, 2003-2010
* Markus Armbruster, 2003-2011
*/
#include <config.h>
@ -657,7 +657,7 @@ docountry(char op, int arg, char *p, struct natstr *np)
switch (op) {
case 'n':
if (!check_nat_name(p))
if (!check_nat_name(p, nat))
return RET_SYN;
pr("Country name changed from %s to %s\n", np->nat_cnam, p);
strcpy(np->nat_cnam, p);

View file

@ -27,7 +27,7 @@
* nat.c: Nation subroutines
*
* Known contributors to this file:
* Markus Armbruster, 2009
* Markus Armbruster, 2009-2011
* Ron Koenderink, 2008-2009
*/
@ -117,7 +117,7 @@ nat_reset(struct natstr *natp, enum nat_status stat, coord x, coord y)
}
int
check_nat_name(char *cname)
check_nat_name(char *cname, natid cnum)
{
struct natstr *natp;
natid cn;
@ -143,7 +143,7 @@ check_nat_name(char *cname)
}
for (cn = 0; NULL != (natp = getnatp(cn)); cn++) {
if (!strcmp(cname, natp->nat_cnam)) {
if (cn != cnum && !strcmp(cname, natp->nat_cnam)) {
pr("Country #%d is already called `%s'\n", cn, cname);
return 0;
}