Det er bedre å bruke pieceinfo til navn på brikkene.

This commit is contained in:
Jens ]dne Rydland 2008-10-09 22:53:09 +00:00
parent fc4418e158
commit d860d50001
3 changed files with 21 additions and 13 deletions

View File

@ -6,21 +6,25 @@
#include "net.h" #include "net.h"
#include "game.h" #include "game.h"
struct pieceinfo { pieceinfo_t pieceinfo[] = {
int num;
} pieceinfo[] = {
{ // NONE { // NONE
.num = 0 }, .num = 0,
{ // PHARAO .name = "" },
.num = 1 }, {
.num = 1,
.name = "pharao" },
{ // DJHED { // DJHED
.num = 2 }, .num = 2,
.name = "djhed" },
{ // PYRAMID { // PYRAMID
.num = 7 }, .num = 7,
.name = "pyramid" },
{ // OBELISK { // OBELISK
.num = 4 }, .num = 4,
.name = "obelisk" },
{ // OBELISK2 { // OBELISK2
.num = 0 }, .num = 0,
.name = "stacked obelisk" },
}; };
sideinfo_t sideinfo[] = { sideinfo_t sideinfo[] = {

View File

@ -43,6 +43,11 @@ typedef struct {
int last_hit; int last_hit;
} game_t; } game_t;
typedef struct {
int num;
char *name;
} pieceinfo_t;
typedef struct { typedef struct {
char ch; char ch;
char *name; char *name;
@ -53,8 +58,7 @@ typedef enum { D_NW=0, D_N, D_NE, D_E, D_SE, D_S, D_SW, D_W } dir_t;
extern char classic_setup[]; extern char classic_setup[];
extern sideinfo_t sideinfo[]; extern sideinfo_t sideinfo[];
extern pieceinfo_t pieceinfo[];
char* piece_names[N_PIECE_TYPES] = {NULL,"pharao","djhed","pyramid","obelisk"};
int laser_at(game_t *game, int x, int y); int laser_at(game_t *game, int x, int y);
int laser(game_t *game, int side); int laser(game_t *game, int side);

View File

@ -218,7 +218,7 @@ simple_game(void)
case L_WALL: case L_WALL:
case L_PIECE: case L_PIECE:
net_all_printf("laser hits %s at %c%c\n", net_all_printf("laser hits %s at %c%c\n",
r==L_WALL ? "wall" : piece_names[game.last_hit], r==L_WALL ? "wall" : pieceinfo[game.last_hit].name,
game.laser_pos[1]+'A', game.laser_pos[0]+'0'); game.laser_pos[1]+'A', game.laser_pos[0]+'0');
break; break;
} }