Introduce 'coord' data structure, an (x,y) tuple.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 18 Sep 2006 03:49:33 +0000 (03:49 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 18 Sep 2006 03:49:33 +0000 (03:49 +0000)
Use it consistently in both data structures and arguments of functions
that handle coordinates.

The main benefit of this is that lots of conditional expressions become
significantly less gnarly.  We get a bit of reduction in the line count
by cutting down on pairs of coordinate assignments.

src/ai.c
src/battle.c
src/events.c
src/finish.c
src/moving.c
src/planets.c
src/reports.c
src/setup.c
src/sst.c
src/sst.h

index 81e3205f7e71bd61e60815c9b12db8e9f810adf4..ead5a8b1d34064d7f22eed52e0dfefb7f67db7bf 100644 (file)
--- a/src/ai.c
+++ b/src/ai.c
@@ -2,22 +2,23 @@
 
 static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) 
 {
 
 static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) 
 {
-    int iqx, iqy, l;
+    int l;
+    coord iq;
 
 
-    iqx = game.quadx+(lookx+(QUADSIZE-1))/QUADSIZE - 1;
-    iqy = game.quady+(looky+(QUADSIZE-1))/QUADSIZE - 1;
-    if (!VALID_QUADRANT(iqx,iqy) ||
-       game.state.galaxy[iqx][iqy].supernova ||
-       game.state.galaxy[iqx][iqy].klingons > 8)
+    iq.x = game.quadrant.x+(lookx+(QUADSIZE-1))/QUADSIZE - 1;
+    iq.y = game.quadrant.y+(looky+(QUADSIZE-1))/QUADSIZE - 1;
+    if (!VALID_QUADRANT(iq.x,iq.y) ||
+       game.state.galaxy[iq.x][iq.y].supernova ||
+       game.state.galaxy[iq.x][iq.y].klingons > 8)
        return 0; /* no can do -- neg energy, supernovae, or >8 Klingons */
     if (ienm == IHR) return 0; /* Romulans cannot escape! */
     if (irun == 0) {
        /* avoid intruding on another commander's territory */
        if (ienm == IHC) {
            for_commanders(l)
        return 0; /* no can do -- neg energy, supernovae, or >8 Klingons */
     if (ienm == IHR) return 0; /* Romulans cannot escape! */
     if (irun == 0) {
        /* avoid intruding on another commander's territory */
        if (ienm == IHC) {
            for_commanders(l)
-               if (game.state.cx[l]==iqx && game.state.cy[l]==iqy) return 0;
+               if (same(game.state.kcmdr[l],iq)) return 0;
            /* refuse to leave if currently attacking starbase */
            /* refuse to leave if currently attacking starbase */
-           if (game.batx==game.quadx && game.baty==game.quady) return 0;
+           if (same(game.battle, game.quadrant)) return 0;
        }
        /* don't leave if over 1000 units of energy */
        if (game.kpower[loccom] > 1000.) return 0;
        }
        /* don't leave if over 1000 units of energy */
        if (game.kpower[loccom] > 1000.) return 0;
@@ -26,14 +27,13 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun)
        We know this if either short or long range sensors are working */
     if (game.damage[DSRSENS] == 0.0 || game.damage[DLRSENS] == 0.0 ||
        game.condit == IHDOCKED) {
        We know this if either short or long range sensors are working */
     if (game.damage[DSRSENS] == 0.0 || game.damage[DLRSENS] == 0.0 ||
        game.condit == IHDOCKED) {
-       crmena(1, ienm, 2, game.kx[loccom], game.ky[loccom]);
+       crmena(1, ienm, 2, game.ks[loccom]);
        prout(_(" escapes to %s (and regains strength)."),
        prout(_(" escapes to %s (and regains strength)."),
-             cramlc(quadrant, iqx, iqy));
+             cramlc(quadrant, iq));
     }
     /* handle local matters related to escape */
     }
     /* handle local matters related to escape */
-    game.quad[game.kx[loccom]][game.ky[loccom]] = IHDOT;
-    game.kx[loccom] = game.kx[game.nenhere];
-    game.ky[loccom] = game.ky[game.nenhere];
+    game.quad[game.ks[loccom].x][game.ks[loccom].y] = IHDOT;
+    game.ks[loccom] = game.ks[game.nenhere];
     game.kavgd[loccom] = game.kavgd[game.nenhere];
     game.kpower[loccom] = game.kpower[game.nenhere];
     game.kdist[loccom] = game.kdist[game.nenhere];
     game.kavgd[loccom] = game.kavgd[game.nenhere];
     game.kpower[loccom] = game.kpower[game.nenhere];
     game.kdist[loccom] = game.kdist[game.nenhere];
@@ -41,8 +41,8 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun)
     game.nenhere--;
     if (game.condit != IHDOCKED) newcnd();
     /* Handle global matters related to escape */
     game.nenhere--;
     if (game.condit != IHDOCKED) newcnd();
     /* Handle global matters related to escape */
-    game.state.galaxy[game.quadx][game.quady].klingons--;
-    game.state.galaxy[iqx][iqy].klingons++;
+    game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons--;
+    game.state.galaxy[iq.x][iq.y].klingons++;
     if (ienm==IHS) {
        game.ishere=0;
        game.iscate=0;
     if (ienm==IHS) {
        game.ishere=0;
        game.iscate=0;
@@ -50,14 +50,13 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun)
        game.isatb=0;
        schedule(FSCMOVE, 0.2777);
        unschedule(FSCDBAS);
        game.isatb=0;
        schedule(FSCMOVE, 0.2777);
        unschedule(FSCDBAS);
-       game.state.isx=iqx;
-       game.state.isy=iqy;
+       game.state.kscmdr.x=iq.x;
+       game.state.kscmdr.y=iq.y;
     }
     else {
        for_commanders(l) {
     }
     else {
        for_commanders(l) {
-           if (game.state.cx[l]==game.quadx && game.state.cy[l]==game.quady) {
-               game.state.cx[l]=iqx;
-               game.state.cy[l]=iqy;
+           if (same(game.state.kcmdr[l], game.quadrant)) {
+               game.state.kcmdr[l]=iq;
                break;
            }
        }
                break;
            }
        }
@@ -67,9 +66,10 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun)
 }
 
 
 }
 
 
-static void movebaddy(int comx, int comy, int loccom, int ienm) 
+static void movebaddy(coord com, int loccom, int ienm) 
 {
 {
-    int motion, mdist, nsteps, mx, my, nextx, nexty, lookx, looky, ll;
+    int motion, mdist, nsteps, mx, my, lookx, looky, ll;
+    coord next;
     int irun = 0;
     int krawlx, krawly;
     int success;
     int irun = 0;
     int krawlx, krawly;
     int success;
@@ -176,14 +176,13 @@ static void movebaddy(int comx, int comy, int loccom, int ienm)
     }
 #endif
     /* Compute preferred values of delta X and Y */
     }
 #endif
     /* Compute preferred values of delta X and Y */
-    mx = game.sectx - comx;
-    my = game.secty - comy;
+    mx = game.sector.x - com.x;
+    my = game.sector.y - com.y;
     if (2.0 * abs(mx) < abs(my)) mx = 0;
     if (2.0 * abs(mx) < abs(my)) mx = 0;
-    if (2.0 * abs(my) < abs(game.sectx-comx)) my = 0;
+    if (2.0 * abs(my) < abs(game.sector.x-com.x)) my = 0;
     if (mx != 0) mx = mx*motion < 0 ? -1 : 1;
     if (my != 0) my = my*motion < 0 ? -1 : 1;
     if (mx != 0) mx = mx*motion < 0 ? -1 : 1;
     if (my != 0) my = my*motion < 0 ? -1 : 1;
-    nextx = comx;
-    nexty = comy;
+    next = com;
     /* main move loop */
     for (ll = 0; ll < nsteps; ll++) {
 #ifdef DEBUG
     /* main move loop */
     for (ll = 0; ll < nsteps; ll++) {
 #ifdef DEBUG
@@ -192,8 +191,8 @@ static void movebaddy(int comx, int comy, int loccom, int ienm)
        }
 #endif
        /* Check if preferred position available */
        }
 #endif
        /* Check if preferred position available */
-       lookx = nextx + mx;
-       looky = nexty + my;
+       lookx = next.x + mx;
+       looky = next.y + my;
        krawlx = mx < 0 ? 1 : -1;
        krawly = my < 0 ? 1 : -1;
        success = 0;
        krawlx = mx < 0 ? 1 : -1;
        krawly = my < 0 ? 1 : -1;
        success = 0;
@@ -203,29 +202,29 @@ static void movebaddy(int comx, int comy, int loccom, int ienm)
                if (motion < 0 && tryexit(lookx, looky, ienm, loccom, irun))
                    return;
                if (krawlx == mx || my == 0) break;
                if (motion < 0 && tryexit(lookx, looky, ienm, loccom, irun))
                    return;
                if (krawlx == mx || my == 0) break;
-               lookx = nextx + krawlx;
+               lookx = next.x + krawlx;
                krawlx = -krawlx;
            }
            else if (looky < 1 || looky > QUADSIZE) {
                if (motion < 0 && tryexit(lookx, looky, ienm, loccom, irun))
                    return;
                if (krawly == my || mx == 0) break;
                krawlx = -krawlx;
            }
            else if (looky < 1 || looky > QUADSIZE) {
                if (motion < 0 && tryexit(lookx, looky, ienm, loccom, irun))
                    return;
                if (krawly == my || mx == 0) break;
-               looky = nexty + krawly;
+               looky = next.y + krawly;
                krawly = -krawly;
            }
            else if ((game.options & OPTION_RAMMING) && game.quad[lookx][looky] != IHDOT) {
                /* See if we should ram ship */
                if (game.quad[lookx][looky] == game.ship &&
                    (ienm == IHC || ienm == IHS)) {
                krawly = -krawly;
            }
            else if ((game.options & OPTION_RAMMING) && game.quad[lookx][looky] != IHDOT) {
                /* See if we should ram ship */
                if (game.quad[lookx][looky] == game.ship &&
                    (ienm == IHC || ienm == IHS)) {
-                   ram(1, ienm, comx, comy);
+                   ram(1, ienm, com);
                    return;
                }
                if (krawlx != mx && my != 0) {
                    return;
                }
                if (krawlx != mx && my != 0) {
-                   lookx = nextx + krawlx;
+                   lookx = next.x + krawlx;
                    krawlx = -krawlx;
                }
                else if (krawly != my && mx != 0) {
                    krawlx = -krawlx;
                }
                else if (krawly != my && mx != 0) {
-                   looky = nexty + krawly;
+                   looky = next.y + krawly;
                    krawly = -krawly;
                }
                else break; /* we have failed */
                    krawly = -krawly;
                }
                else break; /* we have failed */
@@ -233,39 +232,40 @@ static void movebaddy(int comx, int comy, int loccom, int ienm)
            else success = 1;
        }
        if (success) {
            else success = 1;
        }
        if (success) {
-           nextx = lookx;
-           nexty = looky;
+           next.x = lookx;
+           next.y = looky;
 #ifdef DEBUG
            if (game.idebug) {
 #ifdef DEBUG
            if (game.idebug) {
-               prout(cramlc(neither, nextx, nexty));
+               prout(cramlc(neither, next));
            }
 #endif
        }
        else break; /* done early */
     }
     /* Put commander in place within same quadrant */
            }
 #endif
        }
        else break; /* done early */
     }
     /* Put commander in place within same quadrant */
-    game.quad[comx][comy] = IHDOT;
-    game.quad[nextx][nexty] = ienm;
-    if (nextx != comx || nexty != comy) {
+    game.quad[com.x][com.y] = IHDOT;
+    game.quad[next.x][next.y] = ienm;
+    if (next.x != com.x || next.y != com.y) {
        /* it moved */
        /* it moved */
-       game.kx[loccom] = nextx;
-       game.ky[loccom] = nexty;
+       game.ks[loccom].x = next.x;
+       game.ks[loccom].y = next.y;
        game.kdist[loccom] = game.kavgd[loccom] =
        game.kdist[loccom] = game.kavgd[loccom] =
-           sqrt(square(game.sectx-nextx)+square(game.secty-nexty));
+           sqrt(square(game.sector.x-next.x)+square(game.sector.y-next.y));
        if (game.damage[DSRSENS] == 0 || game.condit == IHDOCKED) {
            proutn("***");
            cramen(ienm);
        if (game.damage[DSRSENS] == 0 || game.condit == IHDOCKED) {
            proutn("***");
            cramen(ienm);
-           proutn(_(" from %s"), cramlc(2, comx, comy));
+           proutn(_(" from %s"), cramlc(2, com));
            if (game.kdist[loccom] < dist1) proutn(_(" advances to "));
            else proutn(_(" retreats to "));
            if (game.kdist[loccom] < dist1) proutn(_(" advances to "));
            else proutn(_(" retreats to "));
-           prout(cramlc(sector, nextx, nexty));
+           prout(cramlc(sector, next));
        }
     }
 }
 
 void movcom(void) 
 {
        }
     }
 }
 
 void movcom(void) 
 {
-    int ix, iy, i;
+    coord w; 
+    int i;
 
 #ifdef DEBUG
     if (game.idebug) prout("MOVCOM");
 
 #ifdef DEBUG
     if (game.idebug) prout("MOVCOM");
@@ -275,19 +275,17 @@ void movcom(void)
        and do move */
     if (game.comhere) 
        for_local_enemies(i) {
        and do move */
     if (game.comhere) 
        for_local_enemies(i) {
-           ix = game.kx[i];
-           iy = game.ky[i];
-           if (game.quad[ix][iy] == IHC) {
-               movebaddy(ix, iy, i, IHC);
+           w = game.ks[i];
+           if (game.quad[w.x][w.y] == IHC) {
+               movebaddy(w, i, IHC);
                break;
            }
        }
     if (game.ishere) 
        for_local_enemies(i) {
                break;
            }
        }
     if (game.ishere) 
        for_local_enemies(i) {
-           ix = game.kx[i];
-           iy = game.ky[i];
-           if (game.quad[ix][iy] == IHS) {
-               movebaddy(ix, iy, i, IHS);
+           w = game.ks[i];
+           if (game.quad[w.x][w.y] == IHS) {
+               movebaddy(w, i, IHS);
                break;
            }
        }
                break;
            }
        }
@@ -296,35 +294,32 @@ void movcom(void)
        commander(s) do. */
     if (game.skill >= SKILL_EXPERT && (game.options & OPTION_MVBADDY)) 
        for_local_enemies(i) {
        commander(s) do. */
     if (game.skill >= SKILL_EXPERT && (game.options & OPTION_MVBADDY)) 
        for_local_enemies(i) {
-           ix = game.kx[i];
-           iy = game.ky[i];
-           if (game.quad[ix][iy] == IHK || game.quad[ix][iy] == IHR)
-               movebaddy(ix, iy, i, game.quad[ix][iy]);
+           w = game.ks[i];
+           if (game.quad[w.x][w.y] == IHK || game.quad[w.x][w.y] == IHR)
+               movebaddy(w, i, game.quad[w.x][w.y]);
        }
 
     sortkl();
 }
 
        }
 
     sortkl();
 }
 
-static int movescom(int iqx, int iqy, int flag, int *ipage) 
+static int movescom(coord iq, int flag, int *ipage) 
 {
     int i;
 
 {
     int i;
 
-    if ((iqx==game.quadx && iqy==game.quady) ||
-       !VALID_QUADRANT(iqx, iqy) ||
-       game.state.galaxy[iqx][iqy].supernova ||
-       game.state.galaxy[iqx][iqy].klingons > 8) 
+    if (same(iq, game.quadrant) || !VALID_QUADRANT(iq.x, iq.y) ||
+       game.state.galaxy[iq.x][iq.y].supernova ||
+       game.state.galaxy[iq.x][iq.y].klingons > 8) 
        return 1;
     if (flag) {
        /* Avoid quadrants with bases if we want to avoid Enterprise */
        for_starbases(i)
        return 1;
     if (flag) {
        /* Avoid quadrants with bases if we want to avoid Enterprise */
        for_starbases(i)
-           if (game.state.baseqx[i]==iqx && game.state.baseqy[i]==iqy) return 1;
+           if (game.state.baseq[i].x==iq.x && game.state.baseq[i].y==iq.y) return 1;
     }
     if (game.justin && !game.iscate) return 1;
     /* do the move */
     }
     if (game.justin && !game.iscate) return 1;
     /* do the move */
-    game.state.galaxy[game.state.isx][game.state.isy].klingons--;
-    game.state.isx = iqx;
-    game.state.isy = iqy;
-    game.state.galaxy[game.state.isx][game.state.isy].klingons++;
+    game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].klingons--;
+    game.state.kscmdr = iq;
+    game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].klingons++;
     if (game.ishere) {
        /* SC has scooted, Remove him from current quadrant */
        game.iscate=0;
     if (game.ishere) {
        /* SC has scooted, Remove him from current quadrant */
        game.iscate=0;
@@ -333,10 +328,9 @@ static int movescom(int iqx, int iqy, int flag, int *ipage)
        game.ientesc=0;
        unschedule(FSCDBAS);
        for_local_enemies(i) 
        game.ientesc=0;
        unschedule(FSCDBAS);
        for_local_enemies(i) 
-           if (game.quad[game.kx[i]][game.ky[i]] == IHS) break;
-       game.quad[game.kx[i]][game.ky[i]] = IHDOT;
-       game.kx[i] = game.kx[game.nenhere];
-       game.ky[i] = game.ky[game.nenhere];
+           if (game.quad[game.ks[i].x][game.ks[i].y] == IHS) break;
+       game.quad[game.ks[i].x][game.ks[i].y] = IHDOT;
+       game.ks[i] = game.ks[game.nenhere];
        game.kdist[i] = game.kdist[game.nenhere];
        game.kavgd[i] = game.kavgd[game.nenhere];
        game.kpower[i] = game.kpower[game.nenhere];
        game.kdist[i] = game.kdist[game.nenhere];
        game.kavgd[i] = game.kavgd[game.nenhere];
        game.kpower[i] = game.kpower[game.nenhere];
@@ -347,17 +341,17 @@ static int movescom(int iqx, int iqy, int flag, int *ipage)
     }
     /* check for a helpful planet */
     for (i = 0; i < game.inplan; i++) {
     }
     /* check for a helpful planet */
     for (i = 0; i < game.inplan; i++) {
-       if (game.state.plnets[i].x==game.state.isx && game.state.plnets[i].y==game.state.isy &&
+       if (game.state.plnets[i].w.x==game.state.kscmdr.x && game.state.plnets[i].w.y==game.state.kscmdr.y &&
            game.state.plnets[i].crystals == 1) {
            /* destroy the planet */
            DESTROY(&game.state.plnets[i]);
            game.state.plnets[i].crystals == 1) {
            /* destroy the planet */
            DESTROY(&game.state.plnets[i]);
-           game.state.galaxy[game.state.isx][game.state.isy].planet = NULL;
+           game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].planet = NULL;
            if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED) {
                if (*ipage==0) pause_game(1);
                *ipage = 1;
                prout(_("Lt. Uhura-  \"Captain, Starfleet Intelligence reports"));
                proutn(_("   a planet in "));
            if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED) {
                if (*ipage==0) pause_game(1);
                *ipage = 1;
                prout(_("Lt. Uhura-  \"Captain, Starfleet Intelligence reports"));
                proutn(_("   a planet in "));
-               proutn(cramlc(quadrant, game.state.isx, game.state.isy));
+               proutn(cramlc(quadrant, game.state.kscmdr));
                prout(_(" has been destroyed"));
                prout(_("   by the Super-commander.\""));
            }
                prout(_(" has been destroyed"));
                prout(_("   by the Super-commander.\""));
            }
@@ -369,8 +363,8 @@ static int movescom(int iqx, int iqy, int flag, int *ipage)
                        
 void scom(int *ipage)
 {
                        
 void scom(int *ipage)
 {
-    int i, i2, j, ideltax, ideltay, ibqx, ibqy, sx, sy, ifindit, iwhichb;
-    int iqx, iqy;
+    int i, i2, j, ideltax, ideltay, ifindit, iwhichb;
+    coord iq, sc, ibq;
     int basetbl[BASEMAX+1];
     double bdist[BASEMAX+1];
     int flag;
     int basetbl[BASEMAX+1];
     double bdist[BASEMAX+1];
     int flag;
@@ -383,12 +377,12 @@ void scom(int *ipage)
            (game.state.date-game.indate) < 3.0);
     if (game.iscate==0 && flag) {
        /* compute move away from Enterprise */
            (game.state.date-game.indate) < 3.0);
     if (game.iscate==0 && flag) {
        /* compute move away from Enterprise */
-       ideltax = game.state.isx-game.quadx;
-       ideltay = game.state.isy-game.quady;
+       ideltax = game.state.kscmdr.x-game.quadrant.x;
+       ideltay = game.state.kscmdr.y-game.quadrant.y;
        if (sqrt(ideltax*(double)ideltax+ideltay*(double)ideltay) > 2.0) {
            /* circulate in space */
        if (sqrt(ideltax*(double)ideltax+ideltay*(double)ideltay) > 2.0) {
            /* circulate in space */
-           ideltax = game.state.isy-game.quady;
-           ideltay = game.quadx-game.state.isx;
+           ideltax = game.state.kscmdr.y-game.quadrant.y;
+           ideltay = game.quadrant.x-game.state.kscmdr.x;
        }
     }
     else {
        }
     }
     else {
@@ -398,13 +392,12 @@ void scom(int *ipage)
            unschedule(FSCMOVE);
            return;
        }
            unschedule(FSCMOVE);
            return;
        }
-       sx = game.state.isx;
-       sy = game.state.isy;
+       sc = game.state.kscmdr;
        for_starbases(i) {
            basetbl[i] = i;
        for_starbases(i) {
            basetbl[i] = i;
-           ibqx = game.state.baseqx[i];
-           ibqy = game.state.baseqy[i];
-           bdist[i] = sqrt(square(ibqx-sx) + square(ibqy-sy));
+           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));
        }
        if (game.state.rembase > 1) {
            /* sort into nearest first order */
        }
        if (game.state.rembase > 1) {
            /* sort into nearest first order */
@@ -430,17 +423,17 @@ void scom(int *ipage)
 
        for_starbases(i2) {
            i = basetbl[i2];    /* bug in original had it not finding nearest*/
 
        for_starbases(i2) {
            i = basetbl[i2];    /* bug in original had it not finding nearest*/
-           ibqx = game.state.baseqx[i];
-           ibqy = game.state.baseqy[i];
-           if ((ibqx == game.quadx && ibqy == game.quady) ||
-               (ibqx == game.batx && ibqy == game.baty) ||
-               game.state.galaxy[ibqx][ibqy].supernova ||
-               game.state.galaxy[ibqx][ibqy].klingons > 8) 
+           ibq.x = game.state.baseq[i].x;
+           ibq.y = game.state.baseq[i].y;
+           if ((ibq.x == game.quadrant.x && ibq.y == game.quadrant.y) ||
+               (ibq.x == game.battle.x && ibq.y == game.battle.y) ||
+               game.state.galaxy[ibq.x][ibq.y].supernova ||
+               game.state.galaxy[ibq.x][ibq.y].klingons > 8) 
                continue;
            /* if there is a commander, an no other base is appropriate,
               we will take the one with the commander */
            for_commanders (j) {
                continue;
            /* if there is a commander, an no other base is appropriate,
               we will take the one with the commander */
            for_commanders (j) {
-               if (ibqx==game.state.cx[j] && ibqy==game.state.cy[j] && ifindit!= 2) {
+               if (ibq.x==game.state.kcmdr[j].x && ibq.y==game.state.kcmdr[j].y && ifindit!= 2) {
                    ifindit = 2;
                    iwhichb = i;
                    break;
                    ifindit = 2;
                    iwhichb = i;
                    break;
@@ -453,11 +446,11 @@ void scom(int *ipage)
            }
        }
        if (ifindit==0) return; /* Nothing suitable -- wait until next time*/
            }
        }
        if (ifindit==0) return; /* Nothing suitable -- wait until next time*/
-       ibqx = game.state.baseqx[iwhichb];
-       ibqy = game.state.baseqy[iwhichb];
+       ibq.x = game.state.baseq[iwhichb].x;
+       ibq.y = game.state.baseq[iwhichb].y;
        /* decide how to move toward base */
        /* decide how to move toward base */
-       ideltax = ibqx - game.state.isx;
-       ideltay = ibqy - game.state.isy;
+       ideltax = ibq.x - game.state.kscmdr.x;
+       ideltay = ibq.y - game.state.kscmdr.y;
     }
     /* Maximum movement is 1 quadrant in either or both axis */
     if (ideltax > 1) ideltax = 1;
     }
     /* Maximum movement is 1 quadrant in either or both axis */
     if (ideltax > 1) ideltax = 1;
@@ -466,34 +459,34 @@ void scom(int *ipage)
     if (ideltay < -1) ideltay = -1;
 
     /* try moving in both x and y directions */
     if (ideltay < -1) ideltay = -1;
 
     /* try moving in both x and y directions */
-    iqx = game.state.isx + ideltax;
-    iqy = game.state.isy + ideltax;
-    if (movescom(iqx, iqy, flag, ipage)) {
+    iq.x = game.state.kscmdr.x + ideltax;
+    iq.y = game.state.kscmdr.y + ideltax;
+    if (movescom(iq, flag, ipage)) {
        /* failed -- try some other maneuvers */
        if (ideltax==0 || ideltay==0) {
            /* attempt angle move */
            if (ideltax != 0) {
        /* failed -- try some other maneuvers */
        if (ideltax==0 || ideltay==0) {
            /* attempt angle move */
            if (ideltax != 0) {
-               iqy = game.state.isy + 1;
-               if (movescom(iqx, iqy, flag, ipage)) {
-                   iqy = game.state.isy - 1;
-                   movescom(iqx, iqy, flag, ipage);
+               iq.y = game.state.kscmdr.y + 1;
+               if (movescom(iq, flag, ipage)) {
+                   iq.y = game.state.kscmdr.y - 1;
+                   movescom(iq, flag, ipage);
                }
            }
            else {
                }
            }
            else {
-               iqx = game.state.isx + 1;
-               if (movescom(iqx, iqy, flag, ipage)) {
-                   iqx = game.state.isx - 1;
-                   movescom(iqx, iqy, flag, ipage);
+               iq.x = game.state.kscmdr.x + 1;
+               if (movescom(iq, flag, ipage)) {
+                   iq.x = game.state.kscmdr.x - 1;
+                   movescom(iq, flag, ipage);
                }
            }
        }
        else {
            /* try moving just in x or y */
                }
            }
        }
        else {
            /* try moving just in x or y */
-           iqy = game.state.isy;
-           if (movescom(iqx, iqy, flag, ipage)) {
-               iqy = game.state.isy + ideltay;
-               iqx = game.state.isx;
-               movescom(iqx, iqy, flag, ipage);
+           iq.y = game.state.kscmdr.y;
+           if (movescom(iq, flag, ipage)) {
+               iq.y = game.state.kscmdr.y + ideltay;
+               iq.x = game.state.kscmdr.x;
+               movescom(iq, flag, ipage);
            }
        }
     }
            }
        }
     }
@@ -502,9 +495,8 @@ void scom(int *ipage)
        unschedule(FSCMOVE);
     }
     else for_starbases(i) {
        unschedule(FSCMOVE);
     }
     else for_starbases(i) {
-       ibqx = game.state.baseqx[i];
-       ibqy = game.state.baseqy[i];
-       if (ibqx==game.state.isx && ibqy == game.state.isy && game.state.isx != game.batx && game.state.isy != game.baty) {
+       ibq = game.state.baseq[i];
+       if (same(ibq, game.state.kscmdr) && same(game.state.kscmdr, game.battle)) {
            /* attack the base */
            if (flag) return; /* no, don't attack base! */
            game.iseenit = 0;
            /* attack the base */
            if (flag) return; /* no, don't attack base! */
            game.iseenit = 0;
@@ -518,7 +510,7 @@ void scom(int *ipage)
            if (*ipage == 0)  pause_game(1);
            *ipage=1;
            proutn(_("Lt. Uhura-  \"Captain, the starbase in "));
            if (*ipage == 0)  pause_game(1);
            *ipage=1;
            proutn(_("Lt. Uhura-  \"Captain, the starbase in "));
-           proutn(cramlc(quadrant, game.state.isx, game.state.isy));
+           proutn(cramlc(quadrant, game.state.kscmdr));
            skip(1);
            prout(_("   reports that it is under attack from the Klingon Super-commander."));
            proutn(_("   It can survive until stardate %d.\""),
            skip(1);
            prout(_("   reports that it is under attack from the Klingon Super-commander."));
            proutn(_("   It can survive until stardate %d.\""),
@@ -538,33 +530,34 @@ void scom(int *ipage)
 #endif
        (Rand() > 0.2 ||
         (game.damage[DRADIO] > 0.0 && game.condit != IHDOCKED) ||
 #endif
        (Rand() > 0.2 ||
         (game.damage[DRADIO] > 0.0 && game.condit != IHDOCKED) ||
-        !game.state.galaxy[game.state.isx][game.state.isy].charted))
+        !game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].charted))
        return;
     if (*ipage==0) pause_game(1);
     *ipage = 1;
     prout(_("Lt. Uhura-  \"Captain, Starfleet Intelligence reports"));
     proutn(_("   the Super-commander is in "));
        return;
     if (*ipage==0) pause_game(1);
     *ipage = 1;
     prout(_("Lt. Uhura-  \"Captain, Starfleet Intelligence reports"));
     proutn(_("   the Super-commander is in "));
-    proutn(cramlc(quadrant, game.state.isx, game.state. isy));
+    proutn(cramlc(quadrant, game.state.kscmdr));
     prout(".\"");
     return;
 }
 
 void movetho(void)
 {
     prout(".\"");
     return;
 }
 
 void movetho(void)
 {
-    int idx, idy, im, i, dum, my;
+    int idx, idy, im, i;
+    coord dummy;
     /* Move the Tholian */
     if (game.ithere==0 || game.justin == 1) return;
 
     /* Move the Tholian */
     if (game.ithere==0 || game.justin == 1) return;
 
-    if (game.ithx == 1 && game.ithy == 1) {
+    if (game.tholian.x == 1 && game.tholian.y == 1) {
        idx = 1; idy = QUADSIZE;
     }
        idx = 1; idy = QUADSIZE;
     }
-    else if (game.ithx == 1 && game.ithy == QUADSIZE) {
+    else if (game.tholian.x == 1 && game.tholian.y == QUADSIZE) {
        idx = QUADSIZE; idy = QUADSIZE;
     }
        idx = QUADSIZE; idy = QUADSIZE;
     }
-    else if (game.ithx == QUADSIZE && game.ithy == QUADSIZE) {
+    else if (game.tholian.x == QUADSIZE && game.tholian.y == QUADSIZE) {
        idx = QUADSIZE; idy = 1;
     }
        idx = QUADSIZE; idy = 1;
     }
-    else if (game.ithx == QUADSIZE && game.ithy == 1) {
+    else if (game.tholian.x == QUADSIZE && game.tholian.y == 1) {
        idx = 1; idy = 1;
     }
     else {
        idx = 1; idy = 1;
     }
     else {
@@ -575,27 +568,27 @@ void movetho(void)
 
     /* Do nothing if we are blocked */
     if (game.quad[idx][idy]!= IHDOT && game.quad[idx][idy]!= IHWEB) return;
 
     /* Do nothing if we are blocked */
     if (game.quad[idx][idy]!= IHDOT && game.quad[idx][idy]!= IHWEB) return;
-    game.quad[game.ithx][game.ithy] = IHWEB;
+    game.quad[game.tholian.x][game.tholian.y] = IHWEB;
 
 
-    if (game.ithx != idx) {
+    if (game.tholian.x != idx) {
        /* move in x axis */
        /* move in x axis */
-       im = fabs((double)idx - game.ithx)/((double)idx - game.ithx);
-       while (game.ithx != idx) {
-           game.ithx += im;
-           if (game.quad[game.ithx][game.ithy]==IHDOT) game.quad[game.ithx][game.ithy] = IHWEB;
+       im = fabs((double)idx - game.tholian.x)/((double)idx - game.tholian.x);
+       while (game.tholian.x != idx) {
+           game.tholian.x += im;
+           if (game.quad[game.tholian.x][game.tholian.y]==IHDOT) game.quad[game.tholian.x][game.tholian.y] = IHWEB;
        }
     }
        }
     }
-    else if (game.ithy != idy) {
+    else if (game.tholian.y != idy) {
        /* move in y axis */
        /* move in y axis */
-       im = fabs((double)idy - game.ithy)/((double)idy - game.ithy);
-       while (game.ithy != idy) {
-           game.ithy += im;
-           if (game.quad[game.ithx][game.ithy]==IHDOT) game.quad[game.ithx][game.ithy] = IHWEB;
+       im = fabs((double)idy - game.tholian.y)/((double)idy - game.tholian.y);
+       while (game.tholian.y != idy) {
+           game.tholian.y += im;
+           if (game.quad[game.tholian.x][game.tholian.y]==IHDOT) game.quad[game.tholian.x][game.tholian.y] = IHWEB;
        }
     }
        }
     }
-    game.quad[game.ithx][game.ithy] = IHT;
-    game.kx[game.nenhere]=game.ithx;
-    game.ky[game.nenhere]=game.ithy;
+    game.quad[game.tholian.x][game.tholian.y] = IHT;
+    game.ks[game.nenhere].x=game.tholian.x;
+    game.ks[game.nenhere].y=game.tholian.y;
 
     /* check to see if all holes plugged */
     for_sectors(i) {
 
     /* check to see if all holes plugged */
     for_sectors(i) {
@@ -605,11 +598,11 @@ void movetho(void)
        if (game.quad[i][QUADSIZE]!=IHWEB && game.quad[i][QUADSIZE]!=IHT) return;
     }
     /* All plugged up -- Tholian splits */
        if (game.quad[i][QUADSIZE]!=IHWEB && game.quad[i][QUADSIZE]!=IHT) return;
     }
     /* All plugged up -- Tholian splits */
-    game.quad[game.ithx][game.ithy]=IHWEB;
-    dropin(IHBLANK, &dum, &my);
-    crmena(1,IHT, 2, game.ithx, game.ithy);
+    game.quad[game.tholian.x][game.tholian.y]=IHWEB;
+    dropin(IHBLANK, &dummy);
+    crmena(1,IHT, 2, game.tholian);
     prout(_(" completes web."));
     prout(_(" completes web."));
-    game.ithere = game.ithx = game.ithy = 0;
+    game.ithere = game.tholian.x = game.tholian.y = 0;
     game.nenhere--;
     return;
 }
     game.nenhere--;
     return;
 }
index b9b32fe74f0e7f8d3bf51f5209c049c84c936b23..01365f52fc5bf1b3f92590bd2c0602c6326c00b4 100644 (file)
@@ -129,7 +129,7 @@ void doshield(int i)
     }
 }
 
     }
 }
 
-void ram(int ibumpd, int ienm, int ix, int iy)
+void ram(int ibumpd, int ienm, coord w)
 {
     double type = 1.0, extradm;
     int icas, l;
 {
     double type = 1.0, extradm;
     int icas, l;
@@ -148,10 +148,10 @@ void ram(int ibumpd, int ienm, int ix, int iy)
     case IHQUEST: type = 4.0; break;
     }
     proutn(ibumpd ? _(" rammed by ") : _(" rams "));
     case IHQUEST: type = 4.0; break;
     }
     proutn(ibumpd ? _(" rammed by ") : _(" rams "));
-    crmena(0, ienm, 2, ix, iy);
+    crmena(0, ienm, 2, w);
     if (ibumpd) proutn(_(" (original position)"));
     skip(1);
     if (ibumpd) proutn(_(" (original position)"));
     skip(1);
-    deadkl(ix, iy, ienm, game.sectx, game.secty);
+    deadkl(w.x, w.y, ienm, game.sector.x, game.sector.y);
     proutn("***");
     crmshp();
     prout(_(" heavily damaged."));
     proutn("***");
     crmshp();
     prout(_(" heavily damaged."));
@@ -177,14 +177,16 @@ void ram(int ibumpd, int ienm, int ix, int iy)
 
 void torpedo(double course, double r, int inx, int iny, double *hit, int i, int n)
 {
 
 void torpedo(double course, double r, int inx, int iny, double *hit, int i, int n)
 {
-    int l, iquad=0, ix=0, iy=0, jx=0, jy=0, shoved=0, ll;
+    int l, iquad=0, jx=0, jy=0, shoved=0, ll;
        
     double ac=course + 0.25*r;
     double angle = (15.0-ac)*0.5235988;
     double bullseye = (15.0 - course)*0.5235988;
     double deltax=-sin(angle), deltay=cos(angle), x=inx, y=iny, bigger;
     double ang, temp, xx, yy, kp, h1;
        
     double ac=course + 0.25*r;
     double angle = (15.0-ac)*0.5235988;
     double bullseye = (15.0 - course)*0.5235988;
     double deltax=-sin(angle), deltay=cos(angle), x=inx, y=iny, bigger;
     double ang, temp, xx, yy, kp, h1;
+    coord w;
 
 
+    w.x = w.y = 0;
     bigger = fabs(deltax);
     if (fabs(deltay) > bigger) bigger = fabs(deltay);
     deltax /= bigger;
     bigger = fabs(deltax);
     if (fabs(deltay) > bigger) bigger = fabs(deltay);
     deltax /= bigger;
@@ -196,12 +198,12 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
     /* Loop to move a single torpedo */
     for (l=1; l <= 15; l++) {
        x += deltax;
     /* Loop to move a single torpedo */
     for (l=1; l <= 15; l++) {
        x += deltax;
-       ix = x + 0.5;
+       w.x = x + 0.5;
        y += deltay;
        y += deltay;
-       iy = y + 0.5;
-       if (!VALID_SECTOR(ix, iy)) break;
-       iquad=game.quad[ix][iy];
-       tracktorpedo(ix, iy, l, i, n, iquad);
+       w.y = y + 0.5;
+       if (!VALID_SECTOR(w.x, w.y)) break;
+       iquad=game.quad[w.x][w.y];
+       tracktorpedo(w.x, w.y, l, i, n, iquad);
        if (iquad==IHDOT) continue;
        /* hit something */
        setwnd(message_window);
        if (iquad==IHDOT) continue;
        /* hit something */
        setwnd(message_window);
@@ -214,7 +216,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
            crmshp();
            prout(".");
            *hit = 700.0 + 100.0*Rand() -
            crmshp();
            prout(".");
            *hit = 700.0 + 100.0*Rand() -
-               1000.0*sqrt(square(ix-inx)+square(iy-iny))*
+               1000.0*sqrt(square(w.x-inx)+square(w.y-iny))*
                fabs(sin(bullseye-angle));
            *hit = fabs(*hit);
            newcnd(); /* we're blown out of dock */
                fabs(sin(bullseye-angle));
            *hit = fabs(*hit);
            newcnd(); /* we're blown out of dock */
@@ -225,8 +227,8 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
            if (fabs(cos(ang)) > temp) temp = fabs(cos(ang));
            xx = -sin(ang)/temp;
            yy = cos(ang)/temp;
            if (fabs(cos(ang)) > temp) temp = fabs(cos(ang));
            xx = -sin(ang)/temp;
            yy = cos(ang)/temp;
-           jx=ix+xx+0.5;
-           jy=iy+yy+0.5;
+           jx=w.x+xx+0.5;
+           jy=w.y+yy+0.5;
            if (!VALID_SECTOR(jx, jy)) return;
            if (game.quad[jx][jy]==IHBLANK) {
                finish(FHOLE);
            if (!VALID_SECTOR(jx, jy)) return;
            if (game.quad[jx][jy]==IHBLANK) {
                finish(FHOLE);
@@ -236,8 +238,8 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
                /* can't move into object */
                return;
            }
                /* can't move into object */
                return;
            }
-           game.sectx = jx;
-           game.secty = jy;
+           game.sector.x = jx;
+           game.sector.y = jy;
            crmshp();
            shoved = 1;
            break;
            crmshp();
            shoved = 1;
            break;
@@ -245,7 +247,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
        case IHC: /* Hit a commander */
        case IHS:
            if (Rand() <= 0.05) {
        case IHC: /* Hit a commander */
        case IHS:
            if (Rand() <= 0.05) {
-               crmena(1, iquad, 2, ix, iy);
+               crmena(1, iquad, 2, w);
                prout(_(" uses anti-photon device;"));
                prout(_("   torpedo neutralized."));
                return;
                prout(_(" uses anti-photon device;"));
                prout(_("   torpedo neutralized."));
                return;
@@ -254,34 +256,34 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
        case IHK:
            /* find the enemy */
            for_local_enemies(ll)
        case IHK:
            /* find the enemy */
            for_local_enemies(ll)
-               if (ix==game.kx[ll] && iy==game.ky[ll]) break;
+               if (w.x==game.ks[ll].x && w.y==game.ks[ll].y) break;
            kp = fabs(game.kpower[ll]);
            h1 = 700.0 + 100.0*Rand() -
            kp = fabs(game.kpower[ll]);
            h1 = 700.0 + 100.0*Rand() -
-               1000.0*sqrt(square(ix-inx)+square(iy-iny))*
+               1000.0*sqrt(square(w.x-inx)+square(w.y-iny))*
                fabs(sin(bullseye-angle));
            h1 = fabs(h1);
            if (kp < h1) h1 = kp;
            game.kpower[ll] -= (game.kpower[ll]<0 ? -h1 : h1);
            if (game.kpower[ll] == 0) {
                fabs(sin(bullseye-angle));
            h1 = fabs(h1);
            if (kp < h1) h1 = kp;
            game.kpower[ll] -= (game.kpower[ll]<0 ? -h1 : h1);
            if (game.kpower[ll] == 0) {
-               deadkl(ix, iy, iquad, ix, iy);
+               deadkl(w.x, w.y, iquad, w.x, w.y);
                return;
            }
                return;
            }
-           crmena(1, iquad, 2, ix, iy);
+           crmena(1, iquad, 2, w);
            /* If enemy damaged but not destroyed, try to displace */
            ang = angle + 2.5*(Rand()-0.5);
            temp = fabs(sin(ang));
            if (fabs(cos(ang)) > temp) temp = fabs(cos(ang));
            xx = -sin(ang)/temp;
            yy = cos(ang)/temp;
            /* If enemy damaged but not destroyed, try to displace */
            ang = angle + 2.5*(Rand()-0.5);
            temp = fabs(sin(ang));
            if (fabs(cos(ang)) > temp) temp = fabs(cos(ang));
            xx = -sin(ang)/temp;
            yy = cos(ang)/temp;
-           jx=ix+xx+0.5;
-           jy=iy+yy+0.5;
+           jx=w.x+xx+0.5;
+           jy=w.y+yy+0.5;
            if (!VALID_SECTOR(jx, jy)) {
                prout(_(" damaged but not destroyed."));
                return;
            }
            if (game.quad[jx][jy]==IHBLANK) {
                prout(_(" buffeted into black hole."));
            if (!VALID_SECTOR(jx, jy)) {
                prout(_(" damaged but not destroyed."));
                return;
            }
            if (game.quad[jx][jy]==IHBLANK) {
                prout(_(" buffeted into black hole."));
-               deadkl(ix, iy, iquad, jx, jy);
+               deadkl(w.x, w.y, iquad, jx, jy);
                return;
            }
            if (game.quad[jx][jy]!=IHDOT) {
                return;
            }
            if (game.quad[jx][jy]!=IHDOT) {
@@ -290,37 +292,37 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
                return;
            }
            proutn(_(" damaged--"));
                return;
            }
            proutn(_(" damaged--"));
-           game.kx[ll] = jx;
-           game.ky[ll] = jy;
+           game.ks[ll].x = jx;
+           game.ks[ll].y = jy;
            shoved = 1;
            break;
        case IHB: /* Hit a base */
            skip(1);
            prout(_("***STARBASE DESTROYED.."));
            for_starbases(ll) {
            shoved = 1;
            break;
        case IHB: /* Hit a base */
            skip(1);
            prout(_("***STARBASE DESTROYED.."));
            for_starbases(ll) {
-               if (game.state.baseqx[ll]==game.quadx && game.state.baseqy[ll]==game.quady) {
-                   game.state.baseqx[ll]=game.state.baseqx[game.state.rembase];
-                   game.state.baseqy[ll]=game.state.baseqy[game.state.rembase];
+               if (game.state.baseq[ll].x==game.quadrant.x && game.state.baseq[ll].y==game.quadrant.y) {
+                   game.state.baseq[ll].x=game.state.baseq[game.state.rembase].x;
+                   game.state.baseq[ll].y=game.state.baseq[game.state.rembase].y;
                    break;
                }
            }
                    break;
                }
            }
-           game.quad[ix][iy]=IHDOT;
+           game.quad[w.x][w.y]=IHDOT;
            game.state.rembase--;
            game.state.rembase--;
-           game.basex=game.basey=0;
-           game.state.galaxy[game.quadx][game.quady].starbase--;
-           game.state.chart[game.quadx][game.quady].starbase--;
+           game.base.x=game.base.y=0;
+           game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase--;
+           game.state.chart[game.quadrant.x][game.quadrant.y].starbase--;
            game.state.basekl++;
            newcnd();
            return;
        case IHP: /* Hit a planet */
            game.state.basekl++;
            newcnd();
            return;
        case IHP: /* Hit a planet */
-           crmena(1, iquad, 2, ix, iy);
+           crmena(1, iquad, 2, w);
            prout(_(" destroyed."));
            game.state.nplankl++;
            prout(_(" destroyed."));
            game.state.nplankl++;
-           game.state.galaxy[game.quadx][game.quady].planet = NULL;
+           game.state.galaxy[game.quadrant.x][game.quadrant.y].planet = NULL;
            DESTROY(&game.state.plnets[game.iplnet]);
            game.iplnet = 0;
            DESTROY(&game.state.plnets[game.iplnet]);
            game.iplnet = 0;
-           game.plnetx = game.plnety = 0;
-           game.quad[ix][iy] = IHDOT;
+           game.plnet.x = game.plnet.y = 0;
+           game.quad[w.x][w.y] = IHDOT;
            if (game.landed==1) {
                /* captain perishes on planet */
                finish(FDPLANET);
            if (game.landed==1) {
                /* captain perishes on planet */
                finish(FDPLANET);
@@ -328,10 +330,10 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
            return;
        case IHSTAR: /* Hit a star */
            if (Rand() > 0.10) {
            return;
        case IHSTAR: /* Hit a star */
            if (Rand() > 0.10) {
-               nova(ix, iy);
+               nova(w.x, w.y);
                return;
            }
                return;
            }
-           crmena(1, IHSTAR, 2, ix, iy);
+           crmena(1, IHSTAR, 2, w);
            prout(_(" unaffected by photon blast."));
            return;
        case IHQUEST: /* Hit a thingy */
            prout(_(" unaffected by photon blast."));
            return;
        case IHQUEST: /* Hit a thingy */
@@ -344,7 +346,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
                proutn(_("Mr. Spock-"));
                prouts(_("  \"Fascinating!\""));
                skip(1);
                proutn(_("Mr. Spock-"));
                prouts(_("  \"Fascinating!\""));
                skip(1);
-               deadkl(ix, iy, iquad, ix, iy);
+               deadkl(w.x, w.y, iquad, w.x, w.y);
            } else {
                /*
                 * Stas Sergeev added the possibility that
            } else {
                /*
                 * Stas Sergeev added the possibility that
@@ -357,7 +359,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
            return;
        case IHBLANK: /* Black hole */
            skip(1);
            return;
        case IHBLANK: /* Black hole */
            skip(1);
-           crmena(1, IHBLANK, 2, ix, iy);
+           crmena(1, IHBLANK, 2, w);
            prout(_(" swallows torpedo."));
            return;
        case IHWEB: /* hit the web */
            prout(_(" swallows torpedo."));
            return;
        case IHWEB: /* hit the web */
@@ -366,36 +368,36 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
            return;
        case IHT:  /* Hit a Tholian */
            h1 = 700.0 + 100.0*Rand() -
            return;
        case IHT:  /* Hit a Tholian */
            h1 = 700.0 + 100.0*Rand() -
-               1000.0*sqrt(square(ix-inx)+square(iy-iny))*
+               1000.0*sqrt(square(w.x-inx)+square(w.y-iny))*
                fabs(sin(bullseye-angle));
            h1 = fabs(h1);
            if (h1 >= 600) {
                fabs(sin(bullseye-angle));
            h1 = fabs(h1);
            if (h1 >= 600) {
-               game.quad[ix][iy] = IHDOT;
+               game.quad[w.x][w.y] = IHDOT;
                game.ithere = 0;
                game.ithere = 0;
-               game.ithx = game.ithy = 0;
-               deadkl(ix, iy, iquad, ix, iy);
+               game.tholian.x = game.tholian.y = 0;
+               deadkl(w.x, w.y, iquad, w.x, w.y);
                return;
            }
            skip(1);
                return;
            }
            skip(1);
-           crmena(1, IHT, 2, ix, iy);
+           crmena(1, IHT, 2, w);
            if (Rand() > 0.05) {
                prout(_(" survives photon blast."));
                return;
            }
            prout(_(" disappears."));
            if (Rand() > 0.05) {
                prout(_(" survives photon blast."));
                return;
            }
            prout(_(" disappears."));
-           game.quad[ix][iy] = IHWEB;
-           game.ithere = game.ithx = game.ithy = 0;
+           game.quad[w.x][w.y] = IHWEB;
+           game.ithere = game.tholian.x = game.tholian.y = 0;
            game.nenhere--;
            {
            game.nenhere--;
            {
-               int dum, my;
-               dropin(IHBLANK, &dum, &my);
+               coord dummy;
+               dropin(IHBLANK, &dummy);
            }
            return;
                                        
        default: /* Problem! */
            skip(1);
            proutn("Don't know how to handle collision with ");
            }
            return;
                                        
        default: /* Problem! */
            skip(1);
            proutn("Don't know how to handle collision with ");
-           crmena(1, iquad, 2, ix, iy);
+           crmena(1, iquad, 2, w);
            skip(1);
            return;
        }
            skip(1);
            return;
        }
@@ -405,11 +407,13 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
        setwnd(message_window);
     }
     if (shoved) {
        setwnd(message_window);
     }
     if (shoved) {
+       coord w;
+       w.x = jx; w.y = jy;
        game.quad[jx][jy]=iquad;
        game.quad[jx][jy]=iquad;
-       game.quad[ix][iy]=IHDOT;
-       prout(_(" displaced by blast to %s "), cramlc(sector, jx, jy));
+       game.quad[w.x][w.y]=IHDOT;
+       prout(_(" displaced by blast to %s "), cramlc(sector, w));
        for_local_enemies(ll)
        for_local_enemies(ll)
-           game.kdist[ll] = game.kavgd[ll] = sqrt(square(game.sectx-game.kx[ll])+square(game.secty-game.ky[ll]));
+           game.kdist[ll] = game.kavgd[ll] = sqrt(square(game.sector.x-game.ks[ll].x)+square(game.sector.y-game.ks[ll].y));
        sortkl();
        return;
     }
        sortkl();
        return;
     }
@@ -457,10 +461,11 @@ static void fry(double hit)
 void attack(int torps_ok) 
 {
     /* torps_ok == 0 forces use of phasers in an attack */
 void attack(int torps_ok) 
 {
     /* torps_ok == 0 forces use of phasers in an attack */
-    int percent, ihurt=0, l, i=0, jx, jy, iquad, itflag;
+    int percent, ihurt=0, l, i=0, iquad, itflag;
     int atackd = 0, attempt = 0;
     double hit;
     double pfac, dustfac, hitmax=0.0, hittot=0.0, chgfac=1.0, r;
     int atackd = 0, attempt = 0;
     double hit;
     double pfac, dustfac, hitmax=0.0, hittot=0.0, chgfac=1.0, r;
+    coord jay;
 
     game.iattak = 1;
     if (game.alldone) return;
 
     game.iattak = 1;
     if (game.alldone) return;
@@ -487,9 +492,9 @@ void attack(int torps_ok)
        /* Increase chance of photon torpedos if docked or enemy energy low */
        if (game.condit == IHDOCKED) r *= 0.25;
        if (game.kpower[l] < 500) r *= 0.25; 
        /* Increase chance of photon torpedos if docked or enemy energy low */
        if (game.condit == IHDOCKED) r *= 0.25;
        if (game.kpower[l] < 500) r *= 0.25; 
-       jx = game.kx[l];
-       jy = game.ky[l];
-       iquad = game.quad[jx][jy];
+       jay.x = game.ks[l].x;
+       jay.y = game.ks[l].y;
+       iquad = game.quad[jay.x][jay.y];
        if (iquad==IHT || (iquad==IHQUEST && !iqengry)) continue;
        itflag = (iquad == IHK && r > 0.0005) || !torps_ok ||
            (iquad==IHC && r > 0.015) ||
        if (iquad==IHT || (iquad==IHQUEST && !iqengry)) continue;
        itflag = (iquad == IHK && r > 0.0005) || !torps_ok ||
            (iquad==IHC && r > 0.015) ||
@@ -505,21 +510,21 @@ void attack(int torps_ok)
            game.kpower[l] *= 0.75;
        }
        else { /* Enemy used photon torpedo */
            game.kpower[l] *= 0.75;
        }
        else { /* Enemy used photon torpedo */
-           double course = 1.90985*atan2((double)game.secty-jy, (double)jx-game.sectx);
+           double course = 1.90985*atan2((double)game.sector.y-jay.y, (double)jay.x-game.sector.x);
            hit = 0;
            proutn(_("***TORPEDO INCOMING"));
            if (game.damage[DSRSENS] <= 0.0) {
                proutn(_(" From "));
            hit = 0;
            proutn(_("***TORPEDO INCOMING"));
            if (game.damage[DSRSENS] <= 0.0) {
                proutn(_(" From "));
-               crmena(0, iquad, i, jx, jy);
+               crmena(0, iquad, i, jay);
            }
            attempt = 1;
            prout("  ");
            r = (Rand()+Rand())*0.5 -0.5;
            r += 0.002*game.kpower[l]*r;
            }
            attempt = 1;
            prout("  ");
            r = (Rand()+Rand())*0.5 -0.5;
            r += 0.002*game.kpower[l]*r;
-           torpedo(course, r, jx, jy, &hit, 1, 1);
+           torpedo(course, r, jay.x, jay.y, &hit, 1, 1);
            if (KLINGREM==0) 
                finish(FWON); /* Klingons did themselves in! */
            if (KLINGREM==0) 
                finish(FWON); /* Klingons did themselves in! */
-           if (game.state.galaxy[game.quadx][game.quady].supernova || game.alldone) 
+           if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova || game.alldone) 
                return; /* Supernova or finished */
            if (hit == 0) continue;
        }
                return; /* Supernova or finished */
            if (hit == 0) continue;
        }
@@ -539,7 +544,7 @@ void attack(int torps_ok)
        /* It's a hit -- print out hit size */
        atackd = 1; /* We weren't going to check casualties, etc. if
                       shields were down for some strange reason. This
        /* It's a hit -- print out hit size */
        atackd = 1; /* We weren't going to check casualties, etc. if
                       shields were down for some strange reason. This
-                      doesn't make any sense, so I've fixed it */
+                      doesn't make any sense, so I've fw.xed it */
        ihurt = 1;
        proutn(_("%d unit hit"), (int)hit);
        if ((game.damage[DSRSENS] > 0 && itflag) || game.skill<=SKILL_FAIR) {
        ihurt = 1;
        proutn(_("%d unit hit"), (int)hit);
        if ((game.damage[DSRSENS] > 0 && itflag) || game.skill<=SKILL_FAIR) {
@@ -548,7 +553,7 @@ void attack(int torps_ok)
        }
        if (game.damage[DSRSENS] <= 0.0 && itflag) {
            proutn(_(" from "));
        }
        if (game.damage[DSRSENS] <= 0.0 && itflag) {
            proutn(_(" from "));
-           crmena(0, iquad, i, jx, jy);
+           crmena(0, iquad, i, jay);
        }
        skip(1);
        /* Decide if hit is critical */
        }
        skip(1);
        /* Decide if hit is critical */
@@ -601,15 +606,16 @@ void attack(int torps_ok)
 void deadkl(int ix, int iy, int type, int ixx, int iyy) 
 {
     /* Added ixx and iyy allow enemy to "move" before dying */
 void deadkl(int ix, int iy, int type, int ixx, int iyy) 
 {
     /* Added ixx and iyy allow enemy to "move" before dying */
-
+    coord mv;
     int i,j;
 
     int i,j;
 
+    mv.x = ixx; mv.y = iyy;
     skip(1);
     skip(1);
-    crmena(1, type, 2, ixx, iyy);
+    crmena(1, type, 2, mv);
     /* Decide what kind of enemy it is and update approriately */
     if (type == IHR) {
        /* chalk up a Romulan */
     /* Decide what kind of enemy it is and update approriately */
     if (type == IHR) {
        /* chalk up a Romulan */
-       game.state.galaxy[game.quadx][game.quady].romulans--;
+       game.state.galaxy[game.quadrant.x][game.quadrant.y].romulans--;
        game.irhere--;
        game.state.nromrem--;
     }
        game.irhere--;
        game.state.nromrem--;
     }
@@ -619,21 +625,20 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy)
     }
     else if (type == IHQUEST) {
        /* Killed a Thingy */
     }
     else if (type == IHQUEST) {
        /* Killed a Thingy */
-       iqhere=iqengry=thingx=thingy=0;
+       iqhere=iqengry=thing.x=thing.y=0;
     }
     else {
        /* Some type of a Klingon */
     }
     else {
        /* Some type of a Klingon */
-       game.state.galaxy[game.quadx][game.quady].klingons--;
+       game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons--;
        game.klhere--;
        switch (type) {
        case IHC:
            game.comhere = 0;
            for_commanders (i)
        game.klhere--;
        switch (type) {
        case IHC:
            game.comhere = 0;
            for_commanders (i)
-               if (game.state.cx[i]==game.quadx && game.state.cy[i]==game.quady) break;
-           game.state.cx[i] = game.state.cx[game.state.remcom];
-           game.state.cy[i] = game.state.cy[game.state.remcom];
-           game.state.cx[game.state.remcom] = 0;
-           game.state.cy[game.state.remcom] = 0;
+               if (game.state.kcmdr[i].x==game.quadrant.x && game.state.kcmdr[i].y==game.quadrant.y) break;
+           game.state.kcmdr[i] = game.state.kcmdr[game.state.remcom];
+           game.state.kcmdr[game.state.remcom].x = 0;
+           game.state.kcmdr[game.state.remcom].y = 0;
            game.state.remcom--;
            unschedule(FTBEAM);
            if (game.state.remcom != 0)
            game.state.remcom--;
            unschedule(FTBEAM);
            if (game.state.remcom != 0)
@@ -644,7 +649,7 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy)
            break;
        case IHS:
            game.state.nscrem--;
            break;
        case IHS:
            game.state.nscrem--;
-           game.ishere = game.state.isx = game.state.isy = game.isatb = game.iscate = 0;
+           game.ishere = game.state.kscmdr.x = game.state.kscmdr.y = game.isatb = game.iscate = 0;
            unschedule(FSCMOVE);
            unschedule(FSCDBAS);
            break;
            unschedule(FSCMOVE);
            unschedule(FSCDBAS);
            break;
@@ -659,21 +664,20 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy)
     game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom);
 
     /* Remove enemy ship from arrays describing local game.conditions */
     game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom);
 
     /* Remove enemy ship from arrays describing local game.conditions */
-    if (is_scheduled(FCDBAS) && game.batx==game.quadx && game.baty==game.quady && type==IHC)
+    if (is_scheduled(FCDBAS) && game.battle.x==game.quadrant.x && game.battle.y==game.quadrant.y && type==IHC)
        unschedule(FCDBAS);
     for_local_enemies(i)
        unschedule(FCDBAS);
     for_local_enemies(i)
-       if (game.kx[i]==ix && game.ky[i]==iy) break;
+       if (game.ks[i].x==ix && game.ks[i].y==iy) break;
     game.nenhere--;
     if (i <= game.nenhere)  {
        for (j=i; j<=game.nenhere; j++) {
     game.nenhere--;
     if (i <= game.nenhere)  {
        for (j=i; j<=game.nenhere; j++) {
-           game.kx[j] = game.kx[j+1];
-           game.ky[j] = game.ky[j+1];
+           game.ks[j] = game.ks[j+1];
            game.kpower[j] = game.kpower[j+1];
            game.kavgd[j] = game.kdist[j] = game.kdist[j+1];
        }
     }
            game.kpower[j] = game.kpower[j+1];
            game.kavgd[j] = game.kdist[j] = game.kdist[j+1];
        }
     }
-    game.kx[game.nenhere+1] = 0;
-    game.ky[game.nenhere+1] = 0;
+    game.ks[game.nenhere+1].x = 0;
+    game.ks[game.nenhere+1].x = 0;
     game.kdist[game.nenhere+1] = 0;
     game.kavgd[game.nenhere+1] = 0;
     game.kpower[game.nenhere+1] = 0;
     game.kdist[game.nenhere+1] = 0;
     game.kavgd[game.nenhere+1] = 0;
     game.kpower[game.nenhere+1] = 0;
@@ -688,8 +692,8 @@ static int targetcheck(double x, double y, double *course)
        huh();
        return 1;
     }
        huh();
        return 1;
     }
-    deltx = 0.1*(y - game.secty);
-    delty = 0.1*(game.sectx - x);
+    deltx = 0.1*(y - game.sector.y);
+    delty = 0.1*(game.sector.x - x);
     if (deltx==0 && delty== 0) {
        skip(1);
        prout(_("Spock-  \"Bridge to sickbay.  Dr. McCoy,"));
     if (deltx==0 && delty== 0) {
        skip(1);
        prout(_("Spock-  \"Bridge to sickbay.  Dr. McCoy,"));
@@ -822,8 +826,8 @@ void photon(void)
        }
        if (game.shldup || game.condit == IHDOCKED) 
            r *= 1.0 + 0.0001*game.shield;
        }
        if (game.shldup || game.condit == IHDOCKED) 
            r *= 1.0 + 0.0001*game.shield;
-       torpedo(course[i], r, game.sectx, game.secty, &dummy, i, n);
-       if (game.alldone || game.state.galaxy[game.quadx][game.quady].supernova)
+       torpedo(course[i], r, game.sector.x, game.sector.y, &dummy, i, n);
+       if (game.alldone || game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova)
            return;
     }
     if (KLINGREM==0) finish(FWON);
            return;
     }
     if (KLINGREM==0) finish(FWON);
@@ -1071,8 +1075,8 @@ void phasers(void)
     case MANUAL:
        rpow = 0.0;
        for (k = 1; k <= game.nenhere;) {
     case MANUAL:
        rpow = 0.0;
        for (k = 1; k <= game.nenhere;) {
-           int ii = game.kx[k], jj = game.ky[k];
-           int ienm = game.quad[ii][jj];
+           coord aim = game.ks[k];
+           int ienm = game.quad[aim.x][aim.y];
            if (msgflag) {
                proutn(_("Energy available= %.2f"),
                       game.energy-.006-(ifast?200:0));
            if (msgflag) {
                proutn(_("Energy available= %.2f"),
                       game.energy-.006-(ifast?200:0));
@@ -1080,7 +1084,7 @@ void phasers(void)
                msgflag = 0;
                rpow = 0.0;
            }
                msgflag = 0;
                rpow = 0.0;
            }
-           if (game.damage[DSRSENS] && !(abs(game.sectx-ii) < 2 && abs(game.secty-jj) < 2) &&
+           if (game.damage[DSRSENS] && !(abs(game.sector.x-aim.x) < 2 && abs(game.sector.y-aim.y) < 2) &&
                (ienm == IHC || ienm == IHS)) {
                cramen(ienm);
                prout(_(" can't be located without short range scan."));
                (ienm == IHC || ienm == IHS)) {
                cramen(ienm);
                prout(_(" can't be located without short range scan."));
@@ -1101,7 +1105,7 @@ void phasers(void)
                else proutn("??");
                proutn(")  ");
                proutn(_("units to fire at "));
                else proutn("??");
                proutn(")  ");
                proutn(_("units to fire at "));
-               crmena(0, ienm, 2, ii, jj);
+               crmena(0, ienm, 2, aim);
                proutn("-  ");
                key = scan();
            }
                proutn("-  ");
                key = scan();
            }
@@ -1179,7 +1183,8 @@ void phasers(void)
 void hittem(double *hits) 
 {
     double kp, kpow, wham, hit, dustfac, kpini;
 void hittem(double *hits) 
 {
     double kp, kpow, wham, hit, dustfac, kpini;
-    int nenhr2=game.nenhere, k=1, kk=1, ii, jj, ienm;
+    int nenhr2=game.nenhere, k=1, kk=1, ienm;
+    coord w;
 
     skip(1);
 
 
     skip(1);
 
@@ -1192,21 +1197,20 @@ void hittem(double *hits)
        if (PHASEFAC*hit < kp) kp = PHASEFAC*hit;
        game.kpower[kk] -= (game.kpower[kk] < 0 ? -kp: kp);
        kpow = game.kpower[kk];
        if (PHASEFAC*hit < kp) kp = PHASEFAC*hit;
        game.kpower[kk] -= (game.kpower[kk] < 0 ? -kp: kp);
        kpow = game.kpower[kk];
-       ii = game.kx[kk];
-       jj = game.ky[kk];
+       w = game.ks[kk];
        if (hit > 0.005) {
            if (game.damage[DSRSENS]==0)
        if (hit > 0.005) {
            if (game.damage[DSRSENS]==0)
-               boom(ii, jj);
+               boom(w.x, w.y);
            proutn(_("%d unit hit on "), (int)hit);
        }
        else
            proutn(_("Very small hit on "));
            proutn(_("%d unit hit on "), (int)hit);
        }
        else
            proutn(_("Very small hit on "));
-       ienm = game.quad[ii][jj];
+       ienm = game.quad[w.x][w.y];
        if (ienm==IHQUEST) iqengry=1;
        if (ienm==IHQUEST) iqengry=1;
-       crmena(0,ienm,2,ii,jj);
+       crmena(0,ienm,2,w);
        skip(1);
        if (kpow == 0) {
        skip(1);
        if (kpow == 0) {
-           deadkl(ii, jj, ienm, ii, jj);
+           deadkl(w.x, w.y, ienm, w.x, w.y);
            if (KLINGREM==0) finish(FWON);
            if (game.alldone) return;
            kk--; /* don't do the increment */
            if (KLINGREM==0) finish(FWON);
            if (game.alldone) return;
            kk--; /* don't do the increment */
@@ -1215,7 +1219,7 @@ void hittem(double *hits)
            if (kpow > 0 && Rand() >= 0.9 &&
                kpow <= ((0.4 + 0.4*Rand())*kpini)) {
                prout(_("***Mr. Spock-  \"Captain, the vessel at "),
            if (kpow > 0 && Rand() >= 0.9 &&
                kpow <= ((0.4 + 0.4*Rand())*kpini)) {
                prout(_("***Mr. Spock-  \"Captain, the vessel at "),
-                     cramlc(sector,ii,jj));
+                     cramlc(sector, w));
                prout(_("   has just lost its firepower.\""));
                game.kpower[kk] = -kpow;
            }
                prout(_("   has just lost its firepower.\""));
                game.kpower[kk] = -kpow;
            }
index 7b915f22e28f45b3119f74d3c6c0013da5b74ed6..f5aed2e75f49039b022da27260cdf7de82bdde7a 100644 (file)
@@ -99,7 +99,7 @@ void events(void)
            ipage=1;
            snova(0,0);
            schedule(FSNOVA, expran(0.5*game.intime));
            ipage=1;
            snova(0,0);
            schedule(FSNOVA, expran(0.5*game.intime));
-           if (game.state.galaxy[game.quadx][game.quady].supernova) return;
+           if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) return;
            break;
        case FSPY: /* Check with spy to see if S.C. should tractor beam */
            if (game.state.nscrem == 0 ||
            break;
        case FSPY: /* Check with spy to see if S.C. should tractor beam */
            if (game.state.nscrem == 0 ||
@@ -113,7 +113,7 @@ void events(void)
                 (game.torps < 5 || game.damage[DPHOTON] > 0))) {
                /* Tractor-beam her! */
                istract=1;
                 (game.torps < 5 || game.damage[DPHOTON] > 0))) {
                /* Tractor-beam her! */
                istract=1;
-               yank = square(game.state.isx-game.quadx) + square(game.state.isy-game.quady);
+               yank = square(game.state.kscmdr.x-game.quadrant.x) + square(game.state.kscmdr.y-game.quadrant.y);
                /********* fall through to FTBEAM code ***********/
            }
            else return;
                /********* fall through to FTBEAM code ***********/
            }
            else return;
@@ -124,7 +124,7 @@ void events(void)
                    break;
                }
                i = Rand()*game.state.remcom+1.0;
                    break;
                }
                i = Rand()*game.state.remcom+1.0;
-               yank = square(game.state.cx[i]-game.quadx) + square(game.state.cy[i]-game.quady);
+               yank = square(game.state.kcmdr[i].x-game.quadrant.x) + square(game.state.kcmdr[i].y-game.quadrant.y);
                if (istract || game.condit == IHDOCKED || yank == 0) {
                    /* Drats! Have to reschedule */
                    schedule(FTBEAM, 
                if (istract || game.condit == IHDOCKED || yank == 0) {
                    /* Drats! Have to reschedule */
                    schedule(FTBEAM, 
@@ -163,19 +163,19 @@ void events(void)
                }
            }
            if (line==0) {
                }
            }
            if (line==0) {
-               game.quadx = game.state.isx;
-               game.quady = game.state.isy;
+               game.quadrant.x = game.state.kscmdr.x;
+               game.quadrant.y = game.state.kscmdr.y;
            }
            else {
            }
            else {
-               game.quadx = game.state.cx[i];
-               game.quady = game.state.cy[i];
+               game.quadrant.x = game.state.kcmdr[i].x;
+               game.quadrant.y = game.state.kcmdr[i].y;
            }
            }
-           iran(QUADSIZE, &game.sectx, &game.secty);
+           iran(QUADSIZE, &game.sector.x, &game.sector.y);
            crmshp();
            proutn(_(" is pulled to "));
            crmshp();
            proutn(_(" is pulled to "));
-           proutn(cramlc(quadrant, game.quadx, game.quady));
+           proutn(cramlc(quadrant, game.quadrant));
            proutn(", ");
            proutn(", ");
-           prout(cramlc(sector, game.sectx, game.secty));
+           prout(cramlc(sector, game.sector));
            if (game.resting) {
                prout(_("(Remainder of rest/repair period cancelled.)"));
                game.resting = 0;
            if (game.resting) {
                prout(_("(Remainder of rest/repair period cancelled.)"));
                game.resting = 0;
@@ -209,9 +209,9 @@ void events(void)
            i = 0;
            for_starbases(j) {
                for_commanders(k)
            i = 0;
            for_starbases(j) {
                for_commanders(k)
-                   if (game.state.baseqx[j]==game.state.cx[k] && game.state.baseqy[j]==game.state.cy[k] &&
-                       (game.state.baseqx[j]!=game.quadx || game.state.baseqy[j]!=game.quady) &&
-                       (game.state.baseqx[j]!=game.state.isx || game.state.baseqy[j]!=game.state.isy)) {
+                   if (game.state.baseq[j].x==game.state.kcmdr[k].x && game.state.baseq[j].y==game.state.kcmdr[k].y &&
+                       (game.state.baseq[j].x!=game.quadrant.x || game.state.baseq[j].y!=game.quadrant.y) &&
+                       (game.state.baseq[j].x!=game.state.kscmdr.x || game.state.baseq[j].y!=game.state.kscmdr.y)) {
                        i = 1;
                        break;
                    }
                        i = 1;
                        break;
                    }
@@ -224,8 +224,8 @@ void events(void)
                break;
            }
            /* commander + starbase combination found -- launch attack */
                break;
            }
            /* commander + starbase combination found -- launch attack */
-           game.batx = game.state.baseqx[j];
-           game.baty = game.state.baseqy[j];
+           game.battle.x = game.state.baseq[j].x;
+           game.battle.y = game.state.baseq[j].y;
            schedule(FCDBAS, 1.0+3.0*Rand());
            if (game.isatb) /* extra time if SC already attacking */
                postpone(FCDBAS, scheduled(FSCDBAS)-game.state.date);
            schedule(FCDBAS, 1.0+3.0*Rand());
            if (game.isatb) /* extra time if SC already attacking */
                postpone(FCDBAS, scheduled(FSCDBAS)-game.state.date);
@@ -238,7 +238,7 @@ void events(void)
            ipage = 1;
            skip(1);
            proutn(_("Lt. Uhura-  \"Captain, the starbase in "));
            ipage = 1;
            skip(1);
            proutn(_("Lt. Uhura-  \"Captain, the starbase in "));
-           prout(cramlc(quadrant, game.batx, game.baty));
+           prout(cramlc(quadrant, game.battle));
            prout(_("   reports that it is under attack and that it can"));
            proutn(_("   hold out only until stardate %d"),
                   (int)scheduled(FCDBAS));
            prout(_("   reports that it is under attack and that it can"));
            proutn(_("   hold out only until stardate %d"),
                   (int)scheduled(FCDBAS));
@@ -256,33 +256,33 @@ void events(void)
        case FSCDBAS: /* Supercommander destroys base */
            unschedule(FSCDBAS);
            game.isatb = 2;
        case FSCDBAS: /* Supercommander destroys base */
            unschedule(FSCDBAS);
            game.isatb = 2;
-           if (!game.state.galaxy[game.state.isx][game.state.isy].starbase) 
+           if (!game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].starbase) 
                break; /* WAS RETURN! */
                break; /* WAS RETURN! */
-           ixhold = game.batx;
-           iyhold = game.baty;
-           game.batx = game.state.isx;
-           game.baty = game.state.isy;
+           ixhold = game.battle.x;
+           iyhold = game.battle.y;
+           game.battle.x = game.state.kscmdr.x;
+           game.battle.y = game.state.kscmdr.y;
        case FCDBAS: /* Commander succeeds in destroying base */
            if (line==FCDBAS) {
                unschedule(FCDBAS);
                /* find the lucky pair */
                for_commanders(i)
        case FCDBAS: /* Commander succeeds in destroying base */
            if (line==FCDBAS) {
                unschedule(FCDBAS);
                /* find the lucky pair */
                for_commanders(i)
-                   if (game.state.cx[i]==game.batx && game.state.cy[i]==game.baty) 
+                   if (game.state.kcmdr[i].x==game.battle.x && game.state.kcmdr[i].y==game.battle.y) 
                        break;
                if (i > game.state.remcom || game.state.rembase == 0 ||
                        break;
                if (i > game.state.remcom || game.state.rembase == 0 ||
-                   !game.state.galaxy[game.batx][game.baty].starbase) {
+                   !game.state.galaxy[game.battle.x][game.battle.y].starbase) {
                    /* No action to take after all */
                    /* No action to take after all */
-                   game.batx = game.baty = 0;
+                   game.battle.x = game.battle.y = 0;
                    break;
                }
            }
            /* Code merges here for any commander destroying base */
            /* Not perfect, but will have to do */
            /* Handle case where base is in same quadrant as starship */
                    break;
                }
            }
            /* Code merges here for any commander destroying base */
            /* Not perfect, but will have to do */
            /* Handle case where base is in same quadrant as starship */
-           if (game.batx==game.quadx && game.baty==game.quady) {
-               game.state.chart[game.batx][game.baty].starbase = FALSE;
-               game.quad[game.basex][game.basey]= IHDOT;
-               game.basex=game.basey=0;
+           if (game.battle.x==game.quadrant.x && game.battle.y==game.quadrant.y) {
+               game.state.chart[game.battle.x][game.battle.y].starbase = FALSE;
+               game.quad[game.base.x][game.base.y]= IHDOT;
+               game.base.x=game.base.y=0;
                newcnd();
                skip(1);
                prout(_("Spock-  \"Captain, I believe the starbase has been destroyed.\""));
                newcnd();
                skip(1);
                prout(_("Spock-  \"Captain, I believe the starbase has been destroyed.\""));
@@ -295,28 +295,28 @@ void events(void)
                skip(1);
                prout(_("Lt. Uhura-  \"Captain, Starfleet Command reports that"));
                proutn(_("   the starbase in "));
                skip(1);
                prout(_("Lt. Uhura-  \"Captain, Starfleet Command reports that"));
                proutn(_("   the starbase in "));
-               proutn(cramlc(quadrant, game.batx, game.baty));
+               proutn(cramlc(quadrant, game.battle));
                prout(_(" has been destroyed by"));
                if (game.isatb==2) prout(_("the Klingon Super-Commander"));
                else prout(_("a Klingon Commander"));
                prout(_(" has been destroyed by"));
                if (game.isatb==2) prout(_("the Klingon Super-Commander"));
                else prout(_("a Klingon Commander"));
-               game.state.chart[game.batx][game.baty].starbase = FALSE;
+               game.state.chart[game.battle.x][game.battle.y].starbase = FALSE;
            }
            /* Remove Starbase from galaxy */
            }
            /* Remove Starbase from galaxy */
-           game.state.galaxy[game.batx][game.baty].starbase = FALSE;
+           game.state.galaxy[game.battle.x][game.battle.y].starbase = FALSE;
            for_starbases(i)
            for_starbases(i)
-               if (game.state.baseqx[i]==game.batx && game.state.baseqy[i]==game.baty) {
-                   game.state.baseqx[i]=game.state.baseqx[game.state.rembase];
-                   game.state.baseqy[i]=game.state.baseqy[game.state.rembase];
+               if (game.state.baseq[i].x==game.battle.x && game.state.baseq[i].y==game.battle.y) {
+                   game.state.baseq[i].x=game.state.baseq[game.state.rembase].x;
+                   game.state.baseq[i].y=game.state.baseq[game.state.rembase].y;
                }
            game.state.rembase--;
            if (game.isatb == 2) {
                /* reinstate a commander's base attack */
                }
            game.state.rembase--;
            if (game.isatb == 2) {
                /* reinstate a commander's base attack */
-               game.batx = ixhold;
-               game.baty = iyhold;
+               game.battle.x = ixhold;
+               game.battle.y = iyhold;
                game.isatb = 0;
            }
            else {
                game.isatb = 0;
            }
            else {
-               game.batx = game.baty = 0;
+               game.battle.x = game.battle.y = 0;
            }
            break;
        case FSCMOVE: /* Supercommander moves */
            }
            break;
        case FSCMOVE: /* Supercommander moves */
@@ -331,11 +331,11 @@ void events(void)
            game.probey += game.probeiny;
            i = (int)(game.probex/QUADSIZE +0.05);
            j = (int)(game.probey/QUADSIZE + 0.05);
            game.probey += game.probeiny;
            i = (int)(game.probex/QUADSIZE +0.05);
            j = (int)(game.probey/QUADSIZE + 0.05);
-           if (game.probecx != i || game.probecy != j) {
-               game.probecx = i;
-               game.probecy = j;
+           if (game.probec.x != i || game.probec.y != j) {
+               game.probec.x = i;
+               game.probec.y = j;
                if (!VALID_QUADRANT(i, j) ||
                if (!VALID_QUADRANT(i, j) ||
-                   game.state.galaxy[game.probecx][game.probecy].supernova) {
+                   game.state.galaxy[game.probec.x][game.probec.y].supernova) {
                    // Left galaxy or ran into supernova
                    if (game.damage[DRADIO]==0.0 || game.condit == IHDOCKED) {
                        if (ipage==0) pause_game(1);
                    // Left galaxy or ran into supernova
                    if (game.damage[DRADIO]==0.0 || game.condit == IHDOCKED) {
                        if (ipage==0) pause_game(1);
@@ -356,25 +356,25 @@ void events(void)
                    ipage = 1;
                    skip(1);
                    proutn(_("Lt. Uhura-  \"The deep space probe is now in "));
                    ipage = 1;
                    skip(1);
                    proutn(_("Lt. Uhura-  \"The deep space probe is now in "));
-                   proutn(cramlc(quadrant, game.probecx, game.probecy));
+                   proutn(cramlc(quadrant, game.probec));
                    prout(".\"");
                }
            }
            /* Update star chart if Radio is working or have access to
               radio. */
            if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED) {
                    prout(".\"");
                }
            }
            /* Update star chart if Radio is working or have access to
               radio. */
            if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED) {
-               game.state.chart[game.probecx][game.probecy].klingons = game.state.galaxy[game.probecx][game.probecy].klingons;
-               game.state.chart[game.probecx][game.probecy].starbase = game.state.galaxy[game.probecx][game.probecy].starbase;
-               game.state.chart[game.probecx][game.probecy].stars = game.state.galaxy[game.probecx][game.probecy].stars;
-               game.state.galaxy[game.probecx][game.probecy].charted = TRUE;
+               game.state.chart[game.probec.x][game.probec.y].klingons = game.state.galaxy[game.probec.x][game.probec.y].klingons;
+               game.state.chart[game.probec.x][game.probec.y].starbase = game.state.galaxy[game.probec.x][game.probec.y].starbase;
+               game.state.chart[game.probec.x][game.probec.y].stars = game.state.galaxy[game.probec.x][game.probec.y].stars;
+               game.state.galaxy[game.probec.x][game.probec.y].charted = TRUE;
            }
            game.proben--; // One less to travel
            if (game.proben == 0 && game.isarmed &&
            }
            game.proben--; // One less to travel
            if (game.proben == 0 && game.isarmed &&
-               game.state.galaxy[game.probecx][game.probecy].stars) {
+               game.state.galaxy[game.probec.x][game.probec.y].stars) {
                /* lets blow the sucker! */
                snova(1,0);
                unschedule(FDSPROB);
                /* lets blow the sucker! */
                snova(1,0);
                unschedule(FDSPROB);
-               if (game.state.galaxy[game.quadx][game.quady].supernova) 
+               if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) 
                    return;
            }
            break;
                    return;
            }
            break;
@@ -389,12 +389,12 @@ void events(void)
            for (i = 0; i < 100; i++) {
                struct quadrant *q;
                iran(GALSIZE, &ix, &iy);
            for (i = 0; i < 100; i++) {
                struct quadrant *q;
                iran(GALSIZE, &ix, &iy);
-               q = &game.state.galaxy[game.quadx][game.quady];
+               q = &game.state.galaxy[game.quadrant.x][game.quadrant.y];
                /* need a quadrant which is not the current one,
                   which has some stars which are inhabited and
                   not already under attack, which is not
                   supernova'ed, and which has some Klingons in it */
                /* need a quadrant which is not the current one,
                   which has some stars which are inhabited and
                   not already under attack, which is not
                   supernova'ed, and which has some Klingons in it */
-               if (!((ix == game.quadx && iy == game.quady) || q->stars<=0 ||
+               if (!((ix == game.quadrant.x && iy == game.quadrant.y) || q->stars<=0 ||
                      (q->qsystemname & Q_DISTRESSED) ||
                      (q->qsystemname & Q_SYSTEM) == 0 || q->klings <= 0))
                    break;
                      (q->qsystemname & Q_DISTRESSED) ||
                      (q->qsystemname & Q_SYSTEM) == 0 || q->klings <= 0))
                    break;
@@ -487,7 +487,7 @@ void events(void)
            }
            /* deliver the child */
            game.remkl++;
            }
            /* deliver the child */
            game.remkl++;
-           if (ix == game.quadx && iy == game.quady)
+           if (ix == game.quadrant.x && iy == game.quadrant.y)
                newkling(++game.klhere, &ixhold, &iyhold);
 
            /* recompute time left */
                newkling(++game.klhere, &ixhold, &iyhold);
 
            /* recompute time left */
@@ -549,7 +549,7 @@ void wait(void)
            game.damage[DDRAY] = 0.0;
     } while 
        // leave if quadrant supernovas
            game.damage[DDRAY] = 0.0;
     } while 
        // leave if quadrant supernovas
-       (!game.state.galaxy[game.quadx][game.quady].supernova);
+       (!game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova);
 
     game.resting = 0;
     game.optime = 0;
 
     game.resting = 0;
     game.optime = 0;
@@ -560,7 +560,10 @@ void nova(int ix, int iy)
     static double course[] =
        {0.0, 10.5, 12.0, 1.5, 9.0, 0.0, 3.0, 7.5, 6.0, 4.5};
     int bot, top, top2, hits[QUADSIZE+1][3], kount, icx, icy, mm, nn, j;
     static double course[] =
        {0.0, 10.5, 12.0, 1.5, 9.0, 0.0, 3.0, 7.5, 6.0, 4.5};
     int bot, top, top2, hits[QUADSIZE+1][3], kount, icx, icy, mm, nn, j;
-    int iquad, iquad1, i, ll, newcx, newcy, ii, jj;
+    int iquad, iquad1, i, ll;
+    coord newc, nov, scratch;
+
+    nov.x = ix; nov.y = iy;
     if (Rand() < 0.05) {
        /* Wow! We've supernova'ed */
        snova(ix, iy);
     if (Rand() < 0.05) {
        /* Wow! We've supernova'ed */
        snova(ix, iy);
@@ -569,9 +572,9 @@ void nova(int ix, int iy)
 
     /* handle initial nova */
     game.quad[ix][iy] = IHDOT;
 
     /* handle initial nova */
     game.quad[ix][iy] = IHDOT;
-    crmena(1, IHSTAR, 2, ix, iy);
+    crmena(1, IHSTAR, 2, nov);
     prout(_(" novas."));
     prout(_(" novas."));
-    game.state.galaxy[game.quadx][game.quady].stars--;
+    game.state.galaxy[game.quadrant.x][game.quadrant.y].stars--;
     game.state.starkl++;
        
     /* Set up stack to recursively trigger adjacent stars */
     game.state.starkl++;
        
     /* Set up stack to recursively trigger adjacent stars */
@@ -585,10 +588,10 @@ void nova(int ix, int iy)
            for (nn = 1; nn <= 3; nn++)  /* nn,j represents coordinates around current */
                for (j = 1; j <= 3; j++) {
                    if (j==2 && nn== 2) continue;
            for (nn = 1; nn <= 3; nn++)  /* nn,j represents coordinates around current */
                for (j = 1; j <= 3; j++) {
                    if (j==2 && nn== 2) continue;
-                   ii = hits[mm][1]+nn-2;
-                   jj = hits[mm][2]+j-2;
-                   if (!VALID_SECTOR(jj, ii)) continue;
-                   iquad = game.quad[ii][jj];
+                   scratch.x = hits[mm][1]+nn-2;
+                   scratch.y = hits[mm][2]+j-2;
+                   if (!VALID_SECTOR(scratch.y, scratch.x)) continue;
+                   iquad = game.quad[scratch.x][scratch.y];
                    switch (iquad) {
                    // case IHDOT:      /* Empty space ends reaction
                    // case IHQUEST:
                    switch (iquad) {
                    // case IHDOT:      /* Empty space ends reaction
                    // case IHQUEST:
@@ -600,45 +603,44 @@ void nova(int ix, int iy)
                    case IHSTAR: /* Affect another star */
                        if (Rand() < 0.05) {
                            /* This star supernovas */
                    case IHSTAR: /* Affect another star */
                        if (Rand() < 0.05) {
                            /* This star supernovas */
-                           snova(ii,jj);
+                           snova(scratch.x,scratch.y);
                            return;
                        }
                        top2++;
                            return;
                        }
                        top2++;
-                       hits[top2][1]=ii;
-                       hits[top2][2]=jj;
-                       game.state.galaxy[game.quadx][game.quady].stars -= 1;
+                       hits[top2][1]=scratch.x;
+                       hits[top2][2]=scratch.y;
+                       game.state.galaxy[game.quadrant.x][game.quadrant.y].stars -= 1;
                        game.state.starkl++;
                        game.state.starkl++;
-                       crmena(1, IHSTAR, 2, ii, jj);
+                       crmena(1, IHSTAR, 2, scratch);
                        prout(_(" novas."));
                        prout(_(" novas."));
-                       game.quad[ii][jj] = IHDOT;
+                       game.quad[scratch.x][scratch.y] = IHDOT;
                        break;
                    case IHP: /* Destroy planet */
                        break;
                    case IHP: /* Destroy planet */
-                       game.state.galaxy[game.quadx][game.quady].planet = NULL;
+                       game.state.galaxy[game.quadrant.x][game.quadrant.y].planet = NULL;
                        game.state.nplankl++;
                        game.state.nplankl++;
-                       crmena(1, IHP, 2, ii, jj);
+                       crmena(1, IHP, 2, scratch);
                        prout(_(" destroyed."));
                        DESTROY(&game.state.plnets[game.iplnet]);
                        prout(_(" destroyed."));
                        DESTROY(&game.state.plnets[game.iplnet]);
-                       game.iplnet = game.plnetx = game.plnety = 0;
+                       game.iplnet = game.plnet.x = game.plnet.y = 0;
                        if (game.landed == 1) {
                            finish(FPNOVA);
                            return;
                        }
                        if (game.landed == 1) {
                            finish(FPNOVA);
                            return;
                        }
-                       game.quad[ii][jj] = IHDOT;
+                       game.quad[scratch.x][scratch.y] = IHDOT;
                        break;
                    case IHB: /* Destroy base */
                        break;
                    case IHB: /* Destroy base */
-                       game.state.galaxy[game.quadx][game.quady].starbase = FALSE;
+                       game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase = FALSE;
                        for_starbases(i)
                        for_starbases(i)
-                           if (game.state.baseqx[i]==game.quadx && game.state.baseqy[i]==game.quady) 
+                           if (game.state.baseq[i].x==game.quadrant.x && game.state.baseq[i].y==game.quadrant.y) 
                                break;
                                break;
-                       game.state.baseqx[i] = game.state.baseqx[game.state.rembase];
-                       game.state.baseqy[i] = game.state.baseqy[game.state.rembase];
+                       game.state.baseq[i] = game.state.baseq[game.state.rembase];
                        game.state.rembase--;
                        game.state.rembase--;
-                       game.basex = game.basey = 0;
+                       game.base.x = game.base.y = 0;
                        game.state.basekl++;
                        newcnd();
                        game.state.basekl++;
                        newcnd();
-                       crmena(1, IHB, 2, ii, jj);
+                       crmena(1, IHB, 2, scratch);
                        prout(_(" destroyed."));
                        prout(_(" destroyed."));
-                       game.quad[ii][jj] = IHDOT;
+                       game.quad[scratch.x][scratch.y] = IHDOT;
                        break;
                    case IHE: /* Buffet ship */
                    case IHF:
                        break;
                    case IHE: /* Buffet ship */
                    case IHF:
@@ -660,38 +662,38 @@ void nova(int ix, int iy)
                            return;
                        }
                        /* add in course nova contributes to kicking starship*/
                            return;
                        }
                        /* add in course nova contributes to kicking starship*/
-                       icx += game.sectx-hits[mm][1];
-                       icy += game.secty-hits[mm][2];
+                       icx += game.sector.x-hits[mm][1];
+                       icy += game.sector.y-hits[mm][2];
                        kount++;
                        break;
                    case IHK: /* kill klingon */
                        kount++;
                        break;
                    case IHK: /* kill klingon */
-                       deadkl(ii,jj,iquad, ii, jj);
+                       deadkl(scratch.x,scratch.y,iquad, scratch.x, scratch.y);
                        break;
                    case IHC: /* Damage/destroy big enemies */
                    case IHS:
                    case IHR:
                        for_local_enemies(ll)
                        break;
                    case IHC: /* Damage/destroy big enemies */
                    case IHS:
                    case IHR:
                        for_local_enemies(ll)
-                           if (game.kx[ll]==ii && game.ky[ll]==jj) break;
+                           if (game.ks[ll].x==scratch.x && game.ks[ll].y==scratch.y) break;
                        game.kpower[ll] -= 800.0; /* If firepower is lost, die */
                        if (game.kpower[ll] <= 0.0) {
                        game.kpower[ll] -= 800.0; /* If firepower is lost, die */
                        if (game.kpower[ll] <= 0.0) {
-                           deadkl(ii, jj, iquad, ii, jj);
+                           deadkl(scratch.x, scratch.y, iquad, scratch.x, scratch.y);
                            break;
                        }
                            break;
                        }
-                       newcx = ii + ii - hits[mm][1];
-                       newcy = jj + jj - hits[mm][2];
-                       crmena(1, iquad, 2, ii, jj);
+                       newc.x = scratch.x + scratch.x - hits[mm][1];
+                       newc.y = scratch.y + scratch.y - hits[mm][2];
+                       crmena(1, iquad, 2, scratch);
                        proutn(_(" damaged"));
                        proutn(_(" damaged"));
-                       if (!VALID_SECTOR(newcx, newcy)) {
+                       if (!VALID_SECTOR(newc.x, newc.y)) {
                            /* can't leave quadrant */
                            skip(1);
                            break;
                        }
                            /* can't leave quadrant */
                            skip(1);
                            break;
                        }
-                       iquad1 = game.quad[newcx][newcy];
+                       iquad1 = game.quad[newc.x][newc.y];
                        if (iquad1 == IHBLANK) {
                            proutn(_(", blasted into "));
                        if (iquad1 == IHBLANK) {
                            proutn(_(", blasted into "));
-                           crmena(0, IHBLANK, 2, newcx, newcy);
+                           crmena(0, IHBLANK, 2, newc);
                            skip(1);
                            skip(1);
-                           deadkl(ii, jj, iquad, newcx, newcy);
+                           deadkl(scratch.x, scratch.y, iquad, newc.x, newc.y);
                            break;
                        }
                        if (iquad1 != IHDOT) {
                            break;
                        }
                        if (iquad1 != IHDOT) {
@@ -700,12 +702,12 @@ void nova(int ix, int iy)
                            break;
                        }
                        proutn(_(", buffeted to "));
                            break;
                        }
                        proutn(_(", buffeted to "));
-                       proutn(cramlc(sector, newcx, newcy));
-                       game.quad[ii][jj] = IHDOT;
-                       game.quad[newcx][newcy] = iquad;
-                       game.kx[ll] = newcx;
-                       game.ky[ll] = newcy;
-                       game.kavgd[ll] = sqrt(square(game.sectx-newcx)+square(game.secty-newcy));
+                       proutn(cramlc(sector, newc));
+                       game.quad[scratch.x][scratch.y] = IHDOT;
+                       game.quad[newc.x][newc.y] = iquad;
+                       game.ks[ll].x = newc.x;
+                       game.ks[ll].y = newc.y;
+                       game.kavgd[ll] = sqrt(square(game.sector.x-newc.x)+square(game.sector.y-newc.y));
                        game.kdist[ll] = game.kavgd[ll];
                        skip(1);
                        break;
                        game.kdist[ll] = game.kavgd[ll];
                        skip(1);
                        break;
@@ -738,34 +740,34 @@ void nova(int ix, int iy)
        
 void snova(int insx, int insy) 
 {
        
 void snova(int insx, int insy) 
 {
-    int comdead, nqx=0, nqy=0, nsx, nsy, num=0, kldead, iscdead;
+    int comdead, nsx, nsy, num=0, kldead, iscdead;
     int nrmdead, npdead;
     int incipient=0;
     int nrmdead, npdead;
     int incipient=0;
+    coord nq;
 
 
+    nq.x = nq.y = 0;
     nsx = insy;
     nsy = insy;
 
     if (insy== 0) {
     nsx = insy;
     nsy = insy;
 
     if (insy== 0) {
-       if (insx == 1) {
+       if (insx == 1)
            /* NOVAMAX being used */
            /* NOVAMAX being used */
-           nqx = game.probecx;
-           nqy = game.probecy;
-       }
+           nq = game.probec;
        else {
            int stars = 0;
            /* Scheduled supernova -- select star */
            /* logic changed here so that we won't favor quadrants in top
               left of universe */
        else {
            int stars = 0;
            /* Scheduled supernova -- select star */
            /* logic changed here so that we won't favor quadrants in top
               left of universe */
-           for_quadrants(nqx) {
-               for_quadrants(nqy) {
-                   stars += game.state.galaxy[nqx][nqy].stars;
+           for_quadrants(nq.x) {
+               for_quadrants(nq.y) {
+                   stars += game.state.galaxy[nq.x][nq.y].stars;
                }
            }
            if (stars == 0) return; /* nothing to supernova exists */
            num = Rand()*stars + 1;
                }
            }
            if (stars == 0) return; /* nothing to supernova exists */
            num = Rand()*stars + 1;
-           for_quadrants(nqx) {
-               for_quadrants(nqy) {
-                   num -= game.state.galaxy[nqx][nqy].stars;
+           for_quadrants(nq.x) {
+               for_quadrants(nq.y) {
+                   num -= game.state.galaxy[nq.x][nq.y].stars;
                    if (num <= 0) break;
                }
                if (num <=0) break;
                    if (num <= 0) break;
                }
                if (num <=0) break;
@@ -774,26 +776,26 @@ void snova(int insx, int insy)
            if (game.idebug) {
                proutn("Super nova here?");
                if (ja()==1) {
            if (game.idebug) {
                proutn("Super nova here?");
                if (ja()==1) {
-                   nqx = game.quadx;
-                   nqy = game.quady;
+                   nq.x = game.quadrant.x;
+                   nq.y = game.quadrant.y;
                }
            }
 #endif
        }
 
                }
            }
 #endif
        }
 
-       if (nqx != game.quady || nqy != game.quady || game.justin != 0) {
+       if (nq.x != game.quadrant.y || nq.y != game.quadrant.y || game.justin != 0) {
            /* it isn't here, or we just entered (treat as inroute) */
            if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED) {
                skip(1);
                prout(_("Message from Starfleet Command       Stardate %.2f"), game.state.date);
                prout(_("     Supernova in %s; caution advised."),
            /* it isn't here, or we just entered (treat as inroute) */
            if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED) {
                skip(1);
                prout(_("Message from Starfleet Command       Stardate %.2f"), game.state.date);
                prout(_("     Supernova in %s; caution advised."),
-                     cramlc(quadrant, nqx, nqy));
+                     cramlc(quadrant, nq));
            }
        }
        else {
            /* we are in the quadrant! */
            incipient = 1;
            }
        }
        else {
            /* we are in the quadrant! */
            incipient = 1;
-           num = Rand()* game.state.galaxy[nqx][nqy].stars + 1;
+           num = Rand()* game.state.galaxy[nq.x][nq.y].stars + 1;
            for_sectors(nsx) {
                for_sectors(nsy) {
                    if (game.quad[nsx][nsy]==IHSTAR) {
            for_sectors(nsx) {
                for_sectors(nsy) {
                    if (game.quad[nsx][nsy]==IHSTAR) {
@@ -810,13 +812,14 @@ void snova(int insx, int insy)
     }
 
     if (incipient) {
     }
 
     if (incipient) {
+       coord nd;
        skip(1);
        prouts(_("***RED ALERT!  RED ALERT!"));
        skip(1);
        skip(1);
        prouts(_("***RED ALERT!  RED ALERT!"));
        skip(1);
-       prout(_("***Incipient supernova detected at "), cramlc(sector, nsx, nsy));
-       nqx = game.quadx;
-       nqy = game.quady;
-       if (square(nsx-game.sectx) + square(nsy-game.secty) <= 2.1) {
+       nd.x = nsx; nd.y = nsy;
+       prout(_("***Incipient supernova detected at "), cramlc(sector, nd));
+       nq = game.quadrant;
+       if (square(nsx-game.sector.x) + square(nsy-game.sector.y) <= 2.1) {
            proutn(_("Emergency override attempts t"));
            prouts("***************");
            skip(1);
            proutn(_("Emergency override attempts t"));
            prouts("***************");
            skip(1);
@@ -825,12 +828,12 @@ void snova(int insx, int insy)
        }
     }
     /* destroy any Klingons in supernovaed quadrant */
        }
     }
     /* destroy any Klingons in supernovaed quadrant */
-    kldead = game.state.galaxy[nqx][nqy].klingons;
-    game.state.galaxy[nqx][nqy].klingons = 0;
+    kldead = game.state.galaxy[nq.x][nq.y].klingons;
+    game.state.galaxy[nq.x][nq.y].klingons = 0;
     comdead = iscdead = 0;
     comdead = iscdead = 0;
-    if (nqx==game.state.isx && nqy == game.state.isy) {
+    if (same(nq, game.state.kscmdr)) {
        /* did in the Supercommander! */
        /* did in the Supercommander! */
-       game.state.nscrem = game.state.isx = game.state.isy = game.isatb = game.iscate = 0;
+       game.state.nscrem = game.state.kscmdr.x = game.state.kscmdr.y = game.isatb = game.iscate = 0;
        iscdead = 1;
        unschedule(FSCMOVE);
        unschedule(FSCDBAS);
        iscdead = 1;
        unschedule(FSCMOVE);
        unschedule(FSCDBAS);
@@ -838,10 +841,9 @@ void snova(int insx, int insy)
     if (game.state.remcom) {
        int maxloop = game.state.remcom, l;
        for (l = 1; l <= maxloop; l++) {
     if (game.state.remcom) {
        int maxloop = game.state.remcom, l;
        for (l = 1; l <= maxloop; l++) {
-           if (game.state.cx[l] == nqx && game.state.cy[l] == nqy) {
-               game.state.cx[l] = game.state.cx[game.state.remcom];
-               game.state.cy[l] = game.state.cy[game.state.remcom];
-               game.state.cx[game.state.remcom] = game.state.cy[game.state.remcom] = 0;
+           if (same(game.state.kcmdr[l], nq)) {
+               game.state.kcmdr[l] = game.state.kcmdr[game.state.remcom];
+               game.state.kcmdr[game.state.remcom].x = game.state.kcmdr[game.state.remcom].y = 0;
                game.state.remcom--;
                kldead--;
                comdead++;
                game.state.remcom--;
                kldead--;
                comdead++;
@@ -852,14 +854,14 @@ void snova(int insx, int insy)
     }
     game.state.remkl -= kldead;
     /* destroy Romulans and planets in supernovaed quadrant */
     }
     game.state.remkl -= kldead;
     /* destroy Romulans and planets in supernovaed quadrant */
-    nrmdead = game.state.galaxy[nqx][nqy].romulans;
-    game.state.galaxy[nqx][nqy].romulans = 0;
+    nrmdead = game.state.galaxy[nq.x][nq.y].romulans;
+    game.state.galaxy[nq.x][nq.y].romulans = 0;
     game.state.nromrem -= nrmdead;
     npdead = num - nrmdead*10;
     if (npdead) {
        int l;
        for (l = 0; l < game.inplan; l++)
     game.state.nromrem -= nrmdead;
     npdead = num - nrmdead*10;
     if (npdead) {
        int l;
        for (l = 0; l < game.inplan; l++)
-           if (game.state.plnets[l].x == nqx && game.state.plnets[l].y == nqy) {
+           if (same(game.state.plnets[l].w, nq)) {
                DESTROY(&game.state.plnets[l]);
            }
     }
                DESTROY(&game.state.plnets[l]);
            }
     }
@@ -867,31 +869,30 @@ void snova(int insx, int insy)
     if (game.state.rembase) {
        int maxloop = game.state.rembase, l;
        for (l = 1; l <= maxloop; l++)
     if (game.state.rembase) {
        int maxloop = game.state.rembase, l;
        for (l = 1; l <= maxloop; l++)
-           if (game.state.baseqx[l]==nqx && game.state.baseqy[l]==nqy) {
-               game.state.baseqx[l] = game.state.baseqx[game.state.rembase];
-               game.state.baseqy[l] = game.state.baseqy[game.state.rembase];
-               game.state.baseqx[game.state.rembase] = game.state.baseqy[game.state.rembase] = 0;
+           if (same(game.state.baseq[l], nq)) {
+               game.state.baseq[l] = game.state.baseq[game.state.rembase];
+               game.state.baseq[game.state.rembase].x = game.state.baseq[game.state.rembase].y = 0;
                game.state.rembase--;
                break;
            }
     }
     /* If starship caused supernova, tally up destruction */
     if (insx) {
                game.state.rembase--;
                break;
            }
     }
     /* If starship caused supernova, tally up destruction */
     if (insx) {
-       game.state.starkl += game.state.galaxy[nqx][nqy].stars;
-       game.state.basekl += game.state.galaxy[nqx][nqy].starbase;
+       game.state.starkl += game.state.galaxy[nq.x][nq.y].stars;
+       game.state.basekl += game.state.galaxy[nq.x][nq.y].starbase;
        game.state.nplankl += npdead;
     }
     /* mark supernova in galaxy and in star chart */
        game.state.nplankl += npdead;
     }
     /* mark supernova in galaxy and in star chart */
-    if ((game.quadx == nqx && game.quady == nqy) ||
+    if ((game.quadrant.x == nq.x && game.quadrant.y == nq.y) ||
        game.damage[DRADIO] == 0 ||
        game.condit == IHDOCKED)
        game.damage[DRADIO] == 0 ||
        game.condit == IHDOCKED)
-       game.state.galaxy[nqx][nqy].supernova = TRUE;
+       game.state.galaxy[nq.x][nq.y].supernova = TRUE;
     /* If supernova destroys last klingons give special message */
     /* If supernova destroys last klingons give special message */
-    if (KLINGREM==0 && (nqx != game.quadx || nqy != game.quady)) {
+    if (KLINGREM==0 && (nq.x != game.quadrant.x || nq.y != game.quadrant.y)) {
        skip(2);
        if (insx == 0) prout(_("Lucky you!"));
        proutn(_("A supernova in %s has just destroyed the last Klingons."),
        skip(2);
        if (insx == 0) prout(_("Lucky you!"));
        proutn(_("A supernova in %s has just destroyed the last Klingons."),
-              cramlc(quadrant, nqx, nqy));
+              cramlc(quadrant, nq));
        finish(FWON);
        return;
     }
        finish(FWON);
        return;
     }
index c9e83335b56e4e0f0068af62af0a35ecab1dfdd9..e5a7386cf1cbfb2912a737a525fa5378ddfc94db 100644 (file)
@@ -61,7 +61,7 @@ void kaboom(void)
        int l=1;
        while (l <= game.nenhere) {
            if (game.kpower[l]*game.kdist[l] <= whammo) 
        int l=1;
        while (l <= game.nenhere) {
            if (game.kpower[l]*game.kdist[l] <= whammo) 
-               deadkl(game.kx[l],game.ky[l], game.quad[game.kx[l]][game.ky[l]], game.kx[l], game.ky[l]);
+               deadkl(game.ks[l].x,game.ks[l].x, game.quad[game.ks[l].x][game.ks[l].y], game.ks[l].x, game.ks[l].y);
            l++;
        }
     }
            l++;
        }
     }
index 632b335d6470e149ceb23bbd56a377bc4e79c194..48c08a210449561ff4a81ea8f5ac9daaac619205 100644 (file)
@@ -8,8 +8,10 @@ void imove(void)
 {
     double angle, deltax, deltay, bigger, x, y,
         finald, finalx, finaly, stopegy, probf;
 {
     double angle, deltax, deltay, bigger, x, y,
         finald, finalx, finaly, stopegy, probf;
-    int trbeam = 0, n, l, ix=0, iy=0, kink, kinks, iquad;
+    int trbeam = 0, n, l, kink, kinks, iquad;
+    coord w;
 
 
+    w.x = w.y = 0;
     if (game.inorbit) {
        prout("Helmsman Sulu- \"Leaving standard orbit.\"");
        game.inorbit = FALSE;
     if (game.inorbit) {
        prout("Helmsman Sulu- \"Leaving standard orbit.\"");
        game.inorbit = FALSE;
@@ -34,23 +36,23 @@ void imove(void)
        game.optime = scheduled(FTBEAM) - game.state.date + 1e-5;
     }
     /* Move within the quadrant */
        game.optime = scheduled(FTBEAM) - game.state.date + 1e-5;
     }
     /* Move within the quadrant */
-    game.quad[game.sectx][game.secty] = IHDOT;
-    x = game.sectx;
-    y = game.secty;
+    game.quad[game.sector.x][game.sector.y] = IHDOT;
+    x = game.sector.x;
+    y = game.sector.y;
     n = 10.0*game.dist*bigger+0.5;
 
     if (n > 0) {
        for (l = 1; l <= n; l++) {
     n = 10.0*game.dist*bigger+0.5;
 
     if (n > 0) {
        for (l = 1; l <= n; l++) {
-           ix = (x += deltax) + 0.5;
-           iy = (y += deltay) + 0.5;
-           if (!VALID_SECTOR(ix, iy)) {
+           w.x = (x += deltax) + 0.5;
+           w.y = (y += deltay) + 0.5;
+           if (!VALID_SECTOR(w.x, w.y)) {
                /* Leaving quadrant -- allow final enemy attack */
                /* Don't do it if being pushed by Nova */
                if (game.nenhere != 0 && game.iattak != 2) {
                    newcnd();
                    for_local_enemies(l) {
                /* Leaving quadrant -- allow final enemy attack */
                /* Don't do it if being pushed by Nova */
                if (game.nenhere != 0 && game.iattak != 2) {
                    newcnd();
                    for_local_enemies(l) {
-                       finald = sqrt((ix-game.kx[l])*(double)(ix-game.kx[l]) +
-                                     (iy-game.ky[l])*(double)(iy-game.ky[l]));
+                       finald = sqrt((w.x-game.ks[l].x)*(double)(w.x-game.ks[l].x) +
+                                     (w.y-game.ks[l].y)*(double)(w.y-game.ks[l].y));
                        game.kavgd[l] = 0.5 * (finald+game.kdist[l]);
                    }
                    /*
                        game.kavgd[l] = 0.5 * (finald+game.kdist[l]);
                    }
                    /*
@@ -58,33 +60,33 @@ void imove(void)
                     * that attacks only happen if Klingons
                     * are present and your skill is good.
                     */
                     * that attacks only happen if Klingons
                     * are present and your skill is good.
                     */
-                   if (game.skill > SKILL_GOOD && game.klhere > 0 && !game.state.galaxy[game.quadx][game.quady].supernova)
+                   if (game.skill > SKILL_GOOD && game.klhere > 0 && !game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova)
                        attack(0);
                    if (game.alldone) return;
                }
                /* compute final position -- new quadrant and sector */
                        attack(0);
                    if (game.alldone) return;
                }
                /* compute final position -- new quadrant and sector */
-               x = QUADSIZE*(game.quadx-1)+game.sectx;
-               y = QUADSIZE*(game.quady-1)+game.secty;
-               ix = x+10.0*game.dist*bigger*deltax+0.5;
-               iy = y+10.0*game.dist*bigger*deltay+0.5;
+               x = QUADSIZE*(game.quadrant.x-1)+game.sector.x;
+               y = QUADSIZE*(game.quadrant.y-1)+game.sector.y;
+               w.x = x+10.0*game.dist*bigger*deltax+0.5;
+               w.y = y+10.0*game.dist*bigger*deltay+0.5;
                /* check for edge of galaxy */
                kinks = 0;
                do {
                    kink = 0;
                /* check for edge of galaxy */
                kinks = 0;
                do {
                    kink = 0;
-                   if (ix <= 0) {
-                       ix = -ix + 1;
+                   if (w.x <= 0) {
+                       w.x = -w.x + 1;
                        kink = 1;
                    }
                        kink = 1;
                    }
-                   if (iy <= 0) {
-                       iy = -iy + 1;
+                   if (w.y <= 0) {
+                       w.y = -w.y + 1;
                        kink = 1;
                    }
                        kink = 1;
                    }
-                   if (ix > GALSIZE*QUADSIZE) {
-                       ix = (GALSIZE*QUADSIZE*2)+1 - ix;
+                   if (w.x > GALSIZE*QUADSIZE) {
+                       w.x = (GALSIZE*QUADSIZE*2)+1 - w.x;
                        kink = 1;
                    }
                        kink = 1;
                    }
-                   if (iy > GALSIZE*QUADSIZE) {
-                       iy = (GALSIZE*QUADSIZE*2)+1 - iy;
+                   if (w.y > GALSIZE*QUADSIZE) {
+                       w.y = (GALSIZE*QUADSIZE*2)+1 - w.y;
                        kink = 1;
                    }
                    if (kink) kinks = 1;
                        kink = 1;
                    }
                    if (kink) kinks = 1;
@@ -104,24 +106,23 @@ void imove(void)
                }
                /* Compute final position in new quadrant */
                if (trbeam) return; /* Don't bother if we are to be beamed */
                }
                /* Compute final position in new quadrant */
                if (trbeam) return; /* Don't bother if we are to be beamed */
-               game.quadx = (ix+(QUADSIZE-1))/QUADSIZE;
-               game.quady = (iy+(QUADSIZE-1))/QUADSIZE;
-               game.sectx = ix - QUADSIZE*(game.quadx-1);
-               game.secty = iy - QUADSIZE*(game.quady-1);
+               game.quadrant.x = (w.x+(QUADSIZE-1))/QUADSIZE;
+               game.quadrant.y = (w.y+(QUADSIZE-1))/QUADSIZE;
+               game.sector.x = w.x - QUADSIZE*(game.quadrant.x-1);
+               game.sector.y = w.y - QUADSIZE*(game.quadrant.y-1);
                skip(1);
                skip(1);
-               prout("Entering %s.",
-                     cramlc(quadrant, game.quadx, game.quady));
-               game.quad[game.sectx][game.secty] = game.ship;
+               prout("Entering %s.", cramlc(quadrant, game.quadrant));
+               game.quad[game.sector.x][game.sector.y] = game.ship;
                newqad(0);
                if (game.skill>SKILL_NOVICE) attack(0);
                return;
            }
                newqad(0);
                if (game.skill>SKILL_NOVICE) attack(0);
                return;
            }
-           iquad = game.quad[ix][iy];
+           iquad = game.quad[w.x][w.y];
            if (iquad != IHDOT) {
                /* object encountered in flight path */
                stopegy = 50.0*game.dist/game.optime;
            if (iquad != IHDOT) {
                /* object encountered in flight path */
                stopegy = 50.0*game.dist/game.optime;
-               game.dist=0.1*sqrt((game.sectx-ix)*(double)(game.sectx-ix) +
-                             (game.secty-iy)*(double)(game.secty-iy));
+               game.dist=0.1*sqrt((game.sector.x-w.x)*(double)(game.sector.x-w.x) +
+                             (game.sector.y-w.y)*(double)(game.sector.y-w.y));
                switch (iquad) {
                case IHT: /* Ram a Tholian */
                case IHK: /* Ram enemy ship */
                switch (iquad) {
                case IHT: /* Ram a Tholian */
                case IHK: /* Ram enemy ship */
@@ -129,11 +130,11 @@ void imove(void)
                case IHS:
                case IHR:
                case IHQUEST:
                case IHS:
                case IHR:
                case IHQUEST:
-                   game.sectx = ix;
-                   game.secty = iy;
-                   ram(0, iquad, game.sectx, game.secty);
-                   finalx = game.sectx;
-                   finaly = game.secty;
+                   game.sector.x = w.x;
+                   game.sector.y = w.y;
+                   ram(0, iquad, game.sector);
+                   finalx = game.sector.x;
+                   finaly = game.sector.y;
                    break;
                case IHBLANK:
                    skip(1);
                    break;
                case IHBLANK:
                    skip(1);
@@ -142,7 +143,7 @@ void imove(void)
                    proutn("***");
                    crmshp();
                    proutn(" pulled into black hole at ");
                    proutn("***");
                    crmshp();
                    proutn(" pulled into black hole at ");
-                   prout(cramlc(sector, ix, iy));
+                   prout(cramlc(sector, w));
                    /*
                     * Getting pulled into a black hole was certain
                     * death in Almy's original.  Stas Sergeev added a
                    /*
                     * Getting pulled into a black hole was certain
                     * death in Almy's original.  Stas Sergeev added a
@@ -166,15 +167,15 @@ void imove(void)
                        proutn(" encounters Tholian web at ");
                    else
                        proutn(" blocked by object at ");
                        proutn(" encounters Tholian web at ");
                    else
                        proutn(" blocked by object at ");
-                   proutn(cramlc(sector, ix,iy));
+                   proutn(cramlc(sector, w));
                    prout(";");
                    proutn("Emergency stop required ");
                    prout("%2d units of energy.", (int)stopegy);
                    game.energy -= stopegy;
                    finalx = x-deltax+0.5;
                    prout(";");
                    proutn("Emergency stop required ");
                    prout("%2d units of energy.", (int)stopegy);
                    game.energy -= stopegy;
                    finalx = x-deltax+0.5;
-                   game.sectx = finalx;
+                   game.sector.x = finalx;
                    finaly = y-deltay+0.5;
                    finaly = y-deltay+0.5;
-                   game.secty = finaly;
+                   game.sector.y = finaly;
                    if (game.energy <= 0) {
                        finish(FNRG);
                        return;
                    if (game.energy <= 0) {
                        finish(FNRG);
                        return;
@@ -184,25 +185,25 @@ void imove(void)
                goto no_quad_change;    /* sorry! */
            }
        }
                goto no_quad_change;    /* sorry! */
            }
        }
-       game.dist = 0.1*sqrt((game.sectx-ix)*(double)(game.sectx-ix) +
-                       (game.secty-iy)*(double)(game.secty-iy));
-       game.sectx = ix;
-       game.secty = iy;
+       game.dist = 0.1*sqrt((game.sector.x-w.x)*(double)(game.sector.x-w.x) +
+                       (game.sector.y-w.y)*(double)(game.sector.y-w.y));
+       game.sector.x = w.x;
+       game.sector.y = w.y;
     }
     }
-    finalx = game.sectx;
-    finaly = game.secty;
+    finalx = game.sector.x;
+    finaly = game.sector.y;
 no_quad_change:
     /* No quadrant change -- compute new avg enemy distances */
 no_quad_change:
     /* No quadrant change -- compute new avg enemy distances */
-    game.quad[game.sectx][game.secty] = game.ship;
+    game.quad[game.sector.x][game.sector.y] = game.ship;
     if (game.nenhere) {
        for_local_enemies(l) {
     if (game.nenhere) {
        for_local_enemies(l) {
-           finald = sqrt((ix-game.kx[l])*(double)(ix-game.kx[l]) +
-                         (iy-game.ky[l])*(double)(iy-game.ky[l]));
+           finald = sqrt((w.x-game.ks[l].x)*(double)(w.x-game.ks[l].x) +
+                         (w.y-game.ks[l].y)*(double)(w.y-game.ks[l].y));
            game.kavgd[l] = 0.5 * (finald+game.kdist[l]);
            game.kdist[l] = finald;
        }
        sortkl();
            game.kavgd[l] = 0.5 * (finald+game.kdist[l]);
            game.kdist[l] = finald;
        }
        sortkl();
-       if (!game.state.galaxy[game.quadx][game.quady].supernova && game.iattak == 0)
+       if (!game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova && game.iattak == 0)
            attack(0);
        for_local_enemies(l) game.kavgd[l] = game.kdist[l];
     }
            attack(0);
        for_local_enemies(l) game.kavgd[l] = game.kdist[l];
     }
@@ -224,7 +225,7 @@ void dock(int l)
        prout("You must first leave standard orbit.");
        return;
     }
        prout("You must first leave standard orbit.");
        return;
     }
-    if (game.basex==0 || abs(game.sectx-game.basex) > 1 || abs(game.secty-game.basey) > 1) {
+    if (game.base.x==0 || abs(game.sector.x-game.base.x) > 1 || abs(game.sector.y-game.base.y) > 1) {
        crmshp();
        prout(" not adjacent to base.");
        return;
        crmshp();
        prout(" not adjacent to base.");
        return;
@@ -255,10 +256,11 @@ static void getcd(int isprobe, int akey) {
           are always displayed y - x, where +y is downward! */
 
        
           are always displayed y - x, where +y is downward! */
 
        
-        int irowq=game.quadx, icolq=game.quady, irows, icols, itemp=0, iprompt=0, key=0;
+        int irowq=game.quadrant.x, icolq=game.quadrant.y, itemp=0, iprompt=0, key=0;
        double xi, xj, xk, xl;
        double deltax, deltay;
        int automatic = -1;
        double xi, xj, xk, xl;
        double deltax, deltay;
        int automatic = -1;
+       coord incr;
 
        /* Get course direction and distance. If user types bad values, return
           with DIREC = -1.0. */
 
        /* Get course direction and distance. If user types bad values, return
           with DIREC = -1.0. */
@@ -359,23 +361,23 @@ static void getcd(int isprobe, int akey) {
 
                        irowq = xi + 0.5;
                        icolq = xj + 0.5;
 
                        irowq = xi + 0.5;
                        icolq = xj + 0.5;
-                       irows = xk + 0.5;
-                       icols = xl + 0.5;
+                       incr.y = xk + 0.5;
+                       incr.x = xl + 0.5;
                }
                else {
                        if (isprobe) {
                                /* only quadrant specified -- go to center of dest quad */
                                irowq = xi + 0.5;
                                icolq = xj + 0.5;
                }
                else {
                        if (isprobe) {
                                /* only quadrant specified -- go to center of dest quad */
                                irowq = xi + 0.5;
                                icolq = xj + 0.5;
-                               irows = icols = 5;
+                               incr.y = incr.x = 5;
                        }
                        else {
                        }
                        else {
-                               irows = xi + 0.5;
-                               icols = xj + 0.5;
+                               incr.y = xi + 0.5;
+                               incr.x = xj + 0.5;
                        }
                        itemp = 1;
                }
                        }
                        itemp = 1;
                }
-               if (!VALID_QUADRANT(icolq,irowq)||!VALID_SECTOR(icols,irows)) {
+               if (!VALID_QUADRANT(icolq,irowq)||!VALID_SECTOR(incr.x,incr.y)) {
                    huh();
                    return;
                }
                    huh();
                    return;
                }
@@ -384,13 +386,13 @@ static void getcd(int isprobe, int akey) {
                        if (itemp) {
                                if (iprompt) {
                                        prout("Helmsman Sulu- \"Course locked in for %s.\"",
                        if (itemp) {
                                if (iprompt) {
                                        prout("Helmsman Sulu- \"Course locked in for %s.\"",
-                                               cramlc(sector, irows, icols));
+                                               cramlc(sector, incr));
                                }
                        }
                        else prout("Ensign Chekov- \"Course laid in, Captain.\"");
                }
                                }
                        }
                        else prout("Ensign Chekov- \"Course laid in, Captain.\"");
                }
-               deltax = icolq - game.quady + 0.1*(icols-game.secty);
-               deltay = game.quadx - irowq + 0.1*(game.sectx-irows);
+               deltax = icolq - game.quadrant.y + 0.1*(incr.x-game.sector.y);
+               deltay = game.quadrant.x - irowq + 0.1*(game.sector.x-incr.y);
        }
        else { /* manual */
                while (key == IHEOL) {
        }
        else { /* manual */
                while (key == IHEOL) {
@@ -586,8 +588,8 @@ void warp(int i)
            deltax /= bigger;
            deltay /= bigger;
            n = 10.0 * game.dist * bigger +0.5;
            deltax /= bigger;
            deltay /= bigger;
            n = 10.0 * game.dist * bigger +0.5;
-           x = game.sectx;
-           y = game.secty;
+           x = game.sector.x;
+           y = game.sector.y;
            for (l = 1; l <= n; l++) {
                x += deltax;
                ix = x + 0.5;
            for (l = 1; l <= n; l++) {
                x += deltax;
                ix = x + 0.5;
@@ -732,7 +734,7 @@ void atover(int igrab)
        skip(1);
        prout("safely out of quadrant.");
        if (game.damage[DRADIO] == 0.0)
        skip(1);
        prout("safely out of quadrant.");
        if (game.damage[DRADIO] == 0.0)
-           game.state.galaxy[game.quadx][game.quady].charted = TRUE;
+           game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = TRUE;
        /* Try to use warp engines */
        if (game.damage[DWARPEN]) {
            skip(1);
        /* Try to use warp engines */
        if (game.damage[DWARPEN]) {
            skip(1);
@@ -762,7 +764,7 @@ void atover(int igrab)
        }
     } while 
        /* Repeat if another snova */
        }
     } while 
        /* Repeat if another snova */
-       (game.state.galaxy[game.quadx][game.quady].supernova);
+       (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova);
     if (KLINGREM==0) 
        finish(FWON); /* Snova killed remaining enemy. */
 }
     if (KLINGREM==0) 
        finish(FWON); /* Snova killed remaining enemy. */
 }
@@ -789,7 +791,7 @@ void timwrp()
        game.isatb = 0;
        unschedule(FCDBAS);
        unschedule(FSCDBAS);
        game.isatb = 0;
        unschedule(FCDBAS);
        unschedule(FSCDBAS);
-       game.batx = game.baty = 0;
+       game.battle.x = game.battle.y = 0;
 
        /* Make sure Galileo is consistant -- Snapshot may have been taken
           when on planet, which would give us two Galileos! */
 
        /* Make sure Galileo is consistant -- Snapshot may have been taken
           when on planet, which would give us two Galileos! */
@@ -890,10 +892,9 @@ void probe(void)
     game.probeiny /= bigger;
     game.probeinx /= bigger;
     game.proben = 10.0*game.dist*bigger +0.5;
     game.probeiny /= bigger;
     game.probeinx /= bigger;
     game.proben = 10.0*game.dist*bigger +0.5;
-    game.probex = game.quadx*QUADSIZE + game.sectx - 1;        // We will use better packing than original
-    game.probey = game.quady*QUADSIZE + game.secty - 1;
-    game.probecx = game.quadx;
-    game.probecy = game.quady;
+    game.probex = game.quadrant.x*QUADSIZE + game.sector.x - 1;        // We will use better packing than original
+    game.probey = game.quadrant.y*QUADSIZE + game.sector.y - 1;
+    game.probec = game.quadrant;
     schedule(FDSPROB, 0.01); // Time to move one sector
     prout("Ensign Chekov-  \"The deep space probe is launched, Captain.\"");
     game.ididit = 1;
     schedule(FDSPROB, 0.01); // Time to move one sector
     prout("Ensign Chekov-  \"The deep space probe is launched, Captain.\"");
     game.ididit = 1;
@@ -928,42 +929,42 @@ void mayday(void)
     }
     /* OK -- call for help from nearest starbase */
     game.nhelp++;
     }
     /* OK -- call for help from nearest starbase */
     game.nhelp++;
-    if (game.basex!=0) {
+    if (game.base.x!=0) {
        /* There's one in this quadrant */
        /* There's one in this quadrant */
-       ddist = sqrt(square(game.basex-game.sectx)+square(game.basey-game.secty));
+       ddist = sqrt(square(game.base.x-game.sector.x)+square(game.base.y-game.sector.y));
     }
     else {
        ddist = FOREVER;
        for_starbases(l) {
     }
     else {
        ddist = FOREVER;
        for_starbases(l) {
-           xdist=10.0*sqrt(square(game.state.baseqx[l]-game.quadx)+square(game.state.baseqy[l]-game.quady));
+           xdist=10.0*sqrt(square(game.state.baseq[l].x-game.quadrant.x)+square(game.state.baseq[l].y-game.quadrant.y));
            if (xdist < ddist) {
                ddist = xdist;
                line = l;
            }
        }
        /* Since starbase not in quadrant, set up new quadrant */
            if (xdist < ddist) {
                ddist = xdist;
                line = l;
            }
        }
        /* Since starbase not in quadrant, set up new quadrant */
-       game.quadx = game.state.baseqx[line];
-       game.quady = game.state.baseqy[line];
+       game.quadrant.x = game.state.baseq[line].x;
+       game.quadrant.y = game.state.baseq[line].y;
        newqad(1);
     }
     /* dematerialize starship */
        newqad(1);
     }
     /* dematerialize starship */
-    game.quad[game.sectx][game.secty]=IHDOT;
-    proutn("Starbase in %s responds--", cramlc(quadrant, game.quadx, game.quady));
+    game.quad[game.sector.x][game.sector.y]=IHDOT;
+    proutn("Starbase in %s responds--", cramlc(quadrant, game.quadrant));
     proutn("");
     crmshp();
     prout(" dematerializes.");
     proutn("");
     crmshp();
     prout(" dematerializes.");
-    game.sectx=0;
+    game.sector.x=0;
     for (l = 1; l <= 5; l++) {
     for (l = 1; l <= 5; l++) {
-       ix = game.basex+3.0*Rand()-1;
-       iy = game.basey+3.0*Rand()-1;
+       ix = game.base.x+3.0*Rand()-1;
+       iy = game.base.y+3.0*Rand()-1;
        if (VALID_SECTOR(ix,iy) && game.quad[ix][iy]==IHDOT) {
            /* found one -- finish up */
        if (VALID_SECTOR(ix,iy) && game.quad[ix][iy]==IHDOT) {
            /* found one -- finish up */
-           game.sectx=ix;
-           game.secty=iy;
+           game.sector.x=ix;
+           game.sector.y=iy;
            break;
        }
     }
            break;
        }
     }
-    if (game.sectx==0){
+    if (game.sector.x==0){
        prout("You have been lost in space...");
        finish(FMATERIALIZE);
        return;
        prout("You have been lost in space...");
        finish(FMATERIALIZE);
        return;
index 1ab10a1996cce21a17f5dceba6a98188e4e2feb7..723e5e9a7ab92e24d6a8360076fa6010a1142bcc 100644 (file)
@@ -21,7 +21,7 @@ static int consumeTime(void)
     events();  /* Used to avoid if FSCMOVE is scheduled within time */
 //     schedule(FSNOVA, asave-game.state.time);
     /*fails if game over, quadrant super-novas or we've moved to new quadrant*/
     events();  /* Used to avoid if FSCMOVE is scheduled within time */
 //     schedule(FSNOVA, asave-game.state.time);
     /*fails if game over, quadrant super-novas or we've moved to new quadrant*/
-    if (game.alldone || game.state.galaxy[game.quadx][game.quady].supernova || game.justin != 0) return 1;
+    if (game.alldone || game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova || game.justin != 0) return 1;
     return 0;
 }
 
     return 0;
 }
 
@@ -43,7 +43,7 @@ void preport(void)
 #ifdef DEBUG
            if (game.idebug && game.state.plnets[i].known==unknown) proutn("(Unknown) ");
 #endif
 #ifdef DEBUG
            if (game.idebug && game.state.plnets[i].known==unknown) proutn("(Unknown) ");
 #endif
-           proutn(cramlc(quadrant, game.state.plnets[i].x, game.state.plnets[i].y));
+           proutn(cramlc(quadrant, game.state.plnets[i].w));
            proutn("   class ");
            proutn(classes[game.state.plnets[i].pclass]);
            proutn("   ");
            proutn("   class ");
            proutn(classes[game.state.plnets[i].pclass]);
            proutn("   ");
@@ -68,7 +68,7 @@ void orbit(void)
        prout("Both warp and impulse engines damaged.");
        return;
     }
        prout("Both warp and impulse engines damaged.");
        return;
     }
-    if (game.plnetx == 0 || abs(game.sectx-game.plnetx) > 1 || abs(game.secty-game.plnety) > 1) {
+    if (game.plnet.x == 0 || abs(game.sector.x-game.plnet.x) > 1 || abs(game.sector.y-game.plnet.y) > 1) {
        crmshp();
        prout(" not adjacent to planet.");
        skip(1);
        crmshp();
        prout(" not adjacent to planet.");
        skip(1);
@@ -92,15 +92,15 @@ void sensor(void)
        prout("Short range sensors damaged.");
        return;
     }
        prout("Short range sensors damaged.");
        return;
     }
-    if (!game.plnetx && (game.options & OPTION_TTY)) {
+    if (!game.plnet.x && (game.options & OPTION_TTY)) {
        prout("Spock- \"No planet in this quadrant, Captain.\"");
        return;
     }
        prout("Spock- \"No planet in this quadrant, Captain.\"");
        return;
     }
-    if ((game.plnetx != 0)&& (game.state.plnets[game.iplnet].known == unknown)) {
-       prout("Spock-  \"Sensor scan for %s-", cramlc(quadrant, game.quadx, game.quady));
+    if ((game.plnet.x != 0)&& (game.state.plnets[game.iplnet].known == unknown)) {
+       prout("Spock-  \"Sensor scan for %s-", cramlc(quadrant, game.quadrant));
        skip(1);
        skip(1);
-       prout("         Planet at %s is of class %s.", 
-             cramlc(sector, game.plnetx, game.plnety),
+       prout("         Planet at %s is of class %s.",
+             cramlc(sector,game.plnet),
              classes[game.state.plnets[game.iplnet].pclass]);
        if (game.state.plnets[game.iplnet].known==shuttle_down) 
            prout("         Sensors show Galileo still on surface.");
              classes[game.state.plnets[game.iplnet].pclass]);
        if (game.state.plnets[game.iplnet].known==shuttle_down) 
            prout("         Sensors show Galileo still on surface.");
@@ -443,7 +443,7 @@ void deathray(void)
        prouts("Sulu- \"Captain!  It's working!\"");
        skip(2);
        while (game.nenhere > 0)
        prouts("Sulu- \"Captain!  It's working!\"");
        skip(2);
        while (game.nenhere > 0)
-           deadkl(game.kx[1],game.ky[1],game.quad[game.kx[1]][game.ky[1]],game.kx[1],game.ky[1]);
+           deadkl(game.ks[1].x,game.ks[1].y,game.quad[game.ks[1].x][game.ks[1].y],game.ks[1].x,game.ks[1].y);
        prout("Ensign Chekov-  \"Congratulations, Captain!\"");
        if (KLINGREM == 0) finish(FWON);
        if ((game.options & OPTION_PLAIN) == 0) {
        prout("Ensign Chekov-  \"Congratulations, Captain!\"");
        if (KLINGREM == 0) finish(FWON);
        if ((game.options & OPTION_PLAIN) == 0) {
index a79a4105d2e1b4ee94eb8fea6f9566d064a91432..ac4f417b047b579ad3d211e3192988287046da1e 100644 (file)
@@ -8,21 +8,21 @@ void attakreport(int curt)
     if (!curt) {
        if (is_scheduled(FCDBAS)) {
            prout("Starbase in %s is currently under Commander attack.",
     if (!curt) {
        if (is_scheduled(FCDBAS)) {
            prout("Starbase in %s is currently under Commander attack.",
-                 cramlc(quadrant, game.batx, game.baty));
+                 cramlc(quadrant, game.battle));
            prout("It can hold out until Stardate %d.", 
                  (int)scheduled(FCDBAS));
        }
        if (game.isatb == 1) {
            prout("Starbase in %s is under Super-commander attack.",
            prout("It can hold out until Stardate %d.", 
                  (int)scheduled(FCDBAS));
        }
        if (game.isatb == 1) {
            prout("Starbase in %s is under Super-commander attack.",
-                 cramlc(quadrant, game.state.isx, game.state.isy));
+                 cramlc(quadrant, game.state.kscmdr));
            prout("It can hold out until Stardate %d.", 
                  (int)scheduled(FSCDBAS));
        }
     } else {
         if (is_scheduled(FCDBAS))
            prout("It can hold out until Stardate %d.", 
                  (int)scheduled(FSCDBAS));
        }
     } else {
         if (is_scheduled(FCDBAS))
-           proutn("Base in %i - %i attacked by C. Alive until %.1f", game.batx, game.baty, scheduled(FCDBAS));
+           proutn("Base in %i - %i attacked by C. Alive until %.1f", game.battle.x, game.battle.y, scheduled(FCDBAS));
         if (game.isatb == 1)
         if (game.isatb == 1)
-           proutn("Base in %i - %i attacked by S. Alive until %.1f", game.state.isx, game.state.isy, scheduled(FSCDBAS));
+           proutn("Base in %i - %i attacked by S. Alive until %.1f", game.state.kscmdr.x, game.state.kscmdr.y, scheduled(FSCDBAS));
     }
     clreol();
 }
     }
     clreol();
 }
@@ -93,7 +93,7 @@ void report(void)
            proutn("An armed deep space probe is in");
        else
            proutn("A deep space probe is in");
            proutn("An armed deep space probe is in");
        else
            proutn("A deep space probe is in");
-       proutn(cramlc(quadrant, game.probecx, game.probecy));
+       proutn(cramlc(quadrant, game.probec));
        prout(".");
     }
     if (game.icrystl) {
        prout(".");
     }
     if (game.icrystl) {
@@ -128,9 +128,9 @@ void lrscan(void)
     else {
        prout("Long-range scan");
     }
     else {
        prout("Long-range scan");
     }
-    for (x = game.quadx-1; x <= game.quadx+1; x++) {
+    for (x = game.quadrant.x-1; x <= game.quadrant.x+1; x++) {
        proutn(" ");
        proutn(" ");
-       for (y = game.quady-1; y <= game.quady+1; y++) {
+       for (y = game.quadrant.y-1; y <= game.quadrant.y+1; y++) {
            if (!VALID_QUADRANT(x, y))
                proutn("  -1");
            else {
            if (!VALID_QUADRANT(x, y))
                proutn("  -1");
            else {
@@ -206,7 +206,7 @@ void chart(int nn)
        proutn("%d |", i);
        for_quadrants(j) {
            char buf[4];
        proutn("%d |", i);
        for_quadrants(j) {
            char buf[4];
-           if ((game.options & OPTION_SHOWME) && i == game.quadx && j == game.quady)
+           if ((game.options & OPTION_SHOWME) && i == game.quadrant.x && j == game.quadrant.y)
                proutn("<");
            else
                proutn(" ");
                proutn("<");
            else
                proutn(" ");
@@ -219,7 +219,7 @@ void chart(int nn)
            else
                strcpy(buf, "...");
            proutn(buf);
            else
                strcpy(buf, "...");
            proutn(buf);
-           if ((game.options & OPTION_SHOWME) && i == game.quadx && j == game.quady)
+           if ((game.options & OPTION_SHOWME) && i == game.quadrant.x && j == game.quadrant.y)
                proutn(">");
            else
                proutn(" ");
                proutn(">");
            else
                proutn(" ");
@@ -232,7 +232,7 @@ void chart(int nn)
 
 static void sectscan(int goodScan, int i, int j) 
 {
 
 static void sectscan(int goodScan, int i, int j) 
 {
-    if (goodScan || (abs(i-game.sectx)<= 1 && abs(j-game.secty) <= 1)){
+    if (goodScan || (abs(i-game.sector.x)<= 1 && abs(j-game.sector.y) <= 1)){
        if ((game.quad[i][j]==IHMATER0)||(game.quad[i][j]==IHMATER1)||(game.quad[i][j]==IHMATER2)||(game.quad[i][j]==IHE)||(game.quad[i][j]==IHF)){
            switch (game.condit) {
            case IHRED: textcolor(RED); break;
        if ((game.quad[i][j]==IHMATER0)||(game.quad[i][j]==IHMATER1)||(game.quad[i][j]==IHMATER2)||(game.quad[i][j]==IHE)||(game.quad[i][j]==IHF)){
            switch (game.condit) {
            case IHRED: textcolor(RED); break;
@@ -275,7 +275,7 @@ static void status(int req)
        break;
     case 3:
        proutn("Position      %d - %d , %d - %d",
        break;
     case 3:
        proutn("Position      %d - %d , %d - %d",
-              game.quadx, game.quady, game.sectx, game.secty);
+              game.quadrant.x, game.quadrant.y, game.sector.x, game.sector.y);
        break;
     case 4:
        proutn("Life Support  ");
        break;
     case 4:
        proutn("Life Support  ");
@@ -315,7 +315,7 @@ static void status(int req)
        break;
     case 10:
        if (game.options & OPTION_WORLDS) {
        break;
     case 10:
        if (game.options & OPTION_WORLDS) {
-           planet *here = game.state.galaxy[game.quadx][game.quady].planet;
+           planet *here = game.state.galaxy[game.quadrant.x][game.quadrant.y].planet;
            if (here && here->inhabited != UNINHABITED)
                proutn("Major system  %s", systemname(here));
            else
            if (here && here->inhabited != UNINHABITED)
                proutn("Major system  %s", systemname(here));
            else
@@ -349,10 +349,10 @@ int srscan(int l)
        }
        else prout("     Short-range scan");
        if (goodScan && !game.damage[DRADIO]) { 
        }
        else prout("     Short-range scan");
        if (goodScan && !game.damage[DRADIO]) { 
-           game.state.chart[game.quadx][game.quady].klingons = game.state.galaxy[game.quadx][game.quady].klingons;
-           game.state.chart[game.quadx][game.quady].starbase = game.state.galaxy[game.quadx][game.quady].starbase;
-           game.state.chart[game.quadx][game.quady].stars = game.state.galaxy[game.quadx][game.quady].stars;
-           game.state.galaxy[game.quadx][game.quady].charted = TRUE;
+           game.state.chart[game.quadrant.x][game.quadrant.y].klingons = game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons;
+           game.state.chart[game.quadrant.x][game.quadrant.y].starbase = game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase;
+           game.state.chart[game.quadrant.x][game.quadrant.y].stars = game.state.galaxy[game.quadrant.x][game.quadrant.y].stars;
+           game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = TRUE;
        }
        scan();
        if (isit("chart")) nn = TRUE;
        }
        scan();
        if (isit("chart")) nn = TRUE;
@@ -437,9 +437,9 @@ void eta(void)
        ix2 = aaitem + 0.5;
     }
     else {
        ix2 = aaitem + 0.5;
     }
     else {
-       if (game.quady>ix1) ix2 = 1;
+       if (game.quadrant.y>ix1) ix2 = 1;
        else ix2=QUADSIZE;
        else ix2=QUADSIZE;
-       if (game.quadx>iy1) iy2 = 1;
+       if (game.quadrant.x>iy1) iy2 = 1;
        else iy2=QUADSIZE;
     }
 
        else iy2=QUADSIZE;
     }
 
@@ -447,8 +447,8 @@ void eta(void)
        huh();
        return;
     }
        huh();
        return;
     }
-    game.dist = sqrt(square(iy1-game.quadx+0.1*(iy2-game.sectx))+
-               square(ix1-game.quady+0.1*(ix2-game.secty)));
+    game.dist = sqrt(square(iy1-game.quadrant.x+0.1*(iy2-game.sector.x))+
+               square(ix1-game.quadrant.y+0.1*(ix2-game.sector.y)));
     wfl = FALSE;
 
     if (prompt) prout("Answer \"no\" if you don't know the value:");
     wfl = FALSE;
 
     if (prompt) prout("Answer \"no\" if you don't know the value:");
@@ -526,9 +526,9 @@ void eta(void)
            prout("Unfortunately, the Federation will be destroyed by then.");
        if (twarp > 6.0)
            prout("You'll be taking risks at that speed, Captain");
            prout("Unfortunately, the Federation will be destroyed by then.");
        if (twarp > 6.0)
            prout("You'll be taking risks at that speed, Captain");
-       if ((game.isatb==1 && game.state.isy == iy1 && game.state.isx == ix1 &&
+       if ((game.isatb==1 && game.state.kscmdr.y == iy1 && game.state.kscmdr.x == ix1 &&
             scheduled(FSCDBAS)< ttime+game.state.date)||
             scheduled(FSCDBAS)< ttime+game.state.date)||
-           (scheduled(FCDBAS)<ttime+game.state.date && game.baty==iy1 && game.batx == ix1))
+           (scheduled(FCDBAS)<ttime+game.state.date && game.battle.y==iy1 && game.battle.x == ix1))
            prout("The starbase there will be destroyed by then.");
        proutn("New warp factor to try? ");
        if (scan() == IHREAL) {
            prout("The starbase there will be destroyed by then.");
        proutn("New warp factor to try? ");
        if (scan() == IHREAL) {
index afb9c4fbcbf533142147675c21fc72f194d0b15d..3e6718f4620b1bc0339e0fa205f40c504e2e6a8d 100644 (file)
@@ -147,29 +147,29 @@ void abandn(void)
        prout("the Federation in a prisoner-of-war exchange.");
        nb = Rand()*game.state.rembase+1;
        /* Set up quadrant and position FQ adjacient to base */
        prout("the Federation in a prisoner-of-war exchange.");
        nb = Rand()*game.state.rembase+1;
        /* Set up quadrant and position FQ adjacient to base */
-       if (game.quadx!=game.state.baseqx[nb] || game.quady!=game.state.baseqy[nb]) {
-           game.quadx = game.state.baseqx[nb];
-           game.quady = game.state.baseqy[nb];
-           game.sectx = game.secty = 5;
+       if (game.quadrant.x!=game.state.baseq[nb].x || game.quadrant.y!=game.state.baseq[nb].y) {
+           game.quadrant.x = game.state.baseq[nb].x;
+           game.quadrant.y = game.state.baseq[nb].y;
+           game.sector.x = game.sector.y = 5;
            newqad(1);
        }
        for (;;) {
            /* position next to base by trial and error */
            newqad(1);
        }
        for (;;) {
            /* position next to base by trial and error */
-           game.quad[game.sectx][game.secty] = IHDOT;
+           game.quad[game.sector.x][game.sector.y] = IHDOT;
            for_sectors(l) {
            for_sectors(l) {
-               game.sectx = 3.0*Rand() - 1.0 + game.basex;
-               game.secty = 3.0*Rand() - 1.0 + game.basey;
-               if (VALID_SECTOR(game.sectx, game.secty) &&
-                   game.quad[game.sectx][game.secty] == IHDOT) break;
+               game.sector.x = 3.0*Rand() - 1.0 + game.base.x;
+               game.sector.y = 3.0*Rand() - 1.0 + game.base.y;
+               if (VALID_SECTOR(game.sector.x, game.sector.y) &&
+                   game.quad[game.sector.x][game.sector.y] == IHDOT) break;
            }
            if (l < QUADSIZE+1) break; /* found a spot */
            }
            if (l < QUADSIZE+1) break; /* found a spot */
-           game.sectx=QUADSIZE/2;
-           game.secty=QUADSIZE/2;
+           game.sector.x=QUADSIZE/2;
+           game.sector.y=QUADSIZE/2;
            newqad(1);
        }
     }
     /* Get new commission */
            newqad(1);
        }
     }
     /* Get new commission */
-    game.quad[game.sectx][game.secty] = game.ship = IHF;
+    game.quad[game.sector.x][game.sector.y] = game.ship = IHF;
     prout("Starfleet puts you in command of another ship,");
     prout("the Faerie Queene, which is antiquated but,");
     prout("still useable.");
     prout("Starfleet puts you in command of another ship,");
     prout("the Faerie Queene, which is antiquated but,");
     prout("still useable.");
@@ -208,8 +208,8 @@ void setup(int needprompt)
     game.shldchg = game.shldup = 0;
     game.inlsr = 4.0;
     game.lsupres = 4.0;
     game.shldchg = game.shldup = 0;
     game.inlsr = 4.0;
     game.lsupres = 4.0;
-    iran(GALSIZE, &game.quadx, &game.quady);
-    iran(QUADSIZE, &game.sectx, &game.secty);
+    iran(GALSIZE, &game.quadrant.x, &game.quadrant.y);
+    iran(QUADSIZE, &game.sector.x, &game.sector.y);
     game.torps = game.intorps = 10;
     game.nprobes = (int)(3.0*Rand() + 2.0);    /* Give them 2-4 of these wonders */
     game.warpfac = 5.0;
     game.torps = game.intorps = 10;
     game.nprobes = (int)(3.0*Rand() + 2.0);    /* Give them 2-4 of these wonders */
     game.warpfac = 5.0;
@@ -217,7 +217,7 @@ void setup(int needprompt)
     for (i=0; i < NDEVICES; i++) 
        game.damage[i] = 0.0;
     // Set up assorted game parameters
     for (i=0; i < NDEVICES; i++) 
        game.damage[i] = 0.0;
     // Set up assorted game parameters
-    game.batx = game.baty = 0;
+    game.battle.x = game.battle.y = 0;
     game.state.date = game.indate = 100.0*(int)(31.0*Rand()+20.0);
     game.nkinks = game.nhelp = game.resting = game.casual = 0;
     game.isatb = game.iscate = game.imine = game.icrystl = game.icraft = game.state.nplankl = 0;
     game.state.date = game.indate = 100.0*(int)(31.0*Rand()+20.0);
     game.nkinks = game.nhelp = game.resting = game.casual = 0;
     game.isatb = game.iscate = game.imine = game.icrystl = game.icraft = game.state.nplankl = 0;
@@ -276,7 +276,7 @@ void setup(int needprompt)
            contflag = FALSE;
            for (j = i-1; j > 0; j--) {
                /* Improved placement algorithm to spread out bases */
            contflag = FALSE;
            for (j = i-1; j > 0; j--) {
                /* Improved placement algorithm to spread out bases */
-               double distq = square(ix-game.state.baseqx[j]) + square(iy-game.state.baseqy[j]);
+               double distq = square(ix-game.state.baseq[j].x) + square(iy-game.state.baseq[j].y);
                if (distq < 6.0*(BASEMAX+1-game.inbase) && Rand() < 0.75) {
                    contflag = TRUE;
 #ifdef DEBUG
                if (distq < 6.0*(BASEMAX+1-game.inbase) && Rand() < 0.75) {
                    contflag = TRUE;
 #ifdef DEBUG
@@ -292,8 +292,8 @@ void setup(int needprompt)
            }
        } while (contflag);
                        
            }
        } while (contflag);
                        
-       game.state.baseqx[i] = ix;
-       game.state.baseqy[i] = iy;
+       game.state.baseq[i].x = ix;
+       game.state.baseq[i].y = iy;
        game.state.galaxy[ix][iy].starbase = 1;
        game.state.chart[ix][iy].starbase = 1;
     }
        game.state.galaxy[ix][iy].starbase = 1;
        game.state.chart[ix][iy].starbase = 1;
     }
@@ -320,8 +320,8 @@ void setup(int needprompt)
            do { /* IF debugging, put commanders by bases, always! */
 #ifdef DEBUG
                if (game.idebug && klumper <= game.inbase) {
            do { /* IF debugging, put commanders by bases, always! */
 #ifdef DEBUG
                if (game.idebug && klumper <= game.inbase) {
-                   ix = game.state.baseqx[klumper];
-                   iy = game.state.baseqy[klumper];
+                   ix = game.state.baseq[klumper].x;
+                   iy = game.state.baseq[klumper].y;
                    klumper++;
                }
                else
                    klumper++;
                }
                else
@@ -333,17 +333,17 @@ void setup(int needprompt)
                   game.state.galaxy[ix][iy].klingons > 8);
            // check for duplicate
            for (j = 1; j < i; j++)
                   game.state.galaxy[ix][iy].klingons > 8);
            // check for duplicate
            for (j = 1; j < i; j++)
-               if (game.state.cx[j]==ix && game.state.cy[j]==iy) break;
+               if (game.state.kcmdr[j].x==ix && game.state.kcmdr[j].y==iy) break;
        } while (j < i);
        game.state.galaxy[ix][iy].klingons++;
        } while (j < i);
        game.state.galaxy[ix][iy].klingons++;
-       game.state.cx[i] = ix;
-       game.state.cy[i] = iy;
+       game.state.kcmdr[i].x = ix;
+       game.state.kcmdr[i].y = iy;
     }
     // Locate planets in galaxy
     for (i = 0; i < game.inplan; i++) {
        do iran(GALSIZE, &ix, &iy); while (game.state.galaxy[ix][iy].planet);
     }
     // Locate planets in galaxy
     for (i = 0; i < game.inplan; i++) {
        do iran(GALSIZE, &ix, &iy); while (game.state.galaxy[ix][iy].planet);
-       game.state.plnets[i].x = ix;
-       game.state.plnets[i].y = iy;
+       game.state.plnets[i].w.x = ix;
+       game.state.plnets[i].w.y = iy;
        if (i < NINHAB) {
            game.state.plnets[i].pclass = M;    // All inhabited planets are class M
            game.state.plnets[i].crystals = 0;
        if (i < NINHAB) {
            game.state.plnets[i].pclass = M;    // All inhabited planets are class M
            game.state.plnets[i].crystals = 0;
@@ -367,16 +367,16 @@ void setup(int needprompt)
     if (game.state.nscrem > 0) {
        do iran(GALSIZE, &ix, &iy);
        while (game.state.galaxy[ix][iy].supernova || game.state.galaxy[ix][iy].klingons > 8);
     if (game.state.nscrem > 0) {
        do iran(GALSIZE, &ix, &iy);
        while (game.state.galaxy[ix][iy].supernova || game.state.galaxy[ix][iy].klingons > 8);
-       game.state.isx = ix;
-       game.state.isy = iy;
+       game.state.kscmdr.x = ix;
+       game.state.kscmdr.y = iy;
        game.state.galaxy[ix][iy].klingons++;
     }
     // Place thing (in tournament game, thingx == -1, don't want one!)
        game.state.galaxy[ix][iy].klingons++;
     }
     // Place thing (in tournament game, thingx == -1, don't want one!)
-    if (thingx != -1) {
-       iran(GALSIZE, &thingx, &thingy);
+    if (thing.x != -1) {
+       iran(GALSIZE, &thing.x, &thing.y);
     }
     else {
     }
     else {
-       thingx = thingy = 0;
+       thing.x = thing.y = 0;
     }
 
 //     idate = date;
     }
 
 //     idate = date;
@@ -406,14 +406,14 @@ void setup(int needprompt)
        proutn("%d starbases in ", game.inbase);
     }
     for (i = 1; i <= game.inbase; i++) {
        proutn("%d starbases in ", game.inbase);
     }
     for (i = 1; i <= game.inbase; i++) {
-       proutn(cramlc(0, game.state.baseqx[i], game.state.baseqy[i]));
+       proutn(cramlc(0, game.state.baseq[i]));
        proutn("  ");
     }
     skip(2);
     proutn("The Enterprise is currently in ");
        proutn("  ");
     }
     skip(2);
     proutn("The Enterprise is currently in ");
-    proutn(cramlc(quadrant, game.quadx, game.quady));
+    proutn(cramlc(quadrant, game.quadrant));
     proutn(" ");
     proutn(" ");
-    proutn(cramlc(sector, game.sectx, game.secty));
+    proutn(cramlc(sector, game.sector));
     skip(2);
     prout("Good Luck!");
     if (game.state.nscrem) prout("  YOU'LL NEED IT.");
     skip(2);
     prout("Good Luck!");
     if (game.state.nscrem) prout("  YOU'LL NEED IT.");
@@ -443,7 +443,7 @@ int choose(int needprompt)
                continue; // We don't want a blank entry
            }
            game.tourn = (int)aaitem;
                continue; // We don't want a blank entry
            }
            game.tourn = (int)aaitem;
-           thingx = -1;
+           thing.x = -1;
            srand((unsigned int)(int)aaitem);
            break;
        }
            srand((unsigned int)(int)aaitem);
            break;
        }
@@ -534,43 +534,43 @@ int choose(int needprompt)
     return FALSE;
 }
 
     return FALSE;
 }
 
-void dropin(int iquad, int *ix, int *iy
+void dropin(int iquad, coord *w
 {
 {
-    do iran(QUADSIZE, ix, iy);
-    while (game.quad[*ix][*iy] != IHDOT);
-    game.quad[*ix][*iy] = iquad;
+    do iran(QUADSIZE, &w->x, &w->y);
+    while (game.quad[w->x][w->y] != IHDOT);
+    game.quad[w->x][w->y] = iquad;
 }
 
 void newcnd(void) 
 {
     game.condit = IHGREEN;
     if (game.energy < 1000.0) game.condit = IHYELLOW;
 }
 
 void newcnd(void) 
 {
     game.condit = IHGREEN;
     if (game.energy < 1000.0) game.condit = IHYELLOW;
-    if (game.state.galaxy[game.quadx][game.quady].klingons || game.state.galaxy[game.quadx][game.quady].romulans)
+    if (game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons || game.state.galaxy[game.quadrant.x][game.quadrant.y].romulans)
        game.condit = IHRED;
     if (!game.alive) game.condit=IHDEAD;
 }
 
        game.condit = IHRED;
     if (!game.alive) game.condit=IHDEAD;
 }
 
-void newkling(int i, int *pix, int *piy)
+void newkling(int i, coord *pi)
 /* drop new Klingon into current quadrant */
 {
 /* drop new Klingon into current quadrant */
 {
-    dropin(IHK, pix, piy);
-    game.kx[i] = *pix;
-    game.ky[i] = *piy;
-    game.kdist[i] = game.kavgd[i] = sqrt(square(game.sectx-*pix) + square(game.secty-*piy));
+    dropin(IHK, pi);
+    game.ks[i] = *pi;
+    game.kdist[i] = game.kavgd[i] = sqrt(square(game.sector.x-pi->x) + square(game.sector.y-pi->y));
     game.kpower[i] = Rand()*150.0 +300.0 +25.0*game.skill;
 }
 
 void newqad(int shutup) 
 {
     game.kpower[i] = Rand()*150.0 +300.0 +25.0*game.skill;
 }
 
 void newqad(int shutup) 
 {
-    int i, j, ix, iy;
+    int i, j;
+    coord w;
     struct quadrant *here;
 
     game.iattak = 1;
     game.justin = 1;
     struct quadrant *here;
 
     game.iattak = 1;
     game.justin = 1;
-    game.basex = game.basey = 0;
+    game.base.x = game.base.y = 0;
     game.klhere = 0;
     game.comhere = 0;
     game.klhere = 0;
     game.comhere = 0;
-    game.plnetx = game.plnety = 0;
+    game.plnet.x = game.plnet.y = 0;
     game.ishere = 0;
     game.irhere = 0;
     game.iplnet = 0;
     game.ishere = 0;
     game.irhere = 0;
     game.iplnet = 0;
@@ -592,7 +592,7 @@ void newqad(int shutup)
     for_sectors(i)
        for_sectors(j) 
            game.quad[i][j] = IHDOT;
     for_sectors(i)
        for_sectors(j) 
            game.quad[i][j] = IHDOT;
-    here = &game.state.galaxy[game.quadx][game.quady];
+    here = &game.state.galaxy[game.quadrant.x][game.quadrant.y];
     // cope with supernova
     if (here->supernova)
        return;
     // cope with supernova
     if (here->supernova)
        return;
@@ -601,25 +601,25 @@ void newqad(int shutup)
     game.nenhere = game.klhere + game.irhere;
 
     // Position Starship
     game.nenhere = game.klhere + game.irhere;
 
     // Position Starship
-    game.quad[game.sectx][game.secty] = game.ship;
+    game.quad[game.sector.x][game.sector.y] = game.ship;
 
     if (here->klingons) {
        // Position ordinary Klingons
        for (i = 1; i <= game.klhere; i++)
 
     if (here->klingons) {
        // Position ordinary Klingons
        for (i = 1; i <= game.klhere; i++)
-           newkling(i, &ix, &iy);
+           newkling(i, &w);
        // If we need a commander, promote a Klingon
        for_commanders(i)
        // If we need a commander, promote a Klingon
        for_commanders(i)
-           if (game.state.cx[i]==game.quadx && game.state.cy[i]==game.quady) break;
+           if (game.state.kcmdr[i].x==game.quadrant.x && game.state.kcmdr[i].y==game.quadrant.y) break;
                        
        if (i <= game.state.remcom) {
                        
        if (i <= game.state.remcom) {
-           game.quad[ix][iy] = IHC;
+           game.quad[w.x][w.y] = IHC;
            game.kpower[game.klhere] = 950.0+400.0*Rand()+50.0*game.skill;
            game.comhere = 1;
        }
 
        // If we need a super-commander, promote a Klingon
            game.kpower[game.klhere] = 950.0+400.0*Rand()+50.0*game.skill;
            game.comhere = 1;
        }
 
        // If we need a super-commander, promote a Klingon
-       if (game.quadx == game.state.isx && game.quady == game.state.isy) {
-           game.quad[game.kx[1]][game.ky[1]] = IHS;
+       if (game.quadrant.x == game.state.kscmdr.x && game.quadrant.y == game.state.kscmdr.y) {
+           game.quad[game.ks[1].x][game.ks[1].y] = IHS;
            game.kpower[1] = 1175.0 + 400.0*Rand() + 125.0*game.skill;
            game.iscate = game.state.remkl>1;
            game.ishere = 1;
            game.kpower[1] = 1175.0 + 400.0*Rand() + 125.0*game.skill;
            game.iscate = game.state.remkl>1;
            game.ishere = 1;
@@ -627,29 +627,28 @@ void newqad(int shutup)
     }
     // Put in Romulans if needed
     for (i = game.klhere+1; i <= game.nenhere; i++) {
     }
     // Put in Romulans if needed
     for (i = game.klhere+1; i <= game.nenhere; i++) {
-       dropin(IHR, &ix, &iy);
-       game.kx[i] = ix;
-       game.ky[i] = iy;
-       game.kdist[i] = game.kavgd[i] = sqrt(square(game.sectx-ix) + square(game.secty-iy));
+       dropin(IHR, &w);
+       game.ks[i] = w;
+       game.kdist[i] = game.kavgd[i] = sqrt(square(game.sector.x-w.x) + square(game.sector.y-w.y));
        game.kpower[i] = Rand()*400.0 + 450.0 + 50.0*game.skill;
     }
     // If quadrant needs a starbase, put it in
     if (here->starbase)
        game.kpower[i] = Rand()*400.0 + 450.0 + 50.0*game.skill;
     }
     // If quadrant needs a starbase, put it in
     if (here->starbase)
-       dropin(IHB, &game.basex, &game.basey);
+       dropin(IHB, &game.base);
        
     // If quadrant needs a planet, put it in
     if (here->planet) {
        game.iplnet = here->planet - game.state.plnets;
        if (here->planet->inhabited == UNINHABITED)
        
     // If quadrant needs a planet, put it in
     if (here->planet) {
        game.iplnet = here->planet - game.state.plnets;
        if (here->planet->inhabited == UNINHABITED)
-           dropin(IHP, &game.plnetx, &game.plnety);
+           dropin(IHP, &game.plnet);
        else
        else
-           dropin(IHW, &game.plnetx, &game.plnety);
+           dropin(IHW, &game.plnet);
     }
     // Check for game.condition
     newcnd();
     // And finally the stars
     for (i = 1; i <= here->stars; i++) 
     }
     // Check for game.condition
     newcnd();
     // And finally the stars
     for (i = 1; i <= here->stars; i++) 
-       dropin(IHSTAR, &ix, &iy);
+       dropin(IHSTAR, &w);
 
     // Check for RNZ
     if (game.irhere > 0 && game.klhere == 0 && (!here->planet || here->planet->inhabited == UNINHABITED)) {
 
     // Check for RNZ
     if (game.irhere > 0 && game.klhere == 0 && (!here->planet || here->planet->inhabited == UNINHABITED)) {
@@ -666,15 +665,14 @@ void newqad(int shutup)
 
     if (shutup==0) {
        // Put in THING if needed
 
     if (shutup==0) {
        // Put in THING if needed
-       if (thingx == game.quadx && thingy == game.quady) {
-           dropin(IHQUEST, &ix, &iy);
-           iran(GALSIZE, &thingx, &thingy);
+       if (same(thing, game.quadrant)) {
+           dropin(IHQUEST, &w);
+           iran(GALSIZE, &thing.x, &thing.y);
            game.nenhere++;
            iqhere=1;
            game.nenhere++;
            iqhere=1;
-           game.kx[game.nenhere] = ix;
-           game.ky[game.nenhere] = iy;
+           game.ks[game.nenhere] = w;
            game.kdist[game.nenhere] = game.kavgd[game.nenhere] =
            game.kdist[game.nenhere] = game.kavgd[game.nenhere] =
-               sqrt(square(game.sectx-ix) + square(game.secty-iy));
+               sqrt(square(game.sector.x-w.x) + square(game.sector.y-w.y));
            game.kpower[game.nenhere] = Rand()*6000.0 +500.0 +250.0*game.skill;
            if (game.damage[DSRSENS] == 0.0) {
                skip(1);
            game.kpower[game.nenhere] = Rand()*6000.0 +500.0 +250.0*game.skill;
            if (game.damage[DSRSENS] == 0.0) {
                skip(1);
@@ -694,16 +692,16 @@ void newqad(int shutup)
     #endif
            ) {
            do {
     #endif
            ) {
            do {
-               game.ithx = Rand() > 0.5 ? QUADSIZE : 1;
-               game.ithy = Rand() > 0.5 ? QUADSIZE : 1;
-           } while (game.quad[game.ithx][game.ithy] != IHDOT);
-           game.quad[game.ithx][game.ithy] = IHT;
+               game.tholian.x = Rand() > 0.5 ? QUADSIZE : 1;
+               game.tholian.y = Rand() > 0.5 ? QUADSIZE : 1;
+           } while (game.quad[game.tholian.x][game.tholian.y] != IHDOT);
+           game.quad[game.tholian.x][game.tholian.y] = IHT;
            game.ithere = 1;
            game.nenhere++;
            game.ithere = 1;
            game.nenhere++;
-           game.kx[game.nenhere] = game.ithx;
-           game.ky[game.nenhere] = game.ithy;
+           game.ks[game.nenhere].x = game.tholian.x;
+           game.ks[game.nenhere].y = game.tholian.y;
            game.kdist[game.nenhere] = game.kavgd[game.nenhere] =
            game.kdist[game.nenhere] = game.kavgd[game.nenhere] =
-               sqrt(square(game.sectx-game.ithx) + square(game.secty-game.ithy));
+               sqrt(square(game.sector.x-game.tholian.x) + square(game.sector.y-game.tholian.y));
            game.kpower[game.nenhere] = Rand()*400.0 +100.0 +25.0*game.skill;
            /* Reserve unocupied corners */
            if (game.quad[1][1]==IHDOT) game.quad[1][1] = 'X';
            game.kpower[game.nenhere] = Rand()*400.0 +100.0 +25.0*game.skill;
            /* Reserve unocupied corners */
            if (game.quad[1][1]==IHDOT) game.quad[1][1] = 'X';
@@ -718,7 +716,7 @@ void newqad(int shutup)
     // Put in a few black holes
     for (i = 1; i <= 3; i++)
        if (Rand() > 0.5) 
     // Put in a few black holes
     for (i = 1; i <= 3; i++)
        if (Rand() > 0.5) 
-           dropin(IHBLANK, &ix, &iy);
+           dropin(IHBLANK, &w);
 
     // Take out X's in corners if Tholian present
     if (game.ithere) {
 
     // Take out X's in corners if Tholian present
     if (game.ithere) {
@@ -749,12 +747,12 @@ void sortkl(void)
                t = game.kavgd[j];
                game.kavgd[j] = game.kavgd[j+1];
                game.kavgd[j+1] = t;
                t = game.kavgd[j];
                game.kavgd[j] = game.kavgd[j+1];
                game.kavgd[j+1] = t;
-               k = game.kx[j];
-               game.kx[j] = game.kx[j+1];
-               game.kx[j+1] = k;
-               k = game.ky[j];
-               game.ky[j] = game.ky[j+1];
-               game.ky[j+1] = k;
+               k = game.ks[j].x;
+               game.ks[j].x = game.ks[j+1].x;
+               game.ks[j+1].x = k;
+               k = game.ks[j].y;
+               game.ks[j].y = game.ks[j+1].y;
+               game.ks[j+1].y = k;
                t = game.kpower[j];
                game.kpower[j] = game.kpower[j+1];
                game.kpower[j+1] = t;
                t = game.kpower[j];
                game.kpower[j] = game.kpower[j+1];
                game.kpower[j+1] = t;
index 32208d8cf557d1ba37798ebcdade5b36e0741bd4..b68613d21f8fe26540b763805755d387594ad55a 100644 (file)
--- a/src/sst.c
+++ b/src/sst.c
@@ -164,7 +164,8 @@ for a lot of magic numbers and refactored the heck out of it.
 static char line[128], *linep = line;
 
 struct game game;
 static char line[128], *linep = line;
 
 struct game game;
-int thingx, thingy, iqhere, iqengry;
+coord thing;
+int iqhere, iqengry;
 int iscore, iskill; // Common PLAQ
 double aaitem;
 double perdate;
 int iscore, iskill; // Common PLAQ
 double aaitem;
 double perdate;
@@ -555,14 +556,14 @@ static void makemoves(void)
                events();
                if (game.alldone) break;        // Events did us in
            }
                events();
                if (game.alldone) break;        // Events did us in
            }
-           if (game.state.galaxy[game.quadx][game.quady].supernova) { // Galaxy went Nova!
+           if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) { // Galaxy went Nova!
                atover(0);
                continue;
            }
            if (hitme && game.justin==0) {
                attack(2);
                if (game.alldone) break;
                atover(0);
                continue;
            }
            if (hitme && game.justin==0) {
                attack(2);
                if (game.alldone) break;
-               if (game.state.galaxy[game.quadx][game.quady].supernova) {      // went NOVA! 
+               if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) {    // went NOVA! 
                    atover(0);
                    hitme = TRUE;
                    continue;
                    atover(0);
                    hitme = TRUE;
                    continue;
@@ -660,22 +661,22 @@ void cramen(int i)
     proutn(s);
 }
 
     proutn(s);
 }
 
-char *cramlc(enum loctype key, int x, int y)
+char *cramlc(enum loctype key, coord w)
 {
     static char buf[32];
     buf[0] = '\0';
     if (key == quadrant) strcpy(buf, "Quadrant ");
     else if (key == sector) strcpy(buf, "Sector ");
 {
     static char buf[32];
     buf[0] = '\0';
     if (key == quadrant) strcpy(buf, "Quadrant ");
     else if (key == sector) strcpy(buf, "Sector ");
-    sprintf(buf+strlen(buf), "%d - %d", x, y);
+    sprintf(buf+strlen(buf), "%d - %d", w.x, w.y);
     return buf;
 }
 
     return buf;
 }
 
-void crmena(int i, int enemy, int key, int x, int y
+void crmena(int i, int enemy, int key, coord w
 {
     if (i == 1) proutn("***");
     cramen(enemy);
     proutn(" at ");
 {
     if (i == 1) proutn("***");
     cramen(enemy);
     proutn(" at ");
-    proutn(cramlc(key, x, y));
+    proutn(cramlc(key, w));
 }
 
 void crmshp(void) 
 }
 
 void crmshp(void) 
@@ -870,7 +871,7 @@ void debugme(void)
     }
     proutn("Induce supernova here? ");
     if (ja() != 0) {
     }
     proutn("Induce supernova here? ");
     if (ja() != 0) {
-       game.state.galaxy[game.quadx][game.quady].supernova = TRUE;
+       game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova = TRUE;
        atover(1);
     }
 }
        atover(1);
     }
 }
index 8e6e7c458cce3670ebda4916b1d2f27a1e88711f..182634d6c2da8b741ebaf6a22fc87bd529aecd7b 100644 (file)
--- a/src/sst.h
+++ b/src/sst.h
 #define for_local_enemies(i)   for (i = 1; i <= game.nenhere; i++)
 #define for_starbases(i)       for (i = 1; i <= game.state.rembase; i++)
 
 #define for_local_enemies(i)   for (i = 1; i <= game.nenhere; i++)
 #define for_starbases(i)       for (i = 1; i <= game.state.rembase; i++)
 
+typedef struct {int x; int y;} coord;
+
+#define same(c1, c2)   (c1.x == c2.x && c1.y == c2.y)
+
 typedef struct {
 typedef struct {
-    int x;     /* Quadrant location of planet */
-    int y;
+    coord w;
     enum {M=0, N=1, O=2} pclass;
     int inhabited;     /* if NZ, an index into a name array */
 #define UNINHABITED    -1
     enum {M=0, N=1, O=2} pclass;
     int inhabited;     /* if NZ, an index into a name array */
 #define UNINHABITED    -1
@@ -62,16 +65,15 @@ typedef struct {
        rembase,                // remaining bases
        starkl,                 // destroyed stars
        basekl,                 // destroyed bases
        rembase,                // remaining bases
        starkl,                 // destroyed stars
        basekl,                 // destroyed bases
-       cx[QUADSIZE+1],cy[QUADSIZE+1],  // Commander quadrant coordinates
-       baseqx[BASEMAX+1],              // Base quadrant X
-       baseqy[BASEMAX+1],              // Base quadrant Y
-       isx, isy,               // Coordinate of Super Commander
        nromrem,                // Romulans remaining
        nplankl;                // destroyed planets
        planet plnets[PLNETMAX];  // Planet information
        double date,            // stardate
            remres,             // remaining resources
            remtime;            // remaining time
        nromrem,                // Romulans remaining
        nplankl;                // destroyed planets
        planet plnets[PLNETMAX];  // Planet information
        double date,            // stardate
            remres,             // remaining resources
            remtime;            // remaining time
+    coord baseq[BASEMAX+1];    // Base quadrant coordinates
+    coord kcmdr[QUADSIZE+1];   // Commander quadrant coordinates
+    coord kscmdr;              // Supercommander quadrant coordinates
     struct quadrant {
        int stars;
        planet *planet;
     struct quadrant {
        int stars;
        planet *planet;
@@ -192,8 +194,13 @@ struct game {
     double damage[NDEVICES];   // damage encountered
     double future[NEVENTS];    // future events
     char passwd[10];           // Self Destruct password
     double damage[NDEVICES];   // damage encountered
     double future[NEVENTS];    // future events
     char passwd[10];           // Self Destruct password
-    int kx[(QUADSIZE+1)*(QUADSIZE+1)];                 // enemy sector locations
-    int ky[(QUADSIZE+1)*(QUADSIZE+1)];
+    coord ks[(QUADSIZE+1)*(QUADSIZE+1)];       // enemy sector locations
+    coord quadrant, sector;    // where we are
+    coord tholian;             // coordinates of Tholian
+    coord base;                        // position of base in current quadrant
+    coord battle;              // base coordinates being attacked
+    coord plnet;               // location of planet in quadrant
+    coord probec;      // current probe quadrant
     int inkling,       // Initial number of klingons
        inbase,         // Initial number of bases
        incom,          // Initial number of commanders
     int inkling,       // Initial number of klingons
        inbase,         // Initial number of bases
        incom,          // Initial number of commanders
@@ -204,14 +211,8 @@ struct game {
        condit,         // Condition (red/yellow/green/docked)
        torps,          // number of torpedoes
        ship,           // Ship type -- 'E' is Enterprise
        condit,         // Condition (red/yellow/green/docked)
        torps,          // number of torpedoes
        ship,           // Ship type -- 'E' is Enterprise
-       quadx,          // where we are
-       quady,          //
-       sectx,          // where we are
-       secty,          //
        length,         // length of game
        skill,          // skill level
        length,         // length of game
        skill,          // skill level
-       basex,          // position of base in current quadrant
-       basey,          //
        klhere,         // klingons here
        comhere,        // commanders here
        casual,         // causalties
        klhere,         // klingons here
        comhere,        // commanders here
        casual,         // causalties
@@ -223,8 +224,6 @@ struct game {
        justin,         // just entered quadrant
        alldone,        // game is now finished
        shldchg,        // shield is changing (affects efficiency)
        justin,         // just entered quadrant
        alldone,        // game is now finished
        shldchg,        // shield is changing (affects efficiency)
-       plnetx,         // location of planet in quadrant
-       plnety,         //
        inorbit,        // orbiting
        landed,         // party on planet (1), on ship (-1)
        iplnet,         // planet # in quadrant
        inorbit,        // orbiting
        landed,         // party on planet (1), on ship (-1)
        iplnet,         // planet # in quadrant
@@ -246,17 +245,11 @@ struct game {
        icrystl,        // dilithium crystals aboard
        tourn,          // tournament number
        thawed,         // thawed game
        icrystl,        // dilithium crystals aboard
        tourn,          // tournament number
        thawed,         // thawed game
-       batx,           // base coordinates being attacked
-       baty,           //
        ithere,         // Tholian is here 
        ithere,         // Tholian is here 
-       ithx,           // coordinates of Tholian
-       ithy,           //
        iseenit,        // seen base attack report
 #ifdef EXPERIMENTAL
        ndistr,         //* count of distress calls */ 
 #endif /* EXPERIMENTAL */
        iseenit,        // seen base attack report
 #ifdef EXPERIMENTAL
        ndistr,         //* count of distress calls */ 
 #endif /* EXPERIMENTAL */
-       probecx,        // current probe quadrant
-       probecy,        //
        proben,         // number of moves for probe
        isarmed,        // probe is armed
        nprobes;        // number of probes available
        proben,         // number of moves for probe
        isarmed,        // probe is armed
        nprobes;        // number of probes available
@@ -296,7 +289,8 @@ extern double aaitem;
 extern char citem[10];
 
 /* the Space Thingy's global state should *not* be saved! */
 extern char citem[10];
 
 /* the Space Thingy's global state should *not* be saved! */
-extern int thingx, thingy, iqhere, iqengry;
+extern coord thing;
+extern int iqhere, iqengry;
 
 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
               FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
 
 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
               FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
@@ -380,17 +374,17 @@ void newqad(int);
 int ja(void);
 void cramen(int);
 void crmshp(void);
 int ja(void);
 void cramen(int);
 void crmshp(void);
-char *cramlc(enum loctype, int, int);
+char *cramlc(enum loctype, coord w);
 double expran(double);
 double Rand(void);
 void iran(int, int *, int *);
 #define square(i) ((i)*(i))
 double expran(double);
 double Rand(void);
 void iran(int, int *, int *);
 #define square(i) ((i)*(i))
-void dropin(int, int*, int*);
+void dropin(int, coord*);
 void newcnd(void);
 void sortkl(void);
 void imove(void);
 void newcnd(void);
 void sortkl(void);
 void imove(void);
-void ram(int, int, int, int);
-void crmena(int, int, int, int, int);
+void ram(int, int, coord);
+void crmena(int, int, int, coord w);
 void deadkl(int, int, int, int, int);
 void timwrp(void);
 void movcom(void);
 void deadkl(int, int, int, int, int);
 void timwrp(void);
 void movcom(void);
@@ -428,7 +422,7 @@ void commandhook(char *, int);
 void makechart(void);
 void enqueue(char *);
 char *systemname(planet *);
 void makechart(void);
 void enqueue(char *);
 char *systemname(planet *);
-void newkling(int, int *, int *);
+void newkling(int, coord *);
 
 /* mode arguments for srscan() */
 #define SCAN_FULL              1
 
 /* mode arguments for srscan() */
 #define SCAN_FULL              1