Use relations_with() for getrel(getnatp(US), THEM) where US!=THEM
Replacing getrel(getnatp(US), THEM) by relations_with(US, THEM) makes a difference only when US equals THEM. Replace in places where it's obvious that they're not equal. Note: getsect() sets player->owner to "player is god or owns this sector". Thus, after getsect(..., §), sect.sct_own == player->cnum implies player->owner. Conversely, !player->owner implies sect.sct_own != player->cnum. Similarly for getship(), getplane() and nxtitem().
This commit is contained in:
parent
6807cd91b5
commit
8cb7b75557
10 changed files with 20 additions and 20 deletions
|
@ -59,7 +59,7 @@ arm(void)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
while (nxtitem(&ni, &pl)) {
|
while (nxtitem(&ni, &pl)) {
|
||||||
if (!player->owner
|
if (!player->owner
|
||||||
&& getrel(getnatp(pl.pln_own), player->cnum) != ALLIED)
|
&& relations_with(pl.pln_own, player->cnum) != ALLIED)
|
||||||
continue;
|
continue;
|
||||||
plc = &plchr[(int)pl.pln_type];
|
plc = &plchr[(int)pl.pln_type];
|
||||||
if ((plc->pl_flags & (P_O | P_N | P_MAR))
|
if ((plc->pl_flags & (P_O | P_N | P_MAR))
|
||||||
|
@ -150,7 +150,7 @@ disarm(void)
|
||||||
}
|
}
|
||||||
getsect(nuke.nuk_x, nuke.nuk_y, §);
|
getsect(nuke.nuk_x, nuke.nuk_y, §);
|
||||||
if (!player->owner
|
if (!player->owner
|
||||||
&& getrel(getnatp(sect.sct_own), player->cnum) != ALLIED) {
|
&& relations_with(sect.sct_own, player->cnum) != ALLIED) {
|
||||||
pr("Disarming %s in sector %s requires an alliance!\n",
|
pr("Disarming %s in sector %s requires an alliance!\n",
|
||||||
prplane(&pl), xyas(sect.sct_x, sect.sct_y, player->cnum));
|
prplane(&pl), xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -164,7 +164,7 @@ assa(void)
|
||||||
for (qp = olist.q_forw; qp != &olist; qp = next) {
|
for (qp = olist.q_forw; qp != &olist; qp = next) {
|
||||||
next = qp->q_forw;
|
next = qp->q_forw;
|
||||||
llp = (struct ulist *)qp;
|
llp = (struct ulist *)qp;
|
||||||
rel = getrel(getnatp(def->own), player->cnum);
|
rel = relations_with(def->own, player->cnum);
|
||||||
if (chance(0.10) || rel == ALLIED || !def->own) {
|
if (chance(0.10) || rel == ALLIED || !def->own) {
|
||||||
pr("%s made it on shore safely.\n", prland(&llp->unit.land));
|
pr("%s made it on shore safely.\n", prland(&llp->unit.land));
|
||||||
llp->unit.land.lnd_x = def->x;
|
llp->unit.land.lnd_x = def->x;
|
||||||
|
|
|
@ -95,7 +95,7 @@ atta(void)
|
||||||
newy = def->y + diroff[n + 1][1];
|
newy = def->y + diroff[n + 1][1];
|
||||||
getsect(newx, newy, §); /* incase cross world boundary */
|
getsect(newx, newy, §); /* incase cross world boundary */
|
||||||
if (!player->owner
|
if (!player->owner
|
||||||
&& getrel(getnatp(sect.sct_own), player->cnum) != ALLIED)
|
&& relations_with(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;
|
||||||
|
|
|
@ -117,7 +117,7 @@ load(void)
|
||||||
if (!player->owner) {
|
if (!player->owner) {
|
||||||
if (load_unload == UNLOAD || !noisy)
|
if (load_unload == UNLOAD || !noisy)
|
||||||
continue;
|
continue;
|
||||||
if (getrel(getnatp(ship.shp_own), player->cnum) < FRIENDLY)
|
if (relations_with(ship.shp_own, player->cnum) < FRIENDLY)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ load(void)
|
||||||
}
|
}
|
||||||
if (load_unload == UNLOAD
|
if (load_unload == UNLOAD
|
||||||
&& !player->owner
|
&& !player->owner
|
||||||
&& getrel(getnatp(sect.sct_own), player->cnum) < FRIENDLY) {
|
&& relations_with(sect.sct_own, player->cnum) < FRIENDLY) {
|
||||||
if (noisy)
|
if (noisy)
|
||||||
pr("You can't unload into an unfriendly %s\n",
|
pr("You can't unload into an unfriendly %s\n",
|
||||||
dchr[sect.sct_type].d_name);
|
dchr[sect.sct_type].d_name);
|
||||||
|
@ -251,7 +251,7 @@ lload(void)
|
||||||
if (!player->owner) {
|
if (!player->owner) {
|
||||||
if (load_unload == UNLOAD || !noisy)
|
if (load_unload == UNLOAD || !noisy)
|
||||||
continue;
|
continue;
|
||||||
if (getrel(getnatp(land.lnd_own), player->cnum) != ALLIED)
|
if (relations_with(land.lnd_own, player->cnum) != ALLIED)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ lload(void)
|
||||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (getrel(getnatp(sect.sct_own), player->cnum) != ALLIED) {
|
if (relations_with(sect.sct_own, player->cnum) != ALLIED) {
|
||||||
pr("Sector %s is not yours.\n",
|
pr("Sector %s is not yours.\n",
|
||||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -135,7 +135,7 @@ scra(void)
|
||||||
getsect(item.gen.x, item.gen.y, §);
|
getsect(item.gen.x, item.gen.y, §);
|
||||||
if (type == EF_SHIP) {
|
if (type == EF_SHIP) {
|
||||||
if (!player->owner
|
if (!player->owner
|
||||||
&& getrel(getnatp(sect.sct_own), player->cnum) < FRIENDLY) {
|
&& relations_with(sect.sct_own, player->cnum) < FRIENDLY) {
|
||||||
pr("%s is not in a friendly harbor!\n",
|
pr("%s is not in a friendly harbor!\n",
|
||||||
prship(&item.ship));
|
prship(&item.ship));
|
||||||
continue;
|
continue;
|
||||||
|
@ -158,7 +158,7 @@ scra(void)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!player->owner
|
if (!player->owner
|
||||||
&& getrel(getnatp(sect.sct_own), player->cnum) != ALLIED) {
|
&& relations_with(sect.sct_own, player->cnum) != ALLIED) {
|
||||||
pr("%s is not in an allied sector!\n",
|
pr("%s is not in an allied sector!\n",
|
||||||
obj_nameof(&item.gen));
|
obj_nameof(&item.gen));
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -173,7 +173,7 @@ sona(void)
|
||||||
if (rad[y][x] != dchr[SCT_WATER].d_mnem && rad[y][x] != 'X')
|
if (rad[y][x] != dchr[SCT_WATER].d_mnem && rad[y][x] != 'X')
|
||||||
continue;
|
continue;
|
||||||
if (tmcp->m_flags & M_SUB &&
|
if (tmcp->m_flags & M_SUB &&
|
||||||
getrel(getnatp(targ.shp_own), player->cnum) < FRIENDLY) {
|
relations_with(targ.shp_own, player->cnum) < FRIENDLY) {
|
||||||
if (mcp->m_vrnge + visib < 8)
|
if (mcp->m_vrnge + visib < 8)
|
||||||
pr("Sonar detects sub #%d @ %s\n",
|
pr("Sonar detects sub #%d @ %s\n",
|
||||||
targ.shp_uid,
|
targ.shp_uid,
|
||||||
|
@ -275,7 +275,7 @@ plane_sona(struct emp_qelem *plane_list, int x, int y,
|
||||||
pr("Sonar contact in %s\n", xyas(x, y, player->cnum));
|
pr("Sonar contact in %s\n", xyas(x, y, player->cnum));
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
if (getrel(getnatp(targ->shp_own), pp->pln_own) < FRIENDLY &&
|
if (relations_with(targ->shp_own, pp->pln_own) < FRIENDLY &&
|
||||||
roll(100) > pln_identchance(pp, shp_hardtarget(targ),
|
roll(100) > pln_identchance(pp, shp_hardtarget(targ),
|
||||||
EF_SHIP))
|
EF_SHIP))
|
||||||
if (roll(100) > pln_identchance(pp, shp_hardtarget(targ),
|
if (roll(100) > pln_identchance(pp, shp_hardtarget(targ),
|
||||||
|
|
|
@ -129,7 +129,7 @@ spy(void)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
own = dsect.sct_own;
|
own = dsect.sct_own;
|
||||||
relat = getrel(getnatp(own), player->cnum);
|
relat = relations_with(own, player->cnum);
|
||||||
if (relat <= NEUTRAL
|
if (relat <= NEUTRAL
|
||||||
&& chance(dsect.sct_item[I_MILIT] / 200.0)) {
|
&& chance(dsect.sct_item[I_MILIT] / 200.0)) {
|
||||||
/* spy caught */
|
/* spy caught */
|
||||||
|
|
|
@ -134,8 +134,8 @@ tend(void)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
total = 0;
|
total = 0;
|
||||||
while (nxtitem(&targets, &target)) {
|
while (nxtitem(&targets, &target)) {
|
||||||
if (!player->owner &&
|
if (!player->owner
|
||||||
(getrel(getnatp(target.shp_own), player->cnum) < FRIENDLY))
|
&& relations_with(target.shp_own, player->cnum) < FRIENDLY)
|
||||||
continue;
|
continue;
|
||||||
if (target.shp_uid == tender.shp_uid)
|
if (target.shp_uid == tender.shp_uid)
|
||||||
continue;
|
continue;
|
||||||
|
@ -232,8 +232,8 @@ tend_land(struct shpstr *tenderp, char *units)
|
||||||
if (!check_ship_ok(tenderp) || !check_land_ok(&land))
|
if (!check_ship_ok(tenderp) || !check_land_ok(&land))
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
while (nxtitem(&targets, &target)) {
|
while (nxtitem(&targets, &target)) {
|
||||||
if (!player->owner &&
|
if (!player->owner
|
||||||
(getrel(getnatp(target.shp_own), player->cnum) < FRIENDLY))
|
&& relations_with(target.shp_own, player->cnum) < FRIENDLY)
|
||||||
continue;
|
continue;
|
||||||
if (target.shp_uid == tenderp->shp_uid)
|
if (target.shp_uid == tenderp->shp_uid)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -159,8 +159,8 @@ feels_like_helping(natid cn, natid friend, natid foe)
|
||||||
if (cn == friend)
|
if (cn == friend)
|
||||||
return 1; /* help self against anybody else */
|
return 1; /* help self against anybody else */
|
||||||
/* third party helps ally if at war with foe: */
|
/* third party helps ally if at war with foe: */
|
||||||
return getrel(getnatp(cn), friend) == ALLIED
|
return relations_with(cn, friend) == ALLIED
|
||||||
&& getrel(getnatp(cn), foe) == AT_WAR;
|
&& relations_with(cn, foe) == AT_WAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Shoot back
|
/* Shoot back
|
||||||
|
|
|
@ -143,7 +143,7 @@ pln_onewaymission(struct sctstr *target, int *shipno, int *flagp)
|
||||||
if (cno < 0
|
if (cno < 0
|
||||||
|| !getship(cno, &ship)
|
|| !getship(cno, &ship)
|
||||||
|| (!player->owner
|
|| (!player->owner
|
||||||
&& (getrel(getnatp(ship.shp_own), player->cnum)
|
&& (relations_with(ship.shp_own, player->cnum)
|
||||||
!= ALLIED))) {
|
!= ALLIED))) {
|
||||||
pr("Not yours\n");
|
pr("Not yours\n");
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue