From: havoc Date: Wed, 21 Oct 2009 18:20:49 +0000 (+0000) Subject: don't emit obj materials more than once X-Git-Tag: xonotic-v0.1.0preview~1266 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ffeef0387e6935e805cf0d264758fd8a00c44731;p=xonotic%2Fdarkplaces.git don't emit obj materials more than once git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9372 d7cf8633-e32d-0410-b094-e92efae38249 --- 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) {