aboutsummaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-05-21 13:39:23 +0000
committerSimon Tatham <anakin@pobox.com>2005-05-21 13:39:23 +0000
commitf3ba6f8bcefde0ff75971e662841ecef6be56b5a (patch)
tree154663c19554b6fed1f4d5a3143d2a09cb2969bd /net.c
parent862e25c90b8f62fd1cab270b13f5d57f86bff82f (diff)
downloadpuzzles-f3ba6f8bcefde0ff75971e662841ecef6be56b5a.zip
puzzles-f3ba6f8bcefde0ff75971e662841ecef6be56b5a.tar.gz
puzzles-f3ba6f8bcefde0ff75971e662841ecef6be56b5a.tar.bz2
puzzles-f3ba6f8bcefde0ff75971e662841ecef6be56b5a.tar.xz
Cleanups:
- fix documentation of Net's unique solution option (should have tested before last checkin) - make unique solutions optional in Rectangles too (same reasons) - tidy up various issues in parameter encoding in both games. [originally from svn r5818]
Diffstat (limited to 'net.c')
-rw-r--r--net.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/net.c b/net.c
index da9e54c..3520483 100644
--- a/net.c
+++ b/net.c
@@ -201,11 +201,11 @@ static void decode_params(game_params *ret, char const *string)
char const *p = string;
ret->width = atoi(p);
- while (*p && isdigit(*p)) p++;
+ while (*p && isdigit((unsigned char)*p)) p++;
if (*p == 'x') {
p++;
ret->height = atoi(p);
- while (*p && isdigit(*p)) p++;
+ while (*p && isdigit((unsigned char)*p)) p++;
} else {
ret->height = ret->width;
}
@@ -217,11 +217,12 @@ static void decode_params(game_params *ret, char const *string)
} else if (*p == 'b') {
p++;
ret->barrier_probability = atof(p);
- while (*p && isdigit(*p)) p++;
+ while (*p && (*p == '.' || isdigit((unsigned char)*p))) p++;
} else if (*p == 'a') {
p++;
ret->unique = FALSE;
- }
+ } else
+ p++; /* skip any other gunk */
}
}
@@ -235,7 +236,7 @@ static char *encode_params(game_params *params, int full)
ret[len++] = 'w';
if (full && params->barrier_probability)
len += sprintf(ret+len, "b%g", params->barrier_probability);
- if (!params->unique)
+ if (full && !params->unique)
ret[len++] = 'a';
assert(len < lenof(ret));
ret[len] = '\0';