]> git.cworth.org Git - loudgame/commitdiff
Rename board_t to loa_board_t
authorCarl Worth <cworth@cworth.org>
Sat, 23 Feb 2008 20:04:47 +0000 (12:04 -0800)
committerCarl Worth <cworth@cworth.org>
Sat, 23 Feb 2008 20:04:47 +0000 (12:04 -0800)
This is in preparation for moving loa_board to its own file.

lg-loa.c

index ca888e8e7338e1c77c7012a89d0a5321521cf0af..0d582c9def03412357aaa4ede5c58476ece221ed 100644 (file)
--- a/lg-loa.c
+++ b/lg-loa.c
@@ -66,15 +66,15 @@ typedef struct {
     int diag_acute_pieces[DIAG_ARRAY_SIZE];
 
     player_t player;
     int diag_acute_pieces[DIAG_ARRAY_SIZE];
 
     player_t player;
-} board_t;
+} loa_board_t;
 
 typedef struct _loa_game {
     loudgame_t lg;
 
 typedef struct _loa_game {
     loudgame_t lg;
-    board_t board;
+    loa_board_t board;
 } loa_game_t;
 
 static void
 } loa_game_t;
 
 static void
-board_next_player (board_t *board)
+loa_board_next_player (loa_board_t *board)
 {
     if (board->player == PLAYER_BLACK)
        board->player = PLAYER_WHITE;
 {
     if (board->player == PLAYER_BLACK)
        board->player = PLAYER_WHITE;
@@ -83,9 +83,9 @@ board_next_player (board_t *board)
 }
 
 static int
 }
 
 static int
-board_group_size_recursive (board_t *board, int x, int y,
-                           cell_t cell,
-                           uint64_t *visited)
+loa_board_group_size_recursive (loa_board_t *board, int x, int y,
+                               cell_t cell,
+                               uint64_t *visited)
 {
     uint64_t bit;
 
 {
     uint64_t bit;
 
@@ -105,35 +105,35 @@ board_group_size_recursive (board_t *board, int x, int y,
        return 0;
 
     return 1 +
        return 0;
 
     return 1 +
-       board_group_size_recursive (board, x-1, y-1, cell, visited) +
-       board_group_size_recursive (board, x-1, y  , cell, visited) +
-       board_group_size_recursive (board, x-1, y+1, cell, visited) +
-       board_group_size_recursive (board, x  , y-1, cell, visited) +
-       board_group_size_recursive (board, x  , y  , cell, visited) +
-       board_group_size_recursive (board, x  , y+1, cell, visited) +
-       board_group_size_recursive (board, x+1, y-1, cell, visited) +
-       board_group_size_recursive (board, x+1, y  , cell, visited) +
-       board_group_size_recursive (board, x+1, y+1, cell, visited);
+       loa_board_group_size_recursive (board, x-1, y-1, cell, visited) +
+       loa_board_group_size_recursive (board, x-1, y  , cell, visited) +
+       loa_board_group_size_recursive (board, x-1, y+1, cell, visited) +
+       loa_board_group_size_recursive (board, x  , y-1, cell, visited) +
+       loa_board_group_size_recursive (board, x  , y  , cell, visited) +
+       loa_board_group_size_recursive (board, x  , y+1, cell, visited) +
+       loa_board_group_size_recursive (board, x+1, y-1, cell, visited) +
+       loa_board_group_size_recursive (board, x+1, y  , cell, visited) +
+       loa_board_group_size_recursive (board, x+1, y+1, cell, visited);
 }
 
 static int
 }
 
 static int
-board_group_size (board_t *board, int x, int y)
+loa_board_group_size (loa_board_t *board, int x, int y)
 {
     uint64_t visited = 0ll;
     cell_t cell = board->cells[x][y];
 
 {
     uint64_t visited = 0ll;
     cell_t cell = board->cells[x][y];
 
-    return board_group_size_recursive (board, x, y, cell, &visited);
+    return loa_board_group_size_recursive (board, x, y, cell, &visited);
 }
 
 static int
 }
 
 static int
-board_is_won (board_t *board, int x, int y)
+loa_board_is_won (loa_board_t *board, int x, int y)
 {
     cell_t cell = board->cells[x][y];
 
     if (cell == CELL_EMPTY)
        return 0;
 
 {
     cell_t cell = board->cells[x][y];
 
     if (cell == CELL_EMPTY)
        return 0;
 
-    if (board_group_size (board, x, y) == board->num_pieces[cell])
+    if (loa_board_group_size (board, x, y) == board->num_pieces[cell])
        return 1;
 
     return 0;
        return 1;
 
     return 0;
@@ -164,7 +164,10 @@ _acute_index (int x, int y)
 }
 
 static loa_bool_t
 }
 
 static loa_bool_t
-board_move_legal (board_t *board, int x1, int y1, int x2, int y2, char **error)
+loa_board_move_legal (loa_board_t *board,
+                     int x1, int y1,
+                     int x2, int y2,
+                     char **error)
 {
     int x, y;
     int dx, dy;
 {
     int x, y;
     int dx, dy;
@@ -237,7 +240,7 @@ board_move_legal (board_t *board, int x1, int y1, int x2, int y2, char **error)
 }
 
 static void
 }
 
 static void
-board_add_piece (board_t *board, int x, int y, cell_t cell)
+loa_board_add_piece (loa_board_t *board, int x, int y, cell_t cell)
 {
     assert (cell == CELL_BLACK || cell == CELL_WHITE);
     assert (board->cells[x][y] == CELL_EMPTY);
 {
     assert (cell == CELL_BLACK || cell == CELL_WHITE);
     assert (board->cells[x][y] == CELL_EMPTY);
@@ -253,7 +256,7 @@ board_add_piece (board_t *board, int x, int y, cell_t cell)
 }
 
 static cell_t
 }
 
 static cell_t
-board_remove_piece (board_t *board, int x, int y)
+loa_board_remove_piece (loa_board_t *board, int x, int y)
 {
     cell_t cell;
 
 {
     cell_t cell;
 
@@ -275,7 +278,7 @@ board_remove_piece (board_t *board, int x, int y)
 }
 
 static void
 }
 
 static void
-board_init (board_t *board)
+loa_board_init (loa_board_t *board)
 {
     int i, x, y;
 
 {
     int i, x, y;
 
@@ -297,10 +300,10 @@ board_init (board_t *board)
     }
 
     for (i = 1; i < BOARD_SIZE - 1; i++) {
     }
 
     for (i = 1; i < BOARD_SIZE - 1; i++) {
-       board_add_piece (board, i, 0, CELL_BLACK);
-       board_add_piece (board, i, BOARD_SIZE - 1, CELL_BLACK);
-       board_add_piece (board, 0, i, CELL_WHITE);
-       board_add_piece (board, BOARD_SIZE - 1, i, CELL_WHITE);
+       loa_board_add_piece (board, i, 0, CELL_BLACK);
+       loa_board_add_piece (board, i, BOARD_SIZE - 1, CELL_BLACK);
+       loa_board_add_piece (board, 0, i, CELL_WHITE);
+       loa_board_add_piece (board, BOARD_SIZE - 1, i, CELL_WHITE);
     }
 
     board->player = PLAYER_BLACK;
     }
 
     board->player = PLAYER_BLACK;
@@ -338,7 +341,7 @@ board_init (board_t *board)
  *    A   B   C   D   E   F   G   H       A   B   C   D   E   F   G   H
  */
 static char *
  *    A   B   C   D   E   F   G   H       A   B   C   D   E   F   G   H
  */
 static char *
-board_to_string (board_t *board)
+loa_board_to_string (loa_board_t *board)
 {
     int x, y;
     /* In order of BLACK, WHITE, EMPTY */
 {
     int x, y;
     /* In order of BLACK, WHITE, EMPTY */
@@ -391,14 +394,14 @@ board_to_string (board_t *board)
 static void
 loa_game_new_game (loa_game_t *game)
 {
 static void
 loa_game_new_game (loa_game_t *game)
 {
-    board_init (&game->board);
+    loa_board_init (&game->board);
 }
 
 static loa_bool_t
 loa_game_move (loa_game_t *game, const char * peer,
               int x1, int y1, int x2, int y2)
 {
 }
 
 static loa_bool_t
 loa_game_move (loa_game_t *game, const char * peer,
               int x1, int y1, int x2, int y2)
 {
-    board_t *board = &game->board;
+    loa_board_t *board = &game->board;
     cell_t cell;
     char *error;
 
     cell_t cell;
     char *error;
 
@@ -413,18 +416,18 @@ loa_game_move (loa_game_t *game, const char * peer,
        return FALSE;
     }
 
        return FALSE;
     }
 
-    if (! board_move_legal (&game->board, x1, y1, x2, y2, &error)) {
+    if (! loa_board_move_legal (&game->board, x1, y1, x2, y2, &error)) {
        loudgame_sendf (&game->lg, peer, "Illegal move: %c%d%c%d",
                        'a' + x1, BOARD_SIZE - y1,
                        'a' + x2, BOARD_SIZE - y2);
        return FALSE;
     }
 
        loudgame_sendf (&game->lg, peer, "Illegal move: %c%d%c%d",
                        'a' + x1, BOARD_SIZE - y1,
                        'a' + x2, BOARD_SIZE - y2);
        return FALSE;
     }
 
-    cell = board_remove_piece (board, x1, y1);
-    board_remove_piece (board, x2, y2);
-    board_add_piece (board, x2, y2, cell);
+    cell = loa_board_remove_piece (board, x1, y1);
+    loa_board_remove_piece (board, x2, y2);
+    loa_board_add_piece (board, x2, y2, cell);
 
 
-    board_next_player (board);
+    loa_board_next_player (board);
 
     return TRUE;
 }
 
     return TRUE;
 }
@@ -455,7 +458,7 @@ loa_game_handle_show (loa_game_t *game,
     else
        lm_message_node_add_child (body, "span", "White to move:");
 
     else
        lm_message_node_add_child (body, "span", "White to move:");
 
-    board_string = board_to_string (&game->board);
+    board_string = loa_board_to_string (&game->board);
 
     line = board_string;
     while (1) {
 
     line = board_string;
     while (1) {
@@ -511,7 +514,7 @@ loa_game_handle_move (loa_game_t *game,
                         'a' + x1, BOARD_SIZE - y1,
                         'a' + x2, BOARD_SIZE - y2);
 
                         'a' + x1, BOARD_SIZE - y1,
                         'a' + x2, BOARD_SIZE - y2);
 
-    if (board_is_won (&game->board, x2, y2))
+    if (loa_board_is_won (&game->board, x2, y2))
        loudgame_broadcastf (&game->lg, "%s wins", peer);
 }
 
        loudgame_broadcastf (&game->lg, "%s wins", peer);
 }
 
@@ -520,7 +523,7 @@ loa_game_handle_pass (loa_game_t *game, const char *peer)
 {
     loudgame_broadcastf (&game->lg, "%s passes", peer);
 
 {
     loudgame_broadcastf (&game->lg, "%s passes", peer);
 
-    board_next_player (&game->board);
+    loa_board_next_player (&game->board);
 }
 
 static void
 }
 
 static void