Simplify. Split into member sct_che (number) and sct_che_target.
Users changed.
(get_che_cnum, set_che_cnum, get_che_value, get_che_value): Che
encoding/decoding functions; remove.
(CHE_MAX): Move from var.h to sect.h.
(prsect, doland): Print / edit the new field.
u_short sct_mines; /* number of mines */
u_short sct_pstage; /* plague stage */
u_short sct_ptime; /* how many etus remain in this stage */
- u_short sct_che; /* che combo */
+ u_char sct_che; /* number of guerrillas */
+ natid sct_che_target; /* nation targeted by che */
u_short sct_fallout;
time_t sct_access; /* Last time mob was updated (MOB_ACCESS) */
u_char sct_road; /* Road value of a sector */
/* Sector flags */
#define MOVE_IN_PROGRESS bit(0) /* move in progress */
+/* maximal number of che, must fit into struct sctstr member sct_che */
+#define CHE_MAX 255
+
/* Each cost is per point of efficency */
struct sctintrins {
char *in_name;
#define I_RAD 14
#define I_MAX 14
-/* should this be here?? */
-#define CHE_MAX 255
-#define get_che_cnum(x) ((x) >> 8)
-#define set_che_cnum(x, cn) ((x) = ((x) & 0xff) | ((cn) << 8))
-#define get_che_value(x) ((x) & 0xff)
-#define set_che_value(x, n) ((x) = ((x) & 0xff00) | (n))
-
#define V_CIVIL V_ITEM(I_CIVIL)
#define V_MILIT V_ITEM(I_MILIT)
#define V_SHELL V_ITEM(I_SHELL)
sect.sct_pstage = PLG_HEALTHY;
sect.sct_ptime = 0;
sect.sct_che = 0;
+ sect.sct_che_target = 0;
sect.sct_fallout = 0;
putsect(§);
pr("wiped\n");
pr(" ---- --------------------------\n");
}
mil = sect.sct_item[I_MILIT];
- che = get_che_value(sect.sct_che);
- target = get_che_cnum(sect.sct_che);
+ che = sect.sct_che;
+ target = sect.sct_che_target;
avail_mil = sect.sct_mobil / 2;
if (mil <= avail_mil)
avail_mil = mil;
sect.sct_mobil = sect.sct_mobil - chekilled - milkilled;
sect.sct_item[I_MILIT] = mil - milkilled;
if (ache == 0)
- sect.sct_che = 0;
- set_che_value(sect.sct_che, ache);
+ sect.sct_che_target = 0;
+ sect.sct_che = ache;
putsect(§);
pr(" Body count: Military %d - Guerillas %d.\n",
milkilled, chekilled);
/* Ok, now leave anywhere from 16% to 25% of the che */
n_cheleft = (ache / (n_cheleft + 3));
ache -= n_cheleft;
- set_che_value(sect.sct_che, n_cheleft);
- } else
+ sect.sct_che = n_cheleft;
+ } else {
sect.sct_che = 0;
+ sect.sct_che_target = 0;
+ }
sect.sct_item[I_MILIT] = ache;
if (sect.sct_own == sect.sct_oldown)
sect.sct_oldown = 0;
sp->sct_avail = 0;
if (sp->sct_oldown == to) {
- oldche = get_che_value(sp->sct_che);
- set_che_value(oldche, 0);
- set_che_cnum(oldche, 0);
- sp->sct_che = oldche;
+ sp->sct_che = 0; /* FIXME where do these guys go? */
+ sp->sct_che_target = 0;
sp->sct_loyal = 0;
}
xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum));
pr("Designation <s>: %c\t New designation <S>: %c\n",
dchr[sect->sct_type].d_mnem, dchr[sect->sct_newtype].d_mnem);
- pr("own oo eff mob min gld frt oil urn wrk lty che plg ptime fall avail\n");
- pr(" o O e m i g f c u w l x p t F a\n");
- pr("%3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %4d %3d %5d %4d %5d\n",
+ pr("own oo eff mob min gld frt oil urn wrk lty che ctg plg ptime fall avail\n");
+ pr(" o O e m i g f c u w l x X p t F a\n");
+ pr("%3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %5d %4d %5d\n",
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,
- sect->sct_che, sect->sct_pstage, sect->sct_ptime,
+ sect->sct_che, sect->sct_che_target,
+ sect->sct_pstage, sect->sct_ptime,
sect->sct_fallout, sect->sct_avail);
pr("Mines <M>: %d\t", sect->sct_mines);
break;
case 'x':
old = sect->sct_che;
- new = errcheck(arg, 0, 65536);
- pr("Guerillas in %s changed from %d to %d%\n",
+ new = errcheck(arg, 0, CHE_MAX);
+ pr("Guerillas in %s changed from %d to %d\n",
xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
sect->sct_che = new;
break;
+ case 'X':
+ old = sect->sct_che_target;
+ new = errcheck(arg, 0, MAXNOC - 1);
+ pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
+ xyas(sect->sct_x, sect->sct_y, player->cnum),
+ cname(old), old, cname(new), new);
+ sect->sct_che_target = new;
+ break;
case 'p':
old = sect->sct_pstage;
new = errcheck(arg, 0, PLG_EXPOSED);
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(sect.sct_che),
- get_che_value(sect.sct_che),
+ sect.sct_che_target, sect.sct_che,
sect.sct_pstage, sect.sct_ptime, sect.sct_mines);
pr("\n");
}
sp->sct_pstage = PLG_HEALTHY;
sp->sct_ptime = 0;
sp->sct_che = 0;
+ sp->sct_che_target = 0;
}
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(sctstr, sct_pstage), "pstage", 0},
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(sctstr, sct_ptime), "ptime", 0},
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(sctstr, sct_che), "che", 0},
+ {NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(sctstr, sct_che_target), "che_target", 0},
{NSC_USHORT | NSC_OFF | fldoff(sctstr, sct_fallout), "fallout", 0},
{NSC_UCHAR | NSC_OFF | fldoff(sctstr, sct_road), "road", 0},
{NSC_UCHAR | NSC_OFF | fldoff(sctstr, sct_rail), "rail", 0},
struct plnstr *pp;
struct lndstr *lp;
int civ;
- int che;
int che_count;
int oldche;
int n;
sp->sct_avail = 0;
civ = sp->sct_item[I_CIVIL];
- oldche = get_che_value(sp->sct_che);
+ oldche = sp->sct_che;
/*
* create guerrillas from civilians
* how spunky are these guys?
*/
n = (50 - sp->sct_loyal) + ((random() % 100) - 25);
che_count = 0;
- che = 0;
if (n > 0 && sp->sct_own == sp->sct_oldown) {
che_count = (civ * n / 3000) + 5;
if (che_count * 2 > civ)
che_count = oldche;
} else
che_count = oldche;
- set_che_value(che, che_count);
+ sp->sct_che = che_count;
if (newown != sp->sct_oldown)
- set_che_cnum(che, newown);
- sp->sct_che = che;
+ sp->sct_che_target = newown;
sp->sct_item[I_CIVIL] = civ;
if (sp->sct_oldown == newown || civ == 0) {
/*
int che_uw;
int civ;
int uw;
- u_short che_combo;
int che;
int n;
- int target;
- che_combo = sp->sct_che;
- che = get_che_value(che_combo);
- target = get_che_cnum(che_combo);
- if (che_combo != 0 && (target != sp->sct_own || che >= CHE_MAX))
+ che = sp->sct_che;
+ if (che != 0 && (sp->sct_che_target != sp->sct_own || che >= CHE_MAX))
return;
civ = sp->sct_item[I_CIVIL];
uw = sp->sct_item[I_UW];
if (che_civ + che_uw > 0) {
civ -= che_civ;
uw -= che_uw;
- set_che_cnum(che_combo, sp->sct_own);
- set_che_value(che_combo, che);
- sp->sct_che = che_combo;
+ sp->sct_che_target = sp->sct_own;
+ sp->sct_che = che;
if (che_civ > 0)
sp->sct_item[I_CIVIL] = civ;
if (che_uw > 0)
int convert;
natid actor;
natid victim;
- u_short che_combo;
int vec[I_MAX + 1];
int tmp;
int min_mil;
recruit = 0;
convert = 0;
move = 0;
- if ((n = sp->sct_che) <= 0)
+ if (!sp->sct_che)
return;
- che_combo = n;
if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0)
return;
civ = vec[I_CIVIL];
uw = vec[I_UW];
victim = sp->sct_own;
actor = sp->sct_oldown;
- che = get_che_value(che_combo);
+ che = sp->sct_che;
mil = vec[I_MILIT];
snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
/* Security forces killed all the che */
if (che <= 0) {
sp->sct_che = 0;
+ sp->sct_che_target = 0;
return;
}
- target = get_che_cnum(che_combo);
+ target = sp->sct_che_target;
if (target == 0) {
/* the deity can't be a target! */
return;
logerror("%d Che targeted at country %d retiring", che, target);
civ += che;
sp->sct_che = 0;
+ sp->sct_che_target = 0;
sp->sct_item[I_CIVIL] = civ;
return;
}
continue;
if (nsp->sct_own != target)
continue;
- if ((val = nsp->sct_che) > 0) {
- che_combo = val;
- if (get_che_cnum(che_combo) != target)
+ if (nsp->sct_che > 0) {
+ if (nsp->sct_che_target != target)
continue;
- if (get_che_value(che_combo) + che > CHE_MAX)
+ if (nsp->sct_che + che > CHE_MAX)
continue;
}
val = nsp->sct_item[I_MILIT];
}
/* if we found a nice sector, go there */
if (nicest_sp != 0) {
- che_combo = nicest_sp->sct_che;
- che += get_che_value(che_combo);
- set_che_value(che_combo, che);
- set_che_cnum(che_combo, target);
- nicest_sp->sct_che = che_combo;
+ nicest_sp->sct_che += che;
+ nicest_sp->sct_che_target = target;
che = 0;
}
}
if (che > 0) {
- set_che_value(che_combo, che);
- set_che_cnum(che_combo, target);
- sp->sct_che = che_combo;
- } else
+ sp->sct_che = che;
+ sp->sct_che_target = target;
+ } else {
sp->sct_che = 0;
+ sp->sct_che_target = 0;
+ }
if (mc > 0 || cc > 0) {
/* don't tell who won just to be mean */
wu(0, target,