aboutsummaryrefslogtreecommitdiff
path: root/list.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-01-22 15:29:01 +0000
committerSimon Tatham <anakin@pobox.com>2005-01-22 15:29:01 +0000
commita99de1be8f01f619b965e446ff4ff85d4324f487 (patch)
tree2f0aee8aa63600252568868f46422a2576ce76f2 /list.c
parentcc545532268b04e05005bf65f53f0a1ba39335ba (diff)
downloadpuzzles-a99de1be8f01f619b965e446ff4ff85d4324f487.zip
puzzles-a99de1be8f01f619b965e446ff4ff85d4324f487.tar.gz
puzzles-a99de1be8f01f619b965e446ff4ff85d4324f487.tar.bz2
puzzles-a99de1be8f01f619b965e446ff4ff85d4324f487.tar.xz
Arrange that we really _can_ compile all the puzzles into a single
binary if we choose: fix bugs in cube.c and sixteen.c that manifest when compiled that way, and introduce list.c which provides a global list of all the available puzzles. [originally from svn r5169]
Diffstat (limited to 'list.c')
-rw-r--r--list.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/list.c b/list.c
new file mode 100644
index 0000000..9438c7e
--- /dev/null
+++ b/list.c
@@ -0,0 +1,38 @@
+/*
+ * list.c: List of puzzles.
+ */
+
+#include "puzzles.h"
+
+/*
+ * The available games can be most easily enumerated by searching
+ * for the line in each game source file saying "#define thegame
+ * <gamename>". Hence, the following piece of shell/Perl should
+ * regenerate this list automatically:
+
+perl -ne '/^#define thegame (\S+)/ and $1 ne "nullgame" and print "extern const game $1;\n"' *.c
+echo -e '\nconst game *gamelist[] = {'
+perl -ne '/^#define thegame (\S+)/ and $1 ne "nullgame" and print " &$1,\n"' *.c
+echo -e '};\n\nconst int gamecount = lenof(gamelist);'
+
+ */
+
+extern const game cube;
+extern const game fifteen;
+extern const game net;
+extern const game netslide;
+extern const game pattern;
+extern const game rect;
+extern const game sixteen;
+
+const game *gamelist[] = {
+ &cube,
+ &fifteen,
+ &net,
+ &netslide,
+ &pattern,
+ &rect,
+ &sixteen,
+};
+
+const int gamecount = lenof(gamelist);