Another step in coalescing all the globals.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 1 Nov 2004 00:00:39 +0000 (00:00 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 1 Nov 2004 00:00:39 +0000 (00:00 +0000)
ai.c
battle.c
events.c
finish.c
moving.c
planets.c
reports.c
setup.c
sst.h

diff --git a/ai.c b/ai.c
index 6b173b5eb1ca3c8752010ba4ea1cefbf76f19398..4572d4f9a851d23f8ac543f9c9613dbce5d60200 100644 (file)
--- a/ai.c
+++ b/ai.c
@@ -18,11 +18,11 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) {
                        if (batx==quadx && baty==quady) return 0;\r
                }\r
                /* don't leave if over 1000 units of energy */\r
-               if (kpower[loccom] > 1000.) return 0;\r
+               if (frozen.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 (damage[DSRSENS] == 0.0 || damage[DLRSENS] == 0.0 ||\r
+       if (frozen.damage[DSRSENS] == 0.0 || frozen.damage[DLRSENS] == 0.0 ||\r
                condit == IHDOCKED) {\r
                proutn("***");\r
                cramen(ienm);\r
@@ -31,11 +31,11 @@ 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
-       kx[loccom] = kx[nenhere];\r
-       ky[loccom] = ky[nenhere];\r
-       kavgd[loccom] = kavgd[nenhere];\r
-       kpower[loccom] = kpower[nenhere];\r
-       kdist[loccom] = kdist[nenhere];\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
        klhere--;\r
        nenhere--;\r
        if (condit != IHDOCKED) newcnd();\r
@@ -47,8 +47,8 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) {
                iscate=0;\r
                ientesc=0;\r
                isatb=0;\r
-               future[FSCMOVE]=0.2777+state.date;\r
-               future[FSCDBAS]=1e30;\r
+               frozen.future[FSCMOVE]=0.2777+state.date;\r
+               frozen.future[FSCDBAS]=1e30;\r
                state.isx=iqx;\r
                state.isy=iqy;\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 = kdist[loccom];\r
+       dist1 = frozen.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
-               (kpower[loccom] <= 500.0 || (condit==IHDOCKED && damage[DPHOTON]==0))) {\r
+               (frozen.kpower[loccom] <= 500.0 || (condit==IHDOCKED && frozen.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 = kpower[loccom]+100.0*nenhere+400*(nbaddys-1);\r
+               forces = frozen.kpower[loccom]+100.0*nenhere+400*(nbaddys-1);\r
                if (shldup==0) forces += 1000; /* Good for enemy if shield is down! */\r
-               if (damage[DPHASER] == 0.0 || damage[DPHOTON] == 0.0) {\r
-                       if (damage[DPHASER] != 0) /* phasers damaged */\r
+               if (frozen.damage[DPHASER] == 0.0 || frozen.damage[DPHOTON] == 0.0) {\r
+                       if (frozen.damage[DPHASER] != 0) /* phasers damaged */\r
                                forces += 300.0;\r
                        else\r
                                forces -= 0.2*(energy - 2500.0);\r
-                       if (damage[DPHOTON] != 0) /* photon torpedoes damaged */\r
+                       if (frozen.damage[DPHOTON] != 0) /* photon torpedoes damaged */\r
                                forces += 300.0;\r
                        else\r
                                forces -= 50.0*torps;\r
@@ -253,14 +253,14 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) {
        frozen.quad[nextx][nexty] = ienm;\r
        if (nextx != comx || nexty != comy) {\r
                /* it moved */\r
-               kx[loccom] = nextx;\r
-               ky[loccom] = nexty;\r
-               kdist[loccom] = kavgd[loccom] =\r
+               frozen.kx[loccom] = nextx;\r
+               frozen.ky[loccom] = nexty;\r
+               frozen.kdist[loccom] = frozen.kavgd[loccom] =\r
                                        sqrt(square(sectx-nextx)+square(secty-nexty));\r
-               if (damage[DSRSENS] == 0 || condit == IHDOCKED) {\r
+               if (frozen.damage[DSRSENS] == 0 || condit == IHDOCKED) {\r
                        proutn("***");\r
                        cramen(ienm);\r
-                       if (kdist[loccom] < dist1) proutn(" advances to");\r
+                       if (frozen.kdist[loccom] < dist1) proutn(" advances to");\r
                        else proutn(" retreats to");\r
                        cramlc(2, nextx, nexty);\r
                        skip(1);\r
@@ -278,16 +278,16 @@ 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 = kx[i];\r
-               iy = ky[i];\r
+               ix = frozen.kx[i];\r
+               iy = frozen.ky[i];\r
                if (frozen.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 = kx[i];\r
-               iy = ky[i];\r
+               ix = frozen.kx[i];\r
+               iy = frozen.ky[i];\r
                if (frozen.quad[ix][iy] == IHS) {\r
                        movebaddy(ix, iy, i, IHS);\r
                        break;\r
@@ -297,8 +297,8 @@ 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 = kx[i];\r
-               iy = ky[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
        }\r
@@ -329,15 +329,15 @@ static int checkdest(int iqx, int iqy, int flag, int *ipage) {
                isatb=0;\r
                ishere=0;\r
                ientesc=0;\r
-               future[FSCDBAS]=1e30;\r
+               frozen.future[FSCDBAS]=1e30;\r
                for (i = 1; i <= nenhere; i++) \r
-                       if (frozen.quad[kx[i]][ky[i]] == IHS) break;\r
-               frozen.quad[kx[i]][ky[i]] = IHDOT;\r
-               kx[i] = kx[nenhere];\r
-               ky[i] = ky[nenhere];\r
-               kdist[i] = kdist[nenhere];\r
-               kavgd[i] = kavgd[nenhere];\r
-               kpower[i] = kpower[nenhere];\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
                klhere--;\r
                nenhere--;\r
                if (condit!=IHDOCKED) newcnd();\r
@@ -350,7 +350,7 @@ static int checkdest(int iqx, int iqy, int flag, int *ipage) {
                        /* destroy the planet */\r
                        state.plnets[i] = nulplanet;\r
                        state.newstuf[state.isx][state.isy] -= 1;\r
-                       if (damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
+                       if (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
                                if (*ipage==0) pause(1);\r
                                *ipage = 1;\r
                                prout("Lt. Uhura-  \"Captain, Starfleet Intelligence reports");\r
@@ -396,7 +396,7 @@ void scom(int *ipage) {
                /* compute distances to starbases */\r
                if (state.rembase <= 0) {\r
                        /* nothing left to do */\r
-                       future[FSCMOVE] = 1e30;\r
+                       frozen.future[FSCMOVE] = 1e30;\r
                        return;\r
                }\r
                sx = state.isx;\r
@@ -498,7 +498,7 @@ void scom(int *ipage) {
        }\r
        /* check for a base */\r
        if (state.rembase == 0) {\r
-               future[FSCMOVE] = 1e30;\r
+               frozen.future[FSCMOVE] = 1e30;\r
        }\r
        else for (i=1; i<=state.rembase; i++) {\r
                ibqx = state.baseqx[i];\r
@@ -508,9 +508,9 @@ void scom(int *ipage) {
                        if (flag) return; /* no, don't attack base! */\r
                        iseenit = 0;\r
                        isatb=1;\r
-                       future[FSCDBAS] = state.date + 1.0 +2.0*Rand();\r
-                       if (batx != 0) future[FSCDBAS] += future[FCDBAS]-state.date;\r
-                       if (damage[DRADIO] > 0 && condit != IHDOCKED)\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
                                return; /* no warning */\r
                        iseenit = 1;\r
                        if (*ipage == 0)  pause(1);\r
@@ -520,7 +520,7 @@ void scom(int *ipage) {
                        skip(1);\r
                        prout("   reports that it is under attack from the Klingon Super-commander.");\r
                        proutn("   It can survive until stardate ");\r
-                       cramf(future[FSCDBAS], 0, 1);\r
+                       cramf(frozen.future[FSCDBAS], 0, 1);\r
                        prout(" .\"");\r
                        if (resting==0) return;\r
                        prout("Mr. Spock-  \"Captain, shall we cancel the rest period?\"");\r
@@ -536,8 +536,8 @@ void scom(int *ipage) {
                idebug==0 &&\r
 #endif\r
                (Rand() > 0.2 ||\r
-                (damage[DRADIO] > 0.0 && condit != IHDOCKED) ||\r
-                starch[state.isx][state.isy] > 0))\r
+                (frozen.damage[DRADIO] > 0.0 && condit != IHDOCKED) ||\r
+                frozen.starch[state.isx][state.isy] > 0))\r
                return;\r
        if (*ipage==0) pause(1);\r
        *ipage = 1;\r
index 2633a32f97829a480004336f66671c2bde642efb..11a1ca19a64cf7a420fbe316b8db36c2942ce69a 100644 (file)
--- a/battle.c
+++ b/battle.c
@@ -14,7 +14,7 @@ void doshield(int i) {
                                action = NRG;\r
                        else {\r
                                chew();\r
-                               if (damage[DSHIELD]) {\r
+                               if (frozen.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 (damage[DSHIELD]) {\r
+                       else if (frozen.damage[DSHIELD]) {\r
                                prout("Shields damaged and down.");\r
                                return;\r
                        }\r
@@ -158,9 +158,9 @@ 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 (damage[l] < 0) continue;\r
+               if (frozen.damage[l] < 0) continue;\r
                extradm = (10.0*type*Rand()+1.0)*damfac;\r
-               damage[l] += Time + extradm; /* Damage for at least time of travel! */\r
+               frozen.damage[l] += Time + extradm; /* Damage for at least time of travel! */\r
        }\r
        shldup = 0;\r
        if (state.remkl) {\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==kx[ll] && iy==ky[ll]) break;\r
-                               kp = fabs(kpower[ll]);\r
+                                       if (ix==frozen.kx[ll] && iy==frozen.ky[ll]) break;\r
+                               kp = fabs(frozen.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
-                               kpower[ll] -= (kpower[ll]<0 ? -h1 : h1);\r
-                               if (kpower[ll] == 0) {\r
+                               frozen.kpower[ll] -= (frozen.kpower[ll]<0 ? -h1 : h1);\r
+                               if (frozen.kpower[ll] == 0) {\r
                                        deadkl(ix, iy, iquad, ix, iy);\r
                                        return;\r
                                }\r
@@ -285,13 +285,13 @@ void torpedo(double course, double r, int inx, int iny, double *hit) {
                                        return;\r
                                }\r
                                prout(" damaged--");\r
-                               kx[ll] = jx;\r
-                               ky[ll] = jy;\r
+                               frozen.kx[ll] = jx;\r
+                               frozen.ky[ll] = jy;\r
                                shoved = 1;\r
                                break;\r
                        case IHB: /* Hit a base */\r
                                prout("***STARBASE DESTROYED..");\r
-                               if (starch[quadx][quady] < 0) starch[quadx][quady] = 0;\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
@@ -391,7 +391,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit) {
                cramlc(2, jx, jy);\r
                skip(1);\r
                for (ll=1; ll<=nenhere; ll++)\r
-                       kdist[ll] = kavgd[ll] = sqrt(square(sectx-kx[ll])+square(secty-ky[ll]));\r
+                       frozen.kdist[ll] = frozen.kavgd[ll] = sqrt(square(sectx-frozen.kx[ll])+square(secty-frozen.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 (damage[j] < 0.0 || (j == DSHUTTL && iscraft != 1) ||\r
+               } while (frozen.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
-               damage[j] += extradm;\r
+               frozen.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 (damage[DSHIELD] && shldup) {\r
+       if (frozen.damage[DSHIELD] && shldup) {\r
                prout("***Shields knocked down.");\r
                shldup=0;\r
        }\r
@@ -461,14 +461,14 @@ void attack(int k) {
        skip(1);\r
        if (skill <= 2) i = 2;\r
        for (l=1; l <= nenhere; l++) {\r
-               if (kpower[l] < 0) continue;    /* too weak to attack */\r
+               if (frozen.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 (kpower[l] < 500) r *= 0.25; \r
-               jx = kx[l];\r
-               jy = ky[l];\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
                itflag = (iquad == IHK && r > 0.0005) || k == 0 ||\r
                        (iquad==IHC && r > 0.015) ||\r
@@ -479,21 +479,21 @@ 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 = kpower[l]*pow(dustfac,kavgd[l]);\r
-                       kpower[l] *= 0.75;\r
+                       hit = frozen.kpower[l]*pow(dustfac,frozen.kavgd[l]);\r
+                       frozen.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 (damage[DSRSENS] <= 0.0) {\r
+                       if (frozen.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*kpower[l]*r;\r
+                       r += 0.002*frozen.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
@@ -519,11 +519,11 @@ void attack(int k) {
                ihurt = 1;\r
                cramf(hit, 0, 2);\r
                proutn(" unit hit");\r
-               if ((damage[DSRSENS] > 0 && itflag) || skill <= 2) {\r
+               if ((frozen.damage[DSRSENS] > 0 && itflag) || skill <= 2) {\r
                        proutn(" on the ");\r
                        crmshp();\r
                }\r
-               if (damage[DSRSENS] <= 0.0 && itflag) {\r
+               if (frozen.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 (damage[DSHIELD] == 0) proutn("down, ");\r
+               else if (frozen.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
-               kavgd[l] = kdist[l];\r
+               frozen.kavgd[l] = frozen.kdist[l];\r
        sortkl();\r
        return;\r
 }\r
@@ -614,9 +614,9 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) {
                                state.cx[state.remcom] = 0;\r
                                state.cy[state.remcom] = 0;\r
                                state.remcom--;\r
-                               future[FTBEAM] = 1e30;\r
+                               frozen.future[FTBEAM] = 1e30;\r
                                if (state.remcom != 0)\r
-                                       future[FTBEAM] = state.date + expran(1.0*incom/state.remcom);\r
+                                       frozen.future[FTBEAM] = state.date + expran(1.0*incom/state.remcom);\r
                                state.killc++;\r
                                break;\r
                        case IHK:\r
@@ -625,13 +625,13 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) {
                        case IHS:\r
                                state.nscrem = ishere = state.isx = state.isy = isatb = iscate = 0;\r
                                state.nsckill = 1;\r
-                               future[FSCMOVE] = future[FSCDBAS] = 1e30;\r
+                               frozen.future[FSCMOVE] = frozen.future[FSCDBAS] = 1e30;\r
                                break;\r
                }\r
        }\r
 \r
        /* For each kind of enemy, finish message to player */\r
-       prout(" destroyestate.");\r
+       prout(" destroyed.");\r
        frozen.quad[ix][iy] = IHDOT;\r
        if (state.remkl==0) return;\r
 \r
@@ -642,21 +642,21 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) {
        /* Remove enemy ship from arrays describing local conditions */\r
 \r
        for (i=1; i<=nenhere; i++)\r
-               if (kx[i]==ix && ky[i]==iy) break;\r
+               if (frozen.kx[i]==ix && frozen.ky[i]==iy) break;\r
        nenhere--;\r
        if (i <= nenhere)  {\r
                for (j=i; j<=nenhere; j++) {\r
-                       kx[j] = kx[j+1];\r
-                       ky[j] = ky[j+1];\r
-                       kpower[j] = kpower[j+1];\r
-                       kavgd[j] = kdist[j] = kdist[j+1];\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
                }\r
        }\r
-       kx[nenhere+1] = 0;\r
-       ky[nenhere+1] = 0;\r
-       kdist[nenhere+1] = 0;\r
-       kavgd[nenhere+1] = 0;\r
-       kpower[nenhere+1] = 0;\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
        return;\r
 }\r
 \r
@@ -688,7 +688,7 @@ void photon(void) {
 \r
        ididit = 0;\r
 \r
-       if (damage[DPHOTON]) {\r
+       if (frozen.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
-                               damage[DPHOTON] = damfac*(1.0+2.0*Rand());\r
+                               frozen.damage[DPHOTON] = damfac*(1.0+2.0*Rand());\r
                                break;\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
-                       damage[DPHASER] = damfac*(1.0 + Rand()) * (1.0+chekbrn);\r
+                       frozen.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 (damage[DSRSENS]+damage[DCOMPTR] > 0) ipoop = 0;\r
+       if (frozen.damage[DSRSENS]+frozen.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 (damage[DPHASER] != 0) {\r
+       if (frozen.damage[DPHASER] != 0) {\r
                prout("Phaser control damaged.");\r
                chew();\r
                return;\r
        }\r
        if (shldup) {\r
-               if (damage[DSHCTRL]) {\r
+               if (frozen.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(kpower[i])/(phasefac*pow(0.90,kdist[i]));\r
+                                       hits[i] = fabs(frozen.kpower[i])/(phasefac*pow(0.90,frozen.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 (damage[DCOMPTR]!=0)\r
+                       if (frozen.damage[DCOMPTR]!=0)\r
                                prout("Battle comuter damaged, manual file only.");\r
                        else {\r
                                skip(1);\r
@@ -1058,7 +1058,7 @@ void phasers(void) {
                case MANUAL:\r
                        rpow = 0.0;\r
                        for (k = 1; k <= nenhere;) {\r
-                               int ii = kx[k], jj = ky[k];\r
+                               int ii = frozen.kx[k], jj = frozen.ky[k];\r
                                int ienm = frozen.quad[ii][jj];\r
                                if (msgflag) {\r
                                        proutn("Energy available= ");\r
@@ -1067,7 +1067,7 @@ void phasers(void) {
                                        msgflag = 0;\r
                                        rpow = 0.0;\r
                                }\r
-                               if (damage[DSRSENS] && !(abs(sectx-ii) < 2 && abs(secty-jj) < 2) &&\r
+                               if (frozen.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(kpower[k])/(phasefac*pow(0.9,kdist[k])))*\r
+                                               int irec=(fabs(frozen.kpower[k])/(phasefac*pow(0.9,frozen.kdist[k])))*\r
                                                                 (1.01+0.05*Rand()) + 1.0;\r
                                                kz = k;\r
                                                proutn("(");\r
@@ -1176,14 +1176,14 @@ 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,kdist[kk]);\r
-               kpini = kpower[kk];\r
+               hit = wham*pow(dustfac,frozen.kdist[kk]);\r
+               kpini = frozen.kpower[kk];\r
                kp = fabs(kpini);\r
                if (phasefac*hit < kp) kp = phasefac*hit;\r
-               kpower[kk] -= (kpower[kk] < 0 ? -kp: kp);\r
-               kpow = kpower[kk];\r
-               ii = kx[kk];\r
-               jj = ky[kk];\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
                if (hit > 0.005) {\r
                        cramf(hit, 0, 2);\r
                        proutn(" unit hit on ");\r
@@ -1206,7 +1206,7 @@ void hittem(double *hits) {
                                cramlc(2,ii,jj);\r
                                skip(1);\r
                                prout("   has just lost its firepower.\"");\r
-                               kpower[kk] = -kpow;\r
+                               frozen.kpower[kk] = -kpow;\r
                        }\r
        }\r
        return;\r
index b94c05a76913ebaaf435b569bb68dc618d4cbff9..99591deca7b930793c69d4e7ff8a1a04616e205f 100644 (file)
--- a/events.c
+++ b/events.c
@@ -11,12 +11,12 @@ void events(void) {
        if (idebug) prout("EVENTS");\r
 #endif\r
 \r
-       if (stdamtim == 1e30 && damage[DRADIO] != 0.0) {\r
+       if (stdamtim == 1e30 && frozen.damage[DRADIO] != 0.0) {\r
                /* chart will no longer be updated because radio is dead */\r
                stdamtim = state.date;\r
                for (i=1; i <= 8 ; i++)\r
                        for (j=1; j <= 8; j++)\r
-                               if (starch[i][j] == 1) starch[i][j] = state.galaxy[i][j]+1000;\r
+                               if (frozen.starch[i][j] == 1) frozen.starch[i][j] = state.galaxy[i][j]+1000;\r
        }\r
 \r
        for (;;) {\r
@@ -25,9 +25,9 @@ void events(void) {
                if (alldone) return;\r
                datemin = fintim;\r
                for (l=1; l<=NEVENTS; l++)\r
-                       if (future[l] <= datemin) {\r
+                       if (frozen.future[l] <= datemin) {\r
                                line = l;\r
-                               datemin = future[l];\r
+                               datemin = frozen.future[l];\r
                        }\r
                xtime = datemin-state.date;\r
                state.date = datemin;\r
@@ -39,30 +39,30 @@ void events(void) {
                        return;\r
                }\r
                /* Is life support adequate? */\r
-               if (damage[DLIFSUP] && condit != IHDOCKED) {\r
-                       if (lsupres < xtime && damage[DLIFSUP] > lsupres) {\r
+               if (frozen.damage[DLIFSUP] && condit != IHDOCKED) {\r
+                       if (lsupres < xtime && frozen.damage[DLIFSUP] > lsupres) {\r
                                finish(FLIFESUP);\r
                                return;\r
                        }\r
                        lsupres -= xtime;\r
-                       if (damage[DLIFSUP] <= xtime) lsupres = inlsr;\r
+                       if (frozen.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 (damage[l] > 0.0 && l != DDRAY)\r
-                               damage[l] -= (damage[l]-repair > 0.0 ? repair : damage[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 radio repaired, update star chart and attack reports */\r
-               if (stdamtim != 1e30 && damage[DRADIO] == 0.0) {\r
+               if (stdamtim != 1e30 && frozen.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 (starch[i][j] > 999) starch[i][j] = 1;\r
+                                       if (frozen.starch[i][j] > 999) frozen.starch[i][j] = 1;\r
                        if (iseenit==0) {\r
                                attakreport();\r
                                iseenit = 1;\r
@@ -78,7 +78,7 @@ void events(void) {
                                if (ipage==0) pause(1);\r
                                ipage=1;\r
                                snova(0,0);\r
-                               future[FSNOVA] = state.date + expran(0.5*intime);\r
+                               frozen.future[FSNOVA] = state.date + expran(0.5*intime);\r
                                if (state.galaxy[quadx][quady] == 1000) return;\r
                                break;\r
                        case FSPY: /* Check with spy to see if S.C. should tractor beam */\r
@@ -87,10 +87,10 @@ void events(void) {
                                        condit==IHDOCKED || isatb==1 || iscate==1) return;\r
                                if (ientesc ||\r
                                        (energy < 2000 && torps < 4 && shield < 1250) ||\r
-                                       (damage[DPHASER]>0 && (damage[DPHOTON]>0 || torps < 4)) ||\r
-                                       (damage[DSHIELD] > 0 &&\r
-                                        (energy < 2500 || damage[DPHASER] > 0) &&\r
-                                        (torps < 5 || damage[DPHOTON] > 0))) {\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
                                        /* Tractor-beam her! */\r
                                        istract=1;\r
                                        yank = square(state.isx-quadx) + square(state.isy-quady);\r
@@ -100,14 +100,14 @@ void events(void) {
                        case FTBEAM: /* Tractor beam */\r
                                if (line==FTBEAM) {\r
                                        if (state.remcom == 0) {\r
-                                               future[FTBEAM] = 1e30;\r
+                                               frozen.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
                                        if (istract || condit == IHDOCKED || yank == 0) {\r
                                                /* Drats! Have to reschedule */\r
-                                               future[FTBEAM] = state.date + Time +\r
+                                               frozen.future[FTBEAM] = state.date + Time +\r
                                                                                 expran(1.5*intime/state.remcom);\r
                                                break;\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
-                                               damage[DSHUTTL] = -10;\r
+                                               frozen.damage[DSHUTTL] = -10;\r
                                                iscraft = -1;\r
                                        }\r
                                        else {\r
@@ -162,7 +162,7 @@ void events(void) {
                                        resting = 0;\r
                                }\r
                                if (shldup==0) {\r
-                                       if (damage[DSHIELD]==0 && shield > 0) {\r
+                                       if (frozen.damage[DSHIELD]==0 && shield > 0) {\r
                                                doshield(2); /* Shldsup */\r
                                                shldchg=0;\r
                                        }\r
@@ -171,18 +171,18 @@ void events(void) {
                                newqad(0);\r
                                /* Adjust finish time to time of tractor beaming */\r
                                fintim = state.date+Time;\r
-                               if (state.remcom <= 0) future[FTBEAM] = 1e30;\r
-                               else future[FTBEAM] = state.date+Time+expran(1.5*intime/state.remcom);\r
+                               if (state.remcom <= 0) frozen.future[FTBEAM] = 1e30;\r
+                               else frozen.future[FTBEAM] = state.date+Time+expran(1.5*intime/state.remcom);\r
                                break;\r
                        case FSNAP: /* Snapshot of the universe (for time warp) */\r
                                snapsht = state;\r
                                state.snap = 1;\r
-                               future[FSNAP] = state.date + expran(0.5 * intime);\r
+                               frozen.future[FSNAP] = state.date + expran(0.5 * intime);\r
                                break;\r
                        case FBATTAK: /* Commander attacks starbase */\r
                                if (state.remcom==0 || state.rembase==0) {\r
                                        /* no can do */\r
-                                       future[FBATTAK] = future[FCDBAS] = 1e30;\r
+                                       frozen.future[FBATTAK] = frozen.future[FCDBAS] = 1e30;\r
                                        break;\r
                                }\r
                                i = 0;\r
@@ -198,19 +198,19 @@ void events(void) {
                                }\r
                                if (j>state.rembase) {\r
                                        /* no match found -- try later */\r
-                                       future[FBATTAK] = state.date + expran(0.3*intime);\r
-                                       future[FCDBAS] = 1e30;\r
+                                       frozen.future[FBATTAK] = state.date + expran(0.3*intime);\r
+                                       frozen.future[FCDBAS] = 1e30;\r
                                        break;\r
                                }\r
                                /* commander + starbase combination found -- launch attack */\r
                                batx = state.baseqx[j];\r
                                baty = state.baseqy[j];\r
-                               future[FCDBAS] = state.date+1.0+3.0*Rand();\r
+                               frozen.future[FCDBAS] = state.date+1.0+3.0*Rand();\r
                                if (isatb) /* extra time if SC already attacking */\r
-                                       future[FCDBAS] += future[FSCDBAS]-state.date;\r
-                               future[FBATTAK] = future[FCDBAS] +expran(0.3*intime);\r
+                                       frozen.future[FCDBAS] += frozen.future[FSCDBAS]-state.date;\r
+                               frozen.future[FBATTAK] = frozen.future[FCDBAS] +expran(0.3*intime);\r
                                iseenit = 0;\r
-                               if (damage[DRADIO] != 0.0 &&\r
+                               if (frozen.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(future[FCDBAS],1,1);\r
+                               cramf(frozen.future[FCDBAS],1,1);\r
                                prout(".\"");\r
                                if (resting) {\r
                                        skip(1);\r
@@ -234,7 +234,7 @@ void events(void) {
                                }\r
                                break;\r
                        case FSCDBAS: /* Supercommander destroys base */\r
-                               future[FSCDBAS] = 1e30;\r
+                               frozen.future[FSCDBAS] = 1e30;\r
                                isatb = 2;\r
                                if (state.galaxy[state.isx][state.isy]%100 < 10) break; /* WAS RETURN! */\r
                                ixhold = batx;\r
@@ -243,7 +243,7 @@ void events(void) {
                                baty = state.isy;\r
                        case FCDBAS: /* Commander succeeds in destroying base */\r
                                if (line==FCDBAS) {\r
-                                       future[FCDBAS] = 1e30;\r
+                                       frozen.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
@@ -256,10 +256,10 @@ void events(void) {
                                }\r
                                /* Code merges here for any commander destroying base */\r
                                /* Not perfect, but will have to do */\r
-                               if (starch[batx][baty] == -1) starch[batx][baty] = 0;\r
+                               if (frozen.starch[batx][baty] == -1) frozen.starch[batx][baty] = 0;\r
                                /* Handle case where base is in same quadrant as starship */\r
                                if (batx==quadx && baty==quady) {\r
-                                       if (starch[batx][baty] > 999) starch[batx][baty] -= 10;\r
+                                       if (frozen.starch[batx][baty] > 999) frozen.starch[batx][baty] -= 10;\r
                                        frozen.quad[basex][basey]= IHDOT;\r
                                        basex=basey=0;\r
                                        newcnd();\r
@@ -267,7 +267,7 @@ void events(void) {
                                        prout("Spock-  \"Captain, I believe the starbase has been destroyestate.\"");\r
                                }\r
                                else if (state.rembase != 1 &&\r
-                                                (damage[DRADIO] <= 0.0 || condit == IHDOCKED)) {\r
+                                                (frozen.damage[DRADIO] <= 0.0 || condit == IHDOCKED)) {\r
                                        /* Get word via subspace radio */\r
                                        if (ipage==0) pause(1);\r
                                        ipage = 1;\r
@@ -298,13 +298,13 @@ void events(void) {
                                }\r
                                break;\r
                        case FSCMOVE: /* Supercommander moves */\r
-                               future[FSCMOVE] = state.date+0.2777;\r
+                               frozen.future[FSCMOVE] = 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
-                               future[FDSPROB] = state.date + 0.01;\r
+                               frozen.future[FDSPROB] = state.date + 0.01;\r
                                probex += probeinx;\r
                                probey += probeiny;\r
                                i = (int)(probex/10 +0.05);\r
@@ -315,7 +315,7 @@ void events(void) {
                                        if (i < 1 || i > 8 || j < 1 || j > 8 ||\r
                                                state.galaxy[probecx][probecy] == 1000) {\r
                                                // Left galaxy or ran into supernova\r
-                                               if (damage[DRADIO]==0.0 || condit == IHDOCKED) {\r
+                                               if (frozen.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
-                                               future[FDSPROB] = 1e30;\r
+                                               frozen.future[FDSPROB] = 1e30;\r
                                                break;\r
                                        }\r
-                                       if (damage[DRADIO]==0.0   || condit == IHDOCKED) {\r
+                                       if (frozen.damage[DRADIO]==0.0   || condit == IHDOCKED) {\r
                                                if (ipage==0) pause(1);\r
                                                ipage = 1;\r
                                                skip(1);\r
@@ -340,15 +340,15 @@ void events(void) {
                                }\r
                                /* Update star chart if Radio is working or have access to\r
                                   radio. */\r
-                               if (damage[DRADIO] == 0.0 || condit == IHDOCKED)\r
-                                       starch[probecx][probecy] = damage[DRADIO] > 0.0 ?\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
                                proben--; // One less to travel\r
                                if (proben == 0 && isarmed &&\r
                                        state.galaxy[probecx][probecy] % 10 > 0) {\r
                                        /* lets blow the sucker! */\r
                                        snova(1,0);\r
-                                       future[FDSPROB] = 1e30;\r
+                                       frozen.future[FDSPROB] = 1e30;\r
                                        if (state.galaxy[quadx][quady] == 1000) return;\r
                                }\r
                                break;\r
@@ -405,7 +405,7 @@ void wait(void) {
                delay -= temp;\r
                /* Repair Deathray if long rest at starbase */\r
                if (origTime-delay >= 9.99 && condit == IHDOCKED)\r
-                       damage[DDRAY] = 0.0;\r
+                       frozen.damage[DDRAY] = 0.0;\r
        } while (state.galaxy[quadx][quady] != 1000); // leave if quadrant supernovas\r
 \r
        resting = 0;\r
@@ -506,7 +506,7 @@ void nova(int ix, int iy) {
                                                                shield = 0.0;\r
                                                                shldup = 0;\r
                                                                prout("***Shields knocked out.");\r
-                                                               damage[DSHIELD] += 0.005*damfac*Rand()*diff;\r
+                                                               frozen.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 (kx[ll]==ii && ky[ll]==jj) break;\r
-                                               kpower[ll] -= 800.0; /* If firepower is lost, die */\r
-                                               if (kpower[ll] <= 0.0) {\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
                                                        deadkl(ii, jj, iquad, ii, jj);\r
                                                        break;\r
                                                }\r
@@ -558,10 +558,10 @@ void nova(int ix, int iy) {
                                                cramlc(2, newcx, newcy);\r
                                                frozen.quad[ii][jj] = IHDOT;\r
                                                frozen.quad[newcx][newcy] = iquad;\r
-                                               kx[ll] = newcx;\r
-                                               ky[ll] = newcy;\r
-                                               kavgd[ll] = sqrt(square(sectx-newcx)+square(secty-newcy));\r
-                                               kdist[ll] = kavgd[ll];\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
                                                skip(1);\r
                                                break;\r
                                }\r
@@ -635,7 +635,7 @@ 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 (damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
+                       if (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
                                skip(1);\r
                                proutn("Message from Starfleet Command       Stardate ");\r
                                cramf(state.date, 0, 1);\r
@@ -689,7 +689,7 @@ void snova(int insx, int insy) {
                /* did in the Supercommander! */\r
                state.nscrem = state.isx = state.isy = isatb = iscate = 0;\r
                iscdead = 1;\r
-               future[FSCMOVE] = future[FSCDBAS] = 1e30;\r
+               frozen.future[FSCMOVE] = frozen.future[FSCDBAS] = 1e30;\r
        }\r
        state.remkl -= kldead;\r
        if (state.remcom) {\r
@@ -702,7 +702,7 @@ void snova(int insx, int insy) {
                                state.remcom--;\r
                                kldead--;\r
                                comdead++;\r
-                               if (state.remcom==0) future[FTBEAM] = 1e30;\r
+                               if (state.remcom==0) frozen.future[FTBEAM] = 1e30;\r
                                break;\r
                        }\r
                }\r
@@ -745,9 +745,9 @@ void snova(int insx, int insy) {
        }\r
        /* mark supernova in galaxy and in star chart */\r
        if ((quadx == nqx && quady == nqy) ||\r
-               damage[DRADIO] == 0 ||\r
+               frozen.damage[DRADIO] == 0 ||\r
                condit == IHDOCKED)\r
-               starch[nqx][nqy] = 1;\r
+               frozen.starch[nqx][nqy] = 1;\r
        state.galaxy[nqx][nqy] = 1000;\r
        /* If supernova destroys last klingons give special message */\r
        if (state.remkl==0 && (nqx != quadx || nqy != quady)) {\r
index e396759591e6058069467f9b13fbff7fdc5e53bd..f355b5a69f855c929b522117477957a0c376f75a 100644 (file)
--- a/finish.c
+++ b/finish.c
@@ -5,7 +5,7 @@
 void dstrct() {\r
        /* Finish with a BANG! */\r
        chew();\r
-       if (damage[DCOMPTR] != 0.0) {\r
+       if (frozen.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(passwd, citem) != 0) {\r
+       if (strcmp(frozen.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 (kpower[l]*kdist[l] <= whammo) \r
-                               deadkl(kx[l],ky[l], frozen.quad[kx[l]][ky[l]], kx[l], ky[l]);\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
                        l++;\r
                }\r
        }\r
index 24c9643e6187cc3e054a4b94ece8d303443b1ff3..0f53518da8b334475627d6881e59ddeb999ced82 100644 (file)
--- a/moving.c
+++ b/moving.c
@@ -24,11 +24,11 @@ void move(void) {
        deltax /= bigger;\r
 \r
        /* If tractor beam is to occur, don't move full distance */\r
-       if (state.date+Time >= future[FTBEAM]) {\r
+       if (state.date+Time >= frozen.future[FTBEAM]) {\r
                trbeam = 1;\r
                condit = IHRED;\r
-               dist = dist*(future[FTBEAM]-state.date)/Time + 0.1;\r
-               Time = future[FTBEAM] - state.date + 1e-5;\r
+               dist = dist*(frozen.future[FTBEAM]-state.date)/Time + 0.1;\r
+               Time = frozen.future[FTBEAM] - state.date + 1e-5;\r
        }\r
        /* Move within the quadrant */\r
        frozen.quad[sectx][secty] = IHDOT;\r
@@ -46,9 +46,9 @@ void move(void) {
                                if (nenhere != 0 && iattak != 2) {\r
                                        newcnd();\r
                                        for (l = 1; l <= nenhere; l++) {\r
-                                               finald = sqrt((ix-kx[l])*(double)(ix-kx[l]) +\r
-                                                                         (iy-ky[l])*(double)(iy-ky[l]));\r
-                                               kavgd[l] = 0.5 * (finald+kdist[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
                                        }\r
                                        if (state.galaxy[quadx][quady] != 1000) attack(0);\r
                                        if (alldone) return;\r
@@ -173,15 +173,15 @@ label100:
        frozen.quad[sectx][secty] = ship;\r
        if (nenhere) {\r
                for (l = 1; l <= nenhere; l++) {\r
-                       finald = sqrt((ix-kx[l])*(double)(ix-kx[l]) +\r
-                                                 (iy-ky[l])*(double)(iy-ky[l]));\r
-                       kavgd[l] = 0.5 * (finald+kdist[l]);\r
-                       kdist[l] = finald;\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
                }\r
                sortkl();\r
                if (state.galaxy[quadx][quady] != 1000 && iattak == 0)\r
                        attack(0);\r
-               for (l = 1 ; l <= nenhere; l++) kavgd[l] = kdist[l];\r
+               for (l = 1 ; l <= nenhere; l++) frozen.kavgd[l] = frozen.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
-               (future[FCDBAS] < 1e30 || isatb == 1) && iseenit == 0) {\r
+               (frozen.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 (damage[DCOMPTR]) {\r
+               if (frozen.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 (damage[DIMPULS]) {\r
+       if (frozen.damage[DIMPULS]) {\r
                chew();\r
                skip(1);\r
                prout("Engineer Scott- \"The impulse engines are damaged, Sir.\"");\r
@@ -467,13 +467,13 @@ void warp(int i) {
 \r
        if (i!=2) { /* Not WARPX entry */\r
                ididit = 0;\r
-               if (damage[DWARPEN] > 10.0) {\r
+               if (frozen.damage[DWARPEN] > 10.0) {\r
                        chew();\r
                        skip(1);\r
                        prout("Engineer Scott- \"The impulse engines are damaged, Sir.\"");\r
                        return;\r
                }\r
-               if (damage[DWARPEN] > 0.0 && warpfac > 4.0) {\r
+               if (frozen.damage[DWARPEN] > 0.0 && warpfac > 4.0) {\r
                        chew();\r
                        skip(1);\r
                        prout("Engineer Scott- \"Sorry, Captain. Until this damage");\r
@@ -584,7 +584,7 @@ void warp(int i) {
        Time = 10.0*dist/wfacsq;\r
        if (twarp) timwrp();\r
        if (blooey) {\r
-               damage[DWARPEN] = damfac*(3.0*Rand()+1.0);\r
+               frozen.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 (damage[DWARPEN] > 10.0) {\r
+       if (frozen.damage[DWARPEN] > 10.0) {\r
                prout("Warp engines inoperative.");\r
                return;\r
        }\r
-       if (damage[DWARPEN] > 0.0 && aaitem > 4.0) {\r
+       if (frozen.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 (damage[DTRANSP]) {\r
+               if (frozen.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
-               starch[quadx][quady] = damage[DRADIO] > 0.0 ? state.galaxy[quadx][quady]+1000:1;\r
+               frozen.starch[quadx][quady] = frozen.damage[DRADIO] > 0.0 ? state.galaxy[quadx][quady]+1000:1;\r
 \r
                /* Try to use warp engines */\r
-               if (damage[DWARPEN]) {\r
+               if (frozen.damage[DWARPEN]) {\r
                        skip(1);\r
                        prout("Warp engines damaged.");\r
                        finish(FSNOVAED);\r
@@ -750,15 +750,15 @@ void timwrp() {
                state = snapsht;\r
                state.snap = 0;\r
                if (state.remcom) {\r
-                       future[FTBEAM] = state.date + expran(intime/state.remcom);\r
-                       future[FBATTAK] = state.date + expran(0.3*intime);\r
+                       frozen.future[FTBEAM] = state.date + expran(intime/state.remcom);\r
+                       frozen.future[FBATTAK] = state.date + expran(0.3*intime);\r
                }\r
-               future[FSNOVA] = state.date + expran(0.5*intime);\r
-               future[FSNAP] = state.date +expran(0.25*state.remtime); /* next snapshot will\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
                                                                                                           be sooner */\r
-               if (state.nscrem) future[FSCMOVE] = 0.2777;\r
+               if (state.nscrem) frozen.future[FSCMOVE] = 0.2777;\r
                isatb = 0;\r
-               future[FCDBAS] = future[FSCDBAS] = 1e30;\r
+               frozen.future[FCDBAS] = frozen.future[FSCDBAS] = 1e30;\r
                batx = baty = 0;\r
 \r
                /* Make sure Galileo is consistant -- Snapshot may have been taken\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 && damage[DSHUTTL] >= 0.0) {\r
+               if (iscraft==0 && gotit==0 && frozen.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 (damage[DRADIO]==0.0 || stdamtim > state.date) {\r
+               if (frozen.damage[DRADIO]==0.0 || stdamtim > state.date) {\r
                        for (l = 1; l <= 8; l++)\r
                                for (ll = 1; ll <= 8; ll++)\r
-                                       if (starch[l][ll] > 1)\r
-                                               starch[l][ll]=damage[DRADIO]>0.0 ? state.galaxy[l][ll]+1000 :1;\r
+                                       if (frozen.starch[l][ll] > 1)\r
+                                               frozen.starch[l][ll]=frozen.damage[DRADIO]>0.0 ? state.galaxy[l][ll]+1000 :1;\r
                        prout("Spock has reconstructed a correct star chart from memory");\r
-                       if (damage[DRADIO] > 0.0) stdamtim = state.date;\r
+                       if (frozen.damage[DRADIO] > 0.0) stdamtim = 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
-               future[FTBEAM] += Time;\r
-               damage[DRADIO] += Time;\r
+               frozen.future[FTBEAM] += Time;\r
+               frozen.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 (damage[DDSP] != 0.0) {\r
+       if (frozen.damage[DDSP] != 0.0) {\r
                chew();\r
                skip(1);\r
                prout("Engineer Scott- \"The probe launcher is damaged, Sir.\"");\r
                return;\r
        }\r
-       if (future[FDSPROB] != 1e30) {\r
+       if (frozen.future[FDSPROB] != 1e30) {\r
                chew();\r
                skip(1);\r
-               if (damage[DRADIO] != 0 && condit != IHDOCKED) {\r
+               if (frozen.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
-       future[FDSPROB] = state.date + 0.01; // Time to move one sector\r
+       frozen.future[FDSPROB] = 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,7 +886,7 @@ void help(void) {
                prout("Lt. Uhura-  \"But Captain, we're already docked.\"");\r
                return;\r
        }\r
-       if (damage[DRADIO] != 0) {\r
+       if (frozen.damage[DRADIO] != 0) {\r
                prout("Subspace radio damaged.");\r
                return;\r
        }\r
index 133b0daca74fa92ce2a696ab4bf4942b6b0b71ce..ea9aa125337713ab40e03cb36417e11cf4caf987 100644 (file)
--- a/planets.c
+++ b/planets.c
@@ -64,7 +64,7 @@ void orbit(void) {
                prout("Already in standard orbit.");\r
                return;\r
        }\r
-       if (damage[DWARPEN] != 0 && damage[DIMPULS] != 0) {\r
+       if (frozen.damage[DWARPEN] != 0 && frozen.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 (damage[DSRSENS] != 0.0) {\r
+       if (frozen.damage[DSRSENS] != 0.0) {\r
                prout("Short range sensors damaged.");\r
                return;\r
        }\r
@@ -116,9 +116,9 @@ void sensor(void) {
 void beam(void) {\r
        chew();\r
        skip(1);\r
-       if (damage[DTRANSP] != 0) {\r
+       if (frozen.damage[DTRANSP] != 0) {\r
                prout("Transporter damaged.");\r
-               if (damage[DSHUTTL]==0 && (state.plnets[iplnet].known==2 || iscraft == 1)) {\r
+               if (frozen.damage[DSHUTTL]==0 && (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
@@ -285,14 +285,14 @@ void shuttle(void) {
        chew();\r
        skip(1);\r
        ididit = 0;\r
-       if(damage[DSHUTTL] != 0.0) {\r
-               if (damage[DSHUTTL] == -1.0) {\r
+       if(frozen.damage[DSHUTTL] != 0.0) {\r
+               if (frozen.damage[DSHUTTL] == -1.0) {\r
                        if (inorbit && 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 (damage[DSHUTTL] > 0)\r
+               else if (frozen.damage[DSHUTTL] > 0)\r
                        prout("The Galileo is damaged.");\r
                else prout("Shuttle craft is now serving Big Macs.");\r
                return;\r
@@ -337,7 +337,7 @@ void shuttle(void) {
                /* Kirk on planet */\r
                if (iscraft==1) {\r
                        /* Galileo on ship! */\r
-                       if (damage[DTRANSP]==0) {\r
+                       if (frozen.damage[DTRANSP]==0) {\r
                                proutn("Spock-  \"Would you rather use the transporter?\" ");\r
                                if (ja() != 0) {\r
                                        beam();\r
@@ -411,7 +411,7 @@ void deathray(void) {
                prout("Sulu-  \"But Sir, there are no enemies in this quadrant.\"");\r
                return;\r
        }\r
-       if (damage[DDRAY] > 0.0) {\r
+       if (frozen.damage[DDRAY] > 0.0) {\r
                prout("Death Ray is damaged.");\r
                return;\r
        }\r
@@ -437,7 +437,7 @@ void deathray(void) {
                prouts("Sulu- \"Captain!  It's working!\"");\r
                skip(2);\r
                while (nenhere > 0)\r
-                       deadkl(kx[1],ky[1],frozen.quad[kx[1]][ky[1]],kx[1],ky[1]);\r
+                       deadkl(frozen.kx[1],frozen.ky[1],frozen.quad[frozen.kx[1]][frozen.ky[1]],frozen.kx[1],frozen.ky[1]);\r
                prout("Ensign Chekov-  \"Congratulations, Captain!\"");\r
                if (state.remkl == 0) finish(FWON);\r
                prout("Spock-  \"Captain, I believe the `Experimental Death Ray'");\r
@@ -446,7 +446,7 @@ void deathray(void) {
                }\r
                else {\r
                        prout("   has been rendered disfunctional.\"");\r
-                       damage[DDRAY] = 39.95;\r
+                       frozen.damage[DDRAY] = 39.95;\r
                }\r
                return;\r
        }\r
index 6ce31c478cc8e043a70288900d5f09f2265b066b..5841aeca6c74f9750fd2a3d2253d32d9ad33fdbf 100644 (file)
--- a/reports.c
+++ b/reports.c
@@ -4,12 +4,12 @@
 #include <string.h>\r
 \r
 void attakreport(void) {\r
-       if (future[FCDBAS] < 1e30) {\r
+       if (frozen.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(future[FCDBAS], 0,1);\r
+               cramf(frozen.future[FCDBAS], 0,1);\r
                prout(".");\r
        }\r
        if (isatb == 1) {\r
@@ -17,7 +17,7 @@ void attakreport(void) {
                cramlc(1, state.isx, state.isy);\r
                prout(" is under Super-commander attack.");\r
                proutn("It can hold out until Stardate ");\r
-               cramf(future[FSCDBAS], 0, 1);\r
+               cramf(frozen.future[FSCDBAS], 0, 1);\r
                prout(".");\r
        }\r
 }\r
@@ -46,7 +46,7 @@ void report(int f) {
                   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",passwd);\r
+       if (f) printf("Your secret password is \"%s\"\n",frozen.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
@@ -67,7 +67,7 @@ void report(int f) {
                prout(" remaining.");\r
        }\r
        else printf("There are %d bases.\n", inbase);\r
-       if (damage[DRADIO] == 0.0 || condit == IHDOCKED || iseenit) {\r
+       if (frozen.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 ((damage[DRADIO] == 0.0 || condit == IHDOCKED)&&\r
-               future[FDSPROB] != 1e30) {\r
+       if ((frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED)&&\r
+               frozen.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 (damage[DLRSENS] != 0.0) {\r
+       if (frozen.damage[DLRSENS] != 0.0) {\r
                /* Now allow base's sensors if docked */\r
                if (condit != IHDOCKED) {\r
                        prout("LONG-RANGE SENSORS DAMAGED.");\r
@@ -135,7 +135,7 @@ void lrscan(void) {
                                printf("   -1");\r
                        else {\r
                                printf("%5d", state.galaxy[x][y]);\r
-                               starch[x][y] = damage[DRADIO] > 0 ? state.galaxy[x][y]+1000 :1;\r
+                               frozen.starch[x][y] = frozen.damage[DRADIO] > 0 ? 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 (damage[i] > 0.0) {\r
+               if (frozen.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(damage[i]+0.05, 8, 2);\r
+                       cramf(frozen.damage[i]+0.05, 8, 2);\r
                        proutn("  ");\r
-                       cramf(docfac*damage[i]+0.005, 8, 2);\r
+                       cramf(docfac*frozen.damage[i]+0.005, 8, 2);\r
                        skip(1);\r
                }\r
        }\r
@@ -182,7 +182,7 @@ void chart(int nn) {
                        stdamtim = state.date;\r
                        for (i=1; i <= 8 ; i++)\r
                                for (j=1; j <= 8; j++)\r
-                                       if (starch[i][j] == 1) starch[i][j] = state.galaxy[i][j]+1000;\r
+                                       if (frozen.starch[i][j] == 1) frozen.starch[i][j] = state.galaxy[i][j]+1000;\r
                }\r
                else {\r
                        proutn("(Last surveillance update ");\r
@@ -198,12 +198,12 @@ void chart(int nn) {
        for (i = 1; i <= 8; i++) {\r
                printf("%d -", i);\r
                for (j = 1; j <= 8; j++) {\r
-                       if (starch[i][j] < 0)\r
+                       if (frozen.starch[i][j] < 0)\r
                                printf("  .1.");\r
-                       else if (starch[i][j] == 0)\r
+                       else if (frozen.starch[i][j] == 0)\r
                                printf("  ...");\r
-                       else if (starch[i][j] > 999)\r
-                               printf("%5d", starch[i][j]-1000);\r
+                       else if (frozen.starch[i][j] > 999)\r
+                               printf("%5d", frozen.starch[i][j]-1000);\r
                        else\r
                                printf("%5d", state.galaxy[i][j]);\r
                }\r
@@ -227,7 +227,7 @@ void srscan(int l) {
        int goodScan=TRUE;\r
        switch (l) {\r
                case 1: // SRSCAN\r
-                       if (damage[DSRSENS] != 0) {\r
+                       if (frozen.damage[DSRSENS] != 0) {\r
                                /* Allow base's sensors if docked */\r
                                if (condit != IHDOCKED) {\r
                                        prout("SHORT-RANGE SENSORS DAMAGED");\r
@@ -237,7 +237,7 @@ void srscan(int l) {
                                        prout("[Using starbase's sensors]");\r
                        }\r
                        if (goodScan)\r
-                               starch[quadx][quady] = damage[DRADIO]>0.0 ?\r
+                           frozen.starch[quadx][quady] = frozen.damage[DRADIO]>0.0 ?\r
                                                                           state.galaxy[quadx][quady]+1000:1;\r
                        scan();\r
                        if (isit("chart")) nn = TRUE;\r
@@ -298,7 +298,7 @@ void srscan(int l) {
                                        break;\r
                                case 4:\r
                                        printf(" Life Support  ");\r
-                                       if (damage[DLIFSUP] != 0.0) {\r
+                                       if (frozen.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 (damage[DSHIELD] != 0)\r
+                                       if (frozen.damage[DSHIELD] != 0)\r
                                                printf("DAMAGED,");\r
                                        else if (shldup)\r
                                                printf("UP,");\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 (damage[DCOMPTR] != 0.0) {\r
+       if (frozen.damage[DCOMPTR] != 0.0) {\r
                prout("COMPUTER DAMAGED, USE A POCKET CALCULATOR.");\r
                skip(1);\r
                return;\r
@@ -473,8 +473,8 @@ void eta(void) {
                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
-                        future[FSCDBAS]< ttime+state.date)||\r
-                       (future[FCDBAS]<ttime+state.date && baty==ix1 && batx == iy1))\r
+                        frozen.future[FSCDBAS]< ttime+state.date)||\r
+                       (frozen.future[FCDBAS]<ttime+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 5c3174878314156308b9fc8e53236dbca1836fac..5e2db4f056fa43091ca42dbfe64c77ba1cc0e1cd 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -38,16 +38,7 @@ void freeze(int boss) {
        }\r
        fwrite(&state, sizeof(state), 1, fp);\r
        fwrite(&snapsht, sizeof(snapsht), 1, fp);\r
-       fwrite(kx, sizeof(kx), 1, fp);\r
-       fwrite(ky, sizeof(ky), 1, fp);\r
-       fwrite(starch, sizeof(starch), 1, fp);\r
-       fwrite(kpower, sizeof(kpower), 1, fp);\r
-       fwrite(kdist, sizeof(kdist), 1, fp);\r
-       fwrite(kavgd, sizeof(kavgd), 1, fp);\r
-       fwrite(damage, sizeof(damage), 1, fp);\r
-       fwrite(future, sizeof(future), 1, fp);\r
        fwrite(&frozen, sizeof(frozen), 1, fp);\r
-       fwrite(passwd, sizeof(passwd), 1, fp);\r
 \r
        fclose(fp);\r
 \r
@@ -60,7 +51,7 @@ void thaw(void) {
        FILE *fp;\r
        int key;\r
 \r
-       passwd[0] = '\0';\r
+       frozen.passwd[0] = '\0';\r
        if ((key = scan()) == IHEOL) {\r
                proutn("File name: ");\r
                key = scan();\r
@@ -81,16 +72,7 @@ void thaw(void) {
        }\r
        fread(&state, sizeof(state), 1, fp);\r
        fread(&snapsht, sizeof(snapsht), 1, fp);\r
-       fread(kx, sizeof(kx), 1, fp);\r
-       fread(ky, sizeof(ky), 1, fp);\r
-       fread(starch, sizeof(starch), 1, fp);\r
-       fread(kpower, sizeof(kpower), 1, fp);\r
-       fread(kdist, sizeof(kdist), 1, fp);\r
-       fread(kavgd, sizeof(kavgd), 1, fp);\r
-       fread(damage, sizeof(damage), 1, fp);\r
-       fread(future, sizeof(future), 1, fp);\r
        fread(&frozen, sizeof(frozen), 1, fp);\r
-       fread(passwd, sizeof(passwd), 1, fp);\r
 \r
        fclose(fp);\r
 \r
@@ -109,15 +91,15 @@ void abandn(void) {
        }\r
        else {\r
                /* Must take shuttle craft to exit */\r
-               if (damage[DSHUTTL]==-1) {\r
+               if (frozen.damage[DSHUTTL]==-1) {\r
                        prout("Ye Faerie Queene has no shuttle craft.");\r
                        return;\r
                }\r
-               if (damage[DSHUTTL]<0) {\r
+               if (frozen.damage[DSHUTTL]<0) {\r
                        prout("Shuttle craft now serving Big Mac's.");\r
                        return;\r
                }\r
-               if (damage[DSHUTTL]>0) {\r
+               if (frozen.damage[DSHUTTL]>0) {\r
                        prout("Shuttle craft damaged.");\r
                        return;\r
                }\r
@@ -183,8 +165,8 @@ void abandn(void) {
        iscraft=0; /* Gallileo disappears */\r
        /* Resupply ship */\r
        condit=IHDOCKED;\r
-       for (l = 1; l <= ndevice; l++) damage[l] = 0.0;\r
-       damage[DSHUTTL] = -1;\r
+       for (l = 1; l <= ndevice; l++) frozen.damage[l] = 0.0;\r
+       frozen.damage[DSHUTTL] = -1;\r
        energy = inenrg = 3000.0;\r
        shield = inshld = 1250.0;\r
        torps = intorps = 6;\r
@@ -217,7 +199,7 @@ 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++) damage[i] = 0.0;\r
+       for (i=0; i <= ndevice; i++) frozen.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
@@ -228,16 +210,16 @@ void setup(void) {
        alive = 1;\r
        docfac = 0.25;\r
        for (i = 1; i <= 8; i++)\r
-               for (j = 1; j <= 8; j++) state.newstuf[i][j] = starch[i][j] = 0;\r
+               for (j = 1; j <= 8; j++) state.newstuf[i][j] = frozen.starch[i][j] = 0;\r
        // Initialize times for extraneous events\r
-       future[FSNOVA] = state.date + expran(0.5 * intime);\r
-       future[FTBEAM] = state.date + expran(1.5 * (intime / state.remcom));\r
-       future[FSNAP] = state.date + 1.0 + Rand(); // Force an early snapshot\r
-       future[FBATTAK] = state.date + expran(0.3*intime);\r
-       future[FCDBAS] = 1e30;\r
-       future[FSCMOVE] = state.nscrem ? state.date+0.2777 : 1e30;\r
-       future[FSCDBAS] = 1e30;\r
-       future[FDSPROB] = 1e30;\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
        // Starchart is functional\r
        stdamtim = 1e30;\r
        // Put stars in the galaxy\r
@@ -275,7 +257,7 @@ void setup(void) {
                        \r
                state.baseqx[i] = ix;\r
                state.baseqy[i] = iy;\r
-               starch[ix][iy] = -1;\r
+               frozen.starch[ix][iy] = -1;\r
                state.galaxy[ix][iy] += 10;\r
        }\r
        // Position ordinary Klingon Battle Cruisers\r
@@ -421,7 +403,7 @@ int choose(void) {
                if (isit("frozen")) {\r
                        thaw();\r
                        chew();\r
-                       if (*passwd==0) continue;\r
+                       if (*frozen.passwd==0) continue;\r
                        randomize();\r
                        Rand(); Rand(); Rand(); Rand();\r
                        if (!alldone) thawed = 1; // No plaque if not finished\r
@@ -463,13 +445,13 @@ int choose(void) {
        }\r
        while (TRUE) {\r
                scan();\r
-               strcpy(passwd, citem);\r
+               strcpy(frozen.passwd, citem);\r
                chew();\r
-               if (*passwd != 0) break;\r
+               if (*frozen.passwd != 0) break;\r
                proutn("Please type in a secret password-");\r
        }\r
 #ifdef DEBUG\r
-       if (strcmp(passwd, "debug")==0) idebug = 1;\r
+       if (strcmp(frozen.passwd, "debug")==0) idebug = 1;\r
 #endif\r
 \r
        // Use parameters to generate initial values of things\r
@@ -554,7 +536,7 @@ void newqad(int shutup) {
                (skill == 3 && Rand() <= 0.05) ||\r
                (skill > 3 && Rand() <= 0.08)\r
 #ifdef DEBUG\r
-               || strcmp(passwd, "tholianx")==0\r
+               || strcmp(frozen.passwd, "tholianx")==0\r
 #endif\r
                ) {\r
                do {\r
@@ -575,10 +557,10 @@ void newqad(int shutup) {
                quadnum -= 100*klhere;\r
                for (i = 1; i <= klhere; i++) {\r
                        dropin(IHK, &ix, &iy);\r
-                       kx[i] = ix;\r
-                       ky[i] = iy;\r
-                       kdist[i] = kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy));\r
-                       kpower[i] = Rand()*150.0 +300.0 +25.0*skill;\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
                }\r
                // If we need a commander, promote a Klingon\r
                for (i = 1; i <= state.remcom ; i++) \r
@@ -586,14 +568,14 @@ void newqad(int shutup) {
                        \r
                if (i <= state.remcom) {\r
                        frozen.quad[ix][iy] = IHC;\r
-                       kpower[klhere] = 950.0+400.0*Rand()+50.0*skill;\r
+                       frozen.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[kx[1]][ky[1]] = IHS;\r
-                       kpower[1] = 1175.0 + 400.0*Rand() + 125.0*skill;\r
+                       frozen.quad[frozen.kx[1]][frozen.ky[1]] = IHS;\r
+                       frozen.kpower[1] = 1175.0 + 400.0*Rand() + 125.0*skill;\r
                        iscate = 1;\r
                        ishere = 1;\r
                }\r
@@ -601,10 +583,10 @@ void newqad(int shutup) {
        // Put in Romulans if needed\r
        for (i = klhere+1; i <= nenhere; i++) {\r
                dropin(IHR, &ix, &iy);\r
-               kx[i] = ix;\r
-               ky[i] = iy;\r
-               kdist[i] = kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy));\r
-               kpower[i] = Rand()*400.0 + 450.0 + 50.0*skill;\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
        }\r
        sortkl();\r
        // If quadrant needs a starbase, put it in\r
@@ -630,7 +612,7 @@ void newqad(int shutup) {
        // Check for RNZ\r
        if (irhere > 0 && klhere == 0 && basex == 0) {\r
                neutz = 1;\r
-               if (damage[DRADIO] <= 0.0) {\r
+               if (frozen.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
@@ -645,7 +627,7 @@ void newqad(int shutup) {
                if (thingx == quadx && thingy == quady) {\r
                        dropin(IHQUEST, &ix, &iy);\r
                        thingx = thingy = 0; // Transient\r
-                       if (damage[DSRSENS] == 0.0) {\r
+                       if (frozen.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
@@ -677,23 +659,23 @@ void sortkl(void) {
        do {\r
                sw = FALSE;\r
                for (j = 1; j < nenhere; j++)\r
-                       if (kdist[j] > kdist[j+1]) {\r
+                       if (frozen.kdist[j] > frozen.kdist[j+1]) {\r
                                sw = TRUE;\r
-                               t = kdist[j];\r
-                               kdist[j] = kdist[j+1];\r
-                               kdist[j+1] = t;\r
-                               t = kavgd[j];\r
-                               kavgd[j] = kavgd[j+1];\r
-                               kavgd[j+1] = t;\r
-                               k = kx[j];\r
-                               kx[j] = kx[j+1];\r
-                               kx[j+1] = k;\r
-                               k = ky[j];\r
-                               ky[j] = ky[j+1];\r
-                               ky[j+1] = k;\r
-                               t = kpower[j];\r
-                               kpower[j] = kpower[j+1];\r
-                               kpower[j+1] = t;\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
                        }\r
        } while (sw);\r
 }\r
diff --git a/sst.h b/sst.h
index c6a1c87479a0951376a2b655a31d53c0864bf9a0..e0f9bd5d00e87d61309df3997c0cff4ddf1d1947 100644 (file)
--- a/sst.h
+++ b/sst.h
@@ -55,8 +55,18 @@ EXTERN struct foo {
 // but I just didn't think of it back when I started.\r
 \r
 EXTERN struct foo2 {\r
-        char quad[11][11];     // contents of our quadrant\r
-       int inkling,\r
+    char quad[11][11];         // contents of our quadrant\r
+    double kpower[21];         // enemy energy levels\r
+    double kdist[21];          // enemy distances\r
+    double kavgd[21];          // average distances\r
+    double damage[ndevice+1];  // damage encountered\r
+    double future[NEVENTS+1];  // future events\r
+    char passwd[10];           // Self Destruct password\r
+    int kx[21];                        // enemy sector locations\r
+    int ky[21];\r
+    int starch[9][9];          // star chart\r
+    /* members with macro definitions start here */\r
+    int inkling,\r
        inbase,\r
        incom,\r
        instar,\r
@@ -233,26 +243,10 @@ EXTERN struct foo2 {
 #define isarmed frozen.isarmed         // Probe is armed\r
 #define nprobes frozen.nprobes         // number of probes available\r
 \r
-EXTERN int\r
-               kx[21],                 // enemy sector locations\r
-               ky[21],\r
-               starch[9][9];   // star chart\r
-\r
+/* the following global state doesn't need to be saved */\r
 EXTERN int fromcommandline; // Game start from command line options\r
-\r
-\r
-EXTERN char    passwd[10],             // Self Destruct password\r
-               *device[ndevice+1];\r
-\r
+EXTERN char    *device[ndevice+1];\r
 EXTERN PLANETS nulplanet;      // zeroed planet structure\r
-\r
-EXTERN double\r
-               kpower[21],             // enemy energy levels\r
-               kdist[21],              // enemy distances\r
-               kavgd[21],              // average distances\r
-               damage[ndevice+1],              // damage encountered\r
-               future[NEVENTS+1];              // future events\r
-\r
 EXTERN int iscore, iskill; // Common PLAQ\r
 EXTERN double perdate;\r
 \r