From 9dc7267a351b79ac5b855e812520362f28922341 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Thu, 25 Feb 2016 16:51:09 -0500 Subject: dictionary text compression, 7666 bytes free --- messages.pl | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'messages.pl') diff --git a/messages.pl b/messages.pl index 65ade0f..d225d17 100644 --- a/messages.pl +++ b/messages.pl @@ -4,6 +4,21 @@ # messages are listed at the end of this file after __END__ marker. # output of this script should be redirected to messages.c. +# make dictionary from textdecomp.s comments +open my $t, ") { + next unless /^dict(\d\d):.*;\s*"([^"]*)"/; + my $value = 'Z' . chr($1 + 96); + my $key = quotemeta $2; + $dictionary{$key} = $value; +} +close $t; + +#for(sort keys %dictionary) { +# warn "'$_' => $dictionary{$_}\n"; +#} +#exit 0; + print "// do not edit, contents are generated by messages.pl\n\n"; while() { @@ -17,9 +32,17 @@ while() { s/"//g; s/\\r//g; s/\\n/\n/g; - # warn "msg: $_\n"; + #warn "msg: $_\n"; $total_in += (1 + length); + + my $dict_used = 0; + for my $dk (keys %dictionary) { + if(s/$dk/$dictionary{$dk}/g) { + $dict_used = 1; + } + } + open my $out, ">msg.out" or die $!; print $out $_; close $out; @@ -34,7 +57,7 @@ while() { $total_out += @got; } die "failed to compress $orig\n" unless $readbytes; - print "\n};\n\n"; + print "\n};" . ($dict_used ? " // dictionary used" : "") . "\n\n"; } print "// messages: $msgcount\n"; @@ -149,8 +172,8 @@ me_to_go_to "me to go to:\r\n" already_here "\r\n\nYou're already here" hostile_ship " hostile ship" approaching " approaching" -fleet_drove_off "'s fleet drove them off!" -s_pirates "'s pirates" +fleet_drove_off "Li Yuen's fleet drove them off!" +s_pirates "Li Yuen's pirates" they_let_us_be "Good joss!! They let us be!!\r\n" ships_of_fleet " ships of Li Yuen's pirate\r\nfleet" captured_some_booty "We captured some booty.\r\nIt's worth " @@ -163,7 +186,7 @@ were_going_down "We're going down" storm_we_made_it " We made it!!\r\n\n" blown_off_course "We've been blown off course\r\nto " arriving_at "Arriving at " -asks " asks " +asks "Li Yuen asks " in_donation " in donation\r\nto the temple of Tin Hau, the Sea\r\nGoddess. Will you pay? " not_enough_cash "you do not have enough cash!!\r\n\n" make_up_difference "to make up\r\nthe difference for you? " @@ -184,7 +207,7 @@ to_repay_him "to repay\r\nhim? " to_borrow "to \r\nborrow? " wont_loan "\r\n\nHe won't loan you so much" bodyguards_killed " of your bodyguards have been killed\r\nby cutthroats and you have been robbed\r\nof all of your cash" -the_price_of "!! The price of " +the_price_of "Taipan!! The price of " nl_has_spc "\n has " risen "risen" dropped "dropped" @@ -215,6 +238,6 @@ wu_warn_1 "reminds you of the\r\nConfucian ideal of personal worthiness,\r\nand wu_warn_2 "He is reminded of a fabled barbarian\r\nwho came to a bad end, after not caring\r\nfor his obligations.\r\n\nHe hopes no such fate awaits you, his\r\nfriend" siezed_opium "The local authorities have seized your\r\nOpium cargo and have also fined you\r\n" whouse_theft "Messenger reports large theft\r\nfrom warehouse" -has_sent_lieutenant " has sent a Lieutenant,\r\nTaipan. He says his admiral wishes\r\nto see you in Hong Kong, posthaste!\r\n" +has_sent_lieutenant "Li Yuen has sent a Lieutenant,\r\nTaipan. He says his admiral wishes\r\nto see you in Hong Kong, posthaste!\r\n" beaten_robbed "You've been beaten up and\r\nrobbed of " in_cash " in cash" -- cgit v1.2.3