shithub: choc

Download patch

ref: 9e165649eb624ece3a0509841016d5e5c3eb2ddf
parent: 7577bb4156c0a75528a2901cf086c9c547467484
author: Simon Howard <fraggle@gmail.com>
date: Sat Feb 9 17:31:02 EST 2008

Fix up the R_Main startup progress dots. If stdout is a file, don't
display the surrounding box.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1069

--- a/src/i_system.c
+++ b/src/i_system.c
@@ -99,6 +99,21 @@
     return zonemem;
 }
 
+// 
+// I_ConsoleStdout
+//
+// Returns true if stdout is a real console, false if it is a file
+//
+
+boolean I_ConsoleStdout(void)
+{
+#ifdef _WIN32
+    // SDL "helpfully" always redirects stdout to a file.
+    return 0;
+#else
+    return isatty(fileno(stdout));
+#endif
+}
 
 //
 // I_Init
--- a/src/i_system.h
+++ b/src/i_system.h
@@ -41,7 +41,9 @@
 // for the zone management.
 byte*	I_ZoneBase (int *size);
 
+boolean I_ConsoleStdout(void);
 
+
 // Called by D_DoomLoop,
 // called before processing any tics in a frame
 // (just after displaying a frame).
@@ -86,3 +88,4 @@
 
 
 #endif
+
--- a/src/r_data.c
+++ b/src/r_data.c
@@ -529,13 +529,20 @@
     temp1 = W_GetNumForName (DEH_String("S_START"));  // P_???????
     temp2 = W_GetNumForName (DEH_String("S_END")) - 1;
     temp3 = ((temp2-temp1+63)/64) + ((numtextures+63)/64);
-    printf("[");
-    for (i = 0; i < temp3; i++)
-	printf(" ");
-    printf("         ]");
-    for (i = 0; i < temp3; i++)
-	printf("\x8");
-    printf("\x8\x8\x8\x8\x8\x8\x8\x8\x8\x8");	
+
+    // If stdout is a real console, use the classic vanilla "filling
+    // up the box" effect, which uses backspace to "step back" inside
+    // the box.  If stdout is a file, don't draw the box.
+
+    if (I_ConsoleStdout())
+    {
+        printf("[");
+        for (i = 0; i < temp3 + 9; i++)
+            printf(" ");
+        printf("]");
+        for (i = 0; i < temp3 + 10; i++)
+            printf("\b");
+    }
 	
     for (i=0 ; i<numtextures ; i++, directory++)
     {