From 3a5074edcf8c19825f509c4a19407dad1a0e659b Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 14 Apr 2021 04:24:45 -0400 Subject: Allow player to abort "where do you wish to go" (costs 30 bytes) --- taipan.c | 98 ++++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 52 insertions(+), 46 deletions(-) (limited to 'taipan.c') diff --git a/taipan.c b/taipan.c index 25f0855..99e7581 100644 --- a/taipan.c +++ b/taipan.c @@ -2289,13 +2289,8 @@ void transfer(void) { return; } -void quit(void) -{ -#ifdef BIGNUM - bignum(banktmp); -#endif - unsigned char result = 0, choice, sunk; - int damagepct; +unsigned char choose_port(void) { + unsigned char choice; compradores_report(); cprint_taipan_comma(); @@ -2333,11 +2328,20 @@ void quit(void) print_msg(M_already_here); cprint_taipan_period(); good_joss_timed_getch(); - } else if((choice >= 1) && (choice <= 7)) { - port = choice; - break; - } + } else if(choice <= 7) { + return choice; + } else { /* backspace, enter, etc */ + return 0; + } } +} + +void quit(void) { +#ifdef BIGNUM + bignum(banktmp); +#endif + unsigned char result = 0, sunk; + int damagepct; at_sea(); captains_report(); @@ -3396,8 +3400,6 @@ int main(void) { set_prices(); for (;;) { - choice = 0; - port_stats(); if(wu_assassin) { @@ -3569,41 +3571,45 @@ int main(void) { under_attack_timed_getch(); } - for(;;) { - while(choice != 'q') { - switch (choice = port_choices()) { - case 'b': - buy(); - break; - - case 's': - sell(); - break; - - case 'v': - visit_bank(); - break; - - case 't': - transfer(); - break; - - case 'r': - retire(); - } + for(;;) { + static unsigned char new_port; + new_port = 0; + while(!new_port) { + switch (choice = port_choices()) { + case 'b': + buy(); + break; + + case 's': + sell(); + break; + + case 'v': + visit_bank(); + break; + + case 't': + transfer(); + break; + + case 'q': + if(hold < 0) + overload(); + else + new_port = choose_port(); + break; + + case 'r': + retire(); + } - port_stats(); - } + port_stats(); + } - choice = 0; - if (hold >= 0) - { - quit(); - break; - } else { - overload(); - } - } + port = new_port; + quit(); + break; + } } return 0; -- cgit v1.2.3