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 x;
int y; int y;
int z; int z;
int xmax;
int ymax;
int zmax;
} typedef Arrow_t; } typedef Arrow_t;
struct { struct {

View File

@ -54,20 +54,20 @@ static Center_t *findWorkArea(Center_t *centersList, Arrow_t *electedArrow,
while (currentCenter){ while (currentCenter){
//printLog("Center : %d\n", currentCenter->x); //printLog("Center : %d\n", currentCenter->x);
if ( abs(electedArrow->x - currentCenter->x) >= ruleRadius if ( abs(electedArrow->x - currentCenter->x) <= ruleRadius
&& abs(electedArrow->y - currentCenter->y) >= ruleRadius || abs(electedArrow->y - currentCenter->y) <= ruleRadius
&& abs(electedArrow->z - currentCenter->z) >= ruleRadius || abs(electedArrow->z - currentCenter->z) <= ruleRadius
){ ){
newCenter->x = electedArrow->x; free(newCenter);
newCenter->y = electedArrow->y; return NULL;
newCenter->z = electedArrow->z;
return newCenter;
} }
currentCenter = currentCenter->next; currentCenter = currentCenter->next;
} }
free(newCenter); newCenter->x = electedArrow->x;
return NULL; newCenter->y = electedArrow->y;
newCenter->z = electedArrow->z;
return newCenter;
} }
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */