mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -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:
10
cube.c
10
cube.c
@ -25,7 +25,7 @@ struct solid {
|
||||
float border; /* border required around arena */
|
||||
};
|
||||
|
||||
static const struct solid tetrahedron = {
|
||||
static const struct solid s_tetrahedron = {
|
||||
4,
|
||||
{
|
||||
0.0F, -0.57735026919F, -0.20412414523F,
|
||||
@ -46,7 +46,7 @@ static const struct solid tetrahedron = {
|
||||
0.0F, 0.3F
|
||||
};
|
||||
|
||||
static const struct solid cube = {
|
||||
static const struct solid s_cube = {
|
||||
8,
|
||||
{
|
||||
-0.5F,-0.5F,-0.5F, -0.5F,-0.5F,+0.5F,
|
||||
@ -66,7 +66,7 @@ static const struct solid cube = {
|
||||
0.3F, 0.5F
|
||||
};
|
||||
|
||||
static const struct solid octahedron = {
|
||||
static const struct solid s_octahedron = {
|
||||
6,
|
||||
{
|
||||
-0.5F, -0.28867513459472505F, 0.4082482904638664F,
|
||||
@ -93,7 +93,7 @@ static const struct solid octahedron = {
|
||||
0.0F, 0.5F
|
||||
};
|
||||
|
||||
static const struct solid icosahedron = {
|
||||
static const struct solid s_icosahedron = {
|
||||
12,
|
||||
{
|
||||
0.0F, 0.57735026919F, 0.75576131408F,
|
||||
@ -145,7 +145,7 @@ enum {
|
||||
TETRAHEDRON, CUBE, OCTAHEDRON, ICOSAHEDRON
|
||||
};
|
||||
static const struct solid *solids[] = {
|
||||
&tetrahedron, &cube, &octahedron, &icosahedron
|
||||
&s_tetrahedron, &s_cube, &s_octahedron, &s_icosahedron
|
||||
};
|
||||
|
||||
enum {
|
||||
|
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);
|
@ -201,9 +201,13 @@ struct game {
|
||||
|
||||
/*
|
||||
* For one-game-at-a-time platforms, there's a single structure
|
||||
* like the above, under a fixed name.
|
||||
* like the above, under a fixed name. For all-at-once platforms,
|
||||
* there's a list of all available puzzles in array form.
|
||||
*/
|
||||
#ifndef COMBINED
|
||||
#ifdef COMBINED
|
||||
extern const game *gamelist[];
|
||||
extern const int gamecount;
|
||||
#else
|
||||
extern const game thegame;
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user