Allow uncaching of qpics.

qpics loaded via Draw_CachePic can now be uncached via Draw_UncachePic.
This commit is contained in:
Bill Currie 2012-02-01 16:55:35 +09:00
parent a849cf7698
commit 7e406c20e5
5 changed files with 75 additions and 6 deletions

View file

@ -175,6 +175,14 @@ void Draw_BlendScreen (quat_t color);
*/ */
qpic_t *Draw_CachePic (const char *path, qboolean alpha); qpic_t *Draw_CachePic (const char *path, qboolean alpha);
/** Remove a qpic from the qpic cache.
This affects only those qpics that were loaded via Draw_CachePic.
\param path path of the file within the quake filesystem
*/
void Draw_UncachePic (const char *path);
/** Load a qpic from gfx.wad. /** Load a qpic from gfx.wad.
\param name name of the was lump to load \param name name of the was lump to load
\return pointer qpic data. \return pointer qpic data.

View file

@ -249,6 +249,21 @@ Draw_CachePic (const char *path, qboolean alpha)
return &pic->pic; return &pic->pic;
} }
VISIBLE void
Draw_UncachePic (const char *path)
{
cachepic_t *pic;
int i;
//FIXME chachpic and uncachepic suck in GL
for (pic = cachepics, i = 0; i < numcachepics; pic++, i++) {
if ((!strcmp (path, pic->name)) && !pic->dirty) {
pic->dirty = true;
return;
}
}
}
VISIBLE void VISIBLE void
Draw_TextBox (int x, int y, int width, int lines, byte alpha) Draw_TextBox (int x, int y, int width, int lines, byte alpha)
{ {

View file

@ -299,6 +299,12 @@ Draw_CachePic (const char *path, qboolean alpha)
return pic; return pic;
} }
VISIBLE void
Draw_UncachePic (const char *path)
{
Hash_Free (pic_cache, Hash_Del (pic_cache, path));
}
VISIBLE void VISIBLE void
Draw_TextBox (int x, int y, int width, int lines, byte alpha) Draw_TextBox (int x, int y, int width, int lines, byte alpha)
{ {

View file

@ -112,10 +112,15 @@ Draw_CachePic (const char *path, qboolean alpha)
if (!strcmp (path, pic->name)) if (!strcmp (path, pic->name))
break; break;
if (i == numcachepics) {
for (pic = cachepics, i = 0; i < numcachepics; pic++, i++)
if (!pic->name[0])
break;
if (i == numcachepics) { if (i == numcachepics) {
if (numcachepics == MAX_CACHED_PICS) if (numcachepics == MAX_CACHED_PICS)
Sys_Error ("numcachepics == MAX_CACHED_PICS"); Sys_Error ("numcachepics == MAX_CACHED_PICS");
numcachepics++; numcachepics++;
}
strcpy (pic->name, path); strcpy (pic->name, path);
} }
@ -137,6 +142,21 @@ Draw_CachePic (const char *path, qboolean alpha)
return dat; return dat;
} }
VISIBLE void
Draw_UncachePic (const char *path)
{
cachepic_t *pic;
int i;
for (pic = cachepics, i = 0; i < numcachepics; pic++, i++) {
if (!strcmp (path, pic->name)) {
Cache_Release (&pic->cache);
pic->name[0] = 0;
break;
}
}
}
VISIBLE void VISIBLE void
Draw_TextBox (int x, int y, int width, int lines, byte alpha) Draw_TextBox (int x, int y, int width, int lines, byte alpha)

View file

@ -112,10 +112,15 @@ Draw_CachePic (const char *path, qboolean alpha)
if (!strcmp (path, pic->name)) if (!strcmp (path, pic->name))
break; break;
if (i == numcachepics) {
for (pic = cachepics, i = 0; i < numcachepics; pic++, i++)
if (!pic->name[0])
break;
if (i == numcachepics) { if (i == numcachepics) {
if (numcachepics == MAX_CACHED_PICS) if (numcachepics == MAX_CACHED_PICS)
Sys_Error ("numcachepics == MAX_CACHED_PICS"); Sys_Error ("numcachepics == MAX_CACHED_PICS");
numcachepics++; numcachepics++;
}
strcpy (pic->name, path); strcpy (pic->name, path);
} }
@ -137,6 +142,21 @@ Draw_CachePic (const char *path, qboolean alpha)
return dat; return dat;
} }
VISIBLE void
Draw_UncachePic (const char *path)
{
cachepic_t *pic;
int i;
for (pic = cachepics, i = 0; i < numcachepics; pic++, i++) {
if (!strcmp (path, pic->name)) {
Cache_Release (&pic->cache);
pic->name[0] = 0;
break;
}
}
}
VISIBLE void VISIBLE void
Draw_TextBox (int x, int y, int width, int lines, byte alpha) Draw_TextBox (int x, int y, int width, int lines, byte alpha)