ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.465 by root, Thu Jan 8 00:54:55 2009 UTC vs.
Revision 1.466 by root, Thu Jan 8 03:03:24 2009 UTC

21 21
22package cf; 22package cf;
23 23
24use 5.10.0; 24use 5.10.0;
25use utf8; 25use utf8;
26use strict "vars", "subs"; 26use strict qw(vars subs);
27 27
28use Symbol; 28use Symbol;
29use List::Util; 29use List::Util;
30use Socket; 30use Socket;
31use EV; 31use EV;
111 111
112our $BDB_DEADLOCK_WATCHER; 112our $BDB_DEADLOCK_WATCHER;
113our $BDB_CHECKPOINT_WATCHER; 113our $BDB_CHECKPOINT_WATCHER;
114our $BDB_TRICKLE_WATCHER; 114our $BDB_TRICKLE_WATCHER;
115our $DB_ENV; 115our $DB_ENV;
116
117our @EXTRA_MODULES = qw(pod mapscript);
116 118
117our %CFG; 119our %CFG;
118 120
119our $UPTIME; $UPTIME ||= time; 121our $UPTIME; $UPTIME ||= time;
120our $RUNTIME; 122our $RUNTIME;
3052The following functions and methods are available within a safe environment: 3054The 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
3069for ( 3072for (
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
3925use cf::pod; 3930eval "use cf::$_" for @EXTRA_MODULES;
3926 3931
3927END { cf::emergency_save } 3932END { cf::emergency_save }
3928 3933
39291 39341
3930 3935

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines