Sectors need space for items, deliveries and distribution thresholds.
To save space, the ancients invented `variables': a collection of key-value pairs, missing means zero value, space for `enough' keys. This complicates the code, as assigning to a `variable' can fail for lack of space. Over time, `enough' increased, and for quite some time now `variables' have been *wasting* space. This changeset replaces them, except in struct mchrstr, struct lchrstr and struct pchrstr, where they are read-only, and will be replaced later. It is only a first step; further cleanup is required. To simplify and minimize this necessarily huge changeset, the new item[] arrays have an unused slot 0, and the old variable types V_CIVIL, ... are still defined, but must have the same values as the item types I_CIVIL, ...
This commit is contained in:
parent
ba86513b01
commit
eccc5cb7d7
86 changed files with 853 additions and 1226 deletions
|
@ -33,6 +33,7 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "misc.h"
|
||||
#include "player.h"
|
||||
#include "var.h"
|
||||
|
@ -179,7 +180,14 @@ add(void)
|
|||
/* No dist path */
|
||||
sect.sct_dist_x = sect.sct_x;
|
||||
sect.sct_dist_y = sect.sct_y;
|
||||
sect.sct_nv = 0;
|
||||
memset(sect.sct_item, 0, sizeof(sect.sct_item));
|
||||
memset(sect.sct_del, 0, sizeof(sect.sct_del));
|
||||
memset(sect.sct_dist, 0, sizeof(sect.sct_dist));
|
||||
sect.sct_mines = 0;
|
||||
sect.sct_pstage = PLG_HEALTHY;
|
||||
sect.sct_ptime = 0;
|
||||
sect.sct_che = 0;
|
||||
sect.sct_fallout = 0;
|
||||
putsect(§);
|
||||
pr("wiped\n");
|
||||
} else {
|
||||
|
|
|
@ -57,7 +57,6 @@ anti(void)
|
|||
struct sctstr sect;
|
||||
int nsect;
|
||||
struct nstr_sect nstr;
|
||||
int cond[I_MAX + 1];
|
||||
int mil, che, target;
|
||||
int avail_mil;
|
||||
int amil, ache;
|
||||
|
@ -77,10 +76,9 @@ anti(void)
|
|||
pr(" sect subversion activity report\n");
|
||||
pr(" ---- --------------------------\n");
|
||||
}
|
||||
getvec(VT_COND, cond, (char *)§, EF_SECTOR);
|
||||
mil = getvar(V_MILIT, (char *)§, EF_SECTOR);
|
||||
che = get_che_value(cond[C_CHE]);
|
||||
target = get_che_cnum(cond[C_CHE]);
|
||||
mil = sect.sct_item[I_MILIT];
|
||||
che = get_che_value(sect.sct_che);
|
||||
target = get_che_cnum(sect.sct_che);
|
||||
avail_mil = sect.sct_mobil / 2;
|
||||
if (mil <= avail_mil)
|
||||
avail_mil = mil;
|
||||
|
@ -114,11 +112,10 @@ anti(void)
|
|||
}
|
||||
if (mil - milkilled > 0) {
|
||||
sect.sct_mobil = sect.sct_mobil - chekilled - milkilled;
|
||||
putvar(V_MILIT, mil - milkilled, (char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_MILIT] = mil - milkilled;
|
||||
if (ache == 0)
|
||||
cond[C_CHE] = 0;
|
||||
set_che_value(cond[C_CHE], ache);
|
||||
putvar(V_CHE, cond[C_CHE], (char *)§, EF_SECTOR);
|
||||
sect.sct_che = 0;
|
||||
set_che_value(sect.sct_che, ache);
|
||||
putsect(§);
|
||||
pr(" Body count: Military %d - Guerillas %d.\n",
|
||||
milkilled, chekilled);
|
||||
|
@ -141,11 +138,10 @@ anti(void)
|
|||
/* Ok, now leave anywhere from 16% to 25% of the che */
|
||||
n_cheleft = (ache / (n_cheleft + 3));
|
||||
ache -= n_cheleft;
|
||||
set_che_value(cond[C_CHE], n_cheleft);
|
||||
set_che_value(sect.sct_che, n_cheleft);
|
||||
} else
|
||||
cond[C_CHE] = 0;
|
||||
putvar(V_MILIT, ache, (char *)§, EF_SECTOR);
|
||||
putvar(V_CHE, cond[C_CHE], (char *)§, EF_SECTOR);
|
||||
sect.sct_che = 0;
|
||||
sect.sct_item[I_MILIT] = ache;
|
||||
if (sect.sct_own == sect.sct_oldown)
|
||||
sect.sct_oldown = 0;
|
||||
makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x,
|
||||
|
|
|
@ -478,10 +478,8 @@ comm_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
return;
|
||||
getsect(target->sct_x, target->sct_y, §);
|
||||
target = §
|
||||
before = amt = getvar(ip->i_vtype, (s_char *)target, EF_SECTOR);
|
||||
putvar(ip->i_vtype, commdamage(amt, dam, ip->i_vtype),
|
||||
(s_char *)target, EF_SECTOR);
|
||||
amt = getvar(ip->i_vtype, (s_char *)target, EF_SECTOR);
|
||||
before = amt = target->sct_item[ip->i_vtype];
|
||||
target->sct_item[ip->i_vtype] = amt = commdamage(amt, dam, ip->i_vtype);
|
||||
if (before > 0.0)
|
||||
b = 100.0 * (1.0 - ((float)amt / (float)before));
|
||||
else
|
||||
|
@ -582,9 +580,9 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
continue;
|
||||
|
||||
shell = gun = 0;
|
||||
gun = min(getvar(V_GUN, (s_char *)&ship, EF_SHIP), ship.shp_glim);
|
||||
gun = min(ship.shp_item[I_GUN], ship.shp_glim);
|
||||
if (gun > 0) {
|
||||
shell = getvar(V_SHELL, (s_char *)&ship, EF_SHIP);
|
||||
shell = ship.shp_item[I_SHELL];
|
||||
if (shell <= 0)
|
||||
shell = supply_commod(ship.shp_own, ship.shp_x,
|
||||
ship.shp_y, I_SHELL, 1);
|
||||
|
@ -592,7 +590,7 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
mcp = &mchr[(int)ship.shp_type];
|
||||
if (gun > 0 && shell > 0 && !(mcp->m_flags & M_SUB)) {
|
||||
flak = (int)(techfact(ship.shp_tech, (double)gun) * 2.0);
|
||||
putvar(V_SHELL, shell, (s_char *)&ship, EF_SHIP);
|
||||
ship.shp_item[I_SHELL] = shell;
|
||||
putship(ship.shp_uid, &ship);
|
||||
sprintf(msg, "Flak! Firing %d guns from ship %s\n",
|
||||
flak, prship(&ship));
|
||||
|
|
|
@ -435,7 +435,9 @@ build_ship(register struct sctstr *sp, register struct mchrstr *mp,
|
|||
ship.shp_nxlight = 0;
|
||||
ship.shp_nchoppers = 0;
|
||||
ship.shp_fleet = ' ';
|
||||
ship.shp_nv = 0;
|
||||
memset(ship.shp_item, 0, sizeof(ship.shp_item));
|
||||
ship.shp_pstage = PLG_HEALTHY;
|
||||
ship.shp_ptime = 0;
|
||||
ship.shp_tech = tlev;
|
||||
|
||||
techdiff = (int)(tlev - mp->m_tech);
|
||||
|
@ -460,8 +462,8 @@ build_ship(register struct sctstr *sp, register struct mchrstr *mp,
|
|||
vec[I_LCM] -= lcm;
|
||||
vec[I_HCM] -= hcm;
|
||||
|
||||
if (getvar(V_PSTAGE, (s_char *)sp, EF_SECTOR) == PLG_INFECT)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&ship, EF_SHIP);
|
||||
if (sp->sct_pstage == PLG_INFECT)
|
||||
ship.shp_pstage = PLG_EXPOSED;
|
||||
makenotlost(EF_SHIP, ship.shp_own, ship.shp_uid, ship.shp_x,
|
||||
ship.shp_y);
|
||||
putship(ship.shp_uid, &ship);
|
||||
|
@ -585,7 +587,9 @@ build_land(register struct sctstr *sp, register struct lchrstr *lp,
|
|||
land.lnd_rflags = 0;
|
||||
memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath));
|
||||
land.lnd_rad_max = 0;
|
||||
land.lnd_nv = 0;
|
||||
memset(land.lnd_item, 0, sizeof(land.lnd_item));
|
||||
land.lnd_pstage = PLG_HEALTHY;
|
||||
land.lnd_ptime = 0;
|
||||
land.lnd_att = (float)LND_ATTDEF(lp->l_att, tlev - lp->l_tech);
|
||||
land.lnd_def = (float)LND_ATTDEF(lp->l_def, tlev - lp->l_tech);
|
||||
land.lnd_vul = (int)LND_VUL(lp->l_vul, tlev - lp->l_tech);
|
||||
|
@ -627,8 +631,8 @@ build_land(register struct sctstr *sp, register struct lchrstr *lp,
|
|||
putvec(VT_ITEM, lvec, (s_char *)&land, EF_LAND);
|
||||
*/
|
||||
|
||||
if (getvar(V_PSTAGE, (s_char *)sp, EF_SECTOR) == PLG_INFECT)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&land, EF_LAND);
|
||||
if (sp->sct_pstage == PLG_INFECT)
|
||||
land.lnd_pstage = PLG_EXPOSED;
|
||||
putland(nstr.cur, &land);
|
||||
makenotlost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x,
|
||||
land.lnd_y);
|
||||
|
@ -778,7 +782,7 @@ build_bridge(register struct sctstr *sp, register int *vec)
|
|||
} else {
|
||||
sect.sct_mobil = 0;
|
||||
}
|
||||
putvar(V_MINE, 0, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_mines = 0;
|
||||
putsect(§);
|
||||
pr("Bridge span built over %s\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
|
@ -1102,7 +1106,7 @@ build_tower(register struct sctstr *sp, register int *vec)
|
|||
}
|
||||
if (!opt_DEFENSE_INFRA)
|
||||
sect.sct_defense = sect.sct_effic;
|
||||
putvar(V_MINE, 0, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_mines = 0;
|
||||
putsect(§);
|
||||
pr("Bridge tower built in %s\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
|
|
|
@ -161,24 +161,13 @@ buy(void)
|
|||
return RET_FAIL;
|
||||
}
|
||||
ip = whichitem(comm.com_type);
|
||||
n = getvar(ip->i_vtype, (char *)§, EF_SECTOR);
|
||||
n = sect.sct_item[ip->i_vtype];
|
||||
qty = comm.com_amount;
|
||||
if (qty + n > 9990) {
|
||||
pr("That sector cannot hold %d more %s. It currently holds %d.\n",
|
||||
qty, ip->i_name, n);
|
||||
return RET_FAIL;
|
||||
}
|
||||
/* First we check for room, then we yank back. Probably not necessary. */
|
||||
if (putvar(ip->i_vtype, n + qty, (char *)§, EF_SECTOR) <= 0) {
|
||||
pr("No room to store %s in %s\n",
|
||||
ip->i_name, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
return RET_FAIL;
|
||||
}
|
||||
if (putvar(ip->i_vtype, n, (char *)§, EF_SECTOR) <= 0) {
|
||||
pr("Something weird just happened, tell the deity.\n");
|
||||
logerror("buy.c: putvar failed.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
if ((bid * comm.com_amount) > natp->nat_money) {
|
||||
pr("You don't have that much to spend!\n");
|
||||
return RET_FAIL;
|
||||
|
@ -250,7 +239,7 @@ check_market(void)
|
|||
continue;
|
||||
ip = whichitem(comm.com_type);
|
||||
sect = getsectp(comm.com_x, comm.com_y);
|
||||
m = getvar(ip->i_vtype, (char *)sect, EF_SECTOR);
|
||||
m = sect->sct_item[ip->i_vtype];
|
||||
|
||||
monleft = 0;
|
||||
|
||||
|
@ -344,14 +333,14 @@ check_market(void)
|
|||
wu(0, comm.com_owner,
|
||||
"Sale #%d fell through. Goods remain on the market.\n", n);
|
||||
comm.com_maxbidder = comm.com_owner;
|
||||
} else if (putvar(ip->i_vtype, m + comm.com_amount,
|
||||
(char *)sect, EF_SECTOR) <= 0) {
|
||||
} else if (m + comm.com_amount > 32767) {
|
||||
wu(0, comm.com_maxbidder,
|
||||
"Warehouse full, sale #%d fell though.\n", n);
|
||||
wu(0, comm.com_owner,
|
||||
"Sale #%d fell through. Goods remain on the market.\n", n);
|
||||
comm.com_maxbidder = comm.com_owner;
|
||||
} else {
|
||||
sect->sct_item[ip->i_vtype] = m + comm.com_amount;
|
||||
putsect(sect);
|
||||
nreport(comm.com_owner, N_MAKE_SALE, comm.com_maxbidder, 1);
|
||||
wu(0, comm.com_owner, "%s bought %d %c's from you for $%.2f\n",
|
||||
|
|
|
@ -205,12 +205,10 @@ grab_sect(register struct sctstr *sp, natid to)
|
|||
struct plnstr p;
|
||||
struct lndstr l;
|
||||
struct nukstr nuk;
|
||||
int vec[I_MAX + 1];
|
||||
|
||||
/* Wipe all the distribution info */
|
||||
memset(vec, 0, sizeof(vec));
|
||||
putvec(VT_DIST, vec, (s_char *)sp, EF_SECTOR);
|
||||
putvec(VT_DEL, vec, (s_char *)sp, EF_SECTOR);
|
||||
memset(sp->sct_dist, 0, sizeof(sp->sct_dist));
|
||||
memset(sp->sct_del, 0, sizeof(sp->sct_del));
|
||||
sp->sct_dist_x = sp->sct_x;
|
||||
sp->sct_dist_y = sp->sct_y;
|
||||
|
||||
|
@ -275,10 +273,10 @@ grab_sect(register struct sctstr *sp, natid to)
|
|||
sp->sct_avail = 0;
|
||||
|
||||
if (sp->sct_oldown == to) {
|
||||
oldche = get_che_value(getvar(V_CHE, (s_char *)sp, EF_SECTOR));
|
||||
oldche = get_che_value(sp->sct_che);
|
||||
set_che_value(oldche, 0);
|
||||
set_che_cnum(oldche, 0);
|
||||
(void)putvar(V_CHE, oldche, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_che = oldche;
|
||||
sp->sct_loyal = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,14 +85,12 @@ cens(void)
|
|||
pr(" ");
|
||||
pr("%4d", sect.sct_mobil);
|
||||
|
||||
getvec(VT_DEL, vec, (s_char *)§, EF_SECTOR);
|
||||
pr(" %c", dirstr[vec[I_UW] & 0x7]);
|
||||
pr("%c", dirstr[vec[I_FOOD] & 0x7]);
|
||||
pr(" %c", dirstr[sect.sct_del[I_UW] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_FOOD] & 0x7]);
|
||||
|
||||
getvec(VT_DIST, vec, (s_char *)§, EF_SECTOR);
|
||||
n = vec[I_UW] % 1000;
|
||||
n = sect.sct_dist[I_UW] % 1000;
|
||||
pr(" %c", n == 0 ? '.' : '0' + (n / 100));
|
||||
n = vec[I_FOOD] % 1000;
|
||||
n = sect.sct_dist[I_FOOD] % 1000;
|
||||
pr("%c ", n == 0 ? '.' : '0' + (n / 100));
|
||||
pr("%c", sect.sct_own != sect.sct_oldown ? '*' : ' ');
|
||||
|
||||
|
@ -110,8 +108,7 @@ cens(void)
|
|||
pr(" ");
|
||||
}
|
||||
if (opt_FALLOUT) {
|
||||
getvec(VT_COND, vec, (void *)§, EF_SECTOR);
|
||||
pr("%5d", vec[C_FALLOUT]);
|
||||
pr("%5d", sect.sct_fallout);
|
||||
}
|
||||
set_coastal(§);
|
||||
if (sect.sct_coastal)
|
||||
|
|
|
@ -65,7 +65,6 @@ coll(void)
|
|||
double owed;
|
||||
double pay;
|
||||
s_char buf[1024];
|
||||
int vec[I_MAX + 1];
|
||||
|
||||
if (!opt_LOANS) {
|
||||
pr("Loans are not enabled.\n");
|
||||
|
@ -128,7 +127,7 @@ coll(void)
|
|||
for (i = 0; ichr[i].i_name; i++) {
|
||||
if (ichr[i].i_value == 0 || ichr[i].i_vtype == 0)
|
||||
continue;
|
||||
val = getvar(ichr[i].i_vtype, (s_char *)§, EF_SECTOR);
|
||||
val = sect.sct_item[ichr[i].i_vtype];
|
||||
pay += val * ichr[i].i_value;
|
||||
}
|
||||
pr("That sector (and its contents) is valued at $%.2f\n", pay);
|
||||
|
@ -138,7 +137,7 @@ coll(void)
|
|||
}
|
||||
if (sect.sct_type == SCT_CAPIT || sect.sct_type == SCT_MOUNT)
|
||||
caploss(§, sect.sct_own, "that was %s's capital!\n");
|
||||
putvar(V_MILIT, 1, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_MILIT] = 1; /* FIXME no where did this guy come from? */
|
||||
|
||||
/* Consider modifying takeover to take a "no che" argument and
|
||||
putting using it here again. */
|
||||
|
@ -147,9 +146,8 @@ coll(void)
|
|||
makenotlost(EF_SECTOR, player->cnum, 0, sect.sct_x, sect.sct_y);
|
||||
sect.sct_own = player->cnum;
|
||||
|
||||
memset(vec, 0, sizeof(vec));
|
||||
putvec(VT_DIST, vec, (s_char *)§, EF_SECTOR);
|
||||
putvec(VT_DEL, vec, (s_char *)§, EF_SECTOR);
|
||||
memset(sect.sct_dist, 0, sizeof(sect.sct_dist));
|
||||
memset(sect.sct_del, 0, sizeof(sect.sct_del));
|
||||
sect.sct_off = 1;
|
||||
sect.sct_dist_x = sect.sct_x;
|
||||
sect.sct_dist_y = sect.sct_y;
|
||||
|
|
|
@ -52,8 +52,6 @@ comm(void)
|
|||
int nsect;
|
||||
int n;
|
||||
struct nstr_sect nstr;
|
||||
int del[I_MAX + 1];
|
||||
int dist[I_MAX + 1];
|
||||
int item[I_MAX + 1];
|
||||
|
||||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
|
@ -77,31 +75,29 @@ comm(void)
|
|||
}
|
||||
if (player->god)
|
||||
pr("%3d", sect.sct_own);
|
||||
getvec(VT_DEL, del, (s_char *)§, EF_SECTOR);
|
||||
getvec(VT_DIST, dist, (s_char *)§, EF_SECTOR);
|
||||
getvec(VT_ITEM, item, (s_char *)§, EF_SECTOR);
|
||||
prxy("%4d,%-4d", nstr.x, nstr.y, player->cnum);
|
||||
pr(" %c", dchr[sect.sct_type].d_mnem);
|
||||
pr(" %c", dirstr[del[I_SHELL] & 0x7]);
|
||||
pr("%c", dirstr[del[I_GUN] & 0x7]);
|
||||
pr("%c", dirstr[del[I_PETROL] & 0x7]);
|
||||
pr("%c", dirstr[del[I_IRON] & 0x7]);
|
||||
pr("%c", dirstr[del[I_DUST] & 0x7]);
|
||||
pr("%c", dirstr[del[I_BAR] & 0x7]);
|
||||
pr("%c", dirstr[del[I_OIL] & 0x7]);
|
||||
pr("%c", dirstr[del[I_LCM] & 0x7]);
|
||||
pr("%c", dirstr[del[I_HCM] & 0x7]);
|
||||
pr("%c", dirstr[del[I_RAD] & 0x7]);
|
||||
prthresh(" %c", dist[I_SHELL]);
|
||||
prthresh("%c", dist[I_GUN]);
|
||||
prthresh("%c", dist[I_PETROL]);
|
||||
prthresh("%c", dist[I_IRON]);
|
||||
prthresh("%c", dist[I_DUST]);
|
||||
prthresh("%c", dist[I_BAR]);
|
||||
prthresh("%c", dist[I_OIL]);
|
||||
prthresh("%c", dist[I_LCM]);
|
||||
prthresh("%c", dist[I_HCM]);
|
||||
prthresh("%c", dist[I_RAD]);
|
||||
pr(" %c", dirstr[sect.sct_del[I_SHELL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_GUN] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_PETROL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_IRON] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_DUST] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_BAR] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_OIL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_LCM] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_HCM] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_RAD] & 0x7]);
|
||||
prthresh(" %c", sect.sct_dist[I_SHELL]);
|
||||
prthresh("%c", sect.sct_dist[I_GUN]);
|
||||
prthresh("%c", sect.sct_dist[I_PETROL]);
|
||||
prthresh("%c", sect.sct_dist[I_IRON]);
|
||||
prthresh("%c", sect.sct_dist[I_DUST]);
|
||||
prthresh("%c", sect.sct_dist[I_BAR]);
|
||||
prthresh("%c", sect.sct_dist[I_OIL]);
|
||||
prthresh("%c", sect.sct_dist[I_LCM]);
|
||||
prthresh("%c", sect.sct_dist[I_HCM]);
|
||||
prthresh("%c", sect.sct_dist[I_RAD]);
|
||||
pr("%4d", item[I_SHELL]);
|
||||
pr("%4d", item[I_GUN]);
|
||||
pr("%5d", item[I_PETROL]);
|
||||
|
|
|
@ -87,10 +87,10 @@ do_conv(struct nstr_sect nstr, int uwtoconvert, int for_real)
|
|||
continue;
|
||||
if (sect.sct_oldown == player->cnum)
|
||||
continue;
|
||||
civ = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
|
||||
civ = sect.sct_item[I_CIVIL];
|
||||
if (civ == 0)
|
||||
continue;
|
||||
mil = getvar(V_MILIT, (s_char *)§, EF_SECTOR);
|
||||
mil = sect.sct_item[I_MILIT];
|
||||
|
||||
/*
|
||||
* Military units count according to the number of
|
||||
|
@ -128,7 +128,7 @@ do_conv(struct nstr_sect nstr, int uwtoconvert, int for_real)
|
|||
newuw = civ;
|
||||
if (newuw > uwtoconvert)
|
||||
newuw = uwtoconvert;
|
||||
uw = getvar(V_UW, (s_char *)§, EF_SECTOR);
|
||||
uw = sect.sct_item[I_UW];
|
||||
if (uw > 999)
|
||||
continue;
|
||||
if (newuw > 999 - uw)
|
||||
|
@ -157,13 +157,9 @@ do_conv(struct nstr_sect nstr, int uwtoconvert, int for_real)
|
|||
player->dolcost += newuw * 1.5;
|
||||
if (newuw < mob)
|
||||
mob = newuw;
|
||||
if (putvar(V_UW, newuw + uw, (s_char *)§, EF_SECTOR) == 0) {
|
||||
pr("No room for new uw in %s\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
continue;
|
||||
}
|
||||
sect.sct_item[I_UW] = newuw + uw;
|
||||
civ -= newuw;
|
||||
putvar(V_CIVIL, civ, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_CIVIL] = civ;
|
||||
mob = roundavg(mob * 0.2);
|
||||
if (mob > sect.sct_mobil)
|
||||
mob = sect.sct_mobil;
|
||||
|
|
|
@ -50,7 +50,6 @@ cuto(void)
|
|||
int n;
|
||||
struct nstr_sect nstr;
|
||||
s_char dirstr[12];
|
||||
int del[I_MAX + 1];
|
||||
|
||||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
return RET_SYN;
|
||||
|
@ -71,37 +70,36 @@ cuto(void)
|
|||
}
|
||||
if (player->god)
|
||||
pr("%3d", sect.sct_own);
|
||||
getvec(VT_DEL, del, (s_char *)§, EF_SECTOR);
|
||||
pr("%7s", xyas(nstr.x, nstr.y, player->cnum));
|
||||
pr(" %c ", dchr[sect.sct_type].d_mnem);
|
||||
pr("%c", dirstr[del[I_CIVIL] & 0x7]);
|
||||
pr("%c", dirstr[del[I_MILIT] & 0x7]);
|
||||
pr("%c", dirstr[del[I_UW] & 0x7]);
|
||||
pr("%c", dirstr[del[I_FOOD] & 0x7]);
|
||||
pr("%c", dirstr[del[I_SHELL] & 0x7]);
|
||||
pr("%c", dirstr[del[I_GUN] & 0x7]);
|
||||
pr("%c", dirstr[del[I_PETROL] & 0x7]);
|
||||
pr("%c", dirstr[del[I_IRON] & 0x7]);
|
||||
pr("%c", dirstr[del[I_DUST] & 0x7]);
|
||||
pr("%c", dirstr[del[I_BAR] & 0x7]);
|
||||
pr("%c", dirstr[del[I_OIL] & 0x7]);
|
||||
pr("%c", dirstr[del[I_LCM] & 0x7]);
|
||||
pr("%c", dirstr[del[I_HCM] & 0x7]);
|
||||
pr("%c", dirstr[del[I_RAD] & 0x7]);
|
||||
pr("%4d", del[I_CIVIL] & ~0x7);
|
||||
pr("%4d", del[I_MILIT] & ~0x7);
|
||||
pr("%4d", del[I_UW] & ~0x7);
|
||||
pr("%4d", del[I_FOOD] & ~0x7);
|
||||
pr("%4d", del[I_SHELL] & ~0x7);
|
||||
pr("%4d", del[I_GUN] & ~0x7);
|
||||
pr("%4d", del[I_PETROL] & ~0x7);
|
||||
pr("%4d", del[I_IRON] & ~0x7);
|
||||
pr("%4d", del[I_DUST] & ~0x7);
|
||||
pr("%4d", del[I_BAR] & ~0x7);
|
||||
pr("%4d", del[I_OIL] & ~0x7);
|
||||
pr("%4d", del[I_LCM] & ~0x7);
|
||||
pr("%4d", del[I_HCM] & ~0x7);
|
||||
pr("%4d", del[I_RAD] & ~0x7);
|
||||
pr("%c", dirstr[sect.sct_del[I_CIVIL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_MILIT] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_UW] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_FOOD] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_SHELL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_GUN] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_PETROL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_IRON] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_DUST] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_BAR] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_OIL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_LCM] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_HCM] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_RAD] & 0x7]);
|
||||
pr("%4d", sect.sct_del[I_CIVIL] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_MILIT] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_UW] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_FOOD] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_SHELL] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_GUN] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_PETROL] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_IRON] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_DUST] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_BAR] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_OIL] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_LCM] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_HCM] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_RAD] & ~0x7);
|
||||
pr("\n");
|
||||
}
|
||||
if (nsect == 0) {
|
||||
|
|
|
@ -50,9 +50,7 @@ deli(void)
|
|||
register int dir, del;
|
||||
register struct ichrstr *ich;
|
||||
register int thresh;
|
||||
int i_del;
|
||||
int sx, sy;
|
||||
int status;
|
||||
struct nstr_sect nstr;
|
||||
s_char buf[1024];
|
||||
s_char prompt[128];
|
||||
|
@ -68,13 +66,12 @@ deli(void)
|
|||
*/
|
||||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
i_del = V_DEL(ich - ichr);
|
||||
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
|
||||
del = getvar(i_del, (s_char *)§, EF_SECTOR);
|
||||
del = sect.sct_del[ich->i_vtype];
|
||||
thresh = del & ~0x7;
|
||||
dir = del & 0x7;
|
||||
|
||||
|
@ -105,16 +102,8 @@ deli(void)
|
|||
continue;
|
||||
|
||||
del = thresh + dir;
|
||||
status = putvar(i_del, del, (s_char *)§, EF_SECTOR);
|
||||
if (status < 0) {
|
||||
pr("No room for delivery path in %s\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
continue;
|
||||
} else if (!status) {
|
||||
/* Either nothing to set, or bogus amount. */
|
||||
continue;
|
||||
} else
|
||||
putsect(§);
|
||||
sect.sct_del[ich->i_vtype] = del;
|
||||
putsect(§);
|
||||
}
|
||||
|
||||
if (!del)
|
||||
|
|
|
@ -95,11 +95,11 @@ do_demo(struct natstr *natp, struct nstr_sect nstr, int number, s_char *p,
|
|||
while (nxtsct(&nstr, §)) {
|
||||
if (!player->owner || sect.sct_effic < 60)
|
||||
continue;
|
||||
if ((mil = getvar(V_MILIT, (s_char *)§, EF_SECTOR)) == 0)
|
||||
if ((mil = sect.sct_item[I_MILIT]) == 0)
|
||||
continue;
|
||||
if (sect.sct_own != sect.sct_oldown)
|
||||
continue;
|
||||
civ = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
|
||||
civ = sect.sct_item[I_CIVIL];
|
||||
if (number < 0) {
|
||||
if ((deltamil = mil + number) <= 0)
|
||||
continue;
|
||||
|
@ -117,8 +117,8 @@ do_demo(struct natstr *natp, struct nstr_sect nstr, int number, s_char *p,
|
|||
deltamil, xyas(sect.sct_x, sect.sct_y, player->cnum), mil);
|
||||
if (*p == 'y')
|
||||
reserves += deltamil;
|
||||
putvar(V_MILIT, mil, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_CIVIL, civ, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_MILIT] = mil;
|
||||
sect.sct_item[I_CIVIL] = civ;
|
||||
putsect(§);
|
||||
}
|
||||
if (!for_real)
|
||||
|
|
|
@ -52,10 +52,7 @@ dump(void)
|
|||
int nsect;
|
||||
int n, i;
|
||||
struct nstr_sect nstr;
|
||||
int del[I_MAX + 1];
|
||||
int dist[I_MAX + 1];
|
||||
int item[I_MAX + 1];
|
||||
int cond[I_MAX + 1];
|
||||
int field[128];
|
||||
struct natstr *np;
|
||||
time_t now;
|
||||
|
@ -513,10 +510,7 @@ dump(void)
|
|||
/* census */
|
||||
if (player->god)
|
||||
pr("%d ", sect.sct_own);
|
||||
getvec(VT_DEL, del, (s_char *)§, EF_SECTOR);
|
||||
getvec(VT_DIST, dist, (s_char *)§, EF_SECTOR);
|
||||
getvec(VT_ITEM, item, (s_char *)§, EF_SECTOR);
|
||||
getvec(VT_COND, cond, (s_char *)§, EF_SECTOR);
|
||||
pr("%d %d", xrel(np, nstr.x), yrel(np, nstr.y));
|
||||
|
||||
set_coastal(§);
|
||||
|
@ -614,76 +608,76 @@ dump(void)
|
|||
break;
|
||||
/* cutoff */
|
||||
case 29:
|
||||
pr("%c", dirstr[del[I_UW] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_UW] & 0x7]);
|
||||
break;
|
||||
case 30:
|
||||
pr("%c", dirstr[del[I_FOOD] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_FOOD] & 0x7]);
|
||||
break;
|
||||
case 31:
|
||||
pr("%c", dirstr[del[I_SHELL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_SHELL] & 0x7]);
|
||||
break;
|
||||
case 32:
|
||||
pr("%c", dirstr[del[I_GUN] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_GUN] & 0x7]);
|
||||
break;
|
||||
case 33:
|
||||
pr("%c", dirstr[del[I_PETROL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_PETROL] & 0x7]);
|
||||
break;
|
||||
case 34:
|
||||
pr("%c", dirstr[del[I_IRON] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_IRON] & 0x7]);
|
||||
break;
|
||||
case 35:
|
||||
pr("%c", dirstr[del[I_DUST] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_DUST] & 0x7]);
|
||||
break;
|
||||
case 36:
|
||||
pr("%c", dirstr[del[I_BAR] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_BAR] & 0x7]);
|
||||
break;
|
||||
case 37:
|
||||
pr("%c", dirstr[del[I_OIL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_OIL] & 0x7]);
|
||||
break;
|
||||
case 38:
|
||||
pr("%c", dirstr[del[I_LCM] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_LCM] & 0x7]);
|
||||
break;
|
||||
case 39:
|
||||
pr("%c", dirstr[del[I_HCM] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_HCM] & 0x7]);
|
||||
break;
|
||||
case 40:
|
||||
pr("%c", dirstr[del[I_RAD] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_RAD] & 0x7]);
|
||||
break;
|
||||
case 41:
|
||||
pr("%d", del[I_UW] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_UW] & ~0x7);
|
||||
break;
|
||||
case 42:
|
||||
pr("%d", del[I_FOOD] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_FOOD] & ~0x7);
|
||||
break;
|
||||
case 43:
|
||||
pr("%d", del[I_SHELL] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_SHELL] & ~0x7);
|
||||
break;
|
||||
case 44:
|
||||
pr("%d", del[I_GUN] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_GUN] & ~0x7);
|
||||
break;
|
||||
case 45:
|
||||
pr("%d", del[I_PETROL] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_PETROL] & ~0x7);
|
||||
break;
|
||||
case 46:
|
||||
pr("%d", del[I_IRON] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_IRON] & ~0x7);
|
||||
break;
|
||||
case 47:
|
||||
pr("%d", del[I_DUST] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_DUST] & ~0x7);
|
||||
break;
|
||||
case 48:
|
||||
pr("%d", del[I_BAR] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_BAR] & ~0x7);
|
||||
break;
|
||||
case 49:
|
||||
pr("%d", del[I_OIL] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_OIL] & ~0x7);
|
||||
break;
|
||||
case 50:
|
||||
pr("%d", del[I_LCM] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_LCM] & ~0x7);
|
||||
break;
|
||||
case 51:
|
||||
pr("%d", del[I_HCM] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_HCM] & ~0x7);
|
||||
break;
|
||||
case 52:
|
||||
pr("%d", del[I_RAD] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_RAD] & ~0x7);
|
||||
break;
|
||||
/* level */
|
||||
case 53:
|
||||
|
@ -693,46 +687,46 @@ dump(void)
|
|||
pr("%d", yrel(getnatp(player->cnum), sect.sct_dist_y));
|
||||
break;
|
||||
case 55:
|
||||
pr("%d", dist[I_CIVIL]);
|
||||
pr("%d", sect.sct_dist[I_CIVIL]);
|
||||
break;
|
||||
case 56:
|
||||
pr("%d", dist[I_MILIT]);
|
||||
pr("%d", sect.sct_dist[I_MILIT]);
|
||||
break;
|
||||
case 57:
|
||||
pr("%d", dist[I_UW]);
|
||||
pr("%d", sect.sct_dist[I_UW]);
|
||||
break;
|
||||
case 58:
|
||||
pr("%d", dist[I_FOOD]);
|
||||
pr("%d", sect.sct_dist[I_FOOD]);
|
||||
break;
|
||||
case 59:
|
||||
pr("%d", dist[I_SHELL]);
|
||||
pr("%d", sect.sct_dist[I_SHELL]);
|
||||
break;
|
||||
case 60:
|
||||
pr("%d", dist[I_GUN]);
|
||||
pr("%d", sect.sct_dist[I_GUN]);
|
||||
break;
|
||||
case 61:
|
||||
pr("%d", dist[I_PETROL]);
|
||||
pr("%d", sect.sct_dist[I_PETROL]);
|
||||
break;
|
||||
case 62:
|
||||
pr("%d", dist[I_IRON]);
|
||||
pr("%d", sect.sct_dist[I_IRON]);
|
||||
break;
|
||||
case 63:
|
||||
pr("%d", dist[I_DUST]);
|
||||
pr("%d", sect.sct_dist[I_DUST]);
|
||||
break;
|
||||
case 64:
|
||||
pr("%d", dist[I_BAR]);
|
||||
pr("%d", sect.sct_dist[I_BAR]);
|
||||
break;
|
||||
case 65:
|
||||
pr("%d", dist[I_OIL]);
|
||||
pr("%d", sect.sct_dist[I_OIL]);
|
||||
break;
|
||||
case 66:
|
||||
pr("%d", dist[I_LCM]);
|
||||
pr("%d", sect.sct_dist[I_LCM]);
|
||||
break;
|
||||
case 67:
|
||||
pr("%d", dist[I_HCM]);
|
||||
pr("%d", sect.sct_dist[I_HCM]);
|
||||
break;
|
||||
case 68:
|
||||
pr("%d", dist[I_RAD]);
|
||||
pr("%d", sect.sct_dist[I_RAD]);
|
||||
break;
|
||||
case 69:
|
||||
pr("%d", sect.sct_road);
|
||||
|
@ -745,7 +739,7 @@ dump(void)
|
|||
break;
|
||||
case 72:
|
||||
if (opt_FALLOUT)
|
||||
pr("%d", cond[C_FALLOUT]);
|
||||
pr("%d", sect.sct_fallout);
|
||||
else
|
||||
pr("0");
|
||||
break;
|
||||
|
@ -753,16 +747,16 @@ dump(void)
|
|||
pr("%d", sect.sct_coastal);
|
||||
break;
|
||||
case 74:
|
||||
pr("%c", dirstr[del[I_CIVIL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_CIVIL] & 0x7]);
|
||||
break;
|
||||
case 75:
|
||||
pr("%c", dirstr[del[I_MILIT] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_MILIT] & 0x7]);
|
||||
break;
|
||||
case 76:
|
||||
pr("%d", del[I_CIVIL] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_CIVIL] & ~0x7);
|
||||
break;
|
||||
case 77:
|
||||
pr("%d", del[I_MILIT] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_MILIT] & ~0x7);
|
||||
break;
|
||||
case 78:
|
||||
pr("%d", sect.sct_terr1);
|
||||
|
|
|
@ -290,12 +290,10 @@ prsect(struct sctstr *sect)
|
|||
sect->sct_own, sect->sct_oldown, sect->sct_effic, sect->sct_mobil,
|
||||
sect->sct_min, sect->sct_gmin, sect->sct_fertil, sect->sct_oil,
|
||||
sect->sct_uran, sect->sct_work, sect->sct_loyal,
|
||||
getvar(V_CHE, (s_char *)sect, EF_SECTOR),
|
||||
getvar(V_PSTAGE, (s_char *)sect, EF_SECTOR),
|
||||
getvar(V_PTIME, (s_char *)sect, EF_SECTOR),
|
||||
getvar(V_FALLOUT, (s_char *)sect, EF_SECTOR), sect->sct_avail);
|
||||
sect->sct_che, sect->sct_pstage, sect->sct_ptime,
|
||||
sect->sct_fallout, sect->sct_avail);
|
||||
|
||||
pr("Mines <M>: %d\t", getvar(V_MINE, (s_char *)sect, EF_SECTOR));
|
||||
pr("Mines <M>: %d\t", sect->sct_mines);
|
||||
pr("Coastal <C>: %d\n", sect->sct_coastal);
|
||||
pr("Road %% <R>: %d\t", sect->sct_road);
|
||||
pr("Rail %% <r>: %d\t", sect->sct_rail);
|
||||
|
@ -434,9 +432,8 @@ pr_ship(struct shpstr *ship)
|
|||
pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
|
||||
ship->shp_rpath, (int)ship->shp_rflags);
|
||||
getvec(VT_ITEM, vec, (s_char *)ship, EF_SHIP);
|
||||
pr("Plague Stage <a>: %d\n",
|
||||
getvar(V_PSTAGE, (s_char *)ship, EF_SHIP));
|
||||
pr("Plague Time <b>: %d\n", getvar(V_PTIME, (s_char *)ship, EF_SHIP));
|
||||
pr("Plague Stage <a>: %d\n", ship->shp_pstage);
|
||||
pr("Plague Time <b>: %d\n", ship->shp_ptime);
|
||||
pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
|
||||
pr(" c m u f s g p i d o l h r\n");
|
||||
pr("%3d", vec[I_CIVIL]);
|
||||
|
@ -588,32 +585,32 @@ doland(s_char op, int arg, s_char *p, struct sctstr *sect)
|
|||
sect->sct_loyal = (u_char)new;
|
||||
break;
|
||||
case 'x':
|
||||
old = getvar(V_CHE, (s_char *)sect, EF_SECTOR);
|
||||
old = sect->sct_che;
|
||||
new = errcheck(arg, 0, 65536);
|
||||
pr("Guerillas in %s changed from %d to %d%\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
|
||||
putvar(V_CHE, new, (s_char *)sect, EF_SECTOR);
|
||||
sect->sct_che = new;
|
||||
break;
|
||||
case 'p':
|
||||
old = getvar(V_PSTAGE, (s_char *)sect, EF_SECTOR);
|
||||
old = sect->sct_pstage;
|
||||
new = errcheck(arg, 0, PLG_EXPOSED);
|
||||
pr("Plague stage of %s changed from %d to %d%\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
|
||||
putvar(V_PSTAGE, new, (s_char *)sect, EF_SECTOR);
|
||||
sect->sct_pstage = new;
|
||||
break;
|
||||
case 't':
|
||||
old = getvar(V_PTIME, (s_char *)sect, EF_SECTOR);
|
||||
old = sect->sct_ptime;
|
||||
new = errcheck(arg, 0, 255);
|
||||
pr("Plague time of %s changed from %d to %d%\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
|
||||
putvar(V_PTIME, new, (s_char *)sect, EF_SECTOR);
|
||||
sect->sct_ptime = new;
|
||||
break;
|
||||
case 'F':
|
||||
old = getvar(V_FALLOUT, (s_char *)sect, EF_SECTOR);
|
||||
old = sect->sct_fallout;
|
||||
new = errcheck(arg, 0, 9999);
|
||||
pr("Fallout for sector %s changed from %d to %d\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
|
||||
putvar(V_FALLOUT, new, (s_char *)sect, EF_SECTOR);
|
||||
sect->sct_fallout = new;
|
||||
break;
|
||||
case 'a':
|
||||
new = errcheck(arg, 0, 9999);
|
||||
|
@ -621,7 +618,7 @@ doland(s_char op, int arg, s_char *p, struct sctstr *sect)
|
|||
sect->sct_avail = new;
|
||||
break;
|
||||
case 'M':
|
||||
putvar(V_MINE, arg, (s_char *)sect, EF_SECTOR);
|
||||
sect->sct_mines = arg;
|
||||
pr("Mines changed to %d\n", arg);
|
||||
break;
|
||||
case 'L':
|
||||
|
@ -797,10 +794,10 @@ doship(s_char op, int arg, s_char *p, struct shpstr *ship)
|
|||
newx = newy = 0;
|
||||
switch (op) {
|
||||
case 'a':
|
||||
putvar(V_PSTAGE, arg, (s_char *)ship, EF_SHIP);
|
||||
ship->shp_pstage = arg;
|
||||
break;
|
||||
case 'b':
|
||||
putvar(V_PTIME, arg, (s_char *)ship, EF_SHIP);
|
||||
ship->shp_ptime = arg;
|
||||
break;
|
||||
case 'R':
|
||||
memcpy(ship->shp_rpath, p, sizeof(ship->shp_rpath));
|
||||
|
@ -877,82 +874,43 @@ doship(s_char op, int arg, s_char *p, struct shpstr *ship)
|
|||
ship->shp_nplane = errcheck(arg, 0, 100);
|
||||
break;
|
||||
case 'c':
|
||||
if (!putvar(V_CIVIL, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_CIVIL] = arg;
|
||||
break;
|
||||
case 'm':
|
||||
if (!putvar(V_MILIT, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_MILIT] = arg;
|
||||
break;
|
||||
case 'u':
|
||||
if (!putvar(V_UW, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_UW] = arg;
|
||||
break;
|
||||
case 'f':
|
||||
if (!putvar(V_FOOD, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_FOOD] = arg;
|
||||
break;
|
||||
case 's':
|
||||
if (!putvar(V_SHELL, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_SHELL] = arg;
|
||||
break;
|
||||
case 'g':
|
||||
if (!putvar(V_GUN, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_GUN] = arg;
|
||||
break;
|
||||
case 'p':
|
||||
if (!putvar(V_PETROL, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_PETROL] = arg;
|
||||
break;
|
||||
case 'i':
|
||||
if (!putvar(V_IRON, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_IRON] = arg;
|
||||
break;
|
||||
case 'd':
|
||||
if (!putvar(V_DUST, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_DUST] = arg;
|
||||
break;
|
||||
case 'o':
|
||||
if (!putvar(V_OIL, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_OIL] = arg;
|
||||
break;
|
||||
case 'l':
|
||||
if (!putvar(V_LCM, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_LCM] = arg;
|
||||
break;
|
||||
case 'h':
|
||||
if (!putvar(V_HCM, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_HCM] = arg;
|
||||
break;
|
||||
case 'r':
|
||||
if (!putvar(V_RAD, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_RAD] = arg;
|
||||
break;
|
||||
default:
|
||||
pr("huh? (%c)\n", op);
|
||||
|
@ -1050,82 +1008,43 @@ dounit(s_char op, int arg, s_char *p, struct lndstr *land)
|
|||
land->lnd_rflags = arg;
|
||||
break;
|
||||
case 'c':
|
||||
if (!putvar(V_CIVIL, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land unit!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_CIVIL] = arg;
|
||||
break;
|
||||
case 'm':
|
||||
if (!putvar(V_MILIT, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_MILIT] = arg;
|
||||
break;
|
||||
case 'u':
|
||||
if (!putvar(V_UW, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_UW] = arg;
|
||||
break;
|
||||
case 'f':
|
||||
if (!putvar(V_FOOD, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_FOOD] = arg;
|
||||
break;
|
||||
case 's':
|
||||
if (!putvar(V_SHELL, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_SHELL] = arg;
|
||||
break;
|
||||
case 'g':
|
||||
if (!putvar(V_GUN, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_GUN] = arg;
|
||||
break;
|
||||
case 'p':
|
||||
if (!putvar(V_PETROL, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_PETROL] = arg;
|
||||
break;
|
||||
case 'i':
|
||||
if (!putvar(V_IRON, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_IRON] = arg;
|
||||
break;
|
||||
case 'd':
|
||||
if (!putvar(V_DUST, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_DUST] = arg;
|
||||
break;
|
||||
case 'o':
|
||||
if (!putvar(V_OIL, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_OIL] = arg;
|
||||
break;
|
||||
case 'l':
|
||||
if (!putvar(V_LCM, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_LCM] = arg;
|
||||
break;
|
||||
case 'h':
|
||||
if (!putvar(V_HCM, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_HCM] = arg;
|
||||
break;
|
||||
case 'r':
|
||||
if (!putvar(V_RAD, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_RAD] = arg;
|
||||
break;
|
||||
default:
|
||||
pr("huh? (%c)\n", op);
|
||||
|
|
|
@ -83,7 +83,7 @@ enli(void)
|
|||
continue;
|
||||
if (sect.sct_oldown != player->cnum)
|
||||
continue;
|
||||
civ = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
|
||||
civ = sect.sct_item[I_CIVIL];
|
||||
if (civ == 0)
|
||||
continue;
|
||||
if (sect.sct_loyal > 70) {
|
||||
|
@ -95,7 +95,7 @@ enli(void)
|
|||
pr("%s is out of mobility!\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
}
|
||||
mil = getvar(V_MILIT, (s_char *)§, EF_SECTOR);
|
||||
mil = sect.sct_item[I_MILIT];
|
||||
newmil = civ * 0.5;
|
||||
if (quota) {
|
||||
if (newmil > milwant - mil)
|
||||
|
@ -110,14 +110,10 @@ enli(void)
|
|||
continue;
|
||||
if (newmil > reserve)
|
||||
newmil = reserve;
|
||||
if (!putvar(V_MILIT, newmil + mil, (s_char *)§, EF_SECTOR)) {
|
||||
pr("No room for military in %s\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
continue;
|
||||
}
|
||||
sect.sct_item[I_MILIT] = newmil + mil;
|
||||
reserve -= newmil;
|
||||
totalmil += newmil;
|
||||
putvar(V_CIVIL, civ - newmil, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_CIVIL] = civ - newmil;
|
||||
pr("%3d enlisted in %s (%d)\n", newmil,
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum), mil + newmil);
|
||||
if (sect.sct_mobil > 0) {
|
||||
|
|
|
@ -87,8 +87,8 @@ explore(void)
|
|||
pr("Not yours\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
infected = getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == PLG_INFECT;
|
||||
if ((amt_src = getvar(vtype, (s_char *)§, EF_SECTOR)) <= 0) {
|
||||
infected = sect.sct_pstage == PLG_INFECT;
|
||||
if ((amt_src = sect.sct_item[vtype]) <= 0) {
|
||||
pr("No %s in %s\n", ip->i_name,
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
return RET_SYN;
|
||||
|
@ -136,14 +136,14 @@ explore(void)
|
|||
weight = amount * ip->i_lbs;
|
||||
/* remove commodities from source sector */
|
||||
getsect(x, y, &start);
|
||||
amt_src = getvar(vtype, (s_char *)&start, EF_SECTOR);
|
||||
amt_src = start.sct_item[vtype];
|
||||
amt_src -= amount;
|
||||
if (amt_src < 0) {
|
||||
pr("%s in %s are gone!\n", ip->i_name,
|
||||
xyas(start.sct_x, start.sct_y, player->cnum));
|
||||
return RET_OK;
|
||||
}
|
||||
putvar(vtype, amt_src, (s_char *)&start, EF_SECTOR);
|
||||
start.sct_item[vtype] = amt_src;
|
||||
start.sct_flags |= MOVE_IN_PROGRESS;
|
||||
putsect(&start);
|
||||
/*
|
||||
|
@ -235,18 +235,14 @@ explore(void)
|
|||
getsect(start.sct_x, start.sct_y, &start);
|
||||
start.sct_flags &= ~MOVE_IN_PROGRESS;
|
||||
putsect(&start);
|
||||
amt_dst = getvar(vtype, (s_char *)§, EF_SECTOR);
|
||||
amt_dst = sect.sct_item[vtype];
|
||||
if (32767 - amt_dst < amount) {
|
||||
amount = 32767 - amt_dst;
|
||||
pr("Only %d can be left there.\n", amount);
|
||||
if (amount <= 0)
|
||||
getsect(start.sct_x, start.sct_y, §);
|
||||
}
|
||||
if (putvar(vtype, amount + amt_dst, (s_char *)§, EF_SECTOR) < 0) {
|
||||
pr("No more room in %s.\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
return RET_OK;
|
||||
}
|
||||
sect.sct_item[vtype] = amount + amt_dst;
|
||||
/*
|
||||
* Now add commodities to destination sector,
|
||||
* along with plague that came along for the ride.
|
||||
|
@ -262,8 +258,8 @@ explore(void)
|
|||
sect.sct_mobil = 0;
|
||||
}
|
||||
}
|
||||
if (infected && getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == 0)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)§, EF_SECTOR);
|
||||
if (infected && sect.sct_pstage == PLG_HEALTHY)
|
||||
sect.sct_pstage = PLG_EXPOSED;
|
||||
if (vtype == V_CIVIL) {
|
||||
if (opt_NEW_WORK) {
|
||||
sect.sct_loyal = ((amt_dst * sect.sct_loyal) +
|
||||
|
|
|
@ -139,8 +139,8 @@ fuel(void)
|
|||
if (sect.sct_type == SCT_HARBR
|
||||
|| (opt_BIG_CITY && sect.sct_type == SCT_CAPIT)) {
|
||||
harbor = 1;
|
||||
oil_amt = getvar(V_OIL, (s_char *)§, EF_SECTOR);
|
||||
pet_amt = getvar(V_PETROL, (s_char *)§, EF_SECTOR);
|
||||
oil_amt = sect.sct_item[I_OIL];
|
||||
pet_amt = sect.sct_item[I_PETROL];
|
||||
if ((oil_amt + pet_amt) == 0)
|
||||
harbor = 0;
|
||||
|
||||
|
@ -161,8 +161,8 @@ fuel(void)
|
|||
|
||||
if (harbor) {
|
||||
ship_fuel = item.ship.shp_fuel;
|
||||
oil_amt = getvar(V_OIL, (s_char *)§, EF_SECTOR);
|
||||
pet_amt = getvar(V_PETROL, (s_char *)§, EF_SECTOR);
|
||||
oil_amt = sect.sct_item[I_OIL];
|
||||
pet_amt = sect.sct_item[I_PETROL];
|
||||
max_amt = mp->m_fuelc - ship_fuel;
|
||||
|
||||
if (max_amt == 0) {
|
||||
|
@ -188,36 +188,28 @@ fuel(void)
|
|||
if ((pet_amt * 5) >= move_amt) {
|
||||
extra = ((float)move_amt / 5.0) - (move_amt / 5);
|
||||
if (extra > 0.0)
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)) - 1, 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5) - 1, 0);
|
||||
else
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)), 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5), 0);
|
||||
} else {
|
||||
putvar(V_PETROL, 0, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_PETROL] = 0;
|
||||
move_amt -= pet_amt * 5;
|
||||
extra = ((float)move_amt / 50.0) - (move_amt / 50);
|
||||
putvar(V_OIL, max(oil_amt - (move_amt / 50), 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_OIL] = max(oil_amt - move_amt / 50, 0);
|
||||
if (extra > 0.0)
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)) - 1, 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50) - 1, 0);
|
||||
else
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)), 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50), 0);
|
||||
}
|
||||
|
||||
/* load plague */
|
||||
if (getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) ==
|
||||
PLG_INFECT && getvar(V_PSTAGE,
|
||||
(s_char *)&item.ship,
|
||||
EF_SHIP) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&item.ship,
|
||||
EF_SHIP);
|
||||
if (sect.sct_pstage == PLG_INFECT
|
||||
&& item.ship.shp_pstage == PLG_HEALTHY)
|
||||
item.ship.shp_pstage = PLG_EXPOSED;
|
||||
|
||||
putsect(§);
|
||||
putship(item.ship.shp_uid, &item.ship);
|
||||
|
@ -250,8 +242,8 @@ fuel(void)
|
|||
continue;
|
||||
}
|
||||
ship_fuel = item.ship.shp_fuel;
|
||||
oil_amt = getvar(V_OIL, (s_char *)&item2.ship, EF_SHIP);
|
||||
pet_amt = getvar(V_PETROL, (s_char *)&item2.ship, EF_SHIP);
|
||||
oil_amt = item2.ship.shp_item[I_OIL];
|
||||
pet_amt = item2.ship.shp_item[I_PETROL];
|
||||
max_amt = mp->m_fuelc - ship_fuel;
|
||||
|
||||
if (max_amt == 0) {
|
||||
|
@ -272,36 +264,29 @@ fuel(void)
|
|||
if ((pet_amt * 5) >= move_amt) {
|
||||
extra = ((float)move_amt / 5.0) - (move_amt / 5);
|
||||
if (extra > 0.0)
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)) - 1, 0),
|
||||
(s_char *)&item2.ship, EF_SHIP);
|
||||
item2.ship.shp_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5) - 1, 0);
|
||||
else
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)), 0),
|
||||
(s_char *)&item2.ship, EF_SHIP);
|
||||
item2.ship.shp_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5), 0);
|
||||
} else {
|
||||
putvar(V_PETROL, 0, (s_char *)&item2.ship, EF_SHIP);
|
||||
item2.ship.shp_item[I_PETROL] = 0;
|
||||
move_amt -= pet_amt * 5;
|
||||
extra = ((float)move_amt / 50.0) - (move_amt / 50);
|
||||
putvar(V_OIL, max(oil_amt - (move_amt / 50), 0),
|
||||
(s_char *)&item2.ship, EF_SHIP);
|
||||
item2.ship.shp_item[I_OIL]
|
||||
= max(oil_amt - (move_amt / 50), 0);
|
||||
if (extra > 0.0)
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)) - 1, 0),
|
||||
(s_char *)&item2.ship, EF_SHIP);
|
||||
item2.ship.shp_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50) - 1, 0);
|
||||
else
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)), 0),
|
||||
(s_char *)&item2.ship, EF_SHIP);
|
||||
item2.ship.shp_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50), 0);
|
||||
}
|
||||
|
||||
/* load plague */
|
||||
if (getvar(V_PSTAGE, (s_char *)&item2.ship, EF_SHIP) ==
|
||||
PLG_INFECT && getvar(V_PSTAGE,
|
||||
(s_char *)&item.ship,
|
||||
EF_SHIP) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&item.ship,
|
||||
EF_SHIP);
|
||||
if (item2.ship.shp_pstage == PLG_INFECT
|
||||
&& item.ship.shp_pstage == PLG_HEALTHY)
|
||||
item.ship.shp_pstage = PLG_EXPOSED;
|
||||
|
||||
putship(item.ship.shp_uid, &item.ship);
|
||||
/* quick hack -KHS */
|
||||
|
@ -323,8 +308,8 @@ fuel(void)
|
|||
lcp = &lchr[(int)item.land.lnd_type];
|
||||
|
||||
sector = 1;
|
||||
oil_amt = getvar(V_OIL, (s_char *)§, EF_SECTOR);
|
||||
pet_amt = getvar(V_PETROL, (s_char *)§, EF_SECTOR);
|
||||
oil_amt = sect.sct_item[I_OIL];
|
||||
pet_amt = sect.sct_item[I_PETROL];
|
||||
|
||||
if ((oil_amt + pet_amt) == 0)
|
||||
sector = 0;
|
||||
|
@ -337,8 +322,8 @@ fuel(void)
|
|||
|
||||
if (sector) {
|
||||
land_fuel = item.land.lnd_fuel;
|
||||
oil_amt = getvar(V_OIL, (s_char *)§, EF_SECTOR);
|
||||
pet_amt = getvar(V_PETROL, (s_char *)§, EF_SECTOR);
|
||||
oil_amt = sect.sct_item[I_OIL];
|
||||
pet_amt = sect.sct_item[I_PETROL];
|
||||
max_amt = item.land.lnd_fuelc - land_fuel;
|
||||
|
||||
if (max_amt == 0) {
|
||||
|
@ -364,36 +349,28 @@ fuel(void)
|
|||
if ((pet_amt * 5) >= move_amt) {
|
||||
extra = ((float)move_amt / 5.0) - (move_amt / 5);
|
||||
if (extra > 0.0)
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)) - 1, 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5) - 1, 0);
|
||||
else
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)), 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5), 0);
|
||||
} else {
|
||||
putvar(V_PETROL, 0, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_PETROL] = 0;
|
||||
move_amt -= pet_amt * 5;
|
||||
extra = ((float)move_amt / 50.0) - (move_amt / 50);
|
||||
putvar(V_OIL, max(oil_amt - (move_amt / 50), 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_OIL] = max(oil_amt - move_amt / 50, 0);
|
||||
if (extra > 0.0)
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)) - 1, 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50) - 1, 0);
|
||||
else
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)), 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50), 0);
|
||||
}
|
||||
|
||||
/* load plague */
|
||||
if (getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) ==
|
||||
PLG_INFECT && getvar(V_PSTAGE,
|
||||
(s_char *)&item.land,
|
||||
EF_LAND) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&item.land,
|
||||
EF_LAND);
|
||||
if (sect.sct_pstage == PLG_INFECT
|
||||
&& item.land.lnd_pstage == PLG_HEALTHY)
|
||||
item.land.lnd_pstage = PLG_EXPOSED;
|
||||
|
||||
putsect(§);
|
||||
putland(item.land.lnd_uid, &item.land);
|
||||
|
@ -427,8 +404,8 @@ fuel(void)
|
|||
continue;
|
||||
}
|
||||
land_fuel = item.land.lnd_fuel;
|
||||
oil_amt = getvar(V_OIL, (s_char *)&item2.land, EF_LAND);
|
||||
pet_amt = getvar(V_PETROL, (s_char *)&item2.land, EF_LAND);
|
||||
oil_amt = item2.land.lnd_item[I_OIL];
|
||||
pet_amt = item2.land.lnd_item[I_PETROL];
|
||||
max_amt = item.land.lnd_fuelc - land_fuel;
|
||||
|
||||
if (max_amt == 0) {
|
||||
|
@ -449,36 +426,29 @@ fuel(void)
|
|||
if ((pet_amt * 5) >= move_amt) {
|
||||
extra = ((float)move_amt / 5.0) - (move_amt / 5);
|
||||
if (extra > 0.0)
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)) - 1, 0),
|
||||
(s_char *)&item2.land, EF_LAND);
|
||||
item2.land.lnd_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5) - 1, 0);
|
||||
else
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)), 0),
|
||||
(s_char *)&item2.land, EF_LAND);
|
||||
item2.land.lnd_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5), 0);
|
||||
} else {
|
||||
putvar(V_PETROL, 0, (s_char *)&item2.land, EF_LAND);
|
||||
item2.land.lnd_item[I_PETROL] = 0;
|
||||
move_amt -= pet_amt * 5;
|
||||
extra = ((float)move_amt / 50.0) - (move_amt / 50);
|
||||
putvar(V_OIL, max(oil_amt - (move_amt / 50), 0),
|
||||
(s_char *)&item2.land, EF_LAND);
|
||||
item2.land.lnd_item[I_OIL]
|
||||
= max(oil_amt - move_amt / 50, 0);
|
||||
if (extra > 0.0)
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)) - 1, 0),
|
||||
(s_char *)&item2.land, EF_LAND);
|
||||
item2.land.lnd_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50) - 1, 0);
|
||||
else
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)), 0),
|
||||
(s_char *)&item2.land, EF_LAND);
|
||||
item2.land.lnd_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50), 0);
|
||||
}
|
||||
|
||||
/* load plague */
|
||||
if (getvar(V_PSTAGE, (s_char *)&item2.land, EF_LAND) ==
|
||||
PLG_INFECT && getvar(V_PSTAGE,
|
||||
(s_char *)&item.land,
|
||||
EF_LAND) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&item.land,
|
||||
EF_LAND);
|
||||
if (item2.land.lnd_pstage == PLG_INFECT
|
||||
&& item.land.lnd_pstage == PLG_HEALTHY)
|
||||
item.land.lnd_pstage = PLG_EXPOSED;
|
||||
|
||||
putland(item.land.lnd_uid, &item.land);
|
||||
/* quick hack -KHS */
|
||||
|
|
|
@ -69,18 +69,14 @@ give(void)
|
|||
return RET_SYN;
|
||||
if ((amt = atoi(p)) == 0)
|
||||
return RET_SYN;
|
||||
n = getvar(ip->i_vtype, (s_char *)§, EF_SECTOR);
|
||||
n = sect.sct_item[ip->i_vtype];
|
||||
if (amt < 0 && -amt > n) {
|
||||
m = 0;
|
||||
} else if (amt > 0 && amt + n > 9990) {
|
||||
m = 9990;
|
||||
} else
|
||||
m = n + amt;
|
||||
if (putvar(ip->i_vtype, m, (s_char *)§, EF_SECTOR) < 0) {
|
||||
pr("No room to store %s in %s\n", ip->i_name,
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
return RET_FAIL;
|
||||
}
|
||||
sect.sct_item[ip->i_vtype] = m;
|
||||
putsect(§);
|
||||
if (sect.sct_own != 0 && m != n) {
|
||||
if (m > n) {
|
||||
|
|
|
@ -97,7 +97,7 @@ hard(void)
|
|||
prplane(&pln), xyas(pln.pln_x, pln.pln_y, player->cnum));
|
||||
continue;
|
||||
}
|
||||
hcm = getvar(V_HCM, (s_char *)§, EF_SECTOR);
|
||||
hcm = sect.sct_item[I_HCM];
|
||||
if (hcm == 0) {
|
||||
pr("No hcm in %s\n", xyas(pln.pln_x, pln.pln_y, player->cnum));
|
||||
continue;
|
||||
|
@ -112,7 +112,7 @@ hard(void)
|
|||
pln.pln_harden += n;
|
||||
player->dolcost += (5.0 * n);
|
||||
putplane(pln.pln_uid, &pln);
|
||||
putvar(V_HCM, hcm - n, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_HCM] = hcm - n;
|
||||
putsect(§);
|
||||
pr("%s hardened to %d\n", prplane(&pln), pln.pln_harden);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ hidd(void)
|
|||
struct sctstr sect;
|
||||
int nsect;
|
||||
struct nstr_sect nstr;
|
||||
int cond[I_MAX + 1];
|
||||
|
||||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
return RET_SYN;
|
||||
|
@ -68,14 +67,13 @@ hidd(void)
|
|||
}
|
||||
if (player->god)
|
||||
pr("%3d ", sect.sct_own);
|
||||
getvec(VT_COND, cond, (s_char *)§, EF_SECTOR);
|
||||
prxy("%4d,%-4d", nstr.x, nstr.y, player->cnum);
|
||||
pr(" %c %3d%% %3d %3d %3d %3d %3d %3d %3d",
|
||||
dchr[sect.sct_type].d_mnem, sect.sct_effic,
|
||||
sect.sct_oldown, sect.sct_loyal,
|
||||
get_che_cnum(cond[C_CHE]),
|
||||
get_che_value(cond[C_CHE]),
|
||||
cond[C_PSTAGE], cond[C_PTIME], cond[C_MINE]);
|
||||
get_che_cnum(sect.sct_che),
|
||||
get_che_value(sect.sct_che),
|
||||
sect.sct_pstage, sect.sct_ptime, sect.sct_mines);
|
||||
pr("\n");
|
||||
}
|
||||
if (nsect == 0) {
|
||||
|
|
|
@ -48,7 +48,6 @@ leve(void)
|
|||
struct sctstr sect;
|
||||
int nsect;
|
||||
struct nstr_sect nstr;
|
||||
int dist[I_MAX + 1];
|
||||
|
||||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
return RET_SYN;
|
||||
|
@ -65,24 +64,23 @@ leve(void)
|
|||
}
|
||||
if (player->god)
|
||||
pr("%2d ", sect.sct_own);
|
||||
getvec(VT_DIST, dist, (s_char *)§, EF_SECTOR);
|
||||
prxy("%3d,%-3d", nstr.x, nstr.y, player->cnum);
|
||||
pr(" %c ", dchr[sect.sct_type].d_mnem);
|
||||
prxy("%3d,%-3d", sect.sct_dist_x, sect.sct_dist_y, player->cnum);
|
||||
pr(" %4d", dist[I_CIVIL]);
|
||||
pr("%4d", dist[I_MILIT]);
|
||||
pr("%4d", dist[I_UW]);
|
||||
pr("%5d", dist[I_FOOD]);
|
||||
pr("%4d", dist[I_SHELL]);
|
||||
pr("%4d", dist[I_GUN]);
|
||||
pr("%4d", dist[I_PETROL]);
|
||||
pr("%5d", dist[I_IRON]);
|
||||
pr("%5d", dist[I_DUST]);
|
||||
pr("%4d", dist[I_BAR]);
|
||||
pr("%4d", dist[I_OIL]);
|
||||
pr("%4d", dist[I_LCM]);
|
||||
pr("%4d", dist[I_HCM]);
|
||||
pr("%4d", dist[I_RAD]);
|
||||
pr(" %4d", sect.sct_dist[I_CIVIL]);
|
||||
pr("%4d", sect.sct_dist[I_MILIT]);
|
||||
pr("%4d", sect.sct_dist[I_UW]);
|
||||
pr("%5d", sect.sct_dist[I_FOOD]);
|
||||
pr("%4d", sect.sct_dist[I_SHELL]);
|
||||
pr("%4d", sect.sct_dist[I_GUN]);
|
||||
pr("%4d", sect.sct_dist[I_PETROL]);
|
||||
pr("%5d", sect.sct_dist[I_IRON]);
|
||||
pr("%5d", sect.sct_dist[I_DUST]);
|
||||
pr("%4d", sect.sct_dist[I_BAR]);
|
||||
pr("%4d", sect.sct_dist[I_OIL]);
|
||||
pr("%4d", sect.sct_dist[I_LCM]);
|
||||
pr("%4d", sect.sct_dist[I_HCM]);
|
||||
pr("%4d", sect.sct_dist[I_RAD]);
|
||||
pr("\n");
|
||||
}
|
||||
if (nsect == 0) {
|
||||
|
|
|
@ -194,12 +194,12 @@ load(void)
|
|||
return retval;
|
||||
}
|
||||
/* load/unload plague */
|
||||
if (getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)&ship, EF_SHIP) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&ship, EF_SHIP);
|
||||
if (getvar(V_PSTAGE, (s_char *)&ship, EF_SHIP) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)§, EF_SECTOR);
|
||||
if (sect.sct_pstage == PLG_INFECT
|
||||
&& ship.shp_pstage == PLG_HEALTHY)
|
||||
ship.shp_pstage = PLG_EXPOSED;
|
||||
if (ship.shp_pstage == PLG_INFECT
|
||||
&& sect.sct_pstage == PLG_HEALTHY)
|
||||
sect.sct_pstage = PLG_EXPOSED;
|
||||
putsect(§);
|
||||
putship(ship.shp_uid, &ship);
|
||||
}
|
||||
|
@ -302,12 +302,12 @@ lload(void)
|
|||
return retval;
|
||||
}
|
||||
/* load/unload plague */
|
||||
if (getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)&land, EF_LAND) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&land, EF_LAND);
|
||||
if (getvar(V_PSTAGE, (s_char *)&land, EF_LAND) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)§, EF_SECTOR);
|
||||
if (sect.sct_pstage == PLG_INFECT
|
||||
&& land.lnd_pstage == PLG_HEALTHY)
|
||||
land.lnd_pstage = PLG_EXPOSED;
|
||||
if (land.lnd_pstage == PLG_INFECT
|
||||
&& sect.sct_pstage == PLG_HEALTHY)
|
||||
sect.sct_pstage = PLG_EXPOSED;
|
||||
|
||||
putsect(§);
|
||||
putland(land.lnd_uid, &land);
|
||||
|
@ -763,8 +763,8 @@ load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
|
|||
load_unload = LOAD;
|
||||
} else if (!amount)
|
||||
return 0;
|
||||
ship_amt = getvar(item, (s_char *)sp, EF_SHIP);
|
||||
sect_amt = getvar(item, (s_char *)sectp, EF_SECTOR);
|
||||
ship_amt = sp->shp_item[item];
|
||||
sect_amt = sectp->sct_item[item];
|
||||
if (sectp->sct_oldown != player->cnum && item == V_CIVIL) {
|
||||
pr("%s civilians refuse to %s at %s!\n",
|
||||
load_unload == UNLOAD ? "Your" : "Foreign",
|
||||
|
@ -799,8 +799,8 @@ load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
|
|||
return RET_FAIL;
|
||||
if (!still_ok_ship(sectp, sp))
|
||||
return RET_SYN;
|
||||
putvar(item, sect_amt - move_amt, (s_char *)sectp, EF_SECTOR);
|
||||
putvar(item, ship_amt + move_amt, (s_char *)sp, EF_SHIP);
|
||||
sectp->sct_item[item] = sect_amt - move_amt;
|
||||
sp->shp_item[item] = ship_amt + move_amt;
|
||||
if (load_unload == LOAD) {
|
||||
pr("%d %s loaded onto %s at %s\n",
|
||||
move_amt,
|
||||
|
@ -989,8 +989,8 @@ load_comm_land(struct sctstr *sectp, struct lndstr *lp,
|
|||
return 0;
|
||||
}
|
||||
|
||||
land_amt = getvar(item, (s_char *)lp, EF_LAND);
|
||||
sect_amt = getvar(item, (s_char *)sectp, EF_SECTOR);
|
||||
land_amt = lp->lnd_item[item];
|
||||
sect_amt = sectp->sct_item[item];
|
||||
if (sectp->sct_oldown != player->cnum && item == V_CIVIL) {
|
||||
pr("%s civilians refuse to %s at %s!\n",
|
||||
load_unload == UNLOAD ? "Your" : "Foreign",
|
||||
|
@ -1020,8 +1020,8 @@ load_comm_land(struct sctstr *sectp, struct lndstr *lp,
|
|||
move_amt = load_unload * min(amount, max_amt);
|
||||
if (move_amt == 0)
|
||||
return 0;
|
||||
putvar(item, sect_amt - move_amt, (s_char *)sectp, EF_SECTOR);
|
||||
putvar(item, land_amt + move_amt, (s_char *)lp, EF_LAND);
|
||||
sectp->sct_item[item] = sect_amt - move_amt;
|
||||
lp->lnd_item[item] = land_amt + move_amt;
|
||||
|
||||
/* Did we put mils onto this unit? If so, reset the fortification */
|
||||
if (item == V_MILIT && move_amt > 0)
|
||||
|
|
|
@ -92,8 +92,8 @@ look(void)
|
|||
dchr[sect.sct_type].d_mnem, 0);
|
||||
pr(" %d%% efficient ", player->owner ? sect.sct_effic :
|
||||
roundintby((int)sect.sct_effic, 10));
|
||||
civ = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
|
||||
mil = getvar(V_MILIT, (s_char *)§, EF_SECTOR);
|
||||
civ = sect.sct_item[I_CIVIL];
|
||||
mil = sect.sct_item[I_MILIT];
|
||||
if (civ)
|
||||
pr("with %s%d civ ", player->owner ? "" : "approx ",
|
||||
player->owner ? civ : roundintby(civ, 10));
|
||||
|
@ -226,8 +226,8 @@ llook(void)
|
|||
dchr[sect.sct_type].d_mnem, 0);
|
||||
pr(" %d%% efficient ", player->owner ? sect.sct_effic :
|
||||
roundintby((int)sect.sct_effic, 10));
|
||||
civ = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
|
||||
mil = getvar(V_MILIT, (s_char *)§, EF_SECTOR);
|
||||
civ = sect.sct_item[I_CIVIL];
|
||||
mil = sect.sct_item[I_MILIT];
|
||||
if (civ)
|
||||
pr("with %s%d civ ", player->owner ? "" :
|
||||
"approx ", player->owner ? civ : roundintby(civ, 10));
|
||||
|
|
|
@ -88,7 +88,7 @@ ltend(void)
|
|||
return RET_FAIL;
|
||||
if ((amt = atoi(p)) == 0)
|
||||
break;
|
||||
ontender = getvar(ip->i_vtype, (s_char *)&tender, EF_SHIP);
|
||||
ontender = tender.shp_item[ip->i_vtype];
|
||||
if (ontender == 0 && amt > 0) {
|
||||
pr("No %s on %s\n", ip->i_name, prship(&tender));
|
||||
return RET_FAIL;
|
||||
|
@ -114,7 +114,7 @@ ltend(void)
|
|||
|
||||
if (target.lnd_ship != tender.shp_uid)
|
||||
continue;
|
||||
ontarget = getvar(ip->i_vtype, (s_char *)&target, EF_LAND);
|
||||
ontarget = target.lnd_item[ip->i_vtype];
|
||||
if (ontarget == 0 && amt < 0) {
|
||||
pr("No %s on %s\n",
|
||||
ip->i_name, prship((struct shpstr *)&target));
|
||||
|
@ -132,8 +132,7 @@ ltend(void)
|
|||
transfer = min(maxtender - ontender, transfer);
|
||||
if (transfer == 0)
|
||||
continue;
|
||||
putvar(ip->i_vtype, ontarget - transfer,
|
||||
(s_char *)&target, EF_LAND);
|
||||
target.lnd_item[ip->i_vtype] = ontarget - transfer;
|
||||
ontender += transfer;
|
||||
total += transfer;
|
||||
} else {
|
||||
|
@ -142,8 +141,7 @@ ltend(void)
|
|||
transfer = min(transfer, maxtarget - ontarget);
|
||||
if (transfer == 0)
|
||||
continue;
|
||||
putvar(ip->i_vtype, ontarget + transfer,
|
||||
(s_char *)&target, EF_LAND);
|
||||
target.lnd_item[ip->i_vtype] = ontarget + transfer;
|
||||
ontender -= transfer;
|
||||
total += transfer;
|
||||
}
|
||||
|
@ -157,7 +155,7 @@ ltend(void)
|
|||
pr("%d total %s transferred %s %s\n",
|
||||
total, ip->i_name, (amt > 0) ? "off of" : "to",
|
||||
prship(&tender));
|
||||
putvar(ip->i_vtype, ontender, (s_char *)&tender, EF_SHIP);
|
||||
tender.shp_item[ip->i_vtype] = ontender;
|
||||
tender.shp_mission = 0;
|
||||
putship(tender.shp_uid, &tender);
|
||||
}
|
||||
|
@ -167,10 +165,8 @@ ltend(void)
|
|||
static void
|
||||
expose_land(struct shpstr *s1, struct lndstr *l1)
|
||||
{
|
||||
if (getvar(V_PSTAGE, (s_char *)s1, EF_SHIP) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)l1, EF_LAND) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)l1, EF_LAND);
|
||||
if (getvar(V_PSTAGE, (s_char *)l1, EF_LAND) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)s1, EF_SHIP) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)s1, EF_SHIP);
|
||||
if (s1->shp_pstage == PLG_INFECT && l1->lnd_pstage == PLG_HEALTHY)
|
||||
l1->lnd_pstage = PLG_EXPOSED;
|
||||
if (l1->lnd_pstage == PLG_INFECT && s1->shp_pstage == PLG_HEALTHY)
|
||||
s1->shp_pstage = PLG_EXPOSED;
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ multifire(void)
|
|||
}
|
||||
resupply_commod(&fland, I_SHELL); /* Get more shells */
|
||||
putland(fland.lnd_uid, &fland);
|
||||
if (getvar(V_SHELL, (s_char *)&fland, EF_LAND) == 0) {
|
||||
if (fland.lnd_item[I_SHELL] == 0) {
|
||||
pr("%s -- not enough shells\n", prland(&fland));
|
||||
continue;
|
||||
}
|
||||
|
@ -207,11 +207,11 @@ multifire(void)
|
|||
continue;
|
||||
if (item.ship.shp_own != player->cnum)
|
||||
continue;
|
||||
if (getvar(V_MILIT, (s_char *)&item.ship, EF_SHIP) < 1) {
|
||||
if (item.ship.shp_item[I_MILIT] < 1) {
|
||||
pr("Not enough mil on ship #%d\n", item.ship.shp_uid);
|
||||
continue;
|
||||
}
|
||||
gun = getvar(V_GUN, (s_char *)&item.ship, EF_SHIP);
|
||||
gun = item.ship.shp_item[I_GUN];
|
||||
gun = min(gun, item.ship.shp_glim);
|
||||
if (item.ship.shp_frnge == 0) {
|
||||
pr("Ships %d cannot fire guns!\n", item.ship.shp_uid);
|
||||
|
@ -221,7 +221,7 @@ multifire(void)
|
|||
pr("Not enough guns on ship #%d\n", item.ship.shp_uid);
|
||||
continue;
|
||||
}
|
||||
if (getvar(V_SHELL, (s_char *)&item.ship, EF_SHIP) == 0) {
|
||||
if (item.ship.shp_item[I_SHELL] == 0) {
|
||||
pr("Not enough shells on ship #%d\n", item.ship.shp_uid);
|
||||
continue;
|
||||
}
|
||||
|
@ -241,17 +241,17 @@ multifire(void)
|
|||
pr("Fort not efficient enough to fire!\n");
|
||||
continue;
|
||||
}
|
||||
if (getvar(V_GUN, (s_char *)&item.sect, EF_SECTOR) == 0) {
|
||||
if (item.sect.sct_item[I_GUN] == 0) {
|
||||
pr("Not enough guns in sector %s!\n",
|
||||
xyas(item.sect.sct_x, item.sect.sct_y, player->cnum));
|
||||
continue;
|
||||
}
|
||||
if (getvar(V_SHELL, (s_char *)&item.sect, EF_SECTOR) == 0) {
|
||||
if (item.sect.sct_item[I_SHELL] == 0) {
|
||||
pr("Not enough shells in sector %s!\n",
|
||||
xyas(item.sect.sct_x, item.sect.sct_y, player->cnum));
|
||||
continue;
|
||||
}
|
||||
if (getvar(V_MILIT, (s_char *)&item.sect, EF_SECTOR) < 5) {
|
||||
if (item.sect.sct_item[I_MILIT] < 5) {
|
||||
pr("Not enough military in sector %s!\n",
|
||||
xyas(item.sect.sct_x, item.sect.sct_y, player->cnum));
|
||||
continue;
|
||||
|
@ -327,17 +327,17 @@ multifire(void)
|
|||
}
|
||||
*/
|
||||
attacker = targ_ship;
|
||||
if ((mil = getvar(V_MILIT, (s_char *)&fship, EF_SHIP)) < 1) {
|
||||
if ((mil = fship.shp_item[I_MILIT]) < 1) {
|
||||
pr("Not enough military for firing crew.\n");
|
||||
continue;
|
||||
}
|
||||
gun = getvar(V_GUN, (s_char *)&fship, EF_SHIP);
|
||||
gun = fship.shp_item[I_GUN];
|
||||
gun = min(gun, fship.shp_glim);
|
||||
if (fship.shp_frnge == 0 || gun == 0) {
|
||||
pr("Insufficient arms.\n");
|
||||
continue;
|
||||
}
|
||||
shell = getvar(V_SHELL, (s_char *)&fship, EF_SHIP);
|
||||
shell = fship.shp_item[I_SHELL];
|
||||
if (shell < 2)
|
||||
shell += supply_commod(fship.shp_own, fship.shp_x,
|
||||
fship.shp_y, I_SHELL, 2 - shell);
|
||||
|
@ -377,7 +377,7 @@ multifire(void)
|
|||
guneff = seagun(fship.shp_effic, shots);
|
||||
dam = (int)guneff;
|
||||
shell -= ldround(((double)shots) / 2.0, 1);
|
||||
putvar(V_SHELL, shell, (s_char *)&fship, EF_SHIP);
|
||||
fship.shp_item[I_SHELL] = shell;
|
||||
putship(fship.shp_uid, &fship);
|
||||
if (opt_NOMOBCOST == 0)
|
||||
fship.shp_mobil = max(fship.shp_mobil - 15, -100);
|
||||
|
@ -402,12 +402,12 @@ multifire(void)
|
|||
pr("Unit %d cannot fire!\n", fland.lnd_uid);
|
||||
continue;
|
||||
}
|
||||
if (getvar(V_SHELL, (s_char *)&fland, EF_LAND) == 0) {
|
||||
if (fland.lnd_item[I_SHELL] == 0) {
|
||||
pr("%s -- not enough shells\n", prland(&fland));
|
||||
continue;
|
||||
}
|
||||
|
||||
shell = getvar(V_SHELL, (s_char *)&fland, EF_LAND);
|
||||
shell = fland.lnd_item[I_SHELL];
|
||||
|
||||
range = techfact((int)fland.lnd_tech,
|
||||
(double)fland.lnd_frg / 2.0);
|
||||
|
@ -419,7 +419,7 @@ multifire(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
gun = getvar(V_GUN, (s_char *)&fland, EF_LAND);
|
||||
gun = fland.lnd_item[I_GUN];
|
||||
if (gun <= 0) {
|
||||
pr("%s -- not enough guns\n", prland(&fland));
|
||||
continue;
|
||||
|
@ -451,11 +451,11 @@ multifire(void)
|
|||
}
|
||||
}
|
||||
attacker = targ_land;
|
||||
if ((gun = getvar(V_GUN, (s_char *)&fsect, EF_SECTOR)) == 0) {
|
||||
if ((gun = fsect.sct_item[I_GUN]) == 0) {
|
||||
pr("Insufficient arms.\n");
|
||||
continue;
|
||||
}
|
||||
shell = getvar(V_SHELL, (s_char *)&fsect, EF_SECTOR);
|
||||
shell = fsect.sct_item[I_SHELL];
|
||||
if (shell <= 0)
|
||||
shell += supply_commod(fsect.sct_own, fsect.sct_x,
|
||||
fsect.sct_y, I_SHELL, 1);
|
||||
|
@ -463,7 +463,7 @@ multifire(void)
|
|||
pr("Klick! ...\n");
|
||||
continue;
|
||||
}
|
||||
if (getvar(V_MILIT, (s_char *)&fsect, EF_SECTOR) < 5) {
|
||||
if (fsect.sct_item[I_MILIT] < 5) {
|
||||
pr("Not enough military for firing crew.\n");
|
||||
continue;
|
||||
}
|
||||
|
@ -481,7 +481,7 @@ multifire(void)
|
|||
guneff = landgun((int)fsect.sct_effic, gun);
|
||||
dam = (int)guneff;
|
||||
shell--;
|
||||
putvar(V_SHELL, shell, (s_char *)&fsect, EF_SECTOR);
|
||||
fsect.sct_item[I_SHELL] = shell;
|
||||
putsect(&fsect);
|
||||
}
|
||||
trange = mapdist(x, y, fx, fy);
|
||||
|
@ -995,8 +995,8 @@ use_ammo(struct emp_qelem *list)
|
|||
struct shpstr ship;
|
||||
struct lndstr land;
|
||||
struct sctstr sect;
|
||||
int shell, type;
|
||||
s_char *ptr;
|
||||
int shell;
|
||||
u_short *item;
|
||||
double mobcost;
|
||||
struct mchrstr *mcp;
|
||||
|
||||
|
@ -1006,14 +1006,13 @@ use_ammo(struct emp_qelem *list)
|
|||
fp = (struct flist *)qp;
|
||||
if (fp->type == targ_ship) {
|
||||
getship(fp->uid, &ship);
|
||||
ptr = (s_char *)&ship;
|
||||
type = EF_SHIP;
|
||||
item = ship.shp_item;
|
||||
if (mchr[(int)ship.shp_type].m_flags & M_SUB) {
|
||||
shell = getvar(V_SHELL, ptr, type);
|
||||
shell = item[I_SHELL];
|
||||
shell--;
|
||||
if (shell < 0)
|
||||
shell = 0;
|
||||
putvar(V_SHELL, shell, ptr, type);
|
||||
item[I_SHELL] = shell;
|
||||
putship(ship.shp_uid, &ship);
|
||||
mcp = &mchr[(int)ship.shp_type];
|
||||
mobcost = ship.shp_effic * 0.01 * ship.shp_speed;
|
||||
|
@ -1025,18 +1024,16 @@ use_ammo(struct emp_qelem *list)
|
|||
}
|
||||
} else if (fp->type == targ_land) {
|
||||
getsect(fp->x, fp->y, §);
|
||||
ptr = (s_char *)§
|
||||
type = EF_SECTOR;
|
||||
item = sect.sct_item;
|
||||
} else {
|
||||
getland(fp->uid, &land);
|
||||
ptr = (s_char *)&land;
|
||||
type = EF_LAND;
|
||||
item = land.lnd_item;
|
||||
}
|
||||
shell = getvar(V_SHELL, ptr, type);
|
||||
shell = item[I_SHELL];
|
||||
shell--;
|
||||
if (shell < 0)
|
||||
shell = 0;
|
||||
putvar(V_SHELL, shell, ptr, type);
|
||||
item[I_SHELL] = shell;
|
||||
if (fp->type == targ_ship)
|
||||
putship(ship.shp_uid, &ship);
|
||||
else if (fp->type == targ_land)
|
||||
|
|
|
@ -56,7 +56,6 @@ mine(void)
|
|||
int mines;
|
||||
int shells;
|
||||
int mines_avail;
|
||||
int mines_there;
|
||||
|
||||
if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
|
||||
return RET_SYN;
|
||||
|
@ -70,7 +69,7 @@ mine(void)
|
|||
mp = &mchr[(int)ship.shp_type];
|
||||
if ((mp->m_flags & M_MINE) == 0)
|
||||
continue;
|
||||
if ((shells = getvar(V_SHELL, (s_char *)&ship, EF_SHIP)) == 0)
|
||||
if ((shells = ship.shp_item[I_SHELL]) == 0)
|
||||
continue;
|
||||
mines_avail = min(shells, mines);
|
||||
if (getsect(ship.shp_x, ship.shp_y, §) == 0 ||
|
||||
|
@ -78,10 +77,8 @@ mine(void)
|
|||
pr("You can't lay mines there!!\n");
|
||||
continue;
|
||||
}
|
||||
mines_there = getvar(V_MINE, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_SHELL, shells - mines_avail, (s_char *)&ship, EF_SHIP);
|
||||
putvar(V_MINE, mines_avail + mines_there, (s_char *)§,
|
||||
EF_SECTOR);
|
||||
sect.sct_mines += mines_avail;
|
||||
ship.shp_item[I_SHELL] = shells - mines_avail;
|
||||
putsect(§);
|
||||
ship.shp_mission = 0;
|
||||
putship(ship.shp_uid, &ship);
|
||||
|
@ -104,7 +101,6 @@ landmine(void)
|
|||
struct lchrstr *lp;
|
||||
struct nstr_item ni;
|
||||
int shells;
|
||||
int mines_there;
|
||||
int mines_wanted;
|
||||
int mines_laid;
|
||||
int total_mines_laid;
|
||||
|
@ -124,7 +120,7 @@ landmine(void)
|
|||
}
|
||||
resupply_commod(&land, I_SHELL);
|
||||
putland(land.lnd_uid, &land);
|
||||
if (!(shells = getvar(V_SHELL, (s_char *)&land, EF_LAND)))
|
||||
if (!(shells = land.lnd_item[I_SHELL]))
|
||||
continue;
|
||||
shells = min(shells, land.lnd_mobil);
|
||||
if (!getsect(land.lnd_x, land.lnd_y, §) ||
|
||||
|
@ -132,10 +128,9 @@ landmine(void)
|
|||
pr("You can't lay mines there!!\n");
|
||||
continue;
|
||||
}
|
||||
mines_there = getvar(V_MINE, (s_char *)§, EF_SECTOR);
|
||||
if (sect.sct_own == sect.sct_oldown)
|
||||
pr("There are currently %d mines in %s\n",
|
||||
mines_there, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
sect.sct_mines, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
sprintf(prompt, "Drop how many mines from %s? ", prland(&land));
|
||||
mines_wanted = onearg(player->argp[2], prompt);
|
||||
if (!check_land_ok(&land))
|
||||
|
@ -146,18 +141,17 @@ landmine(void)
|
|||
total_mines_laid = 0;
|
||||
while (shells > 0 && total_mines_laid < mines_wanted) {
|
||||
mines_laid = min(shells, mines_wanted - total_mines_laid);
|
||||
putvar(V_SHELL, shells - mines_laid, (s_char *)&land, EF_LAND);
|
||||
land.lnd_item[I_SHELL] = shells - mines_laid;
|
||||
land.lnd_mobil -= mines_laid;
|
||||
putland(land.lnd_uid, &land);
|
||||
resupply_commod(&land, I_SHELL); /* Get more shells */
|
||||
putland(land.lnd_uid, &land);
|
||||
total_mines_laid += mines_laid;
|
||||
shells = getvar(V_SHELL, (s_char *)&land, EF_LAND);
|
||||
shells = land.lnd_item[I_SHELL];
|
||||
shells = min(shells, land.lnd_mobil);
|
||||
}
|
||||
getsect(sect.sct_x, sect.sct_y, §);
|
||||
putvar(V_MINE, total_mines_laid + mines_there, (s_char *)§,
|
||||
EF_SECTOR);
|
||||
sect.sct_mines += total_mines_laid;
|
||||
putsect(§);
|
||||
if (total_mines_laid == mines_wanted) {
|
||||
pr("%s laid a total of %d mines in %s",
|
||||
|
|
|
@ -103,16 +103,15 @@ move(void)
|
|||
if (land.lnd_own == player->cnum)
|
||||
tot_mil += total_mil(&land);
|
||||
}
|
||||
if ((getvar(V_MILIT, (s_char *)§, EF_SECTOR) + tot_mil) * 10
|
||||
< getvar(V_CIVIL, (s_char *)§, EF_SECTOR)) {
|
||||
if ((sect.sct_item[I_MILIT] + tot_mil) * 10 < sect.sct_item[I_CIVIL]) {
|
||||
pr("Military control required to move goods.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
}
|
||||
stype = sect.sct_type;
|
||||
dp = &dchr[stype];
|
||||
infected = getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == PLG_INFECT;
|
||||
amt_src = getvar(vtype, (s_char *)§, EF_SECTOR);
|
||||
infected = sect.sct_pstage == PLG_INFECT;
|
||||
amt_src = sect.sct_item[vtype];
|
||||
if (!istest && amt_src <= 0) {
|
||||
pr("No %s in %s\n", ip->i_name,
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
|
@ -179,7 +178,7 @@ move(void)
|
|||
pr("Somebody has captured that sector!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
amt_src = getvar(vtype, (s_char *)&start, EF_SECTOR);
|
||||
amt_src = start.sct_item[vtype];
|
||||
if (amt_src < amount) {
|
||||
pr("Only %d %s left in %s!\n", amt_src,
|
||||
ip->i_name, xyas(start.sct_x, start.sct_y, player->cnum));
|
||||
|
@ -188,7 +187,7 @@ move(void)
|
|||
} else
|
||||
amt_src -= amount;
|
||||
|
||||
putvar(vtype, amt_src, (s_char *)&start, EF_SECTOR);
|
||||
start.sct_item[vtype] = amt_src;
|
||||
start.sct_flags |= MOVE_IN_PROGRESS;
|
||||
putsect(&start);
|
||||
}
|
||||
|
@ -252,13 +251,13 @@ move(void)
|
|||
pr("Somebody has captured that sector!\n");
|
||||
getsect(x, y, §);
|
||||
}
|
||||
if (vtype == V_CIVIL && getvar(V_CIVIL, (s_char *)§, EF_SECTOR) &&
|
||||
sect.sct_oldown != player->cnum) {
|
||||
if (vtype == V_CIVIL && sect.sct_item[I_CIVIL]
|
||||
&& sect.sct_oldown != player->cnum) {
|
||||
pr("Your civilians don't want to stay!\n");
|
||||
getsect(x, y, §);
|
||||
}
|
||||
|
||||
amt_dst = getvar(vtype, (s_char *)§, EF_SECTOR);
|
||||
amt_dst = sect.sct_item[vtype];
|
||||
if (32767 - amt_dst < amount) {
|
||||
pr("Only enough room for %d in %s. The goods will be returned.\n",
|
||||
32767 - amt_dst, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
|
@ -281,7 +280,7 @@ move(void)
|
|||
getsect(x + diroff[n][0], y + diroff[n][1], &tsct);
|
||||
if (tsct.sct_own != player->cnum)
|
||||
continue;
|
||||
amt_dst = getvar(vtype, (s_char *)&tsct, EF_SECTOR);
|
||||
amt_dst = tsct.sct_item[vtype];
|
||||
if (32767 - amt_dst < amount)
|
||||
continue;
|
||||
n = -1;
|
||||
|
@ -308,26 +307,21 @@ move(void)
|
|||
getsect(tsct.sct_x, tsct.sct_y, §);
|
||||
}
|
||||
|
||||
amt_dst = getvar(vtype, (s_char *)§, EF_SECTOR);
|
||||
amt_dst = sect.sct_item[vtype];
|
||||
if (32767 - amt_dst < amount) {
|
||||
amount = 32767 - amt_dst;
|
||||
pr("Only room for %d, the rest were lost.\n", amount);
|
||||
}
|
||||
if (istest)
|
||||
return RET_OK;
|
||||
if (putvar(vtype, amount + amt_dst, (s_char *)§, EF_SECTOR) < 0) {
|
||||
pr("No more room in %s. The goods were lost.\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
/* charge the player mobility anyway */
|
||||
amount = 0;
|
||||
}
|
||||
sect.sct_item[vtype] = amount + amt_dst;
|
||||
/*
|
||||
* Now add commodities to destination sector,
|
||||
* along with plague that came along for the ride.
|
||||
* Takeover unowned sectors if not deity.
|
||||
*/
|
||||
if (infected && getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == 0)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)§, EF_SECTOR);
|
||||
if (infected && sect.sct_pstage == PLG_HEALTHY)
|
||||
sect.sct_pstage = PLG_EXPOSED;
|
||||
if (vtype == V_CIVIL) {
|
||||
if (opt_NEW_WORK) {
|
||||
sect.sct_loyal = ((amt_dst * sect.sct_loyal) +
|
||||
|
@ -398,8 +392,8 @@ would_abandon(struct sctstr *sp, int vtype, int amnt, struct lndstr *lp)
|
|||
if ((vtype != V_CIVIL) && (vtype != V_MILIT))
|
||||
return 0;
|
||||
|
||||
mil = getvar(V_MILIT, (s_char *)sp, EF_SECTOR);
|
||||
civs = getvar(V_CIVIL, (s_char *)sp, EF_SECTOR);
|
||||
mil = sp->sct_item[I_MILIT];
|
||||
civs = sp->sct_item[I_CIVIL];
|
||||
|
||||
if (vtype == V_MILIT)
|
||||
mil -= amnt;
|
||||
|
|
|
@ -68,8 +68,8 @@ nati(void)
|
|||
pr("No capital. (was at %s)\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
else {
|
||||
civ = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
|
||||
mil = getvar(V_MILIT, (s_char *)§, EF_SECTOR);
|
||||
civ = sect.sct_item[I_CIVIL];
|
||||
mil = sect.sct_item[I_MILIT];
|
||||
pr("%d%% eff %s at %s has %d civilian%s & %d military\n",
|
||||
sect.sct_effic,
|
||||
(sect.sct_type ==
|
||||
|
|
|
@ -160,13 +160,10 @@ new(void)
|
|||
sect.sct_min = 100;
|
||||
sect.sct_gmin = 100;
|
||||
}
|
||||
if (opt_RES_POP)
|
||||
putvar(V_CIVIL, 550, (s_char *)§, EF_SECTOR);
|
||||
else
|
||||
putvar(V_CIVIL, 999, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_MILIT, 55, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_FOOD, 1000, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_UW, 75, (s_char *)§, EF_SECTOR);
|
||||
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;
|
||||
|
@ -188,13 +185,10 @@ new(void)
|
|||
sect.sct_min = 100;
|
||||
sect.sct_gmin = 100;
|
||||
}
|
||||
if (opt_RES_POP)
|
||||
putvar(V_CIVIL, 550, (s_char *)§, EF_SECTOR);
|
||||
else
|
||||
putvar(V_CIVIL, 999, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_FOOD, 100, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_MILIT, 55, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_UW, 75, (s_char *)§, EF_SECTOR);
|
||||
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_NEW;
|
||||
|
@ -370,7 +364,6 @@ deity_build_land(int type, coord x, coord y, natid own, int tlev)
|
|||
land.lnd_maxlight = (int)LND_XPL(lp->l_nxlight, tlev - lp->l_tech);
|
||||
land.lnd_maxland = (int)LND_MXL(lp->l_mxland, tlev - lp->l_tech);
|
||||
|
||||
memset(lvec, 0, sizeof(lvec));
|
||||
getvec(VT_ITEM, lvec, (s_char *)&land, EF_LAND);
|
||||
lvec[I_FOOD] +=
|
||||
vl_find(V_FOOD, lp->l_vtype, lp->l_vamt, (int)lp->l_nv);
|
||||
|
|
|
@ -264,8 +264,7 @@ prod(void)
|
|||
if (*amount == 0)
|
||||
totcomp++;
|
||||
else {
|
||||
used = min(used, (int)(getvar((int)*comp, (s_char *)§,
|
||||
EF_SECTOR) / *amount));
|
||||
used = min(used, sect.sct_item[(int)*comp] / *amount);
|
||||
totcomp += *amount;
|
||||
}
|
||||
++comp;
|
||||
|
@ -293,8 +292,7 @@ prod(void)
|
|||
if (real < 0.0)
|
||||
real = 0.0;
|
||||
/* production backlog? */
|
||||
if ((there =
|
||||
getvar((int)vtype, (s_char *)§, EF_SECTOR)) >= 9999) {
|
||||
if ((there = sect.sct_item[vtype]) >= 9999) {
|
||||
there = 9999;
|
||||
}
|
||||
act = min(act, (9999 - there));
|
||||
|
|
|
@ -120,11 +120,11 @@ rese(void)
|
|||
ix = whichitem(comm.com_type);
|
||||
sect.sct_x = comm.sell_x;
|
||||
sect.sct_y = comm.sell_y;
|
||||
m = getvar(ix->i_vtype, (char *)§, EF_SECTOR);
|
||||
m = sect.sct_item[ix->i_vtype];
|
||||
m = m + comm.com_amount;
|
||||
if (m > 9999)
|
||||
m = 9999;
|
||||
putvar(ix->i_vtype, m, (char *)§, EF_SECTOR);
|
||||
sect.sct_item[ix->i_vtype] = m;
|
||||
putsect(§);
|
||||
comm.com_owner = 0;
|
||||
putcomm(number_set, &comm);
|
||||
|
|
|
@ -73,7 +73,7 @@ rout(void)
|
|||
|
||||
if ((ip = whatitem(player->argp[1], "What item? ")) == 0)
|
||||
return RET_SYN;
|
||||
i_del = V_DEL(ip - ichr);
|
||||
i_del = ip->i_vtype;;
|
||||
if (player->argp[2] == (s_char *)0) {
|
||||
if ((str = getstring("(sects)? ", buf1)) == 0)
|
||||
return RET_SYN;
|
||||
|
@ -122,7 +122,7 @@ rout(void)
|
|||
if (!player->owner)
|
||||
continue;
|
||||
p = &map[ns.dy][ns.dx * 2];
|
||||
if ((dir = getvar(i_del, (s_char *)§, EF_SECTOR) & 0x7) &&
|
||||
if ((dir = sect.sct_del[i_del] & 0x7) &&
|
||||
nstr_exec(cond, ncond, (s_char *)§, EF_SECTOR))
|
||||
memcpy(p, routech[dir][0], 3);
|
||||
p[1] = dchr[sect.sct_type].d_mnem;
|
||||
|
|
|
@ -31,18 +31,6 @@
|
|||
* John Yockey, 2001
|
||||
*/
|
||||
|
||||
/*
|
||||
#include <ctype.h>
|
||||
#include "player.h"
|
||||
#include "sect.h"
|
||||
#include "news.h"
|
||||
#include "xy.h"
|
||||
#include "nat.h"
|
||||
#include "path.h"
|
||||
#include "map.h"
|
||||
#include "commands.h"
|
||||
*/
|
||||
|
||||
#include "misc.h"
|
||||
#include "var.h"
|
||||
#include "land.h"
|
||||
|
@ -79,12 +67,11 @@ sabo(void)
|
|||
}
|
||||
if (!getsect(land.lnd_x, land.lnd_y, §))
|
||||
continue;
|
||||
getvec(VT_ITEM, vec, (s_char *)&land, EF_LAND);
|
||||
if (vec[I_SHELL] == 0) {
|
||||
if (land.lnd_item[I_SHELL] == 0) {
|
||||
pr("%s has no shells.\n", prland(&land));
|
||||
continue;
|
||||
}
|
||||
putvar(V_SHELL, vec[I_SHELL] - 1, (s_char *)&land, EF_LAND);
|
||||
--land.lnd_item[I_SHELL];
|
||||
|
||||
odds = LND_SPY_DETECT_CHANCE(land.lnd_effic);
|
||||
if (chance(odds)) {
|
||||
|
|
|
@ -145,13 +145,13 @@ sell(void)
|
|||
if (land.lnd_own == player->cnum)
|
||||
tot_mil += total_mil(&land);
|
||||
}
|
||||
if (((tot_mil + (getvar(V_MILIT, (char *)§, EF_SECTOR))) * 10)
|
||||
< getvar(V_CIVIL, (char *)§, EF_SECTOR)) {
|
||||
if (((tot_mil + sect.sct_item[I_MILIT]) * 10)
|
||||
< sect.sct_item[I_CIVIL]) {
|
||||
pr("Military control required to sell goods.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
}
|
||||
if (((amt = getvar(ip->i_vtype, (char *)§, EF_SECTOR))) == 0) {
|
||||
if ((amt = sect.sct_item[ip->i_vtype]) == 0) {
|
||||
pr("You don't have any %s to sell there.\n", ip->i_name);
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ sell(void)
|
|||
amt -= com;
|
||||
pr("Sold %d %s at %s (%d left)\n", com, ip->i_name,
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum), amt);
|
||||
putvar(ip->i_vtype, amt, (char *)§, EF_SECTOR);
|
||||
sect.sct_item[ip->i_vtype] = amt;
|
||||
cc = ip->i_mnem;
|
||||
putsect(§);
|
||||
if (totalcom > 0) {
|
||||
|
|
|
@ -109,8 +109,8 @@ set(void)
|
|||
if (land.lnd_own == player->cnum)
|
||||
tot_mil += total_mil(&land);
|
||||
}
|
||||
if (tot_mil + (getvar(V_MILIT, (char *)§, EF_SECTOR)) * 10
|
||||
< getvar(V_CIVIL, (char *)§, EF_SECTOR)) {
|
||||
if (tot_mil + sect.sct_item[I_MILIT] * 10
|
||||
< sect.sct_item[I_CIVIL]) {
|
||||
pr("Military control required to sell goods.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
|
|
@ -214,20 +214,17 @@ setsector(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
int mines;
|
||||
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf))
|
||||
|| (*p == '\0'))
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
mines = getvar(V_MINE, (s_char *)§, EF_SECTOR);
|
||||
current = mines;
|
||||
current = sect.sct_mines;
|
||||
current += amt;
|
||||
if (current < 0)
|
||||
current = 0;
|
||||
if (sect.sct_own != 0)
|
||||
resnoise(§, 1, "Mines", (int)mines, current);
|
||||
putvar(V_MINE, current, (s_char *)§, EF_SECTOR);
|
||||
resnoise(§, 1, "Mines", sect.sct_mines, current);
|
||||
sect.sct_mines = current;
|
||||
putsect(§);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -66,7 +66,7 @@ shoo(void)
|
|||
ip = whatitem(player->argp[1], "Shoot what <civ or uw> ");
|
||||
if (ip == 0 || (ip->i_vtype != V_CIVIL && ip->i_vtype != V_UW))
|
||||
return RET_SYN;
|
||||
item = ip - ichr;
|
||||
item = ip->i_vtype;
|
||||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
sprintf(prompt, "number of %s to shoot (max 999)? ", ip->i_name);
|
||||
|
@ -122,13 +122,13 @@ shoo(void)
|
|||
nshot, ip->i_name, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
if (chance(nshot / 100.0))
|
||||
nreport(player->cnum, N_SHOOT_CIV, sect.sct_oldown, 1);
|
||||
if (vec[item] <= 0 && ip->i_vtype == V_CIVIL &&
|
||||
(sect.sct_own != sect.sct_oldown)) {
|
||||
if (vec[item] <= 0 && item == V_CIVIL
|
||||
&& (sect.sct_own != sect.sct_oldown)) {
|
||||
sect.sct_oldown = sect.sct_own;
|
||||
pr(" %s is now completely yours\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
}
|
||||
putvar(ip->i_vtype, vec[item], (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[item] = vec[item];
|
||||
putsect(§);
|
||||
}
|
||||
return RET_OK;
|
||||
|
|
|
@ -70,7 +70,6 @@ sona(void)
|
|||
int dist;
|
||||
int x, y;
|
||||
int cx, cy;
|
||||
int mines;
|
||||
int changed = 0;
|
||||
int row;
|
||||
/* Where these are used are non-re-entrant, so we keep 'em around */
|
||||
|
@ -147,10 +146,10 @@ sona(void)
|
|||
continue;
|
||||
}
|
||||
if (ship.shp_tech >= 310 && sect.sct_type == SCT_WATER) {
|
||||
mines = getvar(V_MINE, (s_char *)§, EF_SECTOR);
|
||||
if (mines) {
|
||||
if (sect.sct_mines) {
|
||||
pr("Sonar detects %d mines in %s!\n",
|
||||
mines, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
sect.sct_mines,
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
rad[ns.dy][ns.dx] = 'X';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,6 @@ stre(void)
|
|||
double dtotal, r_total, eff;
|
||||
struct combat def[1];
|
||||
int dummy;
|
||||
int mines;
|
||||
|
||||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
return RET_SYN;
|
||||
|
@ -96,12 +95,11 @@ stre(void)
|
|||
def->own = 0;
|
||||
eff = att_combat_eff(def);
|
||||
if (sect.sct_own == sect.sct_oldown) {
|
||||
mines = getvar(V_MINE, (s_char *)§, EF_SECTOR);
|
||||
if (mines > 0)
|
||||
pr("%7d", mines);
|
||||
if (sect.sct_mines > 0)
|
||||
pr("%7d", sect.sct_mines);
|
||||
else
|
||||
pr("%7s", "");
|
||||
eff *= (1.0 + min(mines, 20) * 0.02);
|
||||
eff *= (1.0 + min(sect.sct_mines, 20) * 0.02);
|
||||
} else {
|
||||
pr("%7s", "?");
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ tend(void)
|
|||
pr("Amount must be non-zero!\n");
|
||||
return RET_SYN;
|
||||
}
|
||||
ontender = getvar(ip->i_vtype, (s_char *)&tender, EF_SHIP);
|
||||
ontender = tender.shp_item[ip->i_vtype];
|
||||
if (ontender == 0 && amt > 0) {
|
||||
pr("No %s on %s\n", ip->i_name, prship(&tender));
|
||||
return RET_FAIL;
|
||||
|
@ -144,7 +144,7 @@ tend(void)
|
|||
if (tender.shp_x != target.shp_x ||
|
||||
tender.shp_y != target.shp_y)
|
||||
continue;
|
||||
ontarget = getvar(ip->i_vtype, (s_char *)&target, EF_SHIP);
|
||||
ontarget = target.shp_item[ip->i_vtype];
|
||||
if (ontarget == 0 && amt < 0) {
|
||||
pr("No %s on %s\n", ip->i_name, prship(&target));
|
||||
continue;
|
||||
|
@ -161,8 +161,7 @@ tend(void)
|
|||
transfer = min(maxtender - ontender, transfer);
|
||||
if (transfer == 0)
|
||||
continue;
|
||||
putvar(ip->i_vtype, ontarget - transfer,
|
||||
(s_char *)&target, EF_SHIP);
|
||||
target.shp_item[ip->i_vtype] = ontarget - transfer;
|
||||
ontender += transfer;
|
||||
total += transfer;
|
||||
} else {
|
||||
|
@ -171,8 +170,7 @@ tend(void)
|
|||
transfer = min(transfer, maxtarget - ontarget);
|
||||
if (transfer == 0)
|
||||
continue;
|
||||
putvar(ip->i_vtype, ontarget + transfer,
|
||||
(s_char *)&target, EF_SHIP);
|
||||
target.shp_item[ip->i_vtype] = ontarget + transfer;
|
||||
ontender -= transfer;
|
||||
total += transfer;
|
||||
}
|
||||
|
@ -186,7 +184,7 @@ tend(void)
|
|||
pr("%d total %s transferred %s %s\n",
|
||||
total, ip->i_name, (amt > 0) ? "off of" : "to",
|
||||
prship(&tender));
|
||||
putvar(ip->i_vtype, ontender, (s_char *)&tender, EF_SHIP);
|
||||
tender.shp_item[ip->i_vtype] = ontender;
|
||||
tender.shp_mission = 0;
|
||||
putship(tender.shp_uid, &tender);
|
||||
}
|
||||
|
@ -196,12 +194,10 @@ tend(void)
|
|||
static void
|
||||
expose_ship(struct shpstr *s1, struct shpstr *s2)
|
||||
{
|
||||
if (getvar(V_PSTAGE, (s_char *)s1, EF_SHIP) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)s2, EF_SHIP) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)s2, EF_SHIP);
|
||||
if (getvar(V_PSTAGE, (s_char *)s2, EF_SHIP) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)s1, EF_SHIP) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)s1, EF_SHIP);
|
||||
if (s1->shp_pstage == PLG_INFECT && s2->shp_pstage == PLG_HEALTHY)
|
||||
s2->shp_pstage = PLG_EXPOSED;
|
||||
if (s2->shp_pstage == PLG_INFECT && s1->shp_pstage == PLG_HEALTHY)
|
||||
s1->shp_pstage = PLG_EXPOSED;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -63,7 +63,7 @@ thre(void)
|
|||
return RET_SYN;
|
||||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
type = V_DIST(ip->i_vtype & (~VT_TYPE));
|
||||
type = ip->i_vtype;
|
||||
if (player->argp[3] && *player->argp[3] &&
|
||||
(*player->argp[3] < '0' || *player->argp[3] > '9')) {
|
||||
pr("Threshold must be a number\n");
|
||||
|
@ -72,7 +72,7 @@ thre(void)
|
|||
while (!player->aborted && nxtsct(&nstr, §)) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
val = getvar(type, (s_char *)§, EF_SECTOR);
|
||||
val = sect.sct_dist[type];
|
||||
if (val > 0)
|
||||
sprintf(prompt, "%s %s old threshold %d new? ",
|
||||
xyas(nstr.x, nstr.y, player->cnum),
|
||||
|
@ -98,9 +98,7 @@ thre(void)
|
|||
if (val > 0 && (player->argp[3] != 0 && *player->argp[3] != 0))
|
||||
pr("%s old threshold %d\n",
|
||||
xyas(nstr.x, nstr.y, player->cnum), val);
|
||||
if (putvar(type, thresh, (s_char *)§, EF_SECTOR) < 0)
|
||||
pr("No room for threshold in %s\n",
|
||||
xyas(nstr.x, nstr.y, player->cnum));
|
||||
sect.sct_dist[type] = thresh;
|
||||
putsect(§);
|
||||
}
|
||||
return RET_OK;
|
||||
|
|
|
@ -87,14 +87,14 @@ torp(void)
|
|||
continue;
|
||||
if ((mchr[(int)sub.shp_type].m_flags & M_TORP) == 0)
|
||||
continue;
|
||||
shells = getvar(V_SHELL, (s_char *)&sub, EF_SHIP);
|
||||
shells = sub.shp_item[I_SHELL];
|
||||
if (shells < 3)
|
||||
shells +=
|
||||
supply_commod(sub.shp_own, sub.shp_x, sub.shp_y, I_SHELL,
|
||||
3 - shells);
|
||||
if (getvar(V_GUN, (s_char *)&sub, EF_SHIP) == 0 || shells < 3)
|
||||
if (sub.shp_item[I_GUN] == 0 || shells < 3)
|
||||
continue;
|
||||
if (getvar(V_MILIT, (s_char *)&sub, EF_SHIP) < 1)
|
||||
if (sub.shp_item[I_MILIT] < 1)
|
||||
continue;
|
||||
if (sub.shp_effic < 60)
|
||||
continue;
|
||||
|
@ -115,16 +115,16 @@ torp(void)
|
|||
mchr[(int)sub.shp_type].m_name);
|
||||
continue;
|
||||
}
|
||||
shells = getvar(V_SHELL, (s_char *)&sub, EF_SHIP);
|
||||
shells = sub.shp_item[I_SHELL];
|
||||
if (shells < 3)
|
||||
shells +=
|
||||
supply_commod(sub.shp_own, sub.shp_x, sub.shp_y, I_SHELL,
|
||||
3 - shells);
|
||||
if (getvar(V_GUN, (s_char *)&sub, EF_SHIP) == 0 || shells < 3) {
|
||||
if (sub.shp_item[I_GUN] == 0 || shells < 3) {
|
||||
pr("Ship #%d has insufficient armament\n", sub.shp_uid);
|
||||
continue;
|
||||
}
|
||||
if (getvar(V_MILIT, (s_char *)&sub, EF_SHIP) < 1) {
|
||||
if (sub.shp_item[I_MILIT] < 1) {
|
||||
pr("Ship #%d has insufficient crew\n", sub.shp_uid);
|
||||
continue;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ torp(void)
|
|||
erange = (double)roundrange(erange);
|
||||
pr("Effective torpedo range is %.1f\n", erange);
|
||||
shells -= 3;
|
||||
putvar(V_SHELL, shells, (s_char *)&sub, EF_SHIP);
|
||||
sub.shp_item[I_SHELL] = shells;
|
||||
putship(sub.shp_uid, &sub);
|
||||
mcp = &mchr[(int)sub.shp_type];
|
||||
mobcost = sub.shp_effic * 0.01 * sub.shp_speed;
|
||||
|
@ -349,10 +349,10 @@ fire_dchrg(struct shpstr *sp, struct shpstr *targ, int ntargets)
|
|||
int gun;
|
||||
double guneff;
|
||||
|
||||
shells = getvar(V_SHELL, (s_char *)sp, EF_SHIP);
|
||||
gun = getvar(V_GUN, (s_char *)sp, EF_SHIP);
|
||||
shells = sp->shp_item[I_SHELL];
|
||||
gun = sp->shp_item[I_GUN];
|
||||
gun = min(gun, sp->shp_glim);
|
||||
gun = min(gun, getvar(V_MILIT, (s_char *)sp, EF_SHIP) / 2);
|
||||
gun = min(gun, sp->shp_item[I_MILIT] / 2);
|
||||
|
||||
shells +=
|
||||
supply_commod(sp->shp_own, sp->shp_x, sp->shp_y, I_SHELL,
|
||||
|
@ -364,7 +364,7 @@ fire_dchrg(struct shpstr *sp, struct shpstr *targ, int ntargets)
|
|||
|
||||
/* ok, all set.. now, we shoot */
|
||||
shells -= ldround(((double)gun) / 2.0, 1);
|
||||
putvar(V_SHELL, shells, (s_char *)sp, EF_SHIP);
|
||||
sp->shp_item[I_SHELL] = shells;
|
||||
putship(sp->shp_uid, sp);
|
||||
|
||||
guneff = seagun(sp->shp_effic, gun);
|
||||
|
@ -407,16 +407,16 @@ fire_torp(struct shpstr *sp, struct shpstr *targ, int range, int ntargets)
|
|||
double mobcost;
|
||||
struct mchrstr *mcp;
|
||||
|
||||
shells = getvar(V_SHELL, (s_char *)sp, EF_SHIP);
|
||||
shells = sp->shp_item[I_SHELL];
|
||||
|
||||
if (shells < 3)
|
||||
shells += supply_commod(sp->shp_own, sp->shp_x, sp->shp_y, I_SHELL,
|
||||
3 - shells);
|
||||
|
||||
if (getvar(V_GUN, (s_char *)sp, EF_SHIP) == 0 || shells < 3)
|
||||
if (sp->shp_item[I_GUN] == 0 || shells < 3)
|
||||
return 0;
|
||||
|
||||
if (getvar(V_MILIT, (s_char *)sp, EF_SHIP) < 1)
|
||||
if (sp->shp_item[I_MILIT] < 1)
|
||||
return 0;
|
||||
|
||||
if (sp->shp_effic < 60)
|
||||
|
@ -427,7 +427,7 @@ fire_torp(struct shpstr *sp, struct shpstr *targ, int range, int ntargets)
|
|||
|
||||
/* All set.. fire! */
|
||||
shells -= 3;
|
||||
putvar(V_SHELL, shells, (s_char *)sp, EF_SHIP);
|
||||
sp->shp_item[I_SHELL] = shells;
|
||||
putship(sp->shp_uid, sp);
|
||||
|
||||
mcp = &mchr[(int)sp->shp_type];
|
||||
|
|
|
@ -166,8 +166,7 @@ tran_nuke(void)
|
|||
if (land.lnd_own == player->cnum)
|
||||
tot_mil += total_mil(&land);
|
||||
}
|
||||
if ((getvar(V_MILIT, (s_char *)§, EF_SECTOR) + tot_mil) * 10
|
||||
< getvar(V_CIVIL, (s_char *)§, EF_SECTOR)) {
|
||||
if ((sect.sct_item[I_MILIT] + tot_mil) * 10 < sect.sct_item[I_CIVIL]) {
|
||||
pr("Military control required to move goods.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
@ -282,8 +281,7 @@ tran_plane(void)
|
|||
snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y);
|
||||
while (nxtitem(&ni, (s_char *)&land))
|
||||
tot_mil += total_mil(&land);
|
||||
if ((getvar(V_MILIT, (s_char *)§, EF_SECTOR) + tot_mil) * 10
|
||||
< getvar(V_CIVIL, (s_char *)§, EF_SECTOR)) {
|
||||
if ((sect.sct_item[I_MILIT] + tot_mil) * 10 < sect.sct_item[I_CIVIL]) {
|
||||
pr("Military control required to move goods.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
|
|
@ -47,15 +47,13 @@ wipe(void)
|
|||
{
|
||||
struct sctstr sect;
|
||||
struct nstr_sect nstr;
|
||||
int vec[I_MAX + 1];
|
||||
|
||||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
return RET_SYN;
|
||||
memset(vec, 0, sizeof(vec));
|
||||
while (nxtsct(&nstr, §)) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
putvec(VT_DIST, vec, (s_char *)§, EF_SECTOR);
|
||||
memset(sect.sct_dist, 0, sizeof(sect.sct_dist));
|
||||
pr("Distribution thresholds wiped from %s\n",
|
||||
xyas(nstr.x, nstr.y, player->cnum));
|
||||
putsect(§);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue