prevent bla%0

This commit is contained in:
Sander van Dijk 2006-04-24 19:21:11 +00:00
parent 5b4c12b53d
commit 4dfb3c41ed

View File

@ -148,7 +148,7 @@ send_to_area(Area *to, Area *from, Client *c)
void void
place_client(Area *a, Client *c) place_client(Area *a, Client *c)
{ {
static unsigned int mx, my; static unsigned int mx, my, offset;
static Bool *field = nil; static Bool *field = nil;
Bool fit = False; Bool fit = False;
unsigned int i, j, k, x, y, maxx, maxy, dx, dy, cx, cy; unsigned int i, j, k, x, y, maxx, maxy, dx, dy, cx, cy;
@ -218,13 +218,17 @@ place_client(Area *a, Client *c)
if(fit && (p1.x + f->rect.width < a->rect.x + a->rect.width)) if(fit && (p1.x + f->rect.width < a->rect.x + a->rect.width))
f->rect.x = p1.x; f->rect.x = p1.x;
else else {
f->rect.x = a->rect.x + (random()%(a->rect.width - f->rect.width)); offset = (a->rect.width - f->rect.width) > 0 ? (a->rect.width - f->rect.width) : 1;
f->rect.x = a->rect.x + (random()%offset);
}
if(fit && (p1.y + f->rect.height < a->rect.y + a->rect.height)) if(fit && (p1.y + f->rect.height < a->rect.y + a->rect.height))
f->rect.y = p1.y; f->rect.y = p1.y;
else else {
f->rect.y = a->rect.y + (random()%(a->rect.height - f->rect.height)); offset = (a->rect.height - f->rect.height) > 0 ? (a->rect.height - f->rect.height) : 1;
f->rect.y = a->rect.y + (random()%offset);
}
} }
void void