2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2010, 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:
50 struct nstr_sect nstr;
52 char cntryname[sizeof(natp->nat_cnam)];
53 char pname[sizeof(natp->nat_pnam)];
63 for (freecn = 0; NULL != (natp = getnatp(freecn)); freecn++) {
64 if (natp->nat_stat == STAT_UNUSED)
68 sprintf(prompt, "New country number? (%d is unused) ", freecn);
70 strcpy(prompt, "New country number? (they all seem to be used) ");
71 p = getstarg(player->argp[1], prompt, buf);
76 pr("Max # countries is %d\n", MAXNOC);
81 pr("Not allowed to add country #0\n");
85 p = getstarg(player->argp[2], "Country Name? ", buf);
88 if (!check_nat_name(p))
91 p = getstarg(player->argp[3], "Representative? ", buf);
94 if (strlen(p) >= sizeof(pname)) {
95 pr("Representative too long\n");
99 p = getstarg(player->argp[4],
100 "Status? (visitor, new, active, god, delete) ", buf);
120 pr("Illegal status\n");
123 p = getstarg(player->argp[5],
124 "Check, wipe, or ignore existing sectors (c|w|i) ", buf);
127 snxtitem_all(&ni, EF_LAND);
128 while (nxtitem(&ni, &land)) {
129 if (land.lnd_own == coun) {
131 pr("Land unit %d wiped\n", land.lnd_uid);
132 putland(land.lnd_uid, &land);
135 strcpy(natp->nat_cnam, cntryname);
136 strcpy(natp->nat_pnam, pname);
137 if (*p != 'w' && *p != 'c') {
138 pr("Any existing sectors ignored\n");
140 pr("Checking sectors...\n");
142 while (nxtsct(&nstr, §)) {
143 if (sect.sct_own != coun)
145 pr("%s ", xyas(nstr.x, nstr.y, player->cnum));
151 sect.sct_defense = 0;
154 sect.sct_newtype = sect.sct_type
155 = dchr[sect.sct_type].d_terrain;
156 sect.sct_dist_x = sect.sct_x;
157 sect.sct_dist_y = sect.sct_y;
158 memset(sect.sct_item, 0, sizeof(sect.sct_item));
159 memset(sect.sct_del, 0, sizeof(sect.sct_del));
160 memset(sect.sct_dist, 0, sizeof(sect.sct_dist));
162 sect.sct_pstage = PLG_HEALTHY;
165 sect.sct_che_target = 0;
166 sect.sct_fallout = 0;
175 if (stat == STAT_NEW || stat == STAT_VIS)
176 nat_reset(natp, stat, 0, 0);
178 natp->nat_stat = stat;
179 pr("No special initializations done...\n");