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.463 by root, Sun Dec 28 06:59:27 2008 UTC vs.
Revision 1.468 by root, Thu Jan 8 19:23:44 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;
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 116
117our @EXTRA_MODULES = qw(pod mapscript);
118
117our %CFG; 119our %CFG;
118 120
119our $UPTIME; $UPTIME ||= time; 121our $UPTIME; $UPTIME ||= time;
120our $RUNTIME; 122our $RUNTIME;
121our $NOW; 123our $NOW;
143unless ($RUNTIME || !-e $RUNTIMEFILE) { 145unless ($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
151eval "sub TICK() { $TICK } 1" or die;
148 152
149mkdir $_ 153mkdir $_
150 for $LOCALDIR, $TMPDIR, $UNIQUEDIR, $PLAYERDIR, $RANDOMDIR, $BDBDIR; 154 for $LOCALDIR, $TMPDIR, $UNIQUEDIR, $PLAYERDIR, $RANDOMDIR, $BDBDIR;
151 155
152our $EMERGENCY_POSITION; 156our $EMERGENCY_POSITION;
2384 2388
2385our $SAY_CHANNEL = { 2389our $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
2392our $CHAT_CHANNEL = { 2396our $CHAT_CHANNEL = {
2393 id => "chat", 2397 id => "chat",
2394 title => "Chat", 2398 title => "Chat",
2769 id => "infobox", 2773 id => "infobox",
2770 title => "Body Parts", 2774 title => "Body Parts",
2771 reply => undef, 2775 reply => undef,
2772 tooltip => "Shows which body parts you posess and are available", 2776 tooltip => "Shows which body parts you posess and are available",
2773 }, 2777 },
2778 "c/statistics" => {
2779 id => "infobox",
2780 title => "Statistics",
2781 reply => undef,
2782 tooltip => "Shows your primary statistics",
2783 },
2774 "c/skills" => { 2784 "c/skills" => {
2775 id => "infobox", 2785 id => "infobox",
2776 title => "Skills", 2786 title => "Skills",
2777 reply => undef, 2787 reply => undef,
2778 tooltip => "Shows your experience per skill and item power", 2788 tooltip => "Shows your experience per skill and item power",
2789 },
2790 "c/resistances" => {
2791 id => "infobox",
2792 title => "Resistances",
2793 reply => undef,
2794 tooltip => "Shows your resistances",
2795 },
2796 "c/pets" => {
2797 id => "infobox",
2798 title => "Pets",
2799 reply => undef,
2800 tooltip => "Shows information abotu your pets/a specific pet",
2779 }, 2801 },
2780 "c/uptime" => { 2802 "c/uptime" => {
2781 id => "infobox", 2803 id => "infobox",
2782 title => "Uptime", 2804 title => "Uptime",
2783 reply => undef, 2805 reply => undef,
2793 id => "party", 2815 id => "party",
2794 title => "Party", 2816 title => "Party",
2795 reply => "gsay ", 2817 reply => "gsay ",
2796 tooltip => "Messages and chat related to your party", 2818 tooltip => "Messages and chat related to your party",
2797 }, 2819 },
2820 "c/death" => {
2821 id => "death",
2822 title => "Death",
2823 reply => undef,
2824 tooltip => "Reason for and more info about your most recent death",
2825 },
2798 "c/say" => $SAY_CHANNEL, 2826 "c/say" => $SAY_CHANNEL,
2799 "c/chat" => $CHAT_CHANNEL, 2827 "c/chat" => $CHAT_CHANNEL,
2800); 2828);
2801 2829
2802sub cf::client::send_msg { 2830sub cf::client::send_msg {
3028The following functions and methods are available within a safe environment: 3056The following functions and methods are available within a safe environment:
3029 3057
3030 cf::object 3058 cf::object
3031 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
3032 insert remove name archname title slaying race decrease split 3060 insert remove name archname title slaying race decrease split
3061 value
3033 3062
3034 cf::object::player 3063 cf::object::player
3035 player 3064 player
3036 3065
3037 cf::player 3066 cf::player
3043=cut 3072=cut
3044 3073
3045for ( 3074for (
3046 ["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
3047 insert remove inv nrof name archname title slaying race 3076 insert remove inv nrof name archname title slaying race
3048 decrease split destroy change_exp)], 3077 decrease split destroy change_exp value msg lore send_msg)],
3049 ["cf::object::player" => qw(player)], 3078 ["cf::object::player" => qw(player)],
3050 ["cf::player" => qw(peaceful)], 3079 ["cf::player" => qw(peaceful send_msg)],
3051 ["cf::map" => qw(trigger)], 3080 ["cf::map" => qw(trigger)],
3052) { 3081) {
3053 no strict 'refs'; 3082 no strict 'refs';
3054 my ($pkg, @funs) = @$_; 3083 my ($pkg, @funs) = @$_;
3055 *{"safe::$pkg\::$_"} = $safe_hole->wrap (\&{"$pkg\::$_"}) 3084 *{"safe::$pkg\::$_"} = $safe_hole->wrap (\&{"$pkg\::$_"})
3072 my ($code, %vars) = @_; 3101 my ($code, %vars) = @_;
3073 3102
3074 my $qcode = $code; 3103 my $qcode = $code;
3075 $qcode =~ s/"/‟/g; # not allowed in #line filenames 3104 $qcode =~ s/"/‟/g; # not allowed in #line filenames
3076 $qcode =~ s/\n/\\n/g; 3105 $qcode =~ s/\n/\\n/g;
3106
3107 %vars = (_dummy => 0) unless %vars;
3077 3108
3078 local $_; 3109 local $_;
3079 local @safe::cf::_safe_eval_args = values %vars; 3110 local @safe::cf::_safe_eval_args = values %vars;
3080 3111
3081 my $eval = 3112 my $eval =
3669 clear_package "safe::$_" 3700 clear_package "safe::$_"
3670 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);
3671 3702
3672 warn "unloading cf.pm \"a bit\""; 3703 warn "unloading cf.pm \"a bit\"";
3673 delete $INC{"cf.pm"}; 3704 delete $INC{"cf.pm"};
3674 delete $INC{"cf/pod.pm"}; 3705 delete $INC{"cf/$_.pm"} for @EXTRA_MODULES;
3675 3706
3676 # don't, removes xs symbols, too, 3707 # don't, removes xs symbols, too,
3677 # and global variables created in xs 3708 # and global variables created in xs
3678 #clear_package __PACKAGE__; 3709 #clear_package __PACKAGE__;
3679 3710
3896 LOG llevInfo, "[ABT] [suppressed]\n"; 3927 LOG llevInfo, "[ABT] [suppressed]\n";
3897 } 3928 }
3898} 3929}
3899 3930
3900# load additional modules 3931# load additional modules
3901use cf::pod; 3932require "cf/$_.pm" for @EXTRA_MODULES;
3902 3933
3903END { cf::emergency_save } 3934END { cf::emergency_save }
3904 3935
39051 39361
3906 3937

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines