aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2021-05-30 12:59:22 -0400
committerB. Watson <yalhcru@gmail.com>2021-05-30 12:59:22 -0400
commitfd0f91a029361e4bd6406bc89f1d117747f880c4 (patch)
treeec4d083933c41f9153e25c1f198c00dfd4980af2
parent0f32f20974ea45ac63cb219dcd0a2f9b0205fd45 (diff)
downloadtaipan-fd0f91a029361e4bd6406bc89f1d117747f880c4.tar.gz
Fix booty calculation so it works like the Apple version (costs 27 bytes)
-rw-r--r--taipan.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/taipan.c b/taipan.c
index 7b0396f..884af0e 100644
--- a/taipan.c
+++ b/taipan.c
@@ -1310,9 +1310,13 @@ char sea_battle(char id, int num_ships) {
time = get_time();
s0 = num_ships;
- booty = (time / 4 * 1000 * num_ships) + randi()%1000 + 250;
- if(would_overflow(cash, booty)) {
- booty = 0L;
+ /* This calculation was different in the Apple and Linux ports. I went
+ with the Apple version. */
+ booty = randclamp((long)(time / 4L * 1000L * num_ships)) + (long)(randi()%1000 + 250);
+
+ /* Not ideal, but better than 'booty = 0L' I think. */
+ while(would_overflow(cash, booty)) {
+ booty >>= 1;
}
clear_ships_on_screen();