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.3 by root, Fri Jul 21 10:47:02 2006 UTC vs.
Revision 1.4 by root, Thu Aug 3 11:23:58 2006 UTC

3use Storable qw/nfreeze thaw/; 3use Storable qw/nfreeze thaw/;
4 4
5my %global; # for use by eval'ed commands 5my %global; # for use by eval'ed commands
6 6
7cf::register_extcmd perl_eval => sub { 7cf::register_extcmd perl_eval => sub {
8 my ($pl, $data) = @_; 8 my ($pl, $msg) = @_;
9 9
10 my ($token, $data) = split / /, $data, 2; 10 return (error => "error permission denied")
11 unless $pl->ob->flag (cf::FLAG_WIZ);
11 12
12 unless ($pl->ob->flag (cf::FLAG_WIZ)) { 13 my $arg = eval { thaw $msg->{arg} };
13 $pl->send ("ext $token error permission denied"); 14 my @res = eval $msg->{code};
14 return;
15 }
16 15
17 my ($code, $arg) = split /\0/, $data, 2; 16 $@ ? (error => $@)
18 17 : (result => nfreeze \@res)
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);
24}; 18};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines