Corrected logic of scheduler.c/findWorkArea()

This commit is contained in:
Adrien Bourmault 2021-06-16 10:06:05 +02:00
parent 51a3fc3719
commit 4f54f3030b
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
2 changed files with 12 additions and 9 deletions

View File

@ -34,6 +34,9 @@ struct {
int x;
int y;
int z;
int xmax;
int ymax;
int zmax;
} typedef Arrow_t;
struct {

View File

@ -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;
}
/* -------------------------------------------------------------------------- */