summary refs log tree commit diff
path: root/bin/freecell.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/freecell.c')
-rw-r--r--bin/freecell.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/bin/freecell.c b/bin/freecell.c
index 762b5552..0110ecfe 100644
--- a/bin/freecell.c
+++ b/bin/freecell.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2019, 2021  C. McEnroe <june@causal.agency>
+/* Copyright (C) 2019, 2021  June McEnroe <june@causal.agency>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -22,7 +22,6 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <sysexits.h>
 #include <time.h>
 #include <unistd.h>
 
@@ -173,10 +172,9 @@ static void moveSingle(uint dst, uint src) {
 	enq(dst, src);
 }
 
-static uint freeCells(uint cells[static Stacks], uint dst) {
+static uint freeCells(uint cells[static 4]) {
 	uint len = 0;
-	for (uint i = Cell; i < Stacks; ++i) {
-		if (i == dst) continue;
+	for (uint i = Cell; i < Tableau; ++i) {
 		if (!stacks[i].len) cells[len++] = i;
 	}
 	return len;
@@ -195,8 +193,8 @@ static uint moveDepth(uint src) {
 
 static void moveColumn(uint dst, uint src) {
 	uint depth;
-	uint cells[Stacks];
-	uint free = freeCells(cells, dst);
+	uint cells[4];
+	uint free = freeCells(cells);
 	for (depth = moveDepth(src); depth; --depth) {
 		if (free < depth-1) continue;
 		if (valid(dst, stacks[src].cards[stacks[src].len-depth])) break;
@@ -285,7 +283,7 @@ static void draw(void) {
 		char key;
 		if (i < Cell) {
 			y = FoundationY;
-			x = FoundationX + (i-Foundation) * (CardWidth+Padding);
+			x = FoundationX + (3-(i-Foundation)) * (CardWidth+Padding);
 			key = '_';
 		} else if (i < Tableau) {
 			y = CellY;
@@ -368,7 +366,7 @@ int main(int argc, char *argv[]) {
 		switch (opt) {
 			break; case 'd': delay = strtoul(optarg, NULL, 10);
 			break; case 'n': game = strtoul(optarg, NULL, 10);
-			break; default:  return EX_USAGE;
+			break; default:  return 1;
 		}
 	}
 	curse();