Another step in consolidating the saved-state globals.
[super-star-trek.git] / finish.c
index f355b5a69f855c929b522117477957a0c376f75a..e0fb221822b892e0c4257bb6a237700c996f6584 100644 (file)
--- a/finish.c
+++ b/finish.c
@@ -5,7 +5,7 @@
 void dstrct() {\r
        /* Finish with a BANG! */\r
        chew();\r
-       if (frozen.damage[DCOMPTR] != 0.0) {\r
+       if (game.damage[DCOMPTR] != 0.0) {\r
                prout("Computer damaged; cannot execute destruct sequence.");\r
                return;\r
        }\r
@@ -22,7 +22,7 @@ void dstrct() {
        prout("SELF-DESTRUCT-SEQUENCE-WILL-BE-ABORTED");\r
        scan();\r
        chew();\r
-       if (strcmp(frozen.passwd, citem) != 0) {\r
+       if (strcmp(game.passwd, citem) != 0) {\r
                prouts("PASSWORD-REJECTED;"); skip(1);\r
                prout("CONTINUITY-EFFECTED");\r
                skip(1);\r
@@ -55,8 +55,8 @@ void kaboom(void) {
                double whammo = 25.0 * energy;\r
                int l=1;\r
                while (l <= nenhere) {\r
-                       if (frozen.kpower[l]*frozen.kdist[l] <= whammo) \r
-                               deadkl(frozen.kx[l],frozen.ky[l], frozen.quad[frozen.kx[l]][frozen.ky[l]], frozen.kx[l], frozen.ky[l]);\r
+                       if (game.kpower[l]*game.kdist[l] <= whammo) \r
+                               deadkl(game.kx[l],game.ky[l], game.quad[game.kx[l]][game.ky[l]], game.kx[l], game.ky[l]);\r
                        l++;\r
                }\r
        }\r
@@ -68,26 +68,26 @@ void finish(FINTYPE ifin) {
        int igotit = 0;\r
        alldone = 1;\r
        skip(3);\r
-       printf("It is stardate %.1f .\n\n", state.date);\r
+       printf("It is stardate %.1f .\n\n", game.state.date);\r
        switch (ifin) {\r
                case FWON: // Game has been won\r
-                       if (state.nromrem != 0)\r
+                       if (game.state.nromrem != 0)\r
                                printf("The remaining %d Romulans surrender to Starfleet Command.\n",\r
-                                          state.nromrem);\r
+                                          game.state.nromrem);\r
                        \r
                        prout("You have smashed the Klingon invasion fleet and saved");\r
                        prout("the Federation.");\r
                        gamewon=1;\r
                        if (alive) {\r
                                double badpt;\r
-                               badpt = 5.*state.starkl + casual + 10.*state.nplankl +\r
-                                               45.*nhelp+100.*state.basekl;\r
+                               badpt = 5.*game.state.starkl + casual + 10.*game.state.nplankl +\r
+                                               45.*nhelp+100.*game.state.basekl;\r
                                if (ship == IHF) badpt += 100.0;\r
                                else if (ship == 0) badpt += 200.0;\r
                                if (badpt < 100.0) badpt = 0.0; // Close enough!\r
-                               if (state.date-indate < 5.0 ||\r
+                               if (game.state.date-indate < 5.0 ||\r
                                        // killsPerDate >= RateMax\r
-                                       (state.killk+state.killc+state.nsckill)/(state.date-indate) >=\r
+                                       (game.state.killk+game.state.killc+game.state.nsckill)/(game.state.date-indate) >=\r
                                        0.1*skill*(skill+1.0) + 0.1 + 0.008*badpt) {\r
                                        skip(1);\r
                                        prout("In fact, you have done so well that Starfleet Command");\r
@@ -105,7 +105,7 @@ void finish(FINTYPE ifin) {
                                                        prout("promotes you to Commodore Emeritus.");\r
                                                        skip(1);\r
                                                        prout("Now that you think you're really good, try playing");\r
-                                                       prout("the \"Emeritus\" frozen. It will splatter your ego.");\r
+                                                       prout("the \"Emeritus\" game. It will splatter your ego.");\r
                                                        break;\r
                                                case 5:\r
                                                        skip(1);\r
@@ -150,7 +150,7 @@ void finish(FINTYPE ifin) {
                        prout("conquered.  Your starship is now Klingon property,");\r
                        prout("and you are put on trial as a war criminal.  On the");\r
                        proutn("basis of your record, you are ");\r
-                       if (state.remkl*3.0 > inkling) {\r
+                       if (game.state.remkl*3.0 > inkling) {\r
                                prout("aquitted.");\r
                                skip(1);\r
                                prout("LIVE LONG AND PROSPER.");\r
@@ -275,9 +275,9 @@ void finish(FINTYPE ifin) {
        if (ship==IHF) ship= 0;\r
        else if (ship == IHE) ship = IHF;\r
        alive = 0;\r
-       if (state.remkl != 0) {\r
-               double goodies = state.remres/inresor;\r
-               double baddies = (state.remkl + 2.0*state.remcom)/(inkling+2.0*incom);\r
+       if (game.state.remkl != 0) {\r
+               double goodies = game.state.remres/inresor;\r
+               double baddies = (game.state.remkl + 2.0*game.state.remcom)/(inkling+2.0*incom);\r
                if (goodies/baddies >= 1.0+0.5*Rand()) {\r
                        prout("As a result of your actions, a treaty with the Klingon");\r
                        prout("Empire has been signed. The terms of the treaty are");\r
@@ -303,54 +303,54 @@ void finish(FINTYPE ifin) {
 }\r
 \r
 void score(void) {\r
-       double timused = state.date - indate;\r
+       double timused = game.state.date - indate;\r
        int ithperd, iwon, klship;\r
 \r
        pause(0);\r
 \r
        iskill = skill;\r
-       if ((timused == 0 || state.remkl != 0) && timused < 5.0) timused = 5.0;\r
-       perdate = (state.killc + state.killk + state.nsckill)/timused;\r
+       if ((timused == 0 || game.state.remkl != 0) && timused < 5.0) timused = 5.0;\r
+       perdate = (game.state.killc + game.state.killk + game.state.nsckill)/timused;\r
        ithperd = 500*perdate + 0.5;\r
        iwon = 0;\r
        if (gamewon) iwon = 100*skill;\r
        if (ship == IHE) klship = 0;\r
        else if (ship == IHF) klship = 1;\r
        else klship = 2;\r
-       if (gamewon == 0) state.nromrem = 0; // None captured if no win\r
-       iscore = 10*state.killk + 50*state.killc + ithperd + iwon\r
-                        - 100*state.basekl - 100*klship - 45*nhelp -5*state.starkl - casual\r
-                        + 20*state.nromkl + 200*state.nsckill - 10*state.nplankl + state.nromrem;\r
+       if (gamewon == 0) game.state.nromrem = 0; // None captured if no win\r
+       iscore = 10*game.state.killk + 50*game.state.killc + ithperd + iwon\r
+                        - 100*game.state.basekl - 100*klship - 45*nhelp -5*game.state.starkl - casual\r
+                        + 20*game.state.nromkl + 200*game.state.nsckill - 10*game.state.nplankl + game.state.nromrem;\r
        if (alive == 0) iscore -= 200;\r
        skip(2);\r
        prout("Your score --");\r
-       if (state.nromkl)\r
+       if (game.state.nromkl)\r
                printf("%6d Romulans destroyed                 %5d\n",\r
-                          state.nromkl,20*state.nromkl);\r
-       if (state.nromrem)\r
+                          game.state.nromkl,20*game.state.nromkl);\r
+       if (game.state.nromrem)\r
                printf("%6d Romulans captured                  %5d\n",\r
-                          state.nromrem, state.nromrem);\r
-       if (state.killk)\r
+                          game.state.nromrem, game.state.nromrem);\r
+       if (game.state.killk)\r
                printf("%6d ordinary Klingons destroyed        %5d\n",\r
-                          state.killk, 10*state.killk);\r
-       if (state.killc)\r
+                          game.state.killk, 10*game.state.killk);\r
+       if (game.state.killc)\r
                printf("%6d Klingon commanders destroyed       %5d\n",\r
-                          state.killc, 50*state.killc);\r
-       if (state.nsckill)\r
+                          game.state.killc, 50*game.state.killc);\r
+       if (game.state.nsckill)\r
                printf("%6d Super-Commander destroyed          %5d\n",\r
-                          state.nsckill, 200*state.nsckill);\r
+                          game.state.nsckill, 200*game.state.nsckill);\r
        if (ithperd)\r
                printf("%6.2f Klingons per stardate              %5d\n",\r
                           perdate, ithperd);\r
-       if (state.starkl)\r
+       if (game.state.starkl)\r
                printf("%6d stars destroyed by your action     %5d\n",\r
-                          state.starkl, -5*state.starkl);\r
-       if (state.nplankl)\r
+                          game.state.starkl, -5*game.state.starkl);\r
+       if (game.state.nplankl)\r
                printf("%6d planets destroyed by your action   %5d\n",\r
-                          state.nplankl, -10*state.nplankl);\r
-       if (state.basekl)\r
+                          game.state.nplankl, -10*game.state.nplankl);\r
+       if (game.state.basekl)\r
                printf("%6d bases destroyed by your action     %5d\n",\r
-                          state.basekl, -100*state.basekl);\r
+                          game.state.basekl, -100*game.state.basekl);\r
        if (nhelp)\r
                printf("%6d calls for help from starbase       %5d\n",\r
                           nhelp, -45*nhelp);\r