2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * nat.c: Nation subroutines
29 * Known contributors to this file:
30 * Markus Armbruster, 2009-2011
31 * Ron Koenderink, 2008-2009
44 #include "prototypes.h"
48 * Initialize NATP for country #CNUM in status STAT.
49 * STAT must be STAT_UNUSED, STAT_NEW, STAT_VIS or STAT_GOD.
50 * Also wipe realms and telegrams.
53 nat_reset(struct natstr *natp, natid cnum, enum nat_status stat)
55 struct realmstr newrealm;
59 ef_blank(EF_NATION, cnum, natp);
60 natp->nat_stat = stat;
61 for (i = 0; i < MAXNOR; i++) {
62 ef_blank(EF_REALM, i + cnum * MAXNOR, &newrealm);
65 close(creat(mailbox(buf, cnum),
66 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP));
67 /* FIXME natp->nat_ann = #annos */
68 natp->nat_level[NAT_HLEV] = start_happiness;
69 natp->nat_level[NAT_RLEV] = start_research;
70 natp->nat_level[NAT_TLEV] = start_technology;
71 natp->nat_level[NAT_ELEV] = start_education;
72 for (i = 0; i < MAXNOC; i++)
73 natp->nat_relate[i] = NEUTRAL;
75 NF_FLASH | NF_BEEP | NF_COASTWATCH | NF_SONAR | NF_TECHLISTS;
80 check_nat_name(char *cname, natid cnum)
87 if (strlen(cname) >= sizeof(natp->nat_cnam)) {
88 pr("Country name too long\n");
93 for (p = cname; *p != '\0'; p++) {
95 pr("No control characters allowed in country names!\n");
97 } else if (!isspace(*p))
101 pr("Country name can't be all blank\n");
105 for (cn = 0; NULL != (natp = getnatp(cn)); cn++) {
106 if (cn != cnum && !strcmp(cname, natp->nat_cnam)) {
107 pr("Country #%d is already called `%s'\n", cn, cname);