diff --git a/include/base.h b/include/base.h index 6553fad..951a8b7 100644 --- a/include/base.h +++ b/include/base.h @@ -34,6 +34,9 @@ struct { int x; int y; int z; + int xmax; + int ymax; + int zmax; } typedef Arrow_t; struct { diff --git a/src/scheduler.c b/src/scheduler.c index 6d793ff..2587130 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -54,20 +54,20 @@ static Center_t *findWorkArea(Center_t *centersList, Arrow_t *electedArrow, while (currentCenter){ //printLog("Center : %d\n", currentCenter->x); - if ( abs(electedArrow->x - currentCenter->x) >= ruleRadius - && abs(electedArrow->y - currentCenter->y) >= ruleRadius - && abs(electedArrow->z - currentCenter->z) >= ruleRadius + if ( abs(electedArrow->x - currentCenter->x) <= ruleRadius + || abs(electedArrow->y - currentCenter->y) <= ruleRadius + || abs(electedArrow->z - currentCenter->z) <= ruleRadius ){ - newCenter->x = electedArrow->x; - newCenter->y = electedArrow->y; - newCenter->z = electedArrow->z; - return newCenter; + free(newCenter); + return NULL; } currentCenter = currentCenter->next; } - free(newCenter); - return NULL; + newCenter->x = electedArrow->x; + newCenter->y = electedArrow->y; + newCenter->z = electedArrow->z; + return newCenter; } /* -------------------------------------------------------------------------- */