From 09aa8de52cb962f1ceebfb1fd44f2c54a924fc5c Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Mon, 22 Jul 2024 21:43:25 -0400 Subject: puzzles: resync with upstream This brings the puzzles source in sync with Simon's branch, commit fd304c5 (from March 2024), with some added Rockbox-specific compatibility changes: https://www.franklinwei.com/git/puzzles/commit/?h=rockbox-devel&id=516830d9d76bdfe64fe5ccf2a9b59c33f5c7c078 There are quite a lot of backend changes, including a new "Mosaic" puzzle. In addition, some new frontend changes were necessary: - New "Preferences" menu to access the user preferences system. - Enabled spacebar input for several games. Change-Id: I94c7df674089c92f32d5f07025f6a1059068af1e --- apps/plugins/puzzles/src/grid.h | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'apps/plugins/puzzles/src/grid.h') 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; typedef struct grid_dot grid_dot; struct grid_face { + int index; /* index in grid->faces[] where this face appears */ int order; /* Number of edges, also the number of dots */ grid_edge **edges; /* edges around this face */ grid_dot **dots; /* corners of this face */ @@ -56,8 +57,10 @@ struct grid_face { struct grid_edge { grid_dot *dot1, *dot2; grid_face *face1, *face2; /* Use NULL for the infinite outside face */ + int index; /* index in grid->edges[] where this edge appears */ }; struct grid_dot { + int index; /* index in grid->dots[] where this dot appears */ int order; grid_edge **edges; grid_face **faces; /* A NULL grid_face* means infinite outside face */ @@ -69,11 +72,13 @@ struct grid_dot { int x, y; }; typedef struct grid { - /* These are (dynamically allocated) arrays of all the - * faces, edges, dots that are in the grid. */ - int num_faces; grid_face *faces; - int num_edges; grid_edge *edges; - int num_dots; grid_dot *dots; + /* Arrays of all the faces, edges, dots that are in the grid. + * The arrays themselves are dynamically allocated, and so is each object + * inside them. num_foo indicates the number of things actually stored, + * and size_foo indicates the allocated size of the array. */ + int num_faces, size_faces; grid_face **faces; + int num_edges, size_edges; grid_edge **edges; + int num_dots, size_dots; grid_dot **dots; /* Cache the bounding-box of the grid, so the drawing-code can quickly * figure out the proper scaling to draw onto a given area. */ @@ -107,13 +112,19 @@ typedef struct grid { A(DODECAGONAL,dodecagonal) \ A(GREATDODECAGONAL,greatdodecagonal) \ A(GREATGREATDODECAGONAL,greatgreatdodecagonal) \ + A(COMPASSDODECAGONAL,compassdodecagonal) \ A(PENROSE_P2,penrose_p2_kite) \ - A(PENROSE_P3,penrose_p3_thick) + A(PENROSE_P3,penrose_p3_thick) \ + A(HATS,hats) \ + A(SPECTRES,spectres) \ + /* end of list */ #define ENUM(upper,lower) GRID_ ## upper, typedef enum grid_type { GRIDGEN_LIST(ENUM) GRID_TYPE_MAX } grid_type; #undef ENUM +const char *grid_validate_params(grid_type type, int width, int height); + /* Free directly after use if non-NULL. Will never contain an underscore * (so clients can safely use that as a separator). */ char *grid_new_desc(grid_type type, int width, int height, random_state *rs); -- cgit v1.2.3