From 907ce24e48004d0a36e33a5e3a4481bcba49c4e0 Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 7 Jun 2006 08:49:56 +0000 Subject: [PATCH] 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 --- gl_rmain.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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; } -- 2.39.2