X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=remoteglot.pl;h=7f4fd3c2ddc58d03fff0b0a276236572cfffe993;hp=19f0446cb496128cc4fa4b04cf80f8d7ad345cdb;hb=01a8eaa3db2c015b25c0cf53df96b12493f3db58;hpb=de36b0b19903bcd95cc1ea131733e69b91b81c6b diff --git a/remoteglot.pl b/remoteglot.pl index 19f0446..7f4fd3c 100755 --- a/remoteglot.pl +++ b/remoteglot.pl @@ -286,7 +286,16 @@ sub handle_pgn { my $black = $pgn->black; $white =~ s/,.*//; # Remove first name. $black =~ s/,.*//; # Remove first name. - my $pos = Position->start_pos($white, $black); + my $tags = $pgn->tags(); + my $pos; + if (exists($tags->{'FEN'})) { + $pos = Position->from_fen($tags->{'FEN'}); + $pos->{'player_w'} = $white; + $pos->{'player_b'} = $black; + $pos->{'start_fen'} = $tags->{'FEN'}; + } else { + $pos = Position->start_pos($white, $black); + } my $moves = $pgn->moves; my @uci_moves = (); my @repretty_moves = (); @@ -880,7 +889,12 @@ sub output_json { local $dbh->{AutoCommit} = 0; my $q = $dbh->prepare('SELECT * FROM scores WHERE id=?'); - my $pos = Position->start_pos('white', 'black'); + my $pos; + if (exists($pos_calculating->{'start_fen'})) { + $pos = Position->from_fen($pos_calculating->{'start_fen'}); + } else { + $pos = Position->start_pos('white', 'black'); + } my $halfmove_num = 0; for my $move (@{$pos_calculating->{'history'}}) { my $id = id_for_pos($pos, $halfmove_num);