… | |
… | |
21 | |
21 | |
22 | package cf; |
22 | package cf; |
23 | |
23 | |
24 | use 5.10.0; |
24 | use 5.10.0; |
25 | use utf8; |
25 | use utf8; |
26 | use strict "vars", "subs"; |
26 | use strict qw(vars subs); |
27 | |
27 | |
28 | use Symbol; |
28 | use Symbol; |
29 | use List::Util; |
29 | use List::Util; |
30 | use Socket; |
30 | use Socket; |
31 | use EV; |
31 | use EV; |
… | |
… | |
111 | |
111 | |
112 | our $BDB_DEADLOCK_WATCHER; |
112 | our $BDB_DEADLOCK_WATCHER; |
113 | our $BDB_CHECKPOINT_WATCHER; |
113 | our $BDB_CHECKPOINT_WATCHER; |
114 | our $BDB_TRICKLE_WATCHER; |
114 | our $BDB_TRICKLE_WATCHER; |
115 | our $DB_ENV; |
115 | our $DB_ENV; |
|
|
116 | |
|
|
117 | our @EXTRA_MODULES = qw(pod mapscript); |
116 | |
118 | |
117 | our %CFG; |
119 | our %CFG; |
118 | |
120 | |
119 | our $UPTIME; $UPTIME ||= time; |
121 | our $UPTIME; $UPTIME ||= time; |
120 | our $RUNTIME; |
122 | our $RUNTIME; |
… | |
… | |
3052 | The following functions and methods are available within a safe environment: |
3054 | The following functions and methods are available within a safe environment: |
3053 | |
3055 | |
3054 | cf::object |
3056 | cf::object |
3055 | contr pay_amount pay_player map x y force_find force_add destroy |
3057 | contr pay_amount pay_player map x y force_find force_add destroy |
3056 | insert remove name archname title slaying race decrease split |
3058 | insert remove name archname title slaying race decrease split |
|
|
3059 | value |
3057 | |
3060 | |
3058 | cf::object::player |
3061 | cf::object::player |
3059 | player |
3062 | player |
3060 | |
3063 | |
3061 | cf::player |
3064 | cf::player |
… | |
… | |
3067 | =cut |
3070 | =cut |
3068 | |
3071 | |
3069 | for ( |
3072 | for ( |
3070 | ["cf::object" => qw(contr pay_amount pay_player map force_find force_add x y |
3073 | ["cf::object" => qw(contr pay_amount pay_player map force_find force_add x y |
3071 | insert remove inv nrof name archname title slaying race |
3074 | insert remove inv nrof name archname title slaying race |
3072 | decrease split destroy change_exp)], |
3075 | decrease split destroy change_exp value msg lore send_msg)], |
3073 | ["cf::object::player" => qw(player)], |
3076 | ["cf::object::player" => qw(player)], |
3074 | ["cf::player" => qw(peaceful)], |
3077 | ["cf::player" => qw(peaceful send_msg)], |
3075 | ["cf::map" => qw(trigger)], |
3078 | ["cf::map" => qw(trigger)], |
3076 | ) { |
3079 | ) { |
3077 | no strict 'refs'; |
3080 | no strict 'refs'; |
3078 | my ($pkg, @funs) = @$_; |
3081 | my ($pkg, @funs) = @$_; |
3079 | *{"safe::$pkg\::$_"} = $safe_hole->wrap (\&{"$pkg\::$_"}) |
3082 | *{"safe::$pkg\::$_"} = $safe_hole->wrap (\&{"$pkg\::$_"}) |
… | |
… | |
3096 | my ($code, %vars) = @_; |
3099 | my ($code, %vars) = @_; |
3097 | |
3100 | |
3098 | my $qcode = $code; |
3101 | my $qcode = $code; |
3099 | $qcode =~ s/"/‟/g; # not allowed in #line filenames |
3102 | $qcode =~ s/"/‟/g; # not allowed in #line filenames |
3100 | $qcode =~ s/\n/\\n/g; |
3103 | $qcode =~ s/\n/\\n/g; |
|
|
3104 | |
|
|
3105 | %vars = (_dummy => 0) unless %vars; |
3101 | |
3106 | |
3102 | local $_; |
3107 | local $_; |
3103 | local @safe::cf::_safe_eval_args = values %vars; |
3108 | local @safe::cf::_safe_eval_args = values %vars; |
3104 | |
3109 | |
3105 | my $eval = |
3110 | my $eval = |
… | |
… | |
3693 | clear_package "safe::$_" |
3698 | clear_package "safe::$_" |
3694 | for qw(cf::attachable cf::object cf::object::player cf::client cf::player cf::map cf::party cf::region); |
3699 | for qw(cf::attachable cf::object cf::object::player cf::client cf::player cf::map cf::party cf::region); |
3695 | |
3700 | |
3696 | warn "unloading cf.pm \"a bit\""; |
3701 | warn "unloading cf.pm \"a bit\""; |
3697 | delete $INC{"cf.pm"}; |
3702 | delete $INC{"cf.pm"}; |
3698 | delete $INC{"cf/pod.pm"}; |
3703 | delete $INC{"cf/$_.pm"} for @EXTRA_MODULES; |
3699 | |
3704 | |
3700 | # don't, removes xs symbols, too, |
3705 | # don't, removes xs symbols, too, |
3701 | # and global variables created in xs |
3706 | # and global variables created in xs |
3702 | #clear_package __PACKAGE__; |
3707 | #clear_package __PACKAGE__; |
3703 | |
3708 | |
… | |
… | |
3920 | LOG llevInfo, "[ABT] [suppressed]\n"; |
3925 | LOG llevInfo, "[ABT] [suppressed]\n"; |
3921 | } |
3926 | } |
3922 | } |
3927 | } |
3923 | |
3928 | |
3924 | # load additional modules |
3929 | # load additional modules |
3925 | use cf::pod; |
3930 | eval "use cf::$_" for @EXTRA_MODULES; |
3926 | |
3931 | |
3927 | END { cf::emergency_save } |
3932 | END { cf::emergency_save } |
3928 | |
3933 | |
3929 | 1 |
3934 | 1 |
3930 | |
3935 | |