1 /*
2     XorGramana Copyright 2009 James W. Morris, james@jwm-art.net
3 
4     This file is part of XorGramana.
5 
6     XorGramana is free software: you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation, either version 3 of the License, or
9     (at your option) any later version.
10 
11     XorGramana is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with XorGramana.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef _MOVELIST_H
20 #define _MOVELIST_H
21 
22 #include "actions.h"
23 #include "types.h"
24 
25 struct xmv_link
26 {
27     struct xor_move* xmv;
28     struct xmv_link* prev;
29     struct xmv_link* next;
30 };
31 
32 struct xmv_list
33 {
34     struct xmv_link* first;
35     struct xmv_link* last;
36     struct xmv_link* current;
37 };
38 
39 extern struct xmv_list* xmvlist;
40 
41 /* basic list functionality */
42 struct xmv_list* xmvlist_create();
43 void xmvlist_destroy();
44 
45 struct xmv_link* xmvlist_first();
46 struct xmv_link* xmvlist_last();
47 struct xmv_link* xmvlist_prev();
48 struct xmv_link* xmvlist_next();
49 
50 struct xmv_link* xmvlist_cycle_prev();
51 struct xmv_link* xmvlist_cycle_next();
52 
53 struct xmv_link* xmvlist_append_xor_move(struct xor_move* xmv);
54 struct xor_move* xmvlist_unlink_xor_move(struct xmv_link* lnk);
55 
56 
57 /* xor_move relevant functions */
58 
59 /*
60     xmvlist_contains_coord searches the xmvlist for xor_moves
61     satisfying (from_x == x && from_y == y). the function restores
62     xmv_list->current to the value it had before xmvlist_contains_coord
63     was called.
64 
65     when the link stop_at is encountered the search is abandonded.
66 
67     the xor_move* res_prev pointer is set to point, when a result is
68     found, to the xor_move preceding the result in the chain, or 0.
69     (for purposes of splitting the chain)
70 */
71 struct xmv_link* xmvlist_contains_coord(
72     xy_t x,
73     xy_t y,
74     struct xmv_link* stop_at,
75     struct xor_move** res_prev);
76 
77 
78 #endif
79