Pārlūkot izejas kodu

small calculation reduction

tarfeef101 7 gadi atpakaļ
vecāks
revīzija
0ecd68a645
1 mainītis faili ar 1 papildinājumiem un 8 dzēšanām
  1. 1 8
      kern/synchprobs/traffic_synch.c

+ 1 - 8
kern/synchprobs/traffic_synch.c

@@ -57,13 +57,6 @@ 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()
 {
@@ -114,7 +107,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 && (rightturn(new) || rightturn(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))))
       {
         continue;
       }