Eliminate nasty macro holdovers.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 14 Sep 2006 20:42:27 +0000 (20:42 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 14 Sep 2006 20:42:27 +0000 (20:42 +0000)
All game structure members are now referred to by full name. Also, one
more minor step in making xio work.

14 files changed:
src/Makefile.am
src/Makefile.in
src/ai.c
src/battle.c
src/events.c
src/finish.c
src/io.c
src/moving.c
src/planets.c
src/reports.c
src/setup.c
src/sst.c
src/sst.h
src/xio.c

index 2249438d518054d2828ba4e55da31d6bdfd8dec1..2959ff1a97ead4080c384c73018e7ad3ef801200 100644 (file)
@@ -19,3 +19,7 @@ sst_SOURCES = \
 EXTRA_DIST = \
        sst.h \
        sstlinux.h
 EXTRA_DIST = \
        sst.h \
        sstlinux.h
+
+# Experimental XaW code, not yet integrated with the game
+xio: xio.o
+       gcc xio.c -lXaw3d -o xio
index 95a9820e85c10c4cc101d4a56a2f1bd76af78426..2d5b8aeae59d78a1f3e8b9a921cd874c0f064b68 100644 (file)
@@ -467,6 +467,10 @@ uninstall-am: uninstall-binPROGRAMS uninstall-info-am
        tags uninstall uninstall-am uninstall-binPROGRAMS \
        uninstall-info-am
 
        tags uninstall uninstall-am uninstall-binPROGRAMS \
        uninstall-info-am
 
+
+# Experimental XaW code, not yet integrated with the game
+xio: xio.o
+       gcc xio.c -lXaw3d -o xio
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
index a1b4bbf6f92ef101dc9ac53ed5a8b3af39f8fcde..25d58274624efd7f151058321cb3135f8e692c32 100644 (file)
--- a/src/ai.c
+++ b/src/ai.c
@@ -4,8 +4,8 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun)
 {
     int iqx, iqy, l;
 
 {
     int iqx, iqy, l;
 
-    iqx = quadx+(lookx+(QUADSIZE-1))/QUADSIZE - 1;
-    iqy = quady+(looky+(QUADSIZE-1))/QUADSIZE - 1;
+    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)
     if (!VALID_QUADRANT(iqx,iqy) ||
        game.state.galaxy[iqx][iqy].supernova ||
        game.state.galaxy[iqx][iqy].klingons > 8)
@@ -17,7 +17,7 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun)
            for_commanders(l)
                if (game.state.cx[l]==iqx && game.state.cy[l]==iqy) return 0;
            /* refuse to leave if currently attacking starbase */
            for_commanders(l)
                if (game.state.cx[l]==iqx && game.state.cy[l]==iqy) return 0;
            /* refuse to leave if currently attacking starbase */
-           if (batx==quadx && baty==quady) return 0;
+           if (game.batx==game.quadx && game.baty==game.quady) 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;
@@ -25,29 +25,29 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun)
     /* print escape message and move out of quadrant.
        We know this if either short or long range sensors are working */
     if (game.damage[DSRSENS] == 0.0 || game.damage[DLRSENS] == 0.0 ||
     /* print escape message and move out of quadrant.
        We know this if either short or long range sensors are working */
     if (game.damage[DSRSENS] == 0.0 || game.damage[DLRSENS] == 0.0 ||
-       condit == IHDOCKED) {
+       game.condit == IHDOCKED) {
        crmena(1, ienm, 2, game.kx[loccom], game.ky[loccom]);
        prout(" escapes to %s (and regains strength).",
              cramlc(quadrant, iqx, iqy));
     }
     /* handle local matters related to escape */
     game.quad[game.kx[loccom]][game.ky[loccom]] = IHDOT;
        crmena(1, ienm, 2, game.kx[loccom], game.ky[loccom]);
        prout(" escapes to %s (and regains strength).",
              cramlc(quadrant, iqx, iqy));
     }
     /* handle local matters related to escape */
     game.quad[game.kx[loccom]][game.ky[loccom]] = IHDOT;
-    game.kx[loccom] = game.kx[nenhere];
-    game.ky[loccom] = game.ky[nenhere];
-    game.kavgd[loccom] = game.kavgd[nenhere];
-    game.kpower[loccom] = game.kpower[nenhere];
-    game.kdist[loccom] = game.kdist[nenhere];
-    klhere--;
-    nenhere--;
-    if (condit != IHDOCKED) newcnd();
+    game.kx[loccom] = game.kx[game.nenhere];
+    game.ky[loccom] = game.ky[game.nenhere];
+    game.kavgd[loccom] = game.kavgd[game.nenhere];
+    game.kpower[loccom] = game.kpower[game.nenhere];
+    game.kdist[loccom] = game.kdist[game.nenhere];
+    game.klhere--;
+    game.nenhere--;
+    if (game.condit != IHDOCKED) newcnd();
     /* Handle global matters related to escape */
     /* Handle global matters related to escape */
-    game.state.galaxy[quadx][quady].klingons--;
+    game.state.galaxy[game.quadx][game.quady].klingons--;
     game.state.galaxy[iqx][iqy].klingons++;
     if (ienm==IHS) {
     game.state.galaxy[iqx][iqy].klingons++;
     if (ienm==IHS) {
-       ishere=0;
-       iscate=0;
-       ientesc=0;
-       isatb=0;
+       game.ishere=0;
+       game.iscate=0;
+       game.ientesc=0;
+       game.isatb=0;
        game.future[FSCMOVE]=0.2777+game.state.date;
        game.future[FSCDBAS]=FOREVER;
        game.state.isx=iqx;
        game.future[FSCMOVE]=0.2777+game.state.date;
        game.future[FSCDBAS]=FOREVER;
        game.state.isx=iqx;
@@ -55,13 +55,13 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun)
     }
     else {
        for_commanders(l) {
     }
     else {
        for_commanders(l) {
-           if (game.state.cx[l]==quadx && game.state.cy[l]==quady) {
+           if (game.state.cx[l]==game.quadx && game.state.cy[l]==game.quady) {
                game.state.cx[l]=iqx;
                game.state.cy[l]=iqy;
                break;
            }
        }
                game.state.cx[l]=iqx;
                game.state.cy[l]=iqy;
                break;
            }
        }
-       comhere = 0;
+       game.comhere = 0;
     }
     return 1; /* success */
 }
     }
     return 1; /* success */
 }
@@ -74,10 +74,10 @@ static void movebaddy(int comx, int comy, int loccom, int ienm)
     int krawlx, krawly;
     int success;
     int attempts;
     int krawlx, krawly;
     int success;
     int attempts;
-    /* This should probably be just comhere + ishere */
-    int nbaddys = skill >= SKILL_EXPERT ?
-       (int)((comhere*2 + ishere*2+klhere*1.23+irhere*1.5)/2.0):
-       (comhere + ishere);
+    /* This should probably be just game.comhere + game.ishere */
+    int nbaddys = game.skill >= SKILL_EXPERT ?
+       (int)((game.comhere*2 + game.ishere*2+game.klhere*1.23+game.irhere*1.5)/2.0):
+       (game.comhere + game.ishere);
     double dist1, forces;
 
     dist1 = game.kdist[loccom];
     double dist1, forces;
 
     dist1 = game.kdist[loccom];
@@ -85,7 +85,7 @@ static void movebaddy(int comx, int comy, int loccom, int ienm)
 
     /* If SC, check with spy to see if should hi-tail it */
     if (ienm==IHS &&
 
     /* If SC, check with spy to see if should hi-tail it */
     if (ienm==IHS &&
-       (game.kpower[loccom] <= 500.0 || (condit==IHDOCKED && game.damage[DPHOTON]==0))) {
+       (game.kpower[loccom] <= 500.0 || (game.condit==IHDOCKED && game.damage[DPHOTON]==0))) {
        irun = 1;
        motion = -QUADSIZE;
     }
        irun = 1;
        motion = -QUADSIZE;
     }
@@ -123,39 +123,39 @@ static void movebaddy(int comx, int comy, int loccom, int ienm)
  advantage with a 650 advantage being to hold ground, 800 to move forward
  1, 950 for two, 150 for back 4, etc. Variance of 100.
 
  advantage with a 650 advantage being to hold ground, 800 to move forward
  1, 950 for two, 150 for back 4, etc. Variance of 100.
 
- If docked, is reduced by roughly 1.75*skill, generally forcing a
+ If docked, is reduced by roughly 1.75*game.skill, generally forcing a
  retreat, especially at high skill levels.
 
  *  Motion is limited to skill level, except for SC hi-tailing it out.
  */
 
  retreat, especially at high skill levels.
 
  *  Motion is limited to skill level, except for SC hi-tailing it out.
  */
 
-       forces = game.kpower[loccom]+100.0*nenhere+400*(nbaddys-1);
-       if (shldup==0) forces += 1000; /* Good for enemy if shield is down! */
+       forces = game.kpower[loccom]+100.0*game.nenhere+400*(nbaddys-1);
+       if (game.shldup==0) forces += 1000; /* Good for enemy if shield is down! */
        if (game.damage[DPHASER] == 0.0 || game.damage[DPHOTON] == 0.0) {
            if (game.damage[DPHASER] != 0) /* phasers damaged */
                forces += 300.0;
            else
        if (game.damage[DPHASER] == 0.0 || game.damage[DPHOTON] == 0.0) {
            if (game.damage[DPHASER] != 0) /* phasers damaged */
                forces += 300.0;
            else
-               forces -= 0.2*(energy - 2500.0);
+               forces -= 0.2*(game.energy - 2500.0);
            if (game.damage[DPHOTON] != 0) /* photon torpedoes damaged */
                forces += 300.0;
            else
            if (game.damage[DPHOTON] != 0) /* photon torpedoes damaged */
                forces += 300.0;
            else
-               forces -= 50.0*torps;
+               forces -= 50.0*game.torps;
        }
        else {
            /* phasers and photon tubes both out! */
            forces += 1000.0;
        }
        motion = 0;
        }
        else {
            /* phasers and photon tubes both out! */
            forces += 1000.0;
        }
        motion = 0;
-       if (forces <= 1000.0 && condit != IHDOCKED) /* Typical situation */
+       if (forces <= 1000.0 && game.condit != IHDOCKED) /* Typical situation */
            motion = ((forces+200.0*Rand())/150.0) - 5.0;
        else {
            if (forces > 1000.0) /* Very strong -- move in for kill */
                motion = (1.0-square(Rand()))*dist1 + 1.0;
            motion = ((forces+200.0*Rand())/150.0) - 5.0;
        else {
            if (forces > 1000.0) /* Very strong -- move in for kill */
                motion = (1.0-square(Rand()))*dist1 + 1.0;
-           if (condit==IHDOCKED && (game.options & OPTION_BASE)) /* protected by base -- back off ! */
-               motion -= skill*(2.0-square(Rand()));
+           if (game.condit==IHDOCKED && (game.options & OPTION_BASE)) /* protected by base -- back off ! */
+               motion -= game.skill*(2.0-square(Rand()));
        }
 #ifdef DEBUG
        }
 #ifdef DEBUG
-       if (idebug) {
+       if (game.idebug) {
            proutn("MOTION = %1.2f", motion);
            proutn("  FORCES = %1,2f", forces);
        }
            proutn("MOTION = %1.2f", motion);
            proutn("  FORCES = %1,2f", forces);
        }
@@ -163,7 +163,7 @@ static void movebaddy(int comx, int comy, int loccom, int ienm)
        /* don't move if no motion */
        if (motion==0) return;
        /* Limit motion according to skill */
        /* don't move if no motion */
        if (motion==0) return;
        /* Limit motion according to skill */
-       if (abs(motion) > skill) motion = (motion < 0) ? -skill : skill;
+       if (abs(motion) > game.skill) motion = (motion < 0) ? -game.skill : game.skill;
     }
     /* calculate preferred number of steps */
     nsteps = motion < 0 ? -motion : motion;
     }
     /* calculate preferred number of steps */
     nsteps = motion < 0 ? -motion : motion;
@@ -171,15 +171,15 @@ static void movebaddy(int comx, int comy, int loccom, int ienm)
     if (nsteps > QUADSIZE) nsteps = QUADSIZE; /* This shouldn't be necessary */
     if (nsteps < 1) nsteps = 1; /* This shouldn't be necessary */
 #ifdef DEBUG
     if (nsteps > QUADSIZE) nsteps = QUADSIZE; /* This shouldn't be necessary */
     if (nsteps < 1) nsteps = 1; /* This shouldn't be necessary */
 #ifdef DEBUG
-    if (idebug) {
+    if (game.idebug) {
        prout("NSTEPS = %d", nsteps);
     }
 #endif
     /* Compute preferred values of delta X and Y */
        prout("NSTEPS = %d", nsteps);
     }
 #endif
     /* Compute preferred values of delta X and Y */
-    mx = sectx - comx;
-    my = secty - comy;
+    mx = game.sectx - comx;
+    my = game.secty - comy;
     if (2.0 * abs(mx) < abs(my)) mx = 0;
     if (2.0 * abs(mx) < abs(my)) mx = 0;
-    if (2.0 * abs(my) < abs(sectx-comx)) my = 0;
+    if (2.0 * abs(my) < abs(game.sectx-comx)) my = 0;
     if (mx != 0) mx = mx*motion < 0 ? -1 : 1;
     if (my != 0) my = my*motion < 0 ? -1 : 1;
     nextx = comx;
     if (mx != 0) mx = mx*motion < 0 ? -1 : 1;
     if (my != 0) my = my*motion < 0 ? -1 : 1;
     nextx = comx;
@@ -187,7 +187,7 @@ static void movebaddy(int comx, int comy, int loccom, int ienm)
     /* main move loop */
     for (ll = 0; ll < nsteps; ll++) {
 #ifdef DEBUG
     /* main move loop */
     for (ll = 0; ll < nsteps; ll++) {
 #ifdef DEBUG
-       if (idebug) {
+       if (game.idebug) {
            prout("%d", ll+1);
        }
 #endif
            prout("%d", ll+1);
        }
 #endif
@@ -215,7 +215,7 @@ static void movebaddy(int comx, int comy, int loccom, int ienm)
            }
            else if ((game.options & OPTION_RAMMING) && game.quad[lookx][looky] != IHDOT) {
                /* See if we should ram ship */
            }
            else if ((game.options & OPTION_RAMMING) && game.quad[lookx][looky] != IHDOT) {
                /* See if we should ram ship */
-               if (game.quad[lookx][looky] == ship &&
+               if (game.quad[lookx][looky] == game.ship &&
                    (ienm == IHC || ienm == IHS)) {
                    ram(1, ienm, comx, comy);
                    return;
                    (ienm == IHC || ienm == IHS)) {
                    ram(1, ienm, comx, comy);
                    return;
@@ -236,7 +236,7 @@ static void movebaddy(int comx, int comy, int loccom, int ienm)
            nextx = lookx;
            nexty = looky;
 #ifdef DEBUG
            nextx = lookx;
            nexty = looky;
 #ifdef DEBUG
-           if (idebug) {
+           if (game.idebug) {
                prout(cramlc(neither, nextx, nexty));
            }
 #endif
                prout(cramlc(neither, nextx, nexty));
            }
 #endif
@@ -251,8 +251,8 @@ static void movebaddy(int comx, int comy, int loccom, int ienm)
        game.kx[loccom] = nextx;
        game.ky[loccom] = nexty;
        game.kdist[loccom] = game.kavgd[loccom] =
        game.kx[loccom] = nextx;
        game.ky[loccom] = nexty;
        game.kdist[loccom] = game.kavgd[loccom] =
-           sqrt(square(sectx-nextx)+square(secty-nexty));
-       if (game.damage[DSRSENS] == 0 || condit == IHDOCKED) {
+           sqrt(square(game.sectx-nextx)+square(game.secty-nexty));
+       if (game.damage[DSRSENS] == 0 || game.condit == IHDOCKED) {
            proutn("***");
            cramen(ienm);
            proutn(" from %s", cramlc(2, comx, comy));
            proutn("***");
            cramen(ienm);
            proutn(" from %s", cramlc(2, comx, comy));
@@ -268,12 +268,12 @@ void movcom(void)
     int ix, iy, i;
 
 #ifdef DEBUG
     int ix, iy, i;
 
 #ifdef DEBUG
-    if (idebug) prout("MOVCOM");
+    if (game.idebug) prout("MOVCOM");
 #endif
 
     /* Figure out which Klingon is the commander (or Supercommander)
        and do move */
 #endif
 
     /* Figure out which Klingon is the commander (or Supercommander)
        and do move */
-    if (comhere) 
+    if (game.comhere) 
        for_local_enemies(i) {
            ix = game.kx[i];
            iy = game.ky[i];
        for_local_enemies(i) {
            ix = game.kx[i];
            iy = game.ky[i];
@@ -282,7 +282,7 @@ void movcom(void)
                break;
            }
        }
                break;
            }
        }
-    if (ishere) 
+    if (game.ishere) 
        for_local_enemies(i) {
            ix = game.kx[i];
            iy = game.ky[i];
        for_local_enemies(i) {
            ix = game.kx[i];
            iy = game.ky[i];
@@ -294,7 +294,7 @@ void movcom(void)
     /* if skill level is high, move other Klingons and Romulans too!
        Move these last so they can base their actions on what the
        commander(s) do. */
     /* if skill level is high, move other Klingons and Romulans too!
        Move these last so they can base their actions on what the
        commander(s) do. */
-    if (skill >= SKILL_EXPERT && (game.options & OPTION_MVBADDY)) 
+    if (game.skill >= SKILL_EXPERT && (game.options & OPTION_MVBADDY)) 
        for_local_enemies(i) {
            ix = game.kx[i];
            iy = game.ky[i];
        for_local_enemies(i) {
            ix = game.kx[i];
            iy = game.ky[i];
@@ -309,7 +309,7 @@ static int movescom(int iqx, int iqy, int flag, int *ipage)
 {
     int i;
 
 {
     int i;
 
-    if ((iqx==quadx && iqy==quady) ||
+    if ((iqx==game.quadx && iqy==game.quady) ||
        !VALID_QUADRANT(iqx, iqy) ||
        game.state.galaxy[iqx][iqy].supernova ||
        game.state.galaxy[iqx][iqy].klingons > 8) 
        !VALID_QUADRANT(iqx, iqy) ||
        game.state.galaxy[iqx][iqy].supernova ||
        game.state.galaxy[iqx][iqy].klingons > 8) 
@@ -319,40 +319,40 @@ static int movescom(int iqx, int iqy, int flag, int *ipage)
        for_starbases(i)
            if (game.state.baseqx[i]==iqx && game.state.baseqy[i]==iqy) return 1;
     }
        for_starbases(i)
            if (game.state.baseqx[i]==iqx && game.state.baseqy[i]==iqy) return 1;
     }
-    if (justin && !iscate) return 1;
+    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++;
     /* 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++;
-    if (ishere) {
+    if (game.ishere) {
        /* SC has scooted, Remove him from current quadrant */
        /* SC has scooted, Remove him from current quadrant */
-       iscate=0;
-       isatb=0;
-       ishere=0;
-       ientesc=0;
+       game.iscate=0;
+       game.isatb=0;
+       game.ishere=0;
+       game.ientesc=0;
        game.future[FSCDBAS]=FOREVER;
        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.future[FSCDBAS]=FOREVER;
        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[nenhere];
-       game.ky[i] = game.ky[nenhere];
-       game.kdist[i] = game.kdist[nenhere];
-       game.kavgd[i] = game.kavgd[nenhere];
-       game.kpower[i] = game.kpower[nenhere];
-       klhere--;
-       nenhere--;
-       if (condit!=IHDOCKED) newcnd();
+       game.kx[i] = game.kx[game.nenhere];
+       game.ky[i] = game.ky[game.nenhere];
+       game.kdist[i] = game.kdist[game.nenhere];
+       game.kavgd[i] = game.kavgd[game.nenhere];
+       game.kpower[i] = game.kpower[game.nenhere];
+       game.klhere--;
+       game.nenhere--;
+       if (game.condit!=IHDOCKED) newcnd();
        sortkl();
     }
     /* check for a helpful planet */
        sortkl();
     }
     /* check for a helpful planet */
-    for (i = 0; i < inplan; i++) {
+    for (i = 0; i < game.inplan; i++) {
        if (game.state.plnets[i].x==game.state.isx && game.state.plnets[i].y==game.state.isy &&
            game.state.plnets[i].crystals == 1) {
            /* destroy the planet */
            DESTROY(&game.state.plnets[i]);
            game.state.galaxy[game.state.isx][game.state.isy].planets -= 1;
        if (game.state.plnets[i].x==game.state.isx && game.state.plnets[i].y==game.state.isy &&
            game.state.plnets[i].crystals == 1) {
            /* destroy the planet */
            DESTROY(&game.state.plnets[i]);
            game.state.galaxy[game.state.isx][game.state.isy].planets -= 1;
-           if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED) {
+           if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED) {
                if (*ipage==0) pause_game(1);
                *ipage = 1;
                prout("Lt. Uhura-  \"Captain, Starfleet Intelligence reports");
                if (*ipage==0) pause_game(1);
                *ipage = 1;
                prout("Lt. Uhura-  \"Captain, Starfleet Intelligence reports");
@@ -375,20 +375,20 @@ void scom(int *ipage)
     double bdist[BASEMAX+1];
     int flag;
 #ifdef DEBUG
     double bdist[BASEMAX+1];
     int flag;
 #ifdef DEBUG
-    if (idebug) prout("SCOM");
+    if (game.idebug) prout("SCOM");
 #endif
 
     /* Decide on being active or passive */
 #endif
 
     /* Decide on being active or passive */
-    flag = ((NKILLC+NKILLK)/(game.state.date+0.01-indate) < 0.1*skill*(skill+1.0) ||
-           (game.state.date-indate) < 3.0);
-    if (iscate==0 && flag) {
+    flag = ((NKILLC+NKILLK)/(game.state.date+0.01-game.indate) < 0.1*game.skill*(game.skill+1.0) ||
+           (game.state.date-game.indate) < 3.0);
+    if (game.iscate==0 && flag) {
        /* compute move away from Enterprise */
        /* compute move away from Enterprise */
-       ideltax = game.state.isx-quadx;
-       ideltay = game.state.isy-quady;
+       ideltax = game.state.isx-game.quadx;
+       ideltay = game.state.isy-game.quady;
        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-quady;
-           ideltay = quadx-game.state.isx;
+           ideltax = game.state.isy-game.quady;
+           ideltay = game.quadx-game.state.isx;
        }
     }
     else {
        }
     }
     else {
@@ -432,8 +432,8 @@ void scom(int *ipage)
            i = basetbl[i2];    /* bug in original had it not finding nearest*/
            ibqx = game.state.baseqx[i];
            ibqy = game.state.baseqy[i];
            i = basetbl[i2];    /* bug in original had it not finding nearest*/
            ibqx = game.state.baseqx[i];
            ibqy = game.state.baseqy[i];
-           if ((ibqx == quadx && ibqy == quady) ||
-               (ibqx == batx && ibqy == baty) ||
+           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) 
                continue;
                game.state.galaxy[ibqx][ibqy].supernova ||
                game.state.galaxy[ibqx][ibqy].klingons > 8) 
                continue;
@@ -504,17 +504,17 @@ void scom(int *ipage)
     else for_starbases(i) {
        ibqx = game.state.baseqx[i];
        ibqy = game.state.baseqy[i];
     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 != batx && game.state.isy != baty) {
+       if (ibqx==game.state.isx && ibqy == game.state.isy && game.state.isx != game.batx && game.state.isy != game.baty) {
            /* attack the base */
            if (flag) return; /* no, don't attack base! */
            /* attack the base */
            if (flag) return; /* no, don't attack base! */
-           iseenit = 0;
-           isatb=1;
+           game.iseenit = 0;
+           game.isatb=1;
            game.future[FSCDBAS] = game.state.date + 1.0 +2.0*Rand();
            if (game.future[FCDBAS] < FOREVER) game.future[FSCDBAS] +=
                game.future[FCDBAS]-game.state.date;
            game.future[FSCDBAS] = game.state.date + 1.0 +2.0*Rand();
            if (game.future[FCDBAS] < FOREVER) game.future[FSCDBAS] +=
                game.future[FCDBAS]-game.state.date;
-           if (game.damage[DRADIO] > 0 && condit != IHDOCKED)
+           if (game.damage[DRADIO] > 0 && game.condit != IHDOCKED)
                return; /* no warning */
                return; /* no warning */
-           iseenit = 1;
+           game.iseenit = 1;
            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 ");
@@ -523,21 +523,21 @@ void scom(int *ipage)
            prout("   reports that it is under attack from the Klingon Super-commander.");
            proutn("   It can survive until stardate %d.\"",
                   (int)game.future[FSCDBAS]);
            prout("   reports that it is under attack from the Klingon Super-commander.");
            proutn("   It can survive until stardate %d.\"",
                   (int)game.future[FSCDBAS]);
-           if (resting==0) return;
+           if (game.resting==0) return;
            prout("Mr. Spock-  \"Captain, shall we cancel the rest period?\"");
            if (ja()==0) return;
            prout("Mr. Spock-  \"Captain, shall we cancel the rest period?\"");
            if (ja()==0) return;
-           resting = 0;
-           Time = 0.0; /* actually finished */
+           game.resting = 0;
+           game.optime = 0.0; /* actually finished */
            return;
        }
     }
     /* Check for intelligence report */
     if (
 #ifdef DEBUG
            return;
        }
     }
     /* Check for intelligence report */
     if (
 #ifdef DEBUG
-       idebug==0 &&
+       game.idebug==0 &&
 #endif
        (Rand() > 0.2 ||
 #endif
        (Rand() > 0.2 ||
-        (game.damage[DRADIO] > 0.0 && condit != IHDOCKED) ||
+        (game.damage[DRADIO] > 0.0 && game.condit != IHDOCKED) ||
         !game.state.galaxy[game.state.isx][game.state.isy].charted))
        return;
     if (*ipage==0) pause_game(1);
         !game.state.galaxy[game.state.isx][game.state.isy].charted))
        return;
     if (*ipage==0) pause_game(1);
@@ -553,49 +553,49 @@ void movetho(void)
 {
     int idx, idy, im, i, dum, my;
     /* Move the Tholian */
 {
     int idx, idy, im, i, dum, my;
     /* Move the Tholian */
-    if (ithere==0 || justin == 1) return;
+    if (game.ithere==0 || game.justin == 1) return;
 
 
-    if (ithx == 1 && ithy == 1) {
+    if (game.ithx == 1 && game.ithy == 1) {
        idx = 1; idy = QUADSIZE;
     }
        idx = 1; idy = QUADSIZE;
     }
-    else if (ithx == 1 && ithy == QUADSIZE) {
+    else if (game.ithx == 1 && game.ithy == QUADSIZE) {
        idx = QUADSIZE; idy = QUADSIZE;
     }
        idx = QUADSIZE; idy = QUADSIZE;
     }
-    else if (ithx == QUADSIZE && ithy == QUADSIZE) {
+    else if (game.ithx == QUADSIZE && game.ithy == QUADSIZE) {
        idx = QUADSIZE; idy = 1;
     }
        idx = QUADSIZE; idy = 1;
     }
-    else if (ithx == QUADSIZE && ithy == 1) {
+    else if (game.ithx == QUADSIZE && game.ithy == 1) {
        idx = 1; idy = 1;
     }
     else {
        /* something is wrong! */
        idx = 1; idy = 1;
     }
     else {
        /* something is wrong! */
-       ithere = 0;
+       game.ithere = 0;
        return;
     }
 
     /* Do nothing if we are blocked */
     if (game.quad[idx][idy]!= IHDOT && game.quad[idx][idy]!= IHWEB) return;
        return;
     }
 
     /* Do nothing if we are blocked */
     if (game.quad[idx][idy]!= IHDOT && game.quad[idx][idy]!= IHWEB) return;
-    game.quad[ithx][ithy] = IHWEB;
+    game.quad[game.ithx][game.ithy] = IHWEB;
 
 
-    if (ithx != idx) {
+    if (game.ithx != idx) {
        /* move in x axis */
        /* move in x axis */
-       im = fabs((double)idx - ithx)/((double)idx - ithx);
-       while (ithx != idx) {
-           ithx += im;
-           if (game.quad[ithx][ithy]==IHDOT) game.quad[ithx][ithy] = IHWEB;
+       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;
        }
     }
        }
     }
-    else if (ithy != idy) {
+    else if (game.ithy != idy) {
        /* move in y axis */
        /* move in y axis */
-       im = fabs((double)idy - ithy)/((double)idy - ithy);
-       while (ithy != idy) {
-           ithy += im;
-           if (game.quad[ithx][ithy]==IHDOT) game.quad[ithx][ithy] = IHWEB;
+       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;
        }
     }
        }
     }
-    game.quad[ithx][ithy] = IHT;
-    game.kx[nenhere]=ithx;
-    game.ky[nenhere]=ithy;
+    game.quad[game.ithx][game.ithy] = IHT;
+    game.kx[game.nenhere]=game.ithx;
+    game.ky[game.nenhere]=game.ithy;
 
     /* check to see if all holes plugged */
     for_sectors(i) {
 
     /* check to see if all holes plugged */
     for_sectors(i) {
@@ -605,11 +605,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[ithx][ithy]=IHWEB;
+    game.quad[game.ithx][game.ithy]=IHWEB;
     dropin(IHBLANK, &dum, &my);
     dropin(IHBLANK, &dum, &my);
-    crmena(1,IHT, 2, ithx, ithy);
+    crmena(1,IHT, 2, game.ithx, game.ithy);
     prout(" completes web.");
     prout(" completes web.");
-    ithere = ithx = ithy = 0;
-    nenhere--;
+    game.ithere = game.ithx = game.ithy = 0;
+    game.nenhere--;
     return;
 }
     return;
 }
index 374b3822693972a1ec22291b1ad716a2ca5c599c..b8ffbcbb4eeb143c842a11159f4b4cc4ce5e466a 100644 (file)
@@ -5,7 +5,7 @@ void doshield(int i)
     int key;
     enum {NONE, SHUP, SHDN, NRG} action = NONE;
 
     int key;
     enum {NONE, SHUP, SHDN, NRG} action = NONE;
 
-    ididit = 0;
+    game.ididit = 0;
 
     if (i == 2) action = SHUP;
     else {
 
     if (i == 2) action = SHUP;
     else {
@@ -35,7 +35,7 @@ void doshield(int i)
                prout("Shields damaged and down.");
                return;
            }
                prout("Shields damaged and down.");
                return;
            }
-           else if (shldup) {
+           else if (game.shldup) {
                proutn("Shields are up. Do you want them down? ");
                if (ja()) action = SHDN;
                else {
                proutn("Shields are up. Do you want them down? ");
                if (ja()) action = SHDN;
                else {
@@ -55,31 +55,31 @@ void doshield(int i)
     }
     switch (action) {
     case SHUP: /* raise shields */
     }
     switch (action) {
     case SHUP: /* raise shields */
-       if (shldup) {
+       if (game.shldup) {
            prout("Shields already up.");
            return;
        }
            prout("Shields already up.");
            return;
        }
-       shldup = 1;
-       shldchg = 1;
-       if (condit != IHDOCKED) energy -= 50.0;
+       game.shldup = 1;
+       game.shldchg = 1;
+       if (game.condit != IHDOCKED) game.energy -= 50.0;
        prout("Shields raised.");
        prout("Shields raised.");
-       if (energy <= 0) {
+       if (game.energy <= 0) {
            skip(1);
            prout("Shields raising uses up last of energy.");
            finish(FNRG);
            return;
        }
            skip(1);
            prout("Shields raising uses up last of energy.");
            finish(FNRG);
            return;
        }
-       ididit=1;
+       game.ididit=1;
        return;
     case SHDN:
        return;
     case SHDN:
-       if (shldup==0) {
+       if (game.shldup==0) {
            prout("Shields already down.");
            return;
        }
            prout("Shields already down.");
            return;
        }
-       shldup=0;
-       shldchg=1;
+       game.shldup=0;
+       game.shldchg=1;
        prout("Shields lowered.");
        prout("Shields lowered.");
-       ididit=1;
+       game.ididit=1;
        return;
     case NRG:
        while (scan() != IHREAL) {
        return;
     case NRG:
        while (scan() != IHREAL) {
@@ -88,33 +88,33 @@ void doshield(int i)
        }
        chew();
        if (aaitem==0) return;
        }
        chew();
        if (aaitem==0) return;
-       if (aaitem > energy) {
+       if (aaitem > game.energy) {
            prout("Insufficient ship energy.");
            return;
        }
            prout("Insufficient ship energy.");
            return;
        }
-       ididit = 1;
-       if (shield+aaitem >= inshld) {
+       game.ididit = 1;
+       if (game.shield+aaitem >= game.inshld) {
            prout("Shield energy maximized.");
            prout("Shield energy maximized.");
-           if (shield+aaitem > inshld) {
+           if (game.shield+aaitem > game.inshld) {
                prout("Excess energy requested returned to ship energy");
            }
                prout("Excess energy requested returned to ship energy");
            }
-           energy -= inshld-shield;
-           shield = inshld;
+           game.energy -= game.inshld-game.shield;
+           game.shield = game.inshld;
            return;
        }
            return;
        }
-       if (aaitem < 0.0 && energy-aaitem > inenrg) {
+       if (aaitem < 0.0 && game.energy-aaitem > game.inenrg) {
            /* Prevent shield drain loophole */
            skip(1);
            prout("Engineering to bridge--");
            prout("  Scott here. Power circuit problem, Captain.");
            prout("  I can't drain the shields.");
            /* Prevent shield drain loophole */
            skip(1);
            prout("Engineering to bridge--");
            prout("  Scott here. Power circuit problem, Captain.");
            prout("  I can't drain the shields.");
-           ididit = 0;
+           game.ididit = 0;
            return;
        }
            return;
        }
-       if (shield+aaitem < 0) {
+       if (game.shield+aaitem < 0) {
            prout("All shield energy transferred to ship.");
            prout("All shield energy transferred to ship.");
-           energy += shield;
-           shield = 0.0;
+           game.energy += game.shield;
+           game.shield = 0.0;
            return;
        }
        proutn("Scotty- \"");
            return;
        }
        proutn("Scotty- \"");
@@ -122,8 +122,8 @@ void doshield(int i)
            prout("Transferring energy to shields.\"");
        else
            prout("Draining energy from shields.\"");
            prout("Transferring energy to shields.\"");
        else
            prout("Draining energy from shields.\"");
-       shield += aaitem;
-       energy -= aaitem;
+       game.shield += aaitem;
+       game.energy -= aaitem;
        return;
     case NONE:;        /* avoid gcc warning */
     }
        return;
     case NONE:;        /* avoid gcc warning */
     }
@@ -151,22 +151,22 @@ void ram(int ibumpd, int ienm, int ix, int iy)
     crmena(0, ienm, 2, ix, iy);
     if (ibumpd) proutn(" (original position)");
     skip(1);
     crmena(0, ienm, 2, ix, iy);
     if (ibumpd) proutn(" (original position)");
     skip(1);
-    deadkl(ix, iy, ienm, sectx, secty);
+    deadkl(ix, iy, ienm, game.sectx, game.secty);
     proutn("***");
     crmshp();
     prout(" heavily damaged.");
     icas = 10.0+20.0*Rand();
     prout("***Sickbay reports %d casualties", icas);
     proutn("***");
     crmshp();
     prout(" heavily damaged.");
     icas = 10.0+20.0*Rand();
     prout("***Sickbay reports %d casualties", icas);
-    casual += icas;
+    game.casual += icas;
     for (l=0; l < NDEVICES; l++) {
        if (l == DDRAY) 
            continue; // Don't damage deathray 
        if (game.damage[l] < 0) 
            continue;
     for (l=0; l < NDEVICES; l++) {
        if (l == DDRAY) 
            continue; // Don't damage deathray 
        if (game.damage[l] < 0) 
            continue;
-       extradm = (10.0*type*Rand()+1.0)*damfac;
-       game.damage[l] += Time + extradm; /* Damage for at least time of travel! */
+       extradm = (10.0*type*Rand()+1.0)*game.damfac;
+       game.damage[l] += game.optime + extradm; /* Damage for at least time of travel! */
     }
     }
-    shldup = 0;
+    game.shldup = 0;
     if (KLINGREM) {
        pause_game(2);
        dreprt();
     if (KLINGREM) {
        pause_game(2);
        dreprt();
@@ -189,7 +189,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
     if (fabs(deltay) > bigger) bigger = fabs(deltay);
     deltax /= bigger;
     deltay /= bigger;
     if (fabs(deltay) > bigger) bigger = fabs(deltay);
     deltax /= bigger;
     deltay /= bigger;
-    if (game.damage[DSRSENS]==0 || condit==IHDOCKED) 
+    if (game.damage[DSRSENS]==0 || game.condit==IHDOCKED) 
        setwnd(srscan_window);
     else 
        setwnd(message_window);
        setwnd(srscan_window);
     else 
        setwnd(message_window);
@@ -219,7 +219,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
            *hit = fabs(*hit);
            newcnd(); /* we're blown out of dock */
            /* We may be displaced. */
            *hit = fabs(*hit);
            newcnd(); /* we're blown out of dock */
            /* We may be displaced. */
-           if (landed==1 || condit==IHDOCKED) return; /* Cheat if on a planet */
+           if (game.landed==1 || game.condit==IHDOCKED) return; /* Cheat if on a planet */
            ang = angle + 2.5*(Rand()-0.5);
            temp = fabs(sin(ang));
            if (fabs(cos(ang)) > temp) temp = fabs(cos(ang));
            ang = angle + 2.5*(Rand()-0.5);
            temp = fabs(sin(ang));
            if (fabs(cos(ang)) > temp) temp = fabs(cos(ang));
@@ -236,8 +236,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;
            }
-           sectx = jx;
-           secty = jy;
+           game.sectx = jx;
+           game.secty = jy;
            crmshp();
            shoved = 1;
            break;
            crmshp();
            shoved = 1;
            break;
@@ -298,7 +298,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
            skip(1);
            prout("***STARBASE DESTROYED..");
            for_starbases(ll) {
            skip(1);
            prout("***STARBASE DESTROYED..");
            for_starbases(ll) {
-               if (game.state.baseqx[ll]==quadx && game.state.baseqy[ll]==quady) {
+               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];
                    break;
                    game.state.baseqx[ll]=game.state.baseqx[game.state.rembase];
                    game.state.baseqy[ll]=game.state.baseqy[game.state.rembase];
                    break;
@@ -306,9 +306,9 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
            }
            game.quad[ix][iy]=IHDOT;
            game.state.rembase--;
            }
            game.quad[ix][iy]=IHDOT;
            game.state.rembase--;
-           basex=basey=0;
-           game.state.galaxy[quadx][quady].starbase--;
-           game.state.chart[quadx][quady].starbase--;
+           game.basex=game.basey=0;
+           game.state.galaxy[game.quadx][game.quady].starbase--;
+           game.state.chart[game.quadx][game.quady].starbase--;
            game.state.basekl++;
            newcnd();
            return;
            game.state.basekl++;
            newcnd();
            return;
@@ -316,12 +316,12 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
            crmena(1, iquad, 2, ix, iy);
            prout(" destroyed.");
            game.state.nplankl++;
            crmena(1, iquad, 2, ix, iy);
            prout(" destroyed.");
            game.state.nplankl++;
-           game.state.galaxy[quadx][quady].planets--;
-           DESTROY(&game.state.plnets[iplnet]);
-           iplnet = 0;
-           plnetx = plnety = 0;
+           game.state.galaxy[game.quadx][game.quady].planets--;
+           DESTROY(&game.state.plnets[game.iplnet]);
+           game.iplnet = 0;
+           game.plnetx = game.plnety = 0;
            game.quad[ix][iy] = IHDOT;
            game.quad[ix][iy] = IHDOT;
-           if (landed==1) {
+           if (game.landed==1) {
                /* captain perishes on planet */
                finish(FDPLANET);
            }
                /* captain perishes on planet */
                finish(FDPLANET);
            }
@@ -371,8 +371,8 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
            h1 = fabs(h1);
            if (h1 >= 600) {
                game.quad[ix][iy] = IHDOT;
            h1 = fabs(h1);
            if (h1 >= 600) {
                game.quad[ix][iy] = IHDOT;
-               ithere = 0;
-               ithx = ithy = 0;
+               game.ithere = 0;
+               game.ithx = game.ithy = 0;
                deadkl(ix, iy, iquad, ix, iy);
                return;
            }
                deadkl(ix, iy, iquad, ix, iy);
                return;
            }
@@ -384,8 +384,8 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
            }
            prout(" disappears.");
            game.quad[ix][iy] = IHWEB;
            }
            prout(" disappears.");
            game.quad[ix][iy] = IHWEB;
-           ithere = ithx = ithy = 0;
-           nenhere--;
+           game.ithere = game.ithx = game.ithy = 0;
+           game.nenhere--;
            {
                int dum, my;
                dropin(IHBLANK, &dum, &my);
            {
                int dum, my;
                dropin(IHBLANK, &dum, &my);
@@ -409,7 +409,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
        game.quad[ix][iy]=IHDOT;
        prout(" displaced by blast to %s ", cramlc(sector, jx, jy));
        for_local_enemies(ll)
        game.quad[ix][iy]=IHDOT;
        prout(" displaced by blast to %s ", cramlc(sector, jx, jy));
        for_local_enemies(ll)
-           game.kdist[ll] = game.kavgd[ll] = sqrt(square(sectx-game.kx[ll])+square(secty-game.ky[ll]));
+           game.kdist[ll] = game.kavgd[ll] = sqrt(square(game.sectx-game.kx[ll])+square(game.secty-game.ky[ll]));
        sortkl();
        return;
     }
        sortkl();
        return;
     }
@@ -424,7 +424,7 @@ static void fry(double hit)
     int ktr=1, l, ll, j, cdam[NDEVICES];
 
     /* a critical hit occured */
     int ktr=1, l, ll, j, cdam[NDEVICES];
 
     /* a critical hit occured */
-    if (hit < (275.0-25.0*skill)*(1.0+0.5*Rand())) return;
+    if (hit < (275.0-25.0*game.skill)*(1.0+0.5*Rand())) return;
 
     ncrit = 1.0 + hit/(500.0+100.0*Rand());
     proutn("***CRITICAL HIT--");
 
     ncrit = 1.0 + hit/(500.0+100.0*Rand());
     proutn("***CRITICAL HIT--");
@@ -434,9 +434,9 @@ static void fry(double hit)
            j = NDEVICES*Rand();
            /* Cheat to prevent shuttle damage unless on ship */
        } while 
            j = NDEVICES*Rand();
            /* Cheat to prevent shuttle damage unless on ship */
        } while 
-             (game.damage[j]<0.0 || (j==DSHUTTL && iscraft!=1) || j==DDRAY);
+             (game.damage[j]<0.0 || (j==DSHUTTL && game.iscraft!=1) || j==DDRAY);
        cdam[l] = j;
        cdam[l] = j;
-       extradm = (hit*damfac)/(ncrit*(75.0+25.0*Rand()));
+       extradm = (hit*game.damfac)/(ncrit*(75.0+25.0*Rand()));
        game.damage[j] += extradm;
        if (l > 0) {
            for (ll=2; ll<=l && j != cdam[ll-1]; ll++) ;
        game.damage[j] += extradm;
        if (l > 0) {
            for (ll=2; ll<=l && j != cdam[ll-1]; ll++) ;
@@ -448,9 +448,9 @@ static void fry(double hit)
        proutn(device[j]);
     }
     prout(" damaged.");
        proutn(device[j]);
     }
     prout(" damaged.");
-    if (game.damage[DSHIELD] && shldup) {
+    if (game.damage[DSHIELD] && game.shldup) {
        prout("***Shields knocked down.");
        prout("***Shields knocked down.");
-       shldup=0;
+       game.shldup=0;
     }
 }
 
     }
 }
 
@@ -462,30 +462,30 @@ void attack(int torps_ok)
     double hit;
     double pfac, dustfac, hitmax=0.0, hittot=0.0, chgfac=1.0, r;
 
     double hit;
     double pfac, dustfac, hitmax=0.0, hittot=0.0, chgfac=1.0, r;
 
-    iattak = 1;
-    if (alldone) return;
+    game.iattak = 1;
+    if (game.alldone) return;
 #ifdef DEBUG
 #ifdef DEBUG
-    if (idebug) prout("ATTACK!");
+    if (game.idebug) prout("ATTACK!");
 #endif
 
 #endif
 
-    if (ithere) movetho();
+    if (game.ithere) movetho();
 
 
-    if (neutz) { /* The one chance not to be attacked */
-       neutz = 0;
+    if (game.neutz) { /* The one chance not to be attacked */
+       game.neutz = 0;
        return;
     }
        return;
     }
-    if ((((comhere || ishere) && (justin == 0)) || skill == SKILL_EMERITUS)&&(torps_ok!=0)) movcom();
-    if (nenhere==0 || (nenhere==1 && iqhere && iqengry==0)) return;
-    pfac = 1.0/inshld;
-    if (shldchg == 1) chgfac = 0.25+0.5*Rand();
+    if ((((game.comhere || game.ishere) && (game.justin == 0)) || game.skill == SKILL_EMERITUS)&&(torps_ok!=0)) movcom();
+    if (game.nenhere==0 || (game.nenhere==1 && iqhere && iqengry==0)) return;
+    pfac = 1.0/game.inshld;
+    if (game.shldchg == 1) chgfac = 0.25+0.5*Rand();
     skip(1);
     skip(1);
-    if (skill <= SKILL_FAIR) i = 2;
+    if (game.skill <= SKILL_FAIR) i = 2;
     for_local_enemies(l) {
        if (game.kpower[l] < 0) continue;       /* too weak to attack */
        /* compute hit strength and diminsh shield power */
        r = Rand();
        /* Increase chance of photon torpedos if docked or enemy energy low */
     for_local_enemies(l) {
        if (game.kpower[l] < 0) continue;       /* too weak to attack */
        /* compute hit strength and diminsh shield power */
        r = Rand();
        /* Increase chance of photon torpedos if docked or enemy energy low */
-       if (condit == IHDOCKED) r *= 0.25;
+       if (game.condit == IHDOCKED) r *= 0.25;
        if (game.kpower[l] < 500) r *= 0.25; 
        jx = game.kx[l];
        jy = game.ky[l];
        if (game.kpower[l] < 500) r *= 0.25; 
        jx = game.kx[l];
        jy = game.ky[l];
@@ -498,14 +498,14 @@ void attack(int torps_ok)
            (iquad==IHQUEST && r > 0.05);
        if (itflag) {
            /* Enemy uses phasers */
            (iquad==IHQUEST && r > 0.05);
        if (itflag) {
            /* Enemy uses phasers */
-           if (condit == IHDOCKED) continue; /* Don't waste the effort! */
+           if (game.condit == IHDOCKED) continue; /* Don't waste the effort! */
            attempt = 1; /* Attempt to attack */
            dustfac = 0.8+0.05*Rand();
            hit = game.kpower[l]*pow(dustfac,game.kavgd[l]);
            game.kpower[l] *= 0.75;
        }
        else { /* Enemy used photon torpedo */
            attempt = 1; /* Attempt to attack */
            dustfac = 0.8+0.05*Rand();
            hit = game.kpower[l]*pow(dustfac,game.kavgd[l]);
            game.kpower[l] *= 0.75;
        }
        else { /* Enemy used photon torpedo */
-           double course = 1.90985*atan2((double)secty-jy, (double)jx-sectx);
+           double course = 1.90985*atan2((double)game.secty-jy, (double)jx-game.sectx);
            hit = 0;
            proutn("***TORPEDO INCOMING");
            if (game.damage[DSRSENS] <= 0.0) {
            hit = 0;
            proutn("***TORPEDO INCOMING");
            if (game.damage[DSRSENS] <= 0.0) {
@@ -519,22 +519,22 @@ void attack(int torps_ok)
            torpedo(course, r, jx, jy, &hit, 1, 1);
            if (KLINGREM==0) 
                finish(FWON); /* Klingons did themselves in! */
            torpedo(course, r, jx, jy, &hit, 1, 1);
            if (KLINGREM==0) 
                finish(FWON); /* Klingons did themselves in! */
-           if (game.state.galaxy[quadx][quady].supernova || alldone) 
+           if (game.state.galaxy[game.quadx][game.quady].supernova || game.alldone) 
                return; /* Supernova or finished */
            if (hit == 0) continue;
        }
                return; /* Supernova or finished */
            if (hit == 0) continue;
        }
-       if (shldup != 0 || shldchg != 0 || condit==IHDOCKED) {
+       if (game.shldup != 0 || game.shldchg != 0 || game.condit==IHDOCKED) {
            /* shields will take hits */
            /* shields will take hits */
-           double absorb, hitsh, propor = pfac*shield*(condit==IHDOCKED ? 2.1 : 1.0);
+           double absorb, hitsh, propor = pfac*game.shield*(game.condit==IHDOCKED ? 2.1 : 1.0);
            if(propor < 0.1) propor = 0.1;
            hitsh = propor*chgfac*hit+1.0;
            atackd=1;
            absorb = 0.8*hitsh;
            if(propor < 0.1) propor = 0.1;
            hitsh = propor*chgfac*hit+1.0;
            atackd=1;
            absorb = 0.8*hitsh;
-           if (absorb > shield) absorb = shield;
-           shield -= absorb;
+           if (absorb > game.shield) absorb = game.shield;
+           game.shield -= absorb;
            hit -= hitsh;
            hit -= hitsh;
-           if (condit==IHDOCKED) dock(0);
-           if (propor > 0.1 && hit < 0.005*energy) continue;
+           if (game.condit==IHDOCKED) dock(0);
+           if (propor > 0.1 && hit < 0.005*game.energy) continue;
        }
        /* It's a hit -- print out hit size */
        atackd = 1; /* We weren't going to check casualties, etc. if
        }
        /* It's a hit -- print out hit size */
        atackd = 1; /* We weren't going to check casualties, etc. if
@@ -542,7 +542,7 @@ void attack(int torps_ok)
                       doesn't make any sense, so I've fixed it */
        ihurt = 1;
        proutn("%d unit hit", (int)hit);
                       doesn't make any sense, so I've fixed it */
        ihurt = 1;
        proutn("%d unit hit", (int)hit);
-       if ((game.damage[DSRSENS] > 0 && itflag) || skill<=SKILL_FAIR) {
+       if ((game.damage[DSRSENS] > 0 && itflag) || game.skill<=SKILL_FAIR) {
            proutn(" on the ");
            crmshp();
        }
            proutn(" on the ");
            crmshp();
        }
@@ -555,20 +555,20 @@ void attack(int torps_ok)
        if (hit > hitmax) hitmax = hit;
        hittot += hit;
        fry(hit);
        if (hit > hitmax) hitmax = hit;
        hittot += hit;
        fry(hit);
-       prout("Hit %g energy %g", hit, energy);
-       energy -= hit;
-       if (condit==IHDOCKED) 
+       prout("Hit %g energy %g", hit, game.energy);
+       game.energy -= hit;
+       if (game.condit==IHDOCKED) 
            dock(0);
     }
            dock(0);
     }
-    if (energy <= 0) {
+    if (game.energy <= 0) {
        /* Returning home upon your shield, not with it... */
        finish(FBATTLE);
        return;
     }
        /* Returning home upon your shield, not with it... */
        finish(FBATTLE);
        return;
     }
-    if (attempt == 0 && condit == IHDOCKED)
+    if (attempt == 0 && game.condit == IHDOCKED)
        prout("***Enemies decide against attacking your ship.");
     if (atackd == 0) return;
        prout("***Enemies decide against attacking your ship.");
     if (atackd == 0) return;
-    percent = 100.0*pfac*shield+0.5;
+    percent = 100.0*pfac*game.shield+0.5;
     if (ihurt==0) {
        /* Shields fully protect ship */
        proutn("Enemy attack reduces shield strength to ");
     if (ihurt==0) {
        /* Shields fully protect ship */
        proutn("Enemy attack reduces shield strength to ");
@@ -576,12 +576,12 @@ void attack(int torps_ok)
     else {
        /* Print message if starship suffered hit(s) */
        skip(1);
     else {
        /* Print message if starship suffered hit(s) */
        skip(1);
-       proutn("Energy left %2d    shields ", (int)energy);
-       if (shldup) proutn("up ");
+       proutn("Energy left %2d    shields ", (int)game.energy);
+       if (game.shldup) proutn("up ");
        else if (game.damage[DSHIELD] == 0) proutn("down ");
        else proutn("damaged, ");
     }
        else if (game.damage[DSHIELD] == 0) proutn("down ");
        else proutn("damaged, ");
     }
-    prout("%d%%,   torpedoes left %d", percent, torps);
+    prout("%d%%,   torpedoes left %d", percent, game.torps);
     /* Check if anyone was hurt */
     if (hitmax >= 200 || hittot >= 500) {
        int icas= hittot*Rand()*0.015;
     /* Check if anyone was hurt */
     if (hitmax >= 200 || hittot >= 500) {
        int icas= hittot*Rand()*0.015;
@@ -589,7 +589,7 @@ void attack(int torps_ok)
            skip(1);
            prout("Mc Coy-  \"Sickbay to bridge.  We suffered %d casualties", icas);
            prout("   in that last attack.\"");
            skip(1);
            prout("Mc Coy-  \"Sickbay to bridge.  We suffered %d casualties", icas);
            prout("   in that last attack.\"");
-           casual += icas;
+           game.casual += icas;
        }
     }
     /* After attack, reset average distance to enemies */
        }
     }
     /* After attack, reset average distance to enemies */
@@ -610,13 +610,13 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy)
     /* 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[quadx][quady].romulans--;
-       irhere--;
+       game.state.galaxy[game.quadx][game.quady].romulans--;
+       game.irhere--;
        game.state.nromrem--;
     }
     else if (type == IHT) {
        /* Killed a Tholian */
        game.state.nromrem--;
     }
     else if (type == IHT) {
        /* Killed a Tholian */
-       ithere = 0;
+       game.ithere = 0;
     }
     else if (type == IHQUEST) {
        /* Killed a Thingy */
     }
     else if (type == IHQUEST) {
        /* Killed a Thingy */
@@ -624,13 +624,13 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy)
     }
     else {
        /* Some type of a Klingon */
     }
     else {
        /* Some type of a Klingon */
-       game.state.galaxy[quadx][quady].klingons--;
-       klhere--;
+       game.state.galaxy[game.quadx][game.quady].klingons--;
+       game.klhere--;
        switch (type) {
        case IHC:
        switch (type) {
        case IHC:
-           comhere = 0;
+           game.comhere = 0;
            for_commanders (i)
            for_commanders (i)
-               if (game.state.cx[i]==quadx && game.state.cy[i]==quady) break;
+               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.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;
@@ -638,14 +638,14 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy)
            game.state.remcom--;
            game.future[FTBEAM] = FOREVER;
            if (game.state.remcom != 0)
            game.state.remcom--;
            game.future[FTBEAM] = FOREVER;
            if (game.state.remcom != 0)
-               game.future[FTBEAM] = game.state.date + expran(1.0*incom/game.state.remcom);
+               game.future[FTBEAM] = game.state.date + expran(1.0*game.incom/game.state.remcom);
            break;
        case IHK:
            game.state.remkl--;
            break;
        case IHS:
            game.state.nscrem--;
            break;
        case IHK:
            game.state.remkl--;
            break;
        case IHS:
            game.state.nscrem--;
-           ishere = game.state.isx = game.state.isy = isatb = iscate = 0;
+           game.ishere = game.state.isx = game.state.isy = game.isatb = game.iscate = 0;
            game.future[FSCMOVE] = game.future[FSCDBAS] = FOREVER;
            break;
        }
            game.future[FSCMOVE] = game.future[FSCDBAS] = FOREVER;
            break;
        }
@@ -658,25 +658,25 @@ 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);
 
 
     game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom);
 
-    /* Remove enemy ship from arrays describing local conditions */
-    if (game.future[FCDBAS] < FOREVER && batx==quadx && baty==quady && type==IHC)
+    /* Remove enemy ship from arrays describing local game.conditions */
+    if (game.future[FCDBAS] < FOREVER && game.batx==game.quadx && game.baty==game.quady && type==IHC)
        game.future[FCDBAS] = FOREVER;
     for_local_enemies(i)
        if (game.kx[i]==ix && game.ky[i]==iy) break;
        game.future[FCDBAS] = FOREVER;
     for_local_enemies(i)
        if (game.kx[i]==ix && game.ky[i]==iy) break;
-    nenhere--;
-    if (i <= nenhere)  {
-       for (j=i; j<=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.kpower[j] = game.kpower[j+1];
            game.kavgd[j] = game.kdist[j] = game.kdist[j+1];
        }
     }
            game.kx[j] = game.kx[j+1];
            game.ky[j] = game.ky[j+1];
            game.kpower[j] = game.kpower[j+1];
            game.kavgd[j] = game.kdist[j] = game.kdist[j+1];
        }
     }
-    game.kx[nenhere+1] = 0;
-    game.ky[nenhere+1] = 0;
-    game.kdist[nenhere+1] = 0;
-    game.kavgd[nenhere+1] = 0;
-    game.kpower[nenhere+1] = 0;
+    game.kx[game.nenhere+1] = 0;
+    game.ky[game.nenhere+1] = 0;
+    game.kdist[game.nenhere+1] = 0;
+    game.kavgd[game.nenhere+1] = 0;
+    game.kpower[game.nenhere+1] = 0;
     return;
 }
 
     return;
 }
 
@@ -688,8 +688,8 @@ static int targetcheck(double x, double y, double *course)
        huh();
        return 1;
     }
        huh();
        return 1;
     }
-    deltx = 0.1*(y - secty);
-    delty = 0.1*(sectx - x);
+    deltx = 0.1*(y - game.secty);
+    delty = 0.1*(game.sectx - 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,");
@@ -708,14 +708,14 @@ void photon(void)
     double r, dummy;
     int key, n, i, osuabor;
 
     double r, dummy;
     int key, n, i, osuabor;
 
-    ididit = 0;
+    game.ididit = 0;
 
     if (game.damage[DPHOTON]) {
        prout("Photon tubes damaged.");
        chew();
        return;
     }
 
     if (game.damage[DPHOTON]) {
        prout("Photon tubes damaged.");
        chew();
        return;
     }
-    if (torps == 0) {
+    if (game.torps == 0) {
        prout("No torpedoes left.");
        chew();
        return;
        prout("No torpedoes left.");
        chew();
        return;
@@ -727,7 +727,7 @@ void photon(void)
            return;
        }
        else if (key == IHEOL) {
            return;
        }
        else if (key == IHEOL) {
-           prout("%d torpedoes left.", torps);
+           prout("%d torpedoes left.", game.torps);
            proutn("Number of torpedoes to fire- ");
            key = scan();
        }
            proutn("Number of torpedoes to fire- ");
            key = scan();
        }
@@ -743,7 +743,7 @@ void photon(void)
                key = IHEOL;
                return;
            }
                key = IHEOL;
                return;
            }
-           if (n <= torps) break;
+           if (n <= game.torps) break;
            chew();
            key = IHEOL;
        }
            chew();
            key = IHEOL;
        }
@@ -797,11 +797,11 @@ void photon(void)
            if (targetcheck(targ[i][1], targ[i][2], &course[i])) return;
        }
     }
            if (targetcheck(targ[i][1], targ[i][2], &course[i])) return;
        }
     }
-    ididit = 1;
+    game.ididit = 1;
     /* Loop for moving <n> torpedoes */
     osuabor = 0;
     for (i = 1; i <= n && !osuabor; i++) {
     /* Loop for moving <n> torpedoes */
     osuabor = 0;
     for (i = 1; i <= n && !osuabor; i++) {
-       if (condit != IHDOCKED) torps--;
+       if (game.condit != IHDOCKED) game.torps--;
        r = (Rand()+Rand())*0.5 -0.5;
        if (fabs(r) >= 0.47) {
            /* misfire! */
        r = (Rand()+Rand())*0.5 -0.5;
        if (fabs(r) >= 0.47) {
            /* misfire! */
@@ -816,14 +816,14 @@ void photon(void)
            osuabor=1;
            if (Rand() <= 0.2) {
                prout("***Photon tubes damaged by misfire.");
            osuabor=1;
            if (Rand() <= 0.2) {
                prout("***Photon tubes damaged by misfire.");
-               game.damage[DPHOTON] = damfac*(1.0+2.0*Rand());
+               game.damage[DPHOTON] = game.damfac*(1.0+2.0*Rand());
                break;
            }
        }
                break;
            }
        }
-       if (shldup || condit == IHDOCKED) 
-           r *= 1.0 + 0.0001*shield;
-       torpedo(course[i], r, sectx, secty, &dummy, i, n);
-       if (alldone || game.state.galaxy[quadx][quady].supernova)
+       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)
            return;
     }
     if (KLINGREM==0) finish(FWON);
            return;
     }
     if (KLINGREM==0) finish(FWON);
@@ -837,7 +837,7 @@ static void overheat(double rpow)
        double chekbrn = (rpow-1500.)*0.00038;
        if (Rand() <= chekbrn) {
            prout("Weapons officer Sulu-  \"Phasers overheated, sir.\"");
        double chekbrn = (rpow-1500.)*0.00038;
        if (Rand() <= chekbrn) {
            prout("Weapons officer Sulu-  \"Phasers overheated, sir.\"");
-           game.damage[DPHASER] = damfac*(1.0 + Rand()) * (1.0+chekbrn);
+           game.damage[DPHASER] = game.damfac*(1.0 + Rand()) * (1.0+chekbrn);
        }
     }
 }
        }
     }
 }
@@ -855,10 +855,10 @@ static int checkshctrl(double rpow)
     /* Something bad has happened */
     prouts("***RED ALERT!  RED ALERT!");
     skip(2);
     /* Something bad has happened */
     prouts("***RED ALERT!  RED ALERT!");
     skip(2);
-    hit = rpow*shield/inshld;
-    energy -= rpow+hit*0.8;
-    shield -= hit*0.2;
-    if (energy <= 0.0) {
+    hit = rpow*game.shield/game.inshld;
+    game.energy -= rpow+hit*0.8;
+    game.shield -= hit*0.2;
+    if (game.energy <= 0.0) {
        prouts("Sulu-  \"Captain! Shield malf***********************\"");
        skip(1);
        stars();
        prouts("Sulu-  \"Captain! Shield malf***********************\"");
        skip(1);
        stars();
@@ -875,7 +875,7 @@ static int checkshctrl(double rpow)
        skip(1);
        prout("McCoy to bridge- \"Severe radiation burns, Jim.");
        prout("  %d casualties so far.\"", icas);
        skip(1);
        prout("McCoy to bridge- \"Severe radiation burns, Jim.");
        prout("  %d casualties so far.\"", icas);
-       casual -= icas;
+       game.casual -= icas;
     }
     skip(1);
     prout("Phaser energy dispersed by shields.");
     }
     skip(1);
     prout("Phaser energy dispersed by shields.");
@@ -896,7 +896,7 @@ void phasers(void)
     skip(1);
     /* SR sensors and Computer */
     if (game.damage[DSRSENS]+game.damage[DCOMPTR] > 0) ipoop = 0;
     skip(1);
     /* SR sensors and Computer */
     if (game.damage[DSRSENS]+game.damage[DCOMPTR] > 0) ipoop = 0;
-    if (condit == IHDOCKED) {
+    if (game.condit == IHDOCKED) {
        prout("Phasers can't be fired through base shields.");
        chew();
        return;
        prout("Phasers can't be fired through base shields.");
        chew();
        return;
@@ -906,13 +906,13 @@ void phasers(void)
        chew();
        return;
     }
        chew();
        return;
     }
-    if (shldup) {
+    if (game.shldup) {
        if (game.damage[DSHCTRL]) {
            prout("High speed shield control damaged.");
            chew();
            return;
        }
        if (game.damage[DSHCTRL]) {
            prout("High speed shield control damaged.");
            chew();
            return;
        }
-       if (energy <= 200.0) {
+       if (game.energy <= 200.0) {
            prout("Insufficient energy to activate high-speed shield control.");
            chew();
            return;
            prout("Insufficient energy to activate high-speed shield control.");
            chew();
            return;
@@ -926,7 +926,7 @@ void phasers(void)
        key=scan();
        if (key == IHALPHA) {
            if (isit("manual")) {
        key=scan();
        if (key == IHALPHA) {
            if (isit("manual")) {
-               if (nenhere==0) {
+               if (game.nenhere==0) {
                    prout("There is no enemy present to select.");
                    chew();
                    key = IHEOL;
                    prout("There is no enemy present to select.");
                    chew();
                    key = IHEOL;
@@ -938,11 +938,11 @@ void phasers(void)
                }
            }
            else if (isit("automatic")) {
                }
            }
            else if (isit("automatic")) {
-               if ((!ipoop) && nenhere != 0) {
+               if ((!ipoop) && game.nenhere != 0) {
                    automode = FORCEMAN;
                }
                else {
                    automode = FORCEMAN;
                }
                else {
-                   if (nenhere==0)
+                   if (game.nenhere==0)
                        prout("Energy will be expended into space.");
                    automode = AUTOMATIC;
                    key = scan();
                        prout("Energy will be expended into space.");
                    automode = AUTOMATIC;
                    key = scan();
@@ -957,7 +957,7 @@ void phasers(void)
            }
        }
        else if (key == IHREAL) {
            }
        }
        else if (key == IHREAL) {
-           if (nenhere==0) {
+           if (game.nenhere==0) {
                prout("Energy will be expended into space.");
                automode = AUTOMATIC;
            }
                prout("Energy will be expended into space.");
                automode = AUTOMATIC;
            }
@@ -968,7 +968,7 @@ void phasers(void)
        }
        else {
            /* IHEOL */
        }
        else {
            /* IHEOL */
-           if (nenhere==0) {
+           if (game.nenhere==0) {
                prout("Energy will be expended into space.");
                automode = AUTOMATIC;
            }
                prout("Energy will be expended into space.");
                automode = AUTOMATIC;
            }
@@ -985,9 +985,9 @@ void phasers(void)
            no = 1;
            key = scan();
        }
            no = 1;
            key = scan();
        }
-       if (key != IHREAL && nenhere != 0) {
+       if (key != IHREAL && game.nenhere != 0) {
            prout("Phasers locked on target. Energy available: %.2f",
            prout("Phasers locked on target. Energy available: %.2f",
-                 ifast?energy-200.0:energy,1,2);
+                 ifast?game.energy-200.0:game.energy,1,2);
        }
        irec=0;
        do {
        }
        irec=0;
        do {
@@ -1002,13 +1002,13 @@ void phasers(void)
            key = scan();
            if (key!=IHREAL) return;
            rpow = aaitem;
            key = scan();
            if (key!=IHREAL) return;
            rpow = aaitem;
-           if (rpow > (ifast?energy-200:energy)) {
+           if (rpow > (ifast?game.energy-200:game.energy)) {
                proutn("Energy available= %.2f",
                proutn("Energy available= %.2f",
-                      ifast?energy-200:energy);
+                      ifast?game.energy-200:game.energy);
                skip(1);
                key = IHEOL;
            }
                skip(1);
                key = IHEOL;
            }
-       } while (rpow > (ifast?energy-200:energy));
+       } while (rpow > (ifast?game.energy-200:game.energy));
        if (rpow<=0) {
            /* chicken out */
            chew();
        if (rpow<=0) {
            /* chicken out */
            chew();
@@ -1018,13 +1018,13 @@ void phasers(void)
            no = 1;
        }
        if (ifast) {
            no = 1;
        }
        if (ifast) {
-           energy -= 200; /* Go and do it! */
+           game.energy -= 200; /* Go and do it! */
            if (checkshctrl(rpow)) return;
        }
        chew();
            if (checkshctrl(rpow)) return;
        }
        chew();
-       energy -= rpow;
+       game.energy -= rpow;
        extra = rpow;
        extra = rpow;
-       if (nenhere) {
+       if (game.nenhere) {
            extra = 0.0;
            powrem = rpow;
            for_local_enemies(i) {
            extra = 0.0;
            powrem = rpow;
            for_local_enemies(i) {
@@ -1040,12 +1040,12 @@ void phasers(void)
            }
            if (powrem > 0.0) extra += powrem;
            hittem(hits);
            }
            if (powrem > 0.0) extra += powrem;
            hittem(hits);
-           ididit=1;
+           game.ididit=1;
        }
        }
-       if (extra > 0 && alldone == 0) {
-           if (ithere) {
+       if (extra > 0 && game.alldone == 0) {
+           if (game.ithere) {
                proutn("*** Tholian web absorbs ");
                proutn("*** Tholian web absorbs ");
-               if (nenhere>0) proutn("excess ");
+               if (game.nenhere>0) proutn("excess ");
                prout("phaser energy.");
            }
            else {
                prout("phaser energy.");
            }
            else {
@@ -1070,17 +1070,17 @@ void phasers(void)
        }
     case MANUAL:
        rpow = 0.0;
        }
     case MANUAL:
        rpow = 0.0;
-       for (k = 1; k <= nenhere;) {
+       for (k = 1; k <= game.nenhere;) {
            int ii = game.kx[k], jj = game.ky[k];
            int ienm = game.quad[ii][jj];
            if (msgflag) {
                proutn("Energy available= %.2f",
            int ii = game.kx[k], jj = game.ky[k];
            int ienm = game.quad[ii][jj];
            if (msgflag) {
                proutn("Energy available= %.2f",
-                      energy-.006-(ifast?200:0));
+                      game.energy-.006-(ifast?200:0));
                skip(1);
                msgflag = 0;
                rpow = 0.0;
            }
                skip(1);
                msgflag = 0;
                rpow = 0.0;
            }
-           if (game.damage[DSRSENS] && !(abs(sectx-ii) < 2 && abs(secty-jj) < 2) &&
+           if (game.damage[DSRSENS] && !(abs(game.sectx-ii) < 2 && abs(game.secty-jj) < 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.");
@@ -1129,7 +1129,7 @@ void phasers(void)
            rpow += aaitem;
            /* If total requested is too much, inform and start over */
                                
            rpow += aaitem;
            /* If total requested is too much, inform and start over */
                                
-           if (rpow > (ifast?energy-200:energy)) {
+           if (rpow > (ifast?game.energy-200:game.energy)) {
                prout("Available energy exceeded -- try again.");
                chew();
                return;
                prout("Available energy exceeded -- try again.");
                chew();
                return;
@@ -1145,18 +1145,18 @@ void phasers(void)
        if (key == IHALPHA && isit("no")) {
            no = 1;
        }
        if (key == IHALPHA && isit("no")) {
            no = 1;
        }
-       energy -= rpow;
+       game.energy -= rpow;
        chew();
        if (ifast) {
        chew();
        if (ifast) {
-           energy -= 200.0;
+           game.energy -= 200.0;
            if (checkshctrl(rpow)) return;
        }
        hittem(hits);
            if (checkshctrl(rpow)) return;
        }
        hittem(hits);
-       ididit=1;
+       game.ididit=1;
     case NOTSET:;      /* avoid gcc warning */
     }
     /* Say shield raised or malfunction, if necessary */
     case NOTSET:;      /* avoid gcc warning */
     }
     /* Say shield raised or malfunction, if necessary */
-    if (alldone) 
+    if (game.alldone) 
        return;
     if (ifast) {
        skip(1);
        return;
     if (ifast) {
        skip(1);
@@ -1165,13 +1165,13 @@ void phasers(void)
                prout("Sulu-  \"Sir, the high-speed shield control has malfunctioned . . .");
                prouts("         CLICK   CLICK   POP  . . .");
                prout(" No  response, sir!");
                prout("Sulu-  \"Sir, the high-speed shield control has malfunctioned . . .");
                prouts("         CLICK   CLICK   POP  . . .");
                prout(" No  response, sir!");
-               shldup = 0;
+               game.shldup = 0;
            }
            else
                prout("Shields raised.");
        }
        else
            }
            else
                prout("Shields raised.");
        }
        else
-           shldup = 0;
+           game.shldup = 0;
     }
     overheat(rpow);
 }
     }
     overheat(rpow);
 }
@@ -1179,7 +1179,7 @@ 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=nenhere, k=1, kk=1, ii, jj, ienm;
+    int nenhr2=game.nenhere, k=1, kk=1, ii, jj, ienm;
 
     skip(1);
 
 
     skip(1);
 
@@ -1208,7 +1208,7 @@ void hittem(double *hits)
        if (kpow == 0) {
            deadkl(ii, jj, ienm, ii, jj);
            if (KLINGREM==0) finish(FWON);
        if (kpow == 0) {
            deadkl(ii, jj, ienm, ii, jj);
            if (KLINGREM==0) finish(FWON);
-           if (alldone) return;
+           if (game.alldone) return;
            kk--; /* don't do the increment */
        }
        else /* decide whether or not to emasculate klingon */
            kk--; /* don't do the increment */
        }
        else /* decide whether or not to emasculate klingon */
index 589a83821ad22a3489a01dc0fb10334be4a3dbca..ac674a27e581c0c749378c6fe1a547d7246de548 100644 (file)
@@ -4,11 +4,11 @@
 void events(void) 
 {
     int ictbeam=0, ipage=0, istract=0, line, i=0, j, k, l, ixhold=0, iyhold=0;
 void events(void) 
 {
     int ictbeam=0, ipage=0, istract=0, line, i=0, j, k, l, ixhold=0, iyhold=0;
-    double fintim = game.state.date + Time, datemin, xtime, repair, yank=0;
+    double fintim = game.state.date + game.optime, datemin, xtime, repair, yank=0;
     int radio_was_broken;
 
 #ifdef DEBUG
     int radio_was_broken;
 
 #ifdef DEBUG
-    if (idebug) prout("EVENTS");
+    if (game.idebug) prout("EVENTS");
 #endif
 
     radio_was_broken = (game.damage[DRADIO] != 0.0);
 #endif
 
     radio_was_broken = (game.damage[DRADIO] != 0.0);
@@ -16,7 +16,7 @@ void events(void)
     for (;;) {
        /* Select earliest extraneous event, line==0 if no events */
        line = FSPY;
     for (;;) {
        /* Select earliest extraneous event, line==0 if no events */
        line = FSPY;
-       if (alldone) return;
+       if (game.alldone) return;
        datemin = fintim;
        for (l = 1; l < NEVENTS; l++)
            if (game.future[l] < datemin) {
        datemin = fintim;
        for (l = 1; l < NEVENTS; l++)
            if (game.future[l] < datemin) {
@@ -33,17 +33,17 @@ void events(void)
            return;
        }
        /* Is life support adequate? */
            return;
        }
        /* Is life support adequate? */
-       if (game.damage[DLIFSUP] && condit != IHDOCKED) {
-           if (lsupres < xtime && game.damage[DLIFSUP] > lsupres) {
+       if (game.damage[DLIFSUP] && game.condit != IHDOCKED) {
+           if (game.lsupres < xtime && game.damage[DLIFSUP] > game.lsupres) {
                finish(FLIFESUP);
                return;
            }
                finish(FLIFESUP);
                return;
            }
-           lsupres -= xtime;
-           if (game.damage[DLIFSUP] <= xtime) lsupres = inlsr;
+           game.lsupres -= xtime;
+           if (game.damage[DLIFSUP] <= xtime) game.lsupres = game.inlsr;
        }
        /* Fix devices */
        repair = xtime;
        }
        /* Fix devices */
        repair = xtime;
-       if (condit == IHDOCKED) repair /= docfac;
+       if (game.condit == IHDOCKED) repair /= game.docfac;
        /* Don't fix Deathray here */
        for (l=0; l<NDEVICES; l++)
            if (game.damage[l] > 0.0 && l != DDRAY)
        /* Don't fix Deathray here */
        for (l=0; l<NDEVICES; l++)
            if (game.damage[l] > 0.0 && l != DDRAY)
@@ -53,37 +53,37 @@ void events(void)
            prout("Lt. Uhura- \"Captain, the sub-space radio is working and");
            prout("   surveillance reports are coming in.");
            skip(1);
            prout("Lt. Uhura- \"Captain, the sub-space radio is working and");
            prout("   surveillance reports are coming in.");
            skip(1);
-           if (iseenit==0) {
+           if (game.iseenit==0) {
                attakreport(0);
                attakreport(0);
-               iseenit = 1;
+               game.iseenit = 1;
            }
            rechart();
            prout("   The star chart is now up to date.\"");
            skip(1);
        }
        /* Cause extraneous event LINE to occur */
            }
            rechart();
            prout("   The star chart is now up to date.\"");
            skip(1);
        }
        /* Cause extraneous event LINE to occur */
-       Time -= xtime;
+       game.optime -= xtime;
        switch (line) {
        case FSNOVA: /* Supernova */
            if (ipage==0) pause_game(1);
            ipage=1;
            snova(0,0);
        switch (line) {
        case FSNOVA: /* Supernova */
            if (ipage==0) pause_game(1);
            ipage=1;
            snova(0,0);
-           game.future[FSNOVA] = game.state.date + expran(0.5*intime);
-           if (game.state.galaxy[quadx][quady].supernova) return;
+           game.future[FSNOVA] = game.state.date + expran(0.5*game.intime);
+           if (game.state.galaxy[game.quadx][game.quady].supernova) return;
            break;
        case FSPY: /* Check with spy to see if S.C. should tractor beam */
            if (game.state.nscrem == 0 ||
                ictbeam+istract > 0 ||
            break;
        case FSPY: /* Check with spy to see if S.C. should tractor beam */
            if (game.state.nscrem == 0 ||
                ictbeam+istract > 0 ||
-               condit==IHDOCKED || isatb==1 || iscate==1) return;
-           if (ientesc ||
-               (energy < 2000 && torps < 4 && shield < 1250) ||
-               (game.damage[DPHASER]>0 && (game.damage[DPHOTON]>0 || torps < 4)) ||
+               game.condit==IHDOCKED || game.isatb==1 || game.iscate==1) return;
+           if (game.ientesc ||
+               (game.energy < 2000 && game.torps < 4 && game.shield < 1250) ||
+               (game.damage[DPHASER]>0 && (game.damage[DPHOTON]>0 || game.torps < 4)) ||
                (game.damage[DSHIELD] > 0 &&
                (game.damage[DSHIELD] > 0 &&
-                (energy < 2500 || game.damage[DPHASER] > 0) &&
-                (torps < 5 || game.damage[DPHOTON] > 0))) {
+                (game.energy < 2500 || game.damage[DPHASER] > 0) &&
+                (game.torps < 5 || game.damage[DPHOTON] > 0))) {
                /* Tractor-beam her! */
                istract=1;
                /* Tractor-beam her! */
                istract=1;
-               yank = square(game.state.isx-quadx) + square(game.state.isy-quady);
+               yank = square(game.state.isx-game.quadx) + square(game.state.isy-game.quady);
                /********* fall through to FTBEAM code ***********/
            }
            else return;
                /********* fall through to FTBEAM code ***********/
            }
            else return;
@@ -94,11 +94,11 @@ 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]-quadx) + square(game.state.cy[i]-quady);
-               if (istract || condit == IHDOCKED || yank == 0) {
+               yank = square(game.state.cx[i]-game.quadx) + square(game.state.cy[i]-game.quady);
+               if (istract || game.condit == IHDOCKED || yank == 0) {
                    /* Drats! Have to reschedule */
                    /* Drats! Have to reschedule */
-                   game.future[FTBEAM] = game.state.date + Time +
-                       expran(1.5*intime/game.state.remcom);
+                   game.future[FTBEAM] = game.state.date + game.optime +
+                       expran(1.5*game.intime/game.state.remcom);
                    break;
                }
            }
                    break;
                }
            }
@@ -106,7 +106,7 @@ void events(void)
            yank = sqrt(yank);
            if (ipage==0) pause_game(1);
            ipage=1;
            yank = sqrt(yank);
            if (ipage==0) pause_game(1);
            ipage=1;
-           Time = (10.0/(7.5*7.5))*yank; /* 7.5 is yank rate (warp 7.5) */
+           game.optime = (10.0/(7.5*7.5))*yank; /* 7.5 is yank rate (warp 7.5) */
            ictbeam = 1;
            skip(1);
            proutn("***");
            ictbeam = 1;
            skip(1);
            proutn("***");
@@ -114,60 +114,60 @@ void events(void)
            prout(" caught in long range tractor beam--");
            /* If Kirk & Co. screwing around on planet, handle */
            atover(1); /* atover(1) is Grab */
            prout(" caught in long range tractor beam--");
            /* If Kirk & Co. screwing around on planet, handle */
            atover(1); /* atover(1) is Grab */
-           if (alldone) return;
-           if (icraft == 1) { /* Caught in Galileo? */
+           if (game.alldone) return;
+           if (game.icraft == 1) { /* Caught in Galileo? */
                finish(FSTRACTOR);
                return;
            }
            /* Check to see if shuttle is aboard */
                finish(FSTRACTOR);
                return;
            }
            /* Check to see if shuttle is aboard */
-           if (iscraft==0) {
+           if (game.iscraft==0) {
                skip(1);
                if (Rand() > 0.5) {
                    prout("Galileo, left on the planet surface, is captured");
                    prout("by aliens and made into a flying McDonald's.");
                    game.damage[DSHUTTL] = -10;
                skip(1);
                if (Rand() > 0.5) {
                    prout("Galileo, left on the planet surface, is captured");
                    prout("by aliens and made into a flying McDonald's.");
                    game.damage[DSHUTTL] = -10;
-                   iscraft = -1;
+                   game.iscraft = -1;
                }
                else {
                    prout("Galileo, left on the planet surface, is well hidden.");
                }
            }
            if (line==0) {
                }
                else {
                    prout("Galileo, left on the planet surface, is well hidden.");
                }
            }
            if (line==0) {
-               quadx = game.state.isx;
-               quady = game.state.isy;
+               game.quadx = game.state.isx;
+               game.quady = game.state.isy;
            }
            else {
            }
            else {
-               quadx = game.state.cx[i];
-               quady = game.state.cy[i];
+               game.quadx = game.state.cx[i];
+               game.quady = game.state.cy[i];
            }
            }
-           iran(QUADSIZE, &sectx, &secty);
+           iran(QUADSIZE, &game.sectx, &game.secty);
            crmshp();
            proutn(" is pulled to ");
            crmshp();
            proutn(" is pulled to ");
-           proutn(cramlc(quadrant, quadx, quady));
+           proutn(cramlc(quadrant, game.quadx, game.quady));
            proutn(", ");
            proutn(", ");
-           prout(cramlc(sector, sectx, secty));
-           if (resting) {
+           prout(cramlc(sector, game.sectx, game.secty));
+           if (game.resting) {
                prout("(Remainder of rest/repair period cancelled.)");
                prout("(Remainder of rest/repair period cancelled.)");
-               resting = 0;
+               game.resting = 0;
            }
            }
-           if (shldup==0) {
-               if (game.damage[DSHIELD]==0 && shield > 0) {
+           if (game.shldup==0) {
+               if (game.damage[DSHIELD]==0 && game.shield > 0) {
                    doshield(2); /* Shldsup */
                    doshield(2); /* Shldsup */
-                   shldchg=0;
+                   game.shldchg=0;
                }
                else prout("(Shields not currently useable.)");
            }
            newqad(0);
            /* Adjust finish time to time of tractor beaming */
                }
                else prout("(Shields not currently useable.)");
            }
            newqad(0);
            /* Adjust finish time to time of tractor beaming */
-           fintim = game.state.date+Time;
+           fintim = game.state.date+game.optime;
            attack(0);
            if (game.state.remcom <= 0) game.future[FTBEAM] = FOREVER;
            attack(0);
            if (game.state.remcom <= 0) game.future[FTBEAM] = FOREVER;
-           else game.future[FTBEAM] = game.state.date+Time+expran(1.5*intime/game.state.remcom);
+           else game.future[FTBEAM] = game.state.date+game.optime+expran(1.5*game.intime/game.state.remcom);
            break;
        case FSNAP: /* Snapshot of the universe (for time warp) */
            game.snapsht = game.state;
            game.state.snap = 1;
            break;
        case FSNAP: /* Snapshot of the universe (for time warp) */
            game.snapsht = game.state;
            game.state.snap = 1;
-           game.future[FSNAP] = game.state.date + expran(0.5 * intime);
+           game.future[FSNAP] = game.state.date + expran(0.5 * game.intime);
            break;
        case FBATTAK: /* Commander attacks starbase */
            if (game.state.remcom==0 || game.state.rembase==0) {
            break;
        case FBATTAK: /* Commander attacks starbase */
            if (game.state.remcom==0 || game.state.rembase==0) {
@@ -179,7 +179,7 @@ void events(void)
            for_starbases(j) {
                for_commanders(k)
                    if (game.state.baseqx[j]==game.state.cx[k] && game.state.baseqy[j]==game.state.cy[k] &&
            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]!=quadx || game.state.baseqy[j]!=quady) &&
+                       (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)) {
                        i = 1;
                        break;
                        (game.state.baseqx[j]!=game.state.isx || game.state.baseqy[j]!=game.state.isy)) {
                        i = 1;
                        break;
@@ -188,125 +188,125 @@ void events(void)
            }
            if (j>game.state.rembase) {
                /* no match found -- try later */
            }
            if (j>game.state.rembase) {
                /* no match found -- try later */
-               game.future[FBATTAK] = game.state.date + expran(0.3*intime);
+               game.future[FBATTAK] = game.state.date + expran(0.3*game.intime);
                game.future[FCDBAS] = FOREVER;
                break;
            }
            /* commander + starbase combination found -- launch attack */
                game.future[FCDBAS] = FOREVER;
                break;
            }
            /* commander + starbase combination found -- launch attack */
-           batx = game.state.baseqx[j];
-           baty = game.state.baseqy[j];
+           game.batx = game.state.baseqx[j];
+           game.baty = game.state.baseqy[j];
            game.future[FCDBAS] = game.state.date+1.0+3.0*Rand();
            game.future[FCDBAS] = game.state.date+1.0+3.0*Rand();
-           if (isatb) /* extra time if SC already attacking */
+           if (game.isatb) /* extra time if SC already attacking */
                game.future[FCDBAS] += game.future[FSCDBAS]-game.state.date;
                game.future[FCDBAS] += game.future[FSCDBAS]-game.state.date;
-           game.future[FBATTAK] = game.future[FCDBAS] +expran(0.3*intime);
-           iseenit = 0;
+           game.future[FBATTAK] = game.future[FCDBAS] +expran(0.3*game.intime);
+           game.iseenit = 0;
            if (game.damage[DRADIO] != 0.0 &&
            if (game.damage[DRADIO] != 0.0 &&
-               condit != IHDOCKED) break; /* No warning :-( */
-           iseenit = 1;
+               game.condit != IHDOCKED) break; /* No warning :-( */
+           game.iseenit = 1;
            if (ipage==0) pause_game(1);
            ipage = 1;
            skip(1);
            proutn("Lt. Uhura-  \"Captain, the starbase in ");
            if (ipage==0) pause_game(1);
            ipage = 1;
            skip(1);
            proutn("Lt. Uhura-  \"Captain, the starbase in ");
-           prout(cramlc(quadrant, batx, baty));
+           prout(cramlc(quadrant, game.batx, game.baty));
            prout("   reports that it is under attack and that it can");
            proutn("   hold out only until stardate %d",
                   (int)game.future[FCDBAS]);
            prout(".\"");
            prout("   reports that it is under attack and that it can");
            proutn("   hold out only until stardate %d",
                   (int)game.future[FCDBAS]);
            prout(".\"");
-           if (resting) {
+           if (game.resting) {
                skip(1);
                proutn("Mr. Spock-  \"Captain, shall we cancel the rest period?\" ");
                if (ja()) {
                skip(1);
                proutn("Mr. Spock-  \"Captain, shall we cancel the rest period?\" ");
                if (ja()) {
-                   resting = 0;
-                   Time = 0.0;
+                   game.resting = 0;
+                   game.optime = 0.0;
                    return;
                }
            }
            break;
        case FSCDBAS: /* Supercommander destroys base */
            game.future[FSCDBAS] = FOREVER;
                    return;
                }
            }
            break;
        case FSCDBAS: /* Supercommander destroys base */
            game.future[FSCDBAS] = FOREVER;
-           isatb = 2;
+           game.isatb = 2;
            if (!game.state.galaxy[game.state.isx][game.state.isy].starbase) 
                break; /* WAS RETURN! */
            if (!game.state.galaxy[game.state.isx][game.state.isy].starbase) 
                break; /* WAS RETURN! */
-           ixhold = batx;
-           iyhold = baty;
-           batx = game.state.isx;
-           baty = game.state.isy;
+           ixhold = game.batx;
+           iyhold = game.baty;
+           game.batx = game.state.isx;
+           game.baty = game.state.isy;
        case FCDBAS: /* Commander succeeds in destroying base */
            if (line==FCDBAS) {
                game.future[FCDBAS] = FOREVER;
                /* find the lucky pair */
                for_commanders(i)
        case FCDBAS: /* Commander succeeds in destroying base */
            if (line==FCDBAS) {
                game.future[FCDBAS] = FOREVER;
                /* find the lucky pair */
                for_commanders(i)
-                   if (game.state.cx[i]==batx && game.state.cy[i]==baty) 
+                   if (game.state.cx[i]==game.batx && game.state.cy[i]==game.baty) 
                        break;
                if (i > game.state.remcom || game.state.rembase == 0 ||
                        break;
                if (i > game.state.remcom || game.state.rembase == 0 ||
-                   !game.state.galaxy[batx][baty].starbase) {
+                   !game.state.galaxy[game.batx][game.baty].starbase) {
                    /* No action to take after all */
                    /* No action to take after all */
-                   batx = baty = 0;
+                   game.batx = game.baty = 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 (batx==quadx && baty==quady) {
-               game.state.chart[batx][baty].starbase = FALSE;
-               game.quad[basex][basey]= IHDOT;
-               basex=basey=0;
+           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;
                newcnd();
                skip(1);
                prout("Spock-  \"Captain, I believe the starbase has been destroyegame.state.\"");
            }
            else if (game.state.rembase != 1 &&
                newcnd();
                skip(1);
                prout("Spock-  \"Captain, I believe the starbase has been destroyegame.state.\"");
            }
            else if (game.state.rembase != 1 &&
-                    (game.damage[DRADIO] <= 0.0 || condit == IHDOCKED)) {
+                    (game.damage[DRADIO] <= 0.0 || game.condit == IHDOCKED)) {
                /* Get word via subspace radio */
                if (ipage==0) pause_game(1);
                ipage = 1;
                skip(1);
                prout("Lt. Uhura-  \"Captain, Starfleet Command reports that");
                proutn("   the starbase in ");
                /* Get word via subspace radio */
                if (ipage==0) pause_game(1);
                ipage = 1;
                skip(1);
                prout("Lt. Uhura-  \"Captain, Starfleet Command reports that");
                proutn("   the starbase in ");
-               proutn(cramlc(quadrant, batx, baty));
+               proutn(cramlc(quadrant, game.batx, game.baty));
                prout(" has been destroyed by");
                prout(" has been destroyed by");
-               if (isatb==2) prout("the Klingon Super-Commander");
+               if (game.isatb==2) prout("the Klingon Super-Commander");
                else prout("a Klingon Commander");
                else prout("a Klingon Commander");
-               game.state.chart[batx][baty].starbase = FALSE;
+               game.state.chart[game.batx][game.baty].starbase = FALSE;
            }
            /* Remove Starbase from galaxy */
            }
            /* Remove Starbase from galaxy */
-           game.state.galaxy[batx][baty].starbase = FALSE;
+           game.state.galaxy[game.batx][game.baty].starbase = FALSE;
            for_starbases(i)
            for_starbases(i)
-               if (game.state.baseqx[i]==batx && game.state.baseqy[i]==baty) {
+               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];
                }
            game.state.rembase--;
                    game.state.baseqx[i]=game.state.baseqx[game.state.rembase];
                    game.state.baseqy[i]=game.state.baseqy[game.state.rembase];
                }
            game.state.rembase--;
-           if (isatb == 2) {
+           if (game.isatb == 2) {
                /* reinstate a commander's base attack */
                /* reinstate a commander's base attack */
-               batx = ixhold;
-               baty = iyhold;
-               isatb = 0;
+               game.batx = ixhold;
+               game.baty = iyhold;
+               game.isatb = 0;
            }
            else {
            }
            else {
-               batx = baty = 0;
+               game.batx = game.baty = 0;
            }
            break;
        case FSCMOVE: /* Supercommander moves */
            game.future[FSCMOVE] = game.state.date+0.2777;
            }
            break;
        case FSCMOVE: /* Supercommander moves */
            game.future[FSCMOVE] = game.state.date+0.2777;
-           if (ientesc+istract==0 &&
-               isatb!=1 &&
-               (iscate!=1 || justin==1)) scom(&ipage);
+           if (game.ientesc+istract==0 &&
+               game.isatb!=1 &&
+               (game.iscate!=1 || game.justin==1)) scom(&ipage);
            break;
        case FDSPROB: /* Move deep space probe */
            game.future[FDSPROB] = game.state.date + 0.01;
            break;
        case FDSPROB: /* Move deep space probe */
            game.future[FDSPROB] = game.state.date + 0.01;
-           probex += probeinx;
-           probey += probeiny;
-           i = (int)(probex/QUADSIZE +0.05);
-           j = (int)(probey/QUADSIZE + 0.05);
-           if (probecx != i || probecy != j) {
-               probecx = i;
-               probecy = j;
+           game.probex += game.probeinx;
+           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 (!VALID_QUADRANT(i, j) ||
                if (!VALID_QUADRANT(i, j) ||
-                   game.state.galaxy[probecx][probecy].supernova) {
+                   game.state.galaxy[game.probecx][game.probecy].supernova) {
                    // Left galaxy or ran into supernova
                    // Left galaxy or ran into supernova
-                   if (game.damage[DRADIO]==0.0 || condit == IHDOCKED) {
+                   if (game.damage[DRADIO]==0.0 || game.condit == IHDOCKED) {
                        if (ipage==0) pause_game(1);
                        ipage = 1;
                        skip(1);
                        if (ipage==0) pause_game(1);
                        ipage = 1;
                        skip(1);
@@ -320,30 +320,30 @@ void events(void)
                    game.future[FDSPROB] = FOREVER;
                    break;
                }
                    game.future[FDSPROB] = FOREVER;
                    break;
                }
-               if (game.damage[DRADIO]==0.0   || condit == IHDOCKED) {
+               if (game.damage[DRADIO]==0.0   || game.condit == IHDOCKED) {
                    if (ipage==0) pause_game(1);
                    ipage = 1;
                    skip(1);
                    proutn("Lt. Uhura-  \"The deep space probe is now in ");
                    if (ipage==0) pause_game(1);
                    ipage = 1;
                    skip(1);
                    proutn("Lt. Uhura-  \"The deep space probe is now in ");
-                   proutn(cramlc(quadrant, probecx, probecy));
+                   proutn(cramlc(quadrant, game.probecx, game.probecy));
                    prout(".\"");
                }
            }
            /* Update star chart if Radio is working or have access to
               radio. */
                    prout(".\"");
                }
            }
            /* Update star chart if Radio is working or have access to
               radio. */
-           if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED) {
-               game.state.chart[probecx][probecy].klingons = game.state.galaxy[probecx][probecy].klingons;
-               game.state.chart[probecx][probecy].starbase = game.state.galaxy[probecx][probecy].starbase;
-               game.state.chart[probecx][probecy].stars = game.state.galaxy[probecx][probecy].stars;
-               game.state.galaxy[probecx][probecy].charted = TRUE;
+           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;
            }
            }
-           proben--; // One less to travel
-           if (proben == 0 && isarmed &&
-               game.state.galaxy[probecx][probecy].stars) {
+           game.proben--; // One less to travel
+           if (game.proben == 0 && game.isarmed &&
+               game.state.galaxy[game.probecx][game.probecy].stars) {
                /* lets blow the sucker! */
                snova(1,0);
                game.future[FDSPROB] = FOREVER;
                /* lets blow the sucker! */
                snova(1,0);
                game.future[FDSPROB] = FOREVER;
-               if (game.state.galaxy[quadx][quady].supernova) 
+               if (game.state.galaxy[game.quadx][game.quady].supernova) 
                    return;
            }
            break;
                    return;
            }
            break;
@@ -357,7 +357,7 @@ void wait(void)
     int key;
     double temp, delay, origTime;
 
     int key;
     double temp, delay, origTime;
 
-    ididit = 0;
+    game.ididit = 0;
     for (;;) {
        key = scan();
        if (key  != IHEOL) break;
     for (;;) {
        key = scan();
        if (key  != IHEOL) break;
@@ -370,42 +370,42 @@ void wait(void)
     }
     origTime = delay = aaitem;
     if (delay <= 0.0) return;
     }
     origTime = delay = aaitem;
     if (delay <= 0.0) return;
-    if (delay >= game.state.remtime || nenhere != 0) {
+    if (delay >= game.state.remtime || game.nenhere != 0) {
        proutn("Are you sure? ");
        if (ja() == 0) return;
     }
 
     /* Alternate resting periods (events) with attacks */
 
        proutn("Are you sure? ");
        if (ja() == 0) return;
     }
 
     /* Alternate resting periods (events) with attacks */
 
-    resting = 1;
+    game.resting = 1;
     do {
     do {
-       if (delay <= 0) resting = 0;
-       if (resting == 0) {
+       if (delay <= 0) game.resting = 0;
+       if (game.resting == 0) {
            prout("%d stardates left.", (int)game.state.remtime);
            return;
        }
            prout("%d stardates left.", (int)game.state.remtime);
            return;
        }
-       temp = Time = delay;
+       temp = game.optime = delay;
 
 
-       if (nenhere) {
+       if (game.nenhere) {
            double rtime = 1.0 + Rand();
            if (rtime < temp) temp = rtime;
            double rtime = 1.0 + Rand();
            if (rtime < temp) temp = rtime;
-           Time = temp;
+           game.optime = temp;
        }
        }
-       if (Time < delay) attack(0);
-       if (alldone) return;
+       if (game.optime < delay) attack(0);
+       if (game.alldone) return;
        events();
        events();
-       ididit = 1;
-       if (alldone) return;
+       game.ididit = 1;
+       if (game.alldone) return;
        delay -= temp;
        /* Repair Deathray if long rest at starbase */
        delay -= temp;
        /* Repair Deathray if long rest at starbase */
-       if (origTime-delay >= 9.99 && condit == IHDOCKED)
+       if (origTime-delay >= 9.99 && game.condit == IHDOCKED)
            game.damage[DDRAY] = 0.0;
     } while 
        // leave if quadrant supernovas
            game.damage[DDRAY] = 0.0;
     } while 
        // leave if quadrant supernovas
-       (!game.state.galaxy[quadx][quady].supernova);
+       (!game.state.galaxy[game.quadx][game.quady].supernova);
 
 
-    resting = 0;
-    Time = 0;
+    game.resting = 0;
+    game.optime = 0;
 }
 
 void nova(int ix, int iy) 
 }
 
 void nova(int ix, int iy) 
@@ -424,7 +424,7 @@ void nova(int ix, int iy)
     game.quad[ix][iy] = IHDOT;
     crmena(1, IHSTAR, 2, ix, iy);
     prout(" novas.");
     game.quad[ix][iy] = IHDOT;
     crmena(1, IHSTAR, 2, ix, iy);
     prout(" novas.");
-    game.state.galaxy[quadx][quady].stars--;
+    game.state.galaxy[game.quadx][game.quady].stars--;
     game.state.starkl++;
        
     /* Set up stack to recursively trigger adjacent stars */
     game.state.starkl++;
        
     /* Set up stack to recursively trigger adjacent stars */
@@ -459,34 +459,34 @@ void nova(int ix, int iy)
                        top2++;
                        hits[top2][1]=ii;
                        hits[top2][2]=jj;
                        top2++;
                        hits[top2][1]=ii;
                        hits[top2][2]=jj;
-                       game.state.galaxy[quadx][quady].stars -= 1;
+                       game.state.galaxy[game.quadx][game.quady].stars -= 1;
                        game.state.starkl++;
                        crmena(1, IHSTAR, 2, ii, jj);
                        prout(" novas.");
                        game.quad[ii][jj] = IHDOT;
                        break;
                    case IHP: /* Destroy planet */
                        game.state.starkl++;
                        crmena(1, IHSTAR, 2, ii, jj);
                        prout(" novas.");
                        game.quad[ii][jj] = IHDOT;
                        break;
                    case IHP: /* Destroy planet */
-                       game.state.galaxy[quadx][quady].planets -= 1;
+                       game.state.galaxy[game.quadx][game.quady].planets -= 1;
                        game.state.nplankl++;
                        crmena(1, IHP, 2, ii, jj);
                        prout(" destroyed.");
                        game.state.nplankl++;
                        crmena(1, IHP, 2, ii, jj);
                        prout(" destroyed.");
-                       DESTROY(&game.state.plnets[iplnet]);
-                       iplnet = plnetx = plnety = 0;
-                       if (landed == 1) {
+                       DESTROY(&game.state.plnets[game.iplnet]);
+                       game.iplnet = game.plnetx = game.plnety = 0;
+                       if (game.landed == 1) {
                            finish(FPNOVA);
                            return;
                        }
                        game.quad[ii][jj] = IHDOT;
                        break;
                    case IHB: /* Destroy base */
                            finish(FPNOVA);
                            return;
                        }
                        game.quad[ii][jj] = IHDOT;
                        break;
                    case IHB: /* Destroy base */
-                       game.state.galaxy[quadx][quady].starbase = FALSE;
+                       game.state.galaxy[game.quadx][game.quady].starbase = FALSE;
                        for_starbases(i)
                        for_starbases(i)
-                           if (game.state.baseqx[i]==quadx && game.state.baseqy[i]==quady) 
+                           if (game.state.baseqx[i]==game.quadx && game.state.baseqy[i]==game.quady) 
                                break;
                        game.state.baseqx[i] = game.state.baseqx[game.state.rembase];
                        game.state.baseqy[i] = game.state.baseqy[game.state.rembase];
                        game.state.rembase--;
                                break;
                        game.state.baseqx[i] = game.state.baseqx[game.state.rembase];
                        game.state.baseqy[i] = game.state.baseqy[game.state.rembase];
                        game.state.rembase--;
-                       basex = basey = 0;
+                       game.basex = game.basey = 0;
                        game.state.basekl++;
                        newcnd();
                        crmena(1, IHB, 2, ii, jj);
                        game.state.basekl++;
                        newcnd();
                        crmena(1, IHB, 2, ii, jj);
@@ -496,25 +496,25 @@ void nova(int ix, int iy)
                    case IHE: /* Buffet ship */
                    case IHF:
                        prout("***Starship buffeted by nova.");
                    case IHE: /* Buffet ship */
                    case IHF:
                        prout("***Starship buffeted by nova.");
-                       if (shldup) {
-                           if (shield >= 2000.0) shield -= 2000.0;
+                       if (game.shldup) {
+                           if (game.shield >= 2000.0) game.shield -= 2000.0;
                            else {
                            else {
-                               double diff = 2000.0 - shield;
-                               energy -= diff;
-                               shield = 0.0;
-                               shldup = 0;
+                               double diff = 2000.0 - game.shield;
+                               game.energy -= diff;
+                               game.shield = 0.0;
+                               game.shldup = 0;
                                prout("***Shields knocked out.");
                                prout("***Shields knocked out.");
-                               game.damage[DSHIELD] += 0.005*damfac*Rand()*diff;
+                               game.damage[DSHIELD] += 0.005*game.damfac*Rand()*diff;
                            }
                        }
                            }
                        }
-                       else energy -= 2000.0;
-                       if (energy <= 0) {
+                       else game.energy -= 2000.0;
+                       if (game.energy <= 0) {
                            finish(FNOVA);
                            return;
                        }
                        /* add in course nova contributes to kicking starship*/
                            finish(FNOVA);
                            return;
                        }
                        /* add in course nova contributes to kicking starship*/
-                       icx += sectx-hits[mm][1];
-                       icy += secty-hits[mm][2];
+                       icx += game.sectx-hits[mm][1];
+                       icy += game.secty-hits[mm][2];
                        kount++;
                        break;
                    case IHK: /* kill klingon */
                        kount++;
                        break;
                    case IHK: /* kill klingon */
@@ -558,7 +558,7 @@ void nova(int ix, int iy)
                        game.quad[newcx][newcy] = iquad;
                        game.kx[ll] = newcx;
                        game.ky[ll] = newcy;
                        game.quad[newcx][newcy] = iquad;
                        game.kx[ll] = newcx;
                        game.ky[ll] = newcy;
-                       game.kavgd[ll] = sqrt(square(sectx-newcx)+square(secty-newcy));
+                       game.kavgd[ll] = sqrt(square(game.sectx-newcx)+square(game.secty-newcy));
                        game.kdist[ll] = game.kavgd[ll];
                        skip(1);
                        break;
                        game.kdist[ll] = game.kavgd[ll];
                        skip(1);
                        break;
@@ -573,18 +573,18 @@ void nova(int ix, int iy)
        return;
 
     /* Starship affected by nova -- kick it away. */
        return;
 
     /* Starship affected by nova -- kick it away. */
-    dist = kount*0.1;
+    game.dist = kount*0.1;
     if (icx) icx = (icx < 0 ? -1 : 1);
     if (icy) icy = (icy < 0 ? -1 : 1);
     if (icx) icx = (icx < 0 ? -1 : 1);
     if (icy) icy = (icy < 0 ? -1 : 1);
-    direc = course[3*(icx+1)+icy+2];
-    if (direc == 0.0) dist = 0.0;
-    if (dist == 0.0) return;
-    Time = 10.0*dist/16.0;
+    game.direc = course[3*(icx+1)+icy+2];
+    if (game.direc == 0.0) game.dist = 0.0;
+    if (game.dist == 0.0) return;
+    game.optime = 10.0*game.dist/16.0;
     skip(1);
     prout("Force of nova displaces starship.");
     skip(1);
     prout("Force of nova displaces starship.");
-    iattak=2;  /* Eliminates recursion problem */
+    game.iattak=2;     /* Eliminates recursion problem */
     imove();
     imove();
-    Time = 10.0*dist/16.0;
+    game.optime = 10.0*game.dist/16.0;
     return;
 }
        
     return;
 }
        
@@ -601,8 +601,8 @@ void snova(int insx, int insy)
     if (insy== 0) {
        if (insx == 1) {
            /* NOVAMAX being used */
     if (insy== 0) {
        if (insx == 1) {
            /* NOVAMAX being used */
-           nqx = probecx;
-           nqy = probecy;
+           nqx = game.probecx;
+           nqy = game.probecy;
        }
        else {
            int stars = 0;
        }
        else {
            int stars = 0;
@@ -624,19 +624,19 @@ void snova(int insx, int insy)
                if (num <=0) break;
            }
 #ifdef DEBUG
                if (num <=0) break;
            }
 #ifdef DEBUG
-           if (idebug) {
+           if (game.idebug) {
                proutn("Super nova here?");
                if (ja()==1) {
                proutn("Super nova here?");
                if (ja()==1) {
-                   nqx = quadx;
-                   nqy = quady;
+                   nqx = game.quadx;
+                   nqy = game.quady;
                }
            }
 #endif
        }
 
                }
            }
 #endif
        }
 
-       if (nqx != quady || nqy != quady || justin != 0) {
+       if (nqx != game.quady || nqy != game.quady || game.justin != 0) {
            /* it isn't here, or we just entered (treat as inroute) */
            /* it isn't here, or we just entered (treat as inroute) */
-           if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED) {
+           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.",
                skip(1);
                prout("Message from Starfleet Command       Stardate %.2f", game.state.date);
                prout("     Supernova in %s; caution advised.",
@@ -667,14 +667,14 @@ void snova(int insx, int insy)
        prouts("***RED ALERT!  RED ALERT!");
        skip(1);
        prout("***Incipient supernova detected at ", cramlc(sector, nsx, nsy));
        prouts("***RED ALERT!  RED ALERT!");
        skip(1);
        prout("***Incipient supernova detected at ", cramlc(sector, nsx, nsy));
-       nqx = quadx;
-       nqy = quady;
-       if (square(nsx-sectx) + square(nsy-secty) <= 2.1) {
+       nqx = game.quadx;
+       nqy = game.quady;
+       if (square(nsx-game.sectx) + square(nsy-game.secty) <= 2.1) {
            proutn("Emergency override attempts t");
            prouts("***************");
            skip(1);
            stars();
            proutn("Emergency override attempts t");
            prouts("***************");
            skip(1);
            stars();
-           alldone=1;
+           game.alldone=1;
        }
     }
     /* destroy any Klingons in supernovaed quadrant */
        }
     }
     /* destroy any Klingons in supernovaed quadrant */
@@ -683,7 +683,7 @@ void snova(int insx, int insy)
     comdead = iscdead = 0;
     if (nqx==game.state.isx && nqy == game.state.isy) {
        /* did in the Supercommander! */
     comdead = iscdead = 0;
     if (nqx==game.state.isx && nqy == game.state.isy) {
        /* did in the Supercommander! */
-       game.state.nscrem = game.state.isx = game.state.isy = isatb = iscate = 0;
+       game.state.nscrem = game.state.isx = game.state.isy = game.isatb = game.iscate = 0;
        iscdead = 1;
        game.future[FSCMOVE] = game.future[FSCDBAS] = FOREVER;
     }
        iscdead = 1;
        game.future[FSCMOVE] = game.future[FSCDBAS] = FOREVER;
     }
@@ -710,7 +710,7 @@ void snova(int insx, int insy)
     npdead = num - nrmdead*10;
     if (npdead) {
        int l;
     npdead = num - nrmdead*10;
     if (npdead) {
        int l;
-       for (l = 0; l < inplan; l++)
+       for (l = 0; l < game.inplan; l++)
            if (game.state.plnets[l].x == nqx && game.state.plnets[l].y == nqy) {
                DESTROY(&game.state.plnets[l]);
            }
            if (game.state.plnets[l].x == nqx && game.state.plnets[l].y == nqy) {
                DESTROY(&game.state.plnets[l]);
            }
@@ -734,12 +734,12 @@ void snova(int insx, int insy)
        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 ((quadx == nqx && quady == nqy) ||
+    if ((game.quadx == nqx && game.quady == nqy) ||
        game.damage[DRADIO] == 0 ||
        game.damage[DRADIO] == 0 ||
-       condit == IHDOCKED)
+       game.condit == IHDOCKED)
        game.state.galaxy[nqx][nqy].supernova = TRUE;
     /* If supernova destroys last klingons give special message */
        game.state.galaxy[nqx][nqy].supernova = TRUE;
     /* If supernova destroys last klingons give special message */
-    if (KLINGREM==0 && (nqx != quadx || nqy != quady)) {
+    if (KLINGREM==0 && (nqx != game.quadx || nqy != game.quady)) {
        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.",
@@ -748,7 +748,7 @@ void snova(int insx, int insy)
        return;
     }
     /* if some Klingons remain, continue or die in supernova */
        return;
     }
     /* if some Klingons remain, continue or die in supernova */
-    if (alldone) finish(FSNOVAED);
+    if (game.alldone) finish(FSNOVAED);
     return;
 }
                
     return;
 }
                
index c0d3569f95994f515ac71d12c13784eb5b9c0bd2..bcb168eacabf951423f22366cfcb2f3501834e56 100644 (file)
@@ -48,17 +48,17 @@ void dstrct()
 void kaboom(void) 
 {
     stars();
 void kaboom(void) 
 {
     stars();
-    if (ship==IHE) prouts("***");
+    if (game.ship==IHE) prouts("***");
     prouts("********* Entropy of ");
     crmshp();
     prouts(" maximized *********");
     skip(1);
     stars();
     skip(1);
     prouts("********* Entropy of ");
     crmshp();
     prouts(" maximized *********");
     skip(1);
     stars();
     skip(1);
-    if (nenhere != 0) {
-       double whammo = 25.0 * energy;
+    if (game.nenhere != 0) {
+       double whammo = 25.0 * game.energy;
        int l=1;
        int l=1;
-       while (l <= nenhere) {
+       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]);
            l++;
            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]);
            l++;
@@ -71,7 +71,7 @@ void kaboom(void)
 void finish(FINTYPE ifin) 
 {
     int igotit = 0;
 void finish(FINTYPE ifin) 
 {
     int igotit = 0;
-    alldone = 1;
+    game.alldone = 1;
     skip(3);
     prout("It is stardate %.1f.", game.state.date);
     skip(1);
     skip(3);
     prout("It is stardate %.1f.", game.state.date);
     skip(1);
@@ -83,21 +83,21 @@ void finish(FINTYPE ifin)
 
        prout("You have smashed the Klingon invasion fleet and saved");
        prout("the Federation.");
 
        prout("You have smashed the Klingon invasion fleet and saved");
        prout("the Federation.");
-       gamewon=1;
-       if (alive) {
+       game.gamewon=1;
+       if (game.alive) {
            double badpt;
            double badpt;
-           badpt = 5.0*game.state.starkl + casual + 10.0*game.state.nplankl +
-               45.*nhelp+100.*game.state.basekl;
-           if (ship == IHF) badpt += 100.0;
-           else if (ship == 0) badpt += 200.0;
+           badpt = 5.0*game.state.starkl + game.casual + 10.0*game.state.nplankl +
+               45.*game.nhelp+100.*game.state.basekl;
+           if (game.ship == IHF) badpt += 100.0;
+           else if (game.ship == 0) badpt += 200.0;
            if (badpt < 100.0) badpt = 0.0;     // Close enough!
            if (badpt < 100.0) badpt = 0.0;     // Close enough!
-           if (game.state.date-indate < 5.0 ||
+           if (game.state.date-game.indate < 5.0 ||
                // killsPerDate >= RateMax
                // killsPerDate >= RateMax
-               KLINGKILLED/(game.state.date-indate) >=
-               0.1*skill*(skill+1.0) + 0.1 + 0.008*badpt) {
+               KLINGKILLED/(game.state.date-game.indate) >=
+               0.1*game.skill*(game.skill+1.0) + 0.1 + 0.008*badpt) {
                skip(1);
                prout("In fact, you have done so well that Starfleet Command");
                skip(1);
                prout("In fact, you have done so well that Starfleet Command");
-               switch (skill) {
+               switch (game.skill) {
                case SKILL_NOVICE:
                    prout("promotes you one step in rank from \"Novice\" to \"Fair\".");
                    break;
                case SKILL_NOVICE:
                    prout("promotes you one step in rank from \"Novice\" to \"Fair\".");
                    break;
@@ -132,10 +132,10 @@ void finish(FINTYPE ifin)
                    skip(1);
                    break;
                }
                    skip(1);
                    break;
                }
-               if (skill >= SKILL_EXPERT) {
-                   if (thawed
+               if (game.skill >= SKILL_EXPERT) {
+                   if (game.thawed
 #ifdef DEBUG
 #ifdef DEBUG
-                       && !idebug
+                       && !game.idebug
 #endif
                        )
                        prout("You cannot get a citation, so...");
 #endif
                        )
                        prout("You cannot get a citation, so...");
@@ -168,7 +168,7 @@ void finish(FINTYPE ifin)
        else {
            prout("found guilty and");
            prout("sentenced to death by slow torture.");
        else {
            prout("found guilty and");
            prout("sentenced to death by slow torture.");
-           alive = 0;
+           game.alive = 0;
        }
        score();
        return;
        }
        score();
        return;
@@ -282,12 +282,12 @@ void finish(FINTYPE ifin)
        prout("You are crushed into extremely dense matter.");
        break;
     }
        prout("You are crushed into extremely dense matter.");
        break;
     }
-    if (ship==IHF) ship= 0;
-    else if (ship == IHE) ship = IHF;
-    alive = 0;
+    if (game.ship==IHF) game.ship= 0;
+    else if (game.ship == IHE) game.ship = IHF;
+    game.alive = 0;
     if (KLINGREM != 0) {
     if (KLINGREM != 0) {
-       double goodies = game.state.remres/inresor;
-       double baddies = (game.state.remkl + 2.0*game.state.remcom)/(inkling+2.0*incom);
+       double goodies = game.state.remres/game.inresor;
+       double baddies = (game.state.remkl + 2.0*game.state.remcom)/(game.inkling+2.0*game.incom);
        if (goodies/baddies >= 1.0+0.5*Rand()) {
            prout("As a result of your actions, a treaty with the Klingon");
            prout("Empire has been signed. The terms of the treaty are");
        if (goodies/baddies >= 1.0+0.5*Rand()) {
            prout("As a result of your actions, a treaty with the Klingon");
            prout("Empire has been signed. The terms of the treaty are");
@@ -307,30 +307,30 @@ void finish(FINTYPE ifin)
        prout("martyr and a hero. Someday maybe they'll erect a");
        prout("statue in your memory. Rest in peace, and try not");
        prout("to think about pigeons.");
        prout("martyr and a hero. Someday maybe they'll erect a");
        prout("statue in your memory. Rest in peace, and try not");
        prout("to think about pigeons.");
-       gamewon = 1;
+       game.gamewon = 1;
     }
     score();
 }
 
 void score(void) 
 {
     }
     score();
 }
 
 void score(void) 
 {
-    double timused = game.state.date - indate;
+    double timused = game.state.date - game.indate;
     int ithperd, iwon, klship;
 
     int ithperd, iwon, klship;
 
-    iskill = skill;
+    iskill = game.skill;
     if ((timused == 0 || KLINGREM != 0) && timused < 5.0) timused = 5.0;
     perdate = KLINGKILLED/timused;
     ithperd = 500*perdate + 0.5;
     iwon = 0;
     if ((timused == 0 || KLINGREM != 0) && timused < 5.0) timused = 5.0;
     perdate = KLINGKILLED/timused;
     ithperd = 500*perdate + 0.5;
     iwon = 0;
-    if (gamewon) iwon = 100*skill;
-    if (ship == IHE) klship = 0;
-    else if (ship == IHF) klship = 1;
+    if (game.gamewon) iwon = 100*game.skill;
+    if (game.ship == IHE) klship = 0;
+    else if (game.ship == IHF) klship = 1;
     else klship = 2;
     else klship = 2;
-    if (gamewon == 0) game.state.nromrem = 0; // None captured if no win
+    if (game.gamewon == 0) game.state.nromrem = 0; // None captured if no win
     iscore = 10*NKILLK + 50*NKILLC + ithperd + iwon
     iscore = 10*NKILLK + 50*NKILLC + ithperd + iwon
-       - 100*game.state.basekl - 100*klship - 45*nhelp -5*game.state.starkl - casual
+       - 100*game.state.basekl - 100*klship - 45*game.nhelp -5*game.state.starkl - game.casual
        + 20*NKILLROM + 200*NKILLSC - 10*game.state.nplankl + game.state.nromrem;
        + 20*NKILLROM + 200*NKILLSC - 10*game.state.nplankl + game.state.nromrem;
-    if (alive == 0) iscore -= 200;
+    if (game.alive == 0) iscore -= 200;
     skip(2);
     prout("Your score --");
     if (NKILLROM)
     skip(2);
     prout("Your score --");
     if (NKILLROM)
@@ -360,20 +360,20 @@ void score(void)
     if (game.state.basekl)
        prout("%6d bases destroyed by your action     %5d",
              game.state.basekl, -100*game.state.basekl);
     if (game.state.basekl)
        prout("%6d bases destroyed by your action     %5d",
              game.state.basekl, -100*game.state.basekl);
-    if (nhelp)
+    if (game.nhelp)
        prout("%6d calls for help from starbase       %5d",
        prout("%6d calls for help from starbase       %5d",
-             nhelp, -45*nhelp);
-    if (casual)
+             game.nhelp, -45*game.nhelp);
+    if (game.casual)
        prout("%6d casualties incurred                %5d",
        prout("%6d casualties incurred                %5d",
-             casual, -casual);
+             game.casual, -game.casual);
     if (klship)
        prout("%6d ship(s) lost or destroyed          %5d",
              klship, -100*klship);
     if (klship)
        prout("%6d ship(s) lost or destroyed          %5d",
              klship, -100*klship);
-    if (alive==0)
+    if (game.alive==0)
        prout("Penalty for getting yourself killed        -200");
        prout("Penalty for getting yourself killed        -200");
-    if (gamewon) {
+    if (game.gamewon) {
        proutn("Bonus for winning ");
        proutn("Bonus for winning ");
-       switch (skill) {
+       switch (game.skill) {
        case SKILL_NOVICE:   proutn("Novice game  "); break;
        case SKILL_FAIR:     proutn("Fair game    "); break;
        case SKILL_GOOD:     proutn("Good game    "); break;
        case SKILL_NOVICE:   proutn("Novice game  "); break;
        case SKILL_FAIR:     proutn("Fair game    "); break;
        case SKILL_GOOD:     proutn("Good game    "); break;
index adbbca080a477ff59e274a17a24aab37e2fa64b8..30908e63fee269a2a8803f45908748a07bee5fd1 100644 (file)
--- a/src/io.c
+++ b/src/io.c
@@ -81,13 +81,13 @@ void pause_game(int i)
     char *prompt;
     char buf[BUFSIZ];
     if (i==1) {
     char *prompt;
     char buf[BUFSIZ];
     if (i==1) {
-       if (skill > SKILL_FAIR)
+       if (game.skill > SKILL_FAIR)
            prompt = "[ANOUNCEMENT ARRIVING...]";
        else
            prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
     }
     else {
            prompt = "[ANOUNCEMENT ARRIVING...]";
        else
            prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
     }
     else {
-       if (skill > SKILL_FAIR)
+       if (game.skill > SKILL_FAIR)
            prompt = "[CONTINUE?]";
        else
            prompt = "[PRESS ENTER TO CONTINUE]";
            prompt = "[CONTINUE?]";
        else
            prompt = "[PRESS ENTER TO CONTINUE]";
@@ -383,7 +383,7 @@ void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad)
            skip(1);
        proutn("%d - %d   ", ix, iy);
     } else {
            skip(1);
        proutn("%d - %d   ", ix, iy);
     } else {
-       if (game.damage[DSRSENS]==0 || condit==IHDOCKED) {
+       if (game.damage[DSRSENS]==0 || game.condit==IHDOCKED) {
            if (i != 1 && l == 1) {
                drawmaps(2);
                delay(400);
            if (i != 1 && l == 1) {
                drawmaps(2);
                delay(400);
index a5d11b3e25b7fba12bacd3d2726b8456365a220c..24b6bb08a746bb29897a5e705c2d6f48710d3684 100644 (file)
@@ -10,12 +10,12 @@ void imove(void)
         finald, finalx, finaly, stopegy, probf;
     int trbeam = 0, n, l, ix=0, iy=0, kink, kinks, iquad;
 
         finald, finalx, finaly, stopegy, probf;
     int trbeam = 0, n, l, ix=0, iy=0, kink, kinks, iquad;
 
-    if (inorbit) {
+    if (game.inorbit) {
        prout("Helmsman Sulu- \"Leaving standard orbit.\"");
        prout("Helmsman Sulu- \"Leaving standard orbit.\"");
-       inorbit = FALSE;
+       game.inorbit = FALSE;
     }
 
     }
 
-    angle = ((15.0 - direc) * 0.5235988);
+    angle = ((15.0 - game.direc) * 0.5235988);
     deltax = -sin(angle);
     deltay = cos(angle);
     if (fabs(deltax) > fabs(deltay))
     deltax = -sin(angle);
     deltay = cos(angle);
     if (fabs(deltax) > fabs(deltay))
@@ -27,17 +27,17 @@ void imove(void)
     deltax /= bigger;
 
     /* If tractor beam is to occur, don't move full distance */
     deltax /= bigger;
 
     /* If tractor beam is to occur, don't move full distance */
-    if (game.state.date+Time >= game.future[FTBEAM]) {
+    if (game.state.date+game.optime >= game.future[FTBEAM]) {
        trbeam = 1;
        trbeam = 1;
-       condit = IHRED;
-       dist = dist*(game.future[FTBEAM]-game.state.date)/Time + 0.1;
-       Time = game.future[FTBEAM] - game.state.date + 1e-5;
+       game.condit = IHRED;
+       game.dist = game.dist*(game.future[FTBEAM]-game.state.date)/game.optime + 0.1;
+       game.optime = game.future[FTBEAM] - game.state.date + 1e-5;
     }
     /* Move within the quadrant */
     }
     /* Move within the quadrant */
-    game.quad[sectx][secty] = IHDOT;
-    x = sectx;
-    y = secty;
-    n = 10.0*dist*bigger+0.5;
+    game.quad[game.sectx][game.secty] = IHDOT;
+    x = game.sectx;
+    y = game.secty;
+    n = 10.0*game.dist*bigger+0.5;
 
     if (n > 0) {
        for (l = 1; l <= n; l++) {
 
     if (n > 0) {
        for (l = 1; l <= n; l++) {
@@ -46,7 +46,7 @@ void imove(void)
            if (!VALID_SECTOR(ix, iy)) {
                /* Leaving quadrant -- allow final enemy attack */
                /* Don't do it if being pushed by Nova */
            if (!VALID_SECTOR(ix, iy)) {
                /* Leaving quadrant -- allow final enemy attack */
                /* Don't do it if being pushed by Nova */
-               if (nenhere != 0 && iattak != 2) {
+               if (game.nenhere != 0 && game.iattak != 2) {
                    newcnd();
                    for_local_enemies(l) {
                        finald = sqrt((ix-game.kx[l])*(double)(ix-game.kx[l]) +
                    newcnd();
                    for_local_enemies(l) {
                        finald = sqrt((ix-game.kx[l])*(double)(ix-game.kx[l]) +
@@ -54,19 +54,19 @@ void imove(void)
                        game.kavgd[l] = 0.5 * (finald+game.kdist[l]);
                    }
                    /*
                        game.kavgd[l] = 0.5 * (finald+game.kdist[l]);
                    }
                    /*
-                    * Stas Sergeev added the condition
+                    * Stas Sergeev added the game.condition
                     * 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 (skill > SKILL_GOOD && klhere > 0 && !game.state.galaxy[quadx][quady].supernova)
+                   if (game.skill > SKILL_GOOD && game.klhere > 0 && !game.state.galaxy[game.quadx][game.quady].supernova)
                        attack(0);
                        attack(0);
-                   if (alldone) return;
+                   if (game.alldone) return;
                }
                /* compute final position -- new quadrant and sector */
                }
                /* compute final position -- new quadrant and sector */
-               x = QUADSIZE*(quadx-1)+sectx;
-               y = QUADSIZE*(quady-1)+secty;
-               ix = x+10.0*dist*bigger*deltax+0.5;
-               iy = y+10.0*dist*bigger*deltay+0.5;
+               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;
                /* check for edge of galaxy */
                kinks = 0;
                do {
                /* check for edge of galaxy */
                kinks = 0;
                do {
@@ -91,8 +91,8 @@ void imove(void)
                } while (kink);
 
                if (kinks) {
                } while (kink);
 
                if (kinks) {
-                   nkinks += 1;
-                   if (nkinks == 3) {
+                   game.nkinks += 1;
+                   if (game.nkinks == 3) {
                        /* Three strikes -- you're out! */
                        finish(FNEG3);
                        return;
                        /* Three strikes -- you're out! */
                        finish(FNEG3);
                        return;
@@ -104,24 +104,24 @@ 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 */
-               quadx = (ix+(QUADSIZE-1))/QUADSIZE;
-               quady = (iy+(QUADSIZE-1))/QUADSIZE;
-               sectx = ix - QUADSIZE*(quadx-1);
-               secty = iy - QUADSIZE*(quady-1);
+               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);
                skip(1);
                prout("Entering %s.",
                skip(1);
                prout("Entering %s.",
-                     cramlc(quadrant, quadx, quady));
-               game.quad[sectx][secty] = ship;
+                     cramlc(quadrant, game.quadx, game.quady));
+               game.quad[game.sectx][game.secty] = game.ship;
                newqad(0);
                newqad(0);
-               if (skill>SKILL_NOVICE) attack(0);
+               if (game.skill>SKILL_NOVICE) attack(0);
                return;
            }
            iquad = game.quad[ix][iy];
            if (iquad != IHDOT) {
                /* object encountered in flight path */
                return;
            }
            iquad = game.quad[ix][iy];
            if (iquad != IHDOT) {
                /* object encountered in flight path */
-               stopegy = 50.0*dist/Time;
-               dist=0.1*sqrt((sectx-ix)*(double)(sectx-ix) +
-                             (secty-iy)*(double)(secty-iy));
+               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));
                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 +129,11 @@ void imove(void)
                case IHS:
                case IHR:
                case IHQUEST:
                case IHS:
                case IHR:
                case IHQUEST:
-                   sectx = ix;
-                   secty = iy;
-                   ram(0, iquad, sectx, secty);
-                   finalx = sectx;
-                   finaly = secty;
+                   game.sectx = ix;
+                   game.secty = iy;
+                   ram(0, iquad, game.sectx, game.secty);
+                   finalx = game.sectx;
+                   finaly = game.secty;
                    break;
                case IHBLANK:
                    skip(1);
                    break;
                case IHBLANK:
                    skip(1);
@@ -152,7 +152,7 @@ void imove(void)
                    for (l=0;l<NDEVICES;l++)
                        if (game.damage[l]>0) 
                            n++;
                    for (l=0;l<NDEVICES;l++)
                        if (game.damage[l]>0) 
                            n++;
-                   probf=pow(1.4,(energy+shield)/5000.0-1.0)*pow(1.3,1.0/(n+1)-1.0);
+                   probf=pow(1.4,(game.energy+game.shield)/5000.0-1.0)*pow(1.3,1.0/(n+1)-1.0);
                    if ((game.options & OPTION_BLKHOLE) && Rand()>probf) 
                        timwrp();
                    else 
                    if ((game.options & OPTION_BLKHOLE) && Rand()>probf) 
                        timwrp();
                    else 
@@ -170,12 +170,12 @@ void imove(void)
                    prout(";");
                    proutn("Emergency stop required ");
                    prout("%2d units of energy.", (int)stopegy);
                    prout(";");
                    proutn("Emergency stop required ");
                    prout("%2d units of energy.", (int)stopegy);
-                   energy -= stopegy;
+                   game.energy -= stopegy;
                    finalx = x-deltax+0.5;
                    finalx = x-deltax+0.5;
-                   sectx = finalx;
+                   game.sectx = finalx;
                    finaly = y-deltay+0.5;
                    finaly = y-deltay+0.5;
-                   secty = finaly;
-                   if (energy <= 0) {
+                   game.secty = finaly;
+                   if (game.energy <= 0) {
                        finish(FNRG);
                        return;
                    }
                        finish(FNRG);
                        return;
                    }
@@ -184,17 +184,17 @@ void imove(void)
                goto no_quad_change;    /* sorry! */
            }
        }
                goto no_quad_change;    /* sorry! */
            }
        }
-       dist = 0.1*sqrt((sectx-ix)*(double)(sectx-ix) +
-                       (secty-iy)*(double)(secty-iy));
-       sectx = ix;
-       secty = iy;
+       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;
     }
     }
-    finalx = sectx;
-    finaly = secty;
+    finalx = game.sectx;
+    finaly = game.secty;
 no_quad_change:
     /* No quadrant change -- compute new avg enemy distances */
 no_quad_change:
     /* No quadrant change -- compute new avg enemy distances */
-    game.quad[sectx][secty] = ship;
-    if (nenhere) {
+    game.quad[game.sectx][game.secty] = game.ship;
+    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]));
        for_local_enemies(l) {
            finald = sqrt((ix-game.kx[l])*(double)(ix-game.kx[l]) +
                          (iy-game.ky[l])*(double)(iy-game.ky[l]));
@@ -202,12 +202,12 @@ no_quad_change:
            game.kdist[l] = finald;
        }
        sortkl();
            game.kdist[l] = finald;
        }
        sortkl();
-       if (!game.state.galaxy[quadx][quady].supernova && iattak == 0)
+       if (!game.state.galaxy[game.quadx][game.quady].supernova && game.iattak == 0)
            attack(0);
        for_local_enemies(l) game.kavgd[l] = game.kdist[l];
     }
     newcnd();
            attack(0);
        for_local_enemies(l) game.kavgd[l] = game.kdist[l];
     }
     newcnd();
-    iattak = 0;
+    game.iattak = 0;
     drawmaps(0);
     setwnd(message_window);
     return;
     drawmaps(0);
     setwnd(message_window);
     return;
@@ -216,32 +216,32 @@ no_quad_change:
 void dock(int l) 
 {
     chew();
 void dock(int l) 
 {
     chew();
-    if (condit == IHDOCKED && l) {
+    if (game.condit == IHDOCKED && l) {
        prout("Already docked.");
        return;
     }
        prout("Already docked.");
        return;
     }
-    if (inorbit) {
+    if (game.inorbit) {
        prout("You must first leave standard orbit.");
        return;
     }
        prout("You must first leave standard orbit.");
        return;
     }
-    if (basex==0 || abs(sectx-basex) > 1 || abs(secty-basey) > 1) {
+    if (game.basex==0 || abs(game.sectx-game.basex) > 1 || abs(game.secty-game.basey) > 1) {
        crmshp();
        prout(" not adjacent to base.");
        return;
     }
        crmshp();
        prout(" not adjacent to base.");
        return;
     }
-    condit = IHDOCKED;
+    game.condit = IHDOCKED;
     if (l) prout("Docked.");
     if (l) prout("Docked.");
-    ididit=1;
-    if (energy < inenrg) energy = inenrg;
-    shield = inshld;
-    torps = intorps;
-    lsupres = inlsr;
+    game.ididit=1;
+    if (game.energy < game.inenrg) game.energy = game.inenrg;
+    game.shield = game.inshld;
+    game.torps = game.intorps;
+    game.lsupres = game.inlsr;
     if (game.damage[DRADIO] == 0.0 &&
     if (game.damage[DRADIO] == 0.0 &&
-       (game.future[FCDBAS] < FOREVER || isatb == 1) && iseenit == 0) {
+       (game.future[FCDBAS] < FOREVER || game.isatb == 1) && game.iseenit == 0) {
        /* get attack report from base */
        prout("Lt. Uhura- \"Captain, an important message from the starbase:\"");
        attakreport(0);
        /* get attack report from base */
        prout("Lt. Uhura- \"Captain, an important message from the starbase:\"");
        attakreport(0);
-       iseenit = 1;
+       game.iseenit = 1;
     }
 }
 
     }
 }
 
@@ -255,7 +255,7 @@ 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=quadx, icolq=quady, irows, icols, itemp=0, iprompt=0, key=0;
+        int irowq=game.quadx, icolq=game.quady, irows, icols, 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;
@@ -263,9 +263,9 @@ static void getcd(int isprobe, int akey) {
        /* 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. */
 
-       direc = -1.0;
+       game.direc = -1.0;
        
        
-       if (landed == 1 && !isprobe) {
+       if (game.landed == 1 && !isprobe) {
                prout("Dummy! You can't leave standard orbit until you");
                proutn("are back aboard the ");
                crmshp();
                prout("Dummy! You can't leave standard orbit until you");
                proutn("are back aboard the ");
                crmshp();
@@ -389,8 +389,8 @@ static void getcd(int isprobe, int akey) {
                        }
                        else prout("Ensign Chekov- \"Course laid in, Captain.\"");
                }
                        }
                        else prout("Ensign Chekov- \"Course laid in, Captain.\"");
                }
-               deltax = icolq - quady + 0.1*(icols-secty);
-               deltay = quadx - irowq + 0.1*(sectx-irows);
+               deltax = icolq - game.quady + 0.1*(icols-game.secty);
+               deltay = game.quadx - irowq + 0.1*(game.sectx-irows);
        }
        else { /* manual */
                while (key == IHEOL) {
        }
        else { /* manual */
                while (key == IHEOL) {
@@ -421,9 +421,9 @@ static void getcd(int isprobe, int akey) {
                skip(1);
                prout("Helmsman Sulu- \"Aye, Sir.\"");
        }
                skip(1);
                prout("Helmsman Sulu- \"Aye, Sir.\"");
        }
-       dist = sqrt(deltax*deltax + deltay*deltay);
-       direc = atan2(deltax, deltay)*1.90985932;
-       if (direc < 0.0) direc += 12.0;
+       game.dist = sqrt(deltax*deltax + deltay*deltay);
+       game.direc = atan2(deltax, deltay)*1.90985932;
+       if (game.direc < 0.0) game.direc += 12.0;
        chew();
        return;
 
        chew();
        return;
 
@@ -435,7 +435,7 @@ void impuls(void)
 {
     double power;
 
 {
     double power;
 
-    ididit = 0;
+    game.ididit = 0;
     if (game.damage[DIMPULS]) {
        chew();
        skip(1);
     if (game.damage[DIMPULS]) {
        chew();
        skip(1);
@@ -443,22 +443,22 @@ void impuls(void)
        return;
     }
 
        return;
     }
 
-    if (energy > 30.0) {
+    if (game.energy > 30.0) {
        getcd(FALSE, 0);
        getcd(FALSE, 0);
-       if (direc == -1.0) return;
-       power = 20.0 + 100.0*dist;
+       if (game.direc == -1.0) return;
+       power = 20.0 + 100.0*game.dist;
     }
     else
        power = 30.0;
 
     }
     else
        power = 30.0;
 
-    if (power >= energy) {
+    if (power >= game.energy) {
        /* Insufficient power for trip */
        skip(1);
        prout("First Officer Spock- \"Captain, the impulse engines");
        prout("require 20.0 units to engage, plus 100.0 units per");
        /* Insufficient power for trip */
        skip(1);
        prout("First Officer Spock- \"Captain, the impulse engines");
        prout("require 20.0 units to engage, plus 100.0 units per");
-       if (energy > 30) {
+       if (game.energy > 30) {
            proutn("quadrant.  We can go, therefore, a maximum of %d", 
            proutn("quadrant.  We can go, therefore, a maximum of %d", 
-                  (int)(0.01 * (energy-20.0)-0.05));
+                  (int)(0.01 * (game.energy-20.0)-0.05));
            prout(" quadrants.\"");
        }
        else {
            prout(" quadrants.\"");
        }
        else {
@@ -468,8 +468,8 @@ void impuls(void)
        return;
     }
     /* Make sure enough time is left for the trip */
        return;
     }
     /* Make sure enough time is left for the trip */
-    Time = dist/0.095;
-    if (Time >= game.state.remtime) {
+    game.optime = game.dist/0.095;
+    if (game.optime >= game.state.remtime) {
        prout("First Officer Spock- \"Captain, our speed under impulse");
        prout("power is only 0.95 sectors per stardate. Are you sure");
        proutn("we dare spend the time?\" ");
        prout("First Officer Spock- \"Captain, our speed under impulse");
        prout("power is only 0.95 sectors per stardate. Are you sure");
        proutn("we dare spend the time?\" ");
@@ -477,12 +477,12 @@ void impuls(void)
     }
     /* Activate impulse engines and pay the cost */
     imove();
     }
     /* Activate impulse engines and pay the cost */
     imove();
-    ididit = 1;
-    if (alldone) return;
-    power = 20.0 + 100.0*dist;
-    energy -= power;
-    Time = dist/0.095;
-    if (energy <= 0) finish(FNRG);
+    game.ididit = 1;
+    if (game.alldone) return;
+    power = 20.0 + 100.0*game.dist;
+    game.energy -= power;
+    game.optime = game.dist/0.095;
+    if (game.energy <= 0) finish(FNRG);
     return;
 }
 
     return;
 }
 
@@ -493,14 +493,14 @@ void warp(int i)
     double power;
 
     if (i!=2) { /* Not WARPX entry */
     double power;
 
     if (i!=2) { /* Not WARPX entry */
-       ididit = 0;
+       game.ididit = 0;
        if (game.damage[DWARPEN] > 10.0) {
            chew();
            skip(1);
            prout("Engineer Scott- \"The impulse engines are damaged, Sir.\"");
            return;
        }
        if (game.damage[DWARPEN] > 10.0) {
            chew();
            skip(1);
            prout("Engineer Scott- \"The impulse engines are damaged, Sir.\"");
            return;
        }
-       if (game.damage[DWARPEN] > 0.0 && warpfac > 4.0) {
+       if (game.damage[DWARPEN] > 0.0 && game.warpfac > 4.0) {
            chew();
            skip(1);
            prout("Engineer Scott- \"Sorry, Captain. Until this damage");
            chew();
            skip(1);
            prout("Engineer Scott- \"Sorry, Captain. Until this damage");
@@ -510,25 +510,25 @@ void warp(int i)
                        
        /* Read in course and distance */
        getcd(FALSE, 0);
                        
        /* Read in course and distance */
        getcd(FALSE, 0);
-       if (direc == -1.0) return;
+       if (game.direc == -1.0) return;
 
        /* Make sure starship has enough energy for the trip */
 
        /* Make sure starship has enough energy for the trip */
-       power = (dist+0.05)*warpfac*warpfac*warpfac*(shldup+1);
+       power = (game.dist+0.05)*game.warpfac*game.warpfac*game.warpfac*(game.shldup+1);
 
 
 
 
-       if (power >= energy) {
+       if (power >= game.energy) {
            /* Insufficient power for trip */
            /* Insufficient power for trip */
-           ididit = 0;
+           game.ididit = 0;
            skip(1);
            prout("Engineering to bridge--");
            skip(1);
            prout("Engineering to bridge--");
-           if (shldup==0 || 0.5*power > energy) {
-               iwarp = pow((energy/(dist+0.05)), 0.333333333);
+           if (game.shldup==0 || 0.5*power > game.energy) {
+               iwarp = pow((game.energy/(game.dist+0.05)), 0.333333333);
                if (iwarp <= 0) {
                    prout("We can't do it, Captain. We haven't the energy.");
                }
                else {
                    proutn("We haven't the energy, but we could do it at warp %d", iwarp);
                if (iwarp <= 0) {
                    prout("We can't do it, Captain. We haven't the energy.");
                }
                else {
                    proutn("We haven't the energy, but we could do it at warp %d", iwarp);
-                   if (shldup) {
+                   if (game.shldup) {
                        prout(",");
                        prout("if you'll lower the shields.");
                    }
                        prout(",");
                        prout("if you'll lower the shields.");
                    }
@@ -542,29 +542,29 @@ void warp(int i)
        }
                                                
        /* Make sure enough time is left for the trip */
        }
                                                
        /* Make sure enough time is left for the trip */
-       Time = 10.0*dist/wfacsq;
-       if (Time >= 0.8*game.state.remtime) {
+       game.optime = 10.0*game.dist/game.wfacsq;
+       if (game.optime >= 0.8*game.state.remtime) {
            skip(1);
            prout("First Officer Spock- \"Captain, I compute that such");
            proutn("  a trip would require approximately %2.0f",
            skip(1);
            prout("First Officer Spock- \"Captain, I compute that such");
            proutn("  a trip would require approximately %2.0f",
-                  100.0*Time/game.state.remtime);
+                  100.0*game.optime/game.state.remtime);
            prout(" percent of our");
            proutn("  remaining time.  Are you sure this is wise?\" ");
            prout(" percent of our");
            proutn("  remaining time.  Are you sure this is wise?\" ");
-           if (ja() == 0) { ididit = 0; Time=0; return;}
+           if (ja() == 0) { game.ididit = 0; game.optime=0; return;}
        }
     }
     /* Entry WARPX */
        }
     }
     /* Entry WARPX */
-    if (warpfac > 6.0) {
+    if (game.warpfac > 6.0) {
        /* Decide if engine damage will occur */
        /* Decide if engine damage will occur */
-       double prob = dist*(6.0-warpfac)*(6.0-warpfac)/66.666666666;
+       double prob = game.dist*(6.0-game.warpfac)*(6.0-game.warpfac)/66.666666666;
        if (prob > Rand()) {
            blooey = 1;
        if (prob > Rand()) {
            blooey = 1;
-           dist = Rand()*dist;
+           game.dist = Rand()*game.dist;
        }
        /* Decide if time warp will occur */
        }
        /* Decide if time warp will occur */
-       if (0.5*dist*pow(7.0,warpfac-10.0) > Rand()) twarp=1;
+       if (0.5*game.dist*pow(7.0,game.warpfac-10.0) > Rand()) twarp=1;
 #ifdef DEBUG
 #ifdef DEBUG
-       if (idebug &&warpfac==10 && twarp==0) {
+       if (game.idebug &&game.warpfac==10 && twarp==0) {
            blooey=0;
            proutn("Force time warp? ");
            if (ja()==1) twarp=1;
            blooey=0;
            proutn("Force time warp? ");
            if (ja()==1) twarp=1;
@@ -573,7 +573,7 @@ void warp(int i)
        if (blooey || twarp) {
            /* If time warp or engine damage, check path */
            /* If it is obstructed, don't do warp or damage */
        if (blooey || twarp) {
            /* If time warp or engine damage, check path */
            /* If it is obstructed, don't do warp or damage */
-           double angle = ((15.0-direc)*0.5235998);
+           double angle = ((15.0-game.direc)*0.5235998);
            double deltax = -sin(angle);
            double deltay = cos(angle);
            double bigger, x, y;
            double deltax = -sin(angle);
            double deltay = cos(angle);
            double bigger, x, y;
@@ -585,9 +585,9 @@ void warp(int i)
                        
            deltax /= bigger;
            deltay /= bigger;
                        
            deltax /= bigger;
            deltay /= bigger;
-           n = 10.0 * dist * bigger +0.5;
-           x = sectx;
-           y = secty;
+           n = 10.0 * game.dist * bigger +0.5;
+           x = game.sectx;
+           y = game.secty;
            for (l = 1; l <= n; l++) {
                x += deltax;
                ix = x + 0.5;
            for (l = 1; l <= n; l++) {
                x += deltax;
                ix = x + 0.5;
@@ -605,19 +605,19 @@ void warp(int i)
 
     /* Activate Warp Engines and pay the cost */
     imove();
 
     /* Activate Warp Engines and pay the cost */
     imove();
-    if (alldone) return;
-    energy -= dist*warpfac*warpfac*warpfac*(shldup+1);
-    if (energy <= 0) finish(FNRG);
-    Time = 10.0*dist/wfacsq;
+    if (game.alldone) return;
+    game.energy -= game.dist*game.warpfac*game.warpfac*game.warpfac*(game.shldup+1);
+    if (game.energy <= 0) finish(FNRG);
+    game.optime = 10.0*game.dist/game.wfacsq;
     if (twarp) timwrp();
     if (blooey) {
     if (twarp) timwrp();
     if (blooey) {
-       game.damage[DWARPEN] = damfac*(3.0*Rand()+1.0);
+       game.damage[DWARPEN] = game.damfac*(3.0*Rand()+1.0);
        skip(1);
        prout("Engineering to bridge--");
        prout("  Scott here.  The warp engines are damaged.");
        prout("  We'll have to reduce speed to warp 4.");
     }
        skip(1);
        prout("Engineering to bridge--");
        prout("  Scott here.  The warp engines are damaged.");
        prout("  We'll have to reduce speed to warp 4.");
     }
-    ididit = 1;
+    game.ididit = 1;
     return;
 }
 
     return;
 }
 
@@ -654,19 +654,19 @@ void setwrp(void)
        prout("Helmsman Sulu- \"We can't go below warp 1, Captain.\"");
        return;
     }
        prout("Helmsman Sulu- \"We can't go below warp 1, Captain.\"");
        return;
     }
-    oldfac = warpfac;
-    warpfac = aaitem;
-    wfacsq=warpfac*warpfac;
-    if (warpfac <= oldfac || warpfac <= 6.0) {
+    oldfac = game.warpfac;
+    game.warpfac = aaitem;
+    game.wfacsq=game.warpfac*game.warpfac;
+    if (game.warpfac <= oldfac || game.warpfac <= 6.0) {
        proutn("Helmsman Sulu- \"Warp factor %d, Captain.\"", 
        proutn("Helmsman Sulu- \"Warp factor %d, Captain.\"", 
-              (int)warpfac);
+              (int)game.warpfac);
        return;
     }
        return;
     }
-    if (warpfac < 8.00) {
+    if (game.warpfac < 8.00) {
        prout("Engineer Scott- \"Aye, but our maximum safe speed is warp 6.\"");
        return;
     }
        prout("Engineer Scott- \"Aye, but our maximum safe speed is warp 6.\"");
        return;
     }
-    if (warpfac == 10.0) {
+    if (game.warpfac == 10.0) {
        prout("Engineer Scott- \"Aye, Captain, we'll try it.\"");
        return;
     }
        prout("Engineer Scott- \"Aye, Captain, we'll try it.\"");
        return;
     }
@@ -680,13 +680,13 @@ void atover(int igrab)
 
     chew();
     /* is captain on planet? */
 
     chew();
     /* is captain on planet? */
-    if (landed==1) {
+    if (game.landed==1) {
        if (game.damage[DTRANSP]) {
            finish(FPNOVA);
            return;
        }
        prout("Scotty rushes to the transporter controls.");
        if (game.damage[DTRANSP]) {
            finish(FPNOVA);
            return;
        }
        prout("Scotty rushes to the transporter controls.");
-       if (shldup) {
+       if (game.shldup) {
            prout("But with the shields up it's hopeless.");
            finish(FPNOVA);
        }
            prout("But with the shields up it's hopeless.");
            finish(FPNOVA);
        }
@@ -697,28 +697,28 @@ void atover(int igrab)
            return;
        }
        prout("SUCCEEDS!");
            return;
        }
        prout("SUCCEEDS!");
-       if (imine) {
-           imine = 0;
+       if (game.imine) {
+           game.imine = 0;
            proutn("The crystals mined were ");
            if (Rand() <= 0.25) {
                prout("lost.");
            }
            else {
                prout("saved.");
            proutn("The crystals mined were ");
            if (Rand() <= 0.25) {
                prout("lost.");
            }
            else {
                prout("saved.");
-               icrystl = 1;
+               game.icrystl = 1;
            }
        }
     }
     if (igrab) return;
 
     /* Check to see if captain in shuttle craft */
            }
        }
     }
     if (igrab) return;
 
     /* Check to see if captain in shuttle craft */
-    if (icraft) finish(FSTRACTOR);
-    if (alldone) return;
+    if (game.icraft) finish(FSTRACTOR);
+    if (game.alldone) return;
 
     /* Inform captain of attempt to reach safety */
     skip(1);
     do {
 
     /* Inform captain of attempt to reach safety */
     skip(1);
     do {
-       if (justin) {
+       if (game.justin) {
            prouts("***RED ALERT!  READ ALERT!");
            skip(1);
            proutn("The ");
            prouts("***RED ALERT!  READ ALERT!");
            skip(1);
            proutn("The ");
@@ -732,7 +732,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[quadx][quady].charted = TRUE;
+           game.state.galaxy[game.quadx][game.quady].charted = TRUE;
        /* Try to use warp engines */
        if (game.damage[DWARPEN]) {
            skip(1);
        /* Try to use warp engines */
        if (game.damage[DWARPEN]) {
            skip(1);
@@ -740,21 +740,21 @@ void atover(int igrab)
            finish(FSNOVAED);
            return;
        }
            finish(FSNOVAED);
            return;
        }
-       warpfac = 6.0+2.0*Rand();
-       wfacsq = warpfac * warpfac;
-       prout("Warp factor set to %d", (int)warpfac);
-       power = 0.75*energy;
-       dist = power/(warpfac*warpfac*warpfac*(shldup+1));
+       game.warpfac = 6.0+2.0*Rand();
+       game.wfacsq = game.warpfac * game.warpfac;
+       prout("Warp factor set to %d", (int)game.warpfac);
+       power = 0.75*game.energy;
+       game.dist = power/(game.warpfac*game.warpfac*game.warpfac*(game.shldup+1));
        distreq = 1.4142+Rand();
        distreq = 1.4142+Rand();
-       if (distreq < dist) dist = distreq;
-       Time = 10.0*dist/wfacsq;
-       direc = 12.0*Rand();    /* How dumb! */
-       justin = 0;
-       inorbit = 0;
+       if (distreq < game.dist) game.dist = distreq;
+       game.optime = 10.0*game.dist/game.wfacsq;
+       game.direc = 12.0*Rand();       /* How dumb! */
+       game.justin = 0;
+       game.inorbit = 0;
        warp(2);
        warp(2);
-       if (justin == 0) {
+       if (game.justin == 0) {
            /* This is bad news, we didn't leave quadrant. */
            /* This is bad news, we didn't leave quadrant. */
-           if (alldone) return;
+           if (game.alldone) return;
            skip(1);
            prout("Insufficient energy to leave quadrant.");
            finish(FSNOVAED);
            skip(1);
            prout("Insufficient energy to leave quadrant.");
            finish(FSNOVAED);
@@ -762,7 +762,7 @@ void atover(int igrab)
        }
     } while 
        /* Repeat if another snova */
        }
     } while 
        /* Repeat if another snova */
-       (game.state.galaxy[quadx][quady].supernova);
+       (game.state.galaxy[game.quadx][game.quady].supernova);
     if (KLINGREM==0) 
        finish(FWON); /* Snova killed remaining enemy. */
 }
     if (KLINGREM==0) 
        finish(FWON); /* Snova killed remaining enemy. */
 }
@@ -778,34 +778,34 @@ void timwrp()
        game.state = game.snapsht;
        game.state.snap = 0;
        if (game.state.remcom) {
        game.state = game.snapsht;
        game.state.snap = 0;
        if (game.state.remcom) {
-           game.future[FTBEAM] = game.state.date + expran(intime/game.state.remcom);
-           game.future[FBATTAK] = game.state.date + expran(0.3*intime);
+           game.future[FTBEAM] = game.state.date + expran(game.intime/game.state.remcom);
+           game.future[FBATTAK] = game.state.date + expran(0.3*game.intime);
        }
        }
-       game.future[FSNOVA] = game.state.date + expran(0.5*intime);
+       game.future[FSNOVA] = game.state.date + expran(0.5*game.intime);
        game.future[FSNAP] = game.state.date +expran(0.25*game.state.remtime); /* next snapshot will
                                                                                  be sooner */
        if (game.state.nscrem) game.future[FSCMOVE] = 0.2777;
        game.future[FSNAP] = game.state.date +expran(0.25*game.state.remtime); /* next snapshot will
                                                                                  be sooner */
        if (game.state.nscrem) game.future[FSCMOVE] = 0.2777;
-       isatb = 0;
+       game.isatb = 0;
        game.future[FCDBAS] = game.future[FSCDBAS] = FOREVER;
        game.future[FCDBAS] = game.future[FSCDBAS] = FOREVER;
-       batx = baty = 0;
+       game.batx = game.baty = 0;
 
        /* Make sure Galileo is consistant -- Snapshot may have been taken
           when on planet, which would give us two Galileos! */
        gotit = 0;
 
        /* Make sure Galileo is consistant -- Snapshot may have been taken
           when on planet, which would give us two Galileos! */
        gotit = 0;
-       for (l = 0; l < inplan; l++) {
+       for (l = 0; l < game.inplan; l++) {
            if (game.state.plnets[l].known == shuttle_down) {
                gotit = 1;
            if (game.state.plnets[l].known == shuttle_down) {
                gotit = 1;
-               if (iscraft==1 && ship==IHE) {
+               if (game.iscraft==1 && game.ship==IHE) {
                    prout("Checkov-  \"Security reports the Galileo has disappeared, Sir!");
                    prout("Checkov-  \"Security reports the Galileo has disappeared, Sir!");
-                   iscraft = 0;
+                   game.iscraft = 0;
                }
            }
        }
        /* Likewise, if in the original time the Galileo was abandoned, but
           was on ship earlier, it would have vanished -- lets restore it */
                }
            }
        }
        /* Likewise, if in the original time the Galileo was abandoned, but
           was on ship earlier, it would have vanished -- lets restore it */
-       if (iscraft==0 && gotit==0 && game.damage[DSHUTTL] >= 0.0) {
+       if (game.iscraft==0 && gotit==0 && game.damage[DSHUTTL] >= 0.0) {
            prout("Checkov-  \"Security reports the Galileo has reappeared in the dock!\"");
            prout("Checkov-  \"Security reports the Galileo has reappeared in the dock!\"");
-           iscraft = 1;
+           game.iscraft = 1;
        }
        /* 
         * There used to be code to do the actual reconstrction here,
        }
        /* 
         * There used to be code to do the actual reconstrction here,
@@ -815,11 +815,11 @@ void timwrp()
     }
     else {
        /* Go forward in time */
     }
     else {
        /* Go forward in time */
-       Time = -0.5*intime*log(Rand());
-       prout("You are traveling forward in time %d stardates.", (int)Time);
+       game.optime = -0.5*game.intime*log(Rand());
+       prout("You are traveling forward in time %d stardates.", (int)game.optime);
        /* cheat to make sure no tractor beams occur during time warp */
        /* cheat to make sure no tractor beams occur during time warp */
-       game.future[FTBEAM] += Time;
-       game.damage[DRADIO] += Time;
+       game.future[FTBEAM] += game.optime;
+       game.damage[DRADIO] += game.optime;
     }
     newqad(0);
     events();  /* Stas Sergeev added this -- do pending events */
     }
     newqad(0);
     events();  /* Stas Sergeev added this -- do pending events */
@@ -830,10 +830,10 @@ void probe(void)
     double angle, bigger;
     int key;
     /* New code to launch a deep space probe */
     double angle, bigger;
     int key;
     /* New code to launch a deep space probe */
-    if (nprobes == 0) {
+    if (game.nprobes == 0) {
        chew();
        skip(1);
        chew();
        skip(1);
-       if (ship == IHE) 
+       if (game.ship == IHE) 
            prout("Engineer Scott- \"We have no more deep space probes, Sir.\"");
        else
            prout("Ye Faerie Queene has no deep space probes.");
            prout("Engineer Scott- \"We have no more deep space probes, Sir.\"");
        else
            prout("Ye Faerie Queene has no deep space probes.");
@@ -848,7 +848,7 @@ void probe(void)
     if (game.future[FDSPROB] != FOREVER) {
        chew();
        skip(1);
     if (game.future[FDSPROB] != FOREVER) {
        chew();
        skip(1);
-       if (game.damage[DRADIO] != 0 && condit != IHDOCKED) {
+       if (game.damage[DRADIO] != 0 && game.condit != IHDOCKED) {
            prout("Spock-  \"Records show the previous probe has not yet");
            prout("   reached its destination.\"");
        }
            prout("Spock-  \"Records show the previous probe has not yet");
            prout("   reached its destination.\"");
        }
@@ -860,41 +860,41 @@ void probe(void)
 
     if (key == IHEOL) {
        /* slow mode, so let Kirk know how many probes there are left */
 
     if (key == IHEOL) {
        /* slow mode, so let Kirk know how many probes there are left */
-       prout(nprobes==1 ? "%d probe left." : "%d probes left.", nprobes);
+       prout(game.nprobes==1 ? "%d probe left." : "%d probes left.", game.nprobes);
        proutn("Are you sure you want to fire a probe? ");
        if (ja()==0) return;
     }
 
        proutn("Are you sure you want to fire a probe? ");
        if (ja()==0) return;
     }
 
-    isarmed = FALSE;
+    game.isarmed = FALSE;
     if (key == IHALPHA && strcmp(citem,"armed") == 0) {
     if (key == IHALPHA && strcmp(citem,"armed") == 0) {
-       isarmed = TRUE;
+       game.isarmed = TRUE;
        key = scan();
     }
     else if (key == IHEOL) {
        proutn("Arm NOVAMAX warhead? ");
        key = scan();
     }
     else if (key == IHEOL) {
        proutn("Arm NOVAMAX warhead? ");
-       isarmed = ja();
+       game.isarmed = ja();
     }
     getcd(TRUE, key);
     }
     getcd(TRUE, key);
-    if (direc == -1.0) return;
-    nprobes--;
-    angle = ((15.0 - direc) * 0.5235988);
-    probeinx = -sin(angle);
-    probeiny = cos(angle);
-    if (fabs(probeinx) > fabs(probeiny))
-       bigger = fabs(probeinx);
+    if (game.direc == -1.0) return;
+    game.nprobes--;
+    angle = ((15.0 - game.direc) * 0.5235988);
+    game.probeinx = -sin(angle);
+    game.probeiny = cos(angle);
+    if (fabs(game.probeinx) > fabs(game.probeiny))
+       bigger = fabs(game.probeinx);
     else
     else
-       bigger = fabs(probeiny);
+       bigger = fabs(game.probeiny);
                
                
-    probeiny /= bigger;
-    probeinx /= bigger;
-    proben = 10.0*dist*bigger +0.5;
-    probex = quadx*QUADSIZE + sectx - 1;       // We will use better packing than original
-    probey = quady*QUADSIZE + secty - 1;
-    probecx = quadx;
-    probecy = quady;
+    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.future[FDSPROB] = game.state.date + 0.01; // Time to move one sector
     prout("Ensign Chekov-  \"The deep space probe is launched, Captain.\"");
     game.future[FDSPROB] = game.state.date + 0.01; // Time to move one sector
     prout("Ensign Chekov-  \"The deep space probe is launched, Captain.\"");
-    ididit = 1;
+    game.ididit = 1;
     return;
 }
 
     return;
 }
 
@@ -905,8 +905,8 @@ void help(void)
     int line = 0, l, ix, iy;
 
     chew();
     int line = 0, l, ix, iy;
 
     chew();
-    /* Test for conditions which prevent calling for help */
-    if (condit == IHDOCKED) {
+    /* Test for game.conditions which prevent calling for help */
+    if (game.condit == IHDOCKED) {
        prout("Lt. Uhura-  \"But Captain, we're already docked.\"");
        return;
     }
        prout("Lt. Uhura-  \"But Captain, we're already docked.\"");
        return;
     }
@@ -918,50 +918,50 @@ void help(void)
        prout("Lt. Uhura-  \"Captain, I'm not getting any response from Starbase.\"");
        return;
     }
        prout("Lt. Uhura-  \"Captain, I'm not getting any response from Starbase.\"");
        return;
     }
-    if (landed == 1) {
+    if (game.landed == 1) {
        proutn("You must be aboard the ");
        crmshp();
        prout(".");
        return;
     }
     /* OK -- call for help from nearest starbase */
        proutn("You must be aboard the ");
        crmshp();
        prout(".");
        return;
     }
     /* OK -- call for help from nearest starbase */
-    nhelp++;
-    if (basex!=0) {
+    game.nhelp++;
+    if (game.basex!=0) {
        /* There's one in this quadrant */
        /* There's one in this quadrant */
-       ddist = sqrt(square(basex-sectx)+square(basey-secty));
+       ddist = sqrt(square(game.basex-game.sectx)+square(game.basey-game.secty));
     }
     else {
        ddist = FOREVER;
        for_starbases(l) {
     }
     else {
        ddist = FOREVER;
        for_starbases(l) {
-           xdist=10.0*sqrt(square(game.state.baseqx[l]-quadx)+square(game.state.baseqy[l]-quady));
+           xdist=10.0*sqrt(square(game.state.baseqx[l]-game.quadx)+square(game.state.baseqy[l]-game.quady));
            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 */
-       quadx = game.state.baseqx[line];
-       quady = game.state.baseqy[line];
+       game.quadx = game.state.baseqx[line];
+       game.quady = game.state.baseqy[line];
        newqad(1);
     }
     /* dematerialize starship */
        newqad(1);
     }
     /* dematerialize starship */
-    game.quad[sectx][secty]=IHDOT;
-    proutn("Starbase in %s responds--", cramlc(quadrant, quadx, quady));
+    game.quad[game.sectx][game.secty]=IHDOT;
+    proutn("Starbase in %s responds--", cramlc(quadrant, game.quadx, game.quady));
     proutn("");
     crmshp();
     prout(" dematerializes.");
     proutn("");
     crmshp();
     prout(" dematerializes.");
-    sectx=0;
+    game.sectx=0;
     for (l = 1; l <= 5; l++) {
     for (l = 1; l <= 5; l++) {
-       ix = basex+3.0*Rand()-1;
-       iy = basey+3.0*Rand()-1;
+       ix = game.basex+3.0*Rand()-1;
+       iy = game.basey+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 */
-           sectx=ix;
-           secty=iy;
+           game.sectx=ix;
+           game.secty=iy;
            break;
        }
     }
            break;
        }
     }
-    if (sectx==0){
+    if (game.sectx==0){
        prout("You have been lost in space...");
        finish(FMATERIALIZE);
        return;
        prout("You have been lost in space...");
        finish(FMATERIALIZE);
        return;
@@ -993,13 +993,13 @@ void help(void)
     }
     if (l > 3) {
        game.quad[ix][iy]=IHQUEST;
     }
     if (l > 3) {
        game.quad[ix][iy]=IHQUEST;
-       alive = 0;
+       game.alive = 0;
        drawmaps(1);
        setwnd(message_window);
        finish(FMATERIALIZE);
        return;
     }
        drawmaps(1);
        setwnd(message_window);
        finish(FMATERIALIZE);
        return;
     }
-    game.quad[ix][iy]=ship;
+    game.quad[ix][iy]=game.ship;
     textcolor(GREEN);
     prout("succeeds.");
     textcolor(DEFAULT);
     textcolor(GREEN);
     prout("succeeds.");
     textcolor(DEFAULT);
index 217ce1414e72a47ce740e163cd1b02d0989a8532..6c5f3654a7f35c5c305437b3a5eca5714359caf9 100644 (file)
@@ -8,10 +8,10 @@ static int consumeTime(void)
    Let's see what happens if all events can occur here */
 
 //  double asave;
    Let's see what happens if all events can occur here */
 
 //  double asave;
-    ididit = 1;
+    game.ididit = 1;
 #if 0
     /* Don't worry about this */
 #if 0
     /* Don't worry about this */
-    if (future[FTBEAM] <= game.state.date+Time && game.state.remcom != 0 && condit != IHDOCKED) {
+    if (future[FTBEAM] <= game.state.date+game.optime && game.state.remcom != 0 && game.condit != IHDOCKED) {
        /* We are about to be tractor beamed -- operation fails */
        return 1;
     }
        /* We are about to be tractor beamed -- operation fails */
        return 1;
     }
@@ -21,7 +21,7 @@ static int consumeTime(void)
     events();  /* Used to avoid if future[FSCMOVE] within time */
 //     future[FSNOVA] = asave;
     /*fails if game over, quadrant super-novas or we've moved to new quadrant*/
     events();  /* Used to avoid if future[FSCMOVE] within time */
 //     future[FSNOVA] = asave;
     /*fails if game over, quadrant super-novas or we've moved to new quadrant*/
-    if (alldone || game.state.galaxy[quadx][quady].supernova || justin != 0) return 1;
+    if (game.alldone || game.state.galaxy[game.quadx][game.quady].supernova || game.justin != 0) return 1;
     return 0;
 }
 
     return 0;
 }
 
@@ -32,15 +32,15 @@ void preport(void)
     chew();
     prout("Spock-  \"Planet report follows, Captain.\"");
     skip(1);
     chew();
     prout("Spock-  \"Planet report follows, Captain.\"");
     skip(1);
-    for (i = 0; i < inplan; i++) {
+    for (i = 0; i < game.inplan; i++) {
        if (game.state.plnets[i].known != unknown
 #ifdef DEBUG
        if (game.state.plnets[i].known != unknown
 #ifdef DEBUG
-           || ( idebug && game.state.plnets[i].x !=0)
+           || ( game.idebug && game.state.plnets[i].x !=0)
 #endif
            ) {
            iknow = 1;
 #ifdef DEBUG
 #endif
            ) {
            iknow = 1;
 #ifdef DEBUG
-           if (idebug && game.state.plnets[i].known==unknown) proutn("(Unknown) ");
+           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("   class ");
 #endif
            proutn(cramlc(quadrant, game.state.plnets[i].x, game.state.plnets[i].y));
            proutn("   class ");
@@ -59,7 +59,7 @@ void orbit(void)
 {
     skip(1);
     chew();
 {
     skip(1);
     chew();
-    if (inorbit!=0) {
+    if (game.inorbit!=0) {
        prout("Already in standard orbit.");
        return;
     }
        prout("Already in standard orbit.");
        return;
     }
@@ -67,20 +67,20 @@ void orbit(void)
        prout("Both warp and impulse engines damaged.");
        return;
     }
        prout("Both warp and impulse engines damaged.");
        return;
     }
-    if (plnetx == 0 || abs(sectx-plnetx) > 1 || abs(secty-plnety) > 1) {
+    if (game.plnetx == 0 || abs(game.sectx-game.plnetx) > 1 || abs(game.secty-game.plnety) > 1) {
        crmshp();
        prout(" not adjacent to planet.");
        skip(1);
        return;
     }
        crmshp();
        prout(" not adjacent to planet.");
        skip(1);
        return;
     }
-    Time = 0.02+0.03*Rand();
+    game.optime = 0.02+0.03*Rand();
     prout("Helmsman Sulu-  \"Entering standard orbit, Sir.\"");
     newcnd();
     if (consumeTime()) return;
     game.height = (1400.0+7200.0*Rand());
     prout("Sulu-  \"Entered orbit at altitude %.2f kilometers.\"", game.height);
     prout("Helmsman Sulu-  \"Entering standard orbit, Sir.\"");
     newcnd();
     if (consumeTime()) return;
     game.height = (1400.0+7200.0*Rand());
     prout("Sulu-  \"Entered orbit at altitude %.2f kilometers.\"", game.height);
-    inorbit = 1;
-    ididit=1;
+    game.inorbit = 1;
+    game.ididit=1;
 }
 
 void sensor(void) 
 }
 
 void sensor(void) 
@@ -91,22 +91,22 @@ void sensor(void)
        prout("Short range sensors damaged.");
        return;
     }
        prout("Short range sensors damaged.");
        return;
     }
-    if (!plnetx && (game.options & OPTION_TTY)) {
+    if (!game.plnetx && (game.options & OPTION_TTY)) {
        prout("Spock- \"No planet in this quadrant, Captain.\"");
        return;
     }
        prout("Spock- \"No planet in this quadrant, Captain.\"");
        return;
     }
-    if ((plnetx != 0)&& (game.state.plnets[iplnet].known == unknown)) {
-       prout("Spock-  \"Sensor scan for %s-", cramlc(quadrant, quadx, quady));
+    if ((game.plnetx != 0)&& (game.state.plnets[game.iplnet].known == unknown)) {
+       prout("Spock-  \"Sensor scan for %s-", cramlc(quadrant, game.quadx, game.quady));
        skip(1);
        prout("         Planet at %s is of class %s.", 
        skip(1);
        prout("         Planet at %s is of class %s.", 
-             cramlc(sector, plnetx, plnety),
-             classes[game.state.plnets[iplnet].pclass]);
-       if (game.state.plnets[iplnet].known==shuttle_down) 
+             cramlc(sector, game.plnetx, game.plnety),
+             classes[game.state.plnets[game.iplnet].pclass]);
+       if (game.state.plnets[game.iplnet].known==shuttle_down) 
            prout("         Sensors show Galileo still on surface.");
        proutn("         Readings indicate");
            prout("         Sensors show Galileo still on surface.");
        proutn("         Readings indicate");
-       if (game.state.plnets[iplnet].crystals == 0) proutn(" no");
+       if (game.state.plnets[game.iplnet].crystals == 0) proutn(" no");
        prout(" dilithium crystals present.\"");
        prout(" dilithium crystals present.\"");
-       if (game.state.plnets[iplnet].known == unknown) game.state.plnets[iplnet].known = known;
+       if (game.state.plnets[game.iplnet].known == unknown) game.state.plnets[game.iplnet].known = known;
     }
 }
 
     }
 }
 
@@ -116,31 +116,31 @@ void beam(void)
     skip(1);
     if (game.damage[DTRANSP] != 0) {
        prout("Transporter damaged.");
     skip(1);
     if (game.damage[DTRANSP] != 0) {
        prout("Transporter damaged.");
-       if (game.damage[DSHUTTL]==0 && (game.state.plnets[iplnet].known==shuttle_down || iscraft == 1)) {
+       if (game.damage[DSHUTTL]==0 && (game.state.plnets[game.iplnet].known==shuttle_down || game.iscraft == 1)) {
            skip(1);
            proutn("Spock-  \"May I suggest the shuttle craft, Sir?\" ");
            if (ja() != 0) shuttle();
        }
        return;
     }
            skip(1);
            proutn("Spock-  \"May I suggest the shuttle craft, Sir?\" ");
            if (ja() != 0) shuttle();
        }
        return;
     }
-    if (inorbit==0) {
+    if (game.inorbit==0) {
        crmshp();
        prout(" not in standard orbit.");
        return;
     }
        crmshp();
        prout(" not in standard orbit.");
        return;
     }
-    if (shldup!=0) {
+    if (game.shldup!=0) {
        prout("Impossible to transport through shields.");
        return;
     }
        prout("Impossible to transport through shields.");
        return;
     }
-    if (game.state.plnets[iplnet].known==unknown) {
+    if (game.state.plnets[game.iplnet].known==unknown) {
        prout("Spock-  \"Captain, we have no information on this planet");
        prout("  and Starfleet Regulations clearly state that in this situation");
        prout("  you may not go down.\"");
        return;
     }
        prout("Spock-  \"Captain, we have no information on this planet");
        prout("  and Starfleet Regulations clearly state that in this situation");
        prout("  you may not go down.\"");
        return;
     }
-    if (landed==1) {
+    if (game.landed==1) {
        /* Coming from planet */
        /* Coming from planet */
-       if (game.state.plnets[iplnet].known==shuttle_down) {
+       if (game.state.plnets[game.iplnet].known==shuttle_down) {
            proutn("Spock-  \"Wouldn't you rather take the Galileo?\" ");
            if (ja() != 0) {
                chew();
            proutn("Spock-  \"Wouldn't you rather take the Galileo?\" ");
            if (ja() != 0) {
                chew();
@@ -157,7 +157,7 @@ void beam(void)
     }
     else {
        /* Going to planet */
     }
     else {
        /* Going to planet */
-       if (game.state.plnets[iplnet].crystals==0) {
+       if (game.state.plnets[game.iplnet].crystals==0) {
            prout("Spock-  \"Captain, I fail to see the logic in");
            prout("  exploring a planet with no dilithium crystals.");
            proutn("  Are you sure this is wise?\" ");
            prout("Spock-  \"Captain, I fail to see the logic in");
            prout("  exploring a planet with no dilithium crystals.");
            proutn("  Are you sure this is wise?\" ");
@@ -172,7 +172,7 @@ void beam(void)
        skip(1);
        prout("Kirk-  \"Energize.\"");
     }
        skip(1);
        prout("Kirk-  \"Energize.\"");
     }
-    ididit=1;
+    game.ididit=1;
     skip(1);
     prouts("WWHOOOIIIIIRRRRREEEE.E.E.  .  .  .  .   .    .");
     skip(2);
     skip(1);
     prouts("WWHOOOIIIIIRRRRREEEE.E.E.  .  .  .  .   .    .");
     skip(2);
@@ -186,15 +186,15 @@ void beam(void)
     prouts(".    .   .  .  .  .  .E.E.EEEERRRRRIIIIIOOOHWW");
     skip(2);
     prout("Transport complete.");
     prouts(".    .   .  .  .  .  .E.E.EEEERRRRRIIIIIOOOHWW");
     skip(2);
     prout("Transport complete.");
-    landed = -landed;
-    if (landed==1 && game.state.plnets[iplnet].known==shuttle_down) {
+    game.landed = -game.landed;
+    if (game.landed==1 && game.state.plnets[game.iplnet].known==shuttle_down) {
        prout("The shuttle craft Galileo is here!");
     }
        prout("The shuttle craft Galileo is here!");
     }
-    if (landed!=1 && imine==1) {
-       icrystl = 1;
-       cryprob = 0.05;
+    if (game.landed!=1 && game.imine==1) {
+       game.icrystl = 1;
+       game.cryprob = 0.05;
     }
     }
-    imine = 0;
+    game.imine = 0;
     return;
 }
 
     return;
 }
 
@@ -202,44 +202,44 @@ void mine(void)
 {
     skip(1);
     chew();
 {
     skip(1);
     chew();
-    if (landed!= 1) {
+    if (game.landed!= 1) {
        prout("Mining party not on planet.");
        return;
     }
        prout("Mining party not on planet.");
        return;
     }
-    if (game.state.plnets[iplnet].crystals == 0) {
+    if (game.state.plnets[game.iplnet].crystals == 0) {
        prout("No dilithium crystals on this planet.");
        return;
     }
        prout("No dilithium crystals on this planet.");
        return;
     }
-    if (imine == 1) {
+    if (game.imine == 1) {
        prout("You've already mined enough crystals for this trip.");
        return;
     }
        prout("You've already mined enough crystals for this trip.");
        return;
     }
-    if (icrystl == 1 && cryprob == 0.05) {
+    if (game.icrystl == 1 && game.cryprob == 0.05) {
        proutn("With all those fresh crystals aboard the ");
        crmshp();
        skip(1);
        prout("there's no reason to mine more at this time.");
        return;
     }
        proutn("With all those fresh crystals aboard the ");
        crmshp();
        skip(1);
        prout("there's no reason to mine more at this time.");
        return;
     }
-    Time = (0.1+0.2*Rand())*game.state.plnets[iplnet].pclass;
+    game.optime = (0.1+0.2*Rand())*game.state.plnets[game.iplnet].pclass;
     if (consumeTime()) return;
     prout("Mining operation complete.");
     if (consumeTime()) return;
     prout("Mining operation complete.");
-    imine = 1;
-    ididit=1;
+    game.imine = 1;
+    game.ididit=1;
 }
 
 void usecrystals(void) 
 {
 }
 
 void usecrystals(void) 
 {
-    ididit=0;
+    game.ididit=0;
     skip(1);
     chew();
     skip(1);
     chew();
-    if (icrystl!=1) {
+    if (game.icrystl!=1) {
        prout("No dilithium crystals available.");
        return;
     }
        prout("No dilithium crystals available.");
        return;
     }
-    if (energy >= 1000) {
+    if (game.energy >= 1000) {
        prout("Spock-  \"Captain, Starfleet Regulations prohibit such an operation");
        prout("Spock-  \"Captain, Starfleet Regulations prohibit such an operation");
-       prout("  except when condition Yellow exists.");
+       prout("  except when game.condition Yellow exists.");
        return;
     }
     prout("Spock- \"Captain, I must warn you that loading");
        return;
     }
     prout("Spock- \"Captain, I must warn you that loading");
@@ -259,7 +259,7 @@ void usecrystals(void)
     skip(1);
     prouts("Scotty-  \"Keep your fingers crossed, Sir!\"");
     skip(1);
     skip(1);
     prouts("Scotty-  \"Keep your fingers crossed, Sir!\"");
     skip(1);
-    if (Rand() <= cryprob) {
+    if (Rand() <= game.cryprob) {
        prouts("  \"Activating now! - - No good!  It's***");
        skip(2);
        prouts("***RED ALERT!  RED A*L********************************");
        prouts("  \"Activating now! - - No good!  It's***");
        skip(2);
        prouts("***RED ALERT!  RED A*L********************************");
@@ -270,13 +270,13 @@ void usecrystals(void)
        kaboom();
        return;
     }
        kaboom();
        return;
     }
-    energy += 5000.0*(1.0 + 0.9*Rand());
+    game.energy += 5000.0*(1.0 + 0.9*Rand());
     prouts("  \"Activating now! - - ");
     prout("The instruments");
     prout("   are going crazy, but I think it's");
     prout("   going to work!!  Congratulations, Sir!\"");
     prouts("  \"Activating now! - - ");
     prout("The instruments");
     prout("   are going crazy, but I think it's");
     prout("   going to work!!  Congratulations, Sir!\"");
-    cryprob *= 2.0;
-    ididit=1;
+    game.cryprob *= 2.0;
+    game.ididit=1;
 }
 
 void shuttle(void) 
 }
 
 void shuttle(void) 
@@ -285,7 +285,7 @@ void shuttle(void)
     skip(1);
     if(game.damage[DSHUTTL] != 0.0) {
        if (game.damage[DSHUTTL] == -1.0) {
     skip(1);
     if(game.damage[DSHUTTL] != 0.0) {
        if (game.damage[DSHUTTL] == -1.0) {
-           if (inorbit && game.state.plnets[iplnet].known == shuttle_down)
+           if (game.inorbit && game.state.plnets[game.iplnet].known == shuttle_down)
                prout("Ye Faerie Queene has no shuttle craft bay to dock it at.");
            else
                prout("Ye Faerie Queene had no shuttle craft.");
                prout("Ye Faerie Queene has no shuttle craft bay to dock it at.");
            else
                prout("Ye Faerie Queene had no shuttle craft.");
@@ -295,44 +295,44 @@ void shuttle(void)
        else prout("Shuttle craft is now serving Big Macs.");
        return;
     }
        else prout("Shuttle craft is now serving Big Macs.");
        return;
     }
-    if (inorbit==0) {
+    if (game.inorbit==0) {
        crmshp();
        prout(" not in standard orbit.");
        return;
     }
        crmshp();
        prout(" not in standard orbit.");
        return;
     }
-    if ((game.state.plnets[iplnet].known != shuttle_down) && iscraft != 1) {
+    if ((game.state.plnets[game.iplnet].known != shuttle_down) && game.iscraft != 1) {
        prout("Shuttle craft not currently available.");
        return;
     }
        prout("Shuttle craft not currently available.");
        return;
     }
-    if (landed==-1 && game.state.plnets[iplnet].known==shuttle_down) {
+    if (game.landed==-1 && game.state.plnets[game.iplnet].known==shuttle_down) {
        prout("You will have to beam down to retrieve the shuttle craft.");
        return;
     }
        prout("You will have to beam down to retrieve the shuttle craft.");
        return;
     }
-    if (shldup!=0 || condit == IHDOCKED) {
+    if (game.shldup!=0 || game.condit == IHDOCKED) {
        prout("Shuttle craft cannot pass through shields.");
        return;
     }
        prout("Shuttle craft cannot pass through shields.");
        return;
     }
-    if (game.state.plnets[iplnet].known==unknown) {
+    if (game.state.plnets[game.iplnet].known==unknown) {
        prout("Spock-  \"Captain, we have no information on this planet");
        prout("  and Starfleet Regulations clearly state that in this situation");
        prout("  you may not fly down.\"");
        return;
     }
        prout("Spock-  \"Captain, we have no information on this planet");
        prout("  and Starfleet Regulations clearly state that in this situation");
        prout("  you may not fly down.\"");
        return;
     }
-    Time = 3.0e-5*game.height;
-    if (Time >= 0.8*game.state.remtime) {
+    game.optime = 3.0e-5*game.height;
+    if (game.optime >= 0.8*game.state.remtime) {
        prout("First Officer Spock-  \"Captain, I compute that such");
        proutn("  a maneuver would require approximately 2d%% of our",
        prout("First Officer Spock-  \"Captain, I compute that such");
        proutn("  a maneuver would require approximately 2d%% of our",
-              (int)(100*Time/game.state.remtime));
+              (int)(100*game.optime/game.state.remtime));
        prout("remaining time.");
        proutn("Are you sure this is wise?\" ");
        if (ja()==0) {
        prout("remaining time.");
        proutn("Are you sure this is wise?\" ");
        if (ja()==0) {
-           Time = 0.0;
+           game.optime = 0.0;
            return;
        }
     }
            return;
        }
     }
-    if (landed == 1) {
+    if (game.landed == 1) {
        /* Kirk on planet */
        /* Kirk on planet */
-       if (iscraft==1) {
+       if (game.iscraft==1) {
            /* Galileo on ship! */
            if (game.damage[DTRANSP]==0) {
                proutn("Spock-  \"Would you rather use the transporter?\" ");
            /* Galileo on ship! */
            if (game.damage[DTRANSP]==0) {
                proutn("Spock-  \"Would you rather use the transporter?\" ");
@@ -345,10 +345,10 @@ void shuttle(void)
            else
                proutn("Rescue party");
            prout(" boards Galileo and swoops toward planet surface.");
            else
                proutn("Rescue party");
            prout(" boards Galileo and swoops toward planet surface.");
-           iscraft = 0;
+           game.iscraft = 0;
            skip(1);
            if (consumeTime()) return;
            skip(1);
            if (consumeTime()) return;
-           game.state.plnets[iplnet].known=shuttle_down;
+           game.state.plnets[game.iplnet].known=shuttle_down;
            prout("Trip complete.");
            return;
        }
            prout("Trip complete.");
            return;
        }
@@ -358,18 +358,18 @@ void shuttle(void)
            prout("shuttle craft for the trip back to the Enterprise.");
            skip(1);
            prout("The short hop begins . . .");
            prout("shuttle craft for the trip back to the Enterprise.");
            skip(1);
            prout("The short hop begins . . .");
-           game.state.plnets[iplnet].known=known;
-           icraft = 1;
+           game.state.plnets[game.iplnet].known=known;
+           game.icraft = 1;
            skip(1);
            skip(1);
-           landed = -1;
+           game.landed = -1;
            if (consumeTime()) return;
            if (consumeTime()) return;
-           iscraft = 1;
-           icraft = 0;
-           if (imine!=0) {
-               icrystl = 1;
-               cryprob = 0.05;
+           game.iscraft = 1;
+           game.icraft = 0;
+           if (game.imine!=0) {
+               game.icrystl = 1;
+               game.cryprob = 0.05;
            }
            }
-           imine = 0;
+           game.imine = 0;
            prout("Trip complete.");
            return;
        }
            prout("Trip complete.");
            return;
        }
@@ -382,12 +382,12 @@ void shuttle(void)
        skip(1);
        prouts("The hangar doors open; the trip begins.");
        skip(1);
        skip(1);
        prouts("The hangar doors open; the trip begins.");
        skip(1);
-       icraft = 1;
-       iscraft = 0;
+       game.icraft = 1;
+       game.iscraft = 0;
        if (consumeTime()) return;
        if (consumeTime()) return;
-       game.state.plnets[iplnet].known = shuttle_down;
-       landed = 1;
-       icraft = 0;
+       game.state.plnets[game.iplnet].known = shuttle_down;
+       game.landed = 1;
+       game.icraft = 0;
        prout("Trip complete");
        return;
     }
        prout("Trip complete");
        return;
     }
@@ -397,14 +397,14 @@ void deathray(void)
 {
     double dprob, r = Rand();
        
 {
     double dprob, r = Rand();
        
-    ididit = 0;
+    game.ididit = 0;
     skip(1);
     chew();
     skip(1);
     chew();
-    if (ship != IHE) {
+    if (game.ship != IHE) {
        prout("Ye Faerie Queene has no death ray.");
        return;
     }
        prout("Ye Faerie Queene has no death ray.");
        return;
     }
-    if (nenhere==0) {
+    if (game.nenhere==0) {
        prout("Sulu-  \"But Sir, there are no enemies in this quadrant.\"");
        return;
     }
        prout("Sulu-  \"But Sir, there are no enemies in this quadrant.\"");
        return;
     }
@@ -418,7 +418,7 @@ void deathray(void)
     if (ja()==0) return;
     prout("Spock-  \"Acknowledged.\"");
     skip(1);
     if (ja()==0) return;
     prout("Spock-  \"Acknowledged.\"");
     skip(1);
-    ididit=1;
+    game.ididit=1;
     prouts("WHOOEE ... WHOOEE ... WHOOEE ... WHOOEE");
     skip(1);
     prout("Crew scrambles in emergency preparation.");
     prouts("WHOOEE ... WHOOEE ... WHOOEE ... WHOOEE");
     skip(1);
     prout("Crew scrambles in emergency preparation.");
@@ -436,7 +436,7 @@ void deathray(void)
     if (r > dprob) {
        prouts("Sulu- \"Captain!  It's working!\"");
        skip(2);
     if (r > dprob) {
        prouts("Sulu- \"Captain!  It's working!\"");
        skip(2);
-       while (nenhere > 0)
+       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]);
        prout("Ensign Chekov-  \"Congratulations, Captain!\"");
        if (KLINGREM == 0) finish(FWON);
            deadkl(game.kx[1],game.ky[1],game.quad[game.kx[1]][game.ky[1]],game.kx[1],game.ky[1]);
        prout("Ensign Chekov-  \"Congratulations, Captain!\"");
        if (KLINGREM == 0) finish(FWON);
index f0dc134eb88d29d975e7cb753952030d2882ef97..665701e0abaa0d85a6b24f3487a9df9bc74bedd7 100644 (file)
@@ -8,11 +8,11 @@ void attakreport(int curt)
     if (!curt) {
        if (game.future[FCDBAS] < FOREVER) {
            prout("Starbase in %s is currently under Commander attack.",
     if (!curt) {
        if (game.future[FCDBAS] < FOREVER) {
            prout("Starbase in %s is currently under Commander attack.",
-                 cramlc(quadrant, batx, baty));
+                 cramlc(quadrant, game.batx, game.baty));
            prout("It can hold out until Stardate %d.", 
                  (int)game.future[FCDBAS]);
        }
            prout("It can hold out until Stardate %d.", 
                  (int)game.future[FCDBAS]);
        }
-       if (isatb == 1) {
+       if (game.isatb == 1) {
            prout("Starbase in %s is under Super-commander attack.",
                  cramlc(quadrant, game.state.isx, game.state.isy));
            prout("It can hold out until Stardate %d.", 
            prout("Starbase in %s is under Super-commander attack.",
                  cramlc(quadrant, game.state.isx, game.state.isy));
            prout("It can hold out until Stardate %d.", 
@@ -20,8 +20,8 @@ void attakreport(int curt)
        }
     } else {
         if (game.future[FCDBAS] < FOREVER)
        }
     } else {
         if (game.future[FCDBAS] < FOREVER)
-           proutn("Base in %i - %i attacked by C. Alive until %.1f", batx, baty, game.future[FCDBAS]);
-        if (isatb == 1)
+           proutn("Base in %i - %i attacked by C. Alive until %.1f", game.batx, game.baty, game.future[FCDBAS]);
+        if (game.isatb == 1)
            proutn("Base in %i - %i attacked by S. Alive until %.1f", game.state.isx, game.state.isy, game.future[FSCDBAS]);
     }
     clreol();
            proutn("Base in %i - %i attacked by S. Alive until %.1f", game.state.isx, game.state.isy, game.future[FSCDBAS]);
     }
     clreol();
@@ -33,14 +33,14 @@ void report(void)
     char *s1,*s2,*s3;
 
     chew();
     char *s1,*s2,*s3;
 
     chew();
-    s1 = (thawed?"thawed ":"");
-    switch (length) {
+    s1 = (game.thawed?"game.thawed ":"");
+    switch (game.length) {
     case 1: s2="short"; break;
     case 2: s2="medium"; break;
     case 4: s2="long"; break;
     default: s2="unknown length"; break;
     }
     case 1: s2="short"; break;
     case 2: s2="medium"; break;
     case 4: s2="long"; break;
     default: s2="unknown length"; break;
     }
-    switch (skill) {
+    switch (game.skill) {
     case SKILL_NOVICE: s3="novice"; break;
     case SKILL_FAIR: s3="fair"; break;
     case SKILL_GOOD: s3="good"; break;
     case SKILL_NOVICE: s3="novice"; break;
     case SKILL_FAIR: s3="fair"; break;
     case SKILL_GOOD: s3="good"; break;
@@ -50,59 +50,59 @@ void report(void)
     }
     prout("");
     prout("You %s playing a %s%s %s game.",
     }
     prout("");
     prout("You %s playing a %s%s %s game.",
-         alldone? "were": "are now", s1, s2, s3);
-    if (skill>SKILL_GOOD && thawed && !alldone) prout("No plaque is allowed.");
-    if (tourn) prout("This is tournament game %d.", tourn);
+         game.alldone? "were": "are now", s1, s2, s3);
+    if (game.skill>SKILL_GOOD && game.thawed && !game.alldone) prout("No plaque is allowed.");
+    if (game.tourn) prout("This is tournament game %d.", game.tourn);
     prout("Your secret password is \"%s\"",game.passwd);
     proutn("%d of %d Klingons have been killed", KLINGKILLED, INKLINGTOT);
     if (NKILLC) prout(", including %d Commander%s.", NKILLC, NKILLC==1?"":"s");
     else if (NKILLK + NKILLSC > 0) prout(", but no Commanders.");
     else prout(".");
     prout("Your secret password is \"%s\"",game.passwd);
     proutn("%d of %d Klingons have been killed", KLINGKILLED, INKLINGTOT);
     if (NKILLC) prout(", including %d Commander%s.", NKILLC, NKILLC==1?"":"s");
     else if (NKILLK + NKILLSC > 0) prout(", but no Commanders.");
     else prout(".");
-    if (skill > SKILL_FAIR) prout("The Super Commander has %sbeen destroyed.",
+    if (game.skill > SKILL_FAIR) prout("The Super Commander has %sbeen destroyed.",
                                  game.state.nscrem?"not ":"");
                                  game.state.nscrem?"not ":"");
-    if (game.state.rembase != inbase) {
+    if (game.state.rembase != game.inbase) {
        proutn("There ");
        proutn("There ");
-       if (inbase-game.state.rembase==1) proutn("has been 1 base");
+       if (game.inbase-game.state.rembase==1) proutn("has been 1 base");
        else {
        else {
-           proutn("have been %d bases", inbase-game.state.rembase);
+           proutn("have been %d bases", game.inbase-game.state.rembase);
        }
        prout(" destroyed, %d remaining.", game.state.rembase);
     }
        }
        prout(" destroyed, %d remaining.", game.state.rembase);
     }
-    else prout("There are %d bases.", inbase);
-    if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED || iseenit) {
+    else prout("There are %d bases.", game.inbase);
+    if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED || game.iseenit) {
        /* Don't report this if not seen and
           either the radio is dead or not at base! */
        attakreport(0);
        /* Don't report this if not seen and
           either the radio is dead or not at base! */
        attakreport(0);
-       iseenit = 1;
+       game.iseenit = 1;
     }
     }
-    if (casual) prout("%d casualt%s suffered so far.",
-                     casual, casual==1? "y" : "ies");
-    if (nhelp) prout("There were %d call%s for help.",
-                    nhelp, nhelp==1 ? "" : "s");
-    if (ship == IHE) {
+    if (game.casual) prout("%d casualt%s suffered so far.",
+                     game.casual, game.casual==1? "y" : "ies");
+    if (game.nhelp) prout("There were %d call%s for help.",
+                    game.nhelp, game.nhelp==1 ? "" : "s");
+    if (game.ship == IHE) {
        proutn("You have ");
        proutn("You have ");
-       if (nprobes) proutn("%d", nprobes);
+       if (game.nprobes) proutn("%d", game.nprobes);
        else proutn("no");
        proutn(" deep space probe");
        else proutn("no");
        proutn(" deep space probe");
-       if (nprobes!=1) proutn("s");
+       if (game.nprobes!=1) proutn("s");
        prout(".");
     }
        prout(".");
     }
-    if ((game.damage[DRADIO] == 0.0 || condit == IHDOCKED)&&
+    if ((game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED)&&
        game.future[FDSPROB] != FOREVER) {
        game.future[FDSPROB] != FOREVER) {
-       if (isarmed) 
+       if (game.isarmed) 
            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, probecx, probecy));
+       proutn(cramlc(quadrant, game.probecx, game.probecy));
        prout(".");
     }
        prout(".");
     }
-    if (icrystl) {
-       if (cryprob <= .05)
+    if (game.icrystl) {
+       if (game.cryprob <= .05)
            prout("Dilithium crystals aboard ship... not yet used.");
        else {
            int i=0;
            double ai = 0.05;
            prout("Dilithium crystals aboard ship... not yet used.");
        else {
            int i=0;
            double ai = 0.05;
-           while (cryprob > ai) {
+           while (game.cryprob > ai) {
                ai *= 2.0;
                i++;
            }
                ai *= 2.0;
                i++;
            }
@@ -119,7 +119,7 @@ void lrscan(void)
     chew();
     if (game.damage[DLRSENS] != 0.0) {
        /* Now allow base's sensors if docked */
     chew();
     if (game.damage[DLRSENS] != 0.0) {
        /* Now allow base's sensors if docked */
-       if (condit != IHDOCKED) {
+       if (game.condit != IHDOCKED) {
            prout("LONG-RANGE SENSORS DAMAGED.");
            return;
        }
            prout("LONG-RANGE SENSORS DAMAGED.");
            return;
        }
@@ -128,9 +128,9 @@ void lrscan(void)
     else {
        prout("Long-range scan");
     }
     else {
        prout("Long-range scan");
     }
-    for (x = quadx-1; x <= quadx+1; x++) {
+    for (x = game.quadx-1; x <= game.quadx+1; x++) {
        proutn(" ");
        proutn(" ");
-       for (y = quady-1; y <= quady+1; y++) {
+       for (y = game.quady-1; y <= game.quady+1; y++) {
            if (!VALID_QUADRANT(x, y))
                proutn("  -1");
            else {
            if (!VALID_QUADRANT(x, y))
                proutn("  -1");
            else {
@@ -164,7 +164,7 @@ void dreprt(void)
            prout("  %16s %8.2f  %8.2f", 
                  device[i],
                  game.damage[i]+0.05,
            prout("  %16s %8.2f  %8.2f", 
                  device[i],
                  game.damage[i]+0.05,
-                 docfac*game.damage[i]+0.005);
+                 game.docfac*game.damage[i]+0.005);
        }
     }
     if (!jdam) prout("All devices functional.");
        }
     }
     if (!jdam) prout("All devices functional.");
@@ -174,7 +174,7 @@ void rechart(void)
 /* update the chart in the Enterprise's computer from galaxy data */
 {
     int i, j;
 /* update the chart in the Enterprise's computer from galaxy data */
 {
     int i, j;
-    lastchart = game.state.date;
+    game.lastchart = game.state.date;
     for_quadrants(i)
        for_quadrants(j) 
            if (game.state.galaxy[i][j].charted) {
     for_quadrants(i)
        for_quadrants(j) 
            if (game.state.galaxy[i][j].charted) {
@@ -192,21 +192,21 @@ void chart(int nn)
     if (game.damage[DRADIO] == 0.0)
        rechart();
 
     if (game.damage[DRADIO] == 0.0)
        rechart();
 
-    if (lastchart < game.state.date && condit == IHDOCKED) {
+    if (game.lastchart < game.state.date && game.condit == IHDOCKED) {
        prout("Spock-  \"I revised the Star Chart from the starbase's records.\"");
        rechart();
     }
 
     if (nn == 0) prout("       STAR CHART FOR THE KNOWN GALAXY");
        prout("Spock-  \"I revised the Star Chart from the starbase's records.\"");
        rechart();
     }
 
     if (nn == 0) prout("       STAR CHART FOR THE KNOWN GALAXY");
-    if (game.state.date > lastchart)
+    if (game.state.date > game.lastchart)
        prout("(Last surveillance update %d stardates ago).",
        prout("(Last surveillance update %d stardates ago).",
-             (int)(game.state.date-lastchart));
+             (int)(game.state.date-game.lastchart));
     prout("      1    2    3    4    5    6    7    8");
     for_quadrants(i) {
        proutn("%d |", i);
        for_quadrants(j) {
            char buf[4];
     prout("      1    2    3    4    5    6    7    8");
     for_quadrants(i) {
        proutn("%d |", i);
        for_quadrants(j) {
            char buf[4];
-           if ((game.options & OPTION_SHOWME) && i == quadx && j == quady)
+           if ((game.options & OPTION_SHOWME) && i == game.quadx && j == game.quady)
                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 == quadx && j == quady)
+           if ((game.options & OPTION_SHOWME) && i == game.quadx && j == game.quady)
                proutn(">");
            else
                proutn(" ");
                proutn(">");
            else
                proutn(" ");
@@ -231,16 +231,16 @@ 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-sectx)<= 1 && abs(j-secty) <= 1)){
+    if (goodScan || (abs(i-game.sectx)<= 1 && abs(j-game.secty) <= 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)){
        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 (condit) {
+           switch (game.condit) {
            case IHRED: textcolor(RED); break;
            case IHGREEN: textcolor(GREEN); break;
            case IHYELLOW: textcolor(YELLOW); break;
            case IHDOCKED: textcolor(CYAN); break;
            case IHDEAD: textcolor(BROWN);
            }
            case IHRED: textcolor(RED); break;
            case IHGREEN: textcolor(GREEN); break;
            case IHYELLOW: textcolor(YELLOW); break;
            case IHDOCKED: textcolor(CYAN); break;
            case IHDEAD: textcolor(BROWN);
            }
-           if (game.quad[i][j] != ship) 
+           if (game.quad[i][j] != game.ship) 
                highvideo();
        }
        proutn("%c ",game.quad[i][j]);
                highvideo();
        }
        proutn("%c ",game.quad[i][j]);
@@ -259,8 +259,8 @@ static void status(int req)
        proutn("Stardate      %.1f, Time Left %.2f", game.state.date, game.state.remtime);
        break;
     case 2:
        proutn("Stardate      %.1f, Time Left %.2f", game.state.date, game.state.remtime);
        break;
     case 2:
-       if (condit != IHDOCKED) newcnd();
-       switch (condit) {
+       if (game.condit != IHDOCKED) newcnd();
+       switch (game.condit) {
        case IHRED: cp = "RED"; break;
        case IHGREEN: cp = "GREEN"; break;
        case IHYELLOW: cp = "YELLOW"; break;
        case IHRED: cp = "RED"; break;
        case IHGREEN: cp = "GREEN"; break;
        case IHYELLOW: cp = "YELLOW"; break;
@@ -274,40 +274,40 @@ static void status(int req)
        break;
     case 3:
        proutn("Position      %d - %d , %d - %d",
        break;
     case 3:
        proutn("Position      %d - %d , %d - %d",
-              quadx, quady, sectx, secty);
+              game.quadx, game.quady, game.sectx, game.secty);
        break;
     case 4:
        proutn("Life Support  ");
        if (game.damage[DLIFSUP] != 0.0) {
        break;
     case 4:
        proutn("Life Support  ");
        if (game.damage[DLIFSUP] != 0.0) {
-           if (condit == IHDOCKED)
+           if (game.condit == IHDOCKED)
                proutn("DAMAGED, Base provides");
            else
                proutn("DAMAGED, Base provides");
            else
-               proutn("DAMAGED, reserves=%4.2f", lsupres);
+               proutn("DAMAGED, reserves=%4.2f", game.lsupres);
        }
        else
            proutn("ACTIVE");
        break;
     case 5:
        }
        else
            proutn("ACTIVE");
        break;
     case 5:
-       proutn("Warp Factor   %.1f", warpfac);
+       proutn("Warp Factor   %.1f", game.warpfac);
        break;
     case 6:
        break;
     case 6:
-       proutn("Energy        %.2f", energy);
-       if (icrystl && (game.options & OPTION_SHOWME))  /* ESR */
+       proutn("Energy        %.2f", game.energy);
+       if (game.icrystl && (game.options & OPTION_SHOWME))     /* ESR */
            proutn(" (have crystals)");
        break;
     case 7:
            proutn(" (have crystals)");
        break;
     case 7:
-       proutn("Torpedoes     %d", torps);
+       proutn("Torpedoes     %d", game.torps);
        break;
     case 8:
        proutn("Shields       ");
        if (game.damage[DSHIELD] != 0)
            proutn("DAMAGED,");
        break;
     case 8:
        proutn("Shields       ");
        if (game.damage[DSHIELD] != 0)
            proutn("DAMAGED,");
-       else if (shldup)
+       else if (game.shldup)
            proutn("UP,");
        else
            proutn("DOWN,");
        proutn(" %d%% %.1f units",
            proutn("UP,");
        else
            proutn("DOWN,");
        proutn(" %d%% %.1f units",
-              (int)((100.0*shield)/inshld + 0.5), shield);
+              (int)((100.0*game.shield)/game.inshld + 0.5), game.shield);
        break;
     case 9:
        proutn("Klingons Left %d", KLINGREM);
        break;
     case 9:
        proutn("Klingons Left %d", KLINGREM);
@@ -328,7 +328,7 @@ int srscan(int l)
     case SCAN_FULL: // SRSCAN
        if (game.damage[DSRSENS] != 0) {
            /* Allow base's sensors if docked */
     case SCAN_FULL: // SRSCAN
        if (game.damage[DSRSENS] != 0) {
            /* Allow base's sensors if docked */
-           if (condit != IHDOCKED) {
+           if (game.condit != IHDOCKED) {
                prout("   S.R. SENSORS DAMAGED!");
                goodScan=FALSE;
            }
                prout("   S.R. SENSORS DAMAGED!");
                goodScan=FALSE;
            }
@@ -337,10 +337,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[quadx][quady].klingons = game.state.galaxy[quadx][quady].klingons;
-           game.state.chart[quadx][quady].starbase = game.state.galaxy[quadx][quady].starbase;
-           game.state.chart[quadx][quady].stars = game.state.galaxy[quadx][quady].stars;
-           game.state.galaxy[quadx][quady].charted = TRUE;
+           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;
        }
        scan();
        if (isit("chart")) nn = TRUE;
        }
        scan();
        if (isit("chart")) nn = TRUE;
@@ -357,7 +357,7 @@ int srscan(int l)
                break;
        if (req > sizeof(requests)/sizeof(requests[0])) {
            prout("UNRECOGNIZED REQUEST. Legal requests are:");
                break;
        if (req > sizeof(requests)/sizeof(requests[0])) {
            prout("UNRECOGNIZED REQUEST. Legal requests are:");
-           prout("  date, condition, position, lsupport, warpfactor,");
+           prout("  date, game.condition, position, lsupport, game.warpfactor,");
            prout("  energy, torpedoes, shields, klingons, time, bases.");
            return FALSE;
        }
            prout("  energy, torpedoes, shields, klingons, time, bases.");
            return FALSE;
        }
@@ -371,7 +371,7 @@ int srscan(int l)
        leftside=FALSE;
        break;
     }
        leftside=FALSE;
        break;
     }
-    if (condit != IHDOCKED) newcnd();
+    if (game.condit != IHDOCKED) newcnd();
     for (i = 1; i <= max(QUADSIZE, sizeof(requests)/sizeof(requests[0])); i++) {
        jj = (req!=0 ? req : i);
        if (leftside && i <= QUADSIZE) {
     for (i = 1; i <= max(QUADSIZE, sizeof(requests)/sizeof(requests[0])); i++) {
        jj = (req!=0 ? req : i);
        if (leftside && i <= QUADSIZE) {
@@ -425,9 +425,9 @@ void eta(void)
        ix2 = aaitem + 0.5;
     }
     else {
        ix2 = aaitem + 0.5;
     }
     else {
-       if (quady>ix1) ix2 = 1;
+       if (game.quady>ix1) ix2 = 1;
        else ix2=QUADSIZE;
        else ix2=QUADSIZE;
-       if (quadx>iy1) iy2 = 1;
+       if (game.quadx>iy1) iy2 = 1;
        else iy2=QUADSIZE;
     }
 
        else iy2=QUADSIZE;
     }
 
@@ -435,8 +435,8 @@ void eta(void)
        huh();
        return;
     }
        huh();
        return;
     }
-    dist = sqrt(square(iy1-quadx+0.1*(iy2-sectx))+
-               square(ix1-quady+0.1*(ix2-secty)));
+    game.dist = sqrt(square(iy1-game.quadx+0.1*(iy2-game.sectx))+
+               square(ix1-game.quady+0.1*(ix2-game.secty)));
     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:");
@@ -447,7 +447,7 @@ void eta(void)
            ttime = aaitem;
            if (ttime > game.state.date) ttime -= game.state.date; // Actually a star date
            if (ttime <= 1e-10 ||
            ttime = aaitem;
            if (ttime > game.state.date) ttime -= game.state.date; // Actually a star date
            if (ttime <= 1e-10 ||
-               (twarp=(floor(sqrt((10.0*dist)/ttime)*10.0)+1.0)/10.0) > 10) {
+               (twarp=(floor(sqrt((10.0*game.dist)/ttime)*10.0)+1.0)/10.0) > 10) {
                prout("We'll never make it, sir.");
                chew();
                return;
                prout("We'll never make it, sir.");
                chew();
                return;
@@ -470,11 +470,11 @@ void eta(void)
     }
     while (TRUE) {
        chew();
     }
     while (TRUE) {
        chew();
-       ttime = (10.0*dist)/square(twarp);
-       tpower = dist*twarp*twarp*twarp*(shldup+1);
-       if (tpower >= energy) {
+       ttime = (10.0*game.dist)/square(twarp);
+       tpower = game.dist*twarp*twarp*twarp*(game.shldup+1);
+       if (tpower >= game.energy) {
            prout("Insufficient energy, sir.");
            prout("Insufficient energy, sir.");
-           if (shldup==0 || tpower > energy*2.0) {
+           if (game.shldup==0 || tpower > game.energy*2.0) {
                if (!wfl) return;
                proutn("New warp factor to try? ");
                if (scan() == IHREAL) {
                if (!wfl) return;
                proutn("New warp factor to try? ");
                if (scan() == IHREAL) {
@@ -498,7 +498,7 @@ void eta(void)
        }
        else
            proutn("Remaining");
        }
        else
            proutn("Remaining");
-       prout(" energy will be %.2f.", energy-tpower);
+       prout(" game.energy will be %.2f.", game.energy-tpower);
        if (wfl) {
            prout("And we will arrive at stardate %.2f.",
                  game.state.date+ttime);
        if (wfl) {
            prout("And we will arrive at stardate %.2f.",
                  game.state.date+ttime);
@@ -514,9 +514,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 ((isatb==1 && game.state.isy == ix1 && game.state.isx == iy1 &&
+       if ((game.isatb==1 && game.state.isy == ix1 && game.state.isx == iy1 &&
             game.future[FSCDBAS]< ttime+game.state.date)||
             game.future[FSCDBAS]< ttime+game.state.date)||
-           (game.future[FCDBAS]<ttime+game.state.date && baty==ix1 && batx == iy1))
+           (game.future[FCDBAS]<ttime+game.state.date && game.baty==ix1 && game.batx == iy1))
            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 04a02477f234e0ebf479e2c524203df5678e3390..88211ad52994ae205358d532cebf709e1a980800 100644 (file)
@@ -97,8 +97,8 @@ void abandn(void)
     int nb, l;
 
     chew();
     int nb, l;
 
     chew();
-    if (condit==IHDOCKED) {
-       if (ship!=IHE) {
+    if (game.condit==IHDOCKED) {
+       if (game.ship!=IHE) {
            prout("You cannot abandon Ye Faerie Queene.");
            return;
        }
            prout("You cannot abandon Ye Faerie Queene.");
            return;
        }
@@ -117,11 +117,11 @@ void abandn(void)
            prout("Shuttle craft damaged.");
            return;
        }
            prout("Shuttle craft damaged.");
            return;
        }
-       if (landed==1) {
+       if (game.landed==1) {
            prout("You must be aboard the Enterprise.");
            return;
        }
            prout("You must be aboard the Enterprise.");
            return;
        }
-       if (iscraft!=1) {
+       if (game.iscraft!=1) {
            prout("Shuttle craft not currently available.");
            return;
        }
            prout("Shuttle craft not currently available.");
            return;
        }
@@ -141,53 +141,53 @@ void abandn(void)
        }
        /* If at least one base left, give 'em the Faerie Queene */
        skip(1);
        }
        /* If at least one base left, give 'em the Faerie Queene */
        skip(1);
-       icrystl = 0; /* crystals are lost */
-       nprobes = 0; /* No probes */
+       game.icrystl = 0; /* crystals are lost */
+       game.nprobes = 0; /* No probes */
        prout("You are captured by Klingons and released to");
        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("You are captured by Klingons and released to");
        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 (quadx!=game.state.baseqx[nb] || quady!=game.state.baseqy[nb]) {
-           quadx = game.state.baseqx[nb];
-           quady = game.state.baseqy[nb];
-           sectx = secty = 5;
+       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;
            newqad(1);
        }
        for (;;) {
            /* position next to base by trial and error */
            newqad(1);
        }
        for (;;) {
            /* position next to base by trial and error */
-           game.quad[sectx][secty] = IHDOT;
+           game.quad[game.sectx][game.secty] = IHDOT;
            for_sectors(l) {
            for_sectors(l) {
-               sectx = 3.0*Rand() - 1.0 + basex;
-               secty = 3.0*Rand() - 1.0 + basey;
-               if (VALID_SECTOR(sectx, secty) &&
-                   game.quad[sectx][secty] == IHDOT) break;
+               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;
            }
            if (l < QUADSIZE+1) break; /* found a spot */
            }
            if (l < QUADSIZE+1) break; /* found a spot */
-           sectx=QUADSIZE/2;
-           secty=QUADSIZE/2;
+           game.sectx=QUADSIZE/2;
+           game.secty=QUADSIZE/2;
            newqad(1);
        }
     }
     /* Get new commission */
            newqad(1);
        }
     }
     /* Get new commission */
-    game.quad[sectx][secty] = ship = IHF;
+    game.quad[game.sectx][game.secty] = 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.");
-    if (icrystl!=0) prout("The dilithium crystals have been moved.");
-    imine=0;
-    iscraft=0; /* Gallileo disappears */
+    if (game.icrystl!=0) prout("The dilithium crystals have been moved.");
+    game.imine=0;
+    game.iscraft=0; /* Gallileo disappears */
     /* Resupply ship */
     /* Resupply ship */
-    condit=IHDOCKED;
+    game.condit=IHDOCKED;
     for (l = 0; l < NDEVICES; l++) 
        game.damage[l] = 0.0;
     game.damage[DSHUTTL] = -1;
     for (l = 0; l < NDEVICES; l++) 
        game.damage[l] = 0.0;
     game.damage[DSHUTTL] = -1;
-    energy = inenrg = 3000.0;
-    shield = inshld = 1250.0;
-    torps = intorps = 6;
-    lsupres=inlsr=3.0;
-    shldup=0;
-    warpfac=5.0;
-    wfacsq=25.0;
+    game.energy = game.inenrg = 3000.0;
+    game.shield = game.inshld = 1250.0;
+    game.torps = game.intorps = 6;
+    game.lsupres=game.inlsr=3.0;
+    game.shldup=0;
+    game.warpfac=5.0;
+    game.wfacsq=25.0;
     return;
 }
        
     return;
 }
        
@@ -196,36 +196,36 @@ void setup(int needprompt)
     int i,j, krem, klumper;
     int ix, iy;
 #ifdef DEBUG
     int i,j, krem, klumper;
     int ix, iy;
 #ifdef DEBUG
-    idebug = 0;
+    game.idebug = 0;
 #endif
     //  Decide how many of everything
     if (choose(needprompt)) return; // frozen game
     // Prepare the Enterprise
 #endif
     //  Decide how many of everything
     if (choose(needprompt)) return; // frozen game
     // Prepare the Enterprise
-    alldone = gamewon = 0;
-    ship = IHE;
-    energy = inenrg = 5000.0;
-    shield = inshld = 2500.0;
-    shldchg = shldup = 0;
-    inlsr = 4.0;
-    lsupres = 4.0;
-    iran(GALSIZE, &quadx, &quady);
-    iran(QUADSIZE, &sectx, &secty);
-    torps = intorps = 10;
-    nprobes = (int)(3.0*Rand() + 2.0); /* Give them 2-4 of these wonders */
-    warpfac = 5.0;
-    wfacsq = warpfac * warpfac;
+    game.alldone = game.gamewon = 0;
+    game.ship = IHE;
+    game.energy = game.inenrg = 5000.0;
+    game.shield = game.inshld = 2500.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);
+    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.wfacsq = game.warpfac * game.warpfac;
     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
-    batx = baty = 0;
-    game.state.date = indate = 100.0*(int)(31.0*Rand()+20.0);
-    nkinks = nhelp = resting = casual = 0;
-    isatb = iscate = imine = icrystl = icraft = game.state.nplankl = 0;
+    game.batx = game.baty = 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.starkl = game.state.basekl = 0;
     game.state.starkl = game.state.basekl = 0;
-    iscraft = 1;
-    landed = -1;
-    alive = 1;
-    docfac = 0.25;
+    game.iscraft = 1;
+    game.landed = -1;
+    game.alive = 1;
+    game.docfac = 0.25;
     for_quadrants(i)
        for_quadrants(j) {
            game.state.galaxy[i][j].charted = 0;
     for_quadrants(i)
        for_quadrants(j) {
            game.state.galaxy[i][j].charted = 0;
@@ -236,26 +236,26 @@ void setup(int needprompt)
            game.state.galaxy[i][j].supernova = 0;
        }
     // Initialize times for extraneous events
            game.state.galaxy[i][j].supernova = 0;
        }
     // Initialize times for extraneous events
-    game.future[FSNOVA] = game.state.date + expran(0.5 * intime);
-    game.future[FTBEAM] = game.state.date + expran(1.5 * (intime / game.state.remcom));
+    game.future[FSNOVA] = game.state.date + expran(0.5 * game.intime);
+    game.future[FTBEAM] = game.state.date + expran(1.5 * (game.intime / game.state.remcom));
     game.future[FSNAP] = game.state.date + 1.0 + Rand(); // Force an early snapshot
     game.future[FSNAP] = game.state.date + 1.0 + Rand(); // Force an early snapshot
-    game.future[FBATTAK] = game.state.date + expran(0.3*intime);
+    game.future[FBATTAK] = game.state.date + expran(0.3*game.intime);
     game.future[FCDBAS] = FOREVER;
     game.future[FSCMOVE] = game.state.nscrem ? game.state.date+0.2777 : FOREVER;
     game.future[FSCDBAS] = FOREVER;
     game.future[FDSPROB] = FOREVER;
     // Starchart is functional but we've never seen it
     game.future[FCDBAS] = FOREVER;
     game.future[FSCMOVE] = game.state.nscrem ? game.state.date+0.2777 : FOREVER;
     game.future[FSCDBAS] = FOREVER;
     game.future[FDSPROB] = FOREVER;
     // Starchart is functional but we've never seen it
-    lastchart = FOREVER;
+    game.lastchart = FOREVER;
     // Put stars in the galaxy
     // Put stars in the galaxy
-    instar = 0;
+    game.instar = 0;
     for_quadrants(i)
        for_quadrants(j) {
            int k = Rand()*9.0 + 1.0;
     for_quadrants(i)
        for_quadrants(j) {
            int k = Rand()*9.0 + 1.0;
-           instar += k;
+           game.instar += k;
            game.state.galaxy[i][j].stars = k;
        }
     // Locate star bases in galaxy
            game.state.galaxy[i][j].stars = k;
        }
     // Locate star bases in galaxy
-    for (i = 1; i <= inbase; i++) {
+    for (i = 1; i <= game.inbase; i++) {
        int contflag;
        do {
            do iran(GALSIZE, &ix, &iy);
        int contflag;
        do {
            do iran(GALSIZE, &ix, &iy);
@@ -264,7 +264,7 @@ void setup(int needprompt)
            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]);
            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]);
-               if (distq < 6.0*(BASEMAX+1-inbase) && Rand() < 0.75) {
+               if (distq < 6.0*(BASEMAX+1-game.inbase) && Rand() < 0.75) {
                    contflag = TRUE;
 #ifdef DEBUG
                    prout("DEBUG: Abandoning base #%d at %d-%d", i, ix, iy);
                    contflag = TRUE;
 #ifdef DEBUG
                    prout("DEBUG: Abandoning base #%d at %d-%d", i, ix, iy);
@@ -272,7 +272,7 @@ void setup(int needprompt)
                    break;
                }
 #ifdef DEBUG
                    break;
                }
 #ifdef DEBUG
-               else if (distq < 6.0 * (BASEMAX+1-inbase)) {
+               else if (distq < 6.0 * (BASEMAX+1-game.inbase)) {
                    prout("DEBUG: saving base #%d, close to #%d", i, j);
                }
 #endif
                    prout("DEBUG: saving base #%d, close to #%d", i, j);
                }
 #endif
@@ -285,8 +285,8 @@ void setup(int needprompt)
        game.state.chart[ix][iy].starbase = 1;
     }
     // Position ordinary Klingon Battle Cruisers
        game.state.chart[ix][iy].starbase = 1;
     }
     // Position ordinary Klingon Battle Cruisers
-    krem = inkling;
-    klumper = 0.25*skill*(9.0-length)+1.0;
+    krem = game.inkling;
+    klumper = 0.25*game.skill*(9.0-game.length)+1.0;
     if (klumper > 9) klumper = 9; // Can't have more than 9 in quadrant
     do {
        double r = Rand();
     if (klumper > 9) klumper = 9; // Can't have more than 9 in quadrant
     do {
        double r = Rand();
@@ -302,11 +302,11 @@ void setup(int needprompt)
 #ifdef DEBUG
     klumper = 1;
 #endif
 #ifdef DEBUG
     klumper = 1;
 #endif
-    for (i = 1; i <= incom; i++) {
+    for (i = 1; i <= game.incom; i++) {
        do {
            do { /* IF debugging, put commanders by bases, always! */
 #ifdef DEBUG
        do {
            do { /* IF debugging, put commanders by bases, always! */
 #ifdef DEBUG
-               if (idebug && klumper <= inbase) {
+               if (game.idebug && klumper <= game.inbase) {
                    ix = game.state.baseqx[klumper];
                    iy = game.state.baseqy[klumper];
                    klumper++;
                    ix = game.state.baseqx[klumper];
                    iy = game.state.baseqy[klumper];
                    klumper++;
@@ -327,7 +327,7 @@ void setup(int needprompt)
        game.state.cy[i] = iy;
     }
     // Locate planets in galaxy
        game.state.cy[i] = iy;
     }
     // Locate planets in galaxy
-    for (i = 0; i < inplan; i++) {
+    for (i = 0; i < game.inplan; i++) {
        do iran(GALSIZE, &ix, &iy); while (game.state.galaxy[ix][iy].planets);
        game.state.galaxy[ix][iy].planets = 1;
        game.state.plnets[i].x = ix;
        do iran(GALSIZE, &ix, &iy); while (game.state.galaxy[ix][iy].planets);
        game.state.galaxy[ix][iy].planets = 1;
        game.state.plnets[i].x = ix;
@@ -361,17 +361,17 @@ void setup(int needprompt)
     skip(2);
     game.state.snap = 0;
                
     skip(2);
     game.state.snap = 0;
                
-    if (skill == SKILL_NOVICE) {
+    if (game.skill == SKILL_NOVICE) {
        prout("It is stardate %d. The Federation is being attacked by",
              (int)game.state.date);
        prout("a deadly Klingon invasion force. As captain of the United");
        prout("Starship U.S.S. Enterprise, it is your mission to seek out");
        prout("and destroy this invasion force of %d battle cruisers.",
              INKLINGTOT);
        prout("It is stardate %d. The Federation is being attacked by",
              (int)game.state.date);
        prout("a deadly Klingon invasion force. As captain of the United");
        prout("Starship U.S.S. Enterprise, it is your mission to seek out");
        prout("and destroy this invasion force of %d battle cruisers.",
              INKLINGTOT);
-       prout("You have an initial allotment of %d stardates to complete", (int)intime);
+       prout("You have an initial allotment of %d stardates to complete", (int)game.intime);
        prout("your mission.  As you proceed you may be given more time.");
        prout("");
        prout("your mission.  As you proceed you may be given more time.");
        prout("");
-       prout("You will have %d supporting starbases.", inbase);
+       prout("You will have %d supporting starbases.", game.inbase);
        proutn("Starbase locations-  ");
     }
     else {
        proutn("Starbase locations-  ");
     }
     else {
@@ -380,34 +380,34 @@ void setup(int needprompt)
        prout("%d Klingons.", INKLINGTOT);
        prout("An unknown number of Romulans.");
        if (game.state.nscrem) prout("and one (GULP) Super-Commander.");
        prout("%d Klingons.", INKLINGTOT);
        prout("An unknown number of Romulans.");
        if (game.state.nscrem) prout("and one (GULP) Super-Commander.");
-       prout("%d stardates.",(int)intime);
-       proutn("%d starbases in ", inbase);
+       prout("%d stardates.",(int)game.intime);
+       proutn("%d starbases in ", game.inbase);
     }
     }
-    for (i = 1; i <= inbase; i++) {
+    for (i = 1; i <= game.inbase; i++) {
        proutn(cramlc(0, game.state.baseqx[i], game.state.baseqy[i]));
        proutn("  ");
     }
     skip(2);
     proutn("The Enterprise is currently in ");
        proutn(cramlc(0, game.state.baseqx[i], game.state.baseqy[i]));
        proutn("  ");
     }
     skip(2);
     proutn("The Enterprise is currently in ");
-    proutn(cramlc(quadrant, quadx, quady));
+    proutn(cramlc(quadrant, game.quadx, game.quady));
     proutn(" ");
     proutn(" ");
-    proutn(cramlc(sector, sectx, secty));
+    proutn(cramlc(sector, game.sectx, game.secty));
     skip(2);
     prout("Good Luck!");
     if (game.state.nscrem) prout("  YOU'LL NEED IT.");
     waitfor();
     newqad(0);
     skip(2);
     prout("Good Luck!");
     if (game.state.nscrem) prout("  YOU'LL NEED IT.");
     waitfor();
     newqad(0);
-    if (nenhere-iqhere-ithere) shldup=1.0;
-    if (neutz) attack(0);      // bad luck to start in a Romulan Neutral Zone
+    if (game.nenhere-iqhere-game.ithere) game.shldup=1.0;
+    if (game.neutz) attack(0); // bad luck to start in a Romulan Neutral Zone
 }
 
 int choose(int needprompt) 
 {
     while (TRUE) {
 }
 
 int choose(int needprompt) 
 {
     while (TRUE) {
-       tourn = 0;
-       thawed = 0;
-       skill = SKILL_NONE;
-       length = 0;
+       game.tourn = 0;
+       game.thawed = 0;
+       game.skill = SKILL_NONE;
+       game.length = 0;
        if (needprompt) /* Can start with command line options */
            proutn("Would you like a regular, tournament, or saved game? ");
        scan();
        if (needprompt) /* Can start with command line options */
            proutn("Would you like a regular, tournament, or saved game? ");
        scan();
@@ -420,7 +420,7 @@ int choose(int needprompt)
                chew();
                continue; // We don't want a blank entry
            }
                chew();
                continue; // We don't want a blank entry
            }
-           tourn = (int)aaitem;
+           game.tourn = (int)aaitem;
            thingx = -1;
            srand((unsigned int)(int)aaitem);
            break;
            thingx = -1;
            srand((unsigned int)(int)aaitem);
            break;
@@ -429,7 +429,7 @@ int choose(int needprompt)
            if (thaw()) continue;
            chew();
            if (*game.passwd==0) continue;
            if (thaw()) continue;
            chew();
            if (*game.passwd==0) continue;
-           if (!alldone) thawed = 1; // No plaque if not finished
+           if (!game.alldone) game.thawed = 1; // No plaque if not finished
            report();
            waitfor();
            return TRUE;
            report();
            waitfor();
            return TRUE;
@@ -440,16 +440,16 @@ int choose(int needprompt)
        prout("\"?");
        chew();
     }
        prout("\"?");
        chew();
     }
-    while (length==0 || skill==SKILL_NONE) {
+    while (game.length==0 || game.skill==SKILL_NONE) {
        if (scan() == IHALPHA) {
        if (scan() == IHALPHA) {
-           if (isit("short")) length = 1;
-           else if (isit("medium")) length = 2;
-           else if (isit("long")) length = 4;
-           else if (isit("novice")) skill = SKILL_NOVICE;
-           else if (isit("fair")) skill = SKILL_FAIR;
-           else if (isit("good")) skill = SKILL_GOOD;
-           else if (isit("expert")) skill = SKILL_EXPERT;
-           else if (isit("emeritus")) skill = SKILL_EMERITUS;
+           if (isit("short")) game.length = 1;
+           else if (isit("medium")) game.length = 2;
+           else if (isit("long")) game.length = 4;
+           else if (isit("novice")) game.skill = SKILL_NOVICE;
+           else if (isit("fair")) game.skill = SKILL_FAIR;
+           else if (isit("good")) game.skill = SKILL_GOOD;
+           else if (isit("expert")) game.skill = SKILL_EXPERT;
+           else if (isit("emeritus")) game.skill = SKILL_EMERITUS;
            else {
                proutn("What is \"");
                proutn(citem);
            else {
                proutn("What is \"");
                proutn(citem);
@@ -458,8 +458,8 @@ int choose(int needprompt)
        }
        else {
            chew();
        }
        else {
            chew();
-           if (length==0) proutn("Would you like a Short, Medium, or Long game? ");
-           else if (skill == SKILL_NONE) proutn("Are you a Novice, Fair, Good, Expert, or Emeritus player? ");
+           if (game.length==0) proutn("Would you like a Short, Medium, or Long game? ");
+           else if (game.skill == SKILL_NONE) proutn("Are you a Novice, Fair, Good, Expert, or Emeritus player? ");
        }
     }
     // Choose game options -- added by ESR for SST2K
        }
     }
     // Choose game options -- added by ESR for SST2K
@@ -487,27 +487,27 @@ int choose(int needprompt)
     }
     setpassword();
 #ifdef DEBUG
     }
     setpassword();
 #ifdef DEBUG
-    if (strcmp(game.passwd, "debug")==0) idebug = 1;
+    if (strcmp(game.passwd, "debug")==0) game.idebug = 1;
 #endif
 
     // Use parameters to generate initial values of things
 #endif
 
     // Use parameters to generate initial values of things
-    damfac = 0.5 * skill;
+    game.damfac = 0.5 * game.skill;
     game.state.rembase = 2.0 + Rand()*(BASEMAX-2.0);
     game.state.rembase = 2.0 + Rand()*(BASEMAX-2.0);
-    inbase = game.state.rembase;
+    game.inbase = game.state.rembase;
     if (game.options & OPTION_PLANETS)
     if (game.options & OPTION_PLANETS)
-       inplan = (PLNETMAX/2) + (PLNETMAX/2+1)*Rand();
-    game.state.nromrem = inrom = (2.0+Rand())*skill;
-    game.state.nscrem = inscom = (skill > SKILL_FAIR ? 1 : 0);
-    game.state.remtime = 7.0 * length;
-    intime = game.state.remtime;
-    game.state.remkl = inkling = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15);
-    incom = skill + 0.0625*inkling*Rand();
-    game.state.remcom = min(10, incom);
-    incom = game.state.remcom;
-    game.state.remres = (inkling+4*incom)*intime;
-    inresor = game.state.remres;
-    if (inkling > 50) {
-       inbase = (game.state.rembase += 1);
+       game.inplan = (PLNETMAX/2) + (PLNETMAX/2+1)*Rand();
+    game.state.nromrem = game.inrom = (2.0+Rand())*game.skill;
+    game.state.nscrem = game.inscom = (game.skill > SKILL_FAIR ? 1 : 0);
+    game.state.remtime = 7.0 * game.length;
+    game.intime = game.state.remtime;
+    game.state.remkl = game.inkling = 2.0*game.intime*((game.skill+1 - 2*Rand())*game.skill*0.1+.15);
+    game.incom = game.skill + 0.0625*game.inkling*Rand();
+    game.state.remcom = min(10, game.incom);
+    game.incom = game.state.remcom;
+    game.state.remres = (game.inkling+4*game.incom)*game.intime;
+    game.inresor = game.state.remres;
+    if (game.inkling > 50) {
+       game.inbase = (game.state.rembase += 1);
     }
     return FALSE;
 }
     }
     return FALSE;
 }
@@ -521,11 +521,11 @@ void dropin(int iquad, int *ix, int *iy)
 
 void newcnd(void) 
 {
 
 void newcnd(void) 
 {
-    condit = IHGREEN;
-    if (energy < 1000.0) condit = IHYELLOW;
-    if (game.state.galaxy[quadx][quady].klingons || game.state.galaxy[quadx][quady].romulans)
-       condit = IHRED;
-    if (!alive) condit=IHDEAD;
+    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)
+       game.condit = IHRED;
+    if (!game.alive) game.condit=IHDEAD;
 }
 
 
 }
 
 
@@ -533,101 +533,101 @@ void newqad(int shutup)
 {
     int i, j, ix, iy, nplan;
 
 {
     int i, j, ix, iy, nplan;
 
-    iattak = 1;
-    justin = 1;
-    basex = basey = 0;
-    klhere = 0;
-    comhere = 0;
-    plnetx = plnety = 0;
-    ishere = 0;
-    irhere = 0;
-    iplnet = 0;
-    nenhere = 0;
-    neutz = 0;
-    inorbit = 0;
-    landed = -1;
-    ientesc = 0;
-    ithere = 0;
+    game.iattak = 1;
+    game.justin = 1;
+    game.basex = game.basey = 0;
+    game.klhere = 0;
+    game.comhere = 0;
+    game.plnetx = game.plnety = 0;
+    game.ishere = 0;
+    game.irhere = 0;
+    game.iplnet = 0;
+    game.nenhere = 0;
+    game.neutz = 0;
+    game.inorbit = 0;
+    game.landed = -1;
+    game.ientesc = 0;
+    game.ithere = 0;
     iqhere=0;
     iqengry=0;
     iqhere=0;
     iqengry=0;
-    iseenit = 0;
-    if (iscate) {
+    game.iseenit = 0;
+    if (game.iscate) {
        // Attempt to escape Super-commander, so tbeam back!
        // Attempt to escape Super-commander, so tbeam back!
-       iscate = 0;
-       ientesc = 1;
+       game.iscate = 0;
+       game.ientesc = 1;
     }
     // Clear quadrant
     for_sectors(i)
        for_sectors(j) 
            game.quad[i][j] = IHDOT;
     // cope with supernova
     }
     // Clear quadrant
     for_sectors(i)
        for_sectors(j) 
            game.quad[i][j] = IHDOT;
     // cope with supernova
-    if (game.state.galaxy[quadx][quady].supernova)
+    if (game.state.galaxy[game.quadx][game.quady].supernova)
        return;
        return;
-    klhere = game.state.galaxy[quadx][quady].klingons;
-    irhere = game.state.galaxy[quadx][quady].romulans;
-    nplan  = game.state.galaxy[quadx][quady].planets;
-    nenhere = klhere + irhere;
+    game.klhere = game.state.galaxy[game.quadx][game.quady].klingons;
+    game.irhere = game.state.galaxy[game.quadx][game.quady].romulans;
+    nplan  = game.state.galaxy[game.quadx][game.quady].planets;
+    game.nenhere = game.klhere + game.irhere;
 
     // Position Starship
 
     // Position Starship
-    game.quad[sectx][secty] = ship;
+    game.quad[game.sectx][game.secty] = game.ship;
 
 
-    if (game.state.galaxy[quadx][quady].klingons) {
+    if (game.state.galaxy[game.quadx][game.quady].klingons) {
        // Position ordinary Klingons
        // Position ordinary Klingons
-       for (i = 1; i <= klhere; i++) {
+       for (i = 1; i <= game.klhere; i++) {
            dropin(IHK, &ix, &iy);
            game.kx[i] = ix;
            game.ky[i] = iy;
            dropin(IHK, &ix, &iy);
            game.kx[i] = ix;
            game.ky[i] = iy;
-           game.kdist[i] = game.kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy));
-           game.kpower[i] = Rand()*150.0 +300.0 +25.0*skill;
+           game.kdist[i] = game.kavgd[i] = sqrt(square(game.sectx-ix) + square(game.secty-iy));
+           game.kpower[i] = Rand()*150.0 +300.0 +25.0*game.skill;
        }
        // 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]==quadx && game.state.cy[i]==quady) break;
+           if (game.state.cx[i]==game.quadx && game.state.cy[i]==game.quady) break;
                        
        if (i <= game.state.remcom) {
            game.quad[ix][iy] = IHC;
                        
        if (i <= game.state.remcom) {
            game.quad[ix][iy] = IHC;
-           game.kpower[klhere] = 950.0+400.0*Rand()+50.0*skill;
-           comhere = 1;
+           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 we need a super-commander, promote a Klingon
-       if (quadx == game.state.isx && quady == game.state.isy) {
+       if (game.quadx == game.state.isx && game.quady == game.state.isy) {
            game.quad[game.kx[1]][game.ky[1]] = IHS;
            game.quad[game.kx[1]][game.ky[1]] = IHS;
-           game.kpower[1] = 1175.0 + 400.0*Rand() + 125.0*skill;
-           iscate = game.state.remkl>1;
-           ishere = 1;
+           game.kpower[1] = 1175.0 + 400.0*Rand() + 125.0*game.skill;
+           game.iscate = game.state.remkl>1;
+           game.ishere = 1;
        }
     }
     // Put in Romulans if needed
        }
     }
     // Put in Romulans if needed
-    for (i = klhere+1; i <= nenhere; i++) {
+    for (i = game.klhere+1; i <= game.nenhere; i++) {
        dropin(IHR, &ix, &iy);
        game.kx[i] = ix;
        game.ky[i] = iy;
        dropin(IHR, &ix, &iy);
        game.kx[i] = ix;
        game.ky[i] = iy;
-       game.kdist[i] = game.kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy));
-       game.kpower[i] = Rand()*400.0 + 450.0 + 50.0*skill;
+       game.kdist[i] = game.kavgd[i] = sqrt(square(game.sectx-ix) + square(game.secty-iy));
+       game.kpower[i] = Rand()*400.0 + 450.0 + 50.0*game.skill;
     }
     // If quadrant needs a starbase, put it in
     }
     // If quadrant needs a starbase, put it in
-    if (game.state.galaxy[quadx][quady].starbase)
-       dropin(IHB, &basex, &basey);
+    if (game.state.galaxy[game.quadx][game.quady].starbase)
+       dropin(IHB, &game.basex, &game.basey);
        
     if (nplan) {
        // If quadrant needs a planet, put it in
        
     if (nplan) {
        // If quadrant needs a planet, put it in
-       for (i=0; i < inplan; i++)
-           if (game.state.plnets[i].x == quadx && game.state.plnets[i].y == quady) break;
-       if (i < inplan) {
-           iplnet = i;
-           dropin(IHP, &plnetx, &plnety);
+       for (i=0; i < game.inplan; i++)
+           if (game.state.plnets[i].x == game.quadx && game.state.plnets[i].y == game.quady) break;
+       if (i < game.inplan) {
+           game.iplnet = i;
+           dropin(IHP, &game.plnetx, &game.plnety);
        }
     }
        }
     }
-    // Check for condition
+    // Check for game.condition
     newcnd();
     // And finally the stars
     newcnd();
     // And finally the stars
-    for (i = 1; i <= game.state.galaxy[quadx][quady].stars; i++) 
+    for (i = 1; i <= game.state.galaxy[game.quadx][game.quady].stars; i++) 
        dropin(IHSTAR, &ix, &iy);
 
     // Check for RNZ
        dropin(IHSTAR, &ix, &iy);
 
     // Check for RNZ
-    if (irhere > 0 && klhere == 0) {
-       neutz = 1;
+    if (game.irhere > 0 && game.klhere == 0) {
+       game.neutz = 1;
        if (game.damage[DRADIO] <= 0.0) {
            skip(1);
            prout("LT. Uhura- \"Captain, an urgent message.");
        if (game.damage[DRADIO] <= 0.0) {
            skip(1);
            prout("LT. Uhura- \"Captain, an urgent message.");
@@ -640,16 +640,16 @@ void newqad(int shutup)
 
     if (shutup==0) {
        // Put in THING if needed
 
     if (shutup==0) {
        // Put in THING if needed
-       if (thingx == quadx && thingy == quady) {
+       if (thingx == game.quadx && thingy == game.quady) {
            dropin(IHQUEST, &ix, &iy);
            iran(GALSIZE, &thingx, &thingy);
            dropin(IHQUEST, &ix, &iy);
            iran(GALSIZE, &thingx, &thingy);
-           nenhere++;
+           game.nenhere++;
            iqhere=1;
            iqhere=1;
-           game.kx[nenhere] = ix;
-           game.ky[nenhere] = iy;
-           game.kdist[nenhere] = game.kavgd[nenhere] =
-               sqrt(square(sectx-ix) + square(secty-iy));
-           game.kpower[nenhere] = Rand()*6000.0 +500.0 +250.0*skill;
+           game.kx[game.nenhere] = ix;
+           game.ky[game.nenhere] = iy;
+           game.kdist[game.nenhere] = game.kavgd[game.nenhere] =
+               sqrt(square(game.sectx-ix) + square(game.secty-iy));
+           game.kpower[game.nenhere] = Rand()*6000.0 +500.0 +250.0*game.skill;
            if (game.damage[DSRSENS] == 0.0) {
                skip(1);
                prout("MR. SPOCK- \"Captain, this is most unusual.");
            if (game.damage[DSRSENS] == 0.0) {
                skip(1);
                prout("MR. SPOCK- \"Captain, this is most unusual.");
@@ -660,25 +660,25 @@ void newqad(int shutup)
 
     // Decide if quadrant needs a Tholian
     if (game.options & OPTION_THOLIAN) {
 
     // Decide if quadrant needs a Tholian
     if (game.options & OPTION_THOLIAN) {
-       if ((skill < SKILL_GOOD && Rand() <= 0.02) ||   /* Lighten up if skill is low */
-           (skill == SKILL_GOOD && Rand() <= 0.05) ||
-           (skill > SKILL_GOOD && Rand() <= 0.08)
+       if ((game.skill < SKILL_GOOD && Rand() <= 0.02) ||   /* Lighten up if skill is low */
+           (game.skill == SKILL_GOOD && Rand() <= 0.05) ||
+           (game.skill > SKILL_GOOD && Rand() <= 0.08)
     #ifdef DEBUG
            || strcmp(game.passwd, "tholianx")==0
     #endif
            ) {
            do {
     #ifdef DEBUG
            || strcmp(game.passwd, "tholianx")==0
     #endif
            ) {
            do {
-               ithx = Rand() > 0.5 ? QUADSIZE : 1;
-               ithy = Rand() > 0.5 ? QUADSIZE : 1;
-           } while (game.quad[ithx][ithy] != IHDOT);
-           game.quad[ithx][ithy] = IHT;
-           ithere = 1;
-           nenhere++;
-           game.kx[nenhere] = ithx;
-           game.ky[nenhere] = ithy;
-           game.kdist[nenhere] = game.kavgd[nenhere] =
-               sqrt(square(sectx-ithx) + square(secty-ithy));
-           game.kpower[nenhere] = Rand()*400.0 +100.0 +25.0*skill;
+               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.ithere = 1;
+           game.nenhere++;
+           game.kx[game.nenhere] = game.ithx;
+           game.ky[game.nenhere] = game.ithy;
+           game.kdist[game.nenhere] = game.kavgd[game.nenhere] =
+               sqrt(square(game.sectx-game.ithx) + square(game.secty-game.ithy));
+           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';
            if (game.quad[1][QUADSIZE]==IHDOT) game.quad[1][QUADSIZE] = 'X';
            /* Reserve unocupied corners */
            if (game.quad[1][1]==IHDOT) game.quad[1][1] = 'X';
            if (game.quad[1][QUADSIZE]==IHDOT) game.quad[1][QUADSIZE] = 'X';
@@ -695,7 +695,7 @@ void newqad(int shutup)
            dropin(IHBLANK, &ix, &iy);
 
     // Take out X's in corners if Tholian present
            dropin(IHBLANK, &ix, &iy);
 
     // Take out X's in corners if Tholian present
-    if (ithere) {
+    if (game.ithere) {
        if (game.quad[1][1]=='X') game.quad[1][1] = IHDOT;
        if (game.quad[1][QUADSIZE]=='X') game.quad[1][QUADSIZE] = IHDOT;
        if (game.quad[QUADSIZE][1]=='X') game.quad[QUADSIZE][1] = IHDOT;
        if (game.quad[1][1]=='X') game.quad[1][1] = IHDOT;
        if (game.quad[1][QUADSIZE]=='X') game.quad[1][QUADSIZE] = IHDOT;
        if (game.quad[QUADSIZE][1]=='X') game.quad[QUADSIZE][1] = IHDOT;
@@ -710,11 +710,11 @@ void sortkl(void)
 
     // The author liked bubble sort. So we will use it. :-(
 
 
     // The author liked bubble sort. So we will use it. :-(
 
-    if (nenhere-iqhere-ithere < 2) return;
+    if (game.nenhere-iqhere-game.ithere < 2) return;
 
     do {
        sw = FALSE;
 
     do {
        sw = FALSE;
-       for (j = 1; j < nenhere; j++)
+       for (j = 1; j < game.nenhere; j++)
            if (game.kdist[j] > game.kdist[j+1]) {
                sw = TRUE;
                t = game.kdist[j];
            if (game.kdist[j] > game.kdist[j+1]) {
                sw = TRUE;
                t = game.kdist[j];
index 75dca51ba19433a974bba33d5e1e89a74def516b..3ec832c719017269199db55ee48f624d4358ff83 100644 (file)
--- a/src/sst.c
+++ b/src/sst.c
@@ -375,8 +375,8 @@ static void makemoves(void)
        drawmaps(1);
        while (TRUE)  { /* get a command */
            hitme = FALSE;
        drawmaps(1);
        while (TRUE)  { /* get a command */
            hitme = FALSE;
-           justin = 0;
-           Time = 0.0;
+           game.justin = 0;
+           game.optime = 0.0;
            i = -1;
            chew();
            setwnd(prompt_window);
            i = -1;
            chew();
            setwnd(prompt_window);
@@ -386,7 +386,7 @@ static void makemoves(void)
                makechart();
                continue;
            }
                makechart();
                continue;
            }
-           ididit=0;
+           game.ididit=0;
            clrscr();
            setwnd(message_window);
            clrscr();
            clrscr();
            setwnd(message_window);
            clrscr();
@@ -422,25 +422,25 @@ static void makemoves(void)
            break;
        case PHASERS:                   // phasers
            phasers();
            break;
        case PHASERS:                   // phasers
            phasers();
-           if (ididit) hitme = TRUE;
+           if (game.ididit) hitme = TRUE;
            break;
        case TORPEDO:                   // photons
            photon();
            break;
        case TORPEDO:                   // photons
            photon();
-           if (ididit) hitme = TRUE;
+           if (game.ididit) hitme = TRUE;
            break;
        case MOVE:                      // move
            warp(1);
            break;
        case SHIELDS:                   // shields
            doshield(1);
            break;
        case MOVE:                      // move
            warp(1);
            break;
        case SHIELDS:                   // shields
            doshield(1);
-           if (ididit) {
+           if (game.ididit) {
                hitme=TRUE;
                hitme=TRUE;
-               shldchg = 0;
+               game.shldchg = 0;
            }
            break;
        case DOCK:                      // dock
            dock(1);
            }
            break;
        case DOCK:                      // dock
            dock(1);
-           if (ididit) attack(0);
+           if (game.ididit) attack(0);
            break;
        case DAMAGES:                   // damages
            dreprt();
            break;
        case DAMAGES:                   // damages
            dreprt();
@@ -453,7 +453,7 @@ static void makemoves(void)
            break;
        case REST:                      // rest
            wait();
            break;
        case REST:                      // rest
            wait();
-           if (ididit) hitme = TRUE;
+           if (game.ididit) hitme = TRUE;
            break;
        case WARP:                      // warp
            setwrp();
            break;
        case WARP:                      // warp
            setwrp();
@@ -466,22 +466,22 @@ static void makemoves(void)
            break;
        case ORBIT:                     // orbit
            orbit();
            break;
        case ORBIT:                     // orbit
            orbit();
-           if (ididit) hitme = TRUE;
+           if (game.ididit) hitme = TRUE;
            break;
        case TRANSPORT:                 // transport "beam"
            beam();
            break;
        case MINE:                      // mine
            mine();
            break;
        case TRANSPORT:                 // transport "beam"
            beam();
            break;
        case MINE:                      // mine
            mine();
-           if (ididit) hitme = TRUE;
+           if (game.ididit) hitme = TRUE;
            break;
        case CRYSTALS:                  // crystals
            usecrystals();
            break;
        case CRYSTALS:                  // crystals
            usecrystals();
-           if (ididit) hitme = TRUE;
+           if (game.ididit) hitme = TRUE;
            break;
        case SHUTTLE:                   // shuttle
            shuttle();
            break;
        case SHUTTLE:                   // shuttle
            shuttle();
-           if (ididit) hitme = TRUE;
+           if (game.ididit) hitme = TRUE;
            break;
        case PLANETS:                   // Planet list
            preport();
            break;
        case PLANETS:                   // Planet list
            preport();
@@ -502,7 +502,7 @@ static void makemoves(void)
            break;
        case PROBE:
            probe();                    // Launch probe
            break;
        case PROBE:
            probe();                    // Launch probe
-           if (ididit) hitme = TRUE;
+           if (game.ididit) hitme = TRUE;
            break;
        case ABANDON:                   // Abandon Ship
            abandn();
            break;
        case ABANDON:                   // Abandon Ship
            abandn();
@@ -513,12 +513,12 @@ static void makemoves(void)
        case SAVE:                      // Save Game
            freeze(FALSE);
            clrscr();
        case SAVE:                      // Save Game
            freeze(FALSE);
            clrscr();
-           if (skill > SKILL_GOOD)
+           if (game.skill > SKILL_GOOD)
                prout("WARNING--Saved games produce no plaques!");
            break;
        case DEATHRAY:                  // Try a desparation measure
            deathray();
                prout("WARNING--Saved games produce no plaques!");
            break;
        case DEATHRAY:                  // Try a desparation measure
            deathray();
-           if (ididit) hitme = TRUE;
+           if (game.ididit) hitme = TRUE;
            break;
        case DEBUGCMD:                  // What do we want for debug???
 #ifdef DEBUG
            break;
        case DEBUGCMD:                  // What do we want for debug???
 #ifdef DEBUG
@@ -527,12 +527,12 @@ static void makemoves(void)
            break;
        case MAYDAY:                    // Call for help
            help();
            break;
        case MAYDAY:                    // Call for help
            help();
-           if (ididit) hitme = TRUE;
+           if (game.ididit) hitme = TRUE;
            break;
        case QUIT:
            break;
        case QUIT:
-           alldone = 1;                // quit the game
+           game.alldone = 1;           // quit the game
 #ifdef DEBUG
 #ifdef DEBUG
-           if (idebug) score();
+           if (game.idebug) score();
 #endif
            break;
        case HELP:
 #endif
            break;
        case HELP:
@@ -541,22 +541,22 @@ static void makemoves(void)
        }
        commandhook(commands[i].name, FALSE);
        for (;;) {
        }
        commandhook(commands[i].name, FALSE);
        for (;;) {
-           if (alldone) break;         // Game has ended
+           if (game.alldone) break;            // Game has ended
 #ifdef DEBUG
 #ifdef DEBUG
-           if (idebug) prout("2500");
+           if (game.idebug) prout("2500");
 #endif
 #endif
-           if (Time != 0.0) {
+           if (game.optime != 0.0) {
                events();
                events();
-               if (alldone) break;     // Events did us in
+               if (game.alldone) break;        // Events did us in
            }
            }
-           if (game.state.galaxy[quadx][quady].supernova) { // Galaxy went Nova!
+           if (game.state.galaxy[game.quadx][game.quady].supernova) { // Galaxy went Nova!
                atover(0);
                continue;
            }
                atover(0);
                continue;
            }
-           if (hitme && justin==0) {
+           if (hitme && game.justin==0) {
                attack(2);
                attack(2);
-               if (alldone) break;
-               if (game.state.galaxy[quadx][quady].supernova) {        // went NOVA! 
+               if (game.alldone) break;
+               if (game.state.galaxy[game.quadx][game.quady].supernova) {      // went NOVA! 
                    atover(0);
                    hitme = TRUE;
                    continue;
                    atover(0);
                    hitme = TRUE;
                    continue;
@@ -564,7 +564,7 @@ static void makemoves(void)
            }
            break;
        }
            }
            break;
        }
-       if (alldone) break;
+       if (game.alldone) break;
     }
 }
 
     }
 }
 
@@ -607,16 +607,16 @@ int main(int argc, char **argv)
        clrscr();
        prelim();
        setup(line[0] == '\0');
        clrscr();
        prelim();
        setup(line[0] == '\0');
-       if (alldone) {
+       if (game.alldone) {
            score();
            score();
-           alldone = 0;
+           game.alldone = 0;
        }
        else makemoves();
        skip(1);
        stars();
        skip(1);
 
        }
        else makemoves();
        skip(1);
        stars();
        skip(1);
 
-       if (tourn && alldone) {
+       if (game.tourn && game.alldone) {
            proutn("Do you want your score recorded?");
            if (ja()) {
                chew2();
            proutn("Do you want your score recorded?");
            if (ja()) {
                chew2();
@@ -675,7 +675,7 @@ void crmena(int i, int enemy, int key, int x, int y)
 void crmshp(void) 
 {
     char *s;
 void crmshp(void) 
 {
     char *s;
-    switch (ship) {
+    switch (game.ship) {
     case IHE: s = "Enterprise"; break;
     case IHF: s = "Faerie Queene"; break;
     default:  s = "Ship???"; break;
     case IHE: s = "Enterprise"; break;
     case IHF: s = "Faerie Queene"; break;
     default:  s = "Ship???"; break;
@@ -805,10 +805,10 @@ void debugme(void)
 {
     proutn("Reset levels? ");
     if (ja() != 0) {
 {
     proutn("Reset levels? ");
     if (ja() != 0) {
-       if (energy < inenrg) energy = inenrg;
-       shield = inshld;
-       torps = intorps;
-       lsupres = inlsr;
+       if (energy < game.inenrg) energy = game.inenrg;
+       shield = game.inshld;
+       torps = game.intorps;
+       game.lsupres = game.inlsr;
     }
     proutn("Reset damage? ");
     if (ja() != 0) {
     }
     proutn("Reset damage? ");
     if (ja() != 0) {
@@ -817,10 +817,10 @@ void debugme(void)
            if (game.damage[i] > 0.0) 
                game.damage[i] = 0.0;
     }
            if (game.damage[i] > 0.0) 
                game.damage[i] = 0.0;
     }
-    proutn("Toggle idebug? ");
+    proutn("Toggle game.idebug? ");
     if (ja() != 0) {
     if (ja() != 0) {
-       idebug = !idebug;
-       if (idebug) prout("Debug output ON");
+       game.idebug = !game.idebug;
+       if (game.idebug) prout("Debug output ON");
        else prout("Debug output OFF");
     }
     proutn("Cause selective damage? ");
        else prout("Debug output OFF");
     }
     proutn("Cause selective damage? ");
@@ -864,7 +864,7 @@ void debugme(void)
     }
     proutn("Induce supernova here? ");
     if (ja() != 0) {
     }
     proutn("Induce supernova here? ");
     if (ja() != 0) {
-       game.state.galaxy[quadx][quady].supernova = TRUE;
+       game.state.galaxy[game.quadx][game.quady].supernova = TRUE;
        atover(1);
     }
 }
        atover(1);
     }
 }
index 0c0e49274f80cd7715e736b5a23ba63cccb4843f..838bc8ae829f4a527aa25f4f983ce23318b38b4d 100644 (file)
--- a/src/sst.h
+++ b/src/sst.h
@@ -32,7 +32,7 @@
 #define for_quadrants(i)       for (i = 1; i <= GALSIZE; i++)
 #define for_sectors(i)         for (i = 1; i <= QUADSIZE; i++)
 #define for_commanders(i)      for (i = 1; i <= game.state.remcom; i++)
 #define for_quadrants(i)       for (i = 1; i <= GALSIZE; i++)
 #define for_sectors(i)         for (i = 1; i <= QUADSIZE; i++)
 #define for_commanders(i)      for (i = 1; i <= game.state.remcom; i++)
-#define for_local_enemies(i)   for (i = 1; i <= nenhere; 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 {
 #define for_starbases(i)       for (i = 1; i <= game.state.rembase; i++)
 
 typedef struct {
@@ -79,12 +79,12 @@ typedef struct {
     } chart[GALSIZE+1][GALSIZE+1];     // the starchart (subscript 0 not used)
 } snapshot;                            // Data that is snapshot
 
     } chart[GALSIZE+1][GALSIZE+1];     // the starchart (subscript 0 not used)
 } snapshot;                            // Data that is snapshot
 
-#define NKILLK (inkling - game.state.remkl)
-#define NKILLC (incom - game.state.remcom)
-#define NKILLSC (inscom - game.state.nscrem)
-#define NKILLROM (inrom - game.state.nromrem)
+#define NKILLK (game.inkling - game.state.remkl)
+#define NKILLC (game.incom - game.state.remcom)
+#define NKILLSC (game.inscom - game.state.nscrem)
+#define NKILLROM (game.inrom - game.state.nromrem)
 #define KLINGREM (game.state.remkl + game.state.remcom + game.state.nscrem)
 #define KLINGREM (game.state.remkl + game.state.remcom + game.state.nscrem)
-#define INKLINGTOT (inkling + incom + inscom)
+#define INKLINGTOT (game.inkling + game.incom + game.inscom)
 #define KLINGKILLED (INKLINGTOT - KLINGREM)
 
 #define SKILL_NONE     0
 #define KLINGKILLED (INKLINGTOT - KLINGREM)
 
 #define SKILL_NONE     0
@@ -167,186 +167,97 @@ struct game {
     char passwd[10];           // Self Destruct password
     int kx[(QUADSIZE+1)*(QUADSIZE+1)];                 // enemy sector locations
     int ky[(QUADSIZE+1)*(QUADSIZE+1)];
     char passwd[10];           // Self Destruct password
     int kx[(QUADSIZE+1)*(QUADSIZE+1)];                 // enemy sector locations
     int ky[(QUADSIZE+1)*(QUADSIZE+1)];
-    /* members with macro definitions start here */
-    int inkling,
-       inbase,
-       incom,
-       inscom,
-       inrom,
-       instar,
-       intorps,
-       condit,
-       torps,
-       ship,
-       quadx,
-       quady,
-       sectx,
-       secty,
-       length,
-       skill,
-       basex,
-       basey,
-       klhere,
-       comhere,
-       casual,
-       nhelp,
-       nkinks,
-       ididit,
-       gamewon,
-       alive,
-       justin,
-       alldone,
-       shldchg,
-       plnetx,
-       plnety,
-       inorbit,
-       landed,
-       iplnet,
-       imine,
-       inplan,
-       nenhere,
-       ishere,
-       neutz,
-       irhere,
-       icraft,
-       ientesc,
-       iscraft,
-       isatb,
-       iscate,
+    int inkling,       // Initial number of klingons
+       inbase,         // Initial number of bases
+       incom,          // Initial number of commanders
+       inscom,         // Initial number of commanders
+       inrom,          // Initial number of commanders
+       instar,         // Initial stars
+       intorps,        // Initial/Max torpedoes
+       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
+       basex,          // position of base in current quadrant
+       basey,          //
+       klhere,         // klingons here
+       comhere,        // commanders here
+       casual,         // causalties
+       nhelp,          // calls for help
+       nkinks,         // count of energy-barrier crossings
+       ididit,         // Action taken -- allows enemy to attack
+       gamewon,        // Finished!
+       alive,          // We are alive (not killed)
+       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
+       imine,          // mining
+       inplan,         // initial planets
+       nenhere,        // number of enemies in quadrant
+       ishere,         // super-commander in quandrant
+       neutz,          // Romulan Neutral Zone
+       irhere,         // Romulans in quadrant
+       icraft,         // Kirk in Galileo
+       ientesc,        // attempted escape from supercommander
+       iscraft,        // =1 if craft on ship, -1 if removed from game
+       isatb,          // =1 if super commander is attacking base
+       iscate,         // super commander is here
 #ifdef DEBUG
 #ifdef DEBUG
-       idebug,
+       idebug,         // debug mode
 #endif
 #endif
-       iattak,
-       icrystl,
-       tourn,
-       thawed,
-       batx,
-       baty,
-       ithere,
-       ithx,
-       ithy,
-       iseenit,
-       probecx,
-       probecy,
-       proben,
-       isarmed,
-       nprobes;
-    double inresor,
-       intime,
-       inenrg,
-       inshld,
-       inlsr,
-       indate,
-       energy,
-       shield,
-       shldup,
-       warpfac,
-       wfacsq,
-       lsupres,
-       dist,
-       direc,
-       Time,
-       docfac,
-       resting,
-       damfac,
-       lastchart,
-       cryprob,
-       probex,
-       probey,
-       probeinx,
-       probeiny,
-       height;
+       iattak,         // attack recursion elimination (was cracks[4])
+       icrystl,        // dilithium crystals aboard
+       tourn,          // tournament number
+       thawed,         // thawed game
+       batx,           // base coordinates being attacked
+       baty,           //
+       ithere,         // Tholian is here 
+       ithx,           // coordinates of Tholian
+       ithy,           //
+       iseenit,        // seen base attack report
+       probecx,        // current probe quadrant
+       probecy,        //
+       proben,         // number of moves for probe
+       isarmed,        // probe is armed
+       nprobes;        // number of probes available
+    double inresor,    // initial resources
+       intime,         // initial time
+       inenrg,         // initial/max energy
+       inshld,         // initial/max shield
+       inlsr,          // initial life support resources
+       indate,         // initial date
+       energy,         // energy level
+       shield,         // shield level
+       shldup,         // shields are up
+       warpfac,        // warp speed
+       wfacsq,         // squared warp factor
+       lsupres,        // life support reserves
+       dist,           // movement distance
+       direc,          // movement direction
+       optime,         // time taken by current operation
+       docfac,         // repair factor when docking (constant?)
+       resting,        // rest time
+       damfac,         // damage factor
+       lastchart,      // time star chart was last updated
+       cryprob,        // probability that crystal will work
+       probex,         // location of probe
+       probey,         //
+       probeinx,       // probe x,y increment
+       probeiny,       //
+       height;         // height of orbit around planet
 };
 extern struct game game;
 
 };
 extern struct game game;
 
-#define inkling game.inkling           // Initial number of klingons
-#define inbase game.inbase             // Initial number of bases
-#define incom game.incom               // Initian number of commanders
-#define inscom game.inscom             // Initian number of commanders
-#define inrom game.inrom               // Initian number of commanders
-#define instar game.instar             // Initial stars
-#define intorps game.intorps           // Initial/Max torpedoes
-#define condit game.condit             // Condition (red/yellow/green/docked)
-#define torps game.torps               // number of torpedoes
-#define ship game.ship                 // Ship type -- 'E' is Enterprise
-#define quadx game.quadx               // where we are
-#define quady game.quady               //
-#define sectx game.sectx               // where we are
-#define secty game.secty               //
-#define length game.length             // length of game
-#define skill game.skill               // skill level
-#define basex game.basex               // position of base in current quad
-#define basey game.basey               //
-#define klhere game.klhere             // klingons here
-#define comhere game.comhere           // commanders here
-#define casual game.casual             // causalties
-#define nhelp game.nhelp               // calls for help
-#define nkinks game.nkinks             //
-#define ididit game.ididit             // Action taken -- allows enemy to attack
-#define gamewon game.gamewon           // Finished!
-#define alive game.alive               // We are alive (not killed)
-#define justin game.justin             // just entered quadrant
-#define alldone game.alldone           // game is now finished
-#define shldchg game.shldchg           // shield is changing (affects efficiency)
-#define plnetx game.plnetx             // location of planet in quadrant
-#define plnety game.plnety             //
-#define inorbit game.inorbit           // orbiting
-#define landed game.landed             // party on planet (1), on ship (-1)
-#define iplnet game.iplnet             // planet # in quadrant
-#define imine game.imine               // mining
-#define inplan game.inplan             // initial planets
-#define nenhere game.nenhere           // Number of enemies in quadrant
-#define ishere game.ishere             // Super-commander in quandrant
-#define neutz game.neutz               // Romulan Neutral Zone
-#define irhere game.irhere             // Romulans in quadrant
-#define icraft game.icraft             // Kirk in Galileo
-#define ientesc game.ientesc           // Attempted escape from supercommander
-#define iscraft game.iscraft           // =1 if craft on ship, -1 if removed from game
-#define isatb game.isatb               // =1 if SuperCommander is attacking base
-#define iscate game.iscate             // Super Commander is here
-#ifdef DEBUG
-#define idebug game.idebug             // Debug mode
-#endif
-#define iattak game.iattak             // attack recursion elimination (was cracks[4])
-#define icrystl game.icrystl           // dilithium crystals aboard
-#define tourn game.tourn               // Tournament number
-#define thawed game.thawed             // Thawed game
-#define batx game.batx                 // Base coordinates being attacked
-#define baty game.baty                 //
-#define ithere game.ithere             // Tholean is here 
-#define ithx game.ithx                 // coordinates of tholean
-#define ithy game.ithy
-#define iseenit game.iseenit           // Seen base attack report
-#define inresor game.inresor           // initial resources
-#define intime game.intime             // initial time
-#define inenrg game.inenrg             // Initial/Max Energy
-#define inshld game.inshld             // Initial/Max Shield
-#define inlsr game.inlsr               // initial life support resources
-#define indate game.indate             // Initial date
-#define energy game.energy             // Energy level
-#define shield game.shield             // Shield level
-#define shldup game.shldup             // Shields are up
-#define warpfac game.warpfac           // Warp speed
-#define wfacsq game.wfacsq             // squared warp factor
-#define lsupres game.lsupres           // life support reserves
-#define dist game.dist                 // movement distance
-#define direc game.direc               // movement direction
-#define Time game.Time                 // time taken by current operation
-#define docfac game.docfac             // repair factor when docking (constant?)
-#define resting game.resting           // rest time
-#define damfac game.damfac             // damage factor
-#define lastchart game.lastchart       // time star chart was last updated
-#define cryprob game.cryprob           // probability that crystal will work
-#define probex game.probex             // location of probe
-#define probey game.probey
-#define probecx game.probecx           // current probe quadrant
-#define probecy game.probecy   
-#define probeinx game.probeinx         // Probe x,y increment
-#define probeiny game.probeiny         
-#define proben game.proben             // number of moves for probe
-#define isarmed game.isarmed           // Probe is armed
-#define nprobes game.nprobes           // number of probes available
-
 /* the following global state doesn't need to be saved */
 extern char *device[NDEVICES];
 extern int iscore, iskill; // Common PLAQ
 /* the following global state doesn't need to be saved */
 extern char *device[NDEVICES];
 extern int iscore, iskill; // Common PLAQ
index 126da025166b1ba5de6ca7c9ea4a89f12f3814e7..6d604909d1fe150a5444b97c0c950f01d405040d 100644 (file)
--- a/src/xio.c
+++ b/src/xio.c
@@ -8,8 +8,6 @@
 #include <X11/Xaw/AsciiText.h>
 #include "sst.h"
 
 #include <X11/Xaw/AsciiText.h>
 #include "sst.h"
 
-#undef length  /* ugh -- must get rid of ugly #defines */
-
 static XtAppContext app_context;
 static Widget toplevel, text, form; 
 static Widget navigation, weapons, planets, misc; 
 static XtAppContext app_context;
 static Widget toplevel, text, form; 
 static Widget navigation, weapons, planets, misc;