2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program 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 2 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, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future projects/authors will amend these files as needed.
28 * add.c: Add a new country to the game
30 * Known contributors to this file:
51 struct nstr_sect nstr;
53 char cntryname[sizeof(natp->nat_cnam)];
54 char pname[sizeof(natp->nat_pnam)];
64 for (freecn = 0; NULL != (natp = getnatp(freecn)); freecn++) {
65 if (natp->nat_stat == STAT_UNUSED)
69 sprintf(prompt, "New country number? (%d is unused) ", freecn);
71 strcpy(prompt, "New country number? (they all seem to be used) ");
72 p = getstarg(player->argp[1], prompt, buf);
73 if (p == 0 || *p == 0)
77 pr("Max # countries is %d\n", MAXNOC);
82 pr("Not allowed to add country #0\n");
86 p = getstarg(player->argp[2], "Country Name? ", buf);
89 if (!check_nat_name(p))
92 p = getstarg(player->argp[3], "Representative? ", buf);
93 if (p == 0 || *p == 0)
95 if (strlen(p) >= sizeof(pname)) {
96 pr("Representative too long\n");
100 p = getstarg(player->argp[4],
101 "Status? (visitor, new, active, god, delete) ", buf);
102 if (p == 0 || *p == 0)
121 pr("Illegal status\n");
124 p = getstarg(player->argp[5],
125 "Check, wipe, or ignore existing sectors (c|w|i) ", buf);
128 snxtitem_all(&ni, EF_LAND);
129 while (nxtitem(&ni, &land)) {
130 if (land.lnd_own == coun) {
132 pr("Land unit %d wiped\n", land.lnd_uid);
133 putland(land.lnd_uid, &land);
136 strcpy(natp->nat_cnam, cntryname);
137 strcpy(natp->nat_pnam, pname);
138 if (*p != 'w' && *p != 'c') {
139 pr("Any existing sectors ignored\n");
141 pr("Checking sectors...\n");
143 while (nxtsct(&nstr, §)) {
144 if (sect.sct_own != coun)
146 pr("%s ", xyas(nstr.x, nstr.y, player->cnum));
152 sect.sct_defense = 0;
155 sect.sct_newtype = sect.sct_type
156 = dchr[sect.sct_type].d_terrain;
157 sect.sct_dist_x = sect.sct_x;
158 sect.sct_dist_y = sect.sct_y;
159 memset(sect.sct_item, 0, sizeof(sect.sct_item));
160 memset(sect.sct_del, 0, sizeof(sect.sct_del));
161 memset(sect.sct_dist, 0, sizeof(sect.sct_dist));
163 sect.sct_pstage = PLG_HEALTHY;
166 sect.sct_che_target = 0;
167 sect.sct_fallout = 0;
176 if (stat == STAT_NEW || stat == STAT_VIS)
177 nat_reset(natp, stat, 0, 0);
179 natp->nat_stat = stat;
180 pr("No special initializations done...\n");