http://packetstormsecurity.org/UNIX/admin/xscreensaver-4.14.tar.gz
[xscreensaver] / hacks / flow.c
index 0f8c2f4aee2914762d3ccd952b1ebd042219fe4a..08bd2b046ed7cc723f2865d2d5d109c46f9c5ca7 100644 (file)
@@ -1,9 +1,8 @@
 /* -*- Mode: C; tab-width: 4 -*- */
 /* flow --- flow of strange bees */
 
-#if !defined( lint ) && !defined( SABER )
+#if 0
 static const char sccsid[] = "@(#)flow.c 4.10 98/04/24 xlockmore";
-
 #endif
 
 /*-
@@ -113,7 +112,7 @@ typedef enum {
        FLOW_2D = 8,     /* Allow 2D attractors */
        FLOW_BOX = 16,    /* Compute a box around the attractor */
        FLOW_SLOW = 32,   /* Some bees are slower (and have antifreeze) */
-       FLOW_FREEZE = 64, /* Freeze some of the bees in action */
+       FLOW_FREEZE = 64  /* Freeze some of the bees in action */
 } FlowMode;
 
 #define FLOW_DEFAULT (FLOW_ROTATE|FLOW_RIDE|FLOW_ZOOM|FLOW_2D|\
@@ -472,7 +471,7 @@ static double box_orig[][3] = {
 static double box[BOX_P][3];
 
 /* Lines connecting the box dots */
-static double lines[0][2] = {
+static double lines[][2] = {
        {0,1}, {1,2}, {2,3}, {3,0}, /* box */
        {4,5}, {5,6}, {6,7}, {7,4},
        {0,4}, {1,5}, {2,6}, {3,7},
@@ -496,8 +495,17 @@ void init_clip(flowstruct *sp)
        /* Scale the planes to the screen. I had to invert the projection
         * algorithms so that when projected they would be right at the edge of the
         * screen. */
-       double width = sp->size/sp->view.depth/2;
-       double height = sp->size/sp->view.depth/2*sp->view.height/sp->view.height;
+
+    /* #### jwz: I'm not really sure what it means when sp->view.depth is 0
+       in here -- what's the right thing to do? */
+
+       double width = (sp->view.depth
+                    ? sp->size/sp->view.depth/2
+                    : 1);
+       double height = (sp->view.depth
+                     ? (sp->size/sp->view.depth/2*
+                        sp->view.height/sp->view.height)
+                     : 1);
        for (i = 0; i < PLANES; i++) {
                /* Copy orig planes into planes, expanding <-> clippings */
                plane[i][0][0] = plane_orig[i][0][0];
@@ -798,7 +806,8 @@ draw_flow(ModeInfo * mi)
                                        double A=0;
                                        for(i=0; i<3; i++) A+=C[j][i]*C[j][i]; /* sum squares */
                                        A=sqrt(A);
-                                       for(i=0; i<3; i++) C[j][i]/=A;
+                    if (A != 0) /* #### is this right? */
+                      for(i=0; i<3; i++) C[j][i]/=A;
                                }
 
                                /* Interpolate between Center and Trained Bee matrices */