diff --git a/include/QF/model.h b/include/QF/model.h index 308175a5e..89e0b8730 100644 --- a/include/QF/model.h +++ b/include/QF/model.h @@ -89,7 +89,7 @@ typedef struct instsurf_s { } instsurf_t; typedef struct texture_s { - char *name; + char name[16]; unsigned width, height; void *render; // renderer specific data int anim_total; // total tenths in sequence ( 0 = no) diff --git a/libs/models/brush/model_brush.c b/libs/models/brush/model_brush.c index a13ed16ba..7632c07f2 100644 --- a/libs/models/brush/model_brush.c +++ b/libs/models/brush/model_brush.c @@ -219,28 +219,26 @@ Mod_LeafPVS_mix (const mleaf_t *leaf, const model_t *model, byte defvis, static void mod_unique_miptex_name (texture_t **textures, texture_t *tx, int ind) { - char *name; + char name[17]; int num = 0, i; - dstring_t *tag = 0; + const char *tag; - name = tx->name; + strncpy (name, tx->name, 16); + name[16] = 0; do { for (i = 0; i < ind; i++) if (textures[i] && !strcmp (textures[i]->name, tx->name)) break; if (i == ind) break; - if (!tag) { - tag = dstring_new (); - } - dsprintf (tag, "%s~%x", name, num++); - tx->name = tag->str; + tag = va (0, "~%x", num++); + strncpy (tx->name, name, 16); + tx->name[15] = 0; + if (strlen (name) + strlen (tag) <= 15) + strcat (tx->name, tag); + else + strcpy (tx->name + 15 - strlen (tag), tag); } while (1); - - if (tag) { - tx->name = dstring_freeze (tag); - free(name); - } } static void @@ -280,7 +278,7 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp) brush->textures[i] = tx; - tx->name = strndup(mt->name, sizeof (mt->name)); + memcpy (tx->name, mt->name, sizeof (tx->name)); mod_unique_miptex_name (brush->textures, tx, i); tx->width = mt->width; tx->height = mt->height;