Still more application of coord type.
[super-star-trek.git] / src / ai.c
index 6fc79080ed1112d1579c8327009a3688ba453a28..889aafe210d8e7556b1def774ccbfc567ece1a1e 100644 (file)
--- a/src/ai.c
+++ b/src/ai.c
@@ -208,7 +208,7 @@ static void movebaddy(coord com, int loccom, int ienm)
                /* See if we should ram ship */
                if (game.quad[lookx][looky] == game.ship &&
                    (ienm == IHC || ienm == IHS)) {
-                   ram(1, ienm, com);
+                   ram(true, ienm, com);
                    return;
                }
                if (krawlx != mx && my != 0) {
@@ -241,8 +241,7 @@ static void movebaddy(coord com, int loccom, int ienm)
        /* it moved */
        game.ks[loccom].x = next.x;
        game.ks[loccom].y = next.y;
-       game.kdist[loccom] = game.kavgd[loccom] =
-           sqrt(square(game.sector.x-next.x)+square(game.sector.y-next.y));
+       game.kdist[loccom] = game.kavgd[loccom] = distance(game.sector, next);
        if (!damaged(DSRSENS) || game.condit == IHDOCKED) {
            proutn("***");
            cramen(ienm);
@@ -387,9 +386,7 @@ void scom(bool *ipage)
        sc = game.state.kscmdr;
        for_starbases(i) {
            basetbl[i] = i;
-           ibq.x = game.state.baseq[i].x;
-           ibq.y = game.state.baseq[i].y;
-           bdist[i] = sqrt(square(ibq.x-sc.x) + square(ibq.y-sc.y));
+           bdist[i] = distance(game.state.baseq[i], sc);
        }
        if (game.state.rembase > 1) {
            /* sort into nearest first order */
@@ -532,7 +529,6 @@ void movetho(void)
 /* move the Tholian */
 {
     int idx, idy, im, i;
-    coord dummy;
     /* Move the Tholian */
     if (!game.ithere || game.justin) return;
 
@@ -586,7 +582,7 @@ void movetho(void)
     }
     /* All plugged up -- Tholian splits */
     game.quad[game.tholian.x][game.tholian.y]=IHWEB;
-    dropin(IHBLANK, &dummy);
+    dropin(IHBLANK);
     crmena(true, IHT, sector, game.tholian);
     prout(_(" completes web."));
     game.ithere = false;