On Thu, 2010-05-13 at 03:46 +0000, brian m. carlson wrote:
> When playing a 5x5 game of Keen, if there is a 2รท clue, it accepts 2 and
> 5 instead of changing the symbol to red to warn that this is not a
> satisfactory solution.  This, of course, is likely a result of C's
> integer division truncation.  I took a look at the code, but was unable
> to determine exactly what needed to be patched.

This seems to be a proper fix:

--- a/keen.c
+++ b/keen.c
@@ -1450,11 +1450,12 @@ static int check_errors(game_state *state, long *errors)
                break;
              case C_DIV:
                {
-                   int d1 = cluevals[j], d2 = state->grid[i];
-                   if (d1 == 0 || d2 == 0)
+                   int d1 = min(cluevals[j], state->grid[i]);
+                   int d2 = max(cluevals[j], state->grid[i]);
+                   if (d1 == 0 || d2 % d1 != 0)
                        cluevals[j] = 0;
                    else
-                       cluevals[j] = d2/d1 + d1/d2;/* one of them is 0 :-) */
+                       cluevals[j] = d2 / d1;
                }
                break;
            }
--- END ---

Ben.

-- 
Ben Hutchings
Once a job is fouled up, anything done to improve it makes it worse.

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to