… | |
… | |
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\n" . 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 | |
… | |
… | |
775 | sub cf::player::exists($) { |
783 | sub cf::player::exists($) { |
776 | cf::player::find $_[0] |
784 | cf::player::find $_[0] |
777 | or -f sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($_[0]) x 2; |
785 | or -f sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($_[0]) x 2; |
778 | } |
786 | } |
779 | |
787 | |
780 | =item $object->reply ($npc, $msg[, $flags]) |
788 | =item $player_object->reply ($npc, $msg[, $flags]) |
781 | |
789 | |
782 | Sends a message to the player, as if the npc C<$npc> replied. C<$npc> |
790 | 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 |
791 | can be C<undef>. Does the right thing when the player is currently in a |
784 | dialogue with the given NPC character. |
792 | dialogue with the given NPC character. |
785 | |
793 | |
… | |
… | |
812 | $msg{msgid} = $id; |
820 | $msg{msgid} = $id; |
813 | |
821 | |
814 | $self->send ("ext " . to_json \%msg); |
822 | $self->send ("ext " . to_json \%msg); |
815 | } |
823 | } |
816 | |
824 | |
817 | =back |
825 | =item $player_object->may ("access") |
|
|
826 | |
|
|
827 | Returns wether the given player is authorized to access resource "access" |
|
|
828 | (e.g. "command_wizcast"). |
|
|
829 | |
|
|
830 | =cut |
|
|
831 | |
|
|
832 | sub cf::object::player::may { |
|
|
833 | my ($self, $access) = @_; |
|
|
834 | |
|
|
835 | $self->flag (cf::FLAG_WIZ) || |
|
|
836 | (ref $cf::CFG{"may_$access"} |
|
|
837 | ? scalar grep $self->name eq $_, @{$cf::CFG{"may_$access"}} |
|
|
838 | : $cf::CFG{"may_$access"}) |
|
|
839 | } |
818 | |
840 | |
819 | =cut |
841 | =cut |
820 | |
842 | |
821 | ############################################################################# |
843 | ############################################################################# |
822 | |
844 | |
… | |
… | |
824 | |
846 | |
825 | Functions that provide a safe environment to compile and execute |
847 | Functions that provide a safe environment to compile and execute |
826 | snippets of perl code without them endangering the safety of the server |
848 | snippets of perl code without them endangering the safety of the server |
827 | itself. Looping constructs, I/O operators and other built-in functionality |
849 | itself. Looping constructs, I/O operators and other built-in functionality |
828 | is not available in the safe scripting environment, and the number of |
850 | is not available in the safe scripting environment, and the number of |
829 | functions and methods that cna be called is greatly reduced. |
851 | functions and methods that can be called is greatly reduced. |
830 | |
852 | |
831 | =cut |
853 | =cut |
832 | |
854 | |
833 | our $safe = new Safe "safe"; |
855 | our $safe = new Safe "safe"; |
834 | our $safe_hole = new Safe::Hole; |
856 | our $safe_hole = new Safe::Hole; |
… | |
… | |
1163 | $TICK_WATCHER->at ($NEXT_TICK); |
1185 | $TICK_WATCHER->at ($NEXT_TICK); |
1164 | $TICK_WATCHER->start; |
1186 | $TICK_WATCHER->start; |
1165 | }, |
1187 | }, |
1166 | ); |
1188 | ); |
1167 | |
1189 | |
1168 | eval { IO::AIO::max_poll_time $TICK * 0.2 }; #d# remove eval after restart |
1190 | IO::AIO::max_poll_time $TICK * 0.2; |
1169 | |
1191 | |
1170 | Event->io (fd => IO::AIO::poll_fileno, |
1192 | Event->io (fd => IO::AIO::poll_fileno, |
1171 | poll => 'r', |
1193 | poll => 'r', |
1172 | prio => 5, |
1194 | prio => 5, |
1173 | cb => \&IO::AIO::poll_cb); |
1195 | cb => \&IO::AIO::poll_cb); |