diff options
Diffstat (limited to 'rect.c')
| -rw-r--r-- | rect.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -34,6 +34,7 @@ #include <stdlib.h> #include <string.h> #include <assert.h> +#include <ctype.h> #include <math.h> #include "puzzles.h" @@ -129,6 +130,29 @@ game_params *dup_params(game_params *params) return ret; } +game_params *decode_params(char const *string) +{ + game_params *ret = default_params(); + + ret->w = ret->h = atoi(string); + while (*string && isdigit(*string)) string++; + if (*string == 'x') { + string++; + ret->h = atoi(string); + } + + return ret; +} + +char *encode_params(game_params *params) +{ + char data[256]; + + sprintf(data, "%dx%d", params->w, params->h); + + return dupstr(data); +} + config_item *game_configure(game_params *params) { config_item *ret; |