char *saveboard (board_t *board)
{
- int size = 6 * (8 + 3) + 8 + board->width * board->height + 1;
+ int size = 5 * (8 + 2) + 8 + board->width * board->height + 1;
VERBOSE (INFO, size += board->height * (8 + board->width));
char *buffer = (char *) calloc (size, 1);
CHECKALLOC (buffer);
- int l = sprintf (buffer, "width: %d\n", board->width);
+ int l = sprintf (buffer, "id: %d\n", board->id);
l += sprintf (buffer + l, "height: %d\n", board->height);
+ l += sprintf (buffer + l, "scale: %d\n", board->scale);
l += sprintf (buffer + l, "tab: \"%s\"\n", board->tab);
+ l += sprintf (buffer + l, "width: %d\n", board->width);
VERBOSE (INFO, _makecomments (buffer + l, board));
board_t *loadboard (char *str)
{
- int width = 0;
+ int id = 0;
int height = 0;
+ int scale = 1;
char *tab = NULL;
+ int width = 0;
char *saveptr1, *saveptr2;
value++;
}
- if (strcmp (keyword, "width") == 0) {
- width = atoi (value);
+ if (strcmp (keyword, "id") == 0) {
+ id = atoi (value);
} else if (strcmp (keyword, "height") == 0) {
height = atoi (value);
+ } else if (strcmp (keyword, "scale") == 0) {
+ scale = atoi (value);
} else if (strcmp (keyword, "tab") == 0) {
tab = atos (value);
} else if (strcmp (keyword, "rem") == 0) {
/* nothing to do with remark */
+ } else if (strcmp (keyword, "width") == 0) {
+ width = atoi (value);
} else {
VERBOSE (WARNING, printf ("unknown keyword: %s\n", keyword));
}
if ((tab) && (strlen (tab) == (size_t)(width * height))) {
board = initboard (width, height);
memcpy (board->tab, tab, width * height);
+ board->id = id;
+ board->scale = scale;
}
return board;
/* load playground */
board_t *board = NULL;
+ int id = 0;
if (filename) {
char *buffer = readdata (filename);
if (buffer == NULL) {
VERBOSE (ERROR, fprintf (stderr, "incorrect file (%s)\n", filename));
return 1;
}
+ id = board->id;
+ scale = board->scale;
} else if (boardname) {
board = getboard (boardname);
if (board == (board_t *)(-1)) {
/* main loop */
int stop = 0;
int showpos = 0;
- int id = 0;
int mode = 0;
while (!stop) {
char msg[128] = {0};
case 's':
savename = savewindow (savelen, xsave, ysave);
if (savename != NULL) {
+ board->id = id;
+ board->scale = scale;
char *ptr = saveboard (board);
if (writedata (savename, ptr)) {
VERBOSE (WARNING, printf ("issue writing Board\n"));
/* test: reversi.exe -b unknown 2>&1 | grep 'unknown board' */
/* test: reversi.exe -b list | grep '^board:' */
/* test: reversi.exe -f 2>&1 | grep 'no file' */
-/* test-: reversi.exe -f nofile.pen 2>&1 | grep "can't read file" */
-/* test-: reversi.exe -f bogus.pen 2>&1 | grep 'incorrect file' */
+/* test: reversi.exe -f nofile.rev 2>&1 | grep "can't read file" */
+/* test: reversi.exe -f bogus.rev 2>&1 | grep 'incorrect file' */
/* test: reversi.exe -h | grep usage */
/* test: reversi.exe -r 2>&1 | grep 'missing' */
/* test: reversi.exe -s 2>&1 | grep 'no scale' */
/* test: reversi.exe -s 4 2>&1 | grep incorrect */
/* test: reversi.exe -v 2>&1 | grep missing */
/* test: reversi.exe _ 2>&1 | grep invalid */
+/* test: { for s in kkkkllo mkklo u q; do sleep 1; echo -n $s; done; } | reversi.exe -r 8 | grep omkklouq */
/* test: { sleep 1; echo -n kko; sleep 1; echo q; } | reversi.exe -s 3 -b 4x4 */
/* test: { sleep 1; echo -n kkklo; sleep 1; echo q; } | reversi.exe -s 2 -b 6x6 */
/* test: { sleep 1; echo -n kkkkllo; sleep 1; echo q; } | reversi.exe -s 1 -b 8x8 */
/* test: { sleep 1; echo -n kkkkkkllllo; sleep 1; echo q; } | reversi.exe -b 12x12 */
/* test: { sleep 1; echo -n kkkkkkklllllo; sleep 1; echo q; } | reversi.exe -b 14x14 */
/* test: { sleep 1; echo -n kkkkkkkkllllllo; sleep 1; echo q; } | reversi.exe -b 16x16 */
-/* test: { for s in kko ko ml mo lljjlljo mlmo iijjjo io llo jllko q; do echo -n $s; sleep 1; done; } | reversi.exe -b 4x4 */
+/* test: { for s in kko ko ml mo lljjlljo mlmo iijjjo io llo jllko q; do echo -n $s; sleep .3; done; } | reversi.exe -b 4x4 */
+/* test: { sleep 1; echo -n kkkkllo; sleep 1; echo -e 'sgb\bame.rev'; sleep 1; echo q; } | reversi.exe -v 2 */
+/* test: { sleep 1; echo -n kkkkllklo; sleep 1; echo q; } | reversi.exe -f game.rev && rm game.rev */
/* vim: set ts=4 sw=4 et: */