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.2 by root, Wed Jul 19 08:52:57 2006 UTC vs.
Revision 1.4 by root, Thu Aug 3 11:23:58 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines