ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/help.ext
(Generate patch)

Comparing deliantra/server/ext/help.ext (file contents):
Revision 1.1 by pippijn, Thu Mar 1 13:35:39 2007 UTC vs.
Revision 1.2 by root, Wed Apr 18 17:32:06 2007 UTC

1#! perl 1#! perl
2 2
3#-------------------------------------------------- 3our $TOPIC;
4
5sub load_topics($) {
6 my ($path) = @_;
7
8 my $paragraphs = cf::pod::load_pod "$PODDIR/$path.pod"
9 or die "unable to load $path";
10
11 my @topics;
12 my $level = 1e9;
13
14 for my $par (@$paragraphs) {
15 Coro::cede;
16 if ($par->{type} eq "head2") {
17 if ($par->{markup} =~ /^(\S+)/) {
18 push @topics, $1 => [$par];
19 $level = $par->{level};
20 }
21 } elsif ($par->{level} > $level) {
22 push @{ $topics[-1] }, $par;
23 }
24 }
25
26 @topics
27}
28
29sub reload() {
30 $TOPIC = {
31 load_topics "dmcommand_help",
32 load_topics "emote_help",
33 load_topics "command_help",
34 load_topics "generic_help",
35 };
36}
37
38cf::sync_job {
39 my $guard = cf::lock_acquire "ext::help::loading";
40 cf::async_ext {
41 reload;
42 undef $guard;
43 };
44};
45
4# cf::register_command help => sub { 46cf::register_command xhelp => sub {
5# my ($pl, $topic) = @_; 47 my ($pl, $topic) = @_;
6# 48
7# $pl->reply (undef, "Help on $topic"); 49 if (cf::lock_active "ext::help::loading") {
8# }; 50 $pl->reply (undef, "help files are being loaded currently, try again in a few seconds");
9#-------------------------------------------------- 51 return;
52 }
53};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines