]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fixed crash when ent->skinnum >= model->numskins
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 29 Aug 2002 12:45:24 +0000 (12:45 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 29 Aug 2002 12:45:24 +0000 (12:45 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2309 d7cf8633-e32d-0410-b094-e92efae38249

gl_models.c

index b947c34ec2deafe9975e8e446862895aa9206aeb..fc23da5249e5d61bf8e459a96bca5d17d72afebf 100644 (file)
@@ -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)