From feafd84f67ed8e1f778a058d4d3dbce10b6ac498 Mon Sep 17 00:00:00 2001 From: girst Date: Sat, 16 Feb 2019 22:23:38 +0100 Subject: [PATCH] spider: fix move to empty tableu "no of the additions affect klondike or spider, so its safe to commit" my ass! this is the second bug I've found that I introduced with this. --- sol.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/sol.c b/sol.c index 1167ed7..0e57428 100644 --- a/sol.c +++ b/sol.c @@ -424,14 +424,15 @@ int t2f(int from, int to, int opt) { /* 1:1 copy from KLONDIKE */ return OK; } else return ERR; } -int f2t(int from, int to, int opt) { /* 1:1 copy from KLONDIKE */ +int f2t(int from, int to, int opt) { (void) from; /* don't need */ int top_to = find_top(f.t[to]); from = opt; int top_from = find_top(f.f[from]); - if ((get_color(f.t[to][top_to]) != get_color(f.f[from][top_from])) - && (rank_next(f.f[from][top_from], f.t[to][top_to]))) { + if (top_to < 0 /* empty tableu? */ + ||((get_color(f.t[to][top_to]) != get_color(f.f[from][top_from])) + && (rank_next(f.f[from][top_from], f.t[to][top_to])))) { f.t[to][top_to+1] = f.f[from][top_from]; f.f[from][top_from] = NO_CARD; undo_push(FOUNDATION, to, from, 0); @@ -459,8 +460,9 @@ int c2t(int from, int to, int opt) { int top_to = find_top(f.t[to]); from = opt; - if ((get_color(f.t[to][top_to]) != get_color(f.s[from])) - && (rank_next(f.s[from], f.t[to][top_to]))) { + if (top_to < 0 /* empty tableu? */ + ||((get_color(f.t[to][top_to]) != get_color(f.s[from])) + && (rank_next(f.s[from], f.t[to][top_to])))) { f.t[to][top_to+1] = f.s[from]; f.s[from] = NO_CARD; f.w &= ~(1<pile)) { if (cursor->pile < TAB_MAX) cursor->pile++; + cursor->opt = 0; } else { switch (cursor->pile) { case STOCK: @@ -1017,11 +1020,6 @@ to_l: print_table(&active, &inactive); } /***/ - /* if it was selected with a cursor, it's obvious: */ - if (inactive.opt >= 0) { - *opt = inactive.opt; - return CMD_MOVE; - } #ifdef KLONDIKE if (*from == FOUNDATION) { if (inactive.opt >= 0) { @@ -1085,6 +1083,12 @@ to_l: print_table(&active, &inactive); //TODO: if from is foundation or from is free cell, which one (if two possibilities), like klondike //TODO FREECELL: if (*from==STOCK || *from==FOUNDATION) "select correct one" //NOTE: this is more complicated, because *to can also point to stock or foundation in addition to tableu. + + /* if it was selected with a cursor, it's obvious: */ + if (inactive.opt >= 0) { + *opt = inactive.opt; + return CMD_MOVE; + } if (*from == FOUNDATION && *to == STOCK) { //can take from all non-empty foundations } else if (*from == STOCK && *to == FOUNDATION) { -- 2.39.3