]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added more developer prints when loading shaders
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 11 Jun 2007 17:19:10 +0000 (17:19 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 11 Jun 2007 17:19:10 +0000 (17:19 +0000)
fixed shader loading to refuse empty texture names, this fixes support
for cmt4.bsp which has some unnamed textures

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7405 d7cf8633-e32d-0410-b094-e92efae38249

model_brush.c
model_shared.c

index c09f32a2a9622453fc0aed844aacc01540395d88..bb4ac93b4a72281978b15d497ffe595fb7ab311e 100644 (file)
@@ -1381,7 +1381,10 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l)
        }
 
        if (!m)
+       {
+               Con_Printf("%s: no miptex lump to load textures from\n", loadmodel->name);
                return;
+       }
 
        s = loadmodel->name;
        if (!strncasecmp(s, "maps/", 5))
@@ -1394,8 +1397,13 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l)
        for (i = 0;i < m->nummiptex;i++)
        {
                dofs[i] = LittleLong(dofs[i]);
-               if (dofs[i] == -1 || r_nosurftextures.integer)
+               if (r_nosurftextures.integer)
+                       continue;
+               if (dofs[i] == -1)
+               {
+                       Con_DPrintf("%s: miptex #%i missing\n", loadmodel->name, i);
                        continue;
+               }
                dmiptex = (miptex_t *)((unsigned char *)m + dofs[i]);
 
                // copy name, but only up to 16 characters
@@ -1405,6 +1413,12 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l)
                        name[j] = dmiptex->name[j];
                name[j] = 0;
 
+               if (!name[0])
+               {
+                       sprintf(name, "unnamed%i", i);
+                       Con_Printf("warning: unnamed texture in %s, renaming to %s\n", loadmodel->name, name);
+               }
+
                mtwidth = LittleLong(dmiptex->width);
                mtheight = LittleLong(dmiptex->height);
                mtdata = NULL;
@@ -1428,7 +1442,7 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l)
                        if (name[j] >= 'A' && name[j] <= 'Z')
                                name[j] += 'a' - 'A';
 
-               if (Mod_LoadTextureFromQ3Shader(loadmodel->data_textures + i, name, true, false, false))
+               if (dmiptex->name[0] && Mod_LoadTextureFromQ3Shader(loadmodel->data_textures + i, name, true, false, false))
                        continue;
 
                tx = loadmodel->data_textures + i;
@@ -1436,12 +1450,6 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l)
                tx->width = mtwidth;
                tx->height = mtheight;
 
-               if (!tx->name[0])
-               {
-                       sprintf(tx->name, "unnamed%i", i);
-                       Con_Printf("warning: unnamed texture in %s, renaming to %s\n", loadmodel->name, tx->name);
-               }
-
                if (tx->name[0] == '*')
                {
                        if (!strncmp(tx->name, "*lava", 5))
index 158a6accc2237234c9cff97767e88364c3e8966a..db2c5f98071f62789099d40298077e7f39a3a155 100644 (file)
@@ -1570,9 +1570,11 @@ qboolean Mod_LoadTextureFromQ3Shader(texture_t *texture, const char *name, qbool
        qboolean success = true;
        q3shaderinfo_t *shader;
        strlcpy(texture->name, name, sizeof(texture->name));
-       shader = Mod_LookupQ3Shader(name);
+       shader = name[0] ? Mod_LookupQ3Shader(name) : NULL;
        if (shader)
        {
+               if (developer.integer >= 100)
+                       Con_DPrintf("%s: loaded shader for %s\n", loadmodel->name, name);
                texture->surfaceparms = shader->surfaceparms;
                texture->textureflags = shader->textureflags;
                texture->basematerialflags = 0;
@@ -1682,11 +1684,16 @@ nothing                GL_ZERO GL_ONE
                memcpy(texture->deforms, shader->deforms, sizeof(texture->deforms));
        }
        else if (!strcmp(texture->name, "noshader"))
+       {
+               if (developer.integer >= 100)
+                       Con_DPrintf("%s: using default handler for %s\n", loadmodel->name, name);
                texture->surfaceparms = 0;
+       }
        else
        {
                success = false;
-               Con_DPrintf("%s: No shader found for texture \"%s\"\n", loadmodel->name, texture->name);
+               if (developer.integer >= 100 || loadmodel->type == mod_brushq3)
+                       Con_DPrintf("%s: No shader found for texture \"%s\"\n", loadmodel->name, texture->name);
                texture->surfaceparms = 0;
                if (texture->surfaceflags & Q3SURFACEFLAG_NODRAW)
                        texture->basematerialflags |= MATERIALFLAG_NODRAW | MATERIALFLAG_NOSHADOW;