X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fshadebobs.c;fp=hacks%2Fshadebobs.c;h=d1361dd3aa4f23ed8d460cb3d65f73e7efe9e22d;hp=64fa82c9772d7e28b3ba7a87d3f74e4fd00fd6e1;hb=8afc01a67be4fbf3f1cc0fce9adf01b5289a21c6;hpb=3f1091236d800c43a3124c44c7da54e53f205b13 diff --git a/hacks/shadebobs.c b/hacks/shadebobs.c index 64fa82c9..d1361dd3 100644 --- a/hacks/shadebobs.c +++ b/hacks/shadebobs.c @@ -147,8 +147,11 @@ static void MoveShadeBob( struct state *st, SShadeBob *pShadeBob ) pShadeBob->nAngle += pShadeBob->nAngleInc; pShadeBob->nAngleDelta -= pShadeBob->nAngleInc; - if( pShadeBob->nAngle >= st->iDegreeCount ) pShadeBob->nAngle -= st->iDegreeCount; - else if( pShadeBob->nAngle < 0 ) pShadeBob->nAngle += st->iDegreeCount; + /* Since it can happen that nAngle < 0 and nAngle + iDegreeCount >= iDegreeCount + on floating point, we set some marginal value. + */ + if( pShadeBob->nAngle + 0.5 >= st->iDegreeCount ) pShadeBob->nAngle -= st->iDegreeCount; + else if( pShadeBob->nAngle < -0.5 ) pShadeBob->nAngle += st->iDegreeCount; if( ( pShadeBob->nAngleInc>0.0F && pShadeBob->nAngleDeltanAngleInc ) || ( pShadeBob->nAngleInc<=0.0F && pShadeBob->nAngleDelta>pShadeBob->nAngleInc ) )