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.78 by root, Tue Nov 7 00:15:27 2006 UTC vs.
Revision 1.83 by root, Mon Dec 11 01:30:41 2006 UTC

28our $TICK_WATCHER; 28our $TICK_WATCHER;
29our $NEXT_TICK; 29our $NEXT_TICK;
30 30
31our %CFG; 31our %CFG;
32 32
33our $uptime; 33our $uptime;#d#
34 34our $UPTIME;
35$uptime ||= time; 35$UPTIME ||= $uptime;#d#
36$UPTIME ||= time;
36 37
37############################################################################# 38#############################################################################
38 39
39=head2 GLOBAL VARIABLES 40=head2 GLOBAL VARIABLES
40 41
41=over 4 42=over 4
43
44=item $cf::UPTIME
45
46The timestamp of the server start (so not actually an uptime).
42 47
43=item $cf::LIBDIR 48=item $cf::LIBDIR
44 49
45The perl library directory, where extensions and cf-specific modules can 50The perl library directory, where extensions and cf-specific modules can
46be found. It will be added to C<@INC> automatically. 51be found. It will be added to C<@INC> automatically.
523 unlink $filename; 528 unlink $filename;
524 unlink "$filename.pst"; 529 unlink "$filename.pst";
525 } 530 }
526} 531}
527 532
533sub object_freezer_as_string {
534 my ($rdata, $objs) = @_;
535
536 use Data::Dumper;
537
538 $$rdata . Dumper $objs
539}
540
528sub object_thawer_load { 541sub object_thawer_load {
529 my ($filename) = @_; 542 my ($filename) = @_;
530 543
531 local $/; 544 local $/;
532 545
634 . "#line 1 \"$path\"\n{\n" 647 . "#line 1 \"$path\"\n{\n"
635 . (do { local $/; <$fh> }) 648 . (do { local $/; <$fh> })
636 . "\n};\n1"; 649 . "\n};\n1";
637 650
638 eval $source 651 eval $source
639 or die "$path: $@"; 652 or die $@ ? "$path: $@\n"
653 : "extension disabled.\n";
640 654
641 push @exts, $pkg; 655 push @exts, $pkg;
642 $ext_pkg{$base} = $pkg; 656 $ext_pkg{$base} = $pkg;
643 657
644# no strict 'refs'; 658# no strict 'refs';
775sub cf::player::exists($) { 789sub cf::player::exists($) {
776 cf::player::find $_[0] 790 cf::player::find $_[0]
777 or -f sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($_[0]) x 2; 791 or -f sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($_[0]) x 2;
778} 792}
779 793
780=item $object->reply ($npc, $msg[, $flags]) 794=item $player_object->reply ($npc, $msg[, $flags])
781 795
782Sends a message to the player, as if the npc C<$npc> replied. C<$npc> 796Sends a message to the player, as if the npc C<$npc> replied. C<$npc>
783can be C<undef>. Does the right thing when the player is currently in a 797can be C<undef>. Does the right thing when the player is currently in a
784dialogue with the given NPC character. 798dialogue with the given NPC character.
785 799
812 $msg{msgid} = $id; 826 $msg{msgid} = $id;
813 827
814 $self->send ("ext " . to_json \%msg); 828 $self->send ("ext " . to_json \%msg);
815} 829}
816 830
817=back 831=item $player_object->may ("access")
832
833Returns wether the given player is authorized to access resource "access"
834(e.g. "command_wizcast").
835
836=cut
837
838sub cf::object::player::may {
839 my ($self, $access) = @_;
840
841 $self->flag (cf::FLAG_WIZ) ||
842 (ref $cf::CFG{"may_$access"}
843 ? scalar grep $self->name eq $_, @{$cf::CFG{"may_$access"}}
844 : $cf::CFG{"may_$access"})
845}
818 846
819=cut 847=cut
820 848
821############################################################################# 849#############################################################################
822 850
824 852
825Functions that provide a safe environment to compile and execute 853Functions that provide a safe environment to compile and execute
826snippets of perl code without them endangering the safety of the server 854snippets of perl code without them endangering the safety of the server
827itself. Looping constructs, I/O operators and other built-in functionality 855itself. Looping constructs, I/O operators and other built-in functionality
828is not available in the safe scripting environment, and the number of 856is not available in the safe scripting environment, and the number of
829functions and methods that cna be called is greatly reduced. 857functions and methods that can be called is greatly reduced.
830 858
831=cut 859=cut
832 860
833our $safe = new Safe "safe"; 861our $safe = new Safe "safe";
834our $safe_hole = new Safe::Hole; 862our $safe_hole = new Safe::Hole;
1163 $TICK_WATCHER->at ($NEXT_TICK); 1191 $TICK_WATCHER->at ($NEXT_TICK);
1164 $TICK_WATCHER->start; 1192 $TICK_WATCHER->start;
1165 }, 1193 },
1166); 1194);
1167 1195
1168eval { IO::AIO::max_poll_time $TICK * 0.2 }; #d# remove eval after restart 1196IO::AIO::max_poll_time $TICK * 0.2;
1169 1197
1170Event->io (fd => IO::AIO::poll_fileno, 1198Event->io (fd => IO::AIO::poll_fileno,
1171 poll => 'r', 1199 poll => 'r',
1172 prio => 5, 1200 prio => 5,
1173 cb => \&IO::AIO::poll_cb); 1201 cb => \&IO::AIO::poll_cb);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines