Better project documentation.
[super-star-trek.git] / reports.c
index 9475ab3b4ac1eeb469ed0e7945860f13db5ced71..858c70cb479f66689b0b5b3ff3a3fda391658fa2 100644 (file)
--- a/reports.c
+++ b/reports.c
@@ -5,20 +5,16 @@
 \r
 void attakreport(void) {\r
        if (game.future[FCDBAS] < 1e30) {\r
-               proutn("Starbase in ");\r
-               cramlc(1, batx, baty);\r
-               prout(" is currently under attack.");\r
-               proutn("It can hold out until Stardate ");\r
-               cramf(game.future[FCDBAS], 0,1);\r
-               prout(".");\r
+               prout("Starbase in %s is currently under attack.",\r
+                     cramlc(quadrant, batx, baty));\r
+               prout("It can hold out until Stardate %d.", \r
+                     (int)game.future[FCDBAS]);\r
        }\r
        if (isatb == 1) {\r
-               proutn("Starbase in ");\r
-               cramlc(1, game.state.isx, game.state.isy);\r
-               prout(" is under Super-commander attack.");\r
-               proutn("It can hold out until Stardate ");\r
-               cramf(game.future[FSCDBAS], 0, 1);\r
-               prout(".");\r
+               prout("Starbase in %s is under Super-commander attack.",\r
+                     cramlc(quadrant, game.state.isx, game.state.isy));\r
+               prout("It can hold out until Stardate %d.", \r
+                     (int)game.future[FSCDBAS]);\r
        }\r
 }\r
        \r
@@ -42,44 +38,41 @@ 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
+       prout("");\r
+       prout("You %s playing a %s%s %s game.",\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",game.passwd);\r
-       printf("%d of %d Klingons have been killed",\r
+       if (tourn) prout("This is tournament game %d.", tourn);\r
+       if (f) prout("Your secret password is \"%s\"",game.passwd);\r
+       proutn("%d of %d Klingons have been killed",\r
                   game.state.killk+game.state.killc+game.state.nsckill, inkling);\r
-       if (game.state.killc) printf(", including %d Commander%s.\n", game.state.killc, game.state.killc==1?"":"s");\r
+       if (game.state.killc) prout(", including %d Commander%s.", game.state.killc, game.state.killc==1?"":"s");\r
        else if (game.state.killk+game.state.nsckill > 0) prout(", but no Commanders.");\r
        else prout(".");\r
-       if (skill > 2) printf("The Super Commander has %sbeen destroyed.\n",\r
+       if (skill > 2) prout("The Super Commander has %sbeen destroyed.",\r
                                                  game.state.nscrem?"not ":"");\r
        if (game.state.rembase != inbase) {\r
                proutn("There ");\r
                if (inbase-game.state.rembase==1) proutn("has been 1 base");\r
                else {\r
-                       proutn("have been ");\r
-                       crami(inbase-game.state.rembase, 1);\r
-                       proutn(" bases");\r
+                   proutn("have been %d bases", inbase-game.state.rembase);\r
                }\r
-               proutn(" destroyed, ");\r
-               crami(game.state.rembase, 1);\r
-               prout(" remaining.");\r
+               prout(" destroyed, %d remaining.", game.state.rembase);\r
        }\r
-       else printf("There are %d bases.\n", inbase);\r
+       else prout("There are %d bases.", inbase);\r
        if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED || iseenit) {\r
                /* Don't report this if not seen and\r
                        either the radio is dead or not at base! */\r
                attakreport();\r
                iseenit = 1;\r
        }\r
-       if (casual) printf("%d casualt%s suffered so far.\n",\r
+       if (casual) prout("%d casualt%s suffered so far.",\r
                                           casual, casual==1? "y" : "ies");\r
-       if (nhelp) printf("There were %d call%s for help.\n",\r
+       if (nhelp) prout("There were %d call%s for help.",\r
                                          nhelp, nhelp==1 ? "" : "s");\r
        if (ship == IHE) {\r
                proutn("You have ");\r
-               if (nprobes) crami(nprobes,1);\r
+               if (nprobes) proutn("%d", nprobes);\r
                else proutn("no");\r
                proutn(" deep space probe");\r
                if (nprobes!=1) proutn("s");\r
@@ -91,7 +84,7 @@ void report(int f) {
                        proutn("An armed deep space probe is in");\r
                else\r
                        proutn("A deep space probe is in");\r
-               cramlc(1, probecx, probecy);\r
+               proutn(cramlc(quadrant, probecx, probecy));\r
                prout(".");\r
        }\r
        if (icrystl) {\r
@@ -104,7 +97,7 @@ void report(int f) {
                                ai *= 2.0;\r
                                i++;\r
                        }\r
-                       printf("Dilithium crystals have been used %d time%s.\n",\r
+                       prout("Dilithium crystals have been used %d time%s.",\r
                                   i, i==1? "" : "s");\r
                }\r
        }\r
@@ -127,14 +120,13 @@ void lrscan(void) {
                skip(1);\r
                proutn("Long-range scan for");\r
        }\r
-       cramlc(1, quadx, quady);\r
-       skip(1);\r
+       prout(cramlc(quadrant, quadx, quady));\r
        for (x = quadx-1; x <= quadx+1; x++) {\r
                for (y = quady-1; y <= quady+1; y++) {\r
                        if (x == 0 || x > 8 || y == 0 || y > 8)\r
-                               printf("   -1");\r
+                               proutn("   -1");\r
                        else {\r
-                               printf("%5d", game.state.galaxy[x][y]);\r
+                               proutn("%5d", game.state.galaxy[x][y]);\r
                                game.starch[x][y] = game.damage[DRADIO] > 0 ? game.state.galaxy[x][y]+1000 :1;\r
                        }\r
                }\r
@@ -147,7 +139,7 @@ void dreprt(void) {
        int jdam = FALSE, i;\r
        chew();\r
 \r
-       for (i = 1; i <= ndevice; i++) {\r
+       for (i = 1; i <= NDEVICES; i++) {\r
                if (game.damage[i] > 0.0) {\r
                        if (!jdam) {\r
                                skip(1);\r
@@ -155,11 +147,10 @@ void dreprt(void) {
                                prout("                IN FLIGHT   DOCKED");\r
                                jdam = TRUE;\r
                        }\r
-                       printf("  %16s ", device[i]);\r
-                       cramf(game.damage[i]+0.05, 8, 2);\r
-                       proutn("  ");\r
-                       cramf(docfac*game.damage[i]+0.005, 8, 2);\r
-                       skip(1);\r
+                       prout("  %16s %8.2f  %8.2f", \r
+                               device[i],\r
+                               game.damage[i]+0.05,\r
+                               docfac*game.damage[i]+0.005);\r
                }\r
        }\r
        if (!jdam) prout("All devices functional.");\r
@@ -185,37 +176,34 @@ void chart(int nn) {
                                        if (game.starch[i][j] == 1) game.starch[i][j] = game.state.galaxy[i][j]+1000;\r
                }\r
                else {\r
-                       proutn("(Last surveillance update ");\r
-                       cramf(game.state.date-stdamtim, 0, 1);\r
-                       prout(" stardates ago.)");\r
+                   proutn("(Last surveillance update %d stardates ago.",\r
+                          (int)(game.state.date-stdamtim));\r
                }\r
        }\r
        if (nn ==0) skip(1);\r
 \r
        prout("      1    2    3    4    5    6    7    8");\r
        prout("    ----------------------------------------");\r
-       if (nn==0) prout("  -");\r
+       /* if (nn==0) prout("  -"); */\r
        for (i = 1; i <= 8; i++) {\r
-               printf("%d -", i);\r
+               proutn("%d -", i);\r
                for (j = 1; j <= 8; j++) {\r
                        if (game.starch[i][j] < 0)\r
-                               printf("  .1.");\r
+                               proutn("  .1.");\r
                        else if (game.starch[i][j] == 0)\r
-                               printf("  ...");\r
+                               proutn("  ...");\r
                        else if (game.starch[i][j] > 999)\r
-                               printf("%5d", game.starch[i][j]-1000);\r
+                               proutn("%5d", game.starch[i][j]-1000);\r
                        else\r
-                               printf("%5d", game.state.galaxy[i][j]);\r
+                               proutn("%5d", game.state.galaxy[i][j]);\r
                }\r
                prout("  -");\r
        }\r
        if (nn == 0) {\r
                skip(1);\r
                crmshp();\r
-               proutn(" is currently in");\r
-               cramlc(1, quadx, quady);\r
-               skip(1);\r
-       }\r
+               prout(" is currently in %s", cramlc(quadrant, quadx, quady));\r
+}\r
 }\r
                \r
                \r
@@ -247,7 +235,7 @@ void srscan(int l) {
                        break;\r
                case 2: // REQUEST\r
                        while (scan() == IHEOL)\r
-                               printf("Information desired? ");\r
+                               proutn("Information desired? ");\r
                        chew();\r
                        for (k = 1; k <= 10; k++)\r
                                if (strncmp(citem,requests[k],min(2,strlen(citem)))==0)\r
@@ -267,18 +255,18 @@ void srscan(int l) {
        for (i = 1; i <= 10; i++) {\r
                int jj = (k!=0 ? k : i);\r
                if (leftside) {\r
-                       printf("%2d  ", i);\r
+                       proutn("%2d  ", i);\r
                        for (j = 1; j <= 10; j++) {\r
                                if (goodScan || (abs(i-sectx)<= 1 && abs(j-secty) <= 1))\r
-                                       printf("%c ",game.quad[i][j]);\r
+                                       proutn("%c ",game.quad[i][j]);\r
                                else\r
-                                       printf("- ");\r
+                                       proutn("- ");\r
                        }\r
                }\r
                if (rightside) {\r
                        switch (jj) {\r
                                case 1:\r
-                                       printf(" Stardate      %.1f", game.state.date);\r
+                                       proutn(" Stardate      %.1f", game.state.date);\r
                                        break;\r
                                case 2:\r
                                        if (condit != IHDOCKED) newcnd();\r
@@ -288,50 +276,50 @@ void srscan(int l) {
                                                case IHYELLOW: cp = "YELLOW"; break;\r
                                                case IHDOCKED: cp = "DOCKED"; break;\r
                                        }\r
-                                       printf(" Condition     %s", cp);\r
+                                       proutn(" Condition     %s", cp);\r
                                        break;\r
                                case 3:\r
-                                       printf(" Position     ");\r
-                                       cramlc(0, quadx, quady);\r
-                                       putchar(',');\r
-                                       cramlc(0, sectx, secty);\r
+                                       proutn(" Position      ");\r
+                                       proutn(cramlc(neither, quadx, quady));\r
+                                       proutn(" , ");\r
+                                       proutn(cramlc(neither, sectx, secty));\r
                                        break;\r
                                case 4:\r
-                                       printf(" Life Support  ");\r
+                                       proutn(" Life Support  ");\r
                                        if (game.damage[DLIFSUP] != 0.0) {\r
                                                if (condit == IHDOCKED)\r
-                                                       printf("DAMAGED, supported by starbase");\r
+                                                       proutn("DAMAGED, supported by starbase");\r
                                                else\r
-                                                       printf("DAMAGED, reserves=%4.2f", lsupres);\r
+                                                       proutn("DAMAGED, reserves=%.2f", lsupres);\r
                                        }\r
                                        else\r
-                                               printf("ACTIVE");\r
+                                               proutn("ACTIVE");\r
                                        break;\r
                                case 5:\r
-                                       printf(" Warp Factor   %.1f", warpfac);\r
+                                       proutn(" Warp Factor   %.1f", warpfac);\r
                                        break;\r
                                case 6:\r
-                                       printf(" Energy        %.2f", energy);\r
+                                       proutn(" Energy        %.2f", energy);\r
                                        break;\r
                                case 7:\r
-                                       printf(" Torpedoes     %d", torps);\r
+                                       proutn(" Torpedoes     %d", torps);\r
                                        break;\r
                                case 8:\r
-                                       printf(" Shields       ");\r
+                                       proutn(" Shields       ");\r
                                        if (game.damage[DSHIELD] != 0)\r
-                                               printf("DAMAGED,");\r
+                                               proutn("DAMAGED,");\r
                                        else if (shldup)\r
-                                               printf("UP,");\r
+                                               proutn("UP,");\r
                                        else\r
-                                               printf("DOWN,");\r
-                                       printf(" %d%% %.1f units",\r
+                                               proutn("DOWN,");\r
+                                       proutn(" %d%% %.1f units",\r
                                                   (int)((100.0*shield)/inshld + 0.5), shield);\r
                                        break;\r
                                case 9:\r
-                                       printf(" Klingons Left %d", game.state.remkl);\r
+                                       proutn(" Klingons Left %d", game.state.remkl);\r
                                        break;\r
                                case 10:\r
-                                       printf(" Time Left     %.2f", game.state.remtime);\r
+                                       proutn(" Time Left     %.2f", game.state.remtime);\r
                                        break;\r
                        }\r
                                        \r
@@ -450,23 +438,17 @@ void eta(void) {
                }\r
                else\r
                        proutn("Remaining");\r
-               proutn(" energy will be ");\r
-               cramf(energy-tpower, 1, 1);\r
-               prout(".");\r
+               prout(" energy will be %.2f.", energy-tpower);\r
                if (wfl) {\r
-                       proutn("And we will arrive at stardate ");\r
-                       cramf(game.state.date+ttime, 1, 1);\r
-                       prout(".");\r
+                       prout("And we will arrive at stardate %.2f.",\r
+                               game.state.date+ttime);\r
                }\r
                else if (twarp==1.0)\r
                        prout("Any warp speed is adequate.");\r
                else {\r
-                       proutn("Minimum warp needed is ");\r
-                       cramf(twarp, 1, 2);\r
-                       skip(1);\r
-                       proutn("and we will arrive at stardate ");\r
-                       cramf(game.state.date+ttime, 1, 2);\r
-                       prout(".");\r
+                       prout("Minimum warp needed is %.2f,", twarp);\r
+                       prout("and we will arrive at stardate %.2f.",\r
+                               game.state.date+ttime);\r
                }\r
                if (game.state.remtime < ttime)\r
                        prout("Unfortunately, the Federation will be destroyed by then.");\r