ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/dm-support.ext
(Generate patch)

Comparing deliantra/maps/perl/dm-support.ext (file contents):
Revision 1.1 by elmex, Tue Jul 11 20:03:57 2006 UTC vs.
Revision 1.2 by root, Wed Jul 19 08:52:57 2006 UTC

1#! perl 1#! perl
2 2
3# untested dm support extension 3# untested dm support extension
4 4
5use Storable qw/freeze thaw/; 5use Storable qw/nfreeze thaw/;
6 6
7my %global; # for use by eval'ed commands
8
7#cf::register_extcmd perleval => sub { 9cf::register_extcmd perl_eval => sub {
8# my ($pl, $indata) = @_; 10 my ($pl, $data) = @_;
9# 11
10# my ($token, $evaldata) = split / /, $indata, 2; 12 my ($token, $data) = split / /, $data, 2;
11# my ($code, $storablein) = split /\0/, $evaldata, 2; 13
12#
13# unless ($pl->flag (cf::FLAG_WIZ)) { 14 unless ($pl->flag (cf::FLAG_WIZ)) {
14# $pl->send ("ext $token"); 15 $pl->send ("ext $token error permission denied");
15# return; 16 return;
16# } 17 }
17# 18
18# my $data = thaw $storablein; 19 my ($code, $arg) = split /\0/, $data, 2;
19# 20
20# $pl->send ("ext $token " . freeze eval $code); 21 $arg = eval { thaw $arg };
22 my @res = eval $code;
23
24 $@ ? $pl->send ("ext $token error " . nfreeze $@)
25 : $pl->send ("ext $token ok " . nfreeze \@res);
21#}; 26};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines