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.3 by root, Fri Jul 21 10:47:02 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines