2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, 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 the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * add.c: Add a new country to the game
30 * Known contributors to this file:
48 extern float start_education, start_happiness;
49 extern float start_technology, start_research;
56 struct nstr_sect nstr;
70 for (freecn = 0; NULL != (natp = getnatp(freecn)); freecn++) {
71 if ((natp->nat_stat & STAT_INUSE) == 0)
75 sprintf(prompt, "New country number? (%d is unused) ", freecn);
77 strcpy(prompt, "New country number? (they all seem to be used) ");
78 while ((p = getstarg(player->argp[1], prompt, buf)) && *p) {
82 pr("Max # countries is %d\n", MAXNOC);
85 if (p == 0 || *p == 0)
88 pr("Not allowed to add country #0\n");
92 while ((p = getstarg(player->argp[2], "Country Name? ", buf)) && *p) {
94 (void)strcpy(cntryname, p);
100 if (p == 0 || *p == 0)
102 while ((p = getstarg(player->argp[3], "Representative? ", buf)) && *p) {
103 if (strlen(p) < 20) {
104 (void)strcpy(pname, p);
110 if (p == 0 || *p == 0)
113 stat = natp->nat_stat;
114 strcpy(prompt, "Status? (visitor, new, active, god, delete) ");
115 while (loopflag && (p = getstarg(player->argp[4], prompt, buf))) {
122 stat = STAT_NEW | STAT_INUSE;
125 stat = STAT_NORM | STAT_INUSE;
128 stat = STAT_GOD | STAT_NORM | STAT_INUSE;
134 pr("Illegal selection\n");
142 p = getstarg(player->argp[5],
143 "Check, wipe, or ignore existing sectors (c|w|i) ", buf);
146 snxtitem_all(&ni, EF_LAND);
147 while (nxtitem(&ni, (s_char *)&land)) {
148 if (land.lnd_own == coun) {
149 makelost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x,
152 pr("Land unit %d wiped\n", land.lnd_uid);
153 putland(land.lnd_uid, &land);
156 natp->nat_stat = stat;
157 strcpy(natp->nat_cnam, cntryname);
158 strcpy(natp->nat_pnam, pname);
159 if (*p != 'w' && *p != 'c') {
160 pr("Any existing sectors ignored\n");
162 pr("Checking sectors...\n");
164 while (nxtsct(&nstr, §)) {
165 if (sect.sct_own != coun)
167 pr("%s ", xyas(nstr.x, nstr.y, player->cnum));
173 sect.sct_defense = 0;
176 if (sect.sct_type != SCT_MOUNT &&
177 sect.sct_type != SCT_PLAINS) {
178 sect.sct_type = SCT_RURAL;
179 sect.sct_newtype = SCT_RURAL;
182 sect.sct_dist_x = sect.sct_x;
183 sect.sct_dist_y = sect.sct_y;
193 if ((natp->nat_stat & (STAT_INUSE | STAT_NORM | STAT_GOD)) ==
195 *natp->nat_hostaddr = '\0';
196 *natp->nat_hostname = '\0';
197 *natp->nat_userid = '\0';
199 natp->nat_connected = 0;
200 natp->nat_reserve = 0;
202 natp->nat_ystart = 0;
203 natp->nat_xstart = 0;
209 natp->nat_minused = 0;
210 bzero((s_char *)natp->nat_b, sizeof(natp->nat_b));
211 (void)time(&natp->nat_last_login);
212 (void)time(&natp->nat_last_logout);
214 natp->nat_level[NAT_TLEV] = start_technology;
215 natp->nat_level[NAT_RLEV] = start_research;
216 natp->nat_level[NAT_ELEV] = start_education;
217 natp->nat_level[NAT_HLEV] = start_happiness;
218 for (i = 0; i < MAXNOC / 4; i++)
219 natp->nat_rejects[i] = 0;
220 natp->nat_newstim = 0;
221 natp->nat_annotim = 0;
222 (void)creat(mailbox(buf, coun), 0660);
224 pr("No special initializations done...\n");
226 for (i = 0; i < SCT_MAXDEF + 8; i++)
227 natp->nat_priorities[i] = -1;
229 NF_FLASH | NF_BEEP | NF_COASTWATCH | NF_SONAR | NF_TECHLISTS;
230 for (i = 0; i < MAXNOC; i++)
231 natp->nat_relate[i] = NEUTRAL;