]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_dyntexture.c
Rework cl_video to use dyntextures.
[xonotic/darkplaces.git] / cl_dyntexture.c
index f2b6245113245ab2eecc3f9fe577fe6109f99f9d..8ee494640e73c355db0801e22f066e518642e27b 100644 (file)
@@ -15,11 +15,16 @@ static unsigned dyntexturecount;
 \r
 #define DEFAULT_DYNTEXTURE r_texture_grey128\r
 \r
-static dyntexture_t * _CL_FindDynTexture( const char *name ) {\r
+static dyntexture_t * cl_finddyntexture( const char *name ) {\r
        unsigned i;\r
        dyntexture_t *dyntexture = NULL;\r
-       // some sanity checks - and make sure its actually a dynamic texture path\r
-       if( !name || strncmp( name, DYNAMIC_TEXTURE_PATH_PREFIX, sizeof( DYNAMIC_TEXTURE_PATH_PREFIX ) - 1 ) != 0 ) {\r
+\r
+       // sanity checks - make sure its actually a dynamic texture path\r
+       if( !name || !*name || strncmp( name, CLDYNTEXTUREPREFIX, sizeof( CLDYNTEXTUREPREFIX ) - 1 ) != 0 ) {\r
+               // TODO: print a warning or something\r
+               if( developer.integer > 0 ) {\r
+                       Con_Printf( "cl_finddyntexture: Bad dynamic texture name '%s'\n", name );\r
+               }\r
                return NULL;\r
        }\r
 \r
@@ -41,7 +46,7 @@ static dyntexture_t * _CL_FindDynTexture( const char *name ) {
 }\r
 \r
 rtexture_t * CL_GetDynTexture( const char *name ) {\r
-       dyntexture_t *dyntexture = _CL_FindDynTexture( name );\r
+       dyntexture_t *dyntexture = cl_finddyntexture( name );\r
        if( dyntexture ) {\r
                return dyntexture->texture;\r
        } else {\r
@@ -54,26 +59,28 @@ void CL_LinkDynTexture( const char *name, rtexture_t *texture ) {
        cachepic_t *cachepic;\r
        skinframe_t *skinframe;\r
 \r
-       dyntexture = _CL_FindDynTexture( name );\r
+       dyntexture = cl_finddyntexture( name );\r
        // TODO: assert dyntexture != NULL!\r
        if( dyntexture->texture != texture ) {\r
+               dyntexture->texture = texture;\r
+\r
                cachepic = Draw_CachePic( name, false );\r
-               skinframe = R_SkinFrame_Find( name, 0, 0, 0, 0, false );\r
-               // this is kind of hacky\r
                // TODO: assert cachepic and skinframe should be valid pointers...\r
-\r
                // TODO: assert cachepic->tex = dyntexture->texture\r
                cachepic->tex = texture;\r
                // update cachepic's size, too\r
                cachepic->width = R_TextureWidth( texture );\r
                cachepic->height = R_TextureHeight( texture );\r
-               // TODO: assert skinframe->base = dyntexture->texture\r
-               skinframe->base = texture;\r
-               // simply reset the compare* attributes of skinframe\r
-               skinframe->comparecrc = 0;\r
-               skinframe->comparewidth = skinframe->compareheight = 0;\r
 \r
-               dyntexture->texture = texture;\r
+               // update skinframes\r
+               skinframe = NULL;\r
+               while( (skinframe = R_SkinFrame_FindNextByName( skinframe, name )) != NULL ) {\r
+                       skinframe->base = texture;\r
+                       // simply reset the compare* attributes of skinframe\r
+                       skinframe->comparecrc = 0;\r
+                       skinframe->comparewidth = skinframe->compareheight = 0;\r
+                       // this is kind of hacky\r
+               }\r
        }\r
 }\r
 \r