printfs have been banished. All outputnow goes through prout/proutn/prouts.
[super-star-trek.git] / sst.c
diff --git a/sst.c b/sst.c
index f6db8870c9ae1856cf8eb55d345ac0981475a7c6..af932a0dbcb000c7e1e3ba7f260ece91f3cda2bc 100644 (file)
--- a/sst.c
+++ b/sst.c
@@ -1,6 +1,7 @@
 #define INCLUDED       // Define externs here\r
 #include "sst.h"\r
 #include <ctype.h>\r
+#include <stdarg.h>\r
 #ifdef MSDOS\r
 #include <dos.h>\r
 #endif\r
@@ -373,13 +374,13 @@ int main(int argc, char **argv) {
                skip(1);\r
 \r
                if (tourn && alldone) {\r
-                       printf("Do you want your score recorded?");\r
+                       proutn("Do you want your score recorded?");\r
                        if (ja()) {\r
                                chew2();\r
                                freeze(FALSE);\r
                        }\r
                }\r
-               printf("Do you want to play again?");\r
+               proutn("Do you want to play again?");\r
                if (!ja()) break;\r
        }\r
        skip(1);\r
@@ -410,10 +411,7 @@ void cramen(int i) {
 void cramlc(int key, int x, int y) {\r
        if (key == 1) proutn(" Quadrant");\r
        else if (key == 2) proutn(" Sector");\r
-       proutn(" ");\r
-       crami(x, 1);\r
-       proutn(" - ");\r
-       crami(y, 1);\r
+       proutn(" %d - %d", x, y);\r
 }\r
 \r
 void crmena(int i, int enemy, int key, int x, int y) {\r
@@ -536,12 +534,6 @@ void cramf(double x, int w, int d) {
        proutn(buf);\r
 }\r
 \r
-void crami(int i, int w) {\r
-       char buf[16];\r
-       sprintf(buf, "%*d", w, i);\r
-       proutn(buf);\r
-}\r
-\r
 double square(double i) { return i*i; }\r
                                                                        \r
 static void clearscreen(void) {\r
@@ -591,22 +583,34 @@ void skip(int i) {
 }\r
 \r
 \r
-void proutn(char *s) {\r
-       fputs(s, stdout);\r
+void proutn(char *fmt, ...) {\r
+    va_list ap;\r
+    va_start(ap, fmt);\r
+    vprintf(fmt, ap);\r
+    va_end(ap);\r
 }\r
 \r
-void prout(char *s) {\r
-       proutn(s);\r
-       skip(1);\r
+void prout(char *fmt, ...) {\r
+    va_list ap;\r
+    va_start(ap, fmt);\r
+    vprintf(fmt, ap);\r
+    va_end(ap);\r
+    skip(1);\r
 }\r
 \r
-void prouts(char *s) {\r
+void prouts(char *fmt, ...) {\r
        clock_t endTime;\r
+       char *s, buf[BUFSIZ];\r
        /* print slowly! */\r
-       while (*s) {\r
+       va_list ap;\r
+       va_start(ap, fmt);\r
+       vsprintf(buf, fmt, ap);\r
+       va_end(ap);\r
+       skip(1);\r
+       for (s = buf; *s; s++) {\r
                endTime = clock() + CLOCKS_PER_SEC*0.05;\r
                while (clock() < endTime) ;\r
-               putchar(*s++);\r
+               putchar(*s);\r
                fflush(stdout);\r
        }\r
 }\r