/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
#include <config.h>
#include <string.h>
+#include <ctype.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include "game.h"
#include "nat.h"
#include "optlist.h"
+#include "prototypes.h"
#include "tel.h"
#include "xy.h"
natp->nat_yorg = 0;
}
- natp->nat_dayno = 0;
natp->nat_timeused = 0;
natp->nat_update = 0;
game_tick_to_now(&natp->nat_access);
natp->nat_reserve = 0;
natp->nat_money = stat == STAT_SANCT ? start_cash : 0;
- natp->nat_last_login = natp->nat_last_login = 0;
+ natp->nat_last_login = natp->nat_last_logout = 0;
natp->nat_newstim = 0;
natp->nat_annotim = 0;
natp->nat_level[NAT_HLEV] = start_happiness;
return natp;
}
+
+int
+check_nat_name(char *cname)
+{
+ struct natstr *natp;
+ natid cn;
+ int allblank;
+ char *p;
+
+ if (strlen(cname) >= sizeof(natp->nat_cnam)) {
+ pr("Country name too long\n");
+ return 0;
+ }
+
+ allblank = 1;
+ for (p = cname; *p != '\0'; p++) {
+ if (iscntrl(*p)) {
+ pr("No control characters allowed in country names!\n");
+ return 0;
+ } else if (!isspace(*p))
+ allblank = 0;
+ }
+ if (allblank) {
+ pr("Country name can't be all blank\n");
+ return 0;
+ }
+
+ for (cn = 0; NULL != (natp = getnatp(cn)); cn++) {
+ if (!strcmp(cname, natp->nat_cnam)) {
+ pr("Country #%d is already called `%s'\n", cn, cname);
+ return 0;
+ }
+ }
+ return 1;
+}