From e63a0114bbd617c020c6217f5e1fe1145b1d2c78 Mon Sep 17 00:00:00 2001 From: divverent Date: Fri, 24 Sep 2010 21:37:43 +0000 Subject: [PATCH] Fix a possible crash when an invalid skinframe gets accessed after cl.time steps backwards (e.g. due to time syncing) right after an entity has been created. Might fix the steel storm crash, but certainly IS a segfault on unstable network connection. Note that a%b can be negative for a<0, b>0 (unlike mathematical 'mod' operation, C '%' is based on rounding towards zero) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10490 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index 4f3aeade..250324dc 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -10255,12 +10255,12 @@ texture_t *R_GetCurrentTexture(texture_t *t) R_LoadQWSkin(&r_qwskincache[i], cl.scores[i].qw_skin); t->currentskinframe = r_qwskincache[i].skinframe; if (t->currentskinframe == NULL) - t->currentskinframe = t->skinframes[(int)(t->skinframerate * (cl.time - rsurface.ent_shadertime)) % t->numskinframes]; + t->currentskinframe = t->skinframes[(unsigned int)(t->skinframerate * (cl.time - rsurface.ent_shadertime)) % t->numskinframes]; } else if (t->numskinframes >= 2) - t->currentskinframe = t->skinframes[(int)(t->skinframerate * (cl.time - rsurface.ent_shadertime)) % t->numskinframes]; + t->currentskinframe = t->skinframes[(unsigned int)(t->skinframerate * (cl.time - rsurface.ent_shadertime)) % t->numskinframes]; if (t->backgroundnumskinframes >= 2) - t->backgroundcurrentskinframe = t->backgroundskinframes[(int)(t->backgroundskinframerate * (cl.time - rsurface.ent_shadertime)) % t->backgroundnumskinframes]; + t->backgroundcurrentskinframe = t->backgroundskinframes[(unsigned int)(t->backgroundskinframerate * (cl.time - rsurface.ent_shadertime)) % t->backgroundnumskinframes]; t->currentmaterialflags = t->basematerialflags; t->currentalpha = rsurface.colormod[3]; -- 2.39.2