mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
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]
This commit is contained in:
38
list.c
Normal file
38
list.c
Normal file
@ -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);
|
Reference in New Issue
Block a user