Next step towards structure merge.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 31 Oct 2004 20:05:04 +0000 (20:05 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 31 Oct 2004 20:05:04 +0000 (20:05 +0000)
Change state variables to names that will be easy to replace.

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

diff --git a/ai.c b/ai.c
index 8f4bb988e56eeece0d3c964b7902b66d8deb1094..e34eabcfd58a0e6cb242f61fbae5ef7314deeade 100644 (file)
--- a/ai.c
+++ b/ai.c
@@ -6,14 +6,14 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) {
        iqx = quadx+(lookx+9)/10 - 1;\r
        iqy = quady+(looky+9)/10 - 1;\r
        if (iqx < 1 || iqx > 8 || iqy < 1 || iqy > 8 ||\r
-               d.galaxy[iqx][iqy] > 899)\r
+               state.galaxy[iqx][iqy] > 899)\r
                return 0; /* no can do -- neg energy, supernovae, or >8 Klingons */\r
        if (ienm == IHR) return 0; /* Romulans cannot escape! */\r
        if (irun == 0) {\r
                /* avoid intruding on another commander's territory */\r
                if (ienm == IHC) {\r
-                       for (l = 1; l <= d.remcom; l++)\r
-                               if (d.cx[l]==iqx && d.cy[l]==iqy) return 0;\r
+                       for (l = 1; l <= state.remcom; l++)\r
+                               if (state.cx[l]==iqx && state.cy[l]==iqy) return 0;\r
                        /* refuse to leave if currently attacking starbase */\r
                        if (batx==quadx && baty==quady) return 0;\r
                }\r
@@ -40,23 +40,23 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) {
        nenhere--;\r
        if (condit != IHDOCKED) newcnd();\r
        /* Handle global matters related to escape */\r
-       d.galaxy[quadx][quady] -= 100;\r
-       d.galaxy[iqx][iqy] += 100;\r
+       state.galaxy[quadx][quady] -= 100;\r
+       state.galaxy[iqx][iqy] += 100;\r
        if (ienm==IHS) {\r
                ishere=0;\r
                iscate=0;\r
                ientesc=0;\r
                isatb=0;\r
-               future[FSCMOVE]=0.2777+d.date;\r
+               future[FSCMOVE]=0.2777+state.date;\r
                future[FSCDBAS]=1e30;\r
-               d.isx=iqx;\r
-               d.isy=iqy;\r
+               state.isx=iqx;\r
+               state.isy=iqy;\r
        }\r
        else {\r
-               for (l=1; l<=d.remcom; l++) {\r
-                       if (d.cx[l]==quadx && d.cy[l]==quady) {\r
-                               d.cx[l]=iqx;\r
-                               d.cy[l]=iqy;\r
+               for (l=1; l<=state.remcom; l++) {\r
+                       if (state.cx[l]==quadx && state.cy[l]==quady) {\r
+                               state.cx[l]=iqx;\r
+                               state.cy[l]=iqy;\r
                                break;\r
                        }\r
                }\r
@@ -311,18 +311,18 @@ static int checkdest(int iqx, int iqy, int flag, int *ipage) {
 \r
        if ((iqx==quadx && iqy==quady) ||\r
                iqx < 1 || iqx > 8 || iqy < 1 || iqy > 8 ||\r
-               d.galaxy[iqx][iqy] > 899) return 1;\r
+               state.galaxy[iqx][iqy] > 899) return 1;\r
        if (flag) {\r
                /* Avoid quadrants with bases if we want to avoid Enterprise */\r
-               for (i = 1; i <= d.rembase; i++)\r
-                       if (d.baseqx[i]==iqx && d.baseqy[i]==iqy) return 1;\r
+               for (i = 1; i <= state.rembase; i++)\r
+                       if (state.baseqx[i]==iqx && state.baseqy[i]==iqy) return 1;\r
        }\r
 \r
        /* do the move */\r
-       d.galaxy[d.isx][d.isy] -= 100;\r
-       d.isx = iqx;\r
-       d.isy = iqy;\r
-       d.galaxy[d.isx][d.isy] += 100;\r
+       state.galaxy[state.isx][state.isy] -= 100;\r
+       state.isx = iqx;\r
+       state.isy = iqy;\r
+       state.galaxy[state.isx][state.isy] += 100;\r
        if (iscate) {\r
                /* SC has scooted, Remove him from current quadrant */\r
                iscate=0;\r
@@ -345,17 +345,17 @@ static int checkdest(int iqx, int iqy, int flag, int *ipage) {
        }\r
        /* check for a helpful planet */\r
        for (i = 1; i <= inplan; i++) {\r
-               if (d.plnets[i].x==d.isx && d.plnets[i].y==d.isy &&\r
-                       d.plnets[i].crystals == 1) {\r
+               if (state.plnets[i].x==state.isx && state.plnets[i].y==state.isy &&\r
+                       state.plnets[i].crystals == 1) {\r
                        /* destroy the planet */\r
-                       d.plnets[i] = nulplanet;\r
-                       d.newstuf[d.isx][d.isy] -= 1;\r
+                       state.plnets[i] = nulplanet;\r
+                       state.newstuf[state.isx][state.isy] -= 1;\r
                        if (damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
                                if (*ipage==0) pause(1);\r
                                *ipage = 1;\r
                                prout("Lt. Uhura-  \"Captain, Starfleet Intelligence reports");\r
                                proutn("   a planet in");\r
-                               cramlc(1, d.isx, d.isy);\r
+                               cramlc(1, state.isx, state.isy);\r
                                prout(" has been destroyed");\r
                                prout("   by the Super-commander.\"");\r
                        }\r
@@ -380,39 +380,39 @@ void scom(int *ipage) {
 #endif\r
 \r
        /* Decide on being active or passive */\r
-       flag = ((d.killc+d.killk)/(d.date+0.01-indate) < 0.1*skill*(skill+1.0) ||\r
-                       (d.date-indate) < 3.0);\r
+       flag = ((state.killc+state.killk)/(state.date+0.01-indate) < 0.1*skill*(skill+1.0) ||\r
+                       (state.date-indate) < 3.0);\r
        if (iscate==0 && flag) {\r
                /* compute move away from Enterprise */\r
-               ideltax = d.isx-quadx;\r
-               ideltay = d.isy-quady;\r
+               ideltax = state.isx-quadx;\r
+               ideltay = state.isy-quady;\r
                if (sqrt(ideltax*(double)ideltax+ideltay*(double)ideltay) > 2.0) {\r
                        /* circulate in space */\r
-                       ideltax = d.isy-quady;\r
-                       ideltay = quadx-d.isx;\r
+                       ideltax = state.isy-quady;\r
+                       ideltay = quadx-state.isx;\r
                }\r
        }\r
        else {\r
                /* compute distances to starbases */\r
-               if (d.rembase <= 0) {\r
+               if (state.rembase <= 0) {\r
                        /* nothing left to do */\r
                        future[FSCMOVE] = 1e30;\r
                        return;\r
                }\r
-               sx = d.isx;\r
-               sy = d.isy;\r
-               for (i = 1; i <= d.rembase; i++) {\r
+               sx = state.isx;\r
+               sy = state.isy;\r
+               for (i = 1; i <= state.rembase; i++) {\r
                        basetbl[i] = i;\r
-                       ibqx = d.baseqx[i];\r
-                       ibqy = d.baseqy[i];\r
+                       ibqx = state.baseqx[i];\r
+                       ibqy = state.baseqy[i];\r
                        bdist[i] = sqrt(square(ibqx-sx) + square(ibqy-sy));\r
                }\r
-               if (d.rembase > 1) {\r
+               if (state.rembase > 1) {\r
                        /* sort into nearest first order */\r
                        int iswitch;\r
                        do {\r
                                iswitch = 0;\r
-                               for (i=1; i < d.rembase-1; i++) {\r
+                               for (i=1; i < state.rembase-1; i++) {\r
                                        if (bdist[i] > bdist[i+1]) {\r
                                                int ti = basetbl[i];\r
                                                double t = bdist[i];\r
@@ -429,34 +429,34 @@ void scom(int *ipage) {
                   without too many Klingons, and not already under attack. */\r
                ifindit = iwhichb = 0;\r
 \r
-               for (i2 = 1; i2 <= d.rembase; i2++) {\r
+               for (i2 = 1; i2 <= state.rembase; i2++) {\r
                        i = basetbl[i2];        /* bug in original had it not finding nearest*/\r
-                       ibqx = d.baseqx[i];\r
-                       ibqy = d.baseqy[i];\r
+                       ibqx = state.baseqx[i];\r
+                       ibqy = state.baseqy[i];\r
                        if ((ibqx == quadx && ibqy == quady) ||\r
                                (ibqx == batx && ibqy == baty) ||\r
-                               d.galaxy[ibqx][ibqy] > 899) continue;\r
+                               state.galaxy[ibqx][ibqy] > 899) continue;\r
                        /* if there is a commander, an no other base is appropriate,\r
                           we will take the one with the commander */\r
-                       for (j = 1; j <= d.remcom; j++) {\r
-                               if (ibqx==d.cx[j] && ibqy==d.cy[j] && ifindit!= 2) {\r
+                       for (j = 1; j <= state.remcom; j++) {\r
+                               if (ibqx==state.cx[j] && ibqy==state.cy[j] && ifindit!= 2) {\r
                                                ifindit = 2;\r
                                                iwhichb = i;\r
                                                break;\r
                                }\r
                        }\r
-                       if (j > d.remcom) { /* no commander -- use this one */\r
+                       if (j > state.remcom) { /* no commander -- use this one */\r
                                ifindit = 1;\r
                                iwhichb = i;\r
                                break;\r
                        }\r
                }\r
                if (ifindit==0) return; /* Nothing suitable -- wait until next time*/\r
-               ibqx = d.baseqx[iwhichb];\r
-               ibqy = d.baseqy[iwhichb];\r
+               ibqx = state.baseqx[iwhichb];\r
+               ibqy = state.baseqy[iwhichb];\r
                /* decide how to move toward base */\r
-               ideltax = ibqx - d.isx;\r
-               ideltay = ibqy - d.isy;\r
+               ideltax = ibqx - state.isx;\r
+               ideltay = ibqy - state.isy;\r
        }\r
        /* Maximum movement is 1 quadrant in either or both axis */\r
        if (ideltax > 1) ideltax = 1;\r
@@ -465,58 +465,58 @@ void scom(int *ipage) {
        if (ideltay < -1) ideltay = -1;\r
 \r
        /* try moving in both x and y directions */\r
-       iqx = d.isx + ideltax;\r
-       iqy = d.isy + ideltax;\r
+       iqx = state.isx + ideltax;\r
+       iqy = state.isy + ideltax;\r
        if (checkdest(iqx, iqy, flag, ipage)) {\r
                /* failed -- try some other maneuvers */\r
                if (ideltax==0 || ideltay==0) {\r
                        /* attempt angle move */\r
                        if (ideltax != 0) {\r
-                               iqy = d.isy + 1;\r
+                               iqy = state.isy + 1;\r
                                if (checkdest(iqx, iqy, flag, ipage)) {\r
-                                       iqy = d.isy - 1;\r
+                                       iqy = state.isy - 1;\r
                                        checkdest(iqx, iqy, flag, ipage);\r
                                }\r
                        }\r
                        else {\r
-                               iqx = d.isx + 1;\r
+                               iqx = state.isx + 1;\r
                                if (checkdest(iqx, iqy, flag, ipage)) {\r
-                                       iqx = d.isx - 1;\r
+                                       iqx = state.isx - 1;\r
                                        checkdest(iqx, iqy, flag, ipage);\r
                                }\r
                        }\r
                }\r
                else {\r
                        /* try moving just in x or y */\r
-                       iqy = d.isy;\r
+                       iqy = state.isy;\r
                        if (checkdest(iqx, iqy, flag, ipage)) {\r
-                               iqy = d.isy + ideltay;\r
-                               iqx = d.isx;\r
+                               iqy = state.isy + ideltay;\r
+                               iqx = state.isx;\r
                                checkdest(iqx, iqy, flag, ipage);\r
                        }\r
                }\r
        }\r
        /* check for a base */\r
-       if (d.rembase == 0) {\r
+       if (state.rembase == 0) {\r
                future[FSCMOVE] = 1e30;\r
        }\r
-       else for (i=1; i<=d.rembase; i++) {\r
-               ibqx = d.baseqx[i];\r
-               ibqy = d.baseqy[i];\r
-               if (ibqx==d.isx && ibqy == d.isy && d.isx != batx && d.isy != baty) {\r
+       else for (i=1; i<=state.rembase; i++) {\r
+               ibqx = state.baseqx[i];\r
+               ibqy = state.baseqy[i];\r
+               if (ibqx==state.isx && ibqy == state.isy && state.isx != batx && state.isy != baty) {\r
                        /* attack the base */\r
                        if (flag) return; /* no, don't attack base! */\r
                        iseenit = 0;\r
                        isatb=1;\r
-                       future[FSCDBAS] = d.date + 1.0 +2.0*Rand();\r
-                       if (batx != 0) future[FSCDBAS] += future[FCDBAS]-d.date;\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
                                return; /* no warning */\r
                        iseenit = 1;\r
                        if (*ipage == 0)  pause(1);\r
                        *ipage=1;\r
                        proutn("Lt. Uhura-  \"Captain, the starbase in");\r
-                       cramlc(1, d.isx, d.isy);\r
+                       cramlc(1, state.isx, state.isy);\r
                        skip(1);\r
                        prout("   reports that it is under attack from the Klingon Super-commander.");\r
                        proutn("   It can survive until stardate ");\r
@@ -537,13 +537,13 @@ void scom(int *ipage) {
 #endif\r
                (Rand() > 0.2 ||\r
                 (damage[DRADIO] > 0.0 && condit != IHDOCKED) ||\r
-                starch[d.isx][d.isy] > 0))\r
+                starch[state.isx][state.isy] > 0))\r
                return;\r
        if (*ipage==0) pause(1);\r
        *ipage = 1;\r
        prout("Lt. Uhura-  \"Captain, Starfleet Intelligence reports");\r
        proutn("   the Super-commander is in");\r
-       cramlc(1, d.isx, d.isy);\r
+       cramlc(1, state.isx, state. isy);\r
        prout(".\"");\r
        return;\r
 }\r
index 9a83fba3898309a5bc148bc2481e2c8b40f294e3..184bc7cf144ca1df8a5953a779c2da5842e446da 100644 (file)
--- a/battle.c
+++ b/battle.c
@@ -163,7 +163,7 @@ void ram(int ibumpd, int ienm, int ix, int iy) {
                damage[l] += Time + extradm; /* Damage for at least time of travel! */\r
        }\r
        shldup = 0;\r
-       if (d.remkl) {\r
+       if (state.remkl) {\r
                pause(2);\r
                dreprt();\r
        }\r
@@ -292,26 +292,26 @@ void torpedo(double course, double r, int inx, int iny, double *hit) {
                        case IHB: /* Hit a base */\r
                                prout("***STARBASE DESTROYED..");\r
                                if (starch[quadx][quady] < 0) starch[quadx][quady] = 0;\r
-                               for (ll=1; ll<=d.rembase; ll++) {\r
-                                       if (d.baseqx[ll]==quadx && d.baseqy[ll]==quady) {\r
-                                               d.baseqx[ll]=d.baseqx[d.rembase];\r
-                                               d.baseqy[ll]=d.baseqy[d.rembase];\r
+                               for (ll=1; ll<=state.rembase; ll++) {\r
+                                       if (state.baseqx[ll]==quadx && state.baseqy[ll]==quady) {\r
+                                               state.baseqx[ll]=state.baseqx[state.rembase];\r
+                                               state.baseqy[ll]=state.baseqy[state.rembase];\r
                                                break;\r
                                        }\r
                                }\r
                                quad[ix][iy]=IHDOT;\r
-                               d.rembase--;\r
+                               state.rembase--;\r
                                basex=basey=0;\r
-                               d.galaxy[quadx][quady] -= 10;\r
-                               d.basekl++;\r
+                               state.galaxy[quadx][quady] -= 10;\r
+                               state.basekl++;\r
                                newcnd();\r
                                return;\r
                        case IHP: /* Hit a planet */\r
                                crmena(1, iquad, 2, ix, iy);\r
                                prout(" destroyed.");\r
-                               d.nplankl++;\r
-                               d.newstuf[quadx][quady] -= 1;\r
-                               d.plnets[iplnet] = nulplanet;\r
+                               state.nplankl++;\r
+                               state.newstuf[quadx][quady] -= 1;\r
+                               state.plnets[iplnet] = nulplanet;\r
                                iplnet = 0;\r
                                plnetx = plnety = 0;\r
                                quad[ix][iy] = IHDOT;\r
@@ -495,8 +495,8 @@ void attack(int k) {
                        r = (Rand()+Rand())*0.5 -0.5;\r
                        r += 0.002*kpower[l]*r;\r
                        torpedo(course, r, jx, jy, &hit);\r
-                       if (d.remkl==0) finish(FWON); /* Klingons did themselves in! */\r
-                       if (d.galaxy[quadx][quady] == 1000 ||\r
+                       if (state.remkl==0) finish(FWON); /* Klingons did themselves in! */\r
+                       if (state.galaxy[quadx][quady] == 1000 ||\r
                                alldone) return; /* Supernova or finished */\r
                        if (hit == 0) continue;\r
                }\r
@@ -590,10 +590,10 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) {
        /* Decide what kind of enemy it is and update approriately */\r
        if (type == IHR) {\r
                /* chalk up a Romulan */\r
-               d.newstuf[quadx][quady] -= 10;\r
+               state.newstuf[quadx][quady] -= 10;\r
                irhere--;\r
-               d.nromkl++;\r
-               d.nromrem--;\r
+               state.nromkl++;\r
+               state.nromrem--;\r
        }\r
        else if (type == IHT) {\r
                /* Killed a Tholian */\r
@@ -601,41 +601,41 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) {
        }\r
        else {\r
                /* Some type of a Klingon */\r
-               d.galaxy[quadx][quady] -= 100;\r
+               state.galaxy[quadx][quady] -= 100;\r
                klhere--;\r
-               d.remkl--;\r
+               state.remkl--;\r
                switch (type) {\r
                        case IHC:\r
                                comhere = 0;\r
-                               for (i=1; i<=d.remcom; i++)\r
-                                       if (d.cx[i]==quadx && d.cy[i]==quady) break;\r
-                               d.cx[i] = d.cx[d.remcom];\r
-                               d.cy[i] = d.cy[d.remcom];\r
-                               d.cx[d.remcom] = 0;\r
-                               d.cy[d.remcom] = 0;\r
-                               d.remcom--;\r
+                               for (i=1; i<=state.remcom; i++)\r
+                                       if (state.cx[i]==quadx && state.cy[i]==quady) break;\r
+                               state.cx[i] = state.cx[state.remcom];\r
+                               state.cy[i] = state.cy[state.remcom];\r
+                               state.cx[state.remcom] = 0;\r
+                               state.cy[state.remcom] = 0;\r
+                               state.remcom--;\r
                                future[FTBEAM] = 1e30;\r
-                               if (d.remcom != 0)\r
-                                       future[FTBEAM] = d.date + expran(1.0*incom/d.remcom);\r
-                               d.killc++;\r
+                               if (state.remcom != 0)\r
+                                       future[FTBEAM] = state.date + expran(1.0*incom/state.remcom);\r
+                               state.killc++;\r
                                break;\r
                        case IHK:\r
-                               d.killk++;\r
+                               state.killk++;\r
                                break;\r
                        case IHS:\r
-                               d.nscrem = ishere = d.isx = d.isy = isatb = iscate = 0;\r
-                               d.nsckill = 1;\r
+                               state.nscrem = ishere = state.isx = state.isy = isatb = iscate = 0;\r
+                               state.nsckill = 1;\r
                                future[FSCMOVE] = future[FSCDBAS] = 1e30;\r
                                break;\r
                }\r
        }\r
 \r
        /* For each kind of enemy, finish message to player */\r
-       prout(" destroyed.");\r
+       prout(" destroyestate.");\r
        quad[ix][iy] = IHDOT;\r
-       if (d.remkl==0) return;\r
+       if (state.remkl==0) return;\r
 \r
-       d.remtime = d.remres/(d.remkl + 4*d.remcom);\r
+       state.remtime = state.remres/(state.remkl + 4*state.remcom);\r
 \r
        if (type == IHT) return;\r
 \r
@@ -814,9 +814,9 @@ void photon(void) {
                        proutn("Torpedo track- ");\r
                }\r
                torpedo(course[i], r, sectx, secty, &dummy);\r
-               if (alldone || d.galaxy[quadx][quady]==1000) return;\r
+               if (alldone || state.galaxy[quadx][quady]==1000) return;\r
        }\r
-       if (d.remkl==0) finish(FWON);\r
+       if (state.remkl==0) finish(FWON);\r
 }\r
 \r
        \r
@@ -1195,7 +1195,7 @@ void hittem(double *hits) {
                skip(1);\r
                if (kpow == 0) {\r
                        deadkl(ii, jj, ienm, ii, jj);\r
-                       if (d.remkl==0) finish(FWON);\r
+                       if (state.remkl==0) finish(FWON);\r
                        if (alldone) return;\r
                        kk--; /* don't do the increment */\r
                }\r
index 84ce49b3e5d9dc6e3a4f6f03990efe1db5b7fbf7..098c4a213707e731072367debd1e71ba8519f738 100644 (file)
--- a/events.c
+++ b/events.c
@@ -4,7 +4,7 @@
 void events(void) {\r
 \r
        int ictbeam=0, ipage=0, istract=0, line, i, j, k, l, ixhold, iyhold;\r
-       double fintim = d.date + Time, datemin, xtime, repair, yank;\r
+       double fintim = state.date + Time, datemin, xtime, repair, yank;\r
        \r
 \r
 #ifdef DEBUG\r
@@ -13,10 +13,10 @@ void events(void) {
 \r
        if (stdamtim == 1e30 && damage[DRADIO] != 0.0) {\r
                /* chart will no longer be updated because radio is dead */\r
-               stdamtim = d.date;\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] = d.galaxy[i][j]+1000;\r
+                               if (starch[i][j] == 1) starch[i][j] = state.galaxy[i][j]+1000;\r
        }\r
 \r
        for (;;) {\r
@@ -29,12 +29,12 @@ void events(void) {
                                line = l;\r
                                datemin = future[l];\r
                        }\r
-               xtime = datemin-d.date;\r
-               d.date = datemin;\r
+               xtime = datemin-state.date;\r
+               state.date = datemin;\r
                /* Decrement Federation resources and recompute remaining time */\r
-               d.remres -= (d.remkl+4*d.remcom)*xtime;\r
-               d.remtime = d.remres/(d.remkl+4*d.remcom);\r
-               if (d.remtime <=0) {\r
+               state.remres -= (state.remkl+4*state.remcom)*xtime;\r
+               state.remtime = state.remres/(state.remkl+4*state.remcom);\r
+               if (state.remtime <=0) {\r
                        finish(FDEPLETE);\r
                        return;\r
                }\r
@@ -78,11 +78,11 @@ void events(void) {
                                if (ipage==0) pause(1);\r
                                ipage=1;\r
                                snova(0,0);\r
-                               future[FSNOVA] = d.date + expran(0.5*intime);\r
-                               if (d.galaxy[quadx][quady] == 1000) return;\r
+                               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
-                               if (d.nscrem == 0 ||\r
+                               if (state.nscrem == 0 ||\r
                                        ictbeam+istract > 0 ||\r
                                        condit==IHDOCKED || isatb==1 || iscate==1) return;\r
                                if (ientesc ||\r
@@ -93,22 +93,22 @@ void events(void) {
                                         (torps < 5 || damage[DPHOTON] > 0))) {\r
                                        /* Tractor-beam her! */\r
                                        istract=1;\r
-                                       yank = square(d.isx-quadx) + square(d.isy-quady);\r
+                                       yank = square(state.isx-quadx) + square(state.isy-quady);\r
                                        /*********TBEAM CODE***********/\r
                                }\r
                                else return;\r
                        case FTBEAM: /* Tractor beam */\r
                                if (line==FTBEAM) {\r
-                                       if (d.remcom == 0) {\r
+                                       if (state.remcom == 0) {\r
                                                future[FTBEAM] = 1e30;\r
                                                break;\r
                                        }\r
-                                       i = Rand()*d.remcom+1.0;\r
-                                       yank = square(d.cx[i]-quadx) + square(d.cy[i]-quady);\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] = d.date + Time +\r
-                                                                                expran(1.5*intime/d.remcom);\r
+                                               future[FTBEAM] = state.date + Time +\r
+                                                                                expran(1.5*intime/state.remcom);\r
                                                break;\r
                                        }\r
                                }\r
@@ -143,12 +143,12 @@ void events(void) {
                                        }\r
                                }\r
                                if (line==0) {\r
-                                       quadx = d.isx;\r
-                                       quady = d.isy;\r
+                                       quadx = state.isx;\r
+                                       quady = state.isy;\r
                                }\r
                                else {\r
-                                       quadx = d.cx[i];\r
-                                       quady = d.cy[i];\r
+                                       quadx = state.cx[i];\r
+                                       quady = state.cy[i];\r
                                }\r
                                iran10(&sectx, &secty);\r
                                crmshp();\r
@@ -158,7 +158,7 @@ void events(void) {
                                cramlc(2, sectx, secty);\r
                                skip(1);\r
                                if (resting) {\r
-                                       prout("(Remainder of rest/repair period cancelled.)");\r
+                                       prout("(Remainder of rest/repair period cancellestate.)");\r
                                        resting = 0;\r
                                }\r
                                if (shldup==0) {\r
@@ -170,44 +170,44 @@ void events(void) {
                                }\r
                                newqad(0);\r
                                /* Adjust finish time to time of tractor beaming */\r
-                               fintim = d.date+Time;\r
-                               if (d.remcom <= 0) future[FTBEAM] = 1e30;\r
-                               else future[FTBEAM] = d.date+Time+expran(1.5*intime/d.remcom);\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
                                break;\r
                        case FSNAP: /* Snapshot of the universe (for time warp) */\r
-                               snapsht = d;\r
-                               d.snap = 1;\r
-                               future[FSNAP] = d.date + expran(0.5 * intime);\r
+                               snapsht = state;\r
+                               state.snap = 1;\r
+                               future[FSNAP] = state.date + expran(0.5 * intime);\r
                                break;\r
                        case FBATTAK: /* Commander attacks starbase */\r
-                               if (d.remcom==0 || d.rembase==0) {\r
+                               if (state.remcom==0 || state.rembase==0) {\r
                                        /* no can do */\r
                                        future[FBATTAK] = future[FCDBAS] = 1e30;\r
                                        break;\r
                                }\r
                                i = 0;\r
-                               for (j=1; j<=d.rembase; j++) {\r
-                                       for (k=1; k<=d.remcom; k++)\r
-                                               if (d.baseqx[j]==d.cx[k] && d.baseqy[j]==d.cy[k] &&\r
-                                                       (d.baseqx[j]!=quadx || d.baseqy[j]!=quady) &&\r
-                                                       (d.baseqx[j]!=d.isx || d.baseqy[j]!=d.isy)) {\r
+                               for (j=1; j<=state.rembase; j++) {\r
+                                       for (k=1; k<=state.remcom; k++)\r
+                                               if (state.baseqx[j]==state.cx[k] && state.baseqy[j]==state.cy[k] &&\r
+                                                       (state.baseqx[j]!=quadx || state.baseqy[j]!=quady) &&\r
+                                                       (state.baseqx[j]!=state.isx || state.baseqy[j]!=state.isy)) {\r
                                                        i = 1;\r
                                                        break;\r
                                                }\r
                                        if (i == 1) break;\r
                                }\r
-                               if (j>d.rembase) {\r
+                               if (j>state.rembase) {\r
                                        /* no match found -- try later */\r
-                                       future[FBATTAK] = d.date + expran(0.3*intime);\r
+                                       future[FBATTAK] = state.date + expran(0.3*intime);\r
                                        future[FCDBAS] = 1e30;\r
                                        break;\r
                                }\r
                                /* commander + starbase combination found -- launch attack */\r
-                               batx = d.baseqx[j];\r
-                               baty = d.baseqy[j];\r
-                               future[FCDBAS] = d.date+1.0+3.0*Rand();\r
+                               batx = state.baseqx[j];\r
+                               baty = state.baseqy[j];\r
+                               future[FCDBAS] = state.date+1.0+3.0*Rand();\r
                                if (isatb) /* extra time if SC already attacking */\r
-                                       future[FCDBAS] += future[FSCDBAS]-d.date;\r
+                                       future[FCDBAS] += future[FSCDBAS]-state.date;\r
                                future[FBATTAK] = future[FCDBAS] +expran(0.3*intime);\r
                                iseenit = 0;\r
                                if (damage[DRADIO] != 0.0 &&\r
@@ -236,19 +236,19 @@ void events(void) {
                        case FSCDBAS: /* Supercommander destroys base */\r
                                future[FSCDBAS] = 1e30;\r
                                isatb = 2;\r
-                               if (d.galaxy[d.isx][d.isy]%100 < 10) break; /* WAS RETURN! */\r
+                               if (state.galaxy[state.isx][state.isy]%100 < 10) break; /* WAS RETURN! */\r
                                ixhold = batx;\r
                                iyhold = baty;\r
-                               batx = d.isx;\r
-                               baty = d.isy;\r
+                               batx = state.isx;\r
+                               baty = state.isy;\r
                        case FCDBAS: /* Commander succeeds in destroying base */\r
                                if (line==FCDBAS) {\r
                                        future[FCDBAS] = 1e30;\r
                                        /* find the lucky pair */\r
-                                       for (i = 1; i <= d.remcom; i++)\r
-                                               if (d.cx[i]==batx && d.cy[i]==baty) break;\r
-                                       if (i > d.remcom || d.rembase == 0 ||\r
-                                               d.galaxy[batx][baty] % 100 < 10) {\r
+                                       for (i = 1; i <= state.remcom; i++)\r
+                                               if (state.cx[i]==batx && state.cy[i]==baty) break;\r
+                                       if (i > state.remcom || state.rembase == 0 ||\r
+                                               state.galaxy[batx][baty] % 100 < 10) {\r
                                                /* No action to take after all */\r
                                                batx = baty = 0;\r
                                                break;\r
@@ -264,9 +264,9 @@ void events(void) {
                                        basex=basey=0;\r
                                        newcnd();\r
                                        skip(1);\r
-                                       prout("Spock-  \"Captain, I believe the starbase has been destroyed.\"");\r
+                                       prout("Spock-  \"Captain, I believe the starbase has been destroyestate.\"");\r
                                }\r
-                               else if (d.rembase != 1 &&\r
+                               else if (state.rembase != 1 &&\r
                                                 (damage[DRADIO] <= 0.0 || condit == IHDOCKED)) {\r
                                        /* Get word via subspace radio */\r
                                        if (ipage==0) pause(1);\r
@@ -280,13 +280,13 @@ void events(void) {
                                        else prout("a Klingon Commander");\r
                                }\r
                                /* Remove Starbase from galaxy */\r
-                               d.galaxy[batx][baty] -= 10;\r
-                               for (i=1; i <= d.rembase; i++)\r
-                                       if (d.baseqx[i]==batx && d.baseqy[i]==baty) {\r
-                                               d.baseqx[i]=d.baseqx[d.rembase];\r
-                                               d.baseqy[i]=d.baseqy[d.rembase];\r
+                               state.galaxy[batx][baty] -= 10;\r
+                               for (i=1; i <= state.rembase; i++)\r
+                                       if (state.baseqx[i]==batx && state.baseqy[i]==baty) {\r
+                                               state.baseqx[i]=state.baseqx[state.rembase];\r
+                                               state.baseqy[i]=state.baseqy[state.rembase];\r
                                        }\r
-                               d.rembase--;\r
+                               state.rembase--;\r
                                if (isatb == 2) {\r
                                        /* reinstate a commander's base attack */\r
                                        batx = ixhold;\r
@@ -298,13 +298,13 @@ void events(void) {
                                }\r
                                break;\r
                        case FSCMOVE: /* Supercommander moves */\r
-                               future[FSCMOVE] = d.date+0.2777;\r
+                               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] = d.date + 0.01;\r
+                               future[FDSPROB] = state.date + 0.01;\r
                                probex += probeinx;\r
                                probey += probeiny;\r
                                i = (int)(probex/10 +0.05);\r
@@ -313,7 +313,7 @@ void events(void) {
                                        probecx = i;\r
                                        probecy = j;\r
                                        if (i < 1 || i > 8 || j < 1 || j > 8 ||\r
-                                               d.galaxy[probecx][probecy] == 1000) {\r
+                                               state.galaxy[probecx][probecy] == 1000) {\r
                                                // Left galaxy or ran into supernova\r
                                                if (damage[DRADIO]==0.0 || condit == IHDOCKED) {\r
                                                        if (ipage==0) pause(1);\r
@@ -342,14 +342,14 @@ void events(void) {
                                   radio. */\r
                                if (damage[DRADIO] == 0.0 || condit == IHDOCKED)\r
                                        starch[probecx][probecy] = damage[DRADIO] > 0.0 ?\r
-                                                                                  d.galaxy[probecx][probecy]+1000 : 1;\r
+                                                                                  state.galaxy[probecx][probecy]+1000 : 1;\r
                                proben--; // One less to travel\r
                                if (proben == 0 && isarmed &&\r
-                                       d.galaxy[probecx][probecy] % 10 > 0) {\r
+                                       state.galaxy[probecx][probecy] % 10 > 0) {\r
                                        /* lets blow the sucker! */\r
                                        snova(1,0);\r
                                        future[FDSPROB] = 1e30;\r
-                                       if (d.galaxy[quadx][quady] == 1000) return;\r
+                                       if (state.galaxy[quadx][quady] == 1000) return;\r
                                }\r
                                break;\r
                }\r
@@ -374,7 +374,7 @@ void wait(void) {
        }\r
        origTime = delay = aaitem;\r
        if (delay <= 0.0) return;\r
-       if (delay >= d.remtime || nenhere != 0) {\r
+       if (delay >= state.remtime || nenhere != 0) {\r
                prout("Are you sure? ");\r
                if (ja() == 0) return;\r
        }\r
@@ -385,7 +385,7 @@ void wait(void) {
        do {\r
                if (delay <= 0) resting = 0;\r
                if (resting == 0) {\r
-                       cramf(d.remtime, 0, 2);\r
+                       cramf(state.remtime, 0, 2);\r
                        prout(" stardates left.");\r
                        return;\r
                }\r
@@ -406,7 +406,7 @@ void wait(void) {
                /* Repair Deathray if long rest at starbase */\r
                if (origTime-delay >= 9.99 && condit == IHDOCKED)\r
                        damage[DDRAY] = 0.0;\r
-       } while (d.galaxy[quadx][quady] != 1000); // leave if quadrant supernovas\r
+       } while (state.galaxy[quadx][quady] != 1000); // leave if quadrant supernovas\r
 \r
        resting = 0;\r
        Time = 0;\r
@@ -427,8 +427,8 @@ void nova(int ix, int iy) {
        quad[ix][iy] = IHDOT;\r
        crmena(1, IHSTAR, 2, ix, iy);\r
        prout(" novas.");\r
-       d.galaxy[quadx][quady] -= 1;\r
-       d.starkl++;\r
+       state.galaxy[quadx][quady] -= 1;\r
+       state.starkl++;\r
        \r
        /* Set up stack to recursively trigger adjacent stars */\r
        bot = top = top2 = 1;\r
@@ -462,18 +462,18 @@ void nova(int ix, int iy) {
                                                top2++;\r
                                                hits[top2][1]=ii;\r
                                                hits[top2][2]=jj;\r
-                                               d.galaxy[quadx][quady] -= 1;\r
-                                               d.starkl++;\r
+                                               state.galaxy[quadx][quady] -= 1;\r
+                                               state.starkl++;\r
                                                crmena(1, IHSTAR, 2, ii, jj);\r
                                                prout(" novas.");\r
                                                quad[ii][jj] = IHDOT;\r
                                                break;\r
                                        case IHP: /* Destroy planet */\r
-                                               d.newstuf[quadx][quady] -= 1;\r
-                                               d.nplankl++;\r
+                                               state.newstuf[quadx][quady] -= 1;\r
+                                               state.nplankl++;\r
                                                crmena(1, IHP, 2, ii, jj);\r
                                                prout(" destroyed.");\r
-                                               d.plnets[iplnet] = nulplanet;\r
+                                               state.plnets[iplnet] = nulplanet;\r
                                                iplnet = plnetx = plnety = 0;\r
                                                if (landed == 1) {\r
                                                        finish(FPNOVA);\r
@@ -482,14 +482,14 @@ void nova(int ix, int iy) {
                                                quad[ii][jj] = IHDOT;\r
                                                break;\r
                                        case IHB: /* Destroy base */\r
-                                               d.galaxy[quadx][quady] -= 10;\r
-                                               for (i = 1; i <= d.rembase; i++)\r
-                                                       if (d.baseqx[i]==quadx && d.baseqy[i]==quady) break;\r
-                                               d.baseqx[i] = d.baseqx[d.rembase];\r
-                                               d.baseqy[i] = d.baseqy[d.rembase];\r
-                                               d.rembase--;\r
+                                               state.galaxy[quadx][quady] -= 10;\r
+                                               for (i = 1; i <= state.rembase; i++)\r
+                                                       if (state.baseqx[i]==quadx && state.baseqy[i]==quady) break;\r
+                                               state.baseqx[i] = state.baseqx[state.rembase];\r
+                                               state.baseqy[i] = state.baseqy[state.rembase];\r
+                                               state.rembase--;\r
                                                basex = basey = 0;\r
-                                               d.basekl++;\r
+                                               state.basekl++;\r
                                                newcnd();\r
                                                crmena(1, IHB, 2, ii, jj);\r
                                                prout(" destroyed.");\r
@@ -610,14 +610,14 @@ void snova(int insx, int insy) {
                        left of universe */\r
                        for (nqx = 1; nqx<=8; nqx++) {\r
                                for (nqy = 1; nqy<=8; nqy++) {\r
-                                       stars += d.galaxy[nqx][nqy] % 10;\r
+                                       stars += state.galaxy[nqx][nqy] % 10;\r
                                }\r
                        }\r
                        if (stars == 0) return; /* nothing to supernova exists */\r
                        num = Rand()*stars + 1;\r
                        for (nqx = 1; nqx<=8; nqx++) {\r
                                for (nqy = 1; nqy<=8; nqy++) {\r
-                                       num -= d.galaxy[nqx][nqy] % 10;\r
+                                       num -= state.galaxy[nqx][nqy] % 10;\r
                                        if (num <= 0) break;\r
                                }\r
                                if (num <=0) break;\r
@@ -638,7 +638,7 @@ void snova(int insx, int insy) {
                        if (damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
                                skip(1);\r
                                proutn("Message from Starfleet Command       Stardate ");\r
-                               cramf(d.date, 0, 1);\r
+                               cramf(state.date, 0, 1);\r
                                skip(1);\r
                                proutn("     Supernova in");\r
                                cramlc(1, nqx, nqy);\r
@@ -648,7 +648,7 @@ void snova(int insx, int insy) {
                else {\r
                        /* we are in the quadrant! */\r
                        insipient = 1;\r
-                       num = Rand()* (d.galaxy[nqx][nqy]%10) + 1;\r
+                       num = Rand()* (state.galaxy[nqx][nqy]%10) + 1;\r
                        for (nsx=1; nsx < 10; nsx++) {\r
                                for (nsy=1; nsy < 10; nsy++) {\r
                                        if (quad[nsx][nsy]==IHSTAR) {\r
@@ -682,75 +682,75 @@ void snova(int insx, int insy) {
                }\r
        }\r
        /* destroy any Klingons in supernovaed quadrant */\r
-       num=d.galaxy[nqx][nqy];\r
+       num=state.galaxy[nqx][nqy];\r
        kldead = num/100;\r
        comdead = iscdead = 0;\r
-       if (nqx==d.isx && nqy == d.isy) {\r
+       if (nqx==state.isx && nqy == state.isy) {\r
                /* did in the Supercommander! */\r
-               d.nscrem = d.isx = d.isy = isatb = iscate = 0;\r
+               state.nscrem = state.isx = state.isy = isatb = iscate = 0;\r
                iscdead = 1;\r
                future[FSCMOVE] = future[FSCDBAS] = 1e30;\r
        }\r
-       d.remkl -= kldead;\r
-       if (d.remcom) {\r
-               int maxloop = d.remcom, l;\r
+       state.remkl -= kldead;\r
+       if (state.remcom) {\r
+               int maxloop = state.remcom, l;\r
                for (l = 1; l <= maxloop; l++) {\r
-                       if (d.cx[l] == nqx && d.cy[l] == nqy) {\r
-                               d.cx[l] = d.cx[d.remcom];\r
-                               d.cy[l] = d.cy[d.remcom];\r
-                               d.cx[d.remcom] = d.cy[d.remcom] = 0;\r
-                               d.remcom--;\r
+                       if (state.cx[l] == nqx && state.cy[l] == nqy) {\r
+                               state.cx[l] = state.cx[state.remcom];\r
+                               state.cy[l] = state.cy[state.remcom];\r
+                               state.cx[state.remcom] = state.cy[state.remcom] = 0;\r
+                               state.remcom--;\r
                                kldead--;\r
                                comdead++;\r
-                               if (d.remcom==0) future[FTBEAM] = 1e30;\r
+                               if (state.remcom==0) future[FTBEAM] = 1e30;\r
                                break;\r
                        }\r
                }\r
        }\r
        /* destroy Romulans and planets in supernovaed quadrant */\r
-       num = d.newstuf[nqx][nqy];\r
-       d.newstuf[nqx][nqy] = 0;\r
+       num = state.newstuf[nqx][nqy];\r
+       state.newstuf[nqx][nqy] = 0;\r
        nrmdead = num/10;\r
-       d.nromrem -= nrmdead;\r
+       state.nromrem -= nrmdead;\r
        npdead = num - nrmdead*10;\r
        if (npdead) {\r
                int l;\r
                for (l = 1; l <= inplan; l++)\r
-                       if (d.plnets[l].x == nqx && d.plnets[l].y == nqy) {\r
-                               d.plnets[l] = nulplanet;\r
+                       if (state.plnets[l].x == nqx && state.plnets[l].y == nqy) {\r
+                               state.plnets[l] = nulplanet;\r
                        }\r
        }\r
        /* Destroy any base in supernovaed quadrant */\r
-       if (d.rembase) {\r
-               int maxloop = d.rembase, l;\r
+       if (state.rembase) {\r
+               int maxloop = state.rembase, l;\r
                for (l = 1; l <= maxloop; l++)\r
-                       if (d.baseqx[l]==nqx && d.baseqy[l]==nqy) {\r
-                               d.baseqx[l] = d.baseqx[d.rembase];\r
-                               d.baseqy[l] = d.baseqy[d.rembase];\r
-                               d.baseqx[d.rembase] = d.baseqy[d.rembase] = 0;\r
-                               d.rembase--;\r
+                       if (state.baseqx[l]==nqx && state.baseqy[l]==nqy) {\r
+                               state.baseqx[l] = state.baseqx[state.rembase];\r
+                               state.baseqy[l] = state.baseqy[state.rembase];\r
+                               state.baseqx[state.rembase] = state.baseqy[state.rembase] = 0;\r
+                               state.rembase--;\r
                                break;\r
                        }\r
        }\r
        /* If starship caused supernova, tally up destruction */\r
        if (insx) {\r
-               num = d.galaxy[nqx][nqy] % 100;\r
-               d.starkl += num % 10;\r
-               d.basekl += num/10;\r
-               d.killk += kldead;\r
-               d.killc += comdead;\r
-               d.nromkl += nrmdead;\r
-               d.nplankl += npdead;\r
-               d.nsckill += iscdead;\r
+               num = state.galaxy[nqx][nqy] % 100;\r
+               state.starkl += num % 10;\r
+               state.basekl += num/10;\r
+               state.killk += kldead;\r
+               state.killc += comdead;\r
+               state.nromkl += nrmdead;\r
+               state.nplankl += npdead;\r
+               state.nsckill += iscdead;\r
        }\r
        /* mark supernova in galaxy and in star chart */\r
        if ((quadx == nqx && quady == nqy) ||\r
                damage[DRADIO] == 0 ||\r
                condit == IHDOCKED)\r
                starch[nqx][nqy] = 1;\r
-       d.galaxy[nqx][nqy] = 1000;\r
+       state.galaxy[nqx][nqy] = 1000;\r
        /* If supernova destroys last klingons give special message */\r
-       if (d.remkl==0 && (nqx != quadx || nqy != quady)) {\r
+       if (state.remkl==0 && (nqx != quadx || nqy != quady)) {\r
                skip(2);\r
                if (insx == 0) prout("Lucky you!");\r
                proutn("A supernova in");\r
index 1d58840fa8361a76c5ffffd6614773949a238db7..c9d6aa42a906fda31e5966e5150362b8e703e11e 100644 (file)
--- a/finish.c
+++ b/finish.c
@@ -68,26 +68,26 @@ void finish(FINTYPE ifin) {
        int igotit = 0;\r
        alldone = 1;\r
        skip(3);\r
-       printf("It is stardate %.1f .\n\n", d.date);\r
+       printf("It is stardate %.1f .\n\n", state.date);\r
        switch (ifin) {\r
                case FWON: // Game has been won\r
-                       if (d.nromrem != 0)\r
+                       if (state.nromrem != 0)\r
                                printf("The remaining %d Romulans surrender to Starfleet Command.\n",\r
-                                          d.nromrem);\r
+                                          state.nromrem);\r
                        \r
                        prout("You have smashed the Klingon invasion fleet and saved");\r
                        prout("the Federation.");\r
                        gamewon=1;\r
                        if (alive) {\r
                                double badpt;\r
-                               badpt = 5.*d.starkl + casual + 10.*d.nplankl +\r
-                                               45.*nhelp+100.*d.basekl;\r
+                               badpt = 5.*state.starkl + casual + 10.*state.nplankl +\r
+                                               45.*nhelp+100.*state.basekl;\r
                                if (ship == IHF) badpt += 100.0;\r
                                else if (ship == 0) badpt += 200.0;\r
                                if (badpt < 100.0) badpt = 0.0; // Close enough!\r
-                               if (d.date-indate < 5.0 ||\r
+                               if (state.date-indate < 5.0 ||\r
                                        // killsPerDate >= RateMax\r
-                                       (d.killk+d.killc+d.nsckill)/(d.date-indate) >=\r
+                                       (state.killk+state.killc+state.nsckill)/(state.date-indate) >=\r
                                        0.1*skill*(skill+1.0) + 0.1 + 0.008*badpt) {\r
                                        skip(1);\r
                                        prout("In fact, you have done so well that Starfleet Command");\r
@@ -105,7 +105,7 @@ void finish(FINTYPE ifin) {
                                                        prout("promotes you to Commodore Emeritus.");\r
                                                        skip(1);\r
                                                        prout("Now that you think you're really good, try playing");\r
-                                                       prout("the \"Emeritus\" game. It will splatter your ego.");\r
+                                                       prout("the \"Emeritus\" frozen. It will splatter your ego.");\r
                                                        break;\r
                                                case 5:\r
                                                        skip(1);\r
@@ -150,7 +150,7 @@ void finish(FINTYPE ifin) {
                        prout("conquered.  Your starship is now Klingon property,");\r
                        prout("and you are put on trial as a war criminal.  On the");\r
                        proutn("basis of your record, you are ");\r
-                       if (d.remkl*3.0 > inkling) {\r
+                       if (state.remkl*3.0 > inkling) {\r
                                prout("aquitted.");\r
                                skip(1);\r
                                prout("LIVE LONG AND PROSPER.");\r
@@ -275,9 +275,9 @@ void finish(FINTYPE ifin) {
        if (ship==IHF) ship= 0;\r
        else if (ship == IHE) ship = IHF;\r
        alive = 0;\r
-       if (d.remkl != 0) {\r
-               double goodies = d.remres/inresor;\r
-               double baddies = (d.remkl + 2.0*d.remcom)/(inkling+2.0*incom);\r
+       if (state.remkl != 0) {\r
+               double goodies = state.remres/inresor;\r
+               double baddies = (state.remkl + 2.0*state.remcom)/(inkling+2.0*incom);\r
                if (goodies/baddies >= 1.0+0.5*Rand()) {\r
                        prout("As a result of your actions, a treaty with the Klingon");\r
                        prout("Empire has been signed. The terms of the treaty are");\r
@@ -303,54 +303,54 @@ void finish(FINTYPE ifin) {
 }\r
 \r
 void score(void) {\r
-       double timused = d.date - indate;\r
+       double timused = state.date - indate;\r
        int ithperd, iwon, klship;\r
 \r
        pause(0);\r
 \r
        iskill = skill;\r
-       if ((timused == 0 || d.remkl != 0) && timused < 5.0) timused = 5.0;\r
-       perdate = (d.killc + d.killk + d.nsckill)/timused;\r
+       if ((timused == 0 || state.remkl != 0) && timused < 5.0) timused = 5.0;\r
+       perdate = (state.killc + state.killk + state.nsckill)/timused;\r
        ithperd = 500*perdate + 0.5;\r
        iwon = 0;\r
        if (gamewon) iwon = 100*skill;\r
        if (ship == IHE) klship = 0;\r
        else if (ship == IHF) klship = 1;\r
        else klship = 2;\r
-       if (gamewon == 0) d.nromrem = 0; // None captured if no win\r
-       iscore = 10*d.killk + 50*d.killc + ithperd + iwon\r
-                        - 100*d.basekl - 100*klship - 45*nhelp -5*d.starkl - casual\r
-                        + 20*d.nromkl + 200*d.nsckill - 10*d.nplankl + d.nromrem;\r
+       if (gamewon == 0) state.nromrem = 0; // None captured if no win\r
+       iscore = 10*state.killk + 50*state.killc + ithperd + iwon\r
+                        - 100*state.basekl - 100*klship - 45*nhelp -5*state.starkl - casual\r
+                        + 20*state.nromkl + 200*state.nsckill - 10*state.nplankl + state.nromrem;\r
        if (alive == 0) iscore -= 200;\r
        skip(2);\r
        prout("Your score --");\r
-       if (d.nromkl)\r
+       if (state.nromkl)\r
                printf("%6d Romulans destroyed                 %5d\n",\r
-                          d.nromkl,20*d.nromkl);\r
-       if (d.nromrem)\r
+                          state.nromkl,20*state.nromkl);\r
+       if (state.nromrem)\r
                printf("%6d Romulans captured                  %5d\n",\r
-                          d.nromrem, d.nromrem);\r
-       if (d.killk)\r
+                          state.nromrem, state.nromrem);\r
+       if (state.killk)\r
                printf("%6d ordinary Klingons destroyed        %5d\n",\r
-                          d.killk, 10*d.killk);\r
-       if (d.killc)\r
+                          state.killk, 10*state.killk);\r
+       if (state.killc)\r
                printf("%6d Klingon commanders destroyed       %5d\n",\r
-                          d.killc, 50*d.killc);\r
-       if (d.nsckill)\r
+                          state.killc, 50*state.killc);\r
+       if (state.nsckill)\r
                printf("%6d Super-Commander destroyed          %5d\n",\r
-                          d.nsckill, 200*d.nsckill);\r
+                          state.nsckill, 200*state.nsckill);\r
        if (ithperd)\r
                printf("%6.2f Klingons per stardate              %5d\n",\r
                           perdate, ithperd);\r
-       if (d.starkl)\r
+       if (state.starkl)\r
                printf("%6d stars destroyed by your action     %5d\n",\r
-                          d.starkl, -5*d.starkl);\r
-       if (d.nplankl)\r
+                          state.starkl, -5*state.starkl);\r
+       if (state.nplankl)\r
                printf("%6d planets destroyed by your action   %5d\n",\r
-                          d.nplankl, -10*d.nplankl);\r
-       if (d.basekl)\r
+                          state.nplankl, -10*state.nplankl);\r
+       if (state.basekl)\r
                printf("%6d bases destroyed by your action     %5d\n",\r
-                          d.basekl, -100*d.basekl);\r
+                          state.basekl, -100*state.basekl);\r
        if (nhelp)\r
                printf("%6d calls for help from starbase       %5d\n",\r
                           nhelp, -45*nhelp);\r
index 47bb598448dd3ffe685a548f20495167e7aa1a83..9eb70960c277f72971d3d356e0fec83af5253cf4 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 (d.date+Time >= future[FTBEAM]) {\r
+       if (state.date+Time >= future[FTBEAM]) {\r
                trbeam = 1;\r
                condit = IHRED;\r
-               dist = dist*(future[FTBEAM]-d.date)/Time + 0.1;\r
-               Time = future[FTBEAM] - d.date + 1e-5;\r
+               dist = dist*(future[FTBEAM]-state.date)/Time + 0.1;\r
+               Time = future[FTBEAM] - state.date + 1e-5;\r
        }\r
        /* Move within the quadrant */\r
        quad[sectx][secty] = IHDOT;\r
@@ -50,7 +50,7 @@ void move(void) {
                                                                          (iy-ky[l])*(double)(iy-ky[l]));\r
                                                kavgd[l] = 0.5 * (finald+kdist[l]);\r
                                        }\r
-                                       if (d.galaxy[quadx][quady] != 1000) attack(0);\r
+                                       if (state.galaxy[quadx][quady] != 1000) attack(0);\r
                                        if (alldone) return;\r
                                }\r
                                /* compute final position -- new quadrant and sector */\r
@@ -179,7 +179,7 @@ label100:
                        kdist[l] = finald;\r
                }\r
                sortkl();\r
-               if (d.galaxy[quadx][quady] != 1000 && iattak == 0)\r
+               if (state.galaxy[quadx][quady] != 1000 && iattak == 0)\r
                        attack(0);\r
                for (l = 1 ; l <= nenhere; l++) kavgd[l] = kdist[l];\r
        }\r
@@ -443,7 +443,7 @@ void impuls(void) {
        }\r
        /* Make sure enough time is left for the trip */\r
        Time = dist/0.095;\r
-       if (Time >= d.remtime) {\r
+       if (Time >= state.remtime) {\r
                prout("First Officer Spock- \"Captain, our speed under impulse");\r
                prout("power is only 0.95 sectors per stardate. Are you sure");\r
                prout("we dare spend the time?\"");\r
@@ -515,11 +515,11 @@ void warp(int i) {
                                                \r
                /* Make sure enough time is left for the trip */\r
                Time = 10.0*dist/wfacsq;\r
-               if (Time >= 0.8*d.remtime) {\r
+               if (Time >= 0.8*state.remtime) {\r
                        skip(1);\r
                        prout("First Officer Spock- \"Captain, I compute that such");\r
                        proutn("  a trip would require approximately ");\r
-                       cramf(100.0*Time/d.remtime, 0, 2);\r
+                       cramf(100.0*Time/state.remtime, 0, 2);\r
                        prout(" percent of our");\r
                        prout(" remaining time.  Are you sure this is wise?\"");\r
                        if (ja() == 0) { ididit = 0; return;}\r
@@ -703,7 +703,7 @@ void atover(int igrab) {
                crmshp();\r
                skip(1);\r
                prout("safely out of quadrant.");\r
-               starch[quadx][quady] = damage[DRADIO] > 0.0 ? d.galaxy[quadx][quady]+1000:1;\r
+               starch[quadx][quady] = damage[DRADIO] > 0.0 ? state.galaxy[quadx][quady]+1000:1;\r
 \r
                /* Try to use warp engines */\r
                if (damage[DWARPEN]) {\r
@@ -735,28 +735,28 @@ void atover(int igrab) {
                        return;\r
                }\r
                /* Repeat if another snova */\r
-       } while (d.galaxy[quadx][quady] == 1000);\r
-       if (d.remkl==0) finish(FWON); /* Snova killed remaining enemy. */\r
+       } while (state.galaxy[quadx][quady] == 1000);\r
+       if (state.remkl==0) finish(FWON); /* Snova killed remaining enemy. */\r
 }\r
 \r
 void timwrp() {\r
        int l, ll, gotit;\r
        prout("***TIME WARP ENTERED.");\r
-       if (d.snap && Rand() < 0.5) {\r
+       if (state.snap && Rand() < 0.5) {\r
                /* Go back in time */\r
                proutn("You are traveling backwards in time ");\r
-               cramf(d.date-snapsht.date, 0, 2);\r
+               cramf(state.date-snapsht.date, 0, 2);\r
                prout(" stardates.");\r
-               d = snapsht;\r
-               d.snap = 0;\r
-               if (d.remcom) {\r
-                       future[FTBEAM] = d.date + expran(intime/d.remcom);\r
-                       future[FBATTAK] = d.date + expran(0.3*intime);\r
-               }\r
-               future[FSNOVA] = d.date + expran(0.5*intime);\r
-               future[FSNAP] = d.date +expran(0.25*d.remtime); /* next snapshot will\r
+               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
+               }\r
+               future[FSNOVA] = state.date + expran(0.5*intime);\r
+               future[FSNAP] = state.date +expran(0.25*state.remtime); /* next snapshot will\r
                                                                                                           be sooner */\r
-               if (d.nscrem) future[FSCMOVE] = 0.2777;\r
+               if (state.nscrem) future[FSCMOVE] = 0.2777;\r
                isatb = 0;\r
                future[FCDBAS] = future[FSCDBAS] = 1e30;\r
                batx = baty = 0;\r
@@ -765,7 +765,7 @@ void timwrp() {
                   when on planet, which would give us two Galileos! */\r
                gotit = 0;\r
                for (l = 1; l <= inplan; l++) {\r
-                       if (d.plnets[l].known == 2) {\r
+                       if (state.plnets[l].known == 2) {\r
                                gotit = 1;\r
                                if (iscraft==1 && ship==IHE) {\r
                                        prout("Checkov-  \"Security reports the Galileo has disappeared, Sir!");\r
@@ -781,13 +781,13 @@ void timwrp() {
                }\r
 \r
                /* Revert star chart to earlier era, if it was known then*/\r
-               if (damage[DRADIO]==0.0 || stdamtim > d.date) {\r
+               if (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 ? d.galaxy[l][ll]+1000 :1;\r
+                                               starch[l][ll]=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 = d.date;\r
+                       if (damage[DRADIO] > 0.0) stdamtim = state.date;\r
                }\r
        }\r
        else {\r
@@ -870,7 +870,7 @@ void probe(void) {
        probey = quady*10 + secty - 1;\r
        probecx = quadx;\r
        probecy = quady;\r
-       future[FDSPROB] = d.date + 0.01; // Time to move one sector\r
+       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
@@ -890,7 +890,7 @@ void help(void) {
                prout("Subspace radio damaged.");\r
                return;\r
        }\r
-       if (d.rembase==0) {\r
+       if (state.rembase==0) {\r
                prout("Lt. Uhura-  \"Captain, I'm not getting any response from Starbase.\"");\r
                return;\r
        }\r
@@ -908,16 +908,16 @@ void help(void) {
        }\r
        else {\r
                ddist = 1e30;\r
-               for (l = 1; l <= d.rembase; l++) {\r
-                       xdist=10.0*sqrt(square(d.baseqx[l]-quadx)+square(d.baseqy[l]-quady));\r
+               for (l = 1; l <= state.rembase; l++) {\r
+                       xdist=10.0*sqrt(square(state.baseqx[l]-quadx)+square(state.baseqy[l]-quady));\r
                        if (xdist < ddist) {\r
                                ddist = xdist;\r
                                line = l;\r
                        }\r
                }\r
                /* Since starbase not in quadrant, set up new quadrant */\r
-               quadx = d.baseqx[line];\r
-               quady = d.baseqy[line];\r
+               quadx = state.baseqx[line];\r
+               quady = state.baseqy[line];\r
                newqad(1);\r
        }\r
        /* dematerialize starship */\r
index a816863ecb2e75b0330bd361a976c37d73d85ee6..fefa8a4a1b95e72aa99420464ff8413eddbb4335 100644 (file)
--- a/planets.c
+++ b/planets.c
@@ -11,7 +11,7 @@ static int consumeTime(void) {
        ididit = 1;\r
 #if 0\r
        /* Don't wory about this */\r
-       if (future[FTBEAM] <= d.date+Time && d.remcom != 0 && condit != IHDOCKED) {\r
+       if (future[FTBEAM] <= state.date+Time && state.remcom != 0 && condit != IHDOCKED) {\r
                /* We are about to be tractor beamed -- operation fails */\r
                return 1;\r
        }\r
@@ -21,7 +21,7 @@ static int consumeTime(void) {
        events();       /* Used to avoid if future[FSCMOVE] within time */\r
 //     future[FSNOVA] = asave;\r
        /*fails if game over, quadrant super-novas or we've moved to new quadrant*/\r
-       if (alldone || d.galaxy[quadx][quady] == 1000 || justin != 0) return 1;\r
+       if (alldone || state.galaxy[quadx][quady] == 1000 || justin != 0) return 1;\r
        return 0;\r
 }\r
 \r
@@ -32,22 +32,22 @@ void preport(void) {
        prout("Spock-  \"Planet report follows, Captain.\"");\r
        skip(1);\r
        for (i = 1; i <= inplan; i++) {\r
-               if (d.plnets[i].known\r
+               if (state.plnets[i].known\r
 #ifdef DEBUG\r
-                       || ( idebug && d.plnets[i].x !=0)\r
+                       || ( idebug && state.plnets[i].x !=0)\r
 #endif\r
                        ) {\r
                        iknow = 1;\r
 #ifdef DEBUG\r
-                       if (idebug && d.plnets[i].known==0) proutn("(Unknown) ");\r
+                       if (idebug && state.plnets[i].known==0) proutn("(Unknown) ");\r
 #endif\r
-                       cramlc(1, d.plnets[i].x, d.plnets[i].y);\r
+                       cramlc(1, state.plnets[i].x, state.plnets[i].y);\r
                        proutn("   class ");\r
-                       proutn(classes[d.plnets[i].pclass]);\r
+                       proutn(classes[state.plnets[i].pclass]);\r
                        proutn("   ");\r
-                       if (d.plnets[i].crystals == 0) proutn("no ");\r
+                       if (state.plnets[i].crystals == 0) proutn("no ");\r
                        prout("dilithium crystals present.");\r
-                       if (d.plnets[i].known==2) \r
+                       if (state.plnets[i].known==2) \r
                                prout("    Shuttle Craft Galileo on surface.");\r
                }\r
        }\r
@@ -102,14 +102,14 @@ void sensor(void) {
        proutn("         Planet at");\r
        cramlc(2, plnetx, plnety);\r
        proutn(" is of class ");\r
-       proutn(classes[d.plnets[iplnet].pclass]);\r
+       proutn(classes[state.plnets[iplnet].pclass]);\r
        prout(".");\r
-       if (d.plnets[iplnet].known==2) \r
+       if (state.plnets[iplnet].known==2) \r
                prout("         Sensors show Galileo still on surface.");\r
        proutn("         Readings indicate");\r
-       if (d.plnets[iplnet].crystals == 0) proutn(" no");\r
+       if (state.plnets[iplnet].crystals == 0) proutn(" no");\r
        prout(" dilithium crystals present.\"");\r
-       if (d.plnets[iplnet].known == 0) d.plnets[iplnet].known = 1;\r
+       if (state.plnets[iplnet].known == 0) state.plnets[iplnet].known = 1;\r
        return;\r
 }\r
 \r
@@ -118,7 +118,7 @@ void beam(void) {
        skip(1);\r
        if (damage[DTRANSP] != 0) {\r
                prout("Transporter damaged.");\r
-               if (damage[DSHUTTL]==0 && (d.plnets[iplnet].known==2 || iscraft == 1)) {\r
+               if (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
@@ -134,7 +134,7 @@ void beam(void) {
                prout("Impossible to transport through shields.");\r
                return;\r
        }\r
-       if (d.plnets[iplnet].known==0) {\r
+       if (state.plnets[iplnet].known==0) {\r
                prout("Spock-  \"Captain, we have no information on this planet");\r
                prout("  and Starfleet Regulations clearly state that in this situation");\r
                prout("  you may not go down.\"");\r
@@ -142,7 +142,7 @@ void beam(void) {
        }\r
        if (landed==1) {\r
                /* Coming from planet */\r
-               if (d.plnets[iplnet].known==2) {\r
+               if (state.plnets[iplnet].known==2) {\r
                        proutn("Spock-  \"Wouldn't you rather take the Galileo?\" ");\r
                        if (ja() != 0) {\r
                                chew();\r
@@ -159,7 +159,7 @@ void beam(void) {
        }\r
        else {\r
                /* Going to planet */\r
-               if (d.plnets[iplnet].crystals==0) {\r
+               if (state.plnets[iplnet].crystals==0) {\r
                        prout("Spock-  \"Captain, I fail to see the logic in");\r
                        prout("  exploring a planet with no dilithium crystals.");\r
                        proutn("  Are you sure this is wise?\" ");\r
@@ -188,7 +188,7 @@ void beam(void) {
        skip(2);\r
        prout("Transport complete.");\r
        landed = -landed;\r
-       if (landed==1 && d.plnets[iplnet].known==2) {\r
+       if (landed==1 && state.plnets[iplnet].known==2) {\r
                prout("The shuttle craft Galileo is here!");\r
        }\r
        if (landed!=1 && imine==1) {\r
@@ -208,7 +208,7 @@ void mine(void) {
                prout("Mining party not on planet.");\r
                return;\r
        }\r
-       if (d.plnets[iplnet].crystals == 0) {\r
+       if (state.plnets[iplnet].crystals == 0) {\r
                prout("No dilithium crystals on this planet.");\r
                return;\r
        }\r
@@ -223,7 +223,7 @@ void mine(void) {
                prout("there's no reason to mine more at this time.");\r
                return;\r
        }\r
-       Time = (0.1+0.2*Rand())*d.plnets[iplnet].pclass;\r
+       Time = (0.1+0.2*Rand())*state.plnets[iplnet].pclass;\r
        if (consumeTime()) return;\r
        prout("Mining operation complete.");\r
        imine = 1;\r
@@ -287,7 +287,7 @@ void shuttle(void) {
        ididit = 0;\r
        if(damage[DSHUTTL] != 0.0) {\r
                if (damage[DSHUTTL] == -1.0) {\r
-                       if (inorbit && d.plnets[iplnet].known == 2)\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
@@ -302,11 +302,11 @@ void shuttle(void) {
                prout(" not in standard orbit.");\r
                return;\r
        }\r
-       if ((d.plnets[iplnet].known != 2) && iscraft != 1) {\r
+       if ((state.plnets[iplnet].known != 2) && iscraft != 1) {\r
                prout("Shuttle craft not currently available.");\r
                return;\r
        }\r
-       if (landed==-1 && d.plnets[iplnet].known==2) {\r
+       if (landed==-1 && state.plnets[iplnet].known==2) {\r
                prout("You will have to beam down to retrieve the shuttle craft.");\r
                return;\r
        }\r
@@ -314,17 +314,17 @@ void shuttle(void) {
                prout("Shuttle craft cannot pass through shields.");\r
                return;\r
        }\r
-       if (d.plnets[iplnet].known==0) {\r
+       if (state.plnets[iplnet].known==0) {\r
                prout("Spock-  \"Captain, we have no information on this planet");\r
                prout("  and Starfleet Regulations clearly state that in this situation");\r
                prout("  you may not fly down.\"");\r
                return;\r
        }\r
        Time = 3.0e-5*height;\r
-       if (Time >= 0.8*d.remtime) {\r
+       if (Time >= 0.8*state.remtime) {\r
                prout("First Officer Spock-  \"Captain, I compute that such");\r
                prout("  a maneuver would require approximately ");\r
-               cramf(100*Time/d.remtime,0,4);\r
+               cramf(100*Time/state.remtime,0,4);\r
                prout("% of our");\r
                prout("remaining time.");\r
                prout("Are you sure this is wise?\" ");\r
@@ -351,7 +351,7 @@ void shuttle(void) {
                        iscraft = 0;\r
                        skip(1);\r
                        if (consumeTime()) return;\r
-                       d.plnets[iplnet].known=2;\r
+                       state.plnets[iplnet].known=2;\r
                        prout("Trip complete.");\r
                        return;\r
                }\r
@@ -361,7 +361,7 @@ void shuttle(void) {
                        prout("shuttle craft for the trip back to the Enterprise.");\r
                        skip(1);\r
                        prout("The short hop begins . . .");\r
-                       d.plnets[iplnet].known=1;\r
+                       state.plnets[iplnet].known=1;\r
                        icraft = 1;\r
                        skip(1);\r
                        landed = -1;\r
@@ -388,7 +388,7 @@ void shuttle(void) {
                icraft = 1;\r
                iscraft = 0;\r
                if (consumeTime()) return;\r
-               d.plnets[iplnet].known = 2;\r
+               state.plnets[iplnet].known = 2;\r
                landed = 1;\r
                icraft = 0;\r
                prout("Trip complete");\r
@@ -439,7 +439,7 @@ void deathray(void) {
                while (nenhere > 0)\r
                        deadkl(kx[1],ky[1],quad[kx[1]][ky[1]],kx[1],ky[1]);\r
                prout("Ensign Chekov-  \"Congratulations, Captain!\"");\r
-               if (d.remkl == 0) finish(FWON);\r
+               if (state.remkl == 0) finish(FWON);\r
                prout("Spock-  \"Captain, I believe the `Experimental Death Ray'");\r
                if (Rand() <= 0.05) {\r
                        prout("   is still operational.\"");\r
index 0c8f6062cc0b44b1c723f3914ae5ab1b4ff4ed16..afed60a5aaaea88811f3dfbd2c5477a88dff3bf1 100644 (file)
--- a/reports.c
+++ b/reports.c
@@ -14,7 +14,7 @@ void attakreport(void) {
        }\r
        if (isatb == 1) {\r
                proutn("Starbase in ");\r
-               cramlc(1, d.isx, d.isy);\r
+               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
@@ -42,28 +42,28 @@ void report(int f) {
                case 5: s3="emeritus"; break;\r
                default: s3="skilled"; break;\r
        }\r
-       printf("\nYou %s playing a %s%s %s game.\n",\r
+       printf("\nYou %s playing a %s%s %s frozen.\n",\r
                   alldone? "were": "are now", s1, s2, s3);\r
        if (skill>3 && thawed && !alldone) prout("No plaque is allowed.");\r
        if (tourn) printf("This is tournament game %d.\n", tourn);\r
        if (f) printf("Your secret password is \"%s\"\n",passwd);\r
        printf("%d of %d Klingons have been killed",\r
-                  d.killk+d.killc+d.nsckill, inkling);\r
-       if (d.killc) printf(", including %d Commander%s.\n", d.killc, d.killc==1?"":"s");\r
-       else if (d.killk+d.nsckill > 0) prout(", but no Commanders.");\r
+                  state.killk+state.killc+state.nsckill, inkling);\r
+       if (state.killc) printf(", including %d Commander%s.\n", state.killc, state.killc==1?"":"s");\r
+       else if (state.killk+state.nsckill > 0) prout(", but no Commanders.");\r
        else prout(".");\r
        if (skill > 2) printf("The Super Commander has %sbeen destroyed.\n",\r
-                                                 d.nscrem?"not ":"");\r
-       if (d.rembase != inbase) {\r
+                                                 state.nscrem?"not ":"");\r
+       if (state.rembase != inbase) {\r
                proutn("There ");\r
-               if (inbase-d.rembase==1) proutn("has been 1 base");\r
+               if (inbase-state.rembase==1) proutn("has been 1 base");\r
                else {\r
                        proutn("have been ");\r
-                       crami(inbase-d.rembase, 1);\r
+                       crami(inbase-state.rembase, 1);\r
                        proutn(" bases");\r
                }\r
                proutn(" destroyed, ");\r
-               crami(d.rembase, 1);\r
+               crami(state.rembase, 1);\r
                prout(" remaining.");\r
        }\r
        else printf("There are %d bases.\n", inbase);\r
@@ -134,8 +134,8 @@ void lrscan(void) {
                        if (x == 0 || x > 8 || y == 0 || y > 8)\r
                                printf("   -1");\r
                        else {\r
-                               printf("%5d", d.galaxy[x][y]);\r
-                               starch[x][y] = damage[DRADIO] > 0 ? d.galaxy[x][y]+1000 :1;\r
+                               printf("%5d", state.galaxy[x][y]);\r
+                               starch[x][y] = damage[DRADIO] > 0 ? state.galaxy[x][y]+1000 :1;\r
                        }\r
                }\r
                putchar('\n');\r
@@ -170,7 +170,7 @@ void chart(int nn) {
 \r
        chew();\r
        skip(1);\r
-       if (stdamtim != 1e30 && stdamtim != d.date && condit == IHDOCKED) {\r
+       if (stdamtim != 1e30 && stdamtim != state.date && condit == IHDOCKED) {\r
                prout("Spock-  \"I revised the Star Chart from the");\r
                prout("  starbase's records.\"");\r
                skip(1);\r
@@ -179,14 +179,14 @@ void chart(int nn) {
        if (stdamtim != 1e30) {\r
                if (condit == IHDOCKED) {\r
                        /* We are docked, so restore chart from base information */\r
-                       stdamtim = d.date;\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] = d.galaxy[i][j]+1000;\r
+                                       if (starch[i][j] == 1) starch[i][j] = state.galaxy[i][j]+1000;\r
                }\r
                else {\r
                        proutn("(Last surveillance update ");\r
-                       cramf(d.date-stdamtim, 0, 1);\r
+                       cramf(state.date-stdamtim, 0, 1);\r
                        prout(" stardates ago.)");\r
                }\r
        }\r
@@ -205,7 +205,7 @@ void chart(int nn) {
                        else if (starch[i][j] > 999)\r
                                printf("%5d", starch[i][j]-1000);\r
                        else\r
-                               printf("%5d", d.galaxy[i][j]);\r
+                               printf("%5d", state.galaxy[i][j]);\r
                }\r
                prout("  -");\r
        }\r
@@ -238,7 +238,7 @@ void srscan(int l) {
                        }\r
                        if (goodScan)\r
                                starch[quadx][quady] = damage[DRADIO]>0.0 ?\r
-                                                                          d.galaxy[quadx][quady]+1000:1;\r
+                                                                          state.galaxy[quadx][quady]+1000:1;\r
                        scan();\r
                        if (isit("chart")) nn = TRUE;\r
                        if (isit("no")) rightside = FALSE;\r
@@ -278,7 +278,7 @@ void srscan(int l) {
                if (rightside) {\r
                        switch (jj) {\r
                                case 1:\r
-                                       printf(" Stardate      %.1f", d.date);\r
+                                       printf(" Stardate      %.1f", state.date);\r
                                        break;\r
                                case 2:\r
                                        if (condit != IHDOCKED) newcnd();\r
@@ -328,10 +328,10 @@ void srscan(int l) {
                                                   (int)((100.0*shield)/inshld + 0.5), shield);\r
                                        break;\r
                                case 9:\r
-                                       printf(" Klingons Left %d", d.remkl);\r
+                                       printf(" Klingons Left %d", state.remkl);\r
                                        break;\r
                                case 10:\r
-                                       printf(" Time Left     %.2f", d.remtime);\r
+                                       printf(" Time Left     %.2f", state.remtime);\r
                                        break;\r
                        }\r
                                        \r
@@ -397,7 +397,7 @@ void eta(void) {
                proutn("Time or arrival date? ");\r
                if (scan()==IHREAL) {\r
                        ttime = aaitem;\r
-                       if (ttime > d.date) ttime -= d.date; // Actually a star date\r
+                       if (ttime > state.date) ttime -= state.date; // Actually a star date\r
                        if (ttime <= 1e-10 ||\r
                                (twarp=(floor(sqrt((10.0*dist)/ttime)*10.0)+1.0)/10.0) > 10) {\r
                                prout("We'll never make it, sir.");\r
@@ -455,7 +455,7 @@ void eta(void) {
                prout(".");\r
                if (wfl) {\r
                        proutn("And we will arrive at stardate ");\r
-                       cramf(d.date+ttime, 1, 1);\r
+                       cramf(state.date+ttime, 1, 1);\r
                        prout(".");\r
                }\r
                else if (twarp==1.0)\r
@@ -465,16 +465,16 @@ void eta(void) {
                        cramf(twarp, 1, 2);\r
                        skip(1);\r
                        proutn("and we will arrive at stardate ");\r
-                       cramf(d.date+ttime, 1, 2);\r
+                       cramf(state.date+ttime, 1, 2);\r
                        prout(".");\r
                }\r
-               if (d.remtime < ttime)\r
+               if (state.remtime < ttime)\r
                        prout("Unfortunately, the Federation will be destroyed by then.");\r
                if (twarp > 6.0)\r
                        prout("You'll be taking risks at that speed, Captain");\r
-               if ((isatb==1 && d.isy == ix1 && d.isx == iy1 &&\r
-                        future[FSCDBAS]< ttime+d.date)||\r
-                       (future[FCDBAS]<ttime+d.date && baty==ix1 && batx == iy1))\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
                        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 8cd1536bc95af5709bbe35e1d035ed1a0b0e5831..6484243bb9879f24d3faac343f9eb8c3124814b6 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -36,7 +36,7 @@ void freeze(int boss) {
                skip(1);\r
                return;\r
        }\r
-       fwrite(&d, sizeof(d), 1, fp);\r
+       fwrite(&state, sizeof(state), 1, fp);\r
        fwrite(&snapsht, sizeof(snapsht), 1, fp);\r
        fwrite(quad, sizeof(quad), 1, fp);\r
        fwrite(kx, sizeof(kx), 1, fp);\r
@@ -47,7 +47,7 @@ void freeze(int boss) {
        fwrite(kavgd, sizeof(kavgd), 1, fp);\r
        fwrite(damage, sizeof(damage), 1, fp);\r
        fwrite(future, sizeof(future), 1, fp);\r
-       fwrite(&game, sizeof(game), 1, fp);\r
+       fwrite(&frozen, sizeof(frozen), 1, fp);\r
        fwrite(passwd, sizeof(passwd), 1, fp);\r
 \r
        fclose(fp);\r
@@ -80,7 +80,7 @@ void thaw(void) {
                skip(1);\r
                return;\r
        }\r
-       fread(&d, sizeof(d), 1, fp);\r
+       fread(&state, sizeof(state), 1, fp);\r
        fread(&snapsht, sizeof(snapsht), 1, fp);\r
        fread(quad, sizeof(quad), 1, fp);\r
        fread(kx, sizeof(kx), 1, fp);\r
@@ -91,7 +91,7 @@ void thaw(void) {
        fread(kavgd, sizeof(kavgd), 1, fp);\r
        fread(damage, sizeof(damage), 1, fp);\r
        fread(future, sizeof(future), 1, fp);\r
-       fread(&game, sizeof(game), 1, fp);\r
+       fread(&frozen, sizeof(frozen), 1, fp);\r
        fread(passwd, sizeof(passwd), 1, fp);\r
 \r
        fclose(fp);\r
@@ -140,7 +140,7 @@ void abandn(void) {
                prout("Captain and crew escape in shuttle craft.");\r
                prout("Remainder of ship's complement beam down");\r
                prout("to nearest habitable planet.");\r
-               if (d.rembase==0) {\r
+               if (state.rembase==0) {\r
                        /* Ops! no place to go... */\r
                        finish(FABANDN);\r
                        return;\r
@@ -151,11 +151,11 @@ void abandn(void) {
                nprobes = 0; /* No probes */\r
                prout("You are captured by Klingons and released to");\r
                prout("the Federation in a prisoner-of-war exchange.");\r
-               nb = Rand()*d.rembase+1;\r
+               nb = Rand()*state.rembase+1;\r
                /* Set up quadrant and position FQ adjacient to base */\r
-               if (quadx!=d.baseqx[nb] || quady!=d.baseqy[nb]) {\r
-                       quadx = d.baseqx[nb];\r
-                       quady = d.baseqy[nb];\r
+               if (quadx!=state.baseqx[nb] || quady!=state.baseqy[nb]) {\r
+                       quadx = state.baseqx[nb];\r
+                       quady = state.baseqy[nb];\r
                        sectx = secty = 5;\r
                        newqad(1);\r
                }\r
@@ -222,22 +222,22 @@ void setup(void) {
        for (i=0; i <= ndevice; i++) damage[i] = 0.0;\r
        // Set up assorted game parameters\r
        batx = baty = 0;\r
-       d.date = indate = 100.0*(int)(31.0*Rand()+20.0);\r
-       d.killk = d.killc = nkinks = nhelp = resting = casual = d.nromkl = 0;\r
-       isatb = iscate = imine = icrystl = icraft = d.nsckill = d.nplankl = 0;\r
+       state.date = indate = 100.0*(int)(31.0*Rand()+20.0);\r
+       state.killk = state.killc = nkinks = nhelp = resting = casual = state.nromkl = 0;\r
+       isatb = iscate = imine = icrystl = icraft = state.nsckill = state.nplankl = 0;\r
        iscraft = 1;\r
        landed = -1;\r
        alive = 1;\r
        docfac = 0.25;\r
        for (i = 1; i <= 8; i++)\r
-               for (j = 1; j <= 8; j++) d.newstuf[i][j] = starch[i][j] = 0;\r
+               for (j = 1; j <= 8; j++) state.newstuf[i][j] = starch[i][j] = 0;\r
        // Initialize times for extraneous events\r
-       future[FSNOVA] = d.date + expran(0.5 * intime);\r
-       future[FTBEAM] = d.date + expran(1.5 * (intime / d.remcom));\r
-       future[FSNAP] = d.date + 1.0 + Rand(); // Force an early snapshot\r
-       future[FBATTAK] = d.date + expran(0.3*intime);\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] = d.nscrem ? d.date+0.2777 : 1e30;\r
+       future[FSCMOVE] = state.nscrem ? state.date+0.2777 : 1e30;\r
        future[FSCDBAS] = 1e30;\r
        future[FDSPROB] = 1e30;\r
        // Starchart is functional\r
@@ -248,18 +248,18 @@ void setup(void) {
                for (j=1; j<=8; j++) {\r
                        int k = Rand()*9.0 + 1.0;\r
                        instar += k;\r
-                       d.galaxy[i][j] = k;\r
+                       state.galaxy[i][j] = k;\r
                }\r
        // Locate star bases in galaxy\r
        for (i = 1; i <= inbase; i++) {\r
                int contflag;\r
                do {\r
                        do iran8(&ix, &iy);\r
-                       while (d.galaxy[ix][iy] >= 10);\r
+                       while (state.galaxy[ix][iy] >= 10);\r
                        contflag = FALSE;\r
                        for (j = i-1; j > 0; j--) {\r
                                /* Improved placement algorithm to spread out bases */\r
-                               double distq = square(ix-d.baseqx[j]) + square(iy-d.baseqy[j]);\r
+                               double distq = square(ix-state.baseqx[j]) + square(iy-state.baseqy[j]);\r
                                if (distq < 6.0*(6-inbase) && Rand() < 0.75) {\r
                                        contflag = TRUE;\r
 #ifdef DEBUG\r
@@ -275,13 +275,13 @@ void setup(void) {
                        }\r
                } while (contflag);\r
                        \r
-               d.baseqx[i] = ix;\r
-               d.baseqy[i] = iy;\r
+               state.baseqx[i] = ix;\r
+               state.baseqy[i] = iy;\r
                starch[ix][iy] = -1;\r
-               d.galaxy[ix][iy] += 10;\r
+               state.galaxy[ix][iy] += 10;\r
        }\r
        // Position ordinary Klingon Battle Cruisers\r
-       krem = inkling - incom - d.nscrem;\r
+       krem = inkling - incom - state.nscrem;\r
        klumper = 0.25*skill*(9.0-length)+1.0;\r
        if (klumper > 9) klumper = 9; // Can't have more than 9 in quadrant\r
        do {\r
@@ -291,8 +291,8 @@ void setup(void) {
                krem -= klump;\r
                klump *= 100;\r
                do iran8(&ix, &iy);\r
-               while (d.galaxy[ix][iy] + klump >= 1000);\r
-               d.galaxy[ix][iy] += klump;\r
+               while (state.galaxy[ix][iy] + klump >= 1000);\r
+               state.galaxy[ix][iy] += klump;\r
        } while (krem > 0);\r
        // Position Klingon Commander Ships\r
 #ifdef DEBUG\r
@@ -303,47 +303,47 @@ void setup(void) {
                        do { /* IF debugging, put commanders by bases, always! */\r
 #ifdef DEBUG\r
                                if (idebug && klumper <= inbase) {\r
-                                       ix = d.baseqx[klumper];\r
-                                       iy = d.baseqy[klumper];\r
+                                       ix = state.baseqx[klumper];\r
+                                       iy = state.baseqy[klumper];\r
                                        klumper++;\r
                                }\r
                                else\r
 #endif\r
                                        iran8(&ix, &iy);\r
                        }\r
-                       while ((d.galaxy[ix][iy] < 99 && Rand() < 0.75)||\r
-                                  d.galaxy[ix][iy]>899);\r
+                       while ((state.galaxy[ix][iy] < 99 && Rand() < 0.75)||\r
+                                  state.galaxy[ix][iy]>899);\r
                        // check for duplicate\r
                        for (j = 1; j < i; j++)\r
-                               if (d.cx[j]==ix && d.cy[j]==iy) break;\r
+                               if (state.cx[j]==ix && state.cy[j]==iy) break;\r
                } while (j < i);\r
-               d.galaxy[ix][iy] += 100;\r
-               d.cx[i] = ix;\r
-               d.cy[i] = iy;\r
+               state.galaxy[ix][iy] += 100;\r
+               state.cx[i] = ix;\r
+               state.cy[i] = iy;\r
        }\r
        // Locate planets in galaxy\r
        for (i = 1; i <= inplan; i++) {\r
                do iran8(&ix, &iy);\r
-               while (d.newstuf[ix][iy] > 0);\r
-               d.newstuf[ix][iy] = 1;\r
-               d.plnets[i].x = ix;\r
-               d.plnets[i].y = iy;\r
-               d.plnets[i].pclass = Rand()*3.0 + 1.0; // Planet class M N or O\r
-               d.plnets[i].crystals = 1.5*Rand();              // 1 in 3 chance of crystals\r
-               d.plnets[i].known = 0;\r
+               while (state.newstuf[ix][iy] > 0);\r
+               state.newstuf[ix][iy] = 1;\r
+               state.plnets[i].x = ix;\r
+               state.plnets[i].y = iy;\r
+               state.plnets[i].pclass = Rand()*3.0 + 1.0; // Planet class M N or O\r
+               state.plnets[i].crystals = 1.5*Rand();          // 1 in 3 chance of crystals\r
+               state.plnets[i].known = 0;\r
        }\r
        // Locate Romulans\r
-       for (i = 1; i <= d.nromrem; i++) {\r
+       for (i = 1; i <= state.nromrem; i++) {\r
                iran8(&ix, &iy);\r
-               d.newstuf[ix][iy] += 10;\r
+               state.newstuf[ix][iy] += 10;\r
        }\r
        // Locate the Super Commander\r
-       if (d.nscrem > 0) {\r
+       if (state.nscrem > 0) {\r
                do iran8(&ix, &iy);\r
-               while (d.galaxy[ix][iy] >= 900);\r
-               d.isx = ix;\r
-               d.isy = iy;\r
-               d.galaxy[ix][iy] += 100;\r
+               while (state.galaxy[ix][iy] >= 900);\r
+               state.isx = ix;\r
+               state.isy = iy;\r
+               state.galaxy[ix][iy] += 100;\r
        }\r
        // Place thing (in tournament game, thingx == -1, don't want one!)\r
        if (Rand() < 0.1 && thingx != -1) {\r
@@ -355,11 +355,11 @@ void setup(void) {
 \r
 //     idate = date;\r
        skip(3);\r
-       d.snap = 0;\r
+       state.snap = 0;\r
                \r
        if (skill == 1) {\r
                printf("It is stardate %d. The Federation is being attacked by\n",\r
-                          (int)d.date);\r
+                          (int)state.date);\r
                printf("a deadly Klingon invasion force. As captain of the United\n"\r
                           "Starship U.S.S. Enterprise, it is your mission to seek out\n"\r
                           "and destroy this invasion force of %d battle cruisers.\n",\r
@@ -373,12 +373,12 @@ void setup(void) {
        else {\r
                printf("Stardate %d.\n\n"\r
                           "%d Klingons.\nAn unknown number of Romulans\n",\r
-                          (int)d.date, inkling);\r
-               if (d.nscrem) printf("and one (GULP) Super-Commander.\n");\r
+                          (int)state.date, inkling);\r
+               if (state.nscrem) printf("and one (GULP) Super-Commander.\n");\r
                printf("%d stardates\n%d starbases in  ",(int)intime, inbase);\r
        }\r
        for (i = 1; i <= inbase; i++) {\r
-               cramlc(0, d.baseqx[i], d.baseqy[i]);\r
+               cramlc(0, state.baseqx[i], state.baseqy[i]);\r
                if (i < inbase) proutn("  ");\r
        }\r
        skip(2);\r
@@ -388,7 +388,7 @@ void setup(void) {
        cramlc(2, sectx, secty);\r
        skip(2);\r
        prout("Good Luck!");\r
-       if (d.nscrem) proutn("  YOU'LL NEED IT.");\r
+       if (state.nscrem) proutn("  YOU'LL NEED IT.");\r
        skip(1);\r
        newqad(0);\r
        if (nenhere) shldup=1.0;\r
@@ -476,22 +476,22 @@ int choose(void) {
 \r
        // Use parameters to generate initial values of things\r
        damfac = 0.5 * skill;\r
-       d.rembase = 3.0*Rand()+2.0;\r
-       inbase = d.rembase;\r
+       state.rembase = 3.0*Rand()+2.0;\r
+       inbase = state.rembase;\r
        inplan = (PLNETMAX/2) + (PLNETMAX/2+1)*Rand();\r
-       d.nromrem = (2.0+Rand())*skill;\r
-       d.nscrem = (skill > 2? 1 : 0);\r
-       d.remtime = 7.0 * length;\r
-       intime = d.remtime;\r
-       d.remkl = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15);\r
-       inkling = d.remkl;\r
+       state.nromrem = (2.0+Rand())*skill;\r
+       state.nscrem = (skill > 2? 1 : 0);\r
+       state.remtime = 7.0 * length;\r
+       intime = state.remtime;\r
+       state.remkl = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15);\r
+       inkling = state.remkl;\r
        incom = skill + 0.0625*inkling*Rand();\r
-       d.remcom= min(10, incom);\r
-       incom = d.remcom;\r
-       d.remres = (inkling+4*incom)*intime;\r
-       inresor = d.remres;\r
+       state.remcom= min(10, incom);\r
+       incom = state.remcom;\r
+       state.remres = (inkling+4*incom)*intime;\r
+       inresor = state.remres;\r
        if (inkling > 50) {\r
-               inbase = (d.rembase += 1);\r
+               inbase = (state.rembase += 1);\r
        }\r
        return FALSE;\r
 }\r
@@ -505,14 +505,14 @@ void dropin(int iquad, int *ix, int *iy) {
 void newcnd(void) {\r
        condit = IHGREEN;\r
        if (energy < 1000.0) condit = IHYELLOW;\r
-       if (d.galaxy[quadx][quady] > 99 || d.newstuf[quadx][quady] > 9)\r
+       if (state.galaxy[quadx][quady] > 99 || state.newstuf[quadx][quady] > 9)\r
                condit = IHRED;\r
 }\r
 \r
 \r
 void newqad(int shutup) {\r
-       int quadnum = d.galaxy[quadx][quady];\r
-       int newnum = d.newstuf[quadx][quady];\r
+       int quadnum = state.galaxy[quadx][quady];\r
+       int newnum = state.newstuf[quadx][quady];\r
        int i, j, ix, iy, nplan;\r
 \r
        iattak = 1;\r
@@ -583,17 +583,17 @@ void newqad(int shutup) {
                        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 <= d.remcom ; i++) \r
-                       if (d.cx[i]==quadx && d.cy[i]==quady) break;\r
+               for (i = 1; i <= state.remcom ; i++) \r
+                       if (state.cx[i]==quadx && state.cy[i]==quady) break;\r
                        \r
-               if (i <= d.remcom) {\r
+               if (i <= state.remcom) {\r
                        quad[ix][iy] = IHC;\r
                        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 == d.isx && quady == d.isy) {\r
+               if (quadx == state.isx && quady == state.isy) {\r
                        quad[kx[1]][ky[1]] = IHS;\r
                        kpower[1] = 1175.0 + 400.0*Rand() + 125.0*skill;\r
                        iscate = 1;\r
@@ -618,7 +618,7 @@ void newqad(int shutup) {
        if (nplan) {\r
                // If quadrant needs a planet, put it in\r
                for (i=1; i <= inplan; i++)\r
-                       if (d.plnets[i].x == quadx && d.plnets[i].y == quady) break;\r
+                       if (state.plnets[i].x == quadx && state.plnets[i].y == quady) break;\r
                if (i <= inplan) {\r
                        iplnet = i;\r
                        dropin(IHP, &plnetx, &plnety);\r
diff --git a/sst.c b/sst.c
index e4fe2afe0fcf55a0eab1f3f5d3a4001e47c6bd79..55066eb7fdeaa9b487647493486b2c434834a739 100644 (file)
--- a/sst.c
+++ b/sst.c
@@ -323,7 +323,7 @@ static void makemoves(void) {
                                events();\r
                                if (alldone) break;             // Events did us in\r
                        }\r
-                       if (d.galaxy[quadx][quady] == 1000) { // Galaxy went Nova!\r
+                       if (state.galaxy[quadx][quady] == 1000) { // Galaxy went Nova!\r
                                atover(0);\r
                                continue;\r
                        }\r
@@ -331,7 +331,7 @@ static void makemoves(void) {
                        if (hitme && justin==0) {\r
                                attack(2);\r
                                if (alldone) break;\r
-                               if (d.galaxy[quadx][quady] == 1000) {   // went NOVA! \r
+                               if (state.galaxy[quadx][quady] == 1000) {       // went NOVA! \r
                                        atover(0);\r
                                        hitme = TRUE;\r
                                        continue;\r
@@ -657,7 +657,7 @@ void debugme(void) {
                        key = scan();\r
                        if (key == IHALPHA &&  isit("y")) {\r
                                damage[i] = 10.0;\r
-                               if (i == DRADIO) stdamtim = d.date;\r
+                               if (i == DRADIO) stdamtim = state.date;\r
                        }\r
                }\r
        }\r
@@ -676,12 +676,12 @@ void debugme(void) {
                                case FSCMOVE: proutn("SC Move         "); break;\r
                                case FSCDBAS: proutn("SC Base Destroy "); break;\r
                        }\r
-                       cramf(future[i]-d.date, 8, 2);\r
+                       cramf(future[i]-state.date, 8, 2);\r
                        chew();\r
                        proutn("  ?");\r
                        key = scan();\r
                        if (key == IHREAL) {\r
-                               future[i] = d.date + aaitem;\r
+                               future[i] = state.date + aaitem;\r
                        }\r
                }\r
                chew();\r
diff --git a/sst.h b/sst.h
index b34312068646182ccd7a1eb77a100f3715adfa14..78b8ca46d3b6b371fd83bf96a234e3240323b2c3 100644 (file)
--- a/sst.h
+++ b/sst.h
@@ -47,7 +47,7 @@ EXTERN struct foo {
        double date,            // stardate\r
                remres,                 // remaining resources\r
            remtime;            // remaining time\r
-} d, snapsht;                  // Data that is snapshot\r
+} state, snapsht;                      // Data that is snapshot\r
 \r
 EXTERN char\r
                quad[11][11];   // contents of our quadrant\r
@@ -145,95 +145,95 @@ EXTERN struct foo2 {
        probey,\r
        probeinx,\r
        probeiny;\r
-} game;\r
+} frozen;\r
 \r
-#define inkling game.inkling           // Initial number of klingons\r
-#define inbase game.inbase                     // Initial number of bases\r
-#define incom game.incom                       // Initian number of commanders\r
-#define instar game.instar                     // Initial stars\r
-#define intorps game.intorps           // Initial/Max torpedoes\r
-#define condit game.condit                     // Condition (red, yellow, green docked)\r
-#define torps game.torps                       // number of torpedoes\r
-#define ship game.ship                         // Ship type -- 'E' is Enterprise\r
-#define quadx game.quadx                       // where we are\r
-#define quady game.quady                       //\r
-#define sectx game.sectx                       // where we are\r
-#define secty game.secty                       //\r
-#define length game.length                     // length of game\r
-#define skill game.skill                       // skill level\r
-#define basex game.basex                       // position of base in current quad\r
-#define basey game.basey                       //\r
-#define klhere game.klhere                     // klingons here\r
-#define comhere game.comhere           // commanders here\r
-#define casual game.casual                     // causalties\r
-#define nhelp game.nhelp                       // calls for help\r
-#define nkinks game.nkinks                     //\r
-#define ididit game.ididit                     // Action taken -- allows enemy to attack\r
-#define gamewon game.gamewon           // Finished!\r
-#define alive game.alive                       // We are alive (not killed)\r
-#define justin game.justin                     // just entered quadrant\r
-#define alldone game.alldone           // game is now finished\r
-#define shldchg game.shldchg           // shield is changing (affects efficiency)\r
-#define thingx game.thingx                     // location of strange object in galaxy\r
-#define thingy game.thingy                     //\r
-#define plnetx game.plnetx                     // location of planet in quadrant\r
-#define plnety game.plnety                     //\r
-#define inorbit game.inorbit           // orbiting\r
-#define landed game.landed                     // party on planet (1), on ship (-1)\r
-#define iplnet game.iplnet                     // planet # in quadrant\r
-#define imine game.imine                       // mining\r
-#define inplan game.inplan                     // initial planets\r
-#define nenhere game.nenhere           // Number of enemies in quadrant\r
-#define ishere game.ishere                     // Super-commander in quandrant\r
-#define neutz game.neutz                       // Romulan Neutral Zone\r
-#define irhere game.irhere                     // Romulans in quadrant\r
-#define icraft game.icraft                     // Kirk in Galileo\r
-#define ientesc game.ientesc           // Attempted escape from supercommander\r
-#define iscraft game.iscraft           // =1 if craft on ship, -1 if removed from game\r
-#define isatb game.isatb                       // =1 if SuperCommander is attacking base\r
-#define iscate game.iscate                     // Super Commander is here\r
+#define inkling frozen.inkling         // Initial number of klingons\r
+#define inbase frozen.inbase                   // Initial number of bases\r
+#define incom frozen.incom                     // Initian number of commanders\r
+#define instar frozen.instar                   // Initial stars\r
+#define intorps frozen.intorps         // Initial/Max torpedoes\r
+#define condit frozen.condit                   // Condition (red, yellow, green docked)\r
+#define torps frozen.torps                     // number of torpedoes\r
+#define ship frozen.ship                               // Ship type -- 'E' is Enterprise\r
+#define quadx frozen.quadx                     // where we are\r
+#define quady frozen.quady                     //\r
+#define sectx frozen.sectx                     // where we are\r
+#define secty frozen.secty                     //\r
+#define length frozen.length                   // length of game\r
+#define skill frozen.skill                     // skill level\r
+#define basex frozen.basex                     // position of base in current quad\r
+#define basey frozen.basey                     //\r
+#define klhere frozen.klhere                   // klingons here\r
+#define comhere frozen.comhere         // commanders here\r
+#define casual frozen.casual                   // causalties\r
+#define nhelp frozen.nhelp                     // calls for help\r
+#define nkinks frozen.nkinks                   //\r
+#define ididit frozen.ididit                   // Action taken -- allows enemy to attack\r
+#define gamewon frozen.gamewon         // Finished!\r
+#define alive frozen.alive                     // We are alive (not killed)\r
+#define justin frozen.justin                   // just entered quadrant\r
+#define alldone frozen.alldone         // game is now finished\r
+#define shldchg frozen.shldchg         // shield is changing (affects efficiency)\r
+#define thingx frozen.thingx                   // location of strange object in galaxy\r
+#define thingy frozen.thingy                   //\r
+#define plnetx frozen.plnetx                   // location of planet in quadrant\r
+#define plnety frozen.plnety                   //\r
+#define inorbit frozen.inorbit         // orbiting\r
+#define landed frozen.landed                   // party on planet (1), on ship (-1)\r
+#define iplnet frozen.iplnet                   // planet # in quadrant\r
+#define imine frozen.imine                     // mining\r
+#define inplan frozen.inplan                   // initial planets\r
+#define nenhere frozen.nenhere         // Number of enemies in quadrant\r
+#define ishere frozen.ishere                   // Super-commander in quandrant\r
+#define neutz frozen.neutz                     // Romulan Neutral Zone\r
+#define irhere frozen.irhere                   // Romulans in quadrant\r
+#define icraft frozen.icraft                   // Kirk in Galileo\r
+#define ientesc frozen.ientesc         // Attempted escape from supercommander\r
+#define iscraft frozen.iscraft         // =1 if craft on ship, -1 if removed from game\r
+#define isatb frozen.isatb                     // =1 if SuperCommander is attacking base\r
+#define iscate frozen.iscate                   // Super Commander is here\r
 #ifdef DEBUG\r
-#define idebug game.idebug                     // Debug mode\r
+#define idebug frozen.idebug                   // Debug mode\r
 #endif\r
-#define iattak game.iattak                     // attack recursion elimination (was cracks[4])\r
-#define icrystl game.icrystl           // dilithium crystals aboard\r
-#define tourn game.tourn                       // Tournament number\r
-#define thawed game.thawed                     // Thawed game\r
-#define batx game.batx                         // Base coordinates being attacked\r
-#define baty game.baty                         //\r
-#define ithere game.ithere                     // Tholean is here \r
-#define ithx game.ithx                         // coordinates of tholean\r
-#define ithy game.ithy\r
-#define iseenit game.iseenit           // Seen base attack report\r
-#define inresor game.inresor           // initial resources\r
-#define intime game.intime                     // initial time\r
-#define inenrg game.inenrg                     // Initial/Max Energy\r
-#define inshld game.inshld                     // Initial/Max Shield\r
-#define inlsr game.inlsr                       // initial life support resources\r
-#define indate game.indate                     // Initial date\r
-#define energy game.energy                     // Energy level\r
-#define shield game.shield                     // Shield level\r
-#define shldup game.shldup                     // Shields are up\r
-#define warpfac game.warpfac           // Warp speed\r
-#define wfacsq game.wfacsq                     // squared warp factor\r
-#define lsupres game.lsupres           // life support reserves\r
-#define dist game.dist                         // movement distance\r
-#define direc game.direc                       // movement direction\r
-#define Time game.Time                         // time taken by current operation\r
-#define docfac game.docfac                     // repair factor when docking (constant?)\r
-#define resting game.resting           // rest time\r
-#define damfac game.damfac                     // damage factor\r
-#define stdamtim game.stdamtim         // time that star chart was damaged\r
-#define cryprob game.cryprob           // probability that crystal will work\r
-#define probex game.probex                     // location of probe\r
-#define probey game.probey\r
-#define probecx game.probecx           // current probe quadrant\r
-#define probecy game.probecy   \r
-#define probeinx game.probeinx         // Probe x,y increment\r
-#define probeiny game.probeiny         \r
-#define proben game.proben                     // number of moves for probe\r
-#define isarmed game.isarmed           // Probe is armed\r
-#define nprobes game.nprobes           // number of probes available\r
+#define iattak frozen.iattak                   // attack recursion elimination (was cracks[4])\r
+#define icrystl frozen.icrystl         // dilithium crystals aboard\r
+#define tourn frozen.tourn                     // Tournament number\r
+#define thawed frozen.thawed                   // Thawed game\r
+#define batx frozen.batx                               // Base coordinates being attacked\r
+#define baty frozen.baty                               //\r
+#define ithere frozen.ithere                   // Tholean is here \r
+#define ithx frozen.ithx                               // coordinates of tholean\r
+#define ithy frozen.ithy\r
+#define iseenit frozen.iseenit         // Seen base attack report\r
+#define inresor frozen.inresor         // initial resources\r
+#define intime frozen.intime                   // initial time\r
+#define inenrg frozen.inenrg                   // Initial/Max Energy\r
+#define inshld frozen.inshld                   // Initial/Max Shield\r
+#define inlsr frozen.inlsr                     // initial life support resources\r
+#define indate frozen.indate                   // Initial date\r
+#define energy frozen.energy                   // Energy level\r
+#define shield frozen.shield                   // Shield level\r
+#define shldup frozen.shldup                   // Shields are up\r
+#define warpfac frozen.warpfac         // Warp speed\r
+#define wfacsq frozen.wfacsq                   // squared warp factor\r
+#define lsupres frozen.lsupres         // life support reserves\r
+#define dist frozen.dist                               // movement distance\r
+#define direc frozen.direc                     // movement direction\r
+#define Time frozen.Time                               // time taken by current operation\r
+#define docfac frozen.docfac                   // repair factor when docking (constant?)\r
+#define resting frozen.resting         // rest time\r
+#define damfac frozen.damfac                   // damage factor\r
+#define stdamtim frozen.stdamtim               // time that star chart was damaged\r
+#define cryprob frozen.cryprob         // probability that crystal will work\r
+#define probex frozen.probex                   // location of probe\r
+#define probey frozen.probey\r
+#define probecx frozen.probecx         // current probe quadrant\r
+#define probecy frozen.probecy \r
+#define probeinx frozen.probeinx               // Probe x,y increment\r
+#define probeiny frozen.probeiny               \r
+#define proben frozen.proben                   // number of moves for probe\r
+#define isarmed frozen.isarmed         // Probe is armed\r
+#define nprobes frozen.nprobes         // number of probes available\r
 \r
 EXTERN int\r
                kx[21],                 // enemy sector locations\r