|
@@ -56,14 +56,9 @@ static void push(car * newcar)
|
|
|
}
|
|
|
|
|
|
// called when a car clears the intersection
|
|
|
-static void clearint(car * done)
|
|
|
+static void clearint(car * done, int pos)
|
|
|
{
|
|
|
- // dirs + origin is our offset for where to start in the array
|
|
|
- // compass + origin is the array we use to determine what to add to the first number
|
|
|
- // newcar->dest gives the direction, which we use to find the offset indicating it's additive value
|
|
|
- // set the array of active cars to null at this value
|
|
|
- int total = dirs[done->origin] + *(compass[done->origin] + done->dest);
|
|
|
- active[total] = NULL;
|
|
|
+ active[pos] = NULL;
|
|
|
|
|
|
if (done->cv) // if this car was blocking something
|
|
|
{
|
|
@@ -173,6 +168,6 @@ void intersection_after_exit(Direction origin, Direction destination)
|
|
|
{
|
|
|
lock_acquire(globlock);
|
|
|
int position = dirs[origin] + *(compass[origin] + destination);
|
|
|
- clearint(active[position]);
|
|
|
+ clearint(active[position], position);
|
|
|
lock_release(globlock);
|
|
|
}
|