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;
|
||||
while (nxtitem(&ni, &pl)) {
|
||||
if (!player->owner
|
||||
&& getrel(getnatp(pl.pln_own), player->cnum) != ALLIED)
|
||||
&& relations_with(pl.pln_own, player->cnum) != ALLIED)
|
||||
continue;
|
||||
plc = &plchr[(int)pl.pln_type];
|
||||
if ((plc->pl_flags & (P_O | P_N | P_MAR))
|
||||
|
@ -150,7 +150,7 @@ disarm(void)
|
|||
}
|
||||
getsect(nuke.nuk_x, nuke.nuk_y, §);
|
||||
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",
|
||||
prplane(&pl), xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
continue;
|
||||
|
|
|
@ -164,7 +164,7 @@ assa(void)
|
|||
for (qp = olist.q_forw; qp != &olist; qp = next) {
|
||||
next = qp->q_forw;
|
||||
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) {
|
||||
pr("%s made it on shore safely.\n", prland(&llp->unit.land));
|
||||
llp->unit.land.lnd_x = def->x;
|
||||
|
|
|
@ -95,7 +95,7 @@ atta(void)
|
|||
newy = def->y + diroff[n + 1][1];
|
||||
getsect(newx, newy, §); /* incase cross world boundary */
|
||||
if (!player->owner
|
||||
&& getrel(getnatp(sect.sct_own), player->cnum) != ALLIED)
|
||||
&& relations_with(sect.sct_own, player->cnum) != ALLIED)
|
||||
continue;
|
||||
att_combat_init(&off[++last], EF_SECTOR);
|
||||
off[last].x = sect.sct_x;
|
||||
|
|
|
@ -117,7 +117,7 @@ load(void)
|
|||
if (!player->owner) {
|
||||
if (load_unload == UNLOAD || !noisy)
|
||||
continue;
|
||||
if (getrel(getnatp(ship.shp_own), player->cnum) < FRIENDLY)
|
||||
if (relations_with(ship.shp_own, player->cnum) < FRIENDLY)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ load(void)
|
|||
}
|
||||
if (load_unload == UNLOAD
|
||||
&& !player->owner
|
||||
&& getrel(getnatp(sect.sct_own), player->cnum) < FRIENDLY) {
|
||||
&& relations_with(sect.sct_own, player->cnum) < FRIENDLY) {
|
||||
if (noisy)
|
||||
pr("You can't unload into an unfriendly %s\n",
|
||||
dchr[sect.sct_type].d_name);
|
||||
|
@ -251,7 +251,7 @@ lload(void)
|
|||
if (!player->owner) {
|
||||
if (load_unload == UNLOAD || !noisy)
|
||||
continue;
|
||||
if (getrel(getnatp(land.lnd_own), player->cnum) != ALLIED)
|
||||
if (relations_with(land.lnd_own, player->cnum) != ALLIED)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,7 @@ lload(void)
|
|||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
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",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
continue;
|
||||
|
|
|
@ -135,7 +135,7 @@ scra(void)
|
|||
getsect(item.gen.x, item.gen.y, §);
|
||||
if (type == EF_SHIP) {
|
||||
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",
|
||||
prship(&item.ship));
|
||||
continue;
|
||||
|
@ -158,7 +158,7 @@ scra(void)
|
|||
}
|
||||
} else {
|
||||
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",
|
||||
obj_nameof(&item.gen));
|
||||
continue;
|
||||
|
|
|
@ -173,7 +173,7 @@ sona(void)
|
|||
if (rad[y][x] != dchr[SCT_WATER].d_mnem && rad[y][x] != 'X')
|
||||
continue;
|
||||
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)
|
||||
pr("Sonar detects sub #%d @ %s\n",
|
||||
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));
|
||||
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),
|
||||
EF_SHIP))
|
||||
if (roll(100) > pln_identchance(pp, shp_hardtarget(targ),
|
||||
|
|
|
@ -129,7 +129,7 @@ spy(void)
|
|||
continue;
|
||||
|
||||
own = dsect.sct_own;
|
||||
relat = getrel(getnatp(own), player->cnum);
|
||||
relat = relations_with(own, player->cnum);
|
||||
if (relat <= NEUTRAL
|
||||
&& chance(dsect.sct_item[I_MILIT] / 200.0)) {
|
||||
/* spy caught */
|
||||
|
|
|
@ -134,8 +134,8 @@ tend(void)
|
|||
return RET_SYN;
|
||||
total = 0;
|
||||
while (nxtitem(&targets, &target)) {
|
||||
if (!player->owner &&
|
||||
(getrel(getnatp(target.shp_own), player->cnum) < FRIENDLY))
|
||||
if (!player->owner
|
||||
&& relations_with(target.shp_own, player->cnum) < FRIENDLY)
|
||||
continue;
|
||||
if (target.shp_uid == tender.shp_uid)
|
||||
continue;
|
||||
|
@ -232,8 +232,8 @@ tend_land(struct shpstr *tenderp, char *units)
|
|||
if (!check_ship_ok(tenderp) || !check_land_ok(&land))
|
||||
return RET_SYN;
|
||||
while (nxtitem(&targets, &target)) {
|
||||
if (!player->owner &&
|
||||
(getrel(getnatp(target.shp_own), player->cnum) < FRIENDLY))
|
||||
if (!player->owner
|
||||
&& relations_with(target.shp_own, player->cnum) < FRIENDLY)
|
||||
continue;
|
||||
if (target.shp_uid == tenderp->shp_uid)
|
||||
continue;
|
||||
|
|
|
@ -159,8 +159,8 @@ feels_like_helping(natid cn, natid friend, natid foe)
|
|||
if (cn == friend)
|
||||
return 1; /* help self against anybody else */
|
||||
/* third party helps ally if at war with foe: */
|
||||
return getrel(getnatp(cn), friend) == ALLIED
|
||||
&& getrel(getnatp(cn), foe) == AT_WAR;
|
||||
return relations_with(cn, friend) == ALLIED
|
||||
&& relations_with(cn, foe) == AT_WAR;
|
||||
}
|
||||
|
||||
/* Shoot back
|
||||
|
|
|
@ -143,7 +143,7 @@ pln_onewaymission(struct sctstr *target, int *shipno, int *flagp)
|
|||
if (cno < 0
|
||||
|| !getship(cno, &ship)
|
||||
|| (!player->owner
|
||||
&& (getrel(getnatp(ship.shp_own), player->cnum)
|
||||
&& (relations_with(ship.shp_own, player->cnum)
|
||||
!= ALLIED))) {
|
||||
pr("Not yours\n");
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue