From 5c351a00804cee0cf6fd642ed16b03e719f7a953 Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 29 Aug 2002 12:45:24 +0000 Subject: [PATCH] fixed crash when ent->skinnum >= model->numskins git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2309 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_models.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gl_models.c b/gl_models.c index b947c34e..fc23da52 100644 --- a/gl_models.c +++ b/gl_models.c @@ -203,10 +203,13 @@ void R_AliasLerpVerts(int vertcount, skinframe_t *R_FetchSkinFrame(const entity_render_t *ent) { model_t *model = ent->model; - if (model->skinscenes[ent->skinnum].framecount > 1) - return &model->skinframes[model->skinscenes[ent->skinnum].firstframe + (int) (cl.time * 10) % model->skinscenes[ent->skinnum].framecount]; + unsigned int s = (unsigned int) ent->skinnum; + if (s >= model->numskins) + s = 0; + if (model->skinscenes[s].framecount > 1) + return &model->skinframes[model->skinscenes[s].firstframe + (int) (cl.time * 10) % model->skinscenes[s].framecount]; else - return &model->skinframes[model->skinscenes[ent->skinnum].firstframe]; + return &model->skinframes[model->skinscenes[s].firstframe]; } void R_SetupMDLMD2Frames(const entity_render_t *ent, float colorr, float colorg, float colorb) -- 2.39.2