/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
#include <config.h>
-#include "misc.h"
-#include "player.h"
-#include "nat.h"
-#include "sect.h"
-#include "path.h"
-#include "file.h"
-#include "xy.h"
-#include "tel.h"
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include "commands.h"
#include "land.h"
-#include "nsc.h"
#include "optlist.h"
-#include "commands.h"
-
-#include <fcntl.h>
+#include "path.h"
+#include "prototypes.h"
+#include "tel.h"
static int isok(int x, int y);
static void ok(signed char *map, int x, int y);
+static void init_sanct(struct natstr *, coord, coord);
static struct range defrealm = { -8, -5, 10, 5, 0, 0 };
* another place on the map.
*/
getsect(x, y, §);
- if (sect.sct_type == SCT_WATER || sect.sct_own != 0)
+ if (sect.sct_type != SCT_RURAL || sect.sct_own != 0)
continue;
getsect(x + 2, y, §);
- if (sect.sct_type == SCT_WATER || sect.sct_own != 0)
+ if (sect.sct_type != SCT_RURAL || sect.sct_own != 0)
continue;
if (isok(x, y))
break;
if (player->aborted)
return RET_FAIL;
pr("added country %d at %s\n", num, xyas(x, y, player->cnum));
- getsect(x, y, §);
- sect.sct_own = num;
- sect.sct_type = SCT_SANCT;
- sect.sct_newtype = SCT_SANCT;
- sect.sct_effic = 100;
- sect.sct_road = 0;
- sect.sct_rail = 0;
- sect.sct_defense = 0;
- if (!opt_DEFENSE_INFRA)
- sect.sct_defense = sect.sct_effic;
- sect.sct_mobil = startmob;
- sect.sct_work = 100;
- sect.sct_oldown = num;
- if (at_least_one_100) {
- sect.sct_oil = 100;
- sect.sct_fertil = 100;
- sect.sct_uran = 100;
- sect.sct_min = 100;
- sect.sct_gmin = 100;
- }
- sect.sct_item[I_CIVIL] = opt_RES_POP ? 550 : 999;
- sect.sct_item[I_MILIT] = 55;
- sect.sct_item[I_FOOD] = 1000;
- sect.sct_item[I_UW] = 75;
- putsect(§);
- getsect(x + 2, y, §);
- sect.sct_own = num;
- sect.sct_type = SCT_SANCT;
- sect.sct_newtype = SCT_SANCT;
- sect.sct_effic = 100;
- sect.sct_road = 0;
- sect.sct_rail = 0;
- sect.sct_defense = 0;
- if (!opt_DEFENSE_INFRA)
- sect.sct_defense = sect.sct_effic;
- sect.sct_work = 100;
- sect.sct_oldown = num;
- sect.sct_mobil = startmob;
- if (at_least_one_100) {
- sect.sct_oil = 100;
- sect.sct_fertil = 100;
- sect.sct_uran = 100;
- sect.sct_min = 100;
- sect.sct_gmin = 100;
- }
- sect.sct_item[I_CIVIL] = opt_RES_POP ? 550 : 999;
- sect.sct_item[I_MILIT] = 55;
- sect.sct_item[I_FOOD] = 100;
- sect.sct_item[I_UW] = 75;
- putsect(§);
natp->nat_btu = max_btus;
natp->nat_stat = STAT_SANCT;
natp->nat_xcap = x;
natp->nat_level[NAT_TLEV] = start_technology;
natp->nat_level[NAT_ELEV] = start_education;
natp->nat_tgms = 0;
- (void)close(open(mailbox(buf, num), O_RDWR | O_TRUNC | O_CREAT, 0660));
+ close(creat(mailbox(buf, num), S_IRWUG));
+ init_sanct(natp, x, y);
+ init_sanct(natp, x + 2, y);
putnat(natp);
return RET_OK;
}
+static void
+init_sanct(struct natstr *natp, coord x, coord y)
+{
+ struct sctstr sect;
+
+ getsect(x, y, §);
+ sect.sct_own = natp->nat_cnum;
+ sect.sct_type = SCT_SANCT;
+ sect.sct_newtype = SCT_SANCT;
+ sect.sct_effic = 100;
+ sect.sct_road = 0;
+ sect.sct_rail = 0;
+ sect.sct_defense = 0;
+ sect.sct_mobil = startmob;
+ sect.sct_work = 100;
+ sect.sct_oldown = natp->nat_cnum;
+ if (at_least_one_100) {
+ sect.sct_oil = 100;
+ sect.sct_fertil = 100;
+ sect.sct_uran = 100;
+ sect.sct_min = 100;
+ sect.sct_gmin = 100;
+ }
+ sect.sct_item[I_CIVIL] = max_pop(start_research, §);
+ sect.sct_item[I_MILIT] = 55;
+ sect.sct_item[I_FOOD] = opt_NOFOOD ? 0 : 550;
+ sect.sct_item[I_UW] = 75;
+ putsect(§);
+}
+
static int nmin, ngold, noil, nur;
static int nfree, navail, nowned;
nmin = ngold = noil = nur = 0;
navail = nfree = nowned = 0;
- if ((map = malloc((WORLD_X * WORLD_Y) / 2)) == 0) {
+ if (!(map = malloc(WORLD_SZ()))) {
logerror("malloc failed in isok\n");
pr("Memory error. Tell the deity.\n");
return 0;
}
- memset(map, 0, (WORLD_X * WORLD_Y) / 2);
+ memset(map, 0, WORLD_SZ());
ok(map, x, y);
free(map);
if (nfree < 5)