| 1 | #!/usr/bin/env perl |
|---|
| 2 | # |
|---|
| 3 | # Generate game/txt/hlp/ files from the CHANGES file(s). |
|---|
| 4 | # Should be run by Makefile from top-level directory |
|---|
| 5 | # |
|---|
| 6 | # Usage: mkvershlp game/txt/hlp CHANGES.176 CHANGES.OLD ... |
|---|
| 7 | # |
|---|
| 8 | # Each file CHANGES.<blah> generates file pennv<blah>.hlp in the |
|---|
| 9 | # specified directory. |
|---|
| 10 | # |
|---|
| 11 | use strict; |
|---|
| 12 | use Sort::Versions; |
|---|
| 13 | use Text::Wrap; |
|---|
| 14 | |
|---|
| 15 | my $targetdir = shift; |
|---|
| 16 | my @sources = @ARGV; |
|---|
| 17 | my $verspat = '^Version (\S+) patchlevel (\S+)'; |
|---|
| 18 | my %patchlevels; |
|---|
| 19 | |
|---|
| 20 | @sources = sort byrevision @sources; |
|---|
| 21 | |
|---|
| 22 | my $really_started = 0; |
|---|
| 23 | foreach my $file (@sources) { |
|---|
| 24 | next if $file =~ /~$/o; |
|---|
| 25 | warn "Can't open $file!\n", next unless open(IN,"<$file"); |
|---|
| 26 | my $target = $file; |
|---|
| 27 | $target =~ s/.*\.(.*)/pennv$1.hlp/; |
|---|
| 28 | open(OUT,">$targetdir/$target") or die "Unable to open $targetdir/$target\n"; |
|---|
| 29 | my $started = 0; |
|---|
| 30 | while (<IN>) { |
|---|
| 31 | if (/$verspat/o) { |
|---|
| 32 | print OUT "& $1p$2\n"; |
|---|
| 33 | push @{$patchlevels{$1}}, $2; |
|---|
| 34 | unless ($started) { |
|---|
| 35 | # This is the first one |
|---|
| 36 | unless ($really_started) { |
|---|
| 37 | print OUT <<'EOP'; |
|---|
| 38 | & changes |
|---|
| 39 | This is a list of changes in this patchlevel which are probably of |
|---|
| 40 | interest to players. More information about new commands and functions |
|---|
| 41 | can probably be gotten via 'help <name of whatever>'. 'help credits' |
|---|
| 42 | lists the [initials] of developers and porters that are used in the list |
|---|
| 43 | of changes. |
|---|
| 44 | |
|---|
| 45 | Information about changes in prior releases can be found under |
|---|
| 46 | help topics named for each release (e.g. 'help 1.7.2p30'). |
|---|
| 47 | A list of the patchlevels associated with each release can |
|---|
| 48 | be read in 'help patchlevels'. |
|---|
| 49 | |
|---|
| 50 | EOP |
|---|
| 51 | $really_started = 1; |
|---|
| 52 | } |
|---|
| 53 | $started = 1; |
|---|
| 54 | } |
|---|
| 55 | print OUT; |
|---|
| 56 | } elsif ($started) { |
|---|
| 57 | print OUT; |
|---|
| 58 | } |
|---|
| 59 | } |
|---|
| 60 | close IN; |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | # Now spew the patchlevels list. Special case for 1.50 |
|---|
| 64 | $patchlevels{'1.5.0'} = $patchlevels{'1.50'}; |
|---|
| 65 | delete($patchlevels{'1.50'}); |
|---|
| 66 | my @versions = reverse sort versions keys %patchlevels; |
|---|
| 67 | print OUT <<EOP; |
|---|
| 68 | & patchlevels |
|---|
| 69 | For information on a specific patchlevel of one of the versions listed, |
|---|
| 70 | type 'help <version>p<patchlevel>'. For example, 'help 1.7.2p3' |
|---|
| 71 | |
|---|
| 72 | EOP |
|---|
| 73 | foreach (@versions) { |
|---|
| 74 | my @pls = sort {$a <=> $b} @{$patchlevels{$_}}; |
|---|
| 75 | my $line; |
|---|
| 76 | if ($_ eq "1.5.0") { |
|---|
| 77 | $line = "1.50: ". join(", ",@pls). "\n"; |
|---|
| 78 | } else { |
|---|
| 79 | $line = "$_: ". join(", ",@pls). "\n"; |
|---|
| 80 | } |
|---|
| 81 | print OUT wrap(""," ",$line); |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | close OUT; |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | # A sort subroutine to order CHANGES.<blah> in reverse chronological |
|---|
| 88 | # order |
|---|
| 89 | sub byrevision { |
|---|
| 90 | return $b cmp $a if ($a =~ /\d/ and $b =~ /\d/); |
|---|
| 91 | return $a cmp $b; |
|---|
| 92 | } |
|---|