int
trade_check_ok(int lot, struct trdstr *tp, union trdgenstr *tgp)
{
- union trdgenstr check;
- struct trdstr trade;
+ union trdgenstr check;
+ struct trdstr trade;
int result = 0;
-
+
trade_getitem(tp, &check);
if (tp->trd_type == EF_LAND)
- result = memcmp(&(check.lnd), &(tgp->lnd), sizeof(struct lndstr));
+ result = memcmp(&(check.lnd), &(tgp->lnd), sizeof(struct lndstr));
else if (tp->trd_type == EF_PLANE)
- result = memcmp(&(check.pln), &(tgp->pln), sizeof(struct plnstr));
+ result = memcmp(&(check.pln), &(tgp->pln), sizeof(struct plnstr));
else if (tp->trd_type == EF_SHIP)
- result = memcmp(&(check.shp), &(tgp->shp), sizeof(struct shpstr));
+ result = memcmp(&(check.shp), &(tgp->shp), sizeof(struct shpstr));
else
- result = memcmp(&(check.nuk), &(tgp->nuk), sizeof(struct nukstr));
+ result = memcmp(&(check.nuk), &(tgp->nuk), sizeof(struct nukstr));
if (result) {
pr("That item has changed!\n");
return 0;
s_char *
trade_nameof(struct trdstr *tp, union trdgenstr *tgp)
{
- switch (tp->trd_type) {
- case EF_NUKE:
- return "nuclear stockpile";
- case EF_PLANE:
- return plchr[(int)tgp->pln.pln_type].pl_name;
- case EF_SHIP:
- return mchr[(int)tgp->shp.shp_type].m_name;
- case EF_LAND:
- return lchr[(int)tgp->lnd.lnd_type].l_name;
- }
- return "Bad trade type, get help";
+ switch (tp->trd_type) {
+ case EF_NUKE:
+ return "nuclear stockpile";
+ case EF_PLANE:
+ return plchr[(int)tgp->pln.pln_type].pl_name;
+ case EF_SHIP:
+ return mchr[(int)tgp->shp.shp_type].m_name;
+ case EF_LAND:
+ return lchr[(int)tgp->lnd.lnd_type].l_name;
+ }
+ return "Bad trade type, get help";
}
/*
int
trade_desc(struct trdstr *tp, union trdgenstr *tgp)
{
- int i;
- float price;
- struct sctstr sect;
- struct nukstr *np;
- struct shpstr *sp;
- struct plnstr *pp;
- struct lndstr *lp;
- struct natstr *natp;
- int needcomma;
- struct nstr_item ni;
- struct plnstr plane;
- struct lndstr land;
+ int i;
+ float price;
+ struct sctstr sect;
+ struct nukstr *np;
+ struct shpstr *sp;
+ struct plnstr *pp;
+ struct lndstr *lp;
+ struct natstr *natp;
+ int needcomma;
+ struct nstr_item ni;
+ struct plnstr plane;
+ struct lndstr land;
- price = multread(tp->trd_owner, player->cnum) * tp->trd_price;
- switch (tp->trd_type) {
- case EF_NUKE:
- np = &tgp->nuk;
- if (!getsect(np->nuk_x, np->nuk_y, §))
- return 0;
- tp->trd_owner = sect.sct_own;
- natp = getnatp(tp->trd_owner);
- pr("(%3d) ", sect.sct_own);
- needcomma = 0;
- for (i = 0; i < N_MAXNUKE; i++) {
- if (np->nuk_types[i]) {
- if (needcomma)
- pr(",");
- pr("%dx%s", np->nuk_types[i], nchr[i].n_name);
- needcomma = 1;
- }
- }
- break;
- case EF_SHIP:
- sp = &tgp->shp;
- tp->trd_owner = sp->shp_own;
- pr("(%3d) tech %d %d%% %s [",
- tp->trd_owner,
- sp->shp_tech,
- sp->shp_effic,
- prship(sp));
+ price = multread(tp->trd_owner, player->cnum) * tp->trd_price;
+ switch (tp->trd_type) {
+ case EF_NUKE:
+ np = &tgp->nuk;
+ if (!getsect(np->nuk_x, np->nuk_y, §))
+ return 0;
+ tp->trd_owner = sect.sct_own;
+ natp = getnatp(tp->trd_owner);
+ pr("(%3d) ", sect.sct_own);
+ needcomma = 0;
+ for (i = 0; i < N_MAXNUKE; i++) {
+ if (np->nuk_types[i]) {
+ if (needcomma)
+ pr(",");
+ pr("%dx%s", np->nuk_types[i], nchr[i].n_name);
+ needcomma = 1;
+ }
+ }
+ break;
+ case EF_SHIP:
+ sp = &tgp->shp;
+ tp->trd_owner = sp->shp_own;
+ pr("(%3d) tech %d %d%% %s [",
+ tp->trd_owner, sp->shp_tech, sp->shp_effic, prship(sp));
- for (i = 0; i < sp->shp_nv; i++) {
- pr("%c:%d ",
- ichr[sp->shp_vtype[i] & ~VT_TYPE].i_mnem,
- sp->shp_vamt[i]);
- }
- pr("] #%d", tp->trd_unitid);
- if (opt_SHOWPLANE) {
- snxtitem_all(&ni, EF_PLANE);
- while (nxtitem(&ni, (s_char *)&plane))
- {
- if (plane.pln_ship == sp->shp_uid &&
- plane.pln_own != 0)
- {
- pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
- plane.pln_tech,
- plane.pln_effic,
- plchr[(int)plane.pln_type].pl_name,
- plane.pln_uid);
- if (plane.pln_nuketype != (s_char)-1)
- {
- pr("(%s)",nchr[(int)plane.pln_nuketype].n_name);
- }
- }
+ for (i = 0; i < sp->shp_nv; i++) {
+ pr("%c:%d ",
+ ichr[sp->shp_vtype[i] & ~VT_TYPE].i_mnem, sp->shp_vamt[i]);
+ }
+ pr("] #%d", tp->trd_unitid);
+ if (opt_SHOWPLANE) {
+ snxtitem_all(&ni, EF_PLANE);
+ while (nxtitem(&ni, (s_char *)&plane)) {
+ if (plane.pln_ship == sp->shp_uid && plane.pln_own != 0) {
+ pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
+ plane.pln_tech,
+ plane.pln_effic,
+ plchr[(int)plane.pln_type].pl_name, plane.pln_uid);
+ if (plane.pln_nuketype != (s_char)-1) {
+ pr("(%s)", nchr[(int)plane.pln_nuketype].n_name);
}
- snxtitem_all(&ni, EF_LAND);
- while (nxtitem(&ni, (s_char *)&land))
- {
- if (land.lnd_ship == sp->shp_uid &&
- land.lnd_own != 0)
- {
- pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
- land.lnd_tech,
- land.lnd_effic,
- lchr[(int)land.lnd_type].l_name,
- land.lnd_uid);
- if (land.lnd_nxlight)
- {
- snxtitem_all(&ni, EF_PLANE);
- while (nxtitem(&ni, (s_char *)&plane))
- {
- if (plane.pln_land == land.lnd_uid)
- {
- pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
- plane.pln_tech,
- plane.pln_effic,
- plchr[(int)plane.pln_type].pl_name,
- plane.pln_uid);
- if (plane.pln_nuketype != (s_char)-1)
- {
- pr("(%s)",
- nchr[(int)plane.pln_nuketype].n_name);
- }
- }
+ }
+ }
+ snxtitem_all(&ni, EF_LAND);
+ while (nxtitem(&ni, (s_char *)&land)) {
+ if (land.lnd_ship == sp->shp_uid && land.lnd_own != 0) {
+ pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
+ land.lnd_tech,
+ land.lnd_effic,
+ lchr[(int)land.lnd_type].l_name, land.lnd_uid);
+ if (land.lnd_nxlight) {
+ snxtitem_all(&ni, EF_PLANE);
+ while (nxtitem(&ni, (s_char *)&plane)) {
+ if (plane.pln_land == land.lnd_uid) {
+ pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
+ plane.pln_tech,
+ plane.pln_effic,
+ plchr[(int)plane.pln_type].pl_name,
+ plane.pln_uid);
+ if (plane.pln_nuketype != (s_char)-1) {
+ pr("(%s)",
+ nchr[(int)plane.pln_nuketype].
+ n_name);
}
}
}
}
}
- getsect(sp->shp_x, sp->shp_y, §);
- if (sect.sct_type != SCT_WATER)
- pr(" in a %s %s", cname(sect.sct_own),
- dchr[sect.sct_type].d_name);
- else
- pr(" at sea");
- break;
- case EF_LAND:
- lp = &tgp->lnd;
- tp->trd_owner = lp->lnd_own;
- pr("(%3d) tech %d %d%% %s [",
- tp->trd_owner,
- lp->lnd_tech,
- lp->lnd_effic,
- lchr[(int)lp->lnd_type].l_name);
- for (i = 0; i < lp->lnd_nv; i++) {
- pr("%c:%d ",
- ichr[lp->lnd_vtype[i] & ~VT_TYPE].i_mnem,
- lp->lnd_vamt[i]);
- }
- pr("] #%d", tp->trd_unitid);
- if (opt_SHOWPLANE) {
- snxtitem_all(&ni, EF_PLANE);
- while (nxtitem(&ni, (s_char *)&plane))
- {
- if (plane.pln_land == lp->lnd_uid &&
- plane.pln_own != 0)
- {
- pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
- plane.pln_tech,
- plane.pln_effic,
- plchr[(int)plane.pln_type].pl_name,
- plane.pln_uid);
- if (plane.pln_nuketype != (s_char)-1)
- {
- pr("(%s)",
- nchr[(int)plane.pln_nuketype].n_name);
- }
- }
+ }
+ }
+ getsect(sp->shp_x, sp->shp_y, §);
+ if (sect.sct_type != SCT_WATER)
+ pr(" in a %s %s", cname(sect.sct_own),
+ dchr[sect.sct_type].d_name);
+ else
+ pr(" at sea");
+ break;
+ case EF_LAND:
+ lp = &tgp->lnd;
+ tp->trd_owner = lp->lnd_own;
+ pr("(%3d) tech %d %d%% %s [",
+ tp->trd_owner,
+ lp->lnd_tech, lp->lnd_effic, lchr[(int)lp->lnd_type].l_name);
+ for (i = 0; i < lp->lnd_nv; i++) {
+ pr("%c:%d ",
+ ichr[lp->lnd_vtype[i] & ~VT_TYPE].i_mnem, lp->lnd_vamt[i]);
+ }
+ pr("] #%d", tp->trd_unitid);
+ if (opt_SHOWPLANE) {
+ snxtitem_all(&ni, EF_PLANE);
+ while (nxtitem(&ni, (s_char *)&plane)) {
+ if (plane.pln_land == lp->lnd_uid && plane.pln_own != 0) {
+ pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
+ plane.pln_tech,
+ plane.pln_effic,
+ plchr[(int)plane.pln_type].pl_name, plane.pln_uid);
+ if (plane.pln_nuketype != (s_char)-1) {
+ pr("(%s)", nchr[(int)plane.pln_nuketype].n_name);
}
}
- getsect(lp->lnd_x, lp->lnd_y, §);
- break;
- case EF_PLANE:
- pp = &tgp->pln;
- tp->trd_owner = pp->pln_own;
- pr("(%3d) tech %d %d%% %s #%d",
- tp->trd_owner,
- pp->pln_tech,
- pp->pln_effic,
- plchr[(int)pp->pln_type].pl_name,
- tp->trd_unitid);
- if (pp->pln_nuketype != (s_char)-1) {
- pr("(%s)", nchr[(int)pp->pln_nuketype].n_name);
- }
- break;
- default:
- pr("flaky unit type %d", tp->trd_type);
- break;
+ }
+ }
+ getsect(lp->lnd_x, lp->lnd_y, §);
+ break;
+ case EF_PLANE:
+ pp = &tgp->pln;
+ tp->trd_owner = pp->pln_own;
+ pr("(%3d) tech %d %d%% %s #%d",
+ tp->trd_owner,
+ pp->pln_tech,
+ pp->pln_effic,
+ plchr[(int)pp->pln_type].pl_name, tp->trd_unitid);
+ if (pp->pln_nuketype != (s_char)-1) {
+ pr("(%s)", nchr[(int)pp->pln_nuketype].n_name);
}
- return 1;
+ break;
+ default:
+ pr("flaky unit type %d", tp->trd_type);
+ break;
+ }
+ return 1;
}
int
trade_getitem(struct trdstr *tp, union trdgenstr *tgp)
{
- if (!ef_read(tp->trd_type, tp->trd_unitid, (s_char *)tgp))
- return 0;
- return 1;
+ if (!ef_read(tp->trd_type, tp->trd_unitid, (s_char *)tgp))
+ return 0;
+ return 1;
}
long
if (sp->sct_own != cnum)
continue;
secttot += (long)(dchr[sp->sct_type].d_value *
- ((float)sp->sct_effic+100.0));
+ ((float)sp->sct_effic + 100.0));
for (k = 0; ichr[k].i_name; k++) {
if (ichr[k].i_value == 0 || ichr[k].i_vtype == 0)
continue;
whichitem(char p)
{
register int i;
-
+
if (p == 0)
return 0;
for (i = 1; ichr[i].i_mnem != 0; i++)
pr("Unrecognized item \"%c\"\n", p);
return 0;
}
-