2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2005, 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:
57 struct nstr_sect nstr;
59 char cntryname[sizeof(natp->nat_cnam)];
60 char pname[sizeof(natp->nat_pnam)];
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 p = getstarg(player->argp[1], prompt, buf);
79 if (p == 0 || *p == 0)
83 pr("Max # countries is %d\n", MAXNOC);
88 pr("Not allowed to add country #0\n");
92 p = getstarg(player->argp[2], "Country Name? ", buf);
93 if (p == 0 || *p == 0)
95 if (strlen(p) >= sizeof(cntryname)) {
96 pr("Country name too long\n");
100 p = getstarg(player->argp[3], "Representative? ", buf);
101 if (p == 0 || *p == 0)
103 if (strlen(p) >= sizeof(pname)) {
104 pr("Representative too long\n");
108 p = getstarg(player->argp[4],
109 "Status? (visitor, new, active, god, delete) ", buf);
110 if (p == 0 || *p == 0)
117 stat = STAT_NEW | STAT_INUSE;
120 stat = STAT_NORM | STAT_INUSE;
123 stat = STAT_GOD | STAT_NORM | STAT_INUSE;
129 pr("Illegal status\n");
132 p = getstarg(player->argp[5],
133 "Check, wipe, or ignore existing sectors (c|w|i) ", buf);
136 snxtitem_all(&ni, EF_LAND);
137 while (nxtitem(&ni, &land)) {
138 if (land.lnd_own == coun) {
139 makelost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x,
142 pr("Land unit %d wiped\n", land.lnd_uid);
143 putland(land.lnd_uid, &land);
146 natp->nat_stat = stat;
147 strcpy(natp->nat_cnam, cntryname);
148 strcpy(natp->nat_pnam, pname);
149 if (*p != 'w' && *p != 'c') {
150 pr("Any existing sectors ignored\n");
152 pr("Checking sectors...\n");
154 while (nxtsct(&nstr, §)) {
155 if (sect.sct_own != coun)
157 pr("%s ", xyas(nstr.x, nstr.y, player->cnum));
163 sect.sct_defense = 0;
166 if (sect.sct_type == SCT_BSPAN ||
167 sect.sct_type == SCT_BTOWER)
168 sect.sct_newtype = sect.sct_type = SCT_WATER;
169 else if (sect.sct_type != SCT_MOUNT &&
170 sect.sct_type != SCT_PLAINS)
171 sect.sct_newtype = sect.sct_type = SCT_RURAL;
173 sect.sct_dist_x = sect.sct_x;
174 sect.sct_dist_y = sect.sct_y;
175 memset(sect.sct_item, 0, sizeof(sect.sct_item));
176 memset(sect.sct_del, 0, sizeof(sect.sct_del));
177 memset(sect.sct_dist, 0, sizeof(sect.sct_dist));
179 sect.sct_pstage = PLG_HEALTHY;
182 sect.sct_che_target = 0;
183 sect.sct_fallout = 0;
192 if ((natp->nat_stat & (STAT_INUSE | STAT_NORM | STAT_GOD)) ==
194 *natp->nat_hostaddr = '\0';
195 *natp->nat_hostname = '\0';
196 *natp->nat_userid = '\0';
198 natp->nat_reserve = 0;
205 natp->nat_minused = 0;
206 memset(natp->nat_b, 0, sizeof(natp->nat_b));
207 natp->nat_last_login = natp->nat_last_login = 0;
209 natp->nat_level[NAT_TLEV] = start_technology;
210 natp->nat_level[NAT_RLEV] = start_research;
211 natp->nat_level[NAT_ELEV] = start_education;
212 natp->nat_level[NAT_HLEV] = start_happiness;
213 for (i = 0; i < MAXNOC / 4; i++)
214 natp->nat_rejects[i] = 0;
215 natp->nat_newstim = 0;
216 natp->nat_annotim = 0;
217 (void)creat(mailbox(buf, coun), 0660);
219 pr("No special initializations done...\n");
221 for (i = 0; i <= PRI_MAX; i++)
222 natp->nat_priorities[i] = -1;
224 NF_FLASH | NF_BEEP | NF_COASTWATCH | NF_SONAR | NF_TECHLISTS;
225 for (i = 0; i < MAXNOC; i++)
226 natp->nat_relate[i] = NEUTRAL;