ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/help.ext
Revision: 1.9
Committed: Tue Jul 10 05:51:38 2007 UTC (16 years, 10 months ago) by root
Branch: MAIN
CVS Tags: rel-2_2
Changes since 1.8: +1 -1 lines
Log Message:
- improve dynbuf implementation further
- save now saves shstrs longer than HUGE_BUF, lets fix any brokenness remaining
  in the server...
- converted most describe_*-functions to dynbuf_text, making them likely
  faster (or maybe slower), while removing any hardcoded length limit.
- memory allocated for static dynbuf's is not being returned ever (at least
  not the initial chunk, maybe fix this?)
- implement framework for predeclared const shstrs for comparison purposes
  (shstrinc.h).
- enabled and enforced new material code.
- implement hack to clean up book titles.
- increases HUGE_BUF to 10240, to be similar to mac network packet size.

File Contents

# User Rev Content
1 pippijn 1.1 #! perl
2    
3 root 1.2 our $TOPIC;
4    
5 root 1.3 sub load_topics($$) {
6     my ($type, $path) = @_;
7 root 1.2
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 root 1.3 push @topics, $1 => [$type => $par];
19 root 1.2 $level = $par->{level};
20     }
21     } elsif ($par->{level} > $level) {
22     push @{ $topics[-1] }, $par;
23     }
24     }
25    
26     @topics
27     }
28    
29     sub reload() {
30     $TOPIC = {
31 root 1.3 (load_topics "DM Commands" => "dmcommand_help"),
32     (load_topics "Emotes" => "emote_help"),
33     (load_topics "Commands" => "command_help"),
34     (load_topics "Generic Help Topics" => "generic_help"),
35 root 1.2 };
36     }
37    
38     cf::sync_job {
39     my $guard = cf::lock_acquire "ext::help::loading";
40     cf::async_ext {
41     reload;
42     undef $guard;
43     };
44     };
45    
46 root 1.6 # for lack of a better place: "media tags"
47     # b bold
48     # i italic
49     # ul underlined
50     # fixed font
51     # arcane font
52     # hand font
53     # strange font
54     # print font (default)
55     # color=xxx
56    
57 root 1.3 cf::register_command help => sub {
58 root 1.2 my ($pl, $topic) = @_;
59    
60     if (cf::lock_active "ext::help::loading") {
61 root 1.3 $pl->reply (undef, "help files are being loaded currently, try again in a few seconds.");
62 root 1.2 return;
63     }
64 root 1.3
65     $topic = $1 if $topic =~ /(\S+)/;
66    
67     if (!length $topic) {
68     # sort..
69    
70     my %topics;
71     while (my ($k, $v) = each %$TOPIC) {
72     push @{$topics{$v->[0]}}, $k;
73     }
74    
75     my $res;
76     while (my ($k, $v) = each %topics) {
77 root 1.8 $res .= "B<$k:>\n" . (join " ", sort @$v) . "\n\n";
78 root 1.3 }
79    
80     $pl->reply (undef, $res);
81    
82 root 1.7 } elsif (my $item = $TOPIC->{$topic}) {
83     my ($type, @pars) = @$item;
84 root 1.9 $pl->reply (undef, cf::pod::as_cfpod \@pars);
85 root 1.3
86     } else {
87     $pl->reply (undef, "'$topic' no such help topic, try just 'help' to get a list of topics.");
88     }
89 root 1.2 };
90 root 1.3