]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_draw.c
-Added the parameter 'persistent'(naming?) to Draw_CachePic, which decides
[xonotic/darkplaces.git] / gl_draw.c
index 0ab9c19d7920551f53f81998164008b92526dea3..f0b1d40508da475d8a9501ebbf6ced2a740b34a3 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -262,13 +262,14 @@ Draw_CachePic
 ================
 */
 // FIXME: move this to client somehow
-cachepic_t     *Draw_CachePic (char *path)
+cachepic_t     *Draw_CachePic (char *path, qboolean persistent)
 {
        int i, crc, hashkey;
        cachepic_t *pic;
        qpic_t *p;
+       int persistentflag;
 
-       if (!strncmp(CLVIDEOPREFIX, path, sizeof(CLVIDEOPREFIX) - 1)) {
+    if (!strncmp(CLVIDEOPREFIX, path, sizeof(CLVIDEOPREFIX) - 1)) {
                clvideo_t *video;
 
                video = CL_GetVideo(path);
@@ -276,6 +277,12 @@ cachepic_t *Draw_CachePic (char *path)
                        return &video->cpif;
        }
 
+       if (persistent) {
+               persistentflag = TEXF_PRECACHE;
+       } else {
+               persistentflag = 0;
+       }
+
        crc = CRC_Block(path, strlen(path));
        hashkey = ((crc >> 8) ^ crc) % CACHEPICHASHSIZE;
        for (pic = cachepichash[hashkey];pic;pic = pic->chain)
@@ -291,11 +298,11 @@ cachepic_t        *Draw_CachePic (char *path)
        cachepichash[hashkey] = pic;
 
        // load the pic from disk
-       pic->tex = loadtextureimage(drawtexturepool, path, 0, 0, false, TEXF_ALPHA | TEXF_PRECACHE);
+       pic->tex = loadtextureimage(drawtexturepool, path, 0, 0, false, TEXF_ALPHA | persistentflag);
        if (pic->tex == NULL && !strncmp(path, "gfx/", 4))
        {
                // compatibility with older versions
-               pic->tex = loadtextureimage(drawtexturepool, path + 4, 0, 0, false, TEXF_ALPHA | TEXF_PRECACHE);
+               pic->tex = loadtextureimage(drawtexturepool, path + 4, 0, 0, false, TEXF_ALPHA | persistentflag);
                // failed to find gfx/whatever.tga or similar, try the wad
                if (pic->tex == NULL && (p = W_GetLumpName (path + 4)))
                {
@@ -307,10 +314,10 @@ cachepic_t        *Draw_CachePic (char *path)
                                for (i = 0;i < 128 * 128;i++)
                                        if (pix[i] == 0)
                                                pix[i] = 255;
-                               pic->tex = R_LoadTexture2D(drawtexturepool, path, 128, 128, pix, TEXTYPE_PALETTE, TEXF_ALPHA | TEXF_PRECACHE, palette_complete);
+                               pic->tex = R_LoadTexture2D(drawtexturepool, path, 128, 128, pix, TEXTYPE_PALETTE, TEXF_ALPHA | persistentflag, palette_complete);
                        }
                        else
-                               pic->tex = R_LoadTexture2D(drawtexturepool, path, p->width, p->height, p->data, TEXTYPE_PALETTE, TEXF_ALPHA | TEXF_PRECACHE, palette_complete);
+                               pic->tex = R_LoadTexture2D(drawtexturepool, path, p->width, p->height, p->data, TEXTYPE_PALETTE, TEXF_ALPHA | persistentflag, palette_complete);
                }
        }
 
@@ -416,7 +423,7 @@ static void gl_draw_start(void)
        numcachepics = 0;
        memset(cachepichash, 0, sizeof(cachepichash));
 
-       char_texture = Draw_CachePic("gfx/conchars")->tex;
+       char_texture = Draw_CachePic("gfx/conchars", true)->tex;
 }
 
 static void gl_draw_shutdown(void)