(ichr_ca): Rename selector vtype to uid.
struct ichrstr {
char i_mnem; /* usually the initial letter */
- i_type i_vtype; /* var type */
+ i_type i_uid; /* index in ichr[] */
int i_value; /* mortgage value */
int i_sell; /* can this be sold? */
int i_lbs; /* how hard to move */
return;
getsect(target->sct_x, target->sct_y, §);
target = §
- before = amt = target->sct_item[ip->i_vtype];
- target->sct_item[ip->i_vtype] = amt = commdamage(amt, dam, ip->i_vtype);
+ before = amt = target->sct_item[ip->i_uid];
+ target->sct_item[ip->i_uid] = amt = commdamage(amt, dam, ip->i_uid);
if (before > 0.0)
b = 100.0 * (1.0 - ((float)amt / (float)before));
else
ip = whatitem(player->argp[1], "Commodity you want to buy: ");
if (!ip)
return RET_SYN;
- display_mark(ip->i_vtype, 0);
+ display_mark(ip->i_uid, 0);
pr("\n");
p = getstarg(player->argp[2], "Which lot are you bidding on: ", buf);
if (p == 0)
pr("Invalid lot number.\n");
return RET_OK;
}
- if (comm.com_type != ip->i_vtype) {
+ if (comm.com_type != ip->i_uid) {
pr("That lot is not of the type you specified.\n");
return RET_OK;
}
pr("That sector is under construction.\n");
return RET_FAIL;
}
- n = sect.sct_item[ip->i_vtype];
+ n = sect.sct_item[ip->i_uid];
qty = comm.com_amount;
if (qty + n > ITEM_MAX) {
pr("That sector cannot hold %d more %s. It currently holds %d.\n",
}
pay = dchr[sect.sct_type].d_value * ((float)sect.sct_effic + 100.0);
for (i = 0; ichr[i].i_name; i++) {
- if (ichr[i].i_value == 0 || ichr[i].i_vtype == I_NONE)
+ if (ichr[i].i_value == 0 || ichr[i].i_uid == I_NONE)
continue;
- val = sect.sct_item[ichr[i].i_vtype];
+ val = sect.sct_item[ichr[i].i_uid];
pay += val * ichr[i].i_value;
}
pr("That sector (and its contents) is valued at $%.2f\n", pay);
if ((ich = whatitem(player->argp[1], "deliver what? ")) == 0)
return RET_SYN;
/*
- if (ich->i_vtype == I_CIVIL || ich->i_vtype == I_MILIT) {
+ if (ich->i_uid == I_CIVIL || ich->i_uid == I_MILIT) {
pr("You cannot deliver people!\n");
return RET_FAIL;
}
if (!player->owner)
continue;
- del = sect.sct_del[ich->i_vtype];
+ del = sect.sct_del[ich->i_uid];
thresh = del & ~0x7;
dir = del & 0x7;
thresh = MIN(thresh, ITEM_MAX) & ~7;
del = thresh | dir;
- sect.sct_del[ich->i_vtype] = del;
+ sect.sct_del[ich->i_uid] = del;
putsect(§);
}
if (target.sct_own == player->cnum
|| getrel(getnatp(target.sct_own), player->cnum) == ALLIED) {
- if (ip->i_vtype == I_CIVIL && target.sct_own != target.sct_oldown) {
+ if (ip->i_uid == I_CIVIL && target.sct_own != target.sct_oldown) {
pr("Can't drop civilians into occupied sectors.\n");
return RET_FAIL;
}
} else {
/* into the unknown... */
- if (ip->i_vtype != I_SHELL) {
+ if (ip->i_uid != I_SHELL) {
pr("You don't own %s!\n", xyas(tx, ty, player->cnum));
return RET_FAIL;
}
if (!(ip = whatitem(player->argp[1], "explore with what? (civ/mil) ")))
return RET_SYN;
- vtype = ip->i_vtype;
+ vtype = ip->i_uid;
if ((vtype != I_CIVIL) && (vtype != I_MILIT)) {
pr("You can only explore with civs and mil.\n");
return RET_FAIL;
dst_type = EF_SHIP;
}
- if (ip && ip->i_vtype == I_CIVIL && target.sct_own != target.sct_oldown) {
+ if (ip && ip->i_uid == I_CIVIL && target.sct_own != target.sct_oldown) {
pr("Can't fly civilians into occupied sectors.\n");
return RET_FAIL;
}
return RET_SYN;
if ((amt = atoi(p)) == 0)
return RET_SYN;
- n = sect.sct_item[ip->i_vtype];
+ n = sect.sct_item[ip->i_uid];
if (amt < 0 && -amt > n) {
m = 0;
} else if (amt > 0 && amt + n > ITEM_MAX) {
m = ITEM_MAX;
} else
m = n + amt;
- sect.sct_item[ip->i_vtype] = m;
+ sect.sct_item[ip->i_uid] = m;
putsect(§);
if (sect.sct_own != 0 && m != n) {
if (m > n) {
load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
struct ichrstr *ich, int load_unload, int *nshipsp)
{
- i_type item = ich->i_vtype;
+ i_type item = ich->i_uid;
struct mchrstr *mcp = &mchr[(int)sp->shp_type];
int ship_amt, ship_max, sect_amt, move_amt;
int amount;
load_comm_land(struct sctstr *sectp, struct lndstr *lp,
struct ichrstr *ich, int load_unload, int *nunitsp)
{
- i_type item = ich->i_vtype;
+ i_type item = ich->i_uid;
struct lchrstr *lcp = &lchr[(int)lp->lnd_type];
int land_amt, land_max, sect_amt, move_amt;
int amount;
return RET_FAIL;
if ((amt = atoi(p)) == 0)
break;
- ontender = tender.shp_item[ip->i_vtype];
+ ontender = tender.shp_item[ip->i_uid];
if (ontender == 0 && amt > 0) {
pr("No %s on %s\n", ip->i_name, prship(&tender));
return RET_FAIL;
}
vbase = &mchr[(int)tender.shp_type];
- maxtender = vbase->m_item[ip->i_vtype];
+ maxtender = vbase->m_item[ip->i_uid];
if (maxtender == 0) {
pr("A %s cannot hold any %s\n",
mchr[(int)tender.shp_type].m_name, ip->i_name);
if (target.lnd_ship != tender.shp_uid)
continue;
- ontarget = target.lnd_item[ip->i_vtype];
+ ontarget = target.lnd_item[ip->i_uid];
if (ontarget == 0 && amt < 0) {
pr("No %s on %s\n",
ip->i_name, prland(&target));
continue;
}
lbase = &lchr[(int)target.lnd_type];
- maxtarget = lbase->l_item[ip->i_vtype];
+ maxtarget = lbase->l_item[ip->i_uid];
if (amt < 0) {
if (!player->owner)
amt = 0;
transfer = MIN(maxtender - ontender, transfer);
if (transfer == 0)
continue;
- target.lnd_item[ip->i_vtype] = ontarget - transfer;
+ target.lnd_item[ip->i_uid] = ontarget - transfer;
ontender += transfer;
total += transfer;
} else {
transfer = MIN(transfer, maxtarget - ontarget);
if (transfer == 0)
continue;
- target.lnd_item[ip->i_vtype] = ontarget + transfer;
+ target.lnd_item[ip->i_uid] = ontarget + transfer;
ontender -= transfer;
total += transfer;
}
pr("%d total %s transferred %s %s\n",
total, ip->i_name, (amt > 0) ? "off of" : "to",
prship(&tender));
- tender.shp_item[ip->i_vtype] = ontender;
+ tender.shp_item[ip->i_uid] = ontender;
tender.shp_mission = 0;
putship(tender.shp_uid, &tender);
}
ip = item_by_name(p);
if (!ip)
return RET_SYN;
- return display_mark(ip->i_vtype, 0);
+ return display_mark(ip->i_uid, 0);
}
}
return display_mark(I_NONE, 1);
istest = *player->argp[0] == 't';
if ((ip = whatitem(player->argp[1], "move what? ")) == 0)
return RET_SYN;
- vtype = ip->i_vtype;
+ vtype = ip->i_uid;
if (!(p = getstarg(player->argp[2], "from sector : ", buf)))
return RET_SYN;
if (!sarg_xy(p, &x, &y))
cmd_move_map, 0, &dam);
if (dam) {
- left = commdamage(amount, dam, ip->i_vtype);
+ left = commdamage(amount, dam, ip->i_uid);
if (left < amount) {
if (left) {
pr("%d of the %s you were moving were destroyed!\n"
level = 0; /* prevent negatives. */
pr("You must use positive number! Level set to 0.\n");
}
- ship.shp_tstart[sub] = i1->i_vtype;
+ ship.shp_tstart[sub] = i1->i_uid;
ship.shp_lstart[sub] = level;
pr("Order Set \n");
break;
level = 0;
pr("You must use positive number! Level set to 0.\n");
}
- ship.shp_tend[sub] = i1->i_vtype;
+ ship.shp_tend[sub] = i1->i_uid;
ship.shp_lend[sub] = level;
pr("Order Set \n");
break;
if ((ip = whatitem(player->argp[1], "What item? ")) == 0)
return RET_SYN;
- i_del = ip->i_vtype;;
+ i_del = ip->i_uid;;
if (player->argp[2] == NULL) {
if ((str = getstring("(sects)? ", buf1)) == 0)
return RET_SYN;
pr("Military control required to sell goods.\n");
return RET_FAIL;
}
- if ((amt = sect.sct_item[ip->i_vtype]) == 0) {
+ if ((amt = sect.sct_item[ip->i_uid]) == 0) {
pr("You don't have any %s to sell there.\n", ip->i_name);
return RET_FAIL;
}
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);
- sect.sct_item[ip->i_vtype] = amt;
+ sect.sct_item[ip->i_uid] = amt;
putsect(§);
if (totalcom > 0) {
for (ii = 0; getcomm(ii, &comm); ii++) {
if (getcomm(ii, &comm) == 0)
ef_extend(EF_COMM, 1);
(void)time(&now);
- comm.com_type = ip->i_vtype;
+ comm.com_type = ip->i_uid;
comm.com_owner = player->cnum;
comm.com_price = price;
comm.com_maxbidder = player->cnum;
char buf[1024];
ip = whatitem(player->argp[1], "Shoot what <civ or uw> ");
- if (ip == 0 || (ip->i_vtype != I_CIVIL && ip->i_vtype != I_UW))
+ if (ip == 0 || (ip->i_uid != I_CIVIL && ip->i_uid != I_UW))
return RET_SYN;
- item = ip->i_vtype;
+ item = ip->i_uid;
if (!snxtsct(&nstr, player->argp[2]))
return RET_SYN;
sprintf(prompt, "number of %s to shoot? ", ip->i_name);
pr("Amount must be non-zero!\n");
return RET_SYN;
}
- ontender = tender.shp_item[ip->i_vtype];
+ ontender = tender.shp_item[ip->i_uid];
if (ontender == 0 && amt > 0) {
pr("No %s on %s\n", ip->i_name, prship(&tender));
return RET_FAIL;
}
vbase = &mchr[(int)tender.shp_type];
- maxtender = vbase->m_item[ip->i_vtype];
+ maxtender = vbase->m_item[ip->i_uid];
if (maxtender == 0) {
pr("A %s cannot hold any %s\n",
mchr[(int)tender.shp_type].m_name, ip->i_name);
if (tender.shp_x != target.shp_x ||
tender.shp_y != target.shp_y)
continue;
- ontarget = target.shp_item[ip->i_vtype];
+ ontarget = target.shp_item[ip->i_uid];
if (ontarget == 0 && amt < 0) {
pr("No %s on %s\n", ip->i_name, prship(&target));
continue;
}
vbase = &mchr[(int)target.shp_type];
- maxtarget = vbase->m_item[ip->i_vtype];
+ maxtarget = vbase->m_item[ip->i_uid];
if (amt < 0) {
if (!player->owner)
amt = 0;
transfer = MIN(maxtender - ontender, transfer);
if (transfer == 0)
continue;
- target.shp_item[ip->i_vtype] = ontarget - transfer;
+ target.shp_item[ip->i_uid] = ontarget - transfer;
ontender += transfer;
total += transfer;
} else {
transfer = MIN(transfer, maxtarget - ontarget);
if (transfer == 0)
continue;
- target.shp_item[ip->i_vtype] = ontarget + transfer;
+ target.shp_item[ip->i_uid] = ontarget + transfer;
ontender -= transfer;
total += transfer;
}
wu(0, target.shp_own, "%s tended %d %s to %s\n",
cname(player->cnum), total, ip->i_name, prship(&target));
}
- tender.shp_item[ip->i_vtype] = ontender;
+ tender.shp_item[ip->i_uid] = ontender;
tender.shp_mission = 0;
putship(tender.shp_uid, &tender);
}
return RET_SYN;
if (!snxtsct(&nstr, player->argp[2]))
return RET_SYN;
- type = ip->i_vtype;
+ type = ip->i_uid;
if (player->argp[3] && *player->argp[3] &&
(*player->argp[3] < '0' || *player->argp[3] > '9')) {
pr("Threshold must be a number\n");
NSC_IELT("rad", "r", sfx, base, I_RAD)
struct castr ichr_ca[] = {
- {NSC_SITYPE(i_type), 0, 0, offsetof(struct ichrstr, i_vtype), "vtype",
+ {NSC_SITYPE(i_type), 0, 0, offsetof(struct ichrstr, i_uid), "uid",
EF_ITEM},
{NSC_STRING, 0, 0, offsetof(struct ichrstr, i_name), "name", EF_BAD},
{NSC_STRINGY, NSC_CONST, 1, offsetof(struct ichrstr, i_mnem), "mnem",
case 't':
if ((pcp->pl_flags & P_C) == 0 || ip == 0)
break;
- itype = ip->i_vtype;
+ itype = ip->i_uid;
needed = (pp->pln_load * 2) / ip->i_lbs;
break;
case 'd':
if ((pcp->pl_flags & P_C) == 0 || ip == 0)
break;
- itype = ip->i_vtype;
+ itype = ip->i_uid;
needed = (pp->pln_load * 2) / ip->i_lbs;
break;
case 'a':
xyas(tx, ty, player->cnum));
return;
}
- if (ip->i_vtype == I_CIVIL && sectp->sct_own != sectp->sct_oldown) {
+ if (ip->i_uid == I_CIVIL && sectp->sct_own != sectp->sct_oldown) {
pr("%s is occupied. Your civilians suffer from identity crisis and die.\n",
xyas(tx, ty, player->cnum));
return;
}
- there = sectp->sct_item[ip->i_vtype];
+ there = sectp->sct_item[ip->i_uid];
max = ITEM_MAX;
} else {
sp = ptr;
- there = sp->shp_item[ip->i_vtype];
+ there = sp->shp_item[ip->i_uid];
mp = &mchr[(int)sp->shp_type];
- max = mp->m_item[ip->i_vtype];
+ max = mp->m_item[ip->i_uid];
}
there += amt;
if (there > max) {
pr("%d %s landed safely", amt, ip->i_name);
if (type == EF_SECTOR) {
sectp = ptr;
- sectp->sct_item[ip->i_vtype] = there;
+ sectp->sct_item[ip->i_uid] = there;
if (sectp->sct_own != player->cnum)
wu(0, sectp->sct_own, "%s planes drop %d %s in %s\n",
cname(player->cnum), amt, ip->i_name,
putsect((struct sctstr *)ptr);
} else {
struct shpstr *sp = (struct shpstr *)ptr;
- sp->shp_item[ip->i_vtype] = there;
+ sp->shp_item[ip->i_uid] = there;
if (sp->shp_own != player->cnum)
wu(0, sp->shp_own, "%s planes land %d %s on carrier %d\n",
cname(player->cnum), amt, ip->i_name, sp->shp_uid);
own = sect.sct_oldown;
}
if (ip) {
- if (ip->i_vtype == I_CIVIL) {
+ if (ip->i_uid == I_CIVIL) {
if (pp->pln_own != own) {
pr("You don't control those civilians!\n");
return -1;
case 'd':
if ((pcp->pl_flags & P_C) == 0 || ip == 0)
break;
- itype = ip->i_vtype;
+ itype = ip->i_uid;
needed = (pp->pln_load * 2) / ip->i_lbs;
break;
case 'm':
secttot += (long)(dchr[sp->sct_type].d_value *
((float)sp->sct_effic + 100.0));
for (k = 0; ichr[k].i_name; k++) {
- if (ichr[k].i_value == 0 || ichr[k].i_vtype == I_NONE)
+ if (ichr[k].i_value == 0 || ichr[k].i_uid == I_NONE)
continue;
- val = sp->sct_item[ichr[k].i_vtype];
+ val = sp->sct_item[ichr[k].i_uid];
secttot += val * ichr[k].i_value;
}
}
return 0;
}
dp = &dchr[from->sct_type];
- vtype = ip->i_vtype;
+ vtype = ip->i_uid;
mobility = from->sct_mobil / 2;
if (vtype == I_CIVIL) {
if (from->sct_own != from->sct_oldown) {