Still more application of coord type.
[super-star-trek.git] / src / events.c
index 95a3c44517c1e37650a296e2321a4dec87c1f765..8fed80ac80b34e4d0a8fa1345af6e20a1a00ed27 100644 (file)
@@ -93,6 +93,7 @@ void events(void)
 
     radio_was_broken = damaged(DRADIO);
 
+    hold.x = hold.y = 0;
     for (;;) {
        /* Select earliest extraneous event, evcode==0 if no events */
        evcode = FSPY;
@@ -170,7 +171,7 @@ void events(void)
                 (game.torps < 5 || damaged(DPHOTON)))) {
                /* Tractor-beam her! */
                istract = true;
-               yank = square(game.state.kscmdr.x-game.quadrant.x) + square(game.state.kscmdr.y-game.quadrant.y);
+               yank = distance(game.state.kscmdr, game.quadrant);
                /********* fall through to FTBEAM code ***********/
            }
            else return;
@@ -223,7 +224,7 @@ void events(void)
                game.quadrant = game.state.kscmdr;
            else
                game.quadrant = game.state.kcmdr[i];
-           iran(QUADSIZE, &game.sector.x, &game.sector.y);
+           game.sector = iran(QUADSIZE);
            crmshp();
            proutn(_(" is pulled to "));
            proutn(cramlc(quadrant, game.quadrant));
@@ -431,7 +432,7 @@ void events(void)
                   which has some stars which are inhabited and
                   not already under attack, which is not
                   supernova'ed, and which has some Klingons in it */
-               iran(GALSIZE, &w.x, &w.y);
+               w = iran(GALSIZE);
                q = &game.state.galaxy[w.x][w.y];
            } while (--i &&
                     (same(game.quadrant, w) || q->planet == NOPLANET ||
@@ -521,7 +522,7 @@ void events(void)
            game.state.remkl++;
            q->klingons++;
            if (same(game.quadrant, w))
-               newkling(++game.klhere, &hold);
+               newkling(++game.klhere);
 
            /* recompute time left */
            game.state.remtime = game.state.remres/(game.state.remkl+4*game.state.remcom);
@@ -713,7 +714,7 @@ void nova(coord nov)
                        kount++;
                        break;
                    case IHK: /* kill klingon */
-                       deadkl(scratch,iquad, scratch.x, scratch.y);
+                       deadkl(scratch,iquad, scratch);
                        break;
                    case IHC: /* Damage/destroy big enemies */
                    case IHS:
@@ -722,7 +723,7 @@ void nova(coord nov)
                            if (same(game.ks[ll], scratch)) break;
                        game.kpower[ll] -= 800.0; /* If firepower is lost, die */
                        if (game.kpower[ll] <= 0.0) {
-                           deadkl(scratch, iquad, scratch.x, scratch.y);
+                           deadkl(scratch, iquad, scratch);
                            break;
                        }
                        newc.x = scratch.x + scratch.x - hits[mm][1];
@@ -739,7 +740,7 @@ void nova(coord nov)
                            proutn(_(", blasted into "));
                            crmena(false, IHBLANK, sector, newc);
                            skip(1);
-                           deadkl(scratch, iquad, newc.x, newc.y);
+                           deadkl(scratch, iquad, newc);
                            break;
                        }
                        if (iquad1 != IHDOT) {
@@ -752,8 +753,7 @@ void nova(coord nov)
                        game.quad[scratch.x][scratch.y] = IHDOT;
                        game.quad[newc.x][newc.y] = iquad;
                        game.ks[ll] = newc;
-                       game.kavgd[ll] = sqrt(square(game.sector.x-newc.x)+square(game.sector.y-newc.y));
-                       game.kdist[ll] = game.kavgd[ll];
+                       game.kdist[ll] = game.kavgd[ll] = distance(game.sector, newc);
                        skip(1);
                        break;
                    }
@@ -849,7 +849,7 @@ void snova(bool induced, coord *w)
            prouts("***************");
            skip(1);
            stars();
-           game.alldone=1;
+           game.alldone = true;
        }
     }