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.589 by root, Sun Nov 4 01:01:13 2012 UTC vs.
Revision 1.592 by root, Fri Nov 9 00:11:49 2012 UTC

224=item $cf::RUNTIME 224=item $cf::RUNTIME
225 225
226The time this server has run, starts at 0 and is increased by $cf::TICK on 226The time this server has run, starts at 0 and is increased by $cf::TICK on
227every server tick. 227every server tick.
228 228
229=item $cf::CONFDIR $cf::DATADIR $cf::LIBDIR $cf::PODDIR 229=item $cf::CONFDIR $cf::DATADIR $cf::LIBDIR $cf::PODDIR
230$cf::MAPDIR $cf::LOCALDIR $cf::TMPDIR $cf::UNIQUEDIR 230$cf::MAPDIR $cf::LOCALDIR $cf::TMPDIR $cf::UNIQUEDIR
231$cf::PLAYERDIR $cf::RANDOMDIR $cf::BDBDIR 231$cf::PLAYERDIR $cf::RANDOMDIR $cf::BDBDIR
232 232
233Various directories - "/etc", read-only install directory, perl-library 233Various directories - "/etc", read-only install directory, perl-library
234directory, pod-directory, read-only maps directory, "/var", "/var/tmp", 234directory, pod-directory, read-only maps directory, "/var", "/var/tmp",
235unique-items directory, player file directory, random maps directory and 235unique-items directory, player file directory, random maps directory and
236database environment. 236database environment.
3235=cut 3235=cut
3236 3236
3237sub cf::client::ext_msg($$@) { 3237sub cf::client::ext_msg($$@) {
3238 my ($self, $type, @msg) = @_; 3238 my ($self, $type, @msg) = @_;
3239 3239
3240 if ($self->extcmd == 2) {
3241 $self->send_big_packet ("ext " . $self->{json_coder}->encode ([$type, @msg])); 3240 $self->send_big_packet ("ext " . $self->{json_coder}->encode ([$type, @msg]));
3242 } elsif ($self->extcmd == 1) { # TODO: remove
3243 push @msg, msgtype => "event_$type";
3244 $self->send_big_packet ("ext " . $self->{json_coder}->encode ({@msg}));
3245 }
3246} 3241}
3247 3242
3248=item $client->ext_reply ($msgid, @msg) 3243=item $client->ext_reply ($msgid, @msg)
3249 3244
3250Sends an ext reply to the client. 3245Sends an ext reply to the client.
3251 3246
3252=cut 3247=cut
3253 3248
3254sub cf::client::ext_reply($$@) { 3249sub cf::client::ext_reply($$@) {
3255 my ($self, $id, @msg) = @_; 3250 my ($self, $id, @msg) = @_;
3256
3257 return unless $self->extcmd == 2;
3258 3251
3259 $self->send_big_packet ("ext " . $self->{json_coder}->encode (["reply-$id", @msg])); 3252 $self->send_big_packet ("ext " . $self->{json_coder}->encode (["reply-$id", @msg]));
3260} 3253}
3261 3254
3262=item $success = $client->query ($flags, "text", \&cb) 3255=item $success = $client->query ($flags, "text", \&cb)
3708 my $face = cf::face::find "sound/$v"; 3701 my $face = cf::face::find "sound/$v";
3709 cf::sound::set $k => $face; 3702 cf::sound::set $k => $face;
3710 } 3703 }
3711} 3704}
3712 3705
3706#d# move docstuff to help or so
3707our %DOCSTRING;
3708
3709sub reload_pod {
3710 trace "loading pods $PODDIR\n";
3711
3712 %DOCSTRING = ();
3713 my @command_list;
3714
3715 for (
3716 [0, "command_help"],
3717 [1, "emote_help"],
3718 [2, "dmcommand_help"],
3719 ) {
3720 my ($type, $path) = @$_;
3721
3722 my $paragraphs = &cf::pod::load_pod ("$PODDIR/$path.pod")
3723 or die "unable to load $path";
3724
3725 my $level = 1e9;
3726 my $rpar;
3727
3728 for my $par (@$paragraphs) {
3729 if ($par->{type} eq "head2") {
3730 # this code taken almost verbatim from DC/Protocol.pm
3731
3732 if ($par->{markup} =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x) {
3733 my $cmd = $1;
3734 my @args = split /\|/, $2;
3735 @args = (".*") unless @args;
3736
3737 $_ = $_ eq ".*" ? "" : " $_"
3738 for @args;
3739
3740 my @variants = map "$cmd$_", sort { (length $a) <=> (length $b) } @args;
3741
3742 $rpar = \($DOCSTRING{"command/$cmd"} = &cf::pod::as_cfpod ([$par]));
3743
3744 push @command_list, [$type, \@variants];
3745 $level = $par->{level};
3746 } else {
3747 error "$par->{markup}: unparsable command heading";
3748 }
3749 } elsif ($par->{level} > $level) {
3750 $$rpar .= &cf::pod::as_cfpod ([$par]);
3751 }
3752
3753 cf::cede_to_tick;
3754 }
3755 }
3756
3757 @command_list = sort {
3758 $a->[0] <=> $b->[0]
3759 or $a->[1] cmp $b->[1]
3760 } @command_list;
3761
3762 cf::cede_to_tick;
3763
3764 add_face "res/command_list" => FT_RSRC,
3765 JSON::XS->new->utf8->encode (\@command_list);
3766}
3767
3713sub reload_resources { 3768sub reload_resources {
3714 trace "reloading resource files...\n"; 3769 trace "reloading resource files...\n";
3715 3770
3716 reload_materials; 3771 reload_materials;
3717 reload_facedata; 3772 reload_facedata;
3718 reload_exp_table; 3773 reload_exp_table;
3719 reload_sound; 3774 reload_sound;
3720 reload_archetypes; 3775 reload_archetypes;
3721 reload_regions; 3776 reload_regions;
3722 reload_treasures; 3777 reload_treasures;
3778 reload_pod;
3723 3779
3724 trace "finished reloading resource files\n"; 3780 trace "finished reloading resource files\n";
3725} 3781}
3726 3782
3727sub reload_config { 3783sub reload_config {
3795 evthread_start IO::AIO::poll_fileno; 3851 evthread_start IO::AIO::poll_fileno;
3796 3852
3797 cf::sync_job { 3853 cf::sync_job {
3798 cf::incloader::init (); 3854 cf::incloader::init ();
3799 3855
3856 db_init;
3857
3800 cf::init_anim; 3858 cf::init_anim;
3801 cf::init_attackmess; 3859 cf::init_attackmess;
3802 cf::init_dynamic; 3860 cf::init_dynamic;
3803 3861
3804 cf::load_settings; 3862 cf::load_settings;
3805 3863
3806 reload_resources; 3864 reload_resources;
3807 reload_config; 3865 reload_config;
3808 db_init;
3809 3866
3810 cf::init_uuid; 3867 cf::init_uuid;
3811 cf::init_signals; 3868 cf::init_signals;
3812 cf::init_skills; 3869 cf::init_skills;
3813 3870
4238 } 4295 }
4239} 4296}
4240 4297
4241{ 4298{
4242 # configure BDB 4299 # configure BDB
4300 info "initialising database";
4243 4301
4244 BDB::min_parallel 16; 4302 BDB::min_parallel 16;
4245 BDB::max_poll_reqs $TICK * 0.1; 4303 BDB::max_poll_reqs $TICK * 0.1;
4246 #$AnyEvent::BDB::WATCHER->priority (1); 4304 #$AnyEvent::BDB::WATCHER->priority (1);
4247 4305
4276 BDB::db_env_txn_checkpoint $DB_ENV, 0, 0, 0, sub { }; 4334 BDB::db_env_txn_checkpoint $DB_ENV, 0, 0, 0, sub { };
4277 }; 4335 };
4278 $BDB_TRICKLE_WATCHER = EV::periodic 0, 10, 0, sub { 4336 $BDB_TRICKLE_WATCHER = EV::periodic 0, 10, 0, sub {
4279 BDB::db_env_memp_trickle $DB_ENV, 20, 0, sub { }; 4337 BDB::db_env_memp_trickle $DB_ENV, 20, 0, sub { };
4280 }; 4338 };
4339
4340 info "database initialised";
4281} 4341}
4282 4342
4283{ 4343{
4284 # configure IO::AIO 4344 # configure IO::AIO
4285 4345
4346 info "initialising aio";
4286 IO::AIO::min_parallel 8; 4347 IO::AIO::min_parallel 8;
4287 IO::AIO::max_poll_time $TICK * 0.1; 4348 IO::AIO::max_poll_time $TICK * 0.1;
4288 undef $AnyEvent::AIO::WATCHER; 4349 undef $AnyEvent::AIO::WATCHER;
4350 info "aio initialised";
4289} 4351}
4290 4352
4291our $_log_backtrace; 4353our $_log_backtrace;
4292our $_log_backtrace_last; 4354our $_log_backtrace_last;
4293 4355

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines