Better project documentation.
[super-star-trek.git] / events.c
index 99591deca7b930793c69d4e7ff8a1a04616e205f..c3f22f5d0996b7d0b1d43384c4471e6fba3dbb6e 100644 (file)
--- a/events.c
+++ b/events.c
@@ -4,19 +4,19 @@
 void events(void) {\r
 \r
        int ictbeam=0, ipage=0, istract=0, line, i, j, k, l, ixhold, iyhold;\r
-       double fintim = state.date + Time, datemin, xtime, repair, yank;\r
+       double fintim = game.state.date + Time, datemin, xtime, repair, yank;\r
        \r
 \r
 #ifdef DEBUG\r
        if (idebug) prout("EVENTS");\r
 #endif\r
 \r
-       if (stdamtim == 1e30 && frozen.damage[DRADIO] != 0.0) {\r
+       if (stdamtim == 1e30 && game.damage[DRADIO] != 0.0) {\r
                /* chart will no longer be updated because radio is dead */\r
-               stdamtim = state.date;\r
+               stdamtim = game.state.date;\r
                for (i=1; i <= 8 ; i++)\r
                        for (j=1; j <= 8; j++)\r
-                               if (frozen.starch[i][j] == 1) frozen.starch[i][j] = state.galaxy[i][j]+1000;\r
+                               if (game.starch[i][j] == 1) game.starch[i][j] = game.state.galaxy[i][j]+1000;\r
        }\r
 \r
        for (;;) {\r
@@ -25,44 +25,44 @@ void events(void) {
                if (alldone) return;\r
                datemin = fintim;\r
                for (l=1; l<=NEVENTS; l++)\r
-                       if (frozen.future[l] <= datemin) {\r
+                       if (game.future[l] <= datemin) {\r
                                line = l;\r
-                               datemin = frozen.future[l];\r
+                               datemin = game.future[l];\r
                        }\r
-               xtime = datemin-state.date;\r
-               state.date = datemin;\r
+               xtime = datemin-game.state.date;\r
+               game.state.date = datemin;\r
                /* Decrement Federation resources and recompute remaining time */\r
-               state.remres -= (state.remkl+4*state.remcom)*xtime;\r
-               state.remtime = state.remres/(state.remkl+4*state.remcom);\r
-               if (state.remtime <=0) {\r
+               game.state.remres -= (game.state.remkl+4*game.state.remcom)*xtime;\r
+               game.state.remtime = game.state.remres/(game.state.remkl+4*game.state.remcom);\r
+               if (game.state.remtime <=0) {\r
                        finish(FDEPLETE);\r
                        return;\r
                }\r
                /* Is life support adequate? */\r
-               if (frozen.damage[DLIFSUP] && condit != IHDOCKED) {\r
-                       if (lsupres < xtime && frozen.damage[DLIFSUP] > lsupres) {\r
+               if (game.damage[DLIFSUP] && condit != IHDOCKED) {\r
+                       if (lsupres < xtime && game.damage[DLIFSUP] > lsupres) {\r
                                finish(FLIFESUP);\r
                                return;\r
                        }\r
                        lsupres -= xtime;\r
-                       if (frozen.damage[DLIFSUP] <= xtime) lsupres = inlsr;\r
+                       if (game.damage[DLIFSUP] <= xtime) lsupres = inlsr;\r
                }\r
                /* Fix devices */\r
                repair = xtime;\r
                if (condit == IHDOCKED) repair /= docfac;\r
                /* Don't fix Deathray here */\r
-               for (l=1; l<=ndevice; l++)\r
-                       if (frozen.damage[l] > 0.0 && l != DDRAY)\r
-                               frozen.damage[l] -= (frozen.damage[l]-repair > 0.0 ? repair : frozen.damage[l]);\r
+               for (l=1; l<=NDEVICES; l++)\r
+                       if (game.damage[l] > 0.0 && l != DDRAY)\r
+                               game.damage[l] -= (game.damage[l]-repair > 0.0 ? repair : game.damage[l]);\r
                /* If radio repaired, update star chart and attack reports */\r
-               if (stdamtim != 1e30 && frozen.damage[DRADIO] == 0.0) {\r
+               if (stdamtim != 1e30 && game.damage[DRADIO] == 0.0) {\r
                        stdamtim = 1e30;\r
                        prout("Lt. Uhura- \"Captain, the sub-space radio is working and");\r
                        prout("   surveillance reports are coming in.");\r
                        skip(1);\r
                        for (i=1; i <= 8 ; i++)\r
                                for (j=1; j <= 8; j++)\r
-                                       if (frozen.starch[i][j] > 999) frozen.starch[i][j] = 1;\r
+                                       if (game.starch[i][j] > 999) game.starch[i][j] = 1;\r
                        if (iseenit==0) {\r
                                attakreport();\r
                                iseenit = 1;\r
@@ -78,37 +78,37 @@ void events(void) {
                                if (ipage==0) pause(1);\r
                                ipage=1;\r
                                snova(0,0);\r
-                               frozen.future[FSNOVA] = state.date + expran(0.5*intime);\r
-                               if (state.galaxy[quadx][quady] == 1000) return;\r
+                               game.future[FSNOVA] = game.state.date + expran(0.5*intime);\r
+                               if (game.state.galaxy[quadx][quady] == 1000) return;\r
                                break;\r
                        case FSPY: /* Check with spy to see if S.C. should tractor beam */\r
-                               if (state.nscrem == 0 ||\r
+                               if (game.state.nscrem == 0 ||\r
                                        ictbeam+istract > 0 ||\r
                                        condit==IHDOCKED || isatb==1 || iscate==1) return;\r
                                if (ientesc ||\r
                                        (energy < 2000 && torps < 4 && shield < 1250) ||\r
-                                       (frozen.damage[DPHASER]>0 && (frozen.damage[DPHOTON]>0 || torps < 4)) ||\r
-                                       (frozen.damage[DSHIELD] > 0 &&\r
-                                        (energy < 2500 || frozen.damage[DPHASER] > 0) &&\r
-                                        (torps < 5 || frozen.damage[DPHOTON] > 0))) {\r
+                                       (game.damage[DPHASER]>0 && (game.damage[DPHOTON]>0 || torps < 4)) ||\r
+                                       (game.damage[DSHIELD] > 0 &&\r
+                                        (energy < 2500 || game.damage[DPHASER] > 0) &&\r
+                                        (torps < 5 || game.damage[DPHOTON] > 0))) {\r
                                        /* Tractor-beam her! */\r
                                        istract=1;\r
-                                       yank = square(state.isx-quadx) + square(state.isy-quady);\r
+                                       yank = square(game.state.isx-quadx) + square(game.state.isy-quady);\r
                                        /*********TBEAM CODE***********/\r
                                }\r
                                else return;\r
                        case FTBEAM: /* Tractor beam */\r
                                if (line==FTBEAM) {\r
-                                       if (state.remcom == 0) {\r
-                                               frozen.future[FTBEAM] = 1e30;\r
+                                       if (game.state.remcom == 0) {\r
+                                               game.future[FTBEAM] = 1e30;\r
                                                break;\r
                                        }\r
-                                       i = Rand()*state.remcom+1.0;\r
-                                       yank = square(state.cx[i]-quadx) + square(state.cy[i]-quady);\r
+                                       i = Rand()*game.state.remcom+1.0;\r
+                                       yank = square(game.state.cx[i]-quadx) + square(game.state.cy[i]-quady);\r
                                        if (istract || condit == IHDOCKED || yank == 0) {\r
                                                /* Drats! Have to reschedule */\r
-                                               frozen.future[FTBEAM] = state.date + Time +\r
-                                                                                expran(1.5*intime/state.remcom);\r
+                                               game.future[FTBEAM] = game.state.date + Time +\r
+                                                                                expran(1.5*intime/game.state.remcom);\r
                                                break;\r
                                        }\r
                                }\r
@@ -135,7 +135,7 @@ void events(void) {
                                        if (Rand() >0.5) {\r
                                                prout("Galileo, left on the planet surface, is captured");\r
                                                prout("by aliens and made into a flying McDonald's.");\r
-                                               frozen.damage[DSHUTTL] = -10;\r
+                                               game.damage[DSHUTTL] = -10;\r
                                                iscraft = -1;\r
                                        }\r
                                        else {\r
@@ -143,26 +143,25 @@ void events(void) {
                                        }\r
                                }\r
                                if (line==0) {\r
-                                       quadx = state.isx;\r
-                                       quady = state.isy;\r
+                                       quadx = game.state.isx;\r
+                                       quady = game.state.isy;\r
                                }\r
                                else {\r
-                                       quadx = state.cx[i];\r
-                                       quady = state.cy[i];\r
+                                       quadx = game.state.cx[i];\r
+                                       quady = game.state.cy[i];\r
                                }\r
                                iran10(&sectx, &secty);\r
                                crmshp();\r
-                               proutn(" is pulled to");\r
-                               cramlc(1, quadx, quady);\r
+                               proutn(" is pulled to ");\r
+                               proutn(cramlc(quadrant, quadx, quady));\r
                                proutn(", ");\r
-                               cramlc(2, sectx, secty);\r
-                               skip(1);\r
+                               prout(cramlc(sector, sectx, secty));\r
                                if (resting) {\r
-                                       prout("(Remainder of rest/repair period cancellestate.)");\r
+                                       prout("(Remainder of rest/repair period cancellegame.state.)");\r
                                        resting = 0;\r
                                }\r
                                if (shldup==0) {\r
-                                       if (frozen.damage[DSHIELD]==0 && shield > 0) {\r
+                                       if (game.damage[DSHIELD]==0 && shield > 0) {\r
                                                doshield(2); /* Shldsup */\r
                                                shldchg=0;\r
                                        }\r
@@ -170,58 +169,57 @@ void events(void) {
                                }\r
                                newqad(0);\r
                                /* Adjust finish time to time of tractor beaming */\r
-                               fintim = state.date+Time;\r
-                               if (state.remcom <= 0) frozen.future[FTBEAM] = 1e30;\r
-                               else frozen.future[FTBEAM] = state.date+Time+expran(1.5*intime/state.remcom);\r
+                               fintim = game.state.date+Time;\r
+                               if (game.state.remcom <= 0) game.future[FTBEAM] = 1e30;\r
+                               else game.future[FTBEAM] = game.state.date+Time+expran(1.5*intime/game.state.remcom);\r
                                break;\r
                        case FSNAP: /* Snapshot of the universe (for time warp) */\r
-                               snapsht = state;\r
-                               state.snap = 1;\r
-                               frozen.future[FSNAP] = state.date + expran(0.5 * intime);\r
+                               game.snapsht = game.state;\r
+                               game.state.snap = 1;\r
+                               game.future[FSNAP] = game.state.date + expran(0.5 * intime);\r
                                break;\r
                        case FBATTAK: /* Commander attacks starbase */\r
-                               if (state.remcom==0 || state.rembase==0) {\r
+                               if (game.state.remcom==0 || game.state.rembase==0) {\r
                                        /* no can do */\r
-                                       frozen.future[FBATTAK] = frozen.future[FCDBAS] = 1e30;\r
+                                       game.future[FBATTAK] = game.future[FCDBAS] = 1e30;\r
                                        break;\r
                                }\r
                                i = 0;\r
-                               for (j=1; j<=state.rembase; j++) {\r
-                                       for (k=1; k<=state.remcom; k++)\r
-                                               if (state.baseqx[j]==state.cx[k] && state.baseqy[j]==state.cy[k] &&\r
-                                                       (state.baseqx[j]!=quadx || state.baseqy[j]!=quady) &&\r
-                                                       (state.baseqx[j]!=state.isx || state.baseqy[j]!=state.isy)) {\r
+                               for (j=1; j<=game.state.rembase; j++) {\r
+                                       for (k=1; k<=game.state.remcom; k++)\r
+                                               if (game.state.baseqx[j]==game.state.cx[k] && game.state.baseqy[j]==game.state.cy[k] &&\r
+                                                       (game.state.baseqx[j]!=quadx || game.state.baseqy[j]!=quady) &&\r
+                                                       (game.state.baseqx[j]!=game.state.isx || game.state.baseqy[j]!=game.state.isy)) {\r
                                                        i = 1;\r
                                                        break;\r
                                                }\r
                                        if (i == 1) break;\r
                                }\r
-                               if (j>state.rembase) {\r
+                               if (j>game.state.rembase) {\r
                                        /* no match found -- try later */\r
-                                       frozen.future[FBATTAK] = state.date + expran(0.3*intime);\r
-                                       frozen.future[FCDBAS] = 1e30;\r
+                                       game.future[FBATTAK] = game.state.date + expran(0.3*intime);\r
+                                       game.future[FCDBAS] = 1e30;\r
                                        break;\r
                                }\r
                                /* commander + starbase combination found -- launch attack */\r
-                               batx = state.baseqx[j];\r
-                               baty = state.baseqy[j];\r
-                               frozen.future[FCDBAS] = state.date+1.0+3.0*Rand();\r
+                               batx = game.state.baseqx[j];\r
+                               baty = game.state.baseqy[j];\r
+                               game.future[FCDBAS] = game.state.date+1.0+3.0*Rand();\r
                                if (isatb) /* extra time if SC already attacking */\r
-                                       frozen.future[FCDBAS] += frozen.future[FSCDBAS]-state.date;\r
-                               frozen.future[FBATTAK] = frozen.future[FCDBAS] +expran(0.3*intime);\r
+                                       game.future[FCDBAS] += game.future[FSCDBAS]-game.state.date;\r
+                               game.future[FBATTAK] = game.future[FCDBAS] +expran(0.3*intime);\r
                                iseenit = 0;\r
-                               if (frozen.damage[DRADIO] != 0.0 &&\r
+                               if (game.damage[DRADIO] != 0.0 &&\r
                                        condit != IHDOCKED) break; /* No warning :-( */\r
                                iseenit = 1;\r
                                if (ipage==0) pause(1);\r
                                ipage = 1;\r
                                skip(1);\r
-                               proutn("Lt. Uhura-  \"Captain, the starbase in");\r
-                               cramlc(1, batx, baty);\r
-                               skip(1);\r
+                               proutn("Lt. Uhura-  \"Captain, the starbase in ");\r
+                               prout(cramlc(quadrant, batx, baty));\r
                                prout("   reports that it is under atttack and that it can");\r
-                               proutn("   hold out only until stardate ");\r
-                               cramf(frozen.future[FCDBAS],1,1);\r
+                               proutn("   hold out only until stardate %d",\r
+                                       (int)game.future[FCDBAS]);\r
                                prout(".\"");\r
                                if (resting) {\r
                                        skip(1);\r
@@ -234,21 +232,21 @@ void events(void) {
                                }\r
                                break;\r
                        case FSCDBAS: /* Supercommander destroys base */\r
-                               frozen.future[FSCDBAS] = 1e30;\r
+                               game.future[FSCDBAS] = 1e30;\r
                                isatb = 2;\r
-                               if (state.galaxy[state.isx][state.isy]%100 < 10) break; /* WAS RETURN! */\r
+                               if (game.state.galaxy[game.state.isx][game.state.isy]%100 < 10) break; /* WAS RETURN! */\r
                                ixhold = batx;\r
                                iyhold = baty;\r
-                               batx = state.isx;\r
-                               baty = state.isy;\r
+                               batx = game.state.isx;\r
+                               baty = game.state.isy;\r
                        case FCDBAS: /* Commander succeeds in destroying base */\r
                                if (line==FCDBAS) {\r
-                                       frozen.future[FCDBAS] = 1e30;\r
+                                       game.future[FCDBAS] = 1e30;\r
                                        /* find the lucky pair */\r
-                                       for (i = 1; i <= state.remcom; i++)\r
-                                               if (state.cx[i]==batx && state.cy[i]==baty) break;\r
-                                       if (i > state.remcom || state.rembase == 0 ||\r
-                                               state.galaxy[batx][baty] % 100 < 10) {\r
+                                       for (i = 1; i <= game.state.remcom; i++)\r
+                                               if (game.state.cx[i]==batx && game.state.cy[i]==baty) break;\r
+                                       if (i > game.state.remcom || game.state.rembase == 0 ||\r
+                                               game.state.galaxy[batx][baty] % 100 < 10) {\r
                                                /* No action to take after all */\r
                                                batx = baty = 0;\r
                                                break;\r
@@ -256,37 +254,37 @@ void events(void) {
                                }\r
                                /* Code merges here for any commander destroying base */\r
                                /* Not perfect, but will have to do */\r
-                               if (frozen.starch[batx][baty] == -1) frozen.starch[batx][baty] = 0;\r
+                               if (game.starch[batx][baty] == -1) game.starch[batx][baty] = 0;\r
                                /* Handle case where base is in same quadrant as starship */\r
                                if (batx==quadx && baty==quady) {\r
-                                       if (frozen.starch[batx][baty] > 999) frozen.starch[batx][baty] -= 10;\r
-                                       frozen.quad[basex][basey]= IHDOT;\r
+                                       if (game.starch[batx][baty] > 999) game.starch[batx][baty] -= 10;\r
+                                       game.quad[basex][basey]= IHDOT;\r
                                        basex=basey=0;\r
                                        newcnd();\r
                                        skip(1);\r
-                                       prout("Spock-  \"Captain, I believe the starbase has been destroyestate.\"");\r
+                                       prout("Spock-  \"Captain, I believe the starbase has been destroyegame.state.\"");\r
                                }\r
-                               else if (state.rembase != 1 &&\r
-                                                (frozen.damage[DRADIO] <= 0.0 || condit == IHDOCKED)) {\r
+                               else if (game.state.rembase != 1 &&\r
+                                                (game.damage[DRADIO] <= 0.0 || condit == IHDOCKED)) {\r
                                        /* Get word via subspace radio */\r
                                        if (ipage==0) pause(1);\r
                                        ipage = 1;\r
                                        skip(1);\r
                                        prout("Lt. Uhura-  \"Captain, Starfleet Command reports that");\r
-                                       proutn("   the starbase in");\r
-                                       cramlc(1, batx, baty);\r
+                                       proutn("   the starbase in ");\r
+                                       proutn(cramlc(quadrant, batx, baty));\r
                                        prout(" has been destroyed by");\r
                                        if (isatb==2) prout("the Klingon Super-Commander");\r
                                        else prout("a Klingon Commander");\r
                                }\r
                                /* Remove Starbase from galaxy */\r
-                               state.galaxy[batx][baty] -= 10;\r
-                               for (i=1; i <= state.rembase; i++)\r
-                                       if (state.baseqx[i]==batx && state.baseqy[i]==baty) {\r
-                                               state.baseqx[i]=state.baseqx[state.rembase];\r
-                                               state.baseqy[i]=state.baseqy[state.rembase];\r
+                               game.state.galaxy[batx][baty] -= 10;\r
+                               for (i=1; i <= game.state.rembase; i++)\r
+                                       if (game.state.baseqx[i]==batx && game.state.baseqy[i]==baty) {\r
+                                               game.state.baseqx[i]=game.state.baseqx[game.state.rembase];\r
+                                               game.state.baseqy[i]=game.state.baseqy[game.state.rembase];\r
                                        }\r
-                               state.rembase--;\r
+                               game.state.rembase--;\r
                                if (isatb == 2) {\r
                                        /* reinstate a commander's base attack */\r
                                        batx = ixhold;\r
@@ -298,13 +296,13 @@ void events(void) {
                                }\r
                                break;\r
                        case FSCMOVE: /* Supercommander moves */\r
-                               frozen.future[FSCMOVE] = state.date+0.2777;\r
+                               game.future[FSCMOVE] = game.state.date+0.2777;\r
                                if (ientesc+istract==0 &&\r
                                        isatb!=1 &&\r
                                        (iscate!=1 || justin==1)) scom(&ipage);\r
                                break;\r
                        case FDSPROB: /* Move deep space probe */\r
-                               frozen.future[FDSPROB] = state.date + 0.01;\r
+                               game.future[FDSPROB] = game.state.date + 0.01;\r
                                probex += probeinx;\r
                                probey += probeiny;\r
                                i = (int)(probex/10 +0.05);\r
@@ -313,9 +311,9 @@ void events(void) {
                                        probecx = i;\r
                                        probecy = j;\r
                                        if (i < 1 || i > 8 || j < 1 || j > 8 ||\r
-                                               state.galaxy[probecx][probecy] == 1000) {\r
+                                               game.state.galaxy[probecx][probecy] == 1000) {\r
                                                // Left galaxy or ran into supernova\r
-                                               if (frozen.damage[DRADIO]==0.0 || condit == IHDOCKED) {\r
+                                               if (game.damage[DRADIO]==0.0 || condit == IHDOCKED) {\r
                                                        if (ipage==0) pause(1);\r
                                                        ipage = 1;\r
                                                        skip(1);\r
@@ -326,30 +324,30 @@ void events(void) {
                                                                proutn("is no longer transmitting");\r
                                                        prout(".\"");\r
                                                }\r
-                                               frozen.future[FDSPROB] = 1e30;\r
+                                               game.future[FDSPROB] = 1e30;\r
                                                break;\r
                                        }\r
-                                       if (frozen.damage[DRADIO]==0.0   || condit == IHDOCKED) {\r
+                                       if (game.damage[DRADIO]==0.0   || condit == IHDOCKED) {\r
                                                if (ipage==0) pause(1);\r
                                                ipage = 1;\r
                                                skip(1);\r
                                                proutn("Lt. Uhura-  \"The deep space probe is now in ");\r
-                                               cramlc(1, probecx, probecy);\r
+                                               proutn(cramlc(quadrant, probecx, probecy));\r
                                                prout(".\"");\r
                                        }\r
                                }\r
                                /* Update star chart if Radio is working or have access to\r
                                   radio. */\r
-                               if (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED)\r
-                                       frozen.starch[probecx][probecy] = frozen.damage[DRADIO] > 0.0 ?\r
-                                                                                  state.galaxy[probecx][probecy]+1000 : 1;\r
+                               if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED)\r
+                                       game.starch[probecx][probecy] = game.damage[DRADIO] > 0.0 ?\r
+                                                                                  game.state.galaxy[probecx][probecy]+1000 : 1;\r
                                proben--; // One less to travel\r
                                if (proben == 0 && isarmed &&\r
-                                       state.galaxy[probecx][probecy] % 10 > 0) {\r
+                                       game.state.galaxy[probecx][probecy] % 10 > 0) {\r
                                        /* lets blow the sucker! */\r
                                        snova(1,0);\r
-                                       frozen.future[FDSPROB] = 1e30;\r
-                                       if (state.galaxy[quadx][quady] == 1000) return;\r
+                                       game.future[FDSPROB] = 1e30;\r
+                                       if (game.state.galaxy[quadx][quady] == 1000) return;\r
                                }\r
                                break;\r
                }\r
@@ -374,7 +372,7 @@ void wait(void) {
        }\r
        origTime = delay = aaitem;\r
        if (delay <= 0.0) return;\r
-       if (delay >= state.remtime || nenhere != 0) {\r
+       if (delay >= game.state.remtime || nenhere != 0) {\r
                prout("Are you sure? ");\r
                if (ja() == 0) return;\r
        }\r
@@ -385,8 +383,7 @@ void wait(void) {
        do {\r
                if (delay <= 0) resting = 0;\r
                if (resting == 0) {\r
-                       cramf(state.remtime, 0, 2);\r
-                       prout(" stardates left.");\r
+                       prout("%d stardates left.", (int)game.state.remtime);\r
                        return;\r
                }\r
                temp = Time = delay;\r
@@ -405,8 +402,8 @@ void wait(void) {
                delay -= temp;\r
                /* Repair Deathray if long rest at starbase */\r
                if (origTime-delay >= 9.99 && condit == IHDOCKED)\r
-                       frozen.damage[DDRAY] = 0.0;\r
-       } while (state.galaxy[quadx][quady] != 1000); // leave if quadrant supernovas\r
+                       game.damage[DDRAY] = 0.0;\r
+       } while (game.state.galaxy[quadx][quady] != 1000); // leave if quadrant supernovas\r
 \r
        resting = 0;\r
        Time = 0;\r
@@ -424,11 +421,11 @@ void nova(int ix, int iy) {
        }\r
 \r
        /* handle initial nova */\r
-       frozen.quad[ix][iy] = IHDOT;\r
+       game.quad[ix][iy] = IHDOT;\r
        crmena(1, IHSTAR, 2, ix, iy);\r
        prout(" novas.");\r
-       state.galaxy[quadx][quady] -= 1;\r
-       state.starkl++;\r
+       game.state.galaxy[quadx][quady] -= 1;\r
+       game.state.starkl++;\r
        \r
        /* Set up stack to recursively trigger adjacent stars */\r
        bot = top = top2 = 1;\r
@@ -444,7 +441,7 @@ void nova(int ix, int iy) {
                                ii = hits[mm][1]+nn-2;\r
                                jj = hits[mm][2]+j-2;\r
                                if (ii < 1 || ii > 10 || jj < 1 || jj > 10) continue;\r
-                               iquad = frozen.quad[ii][jj];\r
+                               iquad = game.quad[ii][jj];\r
                                switch (iquad) {\r
 //                                     case IHDOT:     /* Empty space ends reaction\r
 //                                     case IHQUEST:\r
@@ -462,38 +459,38 @@ void nova(int ix, int iy) {
                                                top2++;\r
                                                hits[top2][1]=ii;\r
                                                hits[top2][2]=jj;\r
-                                               state.galaxy[quadx][quady] -= 1;\r
-                                               state.starkl++;\r
+                                               game.state.galaxy[quadx][quady] -= 1;\r
+                                               game.state.starkl++;\r
                                                crmena(1, IHSTAR, 2, ii, jj);\r
                                                prout(" novas.");\r
-                                               frozen.quad[ii][jj] = IHDOT;\r
+                                               game.quad[ii][jj] = IHDOT;\r
                                                break;\r
                                        case IHP: /* Destroy planet */\r
-                                               state.newstuf[quadx][quady] -= 1;\r
-                                               state.nplankl++;\r
+                                               game.state.newstuf[quadx][quady] -= 1;\r
+                                               game.state.nplankl++;\r
                                                crmena(1, IHP, 2, ii, jj);\r
                                                prout(" destroyed.");\r
-                                               state.plnets[iplnet] = nulplanet;\r
+                                               DESTROY(&game.state.plnets[iplnet]);\r
                                                iplnet = plnetx = plnety = 0;\r
                                                if (landed == 1) {\r
                                                        finish(FPNOVA);\r
                                                        return;\r
                                                }\r
-                                               frozen.quad[ii][jj] = IHDOT;\r
+                                               game.quad[ii][jj] = IHDOT;\r
                                                break;\r
                                        case IHB: /* Destroy base */\r
-                                               state.galaxy[quadx][quady] -= 10;\r
-                                               for (i = 1; i <= state.rembase; i++)\r
-                                                       if (state.baseqx[i]==quadx && state.baseqy[i]==quady) break;\r
-                                               state.baseqx[i] = state.baseqx[state.rembase];\r
-                                               state.baseqy[i] = state.baseqy[state.rembase];\r
-                                               state.rembase--;\r
+                                               game.state.galaxy[quadx][quady] -= 10;\r
+                                               for (i = 1; i <= game.state.rembase; i++)\r
+                                                       if (game.state.baseqx[i]==quadx && game.state.baseqy[i]==quady) break;\r
+                                               game.state.baseqx[i] = game.state.baseqx[game.state.rembase];\r
+                                               game.state.baseqy[i] = game.state.baseqy[game.state.rembase];\r
+                                               game.state.rembase--;\r
                                                basex = basey = 0;\r
-                                               state.basekl++;\r
+                                               game.state.basekl++;\r
                                                newcnd();\r
                                                crmena(1, IHB, 2, ii, jj);\r
                                                prout(" destroyed.");\r
-                                               frozen.quad[ii][jj] = IHDOT;\r
+                                               game.quad[ii][jj] = IHDOT;\r
                                                break;\r
                                        case IHE: /* Buffet ship */\r
                                        case IHF:\r
@@ -506,7 +503,7 @@ void nova(int ix, int iy) {
                                                                shield = 0.0;\r
                                                                shldup = 0;\r
                                                                prout("***Shields knocked out.");\r
-                                                               frozen.damage[DSHIELD] += 0.005*damfac*Rand()*diff;\r
+                                                               game.damage[DSHIELD] += 0.005*damfac*Rand()*diff;\r
                                                        }\r
                                                }\r
                                                else energy -= 2000.0;\r
@@ -526,9 +523,9 @@ void nova(int ix, int iy) {
                                        case IHS:\r
                                        case IHR:\r
                                                for (ll = 1; ll <= nenhere; ll++)\r
-                                                       if (frozen.kx[ll]==ii && frozen.ky[ll]==jj) break;\r
-                                               frozen.kpower[ll] -= 800.0; /* If firepower is lost, die */\r
-                                               if (frozen.kpower[ll] <= 0.0) {\r
+                                                       if (game.kx[ll]==ii && game.ky[ll]==jj) break;\r
+                                               game.kpower[ll] -= 800.0; /* If firepower is lost, die */\r
+                                               if (game.kpower[ll] <= 0.0) {\r
                                                        deadkl(ii, jj, iquad, ii, jj);\r
                                                        break;\r
                                                }\r
@@ -541,7 +538,7 @@ void nova(int ix, int iy) {
                                                        skip(1);\r
                                                        break;\r
                                                }\r
-                                               iquad1 = frozen.quad[newcx][newcy];\r
+                                               iquad1 = game.quad[newcx][newcy];\r
                                                if (iquad1 == IHBLANK) {\r
                                                        proutn(", blasted into ");\r
                                                        crmena(0, IHBLANK, 2, newcx, newcy);\r
@@ -554,14 +551,14 @@ void nova(int ix, int iy) {
                                                        skip(1);\r
                                                        break;\r
                                                }\r
-                                               proutn(", buffeted to");\r
-                                               cramlc(2, newcx, newcy);\r
-                                               frozen.quad[ii][jj] = IHDOT;\r
-                                               frozen.quad[newcx][newcy] = iquad;\r
-                                               frozen.kx[ll] = newcx;\r
-                                               frozen.ky[ll] = newcy;\r
-                                               frozen.kavgd[ll] = sqrt(square(sectx-newcx)+square(secty-newcy));\r
-                                               frozen.kdist[ll] = frozen.kavgd[ll];\r
+                                               proutn(", buffeted to ");\r
+                                               proutn(cramlc(sector, newcx, newcy));\r
+                                               game.quad[ii][jj] = IHDOT;\r
+                                               game.quad[newcx][newcy] = iquad;\r
+                                               game.kx[ll] = newcx;\r
+                                               game.ky[ll] = newcy;\r
+                                               game.kavgd[ll] = sqrt(square(sectx-newcx)+square(secty-newcy));\r
+                                               game.kdist[ll] = game.kavgd[ll];\r
                                                skip(1);\r
                                                break;\r
                                }\r
@@ -610,14 +607,14 @@ void snova(int insx, int insy) {
                        left of universe */\r
                        for (nqx = 1; nqx<=8; nqx++) {\r
                                for (nqy = 1; nqy<=8; nqy++) {\r
-                                       stars += state.galaxy[nqx][nqy] % 10;\r
+                                       stars += game.state.galaxy[nqx][nqy] % 10;\r
                                }\r
                        }\r
                        if (stars == 0) return; /* nothing to supernova exists */\r
                        num = Rand()*stars + 1;\r
                        for (nqx = 1; nqx<=8; nqx++) {\r
                                for (nqy = 1; nqy<=8; nqy++) {\r
-                                       num -= state.galaxy[nqx][nqy] % 10;\r
+                                       num -= game.state.galaxy[nqx][nqy] % 10;\r
                                        if (num <= 0) break;\r
                                }\r
                                if (num <=0) break;\r
@@ -635,23 +632,20 @@ void snova(int insx, int insy) {
 \r
                if (nqx != quady || nqy != quady || justin != 0) {\r
                        /* it isn't here, or we just entered (treat as inroute) */\r
-                       if (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
+                       if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
                                skip(1);\r
-                               proutn("Message from Starfleet Command       Stardate ");\r
-                               cramf(state.date, 0, 1);\r
-                               skip(1);\r
-                               proutn("     Supernova in");\r
-                               cramlc(1, nqx, nqy);\r
-                               prout("; caution advised.");\r
+                               prout("Message from Starfleet Command       Stardate %.2f", game.state.date);\r
+                               proutn("     Supernova in %s; caution advised.",\r
+                                      cramlc(quadrant, nqx, nqy));\r
                        }\r
                }\r
                else {\r
                        /* we are in the quadrant! */\r
                        insipient = 1;\r
-                       num = Rand()* (state.galaxy[nqx][nqy]%10) + 1;\r
+                       num = Rand()* (game.state.galaxy[nqx][nqy]%10) + 1;\r
                        for (nsx=1; nsx < 10; nsx++) {\r
                                for (nsy=1; nsy < 10; nsy++) {\r
-                                       if (frozen.quad[nsx][nsy]==IHSTAR) {\r
+                                       if (game.quad[nsx][nsy]==IHSTAR) {\r
                                                num--;\r
                                                if (num==0) break;\r
                                        }\r
@@ -668,9 +662,7 @@ void snova(int insx, int insy) {
                skip(1);\r
                prouts("***RED ALERT!  RED ALERT!");\r
                skip(1);\r
-               proutn("***Incipient supernova detected at");\r
-               cramlc(2, nsx, nsy);\r
-               skip(1);\r
+               prout("***Incipient supernova detected at ", cramlc(sector, nsx, nsy));\r
                nqx = quadx;\r
                nqy = quady;\r
                if (square(nsx-sectx) + square(nsy-secty) <= 2.1) {\r
@@ -682,80 +674,79 @@ void snova(int insx, int insy) {
                }\r
        }\r
        /* destroy any Klingons in supernovaed quadrant */\r
-       num=state.galaxy[nqx][nqy];\r
+       num=game.state.galaxy[nqx][nqy];\r
        kldead = num/100;\r
        comdead = iscdead = 0;\r
-       if (nqx==state.isx && nqy == state.isy) {\r
+       if (nqx==game.state.isx && nqy == game.state.isy) {\r
                /* did in the Supercommander! */\r
-               state.nscrem = state.isx = state.isy = isatb = iscate = 0;\r
+               game.state.nscrem = game.state.isx = game.state.isy = isatb = iscate = 0;\r
                iscdead = 1;\r
-               frozen.future[FSCMOVE] = frozen.future[FSCDBAS] = 1e30;\r
+               game.future[FSCMOVE] = game.future[FSCDBAS] = 1e30;\r
        }\r
-       state.remkl -= kldead;\r
-       if (state.remcom) {\r
-               int maxloop = state.remcom, l;\r
+       game.state.remkl -= kldead;\r
+       if (game.state.remcom) {\r
+               int maxloop = game.state.remcom, l;\r
                for (l = 1; l <= maxloop; l++) {\r
-                       if (state.cx[l] == nqx && state.cy[l] == nqy) {\r
-                               state.cx[l] = state.cx[state.remcom];\r
-                               state.cy[l] = state.cy[state.remcom];\r
-                               state.cx[state.remcom] = state.cy[state.remcom] = 0;\r
-                               state.remcom--;\r
+                       if (game.state.cx[l] == nqx && game.state.cy[l] == nqy) {\r
+                               game.state.cx[l] = game.state.cx[game.state.remcom];\r
+                               game.state.cy[l] = game.state.cy[game.state.remcom];\r
+                               game.state.cx[game.state.remcom] = game.state.cy[game.state.remcom] = 0;\r
+                               game.state.remcom--;\r
                                kldead--;\r
                                comdead++;\r
-                               if (state.remcom==0) frozen.future[FTBEAM] = 1e30;\r
+                               if (game.state.remcom==0) game.future[FTBEAM] = 1e30;\r
                                break;\r
                        }\r
                }\r
        }\r
        /* destroy Romulans and planets in supernovaed quadrant */\r
-       num = state.newstuf[nqx][nqy];\r
-       state.newstuf[nqx][nqy] = 0;\r
+       num = game.state.newstuf[nqx][nqy];\r
+       game.state.newstuf[nqx][nqy] = 0;\r
        nrmdead = num/10;\r
-       state.nromrem -= nrmdead;\r
+       game.state.nromrem -= nrmdead;\r
        npdead = num - nrmdead*10;\r
        if (npdead) {\r
                int l;\r
-               for (l = 1; l <= inplan; l++)\r
-                       if (state.plnets[l].x == nqx && state.plnets[l].y == nqy) {\r
-                               state.plnets[l] = nulplanet;\r
+               for (l = 0; l < inplan; l++)\r
+                       if (game.state.plnets[l].x == nqx && game.state.plnets[l].y == nqy) {\r
+                           DESTROY(&game.state.plnets[l]);\r
                        }\r
        }\r
        /* Destroy any base in supernovaed quadrant */\r
-       if (state.rembase) {\r
-               int maxloop = state.rembase, l;\r
+       if (game.state.rembase) {\r
+               int maxloop = game.state.rembase, l;\r
                for (l = 1; l <= maxloop; l++)\r
-                       if (state.baseqx[l]==nqx && state.baseqy[l]==nqy) {\r
-                               state.baseqx[l] = state.baseqx[state.rembase];\r
-                               state.baseqy[l] = state.baseqy[state.rembase];\r
-                               state.baseqx[state.rembase] = state.baseqy[state.rembase] = 0;\r
-                               state.rembase--;\r
+                       if (game.state.baseqx[l]==nqx && game.state.baseqy[l]==nqy) {\r
+                               game.state.baseqx[l] = game.state.baseqx[game.state.rembase];\r
+                               game.state.baseqy[l] = game.state.baseqy[game.state.rembase];\r
+                               game.state.baseqx[game.state.rembase] = game.state.baseqy[game.state.rembase] = 0;\r
+                               game.state.rembase--;\r
                                break;\r
                        }\r
        }\r
        /* If starship caused supernova, tally up destruction */\r
        if (insx) {\r
-               num = state.galaxy[nqx][nqy] % 100;\r
-               state.starkl += num % 10;\r
-               state.basekl += num/10;\r
-               state.killk += kldead;\r
-               state.killc += comdead;\r
-               state.nromkl += nrmdead;\r
-               state.nplankl += npdead;\r
-               state.nsckill += iscdead;\r
+               num = game.state.galaxy[nqx][nqy] % 100;\r
+               game.state.starkl += num % 10;\r
+               game.state.basekl += num/10;\r
+               game.state.killk += kldead;\r
+               game.state.killc += comdead;\r
+               game.state.nromkl += nrmdead;\r
+               game.state.nplankl += npdead;\r
+               game.state.nsckill += iscdead;\r
        }\r
        /* mark supernova in galaxy and in star chart */\r
        if ((quadx == nqx && quady == nqy) ||\r
-               frozen.damage[DRADIO] == 0 ||\r
+               game.damage[DRADIO] == 0 ||\r
                condit == IHDOCKED)\r
-               frozen.starch[nqx][nqy] = 1;\r
-       state.galaxy[nqx][nqy] = 1000;\r
+               game.starch[nqx][nqy] = 1;\r
+       game.state.galaxy[nqx][nqy] = 1000;\r
        /* If supernova destroys last klingons give special message */\r
-       if (state.remkl==0 && (nqx != quadx || nqy != quady)) {\r
+       if (game.state.remkl==0 && (nqx != quadx || nqy != quady)) {\r
                skip(2);\r
                if (insx == 0) prout("Lucky you!");\r
-               proutn("A supernova in");\r
-               cramlc(1, nqx, nqy);\r
-               prout(" has just destroyed the last Klingons.");\r
+               proutn("A supernova in %s has just destroyed the last Klingons.",\r
+                      cramlc(quadrant, nqx, nqy));\r
                finish(FWON);\r
                return;\r
        }\r