};
-#define cell_x(c) (((c) - st->arr) % st->arr_width)
-#define cell_y(c) (((c) - st->arr) / st->arr_width)
+#define cell_x(c) (st->arr_width ? ((c) - st->arr) % st->arr_width : 0)
+#define cell_y(c) (st->arr_width ? ((c) - st->arr) / st->arr_width : 0)
static int random_life_value (struct state *st)
}
}
- st->xSize = st->windowWidth / st->arr_width;
- st->ySize = st->windowHeight / st->arr_height;
+ st->xSize = st->arr_width ? st->windowWidth / st->arr_width : 0;
+ st->ySize = st->arr_height ? st->windowHeight / st->arr_height : 0;
if (st->xSize > st->ySize)
{
st->xSize = st->ySize;
XFillRectangle (st->dpy, st->window, st->coloredGCs[0], 0, 0,
st->windowWidth, st->windowHeight);
+
+ if (!st->arr_width) st->arr_width = 1;
+ if (!st->arr_height) st->arr_height = 1;
st->arr = (cell *) calloc (sizeof(cell), st->arr_width * st->arr_height);
if (!st->arr)
for (y = 0; y < st->arr_height; y++)
{
int row = y * st->arr_width;
- for (x = 0; x < st->arr_width; x++)
+ for (x = 0; x < st->arr_width; x++)
{
st->arr[row+x].speed = 0.0;
st->arr[row+x].growth = 0.0;
while (n--)
{
- int x = random () % st->arr_width;
- int y = random () % st->arr_height;
+ int x = st->arr_width ? random () % st->arr_width : 0;
+ int y = st->arr_height ? random () % st->arr_height : 0;
int c;
FLOAT s;
if (b)
}
else
{
- c = (random () % (st->count-1)) + 1;
+ c = ((st->count - 1) ? random () % (st->count-1) : 0) + 1;
s = RAND_FLOAT * (st->maxlifespeed - st->minlifespeed) + st->minlifespeed;
}
newcell (st, &st->arr[y * st->arr_width + x], c, s);
int x = cell_x(a) + coords->x;
int y = cell_y(a) + coords->y;
coords++;
-
+
if (x < 0) x = st->arr_width - 1;
else if (x >= st->arr_width) x = 0;
if (a->growth >= st->diaglim)
killcell (st, a);
}
-
+
randblip (st, (st->head->next) == st->tail);
-
+
for (a = st->head->next; a != st->tail; a = a->next)
{
if (a->isnext)