From 701cc864c1aa7ac306857dc917dc3f95d42707fb Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 9 Apr 2018 05:01:24 +0000 Subject: [PATCH] Added R_SkinFrame_PurgeSkinFrame to de-duplicate some repeated code. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12378 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=fc2ec8a05d6ced30a4f3840752566f9460227247 --- gl_rmain.c | 49 +++++++++++++++++++------------------------------ render.h | 1 + 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index ad0e5f5b..a1c90f0a 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -3129,6 +3129,23 @@ void R_SkinFrame_MarkUsed(skinframe_t *skinframe) skinframe->loadsequence = r_skinframe.loadsequence; } +void R_SkinFrame_PurgeSkinFrame(skinframe_t *s) +{ + if (s->merged == s->base) + s->merged = NULL; + R_PurgeTexture(s->stain); s->stain = NULL; + R_PurgeTexture(s->merged); s->merged = NULL; + R_PurgeTexture(s->base); s->base = NULL; + R_PurgeTexture(s->pants); s->pants = NULL; + R_PurgeTexture(s->shirt); s->shirt = NULL; + R_PurgeTexture(s->nmap); s->nmap = NULL; + R_PurgeTexture(s->gloss); s->gloss = NULL; + R_PurgeTexture(s->glow); s->glow = NULL; + R_PurgeTexture(s->fog); s->fog = NULL; + R_PurgeTexture(s->reflect); s->reflect = NULL; + s->loadsequence = 0; +} + void R_SkinFrame_Purge(void) { int i; @@ -3138,22 +3155,7 @@ void R_SkinFrame_Purge(void) for (s = r_skinframe.hash[i];s;s = s->next) { if (s->loadsequence && s->loadsequence != r_skinframe.loadsequence) - { - if (s->merged == s->base) - s->merged = NULL; - // FIXME: maybe pass a pointer to the pointer to R_PurgeTexture and reset it to NULL inside? [11/29/2007 Black] - R_PurgeTexture(s->stain );s->stain = NULL; - R_PurgeTexture(s->merged);s->merged = NULL; - R_PurgeTexture(s->base );s->base = NULL; - R_PurgeTexture(s->pants );s->pants = NULL; - R_PurgeTexture(s->shirt );s->shirt = NULL; - R_PurgeTexture(s->nmap );s->nmap = NULL; - R_PurgeTexture(s->gloss );s->gloss = NULL; - R_PurgeTexture(s->glow );s->glow = NULL; - R_PurgeTexture(s->fog );s->fog = NULL; - R_PurgeTexture(s->reflect);s->reflect = NULL; - s->loadsequence = 0; - } + R_SkinFrame_PurgeSkinFrame(s); } } } @@ -3218,20 +3220,7 @@ skinframe_t *R_SkinFrame_Find(const char *name, int textureflags, int comparewid dyntexture = CL_GetDynTexture( basename ); if (!add && !dyntexture) return NULL; - if (item->merged == item->base) - item->merged = NULL; - // FIXME: maybe pass a pointer to the pointer to R_PurgeTexture and reset it to NULL inside? [11/29/2007 Black] - R_PurgeTexture(item->stain );item->stain = NULL; - R_PurgeTexture(item->merged);item->merged = NULL; - R_PurgeTexture(item->base );item->base = NULL; - R_PurgeTexture(item->pants );item->pants = NULL; - R_PurgeTexture(item->shirt );item->shirt = NULL; - R_PurgeTexture(item->nmap );item->nmap = NULL; - R_PurgeTexture(item->gloss );item->gloss = NULL; - R_PurgeTexture(item->glow );item->glow = NULL; - R_PurgeTexture(item->fog );item->fog = NULL; - R_PurgeTexture(item->reflect);item->reflect = NULL; - item->loadsequence = 0; + R_SkinFrame_PurgeSkinFrame(item); } else if( item->base == NULL ) { diff --git a/render.h b/render.h index 32a607f3..e049dbc0 100644 --- a/render.h +++ b/render.h @@ -139,6 +139,7 @@ r_refdef_scene_t * R_GetScenePointer( r_refdef_scene_type_t scenetype ); void R_SkinFrame_PrepareForPurge(void); void R_SkinFrame_MarkUsed(skinframe_t *skinframe); +void R_SkinFrame_PurgeSkinFrame(skinframe_t *skinframe); void R_SkinFrame_Purge(void); // set last to NULL to start from the beginning skinframe_t *R_SkinFrame_FindNextByName( skinframe_t *last, const char *name ); -- 2.39.2