aboutsummaryrefslogtreecommitdiff
path: root/messages.pl
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-02-25 16:51:09 -0500
committerB. Watson <yalhcru@gmail.com>2016-02-25 16:51:09 -0500
commit9dc7267a351b79ac5b855e812520362f28922341 (patch)
treeb40e8e2144358752b990f1c94091fda0880e3eb7 /messages.pl
parentc9c027bb8d620eb3f5066440067327b7d932a7e1 (diff)
downloadtaipan-9dc7267a351b79ac5b855e812520362f28922341.tar.gz
dictionary text compression, 7666 bytes free
Diffstat (limited to 'messages.pl')
-rw-r--r--messages.pl37
1 files changed, 30 insertions, 7 deletions
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, "<textdecomp.s" or die $!;
+while(<$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(<DATA>) {
@@ -17,9 +32,17 @@ while(<DATA>) {
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(<DATA>) {
$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"