aboutsummaryrefslogtreecommitdiff
path: root/messages.pl
blob: 65ade0f413c224457757617f00475eabdbb4b718 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/usr/bin/perl -w

# compresses messages for taipan.c.
# messages are listed at the end of this file after __END__ marker.
# output of this script should be redirected to messages.c.

print "// do not edit, contents are generated by messages.pl\n\n";

while(<DATA>) {
	chomp;
	$msgcount++;
	/^(\w+)\s/;
	my $label = $1;
	s/^\w+\s+//;

	my $orig = $_;
	s/"//g;
	s/\\r//g;
	s/\\n/\n/g;
	# warn "msg: $_\n";

	$total_in += (1 + length);
	open my $out, ">msg.out" or die $!;
	print $out $_;
	close $out;
	system("./textcomp < msg.out > msg.tmp 2>/dev/null");
	open my $result, "<msg.tmp" or die $!;
	print "const char M_$label\[\] = {\n\t// $orig\n\t";
	my $readbytes;
	while(<$result>) {
		my @got = split " ", $_;
		$readbytes = @got;
		print join(", ", @got);
		$total_out += @got;
	}
	die "failed to compress $orig\n" unless $readbytes;
	print "\n};\n\n";
}

print "// messages:          $msgcount\n";
print "// total input size:  $total_in\n";
print "// total output size: $total_out\n";
print "// compression:       " . ($total_in - $total_out) . "\n";
print "// ratio:             " . sprintf("%.1f", $total_out * 100 / $total_in) . "%\n";

# commented-out messages can go in the pod section below:
=pod
illion "illion"   # somehow this wastes 2 bytes
fine "fine"
run "Run" # too short to be worth compression
how_much_spc "How much "
=cut

__END__
guns "guns"
fight "Fight"
throw "Throw Cargo"
opium "Opium"
silk "Silk"
arms "Arms"
gen_cargo "General Cargo"
ellipsis "..."
at_sea "At sea"
hong_kong "Hong Kong"
shanghai "Shanghai"
nagasaki "Nagasaki"
saigon "Saigon"
manila "Manila"
singapore "Singapore"
batavia "Batavia"
will_you "will you "
bad_joss "Bad Joss!!\r\n"
crlf "\n"
taipan "Taipan"
do_you_wish "do you wish "
elder_brother_wu "Elder Brother Wu "
li_yuen "Li Yuen"
do_you_want "Do you want "
firm_colon "Firm:"
compradors_report "Comprador's Report\r\n\n"
captains_report "  Captain's Report\r\n\n"
overloaded "Your ship is overloaded"
wish_to_trade "Do you wish to trade in your "
ship_for_one "\r\nship for one with "
more_capacity " more capacity by\r\npaying an additional "
gun_offer "Do you wish to buy a ship's gun\r\nfor "
space_ship " ship"
space_attacking " attacking"
your_orders_are "Your orders are: "
we_have "   We have"
cur_seaworth "Current seaworthiness: "
what_shall_we_do "what shall we do??\r\n(Fight, Run, Throw cargo)"
aye_fight "Aye, we'll fight 'em"
were_firing "We're firing on 'em"
sunk "Sunk "
of_the_buggers " of the buggers"
didnt_sink "Hit 'em, but didn't sink 'em"
ran_away " ran away"
we_have_no_guns "We have no guns"
you_have_on_board "You have the following on board"
what_shall_i_throw "What shall I throw overboard"
how_much "How much"
hope_we_lose_em "Let's hope we lose 'em"
nothing_there "There's nothing there"
aye_run "Aye, we'll run"
we_got_away "We got away from 'em"
couldnt_lose_em "Couldn't lose 'em."
but_we_escaped "But we escaped from "
of_em " of 'em!"
theyre_firing "They're firing on us"
weve_been_hit "We've been hit"
buggers_hit_gun "The buggers hit a gun"
we_got_em_all "We got 'em all"
to_start "to start . . .\r\n\n"
with_cash ") With cash (and a debt)\r\n\n"
with_5_guns ") With five guns and no cash\r\n"
but_no_debt "(But no debt!)"
mchenry_has_arrived "Mc Henry from the Hong Kong\r\nShipyards has arrived!! He says, 'I see\r\nye've a wee bit of damage to yer ship.'\r\nWill ye be wanting repairs? "
tis_a_pity "Och, 'tis a pity to be "
percent_damaged "% damaged.\r\nWe can fix yer whole ship for "
or_partial_repairs ",\r\nor make partial repairs if you wish.\r\n"
will_ye_spend "will ye spend? "
illionaire " I L L I O N A I R E !"
youre_a "    Y o u ' r e    a"
your_final_status "Your final status:\r\n\nNet cash:  "
ship_size "\r\nShip size: "
units_with " units with "
you_traded_for " guns\r\n\nYou traded for "
spc_year " year"
spc_and_spc " and "
spc_month " month"
your_score_is "Your score is "
land_based_job "Have you considered a land based job?\r\n\n\n"
stay_on_shore "The crew has requested that you stay on\r\nshore for their safety!!\r\n\n"
3_nls "\n\n\n"
your_rating "Your Rating:\r\n"
ma_tsu "Ma Tsu"
master_taipan "Master Taipan"
compradore "Compradore"
galley_hand "Galley Hand"
play_again "Play again? "
you_have_only "You have only "
you_have_no_cargo "You have no cargo"
move_to_whouse " shall I move\r\nto the warehouse"
whouse_only_hold "Your warehouse will only hold an\r\nadditional "
whouse_full "Your warehouse is full"
move_aboard " shall I move\r\naboard ship"
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"
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 "
we_made_it "We made it!"
buggers_got_us "The buggers got us"
all_over_now "!\r\nIt's all over, now!!!"
storm "Storm"
think_going_down "   I think we're going down!!\r\n\n"
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 "
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? "
given_the_diff "has given Li Yuen the\r\ndifference between what he wanted and\r\nyour cash on hand and added the same\r\namount to your debt.\r\n"
very_well "Very well. "
will_not_pay "will not pay\r\nLi Yuen the difference.  I would be very\r\nwary of pirates if I were you."
you_only_have "you only have "
nl_in_spc "\nin "
the_bank "the bank"
cash "cash"
do_you_have_biz_with_wu "Do you have business with Elder Brother\r\nWu, the moneylender? "
aware_of_your_plight "Elder Brother is aware of your plight,\r\nTaipan. He is willing to loan you an\r\nadditional "
if_you_will_pay_back " if you will pay back\r\n"
are_you_willing ". Are you willing"
game_is_over "Very well, Taipan, the game is over!\r\n"
very_well_good_joss "Very well, Taipan. Good joss!!\r\n"
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 "
nl_has_spc "\n has "
risen "risen"
dropped "dropped"
spc_to_spc " to "
bang_bang_nl "!!\n"
prices_here_are "present prices per unit here are"
general_shortname "General"
shall_i_buy_sell "Shall I Buy, Sell, "
bank_transfer "Visit bank, Transfer\r\ncargo, "
quit_traging "Quit trading"
or_retire ", or Retire"
what_will_you_name_firm " What will you name your"
spc_you_can_spc " You can "
spc_shall " shall"
spc_afford "  afford "
i_buy "I buy, "
shall_i_sell " shall\r\nI sell, "
too_much_cash "\r\nYou cannot carry so much cash"
ship_would_sink "\r\nYour ship would sink under the weight\r\nof your riches.\r\n"
deposit "deposit? "
withdraw "withdraw? "
assassinated_1 "you have been assassinated!"
assassinated_2 "As the masked figure plunges the blade\r\ninto your heart, he says:\r\n"
assassinated_3 "regrets to inform you\r\nthat your account has been terminated\r\nwith extreme prejudice."
has_sent "has sent "
braves_to_escort " braves\r\nto escort you to the Wu mansion"
wu_warn_1 "reminds you of the\r\nConfucian ideal of personal worthiness,\r\nand how this applies to paying one's\r\ndebts.\r\n"
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"
beaten_robbed "You've been beaten up and\r\nrobbed of "
in_cash " in cash"