--- deliantra/server/ext/highscore.ext 2012/02/03 03:01:44 1.9 +++ deliantra/server/ext/highscore.ext 2012/02/03 03:59:17 1.10 @@ -4,6 +4,7 @@ use Coro::AIO; CONF HIGHSCORE_ENTRIES = 1000 +CONF EXPORT_HIGHSCORE = "www.deliantra.net/highscore.json" our $HIGHSCORE; @@ -150,6 +151,22 @@ if ($save) { save_highscore or die "unable to write highscore file: $!"; + + if (defined $EXPORT_HIGHSCORE) { + cf::get_slot 0.05, 0, "highscore export"; + + my $rank; + my @highscore = map { + my ($name, $title, $exp, $killer, $map, $hp, $sp, $grace) = @$_; + [++$rank, $name, $title, (cf::exp_to_level $exp), $exp, $killer, $map, $hp, $sp, $grace] + } @$HIGHSCORE; + + cf::replace_file $EXPORT_HIGHSCORE, cf::encode_json { + version => 1, + date => $cf::NOW, + data => \@highscore, + }; + } } }