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);
87 if (p == 0 || *p == 0)
89 if (strlen(p) >= sizeof(cntryname)) {
90 pr("Country name too long\n");
94 p = getstarg(player->argp[3], "Representative? ", buf);
95 if (p == 0 || *p == 0)
97 if (strlen(p) >= sizeof(pname)) {
98 pr("Representative too long\n");
102 p = getstarg(player->argp[4],
103 "Status? (visitor, new, active, god, delete) ", buf);
104 if (p == 0 || *p == 0)
123 pr("Illegal status\n");
126 p = getstarg(player->argp[5],
127 "Check, wipe, or ignore existing sectors (c|w|i) ", buf);
130 snxtitem_all(&ni, EF_LAND);
131 while (nxtitem(&ni, &land)) {
132 if (land.lnd_own == coun) {
134 pr("Land unit %d wiped\n", land.lnd_uid);
135 putland(land.lnd_uid, &land);
138 strcpy(natp->nat_cnam, cntryname);
139 strcpy(natp->nat_pnam, pname);
140 if (*p != 'w' && *p != 'c') {
141 pr("Any existing sectors ignored\n");
143 pr("Checking sectors...\n");
145 while (nxtsct(&nstr, §)) {
146 if (sect.sct_own != coun)
148 pr("%s ", xyas(nstr.x, nstr.y, player->cnum));
154 sect.sct_defense = 0;
157 if (sect.sct_type == SCT_BSPAN ||
158 sect.sct_type == SCT_BTOWER)
159 sect.sct_newtype = sect.sct_type = SCT_WATER;
160 else if (sect.sct_type != SCT_MOUNT &&
161 sect.sct_type != SCT_PLAINS)
162 sect.sct_newtype = sect.sct_type = SCT_RURAL;
164 sect.sct_dist_x = sect.sct_x;
165 sect.sct_dist_y = sect.sct_y;
166 memset(sect.sct_item, 0, sizeof(sect.sct_item));
167 memset(sect.sct_del, 0, sizeof(sect.sct_del));
168 memset(sect.sct_dist, 0, sizeof(sect.sct_dist));
170 sect.sct_pstage = PLG_HEALTHY;
173 sect.sct_che_target = 0;
174 sect.sct_fallout = 0;
183 if (stat == STAT_NEW || stat == STAT_VIS)
184 nat_reset(natp, stat, 0, 0);
186 pr("No special initializations done...\n");