From: Markus Armbruster Date: Sun, 30 Jan 2011 10:46:17 +0000 (+0100) Subject: Use relations_with() where its different value doesn't matter X-Git-Tag: v4.3.27~135 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=6807cd91b5b8aa457ef18885b7dbca5ec8d5de9e Use relations_with() where its different value doesn't matter Switching from getrel() to relations_with() can change the value from NEUTRAL to ALLIED. The change doesn't matter when the value's only compared to HOSTILE, as both old and new value are greater than HOSTILE. Likewise for >= NEUTRAL. --- diff --git a/src/lib/subs/aircombat.c b/src/lib/subs/aircombat.c index 2645eb69e..29df52f12 100644 --- a/src/lib/subs/aircombat.c +++ b/src/lib/subs/aircombat.c @@ -618,7 +618,7 @@ ac_shipflak(struct emp_qelem *list, coord x, coord y) mcp = &mchr[(int)ship.shp_type]; if (mcp->m_flags & M_SUB) continue; - if (getrel(getnatp(ship.shp_own), plane_owner) > HOSTILE) + if (relations_with(ship.shp_own, plane_owner) > HOSTILE) continue; gun = shp_usable_guns(&ship); if (gun == 0) @@ -669,7 +669,7 @@ ac_landflak(struct emp_qelem *list, coord x, coord y) continue; if (land.lnd_ship >= 0 || land.lnd_land >= 0) continue; - if (getrel(getnatp(land.lnd_own), plane_owner) > HOSTILE) + if (relations_with(land.lnd_own, plane_owner) > HOSTILE) continue; flak = aaf * 1.5 * land.lnd_effic / 100.0; ngun += flak; diff --git a/src/lib/subs/mission.c b/src/lib/subs/mission.c index ab8e58954..bd612cc50 100644 --- a/src/lib/subs/mission.c +++ b/src/lib/subs/mission.c @@ -105,7 +105,7 @@ ground_interdict(coord x, coord y, natid victim, char *s) memset(mi, 0, sizeof(mi)); act[0] = 0; for (cn = 1; cn < MAXNOC; cn++) { - act[cn] = getrel(getnatp(cn), victim) <= HOSTILE; + act[cn] = relations_with(cn, victim) <= HOSTILE; emp_initque((struct emp_qelem *)&mi[cn]); } @@ -1041,7 +1041,7 @@ air_damage(struct emp_qelem *bombers, coord x, coord y, int mission, prplane(pp), xyas(x, y, pp->pln_own)); continue; } - if (getrel(getnatp(pp->pln_own), victim) > HOSTILE) { + if (relations_with(pp->pln_own, victim) > HOSTILE) { wu(0, pp->pln_own, "\t%s tracks %s %s at %s\n", prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own)); diff --git a/src/lib/subs/mslsub.c b/src/lib/subs/mslsub.c index e7c03e5df..7a763c3ba 100644 --- a/src/lib/subs/mslsub.c +++ b/src/lib/subs/mslsub.c @@ -199,7 +199,7 @@ msl_sel(struct emp_qelem *list, coord x, coord y, natid victim, if (mission && plane.pln_radius < mapdist(x, y, plane.pln_opx, plane.pln_opy)) continue; - if (getrel(getnatp(plane.pln_own), victim) >= NEUTRAL) + if (relations_with(plane.pln_own, victim) >= NEUTRAL) continue; /* missiles go one way, so we can use all the range */ if (plane.pln_range < mapdist(x, y, plane.pln_x, plane.pln_y)) diff --git a/src/lib/subs/nreport.c b/src/lib/subs/nreport.c index 13216b88b..f2d01dc60 100644 --- a/src/lib/subs/nreport.c +++ b/src/lib/subs/nreport.c @@ -84,7 +84,7 @@ nreport(natid actor, int event, natid victim, int times) return; if (!chance((double)-nice * times / 20.0)) return; - if (getrel(getnatp(victim), actor) < HOSTILE) + if (relations_with(victim, actor) < HOSTILE) return; setrel(victim, actor, HOSTILE); diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index 5883d2ba5..d18316a96 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -611,7 +611,7 @@ shp_fort_interdiction(struct emp_qelem *list, coord newx, coord newy, return 0; /* Only coastwatch notify in nofortfire */ /* Only fire at Hostile ships */ for (i = 0; i < MAXNOC; ++i) { - if (getrel(getnatp(i), victim) >= NEUTRAL) + if (relations_with(i, victim) >= NEUTRAL) notified[i] = 0; } snxtsct_dist(&ns, newx, newy, fort_max_interdiction_range); @@ -849,7 +849,7 @@ shp_missile_defense(coord dx, coord dy, natid bombown, int hardtarget) if (!(mchr[(int)ship.shp_type].m_flags & M_ANTIMISSILE)) continue; - if (getrel(getnatp(ship.shp_own), bombown) >= NEUTRAL) + if (relations_with(ship.shp_own, bombown) >= NEUTRAL) continue; if (ship.shp_effic < 60)