From: divverent Date: Fri, 24 Sep 2010 21:37:43 +0000 (+0000) Subject: Fix a possible crash when an invalid skinframe gets accessed after cl.time steps... X-Git-Tag: xonotic-v0.1.0preview~164 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=659d2f83a08ef04792186e5ed1d32fb37b237d14;p=xonotic%2Fdarkplaces.git 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 ::stable-branch::merge=e63a0114bbd617c020c6217f5e1fe1145b1d2c78 --- diff --git a/gl_rmain.c b/gl_rmain.c index 7cae34d3..45f80c00 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -9476,12 +9476,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];