diff --git a/src/client/refresh/files/stb.c b/src/client/refresh/files/stb.c index 8467bd99..7d0929f7 100644 --- a/src/client/refresh/files/stb.c +++ b/src/client/refresh/files/stb.c @@ -598,3 +598,26 @@ GetSkyImage(const char *skyname, const char* surfname, qboolean palettedtexture, return image; } + +struct image_s *GetTexImage(const char *name, findimage_t find_image) +{ + struct image_s *image = NULL; + char pathname[MAX_QPATH]; + + Com_sprintf(pathname, sizeof(pathname), "textures/%s.wal", name); + image = find_image(pathname, it_wall); + + if (!image) + { + Com_sprintf(pathname, sizeof(pathname), "textures/%s.m32", name); + image = find_image(pathname, it_wall); + } + + if (!image) + { + Com_sprintf(pathname, sizeof(pathname), "textures/%s.m8", name); + image = find_image(pathname, it_wall); + } + + return image; +} diff --git a/src/client/refresh/gl1/gl1_model.c b/src/client/refresh/gl1/gl1_model.c index d66b97d8..f98f6147 100644 --- a/src/client/refresh/gl1/gl1_model.c +++ b/src/client/refresh/gl1/gl1_model.c @@ -448,7 +448,6 @@ Mod_LoadTexinfo(model_t *loadmodel, byte *mod_base, lump_t *l) texinfo_t *in; mtexinfo_t *out, *step; int i, j, count; - char name[MAX_QPATH]; int next; in = (void *)(mod_base + l->fileofs); @@ -467,6 +466,8 @@ Mod_LoadTexinfo(model_t *loadmodel, byte *mod_base, lump_t *l) for (i = 0; i < count; i++, in++, out++) { + image_t *image; + for (j = 0; j < 4; j++) { out->vecs[0][j] = LittleFloat(in->vecs[0][j]); @@ -485,21 +486,15 @@ Mod_LoadTexinfo(model_t *loadmodel, byte *mod_base, lump_t *l) out->next = NULL; } - Com_sprintf(name, sizeof(name), "textures/%s.wal", in->texture); + image = GetTexImage(in->texture, (findimage_t)R_FindImageUnsafe); - out->image = R_FindImage(name, it_wall); - - if (!out->image || out->image == r_notexture) + if (!image) { - Com_sprintf(name, sizeof(name), "textures/%s.m8", in->texture); - out->image = R_FindImage(name, it_wall); + R_Printf(PRINT_ALL, "Couldn't load %s\n", in->texture); + image = r_notexture; } - if (!out->image) - { - R_Printf(PRINT_ALL, "Couldn't load %s\n", name); - out->image = r_notexture; - } + out->image = image; } /* count animation frames */ diff --git a/src/client/refresh/gl3/gl3_model.c b/src/client/refresh/gl3/gl3_model.c index 94f2affa..8e3f8a72 100644 --- a/src/client/refresh/gl3/gl3_model.c +++ b/src/client/refresh/gl3/gl3_model.c @@ -316,7 +316,6 @@ Mod_LoadTexinfo(gl3model_t *loadmodel, byte *mod_base, lump_t *l) texinfo_t *in; mtexinfo_t *out, *step; int i, j, count; - char name[MAX_QPATH]; int next; in = (void *)(mod_base + l->fileofs); @@ -335,6 +334,8 @@ Mod_LoadTexinfo(gl3model_t *loadmodel, byte *mod_base, lump_t *l) for (i = 0; i < count; i++, in++, out++) { + gl3image_t *image; + for (j = 0; j < 4; j++) { out->vecs[0][j] = LittleFloat(in->vecs[0][j]); @@ -353,21 +354,14 @@ Mod_LoadTexinfo(gl3model_t *loadmodel, byte *mod_base, lump_t *l) out->next = NULL; } - Com_sprintf(name, sizeof(name), "textures/%s.wal", in->texture); - - out->image = GL3_FindImage(name, it_wall); - - if (!out->image || out->image == gl3_notexture) + image = GetTexImage(in->texture, (findimage_t)GL3_FindImageUnsafe); + if (!image) { - Com_sprintf(name, sizeof(name), "textures/%s.m8", in->texture); - out->image = GL3_FindImage(name, it_wall); + R_Printf(PRINT_ALL, "Couldn't load %s\n", in->texture); + image = gl3_notexture; } - if (!out->image) - { - R_Printf(PRINT_ALL, "Couldn't load %s\n", name); - out->image = gl3_notexture; - } + out->image = image; } /* count animation frames */ diff --git a/src/client/refresh/ref_shared.h b/src/client/refresh/ref_shared.h index 4ddfa4f2..40b40f05 100644 --- a/src/client/refresh/ref_shared.h +++ b/src/client/refresh/ref_shared.h @@ -114,5 +114,6 @@ extern int Mod_ReLoadSkins(struct image_s **skins, findimage_t find_image, void *extradata, modtype_t type); extern struct image_s *GetSkyImage(const char *skyname, const char* surfname, qboolean palettedtexture, findimage_t find_image); +extern struct image_s *GetTexImage(const char *name, findimage_t find_image); #endif /* SRC_CLIENT_REFRESH_REF_SHARED_H_ */ diff --git a/src/client/refresh/soft/sw_model.c b/src/client/refresh/soft/sw_model.c index 54a26421..7673863b 100644 --- a/src/client/refresh/soft/sw_model.c +++ b/src/client/refresh/soft/sw_model.c @@ -486,7 +486,6 @@ Mod_LoadTexinfo (model_t *loadmodel, byte *mod_base, lump_t *l) texinfo_t *in; mtexinfo_t *out, *step; int i, count; - char name[MAX_QPATH]; in = (void *)(mod_base + l->fileofs); @@ -504,6 +503,7 @@ Mod_LoadTexinfo (model_t *loadmodel, byte *mod_base, lump_t *l) for ( i=0 ; inext = NULL; } - Com_sprintf (name, sizeof(name), "textures/%s.wal", in->texture); - out->image = R_FindImage (name, it_wall); - if (!out->image || out->image == r_notexture_mip) + image = GetTexImage(in->texture, (findimage_t)R_FindImageUnsafe); + if (!image) { - Com_sprintf (name, sizeof(name), "textures/%s.m8", in->texture); - out->image = R_FindImage (name, it_wall); - } - - if (!out->image) - { - out->image = r_notexture_mip; // texture not found + R_Printf(PRINT_ALL, "Couldn't load %s\n", in->texture); + image = r_notexture_mip; out->flags = 0; } + + out->image = image; } // count animation frames