/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2004, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
if (sect.sct_type == SCT_MOUNT)
continue;
++nowned;
- civs = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
+ civs = sect.sct_item[I_CIVIL];
if (civs > biggest) {
biggest = civs;
bx = sect.sct_x;
int
lnd_getmil(struct lndstr *lp)
{
- int vec[I_MAX + 1];
-
- getvec(VT_ITEM, vec, (s_char *)lp, EF_LAND);
- return vec[I_MILIT];
+ return lp->lnd_item[I_MILIT];
}
void
lnd_submil(struct lndstr *lp, int num)
{
- int vec[I_MAX + 1];
-
- getvec(VT_ITEM, vec, (s_char *)lp, EF_LAND);
- vec[I_MILIT] -= num;
- if (vec[I_MILIT] < 0)
- vec[I_MILIT] = 0;
- putvec(VT_ITEM, vec, (s_char *)lp, EF_LAND);
+ int new = lp->lnd_item[I_MILIT] - num;
+ lp->lnd_item[I_MILIT] = new < 0 ? 0 : new;
}
int
llp->land.lnd_harden = 0;
}
putland(llp->land.lnd_uid, &llp->land);
- if (!(mines = getvar(V_MINE, (s_char *)§, EF_SECTOR)))
+ if (!(mines = sect.sct_mines))
continue;
- max = vl_find(V_SHELL, llp->lcp->l_vtype,
- llp->lcp->l_vamt, (int)llp->lcp->l_nv);
- lshells = getvar(V_SHELL, (s_char *)&llp->land, EF_LAND);
- sshells = getvar(V_SHELL, (s_char *)§, EF_SECTOR);
+ max = llp->lcp->l_item[I_SHELL];
+ lshells = llp->land.lnd_item[I_SHELL];
+ sshells = sect.sct_item[I_SHELL];
for (m = 0; mines > 0 && m < max * 2; m++) {
if (chance(0.5 * llp->lcp->l_att)) {
mpr(actor, "Sweep...\n");
mines--;
if (lshells < max)
++lshells;
- else
+ else if (sshells < ITEM_MAX)
++sshells;
}
}
- putvar(V_MINE, mines, (s_char *)§, EF_SECTOR);
- putvar(V_SHELL, lshells, (s_char *)&llp->land, EF_LAND);
- putvar(V_SHELL, sshells, (s_char *)§, EF_SECTOR);
+ sect.sct_mines = mines;
+ llp->land.lnd_item[I_SHELL] = lshells;
+ sect.sct_item[I_SHELL] = sshells;
putland(llp->land.lnd_uid, &llp->land);
putsect(§);
}
struct emp_qelem *next;
struct llist *llp;
struct sctstr sect;
- int mines;
int stopping = 0;
- int has_engineers = contains_engineer(land_list);
+ int with_eng = contains_engineer(land_list);
for (qp = land_list->q_back; qp != land_list; qp = next) {
next = qp->q_back;
continue;
if (sect.sct_type == SCT_BSPAN)
continue;
- if (!(mines = getvar(V_MINE, (s_char *)§, EF_SECTOR)))
+ if (!sect.sct_mines)
continue;
- if (chance(DMINE_LHITCHANCE(mines) / (1 + 2 * has_engineers))) {
+ if (chance(DMINE_LHITCHANCE(sect.sct_mines) / (1 + 2 * with_eng))) {
lnd_hit_mine(&llp->land, llp->lcp);
- mines--;
- putvar(V_MINE, mines, (s_char *)§, EF_SECTOR);
+ sect.sct_mines--;
putsect(§);
putland(llp->land.lnd_uid, (s_char *)&llp->land);
if (!llp->land.lnd_own) {
struct emp_qelem *next;
struct llist *llp;
struct lndstr *lnd;
- int vec[I_MAX + 1];
pr("lnd# land type x,y a eff sh gun xl mu tech retr fuel\n");
prxy("%4d,%-4d ", lnd->lnd_x, lnd->lnd_y, llp->land.lnd_own);
pr("%1c", lnd->lnd_army);
pr("%4d%%", lnd->lnd_effic);
- getvec(VT_ITEM, vec, (s_char *)lnd, EF_LAND);
- pr("%4d", vec[I_SHELL]);
- pr("%4d", vec[I_GUN]);
+ pr("%4d", lnd->lnd_item[I_SHELL]);
+ pr("%4d", lnd->lnd_item[I_GUN]);
count_land_planes(lnd);
pr("%3d", lnd->lnd_nxlight);
pr("%4d", lnd->lnd_mobil);
continue;
if (getrel(getnatp(fsect.sct_own), victim) >= NEUTRAL)
continue;
- gun = getvar(V_GUN, (s_char *)&fsect, EF_SECTOR);
+ gun = fsect.sct_item[I_GUN];
if (gun < 1)
continue;
range = tfactfire(fsect.sct_own, (double)min(gun, 7));
trange = mapdist(newx, newy, fsect.sct_x, fsect.sct_y);
if (trange > range2)
continue;
- if (getvar(V_MILIT, (s_char *)&fsect, EF_SECTOR) < 5)
+ if (fsect.sct_item[I_MILIT] < 5)
continue;
- shell = getvar(V_SHELL, (s_char *)&fsect, EF_SECTOR);
+ shell = fsect.sct_item[I_SHELL];
if (shell < 1)
shell += supply_commod(fsect.sct_own,
fsect.sct_x, fsect.sct_y, I_SHELL, 1);
if (shell < 1)
continue;
shell--;
- putvar(V_SHELL, shell, (s_char *)&fsect, EF_SECTOR);
+ fsect.sct_item[I_SHELL] = shell;
putsect(&fsect);
if (gun > 7)
gun = 7;
}
/* Note we check would_abandon first because we don't want
to always have to do these checks */
- if (would_abandon(&osect, V_CIVIL, 0, &(llp->land))) {
+ if (would_abandon(&osect, I_CIVIL, 0, &(llp->land))) {
stop = 0;
- if (!want_to_abandon(&osect, V_CIVIL, 0, &(llp->land))) {
+ if (!want_to_abandon(&osect, I_CIVIL, 0, &(llp->land))) {
stop = 1;
}
/* now check stuff */
if (land.lnd_effic < LAND_MINFIREEFF)
continue;
/* Do we have mil? */
- if (getvar(V_MILIT, (s_char *)&land, EF_LAND) <= 0)
+ if (land.lnd_item[I_MILIT] <= 0)
continue;
rel = getrel(getnatp(land.lnd_own), attacker);
rel2 = getrel(getnatp(land.lnd_own), victim);
if (dist > range2)
continue;
- shell = getvar(V_SHELL, (s_char *)&land, EF_LAND);
- gun = getvar(V_GUN, (s_char *)&land, EF_LAND);
+ shell = land.lnd_item[I_SHELL];
+ gun = land.lnd_item[I_GUN];
if (shell == 0 || gun == 0)
continue;
return hard_amt;
}
+
+/*
+ * Set LP's tech to TLEV along with everything else that depends on it.
+ */
+void
+lnd_set_tech(struct lndstr *lp, int tlev)
+{
+ struct lchrstr *lcp = lchr + lp->lnd_type;
+ int tech_diff = tlev - lcp->l_tech;
+
+ if (CANT_HAPPEN(tech_diff < 0)) {
+ tlev -= tech_diff;
+ tech_diff = 0;
+ }
+
+ lp->lnd_tech = tlev;
+ lp->lnd_att = (float)LND_ATTDEF(lcp->l_att, tech_diff);
+ lp->lnd_def = (float)LND_ATTDEF(lcp->l_def, tech_diff);
+ lp->lnd_vul = (int)LND_VUL(lcp->l_vul, tech_diff);
+ lp->lnd_spd = (int)LND_SPD(lcp->l_spd, tech_diff);
+ lp->lnd_vis = (int)LND_VIS(lcp->l_vis, tech_diff);
+ lp->lnd_spy = (int)LND_SPY(lcp->l_spy, tech_diff);
+ lp->lnd_rad = (int)LND_RAD(lcp->l_rad, tech_diff);
+ lp->lnd_frg = (int)LND_FRG(lcp->l_frg, tech_diff);
+ lp->lnd_acc = (int)LND_ACC(lcp->l_acc, tech_diff);
+ lp->lnd_dam = (int)LND_DAM(lcp->l_dam, tech_diff);
+ lp->lnd_ammo = (int)LND_AMM(lcp->l_ammo, lcp->l_dam, tech_diff);
+ lp->lnd_aaf = (int)LND_AAF(lcp->l_aaf, tech_diff);
+ lp->lnd_fuelc = (int)LND_FC(lcp->l_fuelc, tech_diff);
+ lp->lnd_fuelu = (int)LND_FU(lcp->l_fuelu, tech_diff);
+ lp->lnd_maxlight = (int)LND_XPL(lcp->l_nxlight, tech_diff);
+ lp->lnd_maxland = (int)LND_MXL(lcp->l_mxland, tech_diff);
+}