2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2006, 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:
57 struct nstr_sect nstr;
59 char cntryname[sizeof(natp->nat_cnam)];
60 char pname[sizeof(natp->nat_pnam)];
69 struct realmstr realm;
70 time_t current_time = time(NULL);
72 for (freecn = 0; NULL != (natp = getnatp(freecn)); freecn++) {
73 if (natp->nat_stat == STAT_UNUSED)
77 sprintf(prompt, "New country number? (%d is unused) ", freecn);
79 strcpy(prompt, "New country number? (they all seem to be used) ");
80 p = getstarg(player->argp[1], prompt, buf);
81 if (p == 0 || *p == 0)
85 pr("Max # countries is %d\n", MAXNOC);
90 pr("Not allowed to add country #0\n");
94 p = getstarg(player->argp[2], "Country Name? ", buf);
95 if (p == 0 || *p == 0)
97 if (strlen(p) >= sizeof(cntryname)) {
98 pr("Country name too long\n");
101 strcpy(cntryname, p);
102 p = getstarg(player->argp[3], "Representative? ", buf);
103 if (p == 0 || *p == 0)
105 if (strlen(p) >= sizeof(pname)) {
106 pr("Representative too long\n");
110 p = getstarg(player->argp[4],
111 "Status? (visitor, new, active, god, delete) ", buf);
112 if (p == 0 || *p == 0)
131 pr("Illegal status\n");
134 p = getstarg(player->argp[5],
135 "Check, wipe, or ignore existing sectors (c|w|i) ", buf);
138 snxtitem_all(&ni, EF_LAND);
139 while (nxtitem(&ni, &land)) {
140 if (land.lnd_own == coun) {
141 makelost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x,
144 pr("Land unit %d wiped\n", land.lnd_uid);
145 putland(land.lnd_uid, &land);
148 natp->nat_stat = stat;
149 strcpy(natp->nat_cnam, cntryname);
150 strcpy(natp->nat_pnam, pname);
151 if (*p != 'w' && *p != 'c') {
152 pr("Any existing sectors ignored\n");
154 pr("Checking sectors...\n");
156 while (nxtsct(&nstr, §)) {
157 if (sect.sct_own != coun)
159 pr("%s ", xyas(nstr.x, nstr.y, player->cnum));
165 sect.sct_defense = 0;
168 if (sect.sct_type == SCT_BSPAN ||
169 sect.sct_type == SCT_BTOWER)
170 sect.sct_newtype = sect.sct_type = SCT_WATER;
171 else if (sect.sct_type != SCT_MOUNT &&
172 sect.sct_type != SCT_PLAINS)
173 sect.sct_newtype = sect.sct_type = SCT_RURAL;
175 sect.sct_dist_x = sect.sct_x;
176 sect.sct_dist_y = sect.sct_y;
177 memset(sect.sct_item, 0, sizeof(sect.sct_item));
178 memset(sect.sct_del, 0, sizeof(sect.sct_del));
179 memset(sect.sct_dist, 0, sizeof(sect.sct_dist));
181 sect.sct_pstage = PLG_HEALTHY;
184 sect.sct_che_target = 0;
185 sect.sct_fallout = 0;
194 if (natp->nat_stat == STAT_NEW || natp->nat_stat == STAT_VIS) {
195 *natp->nat_hostaddr = '\0';
196 *natp->nat_hostname = '\0';
197 *natp->nat_userid = '\0';
199 natp->nat_reserve = 0;
206 natp->nat_minused = 0;
207 for (i = 0; i < MAXNOR; i++) {
208 getrealm(i, coun, &realm);
209 realm.r_xl = realm.r_xh = realm.r_yl = realm.r_yh = 0;
210 realm.r_timestamp = current_time;
213 natp->nat_last_login = natp->nat_last_login = 0;
215 natp->nat_level[NAT_TLEV] = start_technology;
216 natp->nat_level[NAT_RLEV] = start_research;
217 natp->nat_level[NAT_ELEV] = start_education;
218 natp->nat_level[NAT_HLEV] = start_happiness;
219 for (i = 0; i < MAXNOC / 4; i++)
220 natp->nat_rejects[i] = 0;
221 natp->nat_newstim = 0;
222 natp->nat_annotim = 0;
223 (void)creat(mailbox(buf, coun), 0660);
225 pr("No special initializations done...\n");
227 for (i = 0; i <= PRI_MAX; i++)
228 natp->nat_priorities[i] = -1;
230 NF_FLASH | NF_BEEP | NF_COASTWATCH | NF_SONAR | NF_TECHLISTS;
231 for (i = 0; i < MAXNOC; i++)
232 natp->nat_relate[i] = NEUTRAL;