Forge some nearly-duplicate code into subroutine
[gnushogi.git] / gnushogi / main.c
index 878ce38..da633c2 100644 (file)
@@ -382,28 +382,8 @@ main (int argc, char **argv)
         else
             InputCommand(true);
 
-        if (opponent == white)
-        {
-            if (flag.gamein || TCadd)
-            {
-                TimeCalc();
-            }
-            else if (TimeControl.moves[opponent] == 0)
-            {
-                if (XC)
-                {
-                    if (XCmore < XC)
-                    {
-                        TCmoves   = XCmoves[XCmore];
-                        TCminutes = XCminutes[XCmore];
-                        TCseconds = XCseconds[XCmore];
-                        XCmore++;
-                    }
-                }
-
-                SetTimeControl();
-            }
-        }
+        if(opponent == white)
+            RenewTimeControl(opponent, TCadd);
 
         compptr = (compptr + 1) % MINGAMEIN;
 
@@ -414,28 +394,8 @@ main (int argc, char **argv)
 #endif
             SelectMove(computer, FOREGROUND_MODE);
 
-            if (computer == white)
-            {
-                if (flag.gamein)
-                {
-                    TimeCalc();
-                }
-                else if (TimeControl.moves[computer] == 0)
-                {
-                    if (XC)
-                    {
-                        if (XCmore < XC)
-                        {
-                            TCmoves = XCmoves[XCmore];
-                            TCminutes = XCminutes[XCmore];
-                            TCseconds = XCseconds[XCmore];
-                            XCmore++;
-                        }
-                    }
-
-                    SetTimeControl();
-                }
-            }
+            if(computer == white)
+                RenewTimeControl(computer, false);
         }
     }