From: havoc Date: Thu, 29 Aug 2002 12:45:24 +0000 (+0000) Subject: fixed crash when ent->skinnum >= model->numskins X-Git-Tag: RELEASE_0_2_0_RC1~295 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5c351a00804cee0cf6fd642ed16b03e719f7a953;p=xonotic%2Fdarkplaces.git fixed crash when ent->skinnum >= model->numskins git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2309 d7cf8633-e32d-0410-b094-e92efae38249 --- 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)