… | |
… | |
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; |
… | |
… | |
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 | |
116 | |
|
|
117 | our @EXTRA_MODULES = qw(pod mapscript); |
|
|
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; |
121 | our $NOW; |
123 | our $NOW; |
… | |
… | |
143 | unless ($RUNTIME || !-e $RUNTIMEFILE) { |
145 | unless ($RUNTIME || !-e $RUNTIMEFILE) { |
144 | open my $fh, "<", $RUNTIMEFILE |
146 | open my $fh, "<", $RUNTIMEFILE |
145 | or die "unable to read $RUNTIMEFILE file: $!"; |
147 | or die "unable to read $RUNTIMEFILE file: $!"; |
146 | $RUNTIME = <$fh> + 0.; |
148 | $RUNTIME = <$fh> + 0.; |
147 | } |
149 | } |
|
|
150 | |
|
|
151 | eval "sub TICK() { $TICK } 1" or die; |
148 | |
152 | |
149 | mkdir $_ |
153 | mkdir $_ |
150 | for $LOCALDIR, $TMPDIR, $UNIQUEDIR, $PLAYERDIR, $RANDOMDIR, $BDBDIR; |
154 | for $LOCALDIR, $TMPDIR, $UNIQUEDIR, $PLAYERDIR, $RANDOMDIR, $BDBDIR; |
151 | |
155 | |
152 | our $EMERGENCY_POSITION; |
156 | our $EMERGENCY_POSITION; |
… | |
… | |
2384 | |
2388 | |
2385 | our $SAY_CHANNEL = { |
2389 | our $SAY_CHANNEL = { |
2386 | id => "say", |
2390 | id => "say", |
2387 | title => "Map", |
2391 | title => "Map", |
2388 | reply => "say ", |
2392 | reply => "say ", |
2389 | tooltip => "Things said to and replied from npcs near you and other players on the same map only.", |
2393 | tooltip => "Things said to and replied from NPCs near you and other players on the same map only.", |
2390 | }; |
2394 | }; |
2391 | |
2395 | |
2392 | our $CHAT_CHANNEL = { |
2396 | our $CHAT_CHANNEL = { |
2393 | id => "chat", |
2397 | id => "chat", |
2394 | title => "Chat", |
2398 | title => "Chat", |
… | |
… | |
3052 | The following functions and methods are available within a safe environment: |
3056 | The following functions and methods are available within a safe environment: |
3053 | |
3057 | |
3054 | cf::object |
3058 | cf::object |
3055 | contr pay_amount pay_player map x y force_find force_add destroy |
3059 | contr pay_amount pay_player map x y force_find force_add destroy |
3056 | insert remove name archname title slaying race decrease split |
3060 | insert remove name archname title slaying race decrease split |
|
|
3061 | value |
3057 | |
3062 | |
3058 | cf::object::player |
3063 | cf::object::player |
3059 | player |
3064 | player |
3060 | |
3065 | |
3061 | cf::player |
3066 | cf::player |
… | |
… | |
3067 | =cut |
3072 | =cut |
3068 | |
3073 | |
3069 | for ( |
3074 | for ( |
3070 | ["cf::object" => qw(contr pay_amount pay_player map force_find force_add x y |
3075 | ["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 |
3076 | insert remove inv nrof name archname title slaying race |
3072 | decrease split destroy change_exp)], |
3077 | decrease split destroy change_exp value msg lore send_msg)], |
3073 | ["cf::object::player" => qw(player)], |
3078 | ["cf::object::player" => qw(player)], |
3074 | ["cf::player" => qw(peaceful)], |
3079 | ["cf::player" => qw(peaceful send_msg)], |
3075 | ["cf::map" => qw(trigger)], |
3080 | ["cf::map" => qw(trigger)], |
3076 | ) { |
3081 | ) { |
3077 | no strict 'refs'; |
3082 | no strict 'refs'; |
3078 | my ($pkg, @funs) = @$_; |
3083 | my ($pkg, @funs) = @$_; |
3079 | *{"safe::$pkg\::$_"} = $safe_hole->wrap (\&{"$pkg\::$_"}) |
3084 | *{"safe::$pkg\::$_"} = $safe_hole->wrap (\&{"$pkg\::$_"}) |
… | |
… | |
3096 | my ($code, %vars) = @_; |
3101 | my ($code, %vars) = @_; |
3097 | |
3102 | |
3098 | my $qcode = $code; |
3103 | my $qcode = $code; |
3099 | $qcode =~ s/"/‟/g; # not allowed in #line filenames |
3104 | $qcode =~ s/"/‟/g; # not allowed in #line filenames |
3100 | $qcode =~ s/\n/\\n/g; |
3105 | $qcode =~ s/\n/\\n/g; |
|
|
3106 | |
|
|
3107 | %vars = (_dummy => 0) unless %vars; |
3101 | |
3108 | |
3102 | local $_; |
3109 | local $_; |
3103 | local @safe::cf::_safe_eval_args = values %vars; |
3110 | local @safe::cf::_safe_eval_args = values %vars; |
3104 | |
3111 | |
3105 | my $eval = |
3112 | my $eval = |
… | |
… | |
3693 | clear_package "safe::$_" |
3700 | clear_package "safe::$_" |
3694 | for qw(cf::attachable cf::object cf::object::player cf::client cf::player cf::map cf::party cf::region); |
3701 | for qw(cf::attachable cf::object cf::object::player cf::client cf::player cf::map cf::party cf::region); |
3695 | |
3702 | |
3696 | warn "unloading cf.pm \"a bit\""; |
3703 | warn "unloading cf.pm \"a bit\""; |
3697 | delete $INC{"cf.pm"}; |
3704 | delete $INC{"cf.pm"}; |
3698 | delete $INC{"cf/pod.pm"}; |
3705 | delete $INC{"cf/$_.pm"} for @EXTRA_MODULES; |
3699 | |
3706 | |
3700 | # don't, removes xs symbols, too, |
3707 | # don't, removes xs symbols, too, |
3701 | # and global variables created in xs |
3708 | # and global variables created in xs |
3702 | #clear_package __PACKAGE__; |
3709 | #clear_package __PACKAGE__; |
3703 | |
3710 | |
… | |
… | |
3920 | LOG llevInfo, "[ABT] [suppressed]\n"; |
3927 | LOG llevInfo, "[ABT] [suppressed]\n"; |
3921 | } |
3928 | } |
3922 | } |
3929 | } |
3923 | |
3930 | |
3924 | # load additional modules |
3931 | # load additional modules |
3925 | use cf::pod; |
3932 | require "cf/$_.pm" for @EXTRA_MODULES; |
3926 | |
3933 | |
3927 | END { cf::emergency_save } |
3934 | END { cf::emergency_save } |
3928 | |
3935 | |
3929 | 1 |
3936 | 1 |
3930 | |
3937 | |