- Add a warning level for debug(), defaults to on in debug mode
 - Remove the padding for debug messages
 - Modified loadFile2 the way I intended it to work

Notes:
I guess some LOG_ERROR messages could then be changed to LOG_WARNING.

The build system might not recompile every file dependent on debug.h,
then you'll get some LOG_NEVER messages instead of LOG_ERROR because of
the changed enum (happened to me).

-- 
It's better to be quotable than to be honest.
                -- Tom Stoppard
Index: lib/framework/debug.c
===================================================================
--- lib/framework/debug.c       (revision 422)
+++ lib/framework/debug.c       (working copy)
@@ -24,8 +24,20 @@
 
 /* This list _must_ match the enum in debug.h! */
 static const char *code_part_names[] = {
-  "all", "main", "sound", "video", "wz", "3d", "texture",
-  "net", "memory", "error", "never", "script", "last"
+  "all",
+  "main",
+  "sound",
+  "video",
+  "wz",
+  "3d",
+  "texture",
+  "net",
+  "memory",
+  "warning",
+  "error",
+  "never",
+  "script",
+  "last"
 };
 
 /**********************************************************************
@@ -187,6 +199,9 @@
        }
        memset( enabled_debug_parts, FALSE, sizeof(enabled_debug_parts) );
        enabled_debug_parts[LOG_ERROR] = TRUE;
+#ifdef DEBUG
+       enabled_debug_parts[LOG_WARNING] = TRUE;
+#endif
 }
 
 
@@ -313,7 +328,7 @@
                // Assemble the outputBuffer:
                sprintf( outputBuffer, "%s:", code_part_names[part] );
                memset( outputBuffer + strlen( code_part_names[part] ) + 1, ' 
', MAX_LEN_DEBUG_PART - strlen( code_part_names[part] ) - 1 ); // Fill with 
whitespaces
-               snprintf( outputBuffer + MAX_LEN_DEBUG_PART, MAX_LEN_LOG_LINE, 
useInputBuffer1 ? inputBuffer[1] : inputBuffer[0] ); // Append the message
+               snprintf( outputBuffer + strlen(code_part_names[part]) + 2, 
MAX_LEN_LOG_LINE, useInputBuffer1 ? inputBuffer[1] : inputBuffer[0] ); // 
Append the message
 
                while (curCallback)
                {
Index: lib/framework/debug.h
===================================================================
--- lib/framework/debug.h       (revision 422)
+++ lib/framework/debug.h       (working copy)
@@ -106,6 +106,7 @@
   LOG_TEXTURE,
   LOG_NET,
   LOG_MEMORY,
+  LOG_WARNING, /* special; on in debug mode */
   LOG_ERROR, /* special; on by default */
   LOG_NEVER, /* if too verbose for anything but dedicated debugging... */
   LOG_SCRIPT,
Index: lib/framework/frame.c
===================================================================
--- lib/framework/frame.c       (revision 422)
+++ lib/framework/frame.c       (working copy)
@@ -459,9 +459,12 @@
 
        pfile = PHYSFS_openRead(pFileName);
        if (!pfile) {
-               debug(LOG_ERROR, "loadFile2: %s could not be opened: %s", 
pFileName, PHYSFS_getLastError());
-               if (hard_fail)
+               if (hard_fail) {
+                       debug(LOG_ERROR, "loadFile2: file %s could not be 
opened: %s", pFileName, PHYSFS_getLastError());
                        assert(FALSE);
+               } else {
+                       debug(LOG_WARNING, "loadFile2: optional file %s could 
not be opened: %s", pFileName, PHYSFS_getLastError());
+               }
                return FALSE;
        }
        filesize = PHYSFS_fileLength(pfile);
_______________________________________________
Warzone-dev mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-dev

Reply via email to