Another step in consolidating the saved-state globals.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 1 Nov 2004 00:23:05 +0000 (00:23 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 1 Nov 2004 00:23:05 +0000 (00:23 +0000)
They all live in one structure now.

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

diff --git a/ai.c b/ai.c
index 4572d4f9a851d23f8ac543f9c9613dbce5d60200..9dcb1a01261941591e7a99c64721a2b7d7314e7a 100644 (file)
--- a/ai.c
+++ b/ai.c
@@ -6,23 +6,23 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) {
        iqx = quadx+(lookx+9)/10 - 1;\r
        iqy = quady+(looky+9)/10 - 1;\r
        if (iqx < 1 || iqx > 8 || iqy < 1 || iqy > 8 ||\r
-               state.galaxy[iqx][iqy] > 899)\r
+               game.state.galaxy[iqx][iqy] > 899)\r
                return 0; /* no can do -- neg energy, supernovae, or >8 Klingons */\r
        if (ienm == IHR) return 0; /* Romulans cannot escape! */\r
        if (irun == 0) {\r
                /* avoid intruding on another commander's territory */\r
                if (ienm == IHC) {\r
-                       for (l = 1; l <= state.remcom; l++)\r
-                               if (state.cx[l]==iqx && state.cy[l]==iqy) return 0;\r
+                       for (l = 1; l <= game.state.remcom; l++)\r
+                               if (game.state.cx[l]==iqx && game.state.cy[l]==iqy) return 0;\r
                        /* refuse to leave if currently attacking starbase */\r
                        if (batx==quadx && baty==quady) return 0;\r
                }\r
                /* don't leave if over 1000 units of energy */\r
-               if (frozen.kpower[loccom] > 1000.) return 0;\r
+               if (game.kpower[loccom] > 1000.) return 0;\r
        }\r
        /* print escape message and move out of quadrant.\r
           We know this if either short or long range sensors are working */\r
-       if (frozen.damage[DSRSENS] == 0.0 || frozen.damage[DLRSENS] == 0.0 ||\r
+       if (game.damage[DSRSENS] == 0.0 || game.damage[DLRSENS] == 0.0 ||\r
                condit == IHDOCKED) {\r
                proutn("***");\r
                cramen(ienm);\r
@@ -31,32 +31,32 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) {
                prout(" (and regains strength).");\r
        }\r
        /* handle local matters related to escape */\r
-       frozen.kx[loccom] = frozen.kx[nenhere];\r
-       frozen.ky[loccom] = frozen.ky[nenhere];\r
-       frozen.kavgd[loccom] = frozen.kavgd[nenhere];\r
-       frozen.kpower[loccom] = frozen.kpower[nenhere];\r
-       frozen.kdist[loccom] = frozen.kdist[nenhere];\r
+       game.kx[loccom] = game.kx[nenhere];\r
+       game.ky[loccom] = game.ky[nenhere];\r
+       game.kavgd[loccom] = game.kavgd[nenhere];\r
+       game.kpower[loccom] = game.kpower[nenhere];\r
+       game.kdist[loccom] = game.kdist[nenhere];\r
        klhere--;\r
        nenhere--;\r
        if (condit != IHDOCKED) newcnd();\r
        /* Handle global matters related to escape */\r
-       state.galaxy[quadx][quady] -= 100;\r
-       state.galaxy[iqx][iqy] += 100;\r
+       game.state.galaxy[quadx][quady] -= 100;\r
+       game.state.galaxy[iqx][iqy] += 100;\r
        if (ienm==IHS) {\r
                ishere=0;\r
                iscate=0;\r
                ientesc=0;\r
                isatb=0;\r
-               frozen.future[FSCMOVE]=0.2777+state.date;\r
-               frozen.future[FSCDBAS]=1e30;\r
-               state.isx=iqx;\r
-               state.isy=iqy;\r
+               game.future[FSCMOVE]=0.2777+game.state.date;\r
+               game.future[FSCDBAS]=1e30;\r
+               game.state.isx=iqx;\r
+               game.state.isy=iqy;\r
        }\r
        else {\r
-               for (l=1; l<=state.remcom; l++) {\r
-                       if (state.cx[l]==quadx && state.cy[l]==quady) {\r
-                               state.cx[l]=iqx;\r
-                               state.cy[l]=iqy;\r
+               for (l=1; l<=game.state.remcom; l++) {\r
+                       if (game.state.cx[l]==quadx && game.state.cy[l]==quady) {\r
+                               game.state.cx[l]=iqx;\r
+                               game.state.cy[l]=iqy;\r
                                break;\r
                        }\r
                }\r
@@ -78,12 +78,12 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) {
                                  (comhere + ishere);\r
        double dist1, forces;\r
 \r
-       dist1 = frozen.kdist[loccom];\r
+       dist1 = game.kdist[loccom];\r
        mdist = dist1 + 0.5; /* Nearest integer distance */\r
 \r
        /* If SC, check with spy to see if should hi-tail it */\r
        if (ienm==IHS &&\r
-               (frozen.kpower[loccom] <= 500.0 || (condit==IHDOCKED && frozen.damage[DPHOTON]==0))) {\r
+               (game.kpower[loccom] <= 500.0 || (condit==IHDOCKED && game.damage[DPHOTON]==0))) {\r
                irun = 1;\r
                motion = -10;\r
        }\r
@@ -127,14 +127,14 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) {
   *  Motion is limited to skill level, except for SC hi-tailing it out.\r
   */\r
 \r
-               forces = frozen.kpower[loccom]+100.0*nenhere+400*(nbaddys-1);\r
+               forces = game.kpower[loccom]+100.0*nenhere+400*(nbaddys-1);\r
                if (shldup==0) forces += 1000; /* Good for enemy if shield is down! */\r
-               if (frozen.damage[DPHASER] == 0.0 || frozen.damage[DPHOTON] == 0.0) {\r
-                       if (frozen.damage[DPHASER] != 0) /* phasers damaged */\r
+               if (game.damage[DPHASER] == 0.0 || game.damage[DPHOTON] == 0.0) {\r
+                       if (game.damage[DPHASER] != 0) /* phasers damaged */\r
                                forces += 300.0;\r
                        else\r
                                forces -= 0.2*(energy - 2500.0);\r
-                       if (frozen.damage[DPHOTON] != 0) /* photon torpedoes damaged */\r
+                       if (game.damage[DPHOTON] != 0) /* photon torpedoes damaged */\r
                                forces += 300.0;\r
                        else\r
                                forces -= 50.0*torps;\r
@@ -187,7 +187,7 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) {
        if (my != 0) my = my*motion < 0 ? -1 : 1;\r
        nextx = comx;\r
        nexty = comy;\r
-       frozen.quad[comx][comy] = IHDOT;\r
+       game.quad[comx][comy] = IHDOT;\r
        /* main move loop */\r
        for (ll = 1; ll <= nsteps; ll++) {\r
 #ifdef DEBUG\r
@@ -218,9 +218,9 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) {
                                looky = nexty + krawly;\r
                                krawly = -krawly;\r
                        }\r
-                       else if (frozen.quad[lookx][looky] != IHDOT) {\r
+                       else if (game.quad[lookx][looky] != IHDOT) {\r
                                /* See if we should ram ship */\r
-                               if (frozen.quad[lookx][looky] == ship &&\r
+                               if (game.quad[lookx][looky] == ship &&\r
                                        (ienm == IHC || ienm == IHS)) {\r
                                        ram(1, ienm, comx, comy);\r
                                        return;\r
@@ -250,17 +250,17 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) {
                else break; /* done early */\r
        }\r
        /* Put commander in place within same quadrant */\r
-       frozen.quad[nextx][nexty] = ienm;\r
+       game.quad[nextx][nexty] = ienm;\r
        if (nextx != comx || nexty != comy) {\r
                /* it moved */\r
-               frozen.kx[loccom] = nextx;\r
-               frozen.ky[loccom] = nexty;\r
-               frozen.kdist[loccom] = frozen.kavgd[loccom] =\r
+               game.kx[loccom] = nextx;\r
+               game.ky[loccom] = nexty;\r
+               game.kdist[loccom] = game.kavgd[loccom] =\r
                                        sqrt(square(sectx-nextx)+square(secty-nexty));\r
-               if (frozen.damage[DSRSENS] == 0 || condit == IHDOCKED) {\r
+               if (game.damage[DSRSENS] == 0 || condit == IHDOCKED) {\r
                        proutn("***");\r
                        cramen(ienm);\r
-                       if (frozen.kdist[loccom] < dist1) proutn(" advances to");\r
+                       if (game.kdist[loccom] < dist1) proutn(" advances to");\r
                        else proutn(" retreats to");\r
                        cramlc(2, nextx, nexty);\r
                        skip(1);\r
@@ -278,17 +278,17 @@ void movcom(void) {
        /* Figure out which Klingon is the commander (or Supercommander)\r
           and do move */\r
        if (comhere) for (i = 1; i <= nenhere; i++) {\r
-               ix = frozen.kx[i];\r
-               iy = frozen.ky[i];\r
-               if (frozen.quad[ix][iy] == IHC) {\r
+               ix = game.kx[i];\r
+               iy = game.ky[i];\r
+               if (game.quad[ix][iy] == IHC) {\r
                        movebaddy(ix, iy, i, IHC);\r
                        break;\r
                }\r
        }\r
        if (ishere) for (i = 1; i <= nenhere; i++) {\r
-               ix = frozen.kx[i];\r
-               iy = frozen.ky[i];\r
-               if (frozen.quad[ix][iy] == IHS) {\r
+               ix = game.kx[i];\r
+               iy = game.ky[i];\r
+               if (game.quad[ix][iy] == IHS) {\r
                        movebaddy(ix, iy, i, IHS);\r
                        break;\r
                }\r
@@ -297,10 +297,10 @@ void movcom(void) {
           Move these last so they can base their actions on what the\r
        commander(s) do. */\r
        if (skill > 3) for (i = 1; i <= nenhere; i++) {\r
-               ix = frozen.kx[i];\r
-               iy = frozen.ky[i];\r
-               if (frozen.quad[ix][iy] == IHK || frozen.quad[ix][iy] == IHR)\r
-                       movebaddy(ix, iy, i, frozen.quad[ix][iy]);\r
+               ix = game.kx[i];\r
+               iy = game.ky[i];\r
+               if (game.quad[ix][iy] == IHK || game.quad[ix][iy] == IHR)\r
+                       movebaddy(ix, iy, i, game.quad[ix][iy]);\r
        }\r
 \r
        sortkl();\r
@@ -311,33 +311,33 @@ static int checkdest(int iqx, int iqy, int flag, int *ipage) {
 \r
        if ((iqx==quadx && iqy==quady) ||\r
                iqx < 1 || iqx > 8 || iqy < 1 || iqy > 8 ||\r
-               state.galaxy[iqx][iqy] > 899) return 1;\r
+               game.state.galaxy[iqx][iqy] > 899) return 1;\r
        if (flag) {\r
                /* Avoid quadrants with bases if we want to avoid Enterprise */\r
-               for (i = 1; i <= state.rembase; i++)\r
-                       if (state.baseqx[i]==iqx && state.baseqy[i]==iqy) return 1;\r
+               for (i = 1; i <= game.state.rembase; i++)\r
+                       if (game.state.baseqx[i]==iqx && game.state.baseqy[i]==iqy) return 1;\r
        }\r
 \r
        /* do the move */\r
-       state.galaxy[state.isx][state.isy] -= 100;\r
-       state.isx = iqx;\r
-       state.isy = iqy;\r
-       state.galaxy[state.isx][state.isy] += 100;\r
+       game.state.galaxy[game.state.isx][game.state.isy] -= 100;\r
+       game.state.isx = iqx;\r
+       game.state.isy = iqy;\r
+       game.state.galaxy[game.state.isx][game.state.isy] += 100;\r
        if (iscate) {\r
                /* SC has scooted, Remove him from current quadrant */\r
                iscate=0;\r
                isatb=0;\r
                ishere=0;\r
                ientesc=0;\r
-               frozen.future[FSCDBAS]=1e30;\r
+               game.future[FSCDBAS]=1e30;\r
                for (i = 1; i <= nenhere; i++) \r
-                       if (frozen.quad[frozen.kx[i]][frozen.ky[i]] == IHS) break;\r
-               frozen.quad[frozen.kx[i]][frozen.ky[i]] = IHDOT;\r
-               frozen.kx[i] = frozen.kx[nenhere];\r
-               frozen.ky[i] = frozen.ky[nenhere];\r
-               frozen.kdist[i] = frozen.kdist[nenhere];\r
-               frozen.kavgd[i] = frozen.kavgd[nenhere];\r
-               frozen.kpower[i] = frozen.kpower[nenhere];\r
+                       if (game.quad[game.kx[i]][game.ky[i]] == IHS) break;\r
+               game.quad[game.kx[i]][game.ky[i]] = IHDOT;\r
+               game.kx[i] = game.kx[nenhere];\r
+               game.ky[i] = game.ky[nenhere];\r
+               game.kdist[i] = game.kdist[nenhere];\r
+               game.kavgd[i] = game.kavgd[nenhere];\r
+               game.kpower[i] = game.kpower[nenhere];\r
                klhere--;\r
                nenhere--;\r
                if (condit!=IHDOCKED) newcnd();\r
@@ -345,17 +345,17 @@ static int checkdest(int iqx, int iqy, int flag, int *ipage) {
        }\r
        /* check for a helpful planet */\r
        for (i = 1; i <= inplan; i++) {\r
-               if (state.plnets[i].x==state.isx && state.plnets[i].y==state.isy &&\r
-                       state.plnets[i].crystals == 1) {\r
+               if (game.state.plnets[i].x==game.state.isx && game.state.plnets[i].y==game.state.isy &&\r
+                       game.state.plnets[i].crystals == 1) {\r
                        /* destroy the planet */\r
-                       state.plnets[i] = nulplanet;\r
-                       state.newstuf[state.isx][state.isy] -= 1;\r
-                       if (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
+                       game.state.plnets[i] = nulplanet;\r
+                       game.state.newstuf[game.state.isx][game.state.isy] -= 1;\r
+                       if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
                                if (*ipage==0) pause(1);\r
                                *ipage = 1;\r
                                prout("Lt. Uhura-  \"Captain, Starfleet Intelligence reports");\r
                                proutn("   a planet in");\r
-                               cramlc(1, state.isx, state.isy);\r
+                               cramlc(1, game.state.isx, game.state.isy);\r
                                prout(" has been destroyed");\r
                                prout("   by the Super-commander.\"");\r
                        }\r
@@ -380,39 +380,39 @@ void scom(int *ipage) {
 #endif\r
 \r
        /* Decide on being active or passive */\r
-       flag = ((state.killc+state.killk)/(state.date+0.01-indate) < 0.1*skill*(skill+1.0) ||\r
-                       (state.date-indate) < 3.0);\r
+       flag = ((game.state.killc+game.state.killk)/(game.state.date+0.01-indate) < 0.1*skill*(skill+1.0) ||\r
+                       (game.state.date-indate) < 3.0);\r
        if (iscate==0 && flag) {\r
                /* compute move away from Enterprise */\r
-               ideltax = state.isx-quadx;\r
-               ideltay = state.isy-quady;\r
+               ideltax = game.state.isx-quadx;\r
+               ideltay = game.state.isy-quady;\r
                if (sqrt(ideltax*(double)ideltax+ideltay*(double)ideltay) > 2.0) {\r
                        /* circulate in space */\r
-                       ideltax = state.isy-quady;\r
-                       ideltay = quadx-state.isx;\r
+                       ideltax = game.state.isy-quady;\r
+                       ideltay = quadx-game.state.isx;\r
                }\r
        }\r
        else {\r
                /* compute distances to starbases */\r
-               if (state.rembase <= 0) {\r
+               if (game.state.rembase <= 0) {\r
                        /* nothing left to do */\r
-                       frozen.future[FSCMOVE] = 1e30;\r
+                       game.future[FSCMOVE] = 1e30;\r
                        return;\r
                }\r
-               sx = state.isx;\r
-               sy = state.isy;\r
-               for (i = 1; i <= state.rembase; i++) {\r
+               sx = game.state.isx;\r
+               sy = game.state.isy;\r
+               for (i = 1; i <= game.state.rembase; i++) {\r
                        basetbl[i] = i;\r
-                       ibqx = state.baseqx[i];\r
-                       ibqy = state.baseqy[i];\r
+                       ibqx = game.state.baseqx[i];\r
+                       ibqy = game.state.baseqy[i];\r
                        bdist[i] = sqrt(square(ibqx-sx) + square(ibqy-sy));\r
                }\r
-               if (state.rembase > 1) {\r
+               if (game.state.rembase > 1) {\r
                        /* sort into nearest first order */\r
                        int iswitch;\r
                        do {\r
                                iswitch = 0;\r
-                               for (i=1; i < state.rembase-1; i++) {\r
+                               for (i=1; i < game.state.rembase-1; i++) {\r
                                        if (bdist[i] > bdist[i+1]) {\r
                                                int ti = basetbl[i];\r
                                                double t = bdist[i];\r
@@ -429,34 +429,34 @@ void scom(int *ipage) {
                   without too many Klingons, and not already under attack. */\r
                ifindit = iwhichb = 0;\r
 \r
-               for (i2 = 1; i2 <= state.rembase; i2++) {\r
+               for (i2 = 1; i2 <= game.state.rembase; i2++) {\r
                        i = basetbl[i2];        /* bug in original had it not finding nearest*/\r
-                       ibqx = state.baseqx[i];\r
-                       ibqy = state.baseqy[i];\r
+                       ibqx = game.state.baseqx[i];\r
+                       ibqy = game.state.baseqy[i];\r
                        if ((ibqx == quadx && ibqy == quady) ||\r
                                (ibqx == batx && ibqy == baty) ||\r
-                               state.galaxy[ibqx][ibqy] > 899) continue;\r
+                               game.state.galaxy[ibqx][ibqy] > 899) continue;\r
                        /* if there is a commander, an no other base is appropriate,\r
                           we will take the one with the commander */\r
-                       for (j = 1; j <= state.remcom; j++) {\r
-                               if (ibqx==state.cx[j] && ibqy==state.cy[j] && ifindit!= 2) {\r
+                       for (j = 1; j <= game.state.remcom; j++) {\r
+                               if (ibqx==game.state.cx[j] && ibqy==game.state.cy[j] && ifindit!= 2) {\r
                                                ifindit = 2;\r
                                                iwhichb = i;\r
                                                break;\r
                                }\r
                        }\r
-                       if (j > state.remcom) { /* no commander -- use this one */\r
+                       if (j > game.state.remcom) { /* no commander -- use this one */\r
                                ifindit = 1;\r
                                iwhichb = i;\r
                                break;\r
                        }\r
                }\r
                if (ifindit==0) return; /* Nothing suitable -- wait until next time*/\r
-               ibqx = state.baseqx[iwhichb];\r
-               ibqy = state.baseqy[iwhichb];\r
+               ibqx = game.state.baseqx[iwhichb];\r
+               ibqy = game.state.baseqy[iwhichb];\r
                /* decide how to move toward base */\r
-               ideltax = ibqx - state.isx;\r
-               ideltay = ibqy - state.isy;\r
+               ideltax = ibqx - game.state.isx;\r
+               ideltay = ibqy - game.state.isy;\r
        }\r
        /* Maximum movement is 1 quadrant in either or both axis */\r
        if (ideltax > 1) ideltax = 1;\r
@@ -465,62 +465,62 @@ void scom(int *ipage) {
        if (ideltay < -1) ideltay = -1;\r
 \r
        /* try moving in both x and y directions */\r
-       iqx = state.isx + ideltax;\r
-       iqy = state.isy + ideltax;\r
+       iqx = game.state.isx + ideltax;\r
+       iqy = game.state.isy + ideltax;\r
        if (checkdest(iqx, iqy, flag, ipage)) {\r
                /* failed -- try some other maneuvers */\r
                if (ideltax==0 || ideltay==0) {\r
                        /* attempt angle move */\r
                        if (ideltax != 0) {\r
-                               iqy = state.isy + 1;\r
+                               iqy = game.state.isy + 1;\r
                                if (checkdest(iqx, iqy, flag, ipage)) {\r
-                                       iqy = state.isy - 1;\r
+                                       iqy = game.state.isy - 1;\r
                                        checkdest(iqx, iqy, flag, ipage);\r
                                }\r
                        }\r
                        else {\r
-                               iqx = state.isx + 1;\r
+                               iqx = game.state.isx + 1;\r
                                if (checkdest(iqx, iqy, flag, ipage)) {\r
-                                       iqx = state.isx - 1;\r
+                                       iqx = game.state.isx - 1;\r
                                        checkdest(iqx, iqy, flag, ipage);\r
                                }\r
                        }\r
                }\r
                else {\r
                        /* try moving just in x or y */\r
-                       iqy = state.isy;\r
+                       iqy = game.state.isy;\r
                        if (checkdest(iqx, iqy, flag, ipage)) {\r
-                               iqy = state.isy + ideltay;\r
-                               iqx = state.isx;\r
+                               iqy = game.state.isy + ideltay;\r
+                               iqx = game.state.isx;\r
                                checkdest(iqx, iqy, flag, ipage);\r
                        }\r
                }\r
        }\r
        /* check for a base */\r
-       if (state.rembase == 0) {\r
-               frozen.future[FSCMOVE] = 1e30;\r
+       if (game.state.rembase == 0) {\r
+               game.future[FSCMOVE] = 1e30;\r
        }\r
-       else for (i=1; i<=state.rembase; i++) {\r
-               ibqx = state.baseqx[i];\r
-               ibqy = state.baseqy[i];\r
-               if (ibqx==state.isx && ibqy == state.isy && state.isx != batx && state.isy != baty) {\r
+       else for (i=1; i<=game.state.rembase; i++) {\r
+               ibqx = game.state.baseqx[i];\r
+               ibqy = game.state.baseqy[i];\r
+               if (ibqx==game.state.isx && ibqy == game.state.isy && game.state.isx != batx && game.state.isy != baty) {\r
                        /* attack the base */\r
                        if (flag) return; /* no, don't attack base! */\r
                        iseenit = 0;\r
                        isatb=1;\r
-                       frozen.future[FSCDBAS] = state.date + 1.0 +2.0*Rand();\r
-                       if (batx != 0) frozen.future[FSCDBAS] += frozen.future[FCDBAS]-state.date;\r
-                       if (frozen.damage[DRADIO] > 0 && condit != IHDOCKED)\r
+                       game.future[FSCDBAS] = game.state.date + 1.0 +2.0*Rand();\r
+                       if (batx != 0) game.future[FSCDBAS] += game.future[FCDBAS]-game.state.date;\r
+                       if (game.damage[DRADIO] > 0 && condit != IHDOCKED)\r
                                return; /* no warning */\r
                        iseenit = 1;\r
                        if (*ipage == 0)  pause(1);\r
                        *ipage=1;\r
                        proutn("Lt. Uhura-  \"Captain, the starbase in");\r
-                       cramlc(1, state.isx, state.isy);\r
+                       cramlc(1, game.state.isx, game.state.isy);\r
                        skip(1);\r
                        prout("   reports that it is under attack from the Klingon Super-commander.");\r
                        proutn("   It can survive until stardate ");\r
-                       cramf(frozen.future[FSCDBAS], 0, 1);\r
+                       cramf(game.future[FSCDBAS], 0, 1);\r
                        prout(" .\"");\r
                        if (resting==0) return;\r
                        prout("Mr. Spock-  \"Captain, shall we cancel the rest period?\"");\r
@@ -536,14 +536,14 @@ void scom(int *ipage) {
                idebug==0 &&\r
 #endif\r
                (Rand() > 0.2 ||\r
-                (frozen.damage[DRADIO] > 0.0 && condit != IHDOCKED) ||\r
-                frozen.starch[state.isx][state.isy] > 0))\r
+                (game.damage[DRADIO] > 0.0 && condit != IHDOCKED) ||\r
+                game.starch[game.state.isx][game.state.isy] > 0))\r
                return;\r
        if (*ipage==0) pause(1);\r
        *ipage = 1;\r
        prout("Lt. Uhura-  \"Captain, Starfleet Intelligence reports");\r
        proutn("   the Super-commander is in");\r
-       cramlc(1, state.isx, state. isy);\r
+       cramlc(1, game.state.isx, game.state. isy);\r
        prout(".\"");\r
        return;\r
 }\r
@@ -572,15 +572,15 @@ void movetho(void) {
        }\r
 \r
        /* Do nothing if we are blocked */\r
-       if (frozen.quad[idx][idy]!= IHDOT && frozen.quad[idx][idy]!= IHWEB) return;\r
-       frozen.quad[ithx][ithy] = IHWEB;\r
+       if (game.quad[idx][idy]!= IHDOT && game.quad[idx][idy]!= IHWEB) return;\r
+       game.quad[ithx][ithy] = IHWEB;\r
 \r
        if (ithx != idx) {\r
                /* move in x axis */\r
                im = fabs((double)idx - ithx)/((double)idx - ithx);\r
                while (ithx != idx) {\r
                        ithx += im;\r
-                       if (frozen.quad[ithx][ithy]==IHDOT) frozen.quad[ithx][ithy] = IHWEB;\r
+                       if (game.quad[ithx][ithy]==IHDOT) game.quad[ithx][ithy] = IHWEB;\r
                }\r
        }\r
        else if (ithy != idy) {\r
@@ -588,20 +588,20 @@ void movetho(void) {
                im = fabs((double)idy - ithy)/((double)idy - ithy);\r
                while (ithy != idy) {\r
                        ithy += im;\r
-                       if (frozen.quad[ithx][ithy]==IHDOT) frozen.quad[ithx][ithy] = IHWEB;\r
+                       if (game.quad[ithx][ithy]==IHDOT) game.quad[ithx][ithy] = IHWEB;\r
                }\r
        }\r
-       frozen.quad[ithx][ithy] = IHT;\r
+       game.quad[ithx][ithy] = IHT;\r
 \r
        /* check to see if all holes plugged */\r
        for (i = 1; i < 11; i++) {\r
-               if (frozen.quad[1][i]!=IHWEB && frozen.quad[1][i]!=IHT) return;\r
-               if (frozen.quad[10][i]!=IHWEB && frozen.quad[10][i]!=IHT) return;\r
-               if (frozen.quad[i][1]!=IHWEB && frozen.quad[i][1]!=IHT) return;\r
-               if (frozen.quad[i][10]!=IHWEB && frozen.quad[i][10]!=IHT) return;\r
+               if (game.quad[1][i]!=IHWEB && game.quad[1][i]!=IHT) return;\r
+               if (game.quad[10][i]!=IHWEB && game.quad[10][i]!=IHT) return;\r
+               if (game.quad[i][1]!=IHWEB && game.quad[i][1]!=IHT) return;\r
+               if (game.quad[i][10]!=IHWEB && game.quad[i][10]!=IHT) return;\r
        }\r
        /* All plugged up -- Tholian splits */\r
-       frozen.quad[ithx][ithy]=IHWEB;\r
+       game.quad[ithx][ithy]=IHWEB;\r
        dropin(IHBLANK, &dum, &my);\r
        crmena(1,IHT, 2, ithx, ithy);\r
        prout(" completes web.");\r
index 11a1ca19a64cf7a420fbe316b8db36c2942ce69a..1f043c61d9700a1dcbccf7ce35ac1dde23e6deec 100644 (file)
--- a/battle.c
+++ b/battle.c
@@ -14,7 +14,7 @@ void doshield(int i) {
                                action = NRG;\r
                        else {\r
                                chew();\r
-                               if (frozen.damage[DSHIELD]) {\r
+                               if (game.damage[DSHIELD]) {\r
                                        prout("Shields damaged and down.");\r
                                        return;\r
                                }\r
@@ -30,7 +30,7 @@ void doshield(int i) {
                                proutn("Energy to transfer to shields- ");\r
                                action = NRG;\r
                        }\r
-                       else if (frozen.damage[DSHIELD]) {\r
+                       else if (game.damage[DSHIELD]) {\r
                                prout("Shields damaged and down.");\r
                                return;\r
                        }\r
@@ -158,12 +158,12 @@ void ram(int ibumpd, int ienm, int ix, int iy) {
        casual += icas;\r
        for (l=1; l <= ndevice; l++) {\r
                if (l == DDRAY) continue; // Don't damage deathray \r
-               if (frozen.damage[l] < 0) continue;\r
+               if (game.damage[l] < 0) continue;\r
                extradm = (10.0*type*Rand()+1.0)*damfac;\r
-               frozen.damage[l] += Time + extradm; /* Damage for at least time of travel! */\r
+               game.damage[l] += Time + extradm; /* Damage for at least time of travel! */\r
        }\r
        shldup = 0;\r
-       if (state.remkl) {\r
+       if (game.state.remkl) {\r
                pause(2);\r
                dreprt();\r
        }\r
@@ -197,7 +197,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit) {
                proutn(" - ");\r
                cramf(y, 0, 1);\r
                proutn("   ");\r
-               iquad=frozen.quad[ix][iy];\r
+               iquad=game.quad[ix][iy];\r
                if (iquad==IHDOT) continue;\r
                /* hit something */\r
                skip(1);\r
@@ -223,11 +223,11 @@ void torpedo(double course, double r, int inx, int iny, double *hit) {
                                jx=ix+xx+0.5;\r
                                jy=iy+yy+0.5;\r
                                if (jx<1 || jx>10 || jy<1 ||jy > 10) return;\r
-                               if (frozen.quad[jx][jy]==IHBLANK) {\r
+                               if (game.quad[jx][jy]==IHBLANK) {\r
                                        finish(FHOLE);\r
                                        return;\r
                                }\r
-                               if (frozen.quad[jx][jy]!=IHDOT) {\r
+                               if (game.quad[jx][jy]!=IHDOT) {\r
                                        /* can't move into object */\r
                                        return;\r
                                }\r
@@ -249,15 +249,15 @@ void torpedo(double course, double r, int inx, int iny, double *hit) {
                        case IHK:\r
                                /* find the enemy */\r
                                for (ll=1; ll <= nenhere; ll++)\r
-                                       if (ix==frozen.kx[ll] && iy==frozen.ky[ll]) break;\r
-                               kp = fabs(frozen.kpower[ll]);\r
+                                       if (ix==game.kx[ll] && iy==game.ky[ll]) break;\r
+                               kp = fabs(game.kpower[ll]);\r
                                h1 = 700.0 + 100.0*Rand() -\r
                                         1000.0*sqrt(square(ix-inx)+square(iy-iny))*\r
                                         fabs(sin(bullseye-angle));\r
                                h1 = fabs(h1);\r
                                if (kp < h1) h1 = kp;\r
-                               frozen.kpower[ll] -= (frozen.kpower[ll]<0 ? -h1 : h1);\r
-                               if (frozen.kpower[ll] == 0) {\r
+                               game.kpower[ll] -= (game.kpower[ll]<0 ? -h1 : h1);\r
+                               if (game.kpower[ll] == 0) {\r
                                        deadkl(ix, iy, iquad, ix, iy);\r
                                        return;\r
                                }\r
@@ -274,47 +274,47 @@ void torpedo(double course, double r, int inx, int iny, double *hit) {
                                        prout(" damaged but not destroyed.");\r
                                        return;\r
                                }\r
-                               if (frozen.quad[jx][jy]==IHBLANK) {\r
+                               if (game.quad[jx][jy]==IHBLANK) {\r
                                        prout(" buffeted into black hole.");\r
                                        deadkl(ix, iy, iquad, jx, jy);\r
                                        return;\r
                                }\r
-                               if (frozen.quad[jx][jy]!=IHDOT) {\r
+                               if (game.quad[jx][jy]!=IHDOT) {\r
                                        /* can't move into object */\r
                                        prout(" damaged but not destroyed.");\r
                                        return;\r
                                }\r
                                prout(" damaged--");\r
-                               frozen.kx[ll] = jx;\r
-                               frozen.ky[ll] = jy;\r
+                               game.kx[ll] = jx;\r
+                               game.ky[ll] = jy;\r
                                shoved = 1;\r
                                break;\r
                        case IHB: /* Hit a base */\r
                                prout("***STARBASE DESTROYED..");\r
-                               if (frozen.starch[quadx][quady] < 0) frozen.starch[quadx][quady] = 0;\r
-                               for (ll=1; ll<=state.rembase; ll++) {\r
-                                       if (state.baseqx[ll]==quadx && state.baseqy[ll]==quady) {\r
-                                               state.baseqx[ll]=state.baseqx[state.rembase];\r
-                                               state.baseqy[ll]=state.baseqy[state.rembase];\r
+                               if (game.starch[quadx][quady] < 0) game.starch[quadx][quady] = 0;\r
+                               for (ll=1; ll<=game.state.rembase; ll++) {\r
+                                       if (game.state.baseqx[ll]==quadx && game.state.baseqy[ll]==quady) {\r
+                                               game.state.baseqx[ll]=game.state.baseqx[game.state.rembase];\r
+                                               game.state.baseqy[ll]=game.state.baseqy[game.state.rembase];\r
                                                break;\r
                                        }\r
                                }\r
-                               frozen.quad[ix][iy]=IHDOT;\r
-                               state.rembase--;\r
+                               game.quad[ix][iy]=IHDOT;\r
+                               game.state.rembase--;\r
                                basex=basey=0;\r
-                               state.galaxy[quadx][quady] -= 10;\r
-                               state.basekl++;\r
+                               game.state.galaxy[quadx][quady] -= 10;\r
+                               game.state.basekl++;\r
                                newcnd();\r
                                return;\r
                        case IHP: /* Hit a planet */\r
                                crmena(1, iquad, 2, ix, iy);\r
                                prout(" destroyed.");\r
-                               state.nplankl++;\r
-                               state.newstuf[quadx][quady] -= 1;\r
-                               state.plnets[iplnet] = nulplanet;\r
+                               game.state.nplankl++;\r
+                               game.state.newstuf[quadx][quady] -= 1;\r
+                               game.state.plnets[iplnet] = nulplanet;\r
                                iplnet = 0;\r
                                plnetx = plnety = 0;\r
-                               frozen.quad[ix][iy] = IHDOT;\r
+                               game.quad[ix][iy] = IHDOT;\r
                                if (landed==1) {\r
                                        /* captain parishes on planet */\r
                                        finish(FDPLANET);\r
@@ -337,7 +337,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit) {
                                proutn("Mr. Spock-");\r
                                prouts("  \"Facinating!\"");\r
                                skip(1);\r
-                               frozen.quad[ix][iy] = IHDOT;\r
+                               game.quad[ix][iy] = IHDOT;\r
                                return;\r
                        case IHBLANK: /* Black hole */\r
                                skip(1);\r
@@ -357,7 +357,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit) {
                                h1 = fabs(h1);\r
                                if (h1 >= 600) {\r
                                        prout(" destroyed.");\r
-                                       frozen.quad[ix][iy] = IHDOT;\r
+                                       game.quad[ix][iy] = IHDOT;\r
                                        ithere = 0;\r
                                        ithx = ithy = 0;\r
                                        return;\r
@@ -367,7 +367,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit) {
                                        return;\r
                                }\r
                                prout(" disappears.");\r
-                               frozen.quad[ix][iy] = IHWEB;\r
+                               game.quad[ix][iy] = IHWEB;\r
                                ithere = ithx = ithy = 0;\r
                                {\r
                                        int dum, my;\r
@@ -385,13 +385,13 @@ void torpedo(double course, double r, int inx, int iny, double *hit) {
                break;\r
        }\r
        if (shoved) {\r
-               frozen.quad[jx][jy]=iquad;\r
-               frozen.quad[ix][iy]=IHDOT;\r
+               game.quad[jx][jy]=iquad;\r
+               game.quad[ix][iy]=IHDOT;\r
                proutn(" displaced by blast to");\r
                cramlc(2, jx, jy);\r
                skip(1);\r
                for (ll=1; ll<=nenhere; ll++)\r
-                       frozen.kdist[ll] = frozen.kavgd[ll] = sqrt(square(sectx-frozen.kx[ll])+square(secty-frozen.ky[ll]));\r
+                       game.kdist[ll] = game.kavgd[ll] = sqrt(square(sectx-game.kx[ll])+square(secty-game.ky[ll]));\r
                sortkl();\r
                return;\r
        }\r
@@ -414,11 +414,11 @@ static void fry(double hit) {
                do {\r
                        j = ndevice*Rand()+1.0;\r
                        /* Cheat to prevent shuttle damage unless on ship */\r
-               } while (frozen.damage[j] < 0.0 || (j == DSHUTTL && iscraft != 1) ||\r
+               } while (game.damage[j] < 0.0 || (j == DSHUTTL && iscraft != 1) ||\r
                                 j == DDRAY);\r
                cdam[l] = j;\r
                extradm = (hit*damfac)/(ncrit*(75.0+25.0*Rand()));\r
-               frozen.damage[j] += extradm;\r
+               game.damage[j] += extradm;\r
                if (l > 1) {\r
                        for (ll=2; ll<=l && j != cdam[ll-1]; ll++) ;\r
                        if (ll<=l) continue;\r
@@ -429,7 +429,7 @@ static void fry(double hit) {
                proutn(device[j]);\r
        }\r
        prout(" damaged.");\r
-       if (frozen.damage[DSHIELD] && shldup) {\r
+       if (game.damage[DSHIELD] && shldup) {\r
                prout("***Shields knocked down.");\r
                shldup=0;\r
        }\r
@@ -461,15 +461,15 @@ void attack(int k) {
        skip(1);\r
        if (skill <= 2) i = 2;\r
        for (l=1; l <= nenhere; l++) {\r
-               if (frozen.kpower[l] < 0) continue;     /* too weak to attack */\r
+               if (game.kpower[l] < 0) continue;       /* too weak to attack */\r
                /* compute hit strength and diminsh shield power */\r
                r = Rand();\r
                /* Increase chance of photon torpedos if docked or enemy energy low */\r
                if (condit == IHDOCKED) r *= 0.25;\r
-               if (frozen.kpower[l] < 500) r *= 0.25; \r
-               jx = frozen.kx[l];\r
-               jy = frozen.ky[l];\r
-               iquad = frozen.quad[jx][jy];\r
+               if (game.kpower[l] < 500) r *= 0.25; \r
+               jx = game.kx[l];\r
+               jy = game.ky[l];\r
+               iquad = game.quad[jx][jy];\r
                itflag = (iquad == IHK && r > 0.0005) || k == 0 ||\r
                        (iquad==IHC && r > 0.015) ||\r
                        (iquad==IHR && r > 0.3) ||\r
@@ -479,24 +479,24 @@ void attack(int k) {
                        if (condit == IHDOCKED) continue; /* Don't waste the effort! */\r
                        attempt = 1; /* Attempt to attack */\r
                        dustfac = 0.8+0.05*Rand();\r
-                       hit = frozen.kpower[l]*pow(dustfac,frozen.kavgd[l]);\r
-                       frozen.kpower[l] *= 0.75;\r
+                       hit = game.kpower[l]*pow(dustfac,game.kavgd[l]);\r
+                       game.kpower[l] *= 0.75;\r
                }\r
                else { /* Enemy used photon torpedo */\r
                        double course = 1.90985*atan2((double)secty-jy, (double)jx-sectx);\r
                        hit = 0;\r
                        proutn("***TORPEDO INCOMING");\r
-                       if (frozen.damage[DSRSENS] <= 0.0) {\r
+                       if (game.damage[DSRSENS] <= 0.0) {\r
                                proutn(" From ");\r
                                crmena(0, iquad, i, jx, jy);\r
                        }\r
                        attempt = 1;\r
                        prout("--");\r
                        r = (Rand()+Rand())*0.5 -0.5;\r
-                       r += 0.002*frozen.kpower[l]*r;\r
+                       r += 0.002*game.kpower[l]*r;\r
                        torpedo(course, r, jx, jy, &hit);\r
-                       if (state.remkl==0) finish(FWON); /* Klingons did themselves in! */\r
-                       if (state.galaxy[quadx][quady] == 1000 ||\r
+                       if (game.state.remkl==0) finish(FWON); /* Klingons did themselves in! */\r
+                       if (game.state.galaxy[quadx][quady] == 1000 ||\r
                                alldone) return; /* Supernova or finished */\r
                        if (hit == 0) continue;\r
                }\r
@@ -519,11 +519,11 @@ void attack(int k) {
                ihurt = 1;\r
                cramf(hit, 0, 2);\r
                proutn(" unit hit");\r
-               if ((frozen.damage[DSRSENS] > 0 && itflag) || skill <= 2) {\r
+               if ((game.damage[DSRSENS] > 0 && itflag) || skill <= 2) {\r
                        proutn(" on the ");\r
                        crmshp();\r
                }\r
-               if (frozen.damage[DSRSENS] <= 0.0 && itflag) {\r
+               if (game.damage[DSRSENS] <= 0.0 && itflag) {\r
                        proutn(" from ");\r
                        crmena(0, iquad, i, jx, jy);\r
                }\r
@@ -555,7 +555,7 @@ void attack(int k) {
                cramf(energy, 0, 2);\r
                proutn("    shields ");\r
                if (shldup) proutn("up, ");\r
-               else if (frozen.damage[DSHIELD] == 0) proutn("down, ");\r
+               else if (game.damage[DSHIELD] == 0) proutn("down, ");\r
                else proutn("damaged, ");\r
        }\r
        crami(percent, 1);\r
@@ -576,7 +576,7 @@ void attack(int k) {
        }\r
        /* After attack, reset average distance to enemies */\r
        for (l = 1; l <= nenhere; l++)\r
-               frozen.kavgd[l] = frozen.kdist[l];\r
+               game.kavgd[l] = game.kdist[l];\r
        sortkl();\r
        return;\r
 }\r
@@ -590,10 +590,10 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) {
        /* Decide what kind of enemy it is and update approriately */\r
        if (type == IHR) {\r
                /* chalk up a Romulan */\r
-               state.newstuf[quadx][quady] -= 10;\r
+               game.state.newstuf[quadx][quady] -= 10;\r
                irhere--;\r
-               state.nromkl++;\r
-               state.nromrem--;\r
+               game.state.nromkl++;\r
+               game.state.nromrem--;\r
        }\r
        else if (type == IHT) {\r
                /* Killed a Tholian */\r
@@ -601,62 +601,62 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) {
        }\r
        else {\r
                /* Some type of a Klingon */\r
-               state.galaxy[quadx][quady] -= 100;\r
+               game.state.galaxy[quadx][quady] -= 100;\r
                klhere--;\r
-               state.remkl--;\r
+               game.state.remkl--;\r
                switch (type) {\r
                        case IHC:\r
                                comhere = 0;\r
-                               for (i=1; i<=state.remcom; i++)\r
-                                       if (state.cx[i]==quadx && state.cy[i]==quady) break;\r
-                               state.cx[i] = state.cx[state.remcom];\r
-                               state.cy[i] = state.cy[state.remcom];\r
-                               state.cx[state.remcom] = 0;\r
-                               state.cy[state.remcom] = 0;\r
-                               state.remcom--;\r
-                               frozen.future[FTBEAM] = 1e30;\r
-                               if (state.remcom != 0)\r
-                                       frozen.future[FTBEAM] = state.date + expran(1.0*incom/state.remcom);\r
-                               state.killc++;\r
+                               for (i=1; i<=game.state.remcom; i++)\r
+                                       if (game.state.cx[i]==quadx && game.state.cy[i]==quady) break;\r
+                               game.state.cx[i] = game.state.cx[game.state.remcom];\r
+                               game.state.cy[i] = game.state.cy[game.state.remcom];\r
+                               game.state.cx[game.state.remcom] = 0;\r
+                               game.state.cy[game.state.remcom] = 0;\r
+                               game.state.remcom--;\r
+                               game.future[FTBEAM] = 1e30;\r
+                               if (game.state.remcom != 0)\r
+                                       game.future[FTBEAM] = game.state.date + expran(1.0*incom/game.state.remcom);\r
+                               game.state.killc++;\r
                                break;\r
                        case IHK:\r
-                               state.killk++;\r
+                               game.state.killk++;\r
                                break;\r
                        case IHS:\r
-                               state.nscrem = ishere = state.isx = state.isy = isatb = iscate = 0;\r
-                               state.nsckill = 1;\r
-                               frozen.future[FSCMOVE] = frozen.future[FSCDBAS] = 1e30;\r
+                               game.state.nscrem = ishere = game.state.isx = game.state.isy = isatb = iscate = 0;\r
+                               game.state.nsckill = 1;\r
+                               game.future[FSCMOVE] = game.future[FSCDBAS] = 1e30;\r
                                break;\r
                }\r
        }\r
 \r
        /* For each kind of enemy, finish message to player */\r
        prout(" destroyed.");\r
-       frozen.quad[ix][iy] = IHDOT;\r
-       if (state.remkl==0) return;\r
+       game.quad[ix][iy] = IHDOT;\r
+       if (game.state.remkl==0) return;\r
 \r
-       state.remtime = state.remres/(state.remkl + 4*state.remcom);\r
+       game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom);\r
 \r
        if (type == IHT) return;\r
 \r
        /* Remove enemy ship from arrays describing local conditions */\r
 \r
        for (i=1; i<=nenhere; i++)\r
-               if (frozen.kx[i]==ix && frozen.ky[i]==iy) break;\r
+               if (game.kx[i]==ix && game.ky[i]==iy) break;\r
        nenhere--;\r
        if (i <= nenhere)  {\r
                for (j=i; j<=nenhere; j++) {\r
-                       frozen.kx[j] = frozen.kx[j+1];\r
-                       frozen.ky[j] = frozen.ky[j+1];\r
-                       frozen.kpower[j] = frozen.kpower[j+1];\r
-                       frozen.kavgd[j] = frozen.kdist[j] = frozen.kdist[j+1];\r
+                       game.kx[j] = game.kx[j+1];\r
+                       game.ky[j] = game.ky[j+1];\r
+                       game.kpower[j] = game.kpower[j+1];\r
+                       game.kavgd[j] = game.kdist[j] = game.kdist[j+1];\r
                }\r
        }\r
-       frozen.kx[nenhere+1] = 0;\r
-       frozen.ky[nenhere+1] = 0;\r
-       frozen.kdist[nenhere+1] = 0;\r
-       frozen.kavgd[nenhere+1] = 0;\r
-       frozen.kpower[nenhere+1] = 0;\r
+       game.kx[nenhere+1] = 0;\r
+       game.ky[nenhere+1] = 0;\r
+       game.kdist[nenhere+1] = 0;\r
+       game.kavgd[nenhere+1] = 0;\r
+       game.kpower[nenhere+1] = 0;\r
        return;\r
 }\r
 \r
@@ -688,7 +688,7 @@ void photon(void) {
 \r
        ididit = 0;\r
 \r
-       if (frozen.damage[DPHOTON]) {\r
+       if (game.damage[DPHOTON]) {\r
                prout("Photon tubes damaged.");\r
                chew();\r
                return;\r
@@ -798,7 +798,7 @@ void photon(void) {
                        osuabor=1;\r
                        if (Rand() <= 0.2) {\r
                                prout("***Photon tubes damaged by misfire.");\r
-                               frozen.damage[DPHOTON] = damfac*(1.0+2.0*Rand());\r
+                               game.damage[DPHOTON] = damfac*(1.0+2.0*Rand());\r
                                break;\r
                        }\r
                }\r
@@ -814,9 +814,9 @@ void photon(void) {
                        proutn("Torpedo track- ");\r
                }\r
                torpedo(course[i], r, sectx, secty, &dummy);\r
-               if (alldone || state.galaxy[quadx][quady]==1000) return;\r
+               if (alldone || game.state.galaxy[quadx][quady]==1000) return;\r
        }\r
-       if (state.remkl==0) finish(FWON);\r
+       if (game.state.remkl==0) finish(FWON);\r
 }\r
 \r
        \r
@@ -826,7 +826,7 @@ static void overheat(double rpow) {
                double chekbrn = (rpow-1500.)*0.00038;\r
                if (Rand() <= chekbrn) {\r
                        prout("Weapons officer Sulu-  \"Phasers overheated, sir.\"");\r
-                       frozen.damage[DPHASER] = damfac*(1.0 + Rand()) * (1.0+chekbrn);\r
+                       game.damage[DPHASER] = damfac*(1.0 + Rand()) * (1.0+chekbrn);\r
                }\r
        }\r
 }\r
@@ -884,19 +884,19 @@ void phasers(void) {
 \r
        skip(1);\r
        /* SR sensors and Computer */\r
-       if (frozen.damage[DSRSENS]+frozen.damage[DCOMPTR] > 0) ipoop = 0;\r
+       if (game.damage[DSRSENS]+game.damage[DCOMPTR] > 0) ipoop = 0;\r
        if (condit == IHDOCKED) {\r
                prout("Phasers can't be fired through base shields.");\r
                chew();\r
                return;\r
        }\r
-       if (frozen.damage[DPHASER] != 0) {\r
+       if (game.damage[DPHASER] != 0) {\r
                prout("Phaser control damaged.");\r
                chew();\r
                return;\r
        }\r
        if (shldup) {\r
-               if (frozen.damage[DSHCTRL]) {\r
+               if (game.damage[DSHCTRL]) {\r
                        prout("High speed shield control damaged.");\r
                        chew();\r
                        return;\r
@@ -1017,7 +1017,7 @@ void phasers(void) {
                                for (i = 1; i <= nenhere; i++) {\r
                                        hits[i] = 0.0;\r
                                        if (powrem <= 0) continue;\r
-                                       hits[i] = fabs(frozen.kpower[i])/(phasefac*pow(0.90,frozen.kdist[i]));\r
+                                       hits[i] = fabs(game.kpower[i])/(phasefac*pow(0.90,game.kdist[i]));\r
                                        over = (0.01 + 0.05*Rand())*hits[i];\r
                                        temp = powrem;\r
                                        powrem -= hits[i] + over;\r
@@ -1044,7 +1044,7 @@ void phasers(void) {
                case FORCEMAN:\r
                        chew();\r
                        key = IHEOL;\r
-                       if (frozen.damage[DCOMPTR]!=0)\r
+                       if (game.damage[DCOMPTR]!=0)\r
                                prout("Battle comuter damaged, manual file only.");\r
                        else {\r
                                skip(1);\r
@@ -1058,8 +1058,8 @@ void phasers(void) {
                case MANUAL:\r
                        rpow = 0.0;\r
                        for (k = 1; k <= nenhere;) {\r
-                               int ii = frozen.kx[k], jj = frozen.ky[k];\r
-                               int ienm = frozen.quad[ii][jj];\r
+                               int ii = game.kx[k], jj = game.ky[k];\r
+                               int ienm = game.quad[ii][jj];\r
                                if (msgflag) {\r
                                        proutn("Energy available= ");\r
                                        cramf(energy-.006-(ifast?200:0), 0, 2);\r
@@ -1067,7 +1067,7 @@ void phasers(void) {
                                        msgflag = 0;\r
                                        rpow = 0.0;\r
                                }\r
-                               if (frozen.damage[DSRSENS] && !(abs(sectx-ii) < 2 && abs(secty-jj) < 2) &&\r
+                               if (game.damage[DSRSENS] && !(abs(sectx-ii) < 2 && abs(secty-jj) < 2) &&\r
                                        (ienm == IHC || ienm == IHS)) {\r
                                        cramen(ienm);\r
                                        prout(" can't be located without short range scan.");\r
@@ -1080,7 +1080,7 @@ void phasers(void) {
                                if (key == IHEOL) {\r
                                        chew();\r
                                        if (ipoop && k > kz) {\r
-                                               int irec=(fabs(frozen.kpower[k])/(phasefac*pow(0.9,frozen.kdist[k])))*\r
+                                               int irec=(fabs(game.kpower[k])/(phasefac*pow(0.9,game.kdist[k])))*\r
                                                                 (1.01+0.05*Rand()) + 1.0;\r
                                                kz = k;\r
                                                proutn("(");\r
@@ -1176,26 +1176,26 @@ void hittem(double *hits) {
        for (; k <= nenhr2; k++, kk++) {\r
                if ((wham = hits[k])==0) continue;\r
                dustfac = 0.9 + 0.01*Rand();\r
-               hit = wham*pow(dustfac,frozen.kdist[kk]);\r
-               kpini = frozen.kpower[kk];\r
+               hit = wham*pow(dustfac,game.kdist[kk]);\r
+               kpini = game.kpower[kk];\r
                kp = fabs(kpini);\r
                if (phasefac*hit < kp) kp = phasefac*hit;\r
-               frozen.kpower[kk] -= (frozen.kpower[kk] < 0 ? -kp: kp);\r
-               kpow = frozen.kpower[kk];\r
-               ii = frozen.kx[kk];\r
-               jj = frozen.ky[kk];\r
+               game.kpower[kk] -= (game.kpower[kk] < 0 ? -kp: kp);\r
+               kpow = game.kpower[kk];\r
+               ii = game.kx[kk];\r
+               jj = game.ky[kk];\r
                if (hit > 0.005) {\r
                        cramf(hit, 0, 2);\r
                        proutn(" unit hit on ");\r
                }\r
                else\r
                        proutn("Very small hit on ");\r
-               ienm = frozen.quad[ii][jj];\r
+               ienm = game.quad[ii][jj];\r
                crmena(0,ienm,2,ii,jj);\r
                skip(1);\r
                if (kpow == 0) {\r
                        deadkl(ii, jj, ienm, ii, jj);\r
-                       if (state.remkl==0) finish(FWON);\r
+                       if (game.state.remkl==0) finish(FWON);\r
                        if (alldone) return;\r
                        kk--; /* don't do the increment */\r
                }\r
@@ -1206,7 +1206,7 @@ void hittem(double *hits) {
                                cramlc(2,ii,jj);\r
                                skip(1);\r
                                prout("   has just lost its firepower.\"");\r
-                               frozen.kpower[kk] = -kpow;\r
+                               game.kpower[kk] = -kpow;\r
                        }\r
        }\r
        return;\r
index 99591deca7b930793c69d4e7ff8a1a04616e205f..1fad7134a47b2b0ae5acbdf5e1059003826e05b3 100644 (file)
--- a/events.c
+++ b/events.c
@@ -4,19 +4,19 @@
 void events(void) {\r
 \r
        int ictbeam=0, ipage=0, istract=0, line, i, j, k, l, ixhold, iyhold;\r
-       double fintim = state.date + Time, datemin, xtime, repair, yank;\r
+       double fintim = game.state.date + Time, datemin, xtime, repair, yank;\r
        \r
 \r
 #ifdef DEBUG\r
        if (idebug) prout("EVENTS");\r
 #endif\r
 \r
-       if (stdamtim == 1e30 && frozen.damage[DRADIO] != 0.0) {\r
+       if (stdamtim == 1e30 && game.damage[DRADIO] != 0.0) {\r
                /* chart will no longer be updated because radio is dead */\r
-               stdamtim = state.date;\r
+               stdamtim = game.state.date;\r
                for (i=1; i <= 8 ; i++)\r
                        for (j=1; j <= 8; j++)\r
-                               if (frozen.starch[i][j] == 1) frozen.starch[i][j] = state.galaxy[i][j]+1000;\r
+                               if (game.starch[i][j] == 1) game.starch[i][j] = game.state.galaxy[i][j]+1000;\r
        }\r
 \r
        for (;;) {\r
@@ -25,44 +25,44 @@ void events(void) {
                if (alldone) return;\r
                datemin = fintim;\r
                for (l=1; l<=NEVENTS; l++)\r
-                       if (frozen.future[l] <= datemin) {\r
+                       if (game.future[l] <= datemin) {\r
                                line = l;\r
-                               datemin = frozen.future[l];\r
+                               datemin = game.future[l];\r
                        }\r
-               xtime = datemin-state.date;\r
-               state.date = datemin;\r
+               xtime = datemin-game.state.date;\r
+               game.state.date = datemin;\r
                /* Decrement Federation resources and recompute remaining time */\r
-               state.remres -= (state.remkl+4*state.remcom)*xtime;\r
-               state.remtime = state.remres/(state.remkl+4*state.remcom);\r
-               if (state.remtime <=0) {\r
+               game.state.remres -= (game.state.remkl+4*game.state.remcom)*xtime;\r
+               game.state.remtime = game.state.remres/(game.state.remkl+4*game.state.remcom);\r
+               if (game.state.remtime <=0) {\r
                        finish(FDEPLETE);\r
                        return;\r
                }\r
                /* Is life support adequate? */\r
-               if (frozen.damage[DLIFSUP] && condit != IHDOCKED) {\r
-                       if (lsupres < xtime && frozen.damage[DLIFSUP] > lsupres) {\r
+               if (game.damage[DLIFSUP] && condit != IHDOCKED) {\r
+                       if (lsupres < xtime && game.damage[DLIFSUP] > lsupres) {\r
                                finish(FLIFESUP);\r
                                return;\r
                        }\r
                        lsupres -= xtime;\r
-                       if (frozen.damage[DLIFSUP] <= xtime) lsupres = inlsr;\r
+                       if (game.damage[DLIFSUP] <= xtime) lsupres = inlsr;\r
                }\r
                /* Fix devices */\r
                repair = xtime;\r
                if (condit == IHDOCKED) repair /= docfac;\r
                /* Don't fix Deathray here */\r
                for (l=1; l<=ndevice; l++)\r
-                       if (frozen.damage[l] > 0.0 && l != DDRAY)\r
-                               frozen.damage[l] -= (frozen.damage[l]-repair > 0.0 ? repair : frozen.damage[l]);\r
+                       if (game.damage[l] > 0.0 && l != DDRAY)\r
+                               game.damage[l] -= (game.damage[l]-repair > 0.0 ? repair : game.damage[l]);\r
                /* If radio repaired, update star chart and attack reports */\r
-               if (stdamtim != 1e30 && frozen.damage[DRADIO] == 0.0) {\r
+               if (stdamtim != 1e30 && game.damage[DRADIO] == 0.0) {\r
                        stdamtim = 1e30;\r
                        prout("Lt. Uhura- \"Captain, the sub-space radio is working and");\r
                        prout("   surveillance reports are coming in.");\r
                        skip(1);\r
                        for (i=1; i <= 8 ; i++)\r
                                for (j=1; j <= 8; j++)\r
-                                       if (frozen.starch[i][j] > 999) frozen.starch[i][j] = 1;\r
+                                       if (game.starch[i][j] > 999) game.starch[i][j] = 1;\r
                        if (iseenit==0) {\r
                                attakreport();\r
                                iseenit = 1;\r
@@ -78,37 +78,37 @@ void events(void) {
                                if (ipage==0) pause(1);\r
                                ipage=1;\r
                                snova(0,0);\r
-                               frozen.future[FSNOVA] = state.date + expran(0.5*intime);\r
-                               if (state.galaxy[quadx][quady] == 1000) return;\r
+                               game.future[FSNOVA] = game.state.date + expran(0.5*intime);\r
+                               if (game.state.galaxy[quadx][quady] == 1000) return;\r
                                break;\r
                        case FSPY: /* Check with spy to see if S.C. should tractor beam */\r
-                               if (state.nscrem == 0 ||\r
+                               if (game.state.nscrem == 0 ||\r
                                        ictbeam+istract > 0 ||\r
                                        condit==IHDOCKED || isatb==1 || iscate==1) return;\r
                                if (ientesc ||\r
                                        (energy < 2000 && torps < 4 && shield < 1250) ||\r
-                                       (frozen.damage[DPHASER]>0 && (frozen.damage[DPHOTON]>0 || torps < 4)) ||\r
-                                       (frozen.damage[DSHIELD] > 0 &&\r
-                                        (energy < 2500 || frozen.damage[DPHASER] > 0) &&\r
-                                        (torps < 5 || frozen.damage[DPHOTON] > 0))) {\r
+                                       (game.damage[DPHASER]>0 && (game.damage[DPHOTON]>0 || torps < 4)) ||\r
+                                       (game.damage[DSHIELD] > 0 &&\r
+                                        (energy < 2500 || game.damage[DPHASER] > 0) &&\r
+                                        (torps < 5 || game.damage[DPHOTON] > 0))) {\r
                                        /* Tractor-beam her! */\r
                                        istract=1;\r
-                                       yank = square(state.isx-quadx) + square(state.isy-quady);\r
+                                       yank = square(game.state.isx-quadx) + square(game.state.isy-quady);\r
                                        /*********TBEAM CODE***********/\r
                                }\r
                                else return;\r
                        case FTBEAM: /* Tractor beam */\r
                                if (line==FTBEAM) {\r
-                                       if (state.remcom == 0) {\r
-                                               frozen.future[FTBEAM] = 1e30;\r
+                                       if (game.state.remcom == 0) {\r
+                                               game.future[FTBEAM] = 1e30;\r
                                                break;\r
                                        }\r
-                                       i = Rand()*state.remcom+1.0;\r
-                                       yank = square(state.cx[i]-quadx) + square(state.cy[i]-quady);\r
+                                       i = Rand()*game.state.remcom+1.0;\r
+                                       yank = square(game.state.cx[i]-quadx) + square(game.state.cy[i]-quady);\r
                                        if (istract || condit == IHDOCKED || yank == 0) {\r
                                                /* Drats! Have to reschedule */\r
-                                               frozen.future[FTBEAM] = state.date + Time +\r
-                                                                                expran(1.5*intime/state.remcom);\r
+                                               game.future[FTBEAM] = game.state.date + Time +\r
+                                                                                expran(1.5*intime/game.state.remcom);\r
                                                break;\r
                                        }\r
                                }\r
@@ -135,7 +135,7 @@ void events(void) {
                                        if (Rand() >0.5) {\r
                                                prout("Galileo, left on the planet surface, is captured");\r
                                                prout("by aliens and made into a flying McDonald's.");\r
-                                               frozen.damage[DSHUTTL] = -10;\r
+                                               game.damage[DSHUTTL] = -10;\r
                                                iscraft = -1;\r
                                        }\r
                                        else {\r
@@ -143,12 +143,12 @@ void events(void) {
                                        }\r
                                }\r
                                if (line==0) {\r
-                                       quadx = state.isx;\r
-                                       quady = state.isy;\r
+                                       quadx = game.state.isx;\r
+                                       quady = game.state.isy;\r
                                }\r
                                else {\r
-                                       quadx = state.cx[i];\r
-                                       quady = state.cy[i];\r
+                                       quadx = game.state.cx[i];\r
+                                       quady = game.state.cy[i];\r
                                }\r
                                iran10(&sectx, &secty);\r
                                crmshp();\r
@@ -158,11 +158,11 @@ void events(void) {
                                cramlc(2, sectx, secty);\r
                                skip(1);\r
                                if (resting) {\r
-                                       prout("(Remainder of rest/repair period cancellestate.)");\r
+                                       prout("(Remainder of rest/repair period cancellegame.state.)");\r
                                        resting = 0;\r
                                }\r
                                if (shldup==0) {\r
-                                       if (frozen.damage[DSHIELD]==0 && shield > 0) {\r
+                                       if (game.damage[DSHIELD]==0 && shield > 0) {\r
                                                doshield(2); /* Shldsup */\r
                                                shldchg=0;\r
                                        }\r
@@ -170,47 +170,47 @@ void events(void) {
                                }\r
                                newqad(0);\r
                                /* Adjust finish time to time of tractor beaming */\r
-                               fintim = state.date+Time;\r
-                               if (state.remcom <= 0) frozen.future[FTBEAM] = 1e30;\r
-                               else frozen.future[FTBEAM] = state.date+Time+expran(1.5*intime/state.remcom);\r
+                               fintim = game.state.date+Time;\r
+                               if (game.state.remcom <= 0) game.future[FTBEAM] = 1e30;\r
+                               else game.future[FTBEAM] = game.state.date+Time+expran(1.5*intime/game.state.remcom);\r
                                break;\r
                        case FSNAP: /* Snapshot of the universe (for time warp) */\r
-                               snapsht = state;\r
-                               state.snap = 1;\r
-                               frozen.future[FSNAP] = state.date + expran(0.5 * intime);\r
+                               game.snapsht = game.state;\r
+                               game.state.snap = 1;\r
+                               game.future[FSNAP] = game.state.date + expran(0.5 * intime);\r
                                break;\r
                        case FBATTAK: /* Commander attacks starbase */\r
-                               if (state.remcom==0 || state.rembase==0) {\r
+                               if (game.state.remcom==0 || game.state.rembase==0) {\r
                                        /* no can do */\r
-                                       frozen.future[FBATTAK] = frozen.future[FCDBAS] = 1e30;\r
+                                       game.future[FBATTAK] = game.future[FCDBAS] = 1e30;\r
                                        break;\r
                                }\r
                                i = 0;\r
-                               for (j=1; j<=state.rembase; j++) {\r
-                                       for (k=1; k<=state.remcom; k++)\r
-                                               if (state.baseqx[j]==state.cx[k] && state.baseqy[j]==state.cy[k] &&\r
-                                                       (state.baseqx[j]!=quadx || state.baseqy[j]!=quady) &&\r
-                                                       (state.baseqx[j]!=state.isx || state.baseqy[j]!=state.isy)) {\r
+                               for (j=1; j<=game.state.rembase; j++) {\r
+                                       for (k=1; k<=game.state.remcom; k++)\r
+                                               if (game.state.baseqx[j]==game.state.cx[k] && game.state.baseqy[j]==game.state.cy[k] &&\r
+                                                       (game.state.baseqx[j]!=quadx || game.state.baseqy[j]!=quady) &&\r
+                                                       (game.state.baseqx[j]!=game.state.isx || game.state.baseqy[j]!=game.state.isy)) {\r
                                                        i = 1;\r
                                                        break;\r
                                                }\r
                                        if (i == 1) break;\r
                                }\r
-                               if (j>state.rembase) {\r
+                               if (j>game.state.rembase) {\r
                                        /* no match found -- try later */\r
-                                       frozen.future[FBATTAK] = state.date + expran(0.3*intime);\r
-                                       frozen.future[FCDBAS] = 1e30;\r
+                                       game.future[FBATTAK] = game.state.date + expran(0.3*intime);\r
+                                       game.future[FCDBAS] = 1e30;\r
                                        break;\r
                                }\r
                                /* commander + starbase combination found -- launch attack */\r
-                               batx = state.baseqx[j];\r
-                               baty = state.baseqy[j];\r
-                               frozen.future[FCDBAS] = state.date+1.0+3.0*Rand();\r
+                               batx = game.state.baseqx[j];\r
+                               baty = game.state.baseqy[j];\r
+                               game.future[FCDBAS] = game.state.date+1.0+3.0*Rand();\r
                                if (isatb) /* extra time if SC already attacking */\r
-                                       frozen.future[FCDBAS] += frozen.future[FSCDBAS]-state.date;\r
-                               frozen.future[FBATTAK] = frozen.future[FCDBAS] +expran(0.3*intime);\r
+                                       game.future[FCDBAS] += game.future[FSCDBAS]-game.state.date;\r
+                               game.future[FBATTAK] = game.future[FCDBAS] +expran(0.3*intime);\r
                                iseenit = 0;\r
-                               if (frozen.damage[DRADIO] != 0.0 &&\r
+                               if (game.damage[DRADIO] != 0.0 &&\r
                                        condit != IHDOCKED) break; /* No warning :-( */\r
                                iseenit = 1;\r
                                if (ipage==0) pause(1);\r
@@ -221,7 +221,7 @@ void events(void) {
                                skip(1);\r
                                prout("   reports that it is under atttack and that it can");\r
                                proutn("   hold out only until stardate ");\r
-                               cramf(frozen.future[FCDBAS],1,1);\r
+                               cramf(game.future[FCDBAS],1,1);\r
                                prout(".\"");\r
                                if (resting) {\r
                                        skip(1);\r
@@ -234,21 +234,21 @@ void events(void) {
                                }\r
                                break;\r
                        case FSCDBAS: /* Supercommander destroys base */\r
-                               frozen.future[FSCDBAS] = 1e30;\r
+                               game.future[FSCDBAS] = 1e30;\r
                                isatb = 2;\r
-                               if (state.galaxy[state.isx][state.isy]%100 < 10) break; /* WAS RETURN! */\r
+                               if (game.state.galaxy[game.state.isx][game.state.isy]%100 < 10) break; /* WAS RETURN! */\r
                                ixhold = batx;\r
                                iyhold = baty;\r
-                               batx = state.isx;\r
-                               baty = state.isy;\r
+                               batx = game.state.isx;\r
+                               baty = game.state.isy;\r
                        case FCDBAS: /* Commander succeeds in destroying base */\r
                                if (line==FCDBAS) {\r
-                                       frozen.future[FCDBAS] = 1e30;\r
+                                       game.future[FCDBAS] = 1e30;\r
                                        /* find the lucky pair */\r
-                                       for (i = 1; i <= state.remcom; i++)\r
-                                               if (state.cx[i]==batx && state.cy[i]==baty) break;\r
-                                       if (i > state.remcom || state.rembase == 0 ||\r
-                                               state.galaxy[batx][baty] % 100 < 10) {\r
+                                       for (i = 1; i <= game.state.remcom; i++)\r
+                                               if (game.state.cx[i]==batx && game.state.cy[i]==baty) break;\r
+                                       if (i > game.state.remcom || game.state.rembase == 0 ||\r
+                                               game.state.galaxy[batx][baty] % 100 < 10) {\r
                                                /* No action to take after all */\r
                                                batx = baty = 0;\r
                                                break;\r
@@ -256,18 +256,18 @@ void events(void) {
                                }\r
                                /* Code merges here for any commander destroying base */\r
                                /* Not perfect, but will have to do */\r
-                               if (frozen.starch[batx][baty] == -1) frozen.starch[batx][baty] = 0;\r
+                               if (game.starch[batx][baty] == -1) game.starch[batx][baty] = 0;\r
                                /* Handle case where base is in same quadrant as starship */\r
                                if (batx==quadx && baty==quady) {\r
-                                       if (frozen.starch[batx][baty] > 999) frozen.starch[batx][baty] -= 10;\r
-                                       frozen.quad[basex][basey]= IHDOT;\r
+                                       if (game.starch[batx][baty] > 999) game.starch[batx][baty] -= 10;\r
+                                       game.quad[basex][basey]= IHDOT;\r
                                        basex=basey=0;\r
                                        newcnd();\r
                                        skip(1);\r
-                                       prout("Spock-  \"Captain, I believe the starbase has been destroyestate.\"");\r
+                                       prout("Spock-  \"Captain, I believe the starbase has been destroyegame.state.\"");\r
                                }\r
-                               else if (state.rembase != 1 &&\r
-                                                (frozen.damage[DRADIO] <= 0.0 || condit == IHDOCKED)) {\r
+                               else if (game.state.rembase != 1 &&\r
+                                                (game.damage[DRADIO] <= 0.0 || condit == IHDOCKED)) {\r
                                        /* Get word via subspace radio */\r
                                        if (ipage==0) pause(1);\r
                                        ipage = 1;\r
@@ -280,13 +280,13 @@ void events(void) {
                                        else prout("a Klingon Commander");\r
                                }\r
                                /* Remove Starbase from galaxy */\r
-                               state.galaxy[batx][baty] -= 10;\r
-                               for (i=1; i <= state.rembase; i++)\r
-                                       if (state.baseqx[i]==batx && state.baseqy[i]==baty) {\r
-                                               state.baseqx[i]=state.baseqx[state.rembase];\r
-                                               state.baseqy[i]=state.baseqy[state.rembase];\r
+                               game.state.galaxy[batx][baty] -= 10;\r
+                               for (i=1; i <= game.state.rembase; i++)\r
+                                       if (game.state.baseqx[i]==batx && game.state.baseqy[i]==baty) {\r
+                                               game.state.baseqx[i]=game.state.baseqx[game.state.rembase];\r
+                                               game.state.baseqy[i]=game.state.baseqy[game.state.rembase];\r
                                        }\r
-                               state.rembase--;\r
+                               game.state.rembase--;\r
                                if (isatb == 2) {\r
                                        /* reinstate a commander's base attack */\r
                                        batx = ixhold;\r
@@ -298,13 +298,13 @@ void events(void) {
                                }\r
                                break;\r
                        case FSCMOVE: /* Supercommander moves */\r
-                               frozen.future[FSCMOVE] = state.date+0.2777;\r
+                               game.future[FSCMOVE] = game.state.date+0.2777;\r
                                if (ientesc+istract==0 &&\r
                                        isatb!=1 &&\r
                                        (iscate!=1 || justin==1)) scom(&ipage);\r
                                break;\r
                        case FDSPROB: /* Move deep space probe */\r
-                               frozen.future[FDSPROB] = state.date + 0.01;\r
+                               game.future[FDSPROB] = game.state.date + 0.01;\r
                                probex += probeinx;\r
                                probey += probeiny;\r
                                i = (int)(probex/10 +0.05);\r
@@ -313,9 +313,9 @@ void events(void) {
                                        probecx = i;\r
                                        probecy = j;\r
                                        if (i < 1 || i > 8 || j < 1 || j > 8 ||\r
-                                               state.galaxy[probecx][probecy] == 1000) {\r
+                                               game.state.galaxy[probecx][probecy] == 1000) {\r
                                                // Left galaxy or ran into supernova\r
-                                               if (frozen.damage[DRADIO]==0.0 || condit == IHDOCKED) {\r
+                                               if (game.damage[DRADIO]==0.0 || condit == IHDOCKED) {\r
                                                        if (ipage==0) pause(1);\r
                                                        ipage = 1;\r
                                                        skip(1);\r
@@ -326,10 +326,10 @@ void events(void) {
                                                                proutn("is no longer transmitting");\r
                                                        prout(".\"");\r
                                                }\r
-                                               frozen.future[FDSPROB] = 1e30;\r
+                                               game.future[FDSPROB] = 1e30;\r
                                                break;\r
                                        }\r
-                                       if (frozen.damage[DRADIO]==0.0   || condit == IHDOCKED) {\r
+                                       if (game.damage[DRADIO]==0.0   || condit == IHDOCKED) {\r
                                                if (ipage==0) pause(1);\r
                                                ipage = 1;\r
                                                skip(1);\r
@@ -340,16 +340,16 @@ void events(void) {
                                }\r
                                /* Update star chart if Radio is working or have access to\r
                                   radio. */\r
-                               if (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED)\r
-                                       frozen.starch[probecx][probecy] = frozen.damage[DRADIO] > 0.0 ?\r
-                                                                                  state.galaxy[probecx][probecy]+1000 : 1;\r
+                               if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED)\r
+                                       game.starch[probecx][probecy] = game.damage[DRADIO] > 0.0 ?\r
+                                                                                  game.state.galaxy[probecx][probecy]+1000 : 1;\r
                                proben--; // One less to travel\r
                                if (proben == 0 && isarmed &&\r
-                                       state.galaxy[probecx][probecy] % 10 > 0) {\r
+                                       game.state.galaxy[probecx][probecy] % 10 > 0) {\r
                                        /* lets blow the sucker! */\r
                                        snova(1,0);\r
-                                       frozen.future[FDSPROB] = 1e30;\r
-                                       if (state.galaxy[quadx][quady] == 1000) return;\r
+                                       game.future[FDSPROB] = 1e30;\r
+                                       if (game.state.galaxy[quadx][quady] == 1000) return;\r
                                }\r
                                break;\r
                }\r
@@ -374,7 +374,7 @@ void wait(void) {
        }\r
        origTime = delay = aaitem;\r
        if (delay <= 0.0) return;\r
-       if (delay >= state.remtime || nenhere != 0) {\r
+       if (delay >= game.state.remtime || nenhere != 0) {\r
                prout("Are you sure? ");\r
                if (ja() == 0) return;\r
        }\r
@@ -385,7 +385,7 @@ void wait(void) {
        do {\r
                if (delay <= 0) resting = 0;\r
                if (resting == 0) {\r
-                       cramf(state.remtime, 0, 2);\r
+                       cramf(game.state.remtime, 0, 2);\r
                        prout(" stardates left.");\r
                        return;\r
                }\r
@@ -405,8 +405,8 @@ void wait(void) {
                delay -= temp;\r
                /* Repair Deathray if long rest at starbase */\r
                if (origTime-delay >= 9.99 && condit == IHDOCKED)\r
-                       frozen.damage[DDRAY] = 0.0;\r
-       } while (state.galaxy[quadx][quady] != 1000); // leave if quadrant supernovas\r
+                       game.damage[DDRAY] = 0.0;\r
+       } while (game.state.galaxy[quadx][quady] != 1000); // leave if quadrant supernovas\r
 \r
        resting = 0;\r
        Time = 0;\r
@@ -424,11 +424,11 @@ void nova(int ix, int iy) {
        }\r
 \r
        /* handle initial nova */\r
-       frozen.quad[ix][iy] = IHDOT;\r
+       game.quad[ix][iy] = IHDOT;\r
        crmena(1, IHSTAR, 2, ix, iy);\r
        prout(" novas.");\r
-       state.galaxy[quadx][quady] -= 1;\r
-       state.starkl++;\r
+       game.state.galaxy[quadx][quady] -= 1;\r
+       game.state.starkl++;\r
        \r
        /* Set up stack to recursively trigger adjacent stars */\r
        bot = top = top2 = 1;\r
@@ -444,7 +444,7 @@ void nova(int ix, int iy) {
                                ii = hits[mm][1]+nn-2;\r
                                jj = hits[mm][2]+j-2;\r
                                if (ii < 1 || ii > 10 || jj < 1 || jj > 10) continue;\r
-                               iquad = frozen.quad[ii][jj];\r
+                               iquad = game.quad[ii][jj];\r
                                switch (iquad) {\r
 //                                     case IHDOT:     /* Empty space ends reaction\r
 //                                     case IHQUEST:\r
@@ -462,38 +462,38 @@ void nova(int ix, int iy) {
                                                top2++;\r
                                                hits[top2][1]=ii;\r
                                                hits[top2][2]=jj;\r
-                                               state.galaxy[quadx][quady] -= 1;\r
-                                               state.starkl++;\r
+                                               game.state.galaxy[quadx][quady] -= 1;\r
+                                               game.state.starkl++;\r
                                                crmena(1, IHSTAR, 2, ii, jj);\r
                                                prout(" novas.");\r
-                                               frozen.quad[ii][jj] = IHDOT;\r
+                                               game.quad[ii][jj] = IHDOT;\r
                                                break;\r
                                        case IHP: /* Destroy planet */\r
-                                               state.newstuf[quadx][quady] -= 1;\r
-                                               state.nplankl++;\r
+                                               game.state.newstuf[quadx][quady] -= 1;\r
+                                               game.state.nplankl++;\r
                                                crmena(1, IHP, 2, ii, jj);\r
                                                prout(" destroyed.");\r
-                                               state.plnets[iplnet] = nulplanet;\r
+                                               game.state.plnets[iplnet] = nulplanet;\r
                                                iplnet = plnetx = plnety = 0;\r
                                                if (landed == 1) {\r
                                                        finish(FPNOVA);\r
                                                        return;\r
                                                }\r
-                                               frozen.quad[ii][jj] = IHDOT;\r
+                                               game.quad[ii][jj] = IHDOT;\r
                                                break;\r
                                        case IHB: /* Destroy base */\r
-                                               state.galaxy[quadx][quady] -= 10;\r
-                                               for (i = 1; i <= state.rembase; i++)\r
-                                                       if (state.baseqx[i]==quadx && state.baseqy[i]==quady) break;\r
-                                               state.baseqx[i] = state.baseqx[state.rembase];\r
-                                               state.baseqy[i] = state.baseqy[state.rembase];\r
-                                               state.rembase--;\r
+                                               game.state.galaxy[quadx][quady] -= 10;\r
+                                               for (i = 1; i <= game.state.rembase; i++)\r
+                                                       if (game.state.baseqx[i]==quadx && game.state.baseqy[i]==quady) break;\r
+                                               game.state.baseqx[i] = game.state.baseqx[game.state.rembase];\r
+                                               game.state.baseqy[i] = game.state.baseqy[game.state.rembase];\r
+                                               game.state.rembase--;\r
                                                basex = basey = 0;\r
-                                               state.basekl++;\r
+                                               game.state.basekl++;\r
                                                newcnd();\r
                                                crmena(1, IHB, 2, ii, jj);\r
                                                prout(" destroyed.");\r
-                                               frozen.quad[ii][jj] = IHDOT;\r
+                                               game.quad[ii][jj] = IHDOT;\r
                                                break;\r
                                        case IHE: /* Buffet ship */\r
                                        case IHF:\r
@@ -506,7 +506,7 @@ void nova(int ix, int iy) {
                                                                shield = 0.0;\r
                                                                shldup = 0;\r
                                                                prout("***Shields knocked out.");\r
-                                                               frozen.damage[DSHIELD] += 0.005*damfac*Rand()*diff;\r
+                                                               game.damage[DSHIELD] += 0.005*damfac*Rand()*diff;\r
                                                        }\r
                                                }\r
                                                else energy -= 2000.0;\r
@@ -526,9 +526,9 @@ void nova(int ix, int iy) {
                                        case IHS:\r
                                        case IHR:\r
                                                for (ll = 1; ll <= nenhere; ll++)\r
-                                                       if (frozen.kx[ll]==ii && frozen.ky[ll]==jj) break;\r
-                                               frozen.kpower[ll] -= 800.0; /* If firepower is lost, die */\r
-                                               if (frozen.kpower[ll] <= 0.0) {\r
+                                                       if (game.kx[ll]==ii && game.ky[ll]==jj) break;\r
+                                               game.kpower[ll] -= 800.0; /* If firepower is lost, die */\r
+                                               if (game.kpower[ll] <= 0.0) {\r
                                                        deadkl(ii, jj, iquad, ii, jj);\r
                                                        break;\r
                                                }\r
@@ -541,7 +541,7 @@ void nova(int ix, int iy) {
                                                        skip(1);\r
                                                        break;\r
                                                }\r
-                                               iquad1 = frozen.quad[newcx][newcy];\r
+                                               iquad1 = game.quad[newcx][newcy];\r
                                                if (iquad1 == IHBLANK) {\r
                                                        proutn(", blasted into ");\r
                                                        crmena(0, IHBLANK, 2, newcx, newcy);\r
@@ -556,12 +556,12 @@ void nova(int ix, int iy) {
                                                }\r
                                                proutn(", buffeted to");\r
                                                cramlc(2, newcx, newcy);\r
-                                               frozen.quad[ii][jj] = IHDOT;\r
-                                               frozen.quad[newcx][newcy] = iquad;\r
-                                               frozen.kx[ll] = newcx;\r
-                                               frozen.ky[ll] = newcy;\r
-                                               frozen.kavgd[ll] = sqrt(square(sectx-newcx)+square(secty-newcy));\r
-                                               frozen.kdist[ll] = frozen.kavgd[ll];\r
+                                               game.quad[ii][jj] = IHDOT;\r
+                                               game.quad[newcx][newcy] = iquad;\r
+                                               game.kx[ll] = newcx;\r
+                                               game.ky[ll] = newcy;\r
+                                               game.kavgd[ll] = sqrt(square(sectx-newcx)+square(secty-newcy));\r
+                                               game.kdist[ll] = game.kavgd[ll];\r
                                                skip(1);\r
                                                break;\r
                                }\r
@@ -610,14 +610,14 @@ void snova(int insx, int insy) {
                        left of universe */\r
                        for (nqx = 1; nqx<=8; nqx++) {\r
                                for (nqy = 1; nqy<=8; nqy++) {\r
-                                       stars += state.galaxy[nqx][nqy] % 10;\r
+                                       stars += game.state.galaxy[nqx][nqy] % 10;\r
                                }\r
                        }\r
                        if (stars == 0) return; /* nothing to supernova exists */\r
                        num = Rand()*stars + 1;\r
                        for (nqx = 1; nqx<=8; nqx++) {\r
                                for (nqy = 1; nqy<=8; nqy++) {\r
-                                       num -= state.galaxy[nqx][nqy] % 10;\r
+                                       num -= game.state.galaxy[nqx][nqy] % 10;\r
                                        if (num <= 0) break;\r
                                }\r
                                if (num <=0) break;\r
@@ -635,10 +635,10 @@ void snova(int insx, int insy) {
 \r
                if (nqx != quady || nqy != quady || justin != 0) {\r
                        /* it isn't here, or we just entered (treat as inroute) */\r
-                       if (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
+                       if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
                                skip(1);\r
                                proutn("Message from Starfleet Command       Stardate ");\r
-                               cramf(state.date, 0, 1);\r
+                               cramf(game.state.date, 0, 1);\r
                                skip(1);\r
                                proutn("     Supernova in");\r
                                cramlc(1, nqx, nqy);\r
@@ -648,10 +648,10 @@ void snova(int insx, int insy) {
                else {\r
                        /* we are in the quadrant! */\r
                        insipient = 1;\r
-                       num = Rand()* (state.galaxy[nqx][nqy]%10) + 1;\r
+                       num = Rand()* (game.state.galaxy[nqx][nqy]%10) + 1;\r
                        for (nsx=1; nsx < 10; nsx++) {\r
                                for (nsy=1; nsy < 10; nsy++) {\r
-                                       if (frozen.quad[nsx][nsy]==IHSTAR) {\r
+                                       if (game.quad[nsx][nsy]==IHSTAR) {\r
                                                num--;\r
                                                if (num==0) break;\r
                                        }\r
@@ -682,75 +682,75 @@ void snova(int insx, int insy) {
                }\r
        }\r
        /* destroy any Klingons in supernovaed quadrant */\r
-       num=state.galaxy[nqx][nqy];\r
+       num=game.state.galaxy[nqx][nqy];\r
        kldead = num/100;\r
        comdead = iscdead = 0;\r
-       if (nqx==state.isx && nqy == state.isy) {\r
+       if (nqx==game.state.isx && nqy == game.state.isy) {\r
                /* did in the Supercommander! */\r
-               state.nscrem = state.isx = state.isy = isatb = iscate = 0;\r
+               game.state.nscrem = game.state.isx = game.state.isy = isatb = iscate = 0;\r
                iscdead = 1;\r
-               frozen.future[FSCMOVE] = frozen.future[FSCDBAS] = 1e30;\r
+               game.future[FSCMOVE] = game.future[FSCDBAS] = 1e30;\r
        }\r
-       state.remkl -= kldead;\r
-       if (state.remcom) {\r
-               int maxloop = state.remcom, l;\r
+       game.state.remkl -= kldead;\r
+       if (game.state.remcom) {\r
+               int maxloop = game.state.remcom, l;\r
                for (l = 1; l <= maxloop; l++) {\r
-                       if (state.cx[l] == nqx && state.cy[l] == nqy) {\r
-                               state.cx[l] = state.cx[state.remcom];\r
-                               state.cy[l] = state.cy[state.remcom];\r
-                               state.cx[state.remcom] = state.cy[state.remcom] = 0;\r
-                               state.remcom--;\r
+                       if (game.state.cx[l] == nqx && game.state.cy[l] == nqy) {\r
+                               game.state.cx[l] = game.state.cx[game.state.remcom];\r
+                               game.state.cy[l] = game.state.cy[game.state.remcom];\r
+                               game.state.cx[game.state.remcom] = game.state.cy[game.state.remcom] = 0;\r
+                               game.state.remcom--;\r
                                kldead--;\r
                                comdead++;\r
-                               if (state.remcom==0) frozen.future[FTBEAM] = 1e30;\r
+                               if (game.state.remcom==0) game.future[FTBEAM] = 1e30;\r
                                break;\r
                        }\r
                }\r
        }\r
        /* destroy Romulans and planets in supernovaed quadrant */\r
-       num = state.newstuf[nqx][nqy];\r
-       state.newstuf[nqx][nqy] = 0;\r
+       num = game.state.newstuf[nqx][nqy];\r
+       game.state.newstuf[nqx][nqy] = 0;\r
        nrmdead = num/10;\r
-       state.nromrem -= nrmdead;\r
+       game.state.nromrem -= nrmdead;\r
        npdead = num - nrmdead*10;\r
        if (npdead) {\r
                int l;\r
                for (l = 1; l <= inplan; l++)\r
-                       if (state.plnets[l].x == nqx && state.plnets[l].y == nqy) {\r
-                               state.plnets[l] = nulplanet;\r
+                       if (game.state.plnets[l].x == nqx && game.state.plnets[l].y == nqy) {\r
+                               game.state.plnets[l] = nulplanet;\r
                        }\r
        }\r
        /* Destroy any base in supernovaed quadrant */\r
-       if (state.rembase) {\r
-               int maxloop = state.rembase, l;\r
+       if (game.state.rembase) {\r
+               int maxloop = game.state.rembase, l;\r
                for (l = 1; l <= maxloop; l++)\r
-                       if (state.baseqx[l]==nqx && state.baseqy[l]==nqy) {\r
-                               state.baseqx[l] = state.baseqx[state.rembase];\r
-                               state.baseqy[l] = state.baseqy[state.rembase];\r
-                               state.baseqx[state.rembase] = state.baseqy[state.rembase] = 0;\r
-                               state.rembase--;\r
+                       if (game.state.baseqx[l]==nqx && game.state.baseqy[l]==nqy) {\r
+                               game.state.baseqx[l] = game.state.baseqx[game.state.rembase];\r
+                               game.state.baseqy[l] = game.state.baseqy[game.state.rembase];\r
+                               game.state.baseqx[game.state.rembase] = game.state.baseqy[game.state.rembase] = 0;\r
+                               game.state.rembase--;\r
                                break;\r
                        }\r
        }\r
        /* If starship caused supernova, tally up destruction */\r
        if (insx) {\r
-               num = state.galaxy[nqx][nqy] % 100;\r
-               state.starkl += num % 10;\r
-               state.basekl += num/10;\r
-               state.killk += kldead;\r
-               state.killc += comdead;\r
-               state.nromkl += nrmdead;\r
-               state.nplankl += npdead;\r
-               state.nsckill += iscdead;\r
+               num = game.state.galaxy[nqx][nqy] % 100;\r
+               game.state.starkl += num % 10;\r
+               game.state.basekl += num/10;\r
+               game.state.killk += kldead;\r
+               game.state.killc += comdead;\r
+               game.state.nromkl += nrmdead;\r
+               game.state.nplankl += npdead;\r
+               game.state.nsckill += iscdead;\r
        }\r
        /* mark supernova in galaxy and in star chart */\r
        if ((quadx == nqx && quady == nqy) ||\r
-               frozen.damage[DRADIO] == 0 ||\r
+               game.damage[DRADIO] == 0 ||\r
                condit == IHDOCKED)\r
-               frozen.starch[nqx][nqy] = 1;\r
-       state.galaxy[nqx][nqy] = 1000;\r
+               game.starch[nqx][nqy] = 1;\r
+       game.state.galaxy[nqx][nqy] = 1000;\r
        /* If supernova destroys last klingons give special message */\r
-       if (state.remkl==0 && (nqx != quadx || nqy != quady)) {\r
+       if (game.state.remkl==0 && (nqx != quadx || nqy != quady)) {\r
                skip(2);\r
                if (insx == 0) prout("Lucky you!");\r
                proutn("A supernova in");\r
index f355b5a69f855c929b522117477957a0c376f75a..e0fb221822b892e0c4257bb6a237700c996f6584 100644 (file)
--- a/finish.c
+++ b/finish.c
@@ -5,7 +5,7 @@
 void dstrct() {\r
        /* Finish with a BANG! */\r
        chew();\r
-       if (frozen.damage[DCOMPTR] != 0.0) {\r
+       if (game.damage[DCOMPTR] != 0.0) {\r
                prout("Computer damaged; cannot execute destruct sequence.");\r
                return;\r
        }\r
@@ -22,7 +22,7 @@ void dstrct() {
        prout("SELF-DESTRUCT-SEQUENCE-WILL-BE-ABORTED");\r
        scan();\r
        chew();\r
-       if (strcmp(frozen.passwd, citem) != 0) {\r
+       if (strcmp(game.passwd, citem) != 0) {\r
                prouts("PASSWORD-REJECTED;"); skip(1);\r
                prout("CONTINUITY-EFFECTED");\r
                skip(1);\r
@@ -55,8 +55,8 @@ void kaboom(void) {
                double whammo = 25.0 * energy;\r
                int l=1;\r
                while (l <= nenhere) {\r
-                       if (frozen.kpower[l]*frozen.kdist[l] <= whammo) \r
-                               deadkl(frozen.kx[l],frozen.ky[l], frozen.quad[frozen.kx[l]][frozen.ky[l]], frozen.kx[l], frozen.ky[l]);\r
+                       if (game.kpower[l]*game.kdist[l] <= whammo) \r
+                               deadkl(game.kx[l],game.ky[l], game.quad[game.kx[l]][game.ky[l]], game.kx[l], game.ky[l]);\r
                        l++;\r
                }\r
        }\r
@@ -68,26 +68,26 @@ void finish(FINTYPE ifin) {
        int igotit = 0;\r
        alldone = 1;\r
        skip(3);\r
-       printf("It is stardate %.1f .\n\n", state.date);\r
+       printf("It is stardate %.1f .\n\n", game.state.date);\r
        switch (ifin) {\r
                case FWON: // Game has been won\r
-                       if (state.nromrem != 0)\r
+                       if (game.state.nromrem != 0)\r
                                printf("The remaining %d Romulans surrender to Starfleet Command.\n",\r
-                                          state.nromrem);\r
+                                          game.state.nromrem);\r
                        \r
                        prout("You have smashed the Klingon invasion fleet and saved");\r
                        prout("the Federation.");\r
                        gamewon=1;\r
                        if (alive) {\r
                                double badpt;\r
-                               badpt = 5.*state.starkl + casual + 10.*state.nplankl +\r
-                                               45.*nhelp+100.*state.basekl;\r
+                               badpt = 5.*game.state.starkl + casual + 10.*game.state.nplankl +\r
+                                               45.*nhelp+100.*game.state.basekl;\r
                                if (ship == IHF) badpt += 100.0;\r
                                else if (ship == 0) badpt += 200.0;\r
                                if (badpt < 100.0) badpt = 0.0; // Close enough!\r
-                               if (state.date-indate < 5.0 ||\r
+                               if (game.state.date-indate < 5.0 ||\r
                                        // killsPerDate >= RateMax\r
-                                       (state.killk+state.killc+state.nsckill)/(state.date-indate) >=\r
+                                       (game.state.killk+game.state.killc+game.state.nsckill)/(game.state.date-indate) >=\r
                                        0.1*skill*(skill+1.0) + 0.1 + 0.008*badpt) {\r
                                        skip(1);\r
                                        prout("In fact, you have done so well that Starfleet Command");\r
@@ -105,7 +105,7 @@ void finish(FINTYPE ifin) {
                                                        prout("promotes you to Commodore Emeritus.");\r
                                                        skip(1);\r
                                                        prout("Now that you think you're really good, try playing");\r
-                                                       prout("the \"Emeritus\" frozen. It will splatter your ego.");\r
+                                                       prout("the \"Emeritus\" game. It will splatter your ego.");\r
                                                        break;\r
                                                case 5:\r
                                                        skip(1);\r
@@ -150,7 +150,7 @@ void finish(FINTYPE ifin) {
                        prout("conquered.  Your starship is now Klingon property,");\r
                        prout("and you are put on trial as a war criminal.  On the");\r
                        proutn("basis of your record, you are ");\r
-                       if (state.remkl*3.0 > inkling) {\r
+                       if (game.state.remkl*3.0 > inkling) {\r
                                prout("aquitted.");\r
                                skip(1);\r
                                prout("LIVE LONG AND PROSPER.");\r
@@ -275,9 +275,9 @@ void finish(FINTYPE ifin) {
        if (ship==IHF) ship= 0;\r
        else if (ship == IHE) ship = IHF;\r
        alive = 0;\r
-       if (state.remkl != 0) {\r
-               double goodies = state.remres/inresor;\r
-               double baddies = (state.remkl + 2.0*state.remcom)/(inkling+2.0*incom);\r
+       if (game.state.remkl != 0) {\r
+               double goodies = game.state.remres/inresor;\r
+               double baddies = (game.state.remkl + 2.0*game.state.remcom)/(inkling+2.0*incom);\r
                if (goodies/baddies >= 1.0+0.5*Rand()) {\r
                        prout("As a result of your actions, a treaty with the Klingon");\r
                        prout("Empire has been signed. The terms of the treaty are");\r
@@ -303,54 +303,54 @@ void finish(FINTYPE ifin) {
 }\r
 \r
 void score(void) {\r
-       double timused = state.date - indate;\r
+       double timused = game.state.date - indate;\r
        int ithperd, iwon, klship;\r
 \r
        pause(0);\r
 \r
        iskill = skill;\r
-       if ((timused == 0 || state.remkl != 0) && timused < 5.0) timused = 5.0;\r
-       perdate = (state.killc + state.killk + state.nsckill)/timused;\r
+       if ((timused == 0 || game.state.remkl != 0) && timused < 5.0) timused = 5.0;\r
+       perdate = (game.state.killc + game.state.killk + game.state.nsckill)/timused;\r
        ithperd = 500*perdate + 0.5;\r
        iwon = 0;\r
        if (gamewon) iwon = 100*skill;\r
        if (ship == IHE) klship = 0;\r
        else if (ship == IHF) klship = 1;\r
        else klship = 2;\r
-       if (gamewon == 0) state.nromrem = 0; // None captured if no win\r
-       iscore = 10*state.killk + 50*state.killc + ithperd + iwon\r
-                        - 100*state.basekl - 100*klship - 45*nhelp -5*state.starkl - casual\r
-                        + 20*state.nromkl + 200*state.nsckill - 10*state.nplankl + state.nromrem;\r
+       if (gamewon == 0) game.state.nromrem = 0; // None captured if no win\r
+       iscore = 10*game.state.killk + 50*game.state.killc + ithperd + iwon\r
+                        - 100*game.state.basekl - 100*klship - 45*nhelp -5*game.state.starkl - casual\r
+                        + 20*game.state.nromkl + 200*game.state.nsckill - 10*game.state.nplankl + game.state.nromrem;\r
        if (alive == 0) iscore -= 200;\r
        skip(2);\r
        prout("Your score --");\r
-       if (state.nromkl)\r
+       if (game.state.nromkl)\r
                printf("%6d Romulans destroyed                 %5d\n",\r
-                          state.nromkl,20*state.nromkl);\r
-       if (state.nromrem)\r
+                          game.state.nromkl,20*game.state.nromkl);\r
+       if (game.state.nromrem)\r
                printf("%6d Romulans captured                  %5d\n",\r
-                          state.nromrem, state.nromrem);\r
-       if (state.killk)\r
+                          game.state.nromrem, game.state.nromrem);\r
+       if (game.state.killk)\r
                printf("%6d ordinary Klingons destroyed        %5d\n",\r
-                          state.killk, 10*state.killk);\r
-       if (state.killc)\r
+                          game.state.killk, 10*game.state.killk);\r
+       if (game.state.killc)\r
                printf("%6d Klingon commanders destroyed       %5d\n",\r
-                          state.killc, 50*state.killc);\r
-       if (state.nsckill)\r
+                          game.state.killc, 50*game.state.killc);\r
+       if (game.state.nsckill)\r
                printf("%6d Super-Commander destroyed          %5d\n",\r
-                          state.nsckill, 200*state.nsckill);\r
+                          game.state.nsckill, 200*game.state.nsckill);\r
        if (ithperd)\r
                printf("%6.2f Klingons per stardate              %5d\n",\r
                           perdate, ithperd);\r
-       if (state.starkl)\r
+       if (game.state.starkl)\r
                printf("%6d stars destroyed by your action     %5d\n",\r
-                          state.starkl, -5*state.starkl);\r
-       if (state.nplankl)\r
+                          game.state.starkl, -5*game.state.starkl);\r
+       if (game.state.nplankl)\r
                printf("%6d planets destroyed by your action   %5d\n",\r
-                          state.nplankl, -10*state.nplankl);\r
-       if (state.basekl)\r
+                          game.state.nplankl, -10*game.state.nplankl);\r
+       if (game.state.basekl)\r
                printf("%6d bases destroyed by your action     %5d\n",\r
-                          state.basekl, -100*state.basekl);\r
+                          game.state.basekl, -100*game.state.basekl);\r
        if (nhelp)\r
                printf("%6d calls for help from starbase       %5d\n",\r
                           nhelp, -45*nhelp);\r
index 0f53518da8b334475627d6881e59ddeb999ced82..2fdefb66d5cbab249519967b2e31c4cb5144e069 100644 (file)
--- a/moving.c
+++ b/moving.c
@@ -24,14 +24,14 @@ void move(void) {
        deltax /= bigger;\r
 \r
        /* If tractor beam is to occur, don't move full distance */\r
-       if (state.date+Time >= frozen.future[FTBEAM]) {\r
+       if (game.state.date+Time >= game.future[FTBEAM]) {\r
                trbeam = 1;\r
                condit = IHRED;\r
-               dist = dist*(frozen.future[FTBEAM]-state.date)/Time + 0.1;\r
-               Time = frozen.future[FTBEAM] - state.date + 1e-5;\r
+               dist = dist*(game.future[FTBEAM]-game.state.date)/Time + 0.1;\r
+               Time = game.future[FTBEAM] - game.state.date + 1e-5;\r
        }\r
        /* Move within the quadrant */\r
-       frozen.quad[sectx][secty] = IHDOT;\r
+       game.quad[sectx][secty] = IHDOT;\r
        x = sectx;\r
        y = secty;\r
        n = 10.0*dist*bigger+0.5;\r
@@ -46,11 +46,11 @@ void move(void) {
                                if (nenhere != 0 && iattak != 2) {\r
                                        newcnd();\r
                                        for (l = 1; l <= nenhere; l++) {\r
-                                               finald = sqrt((ix-frozen.kx[l])*(double)(ix-frozen.kx[l]) +\r
-                                                                         (iy-frozen.ky[l])*(double)(iy-frozen.ky[l]));\r
-                                               frozen.kavgd[l] = 0.5 * (finald+frozen.kdist[l]);\r
+                                               finald = sqrt((ix-game.kx[l])*(double)(ix-game.kx[l]) +\r
+                                                                         (iy-game.ky[l])*(double)(iy-game.ky[l]));\r
+                                               game.kavgd[l] = 0.5 * (finald+game.kdist[l]);\r
                                        }\r
-                                       if (state.galaxy[quadx][quady] != 1000) attack(0);\r
+                                       if (game.state.galaxy[quadx][quady] != 1000) attack(0);\r
                                        if (alldone) return;\r
                                }\r
                                /* compute final position -- new quadrant and sector */\r
@@ -101,11 +101,11 @@ void move(void) {
                                proutn("\nEntering");\r
                                cramlc(1, quadx, quady);\r
                                skip(1);\r
-                               frozen.quad[sectx][secty] = ship;\r
+                               game.quad[sectx][secty] = ship;\r
                                newqad(0);\r
                                return;\r
                        }\r
-                       iquad = frozen.quad[ix][iy];\r
+                       iquad = game.quad[ix][iy];\r
                        if (iquad != IHDOT) {\r
                                /* object encountered in flight path */\r
                                stopegy = 50.0*dist/Time;\r
@@ -170,18 +170,18 @@ void move(void) {
        finaly = secty;\r
 label100:\r
        /* No quadrant change -- compute new avg enemy distances */\r
-       frozen.quad[sectx][secty] = ship;\r
+       game.quad[sectx][secty] = ship;\r
        if (nenhere) {\r
                for (l = 1; l <= nenhere; l++) {\r
-                       finald = sqrt((ix-frozen.kx[l])*(double)(ix-frozen.kx[l]) +\r
-                                                 (iy-frozen.ky[l])*(double)(iy-frozen.ky[l]));\r
-                       frozen.kavgd[l] = 0.5 * (finald+frozen.kdist[l]);\r
-                       frozen.kdist[l] = finald;\r
+                       finald = sqrt((ix-game.kx[l])*(double)(ix-game.kx[l]) +\r
+                                                 (iy-game.ky[l])*(double)(iy-game.ky[l]));\r
+                       game.kavgd[l] = 0.5 * (finald+game.kdist[l]);\r
+                       game.kdist[l] = finald;\r
                }\r
                sortkl();\r
-               if (state.galaxy[quadx][quady] != 1000 && iattak == 0)\r
+               if (game.state.galaxy[quadx][quady] != 1000 && iattak == 0)\r
                        attack(0);\r
-               for (l = 1 ; l <= nenhere; l++) frozen.kavgd[l] = frozen.kdist[l];\r
+               for (l = 1 ; l <= nenhere; l++) game.kavgd[l] = game.kdist[l];\r
        }\r
        newcnd();\r
        iattak = 0;\r
@@ -210,7 +210,7 @@ void dock(void) {
        torps = intorps;\r
        lsupres = inlsr;\r
        if (stdamtim != 1e30 &&\r
-               (frozen.future[FCDBAS] < 1e30 || isatb == 1) && iseenit == 0) {\r
+               (game.future[FCDBAS] < 1e30 || isatb == 1) && iseenit == 0) {\r
                /* get attack report from base */\r
                prout("Lt. Uhura- \"Captain, an important message from the starbase:\"");\r
                attakreport();\r
@@ -247,7 +247,7 @@ static void getcd(int isprobe, int akey) {
                return;\r
        }\r
        while (automatic == -1) {\r
-               if (frozen.damage[DCOMPTR]) {\r
+               if (game.damage[DCOMPTR]) {\r
                        if (isprobe)\r
                                prout("Computer damaged; manual navigation only");\r
                        else\r
@@ -410,7 +410,7 @@ void impuls(void) {
        double power;\r
 \r
        ididit = 0;\r
-       if (frozen.damage[DIMPULS]) {\r
+       if (game.damage[DIMPULS]) {\r
                chew();\r
                skip(1);\r
                prout("Engineer Scott- \"The impulse engines are damaged, Sir.\"");\r
@@ -443,7 +443,7 @@ void impuls(void) {
        }\r
        /* Make sure enough time is left for the trip */\r
        Time = dist/0.095;\r
-       if (Time >= state.remtime) {\r
+       if (Time >= game.state.remtime) {\r
                prout("First Officer Spock- \"Captain, our speed under impulse");\r
                prout("power is only 0.95 sectors per stardate. Are you sure");\r
                prout("we dare spend the time?\"");\r
@@ -467,13 +467,13 @@ void warp(int i) {
 \r
        if (i!=2) { /* Not WARPX entry */\r
                ididit = 0;\r
-               if (frozen.damage[DWARPEN] > 10.0) {\r
+               if (game.damage[DWARPEN] > 10.0) {\r
                        chew();\r
                        skip(1);\r
                        prout("Engineer Scott- \"The impulse engines are damaged, Sir.\"");\r
                        return;\r
                }\r
-               if (frozen.damage[DWARPEN] > 0.0 && warpfac > 4.0) {\r
+               if (game.damage[DWARPEN] > 0.0 && warpfac > 4.0) {\r
                        chew();\r
                        skip(1);\r
                        prout("Engineer Scott- \"Sorry, Captain. Until this damage");\r
@@ -515,11 +515,11 @@ void warp(int i) {
                                                \r
                /* Make sure enough time is left for the trip */\r
                Time = 10.0*dist/wfacsq;\r
-               if (Time >= 0.8*state.remtime) {\r
+               if (Time >= 0.8*game.state.remtime) {\r
                        skip(1);\r
                        prout("First Officer Spock- \"Captain, I compute that such");\r
                        proutn("  a trip would require approximately ");\r
-                       cramf(100.0*Time/state.remtime, 0, 2);\r
+                       cramf(100.0*Time/game.state.remtime, 0, 2);\r
                        prout(" percent of our");\r
                        prout(" remaining time.  Are you sure this is wise?\"");\r
                        if (ja() == 0) { ididit = 0; return;}\r
@@ -567,7 +567,7 @@ void warp(int i) {
                                y += deltay;\r
                                iy = y +0.5;\r
                                if (iy < 1 || iy > 10) break;\r
-                               if (frozen.quad[ix][iy] != IHDOT) {\r
+                               if (game.quad[ix][iy] != IHDOT) {\r
                                        blooey = 0;\r
                                        twarp = 0;\r
                                }\r
@@ -584,7 +584,7 @@ void warp(int i) {
        Time = 10.0*dist/wfacsq;\r
        if (twarp) timwrp();\r
        if (blooey) {\r
-               frozen.damage[DWARPEN] = damfac*(3.0*Rand()+1.0);\r
+               game.damage[DWARPEN] = damfac*(3.0*Rand()+1.0);\r
                skip(1);\r
                prout("Engineering to bridge--");\r
                prout("  Scott here.  The warp engines are damaged.");\r
@@ -609,11 +609,11 @@ void setwrp(void) {
                huh();\r
                return;\r
        }\r
-       if (frozen.damage[DWARPEN] > 10.0) {\r
+       if (game.damage[DWARPEN] > 10.0) {\r
                prout("Warp engines inoperative.");\r
                return;\r
        }\r
-       if (frozen.damage[DWARPEN] > 0.0 && aaitem > 4.0) {\r
+       if (game.damage[DWARPEN] > 0.0 && aaitem > 4.0) {\r
                prout("Engineer Scott- \"I'm doing my best, Captain,\n"\r
                          "  but right now we can only go warp 4.\"");\r
                return;\r
@@ -653,7 +653,7 @@ void atover(int igrab) {
        chew();\r
        /* is captain on planet? */\r
        if (landed==1) {\r
-               if (frozen.damage[DTRANSP]) {\r
+               if (game.damage[DTRANSP]) {\r
                        finish(FPNOVA);\r
                        return;\r
                }\r
@@ -703,10 +703,10 @@ void atover(int igrab) {
                crmshp();\r
                skip(1);\r
                prout("safely out of quadrant.");\r
-               frozen.starch[quadx][quady] = frozen.damage[DRADIO] > 0.0 ? state.galaxy[quadx][quady]+1000:1;\r
+               game.starch[quadx][quady] = game.damage[DRADIO] > 0.0 ? game.state.galaxy[quadx][quady]+1000:1;\r
 \r
                /* Try to use warp engines */\r
-               if (frozen.damage[DWARPEN]) {\r
+               if (game.damage[DWARPEN]) {\r
                        skip(1);\r
                        prout("Warp engines damaged.");\r
                        finish(FSNOVAED);\r
@@ -735,37 +735,37 @@ void atover(int igrab) {
                        return;\r
                }\r
                /* Repeat if another snova */\r
-       } while (state.galaxy[quadx][quady] == 1000);\r
-       if (state.remkl==0) finish(FWON); /* Snova killed remaining enemy. */\r
+       } while (game.state.galaxy[quadx][quady] == 1000);\r
+       if (game.state.remkl==0) finish(FWON); /* Snova killed remaining enemy. */\r
 }\r
 \r
 void timwrp() {\r
        int l, ll, gotit;\r
        prout("***TIME WARP ENTERED.");\r
-       if (state.snap && Rand() < 0.5) {\r
+       if (game.state.snap && Rand() < 0.5) {\r
                /* Go back in time */\r
                proutn("You are traveling backwards in time ");\r
-               cramf(state.date-snapsht.date, 0, 2);\r
+               cramf(game.state.date-game.snapsht.date, 0, 2);\r
                prout(" stardates.");\r
-               state = snapsht;\r
-               state.snap = 0;\r
-               if (state.remcom) {\r
-                       frozen.future[FTBEAM] = state.date + expran(intime/state.remcom);\r
-                       frozen.future[FBATTAK] = state.date + expran(0.3*intime);\r
-               }\r
-               frozen.future[FSNOVA] = state.date + expran(0.5*intime);\r
-               frozen.future[FSNAP] = state.date +expran(0.25*state.remtime); /* next snapshot will\r
+               game.state = game.snapsht;\r
+               game.state.snap = 0;\r
+               if (game.state.remcom) {\r
+                       game.future[FTBEAM] = game.state.date + expran(intime/game.state.remcom);\r
+                       game.future[FBATTAK] = game.state.date + expran(0.3*intime);\r
+               }\r
+               game.future[FSNOVA] = game.state.date + expran(0.5*intime);\r
+               game.future[FSNAP] = game.state.date +expran(0.25*game.state.remtime); /* next snapshot will\r
                                                                                                           be sooner */\r
-               if (state.nscrem) frozen.future[FSCMOVE] = 0.2777;\r
+               if (game.state.nscrem) game.future[FSCMOVE] = 0.2777;\r
                isatb = 0;\r
-               frozen.future[FCDBAS] = frozen.future[FSCDBAS] = 1e30;\r
+               game.future[FCDBAS] = game.future[FSCDBAS] = 1e30;\r
                batx = baty = 0;\r
 \r
                /* Make sure Galileo is consistant -- Snapshot may have been taken\r
                   when on planet, which would give us two Galileos! */\r
                gotit = 0;\r
                for (l = 1; l <= inplan; l++) {\r
-                       if (state.plnets[l].known == 2) {\r
+                       if (game.state.plnets[l].known == 2) {\r
                                gotit = 1;\r
                                if (iscraft==1 && ship==IHE) {\r
                                        prout("Checkov-  \"Security reports the Galileo has disappeared, Sir!");\r
@@ -775,19 +775,19 @@ void timwrp() {
                }\r
                /* Likewise, if in the original time the Galileo was abandoned, but\r
                   was on ship earlier, it would have vanished -- lets restore it */\r
-               if (iscraft==0 && gotit==0 && frozen.damage[DSHUTTL] >= 0.0) {\r
+               if (iscraft==0 && gotit==0 && game.damage[DSHUTTL] >= 0.0) {\r
                        prout("Checkov-  \"Security reports the Galileo has reappeared in the dock!\"");\r
                        iscraft = 1;\r
                }\r
 \r
                /* Revert star chart to earlier era, if it was known then*/\r
-               if (frozen.damage[DRADIO]==0.0 || stdamtim > state.date) {\r
+               if (game.damage[DRADIO]==0.0 || stdamtim > game.state.date) {\r
                        for (l = 1; l <= 8; l++)\r
                                for (ll = 1; ll <= 8; ll++)\r
-                                       if (frozen.starch[l][ll] > 1)\r
-                                               frozen.starch[l][ll]=frozen.damage[DRADIO]>0.0 ? state.galaxy[l][ll]+1000 :1;\r
+                                       if (game.starch[l][ll] > 1)\r
+                                               game.starch[l][ll]=game.damage[DRADIO]>0.0 ? game.state.galaxy[l][ll]+1000 :1;\r
                        prout("Spock has reconstructed a correct star chart from memory");\r
-                       if (frozen.damage[DRADIO] > 0.0) stdamtim = state.date;\r
+                       if (game.damage[DRADIO] > 0.0) stdamtim = game.state.date;\r
                }\r
        }\r
        else {\r
@@ -797,8 +797,8 @@ void timwrp() {
                cramf(Time, 1, 2);\r
                prout(" stardates.");\r
                /* cheat to make sure no tractor beams occur during time warp */\r
-               frozen.future[FTBEAM] += Time;\r
-               frozen.damage[DRADIO] += Time;\r
+               game.future[FTBEAM] += Time;\r
+               game.damage[DRADIO] += Time;\r
        }\r
        newqad(0);\r
 }\r
@@ -816,16 +816,16 @@ void probe(void) {
                        prout("Ye Faerie Queene has no deep space probes.");\r
                return;\r
        }\r
-       if (frozen.damage[DDSP] != 0.0) {\r
+       if (game.damage[DDSP] != 0.0) {\r
                chew();\r
                skip(1);\r
                prout("Engineer Scott- \"The probe launcher is damaged, Sir.\"");\r
                return;\r
        }\r
-       if (frozen.future[FDSPROB] != 1e30) {\r
+       if (game.future[FDSPROB] != 1e30) {\r
                chew();\r
                skip(1);\r
-               if (frozen.damage[DRADIO] != 0 && condit != IHDOCKED) {\r
+               if (game.damage[DRADIO] != 0 && condit != IHDOCKED) {\r
                        prout("Spock-  \"Records show the previous probe has not yet");\r
                        prout("   reached its destination.\"");\r
                }\r
@@ -870,7 +870,7 @@ void probe(void) {
        probey = quady*10 + secty - 1;\r
        probecx = quadx;\r
        probecy = quady;\r
-       frozen.future[FDSPROB] = state.date + 0.01; // Time to move one sector\r
+       game.future[FDSPROB] = game.state.date + 0.01; // Time to move one sector\r
        prout("Ensign Chekov-  \"The deep space probe is launched, Captain.\"");\r
        return;\r
 }\r
@@ -886,11 +886,11 @@ void help(void) {
                prout("Lt. Uhura-  \"But Captain, we're already docked.\"");\r
                return;\r
        }\r
-       if (frozen.damage[DRADIO] != 0) {\r
+       if (game.damage[DRADIO] != 0) {\r
                prout("Subspace radio damaged.");\r
                return;\r
        }\r
-       if (state.rembase==0) {\r
+       if (game.state.rembase==0) {\r
                prout("Lt. Uhura-  \"Captain, I'm not getting any response from Starbase.\"");\r
                return;\r
        }\r
@@ -908,20 +908,20 @@ void help(void) {
        }\r
        else {\r
                ddist = 1e30;\r
-               for (l = 1; l <= state.rembase; l++) {\r
-                       xdist=10.0*sqrt(square(state.baseqx[l]-quadx)+square(state.baseqy[l]-quady));\r
+               for (l = 1; l <= game.state.rembase; l++) {\r
+                       xdist=10.0*sqrt(square(game.state.baseqx[l]-quadx)+square(game.state.baseqy[l]-quady));\r
                        if (xdist < ddist) {\r
                                ddist = xdist;\r
                                line = l;\r
                        }\r
                }\r
                /* Since starbase not in quadrant, set up new quadrant */\r
-               quadx = state.baseqx[line];\r
-               quady = state.baseqy[line];\r
+               quadx = game.state.baseqx[line];\r
+               quady = game.state.baseqy[line];\r
                newqad(1);\r
        }\r
        /* dematerialize starship */\r
-       frozen.quad[sectx][secty]=IHDOT;\r
+       game.quad[sectx][secty]=IHDOT;\r
        proutn("Starbase in");\r
        cramlc(1, quadx, quady);\r
        proutn(" responds--");\r
@@ -949,12 +949,12 @@ void help(void) {
        for (l = 1; l <= 5; l++) {\r
                ix = basex+3.0*Rand()-1;\r
                iy = basey+3.0*Rand()-1;\r
-               if (ix>=1 && ix<=10 && iy>=1 && iy<=10 && frozen.quad[ix][iy]==IHDOT) {\r
+               if (ix>=1 && ix<=10 && iy>=1 && iy<=10 && game.quad[ix][iy]==IHDOT) {\r
                        /* found one -- finish up */\r
                        prout("succeeds.");\r
                        sectx=ix;\r
                        secty=iy;\r
-                       frozen.quad[ix][iy]=ship;\r
+                       game.quad[ix][iy]=ship;\r
                        dock();\r
                        skip(1);\r
                        prout("Lt. Uhura-  \"Captain, we made it!\"");\r
diff --git a/os2.c b/os2.c
index c6a7835d36a926aaf02b1209da66add44b6cb8b3..ca0eb54264c33687bceb26f3d16abbac308a2888 100644 (file)
--- a/os2.c
+++ b/os2.c
@@ -23,8 +23,8 @@ int getch(void) {
        struct termio oldstate, newstate;\r
     ioctl(0,TCGETA,&oldstate);\r
        newstate = oldstate;\r
-       newstate.c_iflag = 0;\r
-       newstate.c_lflag = 0;\r
+       newgame.state.c_iflag = 0;\r
+       newgame.state.c_lflag = 0;\r
        ioctl(0,TCSETA,&newstate);\r
        read(0, &chbuf, 1);\r
     ioctl(0,TCSETA,&oldstate);\r
index ea9aa125337713ab40e03cb36417e11cf4caf987..b95761f0e48dfb3fdeec94efcd16e9476c741cbc 100644 (file)
--- a/planets.c
+++ b/planets.c
@@ -11,7 +11,7 @@ static int consumeTime(void) {
        ididit = 1;\r
 #if 0\r
        /* Don't wory about this */\r
-       if (future[FTBEAM] <= state.date+Time && state.remcom != 0 && condit != IHDOCKED) {\r
+       if (future[FTBEAM] <= game.state.date+Time && game.state.remcom != 0 && condit != IHDOCKED) {\r
                /* We are about to be tractor beamed -- operation fails */\r
                return 1;\r
        }\r
@@ -21,7 +21,7 @@ static int consumeTime(void) {
        events();       /* Used to avoid if future[FSCMOVE] within time */\r
 //     future[FSNOVA] = asave;\r
        /*fails if game over, quadrant super-novas or we've moved to new quadrant*/\r
-       if (alldone || state.galaxy[quadx][quady] == 1000 || justin != 0) return 1;\r
+       if (alldone || game.state.galaxy[quadx][quady] == 1000 || justin != 0) return 1;\r
        return 0;\r
 }\r
 \r
@@ -32,22 +32,22 @@ void preport(void) {
        prout("Spock-  \"Planet report follows, Captain.\"");\r
        skip(1);\r
        for (i = 1; i <= inplan; i++) {\r
-               if (state.plnets[i].known\r
+               if (game.state.plnets[i].known\r
 #ifdef DEBUG\r
-                       || ( idebug && state.plnets[i].x !=0)\r
+                       || ( idebug && game.state.plnets[i].x !=0)\r
 #endif\r
                        ) {\r
                        iknow = 1;\r
 #ifdef DEBUG\r
-                       if (idebug && state.plnets[i].known==0) proutn("(Unknown) ");\r
+                       if (idebug && game.state.plnets[i].known==0) proutn("(Unknown) ");\r
 #endif\r
-                       cramlc(1, state.plnets[i].x, state.plnets[i].y);\r
+                       cramlc(1, game.state.plnets[i].x, game.state.plnets[i].y);\r
                        proutn("   class ");\r
-                       proutn(classes[state.plnets[i].pclass]);\r
+                       proutn(classes[game.state.plnets[i].pclass]);\r
                        proutn("   ");\r
-                       if (state.plnets[i].crystals == 0) proutn("no ");\r
+                       if (game.state.plnets[i].crystals == 0) proutn("no ");\r
                        prout("dilithium crystals present.");\r
-                       if (state.plnets[i].known==2) \r
+                       if (game.state.plnets[i].known==2) \r
                                prout("    Shuttle Craft Galileo on surface.");\r
                }\r
        }\r
@@ -64,7 +64,7 @@ void orbit(void) {
                prout("Already in standard orbit.");\r
                return;\r
        }\r
-       if (frozen.damage[DWARPEN] != 0 && frozen.damage[DIMPULS] != 0) {\r
+       if (game.damage[DWARPEN] != 0 && game.damage[DIMPULS] != 0) {\r
                prout("Both warp and impulse engines damaged.");\r
                return;\r
        }\r
@@ -87,7 +87,7 @@ void orbit(void) {
 void sensor(void) {\r
        skip(1);\r
        chew();\r
-       if (frozen.damage[DSRSENS] != 0.0) {\r
+       if (game.damage[DSRSENS] != 0.0) {\r
                prout("Short range sensors damaged.");\r
                return;\r
        }\r
@@ -102,23 +102,23 @@ void sensor(void) {
        proutn("         Planet at");\r
        cramlc(2, plnetx, plnety);\r
        proutn(" is of class ");\r
-       proutn(classes[state.plnets[iplnet].pclass]);\r
+       proutn(classes[game.state.plnets[iplnet].pclass]);\r
        prout(".");\r
-       if (state.plnets[iplnet].known==2) \r
+       if (game.state.plnets[iplnet].known==2) \r
                prout("         Sensors show Galileo still on surface.");\r
        proutn("         Readings indicate");\r
-       if (state.plnets[iplnet].crystals == 0) proutn(" no");\r
+       if (game.state.plnets[iplnet].crystals == 0) proutn(" no");\r
        prout(" dilithium crystals present.\"");\r
-       if (state.plnets[iplnet].known == 0) state.plnets[iplnet].known = 1;\r
+       if (game.state.plnets[iplnet].known == 0) game.state.plnets[iplnet].known = 1;\r
        return;\r
 }\r
 \r
 void beam(void) {\r
        chew();\r
        skip(1);\r
-       if (frozen.damage[DTRANSP] != 0) {\r
+       if (game.damage[DTRANSP] != 0) {\r
                prout("Transporter damaged.");\r
-               if (frozen.damage[DSHUTTL]==0 && (state.plnets[iplnet].known==2 || iscraft == 1)) {\r
+               if (game.damage[DSHUTTL]==0 && (game.state.plnets[iplnet].known==2 || iscraft == 1)) {\r
                        skip(1);\r
                        prout("Spock-  \"May I suggest the shuttle craft, Sir?\" ");\r
                        if (ja() != 0) shuttle();\r
@@ -134,7 +134,7 @@ void beam(void) {
                prout("Impossible to transport through shields.");\r
                return;\r
        }\r
-       if (state.plnets[iplnet].known==0) {\r
+       if (game.state.plnets[iplnet].known==0) {\r
                prout("Spock-  \"Captain, we have no information on this planet");\r
                prout("  and Starfleet Regulations clearly state that in this situation");\r
                prout("  you may not go down.\"");\r
@@ -142,7 +142,7 @@ void beam(void) {
        }\r
        if (landed==1) {\r
                /* Coming from planet */\r
-               if (state.plnets[iplnet].known==2) {\r
+               if (game.state.plnets[iplnet].known==2) {\r
                        proutn("Spock-  \"Wouldn't you rather take the Galileo?\" ");\r
                        if (ja() != 0) {\r
                                chew();\r
@@ -159,7 +159,7 @@ void beam(void) {
        }\r
        else {\r
                /* Going to planet */\r
-               if (state.plnets[iplnet].crystals==0) {\r
+               if (game.state.plnets[iplnet].crystals==0) {\r
                        prout("Spock-  \"Captain, I fail to see the logic in");\r
                        prout("  exploring a planet with no dilithium crystals.");\r
                        proutn("  Are you sure this is wise?\" ");\r
@@ -188,7 +188,7 @@ void beam(void) {
        skip(2);\r
        prout("Transport complete.");\r
        landed = -landed;\r
-       if (landed==1 && state.plnets[iplnet].known==2) {\r
+       if (landed==1 && game.state.plnets[iplnet].known==2) {\r
                prout("The shuttle craft Galileo is here!");\r
        }\r
        if (landed!=1 && imine==1) {\r
@@ -208,7 +208,7 @@ void mine(void) {
                prout("Mining party not on planet.");\r
                return;\r
        }\r
-       if (state.plnets[iplnet].crystals == 0) {\r
+       if (game.state.plnets[iplnet].crystals == 0) {\r
                prout("No dilithium crystals on this planet.");\r
                return;\r
        }\r
@@ -223,7 +223,7 @@ void mine(void) {
                prout("there's no reason to mine more at this time.");\r
                return;\r
        }\r
-       Time = (0.1+0.2*Rand())*state.plnets[iplnet].pclass;\r
+       Time = (0.1+0.2*Rand())*game.state.plnets[iplnet].pclass;\r
        if (consumeTime()) return;\r
        prout("Mining operation complete.");\r
        imine = 1;\r
@@ -285,14 +285,14 @@ void shuttle(void) {
        chew();\r
        skip(1);\r
        ididit = 0;\r
-       if(frozen.damage[DSHUTTL] != 0.0) {\r
-               if (frozen.damage[DSHUTTL] == -1.0) {\r
-                       if (inorbit && state.plnets[iplnet].known == 2)\r
+       if(game.damage[DSHUTTL] != 0.0) {\r
+               if (game.damage[DSHUTTL] == -1.0) {\r
+                       if (inorbit && game.state.plnets[iplnet].known == 2)\r
                                prout("Ye Faerie Queene has no shuttle craft bay to dock it at.");\r
                        else\r
                                prout("Ye Faerie Queene had no shuttle craft.");\r
                }\r
-               else if (frozen.damage[DSHUTTL] > 0)\r
+               else if (game.damage[DSHUTTL] > 0)\r
                        prout("The Galileo is damaged.");\r
                else prout("Shuttle craft is now serving Big Macs.");\r
                return;\r
@@ -302,11 +302,11 @@ void shuttle(void) {
                prout(" not in standard orbit.");\r
                return;\r
        }\r
-       if ((state.plnets[iplnet].known != 2) && iscraft != 1) {\r
+       if ((game.state.plnets[iplnet].known != 2) && iscraft != 1) {\r
                prout("Shuttle craft not currently available.");\r
                return;\r
        }\r
-       if (landed==-1 && state.plnets[iplnet].known==2) {\r
+       if (landed==-1 && game.state.plnets[iplnet].known==2) {\r
                prout("You will have to beam down to retrieve the shuttle craft.");\r
                return;\r
        }\r
@@ -314,17 +314,17 @@ void shuttle(void) {
                prout("Shuttle craft cannot pass through shields.");\r
                return;\r
        }\r
-       if (state.plnets[iplnet].known==0) {\r
+       if (game.state.plnets[iplnet].known==0) {\r
                prout("Spock-  \"Captain, we have no information on this planet");\r
                prout("  and Starfleet Regulations clearly state that in this situation");\r
                prout("  you may not fly down.\"");\r
                return;\r
        }\r
        Time = 3.0e-5*height;\r
-       if (Time >= 0.8*state.remtime) {\r
+       if (Time >= 0.8*game.state.remtime) {\r
                prout("First Officer Spock-  \"Captain, I compute that such");\r
                prout("  a maneuver would require approximately ");\r
-               cramf(100*Time/state.remtime,0,4);\r
+               cramf(100*Time/game.state.remtime,0,4);\r
                prout("% of our");\r
                prout("remaining time.");\r
                prout("Are you sure this is wise?\" ");\r
@@ -337,7 +337,7 @@ void shuttle(void) {
                /* Kirk on planet */\r
                if (iscraft==1) {\r
                        /* Galileo on ship! */\r
-                       if (frozen.damage[DTRANSP]==0) {\r
+                       if (game.damage[DTRANSP]==0) {\r
                                proutn("Spock-  \"Would you rather use the transporter?\" ");\r
                                if (ja() != 0) {\r
                                        beam();\r
@@ -351,7 +351,7 @@ void shuttle(void) {
                        iscraft = 0;\r
                        skip(1);\r
                        if (consumeTime()) return;\r
-                       state.plnets[iplnet].known=2;\r
+                       game.state.plnets[iplnet].known=2;\r
                        prout("Trip complete.");\r
                        return;\r
                }\r
@@ -361,7 +361,7 @@ void shuttle(void) {
                        prout("shuttle craft for the trip back to the Enterprise.");\r
                        skip(1);\r
                        prout("The short hop begins . . .");\r
-                       state.plnets[iplnet].known=1;\r
+                       game.state.plnets[iplnet].known=1;\r
                        icraft = 1;\r
                        skip(1);\r
                        landed = -1;\r
@@ -388,7 +388,7 @@ void shuttle(void) {
                icraft = 1;\r
                iscraft = 0;\r
                if (consumeTime()) return;\r
-               state.plnets[iplnet].known = 2;\r
+               game.state.plnets[iplnet].known = 2;\r
                landed = 1;\r
                icraft = 0;\r
                prout("Trip complete");\r
@@ -411,7 +411,7 @@ void deathray(void) {
                prout("Sulu-  \"But Sir, there are no enemies in this quadrant.\"");\r
                return;\r
        }\r
-       if (frozen.damage[DDRAY] > 0.0) {\r
+       if (game.damage[DDRAY] > 0.0) {\r
                prout("Death Ray is damaged.");\r
                return;\r
        }\r
@@ -437,16 +437,16 @@ void deathray(void) {
                prouts("Sulu- \"Captain!  It's working!\"");\r
                skip(2);\r
                while (nenhere > 0)\r
-                       deadkl(frozen.kx[1],frozen.ky[1],frozen.quad[frozen.kx[1]][frozen.ky[1]],frozen.kx[1],frozen.ky[1]);\r
+                       deadkl(game.kx[1],game.ky[1],game.quad[game.kx[1]][game.ky[1]],game.kx[1],game.ky[1]);\r
                prout("Ensign Chekov-  \"Congratulations, Captain!\"");\r
-               if (state.remkl == 0) finish(FWON);\r
+               if (game.state.remkl == 0) finish(FWON);\r
                prout("Spock-  \"Captain, I believe the `Experimental Death Ray'");\r
                if (Rand() <= 0.05) {\r
                        prout("   is still operational.\"");\r
                }\r
                else {\r
                        prout("   has been rendered disfunctional.\"");\r
-                       frozen.damage[DDRAY] = 39.95;\r
+                       game.damage[DDRAY] = 39.95;\r
                }\r
                return;\r
        }\r
@@ -488,7 +488,7 @@ void deathray(void) {
                prout(" Mr. Sulu.");\r
                for (i=1; i<=10; i++)\r
                        for (j=1; j<=10; j++)\r
-                               if (frozen.quad[i][j] == IHDOT) frozen.quad[i][j] = IHQUEST;\r
+                               if (game.quad[i][j] == IHDOT) game.quad[i][j] = IHQUEST;\r
                prout("  Captain, our quadrant is now infested with");\r
                prouts(" - - - - - -  *THINGS*.");\r
                skip(1);\r
index 5841aeca6c74f9750fd2a3d2253d32d9ad33fdbf..9475ab3b4ac1eeb469ed0e7945860f13db5ced71 100644 (file)
--- a/reports.c
+++ b/reports.c
@@ -4,20 +4,20 @@
 #include <string.h>\r
 \r
 void attakreport(void) {\r
-       if (frozen.future[FCDBAS] < 1e30) {\r
+       if (game.future[FCDBAS] < 1e30) {\r
                proutn("Starbase in ");\r
                cramlc(1, batx, baty);\r
                prout(" is currently under attack.");\r
                proutn("It can hold out until Stardate ");\r
-               cramf(frozen.future[FCDBAS], 0,1);\r
+               cramf(game.future[FCDBAS], 0,1);\r
                prout(".");\r
        }\r
        if (isatb == 1) {\r
                proutn("Starbase in ");\r
-               cramlc(1, state.isx, state.isy);\r
+               cramlc(1, game.state.isx, game.state.isy);\r
                prout(" is under Super-commander attack.");\r
                proutn("It can hold out until Stardate ");\r
-               cramf(frozen.future[FSCDBAS], 0, 1);\r
+               cramf(game.future[FSCDBAS], 0, 1);\r
                prout(".");\r
        }\r
 }\r
@@ -42,32 +42,32 @@ void report(int f) {
                case 5: s3="emeritus"; break;\r
                default: s3="skilled"; break;\r
        }\r
-       printf("\nYou %s playing a %s%s %s frozen.\n",\r
+       printf("\nYou %s playing a %s%s %s game.\n",\r
                   alldone? "were": "are now", s1, s2, s3);\r
        if (skill>3 && thawed && !alldone) prout("No plaque is allowed.");\r
        if (tourn) printf("This is tournament game %d.\n", tourn);\r
-       if (f) printf("Your secret password is \"%s\"\n",frozen.passwd);\r
+       if (f) printf("Your secret password is \"%s\"\n",game.passwd);\r
        printf("%d of %d Klingons have been killed",\r
-                  state.killk+state.killc+state.nsckill, inkling);\r
-       if (state.killc) printf(", including %d Commander%s.\n", state.killc, state.killc==1?"":"s");\r
-       else if (state.killk+state.nsckill > 0) prout(", but no Commanders.");\r
+                  game.state.killk+game.state.killc+game.state.nsckill, inkling);\r
+       if (game.state.killc) printf(", including %d Commander%s.\n", game.state.killc, game.state.killc==1?"":"s");\r
+       else if (game.state.killk+game.state.nsckill > 0) prout(", but no Commanders.");\r
        else prout(".");\r
        if (skill > 2) printf("The Super Commander has %sbeen destroyed.\n",\r
-                                                 state.nscrem?"not ":"");\r
-       if (state.rembase != inbase) {\r
+                                                 game.state.nscrem?"not ":"");\r
+       if (game.state.rembase != inbase) {\r
                proutn("There ");\r
-               if (inbase-state.rembase==1) proutn("has been 1 base");\r
+               if (inbase-game.state.rembase==1) proutn("has been 1 base");\r
                else {\r
                        proutn("have been ");\r
-                       crami(inbase-state.rembase, 1);\r
+                       crami(inbase-game.state.rembase, 1);\r
                        proutn(" bases");\r
                }\r
                proutn(" destroyed, ");\r
-               crami(state.rembase, 1);\r
+               crami(game.state.rembase, 1);\r
                prout(" remaining.");\r
        }\r
        else printf("There are %d bases.\n", inbase);\r
-       if (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED || iseenit) {\r
+       if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED || iseenit) {\r
                /* Don't report this if not seen and\r
                        either the radio is dead or not at base! */\r
                attakreport();\r
@@ -85,8 +85,8 @@ void report(int f) {
                if (nprobes!=1) proutn("s");\r
                prout(".");\r
        }\r
-       if ((frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED)&&\r
-               frozen.future[FDSPROB] != 1e30) {\r
+       if ((game.damage[DRADIO] == 0.0 || condit == IHDOCKED)&&\r
+               game.future[FDSPROB] != 1e30) {\r
                if (isarmed) \r
                        proutn("An armed deep space probe is in");\r
                else\r
@@ -114,7 +114,7 @@ void report(int f) {
 void lrscan(void) {\r
        int x, y;\r
        chew();\r
-       if (frozen.damage[DLRSENS] != 0.0) {\r
+       if (game.damage[DLRSENS] != 0.0) {\r
                /* Now allow base's sensors if docked */\r
                if (condit != IHDOCKED) {\r
                        prout("LONG-RANGE SENSORS DAMAGED.");\r
@@ -134,8 +134,8 @@ void lrscan(void) {
                        if (x == 0 || x > 8 || y == 0 || y > 8)\r
                                printf("   -1");\r
                        else {\r
-                               printf("%5d", state.galaxy[x][y]);\r
-                               frozen.starch[x][y] = frozen.damage[DRADIO] > 0 ? state.galaxy[x][y]+1000 :1;\r
+                               printf("%5d", game.state.galaxy[x][y]);\r
+                               game.starch[x][y] = game.damage[DRADIO] > 0 ? game.state.galaxy[x][y]+1000 :1;\r
                        }\r
                }\r
                putchar('\n');\r
@@ -148,7 +148,7 @@ void dreprt(void) {
        chew();\r
 \r
        for (i = 1; i <= ndevice; i++) {\r
-               if (frozen.damage[i] > 0.0) {\r
+               if (game.damage[i] > 0.0) {\r
                        if (!jdam) {\r
                                skip(1);\r
                                prout("DEVICE            -REPAIR TIMES-");\r
@@ -156,9 +156,9 @@ void dreprt(void) {
                                jdam = TRUE;\r
                        }\r
                        printf("  %16s ", device[i]);\r
-                       cramf(frozen.damage[i]+0.05, 8, 2);\r
+                       cramf(game.damage[i]+0.05, 8, 2);\r
                        proutn("  ");\r
-                       cramf(docfac*frozen.damage[i]+0.005, 8, 2);\r
+                       cramf(docfac*game.damage[i]+0.005, 8, 2);\r
                        skip(1);\r
                }\r
        }\r
@@ -170,7 +170,7 @@ void chart(int nn) {
 \r
        chew();\r
        skip(1);\r
-       if (stdamtim != 1e30 && stdamtim != state.date && condit == IHDOCKED) {\r
+       if (stdamtim != 1e30 && stdamtim != game.state.date && condit == IHDOCKED) {\r
                prout("Spock-  \"I revised the Star Chart from the");\r
                prout("  starbase's records.\"");\r
                skip(1);\r
@@ -179,14 +179,14 @@ void chart(int nn) {
        if (stdamtim != 1e30) {\r
                if (condit == IHDOCKED) {\r
                        /* We are docked, so restore chart from base information */\r
-                       stdamtim = state.date;\r
+                       stdamtim = game.state.date;\r
                        for (i=1; i <= 8 ; i++)\r
                                for (j=1; j <= 8; j++)\r
-                                       if (frozen.starch[i][j] == 1) frozen.starch[i][j] = state.galaxy[i][j]+1000;\r
+                                       if (game.starch[i][j] == 1) game.starch[i][j] = game.state.galaxy[i][j]+1000;\r
                }\r
                else {\r
                        proutn("(Last surveillance update ");\r
-                       cramf(state.date-stdamtim, 0, 1);\r
+                       cramf(game.state.date-stdamtim, 0, 1);\r
                        prout(" stardates ago.)");\r
                }\r
        }\r
@@ -198,14 +198,14 @@ void chart(int nn) {
        for (i = 1; i <= 8; i++) {\r
                printf("%d -", i);\r
                for (j = 1; j <= 8; j++) {\r
-                       if (frozen.starch[i][j] < 0)\r
+                       if (game.starch[i][j] < 0)\r
                                printf("  .1.");\r
-                       else if (frozen.starch[i][j] == 0)\r
+                       else if (game.starch[i][j] == 0)\r
                                printf("  ...");\r
-                       else if (frozen.starch[i][j] > 999)\r
-                               printf("%5d", frozen.starch[i][j]-1000);\r
+                       else if (game.starch[i][j] > 999)\r
+                               printf("%5d", game.starch[i][j]-1000);\r
                        else\r
-                               printf("%5d", state.galaxy[i][j]);\r
+                               printf("%5d", game.state.galaxy[i][j]);\r
                }\r
                prout("  -");\r
        }\r
@@ -227,7 +227,7 @@ void srscan(int l) {
        int goodScan=TRUE;\r
        switch (l) {\r
                case 1: // SRSCAN\r
-                       if (frozen.damage[DSRSENS] != 0) {\r
+                       if (game.damage[DSRSENS] != 0) {\r
                                /* Allow base's sensors if docked */\r
                                if (condit != IHDOCKED) {\r
                                        prout("SHORT-RANGE SENSORS DAMAGED");\r
@@ -237,8 +237,8 @@ void srscan(int l) {
                                        prout("[Using starbase's sensors]");\r
                        }\r
                        if (goodScan)\r
-                           frozen.starch[quadx][quady] = frozen.damage[DRADIO]>0.0 ?\r
-                                                                          state.galaxy[quadx][quady]+1000:1;\r
+                           game.starch[quadx][quady] = game.damage[DRADIO]>0.0 ?\r
+                                                                          game.state.galaxy[quadx][quady]+1000:1;\r
                        scan();\r
                        if (isit("chart")) nn = TRUE;\r
                        if (isit("no")) rightside = FALSE;\r
@@ -270,7 +270,7 @@ void srscan(int l) {
                        printf("%2d  ", i);\r
                        for (j = 1; j <= 10; j++) {\r
                                if (goodScan || (abs(i-sectx)<= 1 && abs(j-secty) <= 1))\r
-                                       printf("%c ",frozen.quad[i][j]);\r
+                                       printf("%c ",game.quad[i][j]);\r
                                else\r
                                        printf("- ");\r
                        }\r
@@ -278,7 +278,7 @@ void srscan(int l) {
                if (rightside) {\r
                        switch (jj) {\r
                                case 1:\r
-                                       printf(" Stardate      %.1f", state.date);\r
+                                       printf(" Stardate      %.1f", game.state.date);\r
                                        break;\r
                                case 2:\r
                                        if (condit != IHDOCKED) newcnd();\r
@@ -298,7 +298,7 @@ void srscan(int l) {
                                        break;\r
                                case 4:\r
                                        printf(" Life Support  ");\r
-                                       if (frozen.damage[DLIFSUP] != 0.0) {\r
+                                       if (game.damage[DLIFSUP] != 0.0) {\r
                                                if (condit == IHDOCKED)\r
                                                        printf("DAMAGED, supported by starbase");\r
                                                else\r
@@ -318,7 +318,7 @@ void srscan(int l) {
                                        break;\r
                                case 8:\r
                                        printf(" Shields       ");\r
-                                       if (frozen.damage[DSHIELD] != 0)\r
+                                       if (game.damage[DSHIELD] != 0)\r
                                                printf("DAMAGED,");\r
                                        else if (shldup)\r
                                                printf("UP,");\r
@@ -328,10 +328,10 @@ void srscan(int l) {
                                                   (int)((100.0*shield)/inshld + 0.5), shield);\r
                                        break;\r
                                case 9:\r
-                                       printf(" Klingons Left %d", state.remkl);\r
+                                       printf(" Klingons Left %d", game.state.remkl);\r
                                        break;\r
                                case 10:\r
-                                       printf(" Time Left     %.2f", state.remtime);\r
+                                       printf(" Time Left     %.2f", game.state.remtime);\r
                                        break;\r
                        }\r
                                        \r
@@ -347,7 +347,7 @@ void eta(void) {
        int key, ix1, ix2, iy1, iy2, prompt=FALSE;\r
        int wfl;\r
        double ttime, twarp, tpower;\r
-       if (frozen.damage[DCOMPTR] != 0.0) {\r
+       if (game.damage[DCOMPTR] != 0.0) {\r
                prout("COMPUTER DAMAGED, USE A POCKET CALCULATOR.");\r
                skip(1);\r
                return;\r
@@ -397,7 +397,7 @@ void eta(void) {
                proutn("Time or arrival date? ");\r
                if (scan()==IHREAL) {\r
                        ttime = aaitem;\r
-                       if (ttime > state.date) ttime -= state.date; // Actually a star date\r
+                       if (ttime > game.state.date) ttime -= game.state.date; // Actually a star date\r
                        if (ttime <= 1e-10 ||\r
                                (twarp=(floor(sqrt((10.0*dist)/ttime)*10.0)+1.0)/10.0) > 10) {\r
                                prout("We'll never make it, sir.");\r
@@ -455,7 +455,7 @@ void eta(void) {
                prout(".");\r
                if (wfl) {\r
                        proutn("And we will arrive at stardate ");\r
-                       cramf(state.date+ttime, 1, 1);\r
+                       cramf(game.state.date+ttime, 1, 1);\r
                        prout(".");\r
                }\r
                else if (twarp==1.0)\r
@@ -465,16 +465,16 @@ void eta(void) {
                        cramf(twarp, 1, 2);\r
                        skip(1);\r
                        proutn("and we will arrive at stardate ");\r
-                       cramf(state.date+ttime, 1, 2);\r
+                       cramf(game.state.date+ttime, 1, 2);\r
                        prout(".");\r
                }\r
-               if (state.remtime < ttime)\r
+               if (game.state.remtime < ttime)\r
                        prout("Unfortunately, the Federation will be destroyed by then.");\r
                if (twarp > 6.0)\r
                        prout("You'll be taking risks at that speed, Captain");\r
-               if ((isatb==1 && state.isy == ix1 && state.isx == iy1 &&\r
-                        frozen.future[FSCDBAS]< ttime+state.date)||\r
-                       (frozen.future[FCDBAS]<ttime+state.date && baty==ix1 && batx == iy1))\r
+               if ((isatb==1 && game.state.isy == ix1 && game.state.isx == iy1 &&\r
+                        game.future[FSCDBAS]< ttime+game.state.date)||\r
+                       (game.future[FCDBAS]<ttime+game.state.date && baty==ix1 && batx == iy1))\r
                        prout("The starbase there will be destroyed by then.");\r
                proutn("New warp factor to try? ");\r
                if (scan() == IHREAL) {\r
diff --git a/setup.c b/setup.c
index 5e2db4f056fa43091ca42dbfe64c77ba1cc0e1cd..9b5ac4241b9abda67b875a4ef39c89fb6af1446c 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -36,9 +36,7 @@ void freeze(int boss) {
                skip(1);\r
                return;\r
        }\r
-       fwrite(&state, sizeof(state), 1, fp);\r
-       fwrite(&snapsht, sizeof(snapsht), 1, fp);\r
-       fwrite(&frozen, sizeof(frozen), 1, fp);\r
+       fwrite(&game, sizeof(game), 1, fp);\r
 \r
        fclose(fp);\r
 \r
@@ -51,7 +49,7 @@ void thaw(void) {
        FILE *fp;\r
        int key;\r
 \r
-       frozen.passwd[0] = '\0';\r
+       game.passwd[0] = '\0';\r
        if ((key = scan()) == IHEOL) {\r
                proutn("File name: ");\r
                key = scan();\r
@@ -70,9 +68,7 @@ void thaw(void) {
                skip(1);\r
                return;\r
        }\r
-       fread(&state, sizeof(state), 1, fp);\r
-       fread(&snapsht, sizeof(snapsht), 1, fp);\r
-       fread(&frozen, sizeof(frozen), 1, fp);\r
+       fread(&game, sizeof(game), 1, fp);\r
 \r
        fclose(fp);\r
 \r
@@ -91,15 +87,15 @@ void abandn(void) {
        }\r
        else {\r
                /* Must take shuttle craft to exit */\r
-               if (frozen.damage[DSHUTTL]==-1) {\r
+               if (game.damage[DSHUTTL]==-1) {\r
                        prout("Ye Faerie Queene has no shuttle craft.");\r
                        return;\r
                }\r
-               if (frozen.damage[DSHUTTL]<0) {\r
+               if (game.damage[DSHUTTL]<0) {\r
                        prout("Shuttle craft now serving Big Mac's.");\r
                        return;\r
                }\r
-               if (frozen.damage[DSHUTTL]>0) {\r
+               if (game.damage[DSHUTTL]>0) {\r
                        prout("Shuttle craft damaged.");\r
                        return;\r
                }\r
@@ -120,7 +116,7 @@ void abandn(void) {
                prout("Captain and crew escape in shuttle craft.");\r
                prout("Remainder of ship's complement beam down");\r
                prout("to nearest habitable planet.");\r
-               if (state.rembase==0) {\r
+               if (game.state.rembase==0) {\r
                        /* Ops! no place to go... */\r
                        finish(FABANDN);\r
                        return;\r
@@ -131,23 +127,23 @@ void abandn(void) {
                nprobes = 0; /* No probes */\r
                prout("You are captured by Klingons and released to");\r
                prout("the Federation in a prisoner-of-war exchange.");\r
-               nb = Rand()*state.rembase+1;\r
+               nb = Rand()*game.state.rembase+1;\r
                /* Set up quadrant and position FQ adjacient to base */\r
-               if (quadx!=state.baseqx[nb] || quady!=state.baseqy[nb]) {\r
-                       quadx = state.baseqx[nb];\r
-                       quady = state.baseqy[nb];\r
+               if (quadx!=game.state.baseqx[nb] || quady!=game.state.baseqy[nb]) {\r
+                       quadx = game.state.baseqx[nb];\r
+                       quady = game.state.baseqy[nb];\r
                        sectx = secty = 5;\r
                        newqad(1);\r
                }\r
                for (;;) {\r
                        /* position next to base by trial and error */\r
-                       frozen.quad[sectx][secty] = IHDOT;\r
+                       game.quad[sectx][secty] = IHDOT;\r
                        for (l = 1; l <= 10; l++) {\r
                                sectx = 3.0*Rand() - 1.0 + basex;\r
                                secty = 3.0*Rand() - 1.0 + basey;\r
                                if (sectx >= 1 && sectx <= 10 &&\r
                                        secty >= 1 && secty <= 10 &&\r
-                                       frozen.quad[sectx][secty] == IHDOT) break;\r
+                                       game.quad[sectx][secty] == IHDOT) break;\r
                        }\r
                        if (l < 11) break; /* found a spot */\r
                        sectx=5;\r
@@ -156,7 +152,7 @@ void abandn(void) {
                }\r
        }\r
        /* Get new commission */\r
-       frozen.quad[sectx][secty] = ship = IHF;\r
+       game.quad[sectx][secty] = ship = IHF;\r
        prout("Starfleet puts you in command of another ship,");\r
        prout("the Faerie Queene, which is antiquated but,");\r
        prout("still useable.");\r
@@ -165,8 +161,8 @@ void abandn(void) {
        iscraft=0; /* Gallileo disappears */\r
        /* Resupply ship */\r
        condit=IHDOCKED;\r
-       for (l = 1; l <= ndevice; l++) frozen.damage[l] = 0.0;\r
-       frozen.damage[DSHUTTL] = -1;\r
+       for (l = 1; l <= ndevice; l++) game.damage[l] = 0.0;\r
+       game.damage[DSHUTTL] = -1;\r
        energy = inenrg = 3000.0;\r
        shield = inshld = 1250.0;\r
        torps = intorps = 6;\r
@@ -199,27 +195,27 @@ void setup(void) {
        nprobes = (int)(3.0*Rand() + 2.0);      /* Give them 2-4 of these wonders */\r
        warpfac = 5.0;\r
        wfacsq = warpfac * warpfac;\r
-       for (i=0; i <= ndevice; i++) frozen.damage[i] = 0.0;\r
+       for (i=0; i <= ndevice; i++) game.damage[i] = 0.0;\r
        // Set up assorted game parameters\r
        batx = baty = 0;\r
-       state.date = indate = 100.0*(int)(31.0*Rand()+20.0);\r
-       state.killk = state.killc = nkinks = nhelp = resting = casual = state.nromkl = 0;\r
-       isatb = iscate = imine = icrystl = icraft = state.nsckill = state.nplankl = 0;\r
+       game.state.date = indate = 100.0*(int)(31.0*Rand()+20.0);\r
+       game.state.killk = game.state.killc = nkinks = nhelp = resting = casual = game.state.nromkl = 0;\r
+       isatb = iscate = imine = icrystl = icraft = game.state.nsckill = game.state.nplankl = 0;\r
        iscraft = 1;\r
        landed = -1;\r
        alive = 1;\r
        docfac = 0.25;\r
        for (i = 1; i <= 8; i++)\r
-               for (j = 1; j <= 8; j++) state.newstuf[i][j] = frozen.starch[i][j] = 0;\r
+               for (j = 1; j <= 8; j++) game.state.newstuf[i][j] = game.starch[i][j] = 0;\r
        // Initialize times for extraneous events\r
-       frozen.future[FSNOVA] = state.date + expran(0.5 * intime);\r
-       frozen.future[FTBEAM] = state.date + expran(1.5 * (intime / state.remcom));\r
-       frozen.future[FSNAP] = state.date + 1.0 + Rand(); // Force an early snapshot\r
-       frozen.future[FBATTAK] = state.date + expran(0.3*intime);\r
-       frozen.future[FCDBAS] = 1e30;\r
-       frozen.future[FSCMOVE] = state.nscrem ? state.date+0.2777 : 1e30;\r
-       frozen.future[FSCDBAS] = 1e30;\r
-       frozen.future[FDSPROB] = 1e30;\r
+       game.future[FSNOVA] = game.state.date + expran(0.5 * intime);\r
+       game.future[FTBEAM] = game.state.date + expran(1.5 * (intime / game.state.remcom));\r
+       game.future[FSNAP] = game.state.date + 1.0 + Rand(); // Force an early snapshot\r
+       game.future[FBATTAK] = game.state.date + expran(0.3*intime);\r
+       game.future[FCDBAS] = 1e30;\r
+       game.future[FSCMOVE] = game.state.nscrem ? game.state.date+0.2777 : 1e30;\r
+       game.future[FSCDBAS] = 1e30;\r
+       game.future[FDSPROB] = 1e30;\r
        // Starchart is functional\r
        stdamtim = 1e30;\r
        // Put stars in the galaxy\r
@@ -228,18 +224,18 @@ void setup(void) {
                for (j=1; j<=8; j++) {\r
                        int k = Rand()*9.0 + 1.0;\r
                        instar += k;\r
-                       state.galaxy[i][j] = k;\r
+                       game.state.galaxy[i][j] = k;\r
                }\r
        // Locate star bases in galaxy\r
        for (i = 1; i <= inbase; i++) {\r
                int contflag;\r
                do {\r
                        do iran8(&ix, &iy);\r
-                       while (state.galaxy[ix][iy] >= 10);\r
+                       while (game.state.galaxy[ix][iy] >= 10);\r
                        contflag = FALSE;\r
                        for (j = i-1; j > 0; j--) {\r
                                /* Improved placement algorithm to spread out bases */\r
-                               double distq = square(ix-state.baseqx[j]) + square(iy-state.baseqy[j]);\r
+                               double distq = square(ix-game.state.baseqx[j]) + square(iy-game.state.baseqy[j]);\r
                                if (distq < 6.0*(6-inbase) && Rand() < 0.75) {\r
                                        contflag = TRUE;\r
 #ifdef DEBUG\r
@@ -255,13 +251,13 @@ void setup(void) {
                        }\r
                } while (contflag);\r
                        \r
-               state.baseqx[i] = ix;\r
-               state.baseqy[i] = iy;\r
-               frozen.starch[ix][iy] = -1;\r
-               state.galaxy[ix][iy] += 10;\r
+               game.state.baseqx[i] = ix;\r
+               game.state.baseqy[i] = iy;\r
+               game.starch[ix][iy] = -1;\r
+               game.state.galaxy[ix][iy] += 10;\r
        }\r
        // Position ordinary Klingon Battle Cruisers\r
-       krem = inkling - incom - state.nscrem;\r
+       krem = inkling - incom - game.state.nscrem;\r
        klumper = 0.25*skill*(9.0-length)+1.0;\r
        if (klumper > 9) klumper = 9; // Can't have more than 9 in quadrant\r
        do {\r
@@ -271,8 +267,8 @@ void setup(void) {
                krem -= klump;\r
                klump *= 100;\r
                do iran8(&ix, &iy);\r
-               while (state.galaxy[ix][iy] + klump >= 1000);\r
-               state.galaxy[ix][iy] += klump;\r
+               while (game.state.galaxy[ix][iy] + klump >= 1000);\r
+               game.state.galaxy[ix][iy] += klump;\r
        } while (krem > 0);\r
        // Position Klingon Commander Ships\r
 #ifdef DEBUG\r
@@ -283,47 +279,47 @@ void setup(void) {
                        do { /* IF debugging, put commanders by bases, always! */\r
 #ifdef DEBUG\r
                                if (idebug && klumper <= inbase) {\r
-                                       ix = state.baseqx[klumper];\r
-                                       iy = state.baseqy[klumper];\r
+                                       ix = game.state.baseqx[klumper];\r
+                                       iy = game.state.baseqy[klumper];\r
                                        klumper++;\r
                                }\r
                                else\r
 #endif\r
                                        iran8(&ix, &iy);\r
                        }\r
-                       while ((state.galaxy[ix][iy] < 99 && Rand() < 0.75)||\r
-                                  state.galaxy[ix][iy]>899);\r
+                       while ((game.state.galaxy[ix][iy] < 99 && Rand() < 0.75)||\r
+                                  game.state.galaxy[ix][iy]>899);\r
                        // check for duplicate\r
                        for (j = 1; j < i; j++)\r
-                               if (state.cx[j]==ix && state.cy[j]==iy) break;\r
+                               if (game.state.cx[j]==ix && game.state.cy[j]==iy) break;\r
                } while (j < i);\r
-               state.galaxy[ix][iy] += 100;\r
-               state.cx[i] = ix;\r
-               state.cy[i] = iy;\r
+               game.state.galaxy[ix][iy] += 100;\r
+               game.state.cx[i] = ix;\r
+               game.state.cy[i] = iy;\r
        }\r
        // Locate planets in galaxy\r
        for (i = 1; i <= inplan; i++) {\r
                do iran8(&ix, &iy);\r
-               while (state.newstuf[ix][iy] > 0);\r
-               state.newstuf[ix][iy] = 1;\r
-               state.plnets[i].x = ix;\r
-               state.plnets[i].y = iy;\r
-               state.plnets[i].pclass = Rand()*3.0 + 1.0; // Planet class M N or O\r
-               state.plnets[i].crystals = 1.5*Rand();          // 1 in 3 chance of crystals\r
-               state.plnets[i].known = 0;\r
+               while (game.state.newstuf[ix][iy] > 0);\r
+               game.state.newstuf[ix][iy] = 1;\r
+               game.state.plnets[i].x = ix;\r
+               game.state.plnets[i].y = iy;\r
+               game.state.plnets[i].pclass = Rand()*3.0 + 1.0; // Planet class M N or O\r
+               game.state.plnets[i].crystals = 1.5*Rand();             // 1 in 3 chance of crystals\r
+               game.state.plnets[i].known = 0;\r
        }\r
        // Locate Romulans\r
-       for (i = 1; i <= state.nromrem; i++) {\r
+       for (i = 1; i <= game.state.nromrem; i++) {\r
                iran8(&ix, &iy);\r
-               state.newstuf[ix][iy] += 10;\r
+               game.state.newstuf[ix][iy] += 10;\r
        }\r
        // Locate the Super Commander\r
-       if (state.nscrem > 0) {\r
+       if (game.state.nscrem > 0) {\r
                do iran8(&ix, &iy);\r
-               while (state.galaxy[ix][iy] >= 900);\r
-               state.isx = ix;\r
-               state.isy = iy;\r
-               state.galaxy[ix][iy] += 100;\r
+               while (game.state.galaxy[ix][iy] >= 900);\r
+               game.state.isx = ix;\r
+               game.state.isy = iy;\r
+               game.state.galaxy[ix][iy] += 100;\r
        }\r
        // Place thing (in tournament game, thingx == -1, don't want one!)\r
        if (Rand() < 0.1 && thingx != -1) {\r
@@ -335,11 +331,11 @@ void setup(void) {
 \r
 //     idate = date;\r
        skip(3);\r
-       state.snap = 0;\r
+       game.state.snap = 0;\r
                \r
        if (skill == 1) {\r
                printf("It is stardate %d. The Federation is being attacked by\n",\r
-                          (int)state.date);\r
+                          (int)game.state.date);\r
                printf("a deadly Klingon invasion force. As captain of the United\n"\r
                           "Starship U.S.S. Enterprise, it is your mission to seek out\n"\r
                           "and destroy this invasion force of %d battle cruisers.\n",\r
@@ -353,12 +349,12 @@ void setup(void) {
        else {\r
                printf("Stardate %d.\n\n"\r
                           "%d Klingons.\nAn unknown number of Romulans\n",\r
-                          (int)state.date, inkling);\r
-               if (state.nscrem) printf("and one (GULP) Super-Commander.\n");\r
+                          (int)game.state.date, inkling);\r
+               if (game.state.nscrem) printf("and one (GULP) Super-Commander.\n");\r
                printf("%d stardates\n%d starbases in  ",(int)intime, inbase);\r
        }\r
        for (i = 1; i <= inbase; i++) {\r
-               cramlc(0, state.baseqx[i], state.baseqy[i]);\r
+               cramlc(0, game.state.baseqx[i], game.state.baseqy[i]);\r
                if (i < inbase) proutn("  ");\r
        }\r
        skip(2);\r
@@ -368,7 +364,7 @@ void setup(void) {
        cramlc(2, sectx, secty);\r
        skip(2);\r
        prout("Good Luck!");\r
-       if (state.nscrem) proutn("  YOU'LL NEED IT.");\r
+       if (game.state.nscrem) proutn("  YOU'LL NEED IT.");\r
        skip(1);\r
        newqad(0);\r
        if (nenhere) shldup=1.0;\r
@@ -403,7 +399,7 @@ int choose(void) {
                if (isit("frozen")) {\r
                        thaw();\r
                        chew();\r
-                       if (*frozen.passwd==0) continue;\r
+                       if (*game.passwd==0) continue;\r
                        randomize();\r
                        Rand(); Rand(); Rand(); Rand();\r
                        if (!alldone) thawed = 1; // No plaque if not finished\r
@@ -445,54 +441,54 @@ int choose(void) {
        }\r
        while (TRUE) {\r
                scan();\r
-               strcpy(frozen.passwd, citem);\r
+               strcpy(game.passwd, citem);\r
                chew();\r
-               if (*frozen.passwd != 0) break;\r
+               if (*game.passwd != 0) break;\r
                proutn("Please type in a secret password-");\r
        }\r
 #ifdef DEBUG\r
-       if (strcmp(frozen.passwd, "debug")==0) idebug = 1;\r
+       if (strcmp(game.passwd, "debug")==0) idebug = 1;\r
 #endif\r
 \r
        // Use parameters to generate initial values of things\r
        damfac = 0.5 * skill;\r
-       state.rembase = 3.0*Rand()+2.0;\r
-       inbase = state.rembase;\r
+       game.state.rembase = 3.0*Rand()+2.0;\r
+       inbase = game.state.rembase;\r
        inplan = (PLNETMAX/2) + (PLNETMAX/2+1)*Rand();\r
-       state.nromrem = (2.0+Rand())*skill;\r
-       state.nscrem = (skill > 2? 1 : 0);\r
-       state.remtime = 7.0 * length;\r
-       intime = state.remtime;\r
-       state.remkl = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15);\r
-       inkling = state.remkl;\r
+       game.state.nromrem = (2.0+Rand())*skill;\r
+       game.state.nscrem = (skill > 2? 1 : 0);\r
+       game.state.remtime = 7.0 * length;\r
+       intime = game.state.remtime;\r
+       game.state.remkl = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15);\r
+       inkling = game.state.remkl;\r
        incom = skill + 0.0625*inkling*Rand();\r
-       state.remcom= min(10, incom);\r
-       incom = state.remcom;\r
-       state.remres = (inkling+4*incom)*intime;\r
-       inresor = state.remres;\r
+       game.state.remcom= min(10, incom);\r
+       incom = game.state.remcom;\r
+       game.state.remres = (inkling+4*incom)*intime;\r
+       inresor = game.state.remres;\r
        if (inkling > 50) {\r
-               inbase = (state.rembase += 1);\r
+               inbase = (game.state.rembase += 1);\r
        }\r
        return FALSE;\r
 }\r
 \r
 void dropin(int iquad, int *ix, int *iy) {\r
        do iran10(ix, iy);\r
-       while (frozen.quad[*ix][*iy] != IHDOT);\r
-       frozen.quad[*ix][*iy] = iquad;\r
+       while (game.quad[*ix][*iy] != IHDOT);\r
+       game.quad[*ix][*iy] = iquad;\r
 }\r
 \r
 void newcnd(void) {\r
        condit = IHGREEN;\r
        if (energy < 1000.0) condit = IHYELLOW;\r
-       if (state.galaxy[quadx][quady] > 99 || state.newstuf[quadx][quady] > 9)\r
+       if (game.state.galaxy[quadx][quady] > 99 || game.state.newstuf[quadx][quady] > 9)\r
                condit = IHRED;\r
 }\r
 \r
 \r
 void newqad(int shutup) {\r
-       int quadnum = state.galaxy[quadx][quady];\r
-       int newnum = state.newstuf[quadx][quady];\r
+       int quadnum = game.state.galaxy[quadx][quady];\r
+       int newnum = game.state.newstuf[quadx][quady];\r
        int i, j, ix, iy, nplan;\r
 \r
        iattak = 1;\r
@@ -518,7 +514,7 @@ void newqad(int shutup) {
        }\r
        // Clear quadrant\r
        for (i=1; i <= 10; i++)\r
-               for (j=1; j <= 10; j++) frozen.quad[i][j] = IHDOT;\r
+               for (j=1; j <= 10; j++) game.quad[i][j] = IHDOT;\r
        // cope with supernova\r
        if (quadnum > 999) {\r
                return;\r
@@ -529,27 +525,27 @@ void newqad(int shutup) {
        nenhere = klhere + irhere;\r
 \r
        // Position Starship\r
-       frozen.quad[sectx][secty] = ship;\r
+       game.quad[sectx][secty] = ship;\r
 \r
        // Decide if quadrant needs a Tholian\r
        if ((skill < 3 && Rand() <= 0.02) ||   /* Lighten up if skill is low */\r
                (skill == 3 && Rand() <= 0.05) ||\r
                (skill > 3 && Rand() <= 0.08)\r
 #ifdef DEBUG\r
-               || strcmp(frozen.passwd, "tholianx")==0\r
+               || strcmp(game.passwd, "tholianx")==0\r
 #endif\r
                ) {\r
                do {\r
                        ithx = Rand() > 0.5 ? 10 : 1;\r
                        ithy = Rand() > 0.5 ? 10 : 1;\r
-               } while (frozen.quad[ithx][ithy] != IHDOT);\r
-               frozen.quad[ithx][ithy] = IHT;\r
+               } while (game.quad[ithx][ithy] != IHDOT);\r
+               game.quad[ithx][ithy] = IHT;\r
                ithere = 1;\r
                /* Reserve unocupied corners */\r
-               if (frozen.quad[1][1]==IHDOT) frozen.quad[1][1] = 'X';\r
-               if (frozen.quad[1][10]==IHDOT) frozen.quad[1][10] = 'X';\r
-               if (frozen.quad[10][1]==IHDOT) frozen.quad[10][1] = 'X';\r
-               if (frozen.quad[10][10]==IHDOT) frozen.quad[10][10] = 'X';\r
+               if (game.quad[1][1]==IHDOT) game.quad[1][1] = 'X';\r
+               if (game.quad[1][10]==IHDOT) game.quad[1][10] = 'X';\r
+               if (game.quad[10][1]==IHDOT) game.quad[10][1] = 'X';\r
+               if (game.quad[10][10]==IHDOT) game.quad[10][10] = 'X';\r
        }\r
 \r
        if (quadnum >= 100) {\r
@@ -557,25 +553,25 @@ void newqad(int shutup) {
                quadnum -= 100*klhere;\r
                for (i = 1; i <= klhere; i++) {\r
                        dropin(IHK, &ix, &iy);\r
-                       frozen.kx[i] = ix;\r
-                       frozen.ky[i] = iy;\r
-                       frozen.kdist[i] = frozen.kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy));\r
-                       frozen.kpower[i] = Rand()*150.0 +300.0 +25.0*skill;\r
+                       game.kx[i] = ix;\r
+                       game.ky[i] = iy;\r
+                       game.kdist[i] = game.kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy));\r
+                       game.kpower[i] = Rand()*150.0 +300.0 +25.0*skill;\r
                }\r
                // If we need a commander, promote a Klingon\r
-               for (i = 1; i <= state.remcom ; i++) \r
-                       if (state.cx[i]==quadx && state.cy[i]==quady) break;\r
+               for (i = 1; i <= game.state.remcom ; i++) \r
+                       if (game.state.cx[i]==quadx && game.state.cy[i]==quady) break;\r
                        \r
-               if (i <= state.remcom) {\r
-                       frozen.quad[ix][iy] = IHC;\r
-                       frozen.kpower[klhere] = 950.0+400.0*Rand()+50.0*skill;\r
+               if (i <= game.state.remcom) {\r
+                       game.quad[ix][iy] = IHC;\r
+                       game.kpower[klhere] = 950.0+400.0*Rand()+50.0*skill;\r
                        comhere = 1;\r
                }\r
 \r
                // If we need a super-commander, promote a Klingon\r
-               if (quadx == state.isx && quady == state.isy) {\r
-                       frozen.quad[frozen.kx[1]][frozen.ky[1]] = IHS;\r
-                       frozen.kpower[1] = 1175.0 + 400.0*Rand() + 125.0*skill;\r
+               if (quadx == game.state.isx && quady == game.state.isy) {\r
+                       game.quad[game.kx[1]][game.ky[1]] = IHS;\r
+                       game.kpower[1] = 1175.0 + 400.0*Rand() + 125.0*skill;\r
                        iscate = 1;\r
                        ishere = 1;\r
                }\r
@@ -583,10 +579,10 @@ void newqad(int shutup) {
        // Put in Romulans if needed\r
        for (i = klhere+1; i <= nenhere; i++) {\r
                dropin(IHR, &ix, &iy);\r
-               frozen.kx[i] = ix;\r
-               frozen.ky[i] = iy;\r
-               frozen.kdist[i] = frozen.kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy));\r
-               frozen.kpower[i] = Rand()*400.0 + 450.0 + 50.0*skill;\r
+               game.kx[i] = ix;\r
+               game.ky[i] = iy;\r
+               game.kdist[i] = game.kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy));\r
+               game.kpower[i] = Rand()*400.0 + 450.0 + 50.0*skill;\r
        }\r
        sortkl();\r
        // If quadrant needs a starbase, put it in\r
@@ -598,7 +594,7 @@ void newqad(int shutup) {
        if (nplan) {\r
                // If quadrant needs a planet, put it in\r
                for (i=1; i <= inplan; i++)\r
-                       if (state.plnets[i].x == quadx && state.plnets[i].y == quady) break;\r
+                       if (game.state.plnets[i].x == quadx && game.state.plnets[i].y == quady) break;\r
                if (i <= inplan) {\r
                        iplnet = i;\r
                        dropin(IHP, &plnetx, &plnety);\r
@@ -612,7 +608,7 @@ void newqad(int shutup) {
        // Check for RNZ\r
        if (irhere > 0 && klhere == 0 && basex == 0) {\r
                neutz = 1;\r
-               if (frozen.damage[DRADIO] <= 0.0) {\r
+               if (game.damage[DRADIO] <= 0.0) {\r
                        skip(1);\r
                        prout("LT. Uhura- \"Captain, an urgent message.");\r
                        prout("  I'll put it on audio.\"  CLICK");\r
@@ -627,7 +623,7 @@ void newqad(int shutup) {
                if (thingx == quadx && thingy == quady) {\r
                        dropin(IHQUEST, &ix, &iy);\r
                        thingx = thingy = 0; // Transient\r
-                       if (frozen.damage[DSRSENS] == 0.0) {\r
+                       if (game.damage[DSRSENS] == 0.0) {\r
                                skip(1);\r
                                prout("MR. SPOCK- \"Captain, this is most unusual.");\r
                                prout("    Please examine your short-range scan.\"");\r
@@ -641,10 +637,10 @@ void newqad(int shutup) {
 \r
        // Take out X's in corners if Tholian present\r
        if (ithere) {\r
-               if (frozen.quad[1][1]=='X') frozen.quad[1][1] = IHDOT;\r
-               if (frozen.quad[1][10]=='X') frozen.quad[1][10] = IHDOT;\r
-               if (frozen.quad[10][1]=='X') frozen.quad[10][1] = IHDOT;\r
-               if (frozen.quad[10][10]=='X') frozen.quad[10][10] = IHDOT;\r
+               if (game.quad[1][1]=='X') game.quad[1][1] = IHDOT;\r
+               if (game.quad[1][10]=='X') game.quad[1][10] = IHDOT;\r
+               if (game.quad[10][1]=='X') game.quad[10][1] = IHDOT;\r
+               if (game.quad[10][10]=='X') game.quad[10][10] = IHDOT;\r
        }               \r
 }\r
 \r
@@ -659,23 +655,23 @@ void sortkl(void) {
        do {\r
                sw = FALSE;\r
                for (j = 1; j < nenhere; j++)\r
-                       if (frozen.kdist[j] > frozen.kdist[j+1]) {\r
+                       if (game.kdist[j] > game.kdist[j+1]) {\r
                                sw = TRUE;\r
-                               t = frozen.kdist[j];\r
-                               frozen.kdist[j] = frozen.kdist[j+1];\r
-                               frozen.kdist[j+1] = t;\r
-                               t = frozen.kavgd[j];\r
-                               frozen.kavgd[j] = frozen.kavgd[j+1];\r
-                               frozen.kavgd[j+1] = t;\r
-                               k = frozen.kx[j];\r
-                               frozen.kx[j] = frozen.kx[j+1];\r
-                               frozen.kx[j+1] = k;\r
-                               k = frozen.ky[j];\r
-                               frozen.ky[j] = frozen.ky[j+1];\r
-                               frozen.ky[j+1] = k;\r
-                               t = frozen.kpower[j];\r
-                               frozen.kpower[j] = frozen.kpower[j+1];\r
-                               frozen.kpower[j+1] = t;\r
+                               t = game.kdist[j];\r
+                               game.kdist[j] = game.kdist[j+1];\r
+                               game.kdist[j+1] = t;\r
+                               t = game.kavgd[j];\r
+                               game.kavgd[j] = game.kavgd[j+1];\r
+                               game.kavgd[j+1] = t;\r
+                               k = game.kx[j];\r
+                               game.kx[j] = game.kx[j+1];\r
+                               game.kx[j+1] = k;\r
+                               k = game.ky[j];\r
+                               game.ky[j] = game.ky[j+1];\r
+                               game.ky[j+1] = k;\r
+                               t = game.kpower[j];\r
+                               game.kpower[j] = game.kpower[j+1];\r
+                               game.kpower[j+1] = t;\r
                        }\r
        } while (sw);\r
 }\r
diff --git a/sst.c b/sst.c
index 55066eb7fdeaa9b487647493486b2c434834a739..31202254ae78c2a785f392a4c7d46970522c777b 100644 (file)
--- a/sst.c
+++ b/sst.c
@@ -323,7 +323,7 @@ static void makemoves(void) {
                                events();\r
                                if (alldone) break;             // Events did us in\r
                        }\r
-                       if (state.galaxy[quadx][quady] == 1000) { // Galaxy went Nova!\r
+                       if (game.state.galaxy[quadx][quady] == 1000) { // Galaxy went Nova!\r
                                atover(0);\r
                                continue;\r
                        }\r
@@ -331,7 +331,7 @@ static void makemoves(void) {
                        if (hitme && justin==0) {\r
                                attack(2);\r
                                if (alldone) break;\r
-                               if (state.galaxy[quadx][quady] == 1000) {       // went NOVA! \r
+                               if (game.state.galaxy[quadx][quady] == 1000) {  // went NOVA! \r
                                        atover(0);\r
                                        hitme = TRUE;\r
                                        continue;\r
@@ -657,7 +657,7 @@ void debugme(void) {
                        key = scan();\r
                        if (key == IHALPHA &&  isit("y")) {\r
                                damage[i] = 10.0;\r
-                               if (i == DRADIO) stdamtim = state.date;\r
+                               if (i == DRADIO) stdamtim = game.state.date;\r
                        }\r
                }\r
        }\r
@@ -676,12 +676,12 @@ void debugme(void) {
                                case FSCMOVE: proutn("SC Move         "); break;\r
                                case FSCDBAS: proutn("SC Base Destroy "); break;\r
                        }\r
-                       cramf(future[i]-state.date, 8, 2);\r
+                       cramf(future[i]-game.state.date, 8, 2);\r
                        chew();\r
                        proutn("  ?");\r
                        key = scan();\r
                        if (key == IHREAL) {\r
-                               future[i] = state.date + aaitem;\r
+                               future[i] = game.state.date + aaitem;\r
                        }\r
                }\r
                chew();\r
diff --git a/sst.h b/sst.h
index e0f9bd5d00e87d61309df3997c0cff4ddf1d1947..c93fbc5deccba64d4934c4c3259879e204a8ca3a 100644 (file)
--- a/sst.h
+++ b/sst.h
@@ -21,33 +21,33 @@ typedef struct {
        int pclass; /* class M, N, or O (1, 2, or 3) */\r
        int crystals; /* has crystals */\r
        int known;   /* =1 contents known, =2 shuttle on this planet */\r
-} PLANETS;\r
+} planet;\r
 \r
-EXTERN struct foo {\r
-               int snap,               // snapshot taken\r
-               remkl,                  // remaining klingons\r
-           remcom,                     // remaining commanders\r
-               rembase,                // remaining bases\r
-               starkl,                 // destroyed stars\r
-               basekl,                 // destroyed bases\r
-               killk,                  // Klingons killed\r
-               killc,                  // commanders killed\r
-               galaxy[9][9],   // The Galaxy (subscript 0 not used)\r
-               cx[11],cy[11],  // Commander quadrant coordinates\r
-               baseqx[6],              // Base quadrant X\r
-               baseqy[6],              // Base quadrant Y\r
-               newstuf[9][9],  // Extended galaxy goodies\r
-               isx, isy,               // Coordinate of Super Commander\r
-               nscrem,                 // remaining super commanders\r
-               nromkl,                 // Romulans killed\r
-               nromrem,                // Romulans remaining\r
-               nsckill,                // super commanders killed\r
-               nplankl;                // destroyed planets\r
-       PLANETS plnets[PLNETMAX+1];  // Planet information\r
+typedef struct {\r
+    int snap,          // snapshot taken\r
+       remkl,                  // remaining klingons\r
+       remcom,                 // remaining commanders\r
+       rembase,                // remaining bases\r
+       starkl,                 // destroyed stars\r
+       basekl,                 // destroyed bases\r
+       killk,                  // Klingons killed\r
+       killc,                  // commanders killed\r
+       galaxy[9][9],   // The Galaxy (subscript 0 not used)\r
+       cx[11],cy[11],  // Commander quadrant coordinates\r
+       baseqx[6],              // Base quadrant X\r
+       baseqy[6],              // Base quadrant Y\r
+       newstuf[9][9],  // Extended galaxy goodies\r
+       isx, isy,               // Coordinate of Super Commander\r
+       nscrem,                 // remaining super commanders\r
+       nromkl,                 // Romulans killed\r
+       nromrem,                // Romulans remaining\r
+       nsckill,                // super commanders killed\r
+       nplankl;                // destroyed planets\r
+       planet plnets[PLNETMAX+1];  // Planet information\r
        double date,            // stardate\r
-               remres,                 // remaining resources\r
+           remres,             // remaining resources\r
            remtime;            // remaining time\r
-} state, snapsht;                      // Data that is snapshot\r
+} snapshot;                            // Data that is snapshot\r
 \r
 // Scalar variables that are needed for freezing the game\r
 // are placed in a structure. #defines are used to access by their\r
@@ -55,6 +55,8 @@ EXTERN struct foo {
 // but I just didn't think of it back when I started.\r
 \r
 EXTERN struct foo2 {\r
+    snapshot state;\r
+    snapshot snapsht;\r
     char quad[11][11];         // contents of our quadrant\r
     double kpower[21];         // enemy energy levels\r
     double kdist[21];          // enemy distances\r
@@ -129,7 +131,7 @@ EXTERN struct foo2 {
        proben,\r
        isarmed,\r
        nprobes;\r
-       double inresor,\r
+    double inresor,\r
        intime,\r
        inenrg,\r
        inshld,\r
@@ -153,102 +155,104 @@ EXTERN struct foo2 {
        probey,\r
        probeinx,\r
        probeiny;\r
-} frozen;\r
+} game;\r
 \r
-#define inkling frozen.inkling         // Initial number of klingons\r
-#define inbase frozen.inbase                   // Initial number of bases\r
-#define incom frozen.incom                     // Initian number of commanders\r
-#define instar frozen.instar                   // Initial stars\r
-#define intorps frozen.intorps         // Initial/Max torpedoes\r
-#define condit frozen.condit                   // Condition (red, yellow, green docked)\r
-#define torps frozen.torps                     // number of torpedoes\r
-#define ship frozen.ship                               // Ship type -- 'E' is Enterprise\r
-#define quadx frozen.quadx                     // where we are\r
-#define quady frozen.quady                     //\r
-#define sectx frozen.sectx                     // where we are\r
-#define secty frozen.secty                     //\r
-#define length frozen.length                   // length of game\r
-#define skill frozen.skill                     // skill level\r
-#define basex frozen.basex                     // position of base in current quad\r
-#define basey frozen.basey                     //\r
-#define klhere frozen.klhere                   // klingons here\r
-#define comhere frozen.comhere         // commanders here\r
-#define casual frozen.casual                   // causalties\r
-#define nhelp frozen.nhelp                     // calls for help\r
-#define nkinks frozen.nkinks                   //\r
-#define ididit frozen.ididit                   // Action taken -- allows enemy to attack\r
-#define gamewon frozen.gamewon         // Finished!\r
-#define alive frozen.alive                     // We are alive (not killed)\r
-#define justin frozen.justin                   // just entered quadrant\r
-#define alldone frozen.alldone         // game is now finished\r
-#define shldchg frozen.shldchg         // shield is changing (affects efficiency)\r
-#define thingx frozen.thingx                   // location of strange object in galaxy\r
-#define thingy frozen.thingy                   //\r
-#define plnetx frozen.plnetx                   // location of planet in quadrant\r
-#define plnety frozen.plnety                   //\r
-#define inorbit frozen.inorbit         // orbiting\r
-#define landed frozen.landed                   // party on planet (1), on ship (-1)\r
-#define iplnet frozen.iplnet                   // planet # in quadrant\r
-#define imine frozen.imine                     // mining\r
-#define inplan frozen.inplan                   // initial planets\r
-#define nenhere frozen.nenhere         // Number of enemies in quadrant\r
-#define ishere frozen.ishere                   // Super-commander in quandrant\r
-#define neutz frozen.neutz                     // Romulan Neutral Zone\r
-#define irhere frozen.irhere                   // Romulans in quadrant\r
-#define icraft frozen.icraft                   // Kirk in Galileo\r
-#define ientesc frozen.ientesc         // Attempted escape from supercommander\r
-#define iscraft frozen.iscraft         // =1 if craft on ship, -1 if removed from game\r
-#define isatb frozen.isatb                     // =1 if SuperCommander is attacking base\r
-#define iscate frozen.iscate                   // Super Commander is here\r
+#define inkling game.inkling           // Initial number of klingons\r
+#define inbase game.inbase                     // Initial number of bases\r
+#define incom game.incom                       // Initian number of commanders\r
+#define instar game.instar                     // Initial stars\r
+#define intorps game.intorps           // Initial/Max torpedoes\r
+#define condit game.condit                     // Condition (red, yellow, green docked)\r
+#define torps game.torps                       // number of torpedoes\r
+#define ship game.ship                         // Ship type -- 'E' is Enterprise\r
+#define quadx game.quadx                       // where we are\r
+#define quady game.quady                       //\r
+#define sectx game.sectx                       // where we are\r
+#define secty game.secty                       //\r
+#define length game.length                     // length of game\r
+#define skill game.skill                       // skill level\r
+#define basex game.basex                       // position of base in current quad\r
+#define basey game.basey                       //\r
+#define klhere game.klhere                     // klingons here\r
+#define comhere game.comhere           // commanders here\r
+#define casual game.casual                     // causalties\r
+#define nhelp game.nhelp                       // calls for help\r
+#define nkinks game.nkinks                     //\r
+#define ididit game.ididit                     // Action taken -- allows enemy to attack\r
+#define gamewon game.gamewon           // Finished!\r
+#define alive game.alive                       // We are alive (not killed)\r
+#define justin game.justin                     // just entered quadrant\r
+#define alldone game.alldone           // game is now finished\r
+#define shldchg game.shldchg           // shield is changing (affects efficiency)\r
+#define thingx game.thingx                     // location of strange object in galaxy\r
+#define thingy game.thingy                     //\r
+#define plnetx game.plnetx                     // location of planet in quadrant\r
+#define plnety game.plnety                     //\r
+#define inorbit game.inorbit           // orbiting\r
+#define landed game.landed                     // party on planet (1), on ship (-1)\r
+#define iplnet game.iplnet                     // planet # in quadrant\r
+#define imine game.imine                       // mining\r
+#define inplan game.inplan                     // initial planets\r
+#define nenhere game.nenhere           // Number of enemies in quadrant\r
+#define ishere game.ishere                     // Super-commander in quandrant\r
+#define neutz game.neutz                       // Romulan Neutral Zone\r
+#define irhere game.irhere                     // Romulans in quadrant\r
+#define icraft game.icraft                     // Kirk in Galileo\r
+#define ientesc game.ientesc           // Attempted escape from supercommander\r
+#define iscraft game.iscraft           // =1 if craft on ship, -1 if removed from game\r
+#define isatb game.isatb                       // =1 if SuperCommander is attacking base\r
+#define iscate game.iscate                     // Super Commander is here\r
 #ifdef DEBUG\r
-#define idebug frozen.idebug                   // Debug mode\r
+#define idebug game.idebug                     // Debug mode\r
 #endif\r
-#define iattak frozen.iattak                   // attack recursion elimination (was cracks[4])\r
-#define icrystl frozen.icrystl         // dilithium crystals aboard\r
-#define tourn frozen.tourn                     // Tournament number\r
-#define thawed frozen.thawed                   // Thawed game\r
-#define batx frozen.batx                               // Base coordinates being attacked\r
-#define baty frozen.baty                               //\r
-#define ithere frozen.ithere                   // Tholean is here \r
-#define ithx frozen.ithx                               // coordinates of tholean\r
-#define ithy frozen.ithy\r
-#define iseenit frozen.iseenit         // Seen base attack report\r
-#define inresor frozen.inresor         // initial resources\r
-#define intime frozen.intime                   // initial time\r
-#define inenrg frozen.inenrg                   // Initial/Max Energy\r
-#define inshld frozen.inshld                   // Initial/Max Shield\r
-#define inlsr frozen.inlsr                     // initial life support resources\r
-#define indate frozen.indate                   // Initial date\r
-#define energy frozen.energy                   // Energy level\r
-#define shield frozen.shield                   // Shield level\r
-#define shldup frozen.shldup                   // Shields are up\r
-#define warpfac frozen.warpfac         // Warp speed\r
-#define wfacsq frozen.wfacsq                   // squared warp factor\r
-#define lsupres frozen.lsupres         // life support reserves\r
-#define dist frozen.dist                               // movement distance\r
-#define direc frozen.direc                     // movement direction\r
-#define Time frozen.Time                               // time taken by current operation\r
-#define docfac frozen.docfac                   // repair factor when docking (constant?)\r
-#define resting frozen.resting         // rest time\r
-#define damfac frozen.damfac                   // damage factor\r
-#define stdamtim frozen.stdamtim               // time that star chart was damaged\r
-#define cryprob frozen.cryprob         // probability that crystal will work\r
-#define probex frozen.probex                   // location of probe\r
-#define probey frozen.probey\r
-#define probecx frozen.probecx         // current probe quadrant\r
-#define probecy frozen.probecy \r
-#define probeinx frozen.probeinx               // Probe x,y increment\r
-#define probeiny frozen.probeiny               \r
-#define proben frozen.proben                   // number of moves for probe\r
-#define isarmed frozen.isarmed         // Probe is armed\r
-#define nprobes frozen.nprobes         // number of probes available\r
+#define iattak game.iattak                     // attack recursion elimination (was cracks[4])\r
+#define icrystl game.icrystl           // dilithium crystals aboard\r
+#define tourn game.tourn                       // Tournament number\r
+#define thawed game.thawed                     // Thawed game\r
+#define batx game.batx                         // Base coordinates being attacked\r
+#define baty game.baty                         //\r
+#define ithere game.ithere                     // Tholean is here \r
+#define ithx game.ithx                         // coordinates of tholean\r
+#define ithy game.ithy\r
+#define iseenit game.iseenit           // Seen base attack report\r
+#define inresor game.inresor           // initial resources\r
+#define intime game.intime                     // initial time\r
+#define inenrg game.inenrg                     // Initial/Max Energy\r
+#define inshld game.inshld                     // Initial/Max Shield\r
+#define inlsr game.inlsr                       // initial life support resources\r
+#define indate game.indate                     // Initial date\r
+#define energy game.energy                     // Energy level\r
+#define shield game.shield                     // Shield level\r
+#define shldup game.shldup                     // Shields are up\r
+#define warpfac game.warpfac           // Warp speed\r
+#define wfacsq game.wfacsq                     // squared warp factor\r
+#define lsupres game.lsupres           // life support reserves\r
+#define dist game.dist                         // movement distance\r
+#define direc game.direc                       // movement direction\r
+#define Time game.Time                         // time taken by current operation\r
+#define docfac game.docfac                     // repair factor when docking (constant?)\r
+#define resting game.resting           // rest time\r
+#define damfac game.damfac                     // damage factor\r
+#define stdamtim game.stdamtim         // time that star chart was damaged\r
+#define cryprob game.cryprob           // probability that crystal will work\r
+#define probex game.probex                     // location of probe\r
+#define probey game.probey\r
+#define probecx game.probecx           // current probe quadrant\r
+#define probecy game.probecy   \r
+#define probeinx game.probeinx         // Probe x,y increment\r
+#define probeiny game.probeiny         \r
+#define proben game.proben                     // number of moves for probe\r
+#define isarmed game.isarmed           // Probe is armed\r
+#define nprobes game.nprobes           // number of probes available\r
 \r
 /* the following global state doesn't need to be saved */\r
 EXTERN int fromcommandline; // Game start from command line options\r
 EXTERN char    *device[ndevice+1];\r
-EXTERN PLANETS nulplanet;      // zeroed planet structure\r
+EXTERN planet nulplanet;       // zeroed planet structure\r
 EXTERN int iscore, iskill; // Common PLAQ\r
 EXTERN double perdate;\r
+EXTERN double aaitem;\r
+EXTERN char citem[10];\r
 \r
 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,\r
               FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,\r
@@ -256,11 +260,6 @@ typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
                          FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,\r
                          FHOLE} FINTYPE ;\r
 \r
-\r
-EXTERN double aaitem;\r
-EXTERN char citem[10];\r
-\r
-\r
 /* Define devices */\r
 #define DSRSENS 1\r
 #define DLRSENS 2\r
@@ -291,7 +290,7 @@ EXTERN char citem[10];
 #define FDSPROB 8   // Move deep space probe\r
 \r
 #ifdef INCLUDED\r
-PLANETS nulplanet = {0};\r
+planet nulplanet = {0};\r
 char *device[ndevice+1] = {\r
        "",\r
        "S. R. Sensors",\r