Install/uninstall are in place.
[super-star-trek.git] / finish.c
index 1d58840fa8361a76c5ffffd6614773949a238db7..7144086973e2c8cca21efc56ed33578dcfa7c15e 100644 (file)
--- a/finish.c
+++ b/finish.c
@@ -5,7 +5,7 @@
 void dstrct() {\r
        /* Finish with a BANG! */\r
        chew();\r
-       if (damage[DCOMPTR] != 0.0) {\r
+       if (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(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 (kpower[l]*kdist[l] <= whammo) \r
-                               deadkl(kx[l],ky[l], quad[kx[l]][ky[l]], kx[l], 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,27 @@ void finish(FINTYPE ifin) {
        int igotit = 0;\r
        alldone = 1;\r
        skip(3);\r
-       printf("It is stardate %.1f .\n\n", d.date);\r
+       prout("It is stardate %.1f.", game.state.date);\r
+       prout("");\r
        switch (ifin) {\r
                case FWON: // Game has been won\r
-                       if (d.nromrem != 0)\r
-                               printf("The remaining %d Romulans surrender to Starfleet Command.\n",\r
-                                          d.nromrem);\r
+                       if (game.state.nromrem != 0)\r
+                               prout("The remaining %d Romulans surrender to Starfleet Command.",\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.*d.starkl + casual + 10.*d.nplankl +\r
-                                               45.*nhelp+100.*d.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 (d.date-indate < 5.0 ||\r
+                               if (game.state.date-indate < 5.0 ||\r
                                        // killsPerDate >= RateMax\r
-                                       (d.killk+d.killc+d.nsckill)/(d.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
@@ -150,7 +151,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 (game.state.remkl*3.0 > inkling) {\r
                                prout("aquitted.");\r
                                skip(1);\r
                                prout("LIVE LONG AND PROSPER.");\r
@@ -275,9 +276,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 (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,62 +304,62 @@ void finish(FINTYPE ifin) {
 }\r
 \r
 void score(void) {\r
-       double timused = d.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 || d.remkl != 0) && timused < 5.0) timused = 5.0;\r
-       perdate = (d.killc + d.killk + d.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) 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) 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 (d.nromkl)\r
-               printf("%6d Romulans destroyed                 %5d\n",\r
-                          d.nromkl,20*d.nromkl);\r
-       if (d.nromrem)\r
-               printf("%6d Romulans captured                  %5d\n",\r
-                          d.nromrem, d.nromrem);\r
-       if (d.killk)\r
-               printf("%6d ordinary Klingons destroyed        %5d\n",\r
-                          d.killk, 10*d.killk);\r
-       if (d.killc)\r
-               printf("%6d Klingon commanders destroyed       %5d\n",\r
-                          d.killc, 50*d.killc);\r
-       if (d.nsckill)\r
-               printf("%6d Super-Commander destroyed          %5d\n",\r
-                          d.nsckill, 200*d.nsckill);\r
+       if (game.state.nromkl)\r
+               prout("%6d Romulans destroyed                 %5d",\r
+                          game.state.nromkl,20*game.state.nromkl);\r
+       if (game.state.nromrem)\r
+               prout("%6d Romulans captured                  %5d",\r
+                          game.state.nromrem, game.state.nromrem);\r
+       if (game.state.killk)\r
+               prout("%6d ordinary Klingons destroyed        %5d",\r
+                          game.state.killk, 10*game.state.killk);\r
+       if (game.state.killc)\r
+               prout("%6d Klingon commanders destroyed       %5d",\r
+                          game.state.killc, 50*game.state.killc);\r
+       if (game.state.nsckill)\r
+               prout("%6d Super-Commander destroyed          %5d",\r
+                          game.state.nsckill, 200*game.state.nsckill);\r
        if (ithperd)\r
-               printf("%6.2f Klingons per stardate              %5d\n",\r
+               prout("%.2f Klingons per stardate              %5d",\r
                           perdate, ithperd);\r
-       if (d.starkl)\r
-               printf("%6d stars destroyed by your action     %5d\n",\r
-                          d.starkl, -5*d.starkl);\r
-       if (d.nplankl)\r
-               printf("%6d planets destroyed by your action   %5d\n",\r
-                          d.nplankl, -10*d.nplankl);\r
-       if (d.basekl)\r
-               printf("%6d bases destroyed by your action     %5d\n",\r
-                          d.basekl, -100*d.basekl);\r
+       if (game.state.starkl)\r
+               prout("%6d stars destroyed by your action     %5d",\r
+                          game.state.starkl, -5*game.state.starkl);\r
+       if (game.state.nplankl)\r
+               prout("%6d planets destroyed by your action   %5d",\r
+                          game.state.nplankl, -10*game.state.nplankl);\r
+       if (game.state.basekl)\r
+               prout("%6d bases destroyed by your action     %5d",\r
+                          game.state.basekl, -100*game.state.basekl);\r
        if (nhelp)\r
-               printf("%6d calls for help from starbase       %5d\n",\r
+               prout("%6d calls for help from starbase       %5d",\r
                           nhelp, -45*nhelp);\r
        if (casual)\r
-               printf("%6d casualties incurred                %5d\n",\r
+               prout("%6d casualties incurred                %5d",\r
                           casual, -casual);\r
        if (klship)\r
-               printf("%6d ship(s) lost or destroyed          %5d\n",\r
+               prout("%6d ship(s) lost or destroyed          %5d",\r
                           klship, -100*klship);\r
        if (alive==0)\r
                prout("Penalty for getting yourself killed        -200");\r
@@ -372,10 +373,10 @@ void score(void) {
                        case 4: proutn("Expert game  "); break;\r
                        case 5: proutn("Emeritus game"); break;\r
                }\r
-               printf("           %5d\n", iwon);\r
+               prout("           %5d", iwon);\r
        }\r
        skip(2);\r
-       printf("TOTAL SCORE                               %5d\n", iscore);\r
+       prout("TOTAL SCORE                               %5d", iscore);\r
 }\r
 \r
 void plaque(void) {\r
@@ -388,16 +389,16 @@ void plaque(void) {
        skip(2);\r
        \r
        while (fp == NULL) {\r
-               printf("File or device name for your plaque:");\r
+               proutn("File or device name for your plaque:");\r
                fgets(winner, 128, stdin);\r
                winner[strlen(winner)-1] = '\0';\r
                fp = fopen(winner, "w");\r
                if (fp==NULL) {\r
-                       printf("Invalid name.\n");\r
+                       prout("Invalid name.");\r
                }\r
        }\r
 \r
-       printf("Enter name to go on plaque (up to 30 characters):");\r
+       proutn("Enter name to go on plaque (up to 30 characters):");\r
        fgets(winner, 128, stdin);\r
        winner[strlen(winner)-1] = '\0';\r
        winner[30] = '\0';\r