]> git.pond.sub.org Git - empserver/commitdiff
Use relations_with() where its different value doesn't matter
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 30 Jan 2011 10:46:17 +0000 (11:46 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 16 Feb 2011 06:52:25 +0000 (07:52 +0100)
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.

src/lib/subs/aircombat.c
src/lib/subs/mission.c
src/lib/subs/mslsub.c
src/lib/subs/nreport.c
src/lib/subs/shpsub.c

index 2645eb69e507cc192a6e89e1d5ac48730fec8be9..29df52f1215563009b8587dc3ae55a676ad186e5 100644 (file)
@@ -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;
        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)
            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;
            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;
            continue;
        flak = aaf * 1.5 * land.lnd_effic / 100.0;
        ngun += flak;
index ab8e58954ba1811a538f76753c6065d01680f125..bd612cc50c65150f4c2d5fd0baefe2b26e5f8613 100644 (file)
@@ -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++) {
     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]);
     }
 
        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;
            }
                   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));
                wu(0, pp->pln_own,
                   "\t%s tracks %s %s at %s\n",
                   prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
index e7c03e5df5f5e26579a6f145124ddae1e356217b..7a763c3ba1afc15df23d4f73e3cae935f6205676 100644 (file)
@@ -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 (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))
            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))
index 13216b88bf31dfb5a244590333d7577273ae8178..f2d01dc6075e6f727224d97845e34692932d0d90 100644 (file)
@@ -84,7 +84,7 @@ nreport(natid actor, int event, natid victim, int times)
        return;
     if (!chance((double)-nice * times / 20.0))
        return;
        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);
        return;
 
     setrel(victim, actor, HOSTILE);
index 5883d2ba59e3bac417a50df5a4009983256f61e7..d18316a969a71a40abff8034011051959d1d047e 100644 (file)
@@ -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) {
        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);
            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 (!(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)
            continue;
 
        if (ship.shp_effic < 60)