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.3 by root, Fri Jul 21 10:47:02 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, $data) = @_;
11 9
12 my ($token, $data) = split / /, $data, 2; 10 my ($token, $data) = split / /, $data, 2;
13 11
14 unless ($pl->flag (cf::FLAG_WIZ)) { 12 unless ($pl->ob->flag (cf::FLAG_WIZ)) {
15 $pl->send ("ext $token error permission denied"); 13 $pl->send ("ext $token error permission denied");
16 return; 14 return;
17 } 15 }
18 16
19 my ($code, $arg) = split /\0/, $data, 2; 17 my ($code, $arg) = split /\0/, $data, 2;
20 18
21 $arg = eval { thaw $arg }; 19 $arg = eval { thaw $arg };
22 my @res = eval $code; 20 my @res = eval $code;
23 21
24 $@ ? $pl->send ("ext $token error " . nfreeze $@) 22 $@ ? $pl->send ("ext $token error $@")
25 : $pl->send ("ext $token ok " . nfreeze \@res); 23 : $pl->send ("ext $token ok " . nfreeze \@res);
26}; 24};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines