From fd0f91a029361e4bd6406bc89f1d117747f880c4 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sun, 30 May 2021 12:59:22 -0400 Subject: Fix booty calculation so it works like the Apple version (costs 27 bytes) --- taipan.c | 10 +++++++--- 1 file 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(); -- cgit v1.2.3