00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <config.h>
00035
00036 #include "commands.h"
00037 #include "news.h"
00038 #include "optlist.h"
00039 #include <ctype.h>
00040
00041 int
00042 chan(void)
00043 {
00044 char *temp;
00045 struct natstr *natp;
00046 char *p;
00047 natid cn;
00048 int charge;
00049 int nonb;
00050 int btucost;
00051 char buf[1024];
00052 struct natstr *us;
00053
00054 if ((p =
00055 getstarg(player->argp[1], "country name or representative? ",
00056 buf)) == 0)
00057 return RET_SYN;
00058 us = getnatp(player->cnum);
00059 if (us->nat_stat == STAT_VIS) {
00060 pr("Visitor countries can't change their country name or representative.\n");
00061 return RET_FAIL;
00062 }
00063 switch (*p) {
00064 case 'n':
00065 case 'c':
00066 charge = 0;
00067 btucost = 0;
00068 if (us->nat_stat == STAT_ACTIVE) {
00069 if (opt_BLITZ == 0) {
00070 if (us->nat_btu < 254) {
00071 pr("You need 254 btus to change your country name!\n");
00072 return RET_FAIL;
00073 }
00074 pr("This command costs 254 BTU's and 10%% of your money.\n");
00075 if (!confirm("Are you sure you want to do this? "))
00076 return RET_FAIL;
00077 btucost = 254;
00078 if (us->nat_money <= 0)
00079 charge = 0;
00080 else
00081 charge = us->nat_money / 10;
00082 }
00083 }
00084 if ((p =
00085 getstarg(player->argp[2], "New country name -- ", buf)) == 0)
00086 return RET_SYN;
00087 p[sizeof(us->nat_cnam) - 1] = 0;
00088 for (cn = 0; NULL != (natp = getnatp(cn)); cn++) {
00089 if (!strcmp(p, natp->nat_cnam)) {
00090 pr("Country #%d is already called `%s'!\n", cn, p);
00091 return RET_FAIL;
00092 }
00093 }
00094 nonb = 0;
00095 for (temp = p; *temp != '\0'; temp++) {
00096 if (iscntrl(*temp)) {
00097 pr("No control characters allowed in country names!\n");
00098 return RET_FAIL;
00099 } else if (*temp != ' ')
00100 nonb = 1;
00101 }
00102 if (!nonb) {
00103 pr("Must have a non-blank name!\n");
00104 return RET_FAIL;
00105 }
00106 player->dolcost += charge;
00107 player->btused += btucost;
00108 strcpy(us->nat_cnam, p);
00109 putnat(us);
00110 nreport(player->cnum, N_NAME_CHNG, 0, 1);
00111 break;
00112 case 'p':
00113 case 'r':
00114 pr("(note: these are stored in plain text.)\n");
00115 if ((p = getstarg(player->argp[2],
00116 "New representative name -- ", buf)) == 0)
00117 return RET_SYN;
00118 p[sizeof(us->nat_pnam) - 1] = 0;
00119 strcpy(us->nat_pnam, p);
00120 putnat(us);
00121 break;
00122 default:
00123 pr("Only \"country\" or \"representative\" can change.\n");
00124 return RET_SYN;
00125 }
00126 return RET_OK;
00127 }