Browse Source

moving back to working copy

tarfeef101 6 years ago
parent
commit
ebdc6909c9
1 changed files with 8 additions and 1 deletions
  1. 8 1
      kern/synchprobs/traffic_synch.c

+ 8 - 1
kern/synchprobs/traffic_synch.c

@@ -57,6 +57,13 @@ static void clearint(car * done, int pos)
   kfree(done);
 }
 
+// returns true if a car is turning right
+static bool rightturn(car * car)
+{
+  int temp = car->origin - car->dest;
+  return (temp == 1 || temp == -3);
+}
+
 // inits all arrays we need, lock.
 void intersection_sync_init()
 {
@@ -107,7 +114,7 @@ void intersection_before_entry(Direction origin, Direction destination)
     
     if (temp)
     {
-      if ((temp->origin == new->origin && temp->dest != new->dest) || (temp->origin == new->dest && temp->dest == new->origin) || (temp->dest != new->dest && ((new->origin - new->dest == 1 || new->origin - new->dest == -3) || ((temp->origin - temp->dest) == 1 || (temp->origin - temp->dest) == -3))))
+      if ((temp->origin == new->origin && temp->dest != new->dest) || (temp->origin == new->dest && temp->dest == new->origin) || (temp->dest != new->dest && (rightturn(new) || rightturn(temp))))
       {
         continue;
       }