X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fcrystal.c;h=5ceb91f6f2a2f29d2b1a862c8fe2703fe3d14f9e;hp=be090c2efc0a8fa076da55596a8e3116d9468a5d;hb=07faf451b99879183ed7e909e43a0e065be1ee7f;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439 diff --git a/hacks/crystal.c b/hacks/crystal.c index be090c2e..5ceb91f6 100644 --- a/hacks/crystal.c +++ b/hacks/crystal.c @@ -92,6 +92,9 @@ static const char sccsid[] = "@(#)crystal.c 4.12 98/09/10 xlockmore"; #define DEF_MAXSIZE "False" #define DEF_CYCLE "True" +#undef NRAND +#define NRAND(n) ( (n) ? (int) (LRAND() % (n)) : 0) + #define min(a,b) ((a) <= (b) ? (a) : (b)) static int nx, ny; @@ -980,9 +983,12 @@ init_crystal(ModeInfo * mi) cryst->offset_w = (int) (cryst->b * 0.5); } } else { + int max_repeat = 10; cryst->offset_w = -1; - while (cryst->offset_w < 4 || (int) (cryst->offset_w - cryst->b * - sin((cryst->gamma - 90) * PI_RAD)) < 4) { + while (max_repeat-- && + (cryst->offset_w < 4 || (int) (cryst->offset_w - cryst->b * + sin((cryst->gamma - 90) * PI_RAD)) < 4) + ) { cryst->b = NRAND((int) (cryst->win_height / (cos((cryst->gamma - 90) * PI_RAD))) - cell_min) + cell_min; if (cryst->planegroup > 8)