--- deliantra/server/ext/highscore.ext 2012/02/03 02:04:11 1.8 +++ deliantra/server/ext/highscore.ext 2012/02/03 04:07:06 1.11 @@ -3,7 +3,8 @@ use Fcntl (); use Coro::AIO; -our $HIGHSCORE_ENTRIES = $cf::CFG{highscore_entries} || 1000; +CONF HIGHSCORE_ENTRIES = 1000 +CONF EXPORT_HIGHSCORE = undef 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, + }; + } } }