Clean up some float formatting.
[super-star-trek.git] / planets.c
index a98235ffa1f8934f72090c0aa1cdf0c0f993302f..a45879f05c8adf225ea236fec6150810117b8eb2 100644 (file)
--- a/planets.c
+++ b/planets.c
@@ -1,8 +1,9 @@
 #include "sst.h"\r
 \r
-static char classes[4][2]={"","M","N","O"};\r
 static int height;\r
 \r
+static char *classes[] = {"M","N","O"};\r
+\r
 static int consumeTime(void) {\r
 /* I think most of this avoidance was caused by overlay scheme.\r
    Let's see what happens if all events can occur here */\r
@@ -31,7 +32,7 @@ void preport(void) {
        chew();\r
        prout("Spock-  \"Planet report follows, Captain.\"");\r
        skip(1);\r
-       for (i = 1; i <= inplan; i++) {\r
+       for (i = 0; i < inplan; i++) {\r
                if (game.state.plnets[i].known != unknown\r
 #ifdef DEBUG\r
                        || ( idebug && game.state.plnets[i].x !=0)\r
@@ -41,7 +42,7 @@ void preport(void) {
 #ifdef DEBUG\r
                        if (idebug && game.state.plnets[i].known==unknown) proutn("(Unknown) ");\r
 #endif\r
-                       cramlc(1, game.state.plnets[i].x, game.state.plnets[i].y);\r
+                       proutn(cramlc(quadrant, game.state.plnets[i].x, game.state.plnets[i].y));\r
                        proutn("   class ");\r
                        proutn(classes[game.state.plnets[i].pclass]);\r
                        proutn("   ");\r
@@ -77,9 +78,8 @@ void orbit(void) {
        prout("Helmsman Sulu-  \"Entering standard orbit, Sir.\"");\r
        newcnd();\r
        if (consumeTime()) return;\r
-       proutn("Sulu-  \"Entered orbit at altitude ");\r
-       cramf(height = (1400.+7200.*Rand()), 0, 2);\r
-       prout(" kilometers.\"");\r
+       height = (1400.+7200.*Rand());\r
+       prout("Sulu-  \"Entered orbit at altitude %.2f kilometers.\"", height);\r
        inorbit = 1;\r
        return;\r
 }\r
@@ -95,15 +95,11 @@ void sensor(void) {
                prout("No planet in this quadrant.");\r
                return;\r
        }\r
-       proutn("Spock-  \"Sensor scan for");\r
-       cramlc(1, quadx, quady);\r
-       prout("-");\r
+       prout("Spock-  \"Sensor scan for %s-", cramlc(quadrant, quadx, quady));\r
        skip(1);\r
-       proutn("         Planet at");\r
-       cramlc(2, plnetx, plnety);\r
-       proutn(" is of class ");\r
-       proutn(classes[game.state.plnets[iplnet].pclass]);\r
-       prout(".");\r
+       prout("         Planet at %s is of class %s.", \r
+              cramlc(sector, plnetx, plnety),\r
+              classes[game.state.plnets[iplnet].pclass]);\r
        if (game.state.plnets[iplnet].known==shuttle_down) \r
                prout("         Sensors show Galileo still on surface.");\r
        proutn("         Readings indicate");\r
@@ -323,9 +319,8 @@ void shuttle(void) {
        Time = 3.0e-5*height;\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/game.state.remtime,0,4);\r
-               prout("% of our");\r
+               proutn("  a maneuver would require approximately 2d%% of our",\r
+                     (int)(100*Time/game.state.remtime));\r
                prout("remaining time.");\r
                prout("Are you sure this is wise?\" ");\r
                if (ja()==0) {\r
@@ -445,7 +440,7 @@ void deathray(void) {
                        prout("   is still operational.\"");\r
                }\r
                else {\r
-                       prout("   has been rendered disfunctional.\"");\r
+                       prout("   has been rendered nonfunctional.\"");\r
                        game.damage[DDRAY] = 39.95;\r
                }\r
                return;\r