From c3097e7f6fb602f9f92d9214bd9f56c91eb2fc11 Mon Sep 17 00:00:00 2001 From: John Zaitseff Date: Tue, 19 Jul 2011 00:03:34 +1000 Subject: [PATCH] Fix a long-standing bug: don't impound more cash than the debt amount! --- src/move.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/move.c b/src/move.c index 605604e..83d23fd 100644 --- a/src/move.c +++ b/src/move.c @@ -1076,6 +1076,7 @@ void adjust_values (void) // Check if a player's debt is too large if (total_value(current_player) <= -MAX_OVERDRAFT) { + double impounded; char *buf; buf = malloc(BUFSIZE); @@ -1083,6 +1084,9 @@ void adjust_values (void) err_exit("out of memory"); } + impounded = MIN(player[current_player].cash, + player[current_player].debt); + newtxwin(8, 60, LINE_OFFSET + 7, COL_CENTER(60)); wbkgd(curwin, ATTR_ERROR_WINDOW); box(curwin, 0, 0); @@ -1092,7 +1096,7 @@ void adjust_values (void) strfmon(buf, BUFSIZE, "%1n", player[current_player].debt); center(curwin, 3, ATTR_ERROR_STR, "Your debt has amounted to %s", buf); - strfmon(buf, BUFSIZE, "%1n", player[current_player].cash); + strfmon(buf, BUFSIZE, "%1n", impounded); center3(curwin, 4, ATTR_ERROR_WINDOW, ATTR_ERROR_WINDOW, ATTR_ERROR_STR, "The Bank has impounded ", " from your cash", "%s", buf); @@ -1100,9 +1104,11 @@ void adjust_values (void) deltxwin(); txrefresh(); - player[current_player].debt /= interest_rate + 1.0; - player[current_player].debt -= player[current_player].cash; - player[current_player].cash = 0.0; + player[current_player].cash -= impounded; + player[current_player].debt -= impounded; + if (player[current_player].cash < ROUNDING_AMOUNT) { + player[current_player].cash = 0.0; + } if (player[current_player].debt < ROUNDING_AMOUNT) { player[current_player].debt = 0.0; }