From ffeef0387e6935e805cf0d264758fd8a00c44731 Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 21 Oct 2009 18:20:49 +0000 Subject: [PATCH] don't emit obj materials more than once git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9372 d7cf8633-e32d-0410-b094-e92efae38249 --- model_shared.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/model_shared.c b/model_shared.c index ac16b9ac..d46e2baf 100644 --- a/model_shared.c +++ b/model_shared.c @@ -2534,13 +2534,14 @@ static void Mod_Decompile_OBJ(dp_model_t *model, const char *filename, const cha countvertices += surface->num_vertices; countfaces += surface->num_triangles; texname = (surface->texture && surface->texture->name[0]) ? surface->texture->name : "default"; - for (textureindex = 0;textureindex < maxtextures && texturenames[textureindex*MAX_QPATH];textureindex++) + for (textureindex = 0;textureindex < counttextures;textureindex++) if (!strcmp(texturenames + textureindex * MAX_QPATH, texname)) break; + if (textureindex < counttextures) + continue; // already wrote this material entry if (textureindex >= maxtextures) continue; // just a precaution - if (counttextures < textureindex + 1) - counttextures = textureindex + 1; + textureindex = counttextures++; strlcpy(texturenames + textureindex * MAX_QPATH, texname, MAX_QPATH); if (outbufferpos >= outbuffermax >> 1) { -- 2.39.2