]> git.sesse.net Git - remoteglot/blobdiff - remoteglot.pl
Be more flexible about clk comments.
[remoteglot] / remoteglot.pl
index 2a6e2a6b742ef822422556bac6c714718768e421..9c2130cc55fca075cb853c0904614d322a7fd3e3 100755 (executable)
@@ -1009,14 +1009,20 @@ sub extract_clock {
 
        if (exists($comments->{$white_key}) &&
            exists($comments->{$black_key}) &&
-           $comments->{$white_key} =~ /tl=(\d+:\d+:\d+)/ &&
-           $comments->{$black_key} =~ /tl=(\d+:\d+:\d+)/) {
-               $comments->{$white_key} =~ /tl=(\d+:\d+:\d+)/;
+           $comments->{$white_key} =~ /(?:tl=|clk )(\d+:\d+:\d+)/ &&
+           $comments->{$black_key} =~ /(?:tl=|clk )(\d+:\d+:\d+)/) {
+               $comments->{$white_key} =~ /(?:tl=|clk )(\d+:\d+:\d+)/;
                $pos->{'white_clock'} = $1;
-               $comments->{$black_key} =~ /tl=(\d+:\d+:\d+)/;
+               $comments->{$black_key} =~ /(?:tl=|clk )(\d+:\d+:\d+)/;
                $pos->{'black_clock'} = $1;
+
+               $pos->{'white_clock'} =~ s/\b(\d)\b/0$1/g;
+               $pos->{'black_clock'} =~ s/\b(\d)\b/0$1/g;
                return;
        }
+
+       delete $pos->{'white_clock'};
+       delete $pos->{'black_clock'};
 }
 
 sub find_clock_start {
@@ -1036,6 +1042,7 @@ sub find_clock_start {
        }
 
        # TODO(sesse): Maybe we can get the number of moves somehow else for FICS games.
+       # The history is needed for id_for_pos.
        if (!exists($pos->{'pretty_history'})) {
                return;
        }