- sprintf(buf, "M%d,%d", tx, ty);
- return dupstr(buf);
+ /*
+ * It's just possible that a manually entered game ID
+ * will have at least one square do nothing whatsoever.
+ * If so, we avoid encoding a move at all.
+ */
+ int i = ty*w+tx, j, makemove = FALSE;
+ for (j = 0; j < wh; j++) {
+ if (state->matrix->matrix[i*wh+j])
+ makemove = TRUE;
+ }
+ if (makemove) {
+ sprintf(buf, "M%d,%d", tx, ty);
+ return dupstr(buf);
+ } else {
+ return NULL;
+ }
+ }
+ }
+ else if (button == CURSOR_UP || button == CURSOR_DOWN ||
+ button == CURSOR_RIGHT || button == CURSOR_LEFT) {
+ int dx = 0, dy = 0;
+ switch (button) {
+ case CURSOR_UP: dy = -1; break;
+ case CURSOR_DOWN: dy = 1; break;
+ case CURSOR_RIGHT: dx = 1; break;
+ case CURSOR_LEFT: dx = -1; break;
+ default: assert(!"shouldn't get here");