ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/books.ext
Revision: 1.3
Committed: Tue Jul 10 05:51:38 2007 UTC (16 years, 10 months ago) by root
Branch: MAIN
CVS Tags: rel-2_6, rel-2_7, rel-2_4, rel-2_5, rel-2_2, rel-2_3, rel-2_54, rel-2_55, rel-2_56, rel-2_52, rel-2_53, rel-2_32, rel-2_61, rel-2_43, rel-2_42, rel-2_41
Changes since 1.2: +4 -2 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

# Content
1 #! perl # mandatory
2
3 our @BOOKS;
4
5 sub reload() {
6 @BOOKS = ();
7
8 my $paragraphs = cf::pod::load_pod "$PODDIR/books.pod"
9 or die "unable to load $PODDIR/books.pod";
10
11 my $level = 1e9;
12 my @books;
13
14 for my $par (@$paragraphs) {
15 if ($par->{type} eq "head1") {
16 if ($par->{markup} =~ /^(\S+)/) {
17 push @books, [$par];
18 $level = $par->{level};
19 }
20 } elsif ($par->{level} > $level) {
21 push @{ $books[-1] }, $par;
22 }
23 }
24
25 @BOOKS = @books;
26 }
27
28 cf::sync_job {
29 reload;
30 };
31
32 sub make_book {
33 my ($book, $level) = @_;
34
35 return unless @BOOKS;
36
37 my ($title, @body) = @{$BOOKS[rand @BOOKS]};
38
39 # half-assed attempt to make it a single line text-only title
40 $title = cf::pod::as_cfpod [$title];
41 $title =~ s/\n/ /g;
42 $title =~ s/ +$//;
43 $title =~ s/B<([^>]*)>/$1/g;
44
45 $book->name ($title);
46 $book->name_pl ($title);
47 $book->title (undef);
48 $book->msg (cf::pod::as_cfpod \@body);
49 }
50