Eliminate a few pointless relations variables

Just to make the next few commits easier to review.
This commit is contained in:
Markus Armbruster 2011-01-29 13:09:26 +01:00
parent bb5cd07ce5
commit 7ebbe7da4c
5 changed files with 13 additions and 25 deletions

View file

@ -60,7 +60,6 @@ atta(void)
int last, n; int last, n;
char *p; char *p;
char buf[1024]; char buf[1024];
int rel;
att_combat_init(def, EF_SECTOR); att_combat_init(def, EF_SECTOR);
/* /*
@ -95,8 +94,8 @@ atta(void)
newx = def->x + diroff[n + 1][0]; newx = def->x + diroff[n + 1][0];
newy = def->y + diroff[n + 1][1]; newy = def->y + diroff[n + 1][1];
getsect(newx, newy, &sect); /* incase cross world boundary */ getsect(newx, newy, &sect); /* incase cross world boundary */
rel = getrel(getnatp(sect.sct_own), player->cnum); if (!player->owner
if (!player->owner && rel != ALLIED) && getrel(getnatp(sect.sct_own), player->cnum) != ALLIED)
continue; continue;
att_combat_init(&off[++last], EF_SECTOR); att_combat_init(&off[++last], EF_SECTOR);
off[last].x = sect.sct_x; off[last].x = sect.sct_x;

View file

@ -84,7 +84,6 @@ lupgr(void)
int n; int n;
int tlev; int tlev;
int avail, cost; int avail, cost;
int rel;
long cash; long cash;
if (!snxtitem(&ni, EF_LAND, player->argp[2], NULL)) if (!snxtitem(&ni, EF_LAND, player->argp[2], NULL))
@ -101,8 +100,8 @@ lupgr(void)
continue; continue;
if (sect.sct_type != SCT_HEADQ || sect.sct_effic < 60) if (sect.sct_type != SCT_HEADQ || sect.sct_effic < 60)
continue; continue;
rel = getrel(getnatp(land.lnd_own), sect.sct_own); if (getrel(getnatp(land.lnd_own), sect.sct_own) < FRIENDLY
if (rel < FRIENDLY && sect.sct_own != land.lnd_own) { && sect.sct_own != land.lnd_own) {
pr("You are not on friendly terms with the owner of unit %d!\n", pr("You are not on friendly terms with the owner of unit %d!\n",
land.lnd_uid); land.lnd_uid);
continue; continue;
@ -166,7 +165,6 @@ supgr(void)
int n; int n;
int tlev; int tlev;
int avail, cost; int avail, cost;
int rel;
long cash; long cash;
if (!snxtitem(&ni, EF_SHIP, player->argp[2], NULL)) if (!snxtitem(&ni, EF_SHIP, player->argp[2], NULL))
@ -183,8 +181,8 @@ supgr(void)
continue; continue;
if (sect.sct_type != SCT_HARBR || sect.sct_effic < 60) if (sect.sct_type != SCT_HARBR || sect.sct_effic < 60)
continue; continue;
rel = getrel(getnatp(ship.shp_own), sect.sct_own); if (getrel(getnatp(ship.shp_own), sect.sct_own) < FRIENDLY
if (rel < FRIENDLY && sect.sct_own != ship.shp_own) { && sect.sct_own != ship.shp_own) {
pr("You are not on friendly terms with the owner of ship %d!\n", pr("You are not on friendly terms with the owner of ship %d!\n",
ship.shp_uid); ship.shp_uid);
continue; continue;
@ -247,7 +245,6 @@ pupgr(void)
int n; int n;
int tlev; int tlev;
int avail, cost; int avail, cost;
int rel;
long cash; long cash;
if (!snxtitem(&ni, EF_PLANE, player->argp[2], NULL)) if (!snxtitem(&ni, EF_PLANE, player->argp[2], NULL))
@ -264,8 +261,8 @@ pupgr(void)
continue; continue;
if (sect.sct_type != SCT_AIRPT || sect.sct_effic < 60) if (sect.sct_type != SCT_AIRPT || sect.sct_effic < 60)
continue; continue;
rel = getrel(getnatp(plane.pln_own), sect.sct_own); if (getrel(getnatp(plane.pln_own), sect.sct_own) < FRIENDLY
if (rel < FRIENDLY && sect.sct_own != plane.pln_own) { && sect.sct_own != plane.pln_own) {
pr("You are not on friendly terms with the owner of plane %d!\n", pr("You are not on friendly terms with the owner of plane %d!\n",
plane.pln_uid); plane.pln_uid);
continue; continue;

View file

@ -603,7 +603,6 @@ ac_shipflak(struct emp_qelem *list, coord x, coord y)
struct mchrstr *mcp; struct mchrstr *mcp;
double flak, total, ngun; double flak, total, ngun;
int gun; int gun;
int rel;
struct plist *plp; struct plist *plp;
natid plane_owner; natid plane_owner;
natid from; natid from;
@ -619,8 +618,7 @@ ac_shipflak(struct emp_qelem *list, coord x, coord y)
mcp = &mchr[(int)ship.shp_type]; mcp = &mchr[(int)ship.shp_type];
if (mcp->m_flags & M_SUB) if (mcp->m_flags & M_SUB)
continue; continue;
rel = getrel(getnatp(ship.shp_own), plane_owner); if (getrel(getnatp(ship.shp_own), plane_owner) > HOSTILE)
if (rel > HOSTILE)
continue; continue;
gun = shp_usable_guns(&ship); gun = shp_usable_guns(&ship);
if (gun == 0) if (gun == 0)
@ -653,7 +651,6 @@ ac_landflak(struct emp_qelem *list, coord x, coord y)
struct lchrstr *lcp; struct lchrstr *lcp;
double flak, total, ngun; double flak, total, ngun;
int aaf, gun; int aaf, gun;
int rel;
struct plist *plp; struct plist *plp;
natid plane_owner; natid plane_owner;
natid from; natid from;
@ -672,8 +669,7 @@ ac_landflak(struct emp_qelem *list, coord x, coord y)
continue; continue;
if (land.lnd_ship >= 0 || land.lnd_land >= 0) if (land.lnd_ship >= 0 || land.lnd_land >= 0)
continue; continue;
rel = getrel(getnatp(land.lnd_own), plane_owner); if (getrel(getnatp(land.lnd_own), plane_owner) > HOSTILE)
if (rel > HOSTILE)
continue; continue;
flak = aaf * 1.5 * land.lnd_effic / 100.0; flak = aaf * 1.5 * land.lnd_effic / 100.0;
ngun += flak; ngun += flak;

View file

@ -468,7 +468,6 @@ lnd_mar(struct emp_qelem *list, double *minmobp, double *maxmobp,
coord ally; coord ally;
int first = 1; int first = 1;
char mess[128]; char mess[128];
int rel;
*minmobp = 9876.0; *minmobp = 9876.0;
*maxmobp = -9876.0; *maxmobp = -9876.0;
@ -502,8 +501,8 @@ lnd_mar(struct emp_qelem *list, double *minmobp, double *maxmobp,
lnd_stays(actor, "has no mil on it to guide it", llp); lnd_stays(actor, "has no mil on it to guide it", llp);
continue; continue;
} }
rel = getrel(getnatp(sect.sct_own), actor); if (sect.sct_own != land.lnd_own &&
if (sect.sct_own != land.lnd_own && rel != ALLIED && getrel(getnatp(sect.sct_own), actor) != ALLIED &&
!(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY) && !(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY) &&
sect.sct_own) { sect.sct_own) {
sprintf(mess, "has been kidnapped by %s", cname(sect.sct_own)); sprintf(mess, "has been kidnapped by %s", cname(sect.sct_own));

View file

@ -263,15 +263,12 @@ shiprepair(struct shpstr *ship, struct natstr *np, struct bp *bp, int etus)
int w_p_eff; int w_p_eff;
int mult; int mult;
int mvec[I_MAX + 1]; int mvec[I_MAX + 1];
int rel;
mp = &mchr[(int)ship->shp_type]; mp = &mchr[(int)ship->shp_type];
sp = getsectp(ship->shp_x, ship->shp_y); sp = getsectp(ship->shp_x, ship->shp_y);
if ((sp->sct_own != ship->shp_own) && (sp->sct_own != 0)) { if ((sp->sct_own != ship->shp_own) && (sp->sct_own != 0)) {
rel = getrel(getnatp(sp->sct_own), ship->shp_own); if (getrel(getnatp(sp->sct_own), ship->shp_own) < FRIENDLY)
if (rel < FRIENDLY)
return; return;
} }