]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/chan.c
Add standard checks to the assigning of a country name
[empserver] / src / lib / commands / chan.c
index 03da08d01573768d7fb8e39a5b6c0f99cd2fa769..176b4238027424dd4fa6190f8102a1129acb63cf 100644 (file)
@@ -33,7 +33,6 @@
 
 #include <config.h>
 
-#include <ctype.h>
 #include "commands.h"
 #include "news.h"
 #include "optlist.h"
 int
 chan(void)
 {
-    char *temp;
-    struct natstr *natp;
     char *p;
-    natid cn;
     int charge;
-    int nonb;
     int btucost;
     char buf[1024];
     struct natstr *us;
@@ -84,25 +79,8 @@ chan(void)
        if ((p =
             getstarg(player->argp[2], "New country name -- ", buf)) == 0)
            return RET_SYN;
-       p[sizeof(us->nat_cnam) - 1] = 0;
-       for (cn = 0; NULL != (natp = getnatp(cn)); cn++) {
-           if (!strcmp(p, natp->nat_cnam)) {
-               pr("Country #%d is already called `%s'!\n", cn, p);
-               return RET_FAIL;
-           }
-       }
-       nonb = 0;
-       for (temp = p; *temp != '\0'; temp++) {
-           if (iscntrl(*temp)) {
-               pr("No control characters allowed in country names!\n");
-               return RET_FAIL;
-           } else if (*temp != ' ')
-               nonb = 1;
-       }
-       if (!nonb) {
-           pr("Must have a non-blank name!\n");
+       if (!check_nat_name(p))
            return RET_FAIL;
-       }
        player->dolcost += charge;
        player->btused += btucost;
        strcpy(us->nat_cnam, p);