… | |
… | |
25 | our %EXTCMD = (); |
25 | our %EXTCMD = (); |
26 | |
26 | |
27 | _init_vars; |
27 | _init_vars; |
28 | |
28 | |
29 | our @EVENT; |
29 | our @EVENT; |
30 | our $LIBDIR = maps_directory "perl"; |
30 | our $LIBDIR = datadir . "/ext"; |
31 | |
31 | |
32 | our $TICK = MAX_TIME * 1e-6; |
32 | our $TICK = MAX_TIME * 1e-6; |
33 | our $TICK_WATCHER; |
33 | our $TICK_WATCHER; |
34 | our $NEXT_TICK; |
34 | our $NEXT_TICK; |
35 | |
35 | |
… | |
… | |
80 | |
80 | |
81 | # we bless all objects into (empty) derived classes to force a method lookup |
81 | # we bless all objects into (empty) derived classes to force a method lookup |
82 | # within the Safe compartment. |
82 | # within the Safe compartment. |
83 | for my $pkg (qw( |
83 | for my $pkg (qw( |
84 | cf::object cf::object::player |
84 | cf::object cf::object::player |
85 | cf::client_socket cf::player |
85 | cf::client cf::player |
86 | cf::arch cf::living |
86 | cf::arch cf::living |
87 | cf::map cf::party cf::region |
87 | cf::map cf::party cf::region |
88 | )) { |
88 | )) { |
89 | no strict 'refs'; |
89 | no strict 'refs'; |
90 | @{"safe::$pkg\::wrap::ISA"} = @{"$pkg\::wrap::ISA"} = $pkg; |
90 | @{"safe::$pkg\::wrap::ISA"} = @{"$pkg\::wrap::ISA"} = $pkg; |
… | |
… | |
720 | |
720 | |
721 | Symbol::delete_package $pkg; |
721 | Symbol::delete_package $pkg; |
722 | } |
722 | } |
723 | |
723 | |
724 | sub load_extensions { |
724 | sub load_extensions { |
725 | my $LIBDIR = maps_directory "perl"; |
|
|
726 | |
|
|
727 | for my $ext (<$LIBDIR/*.ext>) { |
725 | for my $ext (<$LIBDIR/*.ext>) { |
728 | next unless -r $ext; |
726 | next unless -r $ext; |
729 | eval { |
727 | eval { |
730 | load_extension $ext; |
728 | load_extension $ext; |
731 | 1 |
729 | 1 |
… | |
… | |
866 | |
864 | |
867 | =pod |
865 | =pod |
868 | |
866 | |
869 | The following fucntions and emthods are available within a safe environment: |
867 | The following fucntions and emthods are available within a safe environment: |
870 | |
868 | |
871 | cf::object contr pay_amount pay_player |
869 | cf::object contr pay_amount pay_player map |
872 | cf::object::player player |
870 | cf::object::player player |
873 | cf::player peaceful |
871 | cf::player peaceful |
|
|
872 | cf::map trigger |
874 | |
873 | |
875 | =cut |
874 | =cut |
876 | |
875 | |
877 | for ( |
876 | for ( |
878 | ["cf::object" => qw(contr pay_amount pay_player)], |
877 | ["cf::object" => qw(contr pay_amount pay_player map)], |
879 | ["cf::object::player" => qw(player)], |
878 | ["cf::object::player" => qw(player)], |
880 | ["cf::player" => qw(peaceful)], |
879 | ["cf::player" => qw(peaceful)], |
|
|
880 | ["cf::map" => qw(trigger)], |
881 | ) { |
881 | ) { |
882 | no strict 'refs'; |
882 | no strict 'refs'; |
883 | my ($pkg, @funs) = @$_; |
883 | my ($pkg, @funs) = @$_; |
884 | *{"safe::$pkg\::$_"} = $safe_hole->wrap (\&{"$pkg\::$_"}) |
884 | *{"safe::$pkg\::$_"} = $safe_hole->wrap (\&{"$pkg\::$_"}) |
885 | for @funs; |
885 | for @funs; |
… | |
… | |
1173 | }; |
1173 | }; |
1174 | |
1174 | |
1175 | unshift @INC, $LIBDIR; |
1175 | unshift @INC, $LIBDIR; |
1176 | |
1176 | |
1177 | $TICK_WATCHER = Event->timer ( |
1177 | $TICK_WATCHER = Event->timer ( |
1178 | prio => 1, |
1178 | prio => 0, |
1179 | async => 1, |
|
|
1180 | at => $NEXT_TICK || 1, |
1179 | at => $NEXT_TICK || 1, |
1181 | data => WF_AUTOCANCEL, |
1180 | data => WF_AUTOCANCEL, |
1182 | cb => sub { |
1181 | cb => sub { |
1183 | cf::server_tick; # one server iteration |
1182 | cf::server_tick; # one server iteration |
1184 | |
1183 | |