… | |
… | |
808 | } |
808 | } |
809 | |
809 | |
810 | wantarray ? @res : $res[0] |
810 | wantarray ? @res : $res[0] |
811 | } |
811 | } |
812 | |
812 | |
|
|
813 | =item cf::register_script_function $function => $cb |
|
|
814 | |
|
|
815 | Register a function that can be called from within map/npc scripts. The |
|
|
816 | function should be reasonably secure and should be put into a package name |
|
|
817 | like the extension. |
|
|
818 | |
|
|
819 | Example: register a function that gets called whenever a map script calls |
|
|
820 | C<rent::overview>, as used by the C<rent> extension. |
|
|
821 | |
|
|
822 | cf::register_script_function "rent::overview" => sub { |
|
|
823 | ... |
|
|
824 | }; |
|
|
825 | |
|
|
826 | =cut |
|
|
827 | |
813 | sub register_script_function { |
828 | sub register_script_function { |
814 | my ($fun, $cb) = @_; |
829 | my ($fun, $cb) = @_; |
815 | |
830 | |
816 | no strict 'refs'; |
831 | no strict 'refs'; |
817 | *{"safe::$fun"} = $safe_hole->wrap ($cb); |
832 | *{"safe::$fun"} = $safe_hole->wrap ($cb); |
… | |
… | |
876 | waitpid $pid, 0 if $pid; |
891 | waitpid $pid, 0 if $pid; |
877 | if (0 == ($pid = fork)) { |
892 | if (0 == ($pid = fork)) { |
878 | $db->{_meta}{version} = 1; |
893 | $db->{_meta}{version} = 1; |
879 | Storable::nstore $db, "$path~"; |
894 | Storable::nstore $db, "$path~"; |
880 | rename "$path~", $path; |
895 | rename "$path~", $path; |
881 | kill 9, $$ if defined $pid; #d# remove when binary updated |
|
|
882 | cf::_exit 0 if defined $pid; |
896 | cf::_exit 0 if defined $pid; |
883 | } |
897 | } |
884 | } |
898 | } |
885 | |
899 | |
886 | my $dirty; |
900 | my $dirty; |