]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_draw.c
fix two types to hopefulyl compile on MSVC
[xonotic/darkplaces.git] / gl_draw.c
index f2c4f0192023433f73c83b56c3acdfb48128823f..6b5c76222ba1ec9d8d902d0569c82804d64ff059 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -331,10 +331,15 @@ cachepic_t *Draw_CachePic_Flags(const char *path, unsigned int cachepicflags)
        hashkey = ((crc >> 8) ^ crc) % CACHEPICHASHSIZE;
        for (pic = cachepichash[hashkey];pic;pic = pic->chain)
                if (!strcmp (path, pic->name))
-                       if(pic->texflags == texflags)
+                       if(!((pic->texflags ^ texflags) & ~(TEXF_COMPRESS))) // ignore TEXF_COMPRESS when comparing, because fallback pics remove the flag
                        {
                                if(!(cachepicflags & CACHEPICFLAG_NOTPERSISTENT))
-                                       pic->autoload = false; // persist it
+                               {
+                                       if(pic->tex)
+                                               pic->autoload = false; // persist it
+                                       else
+                                               goto reload; // load it below, and then persist
+                               }
                                return pic;
                        }
 
@@ -350,6 +355,7 @@ cachepic_t *Draw_CachePic_Flags(const char *path, unsigned int cachepicflags)
        pic->chain = cachepichash[hashkey];
        cachepichash[hashkey] = pic;
 
+reload:
        // check whether it is an dynamic texture (if so, we can directly use its texture handler)
        pic->tex = CL_GetDynTexture( path );
        // if so, set the width/height, too
@@ -536,7 +542,7 @@ cachepic_t *Draw_NewPic(const char *picname, int width, int height, int alpha, u
        pic->height = height;
        if (pic->tex)
                R_FreeTexture(pic->tex);
-       pic->tex = R_LoadTexture2D(drawtexturepool, picname, width, height, pixels_bgra, TEXTYPE_BGRA, (alpha ? TEXF_ALPHA : 0) | TEXF_ALLOWUPDATES, -1, NULL);
+       pic->tex = R_LoadTexture2D(drawtexturepool, picname, width, height, pixels_bgra, TEXTYPE_BGRA, (alpha ? TEXF_ALPHA : 0), -1, NULL);
        return pic;
 }
 
@@ -888,10 +894,28 @@ static void LoadFont_f(void)
                                        voffset = atof(Cmd_Argv(i));
                                continue;
                        }
+
+                       if (sizes == -1)
+                               continue; // no slot for other sizes
+
                        // parse one of sizes
                        sz = atof(Cmd_Argv(i));
                        if (sz > 0.001f && sz < 1000.0f) // do not use crap sizes
                        {
+                               // search for duplicated sizes
+                               int j;
+                               for (j=0; j<sizes; j++)
+                                       if (f->req_sizes[j] == sz)
+                                               break;
+                               if (j != sizes)
+                                       continue; // sz already in req_sizes, don't add it again
+
+                               if (sizes == MAX_FONT_SIZES)
+                               {
+                                       Con_Printf("Warning: specified more than %i different font sizes, exceding ones are ignored\n", MAX_FONT_SIZES);
+                                       sizes = -1;
+                                       continue;
+                               }
                                f->req_sizes[sizes] = sz;
                                sizes++;
                        }
@@ -1051,7 +1075,6 @@ void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, flo
        _DrawQ_SetupAndProcessDrawFlag(flags, pic, alpha);
        if(!r_draw2d.integer && !r_draw2d_force)
                return;
-
        GL_Color(red, green, blue, alpha);
 
        R_Mesh_VertexPointer(floats, 0, 0);
@@ -1109,7 +1132,6 @@ void DrawQ_RotPic(float x, float y, cachepic_t *pic, float width, float height,
        _DrawQ_SetupAndProcessDrawFlag(flags, pic, alpha);
        if(!r_draw2d.integer && !r_draw2d_force)
                return;
-
        GL_Color(red, green, blue, alpha);
 
        R_Mesh_VertexPointer(floats, 0, 0);
@@ -1160,7 +1182,6 @@ void DrawQ_Fill(float x, float y, float width, float height, float red, float gr
        _DrawQ_SetupAndProcessDrawFlag(flags, NULL, alpha);
        if(!r_draw2d.integer && !r_draw2d_force)
                return;
-
        GL_Color(red, green, blue, alpha);
 
        R_Mesh_VertexPointer(floats, 0, 0);