ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.78 by root, Tue Nov 7 00:15:27 2006 UTC vs.
Revision 1.82 by root, Sun Dec 3 20:59:52 2006 UTC

523 unlink $filename; 523 unlink $filename;
524 unlink "$filename.pst"; 524 unlink "$filename.pst";
525 } 525 }
526} 526}
527 527
528sub object_freezer_as_string {
529 my ($rdata, $objs) = @_;
530
531 use Data::Dumper;
532
533 $$rdata . Dumper $objs
534}
535
528sub object_thawer_load { 536sub object_thawer_load {
529 my ($filename) = @_; 537 my ($filename) = @_;
530 538
531 local $/; 539 local $/;
532 540
634 . "#line 1 \"$path\"\n{\n" 642 . "#line 1 \"$path\"\n{\n"
635 . (do { local $/; <$fh> }) 643 . (do { local $/; <$fh> })
636 . "\n};\n1"; 644 . "\n};\n1";
637 645
638 eval $source 646 eval $source
639 or die "$path: $@"; 647 or die $@ ? "$path: $@\n"
648 : "extension disabled.\n";
640 649
641 push @exts, $pkg; 650 push @exts, $pkg;
642 $ext_pkg{$base} = $pkg; 651 $ext_pkg{$base} = $pkg;
643 652
644# no strict 'refs'; 653# no strict 'refs';
775sub cf::player::exists($) { 784sub cf::player::exists($) {
776 cf::player::find $_[0] 785 cf::player::find $_[0]
777 or -f sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($_[0]) x 2; 786 or -f sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($_[0]) x 2;
778} 787}
779 788
780=item $object->reply ($npc, $msg[, $flags]) 789=item $player_object->reply ($npc, $msg[, $flags])
781 790
782Sends a message to the player, as if the npc C<$npc> replied. C<$npc> 791Sends a message to the player, as if the npc C<$npc> replied. C<$npc>
783can be C<undef>. Does the right thing when the player is currently in a 792can be C<undef>. Does the right thing when the player is currently in a
784dialogue with the given NPC character. 793dialogue with the given NPC character.
785 794
812 $msg{msgid} = $id; 821 $msg{msgid} = $id;
813 822
814 $self->send ("ext " . to_json \%msg); 823 $self->send ("ext " . to_json \%msg);
815} 824}
816 825
817=back 826=item $player_object->may ("access")
827
828Returns wether the given player is authorized to access resource "access"
829(e.g. "command_wizcast").
830
831=cut
832
833sub cf::object::player::may {
834 my ($self, $access) = @_;
835
836 $self->flag (cf::FLAG_WIZ) ||
837 (ref $cf::CFG{"may_$access"}
838 ? scalar grep $self->name eq $_, @{$cf::CFG{"may_$access"}}
839 : $cf::CFG{"may_$access"})
840}
818 841
819=cut 842=cut
820 843
821############################################################################# 844#############################################################################
822 845
824 847
825Functions that provide a safe environment to compile and execute 848Functions that provide a safe environment to compile and execute
826snippets of perl code without them endangering the safety of the server 849snippets of perl code without them endangering the safety of the server
827itself. Looping constructs, I/O operators and other built-in functionality 850itself. Looping constructs, I/O operators and other built-in functionality
828is not available in the safe scripting environment, and the number of 851is not available in the safe scripting environment, and the number of
829functions and methods that cna be called is greatly reduced. 852functions and methods that can be called is greatly reduced.
830 853
831=cut 854=cut
832 855
833our $safe = new Safe "safe"; 856our $safe = new Safe "safe";
834our $safe_hole = new Safe::Hole; 857our $safe_hole = new Safe::Hole;
1163 $TICK_WATCHER->at ($NEXT_TICK); 1186 $TICK_WATCHER->at ($NEXT_TICK);
1164 $TICK_WATCHER->start; 1187 $TICK_WATCHER->start;
1165 }, 1188 },
1166); 1189);
1167 1190
1168eval { IO::AIO::max_poll_time $TICK * 0.2 }; #d# remove eval after restart 1191IO::AIO::max_poll_time $TICK * 0.2;
1169 1192
1170Event->io (fd => IO::AIO::poll_fileno, 1193Event->io (fd => IO::AIO::poll_fileno,
1171 poll => 'r', 1194 poll => 'r',
1172 prio => 5, 1195 prio => 5,
1173 cb => \&IO::AIO::poll_cb); 1196 cb => \&IO::AIO::poll_cb);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines