From 74f2d7e0bc2b6c75571e724d72bae80e54f38f50 Mon Sep 17 00:00:00 2001 From: girst Date: Sat, 9 Mar 2019 21:23:20 +0100 Subject: [PATCH] freecell: better join() cell->foundation fix --- sol.c | 4 ++-- sol.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sol.c b/sol.c index f1fac0c..cf68c4f 100644 --- a/sol.c +++ b/sol.c @@ -581,8 +581,8 @@ int join(int to) { if (to == FOUNDATION) { int status = ERR; - for (int i = 0; i <= TAB_MAX+1; i++) - switch ((i?t2f:w2f)(i-1, FOUNDATION, 0)) { + for (int i = 0; i < NUM_PILES+NUM_CELLS; i++) + switch ((is_tableu(i)?t2f(i, FOUNDATION, 0):w2f(STOCK, FOUNDATION, i))) { case WON: return WON; case OK: status = OK; case ERR: /* nop */; diff --git a/sol.h b/sol.h index da0cf5a..d4ed49f 100644 --- a/sol.h +++ b/sol.h @@ -5,6 +5,7 @@ #define DECK_SIZE 52 #ifdef KLONDIKE #define NUM_PILES 7 +#define NUM_CELLS 1 /*for join(); represents the waste*/ #define MAX_HIDDEN 6 /*how many cards are turned over at most in a tableu pile*/ #define MAX_STOCK 24 /*how many cards can be in the stock at most (=@start)*/ #define NUM_DECKS 1 -- 2.39.3