Split multi-leg moves into two CECP move commands UCI prints a multi-leg move on a single line, but in CECP the legs of such a move have to be sent to the GUI separately. This patch supprts splitting into two legs, as is needed for Duck Chess.
Fix hanging when playing with book The queued input moves were not terminated with a linefeed. As a result the last move could be fused with a 'go' command that immediatey followed it, (as it would after loading an opening line), effectively losing the latter from the queue. The engine would then not start.
Use 'isready' after 'ucinewgame' The isready / readyok poll is re-instated for UCI engines, just to give them no excuse to be pedantic and use its absense as an excuse to crash. The GUI will not be made aware of any waiting for the readyok. For USI the use of isready after usinewgame is still avoided, as this would make most engine hang.
Limit Hash setting to engine's maximum The hash-table size requested through the CECP 'memory' command will now be reduced to the maximum the engine specified in its Hash option command, if it was larger. Before it was just passed on 'as is'.
Allow arbitrary board size in USI Apart from regular Shogi on 9x9, UCI2WB would only handle 5x5 boards in USI. The conversion of square coordinates requires the board size to be known. This patch allows UCI2WB to recognize any board-size-overruled Shogi variant NxM+H_shogi, and distinguishes width N from height M when doing the coordinate conversions. This means it now also supports Judkin's Shogi (6x6), a variant that te Petit Shogi engine seems to play.
Fix USI move conversion The previous patches have broken USI mode, sending the move from the input line to the engine rather than the converted one.
Update "usage is" message The usage message now mentiones the -x, -c and -f flags. It also prints the name of the executable, rather than the protocol-adapted name.
Send increment in UCCI also when it is 0 Apparently the increment/oppincrement parameters on the 'go' command are essential in UCCI, and should also be sent in sudden-death TCs. (Elephant Eye had ridiculous time usage when this was not done.)
Fix handling of draw offers The CECP command to offer the engine a draw is "draw", but UCI2WB was testing for "offer" (the engine->GUI command) in its GUI thread. This would even cause hanging when the command was received during pondering, because it was now queued before the input move, eclipsing the latter, and thus preventing it to terminate pondering.
Don't always use UCI Cyclone dialect in Xiangqi Whether the Cyclone dialect is used (omitting 'position' and using 'r' for white-to-move in the FEN) is now determined by whether the engine is called with -c or without protocol specifier; in the latter case it uses standard UCI even in Xiangqi.
Protect against overrun of input buffer The routine ReadLine() now has an extra argument to indicate the maximum length of the string. All characters that exceed the size will overwrite each other in the last position before the terminiating null character, so that the linefeed will be kept.
Add -kill option to specify kill delay The delay between receiving the 'quit' command and killing an engine that survives that can now be specified through an option (the value of which will be added to the 50ms default delay). To make this compatible with WinBoard/XBoard's option -delayAfterQuit, the value is interpreted as seconds in the Windows compile, and milliseconds otherwise.
Kill engines that do not respond to 'quit' in time If an engine process is still alive 50ms after the adapter received a 'quit' command, it will now be killed. This is done by the GUI thread (which now also causes the adapter to exit), because the engine thread might be tied up in listening to an engine that has no intention to respond to 'stop'. (Which would be a necessary condition for the engine thread to relay the queued 'quit' command.)
Add option -nice to lower engine priority To enable the GUI to lower engine priority without lowering the priority of the adapter process, a new argument '-nice N' can be used on UCI2WB to delegate that task to it.
Bump version to 4.1
Silence warnings The options -Wall is added to the CFLAGS, and the resulting warnings for unused variables, default return types, unused results and implicit declarations are all fixed, the latter by including two new standard header files. The results of pipe, read and write are now actually tested, and can give a fatal error. Only the pedantic parentheses warnings are suppressed with -Wno-parentheses.
Only set UCI_Variant to 'chess' when that is in the list CECP specs have it that after 'new' the variant should revert to 'normal' Chess, and only after the 'variant' command switch to the selected variant. But not all engines support Chess, and when they explicitly state they do not (by omitting it from the UCI_Variant choices), it would be pretty silly to sent it to them. A 'variant' command must follow 'new' in that case anyway.
Fix UCI_Variant command The variant list was not properly terminated after replacing the UCI 'var' keywords by commas for use in a CECP variants feature.
Fix loading of opening line Appending moves to the game out of sync with otheer commands (i.e. by the GUI thread) did not work properly: XBoard can send 'new', 'force' plus a ton of moves all at once, and the appending of moves would then overtake the 'new' command (first queued for the engine thread), which would clear the move number, deleting the moves again. Now the appending of moves is also deferred to the engine thread, by queuing them.
Suppress 2nd isready handshake on spurious 'new' The feature reuse=0 should limit the number of 'new' commands to one. But unfortunately XBoard under some conditions sends a spurious second game-start sequence before it quits a reuse=0 engine to start a new instance. This caused (non-compliant) engines that do not always respond to 'isready' (a disease especially common with USI) to dodge the 'quit' command, which then caused hanging engine processes after the adapter was killed. Only the first 'new' command in every run now uses 'isready', so the 'quit' command that follows a spurious 2nd 'new' can be relayed without delay.