diff options
author | Raúl Benencia <rul@kalgan.cc> | 2015-03-27 12:16:23 -0300 |
---|---|---|
committer | Raúl Benencia <rul@kalgan.cc> | 2015-03-27 12:16:23 -0300 |
commit | 4730d415e980cfe1fbf385deaaf2d2f9c531e1fc (patch) | |
tree | 797fbf298da802bb9fe275416c485bbdeeed4f22 | |
parent | 067fac1a3c6ecdd25b10423ab908db69c0cd446f (diff) |
don't use Board pointers
-rw-r--r-- | lib/board.c | 28 | ||||
-rw-r--r-- | main.c | 2 |
2 files changed, 15 insertions, 15 deletions
diff --git a/lib/board.c b/lib/board.c index 6543bcc..3eb7603 100644 --- a/lib/board.c +++ b/lib/board.c @@ -3,54 +3,54 @@ #include "board.h" -Board* _setup_colors(Board *b) { +Board _setup_colors(Board b) { int i, j; for (i = 0; i < SIZE; i++) for (j = 0; j < SIZE; j++) if (i % 2) // Odd rows start with white if (j % 2) - b[i][j]->color = WHITE; + b[i][j].color = WHITE; else - b[i][j]->color = BLACK; + b[i][j].color = BLACK; else if (j % 2) - b[i][j]->color = BLACK; + b[i][j].color = BLACK; else - b[i][j]->color = WHITE; + b[i][j].color = WHITE; return b; } -Board* _pawns(Board *b) { +Board _pawns(Board b) { return b; } -Board* _rocks(Board *b) { +Board _rocks(Board b) { return b; } -Board* _knights(Board *b) { +Board _knights(Board b) { return b; } -Board* _bishops(Board *b) { +Board _bishops(Board b) { return b; } -Board* _queens(Board *b) { +Board _queens(Board b) { return b; } -Board* _kings(Board *b) { +Board _kings(Board b) { return b; } -Board* _setup_pieces(Board *b) { +Board _setup_pieces(Board b) { return _pawns(_rocks(_knights(_bishops(_queens(_kings(b)))))); // :-) } -Board* _initial_setup(Board *b) { +Board _initial_setup(Board b) { return _setup_pieces(_setup_colors(b)); } @@ -65,7 +65,7 @@ Board board_init() { b[i][j].piece = NULL; } - return b; + return _initial_setup(b); } int board_delete(Board* b) { @@ -6,7 +6,7 @@ int main() { Board b = board_init(); - print_board(&b); + print_board(b); return 0; } |