Add time increment after move in XBoard mode
[gnushogi.git] / gnushogi / tcontrl.c
index 539cb7f..4e1da41 100644 (file)
@@ -164,7 +164,8 @@ void SetResponseTime(short side)
                 short rtf = in_opening_stage ? 8 : 2;
                 short tcq = in_opening_stage ? 2 : 4;
 
-                TimeControl.clock[side] += TCadd;
+                if(!xboard) /* no pre-add of increment in XBoard mode */
+                    TimeControl.clock[side] += TCadd;
                 ResponseTime = (TimeControl.clock[side])
                     / (((TimeControl.moves[side]) * rtf) + 1);
                 TCleft = (long)ResponseTime / tcq;
@@ -252,7 +253,9 @@ void SetResponseTime(short side)
         else
         {
             /* calculate avg time per move remaining */
-            TimeControl.clock[side] += TCadd;
+
+            if(!xboard) /* no pre-add of increment in XBoard mode */
+                TimeControl.clock[side] += TCadd;
 
             ResponseTime = (TimeControl.clock[side])
                 / (((TimeControl.moves[side]) * 2) + 1);
@@ -435,3 +438,27 @@ SetTimeControl(void)
     et = 0;
     ElapsedTime(COMPUTE_AND_INIT_MODE);
 }
+
+void
+RenewTimeControl(int side, int TCadd)
+{
+    if (flag.gamein || TCadd)
+    {
+        TimeCalc();
+    }
+    else if (TimeControl.moves[side] == 0)
+    {
+        if (XC)
+        {
+            if (XCmore < XC)
+            {
+                TCmoves   = XCmoves[XCmore];
+                TCminutes = XCminutes[XCmore];
+                TCseconds = XCseconds[XCmore];
+                XCmore++;
+            }
+        }
+
+        SetTimeControl();
+    }
+}