Another step in consolidating the saved-state globals.
[super-star-trek.git] / planets.c
index ea9aa125337713ab40e03cb36417e11cf4caf987..b95761f0e48dfb3fdeec94efcd16e9476c741cbc 100644 (file)
--- a/planets.c
+++ b/planets.c
@@ -11,7 +11,7 @@ static int consumeTime(void) {
        ididit = 1;\r
 #if 0\r
        /* Don't wory about this */\r
-       if (future[FTBEAM] <= state.date+Time && state.remcom != 0 && condit != IHDOCKED) {\r
+       if (future[FTBEAM] <= game.state.date+Time && game.state.remcom != 0 && condit != IHDOCKED) {\r
                /* We are about to be tractor beamed -- operation fails */\r
                return 1;\r
        }\r
@@ -21,7 +21,7 @@ static int consumeTime(void) {
        events();       /* Used to avoid if future[FSCMOVE] within time */\r
 //     future[FSNOVA] = asave;\r
        /*fails if game over, quadrant super-novas or we've moved to new quadrant*/\r
-       if (alldone || state.galaxy[quadx][quady] == 1000 || justin != 0) return 1;\r
+       if (alldone || game.state.galaxy[quadx][quady] == 1000 || justin != 0) return 1;\r
        return 0;\r
 }\r
 \r
@@ -32,22 +32,22 @@ void preport(void) {
        prout("Spock-  \"Planet report follows, Captain.\"");\r
        skip(1);\r
        for (i = 1; i <= inplan; i++) {\r
-               if (state.plnets[i].known\r
+               if (game.state.plnets[i].known\r
 #ifdef DEBUG\r
-                       || ( idebug && state.plnets[i].x !=0)\r
+                       || ( idebug && game.state.plnets[i].x !=0)\r
 #endif\r
                        ) {\r
                        iknow = 1;\r
 #ifdef DEBUG\r
-                       if (idebug && state.plnets[i].known==0) proutn("(Unknown) ");\r
+                       if (idebug && game.state.plnets[i].known==0) proutn("(Unknown) ");\r
 #endif\r
-                       cramlc(1, state.plnets[i].x, state.plnets[i].y);\r
+                       cramlc(1, game.state.plnets[i].x, game.state.plnets[i].y);\r
                        proutn("   class ");\r
-                       proutn(classes[state.plnets[i].pclass]);\r
+                       proutn(classes[game.state.plnets[i].pclass]);\r
                        proutn("   ");\r
-                       if (state.plnets[i].crystals == 0) proutn("no ");\r
+                       if (game.state.plnets[i].crystals == 0) proutn("no ");\r
                        prout("dilithium crystals present.");\r
-                       if (state.plnets[i].known==2) \r
+                       if (game.state.plnets[i].known==2) \r
                                prout("    Shuttle Craft Galileo on surface.");\r
                }\r
        }\r
@@ -64,7 +64,7 @@ void orbit(void) {
                prout("Already in standard orbit.");\r
                return;\r
        }\r
-       if (frozen.damage[DWARPEN] != 0 && frozen.damage[DIMPULS] != 0) {\r
+       if (game.damage[DWARPEN] != 0 && game.damage[DIMPULS] != 0) {\r
                prout("Both warp and impulse engines damaged.");\r
                return;\r
        }\r
@@ -87,7 +87,7 @@ void orbit(void) {
 void sensor(void) {\r
        skip(1);\r
        chew();\r
-       if (frozen.damage[DSRSENS] != 0.0) {\r
+       if (game.damage[DSRSENS] != 0.0) {\r
                prout("Short range sensors damaged.");\r
                return;\r
        }\r
@@ -102,23 +102,23 @@ void sensor(void) {
        proutn("         Planet at");\r
        cramlc(2, plnetx, plnety);\r
        proutn(" is of class ");\r
-       proutn(classes[state.plnets[iplnet].pclass]);\r
+       proutn(classes[game.state.plnets[iplnet].pclass]);\r
        prout(".");\r
-       if (state.plnets[iplnet].known==2) \r
+       if (game.state.plnets[iplnet].known==2) \r
                prout("         Sensors show Galileo still on surface.");\r
        proutn("         Readings indicate");\r
-       if (state.plnets[iplnet].crystals == 0) proutn(" no");\r
+       if (game.state.plnets[iplnet].crystals == 0) proutn(" no");\r
        prout(" dilithium crystals present.\"");\r
-       if (state.plnets[iplnet].known == 0) state.plnets[iplnet].known = 1;\r
+       if (game.state.plnets[iplnet].known == 0) game.state.plnets[iplnet].known = 1;\r
        return;\r
 }\r
 \r
 void beam(void) {\r
        chew();\r
        skip(1);\r
-       if (frozen.damage[DTRANSP] != 0) {\r
+       if (game.damage[DTRANSP] != 0) {\r
                prout("Transporter damaged.");\r
-               if (frozen.damage[DSHUTTL]==0 && (state.plnets[iplnet].known==2 || iscraft == 1)) {\r
+               if (game.damage[DSHUTTL]==0 && (game.state.plnets[iplnet].known==2 || iscraft == 1)) {\r
                        skip(1);\r
                        prout("Spock-  \"May I suggest the shuttle craft, Sir?\" ");\r
                        if (ja() != 0) shuttle();\r
@@ -134,7 +134,7 @@ void beam(void) {
                prout("Impossible to transport through shields.");\r
                return;\r
        }\r
-       if (state.plnets[iplnet].known==0) {\r
+       if (game.state.plnets[iplnet].known==0) {\r
                prout("Spock-  \"Captain, we have no information on this planet");\r
                prout("  and Starfleet Regulations clearly state that in this situation");\r
                prout("  you may not go down.\"");\r
@@ -142,7 +142,7 @@ void beam(void) {
        }\r
        if (landed==1) {\r
                /* Coming from planet */\r
-               if (state.plnets[iplnet].known==2) {\r
+               if (game.state.plnets[iplnet].known==2) {\r
                        proutn("Spock-  \"Wouldn't you rather take the Galileo?\" ");\r
                        if (ja() != 0) {\r
                                chew();\r
@@ -159,7 +159,7 @@ void beam(void) {
        }\r
        else {\r
                /* Going to planet */\r
-               if (state.plnets[iplnet].crystals==0) {\r
+               if (game.state.plnets[iplnet].crystals==0) {\r
                        prout("Spock-  \"Captain, I fail to see the logic in");\r
                        prout("  exploring a planet with no dilithium crystals.");\r
                        proutn("  Are you sure this is wise?\" ");\r
@@ -188,7 +188,7 @@ void beam(void) {
        skip(2);\r
        prout("Transport complete.");\r
        landed = -landed;\r
-       if (landed==1 && state.plnets[iplnet].known==2) {\r
+       if (landed==1 && game.state.plnets[iplnet].known==2) {\r
                prout("The shuttle craft Galileo is here!");\r
        }\r
        if (landed!=1 && imine==1) {\r
@@ -208,7 +208,7 @@ void mine(void) {
                prout("Mining party not on planet.");\r
                return;\r
        }\r
-       if (state.plnets[iplnet].crystals == 0) {\r
+       if (game.state.plnets[iplnet].crystals == 0) {\r
                prout("No dilithium crystals on this planet.");\r
                return;\r
        }\r
@@ -223,7 +223,7 @@ void mine(void) {
                prout("there's no reason to mine more at this time.");\r
                return;\r
        }\r
-       Time = (0.1+0.2*Rand())*state.plnets[iplnet].pclass;\r
+       Time = (0.1+0.2*Rand())*game.state.plnets[iplnet].pclass;\r
        if (consumeTime()) return;\r
        prout("Mining operation complete.");\r
        imine = 1;\r
@@ -285,14 +285,14 @@ void shuttle(void) {
        chew();\r
        skip(1);\r
        ididit = 0;\r
-       if(frozen.damage[DSHUTTL] != 0.0) {\r
-               if (frozen.damage[DSHUTTL] == -1.0) {\r
-                       if (inorbit && state.plnets[iplnet].known == 2)\r
+       if(game.damage[DSHUTTL] != 0.0) {\r
+               if (game.damage[DSHUTTL] == -1.0) {\r
+                       if (inorbit && game.state.plnets[iplnet].known == 2)\r
                                prout("Ye Faerie Queene has no shuttle craft bay to dock it at.");\r
                        else\r
                                prout("Ye Faerie Queene had no shuttle craft.");\r
                }\r
-               else if (frozen.damage[DSHUTTL] > 0)\r
+               else if (game.damage[DSHUTTL] > 0)\r
                        prout("The Galileo is damaged.");\r
                else prout("Shuttle craft is now serving Big Macs.");\r
                return;\r
@@ -302,11 +302,11 @@ void shuttle(void) {
                prout(" not in standard orbit.");\r
                return;\r
        }\r
-       if ((state.plnets[iplnet].known != 2) && iscraft != 1) {\r
+       if ((game.state.plnets[iplnet].known != 2) && iscraft != 1) {\r
                prout("Shuttle craft not currently available.");\r
                return;\r
        }\r
-       if (landed==-1 && state.plnets[iplnet].known==2) {\r
+       if (landed==-1 && game.state.plnets[iplnet].known==2) {\r
                prout("You will have to beam down to retrieve the shuttle craft.");\r
                return;\r
        }\r
@@ -314,17 +314,17 @@ void shuttle(void) {
                prout("Shuttle craft cannot pass through shields.");\r
                return;\r
        }\r
-       if (state.plnets[iplnet].known==0) {\r
+       if (game.state.plnets[iplnet].known==0) {\r
                prout("Spock-  \"Captain, we have no information on this planet");\r
                prout("  and Starfleet Regulations clearly state that in this situation");\r
                prout("  you may not fly down.\"");\r
                return;\r
        }\r
        Time = 3.0e-5*height;\r
-       if (Time >= 0.8*state.remtime) {\r
+       if (Time >= 0.8*game.state.remtime) {\r
                prout("First Officer Spock-  \"Captain, I compute that such");\r
                prout("  a maneuver would require approximately ");\r
-               cramf(100*Time/state.remtime,0,4);\r
+               cramf(100*Time/game.state.remtime,0,4);\r
                prout("% of our");\r
                prout("remaining time.");\r
                prout("Are you sure this is wise?\" ");\r
@@ -337,7 +337,7 @@ void shuttle(void) {
                /* Kirk on planet */\r
                if (iscraft==1) {\r
                        /* Galileo on ship! */\r
-                       if (frozen.damage[DTRANSP]==0) {\r
+                       if (game.damage[DTRANSP]==0) {\r
                                proutn("Spock-  \"Would you rather use the transporter?\" ");\r
                                if (ja() != 0) {\r
                                        beam();\r
@@ -351,7 +351,7 @@ void shuttle(void) {
                        iscraft = 0;\r
                        skip(1);\r
                        if (consumeTime()) return;\r
-                       state.plnets[iplnet].known=2;\r
+                       game.state.plnets[iplnet].known=2;\r
                        prout("Trip complete.");\r
                        return;\r
                }\r
@@ -361,7 +361,7 @@ void shuttle(void) {
                        prout("shuttle craft for the trip back to the Enterprise.");\r
                        skip(1);\r
                        prout("The short hop begins . . .");\r
-                       state.plnets[iplnet].known=1;\r
+                       game.state.plnets[iplnet].known=1;\r
                        icraft = 1;\r
                        skip(1);\r
                        landed = -1;\r
@@ -388,7 +388,7 @@ void shuttle(void) {
                icraft = 1;\r
                iscraft = 0;\r
                if (consumeTime()) return;\r
-               state.plnets[iplnet].known = 2;\r
+               game.state.plnets[iplnet].known = 2;\r
                landed = 1;\r
                icraft = 0;\r
                prout("Trip complete");\r
@@ -411,7 +411,7 @@ void deathray(void) {
                prout("Sulu-  \"But Sir, there are no enemies in this quadrant.\"");\r
                return;\r
        }\r
-       if (frozen.damage[DDRAY] > 0.0) {\r
+       if (game.damage[DDRAY] > 0.0) {\r
                prout("Death Ray is damaged.");\r
                return;\r
        }\r
@@ -437,16 +437,16 @@ void deathray(void) {
                prouts("Sulu- \"Captain!  It's working!\"");\r
                skip(2);\r
                while (nenhere > 0)\r
-                       deadkl(frozen.kx[1],frozen.ky[1],frozen.quad[frozen.kx[1]][frozen.ky[1]],frozen.kx[1],frozen.ky[1]);\r
+                       deadkl(game.kx[1],game.ky[1],game.quad[game.kx[1]][game.ky[1]],game.kx[1],game.ky[1]);\r
                prout("Ensign Chekov-  \"Congratulations, Captain!\"");\r
-               if (state.remkl == 0) finish(FWON);\r
+               if (game.state.remkl == 0) finish(FWON);\r
                prout("Spock-  \"Captain, I believe the `Experimental Death Ray'");\r
                if (Rand() <= 0.05) {\r
                        prout("   is still operational.\"");\r
                }\r
                else {\r
                        prout("   has been rendered disfunctional.\"");\r
-                       frozen.damage[DDRAY] = 39.95;\r
+                       game.damage[DDRAY] = 39.95;\r
                }\r
                return;\r
        }\r
@@ -488,7 +488,7 @@ void deathray(void) {
                prout(" Mr. Sulu.");\r
                for (i=1; i<=10; i++)\r
                        for (j=1; j<=10; j++)\r
-                               if (frozen.quad[i][j] == IHDOT) frozen.quad[i][j] = IHQUEST;\r
+                               if (game.quad[i][j] == IHDOT) game.quad[i][j] = IHQUEST;\r
                prout("  Captain, our quadrant is now infested with");\r
                prouts(" - - - - - -  *THINGS*.");\r
                skip(1);\r