… | |
… | |
523 | unlink $filename; |
523 | unlink $filename; |
524 | unlink "$filename.pst"; |
524 | unlink "$filename.pst"; |
525 | } |
525 | } |
526 | } |
526 | } |
527 | |
527 | |
|
|
528 | sub object_freezer_as_string { |
|
|
529 | my ($rdata, $objs) = @_; |
|
|
530 | |
|
|
531 | use Data::Dumper; |
|
|
532 | |
|
|
533 | $$rdata . Dumper $objs |
|
|
534 | } |
|
|
535 | |
528 | sub object_thawer_load { |
536 | sub 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'; |
… | |
… | |
775 | sub cf::player::exists($) { |
784 | sub 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 | |
782 | Sends a message to the player, as if the npc C<$npc> replied. C<$npc> |
791 | Sends a message to the player, as if the npc C<$npc> replied. C<$npc> |
783 | can be C<undef>. Does the right thing when the player is currently in a |
792 | can be C<undef>. Does the right thing when the player is currently in a |
784 | dialogue with the given NPC character. |
793 | dialogue 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 | |
|
|
828 | Returns wether the given player is authorized to access resource "access" |
|
|
829 | (e.g. "command_wizcast"). |
|
|
830 | |
|
|
831 | =cut |
|
|
832 | |
|
|
833 | sub 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 | |
825 | Functions that provide a safe environment to compile and execute |
848 | Functions that provide a safe environment to compile and execute |
826 | snippets of perl code without them endangering the safety of the server |
849 | snippets of perl code without them endangering the safety of the server |
827 | itself. Looping constructs, I/O operators and other built-in functionality |
850 | itself. Looping constructs, I/O operators and other built-in functionality |
828 | is not available in the safe scripting environment, and the number of |
851 | is not available in the safe scripting environment, and the number of |
829 | functions and methods that cna be called is greatly reduced. |
852 | functions and methods that can be called is greatly reduced. |
830 | |
853 | |
831 | =cut |
854 | =cut |
832 | |
855 | |
833 | our $safe = new Safe "safe"; |
856 | our $safe = new Safe "safe"; |
834 | our $safe_hole = new Safe::Hole; |
857 | our $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 | |
1168 | eval { IO::AIO::max_poll_time $TICK * 0.2 }; #d# remove eval after restart |
1191 | IO::AIO::max_poll_time $TICK * 0.2; |
1169 | |
1192 | |
1170 | Event->io (fd => IO::AIO::poll_fileno, |
1193 | Event->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); |