]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_draw.c
Fixed a bug by me regarding the filesize of the embedded font.
[xonotic/darkplaces.git] / gl_draw.c
index 5c1fe52cea3a2bd1def73a7f64ada100c38a34d9..6e6654631e09928e6089ec6dab015382376ead4f 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -30,6 +30,7 @@ static rtexture_t *char_texture;
 //=============================================================================
 /* Support Routines */
 
+#define FONT_FILESIZE 13468
 #define MAX_CACHED_PICS 256
 #define CACHEPICHASHSIZE 256
 static cachepic_t *cachepichash[CACHEPICHASHSIZE];
@@ -38,7 +39,7 @@ static int numcachepics;
 
 static rtexturepool_t *drawtexturepool;
 
-static qbyte concharimage[13396] =
+static qbyte concharimage[FONT_FILESIZE] =
 {
 #include "lhfont.h"
 };
@@ -51,7 +52,7 @@ static rtexture_t *draw_generateconchars(void)
        qbyte buffer[65536][4], *data = NULL;
        double random;
 
-       fs_filesize = 13396;
+       fs_filesize = FONT_FILESIZE;
        data = LoadTGA (concharimage, 256, 256);
        fs_filesize = -1;
 // Gold numbers
@@ -91,6 +92,10 @@ static rtexture_t *draw_generateconchars(void)
                buffer[i][3] = data[i*4+0];
        }
 
+#if 0
+       Image_WriteTGARGBA ("gfx/generated_conchars.tga", 256, 256, &buffer[0][0]);
+#endif
+
        Mem_Free(data);
        return R_LoadTexture2D(drawtexturepool, "conchars", 256, 256, &buffer[0][0], TEXTYPE_RGBA, TEXF_ALPHA | TEXF_PRECACHE, NULL);
 }
@@ -306,7 +311,11 @@ cachepic_t *Draw_CachePic (const char *path, qboolean persistent)
                        return pic;
 
        if (numcachepics == MAX_CACHED_PICS)
-               Sys_Error ("numcachepics == MAX_CACHED_PICS");
+       {
+               Con_Printf ("Draw_CachePic: numcachepics == MAX_CACHED_PICS");
+               // FIXME: support NULL in callers?
+               return cachepics; // return the first one
+       }
        pic = cachepics + (numcachepics++);
        strlcpy (pic->name, path, sizeof(pic->name));
        // link into list
@@ -396,7 +405,11 @@ cachepic_t *Draw_NewPic(const char *picname, int width, int height, int alpha, q
                if (pic == NULL)
                {
                        if (numcachepics == MAX_CACHED_PICS)
-                               Sys_Error ("numcachepics == MAX_CACHED_PICS");
+                       {
+                               Con_Printf ("Draw_NewPic: numcachepics == MAX_CACHED_PICS");
+                               // FIXME: support NULL in callers?
+                               return cachepics; // return the first one
+                       }
                        pic = cachepics + (numcachepics++);
                        strcpy (pic->name, picname);
                        // link into list