From: havoc Date: Wed, 7 Jun 2006 08:49:56 +0000 (+0000) Subject: don't crash if a quake button entity is on its alternate frames but doesn't actually... X-Git-Tag: xonotic-v0.1.0preview~3941 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=907ce24e48004d0a36e33a5e3a4481bcba49c4e0;p=xonotic%2Fdarkplaces.git don't crash if a quake button entity is on its alternate frames but doesn't actually have any to show git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6435 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/gl_rmain.c b/gl_rmain.c index 82a25ff2..effd5fdd 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -2169,7 +2169,14 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t) if (s > 0) t = t + s * model->num_surfaces; if (t->animated) - t = t->anim_frames[ent->frame != 0][(t->anim_total[ent->frame != 0] >= 2) ? ((int)(r_refdef.time * 5.0f) % t->anim_total[ent->frame != 0]) : 0]; + { + // use an alternate animation if the entity's frame is not 0, + // and only if the texture has an alternate animation + if (ent->frame != 0 && t->anim_total[1]) + t = t->anim_frames[1][(t->anim_total[1] >= 2) ? ((int)(r_refdef.time * 5.0f) % t->anim_total[1]) : 0]; + else + t = t->anim_frames[0][(t->anim_total[0] >= 2) ? ((int)(r_refdef.time * 5.0f) % t->anim_total[0]) : 0]; + } texture->currentframe = t; }