]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - common.c
added DrawQ_SuperPic, fixed severe bug in DrawQ_Mesh (was not allocating enough room...
[xonotic/darkplaces.git] / common.c
index 0f413b2ddde0cc493ed19b662cfde10571388041..9e549fe7dd8ab781a66172792d409221deba64f8 100644 (file)
--- a/common.c
+++ b/common.c
@@ -375,7 +375,7 @@ char *MSG_ReadString (void)
                        break;
                string[l] = c;
                l++;
-       } while (l < sizeof(string)-1);
+       } while (l < (int)sizeof(string)-1);
 
        string[l] = 0;
 
@@ -467,52 +467,61 @@ void SZ_Print (sizebuf_t *buf, const char *data)
 }
 
 static char *hexchar = "0123456789ABCDEF";
-void SZ_HexDumpToConsole(const sizebuf_t *buf)
+void Com_HexDumpToConsole(const qbyte *data, int size)
 {
-       int i;
+       int i, j, n;
        char text[1024];
        char *cur, *flushpointer;
+       const qbyte *d;
        cur = text;
        flushpointer = text + 512;
-       for (i = 0;i < buf->cursize;i++)
+       for (i = 0;i < size;)
        {
-               if ((i & 15) == 0)
+               n = 16;
+               if (n > size - i)
+                       n = size - i;
+               d = data + i;
+               *cur++ = hexchar[(i >> 12) & 15];
+               *cur++ = hexchar[(i >>  8) & 15];
+               *cur++ = hexchar[(i >>  4) & 15];
+               *cur++ = hexchar[(i >>  0) & 15];
+               *cur++ = ':';
+               for (j = 0;j < n;j++)
                {
-                       *cur++ = hexchar[(i >> 12) & 15];
-                       *cur++ = hexchar[(i >>  8) & 15];
-                       *cur++ = hexchar[(i >>  4) & 15];
-                       *cur++ = hexchar[(i >>  0) & 15];
-                       *cur++ = ':';
-                       *cur++ = ' ';
-               }
-               else if ((i & 15) == 15)
-                       *cur++ = '\n';
-               else
-                       *cur++ = ' ';
-               if (i & 1)
-               {
-                       *cur++ = hexchar[(buf->data[i] >> 4) & 15] | 0x80;
-                       *cur++ = hexchar[(buf->data[i] >> 0) & 15] | 0x80;
+                       if (j & 1)
+                       {
+                               *cur++ = hexchar[(d[j] >> 4) & 15] | 0x80;
+                               *cur++ = hexchar[(d[j] >> 0) & 15] | 0x80;
+                       }
+                       else
+                       {
+                               *cur++ = hexchar[(d[j] >> 4) & 15];
+                               *cur++ = hexchar[(d[j] >> 0) & 15];
+                       }
                }
-               else
+               for (;j < 16;j++)
                {
-                       *cur++ = hexchar[(buf->data[i] >> 4) & 15];
-                       *cur++ = hexchar[(buf->data[i] >> 0) & 15];
+                       *cur++ = ' ';
+                       *cur++ = ' ';
                }
-               if (cur >= flushpointer)
+               for (j = 0;j < n;j++)
+                       *cur++ = (d[j] >= ' ' && d[j] <= 0x7E) ? d[j] : '.';
+               for (;j < 16;j++)
+                       *cur++ = ' ';
+               *cur++ = '\n';
+               i += n;
+               if (cur >= flushpointer || i >= size)
                {
                        *cur++ = 0;
                        Con_Printf("%s", text);
                        cur = text;
                }
        }
-       if ((i & 15) != 0)
-               *cur++ = '\n';
-       if (cur > text)
-       {
-               *cur++ = 0;
-               Con_Printf("%s", text);
-       }
+}
+
+void SZ_HexDumpToConsole(const sizebuf_t *buf)
+{
+       Com_HexDumpToConsole(buf->data, buf->cursize);
 }
 
 
@@ -795,6 +804,8 @@ void COM_InitGameType (void)
 
        if (strstr(name, "transfusion"))
                gamemode = GAME_TRANSFUSION;
+       else if (strstr(name, "nexiuz"))
+               gamemode = GAME_NEXIUZ;
        else if (strstr(name, "nehahra"))
                gamemode = GAME_NEHAHRA;
        else if (strstr(name, "hipnotic"))
@@ -806,6 +817,8 @@ void COM_InitGameType (void)
 
        if (COM_CheckParm ("-transfusion"))
                gamemode = GAME_TRANSFUSION;
+       else if (COM_CheckParm ("-nexiuz"))
+               gamemode = GAME_NEXIUZ;
        else if (COM_CheckParm ("-nehahra"))
                gamemode = GAME_NEHAHRA;
        else if (COM_CheckParm ("-hipnotic"))
@@ -833,6 +846,10 @@ void COM_InitGameType (void)
                gamename = "DarkPlaces-Nehahra";
                gamedirname = "nehahra";
                break;
+       case GAME_NEXIUZ:
+               gamename = "Nexiuz";
+               gamedirname = "data";
+               break;
        case GAME_TRANSFUSION:
                gamename = "Transfusion";
                gamedirname = "transfusion";
@@ -1083,7 +1100,7 @@ void COM_CopyFile (char *netpath, char *cachepath)
 
        while (remaining)
        {
-               if (remaining < sizeof(buf))
+               if (remaining < (int)sizeof(buf))
                        count = remaining;
                else
                        count = sizeof(buf);