diff options
Diffstat (limited to 'apps/plugins/puzzles/src/grid.h')
-rw-r--r-- | apps/plugins/puzzles/src/grid.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/apps/plugins/puzzles/src/grid.h b/apps/plugins/puzzles/src/grid.h index 7ca3ff1d5f..77c8dd800f 100644 --- a/apps/plugins/puzzles/src/grid.h +++ b/apps/plugins/puzzles/src/grid.h | |||
@@ -33,6 +33,7 @@ typedef struct grid_edge grid_edge; | |||
33 | typedef struct grid_dot grid_dot; | 33 | typedef struct grid_dot grid_dot; |
34 | 34 | ||
35 | struct grid_face { | 35 | struct grid_face { |
36 | int index; /* index in grid->faces[] where this face appears */ | ||
36 | int order; /* Number of edges, also the number of dots */ | 37 | int order; /* Number of edges, also the number of dots */ |
37 | grid_edge **edges; /* edges around this face */ | 38 | grid_edge **edges; /* edges around this face */ |
38 | grid_dot **dots; /* corners of this face */ | 39 | grid_dot **dots; /* corners of this face */ |
@@ -56,8 +57,10 @@ struct grid_face { | |||
56 | struct grid_edge { | 57 | struct grid_edge { |
57 | grid_dot *dot1, *dot2; | 58 | grid_dot *dot1, *dot2; |
58 | grid_face *face1, *face2; /* Use NULL for the infinite outside face */ | 59 | grid_face *face1, *face2; /* Use NULL for the infinite outside face */ |
60 | int index; /* index in grid->edges[] where this edge appears */ | ||
59 | }; | 61 | }; |
60 | struct grid_dot { | 62 | struct grid_dot { |
63 | int index; /* index in grid->dots[] where this dot appears */ | ||
61 | int order; | 64 | int order; |
62 | grid_edge **edges; | 65 | grid_edge **edges; |
63 | grid_face **faces; /* A NULL grid_face* means infinite outside face */ | 66 | grid_face **faces; /* A NULL grid_face* means infinite outside face */ |
@@ -69,11 +72,13 @@ struct grid_dot { | |||
69 | int x, y; | 72 | int x, y; |
70 | }; | 73 | }; |
71 | typedef struct grid { | 74 | typedef struct grid { |
72 | /* These are (dynamically allocated) arrays of all the | 75 | /* Arrays of all the faces, edges, dots that are in the grid. |
73 | * faces, edges, dots that are in the grid. */ | 76 | * The arrays themselves are dynamically allocated, and so is each object |
74 | int num_faces; grid_face *faces; | 77 | * inside them. num_foo indicates the number of things actually stored, |
75 | int num_edges; grid_edge *edges; | 78 | * and size_foo indicates the allocated size of the array. */ |
76 | int num_dots; grid_dot *dots; | 79 | int num_faces, size_faces; grid_face **faces; |
80 | int num_edges, size_edges; grid_edge **edges; | ||
81 | int num_dots, size_dots; grid_dot **dots; | ||
77 | 82 | ||
78 | /* Cache the bounding-box of the grid, so the drawing-code can quickly | 83 | /* Cache the bounding-box of the grid, so the drawing-code can quickly |
79 | * figure out the proper scaling to draw onto a given area. */ | 84 | * figure out the proper scaling to draw onto a given area. */ |
@@ -107,13 +112,19 @@ typedef struct grid { | |||
107 | A(DODECAGONAL,dodecagonal) \ | 112 | A(DODECAGONAL,dodecagonal) \ |
108 | A(GREATDODECAGONAL,greatdodecagonal) \ | 113 | A(GREATDODECAGONAL,greatdodecagonal) \ |
109 | A(GREATGREATDODECAGONAL,greatgreatdodecagonal) \ | 114 | A(GREATGREATDODECAGONAL,greatgreatdodecagonal) \ |
115 | A(COMPASSDODECAGONAL,compassdodecagonal) \ | ||
110 | A(PENROSE_P2,penrose_p2_kite) \ | 116 | A(PENROSE_P2,penrose_p2_kite) \ |
111 | A(PENROSE_P3,penrose_p3_thick) | 117 | A(PENROSE_P3,penrose_p3_thick) \ |
118 | A(HATS,hats) \ | ||
119 | A(SPECTRES,spectres) \ | ||
120 | /* end of list */ | ||
112 | 121 | ||
113 | #define ENUM(upper,lower) GRID_ ## upper, | 122 | #define ENUM(upper,lower) GRID_ ## upper, |
114 | typedef enum grid_type { GRIDGEN_LIST(ENUM) GRID_TYPE_MAX } grid_type; | 123 | typedef enum grid_type { GRIDGEN_LIST(ENUM) GRID_TYPE_MAX } grid_type; |
115 | #undef ENUM | 124 | #undef ENUM |
116 | 125 | ||
126 | const char *grid_validate_params(grid_type type, int width, int height); | ||
127 | |||
117 | /* Free directly after use if non-NULL. Will never contain an underscore | 128 | /* Free directly after use if non-NULL. Will never contain an underscore |
118 | * (so clients can safely use that as a separator). */ | 129 | * (so clients can safely use that as a separator). */ |
119 | char *grid_new_desc(grid_type type, int width, int height, random_state *rs); | 130 | char *grid_new_desc(grid_type type, int width, int height, random_state *rs); |